qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v4 0/4] virtio-9p refactoring.
@ 2013-04-23  9:08 fred.konrad
  2013-04-23  9:08 ` [Qemu-devel] [PATCH v4 1/4] virtio-9p: add the virtio-9p device fred.konrad
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: fred.konrad @ 2013-04-23  9:08 UTC (permalink / raw)
  To: qemu-devel, aliguori; +Cc: peter.maydell, mark.burton, fred.konrad

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

Basically it creates virtio-9p-device backend which extends virtio-device.
Then a virtio-9p-device can be connected on a virtio-bus.
virtio-9p-pci is modified, extends virtio-pci and have a virtio-9p-device.

You can checkout my branch here:

git://project.greensocs.com/qemu-virtio.git virtio-9p-v4

I made basic tests (with linux guests) on:
    * qemu-system-i386

Changes v3 -> v4:
    * Fix a compilation bug when virtfs is disabled. (lost during a rebase)
    * Renamed device "virtio-9p" => "virtio-9p-device".
    * Rebased.

Changes v2 -> v3:
    * Rebased.

Thanks,

Fred

KONRAD Frederic (4):
  virtio-9p: add the virtio-9p device.
  virtio-9p-pci: switch to the new API.
  virtio-9p: cleanup: init function.
  virtio-9p: cleanup: QOM casts.

 hw/9pfs/virtio-9p-device.c | 91 +++++++++++++++++++++++++++++-----------------
 hw/9pfs/virtio-9p.c        |  2 +-
 hw/9pfs/virtio-9p.h        | 12 +++++-
 hw/virtio/virtio-pci.c     | 61 +++++++++++++++++--------------
 hw/virtio/virtio-pci.h     | 23 ++++++++++--
 5 files changed, 123 insertions(+), 66 deletions(-)

-- 
1.7.11.7

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Qemu-devel] [PATCH v4 1/4] virtio-9p: add the virtio-9p device.
  2013-04-23  9:08 [Qemu-devel] [PATCH v4 0/4] virtio-9p refactoring fred.konrad
@ 2013-04-23  9:08 ` fred.konrad
  2013-04-23  9:08 ` [Qemu-devel] [PATCH v4 2/4] virtio-9p-pci: switch to the new API fred.konrad
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: fred.konrad @ 2013-04-23  9:08 UTC (permalink / raw)
  To: qemu-devel, aliguori
  Cc: peter.maydell, mark.burton, Aneesh Kumar K.V, fred.konrad

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

Create virtio-9p-device which extends virtio-device, so it can be connected on
virtio-bus.

Signed-off-by: KONRAD Frederic <fred.konrad@greensocs.com>
---
 hw/9pfs/virtio-9p-device.c | 73 +++++++++++++++++++++++++++++++++++++++++-----
 hw/9pfs/virtio-9p.h        |  9 ++++++
 hw/virtio/virtio-pci.c     |  3 +-
 3 files changed, 76 insertions(+), 9 deletions(-)

diff --git a/hw/9pfs/virtio-9p-device.c b/hw/9pfs/virtio-9p-device.c
index b476b81..7f00a45 100644
--- a/hw/9pfs/virtio-9p-device.c
+++ b/hw/9pfs/virtio-9p-device.c
@@ -46,19 +46,30 @@ static void virtio_9p_get_config(VirtIODevice *vdev, uint8_t *config)
     g_free(cfg);
 }
 
-VirtIODevice *virtio_9p_init(DeviceState *dev, V9fsConf *conf)
+static VirtIODevice *virtio_9p_common_init(DeviceState *dev, V9fsConf *conf,
+                                           V9fsState **ps)
 {
-    V9fsState *s;
+    V9fsState *s = *ps;
     int i, len;
     struct stat stat;
     FsDriverEntry *fse;
     V9fsPath path;
 
-    s = (V9fsState *)virtio_common_init("virtio-9p",
-                                    VIRTIO_ID_9P,
-                                    sizeof(struct virtio_9p_config)+
-                                    MAX_TAG_LEN,
-                                    sizeof(V9fsState));
+    /*
+     * We have two cases here: the old virtio-9p-pci device, and the
+     * refactored virtio-9p.
+     */
+
+    if (s == NULL) {
+        s = (V9fsState *)virtio_common_init("virtio-9p",
+                                        VIRTIO_ID_9P,
+                                        sizeof(struct virtio_9p_config)+
+                                        MAX_TAG_LEN,
+                                        sizeof(V9fsState));
+    } else {
+        virtio_init(VIRTIO_DEVICE(s), "virtio-9p", VIRTIO_ID_9P,
+                    sizeof(struct virtio_9p_config) + MAX_TAG_LEN);
+    }
     /* initialize pdu allocator */
     QLIST_INIT(&s->free_list);
     QLIST_INIT(&s->active_list);
@@ -136,3 +147,51 @@ VirtIODevice *virtio_9p_init(DeviceState *dev, V9fsConf *conf)
 
     return &s->vdev;
 }
+
+VirtIODevice *virtio_9p_init(DeviceState *dev, V9fsConf *conf)
+{
+    V9fsState *s = NULL;
+    return virtio_9p_common_init(dev, conf, &s);
+}
+
+/* virtio-9p device */
+
+static int virtio_9p_device_init(VirtIODevice *vdev)
+{
+    DeviceState *qdev = DEVICE(vdev);
+    V9fsState *s = VIRTIO_9P(vdev);
+    V9fsConf *fsconf = &(s->fsconf);
+    if (virtio_9p_common_init(qdev, fsconf, &s) == NULL) {
+        return -1;
+    }
+    return 0;
+}
+
+static Property virtio_9p_properties[] = {
+    DEFINE_VIRTIO_9P_PROPERTIES(V9fsState, fsconf),
+    DEFINE_PROP_END_OF_LIST(),
+};
+
+static void virtio_9p_class_init(ObjectClass *klass, void *data)
+{
+    DeviceClass *dc = DEVICE_CLASS(klass);
+    VirtioDeviceClass *vdc = VIRTIO_DEVICE_CLASS(klass);
+    dc->props = virtio_9p_properties;
+    vdc->init = virtio_9p_device_init;
+    vdc->get_features = virtio_9p_get_features;
+    vdc->get_config = virtio_9p_get_config;
+}
+
+static const TypeInfo virtio_device_info = {
+    .name = TYPE_VIRTIO_9P,
+    .parent = TYPE_VIRTIO_DEVICE,
+    .instance_size = sizeof(V9fsState),
+    .class_init = virtio_9p_class_init,
+};
+
+static void virtio_9p_register_types(void)
+{
+    type_register_static(&virtio_device_info);
+}
+
+type_init(virtio_9p_register_types)
diff --git a/hw/9pfs/virtio-9p.h b/hw/9pfs/virtio-9p.h
index 95a8ec3..767f7e6 100644
--- a/hw/9pfs/virtio-9p.h
+++ b/hw/9pfs/virtio-9p.h
@@ -225,6 +225,7 @@ typedef struct V9fsState
     CoRwlock rename_lock;
     int32_t root_fid;
     Error *migration_blocker;
+    V9fsConf fsconf;
 } V9fsState;
 
 typedef struct V9fsStatState {
@@ -401,4 +402,12 @@ extern int v9fs_name_to_path(V9fsState *s, V9fsPath *dirpath,
 #define pdu_unmarshal(pdu, offset, fmt, args...)  \
     v9fs_unmarshal(pdu->elem.out_sg, pdu->elem.out_num, offset, 1, fmt, ##args)
 
+#define TYPE_VIRTIO_9P "virtio-9p-device"
+#define VIRTIO_9P(obj) \
+        OBJECT_CHECK(V9fsState, (obj), TYPE_VIRTIO_9P)
+
+#define DEFINE_VIRTIO_9P_PROPERTIES(_state, _field)             \
+        DEFINE_PROP_STRING("mount_tag", _state, _field.tag),    \
+        DEFINE_PROP_STRING("fsdev", _state, _field.fsdev_id)
+
 #endif
diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
index c1e9a60..787f5fd 100644
--- a/hw/virtio/virtio-pci.c
+++ b/hw/virtio/virtio-pci.c
@@ -1040,8 +1040,7 @@ static Property virtio_9p_properties[] = {
     DEFINE_PROP_BIT("ioeventfd", VirtIOPCIProxy, flags, VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT, true),
     DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy, nvectors, 2),
     DEFINE_VIRTIO_COMMON_FEATURES(VirtIOPCIProxy, host_features),
-    DEFINE_PROP_STRING("mount_tag", VirtIOPCIProxy, fsconf.tag),
-    DEFINE_PROP_STRING("fsdev", VirtIOPCIProxy, fsconf.fsdev_id),
+    DEFINE_VIRTIO_9P_PROPERTIES(VirtIOPCIProxy, fsconf),
     DEFINE_PROP_END_OF_LIST(),
 };
 
-- 
1.7.11.7

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [Qemu-devel] [PATCH v4 2/4] virtio-9p-pci: switch to the new API.
  2013-04-23  9:08 [Qemu-devel] [PATCH v4 0/4] virtio-9p refactoring fred.konrad
  2013-04-23  9:08 ` [Qemu-devel] [PATCH v4 1/4] virtio-9p: add the virtio-9p device fred.konrad
@ 2013-04-23  9:08 ` fred.konrad
  2013-04-23  9:08 ` [Qemu-devel] [PATCH v4 3/4] virtio-9p: cleanup: init function fred.konrad
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: fred.konrad @ 2013-04-23  9:08 UTC (permalink / raw)
  To: qemu-devel, aliguori
  Cc: peter.maydell, mark.burton, Aneesh Kumar K.V, fred.konrad

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

Here the virtio-9p-pci is modified for the new API. The device
virtio-9p-pci extends virtio-pci. It creates and connects a
virtio-9p-device during the init. The properties are not changed.

Signed-off-by: KONRAD Frederic <fred.konrad@greensocs.com>
---
 hw/9pfs/virtio-9p.h    |  1 -
 hw/virtio/virtio-pci.c | 60 ++++++++++++++++++++++++++++----------------------
 hw/virtio/virtio-pci.h | 23 ++++++++++++++++---
 3 files changed, 54 insertions(+), 30 deletions(-)

diff --git a/hw/9pfs/virtio-9p.h b/hw/9pfs/virtio-9p.h
index 767f7e6..e1fa506 100644
--- a/hw/9pfs/virtio-9p.h
+++ b/hw/9pfs/virtio-9p.h
@@ -12,7 +12,6 @@
 #include "qemu/thread.h"
 #include "block/coroutine.h"
 
-
 /* The feature bitmap for virtio 9P */
 /* The mount point is specified in a config variable */
 #define VIRTIO_9P_MOUNT_TAG 0
diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
index 787f5fd..a1f15a8 100644
--- a/hw/virtio/virtio-pci.c
+++ b/hw/virtio/virtio-pci.c
@@ -1023,48 +1023,56 @@ static const TypeInfo virtio_rng_info = {
 };
 
 #ifdef CONFIG_VIRTFS
-static int virtio_9p_init_pci(PCIDevice *pci_dev)
+static int virtio_9p_init_pci(VirtIOPCIProxy *vpci_dev)
 {
-    VirtIOPCIProxy *proxy = DO_UPCAST(VirtIOPCIProxy, pci_dev, pci_dev);
-    VirtIODevice *vdev;
+    V9fsPCIState *dev = VIRTIO_9P_PCI(vpci_dev);
+    DeviceState *vdev = DEVICE(&dev->vdev);
 
-    vdev = virtio_9p_init(&pci_dev->qdev, &proxy->fsconf);
-    vdev->nvectors = proxy->nvectors;
-    virtio_init_pci(proxy, vdev);
-    /* make the actual value visible */
-    proxy->nvectors = vdev->nvectors;
+    qdev_set_parent_bus(vdev, BUS(&vpci_dev->bus));
+    if (qdev_init(vdev) < 0) {
+        return -1;
+    }
     return 0;
 }
 
-static Property virtio_9p_properties[] = {
-    DEFINE_PROP_BIT("ioeventfd", VirtIOPCIProxy, flags, VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT, true),
+static Property virtio_9p_pci_properties[] = {
+    DEFINE_PROP_BIT("ioeventfd", VirtIOPCIProxy, flags,
+                    VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT, true),
     DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy, nvectors, 2),
     DEFINE_VIRTIO_COMMON_FEATURES(VirtIOPCIProxy, host_features),
-    DEFINE_VIRTIO_9P_PROPERTIES(VirtIOPCIProxy, fsconf),
+    DEFINE_VIRTIO_9P_PROPERTIES(V9fsPCIState, vdev.fsconf),
     DEFINE_PROP_END_OF_LIST(),
 };
 
-static void virtio_9p_class_init(ObjectClass *klass, void *data)
+static void virtio_9p_pci_class_init(ObjectClass *klass, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
-    PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
+    PCIDeviceClass *pcidev_k = PCI_DEVICE_CLASS(klass);
+    VirtioPCIClass *k = VIRTIO_PCI_CLASS(klass);
 
     k->init = virtio_9p_init_pci;
-    k->vendor_id = PCI_VENDOR_ID_REDHAT_QUMRANET;
-    k->device_id = PCI_DEVICE_ID_VIRTIO_9P;
-    k->revision = VIRTIO_PCI_ABI_VERSION;
-    k->class_id = 0x2;
-    dc->props = virtio_9p_properties;
-    dc->reset = virtio_pci_reset;
+    pcidev_k->vendor_id = PCI_VENDOR_ID_REDHAT_QUMRANET;
+    pcidev_k->device_id = PCI_DEVICE_ID_VIRTIO_9P;
+    pcidev_k->revision = VIRTIO_PCI_ABI_VERSION;
+    pcidev_k->class_id = 0x2;
+    dc->props = virtio_9p_pci_properties;
 }
 
-static const TypeInfo virtio_9p_info = {
-    .name          = "virtio-9p-pci",
-    .parent        = TYPE_PCI_DEVICE,
-    .instance_size = sizeof(VirtIOPCIProxy),
-    .class_init    = virtio_9p_class_init,
+static void virtio_9p_pci_instance_init(Object *obj)
+{
+    V9fsPCIState *dev = VIRTIO_9P_PCI(obj);
+    object_initialize(OBJECT(&dev->vdev), TYPE_VIRTIO_9P);
+    object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL);
+}
+
+static const TypeInfo virtio_9p_pci_info = {
+    .name          = TYPE_VIRTIO_9P_PCI,
+    .parent        = TYPE_VIRTIO_PCI,
+    .instance_size = sizeof(V9fsPCIState),
+    .instance_init = virtio_9p_pci_instance_init,
+    .class_init    = virtio_9p_pci_class_init,
 };
-#endif
+#endif /* CONFIG_VIRTFS */
 
 /*
  * virtio-pci: This is the PCIDevice which has a virtio-pci-bus.
@@ -1590,7 +1598,7 @@ static void virtio_pci_register_types(void)
     type_register_static(&virtio_pci_bus_info);
     type_register_static(&virtio_pci_info);
 #ifdef CONFIG_VIRTFS
-    type_register_static(&virtio_9p_info);
+    type_register_static(&virtio_9p_pci_info);
 #endif
     type_register_static(&virtio_blk_pci_info);
     type_register_static(&virtio_scsi_pci_info);
diff --git a/hw/virtio/virtio-pci.h b/hw/virtio/virtio-pci.h
index 1b66e46..db0185c 100644
--- a/hw/virtio/virtio-pci.h
+++ b/hw/virtio/virtio-pci.h
@@ -24,6 +24,9 @@
 #include "hw/virtio/virtio-balloon.h"
 #include "hw/virtio/virtio-bus.h"
 #include "hw/virtio/virtio-9p.h"
+#ifdef CONFIG_VIRTFS
+#include "hw/9pfs/virtio-9p.h"
+#endif
 #ifdef CONFIG_VHOST_SCSI
 #include "hw/virtio/vhost-scsi.h"
 #endif
@@ -84,9 +87,6 @@ struct VirtIOPCIProxy {
     uint32_t class_code;
     uint32_t nvectors;
     uint32_t host_features;
-#ifdef CONFIG_VIRTFS
-    V9fsConf fsconf;
-#endif
     VirtIORNGConf rng;
     bool ioeventfd_disabled;
     bool ioeventfd_started;
@@ -171,6 +171,23 @@ struct VirtIONetPCI {
     VirtIONet vdev;
 };
 
+/*
+ * virtio-9p-pci: This extends VirtioPCIProxy.
+ */
+
+#ifdef CONFIG_VIRTFS
+
+#define TYPE_VIRTIO_9P_PCI "virtio-9p-pci"
+#define VIRTIO_9P_PCI(obj) \
+        OBJECT_CHECK(V9fsPCIState, (obj), TYPE_VIRTIO_9P_PCI)
+
+typedef struct V9fsPCIState {
+    VirtIOPCIProxy parent_obj;
+    V9fsState vdev;
+} V9fsPCIState;
+
+#endif
+
 void virtio_init_pci(VirtIOPCIProxy *proxy, VirtIODevice *vdev);
 void virtio_pci_bus_new(VirtioBusState *bus, VirtIOPCIProxy *dev);
 
-- 
1.7.11.7

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [Qemu-devel] [PATCH v4 3/4] virtio-9p: cleanup: init function.
  2013-04-23  9:08 [Qemu-devel] [PATCH v4 0/4] virtio-9p refactoring fred.konrad
  2013-04-23  9:08 ` [Qemu-devel] [PATCH v4 1/4] virtio-9p: add the virtio-9p device fred.konrad
  2013-04-23  9:08 ` [Qemu-devel] [PATCH v4 2/4] virtio-9p-pci: switch to the new API fred.konrad
@ 2013-04-23  9:08 ` fred.konrad
  2013-04-23  9:08 ` [Qemu-devel] [PATCH v4 4/4] virtio-9p: cleanup: QOM casts fred.konrad
  2013-04-24 18:24 ` [Qemu-devel] [PATCH v4 0/4] virtio-9p refactoring Anthony Liguori
  4 siblings, 0 replies; 6+ messages in thread
From: fred.konrad @ 2013-04-23  9:08 UTC (permalink / raw)
  To: qemu-devel, aliguori
  Cc: peter.maydell, mark.burton, Aneesh Kumar K.V, fred.konrad

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

This remove old init function as it is no longer needed.

Signed-off-by: KONRAD Frederic <fred.konrad@greensocs.com>
---
 hw/9pfs/virtio-9p-device.c | 75 ++++++++++++++--------------------------------
 1 file changed, 23 insertions(+), 52 deletions(-)

diff --git a/hw/9pfs/virtio-9p-device.c b/hw/9pfs/virtio-9p-device.c
index 7f00a45..29a639e 100644
--- a/hw/9pfs/virtio-9p-device.c
+++ b/hw/9pfs/virtio-9p-device.c
@@ -46,30 +46,17 @@ static void virtio_9p_get_config(VirtIODevice *vdev, uint8_t *config)
     g_free(cfg);
 }
 
-static VirtIODevice *virtio_9p_common_init(DeviceState *dev, V9fsConf *conf,
-                                           V9fsState **ps)
+static int virtio_9p_device_init(VirtIODevice *vdev)
 {
-    V9fsState *s = *ps;
+    V9fsState *s = VIRTIO_9P(vdev);
     int i, len;
     struct stat stat;
     FsDriverEntry *fse;
     V9fsPath path;
 
-    /*
-     * We have two cases here: the old virtio-9p-pci device, and the
-     * refactored virtio-9p.
-     */
+    virtio_init(VIRTIO_DEVICE(s), "virtio-9p", VIRTIO_ID_9P,
+                sizeof(struct virtio_9p_config) + MAX_TAG_LEN);
 
-    if (s == NULL) {
-        s = (V9fsState *)virtio_common_init("virtio-9p",
-                                        VIRTIO_ID_9P,
-                                        sizeof(struct virtio_9p_config)+
-                                        MAX_TAG_LEN,
-                                        sizeof(V9fsState));
-    } else {
-        virtio_init(VIRTIO_DEVICE(s), "virtio-9p", VIRTIO_ID_9P,
-                    sizeof(struct virtio_9p_config) + MAX_TAG_LEN);
-    }
     /* initialize pdu allocator */
     QLIST_INIT(&s->free_list);
     QLIST_INIT(&s->active_list);
@@ -77,35 +64,36 @@ static VirtIODevice *virtio_9p_common_init(DeviceState *dev, V9fsConf *conf,
         QLIST_INSERT_HEAD(&s->free_list, &s->pdus[i], next);
     }
 
-    s->vq = virtio_add_queue(&s->vdev, MAX_REQ, handle_9p_output);
+    s->vq = virtio_add_queue(vdev, MAX_REQ, handle_9p_output);
 
-    fse = get_fsdev_fsentry(conf->fsdev_id);
+    fse = get_fsdev_fsentry(s->fsconf.fsdev_id);
 
     if (!fse) {
         /* We don't have a fsdev identified by fsdev_id */
         fprintf(stderr, "Virtio-9p device couldn't find fsdev with the "
-                "id = %s\n", conf->fsdev_id ? conf->fsdev_id : "NULL");
-        exit(1);
+                "id = %s\n",
+                s->fsconf.fsdev_id ? s->fsconf.fsdev_id : "NULL");
+        return -1;
     }
 
-    if (!conf->tag) {
+    if (!s->fsconf.tag) {
         /* we haven't specified a mount_tag */
         fprintf(stderr, "fsdev with id %s needs mount_tag arguments\n",
-                conf->fsdev_id);
-        exit(1);
+                s->fsconf.fsdev_id);
+        return -1;
     }
 
     s->ctx.export_flags = fse->export_flags;
     s->ctx.fs_root = g_strdup(fse->path);
     s->ctx.exops.get_st_gen = NULL;
-    len = strlen(conf->tag);
+    len = strlen(s->fsconf.tag);
     if (len > MAX_TAG_LEN - 1) {
         fprintf(stderr, "mount tag '%s' (%d bytes) is longer than "
-                "maximum (%d bytes)", conf->tag, len, MAX_TAG_LEN - 1);
-        exit(1);
+                "maximum (%d bytes)", s->fsconf.tag, len, MAX_TAG_LEN - 1);
+        return -1;
     }
 
-    s->tag = g_strdup(conf->tag);
+    s->tag = strdup(s->fsconf.tag);
     s->ctx.uid = -1;
 
     s->ops = fse->ops;
@@ -117,12 +105,12 @@ static VirtIODevice *virtio_9p_common_init(DeviceState *dev, V9fsConf *conf,
 
     if (s->ops->init(&s->ctx) < 0) {
         fprintf(stderr, "Virtio-9p Failed to initialize fs-driver with id:%s"
-                " and export path:%s\n", conf->fsdev_id, s->ctx.fs_root);
-        exit(1);
+                " and export path:%s\n", s->fsconf.fsdev_id, s->ctx.fs_root);
+        return -1;
     }
     if (v9fs_init_worker_threads() < 0) {
         fprintf(stderr, "worker thread initialization failed\n");
-        exit(1);
+        return -1;
     }
 
     /*
@@ -134,39 +122,22 @@ static VirtIODevice *virtio_9p_common_init(DeviceState *dev, V9fsConf *conf,
     if (s->ops->name_to_path(&s->ctx, NULL, "/", &path) < 0) {
         fprintf(stderr,
                 "error in converting name to path %s", strerror(errno));
-        exit(1);
+        return -1;
     }
     if (s->ops->lstat(&s->ctx, &path, &stat)) {
         fprintf(stderr, "share path %s does not exist\n", fse->path);
-        exit(1);
+        return -1;
     } else if (!S_ISDIR(stat.st_mode)) {
         fprintf(stderr, "share path %s is not a directory\n", fse->path);
-        exit(1);
+        return -1;
     }
     v9fs_path_free(&path);
 
-    return &s->vdev;
-}
-
-VirtIODevice *virtio_9p_init(DeviceState *dev, V9fsConf *conf)
-{
-    V9fsState *s = NULL;
-    return virtio_9p_common_init(dev, conf, &s);
+    return 0;
 }
 
 /* virtio-9p device */
 
-static int virtio_9p_device_init(VirtIODevice *vdev)
-{
-    DeviceState *qdev = DEVICE(vdev);
-    V9fsState *s = VIRTIO_9P(vdev);
-    V9fsConf *fsconf = &(s->fsconf);
-    if (virtio_9p_common_init(qdev, fsconf, &s) == NULL) {
-        return -1;
-    }
-    return 0;
-}
-
 static Property virtio_9p_properties[] = {
     DEFINE_VIRTIO_9P_PROPERTIES(V9fsState, fsconf),
     DEFINE_PROP_END_OF_LIST(),
-- 
1.7.11.7

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [Qemu-devel] [PATCH v4 4/4] virtio-9p: cleanup: QOM casts.
  2013-04-23  9:08 [Qemu-devel] [PATCH v4 0/4] virtio-9p refactoring fred.konrad
                   ` (2 preceding siblings ...)
  2013-04-23  9:08 ` [Qemu-devel] [PATCH v4 3/4] virtio-9p: cleanup: init function fred.konrad
@ 2013-04-23  9:08 ` fred.konrad
  2013-04-24 18:24 ` [Qemu-devel] [PATCH v4 0/4] virtio-9p refactoring Anthony Liguori
  4 siblings, 0 replies; 6+ messages in thread
From: fred.konrad @ 2013-04-23  9:08 UTC (permalink / raw)
  To: qemu-devel, aliguori
  Cc: peter.maydell, mark.burton, Aneesh Kumar K.V, fred.konrad

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

As the virtio-9p-pci is switched to the new API, we can use QOM casts.

Signed-off-by: KONRAD Frederic <fred.konrad@greensocs.com>
---
 hw/9pfs/virtio-9p-device.c | 11 +++--------
 hw/9pfs/virtio-9p.c        |  2 +-
 hw/9pfs/virtio-9p.h        |  2 +-
 3 files changed, 5 insertions(+), 10 deletions(-)

diff --git a/hw/9pfs/virtio-9p-device.c b/hw/9pfs/virtio-9p-device.c
index 29a639e..62a291b 100644
--- a/hw/9pfs/virtio-9p-device.c
+++ b/hw/9pfs/virtio-9p-device.c
@@ -26,16 +26,11 @@ static uint32_t virtio_9p_get_features(VirtIODevice *vdev, uint32_t features)
     return features;
 }
 
-static V9fsState *to_virtio_9p(VirtIODevice *vdev)
-{
-    return (V9fsState *)vdev;
-}
-
 static void virtio_9p_get_config(VirtIODevice *vdev, uint8_t *config)
 {
     int len;
     struct virtio_9p_config *cfg;
-    V9fsState *s = to_virtio_9p(vdev);
+    V9fsState *s = VIRTIO_9P(vdev);
 
     len = strlen(s->tag);
     cfg = g_malloc0(sizeof(struct virtio_9p_config) + len);
@@ -97,9 +92,9 @@ static int virtio_9p_device_init(VirtIODevice *vdev)
     s->ctx.uid = -1;
 
     s->ops = fse->ops;
-    s->vdev.get_features = virtio_9p_get_features;
+    vdev->get_features = virtio_9p_get_features;
     s->config_size = sizeof(struct virtio_9p_config) + len;
-    s->vdev.get_config = virtio_9p_get_config;
+    vdev->get_config = virtio_9p_get_config;
     s->fid_list = NULL;
     qemu_co_rwlock_init(&s->rename_lock);
 
diff --git a/hw/9pfs/virtio-9p.c b/hw/9pfs/virtio-9p.c
index db2ae32..296f66f 100644
--- a/hw/9pfs/virtio-9p.c
+++ b/hw/9pfs/virtio-9p.c
@@ -631,7 +631,7 @@ static void complete_pdu(V9fsState *s, V9fsPDU *pdu, ssize_t len)
     virtqueue_push(s->vq, &pdu->elem, len);
 
     /* FIXME: we should batch these completions */
-    virtio_notify(&s->vdev, s->vq);
+    virtio_notify(VIRTIO_DEVICE(s), s->vq);
 
     /* Now wakeup anybody waiting in flush for this request */
     qemu_co_queue_next(&pdu->complete);
diff --git a/hw/9pfs/virtio-9p.h b/hw/9pfs/virtio-9p.h
index e1fa506..1d6eedb 100644
--- a/hw/9pfs/virtio-9p.h
+++ b/hw/9pfs/virtio-9p.h
@@ -205,7 +205,7 @@ struct V9fsFidState
 
 typedef struct V9fsState
 {
-    VirtIODevice vdev;
+    VirtIODevice parent_obj;
     VirtQueue *vq;
     V9fsPDU pdus[MAX_REQ];
     QLIST_HEAD(, V9fsPDU) free_list;
-- 
1.7.11.7

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCH v4 0/4] virtio-9p refactoring.
  2013-04-23  9:08 [Qemu-devel] [PATCH v4 0/4] virtio-9p refactoring fred.konrad
                   ` (3 preceding siblings ...)
  2013-04-23  9:08 ` [Qemu-devel] [PATCH v4 4/4] virtio-9p: cleanup: QOM casts fred.konrad
@ 2013-04-24 18:24 ` Anthony Liguori
  4 siblings, 0 replies; 6+ messages in thread
From: Anthony Liguori @ 2013-04-24 18:24 UTC (permalink / raw)
  To: fred.konrad, qemu-devel, aliguori; +Cc: peter.maydell, mark.burton

Applied.  Thanks.

Regards,

Anthony Liguori

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2013-04-24 18:35 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-23  9:08 [Qemu-devel] [PATCH v4 0/4] virtio-9p refactoring fred.konrad
2013-04-23  9:08 ` [Qemu-devel] [PATCH v4 1/4] virtio-9p: add the virtio-9p device fred.konrad
2013-04-23  9:08 ` [Qemu-devel] [PATCH v4 2/4] virtio-9p-pci: switch to the new API fred.konrad
2013-04-23  9:08 ` [Qemu-devel] [PATCH v4 3/4] virtio-9p: cleanup: init function fred.konrad
2013-04-23  9:08 ` [Qemu-devel] [PATCH v4 4/4] virtio-9p: cleanup: QOM casts fred.konrad
2013-04-24 18:24 ` [Qemu-devel] [PATCH v4 0/4] virtio-9p refactoring Anthony Liguori

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).