mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 12:35:17 +00:00
virDomainControllerDef: Convert 'type' field to proper enum type
Convert the field and fill in missing cases to switch() statements. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
44f0371c8c
commit
27a653b893
@ -2473,7 +2473,7 @@ virDomainControllerDefNew(virDomainControllerType type)
|
||||
def->model = -1;
|
||||
def->idx = -1;
|
||||
|
||||
switch ((virDomainControllerType) def->type) {
|
||||
switch (def->type) {
|
||||
case VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL:
|
||||
def->opts.vioserial.ports = -1;
|
||||
def->opts.vioserial.vectors = -1;
|
||||
@ -8265,7 +8265,7 @@ static int
|
||||
virDomainControllerModelTypeFromString(const virDomainControllerDef *def,
|
||||
const char *model)
|
||||
{
|
||||
switch ((virDomainControllerType)def->type) {
|
||||
switch (def->type) {
|
||||
case VIR_DOMAIN_CONTROLLER_TYPE_SCSI:
|
||||
return virDomainControllerModelSCSITypeFromString(model);
|
||||
case VIR_DOMAIN_CONTROLLER_TYPE_USB:
|
||||
@ -8293,7 +8293,7 @@ static const char *
|
||||
virDomainControllerModelTypeToString(virDomainControllerDef *def,
|
||||
int model)
|
||||
{
|
||||
switch ((virDomainControllerType)def->type) {
|
||||
switch (def->type) {
|
||||
case VIR_DOMAIN_CONTROLLER_TYPE_SCSI:
|
||||
return virDomainControllerModelSCSITypeToString(model);
|
||||
case VIR_DOMAIN_CONTROLLER_TYPE_USB:
|
||||
@ -8324,7 +8324,7 @@ virDomainControllerDefParseXML(virDomainXMLOption *xmlopt,
|
||||
unsigned int flags)
|
||||
{
|
||||
g_autoptr(virDomainControllerDef) def = NULL;
|
||||
virDomainControllerType type = 0;
|
||||
virDomainControllerType type = VIR_DOMAIN_CONTROLLER_TYPE_IDE;
|
||||
xmlNodePtr driver = NULL;
|
||||
g_autofree xmlNodePtr *targetNodes = NULL;
|
||||
int ntargetNodes = 0;
|
||||
@ -8539,6 +8539,13 @@ virDomainControllerDefParseXML(virDomainXMLOption *xmlopt,
|
||||
break;
|
||||
}
|
||||
|
||||
case VIR_DOMAIN_CONTROLLER_TYPE_IDE:
|
||||
case VIR_DOMAIN_CONTROLLER_TYPE_FDC:
|
||||
case VIR_DOMAIN_CONTROLLER_TYPE_SCSI:
|
||||
case VIR_DOMAIN_CONTROLLER_TYPE_SATA:
|
||||
case VIR_DOMAIN_CONTROLLER_TYPE_CCID:
|
||||
case VIR_DOMAIN_CONTROLLER_TYPE_ISA:
|
||||
case VIR_DOMAIN_CONTROLLER_TYPE_LAST:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -16031,7 +16038,10 @@ virDomainEmulatorPinDefParseXML(xmlNodePtr node)
|
||||
|
||||
|
||||
virDomainControllerDef *
|
||||
virDomainDefAddController(virDomainDef *def, int type, int idx, int model)
|
||||
virDomainDefAddController(virDomainDef *def,
|
||||
virDomainControllerType type,
|
||||
int idx,
|
||||
int model)
|
||||
{
|
||||
virDomainControllerDef *cont;
|
||||
|
||||
@ -16106,7 +16116,7 @@ virDomainDefAddUSBController(virDomainDef *def, int idx, int model)
|
||||
|
||||
int
|
||||
virDomainDefMaybeAddController(virDomainDef *def,
|
||||
int type,
|
||||
virDomainControllerType type,
|
||||
int idx,
|
||||
int model)
|
||||
{
|
||||
@ -21719,7 +21729,7 @@ virDomainDefCheckABIStability(virDomainDef *src,
|
||||
|
||||
static int
|
||||
virDomainDefAddDiskControllersForType(virDomainDef *def,
|
||||
int controllerType,
|
||||
virDomainControllerType controllerType,
|
||||
int diskBus)
|
||||
{
|
||||
size_t i;
|
||||
@ -22981,7 +22991,7 @@ virDomainControllerDefFormat(virBuffer *buf,
|
||||
if (model)
|
||||
virBufferEscapeString(&attrBuf, " model='%s'", model);
|
||||
|
||||
switch ((virDomainControllerType) def->type) {
|
||||
switch (def->type) {
|
||||
case VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL:
|
||||
if (def->opts.vioserial.ports != -1) {
|
||||
virBufferAsprintf(&attrBuf, " ports='%d'",
|
||||
|
@ -784,7 +784,7 @@ struct _virDomainXenbusControllerOpts {
|
||||
|
||||
/* Stores the virtual disk controller configuration */
|
||||
struct _virDomainControllerDef {
|
||||
int type;
|
||||
virDomainControllerType type;
|
||||
int idx;
|
||||
int model; /* -1 == undef */
|
||||
unsigned int queues;
|
||||
@ -4280,12 +4280,15 @@ VIR_ENUM_DECL(virDomainCpuPlacementMode);
|
||||
VIR_ENUM_DECL(virDomainStartupPolicy);
|
||||
|
||||
virDomainControllerDef *
|
||||
virDomainDefAddController(virDomainDef *def, int type, int idx, int model);
|
||||
virDomainDefAddController(virDomainDef *def,
|
||||
virDomainControllerType type,
|
||||
int idx,
|
||||
int model);
|
||||
int
|
||||
virDomainDefAddUSBController(virDomainDef *def, int idx, int model);
|
||||
int
|
||||
virDomainDefMaybeAddController(virDomainDef *def,
|
||||
int type,
|
||||
virDomainControllerType type,
|
||||
int idx,
|
||||
int model);
|
||||
int
|
||||
|
@ -2802,7 +2802,7 @@ qemuBuildControllerDevProps(const virDomainDef *domainDef,
|
||||
|
||||
*devprops = NULL;
|
||||
|
||||
switch ((virDomainControllerType)def->type) {
|
||||
switch (def->type) {
|
||||
case VIR_DOMAIN_CONTROLLER_TYPE_SCSI:
|
||||
if (!(props = qemuBuildControllerSCSIDevProps(def, qemuCaps)))
|
||||
return -1;
|
||||
|
@ -5540,7 +5540,7 @@ qemuDomainControllerDefPostParse(virDomainControllerDef *cont,
|
||||
virQEMUCaps *qemuCaps,
|
||||
unsigned int parseFlags)
|
||||
{
|
||||
switch ((virDomainControllerType)cont->type) {
|
||||
switch (cont->type) {
|
||||
case VIR_DOMAIN_CONTROLLER_TYPE_SCSI:
|
||||
/* Set the default SCSI controller model if not already set */
|
||||
if (qemuDomainSetSCSIControllerModel(def, cont, qemuCaps) < 0)
|
||||
|
@ -608,7 +608,7 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDef *dev,
|
||||
case VIR_DOMAIN_DEVICE_CONTROLLER: {
|
||||
virDomainControllerDef *cont = dev->data.controller;
|
||||
|
||||
switch ((virDomainControllerType)cont->type) {
|
||||
switch (cont->type) {
|
||||
case VIR_DOMAIN_CONTROLLER_TYPE_PCI:
|
||||
return virDomainPCIControllerModelToConnectType(cont->model);
|
||||
|
||||
@ -1984,6 +1984,16 @@ qemuDomainValidateDevicePCISlotsQ35(virDomainDef *def,
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_CONTROLLER_TYPE_IDE:
|
||||
case VIR_DOMAIN_CONTROLLER_TYPE_FDC:
|
||||
case VIR_DOMAIN_CONTROLLER_TYPE_SCSI:
|
||||
case VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL:
|
||||
case VIR_DOMAIN_CONTROLLER_TYPE_CCID:
|
||||
case VIR_DOMAIN_CONTROLLER_TYPE_XENBUS:
|
||||
case VIR_DOMAIN_CONTROLLER_TYPE_ISA:
|
||||
case VIR_DOMAIN_CONTROLLER_TYPE_LAST:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5534,7 +5534,7 @@ qemuDomainDiskControllerIsBusy(virDomainObj *vm,
|
||||
continue;
|
||||
|
||||
/* check whether the disk uses this type controller */
|
||||
switch ((virDomainControllerType) detach->type) {
|
||||
switch (detach->type) {
|
||||
case VIR_DOMAIN_CONTROLLER_TYPE_IDE:
|
||||
if (disk->bus != VIR_DOMAIN_DISK_BUS_IDE)
|
||||
continue;
|
||||
@ -5599,7 +5599,7 @@ static bool
|
||||
qemuDomainControllerIsBusy(virDomainObj *vm,
|
||||
virDomainControllerDef *detach)
|
||||
{
|
||||
switch ((virDomainControllerType) detach->type) {
|
||||
switch (detach->type) {
|
||||
case VIR_DOMAIN_CONTROLLER_TYPE_IDE:
|
||||
case VIR_DOMAIN_CONTROLLER_TYPE_FDC:
|
||||
case VIR_DOMAIN_CONTROLLER_TYPE_SCSI:
|
||||
|
@ -4036,7 +4036,7 @@ qemuValidateDomainDeviceDefController(const virDomainControllerDef *controller,
|
||||
if (qemuValidateDomainDeviceDefControllerAttributes(controller) < 0)
|
||||
return -1;
|
||||
|
||||
switch ((virDomainControllerType)controller->type) {
|
||||
switch (controller->type) {
|
||||
case VIR_DOMAIN_CONTROLLER_TYPE_IDE:
|
||||
ret = qemuValidateDomainDeviceDefControllerIDE(controller, def);
|
||||
break;
|
||||
|
@ -467,7 +467,7 @@ vboxSetStorageController(virDomainControllerDef *controller,
|
||||
int ret = -1;
|
||||
|
||||
/* libvirt controller type => vbox bus type */
|
||||
switch ((virDomainControllerType) controller->type) {
|
||||
switch (controller->type) {
|
||||
case VIR_DOMAIN_CONTROLLER_TYPE_FDC:
|
||||
VBOX_UTF8_TO_UTF16(VBOX_CONTROLLER_FLOPPY_NAME, &controllerName);
|
||||
vboxBusType = StorageBus_Floppy;
|
||||
|
Loading…
x
Reference in New Issue
Block a user