~ruther/guix-local

4a1ea5d0dae3f1c26e0eb67811b5f1f331541fbc — Maxim Cournoyer 1 year, 4 months ago 84a351b
gnu: qemu: Update to 9.1.3.

* gnu/packages/virtualization.scm (qemu): Update to 9.1.3.
[source] <patches>: Add qemu-disable-migration-test.patch.
[arguments] <phases>: Adjust install-user-static phase.
[native-inputs]: Add python-tomli.
(qemu-patch): Delete procedure.
* gnu/packages/patches/qemu-disable-bios-tables-test.patch: Rebase.
* gnu/packages/patches/qemu-fix-agent-paths.patch: Likewise.
* gnu/packages/patches/qemu-disable-aarch64-migration-test.patch: Delete file.
* gnu/packages/patches/qemu-disable-migration-test.patch: New file.
* gnu/local.mk (dist_patch_DATA): Adjust accordingly.

Change-Id: I573070a297ffc9ca096c52e2fa18f839ad89a24e
M gnu/local.mk => gnu/local.mk +1 -1
@@ 2141,8 2141,8 @@ dist_patch_DATA =						\
  %D%/packages/patches/python-xmp-toolkit-add-missing-error-codes.patch	\
  %D%/packages/patches/qemu-7.2.4-build-info-manual.patch	\
  %D%/packages/patches/qemu-build-info-manual.patch		\
  %D%/packages/patches/qemu-disable-aarch64-migration-test.patch	\
  %D%/packages/patches/qemu-disable-bios-tables-test.patch	\
  %D%/packages/patches/qemu-disable-migration-test.patch	\
  %D%/packages/patches/qemu-glibc-2.27.patch 			\
  %D%/packages/patches/qemu-glibc-2.30.patch 			\
  %D%/packages/patches/qemu-fix-agent-paths.patch 		\

D gnu/packages/patches/qemu-disable-aarch64-migration-test.patch => gnu/packages/patches/qemu-disable-aarch64-migration-test.patch +0 -13
@@ 1,13 0,0 @@
Disable the qtest-aarch64/migration-test, which sometimes fail non-deterministically.
See: https://gitlab.com/qemu-project/qemu/-/issues/1230.

--- qemu-7.1.0/tests/qtest/meson.build.old	1969-12-31 19:00:01.000000000 -0500
+++ qemu-7.1.0/tests/qtest/meson.build	2022-09-26 11:11:05.434209797 -0400
@@ -219,7 +219,6 @@
   ['arm-cpu-features',
    'numa-test',
    'boot-serial-test',
-   'migration-test',
    'bcm2835-dma-test']
 
 qtests_s390x = \

M gnu/packages/patches/qemu-disable-bios-tables-test.patch => gnu/packages/patches/qemu-disable-bios-tables-test.patch +20 -11
@@ 1,18 1,17 @@
The bios-tables-test may fail; disable it (see: https://gitlab.com/qemu-project/qemu/-/issues/1098)

diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build
index f096cf3ecd..82f6e1ffeb 100644
index 2f0d3ef080..e3c33a86b5 100644
--- a/tests/qtest/meson.build
+++ b/tests/qtest/meson.build
@@ -1,7 +1,6 @@
@@ -1,6 +1,5 @@
 slow_qtests = {
   'ahci-test' : 60,
   'aspeed_smc-test': 360,
-  'bios-tables-test' : 120,
   'boot-serial-test' : 60,
   'migration-test' : 150,
   'npcm7xx_pwm-test': 150,
@@ -82,9 +81,6 @@ qtests_i386 = \
-  'bios-tables-test' : 910,
   'cdrom-test' : 610,
   'device-introspect-test' : 720,
   'migration-test' : 480,
@@ -86,9 +85,6 @@ qtests_i386 = \
    config_all_devices.has_key('CONFIG_Q35') and                                             \
    config_all_devices.has_key('CONFIG_VIRTIO_PCI') and                                      \
    slirp.found() ? ['virtio-net-failover'] : []) +                                          \


@@ 22,15 21,25 @@ index f096cf3ecd..82f6e1ffeb 100644
   qtests_pci +                                                                              \
   qtests_cxl +                                                                              \
   ['fdc-test',
@@ -213,7 +209,6 @@ qtests_arm = \
@@ -235,7 +231,6 @@ qtests_arm = \
 
 # TODO: once aarch64 TCG is fixed on ARM 32 bit host, make bios-tables-test unconditional
 qtests_aarch64 = \
-  (cpu != 'arm' and unpack_edk2_blobs ? ['bios-tables-test'] : []) +                            \
   (config_all.has_key('CONFIG_TCG') and config_all_devices.has_key('CONFIG_TPM_TIS_SYSBUS') ?            \
   (config_all_accel.has_key('CONFIG_TCG') and config_all_devices.has_key('CONFIG_TPM_TIS_SYSBUS') ?            \
     ['tpm-tis-device-test', 'tpm-tis-device-swtpm-test'] : []) +                                         \
   (config_all_devices.has_key('CONFIG_XLNX_ZYNQMP_ARM') ? ['xlnx-can-test', 'fuzz-xlnx-dp-test'] : []) + \
@@ -304,7 +299,6 @@ if gnutls.found()
@@ -260,9 +255,6 @@ qtests_s390x = \
 qtests_riscv32 = \
   (config_all_devices.has_key('CONFIG_SIFIVE_E_AON') ? ['sifive-e-aon-watchdog-test'] : [])
 
-qtests_riscv64 = \
-  (unpack_edk2_blobs ? ['bios-tables-test'] : [])
-
 qos_test_ss = ss.source_set()
 qos_test_ss.add(
   'ac97-test.c',
@@ -328,7 +320,6 @@ if gnutls.found()
 endif
 
 qtests = {

A gnu/packages/patches/qemu-disable-migration-test.patch => gnu/packages/patches/qemu-disable-migration-test.patch +57 -0
@@ 0,0 1,57 @@
diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build
index e3c33a86b5..a3bbf9c841 100644
--- a/tests/qtest/meson.build
+++ b/tests/qtest/meson.build
@@ -2,7 +2,6 @@ slow_qtests = {
   'aspeed_smc-test': 360,
   'cdrom-test' : 610,
   'device-introspect-test' : 720,
-  'migration-test' : 480,
   'npcm7xx_pwm-test': 300,
   'npcm7xx_watchdog_timer-test': 120,
   'qom-test' : 900,
@@ -100,7 +99,6 @@ qtests_i386 = \
    'cpu-plug-test',
    'q35-test',
    'vmgenid-test',
-   'migration-test',
    'test-x86-cpuid-compat',
    'numa-test'
   ]
@@ -173,7 +171,7 @@ qtests_ppc64 = \
   (slirp.found() ? ['pxe-test'] : []) +              \
   (config_all_devices.has_key('CONFIG_USB_UHCI') ? ['usb-hcd-uhci-test'] : []) +             \
   (config_all_devices.has_key('CONFIG_USB_XHCI_NEC') ? ['usb-hcd-xhci-test'] : []) +         \
-  qtests_pci + ['migration-test', 'numa-test', 'cpu-plug-test', 'drive_del-test']
+  qtests_pci + ['numa-test', 'cpu-plug-test', 'drive_del-test']
 
 qtests_sh4 = (config_all_devices.has_key('CONFIG_ISA_TESTDEV') ? ['endianness-test'] : [])
 qtests_sh4eb = (config_all_devices.has_key('CONFIG_ISA_TESTDEV') ? ['endianness-test'] : [])
@@ -240,8 +238,7 @@ qtests_aarch64 = \
    config_all_devices.has_key('CONFIG_TPM_TIS_I2C') ? ['tpm-tis-i2c-test'] : []) + \
   ['arm-cpu-features',
    'numa-test',
-   'boot-serial-test',
-   'migration-test']
+   'boot-serial-test']
 
 qtests_s390x = \
   qtests_filter + \
@@ -249,8 +246,7 @@ qtests_s390x = \
    'drive_del-test',
    'device-plug-test',
    'virtio-ccw-test',
-   'cpu-plug-test',
-   'migration-test']
+   'cpu-plug-test']
 
 qtests_riscv32 = \
   (config_all_devices.has_key('CONFIG_SIFIVE_E_AON') ? ['sifive-e-aon-watchdog-test'] : [])
@@ -324,7 +320,6 @@ qtests = {
   'dbus-vmstate-test': files('migration-helpers.c') + dbus_vmstate1,
   'erst-test': files('erst-test.c'),
   'ivshmem-test': [rt, '../../contrib/ivshmem-server/ivshmem-server.c'],
-  'migration-test': migration_files,
   'pxe-test': files('boot-sector.c'),
   'qos-test': [chardev, io, qos_test_ss.apply({}).sources()],
   'tpm-crb-swtpm-test': [io, tpmemu_files],

M gnu/packages/patches/qemu-fix-agent-paths.patch => gnu/packages/patches/qemu-fix-agent-paths.patch +35 -37
@@ 4,19 4,20 @@ after the patch from the Nix package:
https://github.com/NixOS/nixpkgs/blob/master/pkgs/applications/virtualization/qemu/fix-qemu-ga.patch

diff --git a/qga/commands-posix.c b/qga/commands-posix.c
index 6e3c15f539..eaef900b6e 100644
--- a/qga/commands-posix.c
+++ b/qga/commands-posix.c
@@ -84,6 +84,7 @@ static void ga_wait_child(pid_t pid, int *status, Error **errp)
 void qmp_guest_shutdown(bool has_mode, const char *mode, Error **errp)
@@ -216,6 +216,7 @@ out:
 void qmp_guest_shutdown(const char *mode, Error **errp)
 {
     const char *shutdown_flag;
+    const char *command;
     Error *local_err = NULL;
     pid_t pid;
     int status;
@@ -101,10 +102,13 @@ void qmp_guest_shutdown(bool has_mode, const char *mode, Error **errp)
 
 #ifdef CONFIG_SOLARIS
@@ -235,16 +236,24 @@ void qmp_guest_shutdown(const char *mode, Error **errp)
     slog("guest-shutdown called, mode: %s", mode);
     if (!has_mode || strcmp(mode, "powerdown") == 0) {
     if (!mode || strcmp(mode, "powerdown") == 0) {
         shutdown_flag = powerdown_flag;
+        command = "shutdown";
     } else if (strcmp(mode, "halt") == 0) {


@@ 28,38 29,35 @@ diff --git a/qga/commands-posix.c b/qga/commands-posix.c
     } else {
         error_setg(errp,
                    "mode is invalid (valid values are: halt|powerdown|reboot");
@@ -123,6 +127,11 @@ void qmp_guest_shutdown(bool has_mode, const char *mode, Error **errp)
         execl("/sbin/shutdown", "shutdown", shutdown_flag, "-g0", "-y",
               "hypervisor initiated shutdown", (char *)NULL);
 #else
+        /* try Guix’s shutdown/halt/reboot first */
+        char *path = g_strdup_printf("/run/current-system/profile/sbin/%s", command);
+        execl(path, command, (char *)NULL);
+        g_free(path);
         return;
     }
 
+    /* Try Guix’s shutdown/halt/reboot first. */
+    char *path = g_strdup_printf("/run/current-system/profile/sbin/%s", command);
+    execl(path, command, (char *) NULL);
+    g_free(path);
+
         execl("/sbin/shutdown", "shutdown", "-h", shutdown_flag, "+0",
                "hypervisor initiated shutdown", (char *)NULL);
 #endif
@@ -159,10 +168,12 @@ void qmp_guest_set_time(bool has_time, int64_t time_ns, Error **errp)
     const char *argv[] = {"/sbin/shutdown",
 #ifdef CONFIG_SOLARIS
                           shutdown_flag, "-g0", "-y",
@@ -269,7 +278,7 @@ void qmp_guest_set_time(bool has_time, int64_t time_ns, Error **errp)
     int ret;
     Error *local_err = NULL;
     struct timeval tv;
     static const char hwclock_path[] = "/sbin/hwclock";
+    static const char hwclock_path_guix[] = "/run/current-system/profile/sbin/hwclock";
     static int hwclock_available = -1;
 
     if (hwclock_available < 0) {
-        hwclock_available = (access(hwclock_path, X_OK) == 0);
+        hwclock_available = (access(hwclock_path_guix, X_OK) == 0) ||
+                            (access(hwclock_path, X_OK) == 0);
     }
 
     if (!hwclock_available) {
@@ -208,6 +219,8 @@ void qmp_guest_set_time(bool has_time, int64_t time_ns, Error **errp)
-    const char *argv[] = {"/sbin/hwclock", has_time ? "-w" : "-s", NULL};
+    const char *argv[] = {"/run/current-system/profile/sbin/hwclock", has_time ? "-w" : "-s", NULL};
 
         /* Use '/sbin/hwclock -w' to set RTC from the system time,
          * or '/sbin/hwclock -s' to set the system time from RTC. */
+        execl(hwclock_path_guix, "hwclock", has_time ? "-w" : "-s",
+               NULL);
         execl(hwclock_path, "hwclock", has_time ? "-w" : "-s", NULL);
         _exit(EXIT_FAILURE);
     } else if (pid < 0) {
     /* If user has passed a time, validate and set it. */
     if (has_time) {
@@ -302,6 +311,11 @@ void qmp_guest_set_time(bool has_time, int64_t time_ns, Error **errp)
      * hardware clock (RTC). */
     ga_run_command(argv, NULL, "set hardware clock to system time",
                    &local_err);
+    if (local_err) {
+        argv[0] = "/sbin/hwclock";
+        ga_run_command(argv, NULL, "set hardware clock to system time",
+                       &local_err);
+    }
     if (local_err) {
         error_propagate(errp, local_err);
         return;

M gnu/packages/virtualization.scm => gnu/packages/virtualization.scm +20 -28
@@ 15,7 15,7 @@
;;; Copyright © 2020, 2021 Brice Waegeneire <brice@waegenei.re>
;;; Copyright © 2020 Mathieu Othacehe <m.othacehe@gmail.com>
;;; Copyright © 2020, 2021, 2022 Marius Bakke <marius@gnu.org>
;;; Copyright © 2020, 2021, 2022, 2023, 2024 Maxim Cournoyer <maxim.cournoyer@gmail.com>
;;; Copyright © 2020-2025 Maxim Cournoyer <maxim.cournoyer@gmail.com>
;;; Copyright © 2020 Brett Gilio <brettg@gnu.org>
;;; Copyright © 2021 Leo Famulari <leo@famulari.name>
;;; Copyright © 2021, 2022 Pierre Langlois <pierre.langlois@gmx.com>


@@ 183,29 183,20 @@
  #:use-module (srfi srfi-26)
  #:use-module (ice-9 match))

(define (qemu-patch commit file-name sha256-bv)
  "Return an origin for COMMIT."
  (origin
    (method url-fetch)
    (uri (string-append
          "http://git.qemu.org/?p=qemu.git;a=commitdiff_plain;h="
          commit))
    (hash (content-hash sha256-bv sha256))
    (file-name file-name)))

(define-public qemu
  (package
    (name "qemu")
    (version "8.2.2")
    (version "9.1.3")
    (source
     (origin
       (method url-fetch)
       (uri (string-append "https://download.qemu.org/qemu-"
                           version ".tar.xz"))
       (sha256
        (base32 "1wy45fbf4816l4ylsz8b8cbypva9apcdnvlgqfr586icp30lcww4"))
        (base32 "12dc3fpv6c6qvw89amjjbb6dgc2f1c1alfgn2nab7a8kxnh7f2j8"))
       (patches (search-patches "qemu-build-info-manual.patch"
                                "qemu-disable-bios-tables-test.patch"
                                "qemu-disable-migration-test.patch"
                                "qemu-fix-agent-paths.patch"))
       (modules '((guix build utils)))
       (snippet


@@ 437,8 428,7 @@
          ;; Configure, build and install QEMU user-emulation static binaries.
          (add-after 'configure 'configure-user-static
            (lambda* (#:key inputs outputs #:allow-other-keys)
              (let* ((static (assoc-ref outputs "static"))
                     (gcc (search-input-file inputs "/bin/gcc"))
              (let* ((gcc (search-input-file inputs "/bin/gcc"))
                     ;; This is the common set of configure flags; it is
                     ;; duplicated here to isolate this phase from manipulations
                     ;; to the #:configure-flags build argument, as done in


@@ 446,7 436,8 @@
                     (configure-flags (list (string-append "--cc=" gcc)
                                            (string-append "--host-cc=" gcc)
                                            "--sysconfdir=/etc"
                                            "--disable-debug-info")))
                                            "--disable-debug-info"))
                     (static (assoc-ref outputs "static")))
                (mkdir-p "../user-static")
                (with-directory-excursion "../user-static"
                  (apply invoke "../../configure"


@@ 462,15 453,18 @@
                (apply (assoc-ref %standard-phases 'build) args))))
          (add-after 'install 'install-user-static
            (lambda* (#:key outputs #:allow-other-keys)
              (let* ((static (assoc-ref outputs "static"))
                     (bin (string-append static "/bin")))
              (let ((static-bin (string-append
                                 (assoc-ref outputs "static") ;see bug#70611
                                 "/bin")))
                (with-directory-excursion "../user-static"
                  (for-each (cut install-file <> bin)
                            (append-map (cut find-files <> "^qemu-" #:stat stat)
                                        (scandir "."
                                                 (cut string-suffix?
                                                      "-linux-user" <>))))))))

                  (for-each
                   (cut install-file <> static-bin)
                   (find-files "."
                               (lambda (name stat)
                                 ;; Select 'qemu-' prefixed executables.
                                 (and (string-prefix? "./qemu-" name)
                                      (eq? 'regular (stat:type stat))
                                      (logtest #o100 (stat:perms stat))))))))))
          (add-before 'check 'set-SOCK_DIR
            (lambda _
              ;; The default value for SOCK_DIR is TMPDIR, which can be long


@@ 506,7 500,7 @@ exec smbd $@")))
          (add-after 'install 'move-html-doc
            (lambda* (#:key inputs outputs #:allow-other-keys)
              (let* ((out #$output)
                     (doc #$output:doc)
                     (doc (assoc-ref outputs "doc")) ;see bug#70611
                     (qemu-doc (string-append doc "/share/doc/qemu-"
                                              #$(package-version this-package))))
                (mkdir-p qemu-doc)


@@ 538,7 532,6 @@ exec smbd $@")))
            ncurses
            openbios-qemu-ppc
            opensbi-qemu
            ;; pciutils
            pixman
            pulseaudio
            sdl2


@@ 548,8 541,6 @@ exec smbd $@")))
            util-linux
            vde2
            virglrenderer

            ;; Formats to support for .qcow2 (and possibly other) compression.
            zlib
            `(,zstd "lib"))))
    (native-inputs


@@ 567,6 558,7 @@ exec smbd $@")))
           python-wrapper
           python-sphinx
           python-sphinx-rtd-theme
           python-tomli
           texinfo
           ;; The following static libraries are required to build
           ;; the static output of QEMU.