[libvirt] [PATCH 3/3] virsh: Adjust logic checks in virshUpdateDiskXML

John Ferlan jferlan at redhat.com
Tue Dec 17 20:30:04 UTC 2019


Make it clearer that what we're trying to do is find @source and
@target_node so that the unattentive or code analysis utility
doesn't believe 'source' and 'target' could be found in the same
node element.

Signed-off-by: John Ferlan <jferlan at redhat.com>
---
 tools/virsh-domain.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 56137bdd74..9d4cdd26dd 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -12476,10 +12476,9 @@ virshUpdateDiskXML(xmlNodePtr disk_node,
         if (tmp->type != XML_ELEMENT_NODE)
             continue;
 
-        if (virXMLNodeNameEqual(tmp, "source"))
+        if (!source && virXMLNodeNameEqual(tmp, "source"))
             source = tmp;
-
-        if (virXMLNodeNameEqual(tmp, "target"))
+        else if (!target_node && virXMLNodeNameEqual(tmp, "target"))
             target_node = tmp;
 
         /*
-- 
2.23.0




More information about the libvir-list mailing list