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

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