Skip to contentSkip to conversation

Fix NetBSD build (don't build ivshmem tools)

PATCH In review Peter Maydell 3 participants 10 messages Jul 14, 2017 – Jul 20, 2017 Kbuild

lore
Share & tools
lore
#0 lore raw

cover Fix NetBSD build (don't build ivshmem tools)

This patchset fixes the build on NetBSD by making sure we only build the ivshmem-client and ivshmem-server tools if the host OS actually supports ivshmem. (Previously we were only gating building of the within-QEMU ivshmem PCI device.)

Most of this patchset is the work of Kamil Rytarowski; I just split it up into easily-reviewable patches and fixed a few bugs.

Tested on Linux, on NetBSD, and on Linux with a '--disable-linux-user --disable-system' config (which was the one that was failing with our previous attempt to fix this bug).

NB: we still have some things we need to fix to be able to put NetBSD into the build-test set. The next issue is that 'make check' fails with

MALLOC_PERTURB_=${MALLOC_PERTURB_:-$((RANDOM % 255 + 1))} gtester -k --verbose -m=quick tests/check-qdict
sh: arith: syntax error: "RANDOM % 255 + 1"

likely because we're using a bashism there.

thanks
-- PMM

Kamil Rytarowski (2):
configure: Use an explicit CONFIG_IVSHMEM rather than CONFIG_EVENTFD
configure: Don't build ivshmem tools unless CONFIG_IVSHMEM is set

Peter Maydell (1):
configure: Rename CONFIG_IVSHMEM to CONFIG_IVSHMEM_DEVICE

 configure               | 11 +++++++++++
 Makefile                |  2 ++
 Makefile.objs           |  4 ++--
 hw/misc/Makefile.objs   |  2 +-
 tests/Makefile.include  |  4 ++--
 default-configs/pci.mak |  2 +-
 6 files changed, 19 insertions(+), 6 deletions(-)
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/3 configure: Rename CONFIG_IVSHMEM to CONFIG_IVSHMEM_DEVICE

The current CONFIG_IVSHMEM is confusing, because it looks like it's a flag for "do we have ivshmem support?", but actually it's a flag for "is the ivshmem PCI device being compiled?" (and implicitly "do we have ivshmem support?" is tested with CONFIG_EVENTFD).

Rename it to CONFIG_IVSHMEM_DEVICE to clear this confusion up; shortly we will add a new CONFIG_IVSHMEM which really does indicate whether the host can support ivshmem.

---
 hw/misc/Makefile.objs   | 2 +-
 default-configs/pci.mak | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
hw/misc/Makefile.objs +1 -1
index 7e373db..28c1560 100644
@@ -23,7 +23,7 @@ common-obj-$(CONFIG_PUV3) += puv3_pm.o
 
 common-obj-$(CONFIG_MACIO) += macio/
 
-obj-$(CONFIG_IVSHMEM) += ivshmem.o
+obj-$(CONFIG_IVSHMEM_DEVICE) += ivshmem.o
 
 obj-$(CONFIG_REALVIEW) += arm_sysctl.o
 obj-$(CONFIG_NSERIES) += cbus.o
default-configs/pci.mak +1 -1
index 53ff109..2451eb2 100644
@@ -41,6 +41,6 @@ CONFIG_SDHCI=y
 CONFIG_EDU=y
 CONFIG_VGA=y
 CONFIG_VGA_PCI=y
-CONFIG_IVSHMEM=$(CONFIG_EVENTFD)
+CONFIG_IVSHMEM_DEVICE=$(CONFIG_EVENTFD)
 CONFIG_ROCKER=y
 CONFIG_VHOST_USER_SCSI=$(CONFIG_LINUX)
Signature · 1 line
2.7.4
#2 lore raw

Re: [Qemu-devel] [PATCH 1/3] configure: Rename CONFIG_IVSHMEM to CONFIG_IVSHMEM_DEVICE

Quoted 10 lines · Peter Maydell

The current CONFIG_IVSHMEM is confusing, because it looks like it's a flag for "do we have ivshmem support?", but actually it's a flag for "is the ivshmem PCI device being compiled?" (and implicitly "do we have ivshmem support?" is tested with CONFIG_EVENTFD).

Rename it to CONFIG_IVSHMEM_DEVICE to clear this confusion up; shortly we will add a new CONFIG_IVSHMEM which really does indicate whether the host can support ivshmem.

I don't really care how we name this macro, but I can't help to wonder... We have many CONFIG_<dev>. The pci.mak context even shows some. Why is <dev> = IVSHMEM confusing? Why is <dev> = EDU *not* confusing?

Quoted 30 lines
---
 hw/misc/Makefile.objs   | 2 +-
 default-configs/pci.mak | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
hw/misc/Makefile.objs +1 -1
index 7e373db..28c1560 100644
@@ -23,7 +23,7 @@ common-obj-$(CONFIG_PUV3) += puv3_pm.o
 
 common-obj-$(CONFIG_MACIO) += macio/
 
-obj-$(CONFIG_IVSHMEM) += ivshmem.o
+obj-$(CONFIG_IVSHMEM_DEVICE) += ivshmem.o
 
 obj-$(CONFIG_REALVIEW) += arm_sysctl.o
 obj-$(CONFIG_NSERIES) += cbus.o
default-configs/pci.mak +1 -1
index 53ff109..2451eb2 100644
@@ -41,6 +41,6 @@ CONFIG_SDHCI=y
 CONFIG_EDU=y
 CONFIG_VGA=y
 CONFIG_VGA_PCI=y
-CONFIG_IVSHMEM=$(CONFIG_EVENTFD)
+CONFIG_IVSHMEM_DEVICE=$(CONFIG_EVENTFD)
 CONFIG_ROCKER=y
 CONFIG_VHOST_USER_SCSI=$(CONFIG_LINUX)
#3 lore raw

Re: [Qemu-devel] [PATCH 1/3] configure: Rename CONFIG_IVSHMEM to CONFIG_IVSHMEM_DEVICE

Quoted 11 lines · Markus Armbruster
Quoted 9 lines · Peter Maydell

The current CONFIG_IVSHMEM is confusing, because it looks like it's a flag for "do we have ivshmem support?", but actually it's a flag for "is the ivshmem PCI device being compiled?" (and implicitly "do we have ivshmem support?" is tested with CONFIG_EVENTFD).

Rename it to CONFIG_IVSHMEM_DEVICE to clear this confusion up; shortly we will add a new CONFIG_IVSHMEM which really does indicate whether the host can support ivshmem.

Quoted 6 lines
Quoted 1 line

I don't really care how we name this macro, but I can't help to wonder... We have many CONFIG_<dev>. The pci.mak context even shows some. Why is <dev> = IVSHMEM confusing? Why is <dev> = EDU *not* confusing?

Well, this did confuse the people involved in trying to fix this bug first time round, because we tried to add
an "ifdef CONFIG_IVSHMEM" guard to the Makefile lines that defnie the rules for ivshmem-client and ivshmem-server, and it it fails in obscure and confusing ways because CONFIG_IVSHMEM doesn't mean "ivshmem OK", it means only "this particular foo-softmmu build has the ivshmem device in it".

Basically, it looks like a global config flag but it isn't (because ivshmem has globally built parts, ie the tools, as well as the device itself, and configure tests that control whether it can be built or not) whereas nobody thinks CONFIG_EDU is something that should control global parts of the build because the device is only the device and the host config doesn't matter.

thanks
-- PMM

#4 lore raw

PATCH 2/3 configure: Use an explicit CONFIG_IVSHMEM rather than CONFIG_EVENTFD

In reply to Peter Maydell

From: Kamil Rytarowski <[email protected]>

Rather than relying on everywhere that cares about whether the host supports ivshmem using CONFIG_EVENTFD, make configure set an explicit CONFIG_IVSHMEM.

[PMM: split out from another patch, add commit message]
---
 configure               | 9 +++++++++
 tests/Makefile.include  | 4 ++--
 default-configs/pci.mak | 2 +-
 3 files changed, 12 insertions(+), 3 deletions(-)
configure +9 -0
index 5096cbc..dea46c5 100755
@@ -4969,6 +4969,11 @@ qemu_moddir=$libdir$confsuffix
 qemu_datadir=$datadir$confsuffix
 qemu_localedir="$datadir/locale"
 
+# We can only support ivshmem if we have eventfd
+if [ "$eventfd" = "yes" ]; then
+  ivshmem=yes
+fi
+
 tools=""
 if test "$want_tools" = "yes" ; then
   tools="qemu-img\$(EXESUF) qemu-io\$(EXESUF) $tools"
@@ -5955,6 +5960,10 @@ if test "$have_static_assert" = "yes" ; then
   echo "CONFIG_STATIC_ASSERT=y" >> $config_host_mak
 fi
 
+if test "$ivshmem" = "yes" ; then
+  echo "CONFIG_IVSHMEM=y" >> $config_host_mak
+fi
+
 # Hold two types of flag:
 #   CONFIG_THREAD_SETNAME_BYTHREAD  - we've got a way of setting the name on
 #                                     a thread we have a handle to
tests/Makefile.include +2 -2
index 42e17e2..6d6cb74 100644
@@ -201,7 +201,7 @@ gcov-files-pci-y += hw/display/virtio-gpu-pci.c
 gcov-files-pci-$(CONFIG_VIRTIO_VGA) += hw/display/virtio-vga.c
 check-qtest-pci-y += tests/intel-hda-test$(EXESUF)
 gcov-files-pci-y += hw/audio/intel-hda.c hw/audio/hda-codec.c
-check-qtest-pci-$(CONFIG_EVENTFD) += tests/ivshmem-test$(EXESUF)
+check-qtest-pci-$(CONFIG_IVSHMEM) += tests/ivshmem-test$(EXESUF)
 gcov-files-pci-y += hw/misc/ivshmem.c
 check-qtest-pci-y += tests/megasas-test$(EXESUF)
 gcov-files-pci-y += hw/scsi/megasas.c
@@ -303,7 +303,7 @@ check-qtest-ppc64-y += tests/test-filter-mirror$(EXESUF)
 check-qtest-ppc64-y += tests/test-filter-redirector$(EXESUF)
 check-qtest-ppc64-y += tests/display-vga-test$(EXESUF)
 check-qtest-ppc64-y += tests/numa-test$(EXESUF)
-check-qtest-ppc64-$(CONFIG_EVENTFD) += tests/ivshmem-test$(EXESUF)
+check-qtest-ppc64-$(CONFIG_IVSHMEM) += tests/ivshmem-test$(EXESUF)
 
 check-qtest-sh4-y = tests/endianness-test$(EXESUF)
 
default-configs/pci.mak +1 -1
index 2451eb2..acaa703 100644
@@ -41,6 +41,6 @@ CONFIG_SDHCI=y
 CONFIG_EDU=y
 CONFIG_VGA=y
 CONFIG_VGA_PCI=y
-CONFIG_IVSHMEM_DEVICE=$(CONFIG_EVENTFD)
+CONFIG_IVSHMEM_DEVICE=$(CONFIG_IVSHMEM)
 CONFIG_ROCKER=y
 CONFIG_VHOST_USER_SCSI=$(CONFIG_LINUX)
Signature · 1 line
2.7.4
#5 lore raw

PATCH 3/3 configure: Don't build ivshmem tools unless CONFIG_IVSHMEM is set

In reply to Peter Maydell

From: Kamil Rytarowski <[email protected]>

Don't try to build the ivshmem-server and ivshmem-client tools unless CONFIG_IVSHMEM is set.

This fixes in passing a build bug on NetBSD, which fails to build the ivshmem tools because they use shm_open() and on NetBSD that requires linking against -lrt.

[PMM: moved some code into earlier patches; minor bugfixes;
added commit message]

---
 configure     | 2 ++
 Makefile      | 2 ++
 Makefile.objs | 4 ++--
 3 files changed, 6 insertions(+), 2 deletions(-)
configure +2 -0
index dea46c5..b54bc2e 100755
@@ -4979,6 +4979,8 @@ if test "$want_tools" = "yes" ; then
   tools="qemu-img\$(EXESUF) qemu-io\$(EXESUF) $tools"
   if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" ] ; then
     tools="qemu-nbd\$(EXESUF) $tools"
+  fi
+  if [ "$ivshmem" = "yes" ]; then
     tools="ivshmem-client\$(EXESUF) ivshmem-server\$(EXESUF) $tools"
   fi
 fi
Makefile +2 -0
index 16a0430..5d5bd6a 100644
@@ -470,10 +470,12 @@ ifneq ($(EXESUF),)
 qemu-ga: qemu-ga$(EXESUF) $(QGA_VSS_PROVIDER) $(QEMU_GA_MSI)
 endif
 
+ifdef CONFIG_IVSHMEM
 ivshmem-client$(EXESUF): $(ivshmem-client-obj-y) $(COMMON_LDADDS)
 	$(call LINK, $^)
 ivshmem-server$(EXESUF): $(ivshmem-server-obj-y) $(COMMON_LDADDS)
 	$(call LINK, $^)
+endif
 vhost-user-scsi$(EXESUF): $(vhost-user-scsi-obj-y)
 	$(call LINK, $^)
 
Makefile.objs +2 -2
index bfd5a6c..24a4ea0 100644
@@ -107,8 +107,8 @@ qga-vss-dll-obj-y = qga/
 
 ######################################################################
 # contrib
-ivshmem-client-obj-y = contrib/ivshmem-client/
-ivshmem-server-obj-y = contrib/ivshmem-server/
+ivshmem-client-obj-$(CONFIG_IVSHMEM) = contrib/ivshmem-client/
+ivshmem-server-obj-$(CONFIG_IVSHMEM) = contrib/ivshmem-server/
 libvhost-user-obj-y = contrib/libvhost-user/
 vhost-user-scsi.o-cflags := $(LIBISCSI_CFLAGS)
 vhost-user-scsi.o-libs := $(LIBISCSI_LIBS)
Signature · 1 line
2.7.4
#6 lore raw
In reply to Peter Maydell

Ping for review? It would be nice to get the NetBSD host into the build-test rotation...

thanks
-- PMM

Quoted 38 lines · Peter Maydell

This patchset fixes the build on NetBSD by making sure we only build the ivshmem-client and ivshmem-server tools if the host OS actually supports ivshmem. (Previously we were only gating building of the within-QEMU ivshmem PCI device.)

Most of this patchset is the work of Kamil Rytarowski; I just split it up into easily-reviewable patches and fixed a few bugs.

Tested on Linux, on NetBSD, and on Linux with a '--disable-linux-user --disable-system' config (which was the one that was failing with our previous attempt to fix this bug).

NB: we still have some things we need to fix to be able to put NetBSD into the build-test set. The next issue is that 'make check' fails with

MALLOC_PERTURB_=${MALLOC_PERTURB_:-$((RANDOM % 255 + 1))} gtester -k --verbose -m=quick tests/check-qdict
sh: arith: syntax error: "RANDOM % 255 + 1"

likely because we're using a bashism there.

thanks
-- PMM

Kamil Rytarowski (2):
configure: Use an explicit CONFIG_IVSHMEM rather than CONFIG_EVENTFD
configure: Don't build ivshmem tools unless CONFIG_IVSHMEM is set

Peter Maydell (1):
configure: Rename CONFIG_IVSHMEM to CONFIG_IVSHMEM_DEVICE

 configure               | 11 +++++++++++
 Makefile                |  2 ++
 Makefile.objs           |  4 ++--
 hw/misc/Makefile.objs   |  2 +-
 tests/Makefile.include  |  4 ++--
 default-configs/pci.mak |  2 +-
 6 files changed, 19 insertions(+), 6 deletions(-)
Reviewed-by on the v1 series
#7 lore raw
In reply to Peter Maydell
Quoted 12 lines · Peter Maydell

This patchset fixes the build on NetBSD by making sure we only build the ivshmem-client and ivshmem-server tools if the host OS actually supports ivshmem. (Previously we were only gating building of the within-QEMU ivshmem PCI device.)

Most of this patchset is the work of Kamil Rytarowski; I just split it up into easily-reviewable patches and fixed a few bugs.

Tested on Linux, on NetBSD, and on Linux with a '--disable-linux-user --disable-system' config (which was the one that was failing with our previous attempt to fix this bug).

Quoted 8 lines

NB: we still have some things we need to fix to be able to put NetBSD into the build-test set. The next issue is that 'make check' fails with

MALLOC_PERTURB_=${MALLOC_PERTURB_:-$((RANDOM % 255 + 1))} gtester -k --verbose -m=quick tests/check-qdict
sh: arith: syntax error: "RANDOM % 255 + 1"

likely because we're using a bashism there.

Regardless of my inability to find CONFIG_IVSHMEM confusing (see PATCH 1), series