]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Fix virDomainDeviceInfoIsSet() to check all struct fields
authorDaniel P. Berrange <berrange@redhat.com>
Tue, 15 May 2012 15:16:49 +0000 (16:16 +0100)
committerCole Robinson <crobinso@redhat.com>
Fri, 15 Jun 2012 14:58:24 +0000 (10:58 -0400)
The virDomainDeviceInfoIsSet API was only checking if an
address or alias was set in the struct. Thus if only a
rom bar setting / filename, boot index, or USB master
value was set, they could be accidentally dropped when
formatting XML
(cherry picked from commit 2c195fdbf3293792e39bc4f06755ae751025b0ea)

Conflicts:

src/conf/domain_conf.c

(crobinso: some elements aren't in maint branch, drop them)

src/conf/domain_conf.c
src/conf/domain_conf.h

index 318f52331655002ba6dc10e5e50969c81b5f4dad..85ef71b9f40cf50ffcf95ca0e202ba46c0200e72 100644 (file)
@@ -1508,14 +1508,16 @@ int virDomainDeviceVirtioSerialAddressIsValid(
 }
 
 
-static int
+static bool
 virDomainDeviceInfoIsSet(virDomainDeviceInfoPtr info, unsigned int flags)
 {
     if (info->type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE)
-        return 1;
+        return true;
     if (info->alias && !(flags & VIR_DOMAIN_XML_INACTIVE))
-        return 1;
-    return 0;
+        return true;
+    if (info->mastertype != VIR_DOMAIN_CONTROLLER_MASTER_NONE)
+        return true;
+    return false;
 }
 
 
index f4a38fbf3af912c16ca2d1e1d1b5d3d1ffb136c3..f2cd8eb80091c1cbc440341c3ceddd30526f7676 100644 (file)
@@ -138,6 +138,10 @@ struct _virDomainDeviceUSBMaster {
 typedef struct _virDomainDeviceInfo virDomainDeviceInfo;
 typedef virDomainDeviceInfo *virDomainDeviceInfoPtr;
 struct _virDomainDeviceInfo {
+    /* If adding to this struct, ensure that
+     * virDomainDeviceInfoIsSet() is updated
+     * to consider the new fields
+     */
     char *alias;
     int type;
     union {