conf: domain: Convert virDomainDiskDef's 'snapshot' to unsigned int

Unfortunately virDomainSnapshotLocation is declared in snapshot_conf.h
which includes domain_conf.h. To avoid a circular dependency use
'unsigned int' for now.

Use XML parser can use virXMLPropEnum.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Peter Krempa 2021-04-16 10:46:00 +02:00
parent 21c10943a9
commit 1db5a84bdc
2 changed files with 4 additions and 13 deletions

View File

@ -9313,7 +9313,6 @@ virDomainDiskDefParseXML(virDomainXMLOption *xmlopt,
VIR_XPATH_NODE_AUTORESTORE(ctxt) VIR_XPATH_NODE_AUTORESTORE(ctxt)
bool source = false; bool source = false;
g_autofree char *tmp = NULL; g_autofree char *tmp = NULL;
g_autofree char *snapshot = NULL;
g_autofree char *target = NULL; g_autofree char *target = NULL;
g_autofree char *bus = NULL; g_autofree char *bus = NULL;
g_autofree char *serial = NULL; g_autofree char *serial = NULL;
@ -9349,7 +9348,9 @@ virDomainDiskDefParseXML(virDomainXMLOption *xmlopt,
VIR_XML_PROP_OPTIONAL, &def->model) < 0) VIR_XML_PROP_OPTIONAL, &def->model) < 0)
return NULL; return NULL;
snapshot = virXMLPropString(node, "snapshot"); if (virXMLPropEnum(node, "snapshot", virDomainSnapshotLocationTypeFromString,
VIR_XML_PROP_OPTIONAL | VIR_XML_PROP_NONZERO, &def->snapshot) < 0)
return NULL;
if (virXMLPropTristateBool(node, "rawio", VIR_XML_PROP_OPTIONAL, &def->rawio) < 0) if (virXMLPropTristateBool(node, "rawio", VIR_XML_PROP_OPTIONAL, &def->rawio) < 0)
return NULL; return NULL;
@ -9461,16 +9462,6 @@ virDomainDiskDefParseXML(virDomainXMLOption *xmlopt,
} }
} }
if (snapshot) {
def->snapshot = virDomainSnapshotLocationTypeFromString(snapshot);
if (def->snapshot <= 0) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unknown disk snapshot setting '%s'"),
snapshot);
return NULL;
}
}
if (bus) { if (bus) {
if ((def->bus = virDomainDiskBusTypeFromString(bus)) <= 0) { if ((def->bus = virDomainDiskBusTypeFromString(bus)) <= 0) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, virReportError(VIR_ERR_CONFIG_UNSUPPORTED,

View File

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