From patchwork Tue Jan 15 14:09:56 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: fred.konrad@greensocs.com X-Patchwork-Id: 212186 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 54E362C00A7 for ; Wed, 16 Jan 2013 01:35:05 +1100 (EST) Received: from localhost ([::1]:41633 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tv7bT-0003wj-FX for incoming@patchwork.ozlabs.org; Tue, 15 Jan 2013 09:35:03 -0500 Received: from eggs.gnu.org ([208.118.235.92]:53277) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tv7bH-0003w0-V8 for qemu-devel@nongnu.org; Tue, 15 Jan 2013 09:34:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Tv7EV-0001T0-Ka for qemu-devel@nongnu.org; Tue, 15 Jan 2013 09:12:35 -0500 Received: from greensocs.com ([87.106.252.221]:60607 helo=s15328186.onlinehome-server.info) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tv7EV-0001Si-7g for qemu-devel@nongnu.org; Tue, 15 Jan 2013 09:11:19 -0500 Received: from localhost (unknown [127.0.0.1]) by s15328186.onlinehome-server.info (Postfix) with ESMTP id 62ECF440FF0; Tue, 15 Jan 2013 14:11:18 +0000 (UTC) Received: from s15328186.onlinehome-server.info ([127.0.0.1]) by localhost (s15328186.onlinehome-server.info [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id nRFmaa5vw0t2; Tue, 15 Jan 2013 15:11:17 +0100 (CET) Received: by s15328186.onlinehome-server.info (Postfix, from userid 491) id 95F5E440FEF; Tue, 15 Jan 2013 15:11:16 +0100 (CET) Received: from compaq.katmai.xl.cx.katmai.xl.cx (lan31-11-83-155-143-136.fbx.proxad.net [83.155.143.136]) by s15328186.onlinehome-server.info (Postfix) with ESMTPSA id 94F09440FD4; Tue, 15 Jan 2013 15:11:14 +0100 (CET) From: fred.konrad@greensocs.com To: qemu-devel@nongnu.org, aliguori@us.ibm.com Date: Tue, 15 Jan 2013 15:09:56 +0100 Message-Id: <1358258998-6504-43-git-send-email-fred.konrad@greensocs.com> X-Mailer: git-send-email 1.7.11.7 In-Reply-To: <1358258998-6504-1-git-send-email-fred.konrad@greensocs.com> References: <1358258998-6504-1-git-send-email-fred.konrad@greensocs.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 87.106.252.221 Cc: kwolf@redhat.com, peter.maydell@linaro.org, e.voevodin@samsung.com, mst@redhat.com, mark.burton@greensocs.com, agraf@suse.de, amit.shah@redhat.com, aneesh.kumar@linux.vnet.ibm.com, stefanha@redhat.com, deepakcs@linux.vnet.ibm.com, cornelia.huck@de.ibm.com, pbonzini@redhat.com, afaerber@suse.de, fred.konrad@greensocs.com Subject: [Qemu-devel] [PATCH V3 42/44] virtio-9p-pci: switch to the new API. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: KONRAD Frederic 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 during the init. The properties are not changed. Signed-off-by: KONRAD Frederic Tested-by: Deepak C Shetty --- hw/9pfs/virtio-9p-device.c | 53 +++++++++++++++++++++++++++------------------- hw/9pfs/virtio-9p.h | 14 ++++++++++++ hw/virtio-pci.h | 3 --- 3 files changed, 45 insertions(+), 25 deletions(-) diff --git a/hw/9pfs/virtio-9p-device.c b/hw/9pfs/virtio-9p-device.c index 17e59a6..bd547ac 100644 --- a/hw/9pfs/virtio-9p-device.c +++ b/hw/9pfs/virtio-9p-device.c @@ -164,45 +164,54 @@ VirtIODevice *virtio_9p_init(DeviceState *dev, V9fsConf *conf) return virtio_9p_common_init(dev, conf, &s); } -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; - - 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; + V9fsPCIState *dev = VIRTIO_9P_PCI(vpci_dev); + DeviceState *vdev = DEVICE(&dev->vdev); + + virtio_9p_set_conf(vdev, &(dev->fsconf)); + qdev_set_parent_bus(vdev, BUS(&vpci_dev->bus)); + if (qdev_init(vdev) < 0) { + return -1; + } return 0; } static Property virtio_9p_pci_properties[] = { - DEFINE_PROP_BIT("ioeventfd", VirtIOPCIProxy, flags, VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT, true), + 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, fsconf), DEFINE_PROP_END_OF_LIST(), }; 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; + 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; - dc->reset = virtio_pci_reset; } -static const TypeInfo virtio_9p_info = { - .name = "virtio-9p-pci", - .parent = TYPE_PCI_DEVICE, - .instance_size = sizeof(VirtIOPCIProxy), +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, }; @@ -244,7 +253,7 @@ static const TypeInfo virtio_device_info = { static void virtio_9p_register_types(void) { type_register_static(&virtio_device_info); - type_register_static(&virtio_9p_info); + type_register_static(&virtio_9p_pci_info); virtio_9p_set_fd_limit(); } diff --git a/hw/9pfs/virtio-9p.h b/hw/9pfs/virtio-9p.h index 3be634f..e88e038 100644 --- a/hw/9pfs/virtio-9p.h +++ b/hw/9pfs/virtio-9p.h @@ -11,6 +11,7 @@ #include "fsdev/virtio-9p-marshal.h" #include "qemu/thread.h" #include "block/coroutine.h" +#include "hw/virtio-pci.h" /* The feature bitmap for virtio 9P */ @@ -413,4 +414,17 @@ extern int v9fs_name_to_path(V9fsState *s, V9fsPath *dirpath, void virtio_9p_set_conf(DeviceState *dev, V9fsConf *conf); +/* + * virtio-9p-pci: This extends VirtioPCIProxy. + */ +#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; + V9fsConf fsconf; +} V9fsPCIState; + #endif diff --git a/hw/virtio-pci.h b/hw/virtio-pci.h index 04c51c5..95dc93b 100644 --- a/hw/virtio-pci.h +++ b/hw/virtio-pci.h @@ -80,9 +80,6 @@ struct VirtIOPCIProxy { uint32_t class_code; uint32_t nvectors; uint32_t host_features; -#ifdef CONFIG_LINUX - V9fsConf fsconf; -#endif bool ioeventfd_disabled; bool ioeventfd_started; VirtIOIRQFD *vector_irqfd;