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.
Signed-off-by: Daniel P. Berrangé <berrange(a)redhat.com>
---
src/qemu/qemu_command.c | 26 ++++++++++++++++++--------
src/qemu/qemu_domain.c | 21 +++++++++++++++++++++
src/qemu/qemu_driver.c | 25 +++++++++++++++++--------
src/qemu/qemu_hotplug.c | 33 ++++++++++++++++++++++++++++-----
src/qemu/qemu_migration.c | 11 ++++++++++-
src/qemu/qemu_process.c | 2 ++
6 files changed, 96 insertions(+), 22 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 34dda23288..fa0aa5d5c3 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -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;
}
}
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index b1308e5a49..8b4efc82de 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -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;
}
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 416567512d..8aa293bf1b 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -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)
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 04f4f689a9..f28006e3cd 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -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:
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 99d58325cb..2d92d38936 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -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 _("no job");
+ 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");
}
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 13b05d236a..dc33eb7bcd 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -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;
--
2.14.3