From: Daniel P. Berrange Date: Tue, 15 May 2012 15:16:49 +0000 (+0100) Subject: Fix virDomainDeviceInfoIsSet() to check all struct fields X-Git-Tag: v0.9.6.1~11 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b4e9a21c3b568ad4aeed6e90506f6c58172c5b77;p=thirdparty%2Flibvirt.git Fix virDomainDeviceInfoIsSet() to check all struct fields 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) --- diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 318f523316..85ef71b9f4 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -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; } diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index f4a38fbf3a..f2cd8eb800 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -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 {