mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-21 12:05:17 +00:00
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)
This commit is contained in:
parent
9a42097bf4
commit
73cfdbff65
@ -1896,14 +1896,21 @@ int virDomainDevicePCIAddressIsValid(virDomainDevicePCIAddressPtr addr)
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
if ((info->rombar != VIR_DOMAIN_PCI_ROMBAR_DEFAULT) ||
|
||||
info->romfile)
|
||||
return true;
|
||||
if (info->bootIndex)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
void virDomainDeviceInfoClear(virDomainDeviceInfoPtr info)
|
||||
|
@ -253,6 +253,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 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user