]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
interface: dump inactive xml when interface isn't active
authorLaine Stump <laine@laine.org>
Mon, 7 Apr 2014 12:32:00 +0000 (15:32 +0300)
committerCole Robinson <crobinso@redhat.com>
Sat, 3 May 2014 20:50:43 +0000 (16:50 -0400)
Other drivers in libvirt (e.g. network, qemu) will automatically
return the "inactive" (persistent configuration) XML of an object when
that object is inactive. The netcf backend of the interface driver
would always try to return the live status XML of the interface, even
when it was down. Although netcf does return valid XML in that case,
for bond interfaces it is missing almost all of its content, including
the <bond> subelement itself, leading to this error message from
"virsh iface-dumpxml" of a bond interface that is inactive:

  error: XML error: bond interface misses the bond element

(this is because libvirt's validation of the XML returned by netcf
always requires a <bond> element be present).

This patch modifies the interface driver netcf backend to check if the
interface is inactive, and in that case always return the inactive XML
(which will always have a <bond> element, thus eliminating the error
message, as well as making operation more in line with other drivers.

This fixes the following bug:

  https://bugzilla.redhat.com/show_bug.cgi?id=878394

(cherry picked from commit 7284c499e54e538fd0ab35a1f09e358f06fc23b0)

src/interface/interface_backend_netcf.c

index ecf9ddd9bfc21fe3ef6045dcc0c6a3442d5d5bef..8fab1703d0a5e1a4ba4a9af46ac63f981b6a7cd0 100644 (file)
@@ -802,6 +802,7 @@ static char *netcfInterfaceGetXMLDesc(virInterfacePtr ifinfo,
     char *xmlstr = NULL;
     virInterfaceDefPtr ifacedef = NULL;
     char *ret = NULL;
+    bool active;
 
     virCheckFlags(VIR_INTERFACE_XML_INACTIVE, NULL);
 
@@ -813,7 +814,10 @@ static char *netcfInterfaceGetXMLDesc(virInterfacePtr ifinfo,
         goto cleanup;
     }
 
-    if ((flags & VIR_INTERFACE_XML_INACTIVE)) {
+    if (netcfInterfaceObjIsActive(iface, &active) < 0)
+       goto cleanup;
+
+    if ((flags & VIR_INTERFACE_XML_INACTIVE) || !active) {
         xmlstr = ncf_if_xml_desc(iface);
     } else {
         xmlstr = ncf_if_xml_state(iface);