|
|
9ae3a8 |
From b434963222bd7ce4b4a7ff493217f3ab00ac734c Mon Sep 17 00:00:00 2001
|
|
|
9ae3a8 |
From: Kevin Wolf <kwolf@redhat.com>
|
|
|
9ae3a8 |
Date: Tue, 5 Nov 2013 14:09:06 +0100
|
|
|
9ae3a8 |
Subject: [PATCH 53/87] blockdev: Moving parsing of geometry options to drive_init
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
RH-Author: Kevin Wolf <kwolf@redhat.com>
|
|
|
9ae3a8 |
Message-id: <1383660558-32096-13-git-send-email-kwolf@redhat.com>
|
|
|
9ae3a8 |
Patchwork-id: 55391
|
|
|
9ae3a8 |
O-Subject: [RHEL-7.0 qemu-kvm PATCH 12/24] blockdev: Moving parsing of geometry options to drive_init
|
|
|
9ae3a8 |
Bugzilla: 978402
|
|
|
9ae3a8 |
RH-Acked-by: Fam Zheng <famz@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Max Reitz <mreitz@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
This moves all of the geometry options (cyls/heads/secs/trans) to
|
|
|
9ae3a8 |
drive_init so that they can only be accessed using legacy functions, but
|
|
|
9ae3a8 |
never with anything blockdev-add related.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
9ae3a8 |
Reviewed-by: Eric Blake <eblake@redhat.com>
|
|
|
9ae3a8 |
(cherry picked from commit b41a7338cfdeeb913ee4846d79a3f7e221350aed)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
blockdev.c | 136 +++++++++++++++++++++++++++++++------------------------------
|
|
|
9ae3a8 |
1 file changed, 69 insertions(+), 67 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
blockdev.c | 136 ++++++++++++++++++++++++++++++-----------------------------
|
|
|
9ae3a8 |
1 files changed, 69 insertions(+), 67 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/blockdev.c b/blockdev.c
|
|
|
9ae3a8 |
index 9bc3417..d69c4a8 100644
|
|
|
9ae3a8 |
--- a/blockdev.c
|
|
|
9ae3a8 |
+++ b/blockdev.c
|
|
|
9ae3a8 |
@@ -336,7 +336,6 @@ static DriveInfo *blockdev_init(QDict *bs_opts,
|
|
|
9ae3a8 |
const char *serial;
|
|
|
9ae3a8 |
const char *mediastr = "";
|
|
|
9ae3a8 |
int bus_id, unit_id;
|
|
|
9ae3a8 |
- int cyls, heads, secs, translation;
|
|
|
9ae3a8 |
int max_devs;
|
|
|
9ae3a8 |
int index;
|
|
|
9ae3a8 |
int ro = 0;
|
|
|
9ae3a8 |
@@ -354,8 +353,6 @@ static DriveInfo *blockdev_init(QDict *bs_opts,
|
|
|
9ae3a8 |
bool has_driver_specific_opts;
|
|
|
9ae3a8 |
BlockDriver *drv = NULL;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
- translation = BIOS_ATA_TRANSLATION_AUTO;
|
|
|
9ae3a8 |
-
|
|
|
9ae3a8 |
/* Check common options by copying from bs_opts to opts, all other options
|
|
|
9ae3a8 |
* stay in bs_opts for processing by bdrv_open(). */
|
|
|
9ae3a8 |
id = qdict_get_try_str(bs_opts, "id");
|
|
|
9ae3a8 |
@@ -384,10 +381,6 @@ static DriveInfo *blockdev_init(QDict *bs_opts,
|
|
|
9ae3a8 |
unit_id = qemu_opt_get_number(opts, "unit", -1);
|
|
|
9ae3a8 |
index = qemu_opt_get_number(opts, "index", -1);
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
- cyls = qemu_opt_get_number(opts, "cyls", 0);
|
|
|
9ae3a8 |
- heads = qemu_opt_get_number(opts, "heads", 0);
|
|
|
9ae3a8 |
- secs = qemu_opt_get_number(opts, "secs", 0);
|
|
|
9ae3a8 |
-
|
|
|
9ae3a8 |
snapshot = qemu_opt_get_bool(opts, "snapshot", 0);
|
|
|
9ae3a8 |
ro = qemu_opt_get_bool(opts, "read-only", 0);
|
|
|
9ae3a8 |
copy_on_read = qemu_opt_get_bool(opts, "copy-on-read", false);
|
|
|
9ae3a8 |
@@ -397,46 +390,6 @@ static DriveInfo *blockdev_init(QDict *bs_opts,
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
max_devs = if_max_devs[type];
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
- if (cyls || heads || secs) {
|
|
|
9ae3a8 |
- if (cyls < 1) {
|
|
|
9ae3a8 |
- error_report("invalid physical cyls number");
|
|
|
9ae3a8 |
- return NULL;
|
|
|
9ae3a8 |
- }
|
|
|
9ae3a8 |
- if (heads < 1) {
|
|
|
9ae3a8 |
- error_report("invalid physical heads number");
|
|
|
9ae3a8 |
- return NULL;
|
|
|
9ae3a8 |
- }
|
|
|
9ae3a8 |
- if (secs < 1) {
|
|
|
9ae3a8 |
- error_report("invalid physical secs number");
|
|
|
9ae3a8 |
- return NULL;
|
|
|
9ae3a8 |
- }
|
|
|
9ae3a8 |
- }
|
|
|
9ae3a8 |
-
|
|
|
9ae3a8 |
- if ((buf = qemu_opt_get(opts, "trans")) != NULL) {
|
|
|
9ae3a8 |
- if (!cyls) {
|
|
|
9ae3a8 |
- error_report("'%s' trans must be used with cyls, heads and secs",
|
|
|
9ae3a8 |
- buf);
|
|
|
9ae3a8 |
- return NULL;
|
|
|
9ae3a8 |
- }
|
|
|
9ae3a8 |
- if (!strcmp(buf, "none"))
|
|
|
9ae3a8 |
- translation = BIOS_ATA_TRANSLATION_NONE;
|
|
|
9ae3a8 |
- else if (!strcmp(buf, "lba"))
|
|
|
9ae3a8 |
- translation = BIOS_ATA_TRANSLATION_LBA;
|
|
|
9ae3a8 |
- else if (!strcmp(buf, "auto"))
|
|
|
9ae3a8 |
- translation = BIOS_ATA_TRANSLATION_AUTO;
|
|
|
9ae3a8 |
- else {
|
|
|
9ae3a8 |
- error_report("'%s' invalid translation type", buf);
|
|
|
9ae3a8 |
- return NULL;
|
|
|
9ae3a8 |
- }
|
|
|
9ae3a8 |
- }
|
|
|
9ae3a8 |
-
|
|
|
9ae3a8 |
- if (media == MEDIA_CDROM) {
|
|
|
9ae3a8 |
- if (cyls || secs || heads) {
|
|
|
9ae3a8 |
- error_report("CHS can't be set with media=cdrom");
|
|
|
9ae3a8 |
- return NULL;
|
|
|
9ae3a8 |
- }
|
|
|
9ae3a8 |
- }
|
|
|
9ae3a8 |
-
|
|
|
9ae3a8 |
if ((buf = qemu_opt_get(opts, "discard")) != NULL) {
|
|
|
9ae3a8 |
if (bdrv_parse_discard_flags(buf, &bdrv_flags) != 0) {
|
|
|
9ae3a8 |
error_report("invalid discard option");
|
|
|
9ae3a8 |
@@ -612,10 +565,6 @@ static DriveInfo *blockdev_init(QDict *bs_opts,
|
|
|
9ae3a8 |
dinfo->type = type;
|
|
|
9ae3a8 |
dinfo->bus = bus_id;
|
|
|
9ae3a8 |
dinfo->unit = unit_id;
|
|
|
9ae3a8 |
- dinfo->cyls = cyls;
|
|
|
9ae3a8 |
- dinfo->heads = heads;
|
|
|
9ae3a8 |
- dinfo->secs = secs;
|
|
|
9ae3a8 |
- dinfo->trans = translation;
|
|
|
9ae3a8 |
dinfo->refcount = 1;
|
|
|
9ae3a8 |
if (serial != NULL) {
|
|
|
9ae3a8 |
dinfo->serial = g_strdup(serial);
|
|
|
9ae3a8 |
@@ -745,6 +694,22 @@ QemuOptsList qemu_legacy_drive_opts = {
|
|
|
9ae3a8 |
.name = "if",
|
|
|
9ae3a8 |
.type = QEMU_OPT_STRING,
|
|
|
9ae3a8 |
.help = "interface (ide, scsi, sd, mtd, floppy, pflash, virtio)",
|
|
|
9ae3a8 |
+ },{
|
|
|
9ae3a8 |
+ .name = "cyls",
|
|
|
9ae3a8 |
+ .type = QEMU_OPT_NUMBER,
|
|
|
9ae3a8 |
+ .help = "number of cylinders (ide disk geometry)",
|
|
|
9ae3a8 |
+ },{
|
|
|
9ae3a8 |
+ .name = "heads",
|
|
|
9ae3a8 |
+ .type = QEMU_OPT_NUMBER,
|
|
|
9ae3a8 |
+ .help = "number of heads (ide disk geometry)",
|
|
|
9ae3a8 |
+ },{
|
|
|
9ae3a8 |
+ .name = "secs",
|
|
|
9ae3a8 |
+ .type = QEMU_OPT_NUMBER,
|
|
|
9ae3a8 |
+ .help = "number of sectors (ide disk geometry)",
|
|
|
9ae3a8 |
+ },{
|
|
|
9ae3a8 |
+ .name = "trans",
|
|
|
9ae3a8 |
+ .type = QEMU_OPT_STRING,
|
|
|
9ae3a8 |
+ .help = "chs translation (auto, lba, none)",
|
|
|
9ae3a8 |
},
|
|
|
9ae3a8 |
{ /* end of list */ }
|
|
|
9ae3a8 |
},
|
|
|
9ae3a8 |
@@ -758,6 +723,7 @@ DriveInfo *drive_init(QemuOpts *all_opts, BlockInterfaceType block_default_type)
|
|
|
9ae3a8 |
QemuOpts *legacy_opts;
|
|
|
9ae3a8 |
DriveMediaType media = MEDIA_DISK;
|
|
|
9ae3a8 |
BlockInterfaceType type;
|
|
|
9ae3a8 |
+ int cyls, heads, secs, translation;
|
|
|
9ae3a8 |
Error *local_err = NULL;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
/* Change legacy command line options into QMP ones */
|
|
|
9ae3a8 |
@@ -836,6 +802,53 @@ DriveInfo *drive_init(QemuOpts *all_opts, BlockInterfaceType block_default_type)
|
|
|
9ae3a8 |
type = block_default_type;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
+ /* Geometry */
|
|
|
9ae3a8 |
+ cyls = qemu_opt_get_number(legacy_opts, "cyls", 0);
|
|
|
9ae3a8 |
+ heads = qemu_opt_get_number(legacy_opts, "heads", 0);
|
|
|
9ae3a8 |
+ secs = qemu_opt_get_number(legacy_opts, "secs", 0);
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ if (cyls || heads || secs) {
|
|
|
9ae3a8 |
+ if (cyls < 1) {
|
|
|
9ae3a8 |
+ error_report("invalid physical cyls number");
|
|
|
9ae3a8 |
+ goto fail;
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
+ if (heads < 1) {
|
|
|
9ae3a8 |
+ error_report("invalid physical heads number");
|
|
|
9ae3a8 |
+ goto fail;
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
+ if (secs < 1) {
|
|
|
9ae3a8 |
+ error_report("invalid physical secs number");
|
|
|
9ae3a8 |
+ goto fail;
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ translation = BIOS_ATA_TRANSLATION_AUTO;
|
|
|
9ae3a8 |
+ value = qemu_opt_get(legacy_opts, "trans");
|
|
|
9ae3a8 |
+ if (value != NULL) {
|
|
|
9ae3a8 |
+ if (!cyls) {
|
|
|
9ae3a8 |
+ error_report("'%s' trans must be used with cyls, heads and secs",
|
|
|
9ae3a8 |
+ value);
|
|
|
9ae3a8 |
+ goto fail;
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
+ if (!strcmp(value, "none")) {
|
|
|
9ae3a8 |
+ translation = BIOS_ATA_TRANSLATION_NONE;
|
|
|
9ae3a8 |
+ } else if (!strcmp(value, "lba")) {
|
|
|
9ae3a8 |
+ translation = BIOS_ATA_TRANSLATION_LBA;
|
|
|
9ae3a8 |
+ } else if (!strcmp(value, "auto")) {
|
|
|
9ae3a8 |
+ translation = BIOS_ATA_TRANSLATION_AUTO;
|
|
|
9ae3a8 |
+ } else {
|
|
|
9ae3a8 |
+ error_report("'%s' invalid translation type", value);
|
|
|
9ae3a8 |
+ goto fail;
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ if (media == MEDIA_CDROM) {
|
|
|
9ae3a8 |
+ if (cyls || secs || heads) {
|
|
|
9ae3a8 |
+ error_report("CHS can't be set with media=cdrom");
|
|
|
9ae3a8 |
+ goto fail;
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
/* Actual block device init: Functionality shared with blockdev-add */
|
|
|
9ae3a8 |
dinfo = blockdev_init(bs_opts, type, media);
|
|
|
9ae3a8 |
if (dinfo == NULL) {
|
|
|
9ae3a8 |
@@ -846,6 +859,11 @@ DriveInfo *drive_init(QemuOpts *all_opts, BlockInterfaceType block_default_type)
|
|
|
9ae3a8 |
dinfo->enable_auto_del = true;
|
|
|
9ae3a8 |
dinfo->opts = all_opts;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
+ dinfo->cyls = cyls;
|
|
|
9ae3a8 |
+ dinfo->heads = heads;
|
|
|
9ae3a8 |
+ dinfo->secs = secs;
|
|
|
9ae3a8 |
+ dinfo->trans = translation;
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
fail:
|
|
|
9ae3a8 |
qemu_opts_del(legacy_opts);
|
|
|
9ae3a8 |
return dinfo;
|
|
|
9ae3a8 |
@@ -1793,22 +1811,6 @@ QemuOptsList qemu_common_drive_opts = {
|
|
|
9ae3a8 |
.type = QEMU_OPT_NUMBER,
|
|
|
9ae3a8 |
.help = "index number",
|
|
|
9ae3a8 |
},{
|
|
|
9ae3a8 |
- .name = "cyls",
|
|
|
9ae3a8 |
- .type = QEMU_OPT_NUMBER,
|
|
|
9ae3a8 |
- .help = "number of cylinders (ide disk geometry)",
|
|
|
9ae3a8 |
- },{
|
|
|
9ae3a8 |
- .name = "heads",
|
|
|
9ae3a8 |
- .type = QEMU_OPT_NUMBER,
|
|
|
9ae3a8 |
- .help = "number of heads (ide disk geometry)",
|
|
|
9ae3a8 |
- },{
|
|
|
9ae3a8 |
- .name = "secs",
|
|
|
9ae3a8 |
- .type = QEMU_OPT_NUMBER,
|
|
|
9ae3a8 |
- .help = "number of sectors (ide disk geometry)",
|
|
|
9ae3a8 |
- },{
|
|
|
9ae3a8 |
- .name = "trans",
|
|
|
9ae3a8 |
- .type = QEMU_OPT_STRING,
|
|
|
9ae3a8 |
- .help = "chs translation (auto, lba. none)",
|
|
|
9ae3a8 |
- },{
|
|
|
9ae3a8 |
.name = "snapshot",
|
|
|
9ae3a8 |
.type = QEMU_OPT_BOOL,
|
|
|
9ae3a8 |
.help = "enable/disable snapshot mode",
|
|
|
9ae3a8 |
--
|
|
|
9ae3a8 |
1.7.1
|
|
|
9ae3a8 |
|