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

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