Blame SOURCES/0004-launch-libvirt-place-our-virtio-net-pci-device-in-sl.patch

a7e38b
From 43e0fdd6cb94370e74b1214c7550aa98b8307409 Mon Sep 17 00:00:00 2001
a7e38b
From: Laszlo Ersek <lersek@redhat.com>
a7e38b
Date: Thu, 23 Dec 2021 11:36:59 +0100
a7e38b
Subject: [PATCH] launch-libvirt: place our virtio-net-pci device in slot 0x1e
a7e38b
a7e38b
The <qemu:commandline> trick we use for adding our virtio-net-pci device
a7e38b
in the libvirt backend can conflict with libvirtd's and QEMU's PCI address
a7e38b
assignment. Try to mitigate that by placing our device in slot 0x1e on the
a7e38b
root bus. In practice this could only conflict with a "dmi-to-pci-bridge"
a7e38b
device model, which libvirtd itself places in slot 0x1e. However, given
a7e38b
the XMLs we generate, and modern QEMU versions, libvirtd has no reason to
a7e38b
auto-add "dmi-to-pci-bridge". Refer to
a7e38b
<https://libvirt.org/formatdomain.html#controllers>.
a7e38b
a7e38b
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2034160
a7e38b
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
a7e38b
Message-Id: <20211223103701.12702-2-lersek@redhat.com>
a7e38b
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
a7e38b
Tested-by: Richard W.M. Jones <rjones@redhat.com>
a7e38b
(cherry picked from commit 5ce5ef6a97a58c5e906083ad4e944545712b3f3f)
a7e38b
---
a7e38b
 lib/guestfs-internal.h | 11 +++++++++++
a7e38b
 lib/launch-libvirt.c   |  4 +++-
a7e38b
 2 files changed, 14 insertions(+), 1 deletion(-)
a7e38b
a7e38b
diff --git a/lib/guestfs-internal.h b/lib/guestfs-internal.h
a7e38b
index 4097b33fd..8eb2dd3ad 100644
a7e38b
--- a/lib/guestfs-internal.h
a7e38b
+++ b/lib/guestfs-internal.h
a7e38b
@@ -172,6 +172,17 @@ cleanup_mutex_unlock (pthread_mutex_t **ptr)
a7e38b
 #define VIRTIO_DEVICE_NAME(type) type "-pci"
a7e38b
 #endif
a7e38b
 
a7e38b
+/* Place the virtio-net controller in slot 0x1e on the root bus, on normal
a7e38b
+ * hardware with PCI. Refer to RHBZ#2034160.
a7e38b
+ */
a7e38b
+#ifdef HAVE_LIBVIRT_BACKEND
a7e38b
+#if defined(__arm__) || defined(__s390x__)
a7e38b
+#define VIRTIO_NET_PCI_ADDR ""
a7e38b
+#else
a7e38b
+#define VIRTIO_NET_PCI_ADDR ",addr=1e.0"
a7e38b
+#endif
a7e38b
+#endif
a7e38b
+
a7e38b
 /* Guestfs handle and associated structures. */
a7e38b
 
a7e38b
 /* State. */
a7e38b
diff --git a/lib/launch-libvirt.c b/lib/launch-libvirt.c
a7e38b
index 194530c49..9e8336938 100644
a7e38b
--- a/lib/launch-libvirt.c
a7e38b
+++ b/lib/launch-libvirt.c
a7e38b
@@ -1851,7 +1851,9 @@ construct_libvirt_xml_qemu_cmdline (guestfs_h *g,
a7e38b
       } end_element ();
a7e38b
 
a7e38b
       start_element ("qemu:arg") {
a7e38b
-        attribute ("value", VIRTIO_DEVICE_NAME ("virtio-net") ",netdev=usernet");
a7e38b
+        attribute ("value", (VIRTIO_DEVICE_NAME ("virtio-net")
a7e38b
+                             ",netdev=usernet"
a7e38b
+                             VIRTIO_NET_PCI_ADDR));
a7e38b
       } end_element ();
a7e38b
     }
a7e38b
 
a7e38b
-- 
a7e38b
2.31.1
a7e38b