Skip to contentSkip to conversation

various fixes (CI, Xen, plugins)

PATCH In review Alex Bennée 2 participants 13 messages Nov 10, 2020 – Nov 11, 2020 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

cover various fixes (CI, Xen, plugins)

Hi,

This collects together a bunch of fixes for 5.2:

- a few resource leak fixes for plugins
- Xen on arm64 build fixes (from my larger Xen series)
- a couple of build and CI fixes
- a tweak to the gitlab status script

I can drop the last patch if I have to but it hopefully allows for easier scripting of the "waiting for gitlab" experience for those that are not using "staging".

The following need review:

- scripts/ci: clean up default args logic a little
- gitlab: move remaining x86 check-tcg targets to gitlab

Alex Bennée (6):
meson.build: fix building of Xen support for aarch64 include/hw/xen.h: drop superfluous struct stubs/xen-hw-stub: drop xenstore_store_pv_console_info stub accel/stubs: drop unused cpu.h include
gitlab: move remaining x86 check-tcg targets to gitlab scripts/ci: clean up default args logic a little

Alex Chen (2):
plugins: Fix resource leak in connect_socket()
plugins: Fix two resource leaks in setup_socket()

Philippe Mathieu-Daudé (2):
hw/i386/acpi-build: Fix maybe-uninitialized error when ACPI hotplug
off
tests/acceptance: Disable Spartan-3A DSP 1800A test

 meson.build                            |  7 ++++-
 include/hw/xen/xen.h                   |  2 +-
 accel/stubs/hax-stub.c                 |  1 -
 contrib/plugins/lockstep.c             |  3 ++
 hw/i386/acpi-build.c                   | 41 ++++++++++++--------------
 stubs/xen-hw-stub.c                    |  4 ---
 .gitlab-ci.yml                         | 17 +++++++++++
 .travis.yml                            | 26 ----------------
 scripts/ci/gitlab-pipeline-status      | 24 ++++++++-------
 tests/acceptance/boot_linux_console.py |  2 ++
 tests/acceptance/replay_kernel.py      |  2 ++
 11 files changed, 63 insertions(+), 66 deletions(-)
Signature · 1 line
2.20.1
#1 lore raw

PATCH 1/10 plugins: Fix resource leak in connect_socket()

From: Alex Chen <[email protected]>

Close the fd when the connect() fails.

Message-Id: <[email protected]>

---
 contrib/plugins/lockstep.c | 1 +
 1 file changed, 1 insertion(+)
contrib/plugins/lockstep.c +1 -0
index a696673dff..319bd44b83 100644
@@ -292,6 +292,7 @@ static bool connect_socket(const char *path)
 
     if (connect(fd, (struct sockaddr *)&sockaddr, sizeof(sockaddr)) < 0) {
         perror("failed to connect");
+        close(fd);
         return false;
     }
 
Signature · 1 line
2.20.1
#2 lore raw

PATCH 2/10 plugins: Fix two resource leaks in setup_socket()

In reply to Alex Bennée

From: Alex Chen <[email protected]>

Either accept() fails or exits normally, we need to close the fd.

Message-Id: <[email protected]>

---
 contrib/plugins/lockstep.c | 2 ++
 1 file changed, 2 insertions(+)
contrib/plugins/lockstep.c +2 -0
index 319bd44b83..5aad50869d 100644
@@ -268,11 +268,13 @@ static bool setup_socket(const char *path)
     socket_fd = accept(fd, NULL, NULL);
     if (socket_fd < 0 && errno != EINTR) {
         perror("accept socket");
+        close(fd);
         return false;
     }
 
     qemu_plugin_outs("setup_socket::ready\n");
 
+    close(fd);
     return true;
 }
 
Signature · 1 line
2.20.1
#3 lore raw

PATCH 3/10 meson.build: fix building of Xen support for aarch64

In reply to Alex Bennée

Xen is supported on ARM although weirdly using the i386-softmmu model. Checking based on the host CPU meant we never enabled Xen support. It would be nice to enable CONFIG_XEN for aarch64-softmmu to make it not seem weird but that will require further build surgery.

Fixes 8a19980e3f ("configure: move accelerator logic to meson")
Cc Masami Hiramatsu <[email protected]>
Cc Stefano Stabellini <[email protected]>
Cc Anthony Perard <[email protected]>
Cc Paul Durrant <[email protected]>

Message-Id: <[email protected]>

---
 meson.build | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
meson.build +6 -1
index b473620321..ef197f9a6b 100644
@@ -74,10 +74,15 @@ else
 endif
 
 accelerator_targets = { 'CONFIG_KVM': kvm_targets }
+if cpu in ['x86', 'x86_64', 'arm', 'aarch64']
+  # i368 emulator provides xenpv machine type for multiple architectures
+  accelerator_targets += {
+    'CONFIG_XEN': ['i386-softmmu', 'x86_64-softmmu'],
+  }
+endif
 if cpu in ['x86', 'x86_64']
   accelerator_targets += {
     'CONFIG_HAX': ['i386-softmmu', 'x86_64-softmmu'],
-    'CONFIG_XEN': ['i386-softmmu', 'x86_64-softmmu'],
     'CONFIG_HVF': ['x86_64-softmmu'],
     'CONFIG_WHPX': ['i386-softmmu', 'x86_64-softmmu'],
   }
Signature · 1 line
2.20.1
#4 lore raw

PATCH 4/10 include/hw/xen.h: drop superfluous struct

In reply to Alex Bennée

Chardev is already a typedef'ed struct.

Message-Id: <[email protected]>

---
 include/hw/xen/xen.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/hw/xen/xen.h +1 -1
index 1406648ca5..0f9962b1c1 100644
@@ -28,7 +28,7 @@ int xen_is_pirq_msi(uint32_t msi_data);
 
 qemu_irq *xen_interrupt_controller_init(void);
 
-void xenstore_store_pv_console_info(int i, struct Chardev *chr);
+void xenstore_store_pv_console_info(int i, Chardev *chr);
 
 void xen_register_framebuffer(struct MemoryRegion *mr);
 
Signature · 1 line
2.20.1
#5 lore raw

PATCH 5/10 stubs/xen-hw-stub: drop xenstore_store_pv_console_info stub

In reply to Alex Bennée

We should never build something that calls this without having it.

Message-Id: <[email protected]>

---
 stubs/xen-hw-stub.c | 4 ----
 1 file changed, 4 deletions(-)
stubs/xen-hw-stub.c +0 -4
index 2ea8190921..15f3921a76 100644
@@ -10,10 +10,6 @@
 #include "hw/xen/xen.h"
 #include "hw/xen/xen-x86.h"
 
-void xenstore_store_pv_console_info(int i, Chardev *chr)
-{
-}
-
 int xen_pci_slot_get_pirq(PCIDevice *pci_dev, int irq_num)
 {
     return -1;
Signature · 1 line
2.20.1
#6 lore raw

PATCH 6/10 accel/stubs: drop unused cpu.h include

In reply to Alex Bennée

Message-Id: <[email protected]>

---
 accel/stubs/hax-stub.c | 1 -
 1 file changed, 1 deletion(-)
accel/stubs/hax-stub.c +0 -1
index 1a9da83185..49077f88e3 100644
@@ -14,7 +14,6 @@
  */
 
 #include "qemu/osdep.h"
-#include "cpu.h"
 #include "sysemu/hax.h"
 
 int hax_sync_vcpus(void)
Signature · 1 line
2.20.1
#7 lore raw

PATCH 7/10 hw/i386/acpi-build: Fix maybe-uninitialized error when ACPI hotplug off

In reply to Alex Bennée

From: Philippe Mathieu-Daudé <[email protected]>

GCC 9.3.0 thinks that 'method' can be left uninitialized. This code is already in the "if (bsel || pcihp_bridge_en)" block statement, but it isn't smart enough to figure it out.

Restrict the code to be used only in the "if (bsel || pcihp_bridge_en)" block statement to fix (on Ubuntu):

../hw/i386/acpi-build.c: In function 'build_append_pci_bus_devices':
../hw/i386/acpi-build.c:496:9: error: 'method' may be used uninitialized in this function [-Werror=maybe-uninitialized]

    496 |         aml_append(parent_scope, method);
        |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

cc1: all warnings being treated as errors

Fixes df4008c9c59 ("piix4: don't reserve hw resources when hotplug is off globally")

Message-Id: <[email protected]>

---
 hw/i386/acpi-build.c | 41 +++++++++++++++++++----------------------
 1 file changed, 19 insertions(+), 22 deletions(-)
hw/i386/acpi-build.c +19 -22
index 4f66642d88..1f5c211245 100644
@@ -465,34 +465,31 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,
      */
     if (bsel || pcihp_bridge_en) {
         method = aml_method("PCNT", 0, AML_NOTSERIALIZED);
-    }
-    /* If bus supports hotplug select it and notify about local events */
-    if (bsel) {
-        uint64_t bsel_val = qnum_get_uint(qobject_to(QNum, bsel));
 
-        aml_append(method, aml_store(aml_int(bsel_val), aml_name("BNUM")));
-        aml_append(method,
-            aml_call2("DVNT", aml_name("PCIU"), aml_int(1) /* Device Check */)
-        );
-        aml_append(method,
-            aml_call2("DVNT", aml_name("PCID"), aml_int(3)/* Eject Request */)
-        );
-    }
+        /* If bus supports hotplug select it and notify about local events */
+        if (bsel) {
+            uint64_t bsel_val = qnum_get_uint(qobject_to(QNum, bsel));
 
-    /* Notify about child bus events in any case */
-    if (pcihp_bridge_en) {
-        QLIST_FOREACH(sec, &bus->child, sibling) {
-            int32_t devfn = sec->parent_dev->devfn;
+            aml_append(method, aml_store(aml_int(bsel_val), aml_name("BNUM")));
+            aml_append(method, aml_call2("DVNT", aml_name("PCIU"),
+                                         aml_int(1))); /* Device Check */
+            aml_append(method, aml_call2("DVNT", aml_name("PCID"),
+                                         aml_int(3))); /* Eject Request */
+        }
 
-            if (pci_bus_is_root(sec) || pci_bus_is_express(sec)) {
-                continue;
-            }
+        /* Notify about child bus events in any case */
+        if (pcihp_bridge_en) {
+            QLIST_FOREACH(sec, &bus->child, sibling) {
+                int32_t devfn = sec->parent_dev->devfn;
+
+                if (pci_bus_is_root(sec) || pci_bus_is_express(sec)) {
+                    continue;
+                }
 
-            aml_append(method, aml_name("^S%.02X.PCNT", devfn));
+                aml_append(method, aml_name("^S%.02X.PCNT", devfn));
+            }
         }
-    }
 
-    if (bsel || pcihp_bridge_en) {
         aml_append(parent_scope, method);
     }
     qobject_unref(bsel);
Signature · 1 line
2.20.1
Reviewed-by on v1 7/10
#8 lore raw

Re: [PATCH v1 07/10] hw/i386/acpi-build: Fix maybe-uninitialized error when ACPI hotplug off

Quoted 12 lines · On Tue, 10 Nov 2020 19:23:13 +0000 Alex Bennée <[email protected]> wrote:

From: Philippe Mathieu-Daudé <[email protected]>

GCC 9.3.0 thinks that 'method' can be left uninitialized. This code is already in the "if (bsel || pcihp_bridge_en)" block statement, but it isn't smart enough to figure it out.

Restrict the code to be used only in the "if (bsel || pcihp_bridge_en)" block statement to fix (on Ubuntu):

../hw/i386/acpi-build.c: In function 'build_append_pci_bus_devices':
../hw/i386/acpi-build.c:496:9: error: 'method' may be used uninitialized in this function [-Werror=maybe-uninitialized]

Quoted 8 lines
    496 |         aml_append(parent_scope, method);
        |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

cc1: all warnings being treated as errors

Fixes df4008c9c59 ("piix4: don't reserve hw resources when hotplug is off globally")

Message-Id: <[email protected]>

Quoted 62 lines
---
 hw/i386/acpi-build.c | 41 +++++++++++++++++++----------------------
 1 file changed, 19 insertions(+), 22 deletions(-)
hw/i386/acpi-build.c +19 -22
index 4f66642d88..1f5c211245 100644
@@ -465,34 +465,31 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,
      */
     if (bsel || pcihp_bridge_en) {
         method = aml_method("PCNT", 0, AML_NOTSERIALIZED);
-    }
-    /* If bus supports hotplug select it and notify about local events */
-    if (bsel) {
-        uint64_t bsel_val = qnum_get_uint(qobject_to(QNum, bsel));
 
-        aml_append(method, aml_store(aml_int(bsel_val), aml_name("BNUM")));
-        aml_append(method,
-            aml_call2("DVNT", aml_name("PCIU"), aml_int(1) /* Device Check */)
-        );
-        aml_append(method,
-            aml_call2("DVNT", aml_name("PCID"), aml_int(3)/* Eject Request */)
-        );
-    }
+        /* If bus supports hotplug select it and notify about local events */
+        if (bsel) {
+            uint64_t bsel_val = qnum_get_uint(qobject_to(QNum, bsel));
 
-    /* Notify about child bus events in any case */
-    if (pcihp_bridge_en) {
-        QLIST_FOREACH(sec, &bus->child, sibling) {
-            int32_t devfn = sec->parent_dev->devfn;
+            aml_append(method, aml_store(aml_int(bsel_val), aml_name("BNUM")));
+            aml_append(method, aml_call2("DVNT", aml_name("PCIU"),
+                                         aml_int(1))); /* Device Check */
+            aml_append(method, aml_call2("DVNT", aml_name("PCID"),
+                                         aml_int(3))); /* Eject Request */
+        }
 
-            if (pci_bus_is_root(sec) || pci_bus_is_express(sec)) {
-                continue;
-            }
+        /* Notify about child bus events in any case */
+        if (pcihp_bridge_en) {
+            QLIST_FOREACH(sec, &bus->child, sibling) {
+                int32_t devfn = sec->parent_dev->devfn;
+
+                if (pci_bus_is_root(sec) || pci_bus_is_express(sec)) {
+                    continue;
+                }
 
-            aml_append(method, aml_name("^S%.02X.PCNT", devfn));
+                aml_append(method, aml_name("^S%.02X.PCNT", devfn));
+            }
         }
-    }
 
-    if (bsel || pcihp_bridge_en) {
         aml_append(parent_scope, method);
     }
     qobject_unref(bsel);
#9 lore raw

PATCH 8/10 tests/acceptance: Disable Spartan-3A DSP 1800A test

In reply to Alex Bennée

From: Philippe Mathieu-Daudé <[email protected]>

This test is regularly failing on CI:

(05/34) tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_microblaze_s3adsp1800:
Linux version 4.11.3 ([email protected]) (gcc version 6.4.0 (Buildroot 2018.05.2) ) #5 Tue Dec 11 11:56:23 CET 2018
...
Freeing unused kernel memory: 1444K
This architecture does not have kernel memory protection.
[nothing happens here]
Runner error occurred: Timeout reached (90.91 s)

This is a regression. Until someone figure out the problem, disable the test to keep CI pipeline useful.

Message-Id: <[email protected]>

---
 tests/acceptance/boot_linux_console.py | 2 ++
 tests/acceptance/replay_kernel.py      | 2 ++
 2 files changed, 4 insertions(+)
tests/acceptance/boot_linux_console.py +2 -0
index 8f433a67f8..cc6ec0f8c1 100644
@@ -13,6 +13,7 @@ import lzma
 import gzip
 import shutil
 
+from avocado import skip
 from avocado import skipUnless
 from avocado_qemu import Test
 from avocado_qemu import exec_command_and_wait_for_pattern
@@ -1025,6 +1026,7 @@ class BootLinuxConsole(LinuxKernelTest):
         tar_hash = 'ac688fd00561a2b6ce1359f9ff6aa2b98c9a570c'
         self.do_test_advcal_2018('07', tar_hash, 'sanity-clause.elf')
 
+    @skip("Test currently broken") # Console stuck as of 5.2-rc1
     def test_microblaze_s3adsp1800(self):
         """
         :avocado: tags=arch:microblaze
tests/acceptance/replay_kernel.py +2 -0
index 00c228382b..772633b01d 100644
@@ -14,6 +14,7 @@ import shutil
 import logging
 import time
 
+from avocado import skip
 from avocado import skipIf
 from avocado import skipUnless
 from avocado_qemu import wait_for_console_pattern
@@ -280,6 +281,7 @@ class ReplayKernelNormal(ReplayKernelBase):
         file_path = self.fetch_asset(tar_url, asset_hash=tar_hash)
         self.do_test_advcal_2018(file_path, 'sanity-clause.elf')
 
+    @skip("Test currently broken") # Console stuck as of 5.2-rc1
     def test_microblaze_s3adsp1800(self):
         """
         :avocado: tags=arch:microblaze
Signature · 1 line
2.20.1
#10 lore raw

PATCH 9/10 gitlab: move remaining x86 check-tcg targets to gitlab

In reply to Alex Bennée

The GCC check-tcg (user) test in particular was very prone to timing out on Travis. We only actually need to move the some-softmmu builds across as we already have coverage for linux-user.

As --enable-debug-tcg does increase the run time somewhat as more debug is put in let's restrict that to just the plugins build. It's unlikely that a plugins enabled build is going to hide a sanity failure in core TCG code so let the plugin builds do the heavy lifting on checking TCG sanity so the non-plugin builds can run swiftly.

Now the only remaining check-tcg builds on Travis are for the various non-x86 arches.

---
 .gitlab-ci.yml | 17 +++++++++++++++++
 .travis.yml    | 26 --------------------------
 2 files changed, 17 insertions(+), 26 deletions(-)
.gitlab-ci.yml +17 -0
index 9a8b375188..b406027a55 100644
@@ -247,6 +247,15 @@ build-user:
     CONFIGURE_ARGS: --disable-tools --disable-system
     MAKE_CHECK_ARGS: check-tcg
 
+# Only build the softmmu targets we have check-tcg tests for
+build-some-softmmu:
+  <<: *native_build_job_definition
+  variables:
+    IMAGE: debian-all-test-cross
+    CONFIGURE_ARGS: --disable-tools --enable-debug-tcg
+    TARGETS: xtensa-softmmu arm-softmmu aarch64-softmmu alpha-softmmu
+    MAKE_CHECK_ARGS: check-tcg
+
 # Run check-tcg against linux-user (with plugins)
 # we skip sparc64-linux-user until it has been fixed somewhat
 # we skip cris-linux-user as it doesn't use the common run loop
@@ -258,6 +267,14 @@ build-user-plugins:
     MAKE_CHECK_ARGS: check-tcg
   timeout: 1h 30m
 
+build-some-softmmu-plugins:
+  <<: *native_build_job_definition
+  variables:
+    IMAGE: debian-all-test-cross
+    CONFIGURE_ARGS: --disable-tools --disable-user --enable-plugins --enable-debug-tcg
+    TARGETS: xtensa-softmmu arm-softmmu aarch64-softmmu alpha-softmmu
+    MAKE_CHECK_ARGS: check-tcg
+
 build-clang:
   <<: *native_build_job_definition
   variables:
.travis.yml +0 -26
index a3d78171ca..bac085f800 100644
@@ -301,32 +301,6 @@ jobs:
         - ${SRC_DIR}/configure ${CONFIG} --extra-cflags="-g3 -O0 -fsanitize=thread" || { cat config.log meson-logs/meson-log.txt && exit 1; }
 
 
-    # Run check-tcg against linux-user
-    - name: "GCC check-tcg (user)"
-      env:
-        - CONFIG="--disable-system --enable-debug-tcg"
-        - TEST_BUILD_CMD="make build-tcg"
-        - TEST_CMD="make check-tcg"
-        - CACHE_NAME="${TRAVIS_BRANCH}-linux-gcc-debug-tcg"
-
-
-    # Run check-tcg against softmmu targets
-    - name: "GCC check-tcg (some-softmmu)"
-      env:
-        - CONFIG="--enable-debug-tcg --target-list=xtensa-softmmu,arm-softmmu,aarch64-softmmu,alpha-softmmu"
-        - TEST_BUILD_CMD="make build-tcg"
-        - TEST_CMD="make check-tcg"
-        - CACHE_NAME="${TRAVIS_BRANCH}-linux-gcc-debug-tcg"
-
-
-    # Run check-tcg against softmmu targets (with plugins)
-    - name: "GCC plugins check-tcg (some-softmmu)"
-      env:
-        - CONFIG="--enable-plugins --enable-debug-tcg --target-list=xtensa-softmmu,arm-softmmu,aarch64-softmmu,alpha-softmmu"
-        - TEST_BUILD_CMD="make build-tcg"
-        - TEST_CMD="make check-tcg"
-        - CACHE_NAME="${TRAVIS_BRANCH}-linux-gcc-debug-tcg"
-
     - name: "[aarch64] GCC check-tcg"
       arch: arm64
       dist: focal
Signature · 1 line
2.20.1
#11 lore raw

PATCH 10/10 scripts/ci: clean up default args logic a little

In reply to Alex Bennée

This allows us to do:

./scripts/ci/gitlab-pipeline-status -w -b HEAD -p 2961854

to check out own pipeline status of a recently pushed branch.

---
 scripts/ci/gitlab-pipeline-status | 24 +++++++++++++-----------
 1 file changed, 13 insertions(+), 11 deletions(-)
scripts/ci/gitlab-pipeline-status +13 -11
index bac8233079..78e72f6008 100755
@@ -31,7 +31,7 @@ class NoPipelineFound(Exception):
     """Communication is successfull but pipeline is not found."""
 
 
-def get_local_branch_commit(branch='staging'):
+def get_local_branch_commit(branch):
     """
     Returns the commit sha1 for the *local* branch named "staging"
     """
@@ -126,18 +126,16 @@ def create_parser():
                         help=('The GitLab project ID. Defaults to the project '
                               'for https://gitlab.com/qemu-project/qemu, that '
                               'is, "%(default)s"'))
-    try:
-        default_commit = get_local_branch_commit()
-        commit_required = False
-    except ValueError:
-        default_commit = ''
-        commit_required = True
-    parser.add_argument('-c', '--commit', required=commit_required,
-                        default=default_commit,
+    parser.add_argument('-b', '--branch', type=str, default="staging",
+                        help=('Specify the branch to check. '
+                              'Use HEAD for your current branch. '
+                              'Otherwise looks at "%(default)s"'))
+    parser.add_argument('-c', '--commit',
+                        default=None,
                         help=('Look for a pipeline associated with the given '
                               'commit.  If one is not explicitly given, the '
-                              'commit associated with the local branch named '
-                              '"staging" is used.  Default: %(default)s'))
+                              'commit associated with the default branch '
+                              'is used.'))
     parser.add_argument('--verbose', action='store_true', default=False,
                         help=('A minimal verbosity level that prints the '
                               'overall result of the check/wait'))
@@ -149,6 +147,10 @@ def main():
     """
     parser = create_parser()
     args = parser.parse_args()
+
+    if not args.commit:
+        args.commit = get_local_branch_commit(args.branch)
+
     success = False
     try:
         if args.wait:
Signature · 1 line
2.20.1
#12 lore raw
In reply to Alex Bennée
Quoted 3 lines · Alex Bennée

Hi,

This collects together a bunch of fixes for 5.2:

Doh, subject did not match body, I of course mean for the current release candidate.

Quoted 4 lines

- a few resource leak fixes for plugins
- Xen on arm64 build fixes (from my larger Xen series)
- a couple of build and CI fixes
- a tweak to the gitlab status script

<snip>

Signature · 1 line
Alex Bennée