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