[libvirt] [PATCH] Fix virsh {net,pool}-edit

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The dumpxml commands for networks and pools don't support any flag
arguments, and in fact explictly fail if flags != 0. This is not the
case for vm dumpxml though, and flags were added to the base 'edit'
implementation in virsh recently.

The net and pool derivatives were not addressing this difference, so any
net-edit or pool-edit attempt currently gives an error like:

Network error : invalid argument in virNetworkGetXMLDesc

The attached patch is one way to fix this. Thanks to Charles Duffy for
the report.

- Cole
diff --git a/src/Makefile.am b/src/Makefile.am
index 9d934b4..3a798d2 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -510,6 +510,7 @@ virsh-net-edit.c: virsh.c Makefile.am
 	      -e 's/Domain/Network/g' \
 	      -e 's/cmdEdit/cmdNetworkEdit/g' \
 	      -e 's/dom/network/g' \
+	      -e 's/int flags.*/int flags = 0;/g' \
 	>> $@-tmp
 	chmod a-w $@-tmp
 	rm -f $@
@@ -528,6 +529,7 @@ virsh-pool-edit.c: virsh.c Makefile.am
 	      -e 's/cmdEdit/cmdPoolEdit/g' \
 	      -e 's/\(virStoragePoolDefineXML.*\));/\1, 0);/' \
 	      -e 's/dom/pool/g' \
+	      -e 's/int flags.*/int flags = 0;/g' \
 	>> $@-tmp
 	chmod a-w $@-tmp
 	rm -f $@
diff --git a/src/virsh.c b/src/virsh.c
index 57bd396..298dde0 100644
--- a/src/virsh.c
+++ b/src/virsh.c
@@ -5397,6 +5397,7 @@ cmdEdit (vshControl *ctl, const vshCmd *cmd)
     char *doc = NULL;
     char *doc_edited = NULL;
     char *doc_reread = NULL;
+    int flags = VIR_DOMAIN_XML_SECURE | VIR_DOMAIN_XML_INACTIVE;
 
     if (!vshConnectionUsability(ctl, ctl->conn, TRUE))
         goto cleanup;
@@ -5406,7 +5407,7 @@ cmdEdit (vshControl *ctl, const vshCmd *cmd)
         goto cleanup;
 
     /* Get the XML configuration of the domain. */
-    doc = virDomainGetXMLDesc (dom, VIR_DOMAIN_XML_SECURE | VIR_DOMAIN_XML_INACTIVE);
+    doc = virDomainGetXMLDesc (dom, flags);
     if (!doc)
         goto cleanup;
 
@@ -5436,7 +5437,7 @@ cmdEdit (vshControl *ctl, const vshCmd *cmd)
      * it was being edited?  This also catches problems such as us
      * losing a connection or the domain going away.
      */
-    doc_reread = virDomainGetXMLDesc (dom, VIR_DOMAIN_XML_SECURE | VIR_DOMAIN_XML_INACTIVE);
+    doc_reread = virDomainGetXMLDesc (dom, flags);
     if (!doc_reread)
         goto cleanup;
 
--
Libvir-list mailing list
Libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]