render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
acda74
From f895d23743a65141a2db7f816e56d18c9c4de6df Mon Sep 17 00:00:00 2001
acda74
Message-Id: <f895d23743a65141a2db7f816e56d18c9c4de6df@dist-git>
acda74
From: Michal Privoznik <mprivozn@redhat.com>
acda74
Date: Mon, 30 Jan 2023 10:55:22 +0100
acda74
Subject: [PATCH] virsh: Make domif-setlink work more than once
acda74
MIME-Version: 1.0
acda74
Content-Type: text/plain; charset=UTF-8
acda74
Content-Transfer-Encoding: 8bit
acda74
acda74
In virsh, we have this convenient domif-setlink command, which is
acda74
just a wrapper over virDomainUpdateDeviceFlags() and which allows
acda74
setting link state of given guest NIC. It does so by fetching
acda74
corresponding <interface/> XML snippet and either putting 
acda74
state=''/> into it, OR if the element already exists setting the
acda74
attribute to desired value. The XML is then fed into the update
acda74
API.
acda74
acda74
There's, however, a small bug in detecting the pre-existence of
acda74
the element and its attribute. The code looks at "link"
acda74
attribute, while in fact, the attribute is called "state".
acda74
acda74
Resolves: https://gitlab.com/libvirt/libvirt/-/issues/426
acda74
Fixes: e575bf082ed4889280be07c986375f1ca15bb7ee
acda74
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
acda74
Reviewed-by: Ján Tomko <jtomko@redhat.com>
acda74
(cherry picked from commit 6f3f6c0f763b9ffd8ef93eb124c88dd0b79138fc)
acda74
https://bugzilla.redhat.com/show_bug.cgi?id=2165466
acda74
---
acda74
 tools/virsh-domain.c | 2 +-
acda74
 1 file changed, 1 insertion(+), 1 deletion(-)
acda74
acda74
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
acda74
index 6b431bd1e5..59b2b3ce60 100644
acda74
--- a/tools/virsh-domain.c
acda74
+++ b/tools/virsh-domain.c
acda74
@@ -3209,7 +3209,7 @@ cmdDomIfSetLink(vshControl *ctl, const vshCmd *cmd)
acda74
         }
acda74
     }
acda74
 
acda74
-    if (xmlHasProp(linkNode, BAD_CAST "link"))
acda74
+    if (xmlHasProp(linkNode, BAD_CAST "state"))
acda74
         stateAttr = xmlSetProp(linkNode, BAD_CAST "state", BAD_CAST state);
acda74
     else
acda74
         stateAttr = xmlNewProp(linkNode, BAD_CAST "state", BAD_CAST state);
acda74
-- 
acda74
2.39.1
acda74