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 | 28 ++++++++++++++++++++--------
src/qemu/qemu_domain.c | 21 +++++++++++++++++++++
src/qemu/qemu_driver.c | 27 +++++++++++++++++++--------
src/qemu/qemu_hotplug.c | 36 +++++++++++++++++++++++++++++++-----
src/qemu/qemu_migration.c | 11 ++++++++++-
src/qemu/qemu_process.c | 2 ++
6 files changed, 103 insertions(+), 22 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 2a75a169c2..33ca1e0960 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -2634,7 +2634,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;
@@ -2686,7 +2686,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;
@@ -3400,12 +3400,18 @@ 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"));
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected NIC tx mode %d"),
+ net->driver.virtio.txmode);
goto error;
}
} else {
@@ -6540,7 +6546,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);
@@ -6883,7 +6889,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;
@@ -6929,7 +6935,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;
@@ -7903,8 +7909,14 @@ 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:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected mouse mode %d"),
+ graphics->data.spice.mousemode);
+ goto error;
}
}
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index e114f5dfcf..7697de69e4 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -2806,6 +2806,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 bbce5bd81b..0b8976010f 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -3041,13 +3041,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;
}
@@ -17820,11 +17815,19 @@ 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:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected graphics type %d"),
+ vm->def->graphics[idx]->type);
+ goto endjob;
}
if (qemuSecuritySetImageFDLabel(driver->securityManager, vm->def, fd) < 0)
@@ -17884,11 +17887,19 @@ 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:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected graphics type %d"),
+ 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 c9868de778..0d7d02c25b 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -2992,11 +2992,25 @@ 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:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected net type %d"),
+ virDomainNetGetActualType(newdev));
+ return -1;
}
virDomainConfNWFilterTeardown(olddev);
@@ -3291,12 +3305,17 @@ 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:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected net type %d"), newdev->type);
+ goto cleanup;
}
} else {
/* interface type has changed. There are a few special cases
@@ -3675,10 +3694,17 @@ 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:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected graphics type %d"), dev->type);
+ break;
}
cleanup:
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 3641b801f6..fe3342b38d 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -1437,11 +1437,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 10211de871..b86ecda93f 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -690,6 +690,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