mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-21 20:15:17 +00:00
qemu: handle missing switch enum cases
Ensure all enum cases are listed in switch statements, or cast away enum type in places where we don't wish to cover all cases. Reviewed-by: John Ferlan <jferlan@redhat.com> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
parent
d4bf8f4150
commit
7fef8e330d
@ -2632,7 +2632,7 @@ qemuBuildControllerDevStr(const virDomainDef *domainDef,
|
||||
case VIR_DOMAIN_CONTROLLER_TYPE_SCSI:
|
||||
switch ((virDomainControllerModelSCSI) def->model) {
|
||||
case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI:
|
||||
switch ((virDomainDeviceAddressType) address_type) {
|
||||
switch (address_type) {
|
||||
case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW:
|
||||
virBufferAddLit(&buf, "virtio-scsi-ccw");
|
||||
break;
|
||||
@ -2684,7 +2684,7 @@ qemuBuildControllerDevStr(const virDomainDef *domainDef,
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL:
|
||||
switch ((virDomainDeviceAddressType) address_type) {
|
||||
switch (address_type) {
|
||||
case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI:
|
||||
virBufferAddLit(&buf, "virtio-serial-pci");
|
||||
break;
|
||||
@ -3407,12 +3407,17 @@ qemuBuildNicDevStr(virDomainDefPtr def,
|
||||
case VIR_DOMAIN_NET_VIRTIO_TX_MODE_TIMER:
|
||||
virBufferAddLit(&buf, "timer");
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_NET_VIRTIO_TX_MODE_DEFAULT:
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_NET_VIRTIO_TX_MODE_LAST:
|
||||
default:
|
||||
/* this should never happen, if it does, we need
|
||||
* to add another case to this switch.
|
||||
*/
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("unrecognized virtio-net-pci 'tx' option"));
|
||||
virReportEnumRangeError(virDomainNetVirtioTxModeType,
|
||||
net->driver.virtio.txmode);
|
||||
goto error;
|
||||
}
|
||||
} else {
|
||||
@ -6598,7 +6603,7 @@ qemuBuildGlobalControllerCommandLine(virCommandPtr cmd,
|
||||
bool cap = false;
|
||||
bool machine = false;
|
||||
|
||||
switch ((virDomainControllerModelPCI) cont->model) {
|
||||
switch (cont->model) {
|
||||
case VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT:
|
||||
hoststr = "i440FX-pcihost";
|
||||
cap = virQEMUCapsGet(qemuCaps, QEMU_CAPS_I440FX_PCI_HOLE64_SIZE);
|
||||
@ -6941,7 +6946,7 @@ qemuBuildCpuCommandLine(virCommandPtr cmd,
|
||||
if (cpu_flags && !cpu) {
|
||||
const char *default_model;
|
||||
|
||||
switch (def->os.arch) {
|
||||
switch ((int)def->os.arch) {
|
||||
case VIR_ARCH_I686:
|
||||
default_model = "qemu32";
|
||||
break;
|
||||
@ -6987,7 +6992,7 @@ qemuBuildObsoleteAccelArg(virCommandPtr cmd,
|
||||
bool disableKVM = false;
|
||||
bool enableKVM = false;
|
||||
|
||||
switch (def->virtType) {
|
||||
switch ((int)def->virtType) {
|
||||
case VIR_DOMAIN_VIRT_QEMU:
|
||||
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM))
|
||||
disableKVM = true;
|
||||
@ -7955,8 +7960,13 @@ qemuBuildGraphicsSPICECommandLine(virQEMUDriverConfigPtr cfg,
|
||||
case VIR_DOMAIN_GRAPHICS_SPICE_MOUSE_MODE_CLIENT:
|
||||
virBufferAddLit(&opt, "agent-mouse=on,");
|
||||
break;
|
||||
default:
|
||||
case VIR_DOMAIN_GRAPHICS_SPICE_MOUSE_MODE_DEFAULT:
|
||||
break;
|
||||
case VIR_DOMAIN_GRAPHICS_SPICE_MOUSE_MODE_LAST:
|
||||
default:
|
||||
virReportEnumRangeError(virDomainGraphicsSpiceMouseMode,
|
||||
graphics->data.spice.mousemode);
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2804,6 +2804,27 @@ qemuDomainDefAddDefaultDevices(virDomainDefPtr def,
|
||||
addPCIRoot = true;
|
||||
break;
|
||||
|
||||
case VIR_ARCH_ARMV6L:
|
||||
case VIR_ARCH_ARMV7B:
|
||||
case VIR_ARCH_CRIS:
|
||||
case VIR_ARCH_ITANIUM:
|
||||
case VIR_ARCH_LM32:
|
||||
case VIR_ARCH_M68K:
|
||||
case VIR_ARCH_MICROBLAZE:
|
||||
case VIR_ARCH_MICROBLAZEEL:
|
||||
case VIR_ARCH_MIPS:
|
||||
case VIR_ARCH_MIPSEL:
|
||||
case VIR_ARCH_MIPS64:
|
||||
case VIR_ARCH_MIPS64EL:
|
||||
case VIR_ARCH_OR32:
|
||||
case VIR_ARCH_PARISC:
|
||||
case VIR_ARCH_PARISC64:
|
||||
case VIR_ARCH_PPCLE:
|
||||
case VIR_ARCH_UNICORE32:
|
||||
case VIR_ARCH_XTENSA:
|
||||
case VIR_ARCH_XTENSAEB:
|
||||
case VIR_ARCH_NONE:
|
||||
case VIR_ARCH_LAST:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -3016,13 +3016,8 @@ qemuCompressGetCommand(virQEMUSaveFormat compression)
|
||||
ret = virCommandNew(prog);
|
||||
virCommandAddArg(ret, "-dc");
|
||||
|
||||
switch (compression) {
|
||||
case QEMU_SAVE_FORMAT_LZOP:
|
||||
if (compression == QEMU_SAVE_FORMAT_LZOP)
|
||||
virCommandAddArg(ret, "--ignore-warn");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -17792,11 +17787,18 @@ qemuDomainOpenGraphics(virDomainPtr dom,
|
||||
case VIR_DOMAIN_GRAPHICS_TYPE_SPICE:
|
||||
protocol = "spice";
|
||||
break;
|
||||
default:
|
||||
case VIR_DOMAIN_GRAPHICS_TYPE_SDL:
|
||||
case VIR_DOMAIN_GRAPHICS_TYPE_RDP:
|
||||
case VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP:
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("Can only open VNC or SPICE graphics backends, not %s"),
|
||||
virDomainGraphicsTypeToString(vm->def->graphics[idx]->type));
|
||||
goto endjob;
|
||||
case VIR_DOMAIN_GRAPHICS_TYPE_LAST:
|
||||
default:
|
||||
virReportEnumRangeError(virDomainGraphicsType,
|
||||
vm->def->graphics[idx]->type);
|
||||
goto endjob;
|
||||
}
|
||||
|
||||
if (qemuSecuritySetImageFDLabel(driver->securityManager, vm->def, fd) < 0)
|
||||
@ -17856,11 +17858,18 @@ qemuDomainOpenGraphicsFD(virDomainPtr dom,
|
||||
case VIR_DOMAIN_GRAPHICS_TYPE_SPICE:
|
||||
protocol = "spice";
|
||||
break;
|
||||
default:
|
||||
case VIR_DOMAIN_GRAPHICS_TYPE_SDL:
|
||||
case VIR_DOMAIN_GRAPHICS_TYPE_RDP:
|
||||
case VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP:
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("Can only open VNC or SPICE graphics backends, not %s"),
|
||||
virDomainGraphicsTypeToString(vm->def->graphics[idx]->type));
|
||||
goto cleanup;
|
||||
case VIR_DOMAIN_GRAPHICS_TYPE_LAST:
|
||||
default:
|
||||
virReportEnumRangeError(virDomainGraphicsType,
|
||||
vm->def->graphics[idx]->type);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (qemuSecuritySetSocketLabel(driver->securityManager, vm->def) < 0)
|
||||
|
@ -2978,11 +2978,24 @@ qemuDomainChangeNetFilter(virDomainObjPtr vm,
|
||||
case VIR_DOMAIN_NET_TYPE_BRIDGE:
|
||||
case VIR_DOMAIN_NET_TYPE_NETWORK:
|
||||
break;
|
||||
default:
|
||||
case VIR_DOMAIN_NET_TYPE_USER:
|
||||
case VIR_DOMAIN_NET_TYPE_VHOSTUSER:
|
||||
case VIR_DOMAIN_NET_TYPE_SERVER:
|
||||
case VIR_DOMAIN_NET_TYPE_CLIENT:
|
||||
case VIR_DOMAIN_NET_TYPE_MCAST:
|
||||
case VIR_DOMAIN_NET_TYPE_INTERNAL:
|
||||
case VIR_DOMAIN_NET_TYPE_DIRECT:
|
||||
case VIR_DOMAIN_NET_TYPE_HOSTDEV:
|
||||
case VIR_DOMAIN_NET_TYPE_UDP:
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("filters not supported on interfaces of type %s"),
|
||||
virDomainNetTypeToString(virDomainNetGetActualType(newdev)));
|
||||
return -1;
|
||||
case VIR_DOMAIN_NET_TYPE_LAST:
|
||||
default:
|
||||
virReportEnumRangeError(virDomainNetType,
|
||||
virDomainNetGetActualType(newdev));
|
||||
return -1;
|
||||
}
|
||||
|
||||
virDomainConfNWFilterTeardown(olddev);
|
||||
@ -3277,12 +3290,16 @@ qemuDomainChangeNet(virQEMUDriverPtr driver,
|
||||
/* all handled in common code directly below this switch */
|
||||
break;
|
||||
|
||||
default:
|
||||
case VIR_DOMAIN_NET_TYPE_VHOSTUSER:
|
||||
case VIR_DOMAIN_NET_TYPE_HOSTDEV:
|
||||
virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
|
||||
_("unable to change config on '%s' network type"),
|
||||
virDomainNetTypeToString(newdev->type));
|
||||
break;
|
||||
|
||||
goto cleanup;
|
||||
case VIR_DOMAIN_NET_TYPE_LAST:
|
||||
default:
|
||||
virReportEnumRangeError(virDomainNetType, newdev->type);
|
||||
goto cleanup;
|
||||
}
|
||||
} else {
|
||||
/* interface type has changed. There are a few special cases
|
||||
@ -3661,10 +3678,16 @@ qemuDomainChangeGraphics(virQEMUDriverPtr driver,
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
case VIR_DOMAIN_GRAPHICS_TYPE_SDL:
|
||||
case VIR_DOMAIN_GRAPHICS_TYPE_RDP:
|
||||
case VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP:
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("unable to change config on '%s' graphics type"), type);
|
||||
break;
|
||||
case VIR_DOMAIN_GRAPHICS_TYPE_LAST:
|
||||
default:
|
||||
virReportEnumRangeError(virDomainGraphicsType, dev->type);
|
||||
break;
|
||||
}
|
||||
|
||||
cleanup:
|
||||
|
@ -1468,11 +1468,20 @@ qemuMigrationJobName(virDomainObjPtr vm)
|
||||
|
||||
switch (priv->job.asyncJob) {
|
||||
case QEMU_ASYNC_JOB_MIGRATION_OUT:
|
||||
return _("migration job");
|
||||
return _("migration out job");
|
||||
case QEMU_ASYNC_JOB_SAVE:
|
||||
return _("domain save job");
|
||||
case QEMU_ASYNC_JOB_DUMP:
|
||||
return _("domain core dump job");
|
||||
case QEMU_ASYNC_JOB_NONE:
|
||||
return _("undefined");
|
||||
case QEMU_ASYNC_JOB_MIGRATION_IN:
|
||||
return _("migration in job");
|
||||
case QEMU_ASYNC_JOB_SNAPSHOT:
|
||||
return _("snapshot job");
|
||||
case QEMU_ASYNC_JOB_START:
|
||||
return _("start job");
|
||||
case QEMU_ASYNC_JOB_LAST:
|
||||
default:
|
||||
return _("job");
|
||||
}
|
||||
|
@ -679,6 +679,8 @@ qemuProcessHandleShutdown(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
|
||||
detail = VIR_DOMAIN_EVENT_SHUTDOWN_HOST;
|
||||
break;
|
||||
|
||||
case VIR_TRISTATE_BOOL_ABSENT:
|
||||
case VIR_TRISTATE_BOOL_LAST:
|
||||
default:
|
||||
detail = VIR_DOMAIN_EVENT_SHUTDOWN_FINISHED;
|
||||
break;
|
||||
|
Loading…
x
Reference in New Issue
Block a user