[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 12/17] blockdev: Move virtio-blk device creation to
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PATCH 12/17] blockdev: Move virtio-blk device creation to drive_init |
Date: |
Fri, 20 Sep 2013 13:54:25 +0200 |
Signed-off-by: Kevin Wolf <address@hidden>
---
blockdev.c | 54 +++++++++++++++++++++++++++---------------------------
1 file changed, 27 insertions(+), 27 deletions(-)
diff --git a/blockdev.c b/blockdev.c
index 26127b3..bbdae31 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -315,7 +315,6 @@ static DriveInfo *blockdev_init(QDict *bs_opts,
int ro = 0;
int bdrv_flags = 0;
int on_read_error, on_write_error;
- const char *devaddr;
DriveInfo *dinfo;
ThrottleConfig cfg;
int snapshot = 0;
@@ -469,20 +468,12 @@ static DriveInfo *blockdev_init(QDict *bs_opts,
}
}
- if ((devaddr = qemu_opt_get(opts, "addr")) != NULL) {
- if (type != IF_VIRTIO) {
- error_report("addr is not supported by this bus type");
- return NULL;
- }
- }
-
/* init */
dinfo = g_malloc0(sizeof(*dinfo));
dinfo->id = g_strdup(qemu_opts_id(opts));
dinfo->bdrv = bdrv_new(dinfo->id);
dinfo->bdrv->open_flags = snapshot ? BDRV_O_SNAPSHOT : 0;
dinfo->bdrv->read_only = ro;
- dinfo->devaddr = devaddr;
dinfo->type = type;
dinfo->refcount = 1;
if (serial != NULL) {
@@ -509,22 +500,8 @@ static DriveInfo *blockdev_init(QDict *bs_opts,
case IF_FLOPPY:
case IF_PFLASH:
case IF_MTD:
- break;
case IF_VIRTIO:
- {
- /* add virtio block device */
- QemuOpts *devopts;
- devopts = qemu_opts_create_nofail(qemu_find_opts("device"));
- if (arch_type == QEMU_ARCH_S390X) {
- qemu_opt_set(devopts, "driver", "virtio-blk-s390");
- } else {
- qemu_opt_set(devopts, "driver", "virtio-blk-pci");
- }
- qemu_opt_set(devopts, "drive", dinfo->id);
- if (devaddr)
- qemu_opt_set(devopts, "addr", devaddr);
break;
- }
default:
abort();
}
@@ -648,6 +625,10 @@ QemuOptsList qemu_legacy_drive_opts = {
.name = "boot",
.type = QEMU_OPT_BOOL,
.help = "(deprecated, ignored)",
+ },{
+ .name = "addr",
+ .type = QEMU_OPT_STRING,
+ .help = "pci address (virtio only)",
},
{ /* end of list */ }
},
@@ -663,6 +644,7 @@ DriveInfo *drive_init(QemuOpts *all_opts,
BlockInterfaceType block_default_type)
BlockInterfaceType type;
int cyls, heads, secs, translation;
int max_devs, bus_id, unit_id, index;
+ const char *devaddr;
Error *local_err = NULL;
/* Change legacy command line options into QMP ones */
@@ -863,6 +845,27 @@ DriveInfo *drive_init(QemuOpts *all_opts,
BlockInterfaceType block_default_type)
g_free(new_id);
}
+ /* Add virtio block device */
+ devaddr = qemu_opt_get(legacy_opts, "addr");
+ if (devaddr && type != IF_VIRTIO) {
+ error_report("addr is not supported by this bus type");
+ return NULL;
+ }
+
+ if (type == IF_VIRTIO) {
+ QemuOpts *devopts;
+ devopts = qemu_opts_create_nofail(qemu_find_opts("device"));
+ if (arch_type == QEMU_ARCH_S390X) {
+ qemu_opt_set(devopts, "driver", "virtio-blk-s390");
+ } else {
+ qemu_opt_set(devopts, "driver", "virtio-blk-pci");
+ }
+ qemu_opt_set(devopts, "drive", qdict_get_str(bs_opts, "id"));
+ if (devaddr) {
+ qemu_opt_set(devopts, "addr", devaddr);
+ }
+ }
+
/* Actual block device init: Functionality shared with blockdev-add */
dinfo = blockdev_init(bs_opts, type, media);
if (dinfo == NULL) {
@@ -880,6 +883,7 @@ DriveInfo *drive_init(QemuOpts *all_opts,
BlockInterfaceType block_default_type)
dinfo->bus = bus_id;
dinfo->unit = unit_id;
+ dinfo->devaddr = devaddr;
fail:
qemu_opts_del(legacy_opts);
@@ -2256,10 +2260,6 @@ QemuOptsList qemu_common_drive_opts = {
.type = QEMU_OPT_STRING,
.help = "write error action",
},{
- .name = "addr",
- .type = QEMU_OPT_STRING,
- .help = "pci address (virtio only)",
- },{
.name = "read-only",
.type = QEMU_OPT_BOOL,
.help = "open drive file as read-only",
--
1.8.1.4
- [Qemu-devel] [PATCH 08/17] blockdev: Move parsing of 'if' option to drive_init, (continued)
- [Qemu-devel] [PATCH 08/17] blockdev: Move parsing of 'if' option to drive_init, Kevin Wolf, 2013/09/20
- [Qemu-devel] [PATCH 09/17] blockdev: Moving parsing of geometry options to drive_init, Kevin Wolf, 2013/09/20
- [Qemu-devel] [PATCH 10/17] blockdev: Move parsing of 'boot' option to drive_init, Kevin Wolf, 2013/09/20
- [Qemu-devel] [PATCH 11/17] blockdev: Move bus/unit/index processing to drive_init, Kevin Wolf, 2013/09/20
- [Qemu-devel] [PATCH 12/17] blockdev: Move virtio-blk device creation to drive_init,
Kevin Wolf <=
- [Qemu-devel] [PATCH 13/17] blockdev: Remove IF_* check for read-only blockdev_init, Kevin Wolf, 2013/09/20
- [Qemu-devel] [PATCH 14/17] qemu-iotests: Check autodel behaviour for device_del, Kevin Wolf, 2013/09/20
- [Qemu-devel] [PATCH 15/17] blockdev: Remove 'media' parameter from blockdev_init(), Kevin Wolf, 2013/09/20
- [Qemu-devel] [PATCH 16/17] blockdev: Don't disable COR automatically with blockdev-add, Kevin Wolf, 2013/09/20