All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] virtio-9p: move 9p files around
@ 2011-04-27  6:53 Aneesh Kumar K.V
  2011-04-27  7:03 ` Jan Kiszka
  0 siblings, 1 reply; 11+ messages in thread
From: Aneesh Kumar K.V @ 2011-04-27  6:53 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori, Aneesh Kumar K.V

Now that we start adding more files related to 9pfs
it make sense to move them to a separate directory

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
---
 Makefile.objs                        |   10 +++++++---
 Makefile.target                      |    6 ++++--
 configure                            |    2 ++
 {hw => fsdev}/file-op-9p.h           |    0
 fsdev/qemu-fsdev.h                   |    2 +-
 hw/{ => 9pfs}/virtio-9p-debug.c      |    0
 hw/{ => 9pfs}/virtio-9p-debug.h      |    0
 hw/{ => 9pfs}/virtio-9p-local.c      |    0
 hw/{ => 9pfs}/virtio-9p-posix-acl.c  |    2 +-
 hw/{ => 9pfs}/virtio-9p-xattr-user.c |    2 +-
 hw/{ => 9pfs}/virtio-9p-xattr.c      |    2 +-
 hw/{ => 9pfs}/virtio-9p-xattr.h      |    0
 hw/{ => 9pfs}/virtio-9p.c            |    0
 hw/{ => 9pfs}/virtio-9p.h            |    2 +-
 14 files changed, 18 insertions(+), 10 deletions(-)
 rename {hw => fsdev}/file-op-9p.h (100%)
 rename hw/{ => 9pfs}/virtio-9p-debug.c (100%)
 rename hw/{ => 9pfs}/virtio-9p-debug.h (100%)
 rename hw/{ => 9pfs}/virtio-9p-local.c (100%)
 rename hw/{ => 9pfs}/virtio-9p-posix-acl.c (99%)
 rename hw/{ => 9pfs}/virtio-9p-xattr-user.c (98%)
 rename hw/{ => 9pfs}/virtio-9p-xattr.c (99%)
 rename hw/{ => 9pfs}/virtio-9p-xattr.h (100%)
 rename hw/{ => 9pfs}/virtio-9p.c (100%)
 rename hw/{ => 9pfs}/virtio-9p.h (99%)

diff --git a/Makefile.objs b/Makefile.objs
index 93406ff..2eb6db5 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -276,9 +276,13 @@ sound-obj-$(CONFIG_HDA) += intel-hda.o hda-audio.o
 adlib.o fmopl.o: QEMU_CFLAGS += -DBUILD_Y8950=0
 hw-obj-$(CONFIG_SOUND) += $(sound-obj-y)
 
-hw-obj-$(CONFIG_REALLY_VIRTFS) += virtio-9p-debug.o
-hw-obj-$(CONFIG_VIRTFS) += virtio-9p-local.o virtio-9p-xattr.o
-hw-obj-$(CONFIG_VIRTFS) += virtio-9p-xattr-user.o virtio-9p-posix-acl.o
+9pfs-nested-$(CONFIG_VIRTFS) = virtio-9p-debug.o
+9pfs-nested-$(CONFIG_VIRTFS) +=  virtio-9p-local.o virtio-9p-xattr.o
+9pfs-nested-$(CONFIG_VIRTFS) +=   virtio-9p-xattr-user.o virtio-9p-posix-acl.o
+
+hw-obj-$(CONFIG_REALLY_VIRTFS) += $(addprefix 9pfs/, $(9pfs-nested-y))
+$(addprefix 9pfs/, $(9pfs-nested-y)): CFLAGS +=  -I$(SRC_PATH)/hw/
+
 
 ######################################################################
 # libdis
diff --git a/Makefile.target b/Makefile.target
index b0ba95f..46f5075 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -194,7 +194,7 @@ obj-$(CONFIG_VIRTIO) += virtio-blk.o virtio-balloon.o virtio-net.o virtio-serial
 obj-$(CONFIG_VIRTIO_PCI) += virtio-pci.o
 obj-y += vhost_net.o
 obj-$(CONFIG_VHOST_NET) += vhost.o
-obj-$(CONFIG_REALLY_VIRTFS) += virtio-9p.o
+obj-$(CONFIG_REALLY_VIRTFS) += 9pfs/virtio-9p.o
 obj-y += rwhandler.o
 obj-$(CONFIG_KVM) += kvm.o kvm-all.o
 obj-$(CONFIG_NO_KVM) += kvm-stub.o
@@ -356,9 +356,11 @@ hmp-commands.h: $(SRC_PATH)/hmp-commands.hx
 qmp-commands.h: $(SRC_PATH)/qmp-commands.hx
 	$(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -h < $< > $@,"  GEN   $(TARGET_DIR)$@")
 
+9pfs/virtio-9p.o: CFLAGS +=  -I$(SRC_PATH)/hw/
+
 clean:
 	rm -f *.o *.a *~ $(PROGS) nwfpe/*.o fpu/*.o
-	rm -f *.d */*.d tcg/*.o ide/*.o
+	rm -f *.d */*.d tcg/*.o ide/*.o 9pfs/*.o
 	rm -f hmp-commands.h qmp-commands.h gdbstub-xml.c
 ifdef CONFIG_SYSTEMTAP_TRACE
 	rm -f *.stp
diff --git a/configure b/configure
index 210670c..ceff93a 100755
--- a/configure
+++ b/configure
@@ -2872,6 +2872,7 @@ mkdir -p $target_dir
 mkdir -p $target_dir/fpu
 mkdir -p $target_dir/tcg
 mkdir -p $target_dir/ide
+mkdir -p $target_dir/9pfs
 if test "$target" = "arm-linux-user" -o "$target" = "armeb-linux-user" -o "$target" = "arm-bsd-user" -o "$target" = "armeb-bsd-user" ; then
   mkdir -p $target_dir/nwfpe
 fi
@@ -3262,6 +3263,7 @@ for hwlib in 32 64; do
   mkdir -p $d
   mkdir -p $d/ide
   symlink $source_path/Makefile.hw $d/Makefile
+  mkdir -p $d/9pfs
   echo "QEMU_CFLAGS+=-DTARGET_PHYS_ADDR_BITS=$hwlib" > $d/config.mak
 done
 
diff --git a/hw/file-op-9p.h b/fsdev/file-op-9p.h
similarity index 100%
rename from hw/file-op-9p.h
rename to fsdev/file-op-9p.h
diff --git a/fsdev/qemu-fsdev.h b/fsdev/qemu-fsdev.h
index a704043..f9f08d3 100644
--- a/fsdev/qemu-fsdev.h
+++ b/fsdev/qemu-fsdev.h
@@ -13,7 +13,7 @@
 #ifndef QEMU_FSDEV_H
 #define QEMU_FSDEV_H
 #include "qemu-option.h"
-#include "hw/file-op-9p.h"
+#include "file-op-9p.h"
 
 
 /*
diff --git a/hw/virtio-9p-debug.c b/hw/9pfs/virtio-9p-debug.c
similarity index 100%
rename from hw/virtio-9p-debug.c
rename to hw/9pfs/virtio-9p-debug.c
diff --git a/hw/virtio-9p-debug.h b/hw/9pfs/virtio-9p-debug.h
similarity index 100%
rename from hw/virtio-9p-debug.h
rename to hw/9pfs/virtio-9p-debug.h
diff --git a/hw/virtio-9p-local.c b/hw/9pfs/virtio-9p-local.c
similarity index 100%
rename from hw/virtio-9p-local.c
rename to hw/9pfs/virtio-9p-local.c
diff --git a/hw/virtio-9p-posix-acl.c b/hw/9pfs/virtio-9p-posix-acl.c
similarity index 99%
rename from hw/virtio-9p-posix-acl.c
rename to hw/9pfs/virtio-9p-posix-acl.c
index 3978d0c..e4e0777 100644
--- a/hw/virtio-9p-posix-acl.c
+++ b/hw/9pfs/virtio-9p-posix-acl.c
@@ -15,7 +15,7 @@
 #include <attr/xattr.h>
 #include "virtio.h"
 #include "virtio-9p.h"
-#include "file-op-9p.h"
+#include "fsdev/file-op-9p.h"
 #include "virtio-9p-xattr.h"
 
 #define MAP_ACL_ACCESS "user.virtfs.system.posix_acl_access"
diff --git a/hw/virtio-9p-xattr-user.c b/hw/9pfs/virtio-9p-xattr-user.c
similarity index 98%
rename from hw/virtio-9p-xattr-user.c
rename to hw/9pfs/virtio-9p-xattr-user.c
index faa02a1..bba13ce 100644
--- a/hw/virtio-9p-xattr-user.c
+++ b/hw/9pfs/virtio-9p-xattr-user.c
@@ -14,7 +14,7 @@
 #include <sys/types.h>
 #include "virtio.h"
 #include "virtio-9p.h"
-#include "file-op-9p.h"
+#include "fsdev/file-op-9p.h"
 #include "virtio-9p-xattr.h"
 
 
diff --git a/hw/virtio-9p-xattr.c b/hw/9pfs/virtio-9p-xattr.c
similarity index 99%
rename from hw/virtio-9p-xattr.c
rename to hw/9pfs/virtio-9p-xattr.c
index 1aab081..03c3d3f 100644
--- a/hw/virtio-9p-xattr.c
+++ b/hw/9pfs/virtio-9p-xattr.c
@@ -13,7 +13,7 @@
 
 #include "virtio.h"
 #include "virtio-9p.h"
-#include "file-op-9p.h"
+#include "fsdev/file-op-9p.h"
 #include "virtio-9p-xattr.h"
 
 
diff --git a/hw/virtio-9p-xattr.h b/hw/9pfs/virtio-9p-xattr.h
similarity index 100%
rename from hw/virtio-9p-xattr.h
rename to hw/9pfs/virtio-9p-xattr.h
diff --git a/hw/virtio-9p.c b/hw/9pfs/virtio-9p.c
similarity index 100%
rename from hw/virtio-9p.c
rename to hw/9pfs/virtio-9p.c
diff --git a/hw/virtio-9p.h b/hw/9pfs/virtio-9p.h
similarity index 99%
rename from hw/virtio-9p.h
rename to hw/9pfs/virtio-9p.h
index 2ae4ce7..95e4977 100644
--- a/hw/virtio-9p.h
+++ b/hw/9pfs/virtio-9p.h
@@ -6,7 +6,7 @@
 #include <sys/time.h>
 #include <utime.h>
 
-#include "file-op-9p.h"
+#include "fsdev/file-op-9p.h"
 
 /* The feature bitmap for virtio 9P */
 /* The mount point is specified in a config variable */
-- 
1.7.4.1

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

* Re: [Qemu-devel] [PATCH] virtio-9p: move 9p files around
  2011-04-27  6:53 [Qemu-devel] [PATCH] virtio-9p: move 9p files around Aneesh Kumar K.V
@ 2011-04-27  7:03 ` Jan Kiszka
  2011-04-27 10:33   ` Aneesh Kumar K.V
  2011-04-27 11:46   ` [Qemu-devel] [PATCH 1/3] virtio-9p: Move 9p device registration into virtio-9p.c Aneesh Kumar K.V
  0 siblings, 2 replies; 11+ messages in thread
From: Jan Kiszka @ 2011-04-27  7:03 UTC (permalink / raw)
  To: Aneesh Kumar K.V; +Cc: aliguori, qemu-devel

[-- Attachment #1: Type: text/plain, Size: 1727 bytes --]

On 2011-04-27 08:53, Aneesh Kumar K.V wrote:
> Now that we start adding more files related to 9pfs
> it make sense to move them to a separate directory
> 
> Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
> ---
>  Makefile.objs                        |   10 +++++++---
>  Makefile.target                      |    6 ++++--
>  configure                            |    2 ++
>  {hw => fsdev}/file-op-9p.h           |    0
>  fsdev/qemu-fsdev.h                   |    2 +-
>  hw/{ => 9pfs}/virtio-9p-debug.c      |    0
>  hw/{ => 9pfs}/virtio-9p-debug.h      |    0
>  hw/{ => 9pfs}/virtio-9p-local.c      |    0
>  hw/{ => 9pfs}/virtio-9p-posix-acl.c  |    2 +-
>  hw/{ => 9pfs}/virtio-9p-xattr-user.c |    2 +-
>  hw/{ => 9pfs}/virtio-9p-xattr.c      |    2 +-
>  hw/{ => 9pfs}/virtio-9p-xattr.h      |    0
>  hw/{ => 9pfs}/virtio-9p.c            |    0
>  hw/{ => 9pfs}/virtio-9p.h            |    2 +-
>  14 files changed, 18 insertions(+), 10 deletions(-)
>  rename {hw => fsdev}/file-op-9p.h (100%)
>  rename hw/{ => 9pfs}/virtio-9p-debug.c (100%)
>  rename hw/{ => 9pfs}/virtio-9p-debug.h (100%)
>  rename hw/{ => 9pfs}/virtio-9p-local.c (100%)
>  rename hw/{ => 9pfs}/virtio-9p-posix-acl.c (99%)
>  rename hw/{ => 9pfs}/virtio-9p-xattr-user.c (98%)
>  rename hw/{ => 9pfs}/virtio-9p-xattr.c (99%)
>  rename hw/{ => 9pfs}/virtio-9p-xattr.h (100%)
>  rename hw/{ => 9pfs}/virtio-9p.c (100%)

That's a good chance to split up this file, move virtio_9p_get_config
into a separate one and build the large virtio-9p.c as part of hwlib
while keeping the new file target-specific. I've some hack for this
lying around, but now that you are already at it...

Thanks,
Jan


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 259 bytes --]

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

* Re: [Qemu-devel] [PATCH] virtio-9p: move 9p files around
  2011-04-27  7:03 ` Jan Kiszka
@ 2011-04-27 10:33   ` Aneesh Kumar K.V
  2011-04-27 14:55     ` Jan Kiszka
  2011-04-27 15:57     ` Venkateswararao Jujjuri
  2011-04-27 11:46   ` [Qemu-devel] [PATCH 1/3] virtio-9p: Move 9p device registration into virtio-9p.c Aneesh Kumar K.V
  1 sibling, 2 replies; 11+ messages in thread
From: Aneesh Kumar K.V @ 2011-04-27 10:33 UTC (permalink / raw)
  To: Jan Kiszka; +Cc: aliguori, qemu-devel

On Wed, 27 Apr 2011 09:03:56 +0200, Jan Kiszka <jan.kiszka@web.de> wrote:
> On 2011-04-27 08:53, Aneesh Kumar K.V wrote:
> > Now that we start adding more files related to 9pfs
> > it make sense to move them to a separate directory
> > 
> > Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
> > ---
> >  Makefile.objs                        |   10 +++++++---
> >  Makefile.target                      |    6 ++++--
> >  configure                            |    2 ++
> >  {hw => fsdev}/file-op-9p.h           |    0
> >  fsdev/qemu-fsdev.h                   |    2 +-
> >  hw/{ => 9pfs}/virtio-9p-debug.c      |    0
> >  hw/{ => 9pfs}/virtio-9p-debug.h      |    0
> >  hw/{ => 9pfs}/virtio-9p-local.c      |    0
> >  hw/{ => 9pfs}/virtio-9p-posix-acl.c  |    2 +-
> >  hw/{ => 9pfs}/virtio-9p-xattr-user.c |    2 +-
> >  hw/{ => 9pfs}/virtio-9p-xattr.c      |    2 +-
> >  hw/{ => 9pfs}/virtio-9p-xattr.h      |    0
> >  hw/{ => 9pfs}/virtio-9p.c            |    0
> >  hw/{ => 9pfs}/virtio-9p.h            |    2 +-
> >  14 files changed, 18 insertions(+), 10 deletions(-)
> >  rename {hw => fsdev}/file-op-9p.h (100%)
> >  rename hw/{ => 9pfs}/virtio-9p-debug.c (100%)
> >  rename hw/{ => 9pfs}/virtio-9p-debug.h (100%)
> >  rename hw/{ => 9pfs}/virtio-9p-local.c (100%)
> >  rename hw/{ => 9pfs}/virtio-9p-posix-acl.c (99%)
> >  rename hw/{ => 9pfs}/virtio-9p-xattr-user.c (98%)
> >  rename hw/{ => 9pfs}/virtio-9p-xattr.c (99%)
> >  rename hw/{ => 9pfs}/virtio-9p-xattr.h (100%)
> >  rename hw/{ => 9pfs}/virtio-9p.c (100%)
> 
> That's a good chance to split up this file, move virtio_9p_get_config
> into a separate one and build the large virtio-9p.c as part of hwlib
> while keeping the new file target-specific. I've some hack for this
> lying around, but now that you are already at it...
> 

How about doing the below patch also and move all those device specific
stuff to virtio-9p-device.c and rest in virtio-9p.c ?

commit 9de1857114dac1dcd0c6399d91036c279373b2d0
Author: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Date:   Thu Oct 21 13:50:05 2010 +0530

    virtio-9p: Move 9p device registration into virtio-9p.c
    
    This patch move the 9p device registration into its own file
    
    Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>

diff --git a/hw/virtio-9p.c b/hw/virtio-9p.c
index daade77..11e87a3 100644
--- a/hw/virtio-9p.c
+++ b/hw/virtio-9p.c
@@ -14,6 +14,7 @@
 #include "virtio.h"
 #include "pc.h"
 #include "qemu_socket.h"
+#include "virtio-pci.h"
 #include "virtio-9p.h"
 #include "fsdev/qemu-fsdev.h"
 #include "virtio-9p-debug.h"
@@ -3741,3 +3742,37 @@ 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);
+    virtio_init_pci(proxy, vdev,
+                    PCI_VENDOR_ID_REDHAT_QUMRANET,
+                    0x1009,
+                    0x2,
+                    0x00);
+
+    return 0;
+}
+
+static PCIDeviceInfo virtio_9p_info = {
+        .qdev.name = "virtio-9p-pci",
+        .qdev.size = sizeof(VirtIOPCIProxy),
+        .init      = virtio_9p_init_pci,
+        .qdev.props = (Property[]) {
+            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);
+}
+
+device_init(virtio_9p_register_devices)
diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c
index 729917d..f1377b1 100644
--- a/hw/virtio-pci.c
+++ b/hw/virtio-pci.c
@@ -25,6 +25,7 @@
 #include "loader.h"
 #include "kvm.h"
 #include "blockdev.h"
+#include "virtio-pci.h"
 
 /* from Linux's linux/virtio_pci.h */
 
@@ -90,26 +91,6 @@
  */
 #define wmb() do { } while (0)
 
-/* PCI bindings.  */
-
-typedef struct {
-    PCIDevice pci_dev;
-    VirtIODevice *vdev;
-    uint32_t bugs;
-    uint32_t addr;
-    uint32_t class_code;
-    uint32_t nvectors;
-    BlockConf block;
-    NICConf nic;
-    uint32_t host_features;
-#ifdef CONFIG_LINUX
-    V9fsConf fsconf;
-#endif
-    /* Max. number of ports we can have for a the virtio-serial device */
-    uint32_t max_virtserial_ports;
-    virtio_net_conf net;
-} VirtIOPCIProxy;
-
 /* virtio device */
 
 static void virtio_pci_notify(void *opaque, uint16_t vector)
@@ -518,7 +499,7 @@ static const VirtIOBindings virtio_pci_bindings = {
     .set_guest_notifiers = virtio_pci_set_guest_notifiers,
 };
 
-static void virtio_init_pci(VirtIOPCIProxy *proxy, VirtIODevice *vdev,
+void virtio_init_pci(VirtIOPCIProxy *proxy, VirtIODevice *vdev,
                             uint16_t vendor, uint16_t device,
                             uint16_t class_code, uint8_t pif)
 {
@@ -677,23 +658,6 @@ static int virtio_balloon_init_pci(PCIDevice *pci_dev)
     return 0;
 }
 
-#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);
-    virtio_init_pci(proxy, vdev,
-                    PCI_VENDOR_ID_REDHAT_QUMRANET,
-                    0x1009,
-                    0x2,
-                    0x00);
-
-    return 0;
-}
-#endif
-
 static PCIDeviceInfo virtio_info[] = {
     {
         .qdev.name = "virtio-blk-pci",
@@ -752,20 +716,7 @@ static PCIDeviceInfo virtio_info[] = {
             DEFINE_PROP_END_OF_LIST(),
         },
         .qdev.reset = virtio_pci_reset,
-    },{
-#ifdef CONFIG_VIRTFS
-        .qdev.name = "virtio-9p-pci",
-        .qdev.size = sizeof(VirtIOPCIProxy),
-        .init      = virtio_9p_init_pci,
-        .qdev.props = (Property[]) {
-            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(),
-        },
-    }, {
-#endif
-        /* end of list */
+    }, {         /* end of list */
     }
 };
 
diff --git a/hw/virtio-pci.h b/hw/virtio-pci.h
new file mode 100644
index 0000000..d9bf683
--- /dev/null
+++ b/hw/virtio-pci.h
@@ -0,0 +1,42 @@
+/*
+ * Virtio PCI Bindings
+ *
+ * Copyright IBM, Corp. 2007
+ * Copyright (c) 2009 CodeSourcery
+ *
+ * Authors:
+ *  Anthony Liguori   <aliguori@us.ibm.com>
+ *  Paul Brook        <paul@codesourcery.com>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2.  See
+ * the COPYING file in the top-level directory.
+ */
+
+#ifndef QEMU_VIRTIO_PCI_H
+#define QEMU_VIRTIO_PCI_H
+
+#include "virtio-net.h"
+
+typedef struct {
+    PCIDevice pci_dev;
+    VirtIODevice *vdev;
+    uint32_t bugs;
+    uint32_t addr;
+    uint32_t class_code;
+    uint32_t nvectors;
+    BlockConf block;
+    NICConf nic;
+    uint32_t host_features;
+#ifdef CONFIG_LINUX
+    V9fsConf fsconf;
+#endif
+    /* Max. number of ports we can have for a the virtio-serial device */
+    uint32_t max_virtserial_ports;
+    virtio_net_conf net;
+} VirtIOPCIProxy;
+
+extern void virtio_init_pci(VirtIOPCIProxy *proxy, VirtIODevice *vdev,
+                            uint16_t vendor, uint16_t device,
+                            uint16_t class_code, uint8_t pif);
+
+#endif

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

* [Qemu-devel] [PATCH 1/3] virtio-9p: Move 9p device registration into virtio-9p.c
  2011-04-27  7:03 ` Jan Kiszka
  2011-04-27 10:33   ` Aneesh Kumar K.V
@ 2011-04-27 11:46   ` Aneesh Kumar K.V
  2011-04-27 11:46     ` [Qemu-devel] [PATCH 2/3] virtio-9p: move 9p files around Aneesh Kumar K.V
                       ` (2 more replies)
  1 sibling, 3 replies; 11+ messages in thread
From: Aneesh Kumar K.V @ 2011-04-27 11:46 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori, Aneesh Kumar K.V

This patch move the 9p device registration into its own file

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
---
 hw/virtio-9p.c  |   38 ++++++++++++++++++++++++++++++++++++
 hw/virtio-pci.c |   57 +-----------------------------------------------------
 hw/virtio-pci.h |   43 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 83 insertions(+), 55 deletions(-)
 create mode 100644 hw/virtio-pci.h

diff --git a/hw/virtio-9p.c b/hw/virtio-9p.c
index 7c59988..64ab3c8 100644
--- a/hw/virtio-9p.c
+++ b/hw/virtio-9p.c
@@ -14,6 +14,7 @@
 #include "virtio.h"
 #include "pc.h"
 #include "qemu_socket.h"
+#include "virtio-pci.h"
 #include "virtio-9p.h"
 #include "fsdev/qemu-fsdev.h"
 #include "virtio-9p-debug.h"
@@ -3742,3 +3743,40 @@ 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,
+                    PCI_VENDOR_ID_REDHAT_QUMRANET,
+                    0x1009,
+                    0x2,
+                    0x00);
+    /* 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,
+    .qdev.props = (Property[]) {
+        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);
+}
+
+device_init(virtio_9p_register_devices)
diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c
index d07ff97..59c75de 100644
--- a/hw/virtio-pci.c
+++ b/hw/virtio-pci.c
@@ -25,6 +25,7 @@
 #include "loader.h"
 #include "kvm.h"
 #include "blockdev.h"
+#include "virtio-pci.h"
 
 /* from Linux's linux/virtio_pci.h */
 
@@ -94,28 +95,6 @@
  */
 #define wmb() do { } while (0)
 
-/* PCI bindings.  */
-
-typedef struct {
-    PCIDevice pci_dev;
-    VirtIODevice *vdev;
-    uint32_t flags;
-    uint32_t addr;
-    uint32_t class_code;
-    uint32_t nvectors;
-    BlockConf block;
-    NICConf nic;
-    uint32_t host_features;
-#ifdef CONFIG_LINUX
-    V9fsConf fsconf;
-#endif
-    /* Max. number of ports we can have for a the virtio-serial device */
-    uint32_t max_virtserial_ports;
-    virtio_net_conf net;
-    bool ioeventfd_disabled;
-    bool ioeventfd_started;
-} VirtIOPCIProxy;
-
 /* virtio device */
 
 static void virtio_pci_notify(void *opaque, uint16_t vector)
@@ -663,7 +642,7 @@ static const VirtIOBindings virtio_pci_bindings = {
     .vmstate_change = virtio_pci_vmstate_change,
 };
 
-static void virtio_init_pci(VirtIOPCIProxy *proxy, VirtIODevice *vdev,
+void virtio_init_pci(VirtIOPCIProxy *proxy, VirtIODevice *vdev,
                             uint16_t vendor, uint16_t device,
                             uint16_t class_code, uint8_t pif)
 {
@@ -828,25 +807,6 @@ static int virtio_balloon_init_pci(PCIDevice *pci_dev)
     return 0;
 }
 
-#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,
-                    PCI_VENDOR_ID_REDHAT_QUMRANET,
-                    0x1009,
-                    0x2,
-                    0x00);
-    /* make the actual value visible */
-    proxy->nvectors = vdev->nvectors;
-    return 0;
-}
-#endif
-
 static PCIDeviceInfo virtio_info[] = {
     {
         .qdev.name = "virtio-blk-pci",
@@ -911,19 +871,6 @@ static PCIDeviceInfo virtio_info[] = {
         },
         .qdev.reset = virtio_pci_reset,
     },{
-#ifdef CONFIG_VIRTFS
-        .qdev.name = "virtio-9p-pci",
-        .qdev.size = sizeof(VirtIOPCIProxy),
-        .init      = virtio_9p_init_pci,
-        .qdev.props = (Property[]) {
-            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(),
-        },
-    }, {
-#endif
         /* end of list */
     }
 };
diff --git a/hw/virtio-pci.h b/hw/virtio-pci.h
new file mode 100644
index 0000000..3bef656
--- /dev/null
+++ b/hw/virtio-pci.h
@@ -0,0 +1,43 @@
+/*
+ * Virtio PCI Bindings
+ *
+ * Copyright IBM, Corp. 2007
+ * Copyright (c) 2009 CodeSourcery
+ *
+ * Authors:
+ *  Anthony Liguori   <aliguori@us.ibm.com>
+ *  Paul Brook        <paul@codesourcery.com>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2.  See
+ * the COPYING file in the top-level directory.
+ */
+
+#ifndef QEMU_VIRTIO_PCI_H
+#define QEMU_VIRTIO_PCI_H
+
+#include "virtio-net.h"
+
+typedef struct {
+    PCIDevice pci_dev;
+    VirtIODevice *vdev;
+    uint32_t flags;
+    uint32_t addr;
+    uint32_t class_code;
+    uint32_t nvectors;
+    BlockConf block;
+    NICConf nic;
+    uint32_t host_features;
+#ifdef CONFIG_LINUX
+    V9fsConf fsconf;
+#endif
+    /* Max. number of ports we can have for a the virtio-serial device */
+    uint32_t max_virtserial_ports;
+    virtio_net_conf net;
+    bool ioeventfd_disabled;
+    bool ioeventfd_started;
+} VirtIOPCIProxy;
+
+extern void virtio_init_pci(VirtIOPCIProxy *proxy, VirtIODevice *vdev,
+                            uint16_t vendor, uint16_t device,
+                            uint16_t class_code, uint8_t pif);
+#endif
-- 
1.7.4.1

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

* [Qemu-devel] [PATCH 2/3] virtio-9p: move 9p files around
  2011-04-27 11:46   ` [Qemu-devel] [PATCH 1/3] virtio-9p: Move 9p device registration into virtio-9p.c Aneesh Kumar K.V
@ 2011-04-27 11:46     ` Aneesh Kumar K.V
  2011-04-27 11:46     ` [Qemu-devel] [PATCH 3/3] virtio-9p: Move device specific code to virtio-9p-device Aneesh Kumar K.V
  2011-05-31 21:28     ` [Qemu-devel] [PATCH 1/3] virtio-9p: Move 9p device registration into virtio-9p.c Venkateswararao Jujjuri
  2 siblings, 0 replies; 11+ messages in thread
From: Aneesh Kumar K.V @ 2011-04-27 11:46 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori, Aneesh Kumar K.V

Now that we start adding more files related to 9pfs
it make sense to move them to a separate directory

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
---
 Makefile.objs                        |   10 +++++++---
 Makefile.target                      |    6 ++++--
 configure                            |    2 ++
 {hw => fsdev}/file-op-9p.h           |    0
 fsdev/qemu-fsdev.h                   |    2 +-
 hw/{ => 9pfs}/virtio-9p-debug.c      |    0
 hw/{ => 9pfs}/virtio-9p-debug.h      |    0
 hw/{ => 9pfs}/virtio-9p-local.c      |    0
 hw/{ => 9pfs}/virtio-9p-posix-acl.c  |    2 +-
 hw/{ => 9pfs}/virtio-9p-xattr-user.c |    2 +-
 hw/{ => 9pfs}/virtio-9p-xattr.c      |    2 +-
 hw/{ => 9pfs}/virtio-9p-xattr.h      |    0
 hw/{ => 9pfs}/virtio-9p.c            |    0
 hw/{ => 9pfs}/virtio-9p.h            |    2 +-
 14 files changed, 18 insertions(+), 10 deletions(-)
 rename {hw => fsdev}/file-op-9p.h (100%)
 rename hw/{ => 9pfs}/virtio-9p-debug.c (100%)
 rename hw/{ => 9pfs}/virtio-9p-debug.h (100%)
 rename hw/{ => 9pfs}/virtio-9p-local.c (100%)
 rename hw/{ => 9pfs}/virtio-9p-posix-acl.c (99%)
 rename hw/{ => 9pfs}/virtio-9p-xattr-user.c (98%)
 rename hw/{ => 9pfs}/virtio-9p-xattr.c (99%)
 rename hw/{ => 9pfs}/virtio-9p-xattr.h (100%)
 rename hw/{ => 9pfs}/virtio-9p.c (100%)
 rename hw/{ => 9pfs}/virtio-9p.h (99%)

diff --git a/Makefile.objs b/Makefile.objs
index 93406ff..2eb6db5 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -276,9 +276,13 @@ sound-obj-$(CONFIG_HDA) += intel-hda.o hda-audio.o
 adlib.o fmopl.o: QEMU_CFLAGS += -DBUILD_Y8950=0
 hw-obj-$(CONFIG_SOUND) += $(sound-obj-y)
 
-hw-obj-$(CONFIG_REALLY_VIRTFS) += virtio-9p-debug.o
-hw-obj-$(CONFIG_VIRTFS) += virtio-9p-local.o virtio-9p-xattr.o
-hw-obj-$(CONFIG_VIRTFS) += virtio-9p-xattr-user.o virtio-9p-posix-acl.o
+9pfs-nested-$(CONFIG_VIRTFS) = virtio-9p-debug.o
+9pfs-nested-$(CONFIG_VIRTFS) +=  virtio-9p-local.o virtio-9p-xattr.o
+9pfs-nested-$(CONFIG_VIRTFS) +=   virtio-9p-xattr-user.o virtio-9p-posix-acl.o
+
+hw-obj-$(CONFIG_REALLY_VIRTFS) += $(addprefix 9pfs/, $(9pfs-nested-y))
+$(addprefix 9pfs/, $(9pfs-nested-y)): CFLAGS +=  -I$(SRC_PATH)/hw/
+
 
 ######################################################################
 # libdis
diff --git a/Makefile.target b/Makefile.target
index b0ba95f..46f5075 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -194,7 +194,7 @@ obj-$(CONFIG_VIRTIO) += virtio-blk.o virtio-balloon.o virtio-net.o virtio-serial
 obj-$(CONFIG_VIRTIO_PCI) += virtio-pci.o
 obj-y += vhost_net.o
 obj-$(CONFIG_VHOST_NET) += vhost.o
-obj-$(CONFIG_REALLY_VIRTFS) += virtio-9p.o
+obj-$(CONFIG_REALLY_VIRTFS) += 9pfs/virtio-9p.o
 obj-y += rwhandler.o
 obj-$(CONFIG_KVM) += kvm.o kvm-all.o
 obj-$(CONFIG_NO_KVM) += kvm-stub.o
@@ -356,9 +356,11 @@ hmp-commands.h: $(SRC_PATH)/hmp-commands.hx
 qmp-commands.h: $(SRC_PATH)/qmp-commands.hx
 	$(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -h < $< > $@,"  GEN   $(TARGET_DIR)$@")
 
+9pfs/virtio-9p.o: CFLAGS +=  -I$(SRC_PATH)/hw/
+
 clean:
 	rm -f *.o *.a *~ $(PROGS) nwfpe/*.o fpu/*.o
-	rm -f *.d */*.d tcg/*.o ide/*.o
+	rm -f *.d */*.d tcg/*.o ide/*.o 9pfs/*.o
 	rm -f hmp-commands.h qmp-commands.h gdbstub-xml.c
 ifdef CONFIG_SYSTEMTAP_TRACE
 	rm -f *.stp
diff --git a/configure b/configure
index 210670c..ceff93a 100755
--- a/configure
+++ b/configure
@@ -2872,6 +2872,7 @@ mkdir -p $target_dir
 mkdir -p $target_dir/fpu
 mkdir -p $target_dir/tcg
 mkdir -p $target_dir/ide
+mkdir -p $target_dir/9pfs
 if test "$target" = "arm-linux-user" -o "$target" = "armeb-linux-user" -o "$target" = "arm-bsd-user" -o "$target" = "armeb-bsd-user" ; then
   mkdir -p $target_dir/nwfpe
 fi
@@ -3262,6 +3263,7 @@ for hwlib in 32 64; do
   mkdir -p $d
   mkdir -p $d/ide
   symlink $source_path/Makefile.hw $d/Makefile
+  mkdir -p $d/9pfs
   echo "QEMU_CFLAGS+=-DTARGET_PHYS_ADDR_BITS=$hwlib" > $d/config.mak
 done
 
diff --git a/hw/file-op-9p.h b/fsdev/file-op-9p.h
similarity index 100%
rename from hw/file-op-9p.h
rename to fsdev/file-op-9p.h
diff --git a/fsdev/qemu-fsdev.h b/fsdev/qemu-fsdev.h
index a704043..f9f08d3 100644
--- a/fsdev/qemu-fsdev.h
+++ b/fsdev/qemu-fsdev.h
@@ -13,7 +13,7 @@
 #ifndef QEMU_FSDEV_H
 #define QEMU_FSDEV_H
 #include "qemu-option.h"
-#include "hw/file-op-9p.h"
+#include "file-op-9p.h"
 
 
 /*
diff --git a/hw/virtio-9p-debug.c b/hw/9pfs/virtio-9p-debug.c
similarity index 100%
rename from hw/virtio-9p-debug.c
rename to hw/9pfs/virtio-9p-debug.c
diff --git a/hw/virtio-9p-debug.h b/hw/9pfs/virtio-9p-debug.h
similarity index 100%
rename from hw/virtio-9p-debug.h
rename to hw/9pfs/virtio-9p-debug.h
diff --git a/hw/virtio-9p-local.c b/hw/9pfs/virtio-9p-local.c
similarity index 100%
rename from hw/virtio-9p-local.c
rename to hw/9pfs/virtio-9p-local.c
diff --git a/hw/virtio-9p-posix-acl.c b/hw/9pfs/virtio-9p-posix-acl.c
similarity index 99%
rename from hw/virtio-9p-posix-acl.c
rename to hw/9pfs/virtio-9p-posix-acl.c
index 3978d0c..e4e0777 100644
--- a/hw/virtio-9p-posix-acl.c
+++ b/hw/9pfs/virtio-9p-posix-acl.c
@@ -15,7 +15,7 @@
 #include <attr/xattr.h>
 #include "virtio.h"
 #include "virtio-9p.h"
-#include "file-op-9p.h"
+#include "fsdev/file-op-9p.h"
 #include "virtio-9p-xattr.h"
 
 #define MAP_ACL_ACCESS "user.virtfs.system.posix_acl_access"
diff --git a/hw/virtio-9p-xattr-user.c b/hw/9pfs/virtio-9p-xattr-user.c
similarity index 98%
rename from hw/virtio-9p-xattr-user.c
rename to hw/9pfs/virtio-9p-xattr-user.c
index faa02a1..bba13ce 100644
--- a/hw/virtio-9p-xattr-user.c
+++ b/hw/9pfs/virtio-9p-xattr-user.c
@@ -14,7 +14,7 @@
 #include <sys/types.h>
 #include "virtio.h"
 #include "virtio-9p.h"
-#include "file-op-9p.h"
+#include "fsdev/file-op-9p.h"
 #include "virtio-9p-xattr.h"
 
 
diff --git a/hw/virtio-9p-xattr.c b/hw/9pfs/virtio-9p-xattr.c
similarity index 99%
rename from hw/virtio-9p-xattr.c
rename to hw/9pfs/virtio-9p-xattr.c
index 1aab081..03c3d3f 100644
--- a/hw/virtio-9p-xattr.c
+++ b/hw/9pfs/virtio-9p-xattr.c
@@ -13,7 +13,7 @@
 
 #include "virtio.h"
 #include "virtio-9p.h"
-#include "file-op-9p.h"
+#include "fsdev/file-op-9p.h"
 #include "virtio-9p-xattr.h"
 
 
diff --git a/hw/virtio-9p-xattr.h b/hw/9pfs/virtio-9p-xattr.h
similarity index 100%
rename from hw/virtio-9p-xattr.h
rename to hw/9pfs/virtio-9p-xattr.h
diff --git a/hw/virtio-9p.c b/hw/9pfs/virtio-9p.c
similarity index 100%
rename from hw/virtio-9p.c
rename to hw/9pfs/virtio-9p.c
diff --git a/hw/virtio-9p.h b/hw/9pfs/virtio-9p.h
similarity index 99%
rename from hw/virtio-9p.h
rename to hw/9pfs/virtio-9p.h
index 2ae4ce7..95e4977 100644
--- a/hw/virtio-9p.h
+++ b/hw/9pfs/virtio-9p.h
@@ -6,7 +6,7 @@
 #include <sys/time.h>
 #include <utime.h>
 
-#include "file-op-9p.h"
+#include "fsdev/file-op-9p.h"
 
 /* The feature bitmap for virtio 9P */
 /* The mount point is specified in a config variable */
-- 
1.7.4.1

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

* [Qemu-devel] [PATCH 3/3] virtio-9p: Move device specific code to virtio-9p-device
  2011-04-27 11:46   ` [Qemu-devel] [PATCH 1/3] virtio-9p: Move 9p device registration into virtio-9p.c Aneesh Kumar K.V
  2011-04-27 11:46     ` [Qemu-devel] [PATCH 2/3] virtio-9p: move 9p files around Aneesh Kumar K.V
@ 2011-04-27 11:46     ` Aneesh Kumar K.V
  2011-05-31 21:28     ` [Qemu-devel] [PATCH 1/3] virtio-9p: Move 9p device registration into virtio-9p.c Venkateswararao Jujjuri
  2 siblings, 0 replies; 11+ messages in thread
From: Aneesh Kumar K.V @ 2011-04-27 11:46 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori, Aneesh Kumar K.V

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
---
 Makefile.objs              |    2 +-
 Makefile.target            |    4 +-
 hw/9pfs/virtio-9p-device.c |  174 ++++++++++++++++++++++++++++++++++++++++++++
 hw/9pfs/virtio-9p.c        |  155 +---------------------------------------
 hw/9pfs/virtio-9p.h        |    2 +
 5 files changed, 180 insertions(+), 157 deletions(-)
 create mode 100644 hw/9pfs/virtio-9p-device.c

diff --git a/Makefile.objs b/Makefile.objs
index 2eb6db5..3833314 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -276,7 +276,7 @@ sound-obj-$(CONFIG_HDA) += intel-hda.o hda-audio.o
 adlib.o fmopl.o: QEMU_CFLAGS += -DBUILD_Y8950=0
 hw-obj-$(CONFIG_SOUND) += $(sound-obj-y)
 
-9pfs-nested-$(CONFIG_VIRTFS) = virtio-9p-debug.o
+9pfs-nested-$(CONFIG_VIRTFS) = virtio-9p.o virtio-9p-debug.o
 9pfs-nested-$(CONFIG_VIRTFS) +=  virtio-9p-local.o virtio-9p-xattr.o
 9pfs-nested-$(CONFIG_VIRTFS) +=   virtio-9p-xattr-user.o virtio-9p-posix-acl.o
 
diff --git a/Makefile.target b/Makefile.target
index 46f5075..b869592 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -194,7 +194,7 @@ obj-$(CONFIG_VIRTIO) += virtio-blk.o virtio-balloon.o virtio-net.o virtio-serial
 obj-$(CONFIG_VIRTIO_PCI) += virtio-pci.o
 obj-y += vhost_net.o
 obj-$(CONFIG_VHOST_NET) += vhost.o
-obj-$(CONFIG_REALLY_VIRTFS) += 9pfs/virtio-9p.o
+obj-$(CONFIG_REALLY_VIRTFS) += 9pfs/virtio-9p-device.o
 obj-y += rwhandler.o
 obj-$(CONFIG_KVM) += kvm.o kvm-all.o
 obj-$(CONFIG_NO_KVM) += kvm-stub.o
@@ -356,7 +356,7 @@ hmp-commands.h: $(SRC_PATH)/hmp-commands.hx
 qmp-commands.h: $(SRC_PATH)/qmp-commands.hx
 	$(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -h < $< > $@,"  GEN   $(TARGET_DIR)$@")
 
-9pfs/virtio-9p.o: CFLAGS +=  -I$(SRC_PATH)/hw/
+9pfs/virtio-9p-device.o: CFLAGS +=  -I$(SRC_PATH)/hw/
 
 clean:
 	rm -f *.o *.a *~ $(PROGS) nwfpe/*.o fpu/*.o
diff --git a/hw/9pfs/virtio-9p-device.c b/hw/9pfs/virtio-9p-device.c
new file mode 100644
index 0000000..df05288
--- /dev/null
+++ b/hw/9pfs/virtio-9p-device.c
@@ -0,0 +1,174 @@
+/*
+ * Virtio 9p backend
+ *
+ * Copyright IBM, Corp. 2010
+ *
+ * Authors:
+ *  Anthony Liguori   <aliguori@us.ibm.com>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2.  See
+ * the COPYING file in the top-level directory.
+ *
+ */
+
+#include "virtio.h"
+#include "pc.h"
+#include "qemu_socket.h"
+#include "virtio-pci.h"
+#include "virtio-9p.h"
+#include "fsdev/qemu-fsdev.h"
+#include "virtio-9p-xattr.h"
+
+static uint32_t virtio_9p_get_features(VirtIODevice *vdev, uint32_t features)
+{
+    features |= 1 << VIRTIO_9P_MOUNT_TAG;
+    return features;
+}
+
+static V9fsState *to_virtio_9p(VirtIODevice *vdev)
+{
+    return (V9fsState *)vdev;
+}
+
+static void virtio_9p_get_config(VirtIODevice *vdev, uint8_t *config)
+{
+    struct virtio_9p_config *cfg;
+    V9fsState *s = to_virtio_9p(vdev);
+
+    cfg = qemu_mallocz(sizeof(struct virtio_9p_config) +
+                        s->tag_len);
+    stw_raw(&cfg->tag_len, s->tag_len);
+    memcpy(cfg->tag, s->tag, s->tag_len);
+    memcpy(config, cfg, s->config_size);
+    qemu_free(cfg);
+}
+
+VirtIODevice *virtio_9p_init(DeviceState *dev, V9fsConf *conf)
+ {
+    V9fsState *s;
+    int i, len;
+    struct stat stat;
+    FsTypeEntry *fse;
+
+
+    s = (V9fsState *)virtio_common_init("virtio-9p",
+                                    VIRTIO_ID_9P,
+                                    sizeof(struct virtio_9p_config)+
+                                    MAX_TAG_LEN,
+                                    sizeof(V9fsState));
+
+    /* initialize pdu allocator */
+    QLIST_INIT(&s->free_list);
+    for (i = 0; i < (MAX_REQ - 1); i++) {
+        QLIST_INSERT_HEAD(&s->free_list, &s->pdus[i], next);
+    }
+
+    s->vq = virtio_add_queue(&s->vdev, MAX_REQ, handle_9p_output);
+
+    fse = get_fsdev_fsentry(conf->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);
+    }
+
+    if (!fse->path || !conf->tag) {
+        /* we haven't specified a mount_tag or the path */
+        fprintf(stderr, "fsdev with id %s needs path "
+                "and Virtio-9p device needs mount_tag arguments\n",
+                conf->fsdev_id);
+        exit(1);
+    }
+
+    if (!strcmp(fse->security_model, "passthrough")) {
+        /* Files on the Fileserver set to client user credentials */
+        s->ctx.fs_sm = SM_PASSTHROUGH;
+        s->ctx.xops = passthrough_xattr_ops;
+    } else if (!strcmp(fse->security_model, "mapped")) {
+        /* Files on the fileserver are set to QEMU credentials.
+         * Client user credentials are saved in extended attributes.
+         */
+        s->ctx.fs_sm = SM_MAPPED;
+        s->ctx.xops = mapped_xattr_ops;
+    } else if (!strcmp(fse->security_model, "none")) {
+        /*
+         * Files on the fileserver are set to QEMU credentials.
+         */
+        s->ctx.fs_sm = SM_NONE;
+        s->ctx.xops = none_xattr_ops;
+    } else {
+        fprintf(stderr, "Default to security_model=none. You may want"
+                " enable advanced security model using "
+                "security option:\n\t security_model=passthrough\n\t "
+                "security_model=mapped\n");
+        s->ctx.fs_sm = SM_NONE;
+        s->ctx.xops = none_xattr_ops;
+    }
+
+    if (lstat(fse->path, &stat)) {
+        fprintf(stderr, "share path %s does not exist\n", fse->path);
+        exit(1);
+    } else if (!S_ISDIR(stat.st_mode)) {
+        fprintf(stderr, "share path %s is not a directory\n", fse->path);
+        exit(1);
+    }
+
+    s->ctx.fs_root = qemu_strdup(fse->path);
+    len = strlen(conf->tag);
+    if (len > MAX_TAG_LEN) {
+        len = MAX_TAG_LEN;
+    }
+    /* s->tag is non-NULL terminated string */
+    s->tag = qemu_malloc(len);
+    memcpy(s->tag, conf->tag, len);
+    s->tag_len = len;
+    s->ctx.uid = -1;
+
+    s->ops = fse->ops;
+    s->vdev.get_features = virtio_9p_get_features;
+    s->config_size = sizeof(struct virtio_9p_config) +
+                        s->tag_len;
+    s->vdev.get_config = virtio_9p_get_config;
+
+    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,
+                    PCI_VENDOR_ID_REDHAT_QUMRANET,
+                    0x1009,
+                    0x2,
+                    0x00);
+    /* 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,
+    .qdev.props = (Property[]) {
+        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);
+}
+
+device_init(virtio_9p_register_devices)
+
diff --git a/hw/9pfs/virtio-9p.c b/hw/9pfs/virtio-9p.c
index 64ab3c8..bd6819d 100644
--- a/hw/9pfs/virtio-9p.c
+++ b/hw/9pfs/virtio-9p.c
@@ -3603,7 +3603,7 @@ static void submit_pdu(V9fsState *s, V9fsPDU *pdu)
     handler(s, pdu);
 }
 
-static void handle_9p_output(VirtIODevice *vdev, VirtQueue *vq)
+void handle_9p_output(VirtIODevice *vdev, VirtQueue *vq)
 {
     V9fsState *s = (V9fsState *)vdev;
     V9fsPDU *pdu;
@@ -3627,156 +3627,3 @@ static void handle_9p_output(VirtIODevice *vdev, VirtQueue *vq)
 
     free_pdu(s, pdu);
 }
-
-static uint32_t virtio_9p_get_features(VirtIODevice *vdev, uint32_t features)
-{
-    features |= 1 << VIRTIO_9P_MOUNT_TAG;
-    return features;
-}
-
-static V9fsState *to_virtio_9p(VirtIODevice *vdev)
-{
-    return (V9fsState *)vdev;
-}
-
-static void virtio_9p_get_config(VirtIODevice *vdev, uint8_t *config)
-{
-    struct virtio_9p_config *cfg;
-    V9fsState *s = to_virtio_9p(vdev);
-
-    cfg = qemu_mallocz(sizeof(struct virtio_9p_config) +
-                        s->tag_len);
-    stw_raw(&cfg->tag_len, s->tag_len);
-    memcpy(cfg->tag, s->tag, s->tag_len);
-    memcpy(config, cfg, s->config_size);
-    qemu_free(cfg);
-}
-
-VirtIODevice *virtio_9p_init(DeviceState *dev, V9fsConf *conf)
- {
-    V9fsState *s;
-    int i, len;
-    struct stat stat;
-    FsTypeEntry *fse;
-
-
-    s = (V9fsState *)virtio_common_init("virtio-9p",
-                                    VIRTIO_ID_9P,
-                                    sizeof(struct virtio_9p_config)+
-                                    MAX_TAG_LEN,
-                                    sizeof(V9fsState));
-
-    /* initialize pdu allocator */
-    QLIST_INIT(&s->free_list);
-    for (i = 0; i < (MAX_REQ - 1); i++) {
-	QLIST_INSERT_HEAD(&s->free_list, &s->pdus[i], next);
-    }
-
-    s->vq = virtio_add_queue(&s->vdev, MAX_REQ, handle_9p_output);
-
-    fse = get_fsdev_fsentry(conf->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);
-    }
-
-    if (!fse->path || !conf->tag) {
-        /* we haven't specified a mount_tag or the path */
-        fprintf(stderr, "fsdev with id %s needs path "
-                "and Virtio-9p device needs mount_tag arguments\n",
-                conf->fsdev_id);
-        exit(1);
-    }
-
-    if (!strcmp(fse->security_model, "passthrough")) {
-        /* Files on the Fileserver set to client user credentials */
-        s->ctx.fs_sm = SM_PASSTHROUGH;
-        s->ctx.xops = passthrough_xattr_ops;
-    } else if (!strcmp(fse->security_model, "mapped")) {
-        /* Files on the fileserver are set to QEMU credentials.
-         * Client user credentials are saved in extended attributes.
-         */
-        s->ctx.fs_sm = SM_MAPPED;
-        s->ctx.xops = mapped_xattr_ops;
-    } else if (!strcmp(fse->security_model, "none")) {
-        /*
-         * Files on the fileserver are set to QEMU credentials.
-         */
-        s->ctx.fs_sm = SM_NONE;
-        s->ctx.xops = none_xattr_ops;
-    } else {
-        fprintf(stderr, "Default to security_model=none. You may want"
-                " enable advanced security model using "
-                "security option:\n\t security_model=passthrough \n\t "
-                "security_model=mapped\n");
-        s->ctx.fs_sm = SM_NONE;
-        s->ctx.xops = none_xattr_ops;
-    }
-
-    if (lstat(fse->path, &stat)) {
-        fprintf(stderr, "share path %s does not exist\n", fse->path);
-        exit(1);
-    } else if (!S_ISDIR(stat.st_mode)) {
-        fprintf(stderr, "share path %s is not a directory \n", fse->path);
-        exit(1);
-    }
-
-    s->ctx.fs_root = qemu_strdup(fse->path);
-    len = strlen(conf->tag);
-    if (len > MAX_TAG_LEN) {
-        len = MAX_TAG_LEN;
-    }
-    /* s->tag is non-NULL terminated string */
-    s->tag = qemu_malloc(len);
-    memcpy(s->tag, conf->tag, len);
-    s->tag_len = len;
-    s->ctx.uid = -1;
-
-    s->ops = fse->ops;
-    s->vdev.get_features = virtio_9p_get_features;
-    s->config_size = sizeof(struct virtio_9p_config) +
-                        s->tag_len;
-    s->vdev.get_config = virtio_9p_get_config;
-
-    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,
-                    PCI_VENDOR_ID_REDHAT_QUMRANET,
-                    0x1009,
-                    0x2,
-                    0x00);
-    /* 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,
-    .qdev.props = (Property[]) {
-        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);
-}
-
-device_init(virtio_9p_register_devices)
diff --git a/hw/9pfs/virtio-9p.h b/hw/9pfs/virtio-9p.h
index 95e4977..ef5b66b 100644
--- a/hw/9pfs/virtio-9p.h
+++ b/hw/9pfs/virtio-9p.h
@@ -504,4 +504,6 @@ static inline size_t do_pdu_unpack(void *dst, struct iovec *sg, int sg_count,
     return pdu_packunpack(dst, sg, sg_count, offset, size, 0);
 }
 
+extern void handle_9p_output(VirtIODevice *vdev, VirtQueue *vq);
+
 #endif
-- 
1.7.4.1

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

* Re: [Qemu-devel] [PATCH] virtio-9p: move 9p files around
  2011-04-27 10:33   ` Aneesh Kumar K.V
@ 2011-04-27 14:55     ` Jan Kiszka
  2011-04-27 15:57     ` Venkateswararao Jujjuri
  1 sibling, 0 replies; 11+ messages in thread
From: Jan Kiszka @ 2011-04-27 14:55 UTC (permalink / raw)
  To: Aneesh Kumar K.V; +Cc: aliguori, qemu-devel

On 2011-04-27 12:33, Aneesh Kumar K.V wrote:
> On Wed, 27 Apr 2011 09:03:56 +0200, Jan Kiszka <jan.kiszka@web.de> wrote:
>> On 2011-04-27 08:53, Aneesh Kumar K.V wrote:
>>> Now that we start adding more files related to 9pfs
>>> it make sense to move them to a separate directory
>>>
>>> Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
>>> ---
>>>  Makefile.objs                        |   10 +++++++---
>>>  Makefile.target                      |    6 ++++--
>>>  configure                            |    2 ++
>>>  {hw => fsdev}/file-op-9p.h           |    0
>>>  fsdev/qemu-fsdev.h                   |    2 +-
>>>  hw/{ => 9pfs}/virtio-9p-debug.c      |    0
>>>  hw/{ => 9pfs}/virtio-9p-debug.h      |    0
>>>  hw/{ => 9pfs}/virtio-9p-local.c      |    0
>>>  hw/{ => 9pfs}/virtio-9p-posix-acl.c  |    2 +-
>>>  hw/{ => 9pfs}/virtio-9p-xattr-user.c |    2 +-
>>>  hw/{ => 9pfs}/virtio-9p-xattr.c      |    2 +-
>>>  hw/{ => 9pfs}/virtio-9p-xattr.h      |    0
>>>  hw/{ => 9pfs}/virtio-9p.c            |    0
>>>  hw/{ => 9pfs}/virtio-9p.h            |    2 +-
>>>  14 files changed, 18 insertions(+), 10 deletions(-)
>>>  rename {hw => fsdev}/file-op-9p.h (100%)
>>>  rename hw/{ => 9pfs}/virtio-9p-debug.c (100%)
>>>  rename hw/{ => 9pfs}/virtio-9p-debug.h (100%)
>>>  rename hw/{ => 9pfs}/virtio-9p-local.c (100%)
>>>  rename hw/{ => 9pfs}/virtio-9p-posix-acl.c (99%)
>>>  rename hw/{ => 9pfs}/virtio-9p-xattr-user.c (98%)
>>>  rename hw/{ => 9pfs}/virtio-9p-xattr.c (99%)
>>>  rename hw/{ => 9pfs}/virtio-9p-xattr.h (100%)
>>>  rename hw/{ => 9pfs}/virtio-9p.c (100%)
>>
>> That's a good chance to split up this file, move virtio_9p_get_config
>> into a separate one and build the large virtio-9p.c as part of hwlib
>> while keeping the new file target-specific. I've some hack for this
>> lying around, but now that you are already at it...
>>
> 
> How about doing the below patch also and move all those device specific
> stuff to virtio-9p-device.c and rest in virtio-9p.c ?

Looks ok. Removing #ifdefs is generally welcome.

Jan

-- 
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux

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

* Re: [Qemu-devel] [PATCH] virtio-9p: move 9p files around
  2011-04-27 10:33   ` Aneesh Kumar K.V
  2011-04-27 14:55     ` Jan Kiszka
@ 2011-04-27 15:57     ` Venkateswararao Jujjuri
  2011-04-27 16:31       ` Aneesh Kumar K.V
  1 sibling, 1 reply; 11+ messages in thread
From: Venkateswararao Jujjuri @ 2011-04-27 15:57 UTC (permalink / raw)
  To: qemu-devel

On 04/27/2011 03:33 AM, Aneesh Kumar K.V wrote:
> On Wed, 27 Apr 2011 09:03:56 +0200, Jan Kiszka<jan.kiszka@web.de>  wrote:
>> On 2011-04-27 08:53, Aneesh Kumar K.V wrote:
>>> Now that we start adding more files related to 9pfs
>>> it make sense to move them to a separate directory
>>>
>>> Signed-off-by: Aneesh Kumar K.V<aneesh.kumar@linux.vnet.ibm.com>
>>> ---
>>>   Makefile.objs                        |   10 +++++++---
>>>   Makefile.target                      |    6 ++++--
>>>   configure                            |    2 ++
>>>   {hw =>  fsdev}/file-op-9p.h           |    0
>>>   fsdev/qemu-fsdev.h                   |    2 +-
>>>   hw/{ =>  9pfs}/virtio-9p-debug.c      |    0
>>>   hw/{ =>  9pfs}/virtio-9p-debug.h      |    0
>>>   hw/{ =>  9pfs}/virtio-9p-local.c      |    0
>>>   hw/{ =>  9pfs}/virtio-9p-posix-acl.c  |    2 +-
>>>   hw/{ =>  9pfs}/virtio-9p-xattr-user.c |    2 +-
>>>   hw/{ =>  9pfs}/virtio-9p-xattr.c      |    2 +-
>>>   hw/{ =>  9pfs}/virtio-9p-xattr.h      |    0
>>>   hw/{ =>  9pfs}/virtio-9p.c            |    0
>>>   hw/{ =>  9pfs}/virtio-9p.h            |    2 +-
>>>   14 files changed, 18 insertions(+), 10 deletions(-)
>>>   rename {hw =>  fsdev}/file-op-9p.h (100%)
>>>   rename hw/{ =>  9pfs}/virtio-9p-debug.c (100%)
>>>   rename hw/{ =>  9pfs}/virtio-9p-debug.h (100%)
>>>   rename hw/{ =>  9pfs}/virtio-9p-local.c (100%)
>>>   rename hw/{ =>  9pfs}/virtio-9p-posix-acl.c (99%)
>>>   rename hw/{ =>  9pfs}/virtio-9p-xattr-user.c (98%)
>>>   rename hw/{ =>  9pfs}/virtio-9p-xattr.c (99%)
>>>   rename hw/{ =>  9pfs}/virtio-9p-xattr.h (100%)
>>>   rename hw/{ =>  9pfs}/virtio-9p.c (100%)
>> That's a good chance to split up this file, move virtio_9p_get_config
>> into a separate one and build the large virtio-9p.c as part of hwlib
>> while keeping the new file target-specific. I've some hack for this
>> lying around, but now that you are already at it...
>>
> How about doing the below patch also and move all those device specific
> stuff to virtio-9p-device.c and rest in virtio-9p.c ?
I think this goes on top of your old patch. I am ready to give pull to 
Anthony with old patch.
May be this can go in next pull?

Thanks,
JV

> commit 9de1857114dac1dcd0c6399d91036c279373b2d0
> Author: Aneesh Kumar K.V<aneesh.kumar@linux.vnet.ibm.com>
> Date:   Thu Oct 21 13:50:05 2010 +0530
>
>      virtio-9p: Move 9p device registration into virtio-9p.c
>
>      This patch move the 9p device registration into its own file
>
>      Signed-off-by: Aneesh Kumar K.V<aneesh.kumar@linux.vnet.ibm.com>
>
> diff --git a/hw/virtio-9p.c b/hw/virtio-9p.c
> index daade77..11e87a3 100644
> --- a/hw/virtio-9p.c
> +++ b/hw/virtio-9p.c
> @@ -14,6 +14,7 @@
>   #include "virtio.h"
>   #include "pc.h"
>   #include "qemu_socket.h"
> +#include "virtio-pci.h"
>   #include "virtio-9p.h"
>   #include "fsdev/qemu-fsdev.h"
>   #include "virtio-9p-debug.h"
> @@ -3741,3 +3742,37 @@ 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);
> +    virtio_init_pci(proxy, vdev,
> +                    PCI_VENDOR_ID_REDHAT_QUMRANET,
> +                    0x1009,
> +                    0x2,
> +                    0x00);
> +
> +    return 0;
> +}
> +
> +static PCIDeviceInfo virtio_9p_info = {
> +        .qdev.name = "virtio-9p-pci",
> +        .qdev.size = sizeof(VirtIOPCIProxy),
> +        .init      = virtio_9p_init_pci,
> +        .qdev.props = (Property[]) {
> +            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);
> +}
> +
> +device_init(virtio_9p_register_devices)
> diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c
> index 729917d..f1377b1 100644
> --- a/hw/virtio-pci.c
> +++ b/hw/virtio-pci.c
> @@ -25,6 +25,7 @@
>   #include "loader.h"
>   #include "kvm.h"
>   #include "blockdev.h"
> +#include "virtio-pci.h"
>
>   /* from Linux's linux/virtio_pci.h */
>
> @@ -90,26 +91,6 @@
>    */
>   #define wmb() do { } while (0)
>
> -/* PCI bindings.  */
> -
> -typedef struct {
> -    PCIDevice pci_dev;
> -    VirtIODevice *vdev;
> -    uint32_t bugs;
> -    uint32_t addr;
> -    uint32_t class_code;
> -    uint32_t nvectors;
> -    BlockConf block;
> -    NICConf nic;
> -    uint32_t host_features;
> -#ifdef CONFIG_LINUX
> -    V9fsConf fsconf;
> -#endif
> -    /* Max. number of ports we can have for a the virtio-serial device */
> -    uint32_t max_virtserial_ports;
> -    virtio_net_conf net;
> -} VirtIOPCIProxy;
> -
>   /* virtio device */
>
>   static void virtio_pci_notify(void *opaque, uint16_t vector)
> @@ -518,7 +499,7 @@ static const VirtIOBindings virtio_pci_bindings = {
>       .set_guest_notifiers = virtio_pci_set_guest_notifiers,
>   };
>
> -static void virtio_init_pci(VirtIOPCIProxy *proxy, VirtIODevice *vdev,
> +void virtio_init_pci(VirtIOPCIProxy *proxy, VirtIODevice *vdev,
>                               uint16_t vendor, uint16_t device,
>                               uint16_t class_code, uint8_t pif)
>   {
> @@ -677,23 +658,6 @@ static int virtio_balloon_init_pci(PCIDevice *pci_dev)
>       return 0;
>   }
>
> -#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);
> -    virtio_init_pci(proxy, vdev,
> -                    PCI_VENDOR_ID_REDHAT_QUMRANET,
> -                    0x1009,
> -                    0x2,
> -                    0x00);
> -
> -    return 0;
> -}
> -#endif
> -
>   static PCIDeviceInfo virtio_info[] = {
>       {
>           .qdev.name = "virtio-blk-pci",
> @@ -752,20 +716,7 @@ static PCIDeviceInfo virtio_info[] = {
>               DEFINE_PROP_END_OF_LIST(),
>           },
>           .qdev.reset = virtio_pci_reset,
> -    },{
> -#ifdef CONFIG_VIRTFS
> -        .qdev.name = "virtio-9p-pci",
> -        .qdev.size = sizeof(VirtIOPCIProxy),
> -        .init      = virtio_9p_init_pci,
> -        .qdev.props = (Property[]) {
> -            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(),
> -        },
> -    }, {
> -#endif
> -        /* end of list */
> +    }, {         /* end of list */
>       }
>   };
>
> diff --git a/hw/virtio-pci.h b/hw/virtio-pci.h
> new file mode 100644
> index 0000000..d9bf683
> --- /dev/null
> +++ b/hw/virtio-pci.h
> @@ -0,0 +1,42 @@
> +/*
> + * Virtio PCI Bindings
> + *
> + * Copyright IBM, Corp. 2007
> + * Copyright (c) 2009 CodeSourcery
> + *
> + * Authors:
> + *  Anthony Liguori<aliguori@us.ibm.com>
> + *  Paul Brook<paul@codesourcery.com>
> + *
> + * This work is licensed under the terms of the GNU GPL, version 2.  See
> + * the COPYING file in the top-level directory.
> + */
> +
> +#ifndef QEMU_VIRTIO_PCI_H
> +#define QEMU_VIRTIO_PCI_H
> +
> +#include "virtio-net.h"
> +
> +typedef struct {
> +    PCIDevice pci_dev;
> +    VirtIODevice *vdev;
> +    uint32_t bugs;
> +    uint32_t addr;
> +    uint32_t class_code;
> +    uint32_t nvectors;
> +    BlockConf block;
> +    NICConf nic;
> +    uint32_t host_features;
> +#ifdef CONFIG_LINUX
> +    V9fsConf fsconf;
> +#endif
> +    /* Max. number of ports we can have for a the virtio-serial device */
> +    uint32_t max_virtserial_ports;
> +    virtio_net_conf net;
> +} VirtIOPCIProxy;
> +
> +extern void virtio_init_pci(VirtIOPCIProxy *proxy, VirtIODevice *vdev,
> +                            uint16_t vendor, uint16_t device,
> +                            uint16_t class_code, uint8_t pif);
> +
> +#endif
>

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

* Re: [Qemu-devel] [PATCH] virtio-9p: move 9p files around
  2011-04-27 15:57     ` Venkateswararao Jujjuri
@ 2011-04-27 16:31       ` Aneesh Kumar K.V
  0 siblings, 0 replies; 11+ messages in thread
From: Aneesh Kumar K.V @ 2011-04-27 16:31 UTC (permalink / raw)
  To: Venkateswararao Jujjuri, qemu-devel

On Wed, 27 Apr 2011 08:57:48 -0700, Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com> wrote:
> On 04/27/2011 03:33 AM, Aneesh Kumar K.V wrote:
> > On Wed, 27 Apr 2011 09:03:56 +0200, Jan Kiszka<jan.kiszka@web.de>  wrote:
> >> On 2011-04-27 08:53, Aneesh Kumar K.V wrote:
> >>> Now that we start adding more files related to 9pfs
> >>> it make sense to move them to a separate directory
> >>>
> >>> Signed-off-by: Aneesh Kumar K.V<aneesh.kumar@linux.vnet.ibm.com>
> >>> ---
> >>>   Makefile.objs                        |   10 +++++++---
> >>>   Makefile.target                      |    6 ++++--
> >>>   configure                            |    2 ++
> >>>   {hw =>  fsdev}/file-op-9p.h           |    0
> >>>   fsdev/qemu-fsdev.h                   |    2 +-
> >>>   hw/{ =>  9pfs}/virtio-9p-debug.c      |    0
> >>>   hw/{ =>  9pfs}/virtio-9p-debug.h      |    0
> >>>   hw/{ =>  9pfs}/virtio-9p-local.c      |    0
> >>>   hw/{ =>  9pfs}/virtio-9p-posix-acl.c  |    2 +-
> >>>   hw/{ =>  9pfs}/virtio-9p-xattr-user.c |    2 +-
> >>>   hw/{ =>  9pfs}/virtio-9p-xattr.c      |    2 +-
> >>>   hw/{ =>  9pfs}/virtio-9p-xattr.h      |    0
> >>>   hw/{ =>  9pfs}/virtio-9p.c            |    0
> >>>   hw/{ =>  9pfs}/virtio-9p.h            |    2 +-
> >>>   14 files changed, 18 insertions(+), 10 deletions(-)
> >>>   rename {hw =>  fsdev}/file-op-9p.h (100%)
> >>>   rename hw/{ =>  9pfs}/virtio-9p-debug.c (100%)
> >>>   rename hw/{ =>  9pfs}/virtio-9p-debug.h (100%)
> >>>   rename hw/{ =>  9pfs}/virtio-9p-local.c (100%)
> >>>   rename hw/{ =>  9pfs}/virtio-9p-posix-acl.c (99%)
> >>>   rename hw/{ =>  9pfs}/virtio-9p-xattr-user.c (98%)
> >>>   rename hw/{ =>  9pfs}/virtio-9p-xattr.c (99%)
> >>>   rename hw/{ =>  9pfs}/virtio-9p-xattr.h (100%)
> >>>   rename hw/{ =>  9pfs}/virtio-9p.c (100%)
> >> That's a good chance to split up this file, move virtio_9p_get_config
> >> into a separate one and build the large virtio-9p.c as part of hwlib
> >> while keeping the new file target-specific. I've some hack for this
> >> lying around, but now that you are already at it...
> >>
> > How about doing the below patch also and move all those device specific
> > stuff to virtio-9p-device.c and rest in virtio-9p.c ?
> I think this goes on top of your old patch. I am ready to give pull to 
> Anthony with old patch.
> May be this can go in next pull?
> 

Yes the two new patches can go later 

-aneesh

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

* Re: [Qemu-devel] [PATCH 1/3] virtio-9p: Move 9p device registration into virtio-9p.c
  2011-04-27 11:46   ` [Qemu-devel] [PATCH 1/3] virtio-9p: Move 9p device registration into virtio-9p.c Aneesh Kumar K.V
  2011-04-27 11:46     ` [Qemu-devel] [PATCH 2/3] virtio-9p: move 9p files around Aneesh Kumar K.V
  2011-04-27 11:46     ` [Qemu-devel] [PATCH 3/3] virtio-9p: Move device specific code to virtio-9p-device Aneesh Kumar K.V
@ 2011-05-31 21:28     ` Venkateswararao Jujjuri
  2011-06-01  6:49       ` Aneesh Kumar K.V
  2 siblings, 1 reply; 11+ messages in thread
From: Venkateswararao Jujjuri @ 2011-05-31 21:28 UTC (permalink / raw)
  To: qemu-devel

On 04/27/2011 04:46 AM, Aneesh Kumar K.V wrote:
> This patch move the 9p device registration into its own file

All other PCI devices registration is in this file. Not sure the need to 
move 9p alone.
Also s390x doesn't support PCI..hence this breaks the s390x build.

Thanks,
JV

> Signed-off-by: Aneesh Kumar K.V<aneesh.kumar@linux.vnet.ibm.com>
> ---
>   hw/virtio-9p.c  |   38 ++++++++++++++++++++++++++++++++++++
>   hw/virtio-pci.c |   57 +-----------------------------------------------------
>   hw/virtio-pci.h |   43 +++++++++++++++++++++++++++++++++++++++++
>   3 files changed, 83 insertions(+), 55 deletions(-)
>   create mode 100644 hw/virtio-pci.h
>
> diff --git a/hw/virtio-9p.c b/hw/virtio-9p.c
> index 7c59988..64ab3c8 100644
> --- a/hw/virtio-9p.c
> +++ b/hw/virtio-9p.c
> @@ -14,6 +14,7 @@
>   #include "virtio.h"
>   #include "pc.h"
>   #include "qemu_socket.h"
> +#include "virtio-pci.h"
>   #include "virtio-9p.h"
>   #include "fsdev/qemu-fsdev.h"
>   #include "virtio-9p-debug.h"
> @@ -3742,3 +3743,40 @@ 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,
> +                    PCI_VENDOR_ID_REDHAT_QUMRANET,
> +                    0x1009,
> +                    0x2,
> +                    0x00);
> +    /* 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,
> +    .qdev.props = (Property[]) {
> +        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);
> +}
> +
> +device_init(virtio_9p_register_devices)
> diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c
> index d07ff97..59c75de 100644
> --- a/hw/virtio-pci.c
> +++ b/hw/virtio-pci.c
> @@ -25,6 +25,7 @@
>   #include "loader.h"
>   #include "kvm.h"
>   #include "blockdev.h"
> +#include "virtio-pci.h"
>
>   /* from Linux's linux/virtio_pci.h */
>
> @@ -94,28 +95,6 @@
>    */
>   #define wmb() do { } while (0)
>
> -/* PCI bindings.  */
> -
> -typedef struct {
> -    PCIDevice pci_dev;
> -    VirtIODevice *vdev;
> -    uint32_t flags;
> -    uint32_t addr;
> -    uint32_t class_code;
> -    uint32_t nvectors;
> -    BlockConf block;
> -    NICConf nic;
> -    uint32_t host_features;
> -#ifdef CONFIG_LINUX
> -    V9fsConf fsconf;
> -#endif
> -    /* Max. number of ports we can have for a the virtio-serial device */
> -    uint32_t max_virtserial_ports;
> -    virtio_net_conf net;
> -    bool ioeventfd_disabled;
> -    bool ioeventfd_started;
> -} VirtIOPCIProxy;
> -
>   /* virtio device */
>
>   static void virtio_pci_notify(void *opaque, uint16_t vector)
> @@ -663,7 +642,7 @@ static const VirtIOBindings virtio_pci_bindings = {
>       .vmstate_change = virtio_pci_vmstate_change,
>   };
>
> -static void virtio_init_pci(VirtIOPCIProxy *proxy, VirtIODevice *vdev,
> +void virtio_init_pci(VirtIOPCIProxy *proxy, VirtIODevice *vdev,
>                               uint16_t vendor, uint16_t device,
>                               uint16_t class_code, uint8_t pif)
>   {
> @@ -828,25 +807,6 @@ static int virtio_balloon_init_pci(PCIDevice *pci_dev)
>       return 0;
>   }
>
> -#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,
> -                    PCI_VENDOR_ID_REDHAT_QUMRANET,
> -                    0x1009,
> -                    0x2,
> -                    0x00);
> -    /* make the actual value visible */
> -    proxy->nvectors = vdev->nvectors;
> -    return 0;
> -}
> -#endif
> -
>   static PCIDeviceInfo virtio_info[] = {
>       {
>           .qdev.name = "virtio-blk-pci",
> @@ -911,19 +871,6 @@ static PCIDeviceInfo virtio_info[] = {
>           },
>           .qdev.reset = virtio_pci_reset,
>       },{
> -#ifdef CONFIG_VIRTFS
> -        .qdev.name = "virtio-9p-pci",
> -        .qdev.size = sizeof(VirtIOPCIProxy),
> -        .init      = virtio_9p_init_pci,
> -        .qdev.props = (Property[]) {
> -            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(),
> -        },
> -    }, {
> -#endif
>           /* end of list */
>       }
>   };
> diff --git a/hw/virtio-pci.h b/hw/virtio-pci.h
> new file mode 100644
> index 0000000..3bef656
> --- /dev/null
> +++ b/hw/virtio-pci.h
> @@ -0,0 +1,43 @@
> +/*
> + * Virtio PCI Bindings
> + *
> + * Copyright IBM, Corp. 2007
> + * Copyright (c) 2009 CodeSourcery
> + *
> + * Authors:
> + *  Anthony Liguori<aliguori@us.ibm.com>
> + *  Paul Brook<paul@codesourcery.com>
> + *
> + * This work is licensed under the terms of the GNU GPL, version 2.  See
> + * the COPYING file in the top-level directory.
> + */
> +
> +#ifndef QEMU_VIRTIO_PCI_H
> +#define QEMU_VIRTIO_PCI_H
> +
> +#include "virtio-net.h"
> +
> +typedef struct {
> +    PCIDevice pci_dev;
> +    VirtIODevice *vdev;
> +    uint32_t flags;
> +    uint32_t addr;
> +    uint32_t class_code;
> +    uint32_t nvectors;
> +    BlockConf block;
> +    NICConf nic;
> +    uint32_t host_features;
> +#ifdef CONFIG_LINUX
> +    V9fsConf fsconf;
> +#endif
> +    /* Max. number of ports we can have for a the virtio-serial device */
> +    uint32_t max_virtserial_ports;
> +    virtio_net_conf net;
> +    bool ioeventfd_disabled;
> +    bool ioeventfd_started;
> +} VirtIOPCIProxy;
> +
> +extern void virtio_init_pci(VirtIOPCIProxy *proxy, VirtIODevice *vdev,
> +                            uint16_t vendor, uint16_t device,
> +                            uint16_t class_code, uint8_t pif);
> +#endif

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

* Re: [Qemu-devel] [PATCH 1/3] virtio-9p: Move 9p device registration into virtio-9p.c
  2011-05-31 21:28     ` [Qemu-devel] [PATCH 1/3] virtio-9p: Move 9p device registration into virtio-9p.c Venkateswararao Jujjuri
@ 2011-06-01  6:49       ` Aneesh Kumar K.V
  0 siblings, 0 replies; 11+ messages in thread
From: Aneesh Kumar K.V @ 2011-06-01  6:49 UTC (permalink / raw)
  To: Venkateswararao Jujjuri, qemu-devel

On Tue, 31 May 2011 14:28:19 -0700, Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com> wrote:
> On 04/27/2011 04:46 AM, Aneesh Kumar K.V wrote:
> > This patch move the 9p device registration into its own file
> 
> All other PCI devices registration is in this file. Not sure the need to 
> move 9p alone.
> Also s390x doesn't support PCI..hence this breaks the s390x build.
> 

s390 got added recently i guess, so my build didn't catch this. Fixed by
the below diff. 

diff --git a/Makefile.objs b/Makefile.objs
index 0668e0a..2d514a7 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -45,7 +45,7 @@ net-nested-$(CONFIG_SLIRP) += slirp.o
 net-nested-$(CONFIG_VDE) += vde.o
 net-obj-y += $(addprefix net/, $(net-nested-y))
 
-ifeq ($(CONFIG_VIRTIO)$(CONFIG_VIRTFS),yy)
+ifeq ($(CONFIG_VIRTIO)$(CONFIG_VIRTFS)$(CONFIG_PCI),yyy)
 # Lots of the fsdev/9pcode is pulled in by vl.c via qemu_fsdev_add.
 # only pull in the actual virtio-9p device

-aneesh

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

end of thread, other threads:[~2011-06-01  6:50 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-27  6:53 [Qemu-devel] [PATCH] virtio-9p: move 9p files around Aneesh Kumar K.V
2011-04-27  7:03 ` Jan Kiszka
2011-04-27 10:33   ` Aneesh Kumar K.V
2011-04-27 14:55     ` Jan Kiszka
2011-04-27 15:57     ` Venkateswararao Jujjuri
2011-04-27 16:31       ` Aneesh Kumar K.V
2011-04-27 11:46   ` [Qemu-devel] [PATCH 1/3] virtio-9p: Move 9p device registration into virtio-9p.c Aneesh Kumar K.V
2011-04-27 11:46     ` [Qemu-devel] [PATCH 2/3] virtio-9p: move 9p files around Aneesh Kumar K.V
2011-04-27 11:46     ` [Qemu-devel] [PATCH 3/3] virtio-9p: Move device specific code to virtio-9p-device Aneesh Kumar K.V
2011-05-31 21:28     ` [Qemu-devel] [PATCH 1/3] virtio-9p: Move 9p device registration into virtio-9p.c Venkateswararao Jujjuri
2011-06-01  6:49       ` Aneesh Kumar K.V

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.