mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 11:35:19 +00:00
conf: domain: Convert virDomainDiskDef's 'device' to virDomainDiskDevice
Use the appropriate type for the variable and refactor the XML parser to parse it correctly using virXMLPropEnum. Changes to other places using switch statements were required. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
0d7f0fe81a
commit
02dfea6693
@ -208,6 +208,9 @@ bhyveBuildAHCIControllerArgStr(const virDomainDef *def,
|
|||||||
else
|
else
|
||||||
virBufferAsprintf(&device, "-cd,%s", disk_source);
|
virBufferAsprintf(&device, "-cd,%s", disk_source);
|
||||||
break;
|
break;
|
||||||
|
case VIR_DOMAIN_DISK_DEVICE_FLOPPY:
|
||||||
|
case VIR_DOMAIN_DISK_DEVICE_LUN:
|
||||||
|
case VIR_DOMAIN_DISK_DEVICE_LAST:
|
||||||
default:
|
default:
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||||
_("unsupported disk device"));
|
_("unsupported disk device"));
|
||||||
|
@ -9319,7 +9319,6 @@ virDomainDiskDefParseXML(virDomainXMLOption *xmlopt,
|
|||||||
xmlNodePtr cur;
|
xmlNodePtr cur;
|
||||||
VIR_XPATH_NODE_AUTORESTORE(ctxt)
|
VIR_XPATH_NODE_AUTORESTORE(ctxt)
|
||||||
bool source = false;
|
bool source = false;
|
||||||
g_autofree char *tmp = NULL;
|
|
||||||
g_autofree char *target = NULL;
|
g_autofree char *target = NULL;
|
||||||
g_autofree char *serial = NULL;
|
g_autofree char *serial = NULL;
|
||||||
g_autofree char *logical_block_size = NULL;
|
g_autofree char *logical_block_size = NULL;
|
||||||
@ -9342,13 +9341,9 @@ virDomainDiskDefParseXML(virDomainXMLOption *xmlopt,
|
|||||||
/* defaults */
|
/* defaults */
|
||||||
def->device = VIR_DOMAIN_DISK_DEVICE_DISK;
|
def->device = VIR_DOMAIN_DISK_DEVICE_DISK;
|
||||||
|
|
||||||
if ((tmp = virXMLPropString(node, "device")) &&
|
if (virXMLPropEnum(node, "device", virDomainDiskDeviceTypeFromString,
|
||||||
(def->device = virDomainDiskDeviceTypeFromString(tmp)) < 0) {
|
VIR_XML_PROP_OPTIONAL, &def->device) < 0)
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
|
||||||
_("unknown disk device '%s'"), tmp);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
|
||||||
VIR_FREE(tmp);
|
|
||||||
|
|
||||||
if (virXMLPropEnum(node, "model", virDomainDiskModelTypeFromString,
|
if (virXMLPropEnum(node, "model", virDomainDiskModelTypeFromString,
|
||||||
VIR_XML_PROP_OPTIONAL, &def->model) < 0)
|
VIR_XML_PROP_OPTIONAL, &def->model) < 0)
|
||||||
|
@ -535,7 +535,7 @@ struct _virDomainDiskDef {
|
|||||||
|
|
||||||
virObject *privateData;
|
virObject *privateData;
|
||||||
|
|
||||||
int device; /* enum virDomainDiskDevice */
|
virDomainDiskDevice device;
|
||||||
virDomainDiskBus bus;
|
virDomainDiskBus bus;
|
||||||
char *dst;
|
char *dst;
|
||||||
virDomainDiskTray tray_status;
|
virDomainDiskTray tray_status;
|
||||||
|
@ -886,6 +886,8 @@ hypervDomainAttachStorageVolume(virDomainPtr domain,
|
|||||||
return hypervDomainAttachCDROM(domain, disk, controller, hostname);
|
return hypervDomainAttachCDROM(domain, disk, controller, hostname);
|
||||||
case VIR_DOMAIN_DISK_DEVICE_FLOPPY:
|
case VIR_DOMAIN_DISK_DEVICE_FLOPPY:
|
||||||
return hypervDomainAttachFloppy(domain, disk, controller, hostname);
|
return hypervDomainAttachFloppy(domain, disk, controller, hostname);
|
||||||
|
case VIR_DOMAIN_DISK_DEVICE_LUN:
|
||||||
|
case VIR_DOMAIN_DISK_DEVICE_LAST:
|
||||||
default:
|
default:
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Unsupported disk bus"));
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Unsupported disk bus"));
|
||||||
break;
|
break;
|
||||||
|
@ -3084,6 +3084,9 @@ libxlDomainAttachDeviceDiskLive(virDomainObj *vm, virDomainDeviceDef *dev)
|
|||||||
virDomainDiskBusTypeToString(l_disk->bus));
|
virDomainDiskBusTypeToString(l_disk->bus));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case VIR_DOMAIN_DISK_DEVICE_FLOPPY:
|
||||||
|
case VIR_DOMAIN_DISK_DEVICE_LUN:
|
||||||
|
case VIR_DOMAIN_DISK_DEVICE_LAST:
|
||||||
default:
|
default:
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||||
_("disk device type '%s' cannot be hotplugged"),
|
_("disk device type '%s' cannot be hotplugged"),
|
||||||
@ -3369,6 +3372,10 @@ libxlDomainDetachDeviceDiskLive(virDomainObj *vm, virDomainDeviceDef *dev)
|
|||||||
virDomainDiskBusTypeToString(dev->data.disk->bus));
|
virDomainDiskBusTypeToString(dev->data.disk->bus));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case VIR_DOMAIN_DISK_DEVICE_CDROM:
|
||||||
|
case VIR_DOMAIN_DISK_DEVICE_FLOPPY:
|
||||||
|
case VIR_DOMAIN_DISK_DEVICE_LUN:
|
||||||
|
case VIR_DOMAIN_DISK_DEVICE_LAST:
|
||||||
default:
|
default:
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||||
_("device type '%s' cannot hot unplugged"),
|
_("device type '%s' cannot hot unplugged"),
|
||||||
@ -4031,6 +4038,10 @@ libxlDomainUpdateDeviceLive(virDomainObj *vm, virDomainDeviceDef *dev)
|
|||||||
if (ret == 0)
|
if (ret == 0)
|
||||||
dev->data.disk = NULL;
|
dev->data.disk = NULL;
|
||||||
break;
|
break;
|
||||||
|
case VIR_DOMAIN_DISK_DEVICE_DISK:
|
||||||
|
case VIR_DOMAIN_DISK_DEVICE_FLOPPY:
|
||||||
|
case VIR_DOMAIN_DISK_DEVICE_LUN:
|
||||||
|
case VIR_DOMAIN_DISK_DEVICE_LAST:
|
||||||
default:
|
default:
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||||
_("disk bus '%s' cannot be updated."),
|
_("disk bus '%s' cannot be updated."),
|
||||||
|
@ -2253,6 +2253,10 @@ qemuBuildDisksCommandLine(virCommand *cmd,
|
|||||||
bootindex = bootDisk;
|
bootindex = bootDisk;
|
||||||
bootDisk = 0;
|
bootDisk = 0;
|
||||||
break;
|
break;
|
||||||
|
case VIR_DOMAIN_DISK_DEVICE_FLOPPY:
|
||||||
|
case VIR_DOMAIN_DISK_DEVICE_LAST:
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3474,6 +3474,7 @@ virVMXFormatConfig(virVMXContext *ctx, virDomainXMLOption *xmlopt, virDomainDef
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case VIR_DOMAIN_DISK_DEVICE_LAST:
|
||||||
default:
|
default:
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||||
_("Unsupported disk device type '%s'"),
|
_("Unsupported disk device type '%s'"),
|
||||||
|
Loading…
Reference in New Issue
Block a user