mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-11 15:27:47 +00:00
conf: domain: Convert virDomainDiskDef's 'tray_status' to virDomainDiskTray
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:
parent
f1c9fed2ca
commit
56be92b473
@ -9344,7 +9344,6 @@ virDomainDiskDefParseXML(virDomainXMLOption *xmlopt,
|
||||
g_autofree char *bus = NULL;
|
||||
g_autofree char *serial = NULL;
|
||||
g_autofree char *startupPolicy = NULL;
|
||||
g_autofree char *tray = NULL;
|
||||
g_autofree char *removable = NULL;
|
||||
g_autofree char *logical_block_size = NULL;
|
||||
g_autofree char *physical_block_size = NULL;
|
||||
@ -9415,7 +9414,9 @@ virDomainDiskDefParseXML(virDomainXMLOption *xmlopt,
|
||||
virXMLNodeNameEqual(cur, "target")) {
|
||||
target = virXMLPropString(cur, "dev");
|
||||
bus = virXMLPropString(cur, "bus");
|
||||
tray = virXMLPropString(cur, "tray");
|
||||
if (virXMLPropEnum(cur, "tray", virDomainDiskTrayTypeFromString,
|
||||
VIR_XML_PROP_OPTIONAL, &def->tray_status) < 0)
|
||||
return NULL;
|
||||
removable = virXMLPropString(cur, "removable");
|
||||
rotation_rate = virXMLPropString(cur, "rotation_rate");
|
||||
|
||||
@ -9634,14 +9635,6 @@ virDomainDiskDefParseXML(virDomainXMLOption *xmlopt,
|
||||
}
|
||||
}
|
||||
|
||||
if (tray) {
|
||||
if ((def->tray_status = virDomainDiskTrayTypeFromString(tray)) < 0) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("unknown disk tray status '%s'"), tray);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (removable) {
|
||||
if ((def->removable = virTristateSwitchTypeFromString(removable)) < 0) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
|
@ -537,7 +537,7 @@ struct _virDomainDiskDef {
|
||||
int device; /* enum virDomainDiskDevice */
|
||||
int bus; /* enum virDomainDiskBus */
|
||||
char *dst;
|
||||
int tray_status; /* enum virDomainDiskTray */
|
||||
virDomainDiskTray tray_status;
|
||||
int removable; /* enum virTristateSwitch */
|
||||
unsigned int rotation_rate;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user