qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Peter Maydell <peter.maydell@linaro.org>
To: qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
	qemu-block@nongnu.org, patches@linaro.org,
	Markus Armbruster <armbru@redhat.com>,
	Alexander Graf <agraf@suse.de>,
	Christian Borntraeger <borntraeger@de.ibm.com>,
	Cornelia Huck <cornelia.huck@de.ibm.com>
Subject: [Qemu-devel] [PATCH 1/4] blockdev: Factor out create_implicit_virtio_device
Date: Thu,  4 Jun 2015 17:20:50 +0100	[thread overview]
Message-ID: <1433434853-19229-2-git-send-email-peter.maydell@linaro.org> (raw)
In-Reply-To: <1433434853-19229-1-git-send-email-peter.maydell@linaro.org>

Factor out the code which creates the implicit virtio device
for IF_VIRTIO drives, so we can call it from drive_check_orphaned().

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 blockdev.c | 35 ++++++++++++++++++++++-------------
 1 file changed, 22 insertions(+), 13 deletions(-)

diff --git a/blockdev.c b/blockdev.c
index de94a8b..9cf6123 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -212,6 +212,27 @@ DriveInfo *drive_get(BlockInterfaceType type, int bus, int unit)
     return NULL;
 }
 
+/* Create the virtio device whose existence is implied by the
+ * creation of a block device with if=virtio.
+ */
+static void create_implicit_virtio_device(const char *driveid,
+                                          const char *devaddr)
+{
+    QemuOpts *devopts;
+
+    devopts = qemu_opts_create(qemu_find_opts("device"), NULL, 0,
+                               &error_abort);
+    if (arch_type == QEMU_ARCH_S390X) {
+        qemu_opt_set(devopts, "driver", "virtio-blk-s390", &error_abort);
+    } else {
+        qemu_opt_set(devopts, "driver", "virtio-blk-pci", &error_abort);
+    }
+    qemu_opt_set(devopts, "drive", driveid, &error_abort);
+    if (devaddr) {
+        qemu_opt_set(devopts, "addr", devaddr, &error_abort);
+    }
+}
+
 bool drive_check_orphaned(void)
 {
     BlockBackend *blk;
@@ -929,19 +950,7 @@ DriveInfo *drive_new(QemuOpts *all_opts, BlockInterfaceType block_default_type)
     }
 
     if (type == IF_VIRTIO) {
-        QemuOpts *devopts;
-        devopts = qemu_opts_create(qemu_find_opts("device"), NULL, 0,
-                                   &error_abort);
-        if (arch_type == QEMU_ARCH_S390X) {
-            qemu_opt_set(devopts, "driver", "virtio-blk-s390", &error_abort);
-        } else {
-            qemu_opt_set(devopts, "driver", "virtio-blk-pci", &error_abort);
-        }
-        qemu_opt_set(devopts, "drive", qdict_get_str(bs_opts, "id"),
-                     &error_abort);
-        if (devaddr) {
-            qemu_opt_set(devopts, "addr", devaddr, &error_abort);
-        }
+        create_implicit_virtio_device(qdict_get_str(bs_opts, "id"), devaddr);
     }
 
     filename = qemu_opt_get(legacy_opts, "file");
-- 
1.9.1

  reply	other threads:[~2015-06-04 16:21 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-04 16:20 [Qemu-devel] [PATCH 0/4] blockdev: Defer creation of implicit PCI devices for IF_VIRTIO drives Peter Maydell
2015-06-04 16:20 ` Peter Maydell [this message]
2015-06-04 16:20 ` [Qemu-devel] [PATCH 2/4] blockdev: Don't call create_implicit_virtio_device() when it has no effect Peter Maydell
2015-06-04 16:20 ` [Qemu-devel] [PATCH 3/4] blockdev: Defer creation of implicit PCI devices for IF_VIRTIO drives Peter Maydell
2015-06-04 16:20 ` [Qemu-devel] [PATCH 4/4] hw/arm/virt: Make block devices default to virtio Peter Maydell
2015-06-08  8:02 ` [Qemu-devel] [PATCH 0/4] blockdev: Defer creation of implicit PCI devices for IF_VIRTIO drives Christian Borntraeger
2015-06-08  8:18   ` Christian Borntraeger
2015-06-08 12:37     ` Peter Maydell
2015-06-08 14:18 ` Markus Armbruster
2015-06-08 14:53   ` Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1433434853-19229-2-git-send-email-peter.maydell@linaro.org \
    --to=peter.maydell@linaro.org \
    --cc=agraf@suse.de \
    --cc=armbru@redhat.com \
    --cc=borntraeger@de.ibm.com \
    --cc=cornelia.huck@de.ibm.com \
    --cc=kwolf@redhat.com \
    --cc=patches@linaro.org \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).