All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PULL 00/54] Misc patches for 2018-12-12
@ 2018-12-12 15:22 Paolo Bonzini
  2018-12-12 15:22 ` [Qemu-devel] [PULL 01/54] accel: Improve selection of the default accelerator Paolo Bonzini
                   ` (55 more replies)
  0 siblings, 56 replies; 60+ messages in thread
From: Paolo Bonzini @ 2018-12-12 15:22 UTC (permalink / raw)
  To: qemu-devel

The following changes since commit bb9bf94b3e8926553290bc9a7cb84315af422086:

  Merge remote-tracking branch 'remotes/ehabkost/tags/machine-next-pull-request' into staging (2018-12-11 19:18:58 +0000)

are available in the git repository at:


  git://github.com/bonzini/qemu.git tags/for-upstream

for you to fetch changes up to e2a9129b491fdb3be3661baf08a9fa4c2e19a028:

  vhost-user-test: create a temporary directory per TestServer (2018-12-12 13:49:31 +0100)

This introduces a new dependency on perl's Test::Harness package.  This is
distributed in package perl-Test-Harness for Fedora, and libtest-harness-perl
for Debian.  I couldn't find anything for BSD or macOS, but at least the
Patchew BSD images already have it so it is probably bundled with Perl.

Thanks,

Paolo

----------------------------------------------------------------
* HAX support for Linux hosts (Alejandro)
* esp bugfixes (Guenter)
* Windows build cleanup (Marc-André)
* checkpatch logic improvements (Paolo)
* coalesced range bugfix (Paolo)
* switch testsuite to TAP (Paolo)
* QTAILQ rewrite (Paolo)
* enable vhost for TCG and clean up vhost-user-test (Paolo)
* block/iscsi.c cancellation fixes (Stefan)
* improve selection of the default accelerator (Thomas)
* add explicit checks for the compiler version and cleanup (Thomas)

----------------------------------------------------------------
Alexandro Sanchez Bach (1):
      hax: Support for Linux hosts

Guenter Roeck (2):
      esp-pci: Fix status register write erase control
      scsi: esp: Defer command completion until previous interrupts have been handled

Marc-André Lureau (5):
      vhost-user-bridge: fix "unknown type name" compilation error
      build-sys: don't include windows.h, osdep.h does it
      build-sys: move windows defines in osdep.h header
      build-sys: build with Vista API by default
      RFC: qga: drop < Vista compatibility

Paolo Bonzini (32):
      checkpatch: fix premature exit when no input or --mailback
      checkpatch: check Signed-off-by in --mailback mode
      checkpatch: improve handling of multiple patches or files
      checkpatch: colorize output to terminal
      pam: wrap MemoryRegion initialization in a transaction
      memory: extract flat_range_coalesced_io_{del,add}
      memory: avoid unnecessary coalesced_io_del operations
      memory: update coalesced_range on transaction_commit
      test: execute g_test_run when tests are skipped
      test: replace gtester with a TAP driver
      qemu/queue.h: do not access tqe_prev directly
      vfio: make vfio_address_spaces static
      qemu/queue.h: leave head structs anonymous unless necessary
      qemu/queue.h: typedef QTAILQ heads
      qemu/queue.h: remove Q_TAILQ_{HEAD,ENTRY}
      qemu/queue.h: reimplement QTAILQ without pointer-to-pointers
      qemu/queue.h: simplify reverse access to QTAILQ
      checkpatch: warn about qemu/queue.h head structs that are not typedef-ed
      vhost-net: move stubs to a separate file
      vhost-net-user: add stubs for when no virtio-net device is present
      vhost: restrict Linux dependency to kernel vhost
      vhost-net: compile it on all targets that have virtio-net.
      vhost-net: revamp configure logic
      vhost-user-test: use g_cond_broadcast
      vhost-user-test: signal data_cond when s->rings changes
      vhost-user: support cross-endian vnet headers
      vhost-user-test: support VHOST_USER_PROTOCOL_F_CROSS_ENDIAN
      vhost-user-test: skip if there is no memory at address 0
      vhost-user-test: reduce usage of global_qtest
      vhost-user-test: create a main loop per TestServer
      vhost-user-test: small changes to init_hugepagefs
      vhost-user-test: create a temporary directory per TestServer

Peng Hao (1):
      hw/watchdog/wdt_i6300esb : remove a unnecessary comment

Stefan Hajnoczi (4):
      block/iscsi: drop unused IscsiAIOCB->buf field
      block/iscsi: take iscsilun->mutex in iscsi_timed_check_events()
      block/iscsi: fix ioctl cancel use-after-free
      block/iscsi: cancel libiscsi task when ABORT TASK TMF completes

Thomas Huth (9):
      accel: Improve selection of the default accelerator
      compiler.h: Add an explicit check for the compiler version
      configure: Add a test for the minimum compiler version
      configure: Remove obsolete check for Clang < 3.2
      configure: Remove old -fno-gcse workaround for GCC 4.6.x and 4.7.[012]
      tcg/tcg.h: Remove GCC check for tcg_debug_assert() macro
      audio/alsaaudio: Remove compiler check around pragma
      includes: Replace QEMU_GNUC_PREREQ with "__has_builtin || !defined(__clang__)"
      Remove QEMU_ARTIFICIAL macro

 Makefile.target                              |   3 -
 accel/accel.c                                |  18 +-
 accel/kvm/kvm-all.c                          |   4 +-
 accel/tcg/translate-all.c                    |   4 -
 audio/alsaaudio.c                            |   2 -
 backends/Makefile.objs                       |   5 +-
 block/gluster.c                              |   2 +-
 block/iscsi.c                                |  47 +++-
 block/mirror.c                               |   2 +-
 block/qcow2-bitmap.c                         |   4 +-
 block/qcow2.h                                |   2 +-
 block/sheepdog.c                             |   6 +-
 block/vhdx.h                                 |   2 +-
 blockdev.c                                   |   4 +-
 configure                                    | 151 ++++++-----
 contrib/ivshmem-client/ivshmem-client.h      |   4 +-
 contrib/ivshmem-server/ivshmem-server.h      |   5 +-
 cpus-common.c                                |   2 +-
 default-configs/virtio.mak                   |   4 +-
 dump.c                                       |   2 +-
 exec.c                                       |   5 +-
 fsdev/qemu-fsdev.c                           |   2 +-
 hw/block/nvme.h                              |   8 +-
 hw/block/xen_disk.c                          |   6 +-
 hw/core/qdev.c                               |   4 +-
 hw/core/reset.c                              |   2 +-
 hw/i386/xen/xen-mapcache.c                   |   2 +-
 hw/net/Makefile.objs                         |   4 +-
 hw/net/vhost_net-stub.c                      |  92 +++++++
 hw/net/vhost_net.c                           |  78 +-----
 hw/pci-host/pam.c                            |   2 +
 hw/ppc/spapr_iommu.c                         |   2 +-
 hw/scsi/esp-pci.c                            |  10 +-
 hw/scsi/esp.c                                |  33 ++-
 hw/scsi/scsi-bus.c                           |   2 +-
 hw/scsi/trace-events                         |   1 +
 hw/usb/ccid-card-emulated.c                  |   4 +-
 hw/usb/combined-packet.c                     |   2 +-
 hw/usb/dev-mtp.c                             |   4 +-
 hw/usb/dev-network.c                         |   2 +-
 hw/usb/hcd-ehci.c                            |   2 +-
 hw/usb/hcd-ehci.h                            |   2 +-
 hw/usb/hcd-uhci.c                            |   4 +-
 hw/usb/xen-usb.c                             |   6 +-
 hw/vfio/common.c                             |   4 +-
 hw/virtio/Makefile.objs                      |   5 +-
 hw/virtio/vhost-backend.c                    |  11 +-
 hw/watchdog/watchdog.c                       |   2 +-
 hw/watchdog/wdt_i6300esb.c                   |   1 -
 hw/xen/xen_pvdev.c                           |   4 +-
 include/exec/memory.h                        |   6 +-
 include/exec/poison.h                        |   1 -
 include/hw/qdev-core.h                       |   2 +-
 include/hw/scsi/esp.h                        |   2 +
 include/hw/usb.h                             |   2 +-
 include/hw/vfio/vfio-common.h                |   4 +-
 include/hw/vfio/vfio-platform.h              |   2 +-
 include/net/net.h                            |   2 +-
 include/qemu/compiler.h                      |  16 +-
 include/qemu/host-utils.h                    |   4 +-
 include/qemu/option_int.h                    |   2 +-
 include/qemu/osdep.h                         |  17 ++
 include/qemu/queue.h                         | 153 +++++------
 include/qemu/rcu_queue.h                     |  45 ++--
 include/qom/cpu.h                            |   9 +-
 include/sysemu/accel.h                       |   2 +-
 include/sysemu/kvm.h                         |   2 -
 include/sysemu/memory_mapping.h              |   2 +-
 include/sysemu/rng.h                         |   2 +-
 linux-user/elfload.c                         |   2 +-
 memory.c                                     |  97 ++++---
 memory_mapping.c                             |   2 +-
 migration/block-dirty-bitmap.c               |   2 +-
 migration/block.c                            |   4 +-
 migration/ram.c                              |   2 +-
 monitor.c                                    |   4 +-
 net/Makefile.objs                            |   4 +-
 net/filter.c                                 |   2 +-
 net/net.c                                    |   4 +-
 net/queue.c                                  |   2 +-
 net/slirp.c                                  |   2 +-
 net/vhost-user-stub.c                        |  23 ++
 net/vhost-user.c                             |  13 +
 qga/commands-posix.c                         |   2 +-
 qga/commands-win32.c                         |  70 +----
 scripts/checkpatch.pl                        |  96 +++++--
 scripts/cocci-macro-file.h                   |  25 +-
 scripts/gtester-cat                          |  26 --
 scripts/tap-driver.pl                        | 378 +++++++++++++++++++++++++++
 scripts/tap-merge.pl                         | 110 ++++++++
 slirp/slirp.c                                |   2 +-
 target/arm/kvm.c                             |   2 +-
 target/i386/Makefile.objs                    |   6 +-
 target/i386/hax-i386.h                       |   6 +-
 target/i386/hax-mem.c                        |   2 +-
 target/i386/{hax-darwin.c => hax-posix.c}    |   0
 target/i386/{hax-darwin.h => hax-posix.h}    |   0
 tcg/tcg.c                                    |   2 +-
 tcg/tcg.h                                    |  10 +-
 tests/Makefile.include                       |  59 +++--
 tests/cdrom-test.c                           |   2 +-
 tests/docker/dockerfiles/centos7.docker      |   1 +
 tests/docker/dockerfiles/debian-amd64.docker |   1 +
 tests/docker/dockerfiles/debian-ports.docker |   1 +
 tests/docker/dockerfiles/debian-sid.docker   |   1 +
 tests/docker/dockerfiles/debian8.docker      |   1 +
 tests/docker/dockerfiles/debian9.docker      |   1 +
 tests/docker/dockerfiles/fedora.docker       |   1 +
 tests/docker/dockerfiles/ubuntu.docker       |   1 +
 tests/libqos/malloc.c                        |   2 +-
 tests/migration-test.c                       |   8 +-
 tests/test-rcu-list.c                        |   2 +-
 tests/test-vmstate.c                         |   8 +-
 tests/vhost-user-bridge.c                    |   3 +-
 tests/vhost-user-test.c                      | 234 +++++++++--------
 ui/console.c                                 |   4 +-
 ui/input.c                                   |  14 +-
 util/qemu-option.c                           |   4 +-
 util/qemu-thread-win32.c                     |   4 -
 vl.c                                         |   4 +-
 120 files changed, 1373 insertions(+), 737 deletions(-)
 create mode 100644 hw/net/vhost_net-stub.c
 create mode 100644 net/vhost-user-stub.c
 delete mode 100755 scripts/gtester-cat
 create mode 100755 scripts/tap-driver.pl
 create mode 100755 scripts/tap-merge.pl
 rename target/i386/{hax-darwin.c => hax-posix.c} (100%)
 rename target/i386/{hax-darwin.h => hax-posix.h} (100%)
-- 
1.8.3.1

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

* [Qemu-devel] [PULL 01/54] accel: Improve selection of the default accelerator
  2018-12-12 15:22 [Qemu-devel] [PULL 00/54] Misc patches for 2018-12-12 Paolo Bonzini
@ 2018-12-12 15:22 ` Paolo Bonzini
  2018-12-12 15:22 ` [Qemu-devel] [PULL 02/54] vhost-user-bridge: fix "unknown type name" compilation error Paolo Bonzini
                   ` (54 subsequent siblings)
  55 siblings, 0 replies; 60+ messages in thread
From: Paolo Bonzini @ 2018-12-12 15:22 UTC (permalink / raw)
  To: qemu-devel; +Cc: Thomas Huth

From: Thomas Huth <thuth@redhat.com>

When compiling with "--disable-tcg", we currently still use "tcg"
as default accelerator. "kvm" should be used in this case instead.
Also, some downstream distros provide QEMU binaries which have "kvm"
in their names (e.g. "qemu-kvm" on RHEL or "kvm" on Ubuntu) that use
KVM by default - and some users might want to do something similar
with upstream binaries, too. Accomodate them by using "kvm:tcg" as
default when we detect such a binary name.

Signed-off-by: Thomas Huth <thuth@redhat.com>
Message-Id: <1538748792-19444-1-git-send-email-thuth@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 accel/accel.c          | 18 +++++++++++++++---
 include/sysemu/accel.h |  2 +-
 vl.c                   |  2 +-
 3 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/accel/accel.c b/accel/accel.c
index 3da26eb..1b1214e 100644
--- a/accel/accel.c
+++ b/accel/accel.c
@@ -69,7 +69,7 @@ static int accel_init_machine(AccelClass *acc, MachineState *ms)
     return ret;
 }
 
-void configure_accelerator(MachineState *ms)
+void configure_accelerator(MachineState *ms, const char *progname)
 {
     const char *accel;
     char **accel_list, **tmp;
@@ -80,8 +80,20 @@ void configure_accelerator(MachineState *ms)
 
     accel = qemu_opt_get(qemu_get_machine_opts(), "accel");
     if (accel == NULL) {
-        /* Use the default "accelerator", tcg */
-        accel = "tcg";
+        /* Select the default accelerator */
+        int pnlen = strlen(progname);
+        if (pnlen >= 3 && g_str_equal(&progname[pnlen - 3], "kvm")) {
+            /* If the program name ends with "kvm", we prefer KVM */
+            accel = "kvm:tcg";
+        } else {
+#if defined(CONFIG_TCG)
+            accel = "tcg";
+#elif defined(CONFIG_KVM)
+            accel = "kvm";
+#else
+#error "No default accelerator available"
+#endif
+        }
     }
 
     accel_list = g_strsplit(accel, ":", 0);
diff --git a/include/sysemu/accel.h b/include/sysemu/accel.h
index 637358f..285899e 100644
--- a/include/sysemu/accel.h
+++ b/include/sysemu/accel.h
@@ -66,7 +66,7 @@ typedef struct AccelClass {
 
 extern unsigned long tcg_tb_size;
 
-void configure_accelerator(MachineState *ms);
+void configure_accelerator(MachineState *ms, const char *progname);
 /* Register accelerator specific global properties */
 void accel_register_compat_props(AccelState *accel);
 /* Called just before os_setup_post (ie just before drop OS privs) */
diff --git a/vl.c b/vl.c
index a5ae5f2..f6a6193 100644
--- a/vl.c
+++ b/vl.c
@@ -4308,7 +4308,7 @@ int main(int argc, char **argv, char **envp)
     qemu_opt_foreach(machine_opts, machine_set_property, current_machine,
                      &error_fatal);
 
-    configure_accelerator(current_machine);
+    configure_accelerator(current_machine, argv[0]);
 
     if (!qtest_enabled() && machine_class->deprecation_reason) {
         error_report("Machine type '%s' is deprecated: %s",
-- 
1.8.3.1

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

* [Qemu-devel] [PULL 02/54] vhost-user-bridge: fix "unknown type name" compilation error
  2018-12-12 15:22 [Qemu-devel] [PULL 00/54] Misc patches for 2018-12-12 Paolo Bonzini
  2018-12-12 15:22 ` [Qemu-devel] [PULL 01/54] accel: Improve selection of the default accelerator Paolo Bonzini
@ 2018-12-12 15:22 ` Paolo Bonzini
  2018-12-12 15:22 ` [Qemu-devel] [PULL 03/54] checkpatch: fix premature exit when no input or --mailback Paolo Bonzini
                   ` (53 subsequent siblings)
  55 siblings, 0 replies; 60+ messages in thread
From: Paolo Bonzini @ 2018-12-12 15:22 UTC (permalink / raw)
  To: qemu-devel; +Cc: Marc-André Lureau

From: Marc-André Lureau <marcandre.lureau@redhat.com>

osdep.h should be included first:

  CC      tests/vhost-user-bridge.o
In file included from /home/elmarco/src/qemu/tests/vhost-user-bridge.c:32:
/home/elmarco/src/qemu/include/qemu/atomic.h:480:1: error: unknown type name ‘int64_t’
 int64_t  atomic_read_i64(const int64_t *ptr);
 ^~~~~~~
/home/elmarco/src/qemu/include/qemu/atomic.h:480:32: error: unknown type name ‘int64_t’
 int64_t  atomic_read_i64(const int64_t *ptr);
                                ^~~~~~~
/home/elmarco/src/qemu/include/qemu/atomic.h:481:1: error: unknown type name ‘uint64_t’
 uint64_t atomic_read_u64(const uint64_t *ptr);
 ^~~~~~~~
/home/elmarco/src/qemu/include/qemu/atomic.h:481:32: error: unknown type name ‘uint64_t’
 uint64_t atomic_read_u64(const uint64_t *ptr);
                                ^~~~~~~~
/home/elmarco/src/qemu/include/qemu/atomic.h:482:21: error: unknown type name ‘int64_t’
 void atomic_set_i64(int64_t *ptr, int64_t val);
                     ^~~~~~~
/home/elmarco/src/qemu/include/qemu/atomic.h:482:35: error: unknown type name ‘int64_t’
 void atomic_set_i64(int64_t *ptr, int64_t val);
                                   ^~~~~~~
/home/elmarco/src/qemu/include/qemu/atomic.h:483:21: error: unknown type name ‘uint64_t’
 void atomic_set_u64(uint64_t *ptr, uint64_t val);
                     ^~~~~~~~
/home/elmarco/src/qemu/include/qemu/atomic.h:483:36: error: unknown type name ‘uint64_t’
 void atomic_set_u64(uint64_t *ptr, uint64_t val);
                                    ^~~~~~~~

(regression from 782da5b2921c4d18777d5d5bd9385b9f7beae360)

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20181031104136.9953-1-marcandre.lureau@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Emilio G. Cota <cota@braap.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 tests/vhost-user-bridge.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tests/vhost-user-bridge.c b/tests/vhost-user-bridge.c
index 0cf8d0b..e029e5b 100644
--- a/tests/vhost-user-bridge.c
+++ b/tests/vhost-user-bridge.c
@@ -29,8 +29,9 @@
 
 #define _FILE_OFFSET_BITS 64
 
-#include "qemu/atomic.h"
 #include "qemu/osdep.h"
+
+#include "qemu/atomic.h"
 #include "qemu/iov.h"
 #include "standard-headers/linux/virtio_net.h"
 #include "contrib/libvhost-user/libvhost-user.h"
-- 
1.8.3.1

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

* [Qemu-devel] [PULL 03/54] checkpatch: fix premature exit when no input or --mailback
  2018-12-12 15:22 [Qemu-devel] [PULL 00/54] Misc patches for 2018-12-12 Paolo Bonzini
  2018-12-12 15:22 ` [Qemu-devel] [PULL 01/54] accel: Improve selection of the default accelerator Paolo Bonzini
  2018-12-12 15:22 ` [Qemu-devel] [PULL 02/54] vhost-user-bridge: fix "unknown type name" compilation error Paolo Bonzini
@ 2018-12-12 15:22 ` Paolo Bonzini
  2018-12-12 15:22 ` [Qemu-devel] [PULL 04/54] checkpatch: check Signed-off-by in --mailback mode Paolo Bonzini
                   ` (52 subsequent siblings)
  55 siblings, 0 replies; 60+ messages in thread
From: Paolo Bonzini @ 2018-12-12 15:22 UTC (permalink / raw)
  To: qemu-devel

In some cases, checkpatch's process subroutine is exiting the
whole process.  This is wrong, just return from the subroutine
instead.

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 scripts/checkpatch.pl | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 60f6f89..b9974f0 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2820,19 +2820,19 @@ sub process {
 	# If we have no input at all, then there is nothing to report on
 	# so just keep quiet.
 	if ($#rawlines == -1) {
-		exit(0);
+		return 1;
 	}
 
 	# In mailback mode only produce a report in the negative, for
 	# things that appear to be patches.
 	if ($mailback && ($clean == 1 || !$is_patch)) {
-		exit(0);
+		return 1;
 	}
 
 	# This is not a patch, and we are are in 'no-patch' mode so
 	# just keep quiet.
 	if (!$chk_patch && !$is_patch) {
-		exit(0);
+		return 1;
 	}
 
 	if (!$is_patch) {
-- 
1.8.3.1

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

* [Qemu-devel] [PULL 04/54] checkpatch: check Signed-off-by in --mailback mode
  2018-12-12 15:22 [Qemu-devel] [PULL 00/54] Misc patches for 2018-12-12 Paolo Bonzini
                   ` (2 preceding siblings ...)
  2018-12-12 15:22 ` [Qemu-devel] [PULL 03/54] checkpatch: fix premature exit when no input or --mailback Paolo Bonzini
@ 2018-12-12 15:22 ` Paolo Bonzini
  2018-12-12 15:22 ` [Qemu-devel] [PULL 05/54] checkpatch: improve handling of multiple patches or files Paolo Bonzini
                   ` (51 subsequent siblings)
  55 siblings, 0 replies; 60+ messages in thread
From: Paolo Bonzini @ 2018-12-12 15:22 UTC (permalink / raw)
  To: qemu-devel

Pull the test before the anticipated exits from the process sub.

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 scripts/checkpatch.pl | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index b9974f0..506aa6c 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2817,6 +2817,10 @@ sub process {
 		}
 	}
 
+	if ($is_patch && $chk_signoff && $signoff == 0) {
+		ERROR("Missing Signed-off-by: line(s)\n");
+	}
+
 	# If we have no input at all, then there is nothing to report on
 	# so just keep quiet.
 	if ($#rawlines == -1) {
@@ -2838,9 +2842,6 @@ sub process {
 	if (!$is_patch) {
 		ERROR("Does not appear to be a unified-diff format patch\n");
 	}
-	if ($is_patch && $chk_signoff && $signoff == 0) {
-		ERROR("Missing Signed-off-by: line(s)\n");
-	}
 
 	print report_dump();
 	if ($summary && !($clean == 1 && $quiet == 1)) {
-- 
1.8.3.1

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

* [Qemu-devel] [PULL 05/54] checkpatch: improve handling of multiple patches or files
  2018-12-12 15:22 [Qemu-devel] [PULL 00/54] Misc patches for 2018-12-12 Paolo Bonzini
                   ` (3 preceding siblings ...)
  2018-12-12 15:22 ` [Qemu-devel] [PULL 04/54] checkpatch: check Signed-off-by in --mailback mode Paolo Bonzini
@ 2018-12-12 15:22 ` Paolo Bonzini
  2018-12-12 15:22 ` [Qemu-devel] [PULL 06/54] checkpatch: colorize output to terminal Paolo Bonzini
                   ` (50 subsequent siblings)
  55 siblings, 0 replies; 60+ messages in thread
From: Paolo Bonzini @ 2018-12-12 15:22 UTC (permalink / raw)
  To: qemu-devel

Similar to how patchew output looks like for multiple patches,
say what file or patch is being tested _before_ emitting errors.
This is clearer to a human that scans the output from top to
bottom.

In addition, provide a truncated commit hash and subject instead of
the full hash, and process the commits first-to-last rather than
last-to-first.

Inspired by Linux commit 0dea9f1eef86bedacad91b6f652ca1ab0d08854c
("checkpatch: reduce number of `git log` calls with --git", 2016-03-20).

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 scripts/checkpatch.pl | 30 +++++++++++++++++++++++-------
 1 file changed, 23 insertions(+), 7 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 506aa6c..2edb4e2 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -340,13 +340,18 @@ my @lines = ();
 my $vname;
 if ($chk_branch) {
 	my @patches;
+	my %git_commits = ();
 	my $HASH;
-	open($HASH, "-|", "git", "log", "--format=%H", $ARGV[0]) ||
-		die "$P: git log --format=%H $ARGV[0] failed - $!\n";
-
-	while (<$HASH>) {
-		chomp;
-		push @patches, $_;
+	open($HASH, "-|", "git", "log", "--reverse", "--no-merges", "--format=%H %s", $ARGV[0]) ||
+		die "$P: git log --reverse --no-merges --format='%H %s' $ARGV[0] failed - $!\n";
+
+	for my $line (<$HASH>) {
+		$line =~ /^([0-9a-fA-F]{40,40}) (.*)$/;
+		next if (!defined($1) || !defined($2));
+		my $sha1 = $1;
+		my $subject = $2;
+		push(@patches, $sha1);
+		$git_commits{$sha1} = $subject;
 	}
 
 	close $HASH;
@@ -354,21 +359,31 @@ if ($chk_branch) {
 	die "$P: no revisions returned for revlist '$chk_branch'\n"
 	    unless @patches;
 
+	my $i = 1;
+	my $num_patches = @patches;
 	for my $hash (@patches) {
 		my $FILE;
 		open($FILE, '-|', "git", "show", $hash) ||
 			die "$P: git show $hash - $!\n";
-		$vname = $hash;
 		while (<$FILE>) {
 			chomp;
 			push(@rawlines, $_);
 		}
 		close($FILE);
+		$vname = substr($hash, 0, 12) . ' (' . $git_commits{$hash} . ')';
+		if ($num_patches > 1 && $quiet == 0) {
+			print "$i/$num_patches Checking commit $vname\n";
+			$vname = "Patch $i/$num_patches";
+		} else {
+			$vname = "Commit " . $vname;
+		}
 		if (!process($hash)) {
 			$exit = 1;
+			print "\n" if ($num_patches > 1 && $quiet == 0);
 		}
 		@rawlines = ();
 		@lines = ();
+		$i++;
 	}
 } else {
 	for my $filename (@ARGV) {
@@ -387,6 +402,7 @@ if ($chk_branch) {
 		} else {
 			$vname = $filename;
 		}
+		print "Checking $filename...\n" if @ARGV > 1 && $quiet == 0;
 		while (<$FILE>) {
 			chomp;
 			push(@rawlines, $_);
-- 
1.8.3.1

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

* [Qemu-devel] [PULL 06/54] checkpatch: colorize output to terminal
  2018-12-12 15:22 [Qemu-devel] [PULL 00/54] Misc patches for 2018-12-12 Paolo Bonzini
                   ` (4 preceding siblings ...)
  2018-12-12 15:22 ` [Qemu-devel] [PULL 05/54] checkpatch: improve handling of multiple patches or files Paolo Bonzini
@ 2018-12-12 15:22 ` Paolo Bonzini
  2018-12-12 15:22 ` [Qemu-devel] [PULL 07/54] pam: wrap MemoryRegion initialization in a transaction Paolo Bonzini
                   ` (49 subsequent siblings)
  55 siblings, 0 replies; 60+ messages in thread
From: Paolo Bonzini @ 2018-12-12 15:22 UTC (permalink / raw)
  To: qemu-devel

Add optional colors to make seeing message types a bit easier.
The default is to show them on a tty.

Inspired by Linux commits 57230297116fa ("checkpatch: colorize output
to terminal") and 737c0767758b ("checkpatch: change format of --color
argument to --color[=WHEN]").

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 scripts/checkpatch.pl | 49 ++++++++++++++++++++++++++++++++++++++++++-------
 1 file changed, 42 insertions(+), 7 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 2edb4e2..a8d6e44 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -7,6 +7,7 @@
 
 use strict;
 use warnings;
+use Term::ANSIColor qw(:constants);
 
 my $P = $0;
 $P =~ s@.*/@@g;
@@ -26,6 +27,7 @@ my $tst_only;
 my $emacs = 0;
 my $terse = 0;
 my $file = undef;
+my $color = "auto";
 my $no_warnings = 0;
 my $summary = 1;
 my $mailback = 0;
@@ -64,6 +66,8 @@ Options:
                              is all off)
   --test-only=WORD           report only warnings/errors containing WORD
                              literally
+  --color[=WHEN]             Use colors 'always', 'never', or only when output
+                             is a terminal ('auto'). Default is 'auto'.
   -h, --help, --version      display this help and exit
 
 When FILE is - read standard input.
@@ -72,6 +76,14 @@ EOM
 	exit($exitcode);
 }
 
+# Perl's Getopt::Long allows options to take optional arguments after a space.
+# Prevent --color by itself from consuming other arguments
+foreach (@ARGV) {
+	if ($_ eq "--color" || $_ eq "-color") {
+		$_ = "--color=$color";
+	}
+}
+
 GetOptions(
 	'q|quiet+'	=> \$quiet,
 	'tree!'		=> \$tree,
@@ -89,6 +101,8 @@ GetOptions(
 
 	'debug=s'	=> \%debug,
 	'test-only=s'	=> \$tst_only,
+	'color=s'       => \$color,
+	'no-color'      => sub { $color = 'never'; },
 	'h|help'	=> \$help,
 	'version'	=> \$help
 ) or help(1);
@@ -144,6 +158,16 @@ if (!$chk_patch && !$chk_branch && !$file) {
 	die "One of --file, --branch, --patch is required\n";
 }
 
+if ($color =~ /^always$/i) {
+	$color = 1;
+} elsif ($color =~ /^never$/i) {
+	$color = 0;
+} elsif ($color =~ /^auto$/i) {
+	$color = (-t STDOUT);
+} else {
+	die "Invalid color mode: $color\n";
+}
+
 my $dbg_values = 0;
 my $dbg_possible = 0;
 my $dbg_type = 0;
@@ -372,7 +396,9 @@ if ($chk_branch) {
 		close($FILE);
 		$vname = substr($hash, 0, 12) . ' (' . $git_commits{$hash} . ')';
 		if ($num_patches > 1 && $quiet == 0) {
-			print "$i/$num_patches Checking commit $vname\n";
+			my $prefix = "$i/$num_patches";
+			$prefix = BLUE . BOLD . $prefix . RESET if $color;
+			print "$prefix Checking commit $vname\n";
 			$vname = "Patch $i/$num_patches";
 		} else {
 			$vname = "Commit " . $vname;
@@ -1182,14 +1208,23 @@ sub possible {
 my $prefix = '';
 
 sub report {
-	if (defined $tst_only && $_[0] !~ /\Q$tst_only\E/) {
+	my ($level, $msg) = @_;
+	if (defined $tst_only && $msg !~ /\Q$tst_only\E/) {
 		return 0;
 	}
-	my $line = $prefix . $_[0];
 
-	$line = (split('\n', $line))[0] . "\n" if ($terse);
+	my $output = '';
+	$output .= BOLD if $color;
+	$output .= $prefix;
+	$output .= RED if $color && $level eq 'ERROR';
+	$output .= MAGENTA if $color && $level eq 'WARNING';
+	$output .= $level . ':';
+	$output .= RESET if $color;
+	$output .= ' ' . $msg . "\n";
+
+	$output = (split('\n', $output))[0] . "\n" if ($terse);
 
-	push(our @report, $line);
+	push(our @report, $output);
 
 	return 1;
 }
@@ -1197,13 +1232,13 @@ sub report_dump {
 	our @report;
 }
 sub ERROR {
-	if (report("ERROR: $_[0]\n")) {
+	if (report("ERROR", $_[0])) {
 		our $clean = 0;
 		our $cnt_error++;
 	}
 }
 sub WARN {
-	if (report("WARNING: $_[0]\n")) {
+	if (report("WARNING", $_[0])) {
 		our $clean = 0;
 		our $cnt_warn++;
 	}
-- 
1.8.3.1

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

* [Qemu-devel] [PULL 07/54] pam: wrap MemoryRegion initialization in a transaction
  2018-12-12 15:22 [Qemu-devel] [PULL 00/54] Misc patches for 2018-12-12 Paolo Bonzini
                   ` (5 preceding siblings ...)
  2018-12-12 15:22 ` [Qemu-devel] [PULL 06/54] checkpatch: colorize output to terminal Paolo Bonzini
@ 2018-12-12 15:22 ` Paolo Bonzini
  2018-12-12 15:22 ` [Qemu-devel] [PULL 08/54] memory: extract flat_range_coalesced_io_{del, add} Paolo Bonzini
                   ` (48 subsequent siblings)
  55 siblings, 0 replies; 60+ messages in thread
From: Paolo Bonzini @ 2018-12-12 15:22 UTC (permalink / raw)
  To: qemu-devel

This avoids a few re-rendering of the memory AddressSpace.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/pci-host/pam.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/hw/pci-host/pam.c b/hw/pci-host/pam.c
index e361ecb..aa5ecfd 100644
--- a/hw/pci-host/pam.c
+++ b/hw/pci-host/pam.c
@@ -52,11 +52,13 @@ void init_pam(DeviceState *dev, MemoryRegion *ram_memory,
     memory_region_init_alias(&mem->alias[2], OBJECT(dev), "pam-pci", ram_memory,
                              start, size);
 
+    memory_region_transaction_begin();
     for (i = 0; i < 4; ++i) {
         memory_region_set_enabled(&mem->alias[i], false);
         memory_region_add_subregion_overlap(system_memory, start,
                                             &mem->alias[i], 1);
     }
+    memory_region_transaction_commit();
     mem->current = 0;
 }
 
-- 
1.8.3.1

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

* [Qemu-devel] [PULL 08/54] memory: extract flat_range_coalesced_io_{del, add}
  2018-12-12 15:22 [Qemu-devel] [PULL 00/54] Misc patches for 2018-12-12 Paolo Bonzini
                   ` (6 preceding siblings ...)
  2018-12-12 15:22 ` [Qemu-devel] [PULL 07/54] pam: wrap MemoryRegion initialization in a transaction Paolo Bonzini
@ 2018-12-12 15:22 ` Paolo Bonzini
  2018-12-12 15:22 ` [Qemu-devel] [PULL 09/54] memory: avoid unnecessary coalesced_io_del operations Paolo Bonzini
                   ` (47 subsequent siblings)
  55 siblings, 0 replies; 60+ messages in thread
From: Paolo Bonzini @ 2018-12-12 15:22 UTC (permalink / raw)
  To: qemu-devel

Extract two new functions from memory_region_update_coalesced_range_as.
To avoid duplication in the creation of the MemoryRegionSection, use
MEMORY_LISTENER_UPDATE_REGION instead of MEMORY_LISTENER_CALL
to invoke the listener callback.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 memory.c | 53 +++++++++++++++++++++++++++++------------------------
 1 file changed, 29 insertions(+), 24 deletions(-)

diff --git a/memory.c b/memory.c
index d14c6de..119b6e4 100644
--- a/memory.c
+++ b/memory.c
@@ -850,6 +850,33 @@ static void address_space_update_ioeventfds(AddressSpace *as)
     flatview_unref(view);
 }
 
+static void flat_range_coalesced_io_del(FlatRange *fr, AddressSpace *as)
+{
+    MEMORY_LISTENER_UPDATE_REGION(fr, as, Reverse, coalesced_io_del,
+                                  int128_get64(fr->addr.start),
+                                  int128_get64(fr->addr.size));
+}
+
+static void flat_range_coalesced_io_add(FlatRange *fr, AddressSpace *as)
+{
+    MemoryRegion *mr = fr->mr;
+    CoalescedMemoryRange *cmr;
+    AddrRange tmp;
+
+    QTAILQ_FOREACH(cmr, &mr->coalesced, link) {
+        tmp = addrrange_shift(cmr->addr,
+                              int128_sub(fr->addr.start,
+                                         int128_make64(fr->offset_in_region)));
+        if (!addrrange_intersects(tmp, fr->addr)) {
+            continue;
+        }
+        tmp = addrrange_intersection(tmp, fr->addr);
+        MEMORY_LISTENER_UPDATE_REGION(fr, as, Forward, coalesced_io_add,
+                                      int128_get64(tmp.start),
+                                      int128_get64(tmp.size));
+    }
+}
+
 static void address_space_update_topology_pass(AddressSpace *as,
                                                const FlatView *old_view,
                                                const FlatView *new_view,
@@ -2136,34 +2163,12 @@ static void memory_region_update_coalesced_range_as(MemoryRegion *mr, AddressSpa
 {
     FlatView *view;
     FlatRange *fr;
-    CoalescedMemoryRange *cmr;
-    AddrRange tmp;
-    MemoryRegionSection section;
 
     view = address_space_get_flatview(as);
     FOR_EACH_FLAT_RANGE(fr, view) {
         if (fr->mr == mr) {
-            section = (MemoryRegionSection) {
-                .fv = view,
-                .offset_within_address_space = int128_get64(fr->addr.start),
-                .size = fr->addr.size,
-            };
-
-            MEMORY_LISTENER_CALL(as, coalesced_io_del, Reverse, &section,
-                                 int128_get64(fr->addr.start),
-                                 int128_get64(fr->addr.size));
-            QTAILQ_FOREACH(cmr, &mr->coalesced, link) {
-                tmp = addrrange_shift(cmr->addr,
-                                      int128_sub(fr->addr.start,
-                                                 int128_make64(fr->offset_in_region)));
-                if (!addrrange_intersects(tmp, fr->addr)) {
-                    continue;
-                }
-                tmp = addrrange_intersection(tmp, fr->addr);
-                MEMORY_LISTENER_CALL(as, coalesced_io_add, Forward, &section,
-                                     int128_get64(tmp.start),
-                                     int128_get64(tmp.size));
-            }
+            flat_range_coalesced_io_del(fr, as);
+            flat_range_coalesced_io_add(fr, as);
         }
     }
     flatview_unref(view);
-- 
1.8.3.1

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

* [Qemu-devel] [PULL 09/54] memory: avoid unnecessary coalesced_io_del operations
  2018-12-12 15:22 [Qemu-devel] [PULL 00/54] Misc patches for 2018-12-12 Paolo Bonzini
                   ` (7 preceding siblings ...)
  2018-12-12 15:22 ` [Qemu-devel] [PULL 08/54] memory: extract flat_range_coalesced_io_{del, add} Paolo Bonzini
@ 2018-12-12 15:22 ` Paolo Bonzini
  2018-12-12 15:22 ` [Qemu-devel] [PULL 10/54] memory: update coalesced_range on transaction_commit Paolo Bonzini
                   ` (46 subsequent siblings)
  55 siblings, 0 replies; 60+ messages in thread
From: Paolo Bonzini @ 2018-12-12 15:22 UTC (permalink / raw)
  To: qemu-devel

Store whether the FlatRange has had any coalesced I/O ranges applied,
and if not avoid calling coalesced_io_del.  This is useful in preparation
for the next patch, which will call coalesced_io_del when rendering
memory regions.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 memory.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/memory.c b/memory.c
index 119b6e4..072769a 100644
--- a/memory.c
+++ b/memory.c
@@ -217,6 +217,7 @@ struct FlatRange {
     bool romd_mode;
     bool readonly;
     bool nonvolatile;
+    bool has_coalesced_range;
 };
 
 #define FOR_EACH_FLAT_RANGE(var, view)          \
@@ -650,6 +651,7 @@ static void render_memory_region(FlatView *view,
     fr.romd_mode = mr->romd_mode;
     fr.readonly = readonly;
     fr.nonvolatile = nonvolatile;
+    fr.has_coalesced_range = false;
 
     /* Render the region itself into any gaps left by the current view. */
     for (i = 0; i < view->nr && int128_nz(remain); ++i) {
@@ -852,6 +854,10 @@ static void address_space_update_ioeventfds(AddressSpace *as)
 
 static void flat_range_coalesced_io_del(FlatRange *fr, AddressSpace *as)
 {
+    if (!fr->has_coalesced_range) {
+        return;
+    }
+
     MEMORY_LISTENER_UPDATE_REGION(fr, as, Reverse, coalesced_io_del,
                                   int128_get64(fr->addr.start),
                                   int128_get64(fr->addr.size));
@@ -863,6 +869,11 @@ static void flat_range_coalesced_io_add(FlatRange *fr, AddressSpace *as)
     CoalescedMemoryRange *cmr;
     AddrRange tmp;
 
+    if (QTAILQ_EMPTY(&mr->coalesced)) {
+        return;
+    }
+
+    fr->has_coalesced_range = true;
     QTAILQ_FOREACH(cmr, &mr->coalesced, link) {
         tmp = addrrange_shift(cmr->addr,
                               int128_sub(fr->addr.start,
-- 
1.8.3.1

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

* [Qemu-devel] [PULL 10/54] memory: update coalesced_range on transaction_commit
  2018-12-12 15:22 [Qemu-devel] [PULL 00/54] Misc patches for 2018-12-12 Paolo Bonzini
                   ` (8 preceding siblings ...)
  2018-12-12 15:22 ` [Qemu-devel] [PULL 09/54] memory: avoid unnecessary coalesced_io_del operations Paolo Bonzini
@ 2018-12-12 15:22 ` Paolo Bonzini
  2018-12-12 15:22 ` [Qemu-devel] [PULL 11/54] hax: Support for Linux hosts Paolo Bonzini
                   ` (45 subsequent siblings)
  55 siblings, 0 replies; 60+ messages in thread
From: Paolo Bonzini @ 2018-12-12 15:22 UTC (permalink / raw)
  To: qemu-devel

The e1000 driver calls memory_region_add_coalescing but
kvm_coalesce_mmio_region is never called for those regions.  The bug
dates back to the introduction of the memory region API; to fix it,
delete and re-add coalesced MMIO ranges when building the FlatViews.

Because coalesced MMIO regions apply to all address spaces, the
has_coalesced_range flag has to be changed into an int.

Fixes: 093bc2cd885e ("Hierarchical memory region API")
Reported-by: Atsushi Nemoto <atsushi.nemoto@sord.co.jp>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 memory.c | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/memory.c b/memory.c
index 072769a..5759f74 100644
--- a/memory.c
+++ b/memory.c
@@ -217,7 +217,7 @@ struct FlatRange {
     bool romd_mode;
     bool readonly;
     bool nonvolatile;
-    bool has_coalesced_range;
+    int has_coalesced_range;
 };
 
 #define FOR_EACH_FLAT_RANGE(var, view)          \
@@ -651,7 +651,7 @@ static void render_memory_region(FlatView *view,
     fr.romd_mode = mr->romd_mode;
     fr.readonly = readonly;
     fr.nonvolatile = nonvolatile;
-    fr.has_coalesced_range = false;
+    fr.has_coalesced_range = 0;
 
     /* Render the region itself into any gaps left by the current view. */
     for (i = 0; i < view->nr && int128_nz(remain); ++i) {
@@ -858,6 +858,10 @@ static void flat_range_coalesced_io_del(FlatRange *fr, AddressSpace *as)
         return;
     }
 
+    if (--fr->has_coalesced_range > 0) {
+        return;
+    }
+
     MEMORY_LISTENER_UPDATE_REGION(fr, as, Reverse, coalesced_io_del,
                                   int128_get64(fr->addr.start),
                                   int128_get64(fr->addr.size));
@@ -873,7 +877,10 @@ static void flat_range_coalesced_io_add(FlatRange *fr, AddressSpace *as)
         return;
     }
 
-    fr->has_coalesced_range = true;
+    if (fr->has_coalesced_range++) {
+        return;
+    }
+
     QTAILQ_FOREACH(cmr, &mr->coalesced, link) {
         tmp = addrrange_shift(cmr->addr,
                               int128_sub(fr->addr.start,
@@ -920,6 +927,7 @@ static void address_space_update_topology_pass(AddressSpace *as,
             /* In old but not in new, or in both but attributes changed. */
 
             if (!adding) {
+                flat_range_coalesced_io_del(frold, as);
                 MEMORY_LISTENER_UPDATE_REGION(frold, as, Reverse, region_del);
             }
 
@@ -927,7 +935,9 @@ static void address_space_update_topology_pass(AddressSpace *as,
         } else if (frold && frnew && flatrange_equal(frold, frnew)) {
             /* In both and unchanged (except logging may have changed) */
 
-            if (adding) {
+            if (!adding) {
+                flat_range_coalesced_io_del(frold, as);
+            } else {
                 MEMORY_LISTENER_UPDATE_REGION(frnew, as, Forward, region_nop);
                 if (frnew->dirty_log_mask & ~frold->dirty_log_mask) {
                     MEMORY_LISTENER_UPDATE_REGION(frnew, as, Forward, log_start,
@@ -939,6 +949,7 @@ static void address_space_update_topology_pass(AddressSpace *as,
                                                   frold->dirty_log_mask,
                                                   frnew->dirty_log_mask);
                 }
+                flat_range_coalesced_io_add(frnew, as);
             }
 
             ++iold;
@@ -948,6 +959,7 @@ static void address_space_update_topology_pass(AddressSpace *as,
 
             if (adding) {
                 MEMORY_LISTENER_UPDATE_REGION(frnew, as, Forward, region_add);
+                flat_range_coalesced_io_add(frnew, as);
             }
 
             ++inew;
-- 
1.8.3.1

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

* [Qemu-devel] [PULL 11/54] hax: Support for Linux hosts
  2018-12-12 15:22 [Qemu-devel] [PULL 00/54] Misc patches for 2018-12-12 Paolo Bonzini
                   ` (9 preceding siblings ...)
  2018-12-12 15:22 ` [Qemu-devel] [PULL 10/54] memory: update coalesced_range on transaction_commit Paolo Bonzini
@ 2018-12-12 15:22 ` Paolo Bonzini
  2018-12-12 15:22 ` [Qemu-devel] [PULL 12/54] block/iscsi: drop unused IscsiAIOCB->buf field Paolo Bonzini
                   ` (44 subsequent siblings)
  55 siblings, 0 replies; 60+ messages in thread
From: Paolo Bonzini @ 2018-12-12 15:22 UTC (permalink / raw)
  To: qemu-devel; +Cc: Alexandro Sanchez Bach

From: Alexandro Sanchez Bach <asanchez@kryptoslogic.com>

Intel HAXM supports now 32-bit and 64-bit Linux hosts. This patch includes
the corresponding userland changes.

Since the Darwin userland backend is POSIX-compliant, the hax-darwin.{c,h}
files have been renamed to hax-posix.{c,h}. This prefix is consistent with
the naming used in the rest of QEMU.

Signed-off-by: Alexandro Sanchez Bach <asanchez@kryptoslogic.com>
Message-Id: <20181115013331.65820-1-asanchez@kryptoslogic.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 target/i386/Makefile.objs                 | 6 +++---
 target/i386/hax-i386.h                    | 6 +++---
 target/i386/{hax-darwin.c => hax-posix.c} | 0
 target/i386/{hax-darwin.h => hax-posix.h} | 0
 4 files changed, 6 insertions(+), 6 deletions(-)
 rename target/i386/{hax-darwin.c => hax-posix.c} (100%)
 rename target/i386/{hax-darwin.h => hax-posix.h} (100%)

diff --git a/target/i386/Makefile.objs b/target/i386/Makefile.objs
index 32bf966..cb9c265 100644
--- a/target/i386/Makefile.objs
+++ b/target/i386/Makefile.objs
@@ -12,10 +12,10 @@ obj-$(call lnot,$(CONFIG_HYPERV)) += hyperv-stub.o
 ifeq ($(CONFIG_WIN32),y)
 obj-$(CONFIG_HAX) += hax-all.o hax-mem.o hax-windows.o
 endif
-ifeq ($(CONFIG_DARWIN),y)
-obj-$(CONFIG_HAX) += hax-all.o hax-mem.o hax-darwin.o
-obj-$(CONFIG_HVF) += hvf/
+ifeq ($(CONFIG_POSIX),y)
+obj-$(CONFIG_HAX) += hax-all.o hax-mem.o hax-posix.o
 endif
+obj-$(CONFIG_HVF) += hvf/
 obj-$(CONFIG_WHPX) += whpx-all.o
 endif
 obj-$(CONFIG_SEV) += sev.o
diff --git a/target/i386/hax-i386.h b/target/i386/hax-i386.h
index 6abc156..f13fa46 100644
--- a/target/i386/hax-i386.h
+++ b/target/i386/hax-i386.h
@@ -16,7 +16,7 @@
 #include "cpu.h"
 #include "sysemu/hax.h"
 
-#ifdef CONFIG_DARWIN
+#ifdef CONFIG_POSIX
 typedef int hax_fd;
 #endif
 
@@ -82,8 +82,8 @@ hax_fd hax_mod_open(void);
 void hax_memory_init(void);
 
 
-#ifdef CONFIG_DARWIN
-#include "target/i386/hax-darwin.h"
+#ifdef CONFIG_POSIX
+#include "target/i386/hax-posix.h"
 #endif
 
 #ifdef CONFIG_WIN32
diff --git a/target/i386/hax-darwin.c b/target/i386/hax-posix.c
similarity index 100%
rename from target/i386/hax-darwin.c
rename to target/i386/hax-posix.c
diff --git a/target/i386/hax-darwin.h b/target/i386/hax-posix.h
similarity index 100%
rename from target/i386/hax-darwin.h
rename to target/i386/hax-posix.h
-- 
1.8.3.1

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

* [Qemu-devel] [PULL 12/54] block/iscsi: drop unused IscsiAIOCB->buf field
  2018-12-12 15:22 [Qemu-devel] [PULL 00/54] Misc patches for 2018-12-12 Paolo Bonzini
                   ` (10 preceding siblings ...)
  2018-12-12 15:22 ` [Qemu-devel] [PULL 11/54] hax: Support for Linux hosts Paolo Bonzini
@ 2018-12-12 15:22 ` Paolo Bonzini
  2018-12-12 15:22 ` [Qemu-devel] [PULL 13/54] block/iscsi: take iscsilun->mutex in iscsi_timed_check_events() Paolo Bonzini
                   ` (43 subsequent siblings)
  55 siblings, 0 replies; 60+ messages in thread
From: Paolo Bonzini @ 2018-12-12 15:22 UTC (permalink / raw)
  To: qemu-devel; +Cc: Stefan Hajnoczi

From: Stefan Hajnoczi <stefanha@redhat.com>

The IscsiAIOCB->buf field has not been used since commit
e49ab19fcaa617ad6cdfe1ac401327326b6a2552 ("block/iscsi: bump libiscsi
requirement to 1.9.0").  It used to be a linear buffer for old libiscsi
versions that didn't support scatter-gather.  The minimum libiscsi
version supports scatter-gather so we don't linearize buffers anymore.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-Id: <20180203061621.7033-2-stefanha@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 block/iscsi.c | 8 --------
 1 file changed, 8 deletions(-)

diff --git a/block/iscsi.c b/block/iscsi.c
index 727dee5..a4e3730 100644
--- a/block/iscsi.c
+++ b/block/iscsi.c
@@ -117,7 +117,6 @@ typedef struct IscsiAIOCB {
     QEMUBH *bh;
     IscsiLun *iscsilun;
     struct scsi_task *task;
-    uint8_t *buf;
     int status;
     int64_t sector_num;
     int nb_sectors;
@@ -150,9 +149,6 @@ iscsi_bh_cb(void *p)
 
     qemu_bh_delete(acb->bh);
 
-    g_free(acb->buf);
-    acb->buf = NULL;
-
     acb->common.cb(acb->common.opaque, acb->status);
 
     if (acb->task != NULL) {
@@ -933,9 +929,6 @@ iscsi_aio_ioctl_cb(struct iscsi_context *iscsi, int status,
 {
     IscsiAIOCB *acb = opaque;
 
-    g_free(acb->buf);
-    acb->buf = NULL;
-
     acb->status = 0;
     if (status < 0) {
         error_report("Failed to ioctl(SG_IO) to iSCSI lun. %s",
@@ -1010,7 +1003,6 @@ static BlockAIOCB *iscsi_aio_ioctl(BlockDriverState *bs,
     acb->iscsilun = iscsilun;
     acb->bh          = NULL;
     acb->status      = -EINPROGRESS;
-    acb->buf         = NULL;
     acb->ioh         = buf;
 
     if (req != SG_IO) {
-- 
1.8.3.1

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

* [Qemu-devel] [PULL 13/54] block/iscsi: take iscsilun->mutex in iscsi_timed_check_events()
  2018-12-12 15:22 [Qemu-devel] [PULL 00/54] Misc patches for 2018-12-12 Paolo Bonzini
                   ` (11 preceding siblings ...)
  2018-12-12 15:22 ` [Qemu-devel] [PULL 12/54] block/iscsi: drop unused IscsiAIOCB->buf field Paolo Bonzini
@ 2018-12-12 15:22 ` Paolo Bonzini
  2018-12-12 15:22 ` [Qemu-devel] [PULL 14/54] block/iscsi: fix ioctl cancel use-after-free Paolo Bonzini
                   ` (42 subsequent siblings)
  55 siblings, 0 replies; 60+ messages in thread
From: Paolo Bonzini @ 2018-12-12 15:22 UTC (permalink / raw)
  To: qemu-devel; +Cc: Stefan Hajnoczi

From: Stefan Hajnoczi <stefanha@redhat.com>

Commit d045c466d9e62b4321fadf586d024d54ddfd8bd4 ("iscsi: do not use
aio_context_acquire/release") introduced iscsilun->mutex but appears to
have overlooked iscsi_timed_check_events() when introducing the mutex.

iscsi_service() and iscsi_set_events() must be called with
iscsilun->mutex held.

iscsi_timed_check_events() is invoked from the AioContext and does not
take the mutex.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-Id: <20180203061621.7033-3-stefanha@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 block/iscsi.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/block/iscsi.c b/block/iscsi.c
index a4e3730..1924a2b 100644
--- a/block/iscsi.c
+++ b/block/iscsi.c
@@ -344,6 +344,8 @@ static void iscsi_timed_check_events(void *opaque)
 {
     IscsiLun *iscsilun = opaque;
 
+    qemu_mutex_lock(&iscsilun->mutex);
+
     /* check for timed out requests */
     iscsi_service(iscsilun->iscsi, 0);
 
@@ -356,6 +358,8 @@ static void iscsi_timed_check_events(void *opaque)
      * to return to service once this situation changes. */
     iscsi_set_events(iscsilun);
 
+    qemu_mutex_unlock(&iscsilun->mutex);
+
     timer_mod(iscsilun->event_timer,
               qemu_clock_get_ms(QEMU_CLOCK_REALTIME) + EVENT_INTERVAL);
 }
-- 
1.8.3.1

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

* [Qemu-devel] [PULL 14/54] block/iscsi: fix ioctl cancel use-after-free
  2018-12-12 15:22 [Qemu-devel] [PULL 00/54] Misc patches for 2018-12-12 Paolo Bonzini
                   ` (12 preceding siblings ...)
  2018-12-12 15:22 ` [Qemu-devel] [PULL 13/54] block/iscsi: take iscsilun->mutex in iscsi_timed_check_events() Paolo Bonzini
@ 2018-12-12 15:22 ` Paolo Bonzini
  2018-12-12 15:22 ` [Qemu-devel] [PULL 15/54] block/iscsi: cancel libiscsi task when ABORT TASK TMF completes Paolo Bonzini
                   ` (41 subsequent siblings)
  55 siblings, 0 replies; 60+ messages in thread
From: Paolo Bonzini @ 2018-12-12 15:22 UTC (permalink / raw)
  To: qemu-devel; +Cc: Stefan Hajnoczi

From: Stefan Hajnoczi <stefanha@redhat.com>

iscsi_aio_cancel() does not increment the request's reference count,
causing a use-after-free when ABORT TASK finishes after the request has
already completed.

There are some additional issues with iscsi_aio_cancel():
1. Several ABORT TASKs may be sent for the same task if
   iscsi_aio_cancel() is invoked multiple times.  It's better to avoid
   this just in case the command identifier is reused.
2. The iscsilun->mutex protection is missing in iscsi_aio_cancel().

Reported-by: Felipe Franciosi <felipe@nutanix.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-Id: <20180203061621.7033-4-stefanha@redhat.com>
Reviewed-by: Felipe Franciosi <felipe@nutanix.com>
Tested-by: Sreejith Mohanan <sreejit.mohanan@nutanix.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 block/iscsi.c | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)

diff --git a/block/iscsi.c b/block/iscsi.c
index 1924a2b..abb872d 100644
--- a/block/iscsi.c
+++ b/block/iscsi.c
@@ -124,6 +124,7 @@ typedef struct IscsiAIOCB {
 #ifdef __linux__
     sg_io_hdr_t *ioh;
 #endif
+    bool cancelled;
 } IscsiAIOCB;
 
 /* libiscsi uses time_t so its enough to process events every second */
@@ -287,6 +288,7 @@ static void iscsi_co_init_iscsitask(IscsiLun *iscsilun, struct IscsiTask *iTask)
     };
 }
 
+/* Called (via iscsi_service) with QemuMutex held. */
 static void
 iscsi_abort_task_cb(struct iscsi_context *iscsi, int status, void *command_data,
                     void *private_data)
@@ -295,6 +297,7 @@ iscsi_abort_task_cb(struct iscsi_context *iscsi, int status, void *command_data,
 
     acb->status = -ECANCELED;
     iscsi_schedule_bh(acb);
+    qemu_aio_unref(acb); /* acquired in iscsi_aio_cancel() */
 }
 
 static void
@@ -303,14 +306,25 @@ iscsi_aio_cancel(BlockAIOCB *blockacb)
     IscsiAIOCB *acb = (IscsiAIOCB *)blockacb;
     IscsiLun *iscsilun = acb->iscsilun;
 
-    if (acb->status != -EINPROGRESS) {
+    qemu_mutex_lock(&iscsilun->mutex);
+
+    /* If it was cancelled or completed already, our work is done here */
+    if (acb->cancelled || acb->status != -EINPROGRESS) {
+        qemu_mutex_unlock(&iscsilun->mutex);
         return;
     }
 
+    acb->cancelled = true;
+
+    qemu_aio_ref(acb); /* released in iscsi_abort_task_cb() */
+
     /* send a task mgmt call to the target to cancel the task on the target */
-    iscsi_task_mgmt_abort_task_async(iscsilun->iscsi, acb->task,
-                                     iscsi_abort_task_cb, acb);
+    if (iscsi_task_mgmt_abort_task_async(iscsilun->iscsi, acb->task,
+                                         iscsi_abort_task_cb, acb) < 0) {
+        qemu_aio_unref(acb); /* since iscsi_abort_task_cb() won't be called */
+    }
 
+    qemu_mutex_unlock(&iscsilun->mutex);
 }
 
 static const AIOCBInfo iscsi_aiocb_info = {
@@ -1008,6 +1022,7 @@ static BlockAIOCB *iscsi_aio_ioctl(BlockDriverState *bs,
     acb->bh          = NULL;
     acb->status      = -EINPROGRESS;
     acb->ioh         = buf;
+    acb->cancelled   = false;
 
     if (req != SG_IO) {
         iscsi_ioctl_handle_emulated(acb, req, buf);
-- 
1.8.3.1

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

* [Qemu-devel] [PULL 15/54] block/iscsi: cancel libiscsi task when ABORT TASK TMF completes
  2018-12-12 15:22 [Qemu-devel] [PULL 00/54] Misc patches for 2018-12-12 Paolo Bonzini
                   ` (13 preceding siblings ...)
  2018-12-12 15:22 ` [Qemu-devel] [PULL 14/54] block/iscsi: fix ioctl cancel use-after-free Paolo Bonzini
@ 2018-12-12 15:22 ` Paolo Bonzini
  2018-12-12 15:22 ` [Qemu-devel] [PULL 16/54] esp-pci: Fix status register write erase control Paolo Bonzini
                   ` (40 subsequent siblings)
  55 siblings, 0 replies; 60+ messages in thread
From: Paolo Bonzini @ 2018-12-12 15:22 UTC (permalink / raw)
  To: qemu-devel; +Cc: Stefan Hajnoczi

From: Stefan Hajnoczi <stefanha@redhat.com>

The libiscsi iscsi_task_mgmt_async() API documentation says:

  abort_task will also cancel the scsi task. The callback for the scsi
  task will be invoked with SCSI_STATUS_CANCELLED

The libiscsi implementation does not fulfil this promise.  The task's
callback is not invoked and its struct iscsi_pdu remains in the internal
list (effectively leaked).

This patch invokes the libiscsi iscsi_scsi_cancel_task() API to force
the task's callback to be invoked with SCSI_STATUS_CANCELLED when the
ABORT TASK TMF completes and the task's callback hasn't been invoked
yet.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-Id: <20180215111526.2464-1-stefanha@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 block/iscsi.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/block/iscsi.c b/block/iscsi.c
index abb872d..a7e8c1f 100644
--- a/block/iscsi.c
+++ b/block/iscsi.c
@@ -295,8 +295,12 @@ iscsi_abort_task_cb(struct iscsi_context *iscsi, int status, void *command_data,
 {
     IscsiAIOCB *acb = private_data;
 
-    acb->status = -ECANCELED;
-    iscsi_schedule_bh(acb);
+    /* If the command callback hasn't been called yet, drop the task */
+    if (!acb->bh) {
+        /* Call iscsi_aio_ioctl_cb() with SCSI_STATUS_CANCELLED */
+        iscsi_scsi_cancel_task(iscsi, acb->task);
+    }
+
     qemu_aio_unref(acb); /* acquired in iscsi_aio_cancel() */
 }
 
@@ -947,6 +951,14 @@ iscsi_aio_ioctl_cb(struct iscsi_context *iscsi, int status,
 {
     IscsiAIOCB *acb = opaque;
 
+    if (status == SCSI_STATUS_CANCELLED) {
+        if (!acb->bh) {
+            acb->status = -ECANCELED;
+            iscsi_schedule_bh(acb);
+        }
+        return;
+    }
+
     acb->status = 0;
     if (status < 0) {
         error_report("Failed to ioctl(SG_IO) to iSCSI lun. %s",
-- 
1.8.3.1

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

* [Qemu-devel] [PULL 16/54] esp-pci: Fix status register write erase control
  2018-12-12 15:22 [Qemu-devel] [PULL 00/54] Misc patches for 2018-12-12 Paolo Bonzini
                   ` (14 preceding siblings ...)
  2018-12-12 15:22 ` [Qemu-devel] [PULL 15/54] block/iscsi: cancel libiscsi task when ABORT TASK TMF completes Paolo Bonzini
@ 2018-12-12 15:22 ` Paolo Bonzini
  2018-12-12 15:22 ` [Qemu-devel] [PULL 17/54] scsi: esp: Defer command completion until previous interrupts have been handled Paolo Bonzini
                   ` (39 subsequent siblings)
  55 siblings, 0 replies; 60+ messages in thread
From: Paolo Bonzini @ 2018-12-12 15:22 UTC (permalink / raw)
  To: qemu-devel; +Cc: Guenter Roeck

From: Guenter Roeck <linux@roeck-us.net>

Per AM53C974 datasheet, definition of "SCSI Bus and Control (SBAC)"
register:

Bit 24 'STATUS' Write Erase Control

This bit controls the Write Erase feature on bits 3:1 and bit 6 of the DMA
Status Register ((B)+54h). When this bit is programmed to '1', the state
of bits 3:1 are preserved when read. Bits 3:1 are only cleared when a '1'
is written to the corresponding bit location. For example, to clear bit 1,
the value of '0000_0010b' should be written to the register. When the DMA
Status Preserve bit is '0', bits 3:1 are cleared when read.

The status register is currently defined to bit 12, not bit 24.
Also, its implementation is reversed: The status is auto-cleared if
the bit is set to 1, and must be cleared explicitly when the bit is
set to 0. This results in spurious interrupts reported by the Linux
kernel, and in some cases even results in stalled SCSI operations.

Set SBAC_STATUS to bit 24 and reverse the logic to fix the problem.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Message-Id: <1543442171-24863-1-git-send-email-linux@roeck-us.net>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/scsi/esp-pci.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/hw/scsi/esp-pci.c b/hw/scsi/esp-pci.c
index 419fc66..d956909 100644
--- a/hw/scsi/esp-pci.c
+++ b/hw/scsi/esp-pci.c
@@ -59,7 +59,7 @@
 #define DMA_STAT_SCSIINT 0x10
 #define DMA_STAT_BCMBLT  0x20
 
-#define SBAC_STATUS 0x1000
+#define SBAC_STATUS (1 << 24)
 
 typedef struct PCIESPState {
     /*< private >*/
@@ -136,7 +136,7 @@ static void esp_pci_dma_write(PCIESPState *pci, uint32_t saddr, uint32_t val)
         pci->dma_regs[saddr] = val;
         break;
     case DMA_STAT:
-        if (!(pci->sbac & SBAC_STATUS)) {
+        if (pci->sbac & SBAC_STATUS) {
             /* clear some bits on write */
             uint32_t mask = DMA_STAT_ERROR | DMA_STAT_ABORT | DMA_STAT_DONE;
             pci->dma_regs[DMA_STAT] &= ~(val & mask);
@@ -157,7 +157,7 @@ static uint32_t esp_pci_dma_read(PCIESPState *pci, uint32_t saddr)
         if (pci->esp.rregs[ESP_RSTAT] & STAT_INT) {
             val |= DMA_STAT_SCSIINT;
         }
-        if (pci->sbac & SBAC_STATUS) {
+        if (!(pci->sbac & SBAC_STATUS)) {
             pci->dma_regs[DMA_STAT] &= ~(DMA_STAT_ERROR | DMA_STAT_ABORT |
                                          DMA_STAT_DONE);
         }
-- 
1.8.3.1

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

* [Qemu-devel] [PULL 17/54] scsi: esp: Defer command completion until previous interrupts have been handled
  2018-12-12 15:22 [Qemu-devel] [PULL 00/54] Misc patches for 2018-12-12 Paolo Bonzini
                   ` (15 preceding siblings ...)
  2018-12-12 15:22 ` [Qemu-devel] [PULL 16/54] esp-pci: Fix status register write erase control Paolo Bonzini
@ 2018-12-12 15:22 ` Paolo Bonzini
  2018-12-12 15:22 ` [Qemu-devel] [PULL 18/54] build-sys: don't include windows.h, osdep.h does it Paolo Bonzini
                   ` (38 subsequent siblings)
  55 siblings, 0 replies; 60+ messages in thread
From: Paolo Bonzini @ 2018-12-12 15:22 UTC (permalink / raw)
  To: qemu-devel; +Cc: Guenter Roeck

From: Guenter Roeck <linux@roeck-us.net>

The guest OS reads RSTAT, RSEQ, and RINTR, and expects those registers
to reflect a consistent state. However, it is possible that the registers
can change after RSTAT was read, but before RINTR is read, when
esp_command_complete() is called.

Guest OS		qemu
--------		----
[handle interrupt]
Read RSTAT
			esp_command_complete()
			 RSTAT = STAT_ST
			 esp_dma_done()
			  RSTAT |= STAT_TC
			  RSEQ = 0
			  RINTR = INTR_BS

Read RSEQ
Read RINTR		RINTR = 0
			RSTAT &= ~STAT_TC
			RSEQ = SEQ_CD

The guest OS would then try to handle INTR_BS combined with an old
value of RSTAT. This sometimes resulted in lost events, spurious
interrupts, guest OS confusion, and stalled SCSI operations.
A typical guest error log (observed with various versions of Linux)
looks as follows.

scsi host1: Spurious irq, sreg=13.
...
scsi host1: Aborting command [84531f10:2a]
scsi host1: Current command [f882eea8:35]
scsi host1: Queued command [84531f10:2a]
scsi host1:  Active command [f882eea8:35]
scsi host1: Dumping command log
scsi host1: ent[15] CMD val[44] sreg[90] seqreg[00] sreg2[00] ireg[20] ss[00] event[0c]
scsi host1: ent[16] CMD val[01] sreg[90] seqreg[00] sreg2[00] ireg[20] ss[02] event[0c]
scsi host1: ent[17] CMD val[43] sreg[90] seqreg[00] sreg2[00] ireg[20] ss[02] event[0c]
scsi host1: ent[18] EVENT val[0d] sreg[92] seqreg[04] sreg2[00] ireg[18] ss[00] event[0c]
...

Defer handling command completion until previous interrupts have been
handled to fix the problem.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
 hw/scsi/esp-pci.c     |  4 ++--
 hw/scsi/esp.c         | 33 ++++++++++++++++++++++++++-------
 hw/scsi/trace-events  |  1 +
 include/hw/scsi/esp.h |  2 ++
 4 files changed, 31 insertions(+), 9 deletions(-)

diff --git a/hw/scsi/esp-pci.c b/hw/scsi/esp-pci.c
index d956909..6b0bbb9 100644
--- a/hw/scsi/esp-pci.c
+++ b/hw/scsi/esp-pci.c
@@ -313,8 +313,8 @@ static void esp_pci_hard_reset(DeviceState *dev)
 
 static const VMStateDescription vmstate_esp_pci_scsi = {
     .name = "pciespscsi",
-    .version_id = 0,
-    .minimum_version_id = 0,
+    .version_id = 1,
+    .minimum_version_id = 1,
     .fields = (VMStateField[]) {
         VMSTATE_PCI_DEVICE(parent_obj, PCIESPState),
         VMSTATE_BUFFER_UNSAFE(dma_regs, PCIESPState, 0, 8 * sizeof(uint32_t)),
diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c
index 630d923..ca8b36c 100644
--- a/hw/scsi/esp.c
+++ b/hw/scsi/esp.c
@@ -286,11 +286,8 @@ static void esp_do_dma(ESPState *s)
     esp_dma_done(s);
 }
 
-void esp_command_complete(SCSIRequest *req, uint32_t status,
-                                 size_t resid)
+static void esp_report_command_complete(ESPState *s, uint32_t status)
 {
-    ESPState *s = req->hba_private;
-
     trace_esp_command_complete();
     if (s->ti_size != 0) {
         trace_esp_command_complete_unexpected();
@@ -311,6 +308,23 @@ void esp_command_complete(SCSIRequest *req, uint32_t status,
     }
 }
 
+void esp_command_complete(SCSIRequest *req, uint32_t status,
+                          size_t resid)
+{
+    ESPState *s = req->hba_private;
+
+    if (s->rregs[ESP_RSTAT] & STAT_INT) {
+        /* Defer handling command complete until the previous
+         * interrupt has been handled.
+         */
+        trace_esp_command_complete_deferred();
+        s->deferred_status = status;
+        s->deferred_complete = true;
+        return;
+    }
+    esp_report_command_complete(s, status);
+}
+
 void esp_transfer_data(SCSIRequest *req, uint32_t len)
 {
     ESPState *s = req->hba_private;
@@ -422,7 +436,10 @@ uint64_t esp_reg_read(ESPState *s, uint32_t saddr)
         s->rregs[ESP_RSTAT] &= ~STAT_TC;
         s->rregs[ESP_RSEQ] = SEQ_CD;
         esp_lower_irq(s);
-
+        if (s->deferred_complete) {
+            esp_report_command_complete(s, s->deferred_status);
+            s->deferred_complete = false;
+        }
         return old_val;
     case ESP_TCHI:
         /* Return the unique id if the value has never been written */
@@ -582,6 +599,8 @@ const VMStateDescription vmstate_esp = {
         VMSTATE_UINT32(ti_wptr, ESPState),
         VMSTATE_BUFFER(ti_buf, ESPState),
         VMSTATE_UINT32(status, ESPState),
+        VMSTATE_UINT32(deferred_status, ESPState),
+        VMSTATE_BOOL(deferred_complete, ESPState),
         VMSTATE_UINT32(dma, ESPState),
         VMSTATE_PARTIAL_BUFFER(cmdbuf, ESPState, 16),
         VMSTATE_BUFFER_START_MIDDLE_V(cmdbuf, ESPState, 16, 4),
@@ -671,8 +690,8 @@ static void sysbus_esp_hard_reset(DeviceState *dev)
 
 static const VMStateDescription vmstate_sysbus_esp_scsi = {
     .name = "sysbusespscsi",
-    .version_id = 0,
-    .minimum_version_id = 0,
+    .version_id = 1,
+    .minimum_version_id = 1,
     .fields = (VMStateField[]) {
         VMSTATE_STRUCT(esp, SysBusESPState, 0, vmstate_esp, ESPState),
         VMSTATE_END_OF_LIST()
diff --git a/hw/scsi/trace-events b/hw/scsi/trace-events
index 0fb6a99..2fe8a7c 100644
--- a/hw/scsi/trace-events
+++ b/hw/scsi/trace-events
@@ -167,6 +167,7 @@ esp_handle_satn_stop(uint32_t cmdlen) "cmdlen %d"
 esp_write_response(uint32_t status) "Transfer status (status=%d)"
 esp_do_dma(uint32_t cmdlen, uint32_t len) "command len %d + %d"
 esp_command_complete(void) "SCSI Command complete"
+esp_command_complete_deferred(void) "SCSI Command complete deferred"
 esp_command_complete_unexpected(void) "SCSI command completed unexpectedly"
 esp_command_complete_fail(void) "Command failed"
 esp_transfer_data(uint32_t dma_left, int32_t ti_size) "transfer %d/%d"
diff --git a/include/hw/scsi/esp.h b/include/hw/scsi/esp.h
index 682a0d2..adab63d 100644
--- a/include/hw/scsi/esp.h
+++ b/include/hw/scsi/esp.h
@@ -23,6 +23,8 @@ struct ESPState {
     int32_t ti_size;
     uint32_t ti_rptr, ti_wptr;
     uint32_t status;
+    uint32_t deferred_status;
+    bool deferred_complete;
     uint32_t dma;
     uint8_t ti_buf[TI_BUFSZ];
     SCSIBus bus;
-- 
1.8.3.1

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

* [Qemu-devel] [PULL 18/54] build-sys: don't include windows.h, osdep.h does it
  2018-12-12 15:22 [Qemu-devel] [PULL 00/54] Misc patches for 2018-12-12 Paolo Bonzini
                   ` (16 preceding siblings ...)
  2018-12-12 15:22 ` [Qemu-devel] [PULL 17/54] scsi: esp: Defer command completion until previous interrupts have been handled Paolo Bonzini
@ 2018-12-12 15:22 ` Paolo Bonzini
  2018-12-12 15:22 ` [Qemu-devel] [PULL 19/54] build-sys: move windows defines in osdep.h header Paolo Bonzini
                   ` (37 subsequent siblings)
  55 siblings, 0 replies; 60+ messages in thread
From: Paolo Bonzini @ 2018-12-12 15:22 UTC (permalink / raw)
  To: qemu-devel; +Cc: Marc-André Lureau

From: Marc-André Lureau <marcandre.lureau@redhat.com>

osdep.h will also define the available Windows API version for QEMU.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20181122110039.15972-2-marcandre.lureau@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 accel/tcg/translate-all.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c
index 639f0b2..8cb8c88 100644
--- a/accel/tcg/translate-all.c
+++ b/accel/tcg/translate-all.c
@@ -16,12 +16,8 @@
  * You should have received a copy of the GNU Lesser General Public
  * License along with this library; if not, see <http://www.gnu.org/licenses/>.
  */
-#ifdef _WIN32
-#include <windows.h>
-#endif
 #include "qemu/osdep.h"
 
-
 #include "qemu-common.h"
 #define NO_CPU_IO_DEFS
 #include "cpu.h"
-- 
1.8.3.1

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

* [Qemu-devel] [PULL 19/54] build-sys: move windows defines in osdep.h header
  2018-12-12 15:22 [Qemu-devel] [PULL 00/54] Misc patches for 2018-12-12 Paolo Bonzini
                   ` (17 preceding siblings ...)
  2018-12-12 15:22 ` [Qemu-devel] [PULL 18/54] build-sys: don't include windows.h, osdep.h does it Paolo Bonzini
@ 2018-12-12 15:22 ` Paolo Bonzini
  2018-12-12 15:22 ` [Qemu-devel] [PULL 20/54] build-sys: build with Vista API by default Paolo Bonzini
                   ` (36 subsequent siblings)
  55 siblings, 0 replies; 60+ messages in thread
From: Paolo Bonzini @ 2018-12-12 15:22 UTC (permalink / raw)
  To: qemu-devel; +Cc: Marc-André Lureau

From: Marc-André Lureau <marcandre.lureau@redhat.com>

This removes some clutter in compilation logging, and allows some
easier tweaking per compilation unit/CFLAGS overriding.

Note that we can't move those define in os-win32.h, since they must be
set before the first system headers are included.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20181122110039.15972-3-marcandre.lureau@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 configure            |  3 ---
 include/qemu/osdep.h | 17 +++++++++++++++++
 2 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/configure b/configure
index 0a3c6a7..8c292ef 100755
--- a/configure
+++ b/configure
@@ -905,9 +905,6 @@ fi
 if test "$mingw32" = "yes" ; then
   EXESUF=".exe"
   DSOSUF=".dll"
-  QEMU_CFLAGS="-DWIN32_LEAN_AND_MEAN -DWINVER=0x501 $QEMU_CFLAGS"
-  # enable C99/POSIX format strings (needs mingw32-runtime 3.15 or later)
-  QEMU_CFLAGS="-D__USE_MINGW_ANSI_STDIO=1 $QEMU_CFLAGS"
   # MinGW needs -mthreads for TLS and macro _MT.
   QEMU_CFLAGS="-mthreads $QEMU_CFLAGS"
   LIBS="-lwinmm -lws2_32 -liphlpapi $LIBS"
diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h
index 3bf48bc..7b6e5db 100644
--- a/include/qemu/osdep.h
+++ b/include/qemu/osdep.h
@@ -74,13 +74,30 @@ typedef __float128 _Float128;
 extern int daemon(int, int);
 #endif
 
+#ifdef _WIN32
+/* as defined in sdkddkver.h */
+#ifndef WINVER
+#define WINVER 0x0501 /* XP */
+#endif
+/* reduces the number of implicitly included headers */
+#ifndef WIN32_LEAN_AND_MEAN
+#define WIN32_LEAN_AND_MEAN
+#endif
+#endif
+
 #include <stdarg.h>
 #include <stddef.h>
 #include <stdbool.h>
 #include <stdint.h>
 #include <sys/types.h>
 #include <stdlib.h>
+
+/* enable C99/POSIX format strings (needs mingw32-runtime 3.15 or later) */
+#ifdef __MINGW32__
+#define __USE_MINGW_ANSI_STDIO 1
+#endif
 #include <stdio.h>
+
 #include <string.h>
 #include <strings.h>
 #include <inttypes.h>
-- 
1.8.3.1

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

* [Qemu-devel] [PULL 20/54] build-sys: build with Vista API by default
  2018-12-12 15:22 [Qemu-devel] [PULL 00/54] Misc patches for 2018-12-12 Paolo Bonzini
                   ` (18 preceding siblings ...)
  2018-12-12 15:22 ` [Qemu-devel] [PULL 19/54] build-sys: move windows defines in osdep.h header Paolo Bonzini
@ 2018-12-12 15:22 ` Paolo Bonzini
  2018-12-12 15:22 ` [Qemu-devel] [PULL 21/54] RFC: qga: drop < Vista compatibility Paolo Bonzini
                   ` (35 subsequent siblings)
  55 siblings, 0 replies; 60+ messages in thread
From: Paolo Bonzini @ 2018-12-12 15:22 UTC (permalink / raw)
  To: qemu-devel; +Cc: Marc-André Lureau

From: Marc-André Lureau <marcandre.lureau@redhat.com>

Both qemu & qga build with Vista API by default already, by defining
_WIN32_WINNT 0x0600. Set it globally in osdep.h instead.

This replaces WINVER by _WIN32_WINNT in osdep.h. WINVER doesn't seem
to be really useful these days.
(see also https://blogs.msdn.microsoft.com/oldnewthing/20070411-00/?p=27283)

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20181122110039.15972-4-marcandre.lureau@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 include/qemu/osdep.h     | 4 ++--
 qga/commands-win32.c     | 6 +-----
 util/qemu-thread-win32.c | 4 ----
 3 files changed, 3 insertions(+), 11 deletions(-)

diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h
index 7b6e5db..80df725 100644
--- a/include/qemu/osdep.h
+++ b/include/qemu/osdep.h
@@ -76,8 +76,8 @@ extern int daemon(int, int);
 
 #ifdef _WIN32
 /* as defined in sdkddkver.h */
-#ifndef WINVER
-#define WINVER 0x0501 /* XP */
+#ifndef _WIN32_WINNT
+#define _WIN32_WINNT 0x0600 /* Vista */
 #endif
 /* reduces the number of implicitly included headers */
 #ifndef WIN32_LEAN_AND_MEAN
diff --git a/qga/commands-win32.c b/qga/commands-win32.c
index 62e1b51..f03b9c1 100644
--- a/qga/commands-win32.c
+++ b/qga/commands-win32.c
@@ -10,12 +10,8 @@
  * This work is licensed under the terms of the GNU GPL, version 2 or later.
  * See the COPYING file in the top-level directory.
  */
-
-#ifndef _WIN32_WINNT
-#   define _WIN32_WINNT 0x0600
-#endif
-
 #include "qemu/osdep.h"
+
 #include <wtypes.h>
 #include <powrprof.h>
 #include <winsock2.h>
diff --git a/util/qemu-thread-win32.c b/util/qemu-thread-win32.c
index 4a363ca..572f885 100644
--- a/util/qemu-thread-win32.c
+++ b/util/qemu-thread-win32.c
@@ -11,10 +11,6 @@
  *
  */
 
-#ifndef _WIN32_WINNT
-#define _WIN32_WINNT 0x0600
-#endif
-
 #include "qemu/osdep.h"
 #include "qemu-common.h"
 #include "qemu/thread.h"
-- 
1.8.3.1

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

* [Qemu-devel] [PULL 21/54] RFC: qga: drop < Vista compatibility
  2018-12-12 15:22 [Qemu-devel] [PULL 00/54] Misc patches for 2018-12-12 Paolo Bonzini
                   ` (19 preceding siblings ...)
  2018-12-12 15:22 ` [Qemu-devel] [PULL 20/54] build-sys: build with Vista API by default Paolo Bonzini
@ 2018-12-12 15:22 ` Paolo Bonzini
  2018-12-12 15:37   ` Daniel P. Berrangé
  2018-12-12 15:22 ` [Qemu-devel] [PULL 22/54] test: execute g_test_run when tests are skipped Paolo Bonzini
                   ` (34 subsequent siblings)
  55 siblings, 1 reply; 60+ messages in thread
From: Paolo Bonzini @ 2018-12-12 15:22 UTC (permalink / raw)
  To: qemu-devel; +Cc: Marc-André Lureau

From: Marc-André Lureau <marcandre.lureau@redhat.com>

Building QGA for XP seems possible so far: the dependency on
libqemuutil.a implies building qemu-thread-win32.c, which requires
Vista API since commit 12f8def0 (v2.9). But qemu-thread isn't being
used in QGA, the resulting binary may still work on XP.  XP is no
longer supported for the past 4.5y, it's time to drop support for it.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20181122110039.15972-5-marcandre.lureau@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 qga/commands-win32.c | 64 ----------------------------------------------------
 1 file changed, 64 deletions(-)

diff --git a/qga/commands-win32.c b/qga/commands-win32.c
index f03b9c1..989b93e 100644
--- a/qga/commands-win32.c
+++ b/qga/commands-win32.c
@@ -466,13 +466,11 @@ static STORAGE_BUS_TYPE win2qemu[] = {
     [BusTypeFibre] = GUEST_DISK_BUS_TYPE_SSA,
     [BusTypeUsb] = GUEST_DISK_BUS_TYPE_USB,
     [BusTypeRAID] = GUEST_DISK_BUS_TYPE_RAID,
-#if (_WIN32_WINNT >= 0x0600)
     [BusTypeiScsi] = GUEST_DISK_BUS_TYPE_ISCSI,
     [BusTypeSas] = GUEST_DISK_BUS_TYPE_SAS,
     [BusTypeSata] = GUEST_DISK_BUS_TYPE_SATA,
     [BusTypeSd] =  GUEST_DISK_BUS_TYPE_SD,
     [BusTypeMmc] = GUEST_DISK_BUS_TYPE_MMC,
-#endif
 #if (_WIN32_WINNT >= 0x0601)
     [BusTypeVirtual] = GUEST_DISK_BUS_TYPE_VIRTUAL,
     [BusTypeFileBackedVirtual] = GUEST_DISK_BUS_TYPE_FILE_BACKED_VIRTUAL,
@@ -724,10 +722,8 @@ static void get_single_disk_info(GuestDiskAddress *disk, Error **errp)
     if (disk->bus_type == GUEST_DISK_BUS_TYPE_SCSI
             || disk->bus_type == GUEST_DISK_BUS_TYPE_IDE
             || disk->bus_type == GUEST_DISK_BUS_TYPE_RAID
-#if (_WIN32_WINNT >= 0x0600)
             /* This bus type is not supported before Windows Server 2003 SP1 */
             || disk->bus_type == GUEST_DISK_BUS_TYPE_SAS
-#endif
         ) {
         /* We are able to use the same ioctls for different bus types
          * according to Microsoft docs
@@ -1322,7 +1318,6 @@ static char *guest_addr_to_str(IP_ADAPTER_UNICAST_ADDRESS *ip_addr,
     return NULL;
 }
 
-#if (_WIN32_WINNT >= 0x0600)
 static int64_t guest_ip_prefix(IP_ADAPTER_UNICAST_ADDRESS *ip_addr)
 {
     /* For Windows Vista/2008 and newer, use the OnLinkPrefixLength
@@ -1330,60 +1325,6 @@ static int64_t guest_ip_prefix(IP_ADAPTER_UNICAST_ADDRESS *ip_addr)
      */
     return ip_addr->OnLinkPrefixLength;
 }
-#else
-/* When using the Windows XP and 2003 build environment, do the best we can to
- * figure out the prefix.
- */
-static IP_ADAPTER_INFO *guest_get_adapters_info(void)
-{
-    IP_ADAPTER_INFO *adptr_info = NULL;
-    ULONG adptr_info_len = 0;
-    DWORD ret;
-
-    /* Call the first time to get the adptr_info_len. */
-    GetAdaptersInfo(adptr_info, &adptr_info_len);
-
-    adptr_info = g_malloc(adptr_info_len);
-    ret = GetAdaptersInfo(adptr_info, &adptr_info_len);
-    if (ret != ERROR_SUCCESS) {
-        g_free(adptr_info);
-        adptr_info = NULL;
-    }
-    return adptr_info;
-}
-
-static int64_t guest_ip_prefix(IP_ADAPTER_UNICAST_ADDRESS *ip_addr)
-{
-    int64_t prefix = -1; /* Use for AF_INET6 and unknown/undetermined values. */
-    IP_ADAPTER_INFO *adptr_info, *info;
-    IP_ADDR_STRING *ip;
-    struct in_addr *p;
-
-    if (ip_addr->Address.lpSockaddr->sa_family != AF_INET) {
-        return prefix;
-    }
-    adptr_info = guest_get_adapters_info();
-    if (adptr_info == NULL) {
-        return prefix;
-    }
-
-    /* Match up the passed in ip_addr with one found in adaptr_info.
-     * The matching one in adptr_info will have the netmask.
-     */
-    p = &((struct sockaddr_in *)ip_addr->Address.lpSockaddr)->sin_addr;
-    for (info = adptr_info; info; info = info->Next) {
-        for (ip = &info->IpAddressList; ip; ip = ip->Next) {
-            if (p->S_un.S_addr == inet_addr(ip->IpAddress.String)) {
-                prefix = ctpop32(inet_addr(ip->IpMask.String));
-                goto out;
-            }
-        }
-    }
-out:
-    g_free(adptr_info);
-    return prefix;
-}
-#endif
 
 #define INTERFACE_PATH_BUF_SZ 512
 
@@ -1904,7 +1845,6 @@ typedef struct _GA_WTSINFOA {
 
 GuestUserList *qmp_guest_get_users(Error **err)
 {
-#if (_WIN32_WINNT >= 0x0600)
 #define QGA_NANOSECONDS 10000000
 
     GHashTable *cache = NULL;
@@ -1974,10 +1914,6 @@ GuestUserList *qmp_guest_get_users(Error **err)
     }
     g_hash_table_destroy(cache);
     return head;
-#else
-    error_setg(err, QERR_UNSUPPORTED);
-    return NULL;
-#endif
 }
 
 typedef struct _ga_matrix_lookup_t {
-- 
1.8.3.1

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

* [Qemu-devel] [PULL 22/54] test: execute g_test_run when tests are skipped
  2018-12-12 15:22 [Qemu-devel] [PULL 00/54] Misc patches for 2018-12-12 Paolo Bonzini
                   ` (20 preceding siblings ...)
  2018-12-12 15:22 ` [Qemu-devel] [PULL 21/54] RFC: qga: drop < Vista compatibility Paolo Bonzini
@ 2018-12-12 15:22 ` Paolo Bonzini
  2018-12-12 15:22 ` [Qemu-devel] [PULL 23/54] test: replace gtester with a TAP driver Paolo Bonzini
                   ` (33 subsequent siblings)
  55 siblings, 0 replies; 60+ messages in thread
From: Paolo Bonzini @ 2018-12-12 15:22 UTC (permalink / raw)
  To: qemu-devel

Sometimes a test's main() function recognizes that the environment
does not support the test, and therefore exits.  In this case, we
still should run g_test_run() so that a TAP harness will print the
test plan ("1..0") and the test will be marked as skipped.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <1543513531-1151-2-git-send-email-pbonzini@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 tests/cdrom-test.c     | 2 +-
 tests/migration-test.c | 8 ++++----
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/tests/cdrom-test.c b/tests/cdrom-test.c
index 9b43dc9..14bd981 100644
--- a/tests/cdrom-test.c
+++ b/tests/cdrom-test.c
@@ -169,7 +169,7 @@ int main(int argc, char **argv)
 
     if (exec_genisoimg(genisocheck)) {
         /* genisoimage not available - so can't run tests */
-        return 0;
+        return g_test_run();
     }
 
     ret = prepare_image(arch, isoimage);
diff --git a/tests/migration-test.c b/tests/migration-test.c
index 06ca506..8352612 100644
--- a/tests/migration-test.c
+++ b/tests/migration-test.c
@@ -789,7 +789,7 @@ int main(int argc, char **argv)
     g_test_init(&argc, &argv, NULL);
 
     if (!ufd_version_check()) {
-        return 0;
+        return g_test_run();
     }
 
     /*
@@ -800,7 +800,7 @@ int main(int argc, char **argv)
     if (g_str_equal(qtest_get_arch(), "ppc64") &&
         access("/sys/module/kvm_hv", F_OK)) {
         g_test_message("Skipping test: kvm_hv not available");
-        return 0;
+        return g_test_run();
     }
 
     /*
@@ -811,11 +811,11 @@ int main(int argc, char **argv)
 #if defined(HOST_S390X)
         if (access("/dev/kvm", R_OK | W_OK)) {
             g_test_message("Skipping test: kvm not available");
-            return 0;
+            return g_test_run();
         }
 #else
         g_test_message("Skipping test: Need s390x host to work properly");
-        return 0;
+        return g_test_run();
 #endif
     }
 
-- 
1.8.3.1

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

* [Qemu-devel] [PULL 23/54] test: replace gtester with a TAP driver
  2018-12-12 15:22 [Qemu-devel] [PULL 00/54] Misc patches for 2018-12-12 Paolo Bonzini
                   ` (21 preceding siblings ...)
  2018-12-12 15:22 ` [Qemu-devel] [PULL 22/54] test: execute g_test_run when tests are skipped Paolo Bonzini
@ 2018-12-12 15:22 ` Paolo Bonzini
  2018-12-12 15:22 ` [Qemu-devel] [PULL 24/54] compiler.h: Add an explicit check for the compiler version Paolo Bonzini
                   ` (32 subsequent siblings)
  55 siblings, 0 replies; 60+ messages in thread
From: Paolo Bonzini @ 2018-12-12 15:22 UTC (permalink / raw)
  To: qemu-devel

gtester is deprecated by upstream glib (see for example the announcement
at https://blog.gtk.org/2018/07/11/news-from-glib-2-58/) and it does
not support tests that call g_test_skip in some glib stable releases.

glib suggests instead using Automake's TAP support, which gtest itself
supports since version 2.38 (QEMU's minimum requirement is 2.40).
We do not support Automake, but we can use Automake's code to beautify
the TAP output.  I chose to use the Perl copy rather than the shell/awk
one, with some changes so that it can accept TAP through stdin, in order
to reuse Perl's TAP parsing package.  This also avoids duplicating the
parser between tap-driver.pl and tap-merge.pl.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <1543513531-1151-3-git-send-email-pbonzini@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 scripts/gtester-cat                          |  26 --
 scripts/tap-driver.pl                        | 378 +++++++++++++++++++++++++++
 scripts/tap-merge.pl                         | 110 ++++++++
 tests/Makefile.include                       |  54 ++--
 tests/docker/dockerfiles/centos7.docker      |   1 +
 tests/docker/dockerfiles/debian-amd64.docker |   1 +
 tests/docker/dockerfiles/debian-ports.docker |   1 +
 tests/docker/dockerfiles/debian-sid.docker   |   1 +
 tests/docker/dockerfiles/debian8.docker      |   1 +
 tests/docker/dockerfiles/debian9.docker      |   1 +
 tests/docker/dockerfiles/fedora.docker       |   1 +
 tests/docker/dockerfiles/ubuntu.docker       |   1 +
 12 files changed, 529 insertions(+), 47 deletions(-)
 delete mode 100755 scripts/gtester-cat
 create mode 100755 scripts/tap-driver.pl
 create mode 100755 scripts/tap-merge.pl

diff --git a/scripts/gtester-cat b/scripts/gtester-cat
deleted file mode 100755
index 061a952..0000000
--- a/scripts/gtester-cat
+++ /dev/null
@@ -1,26 +0,0 @@
-#!/bin/sh
-#
-# Copyright IBM, Corp. 2012
-#
-# Authors:
-#  Anthony Liguori <aliguori@us.ibm.com>
-#
-# This work is licensed under the terms of the GNU GPLv2 or later.
-# See the COPYING file in the top-level directory.
-
-cat <<EOF
-<?xml version="1.0"?>
-<gtester>
- <info>
-  <package>qemu</package>
-  <version>0.0</version>
-  <revision>rev</revision>
- </info>
-EOF
-
-sed \
-  -e '/<?xml/d' \
-  -e '/^<gtester>$/d' \
-  -e '/<info>/,/<\/info>/d' \
-  -e '$b' \
-  -e '/^<\/gtester>$/d' "$@"
diff --git a/scripts/tap-driver.pl b/scripts/tap-driver.pl
new file mode 100755
index 0000000..5e59b5d
--- /dev/null
+++ b/scripts/tap-driver.pl
@@ -0,0 +1,378 @@
+#! /usr/bin/env perl
+# Copyright (C) 2011-2013 Free Software Foundation, Inc.
+# Copyright (C) 2018 Red Hat, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <https://www.gnu.org/licenses/>.
+
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# ---------------------------------- #
+#  Imports, static data, and setup.  #
+# ---------------------------------- #
+
+use warnings FATAL => 'all';
+use strict;
+use Getopt::Long ();
+use TAP::Parser;
+use Term::ANSIColor qw(:constants);
+
+my $ME = "tap-driver.pl";
+my $VERSION = "2018-11-30";
+
+my $USAGE = <<'END';
+Usage:
+  tap-driver [--test-name=TEST] [--color={always|never|auto}]
+             [--verbose] [--show-failures-only]
+END
+
+my $HELP = "$ME: TAP-aware test driver for QEMU testsuite harness." .
+           "\n" . $USAGE;
+
+# It's important that NO_PLAN evaluates "false" as a boolean.
+use constant NO_PLAN => 0;
+use constant EARLY_PLAN => 1;
+use constant LATE_PLAN => 2;
+
+use constant DIAG_STRING => "#";
+
+# ------------------- #
+#  Global variables.  #
+# ------------------- #
+
+my $testno = 0;     # Number of test results seen so far.
+my $bailed_out = 0; # Whether a "Bail out!" directive has been seen.
+my $failed = 0;     # Final exit code
+
+# Whether the TAP plan has been seen or not, and if yes, which kind
+# it is ("early" is seen before any test result, "late" otherwise).
+my $plan_seen = NO_PLAN;
+
+# ----------------- #
+#  Option parsing.  #
+# ----------------- #
+
+my %cfg = (
+  "color" => 0,
+  "verbose" => 0,
+  "show-failures-only" => 0,
+);
+
+my $color = "auto";
+my $test_name = undef;
+
+# Perl's Getopt::Long allows options to take optional arguments after a space.
+# Prevent --color by itself from consuming other arguments
+foreach (@ARGV) {
+  if ($_ eq "--color" || $_ eq "-color") {
+    $_ = "--color=$color";
+  }
+}
+
+Getopt::Long::GetOptions
+  (
+    'help' => sub { print $HELP; exit 0; },
+    'version' => sub { print "$ME $VERSION\n"; exit 0; },
+    'test-name=s' => \$test_name,
+    'color=s'  => \$color,
+    'show-failures-only' => sub { $cfg{"show-failures-only"} = 1; },
+    'verbose' => sub { $cfg{"verbose"} = 1; },
+  ) or exit 1;
+
+if ($color =~ /^always$/i) {
+  $cfg{'color'} = 1;
+} elsif ($color =~ /^never$/i) {
+  $cfg{'color'} = 0;
+} elsif ($color =~ /^auto$/i) {
+  $cfg{'color'} = (-t STDOUT);
+} else {
+  die "Invalid color mode: $color\n";
+}
+
+# ------------- #
+#  Prototypes.  #
+# ------------- #
+
+sub colored ($$);
+sub decorate_result ($);
+sub extract_tap_comment ($);
+sub handle_tap_bailout ($);
+sub handle_tap_plan ($);
+sub handle_tap_result ($);
+sub is_null_string ($);
+sub main ();
+sub report ($;$);
+sub stringify_result_obj ($);
+sub testsuite_error ($);
+
+# -------------- #
+#  Subroutines.  #
+# -------------- #
+
+# If the given string is undefined or empty, return true, otherwise
+# return false.  This function is useful to avoid pitfalls like:
+#   if ($message) { print "$message\n"; }
+# which wouldn't print anything if $message is the literal "0".
+sub is_null_string ($)
+{
+  my $str = shift;
+  return ! (defined $str and length $str);
+}
+
+sub stringify_result_obj ($)
+{
+  my $result_obj = shift;
+  if ($result_obj->is_unplanned || $result_obj->number != $testno)
+    {
+      return "ERROR";
+    }
+  elsif ($plan_seen == LATE_PLAN)
+    {
+      return "ERROR";
+    }
+  elsif (!$result_obj->directive)
+    {
+      return $result_obj->is_ok ? "PASS" : "FAIL";
+    }
+  elsif ($result_obj->has_todo)
+    {
+      return $result_obj->is_actual_ok ? "XPASS" : "XFAIL";
+    }
+  elsif ($result_obj->has_skip)
+    {
+      return $result_obj->is_ok ? "SKIP" : "FAIL";
+    }
+  die "$ME: INTERNAL ERROR"; # NOTREACHED
+}
+
+sub colored ($$)
+{
+  my ($color_string, $text) = @_;
+  return $color_string . $text . RESET;
+}
+
+sub decorate_result ($)
+{
+  my $result = shift;
+  return $result unless $cfg{"color"};
+  my %color_for_result =
+    (
+      "ERROR" => BOLD.MAGENTA,
+      "PASS"  => GREEN,
+      "XPASS" => BOLD.YELLOW,
+      "FAIL"  => BOLD.RED,
+      "XFAIL" => YELLOW,
+      "SKIP"  => BLUE,
+    );
+  if (my $color = $color_for_result{$result})
+    {
+      return colored ($color, $result);
+    }
+  else
+    {
+      return $result; # Don't colorize unknown stuff.
+    }
+}
+
+sub report ($;$)
+{
+  my ($msg, $result, $explanation) = (undef, @_);
+  if ($result =~ /^(?:X?(?:PASS|FAIL)|SKIP|ERROR)/)
+    {
+      # Output on console might be colorized.
+      $msg = decorate_result($result);
+      if ($result =~ /^(?:PASS|XFAIL|SKIP)/)
+        {
+          return if $cfg{"show-failures-only"};
+        }
+      else
+        {
+          $failed = 1;
+        }
+    }
+  elsif ($result eq "#")
+    {
+      $msg = "  ";
+    }
+  else
+    {
+      die "$ME: INTERNAL ERROR"; # NOTREACHED
+    }
+  $msg .= " $explanation" if defined $explanation;
+  print $msg . "\n";
+}
+
+sub testsuite_error ($)
+{
+  report "ERROR", "- $_[0]";
+}
+
+sub handle_tap_result ($)
+{
+  $testno++;
+  my $result_obj = shift;
+
+  my $test_result = stringify_result_obj $result_obj;
+  my $string = $result_obj->number;
+
+  my $description = $result_obj->description;
+  $string .= " $test_name" unless is_null_string $test_name;
+  $string .= " $description" unless is_null_string $description;
+
+  if ($plan_seen == LATE_PLAN)
+    {
+      $string .= " # AFTER LATE PLAN";
+    }
+  elsif ($result_obj->is_unplanned)
+    {
+      $string .= " # UNPLANNED";
+    }
+  elsif ($result_obj->number != $testno)
+    {
+      $string .= " # OUT-OF-ORDER (expecting $testno)";
+    }
+  elsif (my $directive = $result_obj->directive)
+    {
+      $string .= " # $directive";
+      my $explanation = $result_obj->explanation;
+      $string .= " $explanation"
+        unless is_null_string $explanation;
+    }
+
+  report $test_result, $string;
+}
+
+sub handle_tap_plan ($)
+{
+  my $plan = shift;
+  if ($plan_seen)
+    {
+      # Error, only one plan per stream is acceptable.
+      testsuite_error "multiple test plans";
+      return;
+    }
+  # The TAP plan can come before or after *all* the TAP results; we speak
+  # respectively of an "early" or a "late" plan.  If we see the plan line
+  # after at least one TAP result has been seen, assume we have a late
+  # plan; in this case, any further test result seen after the plan will
+  # be flagged as an error.
+  $plan_seen = ($testno >= 1 ? LATE_PLAN : EARLY_PLAN);
+  # If $testno > 0, we have an error ("too many tests run") that will be
+  # automatically dealt with later, so don't worry about it here.  If
+  # $plan_seen is true, we have an error due to a repeated plan, and that
+  # has already been dealt with above.  Otherwise, we have a valid "plan
+  # with SKIP" specification, and should report it as a particular kind
+  # of SKIP result.
+  if ($plan->directive && $testno == 0)
+    {
+      my $explanation = is_null_string ($plan->explanation) ?
+                        undef : "- " . $plan->explanation;
+      report "SKIP", $explanation;
+    }
+}
+
+sub handle_tap_bailout ($)
+{
+  my ($bailout, $msg) = ($_[0], "Bail out!");
+  $bailed_out = 1;
+  $msg .= " " . $bailout->explanation
+    unless is_null_string $bailout->explanation;
+  testsuite_error $msg;
+}
+
+sub extract_tap_comment ($)
+{
+  my $line = shift;
+  if (index ($line, DIAG_STRING) == 0)
+    {
+      # Strip leading `DIAG_STRING' from `$line'.
+      $line = substr ($line, length (DIAG_STRING));
+      # And strip any leading and trailing whitespace left.
+      $line =~ s/(?:^\s*|\s*$)//g;
+      # Return what is left (if any).
+      return $line;
+    }
+  return "";
+}
+
+sub main ()
+{
+  my $iterator = TAP::Parser::Iterator::Stream->new(\*STDIN);
+  my $parser = TAP::Parser->new ({iterator => $iterator });
+
+  while (defined (my $cur = $parser->next))
+    {
+      # Parsing of TAP input should stop after a "Bail out!" directive.
+      next if $bailed_out;
+
+      if ($cur->is_plan)
+        {
+          handle_tap_plan ($cur);
+        }
+      elsif ($cur->is_test)
+        {
+          handle_tap_result ($cur);
+        }
+      elsif ($cur->is_bailout)
+        {
+          handle_tap_bailout ($cur);
+        }
+      elsif ($cfg{"verbose"})
+        {
+          my $comment = extract_tap_comment ($cur->raw);
+          report "#", "$comment" if length $comment;
+       }
+    }
+  # A "Bail out!" directive should cause us to ignore any following TAP
+  # error.
+  if (!$bailed_out)
+    {
+      if (!$plan_seen)
+        {
+          testsuite_error "missing test plan";
+        }
+      elsif ($parser->tests_planned != $parser->tests_run)
+        {
+          my ($planned, $run) = ($parser->tests_planned, $parser->tests_run);
+          my $bad_amount = $run > $planned ? "many" : "few";
+          testsuite_error (sprintf "too %s tests run (expected %d, got %d)",
+                                   $bad_amount, $planned, $run);
+        }
+    }
+}
+
+# ----------- #
+#  Main code. #
+# ----------- #
+
+main;
+exit($failed);
+
+# Local Variables:
+# perl-indent-level: 2
+# perl-continued-statement-offset: 2
+# perl-continued-brace-offset: 0
+# perl-brace-offset: 0
+# perl-brace-imaginary-offset: 0
+# perl-label-offset: -2
+# cperl-indent-level: 2
+# cperl-brace-offset: 0
+# cperl-continued-brace-offset: 0
+# cperl-label-offset: -2
+# cperl-extra-newline-before-brace: t
+# cperl-merge-trailing-else: nil
+# cperl-continued-statement-offset: 2
+# End:
diff --git a/scripts/tap-merge.pl b/scripts/tap-merge.pl
new file mode 100755
index 0000000..59e3fa5
--- /dev/null
+++ b/scripts/tap-merge.pl
@@ -0,0 +1,110 @@
+#! /usr/bin/env perl
+# Copyright (C) 2018 Red Hat, Inc.
+#
+# Author: Paolo Bonzini <pbonzini@redhat.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <https://www.gnu.org/licenses/>.
+
+# ---------------------------------- #
+#  Imports, static data, and setup.  #
+# ---------------------------------- #
+
+use warnings FATAL => 'all';
+use strict;
+use Getopt::Long ();
+use TAP::Parser;
+
+my $ME = "tap-merge.pl";
+my $VERSION = "2018-11-30";
+
+my $HELP = "$ME: merge multiple TAP inputs from stdin.";
+
+use constant DIAG_STRING => "#";
+
+# ----------------- #
+#  Option parsing.  #
+# ----------------- #
+
+Getopt::Long::GetOptions
+  (
+    'help' => sub { print $HELP; exit 0; },
+    'version' => sub { print "$ME $VERSION\n"; exit 0; },
+  );
+
+# -------------- #
+#  Subroutines.  #
+# -------------- #
+
+sub main ()
+{
+  my $iterator = TAP::Parser::Iterator::Stream->new(\*STDIN);
+  my $parser = TAP::Parser->new ({iterator => $iterator });
+  my $testno = 0;     # Number of test results seen so far.
+  my $bailed_out = 0; # Whether a "Bail out!" directive has been seen.
+
+  while (defined (my $cur = $parser->next))
+    {
+      if ($cur->is_bailout)
+        {
+          $bailed_out = 1;
+          print DIAG_STRING . " " . $cur->as_string . "\n";
+          next;
+        }
+      elsif ($cur->is_plan)
+        {
+          $bailed_out = 0;
+          next;
+        }
+      elsif ($cur->is_test)
+        {
+          $bailed_out = 0 if $cur->number == 1;
+          $testno++;
+          $cur = TAP::Parser::Result::Test->new({
+                          ok => $cur->ok,
+                          test_num => $testno,
+                          directive => $cur->directive,
+                          explanation => $cur->explanation,
+                          description => $cur->description
+                  });
+        }
+      elsif ($cur->is_version)
+        {
+          next if $testno > 0;
+        }
+      print $cur->as_string . "\n" unless $bailed_out;
+    }
+  print "1..$testno\n";
+}
+
+# ----------- #
+#  Main code. #
+# ----------- #
+
+main;
+
+# Local Variables:
+# perl-indent-level: 2
+# perl-continued-statement-offset: 2
+# perl-continued-brace-offset: 0
+# perl-brace-offset: 0
+# perl-brace-imaginary-offset: 0
+# perl-label-offset: -2
+# cperl-indent-level: 2
+# cperl-brace-offset: 0
+# cperl-continued-brace-offset: 0
+# cperl-label-offset: -2
+# cperl-extra-newline-before-brace: t
+# cperl-merge-trailing-else: nil
+# cperl-continued-statement-offset: 2
+# End:
diff --git a/tests/Makefile.include b/tests/Makefile.include
index fb0b449..62915e4 100644
--- a/tests/Makefile.include
+++ b/tests/Makefile.include
@@ -799,41 +799,53 @@ tests/test-qga$(EXESUF): qemu-ga$(EXESUF)
 tests/test-qga$(EXESUF): tests/test-qga.o $(qtest-obj-y)
 
 SPEED = quick
-GTESTER_OPTIONS = -k $(if $(V),--verbose,-q)
-GCOV_OPTIONS = -n $(if $(V),-f,)
 
 # gtester tests, possibly with verbose output
+# do_test_tap runs all tests, even if some of them fail, while do_test_human
+# stops at the first failure unless -k is given on the command line
+
+do_test_human = \
+	$(call quiet-command, rc=0; \
+	  { $(foreach COMMAND, $1, \
+	    MALLOC_PERTURB_=$${MALLOC_PERTURB_:-$$(( $${RANDOM:-0} % 255 + 1))} \
+	      $2 $(COMMAND) -m=$(SPEED) -k --tap \
+	      | ./scripts/tap-driver.pl --test-name="$(notdir $(COMMAND))" --color=always $(if $(V),, --show-failures-only) \
+	      || $(if $(findstring k, $(MAKEFLAGS)), rc=$$?, exit $$?); ) }; exit $$rc, \
+	  "TEST", "$@")
+
+do_test_tap = \
+	$(call quiet-command, \
+	  { $(foreach COMMAND, $1, \
+	    MALLOC_PERTURB_=$${MALLOC_PERTURB_:-$$(( $${RANDOM:-0} % 255 + 1))} \
+	      $2 $(COMMAND) -m=$(SPEED) -k --tap | sed "s/^[a-z][a-z]* [0-9]* /&$(notdir $(COMMAND)) /" || true; ) } \
+	      | ./scripts/tap-merge.pl | tee "$@" \
+	      | ./scripts/tap-driver.pl --color=always $(if $(V),, --show-failures-only), \
+	  "TAP","$@")
 
 .PHONY: $(patsubst %, check-qtest-%, $(QTEST_TARGETS))
 $(patsubst %, check-qtest-%, $(QTEST_TARGETS)): check-qtest-%: subdir-%-softmmu $(check-qtest-y)
-	$(call quiet-command,QTEST_QEMU_BINARY=$*-softmmu/qemu-system-$* \
-		QTEST_QEMU_IMG=qemu-img$(EXESUF) \
-		MALLOC_PERTURB_=$${MALLOC_PERTURB_:-$$(( $${RANDOM:-0} % 255 + 1))} \
-		gtester $(GTESTER_OPTIONS) -m=$(SPEED) $(check-qtest-$*-y) $(check-qtest-generic-y),"GTESTER","$@")
+	$(call do_test_human,$(check-qtest-$*-y) $(check-qtest-generic-y), \
+	  QTEST_QEMU_BINARY=$*-softmmu/qemu-system-$* \
+	  QTEST_QEMU_IMG=qemu-img$(EXESUF))
 
 .PHONY: $(patsubst %, check-%, $(check-unit-y) $(check-speed-y))
 $(patsubst %, check-%, $(check-unit-y) $(check-speed-y)): check-%: %
-	$(call quiet-command, \
-		MALLOC_PERTURB_=$${MALLOC_PERTURB_:-$$(( $${RANDOM:-0} % 255 + 1))} \
-		gtester $(GTESTER_OPTIONS) -m=$(SPEED) $*,"GTESTER","$*")
+	$(call do_test_human, $*)
 
-# gtester tests with XML output
+# gtester tests with TAP output
 
-$(patsubst %, check-report-qtest-%.xml, $(QTEST_TARGETS)): check-report-qtest-%.xml: $(check-qtest-y)
-	$(call quiet-command,QTEST_QEMU_BINARY=$*-softmmu/qemu-system-$* \
-		QTEST_QEMU_IMG=qemu-img$(EXESUF) \
-	  gtester -q $(GTESTER_OPTIONS) -o $@ -m=$(SPEED) $(check-qtest-$*-y) $(check-qtest-generic-y),"GTESTER","$@")
+$(patsubst %, check-report-qtest-%.tap, $(QTEST_TARGETS)): check-report-qtest-%.tap: $(check-qtest-y)
+	$(call do_test_tap, $(check-qtest-$*-y) $(check-qtest-generic-y), \
+	  QTEST_QEMU_BINARY=$*-softmmu/qemu-system-$* \
+	  QTEST_QEMU_IMG=qemu-img$(EXESUF))
 
-check-report-unit.xml: $(check-unit-y)
-	$(call quiet-command,gtester -q $(GTESTER_OPTIONS) -o $@ -m=$(SPEED) $^,"GTESTER","$@")
+check-report-unit.tap: $(check-unit-y)
+	$(call do_test_tap,$^)
 
 # Reports and overall runs
 
-check-report.xml: $(patsubst %,check-report-qtest-%.xml, $(QTEST_TARGETS)) check-report-unit.xml
-	$(call quiet-command,$(SRC_PATH)/scripts/gtester-cat $^ > $@,"GEN","$@")
-
-check-report.html: check-report.xml
-	$(call quiet-command,gtester-report $< > $@,"GEN","$@")
+check-report.tap: $(patsubst %,check-report-qtest-%.tap, $(QTEST_TARGETS)) check-report-unit.tap
+	$(call quiet-command,./scripts/tap-merge.py $^ > $@,"GEN","$@")
 
 # Per guest TCG tests
 
diff --git a/tests/docker/dockerfiles/centos7.docker b/tests/docker/dockerfiles/centos7.docker
index 0a04bfb..e0f18f5 100644
--- a/tests/docker/dockerfiles/centos7.docker
+++ b/tests/docker/dockerfiles/centos7.docker
@@ -22,6 +22,7 @@ ENV PACKAGES \
     mesa-libEGL-devel \
     mesa-libgbm-devel \
     nettle-devel \
+    perl-Test-Harness \
     pixman-devel \
     SDL-devel \
     spice-glib-devel \
diff --git a/tests/docker/dockerfiles/debian-amd64.docker b/tests/docker/dockerfiles/debian-amd64.docker
index 24b113b..c66e341 100644
--- a/tests/docker/dockerfiles/debian-amd64.docker
+++ b/tests/docker/dockerfiles/debian-amd64.docker
@@ -16,6 +16,7 @@ RUN DEBIAN_FRONTEND=noninteractive eatmydata \
         liblzo2-dev \
         librdmacm-dev \
         libsnappy-dev \
+        libtest-harness-perl \
         libvte-dev
 
 # virgl
diff --git a/tests/docker/dockerfiles/debian-ports.docker b/tests/docker/dockerfiles/debian-ports.docker
index e05a9a9..514ab53 100644
--- a/tests/docker/dockerfiles/debian-ports.docker
+++ b/tests/docker/dockerfiles/debian-ports.docker
@@ -29,6 +29,7 @@ RUN DEBIAN_FRONTEND=noninteractive eatmydata \
         flex \
         gettext \
         git \
+        libtest-harness-perl \
         pkg-config \
         psmisc \
         python \
diff --git a/tests/docker/dockerfiles/debian-sid.docker b/tests/docker/dockerfiles/debian-sid.docker
index 9a3d168..b30cbe7 100644
--- a/tests/docker/dockerfiles/debian-sid.docker
+++ b/tests/docker/dockerfiles/debian-sid.docker
@@ -26,6 +26,7 @@ RUN DEBIAN_FRONTEND=noninteractive eatmydata \
         ca-certificates \
         flex \
         git \
+        libtest-harness-perl \
         pkg-config \
         psmisc \
         python \
diff --git a/tests/docker/dockerfiles/debian8.docker b/tests/docker/dockerfiles/debian8.docker
index 5294563..cdc3f11 100644
--- a/tests/docker/dockerfiles/debian8.docker
+++ b/tests/docker/dockerfiles/debian8.docker
@@ -29,6 +29,7 @@ RUN DEBIAN_FRONTEND=noninteractive eatmydata \
         gettext \
         git \
         gnupg \
+        libtest-harness-perl \
         pkg-config \
         python-minimal
 
diff --git a/tests/docker/dockerfiles/debian9.docker b/tests/docker/dockerfiles/debian9.docker
index 154ae2a..9561d4f 100644
--- a/tests/docker/dockerfiles/debian9.docker
+++ b/tests/docker/dockerfiles/debian9.docker
@@ -24,6 +24,7 @@ RUN DEBIAN_FRONTEND=noninteractive eatmydata \
         flex \
         gettext \
         git \
+        libtest-harness-perl \
         pkg-config \
         psmisc \
         python \
diff --git a/tests/docker/dockerfiles/fedora.docker b/tests/docker/dockerfiles/fedora.docker
index 0c4eb9e..1d0e3dc 100644
--- a/tests/docker/dockerfiles/fedora.docker
+++ b/tests/docker/dockerfiles/fedora.docker
@@ -70,6 +70,7 @@ ENV PACKAGES \
     nss-devel \
     numactl-devel \
     perl \
+    perl-Test-Harness \
     pixman-devel \
     python3 \
     PyYAML \
diff --git a/tests/docker/dockerfiles/ubuntu.docker b/tests/docker/dockerfiles/ubuntu.docker
index 36e2b17..229add5 100644
--- a/tests/docker/dockerfiles/ubuntu.docker
+++ b/tests/docker/dockerfiles/ubuntu.docker
@@ -45,6 +45,7 @@ ENV PACKAGES flex bison \
     libspice-protocol-dev \
     libspice-server-dev \
     libssh2-1-dev \
+    libtest-harness-perl \
     libusb-1.0-0-dev \
     libusbredirhost-dev \
     libvdeplug-dev \
-- 
1.8.3.1

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

* [Qemu-devel] [PULL 24/54] compiler.h: Add an explicit check for the compiler version
  2018-12-12 15:22 [Qemu-devel] [PULL 00/54] Misc patches for 2018-12-12 Paolo Bonzini
                   ` (22 preceding siblings ...)
  2018-12-12 15:22 ` [Qemu-devel] [PULL 23/54] test: replace gtester with a TAP driver Paolo Bonzini
@ 2018-12-12 15:22 ` Paolo Bonzini
  2018-12-12 15:59   ` Thomas Huth
  2018-12-12 15:22 ` [Qemu-devel] [PULL 25/54] qemu/queue.h: do not access tqe_prev directly Paolo Bonzini
                   ` (31 subsequent siblings)
  55 siblings, 1 reply; 60+ messages in thread
From: Paolo Bonzini @ 2018-12-12 15:22 UTC (permalink / raw)
  To: qemu-devel; +Cc: Thomas Huth

From: Thomas Huth <thuth@redhat.com>

The questions about our minimum compiler requirement pops up every
couple of months, and we then have to recall the details each time.
So let's document this in a proper way, by adding a comment and
check for the right compiler version to our compiler.h header.

Signed-off-by: Thomas Huth <thuth@redhat.com>
Message-Id: <1543574620-17506-1-git-send-email-thuth@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 include/qemu/compiler.h | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/include/qemu/compiler.h b/include/qemu/compiler.h
index 6b92710..6f32ec2 100644
--- a/include/qemu/compiler.h
+++ b/include/qemu/compiler.h
@@ -22,6 +22,14 @@
 # define QEMU_GNUC_PREREQ(maj, min) 0
 #endif
 
+/*
+ * We need at least GCC 4.1 for atomics support. Clang also supports these,
+ * and reports itself as GCC 4.2, so it passes this check, too.
+ */
+#if !QEMU_GNUC_PREREQ(4, 1)
+#error QEMU needs a compiler that is compatible with GCC v4.1 or newer
+#endif
+
 #define QEMU_NORETURN __attribute__ ((__noreturn__))
 
 #define QEMU_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
-- 
1.8.3.1

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

* [Qemu-devel] [PULL 25/54] qemu/queue.h: do not access tqe_prev directly
  2018-12-12 15:22 [Qemu-devel] [PULL 00/54] Misc patches for 2018-12-12 Paolo Bonzini
                   ` (23 preceding siblings ...)
  2018-12-12 15:22 ` [Qemu-devel] [PULL 24/54] compiler.h: Add an explicit check for the compiler version Paolo Bonzini
@ 2018-12-12 15:22 ` Paolo Bonzini
  2018-12-12 15:22 ` [Qemu-devel] [PULL 26/54] vfio: make vfio_address_spaces static Paolo Bonzini
                   ` (30 subsequent siblings)
  55 siblings, 0 replies; 60+ messages in thread
From: Paolo Bonzini @ 2018-12-12 15:22 UTC (permalink / raw)
  To: qemu-devel

Use the QTAILQ_IN_USE macro instead, it does the same thing but the next
patch will change it to a different definition.

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 blockdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/blockdev.c b/blockdev.c
index 81f95d9..7604b21 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -4259,7 +4259,7 @@ void qmp_blockdev_del(const char *node_name, Error **errp)
         goto out;
     }
 
-    if (!bs->monitor_list.tqe_prev) {
+    if (!QTAILQ_IN_USE(bs, monitor_list)) {
         error_setg(errp, "Node %s is not owned by the monitor",
                    bs->node_name);
         goto out;
-- 
1.8.3.1

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

* [Qemu-devel] [PULL 26/54] vfio: make vfio_address_spaces static
  2018-12-12 15:22 [Qemu-devel] [PULL 00/54] Misc patches for 2018-12-12 Paolo Bonzini
                   ` (24 preceding siblings ...)
  2018-12-12 15:22 ` [Qemu-devel] [PULL 25/54] qemu/queue.h: do not access tqe_prev directly Paolo Bonzini
@ 2018-12-12 15:22 ` Paolo Bonzini
  2018-12-12 15:22 ` [Qemu-devel] [PULL 27/54] qemu/queue.h: leave head structs anonymous unless necessary Paolo Bonzini
                   ` (29 subsequent siblings)
  55 siblings, 0 replies; 60+ messages in thread
From: Paolo Bonzini @ 2018-12-12 15:22 UTC (permalink / raw)
  To: qemu-devel

It is not used outside hw/vfio/common.c, so it does not need to
be extern.

Acked-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/vfio/common.c              | 2 +-
 include/hw/vfio/vfio-common.h | 1 -
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/hw/vfio/common.c b/hw/vfio/common.c
index 7c185e5a..7aa804e 100644
--- a/hw/vfio/common.c
+++ b/hw/vfio/common.c
@@ -39,7 +39,7 @@
 
 struct vfio_group_head vfio_group_list =
     QLIST_HEAD_INITIALIZER(vfio_group_list);
-struct vfio_as_head vfio_address_spaces =
+static QLIST_HEAD(, VFIOAddressSpace) vfio_address_spaces =
     QLIST_HEAD_INITIALIZER(vfio_address_spaces);
 
 #ifdef CONFIG_KVM
diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h
index 1b434d0..127ca47 100644
--- a/include/hw/vfio/vfio-common.h
+++ b/include/hw/vfio/vfio-common.h
@@ -181,7 +181,6 @@ int vfio_get_device(VFIOGroup *group, const char *name,
 
 extern const MemoryRegionOps vfio_region_ops;
 extern QLIST_HEAD(vfio_group_head, VFIOGroup) vfio_group_list;
-extern QLIST_HEAD(vfio_as_head, VFIOAddressSpace) vfio_address_spaces;
 
 #ifdef CONFIG_LINUX
 int vfio_get_region_info(VFIODevice *vbasedev, int index,
-- 
1.8.3.1

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

* [Qemu-devel] [PULL 27/54] qemu/queue.h: leave head structs anonymous unless necessary
  2018-12-12 15:22 [Qemu-devel] [PULL 00/54] Misc patches for 2018-12-12 Paolo Bonzini
                   ` (25 preceding siblings ...)
  2018-12-12 15:22 ` [Qemu-devel] [PULL 26/54] vfio: make vfio_address_spaces static Paolo Bonzini
@ 2018-12-12 15:22 ` Paolo Bonzini
  2018-12-12 15:22 ` [Qemu-devel] [PULL 28/54] qemu/queue.h: typedef QTAILQ heads Paolo Bonzini
                   ` (28 subsequent siblings)
  55 siblings, 0 replies; 60+ messages in thread
From: Paolo Bonzini @ 2018-12-12 15:22 UTC (permalink / raw)
  To: qemu-devel

Most list head structs need not be given a name.  In most cases the
name is given just in case one is going to use QTAILQ_LAST, QTAILQ_PREV
or reverse iteration, but this does not apply to lists of other kinds,
and even for QTAILQ in practice this is only rarely needed.  In addition,
we will soon reimplement those macros completely so that they do not
need a name for the head struct.  So clean up everything, not giving a
name except in the rare case where it is necessary.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 accel/kvm/kvm-all.c                     | 4 ++--
 block/gluster.c                         | 2 +-
 block/mirror.c                          | 2 +-
 block/qcow2-bitmap.c                    | 4 +---
 block/qcow2.h                           | 2 +-
 block/sheepdog.c                        | 6 +++---
 block/vhdx.h                            | 2 +-
 blockdev.c                              | 2 +-
 contrib/ivshmem-client/ivshmem-client.h | 4 +---
 contrib/ivshmem-server/ivshmem-server.h | 5 +----
 exec.c                                  | 2 +-
 fsdev/qemu-fsdev.c                      | 2 +-
 hw/block/nvme.h                         | 8 ++++----
 hw/block/xen_disk.c                     | 6 +++---
 hw/core/reset.c                         | 2 +-
 hw/i386/xen/xen-mapcache.c              | 2 +-
 hw/ppc/spapr_iommu.c                    | 2 +-
 hw/usb/ccid-card-emulated.c             | 4 ++--
 hw/usb/dev-network.c                    | 2 +-
 hw/usb/xen-usb.c                        | 6 +++---
 hw/watchdog/watchdog.c                  | 2 +-
 hw/xen/xen_pvdev.c                      | 4 ++--
 include/exec/memory.h                   | 4 ++--
 include/hw/vfio/vfio-platform.h         | 2 +-
 include/qom/cpu.h                       | 4 ++--
 include/sysemu/kvm.h                    | 2 --
 include/sysemu/rng.h                    | 2 +-
 linux-user/elfload.c                    | 2 +-
 memory.c                                | 2 +-
 migration/block-dirty-bitmap.c          | 2 +-
 migration/block.c                       | 4 ++--
 migration/ram.c                         | 2 +-
 monitor.c                               | 4 ++--
 net/queue.c                             | 2 +-
 net/slirp.c                             | 2 +-
 slirp/slirp.c                           | 2 +-
 target/arm/kvm.c                        | 2 +-
 target/i386/hax-mem.c                   | 2 +-
 tcg/tcg.h                               | 2 +-
 tests/test-rcu-list.c                   | 2 +-
 vl.c                                    | 2 +-
 41 files changed, 56 insertions(+), 65 deletions(-)

diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
index 4880a05..4e1de94 100644
--- a/accel/kvm/kvm-all.c
+++ b/accel/kvm/kvm-all.c
@@ -86,7 +86,7 @@ struct KVMState
     int robust_singlestep;
     int debugregs;
 #ifdef KVM_CAP_SET_GUEST_DEBUG
-    struct kvm_sw_breakpoint_head kvm_sw_breakpoints;
+    QTAILQ_HEAD(, kvm_sw_breakpoint) kvm_sw_breakpoints;
 #endif
     int many_ioeventfds;
     int intx_set_mask;
@@ -102,7 +102,7 @@ struct KVMState
     int nr_allocated_irq_routes;
     unsigned long *used_gsi_bitmap;
     unsigned int gsi_count;
-    QTAILQ_HEAD(msi_hashtab, KVMMSIRoute) msi_hashtab[KVM_MSI_HASHTAB_SIZE];
+    QTAILQ_HEAD(, KVMMSIRoute) msi_hashtab[KVM_MSI_HASHTAB_SIZE];
 #endif
     KVMMemoryListener memory_listener;
     QLIST_HEAD(, KVMParkedVcpu) kvm_parked_vcpus;
diff --git a/block/gluster.c b/block/gluster.c
index 5e300c9..7289106 100644
--- a/block/gluster.c
+++ b/block/gluster.c
@@ -72,7 +72,7 @@ typedef struct ListElement {
     GlfsPreopened saved;
 } ListElement;
 
-static QLIST_HEAD(glfs_list, ListElement) glfs_list;
+static QLIST_HEAD(, ListElement) glfs_list;
 
 static QemuOptsList qemu_gluster_create_opts = {
     .name = "qemu-gluster-create-opts",
diff --git a/block/mirror.c b/block/mirror.c
index 8f52c62..6250cc3 100644
--- a/block/mirror.c
+++ b/block/mirror.c
@@ -72,7 +72,7 @@ typedef struct MirrorBlockJob {
     unsigned long *in_flight_bitmap;
     int in_flight;
     int64_t bytes_in_flight;
-    QTAILQ_HEAD(MirrorOpList, MirrorOp) ops_in_flight;
+    QTAILQ_HEAD(, MirrorOp) ops_in_flight;
     int ret;
     bool unmap;
     int target_cluster_size;
diff --git a/block/qcow2-bitmap.c b/block/qcow2-bitmap.c
index accebef..b946301 100644
--- a/block/qcow2-bitmap.c
+++ b/block/qcow2-bitmap.c
@@ -77,8 +77,6 @@ typedef struct Qcow2BitmapTable {
     uint32_t size; /* number of 64bit entries */
     QSIMPLEQ_ENTRY(Qcow2BitmapTable) entry;
 } Qcow2BitmapTable;
-typedef QSIMPLEQ_HEAD(Qcow2BitmapTableList, Qcow2BitmapTable)
-    Qcow2BitmapTableList;
 
 typedef struct Qcow2Bitmap {
     Qcow2BitmapTable table;
@@ -1316,7 +1314,7 @@ void qcow2_store_persistent_dirty_bitmaps(BlockDriverState *bs, Error **errp)
     int ret;
     Qcow2BitmapList *bm_list;
     Qcow2Bitmap *bm;
-    Qcow2BitmapTableList drop_tables;
+    QSIMPLEQ_HEAD(, Qcow2BitmapTable) drop_tables;
     Qcow2BitmapTable *tb, *tb_next;
 
     if (!bdrv_has_changed_persistent_bitmaps(bs)) {
diff --git a/block/qcow2.h b/block/qcow2.h
index 8662b68..d747dd1 100644
--- a/block/qcow2.h
+++ b/block/qcow2.h
@@ -281,7 +281,7 @@ typedef struct BDRVQcow2State {
     uint8_t *cluster_cache;
     uint8_t *cluster_data;
     uint64_t cluster_cache_offset;
-    QLIST_HEAD(QCowClusterAlloc, QCowL2Meta) cluster_allocs;
+    QLIST_HEAD(, QCowL2Meta) cluster_allocs;
 
     uint64_t *refcount_table;
     uint64_t refcount_table_offset;
diff --git a/block/sheepdog.c b/block/sheepdog.c
index 0125df9..90ab43b 100644
--- a/block/sheepdog.c
+++ b/block/sheepdog.c
@@ -391,12 +391,12 @@ struct BDRVSheepdogState {
     uint32_t aioreq_seq_num;
 
     /* Every aio request must be linked to either of these queues. */
-    QLIST_HEAD(inflight_aio_head, AIOReq) inflight_aio_head;
-    QLIST_HEAD(failed_aio_head, AIOReq) failed_aio_head;
+    QLIST_HEAD(, AIOReq) inflight_aio_head;
+    QLIST_HEAD(, AIOReq) failed_aio_head;
 
     CoMutex queue_lock;
     CoQueue overlapping_queue;
-    QLIST_HEAD(inflight_aiocb_head, SheepdogAIOCB) inflight_aiocb_head;
+    QLIST_HEAD(, SheepdogAIOCB) inflight_aiocb_head;
 };
 
 typedef struct BDRVSheepdogReopenState {
diff --git a/block/vhdx.h b/block/vhdx.h
index 3a5f529..1bfb4e4 100644
--- a/block/vhdx.h
+++ b/block/vhdx.h
@@ -398,7 +398,7 @@ typedef struct BDRVVHDXState {
 
     bool log_replayed_on_open;
 
-    QLIST_HEAD(VHDXRegionHead, VHDXRegionEntry) regions;
+    QLIST_HEAD(, VHDXRegionEntry) regions;
 } BDRVVHDXState;
 
 void vhdx_guid_generate(MSGUID *guid);
diff --git a/blockdev.c b/blockdev.c
index 7604b21..60d05ec 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -2269,7 +2269,7 @@ void qmp_transaction(TransactionActionList *dev_list,
     BlkActionState *state, *next;
     Error *local_err = NULL;
 
-    QSIMPLEQ_HEAD(snap_bdrv_states, BlkActionState) snap_bdrv_states;
+    QSIMPLEQ_HEAD(, BlkActionState) snap_bdrv_states;
     QSIMPLEQ_INIT(&snap_bdrv_states);
 
     /* Does this transaction get canceled as a group on failure?
diff --git a/contrib/ivshmem-client/ivshmem-client.h b/contrib/ivshmem-client/ivshmem-client.h
index 5ee9422..fe3cc4a 100644
--- a/contrib/ivshmem-client/ivshmem-client.h
+++ b/contrib/ivshmem-client/ivshmem-client.h
@@ -46,9 +46,7 @@ typedef struct IvshmemClientPeer {
     int vectors[IVSHMEM_CLIENT_MAX_VECTORS]; /**< one fd per vector */
     unsigned vectors_count;                  /**< number of vectors */
 } IvshmemClientPeer;
-QTAILQ_HEAD(IvshmemClientPeerList, IvshmemClientPeer);
 
-typedef struct IvshmemClientPeerList IvshmemClientPeerList;
 typedef struct IvshmemClient IvshmemClient;
 
 /**
@@ -73,7 +71,7 @@ struct IvshmemClient {
     int sock_fd;                        /**< unix sock filedesc */
     int shm_fd;                         /**< shm file descriptor */
 
-    IvshmemClientPeerList peer_list;    /**< list of peers */
+    QTAILQ_HEAD(, IvshmemClientPeer) peer_list;    /**< list of peers */
     IvshmemClientPeer local;            /**< our own infos */
 
     IvshmemClientNotifCb notif_cb;      /**< notification callback */
diff --git a/contrib/ivshmem-server/ivshmem-server.h b/contrib/ivshmem-server/ivshmem-server.h
index 4af08e1..d870adb 100644
--- a/contrib/ivshmem-server/ivshmem-server.h
+++ b/contrib/ivshmem-server/ivshmem-server.h
@@ -52,9 +52,6 @@ typedef struct IvshmemServerPeer {
     EventNotifier vectors[IVSHMEM_SERVER_MAX_VECTORS]; /**< one per vector */
     unsigned vectors_count;                  /**< number of vectors */
 } IvshmemServerPeer;
-QTAILQ_HEAD(IvshmemServerPeerList, IvshmemServerPeer);
-
-typedef struct IvshmemServerPeerList IvshmemServerPeerList;
 
 /**
  * Structure describing an ivshmem server
@@ -72,7 +69,7 @@ typedef struct IvshmemServer {
     unsigned n_vectors;              /**< number of vectors */
     uint16_t cur_id;                 /**< id to be given to next client */
     bool verbose;                    /**< true in verbose mode */
-    IvshmemServerPeerList peer_list; /**< list of peers */
+    QTAILQ_HEAD(, IvshmemServerPeer) peer_list; /**< list of peers */
 } IvshmemServer;
 
 /**
diff --git a/exec.c b/exec.c
index bb6170d..b6b2007 100644
--- a/exec.c
+++ b/exec.c
@@ -3464,7 +3464,7 @@ typedef struct MapClient {
 } MapClient;
 
 QemuMutex map_client_list_lock;
-static QLIST_HEAD(map_client_list, MapClient) map_client_list
+static QLIST_HEAD(, MapClient) map_client_list
     = QLIST_HEAD_INITIALIZER(map_client_list);
 
 static void cpu_unregister_map_client_do(MapClient *client)
diff --git a/fsdev/qemu-fsdev.c b/fsdev/qemu-fsdev.c
index 7a3b87c..82edf43 100644
--- a/fsdev/qemu-fsdev.c
+++ b/fsdev/qemu-fsdev.c
@@ -18,7 +18,7 @@
 #include "qemu/error-report.h"
 #include "qemu/option.h"
 
-static QTAILQ_HEAD(FsDriverEntry_head, FsDriverListEntry) fsdriver_entries =
+static QTAILQ_HEAD(, FsDriverListEntry) fsdriver_entries =
     QTAILQ_HEAD_INITIALIZER(fsdriver_entries);
 
 static FsDriverTable FsDrivers[] = {
diff --git a/hw/block/nvme.h b/hw/block/nvme.h
index cabcf20..56c9d4b 100644
--- a/hw/block/nvme.h
+++ b/hw/block/nvme.h
@@ -29,8 +29,8 @@ typedef struct NvmeSQueue {
     uint64_t    dma_addr;
     QEMUTimer   *timer;
     NvmeRequest *io_req;
-    QTAILQ_HEAD(sq_req_list, NvmeRequest) req_list;
-    QTAILQ_HEAD(out_req_list, NvmeRequest) out_req_list;
+    QTAILQ_HEAD(, NvmeRequest) req_list;
+    QTAILQ_HEAD(, NvmeRequest) out_req_list;
     QTAILQ_ENTRY(NvmeSQueue) entry;
 } NvmeSQueue;
 
@@ -45,8 +45,8 @@ typedef struct NvmeCQueue {
     uint32_t    size;
     uint64_t    dma_addr;
     QEMUTimer   *timer;
-    QTAILQ_HEAD(sq_list, NvmeSQueue) sq_list;
-    QTAILQ_HEAD(cq_req_list, NvmeRequest) req_list;
+    QTAILQ_HEAD(, NvmeSQueue) sq_list;
+    QTAILQ_HEAD(, NvmeRequest) req_list;
 } NvmeCQueue;
 
 typedef struct NvmeNamespace {
diff --git a/hw/block/xen_disk.c b/hw/block/xen_disk.c
index 36eff94..2a254b9 100644
--- a/hw/block/xen_disk.c
+++ b/hw/block/xen_disk.c
@@ -82,9 +82,9 @@ struct XenBlkDev {
     int                 more_work;
 
     /* request lists */
-    QLIST_HEAD(inflight_head, ioreq) inflight;
-    QLIST_HEAD(finished_head, ioreq) finished;
-    QLIST_HEAD(freelist_head, ioreq) freelist;
+    QLIST_HEAD(, ioreq) inflight;
+    QLIST_HEAD(, ioreq) finished;
+    QLIST_HEAD(, ioreq) freelist;
     int                 requests_total;
     int                 requests_inflight;
     int                 requests_finished;
diff --git a/hw/core/reset.c b/hw/core/reset.c
index 84c8869..9c477f2 100644
--- a/hw/core/reset.c
+++ b/hw/core/reset.c
@@ -35,7 +35,7 @@ typedef struct QEMUResetEntry {
     void *opaque;
 } QEMUResetEntry;
 
-static QTAILQ_HEAD(reset_handlers, QEMUResetEntry) reset_handlers =
+static QTAILQ_HEAD(, QEMUResetEntry) reset_handlers =
     QTAILQ_HEAD_INITIALIZER(reset_handlers);
 
 void qemu_register_reset(QEMUResetHandler *func, void *opaque)
diff --git a/hw/i386/xen/xen-mapcache.c b/hw/i386/xen/xen-mapcache.c
index 4e4f069..02e823c 100644
--- a/hw/i386/xen/xen-mapcache.c
+++ b/hw/i386/xen/xen-mapcache.c
@@ -71,7 +71,7 @@ typedef struct MapCacheRev {
 typedef struct MapCache {
     MapCacheEntry *entry;
     unsigned long nr_buckets;
-    QTAILQ_HEAD(map_cache_head, MapCacheRev) locked_entries;
+    QTAILQ_HEAD(, MapCacheRev) locked_entries;
 
     /* For most cases (>99.9%), the page address is the same. */
     MapCacheEntry *last_entry;
diff --git a/hw/ppc/spapr_iommu.c b/hw/ppc/spapr_iommu.c
index 1b0880a..68dacf6 100644
--- a/hw/ppc/spapr_iommu.c
+++ b/hw/ppc/spapr_iommu.c
@@ -42,7 +42,7 @@ enum sPAPRTCEAccess {
 #define IOMMU_PAGE_SIZE(shift)      (1ULL << (shift))
 #define IOMMU_PAGE_MASK(shift)      (~(IOMMU_PAGE_SIZE(shift) - 1))
 
-static QLIST_HEAD(spapr_tce_tables, sPAPRTCETable) spapr_tce_tables;
+static QLIST_HEAD(, sPAPRTCETable) spapr_tce_tables;
 
 sPAPRTCETable *spapr_tce_find_by_liobn(target_ulong liobn)
 {
diff --git a/hw/usb/ccid-card-emulated.c b/hw/usb/ccid-card-emulated.c
index 25976ed..de880a8 100644
--- a/hw/usb/ccid-card-emulated.c
+++ b/hw/usb/ccid-card-emulated.c
@@ -119,11 +119,11 @@ struct EmulatedState {
     char    *db;
     uint8_t  atr[MAX_ATR_SIZE];
     uint8_t  atr_length;
-    QSIMPLEQ_HEAD(event_list, EmulEvent) event_list;
+    QSIMPLEQ_HEAD(, EmulEvent) event_list;
     QemuMutex event_list_mutex;
     QemuThread event_thread_id;
     VReader *reader;
-    QSIMPLEQ_HEAD(guest_apdu_list, EmulEvent) guest_apdu_list;
+    QSIMPLEQ_HEAD(, EmulEvent) guest_apdu_list;
     QemuMutex vreader_mutex; /* and guest_apdu_list mutex */
     QemuMutex handle_apdu_mutex;
     QemuCond handle_apdu_cond;
diff --git a/hw/usb/dev-network.c b/hw/usb/dev-network.c
index 385e090..ffab3fa 100644
--- a/hw/usb/dev-network.c
+++ b/hw/usb/dev-network.c
@@ -648,7 +648,7 @@ typedef struct USBNetState {
     char usbstring_mac[13];
     NICState *nic;
     NICConf conf;
-    QTAILQ_HEAD(rndis_resp_head, rndis_response) rndis_resp;
+    QTAILQ_HEAD(, rndis_response) rndis_resp;
 } USBNetState;
 
 #define TYPE_USB_NET "usb-net"
diff --git a/hw/usb/xen-usb.c b/hw/usb/xen-usb.c
index 5b2e21e..5564eb9 100644
--- a/hw/usb/xen-usb.c
+++ b/hw/usb/xen-usb.c
@@ -72,7 +72,7 @@ struct usbback_stub {
     USBPort       port;
     unsigned int  speed;
     bool          attached;
-    QTAILQ_HEAD(submit_q_head, usbback_req) submit_q;
+    QTAILQ_HEAD(, usbback_req) submit_q;
 };
 
 struct usbback_req {
@@ -108,8 +108,8 @@ struct usbback_info {
     int                      num_ports;
     int                      usb_ver;
     bool                     ring_error;
-    QTAILQ_HEAD(req_free_q_head, usbback_req) req_free_q;
-    QSIMPLEQ_HEAD(hotplug_q_head, usbback_hotplug) hotplug_q;
+    QTAILQ_HEAD(, usbback_req) req_free_q;
+    QSIMPLEQ_HEAD(, usbback_hotplug) hotplug_q;
     struct usbback_stub      ports[USBBACK_MAXPORTS];
     struct usbback_stub      *addr_table[USB_DEV_ADDR_SIZE];
     QEMUBH                   *bh;
diff --git a/hw/watchdog/watchdog.c b/hw/watchdog/watchdog.c
index 33e6c20..dce7c1d 100644
--- a/hw/watchdog/watchdog.c
+++ b/hw/watchdog/watchdog.c
@@ -32,7 +32,7 @@
 #include "qemu/help_option.h"
 
 static WatchdogAction watchdog_action = WATCHDOG_ACTION_RESET;
-static QLIST_HEAD(watchdog_list, WatchdogTimerModel) watchdog_list;
+static QLIST_HEAD(, WatchdogTimerModel) watchdog_list;
 
 void watchdog_add_model(WatchdogTimerModel *model)
 {
diff --git a/hw/xen/xen_pvdev.c b/hw/xen/xen_pvdev.c
index aed783e..f026556 100644
--- a/hw/xen/xen_pvdev.c
+++ b/hw/xen/xen_pvdev.c
@@ -31,10 +31,10 @@ struct xs_dirs {
     QTAILQ_ENTRY(xs_dirs) list;
 };
 
-static QTAILQ_HEAD(xs_dirs_head, xs_dirs) xs_cleanup =
+static QTAILQ_HEAD(, xs_dirs) xs_cleanup =
     QTAILQ_HEAD_INITIALIZER(xs_cleanup);
 
-static QTAILQ_HEAD(XenDeviceHead, XenDevice) xendevs =
+static QTAILQ_HEAD(, XenDevice) xendevs =
     QTAILQ_HEAD_INITIALIZER(xendevs);
 
 /* ------------------------------------------------------------- */
diff --git a/include/exec/memory.h b/include/exec/memory.h
index 8e61450..ce93068 100644
--- a/include/exec/memory.h
+++ b/include/exec/memory.h
@@ -379,9 +379,9 @@ struct MemoryRegion {
     MemoryRegion *alias;
     hwaddr alias_offset;
     int32_t priority;
-    QTAILQ_HEAD(subregions, MemoryRegion) subregions;
+    QTAILQ_HEAD(, MemoryRegion) subregions;
     QTAILQ_ENTRY(MemoryRegion) subregions_link;
-    QTAILQ_HEAD(coalesced_ranges, CoalescedMemoryRange) coalesced;
+    QTAILQ_HEAD(, CoalescedMemoryRange) coalesced;
     const char *name;
     unsigned ioeventfd_nb;
     MemoryRegionIoeventfd *ioeventfds;
diff --git a/include/hw/vfio/vfio-platform.h b/include/hw/vfio/vfio-platform.h
index 0ee10b1..30d3c28 100644
--- a/include/hw/vfio/vfio-platform.h
+++ b/include/hw/vfio/vfio-platform.h
@@ -53,7 +53,7 @@ typedef struct VFIOPlatformDevice {
     VFIORegion **regions;
     QLIST_HEAD(, VFIOINTp) intp_list; /* list of IRQs */
     /* queue of pending IRQs */
-    QSIMPLEQ_HEAD(pending_intp_queue, VFIOINTp) pending_intp_queue;
+    QSIMPLEQ_HEAD(, VFIOINTp) pending_intp_queue;
     char *compat; /* DT compatible values, separated by NUL */
     unsigned int num_compat; /* number of compatible values */
     uint32_t mmap_timeout; /* delay to re-enable mmaps after interrupt */
diff --git a/include/qom/cpu.h b/include/qom/cpu.h
index 1396f53..62aef77 100644
--- a/include/qom/cpu.h
+++ b/include/qom/cpu.h
@@ -375,9 +375,9 @@ struct CPUState {
     QTAILQ_ENTRY(CPUState) node;
 
     /* ice debug support */
-    QTAILQ_HEAD(breakpoints_head, CPUBreakpoint) breakpoints;
+    QTAILQ_HEAD(, CPUBreakpoint) breakpoints;
 
-    QTAILQ_HEAD(watchpoints_head, CPUWatchpoint) watchpoints;
+    QTAILQ_HEAD(, CPUWatchpoint) watchpoints;
     CPUWatchpoint *watchpoint_hit;
 
     void *opaque;
diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h
index 97d8d9d..a6d1cd1 100644
--- a/include/sysemu/kvm.h
+++ b/include/sysemu/kvm.h
@@ -412,8 +412,6 @@ struct kvm_sw_breakpoint {
     QTAILQ_ENTRY(kvm_sw_breakpoint) entry;
 };
 
-QTAILQ_HEAD(kvm_sw_breakpoint_head, kvm_sw_breakpoint);
-
 struct kvm_sw_breakpoint *kvm_find_sw_breakpoint(CPUState *cpu,
                                                  target_ulong pc);
 
diff --git a/include/sysemu/rng.h b/include/sysemu/rng.h
index 45629c4..27b37da 100644
--- a/include/sysemu/rng.h
+++ b/include/sysemu/rng.h
@@ -57,7 +57,7 @@ struct RngBackend
 
     /*< protected >*/
     bool opened;
-    QSIMPLEQ_HEAD(requests, RngRequest) requests;
+    QSIMPLEQ_HEAD(, RngRequest) requests;
 };
 
 
diff --git a/linux-user/elfload.c b/linux-user/elfload.c
index 5bccd2e..4cff9e1 100644
--- a/linux-user/elfload.c
+++ b/linux-user/elfload.c
@@ -2844,7 +2844,7 @@ struct elf_note_info {
     struct target_elf_prstatus *prstatus;  /* NT_PRSTATUS */
     struct target_elf_prpsinfo *psinfo;    /* NT_PRPSINFO */
 
-    QTAILQ_HEAD(thread_list_head, elf_thread_status) thread_list;
+    QTAILQ_HEAD(, elf_thread_status) thread_list;
 #if 0
     /*
      * Current version of ELF coredump doesn't support
diff --git a/memory.c b/memory.c
index 5759f74..195c5cf 100644
--- a/memory.c
+++ b/memory.c
@@ -2795,7 +2795,7 @@ struct MemoryRegionList {
     QTAILQ_ENTRY(MemoryRegionList) mrqueue;
 };
 
-typedef QTAILQ_HEAD(mrqueue, MemoryRegionList) MemoryRegionListHead;
+typedef QTAILQ_HEAD(, MemoryRegionList) MemoryRegionListHead;
 
 #define MR_SIZE(size) (int128_nz(size) ? (hwaddr)int128_get64( \
                            int128_sub((size), int128_one())) : 0)
diff --git a/migration/block-dirty-bitmap.c b/migration/block-dirty-bitmap.c
index 5e90f44..6426151 100644
--- a/migration/block-dirty-bitmap.c
+++ b/migration/block-dirty-bitmap.c
@@ -116,7 +116,7 @@ typedef struct DirtyBitmapMigBitmapState {
 } DirtyBitmapMigBitmapState;
 
 typedef struct DirtyBitmapMigState {
-    QSIMPLEQ_HEAD(dbms_list, DirtyBitmapMigBitmapState) dbms_list;
+    QSIMPLEQ_HEAD(, DirtyBitmapMigBitmapState) dbms_list;
 
     bool bulk_completed;
     bool no_bitmaps;
diff --git a/migration/block.c b/migration/block.c
index 4c04d93..0e24e18 100644
--- a/migration/block.c
+++ b/migration/block.c
@@ -93,12 +93,12 @@ typedef struct BlkMigBlock {
 } BlkMigBlock;
 
 typedef struct BlkMigState {
-    QSIMPLEQ_HEAD(bmds_list, BlkMigDevState) bmds_list;
+    QSIMPLEQ_HEAD(, BlkMigDevState) bmds_list;
     int64_t total_sector_sum;
     bool zero_blocks;
 
     /* Protected by lock.  */
-    QSIMPLEQ_HEAD(blk_list, BlkMigBlock) blk_list;
+    QSIMPLEQ_HEAD(, BlkMigBlock) blk_list;
     int submitted;
     int read_done;
 
diff --git a/migration/ram.c b/migration/ram.c
index 7e7deec..1849979 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -322,7 +322,7 @@ struct RAMState {
     RAMBlock *last_req_rb;
     /* Queue of outstanding page requests from the destination */
     QemuMutex src_page_req_mutex;
-    QSIMPLEQ_HEAD(src_page_requests, RAMSrcPageRequest) src_page_requests;
+    QSIMPLEQ_HEAD(, RAMSrcPageRequest) src_page_requests;
 };
 typedef struct RAMState RAMState;
 
diff --git a/monitor.c b/monitor.c
index d39390c..b8bdb98 100644
--- a/monitor.c
+++ b/monitor.c
@@ -266,11 +266,11 @@ typedef struct QMPRequest QMPRequest;
 /* Protects mon_list, monitor_qapi_event_state.  */
 static QemuMutex monitor_lock;
 static GHashTable *monitor_qapi_event_state;
-static QTAILQ_HEAD(mon_list, Monitor) mon_list;
+static QTAILQ_HEAD(, Monitor) mon_list;
 
 /* Protects mon_fdsets */
 static QemuMutex mon_fdsets_lock;
-static QLIST_HEAD(mon_fdsets, MonFdset) mon_fdsets;
+static QLIST_HEAD(, MonFdset) mon_fdsets;
 
 static int mon_refcount;
 
diff --git a/net/queue.c b/net/queue.c
index 9c32abd..61276ca 100644
--- a/net/queue.c
+++ b/net/queue.c
@@ -55,7 +55,7 @@ struct NetQueue {
     uint32_t nq_count;
     NetQueueDeliverFunc *deliver;
 
-    QTAILQ_HEAD(packets, NetPacket) packets;
+    QTAILQ_HEAD(, NetPacket) packets;
 
     unsigned delivering : 1;
 };
diff --git a/net/slirp.c b/net/slirp.c
index f6dc039..38ae65e 100644
--- a/net/slirp.c
+++ b/net/slirp.c
@@ -85,7 +85,7 @@ typedef struct SlirpState {
 } SlirpState;
 
 static struct slirp_config_str *slirp_configs;
-static QTAILQ_HEAD(slirp_stacks, SlirpState) slirp_stacks =
+static QTAILQ_HEAD(, SlirpState) slirp_stacks =
     QTAILQ_HEAD_INITIALIZER(slirp_stacks);
 
 static int slirp_hostfwd(SlirpState *s, const char *redir_str, Error **errp);
diff --git a/slirp/slirp.c b/slirp/slirp.c
index 322edf5..ab2fc4e 100644
--- a/slirp/slirp.c
+++ b/slirp/slirp.c
@@ -47,7 +47,7 @@ static const uint8_t special_ethaddr[ETH_ALEN] = {
 
 u_int curtime;
 
-static QTAILQ_HEAD(slirp_instances, Slirp) slirp_instances =
+static QTAILQ_HEAD(, Slirp) slirp_instances =
     QTAILQ_HEAD_INITIALIZER(slirp_instances);
 
 static struct in_addr dns_addr;
diff --git a/target/arm/kvm.c b/target/arm/kvm.c
index 44dd0ce..e00ccf9 100644
--- a/target/arm/kvm.c
+++ b/target/arm/kvm.c
@@ -206,7 +206,7 @@ typedef struct KVMDevice {
     int dev_fd;
 } KVMDevice;
 
-static QSLIST_HEAD(kvm_devices_head, KVMDevice) kvm_devices_head;
+static QSLIST_HEAD(, KVMDevice) kvm_devices_head;
 
 static void kvm_arm_devlistener_add(MemoryListener *listener,
                                     MemoryRegionSection *section)
diff --git a/target/i386/hax-mem.c b/target/i386/hax-mem.c
index 5c37e94..6bb5a24 100644
--- a/target/i386/hax-mem.c
+++ b/target/i386/hax-mem.c
@@ -56,7 +56,7 @@ typedef struct HAXMapping {
  * send to the kernel only the removal of the pages from the MMIO hole after
  * having computed locally the result of the deletion and additions.
  */
-static QTAILQ_HEAD(HAXMappingListHead, HAXMapping) mappings =
+static QTAILQ_HEAD(, HAXMapping) mappings =
     QTAILQ_HEAD_INITIALIZER(mappings);
 
 /**
diff --git a/tcg/tcg.h b/tcg/tcg.h
index f4efbaa..1e9c87b 100644
--- a/tcg/tcg.h
+++ b/tcg/tcg.h
@@ -704,7 +704,7 @@ struct TCGContext {
 
     /* These structures are private to tcg-target.inc.c.  */
 #ifdef TCG_TARGET_NEED_LDST_LABELS
-    QSIMPLEQ_HEAD(ldst_labels, TCGLabelQemuLdst) ldst_labels;
+    QSIMPLEQ_HEAD(, TCGLabelQemuLdst) ldst_labels;
 #endif
 #ifdef TCG_TARGET_NEED_POOL_LABELS
     struct TCGLabelPoolData *pool_labels;
diff --git a/tests/test-rcu-list.c b/tests/test-rcu-list.c
index 2e6f70b..6f07647 100644
--- a/tests/test-rcu-list.c
+++ b/tests/test-rcu-list.c
@@ -108,7 +108,7 @@ static void reclaim_list_el(struct rcu_head *prcu)
 }
 
 #if TEST_LIST_TYPE == 1
-static QLIST_HEAD(q_list_head, list_element) Q_list_head;
+static QLIST_HEAD(, list_element) Q_list_head;
 
 #define TEST_NAME "qlist"
 #define TEST_LIST_REMOVE_RCU        QLIST_REMOVE_RCU
diff --git a/vl.c b/vl.c
index f6a6193..4431ae6 100644
--- a/vl.c
+++ b/vl.c
@@ -1529,7 +1529,7 @@ struct vm_change_state_entry {
     QLIST_ENTRY (vm_change_state_entry) entries;
 };
 
-static QLIST_HEAD(vm_change_state_head, vm_change_state_entry) vm_change_state_head;
+static QLIST_HEAD(, vm_change_state_entry) vm_change_state_head;
 
 VMChangeStateEntry *qemu_add_vm_change_state_handler(VMChangeStateHandler *cb,
                                                      void *opaque)
-- 
1.8.3.1

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

* [Qemu-devel] [PULL 28/54] qemu/queue.h: typedef QTAILQ heads
  2018-12-12 15:22 [Qemu-devel] [PULL 00/54] Misc patches for 2018-12-12 Paolo Bonzini
                   ` (26 preceding siblings ...)
  2018-12-12 15:22 ` [Qemu-devel] [PULL 27/54] qemu/queue.h: leave head structs anonymous unless necessary Paolo Bonzini
@ 2018-12-12 15:22 ` Paolo Bonzini
  2018-12-12 15:22 ` [Qemu-devel] [PULL 29/54] qemu/queue.h: remove Q_TAILQ_{HEAD, ENTRY} Paolo Bonzini
                   ` (27 subsequent siblings)
  55 siblings, 0 replies; 60+ messages in thread
From: Paolo Bonzini @ 2018-12-12 15:22 UTC (permalink / raw)
  To: qemu-devel

This will be needed when we change the QTAILQ head and elem structs
to unions.  However, it is also consistent with the usage elsewhere
in QEMU for other list head structs (see for example FsMountList).

Note that most QTAILQs only need their name in order to do backwards
walks.  Those do not break with the struct->union change, and anyway
the change will also remove the need to name heads when doing backwards
walks, so those are not touched here.

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 exec.c                        |  3 ++-
 hw/vfio/common.c              |  2 +-
 include/hw/vfio/vfio-common.h |  3 ++-
 include/qom/cpu.h             |  5 +++--
 ui/input.c                    | 14 ++++++++------
 5 files changed, 16 insertions(+), 11 deletions(-)

diff --git a/exec.c b/exec.c
index b6b2007..a629c98 100644
--- a/exec.c
+++ b/exec.c
@@ -94,7 +94,8 @@ int target_page_bits;
 bool target_page_bits_decided;
 #endif
 
-struct CPUTailQ cpus = QTAILQ_HEAD_INITIALIZER(cpus);
+CPUTailQ cpus = QTAILQ_HEAD_INITIALIZER(cpus);
+
 /* current CPU in the current thread. It is only valid inside
    cpu_exec() */
 __thread CPUState *current_cpu;
diff --git a/hw/vfio/common.c b/hw/vfio/common.c
index 7aa804e..4262b80 100644
--- a/hw/vfio/common.c
+++ b/hw/vfio/common.c
@@ -37,7 +37,7 @@
 #include "trace.h"
 #include "qapi/error.h"
 
-struct vfio_group_head vfio_group_list =
+VFIOGroupList vfio_group_list =
     QLIST_HEAD_INITIALIZER(vfio_group_list);
 static QLIST_HEAD(, VFIOAddressSpace) vfio_address_spaces =
     QLIST_HEAD_INITIALIZER(vfio_address_spaces);
diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h
index 127ca47..7624c9f 100644
--- a/include/hw/vfio/vfio-common.h
+++ b/include/hw/vfio/vfio-common.h
@@ -180,7 +180,8 @@ int vfio_get_device(VFIOGroup *group, const char *name,
                     VFIODevice *vbasedev, Error **errp);
 
 extern const MemoryRegionOps vfio_region_ops;
-extern QLIST_HEAD(vfio_group_head, VFIOGroup) vfio_group_list;
+typedef QLIST_HEAD(VFIOGroupList, VFIOGroup) VFIOGroupList;
+extern VFIOGroupList vfio_group_list;
 
 #ifdef CONFIG_LINUX
 int vfio_get_region_info(VFIODevice *vbasedev, int index,
diff --git a/include/qom/cpu.h b/include/qom/cpu.h
index 62aef77..4662a20 100644
--- a/include/qom/cpu.h
+++ b/include/qom/cpu.h
@@ -435,8 +435,9 @@ struct CPUState {
     GArray *iommu_notifiers;
 };
 
-QTAILQ_HEAD(CPUTailQ, CPUState);
-extern struct CPUTailQ cpus;
+typedef QTAILQ_HEAD(CPUTailQ, CPUState) CPUTailQ;
+extern CPUTailQ cpus;
+
 #define first_cpu        QTAILQ_FIRST_RCU(&cpus)
 #define CPU_NEXT(cpu)    QTAILQ_NEXT_RCU(cpu, node)
 #define CPU_FOREACH(cpu) QTAILQ_FOREACH_RCU(cpu, &cpus, node)
diff --git a/ui/input.c b/ui/input.c
index 7c9a410..35c7964 100644
--- a/ui/input.c
+++ b/ui/input.c
@@ -19,6 +19,9 @@ struct QemuInputHandlerState {
 };
 
 typedef struct QemuInputEventQueue QemuInputEventQueue;
+typedef QTAILQ_HEAD(QemuInputEventQueueHead, QemuInputEventQueue)
+    QemuInputEventQueueHead;
+
 struct QemuInputEventQueue {
     enum {
         QEMU_INPUT_QUEUE_DELAY = 1,
@@ -37,8 +40,7 @@ static QTAILQ_HEAD(, QemuInputHandlerState) handlers =
 static NotifierList mouse_mode_notifiers =
     NOTIFIER_LIST_INITIALIZER(mouse_mode_notifiers);
 
-static QTAILQ_HEAD(QemuInputEventQueueHead, QemuInputEventQueue) kbd_queue =
-    QTAILQ_HEAD_INITIALIZER(kbd_queue);
+static QemuInputEventQueueHead kbd_queue = QTAILQ_HEAD_INITIALIZER(kbd_queue);
 static QEMUTimer *kbd_timer;
 static uint32_t kbd_default_delay_ms = 10;
 static uint32_t queue_count;
@@ -257,7 +259,7 @@ static void qemu_input_event_trace(QemuConsole *src, InputEvent *evt)
 
 static void qemu_input_queue_process(void *opaque)
 {
-    struct QemuInputEventQueueHead *queue = opaque;
+    QemuInputEventQueueHead *queue = opaque;
     QemuInputEventQueue *item;
 
     g_assert(!QTAILQ_EMPTY(queue));
@@ -288,7 +290,7 @@ static void qemu_input_queue_process(void *opaque)
     }
 }
 
-static void qemu_input_queue_delay(struct QemuInputEventQueueHead *queue,
+static void qemu_input_queue_delay(QemuInputEventQueueHead *queue,
                                    QEMUTimer *timer, uint32_t delay_ms)
 {
     QemuInputEventQueue *item = g_new0(QemuInputEventQueue, 1);
@@ -306,7 +308,7 @@ static void qemu_input_queue_delay(struct QemuInputEventQueueHead *queue,
     }
 }
 
-static void qemu_input_queue_event(struct QemuInputEventQueueHead *queue,
+static void qemu_input_queue_event(QemuInputEventQueueHead *queue,
                                    QemuConsole *src, InputEvent *evt)
 {
     QemuInputEventQueue *item = g_new0(QemuInputEventQueue, 1);
@@ -318,7 +320,7 @@ static void qemu_input_queue_event(struct QemuInputEventQueueHead *queue,
     queue_count++;
 }
 
-static void qemu_input_queue_sync(struct QemuInputEventQueueHead *queue)
+static void qemu_input_queue_sync(QemuInputEventQueueHead *queue)
 {
     QemuInputEventQueue *item = g_new0(QemuInputEventQueue, 1);
 
-- 
1.8.3.1

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

* [Qemu-devel] [PULL 29/54] qemu/queue.h: remove Q_TAILQ_{HEAD, ENTRY}
  2018-12-12 15:22 [Qemu-devel] [PULL 00/54] Misc patches for 2018-12-12 Paolo Bonzini
                   ` (27 preceding siblings ...)
  2018-12-12 15:22 ` [Qemu-devel] [PULL 28/54] qemu/queue.h: typedef QTAILQ heads Paolo Bonzini
@ 2018-12-12 15:22 ` Paolo Bonzini
  2018-12-12 15:22 ` [Qemu-devel] [PULL 30/54] qemu/queue.h: reimplement QTAILQ without pointer-to-pointers Paolo Bonzini
                   ` (26 subsequent siblings)
  55 siblings, 0 replies; 60+ messages in thread
From: Paolo Bonzini @ 2018-12-12 15:22 UTC (permalink / raw)
  To: qemu-devel

These are not present for other kinds of queue, and unused.
Zap them before more changes are made to the QTAILQ
implementation.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 include/qemu/queue.h       | 14 ++++++--------
 scripts/cocci-macro-file.h | 10 ----------
 2 files changed, 6 insertions(+), 18 deletions(-)

diff --git a/include/qemu/queue.h b/include/qemu/queue.h
index ac418ef..b9571e9 100644
--- a/include/qemu/queue.h
+++ b/include/qemu/queue.h
@@ -350,22 +350,20 @@ struct {                                                                \
 /*
  * Tail queue definitions.
  */
-#define Q_TAILQ_HEAD(name, type, qual)                                  \
+#define QTAILQ_HEAD(name, type)                                         \
 struct name {                                                           \
-        qual type *tqh_first;           /* first element */             \
-        qual type *qual *tqh_last;      /* addr of last next element */ \
+        type *tqh_first;      /* first element */                       \
+        type **tqh_last;      /* addr of last next element */           \
 }
-#define QTAILQ_HEAD(name, type)  Q_TAILQ_HEAD(name, struct type,)
 
 #define QTAILQ_HEAD_INITIALIZER(head)                                   \
         { NULL, &(head).tqh_first }
 
-#define Q_TAILQ_ENTRY(type, qual)                                       \
+#define QTAILQ_ENTRY(type)                                              \
 struct {                                                                \
-        qual type *tqe_next;            /* next element */              \
-        qual type *qual *tqe_prev;      /* address of previous next element */\
+        type *tqe_next;       /* next element */                   \
+        type **tqe_prev;      /* address of previous next element */    \
 }
-#define QTAILQ_ENTRY(type)       Q_TAILQ_ENTRY(struct type,)
 
 /*
  * Tail queue functions.
diff --git a/scripts/cocci-macro-file.h b/scripts/cocci-macro-file.h
index 9f2e72e..5c49369 100644
--- a/scripts/cocci-macro-file.h
+++ b/scripts/cocci-macro-file.h
@@ -93,11 +93,6 @@ struct {                                                                \
 /*
  * Tail queue definitions.
  */
-#define Q_TAILQ_HEAD(name, type, qual)                                  \
-struct name {                                                           \
-        qual type *tqh_first;           /* first element */             \
-        qual type *qual *tqh_last;      /* addr of last next element */ \
-}
 #define QTAILQ_HEAD(name, type)                                         \
 struct name {                                                           \
         type *tqh_first;      /* first element */                       \
@@ -107,11 +102,6 @@ struct name {                                                           \
 #define QTAILQ_HEAD_INITIALIZER(head)                                   \
         { NULL, &(head).tqh_first }
 
-#define Q_TAILQ_ENTRY(type, qual)                                       \
-struct {                                                                \
-        qual type *tqe_next;            /* next element */              \
-        qual type *qual *tqe_prev;      /* address of previous next element */\
-}
 #define QTAILQ_ENTRY(type)                                              \
 struct {                                                                \
         type *tqe_next;       /* next element */                        \
-- 
1.8.3.1

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

* [Qemu-devel] [PULL 30/54] qemu/queue.h: reimplement QTAILQ without pointer-to-pointers
  2018-12-12 15:22 [Qemu-devel] [PULL 00/54] Misc patches for 2018-12-12 Paolo Bonzini
                   ` (28 preceding siblings ...)
  2018-12-12 15:22 ` [Qemu-devel] [PULL 29/54] qemu/queue.h: remove Q_TAILQ_{HEAD, ENTRY} Paolo Bonzini
@ 2018-12-12 15:22 ` Paolo Bonzini
  2018-12-12 15:22 ` [Qemu-devel] [PULL 31/54] qemu/queue.h: simplify reverse access to QTAILQ Paolo Bonzini
                   ` (25 subsequent siblings)
  55 siblings, 0 replies; 60+ messages in thread
From: Paolo Bonzini @ 2018-12-12 15:22 UTC (permalink / raw)
  To: qemu-devel

QTAILQ is a doubly linked list, with a pointer-to-pointer to the last
element from the head, and the previous element from each node.

But if you squint enough, QTAILQ becomes a combination of a singly-linked
forwards list, and another singly-linked list which goes backwards and
is circular.  This is the idea that lets QTAILQ implement reverse
iteration: only, because the backwards list points inside the node,
accessing the previous element needs to go two steps back and one
forwards.

What this patch does is implement it in these terms, without actually
changing the in-memory layout at all.  The coexistence of the two lists
is realized by making QTAILQ_HEAD and QTAILQ_ENTRY unions of the forwards
pointer and a generic QTailQLink node.  Thq QTailQLink can walk the list in
both directions; the union is needed so that the forwards pointer can
have the correct type, as a sort of poor man's template.  While there
are other ways to get the same layout without a union, this one has
the advantage of simpler operation in the debugger, because the fields
tqh_first and tqe_next still exist as before the patch.  Those fields are
also used by scripts/qemugdb/mtree.py, so it's a good idea to preserve them.

The advantage of the new representation is that the two-back-one-forward
dance done by backwards accesses can be done all while operating on
QTailQLinks.  No casting to the head struct is needed anymore because,
even though the QTailQLink's forward pointer is a void *, we can use
typeof to recover the correct type.  This patch only changes the
implementation, not the interface.  The next patch will remove the head
struct name from the backwards visit macros.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 include/qemu/queue.h       | 139 ++++++++++++++++++++-------------------------
 include/qemu/rcu_queue.h   |  45 ++++++++-------
 scripts/cocci-macro-file.h |  14 ++---
 3 files changed, 92 insertions(+), 106 deletions(-)

diff --git a/include/qemu/queue.h b/include/qemu/queue.h
index b9571e9..a893fac 100644
--- a/include/qemu/queue.h
+++ b/include/qemu/queue.h
@@ -346,23 +346,28 @@ struct {                                                                \
 #define QSIMPLEQ_FIRST(head)        ((head)->sqh_first)
 #define QSIMPLEQ_NEXT(elm, field)   ((elm)->field.sqe_next)
 
+typedef struct QTailQLink {
+    void *tql_next;
+    struct QTailQLink *tql_prev;
+} QTailQLink;
 
 /*
- * Tail queue definitions.
+ * Tail queue definitions.  The union acts as a poor man template, as if
+ * it were QTailQLink<type>.
  */
 #define QTAILQ_HEAD(name, type)                                         \
-struct name {                                                           \
-        type *tqh_first;      /* first element */                       \
-        type **tqh_last;      /* addr of last next element */           \
+union name {                                                            \
+        struct type *tqh_first;       /* first element */               \
+        QTailQLink tqh_circ;          /* link for circular backwards list */ \
 }
 
 #define QTAILQ_HEAD_INITIALIZER(head)                                   \
-        { NULL, &(head).tqh_first }
+        { .tqh_circ = { NULL, &(head).tqh_circ } }
 
 #define QTAILQ_ENTRY(type)                                              \
-struct {                                                                \
-        type *tqe_next;       /* next element */                   \
-        type **tqe_prev;      /* address of previous next element */    \
+union {                                                                 \
+        struct type *tqe_next;        /* next element */                \
+        QTailQLink tqe_circ;          /* link for circular backwards list */ \
 }
 
 /*
@@ -370,51 +375,51 @@ struct {                                                                \
  */
 #define QTAILQ_INIT(head) do {                                          \
         (head)->tqh_first = NULL;                                       \
-        (head)->tqh_last = &(head)->tqh_first;                          \
+        (head)->tqh_circ.tql_prev = &(head)->tqh_circ;                  \
 } while (/*CONSTCOND*/0)
 
 #define QTAILQ_INSERT_HEAD(head, elm, field) do {                       \
         if (((elm)->field.tqe_next = (head)->tqh_first) != NULL)        \
-                (head)->tqh_first->field.tqe_prev =                     \
-                    &(elm)->field.tqe_next;                             \
+            (head)->tqh_first->field.tqe_circ.tql_prev =                \
+                &(elm)->field.tqe_circ;                                 \
         else                                                            \
-                (head)->tqh_last = &(elm)->field.tqe_next;              \
+            (head)->tqh_circ.tql_prev = &(elm)->field.tqe_circ;         \
         (head)->tqh_first = (elm);                                      \
-        (elm)->field.tqe_prev = &(head)->tqh_first;                     \
+        (elm)->field.tqe_circ.tql_prev = &(head)->tqh_circ;             \
 } while (/*CONSTCOND*/0)
 
 #define QTAILQ_INSERT_TAIL(head, elm, field) do {                       \
         (elm)->field.tqe_next = NULL;                                   \
-        (elm)->field.tqe_prev = (head)->tqh_last;                       \
-        *(head)->tqh_last = (elm);                                      \
-        (head)->tqh_last = &(elm)->field.tqe_next;                      \
+        (elm)->field.tqe_circ.tql_prev = (head)->tqh_circ.tql_prev;     \
+        (head)->tqh_circ.tql_prev->tql_next = (elm);                    \
+        (head)->tqh_circ.tql_prev = &(elm)->field.tqe_circ;             \
 } while (/*CONSTCOND*/0)
 
 #define QTAILQ_INSERT_AFTER(head, listelm, elm, field) do {             \
         if (((elm)->field.tqe_next = (listelm)->field.tqe_next) != NULL)\
-                (elm)->field.tqe_next->field.tqe_prev =                 \
-                    &(elm)->field.tqe_next;                             \
+            (elm)->field.tqe_next->field.tqe_circ.tql_prev =            \
+                &(elm)->field.tqe_circ;                                 \
         else                                                            \
-                (head)->tqh_last = &(elm)->field.tqe_next;              \
+            (head)->tqh_circ.tql_prev = &(elm)->field.tqe_circ;         \
         (listelm)->field.tqe_next = (elm);                              \
-        (elm)->field.tqe_prev = &(listelm)->field.tqe_next;             \
+        (elm)->field.tqe_circ.tql_prev = &(listelm)->field.tqe_circ;    \
 } while (/*CONSTCOND*/0)
 
-#define QTAILQ_INSERT_BEFORE(listelm, elm, field) do {                  \
-        (elm)->field.tqe_prev = (listelm)->field.tqe_prev;              \
-        (elm)->field.tqe_next = (listelm);                              \
-        *(listelm)->field.tqe_prev = (elm);                             \
-        (listelm)->field.tqe_prev = &(elm)->field.tqe_next;             \
+#define QTAILQ_INSERT_BEFORE(listelm, elm, field) do {                       \
+        (elm)->field.tqe_circ.tql_prev = (listelm)->field.tqe_circ.tql_prev; \
+        (elm)->field.tqe_next = (listelm);                                   \
+        (listelm)->field.tqe_circ.tql_prev->tql_next = (elm);                \
+        (listelm)->field.tqe_circ.tql_prev = &(elm)->field.tqe_circ;         \
 } while (/*CONSTCOND*/0)
 
 #define QTAILQ_REMOVE(head, elm, field) do {                            \
         if (((elm)->field.tqe_next) != NULL)                            \
-                (elm)->field.tqe_next->field.tqe_prev =                 \
-                    (elm)->field.tqe_prev;                              \
+            (elm)->field.tqe_next->field.tqe_circ.tql_prev =            \
+                (elm)->field.tqe_circ.tql_prev;                         \
         else                                                            \
-                (head)->tqh_last = (elm)->field.tqe_prev;               \
-        *(elm)->field.tqe_prev = (elm)->field.tqe_next;                 \
-        (elm)->field.tqe_prev = NULL;                                   \
+            (head)->tqh_circ.tql_prev = (elm)->field.tqe_circ.tql_prev; \
+        (elm)->field.tqe_circ.tql_prev->tql_next = (elm)->field.tqe_next; \
+        (elm)->field.tqe_circ.tql_prev = NULL;                          \
 } while (/*CONSTCOND*/0)
 
 #define QTAILQ_FOREACH(var, head, field)                                \
@@ -428,13 +433,13 @@ struct {                                                                \
                 (var) = (next_var))
 
 #define QTAILQ_FOREACH_REVERSE(var, head, headname, field)              \
-        for ((var) = (*(((struct headname *)((head)->tqh_last))->tqh_last));    \
+        for ((var) = QTAILQ_LAST(head, headname);                       \
                 (var);                                                  \
-                (var) = (*(((struct headname *)((var)->field.tqe_prev))->tqh_last)))
+                (var) = QTAILQ_PREV(var, headname, field))
 
 #define QTAILQ_FOREACH_REVERSE_SAFE(var, head, headname, field, prev_var) \
-        for ((var) = (*(((struct headname *)((head)->tqh_last))->tqh_last)); \
-             (var) && ((prev_var) = (*(((struct headname *)((var)->field.tqe_prev))->tqh_last)), 1); \
+        for ((var) = QTAILQ_LAST(head, headname);                       \
+             (var) && ((prev_var) = QTAILQ_PREV(var, headname, field)); \
              (var) = (prev_var))
 
 /*
@@ -443,71 +448,49 @@ struct {                                                                \
 #define QTAILQ_EMPTY(head)               ((head)->tqh_first == NULL)
 #define QTAILQ_FIRST(head)               ((head)->tqh_first)
 #define QTAILQ_NEXT(elm, field)          ((elm)->field.tqe_next)
-#define QTAILQ_IN_USE(elm, field)        ((elm)->field.tqe_prev != NULL)
+#define QTAILQ_IN_USE(elm, field)        ((elm)->field.tqe_circ.tql_prev != NULL)
 
+#define QTAILQ_LINK_PREV(link)                                          \
+        ((link).tql_prev->tql_prev->tql_next)
 #define QTAILQ_LAST(head, headname) \
-        (*(((struct headname *)((head)->tqh_last))->tqh_last))
+        ((typeof((head)->tqh_first)) QTAILQ_LINK_PREV((head)->tqh_circ))
 #define QTAILQ_PREV(elm, headname, field) \
-        (*(((struct headname *)((elm)->field.tqe_prev))->tqh_last))
+        ((typeof((elm)->field.tqe_next)) QTAILQ_LINK_PREV((elm)->field.tqe_circ))
 
 #define field_at_offset(base, offset, type)                                    \
-        ((type) (((char *) (base)) + (offset)))
-
-typedef struct DUMMY_Q_ENTRY DUMMY_Q_ENTRY;
-typedef struct DUMMY_Q DUMMY_Q;
-
-struct DUMMY_Q_ENTRY {
-        QTAILQ_ENTRY(DUMMY_Q_ENTRY) next;
-};
-
-struct DUMMY_Q {
-        QTAILQ_HEAD(DUMMY_Q_HEAD, DUMMY_Q_ENTRY) head;
-};
-
-#define dummy_q ((DUMMY_Q *) 0)
-#define dummy_qe ((DUMMY_Q_ENTRY *) 0)
+        ((type *) (((char *) (base)) + (offset)))
 
 /*
- * Offsets of layout of a tail queue head.
- */
-#define QTAILQ_FIRST_OFFSET (offsetof(typeof(dummy_q->head), tqh_first))
-#define QTAILQ_LAST_OFFSET  (offsetof(typeof(dummy_q->head), tqh_last))
-/*
- * Raw access of elements of a tail queue
+ * Raw access of elements of a tail queue head.  Offsets are all zero
+ * because it's a union.
  */
 #define QTAILQ_RAW_FIRST(head)                                                 \
-        (*field_at_offset(head, QTAILQ_FIRST_OFFSET, void **))
-#define QTAILQ_RAW_TQH_LAST(head)                                              \
-        (*field_at_offset(head, QTAILQ_LAST_OFFSET, void ***))
-
-/*
- * Offsets of layout of a tail queue element.
- */
-#define QTAILQ_NEXT_OFFSET (offsetof(typeof(dummy_qe->next), tqe_next))
-#define QTAILQ_PREV_OFFSET (offsetof(typeof(dummy_qe->next), tqe_prev))
+        field_at_offset(head, 0, void *)
+#define QTAILQ_RAW_TQH_CIRC(head)                                              \
+        field_at_offset(head, 0, QTailQLink)
 
 /*
  * Raw access of elements of a tail entry
  */
 #define QTAILQ_RAW_NEXT(elm, entry)                                            \
-        (*field_at_offset(elm, entry + QTAILQ_NEXT_OFFSET, void **))
-#define QTAILQ_RAW_TQE_PREV(elm, entry)                                        \
-        (*field_at_offset(elm, entry + QTAILQ_PREV_OFFSET, void ***))
+        field_at_offset(elm, entry, void *)
+#define QTAILQ_RAW_TQE_CIRC(elm, entry)                                        \
+        field_at_offset(elm, entry, QTailQLink)
 /*
- * Tail queue tranversal using pointer arithmetic.
+ * Tail queue traversal using pointer arithmetic.
  */
 #define QTAILQ_RAW_FOREACH(elm, head, entry)                                   \
-        for ((elm) = QTAILQ_RAW_FIRST(head);                                   \
+        for ((elm) = *QTAILQ_RAW_FIRST(head);                                  \
              (elm);                                                            \
-             (elm) = QTAILQ_RAW_NEXT(elm, entry))
+             (elm) = *QTAILQ_RAW_NEXT(elm, entry))
 /*
  * Tail queue insertion using pointer arithmetic.
  */
-#define QTAILQ_RAW_INSERT_TAIL(head, elm, entry) do {                          \
-        QTAILQ_RAW_NEXT(elm, entry) = NULL;                                    \
-        QTAILQ_RAW_TQE_PREV(elm, entry) = QTAILQ_RAW_TQH_LAST(head);           \
-        *QTAILQ_RAW_TQH_LAST(head) = (elm);                                    \
-        QTAILQ_RAW_TQH_LAST(head) = &QTAILQ_RAW_NEXT(elm, entry);              \
+#define QTAILQ_RAW_INSERT_TAIL(head, elm, entry) do {                           \
+        *QTAILQ_RAW_NEXT(elm, entry) = NULL;                                    \
+        QTAILQ_RAW_TQE_CIRC(elm, entry)->tql_prev = QTAILQ_RAW_TQH_CIRC(head)->tql_prev; \
+        QTAILQ_RAW_TQH_CIRC(head)->tql_prev->tql_next = (elm);                  \
+        QTAILQ_RAW_TQH_CIRC(head)->tql_prev = QTAILQ_RAW_TQE_CIRC(elm, entry);  \
 } while (/*CONSTCOND*/0)
 
 #endif /* QEMU_SYS_QUEUE_H */
diff --git a/include/qemu/rcu_queue.h b/include/qemu/rcu_queue.h
index 904b337..2d386f3 100644
--- a/include/qemu/rcu_queue.h
+++ b/include/qemu/rcu_queue.h
@@ -206,47 +206,50 @@ extern "C" {
 #define QTAILQ_INSERT_HEAD_RCU(head, elm, field) do {                   \
     (elm)->field.tqe_next = (head)->tqh_first;                          \
     if ((elm)->field.tqe_next != NULL) {                                \
-        (head)->tqh_first->field.tqe_prev = &(elm)->field.tqe_next;     \
+        (head)->tqh_first->field.tqe_circ.tql_prev =                    \
+            &(elm)->field.tqe_circ;                                     \
     } else {                                                            \
-        (head)->tqh_last = &(elm)->field.tqe_next;                      \
+        (head)->tqh_circ.tql_prev = &(elm)->field.tqe_circ;             \
     }                                                                   \
     atomic_rcu_set(&(head)->tqh_first, (elm));                          \
-    (elm)->field.tqe_prev = &(head)->tqh_first;                         \
+    (elm)->field.tqe_circ.tql_prev = &(head)->tqh_circ;                 \
 } while (/*CONSTCOND*/0)
 
-#define QTAILQ_INSERT_TAIL_RCU(head, elm, field) do {               \
-    (elm)->field.tqe_next = NULL;                                   \
-    (elm)->field.tqe_prev = (head)->tqh_last;                       \
-    atomic_rcu_set((head)->tqh_last, (elm));                        \
-    (head)->tqh_last = &(elm)->field.tqe_next;                      \
+#define QTAILQ_INSERT_TAIL_RCU(head, elm, field) do {                   \
+    (elm)->field.tqe_next = NULL;                                       \
+    (elm)->field.tqe_circ.tql_prev = (head)->tqh_circ.tql_prev;         \
+    atomic_rcu_set(&(head)->tqh_circ.tql_prev->tql_next, (elm));        \
+    (head)->tqh_circ.tql_prev = &(elm)->field.tqe_circ;                 \
 } while (/*CONSTCOND*/0)
 
 #define QTAILQ_INSERT_AFTER_RCU(head, listelm, elm, field) do {         \
     (elm)->field.tqe_next = (listelm)->field.tqe_next;                  \
     if ((elm)->field.tqe_next != NULL) {                                \
-        (elm)->field.tqe_next->field.tqe_prev = &(elm)->field.tqe_next; \
+        (elm)->field.tqe_next->field.tqe_circ.tql_prev =                \
+            &(elm)->field.tqe_circ;                                     \
     } else {                                                            \
-        (head)->tqh_last = &(elm)->field.tqe_next;                      \
+        (head)->tqh_circ.tql_prev = &(elm)->field.tqe_circ;             \
     }                                                                   \
     atomic_rcu_set(&(listelm)->field.tqe_next, (elm));                  \
-    (elm)->field.tqe_prev = &(listelm)->field.tqe_next;                 \
+    (elm)->field.tqe_circ.tql_prev = &(listelm)->field.tqe_circ;        \
 } while (/*CONSTCOND*/0)
 
-#define QTAILQ_INSERT_BEFORE_RCU(listelm, elm, field) do {          \
-    (elm)->field.tqe_prev = (listelm)->field.tqe_prev;              \
-    (elm)->field.tqe_next = (listelm);                              \
-    atomic_rcu_set((listelm)->field.tqe_prev, (elm));               \
-    (listelm)->field.tqe_prev = &(elm)->field.tqe_next;             \
-    } while (/*CONSTCOND*/0)
+#define QTAILQ_INSERT_BEFORE_RCU(listelm, elm, field) do {                \
+    (elm)->field.tqe_circ.tql_prev = (listelm)->field.tqe_circ.tql_prev;  \
+    (elm)->field.tqe_next = (listelm);                                    \
+    atomic_rcu_set(&(listelm)->field.tqe_circ.tql_prev->tql_next, (elm)); \
+    (listelm)->field.tqe_circ.tql_prev = &(elm)->field.tqe_circ;          \
+} while (/*CONSTCOND*/0)
 
 #define QTAILQ_REMOVE_RCU(head, elm, field) do {                        \
     if (((elm)->field.tqe_next) != NULL) {                              \
-        (elm)->field.tqe_next->field.tqe_prev = (elm)->field.tqe_prev;  \
+        (elm)->field.tqe_next->field.tqe_circ.tql_prev =                \
+            (elm)->field.tqe_circ.tql_prev;                             \
     } else {                                                            \
-        (head)->tqh_last = (elm)->field.tqe_prev;                       \
+        (head)->tqh_circ.tql_prev = (elm)->field.tqe_circ.tql_prev;     \
     }                                                                   \
-    atomic_set((elm)->field.tqe_prev, (elm)->field.tqe_next);           \
-    (elm)->field.tqe_prev = NULL;                                       \
+    atomic_set(&(elm)->field.tqe_circ.tql_prev->tql_next, (elm)->field.tqe_next); \
+    (elm)->field.tqe_circ.tql_prev = NULL;                              \
 } while (/*CONSTCOND*/0)
 
 #define QTAILQ_FOREACH_RCU(var, head, field)                            \
diff --git a/scripts/cocci-macro-file.h b/scripts/cocci-macro-file.h
index 5c49369..1cb0b4a 100644
--- a/scripts/cocci-macro-file.h
+++ b/scripts/cocci-macro-file.h
@@ -94,18 +94,18 @@ struct {                                                                \
  * Tail queue definitions.
  */
 #define QTAILQ_HEAD(name, type)                                         \
-struct name {                                                           \
-        type *tqh_first;      /* first element */                       \
-        type **tqh_last;      /* addr of last next element */           \
+union name {                                                            \
+        struct type *tqh_first;       /* first element */               \
+        QTailQLink tqh_circ;          /* link for last element */       \
 }
 
 #define QTAILQ_HEAD_INITIALIZER(head)                                   \
-        { NULL, &(head).tqh_first }
+        { .tqh_circ = { NULL, &(head).tqh_circ } }
 
 #define QTAILQ_ENTRY(type)                                              \
-struct {                                                                \
-        type *tqe_next;       /* next element */                        \
-        type **tqe_prev;      /* address of previous next element */    \
+union {                                                                 \
+        struct type *tqe_next;        /* next element */                \
+        QTailQLink tqe_circ;          /* link for prev element */       \
 }
 
 /* From glib */
-- 
1.8.3.1

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

* [Qemu-devel] [PULL 31/54] qemu/queue.h: simplify reverse access to QTAILQ
  2018-12-12 15:22 [Qemu-devel] [PULL 00/54] Misc patches for 2018-12-12 Paolo Bonzini
                   ` (29 preceding siblings ...)
  2018-12-12 15:22 ` [Qemu-devel] [PULL 30/54] qemu/queue.h: reimplement QTAILQ without pointer-to-pointers Paolo Bonzini
@ 2018-12-12 15:22 ` Paolo Bonzini
  2018-12-12 15:22 ` [Qemu-devel] [PULL 32/54] checkpatch: warn about qemu/queue.h head structs that are not typedef-ed Paolo Bonzini
                   ` (24 subsequent siblings)
  55 siblings, 0 replies; 60+ messages in thread
From: Paolo Bonzini @ 2018-12-12 15:22 UTC (permalink / raw)
  To: qemu-devel

The new definition of QTAILQ does not require passing the headname,
remove it.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 cpus-common.c                   |  2 +-
 dump.c                          |  2 +-
 hw/core/qdev.c                  |  4 ++--
 hw/scsi/scsi-bus.c              |  2 +-
 hw/usb/combined-packet.c        |  2 +-
 hw/usb/dev-mtp.c                |  4 ++--
 hw/usb/hcd-ehci.c               |  2 +-
 hw/usb/hcd-ehci.h               |  2 +-
 hw/usb/hcd-uhci.c               |  4 ++--
 include/exec/memory.h           |  2 +-
 include/hw/qdev-core.h          |  2 +-
 include/hw/usb.h                |  2 +-
 include/net/net.h               |  2 +-
 include/qemu/option_int.h       |  2 +-
 include/qemu/queue.h            | 16 ++++++++--------
 include/sysemu/memory_mapping.h |  2 +-
 memory.c                        | 17 ++++++-----------
 memory_mapping.c                |  2 +-
 net/filter.c                    |  2 +-
 net/net.c                       |  2 +-
 qga/commands-posix.c            |  2 +-
 tcg/tcg.c                       |  2 +-
 tcg/tcg.h                       |  4 ++--
 tests/libqos/malloc.c           |  2 +-
 tests/test-vmstate.c            |  8 ++++----
 ui/console.c                    |  4 ++--
 util/qemu-option.c              |  4 ++--
 27 files changed, 48 insertions(+), 53 deletions(-)

diff --git a/cpus-common.c b/cpus-common.c
index 98dd8c6..3ca58c6 100644
--- a/cpus-common.c
+++ b/cpus-common.c
@@ -99,7 +99,7 @@ void cpu_list_remove(CPUState *cpu)
         return;
     }
 
-    assert(!(cpu_index_auto_assigned && cpu != QTAILQ_LAST(&cpus, CPUTailQ)));
+    assert(!(cpu_index_auto_assigned && cpu != QTAILQ_LAST(&cpus)));
 
     QTAILQ_REMOVE_RCU(&cpus, cpu, node);
     cpu->cpu_index = UNASSIGNED_CPU_INDEX;
diff --git a/dump.c b/dump.c
index 4ec94c5..ef1d802 100644
--- a/dump.c
+++ b/dump.c
@@ -1557,7 +1557,7 @@ static void get_max_mapnr(DumpState *s)
 {
     GuestPhysBlock *last_block;
 
-    last_block = QTAILQ_LAST(&s->guest_phys_blocks.head, GuestPhysBlockHead);
+    last_block = QTAILQ_LAST(&s->guest_phys_blocks.head);
     s->max_mapnr = dump_paddr_to_pfn(s, last_block->target_end);
 }
 
diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index 6b3cc55..a7dd4be 100644
--- a/hw/core/qdev.c
+++ b/hw/core/qdev.c
@@ -158,7 +158,7 @@ DeviceState *qdev_try_create(BusState *bus, const char *type)
     return dev;
 }
 
-static QTAILQ_HEAD(device_listeners, DeviceListener) device_listeners
+static QTAILQ_HEAD(, DeviceListener) device_listeners
     = QTAILQ_HEAD_INITIALIZER(device_listeners);
 
 enum ListenerDirection { Forward, Reverse };
@@ -177,7 +177,7 @@ enum ListenerDirection { Forward, Reverse };
             break;                                                \
         case Reverse:                                             \
             QTAILQ_FOREACH_REVERSE(_listener, &device_listeners,  \
-                                   device_listeners, link) {      \
+                                   link) {                        \
                 if (_listener->_callback) {                       \
                     _listener->_callback(_listener, ##_args);     \
                 }                                                 \
diff --git a/hw/scsi/scsi-bus.c b/hw/scsi/scsi-bus.c
index 97cd167..c480553 100644
--- a/hw/scsi/scsi-bus.c
+++ b/hw/scsi/scsi-bus.c
@@ -1554,7 +1554,7 @@ SCSIDevice *scsi_device_find(SCSIBus *bus, int channel, int id, int lun)
     BusChild *kid;
     SCSIDevice *target_dev = NULL;
 
-    QTAILQ_FOREACH_REVERSE(kid, &bus->qbus.children, ChildrenHead, sibling) {
+    QTAILQ_FOREACH_REVERSE(kid, &bus->qbus.children, sibling) {
         DeviceState *qdev = kid->child;
         SCSIDevice *dev = SCSI_DEVICE(qdev);
 
diff --git a/hw/usb/combined-packet.c b/hw/usb/combined-packet.c
index 01a7ed0..fc98383 100644
--- a/hw/usb/combined-packet.c
+++ b/hw/usb/combined-packet.c
@@ -64,7 +64,7 @@ void usb_combined_input_packet_complete(USBDevice *dev, USBPacket *p)
 
     status = combined->first->status;
     actual_length = combined->first->actual_length;
-    short_not_ok = QTAILQ_LAST(&combined->packets, packets_head)->short_not_ok;
+    short_not_ok = QTAILQ_LAST(&combined->packets)->short_not_ok;
 
     QTAILQ_FOREACH_SAFE(p, &combined->packets, combined_entry, next) {
         if (!done) {
diff --git a/hw/usb/dev-mtp.c b/hw/usb/dev-mtp.c
index 100b717..c33d7d6 100644
--- a/hw/usb/dev-mtp.c
+++ b/hw/usb/dev-mtp.c
@@ -191,7 +191,7 @@ struct MTPState {
 #ifdef CONFIG_INOTIFY1
     /* inotify descriptor */
     int          inotifyfd;
-    QTAILQ_HEAD(events, MTPMonEntry) events;
+    QTAILQ_HEAD(, MTPMonEntry) events;
 #endif
     /* Responder is expecting a write operation */
     bool write_pending;
@@ -1982,7 +1982,7 @@ static void usb_mtp_handle_data(USBDevice *dev, USBPacket *p)
     case EP_EVENT:
 #ifdef CONFIG_INOTIFY1
         if (!QTAILQ_EMPTY(&s->events)) {
-            struct MTPMonEntry *e = QTAILQ_LAST(&s->events, events);
+            struct MTPMonEntry *e = QTAILQ_LAST(&s->events);
             uint32_t handle;
             int len = sizeof(container) + sizeof(uint32_t);
 
diff --git a/hw/usb/hcd-ehci.c b/hw/usb/hcd-ehci.c
index e5acfc5..a2105c8 100644
--- a/hw/usb/hcd-ehci.c
+++ b/hw/usb/hcd-ehci.c
@@ -1815,7 +1815,7 @@ static int ehci_state_fetchqtd(EHCIQueue *q)
             break;
         case EHCI_ASYNC_INFLIGHT:
             /* Check if the guest has added new tds to the queue */
-            again = ehci_fill_queue(QTAILQ_LAST(&q->packets, pkts_head));
+            again = ehci_fill_queue(QTAILQ_LAST(&q->packets));
             /* Unfinished async handled packet, go horizontal */
             ehci_set_state(q->ehci, q->async, EST_HORIZONTALQH);
             break;
diff --git a/hw/usb/hcd-ehci.h b/hw/usb/hcd-ehci.h
index 0bc364b..e4460aa 100644
--- a/hw/usb/hcd-ehci.h
+++ b/hw/usb/hcd-ehci.h
@@ -247,7 +247,7 @@ struct EHCIQueue {
     uint32_t qtdaddr;      /* address QTD read from                */
     int last_pid;          /* pid of last packet executed          */
     USBDevice *dev;
-    QTAILQ_HEAD(pkts_head, EHCIPacket) packets;
+    QTAILQ_HEAD(, EHCIPacket) packets;
 };
 
 typedef QTAILQ_HEAD(EHCIQueueHead, EHCIQueue) EHCIQueueHead;
diff --git a/hw/usb/hcd-uhci.c b/hw/usb/hcd-uhci.c
index 836b11f..26f123e 100644
--- a/hw/usb/hcd-uhci.c
+++ b/hw/usb/hcd-uhci.c
@@ -99,7 +99,7 @@ struct UHCIQueue {
     UHCIState *uhci;
     USBEndpoint *ep;
     QTAILQ_ENTRY(UHCIQueue) next;
-    QTAILQ_HEAD(asyncs_head, UHCIAsync) asyncs;
+    QTAILQ_HEAD(, UHCIAsync) asyncs;
     int8_t    valid;
 };
 
@@ -837,7 +837,7 @@ static int uhci_handle_td(UHCIState *s, UHCIQueue *q, uint32_t qh_addr,
         }
         if (!async->done) {
             UHCI_TD last_td;
-            UHCIAsync *last = QTAILQ_LAST(&async->queue->asyncs, asyncs_head);
+            UHCIAsync *last = QTAILQ_LAST(&async->queue->asyncs);
             /*
              * While we are waiting for the current td to complete, the guest
              * may have added more tds to the queue. Note we re-read the td
diff --git a/include/exec/memory.h b/include/exec/memory.h
index ce93068..7353fa2 100644
--- a/include/exec/memory.h
+++ b/include/exec/memory.h
@@ -445,7 +445,7 @@ struct AddressSpace {
 
     int ioeventfd_nb;
     struct MemoryRegionIoeventfd *ioeventfds;
-    QTAILQ_HEAD(memory_listeners_as, MemoryListener) listeners;
+    QTAILQ_HEAD(, MemoryListener) listeners;
     QTAILQ_ENTRY(AddressSpace) address_spaces_link;
 };
 
diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
index a24d0dd..43f926f 100644
--- a/include/hw/qdev-core.h
+++ b/include/hw/qdev-core.h
@@ -206,7 +206,7 @@ struct BusState {
     HotplugHandler *hotplug_handler;
     int max_index;
     bool realized;
-    QTAILQ_HEAD(ChildrenHead, BusChild) children;
+    QTAILQ_HEAD(, BusChild) children;
     QLIST_ENTRY(BusState) sibling;
 };
 
diff --git a/include/hw/usb.h b/include/hw/usb.h
index a5080ad..f9431a0 100644
--- a/include/hw/usb.h
+++ b/include/hw/usb.h
@@ -408,7 +408,7 @@ struct USBPacket {
 
 struct USBCombinedPacket {
     USBPacket *first;
-    QTAILQ_HEAD(packets_head, USBPacket) packets;
+    QTAILQ_HEAD(, USBPacket) packets;
     QEMUIOVector iov;
 };
 
diff --git a/include/net/net.h b/include/net/net.h
index ec13702..643295d 100644
--- a/include/net/net.h
+++ b/include/net/net.h
@@ -97,7 +97,7 @@ struct NetClientState {
     unsigned rxfilter_notify_enabled:1;
     int vring_enable;
     int vnet_hdr_len;
-    QTAILQ_HEAD(NetFilterHead, NetFilterState) filters;
+    QTAILQ_HEAD(, NetFilterState) filters;
 };
 
 typedef struct NICState {
diff --git a/include/qemu/option_int.h b/include/qemu/option_int.h
index 26b1d9e..5dd9a51 100644
--- a/include/qemu/option_int.h
+++ b/include/qemu/option_int.h
@@ -47,7 +47,7 @@ struct QemuOpts {
     char *id;
     QemuOptsList *list;
     Location loc;
-    QTAILQ_HEAD(QemuOptHead, QemuOpt) head;
+    QTAILQ_HEAD(, QemuOpt) head;
     QTAILQ_ENTRY(QemuOpts) next;
 };
 
diff --git a/include/qemu/queue.h b/include/qemu/queue.h
index a893fac..1f8e219 100644
--- a/include/qemu/queue.h
+++ b/include/qemu/queue.h
@@ -432,14 +432,14 @@ union {                                                                 \
                 (var) && ((next_var) = ((var)->field.tqe_next), 1);     \
                 (var) = (next_var))
 
-#define QTAILQ_FOREACH_REVERSE(var, head, headname, field)              \
-        for ((var) = QTAILQ_LAST(head, headname);                       \
+#define QTAILQ_FOREACH_REVERSE(var, head, field)                        \
+        for ((var) = QTAILQ_LAST(head);                                 \
                 (var);                                                  \
-                (var) = QTAILQ_PREV(var, headname, field))
+                (var) = QTAILQ_PREV(var, field))
 
-#define QTAILQ_FOREACH_REVERSE_SAFE(var, head, headname, field, prev_var) \
-        for ((var) = QTAILQ_LAST(head, headname);                       \
-             (var) && ((prev_var) = QTAILQ_PREV(var, headname, field)); \
+#define QTAILQ_FOREACH_REVERSE_SAFE(var, head, field, prev_var)         \
+        for ((var) = QTAILQ_LAST(head);                                 \
+             (var) && ((prev_var) = QTAILQ_PREV(var, field));           \
              (var) = (prev_var))
 
 /*
@@ -452,9 +452,9 @@ union {                                                                 \
 
 #define QTAILQ_LINK_PREV(link)                                          \
         ((link).tql_prev->tql_prev->tql_next)
-#define QTAILQ_LAST(head, headname) \
+#define QTAILQ_LAST(head)                                               \
         ((typeof((head)->tqh_first)) QTAILQ_LINK_PREV((head)->tqh_circ))
-#define QTAILQ_PREV(elm, headname, field) \
+#define QTAILQ_PREV(elm, field)                                         \
         ((typeof((elm)->field.tqe_next)) QTAILQ_LINK_PREV((elm)->field.tqe_circ))
 
 #define field_at_offset(base, offset, type)                                    \
diff --git a/include/sysemu/memory_mapping.h b/include/sysemu/memory_mapping.h
index 706152d..5845245 100644
--- a/include/sysemu/memory_mapping.h
+++ b/include/sysemu/memory_mapping.h
@@ -36,7 +36,7 @@ typedef struct GuestPhysBlock {
 /* point-in-time snapshot of guest-visible physical mappings */
 typedef struct GuestPhysBlockList {
     unsigned num;
-    QTAILQ_HEAD(GuestPhysBlockHead, GuestPhysBlock) head;
+    QTAILQ_HEAD(, GuestPhysBlock) head;
 } GuestPhysBlockList;
 
 /* The physical and virtual address in the memory mapping are contiguous. */
diff --git a/memory.c b/memory.c
index 195c5cf..61d66e4 100644
--- a/memory.c
+++ b/memory.c
@@ -39,7 +39,7 @@ static bool memory_region_update_pending;
 static bool ioeventfd_update_pending;
 static bool global_dirty_log = false;
 
-static QTAILQ_HEAD(memory_listeners, MemoryListener) memory_listeners
+static QTAILQ_HEAD(, MemoryListener) memory_listeners
     = QTAILQ_HEAD_INITIALIZER(memory_listeners);
 
 static QTAILQ_HEAD(, AddressSpace) address_spaces
@@ -113,8 +113,7 @@ enum ListenerDirection { Forward, Reverse };
             }                                                           \
             break;                                                      \
         case Reverse:                                                   \
-            QTAILQ_FOREACH_REVERSE(_listener, &memory_listeners,        \
-                                   memory_listeners, link) {            \
+            QTAILQ_FOREACH_REVERSE(_listener, &memory_listeners, link) { \
                 if (_listener->_callback) {                             \
                     _listener->_callback(_listener, ##_args);           \
                 }                                                       \
@@ -128,19 +127,17 @@ enum ListenerDirection { Forward, Reverse };
 #define MEMORY_LISTENER_CALL(_as, _callback, _direction, _section, _args...) \
     do {                                                                \
         MemoryListener *_listener;                                      \
-        struct memory_listeners_as *list = &(_as)->listeners;           \
                                                                         \
         switch (_direction) {                                           \
         case Forward:                                                   \
-            QTAILQ_FOREACH(_listener, list, link_as) {                  \
+            QTAILQ_FOREACH(_listener, &(_as)->listeners, link_as) {     \
                 if (_listener->_callback) {                             \
                     _listener->_callback(_listener, _section, ##_args); \
                 }                                                       \
             }                                                           \
             break;                                                      \
         case Reverse:                                                   \
-            QTAILQ_FOREACH_REVERSE(_listener, list, memory_listeners_as, \
-                                   link_as) {                           \
+            QTAILQ_FOREACH_REVERSE(_listener, &(_as)->listeners, link_as) { \
                 if (_listener->_callback) {                             \
                     _listener->_callback(_listener, _section, ##_args); \
                 }                                                       \
@@ -2691,8 +2688,7 @@ void memory_listener_register(MemoryListener *listener, AddressSpace *as)
 
     listener->address_space = as;
     if (QTAILQ_EMPTY(&memory_listeners)
-        || listener->priority >= QTAILQ_LAST(&memory_listeners,
-                                             memory_listeners)->priority) {
+        || listener->priority >= QTAILQ_LAST(&memory_listeners)->priority) {
         QTAILQ_INSERT_TAIL(&memory_listeners, listener, link);
     } else {
         QTAILQ_FOREACH(other, &memory_listeners, link) {
@@ -2704,8 +2700,7 @@ void memory_listener_register(MemoryListener *listener, AddressSpace *as)
     }
 
     if (QTAILQ_EMPTY(&as->listeners)
-        || listener->priority >= QTAILQ_LAST(&as->listeners,
-                                             memory_listeners)->priority) {
+        || listener->priority >= QTAILQ_LAST(&as->listeners)->priority) {
         QTAILQ_INSERT_TAIL(&as->listeners, listener, link_as);
     } else {
         QTAILQ_FOREACH(other, &as->listeners, link_as) {
diff --git a/memory_mapping.c b/memory_mapping.c
index 724dd0b..e3ec706 100644
--- a/memory_mapping.c
+++ b/memory_mapping.c
@@ -223,7 +223,7 @@ static void guest_phys_blocks_region_add(MemoryListener *listener,
     if (!QTAILQ_EMPTY(&g->list->head)) {
         hwaddr predecessor_size;
 
-        predecessor = QTAILQ_LAST(&g->list->head, GuestPhysBlockHead);
+        predecessor = QTAILQ_LAST(&g->list->head);
         predecessor_size = predecessor->target_end - predecessor->target_start;
 
         /* the memory API guarantees monotonically increasing traversal */
diff --git a/net/filter.c b/net/filter.c
index c9f9e5f..28d1930 100644
--- a/net/filter.c
+++ b/net/filter.c
@@ -55,7 +55,7 @@ static NetFilterState *netfilter_next(NetFilterState *nf,
         next = QTAILQ_NEXT(nf, next);
     } else {
         /* reverse order */
-        next = QTAILQ_PREV(nf, NetFilterHead, next);
+        next = QTAILQ_PREV(nf, next);
     }
 
     return next;
diff --git a/net/net.c b/net/net.c
index 1f7d626..3acbdcc 100644
--- a/net/net.c
+++ b/net/net.c
@@ -563,7 +563,7 @@ static ssize_t filter_receive_iov(NetClientState *nc,
             }
         }
     } else {
-        QTAILQ_FOREACH_REVERSE(nf, &nc->filters, NetFilterHead, next) {
+        QTAILQ_FOREACH_REVERSE(nf, &nc->filters, next) {
             ret = qemu_netfilter_receive(nf, direction, sender, flags, iov,
                                          iovcnt, sent_cb);
             if (ret) {
diff --git a/qga/commands-posix.c b/qga/commands-posix.c
index 1877976..18a4724 100644
--- a/qga/commands-posix.c
+++ b/qga/commands-posix.c
@@ -1291,7 +1291,7 @@ int64_t qmp_guest_fsfreeze_freeze_list(bool has_mountpoints,
     /* cannot risk guest agent blocking itself on a write in this state */
     ga_set_frozen(ga_state);
 
-    QTAILQ_FOREACH_REVERSE(mount, &mounts, FsMountList, next) {
+    QTAILQ_FOREACH_REVERSE(mount, &mounts, next) {
         /* To issue fsfreeze in the reverse order of mounts, check if the
          * mount is listed in the list here */
         if (has_mountpoints) {
diff --git a/tcg/tcg.c b/tcg/tcg.c
index e85133e..2e09093 100644
--- a/tcg/tcg.c
+++ b/tcg/tcg.c
@@ -2269,7 +2269,7 @@ static void liveness_pass_1(TCGContext *s)
 
     tcg_la_func_end(s);
 
-    QTAILQ_FOREACH_REVERSE_SAFE(op, &s->ops, TCGOpHead, link, op_prev) {
+    QTAILQ_FOREACH_REVERSE_SAFE(op, &s->ops, link, op_prev) {
         int i, nb_iargs, nb_oargs;
         TCGOpcode opc_new, opc_new2;
         bool have_opc_new2;
diff --git a/tcg/tcg.h b/tcg/tcg.h
index 1e9c87b..cbe4309 100644
--- a/tcg/tcg.h
+++ b/tcg/tcg.h
@@ -715,7 +715,7 @@ struct TCGContext {
     TCGTempSet free_temps[TCG_TYPE_COUNT * 2];
     TCGTemp temps[TCG_MAX_TEMPS]; /* globals first, temps after */
 
-    QTAILQ_HEAD(TCGOpHead, TCGOp) ops, free_ops;
+    QTAILQ_HEAD(, TCGOp) ops, free_ops;
 
     /* Tells which temporary holds a given register.
        It does not take into account fixed registers */
@@ -843,7 +843,7 @@ static inline void tcg_set_insn_start_param(TCGOp *op, int arg, target_ulong v)
 /* The last op that was emitted.  */
 static inline TCGOp *tcg_last_op(void)
 {
-    return QTAILQ_LAST(&tcg_ctx->ops, TCGOpHead);
+    return QTAILQ_LAST(&tcg_ctx->ops);
 }
 
 /* Test for whether to terminate the TB for using too many opcodes.  */
diff --git a/tests/libqos/malloc.c b/tests/libqos/malloc.c
index ac05874..f7bae47 100644
--- a/tests/libqos/malloc.c
+++ b/tests/libqos/malloc.c
@@ -104,7 +104,7 @@ static void mlist_coalesce(MemList *head, MemBlock *node)
 
     do {
         merge = 0;
-        left = QTAILQ_PREV(node, MemList, MLIST_ENTNAME);
+        left = QTAILQ_PREV(node, MLIST_ENTNAME);
         right = QTAILQ_NEXT(node, MLIST_ENTNAME);
 
         /* clowns to the left of me */
diff --git a/tests/test-vmstate.c b/tests/test-vmstate.c
index 37a7a93..0ab29a8 100644
--- a/tests/test-vmstate.c
+++ b/tests/test-vmstate.c
@@ -630,7 +630,7 @@ struct TestQtailqElement {
 
 typedef struct TestQtailq {
     int16_t  i16;
-    QTAILQ_HEAD(TestQtailqHead, TestQtailqElement) q;
+    QTAILQ_HEAD(, TestQtailqElement) q;
     int32_t  i32;
 } TestQtailq;
 
@@ -735,9 +735,9 @@ static void test_load_q(void)
     g_assert_cmpint(eof, ==, QEMU_VM_EOF);
 
     TestQtailqElement *qele_from = QTAILQ_FIRST(&obj_q.q);
-    TestQtailqElement *qlast_from = QTAILQ_LAST(&obj_q.q, TestQtailqHead);
+    TestQtailqElement *qlast_from = QTAILQ_LAST(&obj_q.q);
     TestQtailqElement *qele_to = QTAILQ_FIRST(&tgt.q);
-    TestQtailqElement *qlast_to = QTAILQ_LAST(&tgt.q, TestQtailqHead);
+    TestQtailqElement *qlast_to = QTAILQ_LAST(&tgt.q);
 
     while (1) {
         g_assert_cmpint(qele_to->b, ==, qele_from->b);
@@ -755,7 +755,7 @@ static void test_load_q(void)
     /* clean up */
     TestQtailqElement *qele;
     while (!QTAILQ_EMPTY(&tgt.q)) {
-        qele = QTAILQ_LAST(&tgt.q, TestQtailqHead);
+        qele = QTAILQ_LAST(&tgt.q);
         QTAILQ_REMOVE(&tgt.q, qele, next);
         free(qele);
         qele = NULL;
diff --git a/ui/console.c b/ui/console.c
index 3a285ba..5a904e6 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -182,7 +182,7 @@ struct DisplayState {
 
 static DisplayState *display_state;
 static QemuConsole *active_console;
-static QTAILQ_HEAD(consoles_head, QemuConsole) consoles =
+static QTAILQ_HEAD(, QemuConsole) consoles =
     QTAILQ_HEAD_INITIALIZER(consoles);
 static bool cursor_visible_phase;
 static QEMUTimer *cursor_timer;
@@ -1303,7 +1303,7 @@ static QemuConsole *new_console(DisplayState *ds, console_type_t console_type,
         s->index = 0;
         QTAILQ_INSERT_TAIL(&consoles, s, next);
     } else if (console_type != GRAPHIC_CONSOLE || qdev_hotplug) {
-        QemuConsole *last = QTAILQ_LAST(&consoles, consoles_head);
+        QemuConsole *last = QTAILQ_LAST(&consoles);
         s->index = last->index + 1;
         QTAILQ_INSERT_TAIL(&consoles, s, next);
     } else {
diff --git a/util/qemu-option.c b/util/qemu-option.c
index de42e2a..ef60af7 100644
--- a/util/qemu-option.c
+++ b/util/qemu-option.c
@@ -280,7 +280,7 @@ QemuOpt *qemu_opt_find(QemuOpts *opts, const char *name)
 {
     QemuOpt *opt;
 
-    QTAILQ_FOREACH_REVERSE(opt, &opts->head, QemuOptHead, next) {
+    QTAILQ_FOREACH_REVERSE(opt, &opts->head, next) {
         if (strcmp(opt->name, name) != 0)
             continue;
         return opt;
@@ -379,7 +379,7 @@ bool qemu_opt_has_help_opt(QemuOpts *opts)
 {
     QemuOpt *opt;
 
-    QTAILQ_FOREACH_REVERSE(opt, &opts->head, QemuOptHead, next) {
+    QTAILQ_FOREACH_REVERSE(opt, &opts->head, next) {
         if (is_help_option(opt->name)) {
             return true;
         }
-- 
1.8.3.1

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

* [Qemu-devel] [PULL 32/54] checkpatch: warn about qemu/queue.h head structs that are not typedef-ed
  2018-12-12 15:22 [Qemu-devel] [PULL 00/54] Misc patches for 2018-12-12 Paolo Bonzini
                   ` (30 preceding siblings ...)
  2018-12-12 15:22 ` [Qemu-devel] [PULL 31/54] qemu/queue.h: simplify reverse access to QTAILQ Paolo Bonzini
@ 2018-12-12 15:22 ` Paolo Bonzini
  2018-12-12 15:22 ` [Qemu-devel] [PULL 33/54] configure: Add a test for the minimum compiler version Paolo Bonzini
                   ` (23 subsequent siblings)
  55 siblings, 0 replies; 60+ messages in thread
From: Paolo Bonzini @ 2018-12-12 15:22 UTC (permalink / raw)
  To: qemu-devel

These are just like any other struct or union, so they should have
CamelCase typedefs.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 scripts/checkpatch.pl | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index a8d6e44..b4b3495 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2263,6 +2263,11 @@ sub process {
 			}
 		}
 
+		if ($line =~ /^.\s*(Q(?:S?LIST|SIMPLEQ|TAILQ)_HEAD)\s*\(\s*[^,]/ &&
+		    $line !~ /^.typedef/) {
+		    ERROR("named $1 should be typedefed separately\n" . $herecurr);
+		}
+
 # Need a space before open parenthesis after if, while etc
 		if ($line=~/\b(if|while|for|switch)\(/) {
 			ERROR("space required before the open parenthesis '('\n" . $herecurr);
-- 
1.8.3.1

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

* [Qemu-devel] [PULL 33/54] configure: Add a test for the minimum compiler version
  2018-12-12 15:22 [Qemu-devel] [PULL 00/54] Misc patches for 2018-12-12 Paolo Bonzini
                   ` (31 preceding siblings ...)
  2018-12-12 15:22 ` [Qemu-devel] [PULL 32/54] checkpatch: warn about qemu/queue.h head structs that are not typedef-ed Paolo Bonzini
@ 2018-12-12 15:22 ` Paolo Bonzini
  2018-12-12 15:22 ` [Qemu-devel] [PULL 34/54] configure: Remove obsolete check for Clang < 3.2 Paolo Bonzini
                   ` (22 subsequent siblings)
  55 siblings, 0 replies; 60+ messages in thread
From: Paolo Bonzini @ 2018-12-12 15:22 UTC (permalink / raw)
  To: qemu-devel; +Cc: Thomas Huth

From: Thomas Huth <thuth@redhat.com>

So far we only had implicit requirements for the minimum compiler version,
e.g. we require at least GCC 4.1 for the support of atomics. However,
such old compiler versions are not tested anymore by the developers, so
they are not really supported anymore. Since we recently declared explicitly
what platforms we intend to support, we can also get more explicit on the
compiler version now. The supported distributions use the following version
of GCC:

      RHEL-7: 4.8.5
      Debian (Stretch): 6.3.0
      Debian (Jessie): 4.8.4
      OpenBSD (ports): 4.9.4
      FreeBSD (ports): 8.2.0
      OpenSUSE Leap 15: 7.3.1
      Ubuntu (Xenial): 5.3.1
      macOS (Homebrew): 8.2.0

So we can safely assume GCC 4.8 these days. For Clang, the situation is
a little bit more ambiguous, since it is sometimes not available in the
main distros but rather third party repositories. At least Debian Jessie
uses version 3.5, and EPEL7 for RHEL7 uses 3.4, so let's use 3.4 as
minimum Clang version now - we still can adjust this later if necessary.

Unfortunately Apple uses different version numbers for the Clang that is
included in their Xcode suite, so we need to check the version numbers
for Xcode separately. Xcode 5.1 seems to be the first one that has been
shipped with LLVM 3.4, so use this version as the minimum there.

Signed-off-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <1543937577-28256-2-git-send-email-thuth@redhat.com>
---
 configure | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/configure b/configure
index 8c292ef..51150b1 100755
--- a/configure
+++ b/configure
@@ -1837,6 +1837,31 @@ if test "$bogus_os" = "yes"; then
     error_exit "Unrecognized host OS (uname -s reports '$(uname -s)')"
 fi
 
+# Check whether the compiler matches our minimum requirements:
+cat > $TMPC << EOF
+#if defined(__clang_major__) && defined(__clang_minor__)
+# ifdef __apple_build_version__
+#  if __clang_major__ < 5 || (__clang_major__ == 5 && __clang_minor__ < 1)
+#   error You need at least XCode Clang v5.1 to compile QEMU
+#  endif
+# else
+#  if __clang_major__ < 3 || (__clang_major__ == 3 && __clang_minor__ < 4)
+#   error You need at least Clang v3.4 to compile QEMU
+#  endif
+# endif
+#elif defined(__GNUC__) && defined(__GNUC_MINOR__)
+# if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 8)
+#  error You need at least GCC v4.8 to compile QEMU
+# endif
+#else
+# error You either need GCC or Clang to compiler QEMU
+#endif
+int main (void) { return 0; }
+EOF
+if ! compile_prog "" "" ; then
+    error_exit "You need at least GCC v4.8 or Clang v3.4 (or XCode Clang v5.1)"
+fi
+
 gcc_flags="-Wold-style-declaration -Wold-style-definition -Wtype-limits"
 gcc_flags="-Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers $gcc_flags"
 gcc_flags="-Wno-missing-include-dirs -Wempty-body -Wnested-externs $gcc_flags"
-- 
1.8.3.1

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

* [Qemu-devel] [PULL 34/54] configure: Remove obsolete check for Clang < 3.2
  2018-12-12 15:22 [Qemu-devel] [PULL 00/54] Misc patches for 2018-12-12 Paolo Bonzini
                   ` (32 preceding siblings ...)
  2018-12-12 15:22 ` [Qemu-devel] [PULL 33/54] configure: Add a test for the minimum compiler version Paolo Bonzini
@ 2018-12-12 15:22 ` Paolo Bonzini
  2018-12-12 15:22 ` [Qemu-devel] [PULL 35/54] configure: Remove old -fno-gcse workaround for GCC 4.6.x and 4.7.[012] Paolo Bonzini
                   ` (21 subsequent siblings)
  55 siblings, 0 replies; 60+ messages in thread
From: Paolo Bonzini @ 2018-12-12 15:22 UTC (permalink / raw)
  To: qemu-devel; +Cc: Thomas Huth

From: Thomas Huth <thuth@redhat.com>

Since we have got a check for Clang >= 3.4 now, we do not need to
check for older Clang versions in the configure test for 128-bit ints
anymore.

Signed-off-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <1543937577-28256-3-git-send-email-thuth@redhat.com>
---
 configure | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/configure b/configure
index 51150b1..3e401b7 100755
--- a/configure
+++ b/configure
@@ -5145,11 +5145,6 @@ fi
 
 int128=no
 cat > $TMPC << EOF
-#if defined(__clang_major__) && defined(__clang_minor__)
-# if ((__clang_major__ < 3) || (__clang_major__ == 3) && (__clang_minor__ < 2))
-#  error __int128_t does not work in CLANG before 3.2
-# endif
-#endif
 __int128_t a;
 __uint128_t b;
 int main (void) {
-- 
1.8.3.1

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

* [Qemu-devel] [PULL 35/54] configure: Remove old -fno-gcse workaround for GCC 4.6.x and 4.7.[012]
  2018-12-12 15:22 [Qemu-devel] [PULL 00/54] Misc patches for 2018-12-12 Paolo Bonzini
                   ` (33 preceding siblings ...)
  2018-12-12 15:22 ` [Qemu-devel] [PULL 34/54] configure: Remove obsolete check for Clang < 3.2 Paolo Bonzini
@ 2018-12-12 15:22 ` Paolo Bonzini
  2018-12-12 15:22 ` [Qemu-devel] [PULL 36/54] tcg/tcg.h: Remove GCC check for tcg_debug_assert() macro Paolo Bonzini
                   ` (20 subsequent siblings)
  55 siblings, 0 replies; 60+ messages in thread
From: Paolo Bonzini @ 2018-12-12 15:22 UTC (permalink / raw)
  To: qemu-devel; +Cc: Thomas Huth

From: Thomas Huth <thuth@redhat.com>

Now that we require at least GCC 4.8, we don't need this als workaround
for 4.6 and 4.7 anymore.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Thomas Huth <thuth@redhat.com>
Message-Id: <1543937577-28256-4-git-send-email-thuth@redhat.com>
---
 Makefile.target |  3 ---
 configure       | 16 ----------------
 2 files changed, 19 deletions(-)

diff --git a/Makefile.target b/Makefile.target
index 4d56298..44ec4b6 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -158,9 +158,6 @@ GENERATED_FILES += hmp-commands.h hmp-commands-info.h
 
 endif # CONFIG_SOFTMMU
 
-# Workaround for http://gcc.gnu.org/PR55489, see configure.
-%/translate.o: QEMU_CFLAGS += $(TRANSLATE_OPT_CFLAGS)
-
 dummy := $(call unnest-vars,,obj-y)
 all-obj-y := $(obj-y)
 
diff --git a/configure b/configure
index 3e401b7..131eae5 100755
--- a/configure
+++ b/configure
@@ -1933,21 +1933,6 @@ else
   QEMU_CFLAGS="$QEMU_CFLAGS -Wno-missing-braces"
 fi
 
-# Workaround for http://gcc.gnu.org/PR55489.  Happens with -fPIE/-fPIC and
-# large functions that use global variables.  The bug is in all releases of
-# GCC, but it became particularly acute in 4.6.x and 4.7.x.  It is fixed in
-# 4.7.3 and 4.8.0.  We should be able to delete this at the end of 2013.
-cat > $TMPC << EOF
-#if __GNUC__ == 4 && (__GNUC_MINOR__ == 6 || (__GNUC_MINOR__ == 7 && __GNUC_PATCHLEVEL__ <= 2))
-int main(void) { return 0; }
-#else
-#error No bug in this compiler.
-#endif
-EOF
-if compile_prog "-Werror -fno-gcse" "" ; then
-  TRANSLATE_OPT_CFLAGS=-fno-gcse
-fi
-
 if test "$static" = "yes" ; then
   if test "$modules" = "yes" ; then
     error_exit "static and modules are mutually incompatible"
@@ -6980,7 +6965,6 @@ echo "LIBS_QGA+=$libs_qga" >> $config_host_mak
 echo "TASN1_LIBS=$tasn1_libs" >> $config_host_mak
 echo "TASN1_CFLAGS=$tasn1_cflags" >> $config_host_mak
 echo "POD2MAN=$POD2MAN" >> $config_host_mak
-echo "TRANSLATE_OPT_CFLAGS=$TRANSLATE_OPT_CFLAGS" >> $config_host_mak
 if test "$gcov" = "yes" ; then
   echo "CONFIG_GCOV=y" >> $config_host_mak
   echo "GCOV=$gcov_tool" >> $config_host_mak
-- 
1.8.3.1

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

* [Qemu-devel] [PULL 36/54] tcg/tcg.h: Remove GCC check for tcg_debug_assert() macro
  2018-12-12 15:22 [Qemu-devel] [PULL 00/54] Misc patches for 2018-12-12 Paolo Bonzini
                   ` (34 preceding siblings ...)
  2018-12-12 15:22 ` [Qemu-devel] [PULL 35/54] configure: Remove old -fno-gcse workaround for GCC 4.6.x and 4.7.[012] Paolo Bonzini
@ 2018-12-12 15:22 ` Paolo Bonzini
  2018-12-12 15:22 ` [Qemu-devel] [PULL 37/54] audio/alsaaudio: Remove compiler check around pragma Paolo Bonzini
                   ` (19 subsequent siblings)
  55 siblings, 0 replies; 60+ messages in thread
From: Paolo Bonzini @ 2018-12-12 15:22 UTC (permalink / raw)
  To: qemu-devel; +Cc: Thomas Huth

From: Thomas Huth <thuth@redhat.com>

Both GCC v4.8 and Clang v3.4 support (our minimum versions) support
__builtin_unreachable(), so we can remove the version check here now.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Thomas Huth <thuth@redhat.com>
Message-Id: <1543937577-28256-5-git-send-email-thuth@redhat.com>
---
 tcg/tcg.h | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/tcg/tcg.h b/tcg/tcg.h
index cbe4309..973a757 100644
--- a/tcg/tcg.h
+++ b/tcg/tcg.h
@@ -230,11 +230,9 @@ typedef uint64_t tcg_insn_unit;
 
 #if defined CONFIG_DEBUG_TCG || defined QEMU_STATIC_ANALYSIS
 # define tcg_debug_assert(X) do { assert(X); } while (0)
-#elif QEMU_GNUC_PREREQ(4, 5)
+#else
 # define tcg_debug_assert(X) \
     do { if (!(X)) { __builtin_unreachable(); } } while (0)
-#else
-# define tcg_debug_assert(X) do { (void)(X); } while (0)
 #endif
 
 typedef struct TCGRelocation {
-- 
1.8.3.1

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

* [Qemu-devel] [PULL 37/54] audio/alsaaudio: Remove compiler check around pragma
  2018-12-12 15:22 [Qemu-devel] [PULL 00/54] Misc patches for 2018-12-12 Paolo Bonzini
                   ` (35 preceding siblings ...)
  2018-12-12 15:22 ` [Qemu-devel] [PULL 36/54] tcg/tcg.h: Remove GCC check for tcg_debug_assert() macro Paolo Bonzini
@ 2018-12-12 15:22 ` Paolo Bonzini
  2018-12-12 15:22 ` [Qemu-devel] [PULL 38/54] includes: Replace QEMU_GNUC_PREREQ with "__has_builtin || !defined(__clang__)" Paolo Bonzini
                   ` (18 subsequent siblings)
  55 siblings, 0 replies; 60+ messages in thread
From: Paolo Bonzini @ 2018-12-12 15:22 UTC (permalink / raw)
  To: qemu-devel; +Cc: Thomas Huth

From: Thomas Huth <thuth@redhat.com>

Both GCC v4.8 and Clang v3.4 support the -Waddress option, so we do
not need the compiler version check here anymore.

Signed-off-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <1543937577-28256-6-git-send-email-thuth@redhat.com>
---
 audio/alsaaudio.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/audio/alsaaudio.c b/audio/alsaaudio.c
index 362a227..635be73 100644
--- a/audio/alsaaudio.c
+++ b/audio/alsaaudio.c
@@ -28,9 +28,7 @@
 #include "audio.h"
 #include "trace.h"
 
-#if QEMU_GNUC_PREREQ(4, 3)
 #pragma GCC diagnostic ignored "-Waddress"
-#endif
 
 #define AUDIO_CAP "alsa"
 #include "audio_int.h"
-- 
1.8.3.1

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

* [Qemu-devel] [PULL 38/54] includes: Replace QEMU_GNUC_PREREQ with "__has_builtin || !defined(__clang__)"
  2018-12-12 15:22 [Qemu-devel] [PULL 00/54] Misc patches for 2018-12-12 Paolo Bonzini
                   ` (36 preceding siblings ...)
  2018-12-12 15:22 ` [Qemu-devel] [PULL 37/54] audio/alsaaudio: Remove compiler check around pragma Paolo Bonzini
@ 2018-12-12 15:22 ` Paolo Bonzini
  2018-12-12 15:23 ` [Qemu-devel] [PULL 39/54] Remove QEMU_ARTIFICIAL macro Paolo Bonzini
                   ` (17 subsequent siblings)
  55 siblings, 0 replies; 60+ messages in thread
From: Paolo Bonzini @ 2018-12-12 15:22 UTC (permalink / raw)
  To: qemu-devel; +Cc: Thomas Huth

From: Thomas Huth <thuth@redhat.com>

Since we require GCC version 4.8 or newer now, we can be sure that
the builtin functions are always available on GCC. And for Clang,
we can check the availablility with __has_builtin instead.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Thomas Huth <thuth@redhat.com>
Message-Id: <1543937577-28256-7-git-send-email-thuth@redhat.com>
---
 include/qemu/compiler.h   | 2 +-
 include/qemu/host-utils.h | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/qemu/compiler.h b/include/qemu/compiler.h
index 6f32ec2..a1e50ed 100644
--- a/include/qemu/compiler.h
+++ b/include/qemu/compiler.h
@@ -135,7 +135,7 @@
 #define __has_builtin(x) 0 /* compatibility with non-clang compilers */
 #endif
 
-#if __has_builtin(__builtin_assume_aligned) || QEMU_GNUC_PREREQ(4, 7)
+#if __has_builtin(__builtin_assume_aligned) || !defined(__clang__)
 #define HAS_ASSUME_ALIGNED
 #endif
 
diff --git a/include/qemu/host-utils.h b/include/qemu/host-utils.h
index 38da849..4cd170e 100644
--- a/include/qemu/host-utils.h
+++ b/include/qemu/host-utils.h
@@ -207,7 +207,7 @@ static inline int cto64(uint64_t val)
  */
 static inline int clrsb32(uint32_t val)
 {
-#if QEMU_GNUC_PREREQ(4, 7)
+#if __has_builtin(__builtin_clrsb) || !defined(__clang__)
     return __builtin_clrsb(val);
 #else
     return clz32(val ^ ((int32_t)val >> 1)) - 1;
@@ -223,7 +223,7 @@ static inline int clrsb32(uint32_t val)
  */
 static inline int clrsb64(uint64_t val)
 {
-#if QEMU_GNUC_PREREQ(4, 7)
+#if __has_builtin(__builtin_clrsbll) || !defined(__clang__)
     return __builtin_clrsbll(val);
 #else
     return clz64(val ^ ((int64_t)val >> 1)) - 1;
-- 
1.8.3.1

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

* [Qemu-devel] [PULL 39/54] Remove QEMU_ARTIFICIAL macro
  2018-12-12 15:22 [Qemu-devel] [PULL 00/54] Misc patches for 2018-12-12 Paolo Bonzini
                   ` (37 preceding siblings ...)
  2018-12-12 15:22 ` [Qemu-devel] [PULL 38/54] includes: Replace QEMU_GNUC_PREREQ with "__has_builtin || !defined(__clang__)" Paolo Bonzini
@ 2018-12-12 15:23 ` Paolo Bonzini
  2018-12-12 15:23 ` [Qemu-devel] [PULL 40/54] hw/watchdog/wdt_i6300esb : remove a unnecessary comment Paolo Bonzini
                   ` (16 subsequent siblings)
  55 siblings, 0 replies; 60+ messages in thread
From: Paolo Bonzini @ 2018-12-12 15:23 UTC (permalink / raw)
  To: qemu-devel; +Cc: Thomas Huth

From: Thomas Huth <thuth@redhat.com>

The code that used it has already been removed a while ago with commit
dc41aa7d34989b552ef ("tcg: Remove GET_TCGV_* and MAKE_TCGV_*").

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Thomas Huth <thuth@redhat.com>
Message-Id: <1543937577-28256-8-git-send-email-thuth@redhat.com>
---
 include/qemu/compiler.h    | 6 ------
 scripts/checkpatch.pl      | 1 -
 scripts/cocci-macro-file.h | 1 -
 3 files changed, 8 deletions(-)

diff --git a/include/qemu/compiler.h b/include/qemu/compiler.h
index a1e50ed..2dffc66 100644
--- a/include/qemu/compiler.h
+++ b/include/qemu/compiler.h
@@ -36,12 +36,6 @@
 
 #define QEMU_SENTINEL __attribute__((sentinel))
 
-#if QEMU_GNUC_PREREQ(4, 3)
-#define QEMU_ARTIFICIAL __attribute__((always_inline, artificial))
-#else
-#define QEMU_ARTIFICIAL
-#endif
-
 #if defined(_WIN32)
 # define QEMU_PACKED __attribute__((gcc_struct, packed))
 #else
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index b4b3495..440d95d 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -226,7 +226,6 @@ our $Attribute	= qr{
 			QEMU_NORETURN|
 			QEMU_WARN_UNUSED_RESULT|
 			QEMU_SENTINEL|
-			QEMU_ARTIFICIAL|
 			QEMU_PACKED|
 			GCC_FMT_ATTR
 		  }x;
diff --git a/scripts/cocci-macro-file.h b/scripts/cocci-macro-file.h
index 1cb0b4a..e485cdc 100644
--- a/scripts/cocci-macro-file.h
+++ b/scripts/cocci-macro-file.h
@@ -23,7 +23,6 @@
 #define QEMU_NORETURN __attribute__ ((__noreturn__))
 #define QEMU_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
 #define QEMU_SENTINEL __attribute__((sentinel))
-#define QEMU_ARTIFICIAL __attribute__((always_inline, artificial))
 #define QEMU_PACKED __attribute__((gcc_struct, packed))
 
 #define cat(x,y) x ## y
-- 
1.8.3.1

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

* [Qemu-devel] [PULL 40/54] hw/watchdog/wdt_i6300esb : remove a unnecessary comment
  2018-12-12 15:22 [Qemu-devel] [PULL 00/54] Misc patches for 2018-12-12 Paolo Bonzini
                   ` (38 preceding siblings ...)
  2018-12-12 15:23 ` [Qemu-devel] [PULL 39/54] Remove QEMU_ARTIFICIAL macro Paolo Bonzini
@ 2018-12-12 15:23 ` Paolo Bonzini
  2018-12-12 15:23 ` [Qemu-devel] [PULL 41/54] vhost-net: move stubs to a separate file Paolo Bonzini
                   ` (15 subsequent siblings)
  55 siblings, 0 replies; 60+ messages in thread
From: Paolo Bonzini @ 2018-12-12 15:23 UTC (permalink / raw)
  To: qemu-devel; +Cc: Peng Hao

From: Peng Hao <peng.hao2@zte.com.cn>

The registered memory region of i6300esb is not suitable for coalesced
mmio, because a write for the region may trigger an immediate action
and can't be delayed.

Signed-off-by: Peng Hao <peng.hao2@zte.com.cn>
Message-Id: <1544253511-82742-1-git-send-email-peng.hao2@zte.com.cn>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/watchdog/wdt_i6300esb.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/hw/watchdog/wdt_i6300esb.c b/hw/watchdog/wdt_i6300esb.c
index 7b59469..1c6eddf 100644
--- a/hw/watchdog/wdt_i6300esb.c
+++ b/hw/watchdog/wdt_i6300esb.c
@@ -449,7 +449,6 @@ static void i6300esb_realize(PCIDevice *dev, Error **errp)
     memory_region_init_io(&d->io_mem, OBJECT(d), &i6300esb_ops, d,
                           "i6300esb", 0x10);
     pci_register_bar(&d->dev, 0, 0, &d->io_mem);
-    /* qemu_register_coalesced_mmio (addr, 0x10); ? */
 }
 
 static void i6300esb_exit(PCIDevice *dev)
-- 
1.8.3.1

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

* [Qemu-devel] [PULL 41/54] vhost-net: move stubs to a separate file
  2018-12-12 15:22 [Qemu-devel] [PULL 00/54] Misc patches for 2018-12-12 Paolo Bonzini
                   ` (39 preceding siblings ...)
  2018-12-12 15:23 ` [Qemu-devel] [PULL 40/54] hw/watchdog/wdt_i6300esb : remove a unnecessary comment Paolo Bonzini
@ 2018-12-12 15:23 ` Paolo Bonzini
  2018-12-12 15:23 ` [Qemu-devel] [PULL 42/54] vhost-net-user: add stubs for when no virtio-net device is present Paolo Bonzini
                   ` (14 subsequent siblings)
  55 siblings, 0 replies; 60+ messages in thread
From: Paolo Bonzini @ 2018-12-12 15:23 UTC (permalink / raw)
  To: qemu-devel

There is no reason for CONFIG_VHOST_NET to be specific to a single target;
it is a host feature that can be add to all targets, as long as they support
the virtio-net device.  Currently CONFIG_VHOST_NET depends on CONFIG_KVM,
but ioeventfd support is present in the core memory API and works with
other accelerators as well.

As a first step, move the vhost-net stubs to a separate file.  Later, they
will become conditional on CONFIG_VIRTIO_NET, which is not available in .c
files.

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <1543851204-41186-2-git-send-email-pbonzini@redhat.com>
---
 hw/net/Makefile.objs    |  4 ++-
 hw/net/vhost_net-stub.c | 92 +++++++++++++++++++++++++++++++++++++++++++++++++
 hw/net/vhost_net.c      | 74 ---------------------------------------
 3 files changed, 95 insertions(+), 75 deletions(-)
 create mode 100644 hw/net/vhost_net-stub.c

diff --git a/hw/net/Makefile.objs b/hw/net/Makefile.objs
index fa461d4..c2705e6 100644
--- a/hw/net/Makefile.objs
+++ b/hw/net/Makefile.objs
@@ -37,7 +37,9 @@ obj-$(CONFIG_PSERIES) += spapr_llan.o
 obj-$(CONFIG_XILINX_ETHLITE) += xilinx_ethlite.o
 
 obj-$(CONFIG_VIRTIO_NET) += virtio-net.o
-obj-y += vhost_net.o
+obj-$(CONFIG_VHOST_NET) += vhost_net.o
+common-obj-$(call lnot,$(CONFIG_VHOST_NET)) += vhost_net-stub.o
+common-obj-$(CONFIG_ALL) += vhost_net-stub.o
 
 obj-$(CONFIG_ETSEC) += fsl_etsec/etsec.o fsl_etsec/registers.o \
 			fsl_etsec/rings.o fsl_etsec/miim.o
diff --git a/hw/net/vhost_net-stub.c b/hw/net/vhost_net-stub.c
new file mode 100644
index 0000000..aac0e98
--- /dev/null
+++ b/hw/net/vhost_net-stub.c
@@ -0,0 +1,92 @@
+/*
+ * vhost-net support
+ *
+ * Copyright Red Hat, Inc. 2010
+ *
+ * Authors:
+ *  Michael S. Tsirkin <mst@redhat.com>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#include "qemu/osdep.h"
+#include "net/net.h"
+#include "net/tap.h"
+#include "net/vhost-user.h"
+
+#include "hw/virtio/virtio-net.h"
+#include "net/vhost_net.h"
+#include "qemu/error-report.h"
+
+
+uint64_t vhost_net_get_max_queues(VHostNetState *net)
+{
+    return 1;
+}
+
+struct vhost_net *vhost_net_init(VhostNetOptions *options)
+{
+    error_report("vhost-net support is not compiled in");
+    return NULL;
+}
+
+int vhost_net_start(VirtIODevice *dev,
+                    NetClientState *ncs,
+                    int total_queues)
+{
+    return -ENOSYS;
+}
+void vhost_net_stop(VirtIODevice *dev,
+                    NetClientState *ncs,
+                    int total_queues)
+{
+}
+
+void vhost_net_cleanup(struct vhost_net *net)
+{
+}
+
+uint64_t vhost_net_get_features(struct vhost_net *net, uint64_t features)
+{
+    return features;
+}
+
+void vhost_net_ack_features(struct vhost_net *net, uint64_t features)
+{
+}
+
+uint64_t vhost_net_get_acked_features(VHostNetState *net)
+{
+    return 0;
+}
+
+bool vhost_net_virtqueue_pending(VHostNetState *net, int idx)
+{
+    return false;
+}
+
+void vhost_net_virtqueue_mask(VHostNetState *net, VirtIODevice *dev,
+                              int idx, bool mask)
+{
+}
+
+int vhost_net_notify_migration_done(struct vhost_net *net, char* mac_addr)
+{
+    return -1;
+}
+
+VHostNetState *get_vhost_net(NetClientState *nc)
+{
+    return 0;
+}
+
+int vhost_set_vring_enable(NetClientState *nc, int enable)
+{
+    return 0;
+}
+
+int vhost_net_set_mtu(struct vhost_net *net, uint16_t mtu)
+{
+    return 0;
+}
diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c
index e037db6..b901306 100644
--- a/hw/net/vhost_net.c
+++ b/hw/net/vhost_net.c
@@ -23,7 +23,6 @@
 #include "qemu/error-report.h"
 
 
-#ifdef CONFIG_VHOST_NET
 #include <linux/vhost.h>
 #include <sys/socket.h>
 #include <linux/kvm.h>
@@ -449,76 +448,3 @@ int vhost_net_set_mtu(struct vhost_net *net, uint16_t mtu)
 
     return vhost_ops->vhost_net_set_mtu(&net->dev, mtu);
 }
-
-#else
-uint64_t vhost_net_get_max_queues(VHostNetState *net)
-{
-    return 1;
-}
-
-struct vhost_net *vhost_net_init(VhostNetOptions *options)
-{
-    error_report("vhost-net support is not compiled in");
-    return NULL;
-}
-
-int vhost_net_start(VirtIODevice *dev,
-                    NetClientState *ncs,
-                    int total_queues)
-{
-    return -ENOSYS;
-}
-void vhost_net_stop(VirtIODevice *dev,
-                    NetClientState *ncs,
-                    int total_queues)
-{
-}
-
-void vhost_net_cleanup(struct vhost_net *net)
-{
-}
-
-uint64_t vhost_net_get_features(struct vhost_net *net, uint64_t features)
-{
-    return features;
-}
-
-void vhost_net_ack_features(struct vhost_net *net, uint64_t features)
-{
-}
-
-uint64_t vhost_net_get_acked_features(VHostNetState *net)
-{
-    return 0;
-}
-
-bool vhost_net_virtqueue_pending(VHostNetState *net, int idx)
-{
-    return false;
-}
-
-void vhost_net_virtqueue_mask(VHostNetState *net, VirtIODevice *dev,
-                              int idx, bool mask)
-{
-}
-
-int vhost_net_notify_migration_done(struct vhost_net *net, char* mac_addr)
-{
-    return -1;
-}
-
-VHostNetState *get_vhost_net(NetClientState *nc)
-{
-    return 0;
-}
-
-int vhost_set_vring_enable(NetClientState *nc, int enable)
-{
-    return 0;
-}
-
-int vhost_net_set_mtu(struct vhost_net *net, uint16_t mtu)
-{
-    return 0;
-}
-#endif
-- 
1.8.3.1

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

* [Qemu-devel] [PULL 42/54] vhost-net-user: add stubs for when no virtio-net device is present
  2018-12-12 15:22 [Qemu-devel] [PULL 00/54] Misc patches for 2018-12-12 Paolo Bonzini
                   ` (40 preceding siblings ...)
  2018-12-12 15:23 ` [Qemu-devel] [PULL 41/54] vhost-net: move stubs to a separate file Paolo Bonzini
@ 2018-12-12 15:23 ` Paolo Bonzini
  2018-12-12 15:23 ` [Qemu-devel] [PULL 43/54] vhost: restrict Linux dependency to kernel vhost Paolo Bonzini
                   ` (13 subsequent siblings)
  55 siblings, 0 replies; 60+ messages in thread
From: Paolo Bonzini @ 2018-12-12 15:23 UTC (permalink / raw)
  To: qemu-devel

hw/net/vhost_net.c needs functions that are declared in net/vhost-user.c: the
vhost-user code is always compiled into QEMU, only the constructor
net_init_vhost_user is unreachable.  Also, net/vhost-user.c needs functions
declared in hw/virtio/vhost-stub.c even if no virtio device exists.

Break this dependency.  First, add a minimal version of net/vhost-user.c,
with no functionality and no dependency on vhost code.  Second, #ifdef out
the calls back to net/vhost-user.c from hw/net/vhost_net.c.

While at it, this patch fixes the CONFIG_VHOST_NET_USE*D* typo.

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-Id: <1543851204-41186-3-git-send-email-pbonzini@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 configure             |  2 +-
 hw/net/vhost_net.c    |  4 ++++
 net/Makefile.objs     |  4 +++-
 net/net.c             |  2 +-
 net/vhost-user-stub.c | 23 +++++++++++++++++++++++
 5 files changed, 32 insertions(+), 3 deletions(-)
 create mode 100644 net/vhost-user-stub.c

diff --git a/configure b/configure
index 131eae5..b995d71 100755
--- a/configure
+++ b/configure
@@ -6515,7 +6515,7 @@ if test "$vhost_scsi" = "yes" ; then
   echo "CONFIG_VHOST_SCSI=y" >> $config_host_mak
 fi
 if test "$vhost_net" = "yes" -a "$vhost_user" = "yes"; then
-  echo "CONFIG_VHOST_NET_USED=y" >> $config_host_mak
+  echo "CONFIG_VHOST_NET_USER=y" >> $config_host_mak
 fi
 if test "$vhost_crypto" = "yes" ; then
   echo "CONFIG_VHOST_CRYPTO=y" >> $config_host_mak
diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c
index b901306..2a300ee 100644
--- a/hw/net/vhost_net.c
+++ b/hw/net/vhost_net.c
@@ -193,6 +193,7 @@ struct vhost_net *vhost_net_init(VhostNetOptions *options)
     }
 
     /* Set sane init value. Override when guest acks. */
+#ifdef CONFIG_VHOST_NET_USER
     if (net->nc->info->type == NET_CLIENT_DRIVER_VHOST_USER) {
         features = vhost_user_get_acked_features(net->nc);
         if (~net->dev.features & features) {
@@ -202,6 +203,7 @@ struct vhost_net *vhost_net_init(VhostNetOptions *options)
             goto fail;
         }
     }
+#endif
 
     vhost_net_ack_features(net, features);
 
@@ -413,10 +415,12 @@ VHostNetState *get_vhost_net(NetClientState *nc)
     case NET_CLIENT_DRIVER_TAP:
         vhost_net = tap_get_vhost_net(nc);
         break;
+#ifdef CONFIG_VHOST_NET_USER
     case NET_CLIENT_DRIVER_VHOST_USER:
         vhost_net = vhost_user_get_vhost_net(nc);
         assert(vhost_net);
         break;
+#endif
     default:
         break;
     }
diff --git a/net/Makefile.objs b/net/Makefile.objs
index b2bf88a..df2b409 100644
--- a/net/Makefile.objs
+++ b/net/Makefile.objs
@@ -3,7 +3,9 @@ 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-$(call land,$(CONFIG_VIRTIO_NET),$(CONFIG_VHOST_NET_USER)) += vhost-user.o
+common-obj-$(call land,$(call lnot,$(CONFIG_VIRTIO_NET)),$(CONFIG_VHOST_NET_USER)) += vhost-user-stub.o
+common-obj-$(CONFIG_ALL) += vhost-user-stub.o
 common-obj-$(CONFIG_SLIRP) += slirp.o
 common-obj-$(CONFIG_VDE) += vde.o
 common-obj-$(CONFIG_NETMAP) += netmap.o
diff --git a/net/net.c b/net/net.c
index 3acbdcc..ca0e14c 100644
--- a/net/net.c
+++ b/net/net.c
@@ -961,7 +961,7 @@ static int (* const net_client_init_fun[NET_CLIENT_DRIVER__MAX])(
         [NET_CLIENT_DRIVER_BRIDGE]    = net_init_bridge,
 #endif
         [NET_CLIENT_DRIVER_HUBPORT]   = net_init_hubport,
-#ifdef CONFIG_VHOST_NET_USED
+#ifdef CONFIG_VHOST_NET_USER
         [NET_CLIENT_DRIVER_VHOST_USER] = net_init_vhost_user,
 #endif
 #ifdef CONFIG_L2TPV3
diff --git a/net/vhost-user-stub.c b/net/vhost-user-stub.c
new file mode 100644
index 0000000..52ab4e1
--- /dev/null
+++ b/net/vhost-user-stub.c
@@ -0,0 +1,23 @@
+/*
+ * vhost-user-stub.c
+ *
+ * Copyright (c) 2018 Red Hat, Inc.
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ *
+ */
+
+#include "qemu/osdep.h"
+#include "clients.h"
+#include "net/vhost_net.h"
+#include "net/vhost-user.h"
+#include "qemu/error-report.h"
+#include "qapi/error.h"
+
+int net_init_vhost_user(const Netdev *netdev, const char *name,
+                        NetClientState *peer, Error **errp)
+{
+    error_setg(errp, "vhost-user requires frontend driver virtio-net-*");
+    return -1;
+}
-- 
1.8.3.1

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

* [Qemu-devel] [PULL 43/54] vhost: restrict Linux dependency to kernel vhost
  2018-12-12 15:22 [Qemu-devel] [PULL 00/54] Misc patches for 2018-12-12 Paolo Bonzini
                   ` (41 preceding siblings ...)
  2018-12-12 15:23 ` [Qemu-devel] [PULL 42/54] vhost-net-user: add stubs for when no virtio-net device is present Paolo Bonzini
@ 2018-12-12 15:23 ` Paolo Bonzini
  2018-12-12 15:23 ` [Qemu-devel] [PULL 44/54] vhost-net: compile it on all targets that have virtio-net Paolo Bonzini
                   ` (12 subsequent siblings)
  55 siblings, 0 replies; 60+ messages in thread
From: Paolo Bonzini @ 2018-12-12 15:23 UTC (permalink / raw)
  To: qemu-devel

vhost-user does not depend on Linux; it can run on any POSIX system.  Restrict
vhost-kernel to Linux in hw/virtio/vhost-backend.c, everything else can be
compiled on all POSIX systems.

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Message-Id: <1543851204-41186-4-git-send-email-pbonzini@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 backends/Makefile.objs     |  5 ++---
 default-configs/virtio.mak |  4 ++--
 hw/virtio/Makefile.objs    |  5 +++--
 hw/virtio/vhost-backend.c  | 11 +++++++++--
 4 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/backends/Makefile.objs b/backends/Makefile.objs
index 717fcbd..ff619d3 100644
--- a/backends/Makefile.objs
+++ b/backends/Makefile.objs
@@ -9,10 +9,9 @@ common-obj-$(CONFIG_POSIX) += hostmem-file.o
 common-obj-y += cryptodev.o
 common-obj-y += cryptodev-builtin.o
 
-ifeq ($(CONFIG_VIRTIO),y)
+ifeq ($(CONFIG_VIRTIO_CRYPTO),y)
 common-obj-y += cryptodev-vhost.o
-common-obj-$(call land,$(CONFIG_VHOST_USER),$(CONFIG_LINUX)) += \
-    cryptodev-vhost-user.o
+common-obj-$(CONFIG_VHOST_CRYPTO) += cryptodev-vhost-user.o
 endif
 
 common-obj-$(CONFIG_LINUX) += hostmem-memfd.o
diff --git a/default-configs/virtio.mak b/default-configs/virtio.mak
index 1304849..340050a 100644
--- a/default-configs/virtio.mak
+++ b/default-configs/virtio.mak
@@ -1,5 +1,5 @@
-CONFIG_VHOST_USER_SCSI=$(call land,$(CONFIG_VHOST_USER),$(CONFIG_LINUX))
-CONFIG_VHOST_USER_BLK=$(call land,$(CONFIG_VHOST_USER),$(CONFIG_LINUX))
+CONFIG_VHOST_USER_SCSI=$(CONFIG_VHOST_USER)
+CONFIG_VHOST_USER_BLK=$(CONFIG_VHOST_USER)
 CONFIG_VIRTIO=y
 CONFIG_VIRTIO_9P=y
 CONFIG_VIRTIO_BALLOON=y
diff --git a/hw/virtio/Makefile.objs b/hw/virtio/Makefile.objs
index 1b2799c..e8eff80 100644
--- a/hw/virtio/Makefile.objs
+++ b/hw/virtio/Makefile.objs
@@ -9,9 +9,10 @@ obj-$(CONFIG_VIRTIO_BALLOON) += virtio-balloon.o
 obj-$(CONFIG_VIRTIO_CRYPTO) += virtio-crypto.o
 obj-$(call land,$(CONFIG_VIRTIO_CRYPTO),$(CONFIG_VIRTIO_PCI)) += virtio-crypto-pci.o
 
-obj-$(CONFIG_LINUX) += vhost.o vhost-backend.o vhost-user.o
+obj-$(CONFIG_VHOST_USER) += vhost-user.o
 obj-$(CONFIG_VHOST_VSOCK) += vhost-vsock.o
+obj-$(call lor,$(CONFIG_VHOST_USER),$(CONFIG_LINUX)) += vhost.o vhost-backend.o
+common-obj-$(call lnot,$(call lor,$(CONFIG_VHOST_USER),$(CONFIG_LINUX))) += vhost-stub.o
 endif
 
-common-obj-$(call lnot,$(call land,$(CONFIG_VIRTIO),$(CONFIG_LINUX))) += vhost-stub.o
 common-obj-$(CONFIG_ALL) += vhost-stub.o
diff --git a/hw/virtio/vhost-backend.c b/hw/virtio/vhost-backend.c
index 7f09efa..b5d2e30 100644
--- a/hw/virtio/vhost-backend.c
+++ b/hw/virtio/vhost-backend.c
@@ -9,12 +9,14 @@
  */
 
 #include "qemu/osdep.h"
-#include <linux/vhost.h>
-#include <sys/ioctl.h>
 #include "hw/virtio/vhost.h"
 #include "hw/virtio/vhost-backend.h"
 #include "qemu/error-report.h"
 
+#ifdef CONFIG_LINUX
+#include <linux/vhost.h>
+#include <sys/ioctl.h>
+
 static int vhost_kernel_call(struct vhost_dev *dev, unsigned long int request,
                              void *arg)
 {
@@ -265,18 +267,23 @@ static const VhostOps kernel_ops = {
         .vhost_set_iotlb_callback = vhost_kernel_set_iotlb_callback,
         .vhost_send_device_iotlb_msg = vhost_kernel_send_device_iotlb_msg,
 };
+#endif
 
 int vhost_set_backend_type(struct vhost_dev *dev, VhostBackendType backend_type)
 {
     int r = 0;
 
     switch (backend_type) {
+#ifdef CONFIG_LINUX
     case VHOST_BACKEND_TYPE_KERNEL:
         dev->vhost_ops = &kernel_ops;
         break;
+#endif
+#ifdef CONFIG_VHOST_USER
     case VHOST_BACKEND_TYPE_USER:
         dev->vhost_ops = &user_ops;
         break;
+#endif
     default:
         error_report("Unknown vhost backend type");
         r = -1;
-- 
1.8.3.1

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

* [Qemu-devel] [PULL 44/54] vhost-net: compile it on all targets that have virtio-net.
  2018-12-12 15:22 [Qemu-devel] [PULL 00/54] Misc patches for 2018-12-12 Paolo Bonzini
                   ` (42 preceding siblings ...)
  2018-12-12 15:23 ` [Qemu-devel] [PULL 43/54] vhost: restrict Linux dependency to kernel vhost Paolo Bonzini
@ 2018-12-12 15:23 ` Paolo Bonzini
  2018-12-12 15:23 ` [Qemu-devel] [PULL 45/54] vhost-net: revamp configure logic Paolo Bonzini
                   ` (11 subsequent siblings)
  55 siblings, 0 replies; 60+ messages in thread
From: Paolo Bonzini @ 2018-12-12 15:23 UTC (permalink / raw)
  To: qemu-devel

This shows a preexisting bug: if a KVM target did not have virtio-net enabled,
it would fail with undefined symbols when vhost was enabled.  This must now
be fixed, lest targets that have no virtio-net fail to compile.

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Message-Id: <1543851204-41186-5-git-send-email-pbonzini@redhat.com>
---
 configure              | 11 ++++-------
 hw/net/Makefile.objs   |  4 ++--
 include/exec/poison.h  |  1 -
 tests/Makefile.include |  5 +----
 4 files changed, 7 insertions(+), 14 deletions(-)

diff --git a/configure b/configure
index b995d71..b26e4de 100755
--- a/configure
+++ b/configure
@@ -6514,7 +6514,10 @@ fi
 if test "$vhost_scsi" = "yes" ; then
   echo "CONFIG_VHOST_SCSI=y" >> $config_host_mak
 fi
-if test "$vhost_net" = "yes" -a "$vhost_user" = "yes"; then
+if test "$vhost_net" = "yes" ; then
+  echo "CONFIG_VHOST_NET=y" >> $config_host_mak
+fi
+if test "$vhost_net_user" = "yes" ; then
   echo "CONFIG_VHOST_NET_USER=y" >> $config_host_mak
 fi
 if test "$vhost_crypto" = "yes" ; then
@@ -7276,12 +7279,6 @@ if supported_xen_target $target; then
 fi
 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
-        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
     echo "CONFIG_HAX=y" >> $config_target_mak
diff --git a/hw/net/Makefile.objs b/hw/net/Makefile.objs
index c2705e6..2d7ee0a 100644
--- a/hw/net/Makefile.objs
+++ b/hw/net/Makefile.objs
@@ -37,8 +37,8 @@ obj-$(CONFIG_PSERIES) += spapr_llan.o
 obj-$(CONFIG_XILINX_ETHLITE) += xilinx_ethlite.o
 
 obj-$(CONFIG_VIRTIO_NET) += virtio-net.o
-obj-$(CONFIG_VHOST_NET) += vhost_net.o
-common-obj-$(call lnot,$(CONFIG_VHOST_NET)) += vhost_net-stub.o
+common-obj-$(call land,$(CONFIG_VIRTIO_NET),$(CONFIG_VHOST_NET)) += vhost_net.o
+common-obj-$(call lnot,$(call land,$(CONFIG_VIRTIO_NET),$(CONFIG_VHOST_NET))) += vhost_net-stub.o
 common-obj-$(CONFIG_ALL) += vhost_net-stub.o
 
 obj-$(CONFIG_ETSEC) += fsl_etsec/etsec.o fsl_etsec/registers.o \
diff --git a/include/exec/poison.h b/include/exec/poison.h
index 32d5378..b158632 100644
--- a/include/exec/poison.h
+++ b/include/exec/poison.h
@@ -85,7 +85,6 @@
 #pragma GCC poison CONFIG_XTENSA_DIS
 
 #pragma GCC poison CONFIG_LINUX_USER
-#pragma GCC poison CONFIG_VHOST_NET
 #pragma GCC poison CONFIG_KVM
 #pragma GCC poison CONFIG_SOFTMMU
 
diff --git a/tests/Makefile.include b/tests/Makefile.include
index 62915e4..ecb3318 100644
--- a/tests/Makefile.include
+++ b/tests/Makefile.include
@@ -204,10 +204,7 @@ check-qtest-i386-$(CONFIG_USB_XHCI_NEC) += tests/usb-hcd-xhci-test$(EXESUF)
 check-qtest-i386-y += tests/cpu-plug-test$(EXESUF)
 check-qtest-i386-y += tests/q35-test$(EXESUF)
 check-qtest-i386-y += tests/vmgenid-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-$(CONFIG_VHOST_NET_USER) += tests/vhost-user-test$(EXESUF)
 check-qtest-i386-$(CONFIG_TPM_CRB) += tests/tpm-crb-swtpm-test$(EXESUF)
 check-qtest-i386-$(CONFIG_TPM_CRB) += tests/tpm-crb-test$(EXESUF)
 check-qtest-i386-$(CONFIG_TPM_TIS) += tests/tpm-tis-swtpm-test$(EXESUF)
-- 
1.8.3.1

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

* [Qemu-devel] [PULL 45/54] vhost-net: revamp configure logic
  2018-12-12 15:22 [Qemu-devel] [PULL 00/54] Misc patches for 2018-12-12 Paolo Bonzini
                   ` (43 preceding siblings ...)
  2018-12-12 15:23 ` [Qemu-devel] [PULL 44/54] vhost-net: compile it on all targets that have virtio-net Paolo Bonzini
@ 2018-12-12 15:23 ` Paolo Bonzini
  2018-12-12 15:23 ` [Qemu-devel] [PULL 46/54] vhost-user-test: use g_cond_broadcast Paolo Bonzini
                   ` (10 subsequent siblings)
  55 siblings, 0 replies; 60+ messages in thread
From: Paolo Bonzini @ 2018-12-12 15:23 UTC (permalink / raw)
  To: qemu-devel

Detect all invalid configurations (e.g. mingw32 with vhost-user,
non-Linux with vhost-kernel).  As a collateral benefit, all vhost-kernel
backends can be now disabled if one wants to reduce the attack surface.

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Message-Id: <1543851204-41186-6-git-send-email-pbonzini@redhat.com>
---
 configure                 | 89 +++++++++++++++++++++++++++++++----------------
 hw/virtio/Makefile.objs   |  4 +--
 hw/virtio/vhost-backend.c |  4 +--
 3 files changed, 63 insertions(+), 34 deletions(-)

diff --git a/configure b/configure
index b26e4de..b076b43 100755
--- a/configure
+++ b/configure
@@ -366,10 +366,10 @@ libattr=""
 xfs=""
 tcg="yes"
 membarrier=""
-vhost_net="no"
-vhost_crypto="no"
-vhost_scsi="no"
-vhost_vsock="no"
+vhost_net=""
+vhost_crypto=""
+vhost_scsi=""
+vhost_vsock=""
 vhost_user=""
 kvm="no"
 hax="no"
@@ -774,6 +774,7 @@ case $targetos in
 MINGW32*)
   mingw32="yes"
   hax="yes"
+  vhost_user="no"
   audio_possible_drivers="dsound sdl"
   if check_include dsound.h; then
     audio_drv_list="dsound"
@@ -874,10 +875,6 @@ Linux)
   linux="yes"
   linux_user="yes"
   kvm="yes"
-  vhost_net="yes"
-  vhost_crypto="yes"
-  vhost_scsi="yes"
-  vhost_vsock="yes"
   QEMU_INCLUDES="-I\$(SRC_PATH)/linux-headers -I$PWD/linux-headers $QEMU_INCLUDES"
   supported_os="yes"
   libudev="yes"
@@ -1255,11 +1252,7 @@ for opt do
   ;;
   --disable-vhost-crypto) vhost_crypto="no"
   ;;
-  --enable-vhost-crypto)
-      vhost_crypto="yes"
-      if test "$mingw32" = "yes"; then
-          error_exit "vhost-crypto isn't available on win32"
-      fi
+  --enable-vhost-crypto) vhost_crypto="yes"
   ;;
   --disable-vhost-scsi) vhost_scsi="no"
   ;;
@@ -1460,11 +1453,11 @@ for opt do
   ;;
   --disable-vhost-user) vhost_user="no"
   ;;
-  --enable-vhost-user)
-      vhost_user="yes"
-      if test "$mingw32" = "yes"; then
-          error_exit "vhost-user isn't available on win32"
-      fi
+  --enable-vhost-user) vhost_user="yes"
+  ;;
+  --disable-vhost-kernel) vhost_kernel="no"
+  ;;
+  --enable-vhost-kernel) vhost_kernel="yes"
   ;;
   --disable-capstone) capstone="no"
   ;;
@@ -1496,14 +1489,6 @@ 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"
@@ -1728,8 +1713,12 @@ disabled with --disable-FEATURE, default is enabled if available:
   linux-aio       Linux AIO support
   cap-ng          libcap-ng support
   attr            attr and xattr support
-  vhost-net       vhost-net acceleration support
-  vhost-crypto    vhost-crypto acceleration support
+  vhost-net       vhost-net kernel acceleration support
+  vhost-vsock     virtio sockets device support
+  vhost-scsi      vhost-scsi kernel target support
+  vhost-crypto    vhost-user-crypto backend support
+  vhost-kernel    vhost kernel backend support
+  vhost-user      vhost-user backend support
   spice           spice
   rbd             rados block device (rbd)
   libiscsi        iscsi support
@@ -1753,7 +1742,6 @@ disabled with --disable-FEATURE, default is enabled if available:
   jemalloc        jemalloc support
   avx2            AVX2 optimization support
   replication     replication support
-  vhost-vsock     virtio sockets device support
   opengl          opengl support
   virglrenderer   virgl rendering support
   xfsctl          xfsctl support
@@ -1770,7 +1758,6 @@ disabled with --disable-FEATURE, default is enabled if available:
   parallels       parallels image format support
   sheepdog        sheepdog block driver support
   crypto-afalg    Linux AF_ALG crypto backend driver
-  vhost-user      vhost-user support
   capstone        capstone disassembler support
   debug-mutex     mutex debugging support
   libpmem         libpmem support
@@ -2157,6 +2144,45 @@ else
   l2tpv3=no
 fi
 
+#########################################
+# vhost interdependencies and host support
+
+# vhost backends
+test "$vhost_user" = "" && vhost_user=yes
+if test "$vhost_user" = "yes" && test "$mingw32" = "yes"; then
+  error_exit "vhost-user isn't available on win32"
+fi
+test "$vhost_kernel" = "" && vhost_kernel=$linux
+if test "$vhost_kernel" = "yes" && test "$linux" != "yes"; then
+  error_exit "vhost-kernel is only available on Linux"
+fi
+
+# vhost-kernel devices
+test "$vhost_scsi" = "" && vhost_scsi=$vhost_kernel
+if test "$vhost_scsi" = "yes" && test "$vhost_kernel" != "yes"; then
+  error_exit "--enable-vhost-scsi requires --enable-vhost-kernel"
+fi
+test "$vhost_vsock" = "" && vhost_vsock=$vhost_kernel
+if test "$vhost_vsock" = "yes" && test "$vhost_kernel" != "yes"; then
+  error_exit "--enable-vhost-vsock requires --enable-vhost-kernel"
+fi
+
+# vhost-user backends
+test "$vhost_net_user" = "" && vhost_net_user=$vhost_user
+if test "$vhost_net_user" = "yes" && test "$vhost_user" = "no"; then
+  error_exit "--enable-vhost-net-user requires --enable-vhost-user"
+fi
+test "$vhost_crypto" = "" && vhost_crypto=$vhost_user
+if test "$vhost_crypto" = "yes" && test "$vhost_user" = "no"; then
+  error_exit "--enable-vhost-crypto requires --enable-vhost-user"
+fi
+
+# OR the vhost-kernel and vhost-user values for simplicity
+if test "$vhost_net" = ""; then
+  test "$vhost_net_user" = "yes" && vhost_net=yes
+  test "$vhost_kernel" = "yes" && vhost_net=yes
+fi
+
 ##########################################
 # MinGW / Mingw-w64 localtime_r/gmtime_r check
 
@@ -6526,6 +6552,9 @@ fi
 if test "$vhost_vsock" = "yes" ; then
   echo "CONFIG_VHOST_VSOCK=y" >> $config_host_mak
 fi
+if test "$vhost_kernel" = "yes" ; then
+  echo "CONFIG_VHOST_KERNEL=y" >> $config_host_mak
+fi
 if test "$vhost_user" = "yes" ; then
   echo "CONFIG_VHOST_USER=y" >> $config_host_mak
 fi
diff --git a/hw/virtio/Makefile.objs b/hw/virtio/Makefile.objs
index e8eff80..87402d1 100644
--- a/hw/virtio/Makefile.objs
+++ b/hw/virtio/Makefile.objs
@@ -11,8 +11,8 @@ obj-$(call land,$(CONFIG_VIRTIO_CRYPTO),$(CONFIG_VIRTIO_PCI)) += virtio-crypto-p
 
 obj-$(CONFIG_VHOST_USER) += vhost-user.o
 obj-$(CONFIG_VHOST_VSOCK) += vhost-vsock.o
-obj-$(call lor,$(CONFIG_VHOST_USER),$(CONFIG_LINUX)) += vhost.o vhost-backend.o
-common-obj-$(call lnot,$(call lor,$(CONFIG_VHOST_USER),$(CONFIG_LINUX))) += vhost-stub.o
+obj-$(call lor,$(CONFIG_VHOST_USER),$(CONFIG_VHOST_KERNEL)) += vhost.o vhost-backend.o
+common-obj-$(call lnot,$(call lor,$(CONFIG_VHOST_USER),$(CONFIG_VHOST_KERNEL))) += vhost-stub.o
 endif
 
 common-obj-$(CONFIG_ALL) += vhost-stub.o
diff --git a/hw/virtio/vhost-backend.c b/hw/virtio/vhost-backend.c
index b5d2e30..46d388b 100644
--- a/hw/virtio/vhost-backend.c
+++ b/hw/virtio/vhost-backend.c
@@ -13,7 +13,7 @@
 #include "hw/virtio/vhost-backend.h"
 #include "qemu/error-report.h"
 
-#ifdef CONFIG_LINUX
+#ifdef CONFIG_VHOST_KERNEL
 #include <linux/vhost.h>
 #include <sys/ioctl.h>
 
@@ -274,7 +274,7 @@ int vhost_set_backend_type(struct vhost_dev *dev, VhostBackendType backend_type)
     int r = 0;
 
     switch (backend_type) {
-#ifdef CONFIG_LINUX
+#ifdef CONFIG_VHOST_KERNEL
     case VHOST_BACKEND_TYPE_KERNEL:
         dev->vhost_ops = &kernel_ops;
         break;
-- 
1.8.3.1

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

* [Qemu-devel] [PULL 46/54] vhost-user-test: use g_cond_broadcast
  2018-12-12 15:22 [Qemu-devel] [PULL 00/54] Misc patches for 2018-12-12 Paolo Bonzini
                   ` (44 preceding siblings ...)
  2018-12-12 15:23 ` [Qemu-devel] [PULL 45/54] vhost-net: revamp configure logic Paolo Bonzini
@ 2018-12-12 15:23 ` Paolo Bonzini
  2018-12-12 15:23 ` [Qemu-devel] [PULL 47/54] vhost-user-test: signal data_cond when s->rings changes Paolo Bonzini
                   ` (9 subsequent siblings)
  55 siblings, 0 replies; 60+ messages in thread
From: Paolo Bonzini @ 2018-12-12 15:23 UTC (permalink / raw)
  To: qemu-devel

g_cond_signal is rarely the right thing to do, it works now because
vhost-user-test only has two threads but it is not correct in general.
Fix it before adding more calls.

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <1543851204-41186-7-git-send-email-pbonzini@redhat.com>
---
 tests/vhost-user-test.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tests/vhost-user-test.c b/tests/vhost-user-test.c
index 45d58d8..656e519 100644
--- a/tests/vhost-user-test.c
+++ b/tests/vhost-user-test.c
@@ -393,7 +393,7 @@ static void chr_read(void *opaque, const uint8_t *buf, int size)
                                             G_N_ELEMENTS(s->fds));
 
         /* signal the test that it can continue */
-        g_cond_signal(&s->data_cond);
+        g_cond_broadcast(&s->data_cond);
         break;
 
     case VHOST_USER_SET_VRING_KICK:
@@ -419,7 +419,7 @@ static void chr_read(void *opaque, const uint8_t *buf, int size)
         p = (uint8_t *) &msg;
         qemu_chr_fe_write_all(chr, p, VHOST_USER_HDR_SIZE);
 
-        g_cond_signal(&s->data_cond);
+        g_cond_broadcast(&s->data_cond);
         break;
 
     case VHOST_USER_SET_VRING_BASE:
-- 
1.8.3.1

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

* [Qemu-devel] [PULL 47/54] vhost-user-test: signal data_cond when s->rings changes
  2018-12-12 15:22 [Qemu-devel] [PULL 00/54] Misc patches for 2018-12-12 Paolo Bonzini
                   ` (45 preceding siblings ...)
  2018-12-12 15:23 ` [Qemu-devel] [PULL 46/54] vhost-user-test: use g_cond_broadcast Paolo Bonzini
@ 2018-12-12 15:23 ` Paolo Bonzini
  2018-12-12 15:23 ` [Qemu-devel] [PULL 48/54] vhost-user: support cross-endian vnet headers Paolo Bonzini
                   ` (8 subsequent siblings)
  55 siblings, 0 replies; 60+ messages in thread
From: Paolo Bonzini @ 2018-12-12 15:23 UTC (permalink / raw)
  To: qemu-devel

This speeds up wait_for_rings_started, which currently is just waiting for
the timeout before checking s->rings.

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <1543851204-41186-8-git-send-email-pbonzini@redhat.com>
---
 tests/vhost-user-test.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tests/vhost-user-test.c b/tests/vhost-user-test.c
index 656e519..6a805e6 100644
--- a/tests/vhost-user-test.c
+++ b/tests/vhost-user-test.c
@@ -384,6 +384,7 @@ static void chr_read(void *opaque, const uint8_t *buf, int size)
 
         assert(msg.payload.state.index < s->queues * 2);
         s->rings &= ~(0x1ULL << msg.payload.state.index);
+        g_cond_broadcast(&s->data_cond);
         break;
 
     case VHOST_USER_SET_MEM_TABLE:
@@ -425,6 +426,7 @@ static void chr_read(void *opaque, const uint8_t *buf, int size)
     case VHOST_USER_SET_VRING_BASE:
         assert(msg.payload.state.index < s->queues * 2);
         s->rings |= 0x1ULL << msg.payload.state.index;
+        g_cond_broadcast(&s->data_cond);
         break;
 
     case VHOST_USER_GET_QUEUE_NUM:
-- 
1.8.3.1

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

* [Qemu-devel] [PULL 48/54] vhost-user: support cross-endian vnet headers
  2018-12-12 15:22 [Qemu-devel] [PULL 00/54] Misc patches for 2018-12-12 Paolo Bonzini
                   ` (46 preceding siblings ...)
  2018-12-12 15:23 ` [Qemu-devel] [PULL 47/54] vhost-user-test: signal data_cond when s->rings changes Paolo Bonzini
@ 2018-12-12 15:23 ` Paolo Bonzini
  2018-12-12 15:23 ` [Qemu-devel] [PULL 49/54] vhost-user-test: support VHOST_USER_PROTOCOL_F_CROSS_ENDIAN Paolo Bonzini
                   ` (7 subsequent siblings)
  55 siblings, 0 replies; 60+ messages in thread
From: Paolo Bonzini @ 2018-12-12 15:23 UTC (permalink / raw)
  To: qemu-devel

vhost-user already has a way to communicate the endianness of the guest
via the vring endianness messages.  The vring endianness always matches
the vnet header endianness so there is no need to do anything else in
the backend.

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <1543851204-41186-9-git-send-email-pbonzini@redhat.com>
---
 net/vhost-user.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/net/vhost-user.c b/net/vhost-user.c
index a39f9c9..cd9659d 100644
--- a/net/vhost-user.c
+++ b/net/vhost-user.c
@@ -172,6 +172,17 @@ static void net_vhost_user_cleanup(NetClientState *nc)
     qemu_purge_queued_packets(nc);
 }
 
+static int vhost_user_set_vnet_endianness(NetClientState *nc,
+                                          bool enable)
+{
+    /* Nothing to do.  If the server supports
+     * VHOST_USER_PROTOCOL_F_CROSS_ENDIAN, it will get the
+     * vnet header endianness from there.  If it doesn't, negotiation
+     * fails.
+     */
+    return 0;
+}
+
 static bool vhost_user_has_vnet_hdr(NetClientState *nc)
 {
     assert(nc->info->type == NET_CLIENT_DRIVER_VHOST_USER);
@@ -193,6 +204,8 @@ static NetClientInfo net_vhost_user_info = {
         .cleanup = net_vhost_user_cleanup,
         .has_vnet_hdr = vhost_user_has_vnet_hdr,
         .has_ufo = vhost_user_has_ufo,
+        .set_vnet_be = vhost_user_set_vnet_endianness,
+        .set_vnet_le = vhost_user_set_vnet_endianness,
 };
 
 static gboolean net_vhost_user_watch(GIOChannel *chan, GIOCondition cond,
-- 
1.8.3.1

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

* [Qemu-devel] [PULL 49/54] vhost-user-test: support VHOST_USER_PROTOCOL_F_CROSS_ENDIAN
  2018-12-12 15:22 [Qemu-devel] [PULL 00/54] Misc patches for 2018-12-12 Paolo Bonzini
                   ` (47 preceding siblings ...)
  2018-12-12 15:23 ` [Qemu-devel] [PULL 48/54] vhost-user: support cross-endian vnet headers Paolo Bonzini
@ 2018-12-12 15:23 ` Paolo Bonzini
  2018-12-12 15:23 ` [Qemu-devel] [PULL 50/54] vhost-user-test: skip if there is no memory at address 0 Paolo Bonzini
                   ` (6 subsequent siblings)
  55 siblings, 0 replies; 60+ messages in thread
From: Paolo Bonzini @ 2018-12-12 15:23 UTC (permalink / raw)
  To: qemu-devel

This will be useful to run the qtest for ppc64 targets on (for example)
x86_64 hosts.

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Message-Id: <1543851204-41186-10-git-send-email-pbonzini@redhat.com>
---
 tests/vhost-user-test.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/tests/vhost-user-test.c b/tests/vhost-user-test.c
index 6a805e6..82fc6c5 100644
--- a/tests/vhost-user-test.c
+++ b/tests/vhost-user-test.c
@@ -51,6 +51,7 @@
 #define VHOST_USER_F_PROTOCOL_FEATURES 30
 #define VHOST_USER_PROTOCOL_F_MQ 0
 #define VHOST_USER_PROTOCOL_F_LOG_SHMFD 1
+#define VHOST_USER_PROTOCOL_F_CROSS_ENDIAN   6
 
 #define VHOST_LOG_PAGE 0x1000
 
@@ -251,7 +252,7 @@ static void wait_for_fds(TestServer *s)
 
 static void read_guest_mem_server(TestServer *s)
 {
-    uint32_t *guest_mem;
+    uint8_t *guest_mem;
     int i, j;
     size_t size;
 
@@ -278,8 +279,8 @@ static void read_guest_mem_server(TestServer *s)
         g_assert(guest_mem != MAP_FAILED);
         guest_mem += (s->memory.regions[i].mmap_offset / sizeof(*guest_mem));
 
-        for (j = 0; j < 256; j++) {
-            uint32_t a = readl(s->memory.regions[i].guest_phys_addr + j*4);
+        for (j = 0; j < 1024; j++) {
+            uint32_t a = readb(s->memory.regions[i].guest_phys_addr + j);
             uint32_t b = guest_mem[j];
 
             g_assert_cmpint(a, ==, b);
@@ -367,6 +368,7 @@ static void chr_read(void *opaque, const uint8_t *buf, int size)
         msg.flags |= VHOST_USER_REPLY_MASK;
         msg.size = sizeof(m.payload.u64);
         msg.payload.u64 = 1 << VHOST_USER_PROTOCOL_F_LOG_SHMFD;
+        msg.payload.u64 |= 1 << VHOST_USER_PROTOCOL_F_CROSS_ENDIAN;
         if (s->queues > 1) {
             msg.payload.u64 |= 1 << VHOST_USER_PROTOCOL_F_MQ;
         }
-- 
1.8.3.1

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

* [Qemu-devel] [PULL 50/54] vhost-user-test: skip if there is no memory at address 0
  2018-12-12 15:22 [Qemu-devel] [PULL 00/54] Misc patches for 2018-12-12 Paolo Bonzini
                   ` (48 preceding siblings ...)
  2018-12-12 15:23 ` [Qemu-devel] [PULL 49/54] vhost-user-test: support VHOST_USER_PROTOCOL_F_CROSS_ENDIAN Paolo Bonzini
@ 2018-12-12 15:23 ` Paolo Bonzini
  2018-12-12 15:23 ` [Qemu-devel] [PULL 51/54] vhost-user-test: reduce usage of global_qtest Paolo Bonzini
                   ` (5 subsequent siblings)
  55 siblings, 0 replies; 60+ messages in thread
From: Paolo Bonzini @ 2018-12-12 15:23 UTC (permalink / raw)
  To: qemu-devel

The virt machine cannot run the vhost-user qtests because they hardcode
the presence of memory at address 0.  Report the tests as a skip so that
they can be converted to use qgraph.

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <1543851204-41186-11-git-send-email-pbonzini@redhat.com>
---
 tests/vhost-user-test.c | 58 ++++++++++++++++++++++++++++++++++++++-----------
 1 file changed, 45 insertions(+), 13 deletions(-)

diff --git a/tests/vhost-user-test.c b/tests/vhost-user-test.c
index 82fc6c5..59e1aec 100644
--- a/tests/vhost-user-test.c
+++ b/tests/vhost-user-test.c
@@ -228,9 +228,11 @@ static void uninit_virtio_dev(TestServer *s)
     qvirtio_pci_device_free(s->dev);
 }
 
-static void wait_for_fds(TestServer *s)
+static bool wait_for_fds(TestServer *s)
 {
     gint64 end_time;
+    bool got_region;
+    int i;
 
     g_mutex_lock(&s->data_mutex);
 
@@ -248,6 +250,19 @@ static void wait_for_fds(TestServer *s)
     g_assert_cmpint(s->fds_num, ==, s->memory.nregions);
 
     g_mutex_unlock(&s->data_mutex);
+
+    got_region = false;
+    for (i = 0; i < s->memory.nregions; ++i) {
+        VhostUserMemoryRegion *reg = &s->memory.regions[i];
+        if (reg->guest_phys_addr == 0) {
+            got_region = true;
+            break;
+        }
+    }
+    if (!got_region) {
+        g_test_skip("No memory at address 0x0");
+    }
+    return got_region;
 }
 
 static void read_guest_mem_server(TestServer *s)
@@ -256,8 +271,6 @@ static void read_guest_mem_server(TestServer *s)
     int i, j;
     size_t size;
 
-    wait_for_fds(s);
-
     g_mutex_lock(&s->data_mutex);
 
     /* iterate all regions */
@@ -577,8 +590,6 @@ static void write_guest_mem(TestServer *s, uint32_t seed)
     int i, j;
     size_t size;
 
-    wait_for_fds(s);
-
     /* iterate all regions */
     for (i = 0; i < s->fds_num; i++) {
 
@@ -661,8 +672,13 @@ static void test_read_guest_mem(const void *arg)
 
     init_virtio_dev(server, 1u << VIRTIO_NET_F_MAC);
 
+    if (!wait_for_fds(server)) {
+        goto exit;
+    }
+
     read_guest_mem_server(server);
 
+exit:
     uninit_virtio_dev(server);
 
     qtest_quit(s);
@@ -689,8 +705,10 @@ static void test_migrate(void)
     g_free(cmd);
 
     init_virtio_dev(s, 1u << VIRTIO_NET_F_MAC);
-    init_virtio_dev(dest, 1u << VIRTIO_NET_F_MAC);
-    wait_for_fds(s);
+    if (!wait_for_fds(s)) {
+        goto exit;
+    }
+
     size = get_log_size(s);
     g_assert_cmpint(size, ==, (2 * 1024 * 1024) / (VHOST_LOG_PAGE * 8));
 
@@ -699,6 +717,7 @@ static void test_migrate(void)
     g_free(tmp);
     to = qtest_init(cmd);
     g_free(cmd);
+    init_virtio_dev(dest, 1u << VIRTIO_NET_F_MAC);
 
     source = g_source_new(&test_migrate_source_funcs,
                           sizeof(TestMigrateSource));
@@ -738,15 +757,18 @@ static void test_migrate(void)
     global_qtest = to;
     qmp_eventwait("RESUME");
 
+    g_assert(wait_for_fds(s));
     read_guest_mem_server(dest);
 
-    uninit_virtio_dev(s);
     uninit_virtio_dev(dest);
+    qtest_quit(to);
 
     g_source_destroy(source);
     g_source_unref(source);
 
-    qtest_quit(to);
+exit:
+    uninit_virtio_dev(s);
+
     test_server_free(dest);
     qtest_quit(from);
     test_server_free(s);
@@ -810,16 +832,20 @@ static void test_reconnect_subprocess(void)
     g_free(cmd);
 
     init_virtio_dev(s, 1u << VIRTIO_NET_F_MAC);
-    wait_for_fds(s);
+    if (!wait_for_fds(s)) {
+        goto exit;
+    }
+
     wait_for_rings_started(s, 2);
 
     /* reconnect */
     s->fds_num = 0;
     s->rings = 0;
     g_idle_add(reconnect_cb, s);
-    wait_for_fds(s);
+    g_assert(wait_for_fds(s));
     wait_for_rings_started(s, 2);
 
+exit:
     uninit_virtio_dev(s);
 
     qtest_end();
@@ -848,9 +874,12 @@ static void test_connect_fail_subprocess(void)
     g_free(cmd);
 
     init_virtio_dev(s, 1u << VIRTIO_NET_F_MAC);
-    wait_for_fds(s);
+    if (!wait_for_fds(s)) {
+        goto exit;
+    }
     wait_for_rings_started(s, 2);
 
+exit:
     uninit_virtio_dev(s);
 
     qtest_end();
@@ -878,9 +907,12 @@ static void test_flags_mismatch_subprocess(void)
     g_free(cmd);
 
     init_virtio_dev(s, 1u << VIRTIO_NET_F_MAC);
-    wait_for_fds(s);
+    if (!wait_for_fds(s)) {
+        goto exit;
+    }
     wait_for_rings_started(s, 2);
 
+exit:
     uninit_virtio_dev(s);
 
     qtest_end();
-- 
1.8.3.1

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

* [Qemu-devel] [PULL 51/54] vhost-user-test: reduce usage of global_qtest
  2018-12-12 15:22 [Qemu-devel] [PULL 00/54] Misc patches for 2018-12-12 Paolo Bonzini
                   ` (49 preceding siblings ...)
  2018-12-12 15:23 ` [Qemu-devel] [PULL 50/54] vhost-user-test: skip if there is no memory at address 0 Paolo Bonzini
@ 2018-12-12 15:23 ` Paolo Bonzini
  2018-12-12 15:23 ` [Qemu-devel] [PULL 52/54] vhost-user-test: create a main loop per TestServer Paolo Bonzini
                   ` (4 subsequent siblings)
  55 siblings, 0 replies; 60+ messages in thread
From: Paolo Bonzini @ 2018-12-12 15:23 UTC (permalink / raw)
  To: qemu-devel

Whenever the code can run on multiple QTestStates, use them explicitly instead of
global_qtest.

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Message-Id: <1543851204-41186-12-git-send-email-pbonzini@redhat.com>
---
 tests/vhost-user-test.c | 38 +++++++++++++++++---------------------
 1 file changed, 17 insertions(+), 21 deletions(-)

diff --git a/tests/vhost-user-test.c b/tests/vhost-user-test.c
index 59e1aec..c3a8af3 100644
--- a/tests/vhost-user-test.c
+++ b/tests/vhost-user-test.c
@@ -187,12 +187,12 @@ static char *get_qemu_cmd(TestServer *s,
     }
 }
 
-static void init_virtio_dev(TestServer *s, uint32_t features_mask)
+static void init_virtio_dev(QTestState *qts, TestServer *s, uint32_t features_mask)
 {
     uint32_t features;
     int i;
 
-    s->bus = qpci_init_pc(global_qtest, NULL);
+    s->bus = qpci_init_pc(qts, NULL);
     g_assert_nonnull(s->bus);
 
     s->dev = qvirtio_pci_device_find(s->bus, VIRTIO_ID_NET);
@@ -203,7 +203,7 @@ static void init_virtio_dev(TestServer *s, uint32_t features_mask)
     qvirtio_set_acknowledge(&s->dev->vdev);
     qvirtio_set_driver(&s->dev->vdev);
 
-    s->alloc = pc_alloc_init(global_qtest);
+    s->alloc = pc_alloc_init(qts);
 
     for (i = 0; i < s->queues * 2; i++) {
         s->vq[i] = qvirtqueue_setup(&s->dev->vdev, s->alloc, i);
@@ -265,7 +265,7 @@ static bool wait_for_fds(TestServer *s)
     return got_region;
 }
 
-static void read_guest_mem_server(TestServer *s)
+static void read_guest_mem_server(QTestState *qts, TestServer *s)
 {
     uint8_t *guest_mem;
     int i, j;
@@ -293,7 +293,7 @@ static void read_guest_mem_server(TestServer *s)
         guest_mem += (s->memory.regions[i].mmap_offset / sizeof(*guest_mem));
 
         for (j = 0; j < 1024; j++) {
-            uint32_t a = readb(s->memory.regions[i].guest_phys_addr + j);
+            uint32_t a = qtest_readb(qts, s->memory.regions[i].guest_phys_addr + j);
             uint32_t b = guest_mem[j];
 
             g_assert_cmpint(a, ==, b);
@@ -670,13 +670,13 @@ static void test_read_guest_mem(const void *arg)
     s = qtest_start(qemu_cmd);
     g_free(qemu_cmd);
 
-    init_virtio_dev(server, 1u << VIRTIO_NET_F_MAC);
+    init_virtio_dev(global_qtest, server, 1u << VIRTIO_NET_F_MAC);
 
     if (!wait_for_fds(server)) {
         goto exit;
     }
 
-    read_guest_mem_server(server);
+    read_guest_mem_server(global_qtest, server);
 
 exit:
     uninit_virtio_dev(server);
@@ -690,7 +690,7 @@ static void test_migrate(void)
     TestServer *s = test_server_new("src");
     TestServer *dest = test_server_new("dest");
     char *uri = g_strdup_printf("%s%s", "unix:", dest->mig_path);
-    QTestState *global = global_qtest, *from, *to;
+    QTestState *from, *to;
     GSource *source;
     gchar *cmd, *tmp;
     QDict *rsp;
@@ -704,7 +704,7 @@ static void test_migrate(void)
     from = qtest_start(cmd);
     g_free(cmd);
 
-    init_virtio_dev(s, 1u << VIRTIO_NET_F_MAC);
+    init_virtio_dev(from, s, 1u << VIRTIO_NET_F_MAC);
     if (!wait_for_fds(s)) {
         goto exit;
     }
@@ -717,7 +717,7 @@ static void test_migrate(void)
     g_free(tmp);
     to = qtest_init(cmd);
     g_free(cmd);
-    init_virtio_dev(dest, 1u << VIRTIO_NET_F_MAC);
+    init_virtio_dev(to, dest, 1u << VIRTIO_NET_F_MAC);
 
     source = g_source_new(&test_migrate_source_funcs,
                           sizeof(TestMigrateSource));
@@ -753,12 +753,10 @@ static void test_migrate(void)
     qobject_unref(rsp);
 
     qmp_eventwait("STOP");
+    qtest_qmp_eventwait(to, "RESUME");
 
-    global_qtest = to;
-    qmp_eventwait("RESUME");
-
-    g_assert(wait_for_fds(s));
-    read_guest_mem_server(dest);
+    g_assert(wait_for_fds(dest));
+    read_guest_mem_server(to, dest);
 
     uninit_virtio_dev(dest);
     qtest_quit(to);
@@ -773,8 +771,6 @@ exit:
     qtest_quit(from);
     test_server_free(s);
     g_free(uri);
-
-    global_qtest = global;
 }
 
 static void wait_for_rings_started(TestServer *s, size_t count)
@@ -831,7 +827,7 @@ static void test_reconnect_subprocess(void)
     qtest_start(cmd);
     g_free(cmd);
 
-    init_virtio_dev(s, 1u << VIRTIO_NET_F_MAC);
+    init_virtio_dev(global_qtest, s, 1u << VIRTIO_NET_F_MAC);
     if (!wait_for_fds(s)) {
         goto exit;
     }
@@ -873,7 +869,7 @@ static void test_connect_fail_subprocess(void)
     qtest_start(cmd);
     g_free(cmd);
 
-    init_virtio_dev(s, 1u << VIRTIO_NET_F_MAC);
+    init_virtio_dev(global_qtest, s, 1u << VIRTIO_NET_F_MAC);
     if (!wait_for_fds(s)) {
         goto exit;
     }
@@ -906,7 +902,7 @@ static void test_flags_mismatch_subprocess(void)
     qtest_start(cmd);
     g_free(cmd);
 
-    init_virtio_dev(s, 1u << VIRTIO_NET_F_MAC);
+    init_virtio_dev(global_qtest, s, 1u << VIRTIO_NET_F_MAC);
     if (!wait_for_fds(s)) {
         goto exit;
     }
@@ -957,7 +953,7 @@ static void test_multiqueue(void)
     qtest_start(cmd);
     g_free(cmd);
 
-    init_virtio_dev(s, features_mask);
+    init_virtio_dev(global_qtest, s, features_mask);
 
     wait_for_rings_started(s, s->queues * 2);
 
-- 
1.8.3.1

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

* [Qemu-devel] [PULL 52/54] vhost-user-test: create a main loop per TestServer
  2018-12-12 15:22 [Qemu-devel] [PULL 00/54] Misc patches for 2018-12-12 Paolo Bonzini
                   ` (50 preceding siblings ...)
  2018-12-12 15:23 ` [Qemu-devel] [PULL 51/54] vhost-user-test: reduce usage of global_qtest Paolo Bonzini
@ 2018-12-12 15:23 ` Paolo Bonzini
  2018-12-12 15:23 ` [Qemu-devel] [PULL 53/54] vhost-user-test: small changes to init_hugepagefs Paolo Bonzini
                   ` (3 subsequent siblings)
  55 siblings, 0 replies; 60+ messages in thread
From: Paolo Bonzini @ 2018-12-12 15:23 UTC (permalink / raw)
  To: qemu-devel

This makes the tests more independent and removes the need to defer test_server_free
via an idle event source.

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <1543851204-41186-13-git-send-email-pbonzini@redhat.com>
---
 tests/vhost-user-test.c | 38 ++++++++++++++++----------------------
 1 file changed, 16 insertions(+), 22 deletions(-)

diff --git a/tests/vhost-user-test.c b/tests/vhost-user-test.c
index c3a8af3..2e610d4 100644
--- a/tests/vhost-user-test.c
+++ b/tests/vhost-user-test.c
@@ -143,6 +143,8 @@ typedef struct TestServer {
     int fds_num;
     int fds[VHOST_MEMORY_MAX_NREGIONS];
     VhostUserMemory memory;
+    GMainLoop *loop;
+    GThread *thread;
     GMutex data_mutex;
     GCond data_cond;
     int log_fd;
@@ -490,6 +492,10 @@ static TestServer *test_server_new(const gchar *name)
 {
     TestServer *server = g_new0(TestServer, 1);
 
+    server->loop = g_main_loop_new(NULL, FALSE);
+    /* run the main loop thread so the chardev may operate */
+    server->thread = g_thread_new(NULL, thread_function, server->loop);
+
     server->socket_path = g_strdup_printf("%s/%s.sock", tmpfs, name);
     server->mig_path = g_strdup_printf("%s/%s.mig", tmpfs, name);
     server->chr_name = g_strdup_printf("chr-%s", name);
@@ -533,9 +539,18 @@ static void test_server_listen(TestServer *server)
     test_server_create_chr(server, ",server,nowait");
 }
 
-static gboolean _test_server_free(TestServer *server)
+static void test_server_free(TestServer *server)
 {
     int i;
+    int ret;
+
+    /* finish the helper thread and dispatch pending sources */
+    g_main_loop_quit(server->loop);
+    g_thread_join(server->thread);
+    while (g_main_context_pending(NULL)) {
+        g_main_context_iteration(NULL, TRUE);
+    }
+    g_main_loop_unref(server->loop);
 
     qemu_chr_fe_deinit(&server->chr, true);
 
@@ -558,13 +573,6 @@ static gboolean _test_server_free(TestServer *server)
     qpci_free_pc(server->bus);
 
     g_free(server);
-
-    return FALSE;
-}
-
-static void test_server_free(TestServer *server)
-{
-    g_idle_add((GSourceFunc)_test_server_free, server);
 }
 
 static void wait_for_log_fd(TestServer *s)
@@ -969,8 +977,6 @@ int main(int argc, char **argv)
     const char *hugefs;
     int ret;
     char template[] = "/tmp/vhost-test-XXXXXX";
-    GMainLoop *loop;
-    GThread *thread;
 
     g_test_init(&argc, &argv, NULL);
 
@@ -991,10 +997,6 @@ int main(int argc, char **argv)
         root = tmpfs;
     }
 
-    loop = g_main_loop_new(NULL, FALSE);
-    /* run the main loop thread so the chardev may operate */
-    thread = g_thread_new(NULL, thread_function, loop);
-
     if (qemu_memfd_check(0)) {
         qtest_add_data_func("/vhost-user/read-guest-mem/memfd",
                             GINT_TO_POINTER(TEST_MEMFD_YES),
@@ -1022,14 +1024,6 @@ int main(int argc, char **argv)
 
     /* cleanup */
 
-    /* finish the helper thread and dispatch pending sources */
-    g_main_loop_quit(loop);
-    g_thread_join(thread);
-    while (g_main_context_pending(NULL)) {
-        g_main_context_iteration (NULL, TRUE);
-    }
-    g_main_loop_unref(loop);
-
     ret = rmdir(tmpfs);
     if (ret != 0) {
         g_test_message("unable to rmdir: path (%s): %s\n",
-- 
1.8.3.1

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

* [Qemu-devel] [PULL 53/54] vhost-user-test: small changes to init_hugepagefs
  2018-12-12 15:22 [Qemu-devel] [PULL 00/54] Misc patches for 2018-12-12 Paolo Bonzini
                   ` (51 preceding siblings ...)
  2018-12-12 15:23 ` [Qemu-devel] [PULL 52/54] vhost-user-test: create a main loop per TestServer Paolo Bonzini
@ 2018-12-12 15:23 ` Paolo Bonzini
  2018-12-12 15:23 ` [Qemu-devel] [PULL 54/54] vhost-user-test: create a temporary directory per TestServer Paolo Bonzini
                   ` (2 subsequent siblings)
  55 siblings, 0 replies; 60+ messages in thread
From: Paolo Bonzini @ 2018-12-12 15:23 UTC (permalink / raw)
  To: qemu-devel

After the conversion to qgraph, the equivalent of "main" will be in
a constructor and will run even if the tests are not being requested.
Therefore, it should not assert that init_hugepagefs succeeds and will
be called when creating the TestServer.  This patch changes the prototype
of init_hugepagefs, this way the next patch looks nicer.

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <1543851204-41186-14-git-send-email-pbonzini@redhat.com>
---
 tests/vhost-user-test.c | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/tests/vhost-user-test.c b/tests/vhost-user-test.c
index 2e610d4..4e4765b 100644
--- a/tests/vhost-user-test.c
+++ b/tests/vhost-user-test.c
@@ -461,13 +461,19 @@ static void chr_read(void *opaque, const uint8_t *buf, int size)
     g_mutex_unlock(&s->data_mutex);
 }
 
-static const char *init_hugepagefs(const char *path)
+static const char *init_hugepagefs(void)
 {
+    const char *path = getenv("QTEST_HUGETLBFS_PATH");
     struct statfs fs;
     int ret;
 
+    if (!path) {
+        return NULL;
+    }
+
     if (access(path, R_OK | W_OK | X_OK)) {
         g_test_message("access on path (%s): %s\n", path, strerror(errno));
+        abort();
         return NULL;
     }
 
@@ -477,11 +483,13 @@ static const char *init_hugepagefs(const char *path)
 
     if (ret != 0) {
         g_test_message("statfs on path (%s): %s\n", path, strerror(errno));
+        abort();
         return NULL;
     }
 
     if (fs.f_type != HUGETLBFS_MAGIC) {
         g_test_message("Warning: path not on HugeTLBFS: %s\n", path);
+        abort();
         return NULL;
     }
 
@@ -974,7 +982,6 @@ static void test_multiqueue(void)
 
 int main(int argc, char **argv)
 {
-    const char *hugefs;
     int ret;
     char template[] = "/tmp/vhost-test-XXXXXX";
 
@@ -989,13 +996,7 @@ int main(int argc, char **argv)
     }
     g_assert(tmpfs);
 
-    hugefs = getenv("QTEST_HUGETLBFS_PATH");
-    if (hugefs) {
-        root = init_hugepagefs(hugefs);
-        g_assert(root);
-    } else {
-        root = tmpfs;
-    }
+    root = init_hugepagefs() ? : tmpfs;
 
     if (qemu_memfd_check(0)) {
         qtest_add_data_func("/vhost-user/read-guest-mem/memfd",
-- 
1.8.3.1

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

* [Qemu-devel] [PULL 54/54] vhost-user-test: create a temporary directory per TestServer
  2018-12-12 15:22 [Qemu-devel] [PULL 00/54] Misc patches for 2018-12-12 Paolo Bonzini
                   ` (52 preceding siblings ...)
  2018-12-12 15:23 ` [Qemu-devel] [PULL 53/54] vhost-user-test: small changes to init_hugepagefs Paolo Bonzini
@ 2018-12-12 15:23 ` Paolo Bonzini
  2018-12-12 16:16 ` [Qemu-devel] [PULL 00/54] Misc patches for 2018-12-12 Eric Blake
  2018-12-12 21:11 ` no-reply
  55 siblings, 0 replies; 60+ messages in thread
From: Paolo Bonzini @ 2018-12-12 15:23 UTC (permalink / raw)
  To: qemu-devel

This makes the tests more independent, and also the source and destination
TestServers in the migration test.

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <1543851204-41186-15-git-send-email-pbonzini@redhat.com>
---
 tests/vhost-user-test.c | 75 ++++++++++++++++++++++---------------------------
 1 file changed, 34 insertions(+), 41 deletions(-)

diff --git a/tests/vhost-user-test.c b/tests/vhost-user-test.c
index 4e4765b..9d7b0d4 100644
--- a/tests/vhost-user-test.c
+++ b/tests/vhost-user-test.c
@@ -139,6 +139,8 @@ typedef struct TestServer {
     gchar *socket_path;
     gchar *mig_path;
     gchar *chr_name;
+    const gchar *mem_path;
+    gchar *tmpfs;
     CharBackend chr;
     int fds_num;
     int fds[VHOST_MEMORY_MAX_NREGIONS];
@@ -159,9 +161,6 @@ static TestServer *test_server_new(const gchar *name);
 static void test_server_free(TestServer *server);
 static void test_server_listen(TestServer *server);
 
-static const char *tmpfs;
-static const char *root;
-
 enum test_memfd {
     TEST_MEMFD_AUTO,
     TEST_MEMFD_YES,
@@ -169,7 +168,7 @@ enum test_memfd {
 };
 
 static char *get_qemu_cmd(TestServer *s,
-                          int mem, enum test_memfd memfd, const char *mem_path,
+                          int mem, enum test_memfd memfd,
                           const char *chr_opts, const char *extra)
 {
     if (memfd == TEST_MEMFD_AUTO && qemu_memfd_check(0)) {
@@ -184,7 +183,7 @@ static char *get_qemu_cmd(TestServer *s,
     } else {
         return g_strdup_printf(QEMU_CMD_MEM QEMU_CMD_CHR
                                QEMU_CMD_NETDEV QEMU_CMD_NET "%s", mem, mem,
-                               mem_path, s->chr_name, s->socket_path,
+                               s->mem_path, s->chr_name, s->socket_path,
                                chr_opts, s->chr_name, extra);
     }
 }
@@ -499,11 +498,21 @@ static const char *init_hugepagefs(void)
 static TestServer *test_server_new(const gchar *name)
 {
     TestServer *server = g_new0(TestServer, 1);
+    char template[] = "/tmp/vhost-test-XXXXXX";
+    const char *tmpfs;
 
     server->loop = g_main_loop_new(NULL, FALSE);
     /* run the main loop thread so the chardev may operate */
     server->thread = g_thread_new(NULL, thread_function, server->loop);
 
+    tmpfs = mkdtemp(template);
+    if (!tmpfs) {
+        g_test_message("mkdtemp on path (%s): %s", template, strerror(errno));
+    }
+    g_assert(tmpfs);
+
+    server->tmpfs = g_strdup(tmpfs);
+    server->mem_path = init_hugepagefs() ? : server->tmpfs;
     server->socket_path = g_strdup_printf("%s/%s.sock", tmpfs, name);
     server->mig_path = g_strdup_printf("%s/%s.mig", tmpfs, name);
     server->chr_name = g_strdup_printf("chr-%s", name);
@@ -560,6 +569,18 @@ static void test_server_free(TestServer *server)
     }
     g_main_loop_unref(server->loop);
 
+    unlink(server->socket_path);
+    g_free(server->socket_path);
+
+    unlink(server->mig_path);
+    g_free(server->mig_path);
+
+    ret = rmdir(server->tmpfs);
+    if (ret != 0) {
+        g_test_message("unable to rmdir: path (%s): %s",
+                       server->tmpfs, strerror(errno));
+    }
+
     qemu_chr_fe_deinit(&server->chr, true);
 
     for (i = 0; i < server->fds_num; i++) {
@@ -570,12 +591,6 @@ static void test_server_free(TestServer *server)
         close(server->log_fd);
     }
 
-    unlink(server->socket_path);
-    g_free(server->socket_path);
-
-    unlink(server->mig_path);
-    g_free(server->mig_path);
-
     g_free(server->chr_name);
     g_assert(server->bus);
     qpci_free_pc(server->bus);
@@ -681,7 +696,7 @@ static void test_read_guest_mem(const void *arg)
                              "read-guest-memfd" : "read-guest-mem");
     test_server_listen(server);
 
-    qemu_cmd = get_qemu_cmd(server, 512, memfd, root, "", "");
+    qemu_cmd = get_qemu_cmd(server, 512, memfd, "", "");
 
     s = qtest_start(qemu_cmd);
     g_free(qemu_cmd);
@@ -716,7 +731,7 @@ static void test_migrate(void)
     test_server_listen(s);
     test_server_listen(dest);
 
-    cmd = get_qemu_cmd(s, 2, TEST_MEMFD_AUTO, root, "", "");
+    cmd = get_qemu_cmd(s, 2, TEST_MEMFD_AUTO, "", "");
     from = qtest_start(cmd);
     g_free(cmd);
 
@@ -729,7 +744,7 @@ static void test_migrate(void)
     g_assert_cmpint(size, ==, (2 * 1024 * 1024) / (VHOST_LOG_PAGE * 8));
 
     tmp = g_strdup_printf(" -incoming %s", uri);
-    cmd = get_qemu_cmd(dest, 2, TEST_MEMFD_AUTO, root, "", tmp);
+    cmd = get_qemu_cmd(dest, 2, TEST_MEMFD_AUTO, "", tmp);
     g_free(tmp);
     to = qtest_init(cmd);
     g_free(cmd);
@@ -839,7 +854,7 @@ static void test_reconnect_subprocess(void)
     char *cmd;
 
     g_thread_new("connect", connect_thread, s);
-    cmd = get_qemu_cmd(s, 2, TEST_MEMFD_AUTO, root, ",server", "");
+    cmd = get_qemu_cmd(s, 2, TEST_MEMFD_AUTO, ",server", "");
     qtest_start(cmd);
     g_free(cmd);
 
@@ -881,7 +896,7 @@ static void test_connect_fail_subprocess(void)
 
     s->test_fail = true;
     g_thread_new("connect", connect_thread, s);
-    cmd = get_qemu_cmd(s, 2, TEST_MEMFD_AUTO, root, ",server", "");
+    cmd = get_qemu_cmd(s, 2, TEST_MEMFD_AUTO, ",server", "");
     qtest_start(cmd);
     g_free(cmd);
 
@@ -914,7 +929,7 @@ static void test_flags_mismatch_subprocess(void)
 
     s->test_flags = TEST_FLAGS_DISCONNECT;
     g_thread_new("connect", connect_thread, s);
-    cmd = get_qemu_cmd(s, 2, TEST_MEMFD_AUTO, root, ",server", "");
+    cmd = get_qemu_cmd(s, 2, TEST_MEMFD_AUTO, ",server", "");
     qtest_start(cmd);
     g_free(cmd);
 
@@ -962,7 +977,7 @@ static void test_multiqueue(void)
         cmd = g_strdup_printf(
             QEMU_CMD_MEM QEMU_CMD_CHR QEMU_CMD_NETDEV ",queues=%d "
             "-device virtio-net-pci,netdev=net0,mq=on,vectors=%d",
-            512, 512, root, s->chr_name,
+            512, 512, s->mem_path, s->chr_name,
             s->socket_path, "", s->chr_name,
             s->queues, s->queues * 2 + 2);
     }
@@ -982,22 +997,11 @@ static void test_multiqueue(void)
 
 int main(int argc, char **argv)
 {
-    int ret;
-    char template[] = "/tmp/vhost-test-XXXXXX";
-
     g_test_init(&argc, &argv, NULL);
 
     module_call_init(MODULE_INIT_QOM);
     qemu_add_opts(&qemu_chardev_opts);
 
-    tmpfs = mkdtemp(template);
-    if (!tmpfs) {
-        g_test_message("mkdtemp on path (%s): %s\n", template, strerror(errno));
-    }
-    g_assert(tmpfs);
-
-    root = init_hugepagefs() ? : tmpfs;
-
     if (qemu_memfd_check(0)) {
         qtest_add_data_func("/vhost-user/read-guest-mem/memfd",
                             GINT_TO_POINTER(TEST_MEMFD_YES),
@@ -1021,16 +1025,5 @@ int main(int argc, char **argv)
         qtest_add_func("/vhost-user/flags-mismatch", test_flags_mismatch);
     }
 
-    ret = g_test_run();
-
-    /* cleanup */
-
-    ret = rmdir(tmpfs);
-    if (ret != 0) {
-        g_test_message("unable to rmdir: path (%s): %s\n",
-                       tmpfs, strerror(errno));
-    }
-    g_assert_cmpint(ret, ==, 0);
-
-    return ret;
+    return g_test_run();
 }
-- 
1.8.3.1

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

* Re: [Qemu-devel] [PULL 21/54] RFC: qga: drop < Vista compatibility
  2018-12-12 15:22 ` [Qemu-devel] [PULL 21/54] RFC: qga: drop < Vista compatibility Paolo Bonzini
@ 2018-12-12 15:37   ` Daniel P. Berrangé
  0 siblings, 0 replies; 60+ messages in thread
From: Daniel P. Berrangé @ 2018-12-12 15:37 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: qemu-devel, Marc-André Lureau

Doing a pull request for a patch with "RFC: " in the subject
is a bit odd - just s/RFC: // i geuss.

On Wed, Dec 12, 2018 at 04:22:42PM +0100, Paolo Bonzini wrote:
> From: Marc-André Lureau <marcandre.lureau@redhat.com>
> 
> Building QGA for XP seems possible so far: the dependency on
> libqemuutil.a implies building qemu-thread-win32.c, which requires
> Vista API since commit 12f8def0 (v2.9). But qemu-thread isn't being
> used in QGA, the resulting binary may still work on XP.  XP is no
> longer supported for the past 4.5y, it's time to drop support for it.
> 
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> Message-Id: <20181122110039.15972-5-marcandre.lureau@redhat.com>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  qga/commands-win32.c | 64 ----------------------------------------------------
>  1 file changed, 64 deletions(-)
> 
> diff --git a/qga/commands-win32.c b/qga/commands-win32.c
> index f03b9c1..989b93e 100644
> --- a/qga/commands-win32.c
> +++ b/qga/commands-win32.c
> @@ -466,13 +466,11 @@ static STORAGE_BUS_TYPE win2qemu[] = {
>      [BusTypeFibre] = GUEST_DISK_BUS_TYPE_SSA,
>      [BusTypeUsb] = GUEST_DISK_BUS_TYPE_USB,
>      [BusTypeRAID] = GUEST_DISK_BUS_TYPE_RAID,
> -#if (_WIN32_WINNT >= 0x0600)
>      [BusTypeiScsi] = GUEST_DISK_BUS_TYPE_ISCSI,
>      [BusTypeSas] = GUEST_DISK_BUS_TYPE_SAS,
>      [BusTypeSata] = GUEST_DISK_BUS_TYPE_SATA,
>      [BusTypeSd] =  GUEST_DISK_BUS_TYPE_SD,
>      [BusTypeMmc] = GUEST_DISK_BUS_TYPE_MMC,
> -#endif
>  #if (_WIN32_WINNT >= 0x0601)
>      [BusTypeVirtual] = GUEST_DISK_BUS_TYPE_VIRTUAL,
>      [BusTypeFileBackedVirtual] = GUEST_DISK_BUS_TYPE_FILE_BACKED_VIRTUAL,
> @@ -724,10 +722,8 @@ static void get_single_disk_info(GuestDiskAddress *disk, Error **errp)
>      if (disk->bus_type == GUEST_DISK_BUS_TYPE_SCSI
>              || disk->bus_type == GUEST_DISK_BUS_TYPE_IDE
>              || disk->bus_type == GUEST_DISK_BUS_TYPE_RAID
> -#if (_WIN32_WINNT >= 0x0600)
>              /* This bus type is not supported before Windows Server 2003 SP1 */
>              || disk->bus_type == GUEST_DISK_BUS_TYPE_SAS
> -#endif
>          ) {
>          /* We are able to use the same ioctls for different bus types
>           * according to Microsoft docs
> @@ -1322,7 +1318,6 @@ static char *guest_addr_to_str(IP_ADAPTER_UNICAST_ADDRESS *ip_addr,
>      return NULL;
>  }
>  
> -#if (_WIN32_WINNT >= 0x0600)
>  static int64_t guest_ip_prefix(IP_ADAPTER_UNICAST_ADDRESS *ip_addr)
>  {
>      /* For Windows Vista/2008 and newer, use the OnLinkPrefixLength
> @@ -1330,60 +1325,6 @@ static int64_t guest_ip_prefix(IP_ADAPTER_UNICAST_ADDRESS *ip_addr)
>       */
>      return ip_addr->OnLinkPrefixLength;
>  }
> -#else
> -/* When using the Windows XP and 2003 build environment, do the best we can to
> - * figure out the prefix.
> - */
> -static IP_ADAPTER_INFO *guest_get_adapters_info(void)
> -{
> -    IP_ADAPTER_INFO *adptr_info = NULL;
> -    ULONG adptr_info_len = 0;
> -    DWORD ret;
> -
> -    /* Call the first time to get the adptr_info_len. */
> -    GetAdaptersInfo(adptr_info, &adptr_info_len);
> -
> -    adptr_info = g_malloc(adptr_info_len);
> -    ret = GetAdaptersInfo(adptr_info, &adptr_info_len);
> -    if (ret != ERROR_SUCCESS) {
> -        g_free(adptr_info);
> -        adptr_info = NULL;
> -    }
> -    return adptr_info;
> -}
> -
> -static int64_t guest_ip_prefix(IP_ADAPTER_UNICAST_ADDRESS *ip_addr)
> -{
> -    int64_t prefix = -1; /* Use for AF_INET6 and unknown/undetermined values. */
> -    IP_ADAPTER_INFO *adptr_info, *info;
> -    IP_ADDR_STRING *ip;
> -    struct in_addr *p;
> -
> -    if (ip_addr->Address.lpSockaddr->sa_family != AF_INET) {
> -        return prefix;
> -    }
> -    adptr_info = guest_get_adapters_info();
> -    if (adptr_info == NULL) {
> -        return prefix;
> -    }
> -
> -    /* Match up the passed in ip_addr with one found in adaptr_info.
> -     * The matching one in adptr_info will have the netmask.
> -     */
> -    p = &((struct sockaddr_in *)ip_addr->Address.lpSockaddr)->sin_addr;
> -    for (info = adptr_info; info; info = info->Next) {
> -        for (ip = &info->IpAddressList; ip; ip = ip->Next) {
> -            if (p->S_un.S_addr == inet_addr(ip->IpAddress.String)) {
> -                prefix = ctpop32(inet_addr(ip->IpMask.String));
> -                goto out;
> -            }
> -        }
> -    }
> -out:
> -    g_free(adptr_info);
> -    return prefix;
> -}
> -#endif
>  
>  #define INTERFACE_PATH_BUF_SZ 512
>  
> @@ -1904,7 +1845,6 @@ typedef struct _GA_WTSINFOA {
>  
>  GuestUserList *qmp_guest_get_users(Error **err)
>  {
> -#if (_WIN32_WINNT >= 0x0600)
>  #define QGA_NANOSECONDS 10000000
>  
>      GHashTable *cache = NULL;
> @@ -1974,10 +1914,6 @@ GuestUserList *qmp_guest_get_users(Error **err)
>      }
>      g_hash_table_destroy(cache);
>      return head;
> -#else
> -    error_setg(err, QERR_UNSUPPORTED);
> -    return NULL;
> -#endif
>  }
>  
>  typedef struct _ga_matrix_lookup_t {
> -- 
> 1.8.3.1
> 
> 
> 

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

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

* Re: [Qemu-devel] [PULL 24/54] compiler.h: Add an explicit check for the compiler version
  2018-12-12 15:22 ` [Qemu-devel] [PULL 24/54] compiler.h: Add an explicit check for the compiler version Paolo Bonzini
@ 2018-12-12 15:59   ` Thomas Huth
  0 siblings, 0 replies; 60+ messages in thread
From: Thomas Huth @ 2018-12-12 15:59 UTC (permalink / raw)
  To: Paolo Bonzini, qemu-devel, Peter Maydell

On 2018-12-12 16:22, Paolo Bonzini wrote:
> From: Thomas Huth <thuth@redhat.com>
> 
> The questions about our minimum compiler requirement pops up every
> couple of months, and we then have to recall the details each time.
> So let's document this in a proper way, by adding a comment and
> check for the right compiler version to our compiler.h header.
> 
> Signed-off-by: Thomas Huth <thuth@redhat.com>
> Message-Id: <1543574620-17506-1-git-send-email-thuth@redhat.com>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  include/qemu/compiler.h | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/include/qemu/compiler.h b/include/qemu/compiler.h
> index 6b92710..6f32ec2 100644
> --- a/include/qemu/compiler.h
> +++ b/include/qemu/compiler.h
> @@ -22,6 +22,14 @@
>  # define QEMU_GNUC_PREREQ(maj, min) 0
>  #endif
>  
> +/*
> + * We need at least GCC 4.1 for atomics support. Clang also supports these,
> + * and reports itself as GCC 4.2, so it passes this check, too.
> + */
> +#if !QEMU_GNUC_PREREQ(4, 1)
> +#error QEMU needs a compiler that is compatible with GCC v4.1 or newer
> +#endif

You can drop this patch, it has been obsoleted by the configure check.

 Thomas

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

* Re: [Qemu-devel] [PULL 00/54] Misc patches for 2018-12-12
  2018-12-12 15:22 [Qemu-devel] [PULL 00/54] Misc patches for 2018-12-12 Paolo Bonzini
                   ` (53 preceding siblings ...)
  2018-12-12 15:23 ` [Qemu-devel] [PULL 54/54] vhost-user-test: create a temporary directory per TestServer Paolo Bonzini
@ 2018-12-12 16:16 ` Eric Blake
  2018-12-12 19:02   ` Thomas Huth
  2018-12-12 21:11 ` no-reply
  55 siblings, 1 reply; 60+ messages in thread
From: Eric Blake @ 2018-12-12 16:16 UTC (permalink / raw)
  To: Paolo Bonzini, qemu-devel, Thomas Huth

On 12/12/18 9:22 AM, Paolo Bonzini wrote:
> The following changes since commit bb9bf94b3e8926553290bc9a7cb84315af422086:
> 
>    Merge remote-tracking branch 'remotes/ehabkost/tags/machine-next-pull-request' into staging (2018-12-11 19:18:58 +0000)
> 
> are available in the git repository at:
> 
> 
>    git://github.com/bonzini/qemu.git tags/for-upstream
> 
> for you to fetch changes up to e2a9129b491fdb3be3661baf08a9fa4c2e19a028:
> 
>    vhost-user-test: create a temporary directory per TestServer (2018-12-12 13:49:31 +0100)
> 
> This introduces a new dependency on perl's Test::Harness package.  This is
> distributed in package perl-Test-Harness for Fedora, and libtest-harness-perl
> for Debian.  I couldn't find anything for BSD or macOS, but at least the
> Patchew BSD images already have it so it is probably bundled with Perl.

> * add explicit checks for the compiler version and cleanup (Thomas)

Thomas sent a separate pull request for these. Git will probably do the 
right thing if the two pull requests have identical commits, but I 
didn't check if there were any minor variations in patch contents that 
would cause a conflict.


> Marc-André Lureau (5):
>        vhost-user-bridge: fix "unknown type name" compilation error
>        build-sys: don't include windows.h, osdep.h does it
>        build-sys: move windows defines in osdep.h header
>        build-sys: build with Vista API by default
>        RFC: qga: drop < Vista compatibility

As Dan pointed out, removing the RFC from the commit title would require 
a v2 spin of the pull request - if you send a v2, then you can also sort 
out whether to include the minimum compiler version patches.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org

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

* Re: [Qemu-devel] [PULL 00/54] Misc patches for 2018-12-12
  2018-12-12 16:16 ` [Qemu-devel] [PULL 00/54] Misc patches for 2018-12-12 Eric Blake
@ 2018-12-12 19:02   ` Thomas Huth
  0 siblings, 0 replies; 60+ messages in thread
From: Thomas Huth @ 2018-12-12 19:02 UTC (permalink / raw)
  To: Eric Blake, Paolo Bonzini, qemu-devel, Peter Maydell

On 2018-12-12 17:16, Eric Blake wrote:
> On 12/12/18 9:22 AM, Paolo Bonzini wrote:
>> The following changes since commit
>> bb9bf94b3e8926553290bc9a7cb84315af422086:
>>
>>    Merge remote-tracking branch
>> 'remotes/ehabkost/tags/machine-next-pull-request' into staging
>> (2018-12-11 19:18:58 +0000)
>>
>> are available in the git repository at:
>>
>>
>>    git://github.com/bonzini/qemu.git tags/for-upstream
>>
>> for you to fetch changes up to e2a9129b491fdb3be3661baf08a9fa4c2e19a028:
>>
>>    vhost-user-test: create a temporary directory per TestServer
>> (2018-12-12 13:49:31 +0100)
>>
>> This introduces a new dependency on perl's Test::Harness package. 
>> This is
>> distributed in package perl-Test-Harness for Fedora, and
>> libtest-harness-perl
>> for Debian.  I couldn't find anything for BSD or macOS, but at least the
>> Patchew BSD images already have it so it is probably bundled with Perl.
> 
>> * add explicit checks for the compiler version and cleanup (Thomas)
> 
> Thomas sent a separate pull request for these. Git will probably do the
> right thing if the two pull requests have identical commits, but I
> didn't check if there were any minor variations in patch contents that
> would cause a conflict.

There's likely a conflict in the "-fno-gcse" patch since this has minor
edits ... Sorry for that.

So Peter, you've got two options now:

1) Apply Paolo's series. I'll then send a revert for patch 24/54 later.

2) Apply my series first. In that case, I think Paolo should send a v2
of his PULL request with patch 24 and 33-39 dropped.

 Thomas

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

* Re: [Qemu-devel] [PULL 00/54] Misc patches for 2018-12-12
  2018-12-12 15:22 [Qemu-devel] [PULL 00/54] Misc patches for 2018-12-12 Paolo Bonzini
                   ` (54 preceding siblings ...)
  2018-12-12 16:16 ` [Qemu-devel] [PULL 00/54] Misc patches for 2018-12-12 Eric Blake
@ 2018-12-12 21:11 ` no-reply
  55 siblings, 0 replies; 60+ messages in thread
From: no-reply @ 2018-12-12 21:11 UTC (permalink / raw)
  To: pbonzini; +Cc: famz, qemu-devel

Patchew URL: https://patchew.org/QEMU/1544628195-37728-1-git-send-email-pbonzini@redhat.com/



Hi,

This series seems to have some coding style problems. See output below for
more information:

Type: series
Message-id: 1544628195-37728-1-git-send-email-pbonzini@redhat.com
Subject: [Qemu-devel] [PULL 00/54] Misc patches for 2018-12-12

=== TEST SCRIPT BEGIN ===
#!/bin/bash

BASE=base
n=1
total=$(git log --oneline $BASE.. | wc -l)
failed=0

git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram

commits="$(git log --format=%H --reverse $BASE..)"
for c in $commits; do
    echo "Checking PATCH $n/$total: $(git log -n 1 --format=%s $c)..."
    if ! git show $c --format=email | ./scripts/checkpatch.pl --mailback -; then
        failed=1
        echo
    fi
    n=$((n+1))
done

exit $failed
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
 - [tag update]      patchew/20180917145732.48590-1-vsementsov@virtuozzo.com -> patchew/20180917145732.48590-1-vsementsov@virtuozzo.com
Switched to a new branch 'test'
16b9e64 vhost-user-test: create a temporary directory per TestServer
dc7e694 vhost-user-test: small changes to init_hugepagefs
b4414a7 vhost-user-test: create a main loop per TestServer
493f5e3 vhost-user-test: reduce usage of global_qtest
80f65ff vhost-user-test: skip if there is no memory at address 0
053b648 vhost-user-test: support VHOST_USER_PROTOCOL_F_CROSS_ENDIAN
9e1714a vhost-user: support cross-endian vnet headers
6771502 vhost-user-test: signal data_cond when s->rings changes
1f30d35 vhost-user-test: use g_cond_broadcast
c9779b6 vhost-net: revamp configure logic
65060cb vhost-net: compile it on all targets that have virtio-net.
02052a8 vhost: restrict Linux dependency to kernel vhost
2e9125d vhost-net-user: add stubs for when no virtio-net device is present
334c822 vhost-net: move stubs to a separate file
23a88fb hw/watchdog/wdt_i6300esb : remove a unnecessary comment
213a7dc Remove QEMU_ARTIFICIAL macro
2fa6936 includes: Replace QEMU_GNUC_PREREQ with "__has_builtin || !defined(__clang__)"
5dc8dfa audio/alsaaudio: Remove compiler check around pragma
9ded950 tcg/tcg.h: Remove GCC check for tcg_debug_assert() macro
5b4272c configure: Remove old -fno-gcse workaround for GCC 4.6.x and 4.7.[012]
f1f6aa3 configure: Remove obsolete check for Clang < 3.2
d7f23f1 configure: Add a test for the minimum compiler version
bb04958 checkpatch: warn about qemu/queue.h head structs that are not typedef-ed
3b17309 qemu/queue.h: simplify reverse access to QTAILQ
e7ca6bd qemu/queue.h: reimplement QTAILQ without pointer-to-pointers
276fe5a qemu/queue.h: remove Q_TAILQ_{HEAD, ENTRY}
94d7074 qemu/queue.h: typedef QTAILQ heads
33c8d7f qemu/queue.h: leave head structs anonymous unless necessary
515e852 vfio: make vfio_address_spaces static
f0eff3f qemu/queue.h: do not access tqe_prev directly
279b05a compiler.h: Add an explicit check for the compiler version
17afb2c test: replace gtester with a TAP driver
5ac5663 test: execute g_test_run when tests are skipped
4aa44d3 RFC: qga: drop < Vista compatibility
ce507e2 build-sys: build with Vista API by default
4553cbc build-sys: move windows defines in osdep.h header
75ae603 build-sys: don't include windows.h, osdep.h does it
e759092 scsi: esp: Defer command completion until previous interrupts have been handled
eda6b74 esp-pci: Fix status register write erase control
565b3aa block/iscsi: cancel libiscsi task when ABORT TASK TMF completes
363ab7c block/iscsi: fix ioctl cancel use-after-free
e5c91c8 block/iscsi: take iscsilun->mutex in iscsi_timed_check_events()
5213399 block/iscsi: drop unused IscsiAIOCB->buf field
f5729b9 hax: Support for Linux hosts
a050a4d memory: update coalesced_range on transaction_commit
e6bb3cf memory: avoid unnecessary coalesced_io_del operations
dc372b7 memory: extract flat_range_coalesced_io_{del, add}
24905f8 pam: wrap MemoryRegion initialization in a transaction
f03ab76 checkpatch: colorize output to terminal
81e9bae checkpatch: improve handling of multiple patches or files
7bf3d1c checkpatch: check Signed-off-by in --mailback mode
c91e369 checkpatch: fix premature exit when no input or --mailback
15ea796 vhost-user-bridge: fix "unknown type name" compilation error
c837fd5 accel: Improve selection of the default accelerator

=== OUTPUT BEGIN ===
Checking PATCH 1/54: accel: Improve selection of the default accelerator...
Checking PATCH 2/54: vhost-user-bridge: fix "unknown type name" compilation error...
Checking PATCH 3/54: checkpatch: fix premature exit when no input or --mailback...
Checking PATCH 4/54: checkpatch: check Signed-off-by in --mailback mode...
Checking PATCH 5/54: checkpatch: improve handling of multiple patches or files...
ERROR: line over 90 characters
#33: FILE: scripts/checkpatch.pl:345:
+       open($HASH, "-|", "git", "log", "--reverse", "--no-merges", "--format=%H %s", $ARGV[0]) ||

ERROR: line over 90 characters
#34: FILE: scripts/checkpatch.pl:346:
+               die "$P: git log --reverse --no-merges --format='%H %s' $ARGV[0] failed - $!\n";

WARNING: line over 80 characters
#65: FILE: scripts/checkpatch.pl:373:
+               $vname = substr($hash, 0, 12) . ' (' . $git_commits{$hash} . ')';

total: 2 errors, 1 warnings, 62 lines checked

Your patch has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.

Checking PATCH 6/54: checkpatch: colorize output to terminal...
Checking PATCH 7/54: pam: wrap MemoryRegion initialization in a transaction...
Checking PATCH 8/54: memory: extract flat_range_coalesced_io_{del, add}...
Checking PATCH 9/54: memory: avoid unnecessary coalesced_io_del operations...
Checking PATCH 10/54: memory: update coalesced_range on transaction_commit...
Checking PATCH 11/54: hax: Support for Linux hosts...
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
#62: 
rename from target/i386/hax-darwin.c

total: 0 errors, 1 warnings, 31 lines checked

Your patch has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
Checking PATCH 12/54: block/iscsi: drop unused IscsiAIOCB->buf field...
Checking PATCH 13/54: block/iscsi: take iscsilun->mutex in iscsi_timed_check_events()...
Checking PATCH 14/54: block/iscsi: fix ioctl cancel use-after-free...
Checking PATCH 15/54: block/iscsi: cancel libiscsi task when ABORT TASK TMF completes...
Checking PATCH 16/54: esp-pci: Fix status register write erase control...
Checking PATCH 17/54: scsi: esp: Defer command completion until previous interrupts have been handled...
Checking PATCH 18/54: build-sys: don't include windows.h, osdep.h does it...
Checking PATCH 19/54: build-sys: move windows defines in osdep.h header...
WARNING: architecture specific defines should be avoided
#61: FILE: include/qemu/osdep.h:96:
+#ifdef __MINGW32__

total: 0 errors, 1 warnings, 39 lines checked

Your patch has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
Checking PATCH 20/54: build-sys: build with Vista API by default...
Checking PATCH 21/54: RFC: qga: drop < Vista compatibility...
Checking PATCH 22/54: test: execute g_test_run when tests are skipped...
Checking PATCH 23/54: test: replace gtester with a TAP driver...
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
#25: 
deleted file mode 100755

total: 0 errors, 1 warnings, 618 lines checked

Your patch has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
Checking PATCH 24/54: compiler.h: Add an explicit check for the compiler version...
Checking PATCH 25/54: qemu/queue.h: do not access tqe_prev directly...
Checking PATCH 26/54: vfio: make vfio_address_spaces static...
Checking PATCH 27/54: qemu/queue.h: leave head structs anonymous unless necessary...
Checking PATCH 28/54: qemu/queue.h: typedef QTAILQ heads...
Checking PATCH 29/54: qemu/queue.h: remove Q_TAILQ_{HEAD, ENTRY}...
Checking PATCH 30/54: qemu/queue.h: reimplement QTAILQ without pointer-to-pointers...
WARNING: line over 80 characters
#176: FILE: include/qemu/queue.h:451:
+#define QTAILQ_IN_USE(elm, field)        ((elm)->field.tqe_circ.tql_prev != NULL)

WARNING: line over 80 characters
#185: FILE: include/qemu/queue.h:458:
+        ((typeof((elm)->field.tqe_next)) QTAILQ_LINK_PREV((elm)->field.tqe_circ))

WARNING: line over 80 characters
#257: FILE: include/qemu/queue.h:489:
+#define QTAILQ_RAW_INSERT_TAIL(head, elm, entry) do {                           \

WARNING: line over 80 characters
#258: FILE: include/qemu/queue.h:490:
+        *QTAILQ_RAW_NEXT(elm, entry) = NULL;                                    \

WARNING: line over 80 characters
#259: FILE: include/qemu/queue.h:491:
+        QTAILQ_RAW_TQE_CIRC(elm, entry)->tql_prev = QTAILQ_RAW_TQH_CIRC(head)->tql_prev; \

WARNING: line over 80 characters
#260: FILE: include/qemu/queue.h:492:
+        QTAILQ_RAW_TQH_CIRC(head)->tql_prev->tql_next = (elm);                  \

WARNING: line over 80 characters
#261: FILE: include/qemu/queue.h:493:
+        QTAILQ_RAW_TQH_CIRC(head)->tql_prev = QTAILQ_RAW_TQE_CIRC(elm, entry);  \

WARNING: line over 80 characters
#336: FILE: include/qemu/rcu_queue.h:251:
+    atomic_set(&(elm)->field.tqe_circ.tql_prev->tql_next, (elm)->field.tqe_next); \

total: 0 errors, 8 warnings, 315 lines checked

Your patch has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
Checking PATCH 31/54: qemu/queue.h: simplify reverse access to QTAILQ...
Checking PATCH 32/54: checkpatch: warn about qemu/queue.h head structs that are not typedef-ed...
WARNING: line over 80 characters
#21: FILE: scripts/checkpatch.pl:2266:
+               if ($line =~ /^.\s*(Q(?:S?LIST|SIMPLEQ|TAILQ)_HEAD)\s*\(\s*[^,]/ &&

WARNING: line over 80 characters
#23: FILE: scripts/checkpatch.pl:2268:
+                   ERROR("named $1 should be typedefed separately\n" . $herecurr);

total: 0 errors, 2 warnings, 11 lines checked

Your patch has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
Checking PATCH 33/54: configure: Add a test for the minimum compiler version...
Checking PATCH 34/54: configure: Remove obsolete check for Clang < 3.2...
Checking PATCH 35/54: configure: Remove old -fno-gcse workaround for GCC 4.6.x and 4.7.[012]...
Checking PATCH 36/54: tcg/tcg.h: Remove GCC check for tcg_debug_assert() macro...
Checking PATCH 37/54: audio/alsaaudio: Remove compiler check around pragma...
Checking PATCH 38/54: includes: Replace QEMU_GNUC_PREREQ with "__has_builtin || !defined(__clang__)"...
WARNING: architecture specific defines should be avoided
#25: FILE: include/qemu/compiler.h:138:
+#if __has_builtin(__builtin_assume_aligned) || !defined(__clang__)

WARNING: architecture specific defines should be avoided
#38: FILE: include/qemu/host-utils.h:210:
+#if __has_builtin(__builtin_clrsb) || !defined(__clang__)

WARNING: architecture specific defines should be avoided
#47: FILE: include/qemu/host-utils.h:226:
+#if __has_builtin(__builtin_clrsbll) || !defined(__clang__)

total: 0 errors, 3 warnings, 24 lines checked

Your patch has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
Checking PATCH 39/54: Remove QEMU_ARTIFICIAL macro...
Checking PATCH 40/54: hw/watchdog/wdt_i6300esb : remove a unnecessary comment...
Checking PATCH 41/54: vhost-net: move stubs to a separate file...
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
#41: 
new file mode 100644

total: 0 errors, 1 warnings, 112 lines checked

Your patch has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
Checking PATCH 42/54: vhost-net-user: add stubs for when no virtio-net device is present...
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
#102: 
new file mode 100644

total: 0 errors, 1 warnings, 75 lines checked

Your patch has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
Checking PATCH 43/54: vhost: restrict Linux dependency to kernel vhost...
Checking PATCH 44/54: vhost-net: compile it on all targets that have virtio-net....
Checking PATCH 45/54: vhost-net: revamp configure logic...
Checking PATCH 46/54: vhost-user-test: use g_cond_broadcast...
Checking PATCH 47/54: vhost-user-test: signal data_cond when s->rings changes...
Checking PATCH 48/54: vhost-user: support cross-endian vnet headers...
Checking PATCH 49/54: vhost-user-test: support VHOST_USER_PROTOCOL_F_CROSS_ENDIAN...
Checking PATCH 50/54: vhost-user-test: skip if there is no memory at address 0...
Checking PATCH 51/54: vhost-user-test: reduce usage of global_qtest...
WARNING: line over 80 characters
#27: FILE: tests/vhost-user-test.c:190:
+static void init_virtio_dev(QTestState *qts, TestServer *s, uint32_t features_mask)

WARNING: line over 80 characters
#60: FILE: tests/vhost-user-test.c:296:
+            uint32_t a = qtest_readb(qts, s->memory.regions[i].guest_phys_addr + j);

total: 0 errors, 2 warnings, 132 lines checked

Your patch has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
Checking PATCH 52/54: vhost-user-test: create a main loop per TestServer...
Checking PATCH 53/54: vhost-user-test: small changes to init_hugepagefs...
Checking PATCH 54/54: vhost-user-test: create a temporary directory per TestServer...
=== OUTPUT END ===

Test command exited with code: 1


The full log is available at
http://patchew.org/logs/1544628195-37728-1-git-send-email-pbonzini@redhat.com/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to patchew-devel@redhat.com

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

end of thread, other threads:[~2018-12-12 21:27 UTC | newest]

Thread overview: 60+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-12 15:22 [Qemu-devel] [PULL 00/54] Misc patches for 2018-12-12 Paolo Bonzini
2018-12-12 15:22 ` [Qemu-devel] [PULL 01/54] accel: Improve selection of the default accelerator Paolo Bonzini
2018-12-12 15:22 ` [Qemu-devel] [PULL 02/54] vhost-user-bridge: fix "unknown type name" compilation error Paolo Bonzini
2018-12-12 15:22 ` [Qemu-devel] [PULL 03/54] checkpatch: fix premature exit when no input or --mailback Paolo Bonzini
2018-12-12 15:22 ` [Qemu-devel] [PULL 04/54] checkpatch: check Signed-off-by in --mailback mode Paolo Bonzini
2018-12-12 15:22 ` [Qemu-devel] [PULL 05/54] checkpatch: improve handling of multiple patches or files Paolo Bonzini
2018-12-12 15:22 ` [Qemu-devel] [PULL 06/54] checkpatch: colorize output to terminal Paolo Bonzini
2018-12-12 15:22 ` [Qemu-devel] [PULL 07/54] pam: wrap MemoryRegion initialization in a transaction Paolo Bonzini
2018-12-12 15:22 ` [Qemu-devel] [PULL 08/54] memory: extract flat_range_coalesced_io_{del, add} Paolo Bonzini
2018-12-12 15:22 ` [Qemu-devel] [PULL 09/54] memory: avoid unnecessary coalesced_io_del operations Paolo Bonzini
2018-12-12 15:22 ` [Qemu-devel] [PULL 10/54] memory: update coalesced_range on transaction_commit Paolo Bonzini
2018-12-12 15:22 ` [Qemu-devel] [PULL 11/54] hax: Support for Linux hosts Paolo Bonzini
2018-12-12 15:22 ` [Qemu-devel] [PULL 12/54] block/iscsi: drop unused IscsiAIOCB->buf field Paolo Bonzini
2018-12-12 15:22 ` [Qemu-devel] [PULL 13/54] block/iscsi: take iscsilun->mutex in iscsi_timed_check_events() Paolo Bonzini
2018-12-12 15:22 ` [Qemu-devel] [PULL 14/54] block/iscsi: fix ioctl cancel use-after-free Paolo Bonzini
2018-12-12 15:22 ` [Qemu-devel] [PULL 15/54] block/iscsi: cancel libiscsi task when ABORT TASK TMF completes Paolo Bonzini
2018-12-12 15:22 ` [Qemu-devel] [PULL 16/54] esp-pci: Fix status register write erase control Paolo Bonzini
2018-12-12 15:22 ` [Qemu-devel] [PULL 17/54] scsi: esp: Defer command completion until previous interrupts have been handled Paolo Bonzini
2018-12-12 15:22 ` [Qemu-devel] [PULL 18/54] build-sys: don't include windows.h, osdep.h does it Paolo Bonzini
2018-12-12 15:22 ` [Qemu-devel] [PULL 19/54] build-sys: move windows defines in osdep.h header Paolo Bonzini
2018-12-12 15:22 ` [Qemu-devel] [PULL 20/54] build-sys: build with Vista API by default Paolo Bonzini
2018-12-12 15:22 ` [Qemu-devel] [PULL 21/54] RFC: qga: drop < Vista compatibility Paolo Bonzini
2018-12-12 15:37   ` Daniel P. Berrangé
2018-12-12 15:22 ` [Qemu-devel] [PULL 22/54] test: execute g_test_run when tests are skipped Paolo Bonzini
2018-12-12 15:22 ` [Qemu-devel] [PULL 23/54] test: replace gtester with a TAP driver Paolo Bonzini
2018-12-12 15:22 ` [Qemu-devel] [PULL 24/54] compiler.h: Add an explicit check for the compiler version Paolo Bonzini
2018-12-12 15:59   ` Thomas Huth
2018-12-12 15:22 ` [Qemu-devel] [PULL 25/54] qemu/queue.h: do not access tqe_prev directly Paolo Bonzini
2018-12-12 15:22 ` [Qemu-devel] [PULL 26/54] vfio: make vfio_address_spaces static Paolo Bonzini
2018-12-12 15:22 ` [Qemu-devel] [PULL 27/54] qemu/queue.h: leave head structs anonymous unless necessary Paolo Bonzini
2018-12-12 15:22 ` [Qemu-devel] [PULL 28/54] qemu/queue.h: typedef QTAILQ heads Paolo Bonzini
2018-12-12 15:22 ` [Qemu-devel] [PULL 29/54] qemu/queue.h: remove Q_TAILQ_{HEAD, ENTRY} Paolo Bonzini
2018-12-12 15:22 ` [Qemu-devel] [PULL 30/54] qemu/queue.h: reimplement QTAILQ without pointer-to-pointers Paolo Bonzini
2018-12-12 15:22 ` [Qemu-devel] [PULL 31/54] qemu/queue.h: simplify reverse access to QTAILQ Paolo Bonzini
2018-12-12 15:22 ` [Qemu-devel] [PULL 32/54] checkpatch: warn about qemu/queue.h head structs that are not typedef-ed Paolo Bonzini
2018-12-12 15:22 ` [Qemu-devel] [PULL 33/54] configure: Add a test for the minimum compiler version Paolo Bonzini
2018-12-12 15:22 ` [Qemu-devel] [PULL 34/54] configure: Remove obsolete check for Clang < 3.2 Paolo Bonzini
2018-12-12 15:22 ` [Qemu-devel] [PULL 35/54] configure: Remove old -fno-gcse workaround for GCC 4.6.x and 4.7.[012] Paolo Bonzini
2018-12-12 15:22 ` [Qemu-devel] [PULL 36/54] tcg/tcg.h: Remove GCC check for tcg_debug_assert() macro Paolo Bonzini
2018-12-12 15:22 ` [Qemu-devel] [PULL 37/54] audio/alsaaudio: Remove compiler check around pragma Paolo Bonzini
2018-12-12 15:22 ` [Qemu-devel] [PULL 38/54] includes: Replace QEMU_GNUC_PREREQ with "__has_builtin || !defined(__clang__)" Paolo Bonzini
2018-12-12 15:23 ` [Qemu-devel] [PULL 39/54] Remove QEMU_ARTIFICIAL macro Paolo Bonzini
2018-12-12 15:23 ` [Qemu-devel] [PULL 40/54] hw/watchdog/wdt_i6300esb : remove a unnecessary comment Paolo Bonzini
2018-12-12 15:23 ` [Qemu-devel] [PULL 41/54] vhost-net: move stubs to a separate file Paolo Bonzini
2018-12-12 15:23 ` [Qemu-devel] [PULL 42/54] vhost-net-user: add stubs for when no virtio-net device is present Paolo Bonzini
2018-12-12 15:23 ` [Qemu-devel] [PULL 43/54] vhost: restrict Linux dependency to kernel vhost Paolo Bonzini
2018-12-12 15:23 ` [Qemu-devel] [PULL 44/54] vhost-net: compile it on all targets that have virtio-net Paolo Bonzini
2018-12-12 15:23 ` [Qemu-devel] [PULL 45/54] vhost-net: revamp configure logic Paolo Bonzini
2018-12-12 15:23 ` [Qemu-devel] [PULL 46/54] vhost-user-test: use g_cond_broadcast Paolo Bonzini
2018-12-12 15:23 ` [Qemu-devel] [PULL 47/54] vhost-user-test: signal data_cond when s->rings changes Paolo Bonzini
2018-12-12 15:23 ` [Qemu-devel] [PULL 48/54] vhost-user: support cross-endian vnet headers Paolo Bonzini
2018-12-12 15:23 ` [Qemu-devel] [PULL 49/54] vhost-user-test: support VHOST_USER_PROTOCOL_F_CROSS_ENDIAN Paolo Bonzini
2018-12-12 15:23 ` [Qemu-devel] [PULL 50/54] vhost-user-test: skip if there is no memory at address 0 Paolo Bonzini
2018-12-12 15:23 ` [Qemu-devel] [PULL 51/54] vhost-user-test: reduce usage of global_qtest Paolo Bonzini
2018-12-12 15:23 ` [Qemu-devel] [PULL 52/54] vhost-user-test: create a main loop per TestServer Paolo Bonzini
2018-12-12 15:23 ` [Qemu-devel] [PULL 53/54] vhost-user-test: small changes to init_hugepagefs Paolo Bonzini
2018-12-12 15:23 ` [Qemu-devel] [PULL 54/54] vhost-user-test: create a temporary directory per TestServer Paolo Bonzini
2018-12-12 16:16 ` [Qemu-devel] [PULL 00/54] Misc patches for 2018-12-12 Eric Blake
2018-12-12 19:02   ` Thomas Huth
2018-12-12 21:11 ` no-reply

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.