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 6/9] virtio-blk: define VirtIOBlkConf
Date: Thu, 24 Nov 2011 13:38:25 +0100	[thread overview]
Message-ID: <1322138308-31040-7-git-send-email-pbonzini@redhat.com> (raw)
In-Reply-To: <1322138308-31040-1-git-send-email-pbonzini@redhat.com>

It has only one field for now, but this will change soon...

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

diff --git a/hw/s390-virtio-bus.c b/hw/s390-virtio-bus.c
index 282688a..cf7cfef 100644
--- a/hw/s390-virtio-bus.c
+++ b/hw/s390-virtio-bus.c
@@ -129,7 +129,7 @@ static int s390_virtio_blk_init(VirtIOS390Device *dev)
     VirtIODevice *vdev;
 
     vdev = virtio_blk_init((DeviceState *)dev, &dev->block,
-                           &dev->block_serial);
+                           &dev->blk);
     if (!vdev) {
         return -1;
     }
@@ -348,7 +348,7 @@ static VirtIOS390DeviceInfo s390_virtio_blk = {
     .qdev.size = sizeof(VirtIOS390Device),
     .qdev.props = (Property[]) {
         DEFINE_BLOCK_PROPERTIES(VirtIOS390Device, block),
-        DEFINE_PROP_STRING("serial", VirtIOS390Device, block_serial),
+        DEFINE_PROP_STRING("serial", VirtIOS390Device, blk.serial),
         DEFINE_PROP_END_OF_LIST(),
     },
 };
diff --git a/hw/s390-virtio-bus.h b/hw/s390-virtio-bus.h
index b10c78b..1f47e4d 100644
--- a/hw/s390-virtio-bus.h
+++ b/hw/s390-virtio-bus.h
@@ -17,6 +17,7 @@
  * License along with this library; if not, see <http://www.gnu.org/licenses/>.
  */
 
+#include "virtio-blk.h"
 #include "virtio-net.h"
 #include "virtio-serial.h"
 
@@ -42,7 +43,7 @@ typedef struct VirtIOS390Device {
     uint8_t feat_len;
     VirtIODevice *vdev;
     BlockConf block;
-    char *block_serial;
+    VirtIOBlkConf blk;
     uint32_t host_features;
     virtio_serial_conf serial;
     virtio_net_conf net;
diff --git a/hw/virtio-blk.c b/hw/virtio-blk.c
index 19e89e7..e34140e 100644
--- a/hw/virtio-blk.c
+++ b/hw/virtio-blk.c
@@ -29,7 +29,7 @@ typedef struct VirtIOBlock
     void *rq;
     QEMUBH *bh;
     BlockConf *conf;
-    char *serial;
+    VirtIOBlkConf *blk;
     unsigned short sector_mask;
     DeviceState *qdev;
 } VirtIOBlock;
@@ -397,7 +397,7 @@ static void virtio_blk_handle_request(VirtIOBlockReq *req,
          * terminated by '\0' only when shorter than buffer.
          */
         strncpy(req->elem.in_sg[0].iov_base,
-                s->serial ? s->serial : "",
+                s->blk->serial ? s->blk->serial : "",
                 MIN(req->elem.in_sg[0].iov_len, VIRTIO_BLK_ID_BYTES));
         virtio_blk_req_complete(req, VIRTIO_BLK_S_OK);
         g_free(req);
@@ -570,8 +570,7 @@ static const BlockDevOps virtio_block_ops = {
     .resize_cb = virtio_blk_resize,
 };
 
-VirtIODevice *virtio_blk_init(DeviceState *dev, BlockConf *conf,
-                              char **serial)
+VirtIODevice *virtio_blk_init(DeviceState *dev, BlockConf *conf, VirtIOBlkConf *blk)
 {
     VirtIOBlock *s;
     int cylinders, heads, secs;
@@ -587,11 +586,11 @@ VirtIODevice *virtio_blk_init(DeviceState *dev, BlockConf *conf,
         return NULL;
     }
 
-    if (!*serial) {
+    if (!blk->serial) {
         /* try to fall back to value set with legacy -drive serial=... */
         dinfo = drive_get_by_blockdev(conf->bs);
         if (*dinfo->serial) {
-            *serial = strdup(dinfo->serial);
+            blk->serial = strdup(dinfo->serial);
         }
     }
 
@@ -604,7 +603,7 @@ VirtIODevice *virtio_blk_init(DeviceState *dev, BlockConf *conf,
     s->vdev.reset = virtio_blk_reset;
     s->bs = conf->bs;
     s->conf = conf;
-    s->serial = *serial;
+    s->blk = blk;
     s->rq = NULL;
     s->sector_mask = (s->conf->logical_block_size / BDRV_SECTOR_SIZE) - 1;
     bdrv_guess_geometry(s->bs, &cylinders, &heads, &secs);
diff --git a/hw/virtio-blk.h b/hw/virtio-blk.h
index 244dce4..5f150f8 100644
--- a/hw/virtio-blk.h
+++ b/hw/virtio-blk.h
@@ -97,6 +97,11 @@ struct virtio_scsi_inhdr
     uint32_t residual;
 };
 
+struct VirtIOBlkConf
+{
+    char *serial;
+};
+
 #ifdef __linux__
 #define DEFINE_VIRTIO_BLK_FEATURES(_state, _field) \
         DEFINE_VIRTIO_COMMON_FEATURES(_state, _field), \
diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c
index f522156..bd111d0 100644
--- a/hw/virtio-pci.c
+++ b/hw/virtio-pci.c
@@ -670,7 +670,7 @@ static int virtio_blk_init_pci(PCIDevice *pci_dev)
         proxy->class_code = PCI_CLASS_STORAGE_SCSI;
 
     vdev = virtio_blk_init(&pci_dev->qdev, &proxy->block,
-                           &proxy->block_serial);
+                           &proxy->blk);
     if (!vdev) {
         return -1;
     }
@@ -808,7 +808,7 @@ static PCIDeviceInfo virtio_info[] = {
         .qdev.props = (Property[]) {
             DEFINE_PROP_HEX32("class", VirtIOPCIProxy, class_code, 0),
             DEFINE_BLOCK_PROPERTIES(VirtIOPCIProxy, block),
-            DEFINE_PROP_STRING("serial", VirtIOPCIProxy, block_serial),
+            DEFINE_PROP_STRING("serial", VirtIOPCIProxy, blk.serial),
             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 7654c84..195e852 100644
--- a/hw/virtio-pci.h
+++ b/hw/virtio-pci.h
@@ -15,6 +15,7 @@
 #ifndef QEMU_VIRTIO_PCI_H
 #define QEMU_VIRTIO_PCI_H
 
+#include "virtio-blk.h"
 #include "virtio-net.h"
 #include "virtio-serial.h"
 #include "9pfs/virtio-9p-device.h"
@@ -33,7 +34,7 @@ typedef struct {
     uint32_t class_code;
     uint32_t nvectors;
     BlockConf block;
-    char *block_serial;
+    VirtIOBlkConf blk;
     uint32_t host_features;
 #ifdef CONFIG_LINUX
     V9fsConf fsconf;
diff --git a/hw/virtio.h b/hw/virtio.h
index 9ed8dfc..da2941e 100644
--- a/hw/virtio.h
+++ b/hw/virtio.h
@@ -191,8 +191,9 @@ void virtio_bind_device(VirtIODevice *vdev, const VirtIOBindings *binding,
                         void *opaque);
 
 /* Base devices.  */
+typedef struct VirtIOBlkConf VirtIOBlkConf;
 VirtIODevice *virtio_blk_init(DeviceState *dev, BlockConf *conf,
-                              char **serial);
+                              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 ` Paolo Bonzini [this message]
2011-11-24 12:38 ` [Qemu-devel] [PATCH 7/9] virtio-blk: " Paolo Bonzini
2011-11-24 12:38 ` [Qemu-devel] [PATCH 8/9] virtio-blk: move BlockConf into VirtIOBlkConf Paolo Bonzini
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-7-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).