Skip to contentSkip to conversation

testing/next pre-PR

PATCH In review Alex Bennée 3 participants 34 messages Oct 27, 2022 – Oct 31, 2022 Block layer

lore
Share & tools
lore
#0 lore raw

v4 cover testing/next pre-PR

Hi,

Pretty much everything is reviewed now except the late breaking fixes mentioned bellow. Consider this a pre-PR series for the pull req I'm going to send in on Haloween (hopefully no hidden gremlins though).

The following still need review:

- tests/unit: cleanups for test-io-channel-command
- contrib/plugins: protect execlog's last_exec expansion
- tests/docker: update fedora-win[32|64]-cross with lcitool

Alex Bennée (19):
tests/docker: update fedora-win[32|64]-cross with lcitool tests/docker: update test-mingw to run single build
configure: don't enable cross compilers unless in target_list
configure: fix the --enable-static --disable-pie case tests/avocado: extend the timeout for x86_64 tcg tests tests/tcg: use regular semihosting for nios2-softmmu
MAINTAINERS: add entries for the key build bits
MAINTAINERS: add features_to_c.sh to gdbstub files
MAINTAINERS: fix-up for check-tcg Makefile changes tests/avocado: set -machine none for userfwd and vnc tests tests/avocado: disable sh4 rd2 tests on Gitlab tests/tcg: re-enable linux-test for sh4
tests/tcg: re-enable threadcount for sh4 target/s390x: don't use ld_code2 to probe next pc target/s390x: don't probe next pc for EXecuted insns target/s390x: fake instruction loading when handling 'ex' contrib/plugins: enable debug on CONFIG_DEBUG_TCG contrib/plugins: protect execlog's last_exec expansion tests/unit: cleanups for test-io-channel-command

Anton Johansson (2):
tests/docker: Add flex/bison to debian-all-test tests/docker: Add flex/bison to debian-hexagon-cross

Bin Meng (5):
semihosting/arm-compat-semi: Avoid using hardcoded /tmp
tcg: Avoid using hardcoded /tmp
util/qemu-sockets: Use g_get_tmp_dir() to get the directory for
temporary files
block/vvfat: Unify the mkdir() call
hw/usb: dev-mtp: Use g_mkdir()

Ilya Leoshkevich (1):
tests/vm: use -o IdentitiesOnly=yes for ssh

Paolo Bonzini (1):
tests/tcg: include CONFIG_PLUGIN in config-host.mak

Peter Maydell (1):
tests/avocado: raspi2_initrd: Wait for guest shutdown message before
stopping

Richard Henderson (1):
tests/tcg/nios2: Tweak 10m50-ghrd.ld

 configure                                     |  17 +-
 include/exec/translator.h                     |  17 ++
 block/vvfat.c                                 |   9 +-
 contrib/plugins/execlog.c                     |  38 ++-
 hw/usb/dev-mtp.c                              |   4 +-
 semihosting/arm-compat-semi.c                 |   3 +-
 target/s390x/tcg/translate.c                  |  14 +-
 tcg/tcg.c                                     |   3 +-
 tests/unit/test-io-channel-command.c          |  45 ++--
 util/qemu-sockets.c                           |   5 +-
 MAINTAINERS                                   |  29 ++-
 contrib/plugins/Makefile                      |   1 +
 tests/avocado/boot_linux.py                   |   1 +
 tests/avocado/boot_linux_console.py           |   7 +-
 tests/avocado/info_usernet.py                 |   3 +
 tests/avocado/vnc.py                          |   1 +
 tests/docker/dockerfiles/alpine.docker        |   2 +-
 tests/docker/dockerfiles/centos8.docker       |   2 +-
 .../dockerfiles/debian-all-test-cross.docker  |   2 +
 .../dockerfiles/debian-amd64-cross.docker     | 234 ++++++++---------
 tests/docker/dockerfiles/debian-amd64.docker  | 236 +++++++++---------
 .../dockerfiles/debian-arm64-cross.docker     | 232 ++++++++---------
 .../dockerfiles/debian-armel-cross.docker     | 230 ++++++++---------
 .../dockerfiles/debian-armhf-cross.docker     | 232 ++++++++---------
 .../dockerfiles/debian-hexagon-cross.docker   |   2 +-
 .../dockerfiles/debian-mips64el-cross.docker  | 226 ++++++++---------
 .../dockerfiles/debian-mipsel-cross.docker    | 226 ++++++++---------
 .../dockerfiles/debian-ppc64el-cross.docker   | 230 ++++++++---------
 .../dockerfiles/debian-s390x-cross.docker     | 228 ++++++++---------
 .../dockerfiles/fedora-win32-cross.docker     | 139 ++++++++---
 .../dockerfiles/fedora-win64-cross.docker     | 138 +++++++---
 tests/docker/dockerfiles/fedora.docker        | 230 ++++++++---------
 tests/docker/dockerfiles/opensuse-leap.docker |   2 +-
 tests/docker/dockerfiles/ubuntu2004.docker    | 234 ++++++++---------
 tests/docker/test-mingw                       |  16 +-
 tests/lcitool/libvirt-ci                      |   2 +-
 tests/lcitool/refresh                         |  48 ++--
 tests/tcg/nios2/10m50-ghrd.ld                 |  14 +-
 tests/tcg/nios2/Makefile.softmmu-target       |   3 +-
 tests/tcg/sh4/Makefile.target                 |  12 -
 tests/vm/basevm.py                            |   3 +-
 41 files changed, 1670 insertions(+), 1450 deletions(-)
Signature · 1 line
2.34.1
#1 lore raw

PATCH v4 1/30 tests/docker: update fedora-win[32|64]-cross with lcitool

Convert another two dockerfiles to lcitool and update. I renamed the helper because it is not Debian specific. We need an updated lcitool for this to deal with the weirdness of a 32bit nsis tool for both 32 and 64 bit builds. As a result there are some minor whitespace and re-order changes in a bunch of the docker files.

Message-Id: <[email protected]>

---
 tests/docker/dockerfiles/alpine.docker        |   2 +-
 tests/docker/dockerfiles/centos8.docker       |   2 +-
 .../dockerfiles/debian-amd64-cross.docker     | 234 ++++++++---------
 tests/docker/dockerfiles/debian-amd64.docker  | 236 +++++++++---------
 .../dockerfiles/debian-arm64-cross.docker     | 232 ++++++++---------
 .../dockerfiles/debian-armel-cross.docker     | 230 ++++++++---------
 .../dockerfiles/debian-armhf-cross.docker     | 232 ++++++++---------
 .../dockerfiles/debian-mips64el-cross.docker  | 226 ++++++++---------
 .../dockerfiles/debian-mipsel-cross.docker    | 226 ++++++++---------
 .../dockerfiles/debian-ppc64el-cross.docker   | 230 ++++++++---------
 .../dockerfiles/debian-s390x-cross.docker     | 228 ++++++++---------
 .../dockerfiles/fedora-win32-cross.docker     | 139 ++++++++---
 .../dockerfiles/fedora-win64-cross.docker     | 138 +++++++---
 tests/docker/dockerfiles/fedora.docker        | 230 ++++++++---------
 tests/docker/dockerfiles/opensuse-leap.docker |   2 +-
 tests/docker/dockerfiles/ubuntu2004.docker    | 234 ++++++++---------
 tests/lcitool/libvirt-ci                      |   2 +-
 tests/lcitool/refresh                         |  48 ++--
 18 files changed, 1499 insertions(+), 1372 deletions(-)
tests/docker/dockerfiles/alpine.docker +1 -1
index 9b7541261a..a854ae6b78 100644
@@ -119,8 +119,8 @@ RUN apk update && \
     ln -s /usr/bin/ccache /usr/libexec/ccache-wrappers/g++ && \
     ln -s /usr/bin/ccache /usr/libexec/ccache-wrappers/gcc
 
+ENV CCACHE_WRAPPERSDIR "/usr/libexec/ccache-wrappers"
 ENV LANG "en_US.UTF-8"
 ENV MAKE "/usr/bin/make"
 ENV NINJA "/usr/bin/ninja"
 ENV PYTHON "/usr/bin/python3"
-ENV CCACHE_WRAPPERSDIR "/usr/libexec/ccache-wrappers"
tests/docker/dockerfiles/centos8.docker +1 -1
index d89113c0df..1f70d41aeb 100644
@@ -130,8 +130,8 @@ RUN dnf distro-sync -y && \
     ln -s /usr/bin/ccache /usr/libexec/ccache-wrappers/g++ && \
     ln -s /usr/bin/ccache /usr/libexec/ccache-wrappers/gcc
 
+ENV CCACHE_WRAPPERSDIR "/usr/libexec/ccache-wrappers"
 ENV LANG "en_US.UTF-8"
 ENV MAKE "/usr/bin/make"
 ENV NINJA "/usr/bin/ninja"
 ENV PYTHON "/usr/bin/python3"
-ENV CCACHE_WRAPPERSDIR "/usr/libexec/ccache-wrappers"
tests/docker/dockerfiles/debian-amd64-cross.docker +117 -117

255 lines not on this page · raw message

tests/docker/dockerfiles/debian-amd64.docker +118 -118

252 lines not on this page · raw message

tests/docker/dockerfiles/debian-arm64-cross.docker +116 -116

253 lines not on this page · raw message

tests/docker/dockerfiles/debian-armel-cross.docker +115 -115

251 lines not on this page · raw message

tests/docker/dockerfiles/debian-armhf-cross.docker +116 -116

253 lines not on this page · raw message

tests/docker/dockerfiles/debian-mips64el-cross.docker +113 -113

247 lines not on this page · raw message

tests/docker/dockerfiles/debian-mipsel-cross.docker +113 -113

247 lines not on this page · raw message

tests/docker/dockerfiles/debian-ppc64el-cross.docker +115 -115

251 lines not on this page · raw message

tests/docker/dockerfiles/debian-s390x-cross.docker +114 -114

249 lines not on this page · raw message

tests/docker/dockerfiles/fedora-win32-cross.docker +98 -41

144 lines not on this page · raw message

tests/docker/dockerfiles/fedora-win64-cross.docker +99 -39

142 lines not on this page · raw message

tests/docker/dockerfiles/fedora.docker +115 -115

243 lines not on this page · raw message

tests/docker/dockerfiles/opensuse-leap.docker +1 -1
index d80064756f..361979d6b3 100644
@@ -132,8 +132,8 @@ RUN zypper update -y && \
 
 RUN /usr/bin/pip3 install meson==0.56.0
 
+ENV CCACHE_WRAPPERSDIR "/usr/libexec/ccache-wrappers"
 ENV LANG "en_US.UTF-8"
 ENV MAKE "/usr/bin/make"
 ENV NINJA "/usr/bin/ninja"
 ENV PYTHON "/usr/bin/python3"
-ENV CCACHE_WRAPPERSDIR "/usr/libexec/ccache-wrappers"
tests/docker/dockerfiles/ubuntu2004.docker +117 -117

186 lines not on this page · raw message

tests/lcitool/libvirt-ci +1 -1
index e3712b7912..a2633997ff 160000

Lines of this file are not shown. View the raw message.

tests/lcitool/refresh +29 -19

48 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.34.1

Part of the diff is not shown here. View the raw message.

Acked-by on v4 1/30
#2 lore raw

Re: [PATCH v4 01/30] tests/docker: update fedora-win[32|64]-cross with lcitool

Quoted 20 lines · Alex Bennée

Convert another two dockerfiles to lcitool and update. I renamed the helper because it is not Debian specific. We need an updated lcitool for this to deal with the weirdness of a 32bit nsis tool for both 32 and 64 bit builds. As a result there are some minor whitespace and re-order changes in a bunch of the docker files.

Message-Id:<[email protected]>

---
  tests/docker/dockerfiles/alpine.docker        |   2 +-
  tests/docker/dockerfiles/centos8.docker       |   2 +-
  .../dockerfiles/debian-amd64-cross.docker     | 234 ++++++++---------
  tests/docker/dockerfiles/debian-amd64.docker  | 236 +++++++++---------
  .../dockerfiles/debian-arm64-cross.docker     | 232 ++++++++---------
  .../dockerfiles/debian-armel-cross.docker     | 230 ++++++++---------
  .../dockerfiles/debian-armhf-cross.docker     | 232 ++++++++---------
  .../dockerfiles/debian-mips64el-cross.docker  | 226 ++++++++---------
  .../dockerfiles/debian-mipsel-cross.docker    | 226 ++++++++---------
  .../dockerfiles/debian-ppc64el-cross.docker   | 230 ++++++++---------
  .../dockerfiles/debian-s390x-cross.docker     | 228 ++++++++---------
Quoted 8 lines
  .../dockerfiles/fedora-win32-cross.docker     | 139 ++++++++---
  .../dockerfiles/fedora-win64-cross.docker     | 138 +++++++---
  tests/docker/dockerfiles/fedora.docker        | 230 ++++++++---------
  tests/docker/dockerfiles/opensuse-leap.docker |   2 +-
  tests/docker/dockerfiles/ubuntu2004.docker    | 234 ++++++++---------
  tests/lcitool/libvirt-ci                      |   2 +-
  tests/lcitool/refresh                         |  48 ++--
  18 files changed, 1499 insertions(+), 1372 deletions(-)

r~

#3 lore raw

PATCH v4 2/30 tests/docker: update test-mingw to run single build

In reply to Alex Bennée

While the test-build test happily run for mingw the test-mingw case runs more of the packaging inline with what our CI does. It however fails if we don't find both compilers and expects to be run on a docker image with both.

Remove that distinction and make it work more like the other build test scripts.

---
 tests/docker/test-mingw | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)
tests/docker/test-mingw +6 -10
index 0bc6d78872..18366972eb 100755
@@ -13,14 +13,12 @@
 
 . common.rc
 
-requires_binary x86_64-w64-mingw32-gcc
-requires_binary i686-w64-mingw32-gcc
+requires_binary x86_64-w64-mingw32-gcc i686-w64-mingw32-gcc
 
 cd "$BUILD_DIR"
 
-for prefix in x86_64-w64-mingw32- i686-w64-mingw32-; do
-    TARGET_LIST=${TARGET_LIST:-$DEF_TARGET_LIST} \
-        build_qemu --cross-prefix=$prefix \
+TARGET_LIST=${TARGET_LIST:-$DEF_TARGET_LIST} \
+build_qemu \
         --enable-trace-backends=simple \
         --enable-gnutls \
         --enable-nettle \
@@ -29,8 +27,6 @@ for prefix in x86_64-w64-mingw32- i686-w64-mingw32-; do
         --enable-bzip2 \
         --enable-guest-agent \
         --enable-docs
-    install_qemu
-    make installer
-    make clean
-
-done
+install_qemu
+make installer
+make clean
Signature · 1 line
2.34.1
#4 lore raw

PATCH v4 3/30 tests/docker: Add flex/bison to `debian-all-test`

In reply to Alex Bennée

From: Anton Johansson <[email protected]>

Adds flex/bison to the debian-all-test-cross container which was missed in the previous CI patch. These dependencies are required by the idef-parser patchset for target/hexagon.

Message-Id: <[email protected]>

---
 tests/docker/dockerfiles/debian-all-test-cross.docker | 2 ++
 1 file changed, 2 insertions(+)
tests/docker/dockerfiles/debian-all-test-cross.docker +2 -0
index 2beb077fb4..8dc5e1b5de 100644
@@ -20,8 +20,10 @@ RUN export DEBIAN_FRONTEND=noninteractive && \
 # Add extra build tools and as many cross compilers as we can for testing
 RUN DEBIAN_FRONTEND=noninteractive eatmydata \
         apt install -y --no-install-recommends \
+        bison \
         ccache \
         clang  \
+        flex \
         git \
         ninja-build \
         gcc-aarch64-linux-gnu \
Signature · 1 line
2.34.1
#5 lore raw

PATCH v4 4/30 configure: don't enable cross compilers unless in target_list

In reply to Alex Bennée

This avoids the unfortunate effect of always builds the pc-bios blobs for targets the user isn't interested in.

---
 configure | 9 +++++++++
 1 file changed, 9 insertions(+)
configure +9 -0
index 81561be7c1..dd6f58dcde 100755
@@ -1877,6 +1877,15 @@ probe_target_compiler() {
   container_cross_ranlib=
   container_cross_strip=
 
+  # We shall skip configuring the target compiler if the user didn't
+  # bother enabling an appropriate guest. This avoids building
+  # extraneous firmware images and tests.
+  if test "${target_list#*$1}" != "$1"; then
+      break;
+  else
+      return 1
+  fi
+
   target_arch=${1%%-*}
   case $target_arch in
     aarch64) container_hosts="x86_64 aarch64" ;;
Signature · 1 line
2.34.1
#6 lore raw

PATCH v4 5/30 configure: fix the --enable-static --disable-pie case

In reply to Alex Bennée

The previous tweak was incomplete as it missed a leg.

Fixes abafb64b6d (configure: explicitly set cflags for --disable-pie)
---
 configure | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
configure +3 -2
index dd6f58dcde..8c2c4c1a04 100755
@@ -1327,6 +1327,8 @@ static THREAD int tls_var;
 int main(void) { return tls_var; }
 EOF
 
+# Meson currently only handles pie as a boolean for now so if we have
+# explicitly disabled PIE we need to extend our cflags because it wont.
 if test "$static" = "yes"; then
   if test "$pie" != "no" && compile_prog "-Werror -fPIE -DPIE" "-static-pie"; then
     CONFIGURE_CFLAGS="-fPIE -DPIE $CONFIGURE_CFLAGS"
@@ -1335,13 +1337,12 @@ if test "$static" = "yes"; then
     error_exit "-static-pie not available due to missing toolchain support"
   else
     pie="no"
+    QEMU_CFLAGS="-fno-pie -no-pie $QEMU_CFLAGS"
   fi
 elif test "$pie" = "no"; then
   if compile_prog "-Werror -fno-pie" "-no-pie"; then
     CONFIGURE_CFLAGS="-fno-pie $CONFIGURE_CFLAGS"
     CONFIGURE_LDFLAGS="-no-pie $CONFIGURE_LDFLAGS"
-    # Meson currently only handles pie as a boolean for now so if we have
-    # explicitly disabled PIE we need to extend our cflags because it wont.
     QEMU_CFLAGS="-fno-pie -no-pie $QEMU_CFLAGS"
   fi
 elif compile_prog "-Werror -fPIE -DPIE" "-pie"; then
Signature · 1 line
2.34.1
#7 lore raw

PATCH v4 6/30 tests/avocado: extend the timeout for x86_64 tcg tests

In reply to Alex Bennée

These are timing out on gitlab.

---
 tests/avocado/boot_linux.py | 1 +
 1 file changed, 1 insertion(+)
tests/avocado/boot_linux.py +1 -0
index b7522ad3a1..571d33882a 100644
@@ -19,6 +19,7 @@ class BootLinuxX8664(LinuxTest):
     """
     :avocado: tags=arch:x86_64
     """
+    timeout = 480
 
     def test_pc_i440fx_tcg(self):
         """
Signature · 1 line
2.34.1
#8 lore raw

PATCH v4 7/30 tests/docker: Add flex/bison to `debian-hexagon-cross`

In reply to Alex Bennée

From: Anton Johansson <[email protected]>

debian-hexagon-cross contains two images, one to build the toolchain used for building the Hexagon tests themselves, and one image to build QEMU and run the tests.

This commit adds flex/bison to the final image that builds QEMU so that it can also build idef-parser.

Note: This container is not built by the CI and needs to be rebuilt and updated manually.

Message-Id: <[email protected]>

---
 tests/docker/dockerfiles/debian-hexagon-cross.docker | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/docker/dockerfiles/debian-hexagon-cross.docker +1 -1
index 8d219bb81d..c4238e893f 100644
@@ -43,7 +43,7 @@ RUN cat /etc/apt/sources.list | sed "s/^deb\ /deb-src /" >> /etc/apt/sources.lis
 # Install QEMU build deps for use in CI
 RUN apt update && \
     DEBIAN_FRONTEND=noninteractive apt install -yy eatmydata && \
-    DEBIAN_FRONTEND=noninteractive eatmydata apt install -yy git ninja-build && \
+    DEBIAN_FRONTEND=noninteractive eatmydata apt install -yy bison flex git ninja-build && \
     DEBIAN_FRONTEND=noninteractive eatmydata \
     apt build-dep -yy --arch-only qemu
 COPY --from=0 /usr/local /usr/local
Signature · 1 line
2.34.1
#9 lore raw

PATCH v4 8/30 tests/tcg: use regular semihosting for nios2-softmmu

In reply to Alex Bennée

The nios2 code now plugs into the common semihosting code so we can use the same redirect invocation as the other boards. There is however a bug raised for the fact the tests don't seem to be completing properly and silently passing anyway:

https://gitlab.com/qemu-project/qemu/-/issues/1258

---
 tests/tcg/nios2/Makefile.softmmu-target | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
tests/tcg/nios2/Makefile.softmmu-target +1 -2
index c3d0594a39..bc7fd55060 100644
@@ -25,8 +25,7 @@ LDFLAGS += -Wl,-T$(LINK_SCRIPT) -static -nostdlib $(CRT_OBJS) -lgcc
 %: %.o $(LINK_SCRIPT) $(CRT_OBJS)
 	$(call quiet-command, $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $< -o $@ $(LDFLAGS), LD, $@)
 
-# FIXME: nios2 semihosting writes to stdout, not a chardev
-QEMU_OPTS = -M 10m50-ghrd,vic=on -semihosting >[email protected] -kernel
+QEMU_OPTS = -M 10m50-ghrd,vic=on -semihosting-config enable=on,target=native,chardev=output -kernel
 
 memory: CFLAGS+=-DCHECK_UNALIGNED=0
 TESTS += $(MULTIARCH_TESTS)
Signature · 1 line
2.34.1
#10 lore raw

PATCH v4 9/30 tests/tcg/nios2: Tweak 10m50-ghrd.ld

In reply to Alex Bennée

From: Richard Henderson <[email protected]>

More closely follow the default linker script for nios2. This magically fixes a problem resolving .got relocs from the toolchain's libgcc.a.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1258

Message-Id: <[email protected]>

---
 tests/tcg/nios2/10m50-ghrd.ld | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
tests/tcg/nios2/10m50-ghrd.ld +9 -5
index 7db0d59ad7..71cdda450c 100644
@@ -44,11 +44,15 @@ SECTIONS
     .data : ALIGN(4) {
         *(.shdata)
         *(.data .data.* .gnu.linkonce.d.*)
-        . = ALIGN(4);
-        _gp = ABSOLUTE(. + 0x8000);
-        *(.got.plt) *(.got)
-        *(.lit8)
-        *(.lit4)
+    } >ram :RAM
+
+    HIDDEN (_gp = ALIGN(16) + 0x7ff0);
+    PROVIDE_HIDDEN (gp = _gp);
+    .got : ALIGN(4) {
+        *(.got.plt) *(.igot.plt) *(.got) *(.igot)
+    } >ram :RAM
+
+    .sdata : ALIGN(4) {
         *(.sdata .sdata.* .gnu.linkonce.s.*)
     } >ram :RAM
 
Signature · 1 line
2.34.1
#11 lore raw

PATCH v4 10/30 semihosting/arm-compat-semi: Avoid using hardcoded /tmp

In reply to Alex Bennée

From: Bin Meng <[email protected]>

Use g_get_tmp_dir() to get the directory to use for temporary files.

Message-Id: <[email protected]>

---
 semihosting/arm-compat-semi.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
semihosting/arm-compat-semi.c +2 -1
index bfea9e9337..62d8bae97f 100644
@@ -503,7 +503,8 @@ void do_common_semihosting(CPUState *cs)
         GET_ARG(0);
         GET_ARG(1);
         GET_ARG(2);
-        len = asprintf(&s, "/tmp/qemu-%x%02x", getpid(), (int)arg1 & 0xff);
+        len = asprintf(&s, "%s/qemu-%x%02x", g_get_tmp_dir(),
+                       getpid(), (int)arg1 & 0xff);
         if (len < 0) {
             common_semi_set_ret(cs, -1);
             break;
Signature · 1 line
2.34.1
#12 lore raw

PATCH v4 11/30 tcg: Avoid using hardcoded /tmp

In reply to Alex Bennée

From: Bin Meng <[email protected]>

Use g_get_tmp_dir() to get the directory to use for temporary files.

Message-Id: <[email protected]>

---
 tcg/tcg.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
tcg/tcg.c +2 -1
index 612a12f58f..84921b64f7 100644
@@ -4729,7 +4729,8 @@ static void tcg_register_jit_int(const void *buf_ptr, size_t buf_size,
     /* Enable this block to be able to debug the ELF image file creation.
        One can use readelf, objdump, or other inspection utilities.  */
     {
-        FILE *f = fopen("/tmp/qemu.jit", "w+b");
+        g_autofree char *jit = g_strdup_printf("%s/qemu.jit", g_get_tmp_dir());
+        FILE *f = fopen(jit, "w+b");
         if (f) {
             if (fwrite(img, img_size, 1, f) != img_size) {
                 /* Avoid stupid unused return value warning for fwrite.  */
Signature · 1 line
2.34.1
#13 lore raw

PATCH v4 12/30 util/qemu-sockets: Use g_get_tmp_dir() to get the directory for temporary files

In reply to Alex Bennée

From: Bin Meng <[email protected]>

Replace the existing logic to get the directory for temporary files with g_get_tmp_dir(), which works for win32 too.

Message-Id: <[email protected]>

---
 util/qemu-sockets.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
util/qemu-sockets.c +2 -3
index 83f4bd6fd2..0c41ca9e42 100644
@@ -919,9 +919,8 @@ static int unix_listen_saddr(UnixSocketAddress *saddr,
     if (saddr->path[0] || abstract) {
         path = saddr->path;
     } else {
-        const char *tmpdir = getenv("TMPDIR");
-        tmpdir = tmpdir ? tmpdir : "/tmp";
-        path = pathbuf = g_strdup_printf("%s/qemu-socket-XXXXXX", tmpdir);
+        path = pathbuf = g_strdup_printf("%s/qemu-socket-XXXXXX",
+                                         g_get_tmp_dir());
     }
 
     pathlen = strlen(path);
Signature · 1 line
2.34.1
#14 lore raw

PATCH v4 13/30 block/vvfat: Unify the mkdir() call

In reply to Alex Bennée

From: Bin Meng <[email protected]>

There is a difference in the mkdir() call for win32 and non-win32 platforms, and currently is handled in the codes with #ifdefs.

glib provides a portable g_mkdir() API and we can use it to unify the codes without #ifdefs.

Message-Id: <[email protected]>

---
 block/vvfat.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
block/vvfat.c +3 -6
index d6dd919683..723beef025 100644
@@ -25,6 +25,7 @@
 
 #include "qemu/osdep.h"
 #include <dirent.h>
+#include <glib/gstdio.h>
 #include "qapi/error.h"
 #include "block/block_int.h"
 #include "block/qdict.h"
@@ -2726,13 +2727,9 @@ static int handle_renames_and_mkdirs(BDRVVVFATState* s)
             mapping_t* mapping;
             int j, parent_path_len;
 
-#ifdef __MINGW32__
-            if (mkdir(commit->path))
+            if (g_mkdir(commit->path, 0755)) {
                 return -5;
-#else
-            if (mkdir(commit->path, 0755))
-                return -5;
-#endif
+            }
 
             mapping = insert_mapping(s, commit->param.mkdir.cluster,
                     commit->param.mkdir.cluster + 1);
Signature · 1 line
2.34.1
#15 lore raw

PATCH v4 14/30 hw/usb: dev-mtp: Use g_mkdir()

In reply to Alex Bennée

From: Bin Meng <[email protected]>

Use g_mkdir() to create a directory on all platforms.

Message-Id: <[email protected]>

---
 hw/usb/dev-mtp.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
hw/usb/dev-mtp.c +2 -2
index 5831395cef..1cac1cd435 100644
@@ -14,7 +14,7 @@
 #include "qemu/error-report.h"
 #include <wchar.h>
 #include <dirent.h>
-
+#include <glib/gstdio.h>
 #include <sys/statvfs.h>
 
 
@@ -1622,7 +1622,7 @@ static void usb_mtp_write_data(MTPState *s, uint32_t handle)
         if (s->dataset.filename) {
             path = g_strdup_printf("%s/%s", parent->path, s->dataset.filename);
             if (s->dataset.format == FMT_ASSOCIATION) {
-                ret = mkdir(path, mask);
+                ret = g_mkdir(path, mask);
                 if (!ret) {
                     usb_mtp_queue_result(s, RES_OK, d->trans, 3,
                                          QEMU_STORAGE_ID,
Signature · 1 line
2.34.1
#16 lore raw

PATCH v4 15/30 MAINTAINERS: add entries for the key build bits

In reply to Alex Bennée

Changes to the build files are a bit special in that they usually go through other maintainer trees. However considering the build system is the root of everything a developer is likely to do we should at least set it out in MAINTAINERS.

I'm going to nominate Paolo for meson stuff given the conversion was his passion project. I'm happy to cast an eye over configure stuff considering a lot of the cross compile logic is in there anyway.

---
v2
- s/Odd Fixes/Maintained/
- nominate more reviewers
v3
- moved nsis.py to win build section
- moved entitlement.sh to Darwin section
- added Thomas as another reviewer
- a-b tag

---
 MAINTAINERS | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
MAINTAINERS +25 -0
index 32e495e165..f72f02d661 100644
@@ -548,12 +548,14 @@ F: */*win32*
 F: include/*/*win32*
 X: qga/*win32*
 F: qemu.nsi
+F: scripts/nsis.py
 
 Darwin (macOS, iOS)
 M: Philippe Mathieu-Daudé <[email protected]>
 S: Odd Fixes
 F: .gitlab-ci.d/cirrus/macos-*
 F: */*.m
+F: scripts/entitlement.sh
 
 Alpha Machines
 --------------
@@ -3764,6 +3766,29 @@ F: docs/about/deprecated.rst
 
 Build System
 ------------
+Meson
+M: Paolo Bonzini <[email protected]>
+R: Marc-André Lureau <[email protected]>
+R: Daniel P. Berrange <[email protected]>
+R: Thomas Huth <[email protected]>
+R: Philippe Mathieu-Daudé <[email protected]>
+S: Maintained
+F: meson.build
+F: meson_options.txt
+F: scripts/meson-buildoptions.*
+F: scripts/check_sparse.py
+F: scripts/symlink-install-tree.py
+
+Top Level Makefile and configure
+M: Paolo Bonzini <[email protected]>
+R: Alex Bennée <[email protected]>
+R: Thomas Huth <[email protected]>
+S: Maintained
+F: Makefile
+F: configure
+F: scripts/mtest2make.py
+F: tests/Makefile.include
+
 GIT submodules
 M: Daniel P. Berrange <[email protected]>
 S: Odd Fixes
Signature · 1 line
2.34.1
#17 lore raw

PATCH v4 16/30 MAINTAINERS: add features_to_c.sh to gdbstub files

In reply to Alex Bennée
---
 MAINTAINERS | 1 +
 1 file changed, 1 insertion(+)
MAINTAINERS +1 -0
index f72f02d661..f0a6a588e8 100644
@@ -2695,6 +2695,7 @@ F: gdbstub/*
 F: include/exec/gdbstub.h
 F: gdb-xml/
 F: tests/tcg/multiarch/gdbstub/
+F: scripts/feature_to_c.sh
 
 Memory API
 M: Paolo Bonzini <[email protected]>
Signature · 1 line
2.34.1
#18 lore raw

PATCH v4 17/30 MAINTAINERS: fix-up for check-tcg Makefile changes

In reply to Alex Bennée
Fixes fc76c56d3f ("tests/tcg: cleanup Makefile inclusions")
---
 MAINTAINERS | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
MAINTAINERS +1 -2
index f0a6a588e8..3f353b56a7 100644
@@ -3729,8 +3729,7 @@ Guest Test Compilation Support
 M: Alex Bennée <[email protected]>
 R: Philippe Mathieu-Daudé <[email protected]>
 S: Maintained
-F: tests/tcg/Makefile
-F: tests/tcg/Makefile.include
+F: tests/tcg/Makefile.target
 
 Integration Testing with the Avocado framework
 W: https://trello.com/b/6Qi1pxVn/avocado-qemu
Signature · 1 line
2.34.1
#19 lore raw

PATCH v4 18/30 tests/avocado: set -machine none for userfwd and vnc tests

In reply to Alex Bennée

These are exercising core QEMU features and don't actually run code. Not specifying a machine will fail when avocado chooses the native arch binary to run. Be explicit.

---
 tests/avocado/info_usernet.py | 3 +++
 tests/avocado/vnc.py          | 1 +
 2 files changed, 4 insertions(+)
tests/avocado/info_usernet.py +3 -0
index b862a47dba..fdc4d90c42 100644
@@ -14,6 +14,9 @@
 
 
 class InfoUsernet(QemuSystemTest):
+    """
+    :avocado: tags=machine:none
+    """
 
     def test_hostfwd(self):
         self.require_netdev('user')
tests/avocado/vnc.py +1 -0
index 187fd3febc..aeeefc70be 100644
@@ -53,6 +53,7 @@ def find_free_ports(count: int) -> List[int]:
 class Vnc(QemuSystemTest):
     """
     :avocado: tags=vnc,quick
+    :avocado: tags=machine:none
     """
     def test_no_vnc(self):
         self.vm.add_args('-nodefaults', '-S')
Signature · 1 line
2.34.1
#20 lore raw

PATCH v4 19/30 tests/avocado: raspi2_initrd: Wait for guest shutdown message before stopping

In reply to Alex Bennée

From: Peter Maydell <[email protected]>

The avocado test
tests/avocado/boot_linux_console.py:BootLinuxConsole.test_arm_raspi2_initrd
finishes with

exec_command(self, 'halt')
# Wait for VM to shut down gracefully
self.vm.wait()

In theory this should be fine. In practice it runs into two bugs:

* when the test calls self.vm.wait() Avocado closes the socket connection to the guest serial console immediately, so the avocado logs don't have the last part of the guest output:
https://gitlab.com/qemu-project/qemu/-/issues/1265
* when the socket is closed, a bug in the QEMU socket chardev means that it loses any data that the guest UART has not yet consumed. This means that the guest doesn't always read the full 'halt' command string, so the test intermittently fails with a timeout:
https://gitlab.com/qemu-project/qemu/-/issues/1264

Work around both of these by waiting for the guest to print the string that means it has completed the shutdown process. This fixes a very long standing intermittent failure in this test.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/636

Message-Id: <[email protected]>

---
 tests/avocado/boot_linux_console.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/avocado/boot_linux_console.py +1 -1
index ca9d09b0d7..eed4b49e6e 100644
@@ -489,7 +489,7 @@ def test_arm_raspi2_initrd(self):
                                                 'BCM2835')
         exec_command_and_wait_for_pattern(self, 'cat /proc/iomem',
                                                 '/soc/cprman@7e101000')
-        exec_command(self, 'halt')
+        exec_command_and_wait_for_pattern(self, 'halt', 'reboot: System halted')
         # Wait for VM to shut down gracefully
         self.vm.wait()
 
Signature · 1 line
2.34.1
#21 lore raw

PATCH v4 20/30 tests/avocado: disable sh4 rd2 tests on Gitlab

In reply to Alex Bennée

Running repeated invocations on a number of test boxes show a fairly high error rate:

  $ retry.py -n 100 -c -- ./tests/venv/bin/avocado run tests/avocado/boot_linux_console.py:BootLinuxConsole.test_sh4_r2d
  retry.py called with ['./tests/venv/bin/avocado', 'run', 'tests/avocado/boot_linux_console.py:BootLinuxConsole.test_sh4_r2d']
  Results:
  Run, Ret, Pass/Fail, Time, Total Pass, Total Run
  ...
  Results summary:
  0: 94 times (94.00%), avg time 2.254 (0.00 varience/0.04 deviation)
  1: 3 times (3.00%), avg time 1.837 (0.02 varience/0.14 deviation)
  8: 3 times (3.00%), avg time 91.288 (0.02 varience/0.15 deviation)

Examining the logs they fall into various categories of un-handled unaligned access by user space and unexpected FPU usage by the kernel which ultimately lead to the failure to reach the login prompt. This could be bugs in the translator that only get hit occasionally or just a flaky kernel - its hard to tell. To avoid these failures gating CI lets skip on GitLab.

---
v2
- add import for skipIf

---
 tests/avocado/boot_linux_console.py | 5 +++++
 1 file changed, 5 insertions(+)
tests/avocado/boot_linux_console.py +5 -0
index eed4b49e6e..4c9d551f47 100644
@@ -15,6 +15,7 @@
 
 from avocado import skip
 from avocado import skipUnless
+from avocado import skipIf
 from avocado_qemu import QemuSystemTest
 from avocado_qemu import exec_command
 from avocado_qemu import exec_command_and_wait_for_pattern
@@ -1175,6 +1176,10 @@ def test_ppc_mac99(self):
         self.vm.add_args('-M', 'graphics=off')
         self.do_test_advcal_2018('15', tar_hash, 'invaders.elf')
 
+    # This test has a 6-10% failure rate on various hosts that look
+    # like issues with a buggy kernel. As a result we don't want it
+    # gating releases on Gitlab.
+    @skipIf(os.getenv('GITLAB_CI'), 'Running on GitLab')
     def test_sh4_r2d(self):
         """
         :avocado: tags=arch:sh4
Signature · 1 line
2.34.1
#22 lore raw

PATCH v4 21/30 tests/tcg: re-enable linux-test for sh4

In reply to Alex Bennée

This test was marked as broken due to bug #704 which was fixed by aee14c77f4 (linux-user: Rewrite do_getdents, do_getdents64). Local testing shows this is solid now so lets re-enable the test.

---
 tests/tcg/sh4/Makefile.target | 6 ------
 1 file changed, 6 deletions(-)
tests/tcg/sh4/Makefile.target +0 -6
index 35ebe6b4e3..32b019bdf1 100644
@@ -13,12 +13,6 @@ run-signals: signals
 run-plugin-signals-with-%:
 	$(call skip-test, $<, "BROKEN")
 
-# This test is currently broken: https://gitlab.com/qemu-project/qemu/-/issues/704
-run-linux-test: linux-test
-	$(call skip-test, $<, "BROKEN")
-run-plugin-linux-test-with-%:
-	$(call skip-test, $<, "BROKEN")
-
 # This test is currently unreliable: https://gitlab.com/qemu-project/qemu/-/issues/856
 run-threadcount:
 	$(call skip-test, $<, "BROKEN")
Signature · 1 line
2.34.1
#23 lore raw

PATCH v4 22/30 tests/tcg: re-enable threadcount for sh4

In reply to Alex Bennée

This test was marked as broken due to bug #856 which was fixed by ab419fd8a0 (target/sh4: Fix TB_FLAG_UNALIGN). Local testing shows this is solid now so lets re-enable the test.

---
 tests/tcg/sh4/Makefile.target | 6 ------
 1 file changed, 6 deletions(-)
tests/tcg/sh4/Makefile.target +0 -6
index 32b019bdf1..47c39a44b6 100644
@@ -12,9 +12,3 @@ run-signals: signals
 	$(call skip-test, $<, "BROKEN")
 run-plugin-signals-with-%:
 	$(call skip-test, $<, "BROKEN")
-
-# This test is currently unreliable: https://gitlab.com/qemu-project/qemu/-/issues/856
-run-threadcount:
-	$(call skip-test, $<, "BROKEN")
-run-plugin-threadcount-with-%:
-	$(call skip-test, $<, "BROKEN")
Signature · 1 line
2.34.1
#24 lore raw

PATCH v4 23/30 target/s390x: don't use ld_code2 to probe next pc

In reply to Alex Bennée

This isn't an translator picking up an instruction so we shouldn't use the translator_lduw function which has side effects for plugins.

---
 target/s390x/tcg/translate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target/s390x/tcg/translate.c +1 -1
index 5798928473..9df7f9e693 100644
@@ -6612,7 +6612,7 @@ static void s390x_tr_insn_start(DisasContextBase *dcbase, CPUState *cs)
 static target_ulong get_next_pc(CPUS390XState *env, DisasContext *s,
                                 uint64_t pc)
 {
-    uint64_t insn = ld_code2(env, s, pc);
+    uint64_t insn = cpu_lduw_code(env, pc);
 
     return pc + get_ilen((insn >> 8) & 0xff);
 }
Signature · 1 line
2.34.1
#25 lore raw

PATCH v4 24/30 target/s390x: don't probe next pc for EXecuted insns

In reply to Alex Bennée

We have finished the TB anyway so we can shortcut the other tests by checking dc->ex_value first.

---
 target/s390x/tcg/translate.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
target/s390x/tcg/translate.c +3 -3
index 9df7f9e693..f4122db434 100644
@@ -6624,9 +6624,9 @@ static void s390x_tr_translate_insn(DisasContextBase *dcbase, CPUState *cs)
 
     dc->base.is_jmp = translate_one(env, dc);
     if (dc->base.is_jmp == DISAS_NEXT) {
-        if (!is_same_page(dcbase, dc->base.pc_next) ||
-            !is_same_page(dcbase, get_next_pc(env, dc, dc->base.pc_next)) ||
-            dc->ex_value) {
+        if (dc->ex_value ||
+            !is_same_page(dcbase, dc->base.pc_next) ||
+            !is_same_page(dcbase, get_next_pc(env, dc, dc->base.pc_next))) {
             dc->base.is_jmp = DISAS_TOO_MANY;
         }
     }
Signature · 1 line
2.34.1
#26 lore raw

PATCH v4 25/30 target/s390x: fake instruction loading when handling 'ex'

In reply to Alex Bennée

The s390x EXecute instruction is a bit weird as we synthesis the executed instruction from what we have stored in memory. This missed the plugin instrumentation.

Work around this with a special helper to inform the rest of the translator about the instruction so things stay consistent.

---
v2
- s/w/b/ for translator_fake_ldb
- add comment to extract_insn
- reword commit message

---
 include/exec/translator.h    | 17 +++++++++++++++++
 target/s390x/tcg/translate.c |  6 ++++++
 2 files changed, 23 insertions(+)
include/exec/translator.h +17 -0
index 3b77f5f4aa..af2ff95cd5 100644
@@ -211,6 +211,23 @@ translator_ldq_swap(CPUArchState *env, DisasContextBase *db,
     return ret;
 }
 
+/**
+ * translator_fake_ldb - fake instruction load
+ * @insn8: byte of instruction
+ * @pc: program counter of instruction
+ *
+ * This is a special case helper used where the instruction we are
+ * about to translate comes from somewhere else (e.g. being
+ * re-synthesised for s390x "ex"). It ensures we update other areas of
+ * the translator with details of the executed instruction.
+ */
+
+static inline void translator_fake_ldb(uint8_t insn8, abi_ptr pc)
+{
+    plugin_insn_append(pc, &insn8, sizeof(insn8));
+}
+
+
 /*
  * Return whether addr is on the same page as where disassembly started.
  * Translators can use this to enforce the rule that only single-insn
target/s390x/tcg/translate.c +6 -0
index f4122db434..03efccdf9f 100644
@@ -6317,12 +6317,18 @@ static const DisasInsn *extract_insn(CPUS390XState *env, DisasContext *s)
     if (unlikely(s->ex_value)) {
         /* Drop the EX data now, so that it's clear on exception paths.  */
         TCGv_i64 zero = tcg_const_i64(0);
+        int i;
         tcg_gen_st_i64(zero, cpu_env, offsetof(CPUS390XState, ex_value));
         tcg_temp_free_i64(zero);
 
         /* Extract the values saved by EXECUTE.  */
         insn = s->ex_value & 0xffffffffffff0000ull;
         ilen = s->ex_value & 0xf;
+        /* register insn bytes with translator so plugins work */
+        for (i = 0; i < ilen; i++) {
+            uint8_t byte = extract64(insn, 56 - (i * 8), 8);
+            translator_fake_ldb(byte, pc + i);
+        }
         op = insn >> 56;
     } else {
         insn = ld_code2(env, s, pc);
Signature · 1 line
2.34.1
#27 lore raw

PATCH v4 26/30 tests/tcg: include CONFIG_PLUGIN in config-host.mak

In reply to Alex Bennée

From: Paolo Bonzini <[email protected]>

Message-Id: <[email protected]>

---
 configure | 3 +++
 1 file changed, 3 insertions(+)
configure +3 -0
index 8c2c4c1a04..4275f5419f 100755
@@ -2486,6 +2486,9 @@ echo "HOST_CC=$host_cc" >> $config_host_mak
 if test -n "$gdb_bin"; then
     echo "HAVE_GDB_BIN=$gdb_bin" >> $config_host_mak
 fi
+if test "$plugins" = "yes" ; then
+    echo "CONFIG_PLUGIN=y" >> $config_host_mak
+fi
 
 tcg_tests_targets=
 for target in $target_list; do
Signature · 1 line
2.34.1
#28 lore raw

PATCH v4 27/30 contrib/plugins: enable debug on CONFIG_DEBUG_TCG

In reply to Alex Bennée

We used to rely on QEMU_CFLAGS to expose the debug flags but now this is synthesised by meson and only available to the main build. Add our own flags if we detect the build has been enabled with CONFIG_DEBUG_TCG (which is the default for --enable-debug anyway).

---
 contrib/plugins/Makefile | 1 +
 1 file changed, 1 insertion(+)
contrib/plugins/Makefile +1 -0
index df3499f4f2..23e0396687 100644
@@ -29,6 +29,7 @@ SONAMES := $(addsuffix .so,$(addprefix lib,$(NAMES)))
 CFLAGS = $(GLIB_CFLAGS)
 CFLAGS += -fPIC -Wall $(filter -W%, $(QEMU_CFLAGS))
 CFLAGS += $(if $(findstring no-psabi,$(QEMU_CFLAGS)),-Wpsabi)
+CFLAGS += $(if $(CONFIG_DEBUG_TCG), -ggdb -O0)
 CFLAGS += -I$(SRC_PATH)/include/qemu
 
 all: $(SONAMES)
Signature · 1 line
2.34.1
#29 lore raw

PATCH v4 28/30 contrib/plugins: protect execlog's last_exec expansion

In reply to Alex Bennée

We originally naively treated expansion as safe because we expected each new CPU/thread to appear in order. However the -M raspi2 model triggered a case where a new high cpu_index thread started executing just before a smaller one.

Clean this up by converting the GArray into the simpler GPtrArray and then holding a lock for the expansion.

Cc Alexandre Iooss <[email protected]>
---
 contrib/plugins/execlog.c | 38 ++++++++++++++++++++++++++++++--------
 1 file changed, 30 insertions(+), 8 deletions(-)
contrib/plugins/execlog.c +30 -8
index 1b3bb7ebba..e255bd21fd 100644
@@ -18,11 +18,30 @@
 QEMU_PLUGIN_EXPORT int qemu_plugin_version = QEMU_PLUGIN_VERSION;
 
 /* Store last executed instruction on each vCPU as a GString */
-GArray *last_exec;
+static GPtrArray *last_exec;
+static GMutex expand_array_lock;
 
 static GPtrArray *imatches;
 static GArray *amatches;
 
+/*
+ * Expand last_exec array.
+ *
+ * As we could have multiple threads trying to do this we need to
+ * serialise the expansion under a lock. Threads accessing already
+ * created entries can continue without issue even if the ptr array
+ * gets reallocated during resize.
+ */
+static void expand_last_exec(int cpu_index)
+{
+    g_mutex_lock(&expand_array_lock);
+    while (cpu_index >= last_exec->len) {
+        GString *s = g_string_new(NULL);
+        g_ptr_array_add(last_exec, s);
+    }
+    g_mutex_unlock(&expand_array_lock);
+}
+
 /**
  * Add memory read or write information to current instruction log
  */
@@ -33,7 +52,7 @@ static void vcpu_mem(unsigned int cpu_index, qemu_plugin_meminfo_t info,
 
     /* Find vCPU in array */
     g_assert(cpu_index < last_exec->len);
-    s = g_array_index(last_exec, GString *, cpu_index);
+    s = g_ptr_array_index(last_exec, cpu_index);
 
     /* Indicate type of memory access */
     if (qemu_plugin_mem_is_store(info)) {
@@ -61,11 +80,10 @@ static void vcpu_insn_exec(unsigned int cpu_index, void *udata)
     GString *s;
 
     /* Find or create vCPU in array */
-    while (cpu_index >= last_exec->len) {
-        s = g_string_new(NULL);
-        g_array_append_val(last_exec, s);
+    if (cpu_index >= last_exec->len) {
+        expand_last_exec(cpu_index);
     }
-    s = g_array_index(last_exec, GString *, cpu_index);
+    s = g_ptr_array_index(last_exec, cpu_index);
 
     /* Print previous instruction in cache */
     if (s->len) {
@@ -163,7 +181,7 @@ static void plugin_exit(qemu_plugin_id_t id, void *p)
     guint i;
     GString *s;
     for (i = 0; i < last_exec->len; i++) {
-        s = g_array_index(last_exec, GString *, i);
+        s = g_ptr_array_index(last_exec, i);
         if (s->str) {
             qemu_plugin_outs(s->str);
             qemu_plugin_outs("\n");
@@ -201,7 +219,11 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id,
      * Initialize dynamic array to cache vCPU instruction. In user mode
      * we don't know the size before emulation.
      */
-    last_exec = g_array_new(FALSE, FALSE, sizeof(GString *));
+    if (info->system_emulation) {
+        last_exec = g_ptr_array_sized_new(info->system.max_vcpus);
+    } else {
+        last_exec = g_ptr_array_new();
+    }
 
     for (int i = 0; i < argc; i++) {
         char *opt = argv[i];
Signature · 1 line
2.34.1
Reviewed-by on v4 28/30
#30 lore raw

Re: [PATCH v4 28/30] contrib/plugins: protect execlog's last_exec expansion

Quoted 5 lines · Alex Bennée

We originally naively treated expansion as safe because we expected each new CPU/thread to appear in order. However the -M raspi2 model triggered a case where a new high cpu_index thread started executing just before a smaller one.

Quoted 8 lines

Clean this up by converting the GArray into the simpler GPtrArray and then holding a lock for the expansion.

Cc Alexandre Iooss<[email protected]>
---
  contrib/plugins/execlog.c | 38 ++++++++++++++++++++++++++++++--------
  1 file changed, 30 insertions(+), 8 deletions(-)

r~

#31 lore raw

PATCH v4 29/30 tests/unit: cleanups for test-io-channel-command

In reply to Alex Bennée

This test is hanging under heavy load when the two socats race while trying to create the socket. I've tried various approaches to avoid the race but it seems "creat=0" won't stop socat trying to create a pipe if it executes first. In the end I just use a small sleep which seems to be reliable enough on the load situations I've tried.

While I was there I also properly created a tmpdir for the socket to live in which is cleaned up at the end of the test.

Cc Thomas Huth <[email protected]>
Cc Daniel P. Berrangé <[email protected]>
Cc Marc-André Lureau <[email protected]>
Cc Juan Quintela <[email protected]>
---
 tests/unit/test-io-channel-command.c | 45 +++++++++++++++++-----------
 1 file changed, 28 insertions(+), 17 deletions(-)
tests/unit/test-io-channel-command.c +28 -17
index 7eee939c07..54bb0f139a 100644
@@ -19,6 +19,7 @@
  */
 
 #include "qemu/osdep.h"
+#include <glib/gstdio.h>
 #include "io/channel-command.h"
 #include "io-channel-helpers.h"
 #include "qapi/error.h"
@@ -26,32 +27,32 @@
 
 #define TEST_FIFO "test-io-channel-command.fifo"
 
-#define SOCAT_SRC "PIPE:" TEST_FIFO ",wronly"
-#define SOCAT_DST "PIPE:" TEST_FIFO ",rdonly"
-
 static char *socat = NULL;
 
 static void test_io_channel_command_fifo(bool async)
 {
+    g_autofree gchar *tmpdir = g_dir_make_tmp("qemu-test-io-channel.XXXXXX", NULL);
+    g_autofree gchar *fifo = g_strdup_printf("%s/%s", tmpdir, TEST_FIFO);
+    g_autoptr(GString) srcargs = g_string_new(socat);
+    g_autoptr(GString) dstargs = g_string_new(socat);
+    g_auto(GStrv) srcargv;
+    g_auto(GStrv) dstargv;
     QIOChannel *src, *dst;
     QIOChannelTest *test;
-    const char *srcargv[] = {
-        socat, "-", SOCAT_SRC, NULL,
-    };
-    const char *dstargv[] = {
-        socat, SOCAT_DST, "-", NULL,
-    };
 
-    if (!socat) {
-        g_test_skip("socat is not found in PATH");
-        return;
-    }
+    g_string_append_printf(srcargs, " - PIPE:%s,wronly", fifo);
+    g_string_append_printf(dstargs, " PIPE:%s,rdonly -", fifo);
+
+    srcargv = g_strsplit(srcargs->str, " ", -1);
+    dstargv = g_strsplit(dstargs->str, " ", -1);
 
-    unlink(TEST_FIFO);
-    src = QIO_CHANNEL(qio_channel_command_new_spawn(srcargv,
+    src = QIO_CHANNEL(qio_channel_command_new_spawn((const char**) srcargv,
                                                     O_WRONLY,
                                                     &error_abort));
-    dst = QIO_CHANNEL(qio_channel_command_new_spawn(dstargv,
+    /* try to avoid a race to create the socket */
+    g_usleep(1000);
+
+    dst = QIO_CHANNEL(qio_channel_command_new_spawn((const char**) dstargv,
                                                     O_RDONLY,
                                                     &error_abort));
 
@@ -62,17 +63,27 @@ static void test_io_channel_command_fifo(bool async)
     object_unref(OBJECT(src));
     object_unref(OBJECT(dst));
 
-    unlink(TEST_FIFO);
+    g_rmdir(tmpdir);
 }
 
 
 static void test_io_channel_command_fifo_async(void)
 {
+    if (!socat) {
+        g_test_skip("socat is not found in PATH");
+        return;
+    }
+
     test_io_channel_command_fifo(true);
 }
 
 static void test_io_channel_command_fifo_sync(void)
 {
+    if (!socat) {
+        g_test_skip("socat is not found in PATH");
+        return;
+    }
+
     test_io_channel_command_fifo(false);
 }
 
Signature · 1 line
2.34.1
Reviewed-by on v4 29/30
#32 lore raw

Re: [PATCH v4 29/30] tests/unit: cleanups for test-io-channel-command

Quoted 9 lines · Alex Bennée

This test is hanging under heavy load when the two socats race while trying to create the socket. I've tried various approaches to avoid the race but it seems "creat=0" won't stop socat trying to create a pipe if it executes first. In the end I just use a small sleep which seems to be reliable enough on the load situations I've tried.

While I was there I also properly created a tmpdir for the socket to live in which is cleaned up at the end of the test.

Quoted 8 lines
Cc Thomas Huth <[email protected]>
Cc Daniel P. Berrangé <[email protected]>
Cc Marc-André Lureau <[email protected]>
Cc Juan Quintela <[email protected]>
---
 tests/unit/test-io-channel-command.c | 45 +++++++++++++++++-----------
 1 file changed, 28 insertions(+), 17 deletions(-)

We should figure out a better fix eventually, but this hack at least ought to avoid the issue for most cases, so worth it as a temp fix.

If I'm nitpicking, I would have preferred the refactoring to be done separately from the addition of tmpdir, and especially separately from the sleep, so we can just revert the sleep patch later.

With regards,
Daniel

Signature · 3 lines
|: 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 :|
#33 lore raw

PATCH v4 30/30 tests/vm: use -o IdentitiesOnly=yes for ssh

In reply to Alex Bennée

From: Ilya Leoshkevich <[email protected]>

When one has a lot of keys in ~/.ssh directory, the ssh command will try all of them before the one specified on the command line, and this may cause the remote ssh server to reject the connection due to too many failed authentication attempts.

Fix by adding -o IdentitiesOnly=yes, which makes the ssh client consider only the keys specified on the command line.

Message-Id: <[email protected]>

---
 tests/vm/basevm.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
tests/vm/basevm.py +2 -1
index 4fd9af10b7..2276364c42 100644
@@ -233,7 +233,8 @@ def _ssh_do(self, user, cmd, check):
                    "-o", "UserKnownHostsFile=" + os.devnull,
                    "-o",
                    "ConnectTimeout={}".format(self._config["ssh_timeout"]),
-                   "-p", str(self.ssh_port), "-i", self._ssh_tmp_key_file]
+                   "-p", str(self.ssh_port), "-i", self._ssh_tmp_key_file,
+                   "-o", "IdentitiesOnly=yes"]
         # If not in debug mode, set ssh to quiet mode to
         # avoid printing the results of commands.
         if not self.debug:
Signature · 1 line
2.34.1