|
|
218e99 |
From 1a3ba7716b6559be0e4a236c96229b98eb92d9a6 Mon Sep 17 00:00:00 2001
|
|
|
218e99 |
From: Kevin Wolf <kwolf@redhat.com>
|
|
|
218e99 |
Date: Tue, 5 Nov 2013 14:09:09 +0100
|
|
|
218e99 |
Subject: [PATCH 56/87] blockdev: Move virtio-blk device creation to drive_init
|
|
|
218e99 |
|
|
|
218e99 |
RH-Author: Kevin Wolf <kwolf@redhat.com>
|
|
|
218e99 |
Message-id: <1383660558-32096-16-git-send-email-kwolf@redhat.com>
|
|
|
218e99 |
Patchwork-id: 55394
|
|
|
218e99 |
O-Subject: [RHEL-7.0 qemu-kvm PATCH 15/24] blockdev: Move virtio-blk device creation to drive_init
|
|
|
218e99 |
Bugzilla: 978402
|
|
|
218e99 |
RH-Acked-by: Fam Zheng <famz@redhat.com>
|
|
|
218e99 |
RH-Acked-by: Max Reitz <mreitz@redhat.com>
|
|
|
218e99 |
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
|
|
|
218e99 |
|
|
|
218e99 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
218e99 |
Reviewed-by: Max Reitz <mreitz@redhat.com>
|
|
|
218e99 |
Reviewed-by: Eric Blake <eblake@redhat.com>
|
|
|
218e99 |
(cherry picked from commit 394c7d4d6bd06386308e2fef0cf1c613a10e0d23)
|
|
|
218e99 |
|
|
|
218e99 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
218e99 |
---
|
|
|
218e99 |
blockdev.c | 54 +++++++++++++++++++++++++++---------------------------
|
|
|
218e99 |
1 file changed, 27 insertions(+), 27 deletions(-)
|
|
|
218e99 |
|
|
|
218e99 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
218e99 |
---
|
|
|
218e99 |
blockdev.c | 54 +++++++++++++++++++++++++++---------------------------
|
|
|
218e99 |
1 files changed, 27 insertions(+), 27 deletions(-)
|
|
|
218e99 |
|
|
|
218e99 |
diff --git a/blockdev.c b/blockdev.c
|
|
|
218e99 |
index b6dff50..14b357a 100644
|
|
|
218e99 |
--- a/blockdev.c
|
|
|
218e99 |
+++ b/blockdev.c
|
|
|
218e99 |
@@ -337,7 +337,6 @@ static DriveInfo *blockdev_init(QDict *bs_opts,
|
|
|
218e99 |
int ro = 0;
|
|
|
218e99 |
int bdrv_flags = 0;
|
|
|
218e99 |
int on_read_error, on_write_error;
|
|
|
218e99 |
- const char *devaddr;
|
|
|
218e99 |
DriveInfo *dinfo;
|
|
|
218e99 |
BlockIOLimit io_limits;
|
|
|
218e99 |
int snapshot = 0;
|
|
|
218e99 |
@@ -472,20 +471,12 @@ static DriveInfo *blockdev_init(QDict *bs_opts,
|
|
|
218e99 |
}
|
|
|
218e99 |
}
|
|
|
218e99 |
|
|
|
218e99 |
- if ((devaddr = qemu_opt_get(opts, "addr")) != NULL) {
|
|
|
218e99 |
- if (type != IF_VIRTIO) {
|
|
|
218e99 |
- error_report("addr is not supported by this bus type");
|
|
|
218e99 |
- return NULL;
|
|
|
218e99 |
- }
|
|
|
218e99 |
- }
|
|
|
218e99 |
-
|
|
|
218e99 |
/* init */
|
|
|
218e99 |
dinfo = g_malloc0(sizeof(*dinfo));
|
|
|
218e99 |
dinfo->id = g_strdup(qemu_opts_id(opts));
|
|
|
218e99 |
dinfo->bdrv = bdrv_new(dinfo->id);
|
|
|
218e99 |
dinfo->bdrv->open_flags = snapshot ? BDRV_O_SNAPSHOT : 0;
|
|
|
218e99 |
dinfo->bdrv->read_only = ro;
|
|
|
218e99 |
- dinfo->devaddr = devaddr;
|
|
|
218e99 |
dinfo->type = type;
|
|
|
218e99 |
dinfo->refcount = 1;
|
|
|
218e99 |
if (serial != NULL) {
|
|
|
218e99 |
@@ -509,22 +500,8 @@ static DriveInfo *blockdev_init(QDict *bs_opts,
|
|
|
218e99 |
case IF_FLOPPY:
|
|
|
218e99 |
case IF_PFLASH:
|
|
|
218e99 |
case IF_MTD:
|
|
|
218e99 |
- break;
|
|
|
218e99 |
case IF_VIRTIO:
|
|
|
218e99 |
- {
|
|
|
218e99 |
- /* add virtio block device */
|
|
|
218e99 |
- QemuOpts *devopts;
|
|
|
218e99 |
- devopts = qemu_opts_create_nofail(qemu_find_opts("device"));
|
|
|
218e99 |
- if (arch_type == QEMU_ARCH_S390X) {
|
|
|
218e99 |
- qemu_opt_set(devopts, "driver", "virtio-blk-s390");
|
|
|
218e99 |
- } else {
|
|
|
218e99 |
- qemu_opt_set(devopts, "driver", "virtio-blk-pci");
|
|
|
218e99 |
- }
|
|
|
218e99 |
- qemu_opt_set(devopts, "drive", dinfo->id);
|
|
|
218e99 |
- if (devaddr)
|
|
|
218e99 |
- qemu_opt_set(devopts, "addr", devaddr);
|
|
|
218e99 |
break;
|
|
|
218e99 |
- }
|
|
|
218e99 |
default:
|
|
|
218e99 |
abort();
|
|
|
218e99 |
}
|
|
|
218e99 |
@@ -648,6 +625,10 @@ QemuOptsList qemu_legacy_drive_opts = {
|
|
|
218e99 |
.name = "boot",
|
|
|
218e99 |
.type = QEMU_OPT_BOOL,
|
|
|
218e99 |
.help = "(deprecated, ignored)",
|
|
|
218e99 |
+ },{
|
|
|
218e99 |
+ .name = "addr",
|
|
|
218e99 |
+ .type = QEMU_OPT_STRING,
|
|
|
218e99 |
+ .help = "pci address (virtio only)",
|
|
|
218e99 |
},
|
|
|
218e99 |
{ /* end of list */ }
|
|
|
218e99 |
},
|
|
|
218e99 |
@@ -663,6 +644,7 @@ DriveInfo *drive_init(QemuOpts *all_opts, BlockInterfaceType block_default_type)
|
|
|
218e99 |
BlockInterfaceType type;
|
|
|
218e99 |
int cyls, heads, secs, translation;
|
|
|
218e99 |
int max_devs, bus_id, unit_id, index;
|
|
|
218e99 |
+ const char *devaddr;
|
|
|
218e99 |
Error *local_err = NULL;
|
|
|
218e99 |
|
|
|
218e99 |
/* Change legacy command line options into QMP ones */
|
|
|
218e99 |
@@ -852,6 +834,27 @@ DriveInfo *drive_init(QemuOpts *all_opts, BlockInterfaceType block_default_type)
|
|
|
218e99 |
g_free(new_id);
|
|
|
218e99 |
}
|
|
|
218e99 |
|
|
|
218e99 |
+ /* Add virtio block device */
|
|
|
218e99 |
+ devaddr = qemu_opt_get(legacy_opts, "addr");
|
|
|
218e99 |
+ if (devaddr && type != IF_VIRTIO) {
|
|
|
218e99 |
+ error_report("addr is not supported by this bus type");
|
|
|
218e99 |
+ goto fail;
|
|
|
218e99 |
+ }
|
|
|
218e99 |
+
|
|
|
218e99 |
+ if (type == IF_VIRTIO) {
|
|
|
218e99 |
+ QemuOpts *devopts;
|
|
|
218e99 |
+ devopts = qemu_opts_create_nofail(qemu_find_opts("device"));
|
|
|
218e99 |
+ if (arch_type == QEMU_ARCH_S390X) {
|
|
|
218e99 |
+ qemu_opt_set(devopts, "driver", "virtio-blk-s390");
|
|
|
218e99 |
+ } else {
|
|
|
218e99 |
+ qemu_opt_set(devopts, "driver", "virtio-blk-pci");
|
|
|
218e99 |
+ }
|
|
|
218e99 |
+ qemu_opt_set(devopts, "drive", qdict_get_str(bs_opts, "id"));
|
|
|
218e99 |
+ if (devaddr) {
|
|
|
218e99 |
+ qemu_opt_set(devopts, "addr", devaddr);
|
|
|
218e99 |
+ }
|
|
|
218e99 |
+ }
|
|
|
218e99 |
+
|
|
|
218e99 |
/* Actual block device init: Functionality shared with blockdev-add */
|
|
|
218e99 |
dinfo = blockdev_init(bs_opts, type, media);
|
|
|
218e99 |
if (dinfo == NULL) {
|
|
|
218e99 |
@@ -869,6 +872,7 @@ DriveInfo *drive_init(QemuOpts *all_opts, BlockInterfaceType block_default_type)
|
|
|
218e99 |
|
|
|
218e99 |
dinfo->bus = bus_id;
|
|
|
218e99 |
dinfo->unit = unit_id;
|
|
|
218e99 |
+ dinfo->devaddr = devaddr;
|
|
|
218e99 |
|
|
|
218e99 |
fail:
|
|
|
218e99 |
qemu_opts_del(legacy_opts);
|
|
|
218e99 |
@@ -1849,10 +1853,6 @@ QemuOptsList qemu_common_drive_opts = {
|
|
|
218e99 |
.type = QEMU_OPT_STRING,
|
|
|
218e99 |
.help = "write error action",
|
|
|
218e99 |
},{
|
|
|
218e99 |
- .name = "addr",
|
|
|
218e99 |
- .type = QEMU_OPT_STRING,
|
|
|
218e99 |
- .help = "pci address (virtio only)",
|
|
|
218e99 |
- },{
|
|
|
218e99 |
.name = "read-only",
|
|
|
218e99 |
.type = QEMU_OPT_BOOL,
|
|
|
218e99 |
.help = "open drive file as read-only",
|
|
|
218e99 |
--
|
|
|
218e99 |
1.7.1
|
|
|
218e99 |
|