]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: Set proper PCI backend for <interface/>-s that are actually hostdevs
authorMichal Privoznik <mprivozn@redhat.com>
Thu, 1 Jun 2023 11:47:14 +0000 (13:47 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Mon, 5 Jun 2023 10:18:53 +0000 (12:18 +0200)
When starting a domain, it's done so in two steps (actually more,
but lets focus on just the following two):

  1) qemuProcessPrepareDomain(), followed by

  2) qemuProcessPrepareHost().

Now, in the first step (PrepareDomain()), PCI backends for all
hostdevs is set (qemuProcessPrepareDomain() ->
qemuProcessPrepareDomainHostdevs() -> qemuDomainPrepareHostdev()
-> qemuDomainPrepareHostdevPCI()). Perfect.

But then, additional hostdevs may appear, because in the host
prepare phase we may insert some hostdevs into domain definition
(qemuProcessPrepareHost() -> qemuProcessNetworkPrepareDevices()).

Now, these additional hostdevs don't undergo the same prepare as
hostdevs that were already present in the domain definition (i.e.
in qemuProcessPrepareDomain() phase). Therefore, we have to call
corresponding prepare function explicitly.

NB, the interface hotplug code (qemuDomainAttachNetDevice()) does
not suffer from this problem, because it calls top level
qemuDomainAttachHostDevice() which is used to hotplug regular
hostdevs too and as such calls qemuDomainPrepareHostdev().

Fixes: 3b87709c768480e085556e06bd8d08f62270d42d
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2209853
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
src/qemu/qemu_process.c

index 730e59eb7eca3bdc4dec61e81c5f141700ef20cd..de18fd7a3d93c38fffc91fc9ac553819508883d6 100644 (file)
@@ -5834,6 +5834,13 @@ qemuProcessNetworkPrepareDevices(virQEMUDriver *driver,
                                net->data.network.name, def->name);
                 return -1;
             }
+
+            /* For hostdev present in qemuProcessPrepareDomain() phase this was
+             * done already, but this code runs after that, so we have to call
+             * it ourselves. */
+            if (qemuDomainPrepareHostdev(hostdev, priv) < 0)
+                return -1;
+
             if (virDomainHostdevInsert(def, hostdev) < 0)
                 return -1;
         } else if (actualType == VIR_DOMAIN_NET_TYPE_USER &&