Add --disable-vhost-user
v2 cover Add --disable-vhost-user
Hi,
The series aims to add --disable-vhost-user configure option, to disable all vhost-user support.
v2:
- remove some #ifdef, reuse CONFIG_VHOST_NET_USED
- split the patch to have net/vhost-user.c compiled out (adding 2 ifdefs)
- fail if --enable-vhost-user on win32
Marc-André Lureau (2):
build-sys: add --disable-vhost-user
build-sys: do not compile net/vhost-user.c if vhost-user is disabled
hw/net/vhost_net.c | 4 ++++ hw/virtio/virtio-pci.c | 4 ++-- configure | 29 +++++++++++++++++++++++++++-- default-configs/pci.mak | 2 +- default-configs/s390x-softmmu.mak | 2 +- net/Makefile.objs | 2 +- tests/Makefile.include | 6 +++--- 7 files changed, 39 insertions(+), 10 deletions(-)
Signature · 1 line
2.14.0.rc0.1.g40ca67566
PATCH v2 1/2 build-sys: add --disable-vhost-user
Learn to compile out vhost-user. Keep it enabled by default on non-win32, that is assumed to be POSIX. Fail if trying to enable it on win32.
When trying to make a vhost-user netdev, it gives the following error:
-netdev vhost-user,id=foo,chardev=chr-test: Parameter 'type' expects a netdev backend type
And similar error with the HMP/QMP monitors.
While at it, rename CONFIG_VHOST_NET_TEST CONFIG_VHOST_USER_NET_TEST since it's a vhost-user specific variable.
--- hw/virtio/virtio-pci.c | 4 ++-- configure | 29 +++++++++++++++++++++++++++-- default-configs/pci.mak | 2 +- default-configs/s390x-softmmu.mak | 2 +- tests/Makefile.include | 6 +++--- 5 files changed, 34 insertions(+), 9 deletions(-)
hw/virtio/virtio-pci.c +2 -2
@@ -2135,7 +2135,7 @@ static const TypeInfo vhost_scsi_pci_info = { };#endif -#ifdef CONFIG_LINUX +#if defined(CONFIG_VHOST_USER) && defined(CONFIG_LINUX) /* vhost-user-scsi-pci */ static Property vhost_user_scsi_pci_properties[] = { DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy, nvectors,
@@ -2665,7 +2665,7 @@ static void virtio_pci_register_types(void)#ifdef CONFIG_VHOST_SCSI type_register_static (&vhost_scsi_pci_info);#endif -#ifdef CONFIG_LINUX +#if defined(CONFIG_VHOST_USER ) && defined(CONFIG_LINUX )type_register_static (&vhost_user_scsi_pci_info);#endif #ifdef CONFIG_VHOST_VSOCK
configure +27 -2
@@ -306,6 +306,7 @@ tcg="yes" vhost_net="no" vhost_scsi="no" vhost_vsock="no" +vhost_user="" kvm="no" hax="no" rdma=""
@@ -1282,6 +1283,15 @@ for opt do ;; --enable-vxhs) vxhs="yes" ;; + --disable-vhost-user) vhost_user="no" + ;; + --enable-vhost-user) + vhost_user="yes" + if test "$mingw32" = "yes" ; then + echo "ERROR: vhost-user isn't available on win32" + exit 1 + fi + ;; *) echo "ERROR: unknown option $opt" echo "Try '$0 --help' for more information"
@@ -1290,6 +1300,14 @@ for opt do esac done +if test "$vhost_user" = ""; then + if test "$mingw32" = "yes" ; then + vhost_user="no" + else + vhost_user="yes" + fi +fi + case "$cpu" in ppc) CPU_CFLAGS="-m32"
@@ -1518,6 +1536,7 @@ disabled with --disable-FEATURE, default is enabled if available: tools build qemu-io, qemu-nbd and qemu-image tools vxhs Veritas HyperScale vDisk backend support crypto-afalg Linux AF_ALG crypto backend driver + vhost-user vhost-user support NOTE: The object files are built at the place where configure is launched EOF
@@ -5348,6 +5367,7 @@ echo "libcap-ng support $cap_ng" echo "vhost-net support $vhost_net" echo "vhost-scsi support $vhost_scsi" echo "vhost-vsock support $vhost_vsock" +echo "vhost-user support $vhost_user" echo "Trace backends $trace_backends" if have_backend "simple"; then echo "Trace output file $trace_file-<pid>"
@@ -5757,12 +5777,15 @@ fi if test "$vhost_scsi" = "yes" ; then echo "CONFIG_VHOST_SCSI=y" >> $config_host_mak fi -if test "$vhost_net" = "yes" ; then +if test "$vhost_net" = "yes" -a "$vhost_user" = "yes"; then echo "CONFIG_VHOST_NET_USED=y" >> $config_host_mak fi if test "$vhost_vsock" = "yes" ; then echo "CONFIG_VHOST_VSOCK=y" >> $config_host_mak fi +if test "$vhost_user" = "yes" ; then + echo "CONFIG_VHOST_USER=y" >> $config_host_mak +fi if test "$blobs" = "yes" ; then echo "INSTALL_BLOBS=yes" >> $config_host_mak fi
@@ -6358,7 +6381,9 @@ if supported_kvm_target $target; then echo "CONFIG_KVM=y" >> $config_target_mak if test "$vhost_net" = "yes" ; then echo "CONFIG_VHOST_NET=y" >> $config_target_mak - echo "CONFIG_VHOST_NET_TEST_$target_name=y" >> $config_host_mak + if test "$vhost_user" = "yes" ; then + echo "CONFIG_VHOST_USER_NET_TEST_$target_name=y" >> $config_host_mak + fi fi fi if supported_hax_target $target; then
default-configs/pci.mak +1 -1
@@ -43,4 +43,4 @@ CONFIG_VGA=y CONFIG_VGA_PCI=y CONFIG_IVSHMEM_DEVICE=$(CONFIG_IVSHMEM) CONFIG_ROCKER=y -CONFIG_VHOST_USER_SCSI=$(CONFIG_LINUX) +CONFIG_VHOST_USER_SCSI=$(and $(CONFIG_VHOST_USER),$(CONFIG_LINUX))
default-configs/s390x-softmmu.mak +1 -1
@@ -1,6 +1,6 @@ CONFIG_PCI=y CONFIG_VIRTIO_PCI=y -CONFIG_VHOST_USER_SCSI=$(CONFIG_LINUX) +CONFIG_VHOST_USER_SCSI=$(and $(CONFIG_VHOST_USER),$(CONFIG_LINUX)) CONFIG_VIRTIO=y CONFIG_SCLPCONSOLE=y CONFIG_TERMINAL3270=y
tests/Makefile.include +3 -3
@@ -255,9 +255,9 @@ check-qtest-i386-y += tests/pc-cpu-test$(EXESUF) check-qtest-i386-y += tests/q35-test$(EXESUF) check-qtest-i386-y += tests/vmgenid-test$(EXESUF) gcov-files-i386-y += hw/pci-host/q35.c -check-qtest-i386-$(CONFIG_VHOST_NET_TEST_i386) += tests/vhost-user-test$(EXESUF) -ifeq ($(CONFIG_VHOST_NET_TEST_i386),) -check-qtest-x86_64-$(CONFIG_VHOST_NET_TEST_x86_64) += tests/vhost-user-test$(EXESUF) +check-qtest-i386-$(CONFIG_VHOST_USER_NET_TEST_i386) += tests/vhost-user-test$(EXESUF) +ifeq ($(CONFIG_VHOST_USER_NET_TEST_i386),) +check-qtest-x86_64-$(CONFIG_VHOST_USER_NET_TEST_x86_64) += tests/vhost-user-test$(EXESUF) endif check-qtest-i386-y += tests/test-netfilter$(EXESUF) check-qtest-i386-y += tests/test-filter-mirror$(EXESUF)
Signature · 1 line
2.14.0.rc0.1.g40ca67566
Re: [Qemu-devel] [PATCH v2 1/2] build-sys: add --disable-vhost-user
Quoted 22 lines · On Fri, 28 Jul 2017 16:13:08 +0200 Marc-André Lureau…
Learn to compile out vhost-user. Keep it enabled by default on non-win32, that is assumed to be POSIX. Fail if trying to enable it on win32.
When trying to make a vhost-user netdev, it gives the following error:
-netdev vhost-user,id=foo,chardev=chr-test: Parameter 'type' expects a netdev backend type
And similar error with the HMP/QMP monitors.
While at it, rename
CONFIG_VHOST_NET_TESTCONFIG_VHOST_USER_NET_TESTsince it's a vhost-user specific variable.Signed-off-by Marc-André Lureau <[email protected]>--- hw/virtio/virtio-pci.c | 4 ++-- configure | 29 +++++++++++++++++++++++++++-- default-configs/pci.mak | 2 +- default-configs/s390x-softmmu.mak | 2 +- tests/Makefile.include | 6 +++--- 5 files changed, 34 insertions(+), 9 deletions(-)
(...)
Quoted 13 lines
configure +1
-0@@ -306,6 +306,7 @@ tcg="yes" vhost_net="no" vhost_scsi="no" vhost_vsock="no" +vhost_user="" kvm="no" hax="no" rdma=""
configure for opt do · line 1292
Quoted 10 lines
configure +7
-0@@ -1282,6 +1283,15 @@ for opt do ;; --enable-vxhs) vxhs="yes" ;; + --disable-vhost-user) vhost_user="no" + ;; + --enable-vhost-user) + vhost_user="yes" + if test "$mingw32" = "yes" ; then + echo "ERROR: vhost-user isn't available on win32" + exit 1
error_exit?
Quoted 5 lines
configure +2
-0+ fi + ;; *) echo "ERROR: unknown option $opt" echo "Try '$0 --help' for more information"
(...)
default-configs/s390x-softmmu.mak line 3
Quoted 9 lines
default-configs/s390x-softmmu.mak +1
-1@@ -1,6 +1,6 @@ CONFIG_PCI=y CONFIG_VIRTIO_PCI=y -CONFIG_VHOST_USER_SCSI=$(CONFIG_LINUX) +CONFIG_VHOST_USER_SCSI=$(and $(CONFIG_VHOST_USER),$(CONFIG_LINUX))
Huh. I wonder if anyone actually tried this on s390x?
(The change is fine in the context of this patch, of course.)
Quoted 3 lines
default-configs/s390x-softmmu.mak +0
-0CONFIG_VIRTIO=y CONFIG_SCLPCONSOLE=y CONFIG_TERMINAL3270=y
Re: [Qemu-devel] [PATCH v2 1/2] build-sys: add --disable-vhost-user
In reply to Marc-André LureauQuoted 6 lines · Marc-André Lureau
Learn to compile out vhost-user. Keep it enabled by default on non-win32, that is assumed to be POSIX. Fail if trying to enable it on win32.
When trying to make a vhost-user netdev, it gives the following error:
Quoted 8 lines
-netdev vhost-user,id=foo,chardev=chr-test: Parameter 'type' expects a netdev backend type
And similar error with the HMP/QMP monitors.
While at it, rename
CONFIG_VHOST_NET_TESTCONFIG_VHOST_USER_NET_TESTsince it's a vhost-user specific variable.Signed-off-by Marc-André Lureau <[email protected]>
OK so pls address Cornelia's comment and post just patch 1 as it seems appropriate for 2.10.
Quoted 158 lines
--- hw/virtio/virtio-pci.c | 4 ++-- configure | 29 +++++++++++++++++++++++++++-- default-configs/pci.mak | 2 +- default-configs/s390x-softmmu.mak | 2 +- tests/Makefile.include | 6 +++--- 5 files changed, 34 insertions(+), 9 deletions(-)hw/virtio/virtio-pci.c +2
-2@@ -2135,7 +2135,7 @@ static const TypeInfo vhost_scsi_pci_info = { };#endif -#ifdef CONFIG_LINUX +#if defined(CONFIG_VHOST_USER) && defined(CONFIG_LINUX) /* vhost-user-scsi-pci */ static Property vhost_user_scsi_pci_properties[] = { DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy, nvectors,@@ -2665,7 +2665,7 @@ static void virtio_pci_register_types(void)#ifdef CONFIG_VHOST_SCSI type_register_static (&vhost_scsi_pci_info);#endif -#ifdef CONFIG_LINUX +#if defined(CONFIG_VHOST_USER ) && defined(CONFIG_LINUX )type_register_static (&vhost_user_scsi_pci_info);#endif #ifdef CONFIG_VHOST_VSOCK configure +27
-2@@ -306,6 +306,7 @@ tcg="yes" vhost_net="no" vhost_scsi="no" vhost_vsock="no" +vhost_user="" kvm="no" hax="no" rdma=""@@ -1282,6 +1283,15 @@ for opt do ;; --enable-vxhs) vxhs="yes" ;; + --disable-vhost-user) vhost_user="no" + ;; + --enable-vhost-user) + vhost_user="yes" + if test "$mingw32" = "yes" ; then + echo "ERROR: vhost-user isn't available on win32" + exit 1 + fi + ;; *) echo "ERROR: unknown option $opt" echo "Try '$0 --help' for more information"@@ -1290,6 +1300,14 @@ for opt do esac done +if test "$vhost_user" = ""; then + if test "$mingw32" = "yes" ; then + vhost_user="no" + else + vhost_user="yes" + fi +fi + case "$cpu" in ppc) CPU_CFLAGS="-m32"@@ -1518,6 +1536,7 @@ disabled with --disable-FEATURE, default is enabled if available: tools build qemu-io, qemu-nbd and qemu-image tools vxhs Veritas HyperScale vDisk backend support crypto-afalg Linux AF_ALG crypto backend driver + vhost-user vhost-user support NOTE: The object files are built at the place where configure is launched EOF@@ -5348,6 +5367,7 @@ echo "libcap-ng support $cap_ng" echo "vhost-net support $vhost_net" echo "vhost-scsi support $vhost_scsi" echo "vhost-vsock support $vhost_vsock" +echo "vhost-user support $vhost_user" echo "Trace backends $trace_backends" if have_backend "simple"; then echo "Trace output file $trace_file-<pid>"@@ -5757,12 +5777,15 @@ fi if test "$vhost_scsi" = "yes" ; then echo "CONFIG_VHOST_SCSI=y" >> $config_host_mak fi -if test "$vhost_net" = "yes" ; then +if test "$vhost_net" = "yes" -a "$vhost_user" = "yes"; then echo "CONFIG_VHOST_NET_USED=y" >> $config_host_mak fi if test "$vhost_vsock" = "yes" ; then echo "CONFIG_VHOST_VSOCK=y" >> $config_host_mak fi +if test "$vhost_user" = "yes" ; then + echo "CONFIG_VHOST_USER=y" >> $config_host_mak +fi if test "$blobs" = "yes" ; then echo "INSTALL_BLOBS=yes" >> $config_host_mak fi@@ -6358,7 +6381,9 @@ if supported_kvm_target $target; then echo "CONFIG_KVM=y" >> $config_target_mak if test "$vhost_net" = "yes" ; then echo "CONFIG_VHOST_NET=y" >> $config_target_mak - echo "CONFIG_VHOST_NET_TEST_$target_name=y" >> $config_host_mak + if test "$vhost_user" = "yes" ; then + echo "CONFIG_VHOST_USER_NET_TEST_$target_name=y" >> $config_host_mak + fi fi fi if supported_hax_target $target; thendefault-configs/pci.mak +1
-1@@ -43,4 +43,4 @@ CONFIG_VGA=y CONFIG_VGA_PCI=y CONFIG_IVSHMEM_DEVICE=$(CONFIG_IVSHMEM) CONFIG_ROCKER=y -CONFIG_VHOST_USER_SCSI=$(CONFIG_LINUX) +CONFIG_VHOST_USER_SCSI=$(and $(CONFIG_VHOST_USER),$(CONFIG_LINUX))default-configs/s390x-softmmu.mak +1
-1@@ -1,6 +1,6 @@ CONFIG_PCI=y CONFIG_VIRTIO_PCI=y -CONFIG_VHOST_USER_SCSI=$(CONFIG_LINUX) +CONFIG_VHOST_USER_SCSI=$(and $(CONFIG_VHOST_USER),$(CONFIG_LINUX)) CONFIG_VIRTIO=y CONFIG_SCLPCONSOLE=y CONFIG_TERMINAL3270=ytests/Makefile.include +3
-3@@ -255,9 +255,9 @@ check-qtest-i386-y += tests/pc-cpu-test$(EXESUF) check-qtest-i386-y += tests/q35-test$(EXESUF) check-qtest-i386-y += tests/vmgenid-test$(EXESUF) gcov-files-i386-y += hw/pci-host/q35.c -check-qtest-i386-$(CONFIG_VHOST_NET_TEST_i386) += tests/vhost-user-test$(EXESUF) -ifeq ($(CONFIG_VHOST_NET_TEST_i386),) -check-qtest-x86_64-$(CONFIG_VHOST_NET_TEST_x86_64) += tests/vhost-user-test$(EXESUF) +check-qtest-i386-$(CONFIG_VHOST_USER_NET_TEST_i386) += tests/vhost-user-test$(EXESUF) +ifeq ($(CONFIG_VHOST_USER_NET_TEST_i386),) +check-qtest-x86_64-$(CONFIG_VHOST_USER_NET_TEST_x86_64) += tests/vhost-user-test$(EXESUF) endif check-qtest-i386-y += tests/test-netfilter$(EXESUF) check-qtest-i386-y += tests/test-filter-mirror$(EXESUF)Signature · 1 line
2.14.0.rc0.1.g40ca67566
PATCH v2 2/2 build-sys: do not compile net/vhost-user.c if vhost-user is disabled
In reply to Marc-André LureauThis adds two extra #ifdef that have fairly limited conflict potential.
--- hw/net/vhost_net.c | 4 ++++ net/Makefile.objs | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-)
hw/net/vhost_net.c +4 -0
@@ -193,6 +193,7 @@ struct vhost_net *vhost_net_init(VhostNetOptions *options) } } +#ifdef CONFIG_VHOST_USER /* Set sane init value. Override when guest acks. */ if (net->nc->info->type ==NET_CLIENT_DRIVER_VHOST_USER ) { features =vhost_user_get_acked_features (net->nc);
@@ -203,6 +204,7 @@ struct vhost_net *vhost_net_init(VhostNetOptions *options) goto fail; } } +#endif vhost_net_ack_features (net, features);
@@ -414,10 +416,12 @@ VHostNetState *get_vhost_net(NetClientState *nc)case NET_CLIENT_DRIVER_TAP : vhost_net =tap_get_vhost_net (nc);break ; +#ifdef CONFIG_VHOST_USER case NET_CLIENT_DRIVER_VHOST_USER : vhost_net =vhost_user_get_vhost_net (nc);assert (vhost_net);break ; +#endif default :break ; }
net/Makefile.objs +1 -1
@@ -3,7 +3,7 @@ common-obj-y += socket.o common-obj-y += dump.o common-obj-y += eth.o common-obj-$(CONFIG_L2TPV3) += l2tpv3.o -common-obj-$(CONFIG_POSIX) += vhost-user.o +common-obj-$(CONFIG_VHOST_USER) += vhost-user.o common-obj-$(CONFIG_SLIRP) += slirp.o common-obj-$(CONFIG_VDE) += vde.o common-obj-$(CONFIG_NETMAP) += netmap.o
Signature · 1 line
2.14.0.rc0.1.g40ca67566
Re: [Qemu-devel] [PATCH v2 2/2] build-sys: do not compile net/vhost-user.c if vhost-user is disabled
Quoted 3 lines · Marc-André Lureau
This adds two extra #ifdef that have fairly limited conflict potential.
Signed-off-by Marc-André Lureau <[email protected]>
OK but why can't we keep all ifdefs in net/ where all the rest of the features are ifdef'ed?
My concern is no one is going to test this weird configuration so we might accidentally re-enable it without noticing. net/net.c is where all command line play happens so people know a bunch of configs need to be tested when changing it.
Quoted 53 lines
--- hw/net/vhost_net.c | 4 ++++ net/Makefile.objs | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-)hw/net/vhost_net.c +4
-0@@ -193,6 +193,7 @@ struct vhost_net *vhost_net_init(VhostNetOptions *options) } } +#ifdef CONFIG_VHOST_USER /* Set sane init value. Override when guest acks. */ if (net->nc->info->type ==NET_CLIENT_DRIVER_VHOST_USER ) { features =vhost_user_get_acked_features (net->nc);@@ -203,6 +204,7 @@ struct vhost_net *vhost_net_init(VhostNetOptions *options) goto fail; } } +#endif vhost_net_ack_features (net, features);@@ -414,10 +416,12 @@ VHostNetState *get_vhost_net(NetClientState *nc)case NET_CLIENT_DRIVER_TAP : vhost_net =tap_get_vhost_net (nc);break ; +#ifdef CONFIG_VHOST_USER case NET_CLIENT_DRIVER_VHOST_USER : vhost_net =vhost_user_get_vhost_net (nc);assert (vhost_net);break ; +#endif default :break ; }net/Makefile.objs +1
-1@@ -3,7 +3,7 @@ common-obj-y += socket.o common-obj-y += dump.o common-obj-y += eth.o common-obj-$(CONFIG_L2TPV3) += l2tpv3.o -common-obj-$(CONFIG_POSIX) += vhost-user.o +common-obj-$(CONFIG_VHOST_USER) += vhost-user.o common-obj-$(CONFIG_SLIRP) += slirp.o common-obj-$(CONFIG_VDE) += vde.o common-obj-$(CONFIG_NETMAP) += netmap.oSignature · 1 line
2.14.0.rc0.1.g40ca67566
Re: [Qemu-devel] [PATCH v2 2/2] build-sys: do not compile net/vhost-user.c if vhost-user is disabled
Hi
----- Original Message -----
Quoted 8 lines · Marc-André Lureau
Quoted 3 lines
This adds two extra #ifdef that have fairly limited conflict potential.
Signed-off-by Marc-André Lureau <[email protected]>OK but why can't we keep all ifdefs in
net/where all the rest of the features are ifdef'ed?
We would need fallback code for vhost_user_get_* functions (see below).
Quoted 5 lines
My concern is no one is going to test this weird configuration so we might accidentally re-enable it without noticing.
net/net.cis where all command line play happens so people know a bunch of configs need to be tested when changing it.
I am not sure I understand your argument there. You are afraid we 'accidentaly re-enable' vhost-user... and forget to remove those #ifdef?
I can imagine people don't like having code clutter with #ifdef, but I think when it doesn't change much the logic (as in here with clean per-case switch/if), it is fine, ymmv.
Quoted 44 lines
Quoted 44 lines
--- hw/net/vhost_net.c | 4 ++++ net/Makefile.objs | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-)hw/net/vhost_net.c +1
-0@@ -193,6 +193,7 @@ struct vhost_net *vhost_net_init(VhostNetOptions *options) } } +#ifdef CONFIG_VHOST_USER /* Set sane init value. Override when guest acks. */ if (net->nc->info->type ==NET_CLIENT_DRIVER_VHOST_USER ) {features = vhost_user_get_acked_features(net->nc);hw/net/vhost_net.c +3
-0@@ -203,6 +204,7 @@ struct vhost_net *vhost_net_init(VhostNetOptions *options) goto fail; } } +#endif vhost_net_ack_features (net, features);@@ -414,10 +416,12 @@ VHostNetState *get_vhost_net(NetClientState *nc)case NET_CLIENT_DRIVER_TAP : vhost_net =tap_get_vhost_net (nc);break ; +#ifdef CONFIG_VHOST_USER case NET_CLIENT_DRIVER_VHOST_USER : vhost_net =vhost_user_get_vhost_net (nc);assert (vhost_net);break ; +#endif default :break ; }net/Makefile.objs +0
-0
Quoted 8 lines
net/Makefile.objs common-obj-y += socket.o · line 6
Quoted 8 lines
net/Makefile.objs +1
-1@@ -3,7 +3,7 @@ common-obj-y += socket.o common-obj-y += dump.o common-obj-y += eth.o common-obj-$(CONFIG_L2TPV3) += l2tpv3.o -common-obj-$(CONFIG_POSIX) += vhost-user.o +common-obj-$(CONFIG_VHOST_USER) += vhost-user.o
So we could have something like:
+common-obj-$(not CONFIG_VHOST_USER) += vhost-user-stubs.o
?
Quoted 6 lines
Quoted 5 lines
net/Makefile.objs +0
-1common-obj-$(CONFIG_SLIRP) += slirp.o common-obj-$(CONFIG_VDE) += vde.o common-obj-$(CONFIG_NETMAP) += netmap.o --2.14.0.rc0.1.g40ca67566
Re: [Qemu-devel] [PATCH v2 2/2] build-sys: do not compile net/vhost-user.c if vhost-user is disabled
Quoted 6 lines · Marc-André Lureau
Hi
----- Original Message -----
Quoted 3 lines · Marc-André Lureau
Quoted 2 lines
This adds two extra #ifdef that have fairly limited conflict potential.
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
Signed-off-by Marc-André Lureau <[email protected]>OK but why can't we keep all ifdefs in
net/where all the rest of the features are ifdef'ed?We would need fallback code for vhost_user_get_* functions (see below).
Not if you merely add ifdefs around name arrays in net/net.c I think.
Quoted 9 lines
Quoted 5 lines
My concern is no one is going to test this weird configuration so we might accidentally re-enable it without noticing.
net/net.cis where all command line play happens so people know a bunch of configs need to be tested when changing it.I am not sure I understand your argument there. You are afraid we 'accidentaly re-enable' vhost-user... and forget to remove those #ifdef?
I can imagine people don't like having code clutter with #ifdef, but I think when it doesn't change much the logic (as in here with clean per-case switch/if), it is fine, ymmv.
Let's assume all this code is refactored, we'd have to test with ifdefs.
Quoted 65 lines
Quoted 44 lines
Quoted 44 lines
--- hw/net/vhost_net.c | 4 ++++ net/Makefile.objs | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-)hw/net/vhost_net.c +1
-0@@ -193,6 +193,7 @@ struct vhost_net *vhost_net_init(VhostNetOptions *options) } } +#ifdef CONFIG_VHOST_USER /* Set sane init value. Override when guest acks. */ if (net->nc->info->type ==NET_CLIENT_DRIVER_VHOST_USER ) {features = vhost_user_get_acked_features(net->nc);hw/net/vhost_net.c +3
-0@@ -203,6 +204,7 @@ struct vhost_net *vhost_net_init(VhostNetOptions *options) goto fail; } } +#endif vhost_net_ack_features (net, features);@@ -414,10 +416,12 @@ VHostNetState *get_vhost_net(NetClientState *nc)case NET_CLIENT_DRIVER_TAP : vhost_net =tap_get_vhost_net (nc);break ; +#ifdef CONFIG_VHOST_USER case NET_CLIENT_DRIVER_VHOST_USER : vhost_net =vhost_user_get_vhost_net (nc);assert (vhost_net);break ; +#endif default :break ; }net/Makefile.objs +0
-0Quoted 8 lines
net/Makefile.objs common-obj-y += socket.o · line 6
Quoted 8 lines
net/Makefile.objs +1
-1@@ -3,7 +3,7 @@ common-obj-y += socket.o common-obj-y += dump.o common-obj-y += eth.o common-obj-$(CONFIG_L2TPV3) += l2tpv3.o -common-obj-$(CONFIG_POSIX) += vhost-user.o +common-obj-$(CONFIG_VHOST_USER) += vhost-user.oSo we could have something like:
+common-obj-$(not
CONFIG_VHOST_USER) += vhost-user-stubs.o?
Quoted 6 lines
Quoted 5 lines
net/Makefile.objs +0
-1common-obj-$(CONFIG_SLIRP) += slirp.o common-obj-$(CONFIG_VDE) += vde.o common-obj-$(CONFIG_NETMAP) += netmap.o --2.14.0.rc0.1.g40ca67566
Re: [Qemu-devel] [PATCH v2 2/2] build-sys: do not compile net/vhost-user.c if vhost-user is disabled
----- Original Message -----
Quoted 9 lines · Marc-André Lureau
Quoted 8 lines
Hi
----- Original Message -----
Quoted 5 lines · Marc-André Lureau
Quoted 3 lines
This adds two extra #ifdef that have fairly limited conflict potential.
Signed-off-by Marc-André Lureau <[email protected]>
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
OK but why can't we keep all ifdefs in
net/where all the rest of the features are ifdef'ed?We would need fallback code for vhost_user_get_* functions (see below).
Not if you merely add ifdefs around name arrays in
net/net.cI think.
vhost_user_get_* are defined in net/vhost-user.c, linked from hw/net/vhost_net.c
Quoted 10 lines
Quoted 10 lines
Quoted 6 lines
My concern is no one is going to test this weird configuration so we might accidentally re-enable it without noticing.
net/net.cis where all command line play happens so people know a bunch of configs need to be tested when changing it.I am not sure I understand your argument there. You are afraid we 'accidentaly re-enable' vhost-user... and forget to remove those #ifdef?
Quoted 6 lines
Quoted 3 lines
I can imagine people don't like having code clutter with #ifdef, but I think when it doesn't change much the logic (as in here with clean per-case switch/if), it is fine, ymmv.
Let's assume all this code is refactored, we'd have to test with ifdefs.
This is true whether there is one or ten #ifdef, isn't it?
It only gets more complicated the more #ifdef there is. But here it's fairly limited impact since it's just 2 more #ifdef for the proposed CONFIG_VHOST_USER from previous patch.
Quoted 67 lines
Quoted 66 lines
Quoted 45 lines
Quoted 45 lines
--- hw/net/vhost_net.c | 4 ++++ net/Makefile.objs | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-)hw/net/vhost_net.c +1
-0@@ -193,6 +193,7 @@ struct vhost_net *vhost_net_init(VhostNetOptions *options) } } +#ifdef CONFIG_VHOST_USER /* Set sane init value. Override when guest acks. */ if (net->nc->info->type ==NET_CLIENT_DRIVER_VHOST_USER ) {features = vhost_user_get_acked_features(net->nc);hw/net/vhost_net.c +3
-0@@ -203,6 +204,7 @@ struct vhost_net *vhost_net_init(VhostNetOptions *options) goto fail; } } +#endif vhost_net_ack_features (net, features);@@ -414,10 +416,12 @@ VHostNetState *get_vhost_net(NetClientState *nc)case NET_CLIENT_DRIVER_TAP : vhost_net =tap_get_vhost_net (nc);break ; +#ifdef CONFIG_VHOST_USER case NET_CLIENT_DRIVER_VHOST_USER : vhost_net =vhost_user_get_vhost_net (nc);assert (vhost_net);break ; +#endif default :break ; }net/Makefile.objs +0
-0Quoted 8 lines
net/Makefile.objs common-obj-y += socket.o · line 6
Quoted 8 lines
net/Makefile.objs +1
-1@@ -3,7 +3,7 @@ common-obj-y += socket.o common-obj-y += dump.o common-obj-y += eth.o common-obj-$(CONFIG_L2TPV3) += l2tpv3.o -common-obj-$(CONFIG_POSIX) += vhost-user.o +common-obj-$(CONFIG_VHOST_USER) += vhost-user.oSo we could have something like:
+common-obj-$(not
CONFIG_VHOST_USER) += vhost-user-stubs.o?
Quoted 6 lines
Quoted 5 lines
net/Makefile.objs +0
-1common-obj-$(CONFIG_SLIRP) += slirp.o common-obj-$(CONFIG_VDE) += vde.o common-obj-$(CONFIG_NETMAP) += netmap.o --2.14.0.rc0.1.g40ca67566