[PATCH] qemu: match alias when looking for proper <interface> to detach.

Laine Stump posted 1 patch 3 years, 1 month ago
Test syntax-check failed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/20210210213321.76804-1-laine@redhat.com
src/conf/domain_conf.c | 5 +++++
1 file changed, 5 insertions(+)
[PATCH] qemu: match alias when looking for proper <interface> to detach.
Posted by Laine Stump 3 years, 1 month ago
Previously we only checked MAC address and PCI address (or CCW
address). This is not enough information in cases where PCI address
isn't provided and multiple interfaces have the same MAC address (for
example, a virtio + hostdev "teaming" pair - their MAC addresses are
always the same).

Resolves: https://bugzilla.redhat.com/1926190
Signed-off-by: Laine Stump <laine@redhat.com>
---

Arguably, it would be nice to overhaul the device matching used for
virDomainDeviceDetach for *all* the device types, as they could all be
matched by looking at alias (and PCI address, for that matter). On the
other hand, for all other device types there are already enough fields
being matched to assure a unique match even without looking at
alias/PCI address, and this patch is intended to fix a current problem
being experienced in the wild, meaning it's likely that it will need
to be backported to stable branches, and I'd rather not force
backporting a sweeping change to stable branches just to bring in a
fix for one corner case)


 src/conf/domain_conf.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 07e6f39256..8f2207bdf6 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -16431,6 +16431,11 @@ virDomainNetFindIdx(virDomainDefPtr def, virDomainNetDefPtr net)
                                             &net->info.addr.ccw))
             continue;
 
+        if (net->info.alias &&
+            STRNEQ_NULLABLE(def->nets[i]->info.alias, net->info.alias)) {
+            continue;
+        }
+
         if (matchidx >= 0) {
             /* there were multiple matches on mac address, and no
              * qualifying guest-side PCI/CCW address was given, so we must
-- 
2.29.2