virtio-9p: move 9p files around
PATCH 1/1 virtio-9p: move 9p files around
Now that we start adding more files related to 9pfs it make sense to move them to a separate directory
---
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%)Makefile.objs +7 -3
@@ -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
Makefile.target +4 -2
@@ -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
configure +2 -0
@@ -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
fsdev/file-op-9p.h renamed from hw/file-op-9p.h +0 -0
fsdev/qemu-fsdev.h +1 -1
@@ -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" /*
hw/9pfs/virtio-9p-debug.c renamed from hw/virtio-9p-debug.c +0 -0
hw/9pfs/virtio-9p-debug.h renamed from hw/virtio-9p-debug.h +0 -0
hw/9pfs/virtio-9p-local.c renamed from hw/virtio-9p-local.c +0 -0
hw/9pfs/virtio-9p-posix-acl.c renamed from hw/virtio-9p-posix-acl.c +1 -1
@@ -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"
hw/9pfs/virtio-9p-xattr-user.c renamed from hw/virtio-9p-xattr-user.c +1 -1
@@ -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"
hw/9pfs/virtio-9p-xattr.c renamed from hw/virtio-9p-xattr.c +1 -1
@@ -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"
hw/9pfs/virtio-9p-xattr.h renamed from hw/virtio-9p-xattr.h +0 -0
hw/9pfs/virtio-9p.c renamed from hw/virtio-9p.c +0 -0
hw/9pfs/virtio-9p.h renamed from hw/virtio-9p.h +1 -1
@@ -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 */
Signature · 1 line
1.7.4.1
Quoted 21 lines · 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 <[email protected]>--- 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%)
Quoted 8 lines
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
Quoted 31 lines · Jan Kiszka
Quoted 21 lines · 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 <[email protected]>--- 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%)Quoted 8 lines
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%)
Quoted 5 lines
That's a good chance to split up this file, move
virtio_9p_get_configinto a separate one and build the largevirtio-9p.cas 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 <[email protected]> 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
hw/virtio-9p.c +35 -0
@@ -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)
hw/virtio-pci.c +3 -52
85 lines not on this page · raw message
hw/virtio-pci.h new file +42 -0
42 lines not on this page · raw message
PATCH 2/3 virtio-9p: move 9p files around
In reply to Aneesh Kumar K.VNow that we start adding more files related to 9pfs it make sense to move them to a separate directory
---
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%)Makefile.objs +7 -3
@@ -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
Makefile.target +4 -2
@@ -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
configure +2 -0
@@ -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
fsdev/file-op-9p.h renamed from hw/file-op-9p.h +0 -0
fsdev/qemu-fsdev.h +1 -1
@@ -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" /*
hw/9pfs/virtio-9p-debug.c renamed from hw/virtio-9p-debug.c +0 -0
hw/9pfs/virtio-9p-debug.h renamed from hw/virtio-9p-debug.h +0 -0
hw/9pfs/virtio-9p-local.c renamed from hw/virtio-9p-local.c +0 -0
hw/9pfs/virtio-9p-posix-acl.c renamed from hw/virtio-9p-posix-acl.c +1 -1
@@ -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"
hw/9pfs/virtio-9p-xattr-user.c renamed from hw/virtio-9p-xattr-user.c +1 -1
@@ -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"
hw/9pfs/virtio-9p-xattr.c renamed from hw/virtio-9p-xattr.c +1 -1
@@ -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"
hw/9pfs/virtio-9p-xattr.h renamed from hw/virtio-9p-xattr.h +0 -0
hw/9pfs/virtio-9p.c renamed from hw/virtio-9p.c +0 -0
hw/9pfs/virtio-9p.h renamed from hw/virtio-9p.h +1 -1
@@ -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 */
Signature · 1 line
1.7.4.1
PATCH 3/3 virtio-9p: Move device specific code to virtio-9p-device
In reply to Aneesh Kumar K.V--- 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
Makefile.objs +1 -1
@@ -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
Makefile.target +2 -2
@@ -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
hw/9pfs/virtio-9p-device.c new file +174 -0
174 lines not on this page · raw message
hw/9pfs/virtio-9p.c +1 -154
164 lines not on this page · raw message
hw/9pfs/virtio-9p.h +2 -0
@@ -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
Signature · 1 line
1.7.4.1
PATCH 1/3 virtio-9p: Move 9p device registration into virtio-9p.c
In reply to Jan KiszkaThis patch move the 9p device registration into its own file
--- 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
hw/virtio-9p.c +38 -0
@@ -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)
hw/virtio-pci.c +2 -55
87 lines not on this page · raw message
hw/virtio-pci.h new file +43 -0
43 lines not on this page · raw message
Signature · 1 line
1.7.4.1
Quoted 32 lines · Aneesh Kumar K.V
Quoted 31 lines · Jan Kiszka
Quoted 29 lines · 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 <[email protected]>--- 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%)
Quoted 8 lines
Quoted 5 lines
That's a good chance to split up this file, move
virtio_9p_get_configinto a separate one and build the largevirtio-9p.cas 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.cand rest invirtio-9p.c?
Looks ok. Removing #ifdefs is generally welcome.
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux
Quoted 31 lines · Aneesh Kumar K.V
Quoted 30 lines · Jan Kiszka
Quoted 29 lines · 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<[email protected]>--- 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%)
Quoted 7 lines
Quoted 5 lines
That's a good chance to split up this file, move
virtio_9p_get_configinto a separate one and build the largevirtio-9p.cas 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.cand rest invirtio-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
Quoted 203 lines
commit
9de1857114dac1dcd0c6399d91036c279373b2d0Author: Aneesh Kumar K.V<[email protected]> Date: Thu Oct 21 13:50:05 2010 +0530virtio-9p: Move 9p device registration into
virtio-9p.cThis patch move the 9p device registration into its own file
Signed-off-by Aneesh Kumar K.V<[email protected]>hw/virtio-9p.c +35
-0@@ -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)hw/virtio-pci.c +3
-52@@ -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 */ } };hw/virtio-pci.h new file +42
-0@@ -0,0 +1,42 @@ +/* +* Virtio PCI Bindings +* +* Copyright IBM, Corp. 2007 +* Copyright (c) 2009 CodeSourcery +* +* Authors: +* Anthony Liguori<[email protected]> +* Paul Brook<[email protected]> +* +* 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
Quoted 37 lines · Venkateswararao Jujjuri
Quoted 36 lines · Aneesh Kumar K.V
Quoted 35 lines · Jan Kiszka
Quoted 21 lines · 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<[email protected]>--- 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%)Quoted 8 lines
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_configinto a separate one and build the largevirtio-9p.cas 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...
Quoted 6 lines
Quoted 2 lines
How about doing the below patch also and move all those device specific stuff to
virtio-9p-device.cand rest invirtio-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
Re: [Qemu-devel] [PATCH 1/3] virtio-9p: Move 9p device registration into virtio-9p.c
In reply to Aneesh Kumar K.VQuoted 1 line · Aneesh Kumar K.V
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
Quoted 206 lines
Signed-off-by Aneesh Kumar K.V<[email protected]>--- 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.hhw/virtio-9p.c +38
-0@@ -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)hw/virtio-pci.c +2
-55@@ -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 */ } };hw/virtio-pci.h new file +43
-0@@ -0,0 +1,43 @@ +/* +* Virtio PCI Bindings +* +* Copyright IBM, Corp. 2007 +* Copyright (c) 2009 CodeSourcery +* +* Authors: +* Anthony Liguori<[email protected]> +* Paul Brook<[email protected]> +* +* 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
Re: [Qemu-devel] [PATCH 1/3] virtio-9p: Move 9p device registration into virtio-9p.c
Quoted 7 lines · Venkateswararao Jujjuri
Quoted 1 line · Aneesh Kumar K.V
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.
Makefile.objs +1 -1
@@ -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