mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-24 22:55:23 +00:00
conf: domain: Convert virDomainDiskDef's 'removable' to virTristateSwitch
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: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
61fd7174c2
commit
35efc9b535
@ -9319,7 +9319,6 @@ virDomainDiskDefParseXML(virDomainXMLOption *xmlopt,
|
||||
g_autofree char *target = NULL;
|
||||
g_autofree char *bus = NULL;
|
||||
g_autofree char *serial = NULL;
|
||||
g_autofree char *removable = NULL;
|
||||
g_autofree char *logical_block_size = NULL;
|
||||
g_autofree char *physical_block_size = NULL;
|
||||
g_autofree char *wwn = NULL;
|
||||
@ -9381,7 +9380,11 @@ virDomainDiskDefParseXML(virDomainXMLOption *xmlopt,
|
||||
if (virXMLPropEnum(cur, "tray", virDomainDiskTrayTypeFromString,
|
||||
VIR_XML_PROP_OPTIONAL, &def->tray_status) < 0)
|
||||
return NULL;
|
||||
removable = virXMLPropString(cur, "removable");
|
||||
|
||||
if (virXMLPropTristateSwitch(cur, "removable", VIR_XML_PROP_OPTIONAL,
|
||||
&def->removable) < 0)
|
||||
return NULL;
|
||||
|
||||
rotation_rate = virXMLPropString(cur, "rotation_rate");
|
||||
} else if (!domain_name &&
|
||||
virXMLNodeNameEqual(cur, "backenddomain")) {
|
||||
@ -9495,14 +9498,6 @@ virDomainDiskDefParseXML(virDomainXMLOption *xmlopt,
|
||||
}
|
||||
}
|
||||
|
||||
if (removable) {
|
||||
if ((def->removable = virTristateSwitchTypeFromString(removable)) < 0) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("unknown disk removable status '%s'"), removable);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (rotation_rate &&
|
||||
virStrToLong_ui(rotation_rate, NULL, 10, &def->rotation_rate) < 0) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
|
@ -539,7 +539,7 @@ struct _virDomainDiskDef {
|
||||
int bus; /* enum virDomainDiskBus */
|
||||
char *dst;
|
||||
virDomainDiskTray tray_status;
|
||||
int removable; /* enum virTristateSwitch */
|
||||
virTristateSwitch removable;
|
||||
unsigned int rotation_rate;
|
||||
|
||||
virStorageSource *mirror;
|
||||
|
Loading…
Reference in New Issue
Block a user