qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: mst@redhat.com
Subject: [Qemu-devel] [PATCH 8/9] virtio-blk: move BlockConf into VirtIOBlkConf
Date: Thu, 24 Nov 2011 13:38:27 +0100	[thread overview]
Message-ID: <1322138308-31040-9-git-send-email-pbonzini@redhat.com> (raw)
In-Reply-To: <1322138308-31040-1-git-send-email-pbonzini@redhat.com>

This part pushes the block device properties down into VirtIOBlkConf and
DEFINE_VIRTIO_BLK_PROPERTIES.  No semantic change.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/s390-virtio-bus.c |    4 +---
 hw/s390-virtio-bus.h |    1 -
 hw/virtio-blk.c      |   17 +++++++++--------
 hw/virtio-blk.h      |    2 ++
 hw/virtio-pci.c      |    5 +----
 hw/virtio-pci.h      |    1 -
 hw/virtio.h          |    3 +--
 7 files changed, 14 insertions(+), 19 deletions(-)

diff --git a/hw/s390-virtio-bus.c b/hw/s390-virtio-bus.c
index 71720b9..a3810f2 100644
--- a/hw/s390-virtio-bus.c
+++ b/hw/s390-virtio-bus.c
@@ -128,8 +128,7 @@ static int s390_virtio_blk_init(VirtIOS390Device *dev)
 {
     VirtIODevice *vdev;
 
-    vdev = virtio_blk_init((DeviceState *)dev, &dev->block,
-                           &dev->blk);
+    vdev = virtio_blk_init((DeviceState *)dev, &dev->blk);
     if (!vdev) {
         return -1;
     }
@@ -347,7 +346,6 @@ static VirtIOS390DeviceInfo s390_virtio_blk = {
     .qdev.alias = "virtio-blk",
     .qdev.size = sizeof(VirtIOS390Device),
     .qdev.props = (Property[]) {
-        DEFINE_BLOCK_PROPERTIES(VirtIOS390Device, block),
         DEFINE_VIRTIO_BLK_PROPERTIES(VirtIOS390Device, host_features, blk),
         DEFINE_PROP_END_OF_LIST(),
     },
diff --git a/hw/s390-virtio-bus.h b/hw/s390-virtio-bus.h
index 1f47e4d..414fd22 100644
--- a/hw/s390-virtio-bus.h
+++ b/hw/s390-virtio-bus.h
@@ -42,7 +42,6 @@ typedef struct VirtIOS390Device {
     ram_addr_t feat_offs;
     uint8_t feat_len;
     VirtIODevice *vdev;
-    BlockConf block;
     VirtIOBlkConf blk;
     uint32_t host_features;
     virtio_serial_conf serial;
diff --git a/hw/virtio-blk.c b/hw/virtio-blk.c
index e34140e..7713fd1 100644
--- a/hw/virtio-blk.c
+++ b/hw/virtio-blk.c
@@ -570,25 +570,25 @@ static const BlockDevOps virtio_block_ops = {
     .resize_cb = virtio_blk_resize,
 };
 
-VirtIODevice *virtio_blk_init(DeviceState *dev, BlockConf *conf, VirtIOBlkConf *blk)
+VirtIODevice *virtio_blk_init(DeviceState *dev, VirtIOBlkConf *blk)
 {
     VirtIOBlock *s;
     int cylinders, heads, secs;
     static int virtio_blk_id;
     DriveInfo *dinfo;
 
-    if (!conf->bs) {
+    if (!blk->conf.bs) {
         error_report("virtio-blk-pci: drive property not set");
         return NULL;
     }
-    if (!bdrv_is_inserted(conf->bs)) {
+    if (!bdrv_is_inserted(blk->conf.bs)) {
         error_report("Device needs media, but drive is empty");
         return NULL;
     }
 
     if (!blk->serial) {
         /* try to fall back to value set with legacy -drive serial=... */
-        dinfo = drive_get_by_blockdev(conf->bs);
+        dinfo = drive_get_by_blockdev(blk->conf.bs);
         if (*dinfo->serial) {
             blk->serial = strdup(dinfo->serial);
         }
@@ -601,8 +601,8 @@ VirtIODevice *virtio_blk_init(DeviceState *dev, BlockConf *conf, VirtIOBlkConf *
     s->vdev.get_config = virtio_blk_update_config;
     s->vdev.get_features = virtio_blk_get_features;
     s->vdev.reset = virtio_blk_reset;
-    s->bs = conf->bs;
-    s->conf = conf;
+    s->bs = blk->conf.bs;
+    s->conf = &blk->conf;
     s->blk = blk;
     s->rq = NULL;
     s->sector_mask = (s->conf->logical_block_size / BDRV_SECTOR_SIZE) - 1;
@@ -615,10 +615,10 @@ VirtIODevice *virtio_blk_init(DeviceState *dev, BlockConf *conf, VirtIOBlkConf *
     register_savevm(dev, "virtio-blk", virtio_blk_id++, 2,
                     virtio_blk_save, virtio_blk_load, s);
     bdrv_set_dev_ops(s->bs, &virtio_block_ops, s);
-    bdrv_set_buffer_alignment(s->bs, conf->logical_block_size);
+    bdrv_set_buffer_alignment(s->bs, s->conf->logical_block_size);
 
     bdrv_iostatus_enable(s->bs);
-    add_boot_device_path(conf->bootindex, dev, "/disk@0,0");
+    add_boot_device_path(s->conf->bootindex, dev, "/disk@0,0");
 
     return &s->vdev;
 }
@@ -627,5 +627,6 @@ void virtio_blk_exit(VirtIODevice *vdev)
 {
     VirtIOBlock *s = to_virtio_blk(vdev);
     unregister_savevm(s->qdev, "virtio-blk", s);
+    blockdev_mark_auto_del(s->bs);
     virtio_cleanup(vdev);
 }
diff --git a/hw/virtio-blk.h b/hw/virtio-blk.h
index dd26ae7..518e1cc 100644
--- a/hw/virtio-blk.h
+++ b/hw/virtio-blk.h
@@ -99,6 +99,7 @@ struct virtio_scsi_inhdr
 
 struct VirtIOBlkConf
 {
+    BlockConf conf;
     char *serial;
 };
 
@@ -113,6 +114,7 @@ struct VirtIOBlkConf
 
 #define DEFINE_VIRTIO_BLK_PROPERTIES(_state, _features_field, _conf_field) \
         DEFINE_VIRTIO_BLK_FEATURES(_state, _features_field), \
+        DEFINE_BLOCK_PROPERTIES(_state, _conf_field.conf), \
         DEFINE_PROP_STRING("serial", _state, _conf_field.serial)
 
 #endif
diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c
index d64058e..0048dc1 100644
--- a/hw/virtio-pci.c
+++ b/hw/virtio-pci.c
@@ -669,8 +669,7 @@ static int virtio_blk_init_pci(PCIDevice *pci_dev)
         proxy->class_code != PCI_CLASS_STORAGE_OTHER)
         proxy->class_code = PCI_CLASS_STORAGE_SCSI;
 
-    vdev = virtio_blk_init(&pci_dev->qdev, &proxy->block,
-                           &proxy->blk);
+    vdev = virtio_blk_init(&pci_dev->qdev, &proxy->blk);
     if (!vdev) {
         return -1;
     }
@@ -698,7 +697,6 @@ static int virtio_blk_exit_pci(PCIDevice *pci_dev)
 
     virtio_pci_stop_ioeventfd(proxy);
     virtio_blk_exit(proxy->vdev);
-    blockdev_mark_auto_del(proxy->block.bs);
     return virtio_exit_pci(pci_dev);
 }
 
@@ -807,7 +805,6 @@ static PCIDeviceInfo virtio_info[] = {
         .class_id  = PCI_CLASS_STORAGE_SCSI,
         .qdev.props = (Property[]) {
             DEFINE_PROP_HEX32("class", VirtIOPCIProxy, class_code, 0),
-            DEFINE_BLOCK_PROPERTIES(VirtIOPCIProxy, block),
             DEFINE_PROP_BIT("ioeventfd", VirtIOPCIProxy, flags,
                             VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT, true),
             DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy, nvectors, 2),
diff --git a/hw/virtio-pci.h b/hw/virtio-pci.h
index 195e852..63d83ae 100644
--- a/hw/virtio-pci.h
+++ b/hw/virtio-pci.h
@@ -33,7 +33,6 @@ typedef struct {
     uint32_t flags;
     uint32_t class_code;
     uint32_t nvectors;
-    BlockConf block;
     VirtIOBlkConf blk;
     uint32_t host_features;
 #ifdef CONFIG_LINUX
diff --git a/hw/virtio.h b/hw/virtio.h
index da2941e..94963fe 100644
--- a/hw/virtio.h
+++ b/hw/virtio.h
@@ -192,8 +192,7 @@ void virtio_bind_device(VirtIODevice *vdev, const VirtIOBindings *binding,
 
 /* Base devices.  */
 typedef struct VirtIOBlkConf VirtIOBlkConf;
-VirtIODevice *virtio_blk_init(DeviceState *dev, BlockConf *conf,
-                              VirtIOBlkConf *blk);
+VirtIODevice *virtio_blk_init(DeviceState *dev, VirtIOBlkConf *blk);
 struct virtio_net_conf;
 VirtIODevice *virtio_net_init(DeviceState *dev, struct virtio_net_conf *net);
 typedef struct virtio_serial_conf virtio_serial_conf;
-- 
1.7.7.1

  parent reply	other threads:[~2011-11-24 12:39 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-24 12:38 [Qemu-devel] [PATCH 0/9] virtio: device configuration cleanup Paolo Bonzini
2011-11-24 12:38 ` [Qemu-devel] [PATCH 1/9] virtio-net: move property declarations to header file Paolo Bonzini
2011-11-24 12:38 ` [Qemu-devel] [PATCH 2/9] virtio-net: move NICConf into virtio_net_conf Paolo Bonzini
2011-11-24 12:38 ` [Qemu-devel] [PATCH 3/9] virtio-serial: move property declarations to header file Paolo Bonzini
2011-11-24 12:38 ` [Qemu-devel] [PATCH 4/9] virtio-9p: remove PCI dependencies from hw/9pfs/ Paolo Bonzini
2011-11-28 17:18   ` Aneesh Kumar K.V
2011-11-28 18:46   ` Michael S. Tsirkin
2011-11-29  8:38     ` Paolo Bonzini
2011-11-29 13:12       ` Michael S. Tsirkin
2012-01-01 21:45         ` Paolo Bonzini
2011-11-24 12:38 ` [Qemu-devel] [PATCH 5/9] virtio-9p: move property declarations to header file Paolo Bonzini
2011-11-24 12:38 ` [Qemu-devel] [PATCH 6/9] virtio-blk: define VirtIOBlkConf Paolo Bonzini
2011-11-24 12:38 ` [Qemu-devel] [PATCH 7/9] virtio-blk: move property declarations to header file Paolo Bonzini
2011-11-24 12:38 ` Paolo Bonzini [this message]
2011-11-24 12:38 ` [Qemu-devel] [PATCH 9/9] virtio: move conf fields into an anonymous union Paolo Bonzini
2011-11-28 18:51 ` [Qemu-devel] [PATCH 0/9] virtio: device configuration cleanup Michael S. Tsirkin

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=1322138308-31040-9-git-send-email-pbonzini@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=mst@redhat.com \
    --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).