- qemu_migration: Refactor qemuMigrationSrcRestoreDomainState (RHEL-79168) - qemu_migration: Do not automatically resume domain after I/O error (RHEL-79168) - qemucapabilitiestest: Add data for the qemu-10.0 dev cycle on x86_64 (RHEL-79095) - qemucapabilitiestest: Update 'caps_10.0.0_x86_64' to 'v9.2.0-1636-gffaf7f0376' (RHEL-79095) - qemu: capabilies: Introduce QEMU_CAPS_BLOCKDEV_SET_ACTIVE (RHEL-79095) - qemu: monitor: Add monitor backend for 'blockdev-set-active' (RHEL-79095) - qemu: migration: Reactivate block nodes after migration if VM is left paused (RHEL-79095) - conf: change virDomainHostdevInsert() to return void (RHEL-69455) - qemu: fix qemu validation to forbid guest-side IP address for type='vdpa' (RHEL-69455) - qemu: validate that model is virtio for vhostuser and vdpa interfaces in the same place (RHEL-69455) - qemu: automatically set model type='virtio' for interface type='vhostuser' (RHEL-69455) - qemu: do all vhostuser attribute validation in qemu driver (RHEL-69455) - conf/qemu: make <source> element *almost* optional for type=vhostuser (RHEL-69455) - qemu: use switch instead of if in qemuProcessPrepareDomainNetwork() (RHEL-69455) - qemu: make qemuPasstCreateSocketPath() public (RHEL-69455) - qemu: complete vhostuser + passt support (RHEL-69455) - qemu: fail validation if a domain def has vhostuser/passt but no shared mem (RHEL-69455) - docs: improve type='user' docs to higlight differences between SLIRP and passt (RHEL-69455) - docs: document using passt backend with <interface type='vhostuser'> (RHEL-69455) - utils: Canonicalize paths before comparing them (RHEL-79166) Resolves: RHEL-69455, RHEL-79095, RHEL-79166, RHEL-79168
133 lines
5.9 KiB
Diff
133 lines
5.9 KiB
Diff
From cf77e1956a7d128b379f3608d38ec93c424c3ca2 Mon Sep 17 00:00:00 2001
|
|
Message-ID: <cf77e1956a7d128b379f3608d38ec93c424c3ca2.1739824249.git.jdenemar@redhat.com>
|
|
From: Laine Stump <laine@redhat.com>
|
|
Date: Tue, 11 Feb 2025 16:30:11 -0500
|
|
Subject: [PATCH] qemu: use switch instead of if in
|
|
qemuProcessPrepareDomainNetwork()
|
|
MIME-Version: 1.0
|
|
Content-Type: text/plain; charset=UTF-8
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
qemuProcessPrepareDomain()'s comments say that it should be the only
|
|
place to change the "live XML" of a domain (i.e. the public parts of
|
|
the virDomainDef object that is shown in the domain's status
|
|
XML), and that seems like a reasonable idea (although there aren't
|
|
many users of it to date).
|
|
|
|
qemuProcessPrepareDomainNetwork() is called by the aforementioned
|
|
qemuProcessPrepareDomain() - this patch changes the "if (type ==
|
|
HOSTDEV)" in that function to a "switch(type)" so it's simpler to add
|
|
DomainDef modifications for various other types of virDomainNetDef,
|
|
and also so that anyone who adds a new interface type is forced to
|
|
look at the code and decide if anything needs to be done here for the
|
|
new type.
|
|
|
|
Signed-off-by: Laine Stump <laine@redhat.com>
|
|
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
(cherry picked from commit 6fe3d765e506b2954931e228ecd233f1200dce1a)
|
|
|
|
https://issues.redhat.com/browse/RHEL-69455
|
|
Signed-off-by: Laine Stump <laine@redhat.com>
|
|
---
|
|
src/qemu/qemu_process.c | 75 ++++++++++++++++++++++++++---------------
|
|
1 file changed, 47 insertions(+), 28 deletions(-)
|
|
|
|
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
|
|
index a45f1b5b7d..26ca943dfc 100644
|
|
--- a/src/qemu/qemu_process.c
|
|
+++ b/src/qemu/qemu_process.c
|
|
@@ -5888,7 +5888,6 @@ qemuProcessPrepareDomainNetwork(virDomainObj *vm)
|
|
|
|
for (i = 0; i < def->nnets; i++) {
|
|
virDomainNetDef *net = def->nets[i];
|
|
- virDomainNetType actualType;
|
|
|
|
/* If appropriate, grab a physical device from the configured
|
|
* network's pool of devices, or resolve bridge device name
|
|
@@ -5901,36 +5900,56 @@ qemuProcessPrepareDomainNetwork(virDomainObj *vm)
|
|
return -1;
|
|
}
|
|
|
|
- actualType = virDomainNetGetActualType(net);
|
|
- if (actualType == VIR_DOMAIN_NET_TYPE_HOSTDEV &&
|
|
- net->type == VIR_DOMAIN_NET_TYPE_NETWORK) {
|
|
- /* Each type='hostdev' network device must also have a
|
|
- * corresponding entry in the hostdevs array. For netdevs
|
|
- * that are hardcoded as type='hostdev', this is already
|
|
- * done by the parser, but for those allocated from a
|
|
- * network / determined at runtime, we need to do it
|
|
- * separately.
|
|
- */
|
|
- virDomainHostdevDef *hostdev = virDomainNetGetActualHostdev(net);
|
|
- virDomainHostdevSubsysPCI *pcisrc = &hostdev->source.subsys.u.pci;
|
|
-
|
|
- if (virDomainHostdevFind(def, hostdev, NULL) >= 0) {
|
|
- virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
- _("PCI device %1$04x:%2$02x:%3$02x.%4$x allocated from network %5$s is already in use by domain %6$s"),
|
|
- pcisrc->addr.domain, pcisrc->addr.bus,
|
|
- pcisrc->addr.slot, pcisrc->addr.function,
|
|
- net->data.network.name, def->name);
|
|
- return -1;
|
|
- }
|
|
+ switch (virDomainNetGetActualType(net)) {
|
|
+ case VIR_DOMAIN_NET_TYPE_HOSTDEV:
|
|
+ if (net->type == VIR_DOMAIN_NET_TYPE_NETWORK) {
|
|
+ /* Each type='hostdev' network device must also have a
|
|
+ * corresponding entry in the hostdevs array. For netdevs
|
|
+ * that are hardcoded as type='hostdev', this is already
|
|
+ * done by the parser, but for those allocated from a
|
|
+ * network / determined at runtime, we need to do it
|
|
+ * separately.
|
|
+ */
|
|
+ virDomainHostdevDef *hostdev = virDomainNetGetActualHostdev(net);
|
|
+ virDomainHostdevSubsysPCI *pcisrc = &hostdev->source.subsys.u.pci;
|
|
+
|
|
+ if (virDomainHostdevFind(def, hostdev, NULL) >= 0) {
|
|
+ virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
+ _("PCI device %1$04x:%2$02x:%3$02x.%4$x allocated from network %5$s is already in use by domain %6$s"),
|
|
+ pcisrc->addr.domain, pcisrc->addr.bus,
|
|
+ pcisrc->addr.slot, pcisrc->addr.function,
|
|
+ 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;
|
|
+ /* 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;
|
|
|
|
- virDomainHostdevInsert(def, hostdev);
|
|
+ virDomainHostdevInsert(def, hostdev);
|
|
+ }
|
|
+ break;
|
|
+
|
|
+ case VIR_DOMAIN_NET_TYPE_DIRECT:
|
|
+ case VIR_DOMAIN_NET_TYPE_BRIDGE:
|
|
+ case VIR_DOMAIN_NET_TYPE_NETWORK:
|
|
+ case VIR_DOMAIN_NET_TYPE_ETHERNET:
|
|
+ case VIR_DOMAIN_NET_TYPE_USER:
|
|
+ case VIR_DOMAIN_NET_TYPE_VHOSTUSER:
|
|
+ case VIR_DOMAIN_NET_TYPE_SERVER:
|
|
+ case VIR_DOMAIN_NET_TYPE_CLIENT:
|
|
+ case VIR_DOMAIN_NET_TYPE_MCAST:
|
|
+ case VIR_DOMAIN_NET_TYPE_INTERNAL:
|
|
+ case VIR_DOMAIN_NET_TYPE_UDP:
|
|
+ case VIR_DOMAIN_NET_TYPE_VDPA:
|
|
+ case VIR_DOMAIN_NET_TYPE_NULL:
|
|
+ case VIR_DOMAIN_NET_TYPE_VDS:
|
|
+ case VIR_DOMAIN_NET_TYPE_LAST:
|
|
+ break;
|
|
}
|
|
+
|
|
}
|
|
return 0;
|
|
}
|
|
--
|
|
2.48.1
|