From patchwork Fri Mar 1 13:33:37 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 224345 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 688CB2C0094 for ; Sat, 2 Mar 2013 00:39:58 +1100 (EST) Received: from localhost ([::1]:42190 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UBQBo-0002bP-Hb for incoming@patchwork.ozlabs.org; Fri, 01 Mar 2013 08:39:56 -0500 Received: from eggs.gnu.org ([208.118.235.92]:40658) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UBQ6J-0003IX-EW for qemu-devel@nongnu.org; Fri, 01 Mar 2013 08:34:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UBQ6E-0007Oa-2R for qemu-devel@nongnu.org; Fri, 01 Mar 2013 08:34:15 -0500 Received: from mail-qa0-f46.google.com ([209.85.216.46]:50054) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UBQ6D-0007OT-SS for qemu-devel@nongnu.org; Fri, 01 Mar 2013 08:34:09 -0500 Received: by mail-qa0-f46.google.com with SMTP id o13so5015395qaj.12 for ; Fri, 01 Mar 2013 05:34:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:sender:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references; bh=lxHptylJJFjiTeg1rqsz3P+QR1BiNR51aRToS5Le9fg=; b=ZuR2Lc0v8sihUTbtXLIWHbykblwMmUH708OV/nxON1bGv96jvkyZbKqZ6/okWfSCaE zIvrXODL6ONsT4fJh129HF5/FMXNPC13K48QsAyGjiDCLq34/4tMG9JAXcjZZAbqKns0 fmG2knQaH01j/KOvlpmyH/bk/zLi3/9gH5Q2KgQ1pMn/t7cElgDEU7P+Nfu/B40jfmXl prvwu50YdnI5mtgT0H2Cjgc8PatOSK18CPZIzfGK7Ln4nqI1OWW82UzhaRhakhQe/fFm F36nVmeJtG9hTsqeRNrPNoZ9GEwRGqgS2s8hahpcqbBGvEjM51VLkoXqv0SX3WKlUt5Z 0toA== X-Received: by 10.49.84.104 with SMTP id x8mr18259887qey.5.1362144849208; Fri, 01 Mar 2013 05:34:09 -0800 (PST) Received: from yakj.usersys.redhat.com (93-34-176-20.ip50.fastwebnet.it. [93.34.176.20]) by mx.google.com with ESMTPS id hr1sm19338754qeb.3.2013.03.01.05.34.07 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 01 Mar 2013 05:34:08 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 1 Mar 2013 14:33:37 +0100 Message-Id: <1362144829-26979-7-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <1362144829-26979-1-git-send-email-pbonzini@redhat.com> References: <1362144829-26979-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 209.85.216.46 Cc: peter.maydell@linaro.org, afaerber@suse.de Subject: [Qemu-devel] [PATCH 06/18] virtio-9p: remove PCI dependencies from hw/9pfs/ 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 Also move the 9p.h file to 9pfs/virtio-9p-device.h, for consistency with the corresponding .c file. Signed-off-by: Paolo Bonzini --- hw/9pfs/virtio-9p-device.c | 53 +----------------------------------- hw/{9p.h => 9pfs/virtio-9p-device.h} | 4 +-- hw/9pfs/virtio-9p.c | 3 +- hw/9pfs/virtio-9p.h | 1 - hw/virtio-pci.c | 50 +++++++++++++++++++++++++++++++++- hw/virtio-pci.h | 2 +- hw/virtio.h | 2 +- 7 files changed, 55 insertions(+), 60 deletions(-) rename hw/{9p.h => 9pfs/virtio-9p-device.h} (85%) diff --git a/hw/9pfs/virtio-9p-device.c b/hw/9pfs/virtio-9p-device.c index 74155fb..d321c80 100644 --- a/hw/9pfs/virtio-9p-device.c +++ b/hw/9pfs/virtio-9p-device.c @@ -14,9 +14,9 @@ #include "hw/virtio.h" #include "hw/pc.h" #include "qemu/sockets.h" -#include "hw/virtio-pci.h" #include "virtio-9p.h" #include "fsdev/qemu-fsdev.h" +#include "virtio-9p-device.h" #include "virtio-9p-xattr.h" #include "virtio-9p-coth.h" @@ -136,54 +136,3 @@ VirtIODevice *virtio_9p_init(DeviceState *dev, V9fsConf *conf) return &s->vdev; } - -static int virtio_9p_init_pci(PCIDevice *pci_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; - return 0; -} - -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_PROP_END_OF_LIST(), -}; - -static void virtio_9p_class_init(ObjectClass *klass, void *data) -{ - DeviceClass *dc = DEVICE_CLASS(klass); - PCIDeviceClass *k = PCI_DEVICE_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; -} - -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_register_types(void) -{ - type_register_static(&virtio_9p_info); - virtio_9p_set_fd_limit(); -} - -type_init(virtio_9p_register_types) diff --git a/hw/9p.h b/hw/9pfs/virtio-9p-device.h similarity index 85% rename from hw/9p.h rename to hw/9pfs/virtio-9p-device.h index d9951d6..65789db 100644 --- a/hw/9p.h +++ b/hw/9pfs/virtio-9p-device.h @@ -11,8 +11,8 @@ * */ -#ifndef QEMU_9P_H -#define QEMU_9P_H +#ifndef QEMU_VIRTIO_9P_DEVICE_H +#define QEMU_VIRTIO_9P_DEVICE_H typedef struct V9fsConf { diff --git a/hw/9pfs/virtio-9p.c b/hw/9pfs/virtio-9p.c index d3ea820..5cc4c92 100644 --- a/hw/9pfs/virtio-9p.c +++ b/hw/9pfs/virtio-9p.c @@ -14,7 +14,6 @@ #include "hw/virtio.h" #include "hw/pc.h" #include "qemu/sockets.h" -#include "hw/virtio-pci.h" #include "virtio-9p.h" #include "fsdev/qemu-fsdev.h" #include "virtio-9p-xattr.h" @@ -3269,7 +3268,7 @@ void handle_9p_output(VirtIODevice *vdev, VirtQueue *vq) free_pdu(s, pdu); } -void virtio_9p_set_fd_limit(void) +static void __attribute__((__constructor__)) virtio_9p_set_fd_limit(void) { struct rlimit rlim; if (getrlimit(RLIMIT_NOFILE, &rlim) < 0) { diff --git a/hw/9pfs/virtio-9p.h b/hw/9pfs/virtio-9p.h index 406fe52..52b1c69 100644 --- a/hw/9pfs/virtio-9p.h +++ b/hw/9pfs/virtio-9p.h @@ -389,7 +389,6 @@ static inline uint8_t v9fs_request_cancelled(V9fsPDU *pdu) } extern void handle_9p_output(VirtIODevice *vdev, VirtQueue *vq); -extern void virtio_9p_set_fd_limit(void); extern void v9fs_reclaim_fd(V9fsPDU *pdu); extern void v9fs_path_init(V9fsPath *path); extern void v9fs_path_free(V9fsPath *path); diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c index a869f53..df1dd77 100644 --- a/hw/virtio-pci.c +++ b/hw/virtio-pci.c @@ -255,7 +255,7 @@ static void virtio_pci_stop_ioeventfd(VirtIOPCIProxy *proxy) proxy->ioeventfd_started = false; } -void virtio_pci_reset(DeviceState *d) +static void virtio_pci_reset(DeviceState *d) { VirtIOPCIProxy *proxy = to_virtio_pci_proxy(d); virtio_pci_stop_ioeventfd(proxy); @@ -1313,6 +1313,51 @@ static const TypeInfo virtio_scsi_info = { .class_init = virtio_scsi_class_init, }; +#ifdef CONFIG_VIRTFS +static int virtio_9p_init_pci(PCIDevice *pci_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; + return 0; +} + +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_PROP_END_OF_LIST(), +}; + +static void virtio_9p_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc = DEVICE_CLASS(klass); + PCIDeviceClass *k = PCI_DEVICE_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; +} + +static const TypeInfo virtio_9p_info = { + .name = "virtio-9p-pci", + .parent = TYPE_PCI_DEVICE, + .instance_size = sizeof(VirtIOPCIProxy), + .class_init = virtio_9p_class_init, +}; +#endif + /* * virtio-pci: This is the PCIDevice which has a virtio-pci-bus. */ @@ -1475,6 +1520,9 @@ static void virtio_pci_register_types(void) type_register_static(&virtio_rng_info); type_register_static(&virtio_pci_bus_info); type_register_static(&virtio_pci_info); +#ifdef CONFIG_VIRTFS + type_register_static(&virtio_9p_info); +#endif } type_init(virtio_pci_register_types) diff --git a/hw/virtio-pci.h b/hw/virtio-pci.h index e775525..d01db97 100644 --- a/hw/virtio-pci.h +++ b/hw/virtio-pci.h @@ -22,6 +22,7 @@ #include "virtio-serial.h" #include "virtio-scsi.h" #include "virtio-bus.h" +#include "9pfs/virtio-9p-device.h" typedef struct VirtIOPCIProxy VirtIOPCIProxy; @@ -90,7 +91,6 @@ struct VirtIOPCIProxy { }; void virtio_init_pci(VirtIOPCIProxy *proxy, VirtIODevice *vdev); -void virtio_pci_reset(DeviceState *d); void virtio_pci_bus_new(VirtioBusState *bus, VirtIOPCIProxy *dev); /* Virtio ABI version, if we increment this, we break the guest driver. */ diff --git a/hw/virtio.h b/hw/virtio.h index ae43d25..8cc71e9 100644 --- a/hw/virtio.h +++ b/hw/virtio.h @@ -20,7 +20,7 @@ #include "sysemu/sysemu.h" #include "qemu/event_notifier.h" #ifdef CONFIG_VIRTFS -#include "9p.h" +#include "9pfs/virtio-9p-device.h" #endif /* from Linux's linux/virtio_config.h */