qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: fred.konrad@greensocs.com
To: qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org, aliguori@us.ibm.com,
	e.voevodin@samsung.com, mark.burton@greensocs.com,
	stefanha@redhat.com, cornelia.huck@de.ibm.com, afaerber@suse.de,
	fred.konrad@greensocs.com
Subject: [Qemu-devel] [RFC PATCH V4 6/6] virtio-blk : Refactoring virtio-blk.
Date: Fri, 30 Nov 2012 18:12:10 +0100	[thread overview]
Message-ID: <1354295530-18644-7-git-send-email-fred.konrad@greensocs.com> (raw)
In-Reply-To: <1354295530-18644-1-git-send-email-fred.konrad@greensocs.com>

From: KONRAD Frederic <fred.konrad@greensocs.com>

Signed-off-by: KONRAD Frederic <fred.konrad@greensocs.com>
---
 hw/virtio-blk.c |   61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 hw/virtio-blk.h |   16 ++++++++++++++
 2 files changed, 77 insertions(+), 0 deletions(-)

diff --git a/hw/virtio-blk.c b/hw/virtio-blk.c
index e25cc96..3547882 100644
--- a/hw/virtio-blk.c
+++ b/hw/virtio-blk.c
@@ -656,3 +656,64 @@ void virtio_blk_exit(VirtIODevice *vdev)
     blockdev_mark_auto_del(s->bs);
     virtio_cleanup(vdev);
 }
+
+/*
+ * Refactored virtio-blk.
+ */
+
+static int virtio_device_init(DeviceState *qdev)
+{
+    VirtIODevice *vdev = VIRTIO_DEVICE(qdev);
+    /*
+     * TODO: device initialization.
+     */
+    return 0;
+}
+
+static void virtio_device_exit(DeviceState *dev)
+{
+    /*
+     * TODO: destroy device.
+     */
+}
+
+static Property virtio_blk_properties[] = {
+    DEFINE_BLOCK_PROPERTIES(VirtioBlkState, blk.conf),
+    DEFINE_BLOCK_CHS_PROPERTIES(VirtioBlkState, blk.conf),
+    DEFINE_PROP_STRING("serial", VirtioBlkState, blk.serial),
+#ifdef __linux__
+    DEFINE_PROP_BIT("scsi", VirtioBlkState, blk.scsi, 0, true),
+#endif
+    DEFINE_PROP_BIT("config-wce", VirtioBlkState, blk.config_wce, 0, true),
+    DEFINE_VIRTIO_BLK_FEATURES(VirtioBlkState, host_features),
+    DEFINE_PROP_END_OF_LIST(),
+};
+
+static void virtio_blk_class_init(ObjectClass *klass, void *data)
+{
+    DeviceClass *dc = DEVICE_CLASS(klass);
+    VirtioDeviceClass *vdc = VIRTIO_DEVICE_CLASS(klass);
+    dc->init = virtio_device_init;
+    dc->exit = virtio_device_exit;
+    dc->props = virtio_blk_properties;
+    /* VirtioDeviceClass */
+    vdc->get_config = virtio_blk_update_config;
+    vdc->set_config = virtio_blk_set_config;
+    vdc->get_features = virtio_blk_get_features;
+    vdc->set_status = virtio_blk_set_status;
+    vdc->reset = virtio_blk_reset;
+}
+
+static const TypeInfo virtio_device_info = {
+    .name = TYPE_VIRTIO_BLK,
+    .parent = TYPE_VIRTIO_DEVICE,
+    .instance_size = sizeof(VirtioBlkState),
+    .class_init = virtio_blk_class_init,
+};
+
+static void virtio_register_types(void)
+{
+    type_register_static(&virtio_device_info);
+}
+
+type_init(virtio_register_types)
diff --git a/hw/virtio-blk.h b/hw/virtio-blk.h
index f0740d0..13876e7 100644
--- a/hw/virtio-blk.h
+++ b/hw/virtio-blk.h
@@ -111,4 +111,20 @@ struct VirtIOBlkConf
         DEFINE_VIRTIO_COMMON_FEATURES(_state, _field), \
         DEFINE_PROP_BIT("config-wce", _state, _field, VIRTIO_BLK_F_CONFIG_WCE, true)
 
+/*
+ * Refactored virtio-blk.
+ */
+
+#define TYPE_VIRTIO_BLK "virtio-blk"
+#define VIRTIO_BLK(obj) \
+        OBJECT_CHECK(VirtioBlkState, (obj), TYPE_VIRTIO_BLK)
+
+typedef struct {
+    DeviceState parent_obj;
+
+    /* virtio-blk specific */
+    VirtIOBlkConf blk;
+    uint32_t host_features;
+} VirtioBlkState;
+
 #endif
-- 
1.7.1

  parent reply	other threads:[~2012-11-30 17:12 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-30 17:12 [Qemu-devel] [RFC PATCH V4 0/6] Virtio refactoring fred.konrad
2012-11-30 17:12 ` [Qemu-devel] [RFC PATCH V4 1/6] qdev : add a maximum device allowed field for the bus fred.konrad
2012-11-30 18:26   ` Peter Maydell
2012-11-30 17:12 ` [Qemu-devel] [RFC PATCH V4 2/6] virtio-bus : Introduce virtio-bus fred.konrad
2012-11-30 18:36   ` Peter Maydell
2012-11-30 17:12 ` [Qemu-devel] [RFC PATCH V4 3/6] virtio-pci-bus : Introduce virtio-pci-bus fred.konrad
2012-11-30 17:12 ` [Qemu-devel] [RFC PATCH V4 4/6] virtio-pci : Introduce virtio-pci device fred.konrad
2012-11-30 17:12 ` [Qemu-devel] [RFC PATCH V4 5/6] virtio-device : Introduce virtio-device fred.konrad
2012-11-30 18:40   ` Peter Maydell
2012-11-30 17:12 ` fred.konrad [this message]
2012-11-30 18:42   ` [Qemu-devel] [RFC PATCH V4 6/6] virtio-blk : Refactoring virtio-blk Peter Maydell
2012-11-30 18:43 ` [Qemu-devel] [RFC PATCH V4 0/6] Virtio refactoring Peter Maydell
2012-12-03  9:25   ` KONRAD Frédéric

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=1354295530-18644-7-git-send-email-fred.konrad@greensocs.com \
    --to=fred.konrad@greensocs.com \
    --cc=afaerber@suse.de \
    --cc=aliguori@us.ibm.com \
    --cc=cornelia.huck@de.ibm.com \
    --cc=e.voevodin@samsung.com \
    --cc=mark.burton@greensocs.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /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).