Subject: [bug#65645] [PATCH 1/3] gnu: qemu: Update to 7.2.4.

From: Maxim Cournoyer <[email-masked]>
Date: Thu, 31 Aug 2023 00:45:26 -0400

* gnu/packages/virtualization.scm (qemu): Update to 7.2.4.
[source] <patches>: Replace qemu-disable-aarch64-migration-test.patch with
qemu-disable-some-qtests-tests.patch.
<snippet>: Adjust for dtc relocation and meson and sgabios removal.
[arguments] <configure-flags>: Remove --meson flag.  Remove sgabios from the
--firmwarepath value.
<phases>: Adjust replace-firmwares and delete-firmwares phases for sgabios
removal.
[inputs]: Remove sgabios.
(qemu-minimal): Use package/inherit, which is more appropriate for a package
variant.
[arguments]: New disable-extra-tests phase.
* gnu/packages/patches/qemu-disable-aarch64-migration-test.patch: Delete file.
* gnu/packages/patches/qemu-disable-some-qtests-tests.patch: New file.
* gnu/local.mk (dist_patch_DATA): Adjust accordingly.
---
 gnu/local.mk                                  |  2 +-
 .../qemu-disable-aarch64-migration-test.patch | 13 -----
 .../qemu-disable-some-qtests-tests.patch      | 52 +++++++++++++++++++
 gnu/packages/virtualization.scm               | 43 +++++++--------
 4 files changed, 71 insertions(+), 39 deletions(-)
 delete mode 100644 gnu/packages/patches/qemu-disable-aarch64-migration-test.patch
 create mode 100644 gnu/packages/patches/qemu-disable-some-qtests-tests.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index 48187d7e64..0683a87492 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1864,7 +1864,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/python-werkzeug-tests.patch		\
   %D%/packages/patches/python-zeep-Fix-pytest_httpx-test-cases.patch	\
   %D%/packages/patches/qemu-build-info-manual.patch		\
-  %D%/packages/patches/qemu-disable-aarch64-migration-test.patch	\
+  %D%/packages/patches/qemu-disable-some-qtests-tests.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 		\
diff --git a/gnu/packages/patches/qemu-disable-aarch64-migration-test.patch b/gnu/packages/patches/qemu-disable-aarch64-migration-test.patch
deleted file mode 100644
index bf60ed23bb..0000000000
--- a/gnu/packages/patches/qemu-disable-aarch64-migration-test.patch
+++ /dev/null
@@ -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 = \
diff --git a/gnu/packages/patches/qemu-disable-some-qtests-tests.patch b/gnu/packages/patches/qemu-disable-some-qtests-tests.patch
new file mode 100644
index 0000000000..f60698de8f
--- /dev/null
+++ b/gnu/packages/patches/qemu-disable-some-qtests-tests.patch
@@ -0,0 +1,52 @@
+Disable the qtest-aarch64/migration-test, which sometimes fail
+non-deterministically (see:
+https://gitlab.com/qemu-project/qemu/-/issues/1230).
+
+Also disable the bios-tables-test, which may fail on older machines (see:
+https://gitlab.com/qemu-project/qemu/-/issues/1098).
+
+--- qemu-8.1.0/tests/qtest/meson.build.old	2023-08-30 11:48:27.871146249 -0400
++++ qemu-8.1.0/tests/qtest/meson.build	2023-08-30 13:53:25.994084948 -0400
+@@ -1,6 +1,5 @@
+ slow_qtests = {
+   'ahci-test' : 60,
+-  'bios-tables-test' : 120,
+   'boot-serial-test' : 60,
+   'migration-test' : 150,
+   'npcm7xx_pwm-test': 150,
+@@ -81,9 +80,6 @@
+    config_all_devices.has_key('CONFIG_Q35') and                                             \
+    config_all_devices.has_key('CONFIG_VIRTIO_PCI') and                                      \
+    slirp.found() ? ['virtio-net-failover'] : []) +                                          \
+-  (unpack_edk2_blobs and                                                                    \
+-   config_all_devices.has_key('CONFIG_HPET') and                                            \
+-   config_all_devices.has_key('CONFIG_PARALLEL') ? ['bios-tables-test'] : []) +             \
+   qtests_pci +                                                                              \
+   qtests_cxl +                                                                              \
+   ['fdc-test',
+@@ -212,7 +208,6 @@
+
+ # 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') ?            \
+     ['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'] : []) + \
+@@ -222,8 +217,7 @@
+    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 + \
+@@ -301,7 +295,6 @@
+ endif
+
+ qtests = {
+-  'bios-tables-test': [io, 'boot-sector.c', 'acpi-utils.c', 'tpm-emu.c'],
+   'cdrom-test': files('boot-sector.c'),
+   'dbus-vmstate-test': files('migration-helpers.c') + dbus_vmstate1,
+   'erst-test': files('erst-test.c'),
diff --git a/gnu/packages/virtualization.scm b/gnu/packages/virtualization.scm
index 9952dd125a..4ae0049269 100644
--- a/gnu/packages/virtualization.scm
+++ b/gnu/packages/virtualization.scm
@@ -15,7 +15,7 @@
 ;;; Copyright © 2020, 2021 Brice Waegeneire <[email-masked]>
 ;;; Copyright © 2020 Mathieu Othacehe <[email-masked]>
 ;;; Copyright © 2020, 2021, 2022 Marius Bakke <[email-masked]>
-;;; Copyright © 2020, 2021, 2022 Maxim Cournoyer <[email-masked]>
+;;; Copyright © 2020, 2021, 2022, 2023 Maxim Cournoyer <[email-masked]>
 ;;; Copyright © 2020 Brett Gilio <[email-masked]>
 ;;; Copyright © 2021 Leo Famulari <[email-masked]>
 ;;; Copyright © 2021, 2022 Pierre Langlois <[email-masked]>
@@ -164,16 +164,15 @@ (define (qemu-patch commit file-name sha256-bv)
 (define-public qemu
   (package
     (name "qemu")
-    (version "7.2.4")
+    (version "8.1.0")
     (source
      (origin
        (method url-fetch)
        (uri (string-append "https://download.qemu.org/qemu-"
                            version ".tar.xz"))
        (sha256
-        (base32 "0795l8xsy67fnh4mbdz40jm880iisd7q6d7ly6nfzpac3gjr8zyf"))
-       (patches (search-patches "qemu-build-info-manual.patch"
-                                "qemu-disable-aarch64-migration-test.patch"
+        (base32 "0m8fbyr3xv6gi95ma0sksxfqmyj3pi4zcrgg5rvd8d73k08i033i"))
+       (patches (search-patches "qemu-disable-some-qtests-tests.patch"
                                 "qemu-fix-agent-paths.patch"))
        (modules '((guix build utils)))
        (snippet
@@ -182,8 +181,6 @@ (define-public qemu
            (with-directory-excursion "pc-bios"
              ;; Delete firmwares provided by SeaBIOS.
              (for-each delete-file (find-files "." "^(bios|vgabios).*\\.bin$"))
-             ;; Delete SGABIOS.
-             (delete-file "sgabios.bin")
              ;; Delete ppc64 OpenBIOS.  TODO: Remove sparc32 and sparc64 too
              ;; once they are supported in Guix.
              (delete-file "openbios-ppc")
@@ -194,12 +191,11 @@ (define-public qemu
              (for-each delete-file (find-files "." "^(efi|pxe)-.*\\.rom$")))
            ;; Delete bundled code that we provide externally.
            (for-each delete-file-recursively
-                     '("dtc" "meson"
+                     '("subprojects/dtc"
                        "roms/ipxe"
                        "roms/openbios"
                        "roms/opensbi"
-                       "roms/seabios"
-                       "roms/sgabios"))))))
+                       "roms/seabios"))))))
     (outputs '("out" "static" "doc"))   ;5.3 MiB of HTML docs
     (build-system gnu-build-system)
     (arguments
@@ -210,7 +206,6 @@ (define-public qemu
                    (not (string=? "i686-linux" (%current-system))))
       #:configure-flags
       #~(let ((gcc (search-input-file %build-inputs "/bin/gcc"))
-              (meson (search-input-file %build-inputs "bin/meson"))
               (openbios (search-input-file %build-inputs
                                            "share/qemu/openbios-ppc"))
               (opensbi (search-input-file
@@ -218,25 +213,20 @@ (define-public qemu
                         "share/qemu/opensbi-riscv64-generic-fw_dynamic.bin"))
               (seabios (search-input-file %build-inputs
                                           "share/qemu/bios.bin"))
-              (sgabios (search-input-file %build-inputs
-                                          "/share/qemu/sgabios.bin"))
               (ipxe (search-input-file %build-inputs
                                        "share/qemu/pxe-virtio.rom"))
               (out #$output))
           (list (string-append "--cc=" gcc)
                 ;; Some architectures insist on using HOST_CC.
                 (string-append "--host-cc=" gcc)
-                (string-append "--meson=" meson)
                 (string-append "--prefix=" out)
-
                 "--sysconfdir=/etc"
                 "--enable-fdt=system"
                 (string-append "--firmwarepath=" out "/share/qemu:"
                                (dirname seabios) ":"
                                (dirname ipxe) ":"
                                (dirname openbios) ":"
-                               (dirname opensbi) ":"
-                               (dirname sgabios))
+                               (dirname opensbi))
                 (string-append "--smbd=" out "/libexec/samba-wrapper")
                 "--disable-debug-info"  ;for space considerations
                 ;; The binaries need to be linked against -lrt.
@@ -257,7 +247,6 @@ (define-public qemu
               (let* ((seabios (dirname (search-input-file
                                         inputs "share/qemu/bios.bin")))
                      (seabios-firmwares (find-files seabios "\\.bin$"))
-                     (sgabios (search-input-file inputs "share/qemu/sgabios.bin"))
                      (ipxe (dirname (search-input-file
                                      inputs "share/qemu/pxe-virtio.rom")))
                      (ipxe-firmwares (find-files ipxe "\\.rom$"))
@@ -282,7 +271,7 @@ (define-public qemu
                   (for-each (lambda (file)
                               (symlink file (basename file)))
                             (append seabios-firmwares ipxe-firmwares
-                                    (list openbios opensbi-riscv64 sgabios))))
+                                    (list openbios opensbi-riscv64))))
                 (for-each (lambda (file)
                             (format allowed-differences-whitelist
                                     "\"~a\",~%" file))
@@ -405,8 +394,7 @@ (define-public qemu
                 (for-each delete-file
                           (append
                            '("openbios-ppc"
-                             "opensbi-riscv64-generic-fw_dynamic.bin"
-                             "sgabios.bin")
+                             "opensbi-riscv64-generic-fw_dynamic.bin")
                            (find-files "." "^(vga)?bios(-[a-z0-9-]+)?\\.bin$")
                            (find-files "." "^(efi|pxe)-.*\\.rom$"))))))
           ;; Create a wrapper for Samba. This allows QEMU to use Samba without
@@ -457,7 +445,6 @@ (define-public qemu
            pulseaudio
            sdl2
            seabios-qemu
-           sgabios
            spice
            usbredir
            util-linux
@@ -512,8 +499,7 @@ (define-public qemu
 
 (define-public qemu-minimal
   ;; QEMU without GUI support, only supporting the host's architecture
-  (package
-    (inherit qemu)
+  (package/inherit qemu
     (name "qemu-minimal")
     (outputs '("out" "doc"))
     (synopsis
@@ -556,7 +542,14 @@ (define-public qemu-minimal
         #~(modify-phases #$phases
             (delete 'configure-user-static)
             (delete 'build-user-static)
-            (delete 'install-user-static)))))
+            (delete 'install-user-static)
+            (add-after 'disable-unusable-tests 'disable-extra-tests
+              (lambda _
+                ;; Interesting, the iothreads-commit-active test only fails in
+                ;; qemu-minimal, not the complete variant (see:
+                ;; https://gitlab.com/qemu-project/qemu/-/issues/1855).
+                (delete-file
+                 "tests/qemu-iotests/tests/iothreads-commit-active")))))))
 
     ;; Remove dependencies on optional libraries, notably GUI libraries.
     (native-inputs (filter (lambda (input)

base-commit: d6966b8a5b4f2ddda2bc685b9642e7a1c2cbe17c
-- 
2.41.0