diff mbox

[4/9] virtio-9p: remove PCI dependencies from hw/9pfs/

Message ID 1322138308-31040-5-git-send-email-pbonzini@redhat.com
State New
Headers show

Commit Message

Paolo Bonzini Nov. 24, 2011, 12:38 p.m. UTC
Also move the 9p.h file to 9pfs/virtio-9p-device.h, for consistency
with the corresponding .c file.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/9pfs/virtio-9p-device.c           |   35 +---------------------------------
 hw/{9p.h => 9pfs/virtio-9p-device.h} |    4 +-
 hw/9pfs/virtio-9p.c                  |    1 -
 hw/virtio-pci.c                      |   35 ++++++++++++++++++++++++++++++++++
 hw/virtio-pci.h                      |    1 +
 hw/virtio.h                          |    2 +-
 6 files changed, 40 insertions(+), 38 deletions(-)
 rename hw/{9p.h => 9pfs/virtio-9p-device.h} (85%)

Comments

Michael S. Tsirkin Nov. 28, 2011, 6:46 p.m. UTC | #1
On Thu, Nov 24, 2011 at 01:38:23PM +0100, Paolo Bonzini wrote:
> Also move the 9p.h file to 9pfs/virtio-9p-device.h, for consistency
> with the corresponding .c file.
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---

...

> diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c
> index d5cdc04..78c1790 100644
> --- a/hw/virtio-pci.c
> +++ b/hw/virtio-pci.c
> @@ -779,6 +779,21 @@ static int virtio_balloon_exit_pci(PCIDevice *pci_dev)
>      return virtio_exit_pci(pci_dev);
>  }
>  
> +#ifdef CONFIG_LINUX
> +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;
> +}
> +#endif
> +

This ifdef looks wrong to me - is there no way 9p can thinkably
work on non-linux hosts? If yes, we should have a separate config
entry for 9p, configure script can make it
conditional on linux host.
Paolo Bonzini Nov. 29, 2011, 8:38 a.m. UTC | #2
On 11/28/2011 07:46 PM, Michael S. Tsirkin wrote:
>> >  +#ifdef CONFIG_LINUX
>> >  +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;
>> >  +}
>> >  +#endif
>> >  +
> This ifdef looks wrong to me - is there no way 9p can thinkably
> work on non-linux hosts? If yes, we should have a separate config
> entry for 9p, configure script can make it
> conditional on linux host.

I think it was true in the beginning, but more recent versions should 
only depend on CONFIG_POSIX.  I will set up FreeBSD and come back.

Paolo
Michael S. Tsirkin Nov. 29, 2011, 1:12 p.m. UTC | #3
On Tue, Nov 29, 2011 at 09:38:43AM +0100, Paolo Bonzini wrote:
> On 11/28/2011 07:46 PM, Michael S. Tsirkin wrote:
> >>>  +#ifdef CONFIG_LINUX
> >>>  +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;
> >>>  +}
> >>>  +#endif
> >>>  +
> >This ifdef looks wrong to me - is there no way 9p can thinkably
> >work on non-linux hosts? If yes, we should have a separate config
> >entry for 9p, configure script can make it
> >conditional on linux host.
> 
> I think it was true in the beginning, but more recent versions
> should only depend on CONFIG_POSIX.  I will set up FreeBSD and come
> back.
> 
> Paolo

It might be easier to add CONFIG_VIRTIO_9P. That won't hurt in any case.
Paolo Bonzini Jan. 1, 2012, 9:45 p.m. UTC | #4
On 11/29/2011 02:12 PM, Michael S. Tsirkin wrote:
> On Tue, Nov 29, 2011 at 09:38:43AM +0100, Paolo Bonzini wrote:
>> On 11/28/2011 07:46 PM, Michael S. Tsirkin wrote:
>>>>>   +#ifdef CONFIG_LINUX
>>>>>   +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;
>>>>>   +}
>>>>>   +#endif
>>>>>   +
>>> This ifdef looks wrong to me - is there no way 9p can thinkably
>>> work on non-linux hosts? If yes, we should have a separate config
>>> entry for 9p, configure script can make it
>>> conditional on linux host.
>>
>> I think it was true in the beginning, but more recent versions
>> should only depend on CONFIG_POSIX.  I will set up FreeBSD and come
>> back.
>>
>> Paolo
>
> It might be easier to add CONFIG_VIRTIO_9P. That won't hurt in any case.

Actually CONFIG_VIRTFS exists already (Linux dependencies are mostly 
statfs and d_off in struct dirent, plus extended attributes which are 
checked separately).

Will resend.

Paolo
diff mbox

Patch

diff --git a/hw/9pfs/virtio-9p-device.c b/hw/9pfs/virtio-9p-device.c
index bba4c54..509faa8 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_socket.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"
 
@@ -147,41 +147,8 @@  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 PCIDeviceInfo virtio_9p_info = {
-    .qdev.name = "virtio-9p-pci",
-    .qdev.size = sizeof(VirtIOPCIProxy),
-    .init      = virtio_9p_init_pci,
-    .vendor_id = PCI_VENDOR_ID_REDHAT_QUMRANET,
-    .device_id = 0x1009,
-    .revision  = VIRTIO_PCI_ABI_VERSION,
-    .class_id  = 0x2,
-    .qdev.props = (Property[]) {
-        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_register_devices(void)
 {
-    pci_qdev_register(&virtio_9p_info);
     virtio_9p_set_fd_limit();
 }
 
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 1b2fc5d..7b786e5 100644
--- a/hw/9pfs/virtio-9p.c
+++ b/hw/9pfs/virtio-9p.c
@@ -17,7 +17,6 @@ 
 #include "hw/virtio.h"
 #include "hw/pc.h"
 #include "qemu_socket.h"
-#include "hw/virtio-pci.h"
 #include "virtio-9p.h"
 #include "fsdev/qemu-fsdev.h"
 #include "virtio-9p-xattr.h"
diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c
index d5cdc04..78c1790 100644
--- a/hw/virtio-pci.c
+++ b/hw/virtio-pci.c
@@ -779,6 +779,21 @@  static int virtio_balloon_exit_pci(PCIDevice *pci_dev)
     return virtio_exit_pci(pci_dev);
 }
 
+#ifdef CONFIG_LINUX
+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;
+}
+#endif
+
 static PCIDeviceInfo virtio_info[] = {
     {
         .qdev.name = "virtio-blk-pci",
@@ -855,6 +870,26 @@  static PCIDeviceInfo virtio_info[] = {
             DEFINE_PROP_END_OF_LIST(),
         },
         .qdev.reset = virtio_pci_reset,
+#ifdef CONFIG_LINUX
+    }, {
+        .qdev.name = "virtio-9p-pci",
+        .qdev.size = sizeof(VirtIOPCIProxy),
+        .init      = virtio_9p_init_pci,
+        .vendor_id = PCI_VENDOR_ID_REDHAT_QUMRANET,
+        .device_id = 0x1009,
+        .revision  = VIRTIO_PCI_ABI_VERSION,
+        .class_id  = 0x2,
+        .qdev.props = (Property[]) {
+            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(),
+        },
+        .qdev.reset = virtio_pci_reset,
+#endif
     },{
         /* end of list */
     }
diff --git a/hw/virtio-pci.h b/hw/virtio-pci.h
index 4126705..7654c84 100644
--- a/hw/virtio-pci.h
+++ b/hw/virtio-pci.h
@@ -17,6 +17,7 @@ 
 
 #include "virtio-net.h"
 #include "virtio-serial.h"
+#include "9pfs/virtio-9p-device.h"
 
 /* Performance improves when virtqueue kick processing is decoupled from the
  * vcpu thread using ioeventfd for some devices. */
diff --git a/hw/virtio.h b/hw/virtio.h
index 7303b6c..9ed8dfc 100644
--- a/hw/virtio.h
+++ b/hw/virtio.h
@@ -21,7 +21,7 @@ 
 #include "block.h"
 #include "event_notifier.h"
 #ifdef CONFIG_LINUX
-#include "9p.h"
+#include "9pfs/virtio-9p-device.h"
 #endif
 
 /* from Linux's linux/virtio_config.h */