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

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