conf: domain: Convert virDomainDiskDef's 'startupPolicy' to virDomainStartupPolicy

Use the appropriate type for the variable and refactor the XML parser to
parse it correctly using virXMLPropEnum.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
This commit is contained in:
Peter Krempa 2021-04-16 10:46:00 +02:00
parent 56be92b473
commit ac87f612ba
2 changed files with 6 additions and 15 deletions

View File

@ -9343,7 +9343,6 @@ virDomainDiskDefParseXML(virDomainXMLOption *xmlopt,
g_autofree char *target = NULL;
g_autofree char *bus = NULL;
g_autofree char *serial = NULL;
g_autofree char *startupPolicy = NULL;
g_autofree char *removable = NULL;
g_autofree char *logical_block_size = NULL;
g_autofree char *physical_block_size = NULL;
@ -9401,7 +9400,11 @@ virDomainDiskDefParseXML(virDomainXMLOption *xmlopt,
source = true;
startupPolicy = virXMLPropString(cur, "startupPolicy");
if (virXMLPropEnum(cur, "startupPolicy",
virDomainStartupPolicyTypeFromString,
VIR_XML_PROP_OPTIONAL | VIR_XML_PROP_NONZERO,
&def->startupPolicy) < 0)
return NULL;
if (!(flags & VIR_DOMAIN_DEF_PARSE_INACTIVE) &&
(tmp = virXMLPropString(cur, "index")) &&
@ -9655,18 +9658,6 @@ virDomainDiskDefParseXML(virDomainXMLOption *xmlopt,
return NULL;
}
if (startupPolicy) {
int val;
if ((val = virDomainStartupPolicyTypeFromString(startupPolicy)) <= 0) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unknown startupPolicy value '%s'"),
startupPolicy);
return NULL;
}
def->startupPolicy = val;
}
def->dst = g_steal_pointer(&target);
if (authdef) {
/* If we've already parsed <source> and found an <auth> child,

View File

@ -573,7 +573,7 @@ struct _virDomainDiskDef {
virTristateSwitch event_idx;
virTristateSwitch copy_on_read;
int snapshot; /* virDomainSnapshotLocation, snapshot_conf.h */
int startupPolicy; /* enum virDomainStartupPolicy */
virDomainStartupPolicy startupPolicy;
bool transient;
virDomainDeviceInfo info;
int rawio; /* enum virTristateBool */