Even if the compiler has validated that all enum constants have case
statements in a switch, it is not safe to omit a default: case
statement. When assigning a value to a variable / struct field that is
defined with an enum type, nothing prevents an invalid value being
assigned. So defensive code must assume existance of invalid values and
thus all switches should have a default: case.
Signed-off-by: Daniel P. Berrangé <berrange(a)redhat.com>
---
src/libvirt_private.syms | 2 +
src/qemu/qemu_alias.c | 3 +
src/qemu/qemu_block.c | 22 ++-
src/qemu/qemu_blockjob.c | 1 +
src/qemu/qemu_capabilities.c | 23 ++-
src/qemu/qemu_cgroup.c | 9 +-
src/qemu/qemu_command.c | 395 ++++++++++++++++++++++++++++++++-------
src/qemu/qemu_domain.c | 197 ++++++++++++++-----
src/qemu/qemu_domain_address.c | 46 ++++-
src/qemu/qemu_driver.c | 109 +++++++++--
src/qemu/qemu_hostdev.c | 5 +-
src/qemu/qemu_hotplug.c | 58 +++++-
src/qemu/qemu_interface.c | 12 +-
src/qemu/qemu_migration.c | 24 ++-
src/qemu/qemu_migration_cookie.c | 6 +-
src/qemu/qemu_monitor.c | 13 +-
src/qemu/qemu_monitor_json.c | 67 +++++--
src/qemu/qemu_monitor_text.c | 3 +
src/qemu/qemu_parse_command.c | 12 +-
src/qemu/qemu_process.c | 108 ++++++++++-
20 files changed, 918 insertions(+), 197 deletions(-)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 87a9c85f09..6a9e109855 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -198,6 +198,8 @@ virDomainBootTypeFromString;
virDomainBootTypeToString;
virDomainCapabilitiesPolicyTypeToString;
virDomainCapsFeatureTypeToString;
+virDomainChrChannelTargetTypeFromString;
+virDomainChrChannelTargetTypeToString;
virDomainChrConsoleTargetTypeFromString;
virDomainChrConsoleTargetTypeToString;
virDomainChrDefForeach;
diff --git a/src/qemu/qemu_alias.c b/src/qemu/qemu_alias.c
index ae30f7df82..834cc4a319 100644
--- a/src/qemu/qemu_alias.c
+++ b/src/qemu/qemu_alias.c
@@ -110,6 +110,9 @@ qemuAssignDeviceChrAlias(virDomainDefPtr def,
break;
case VIR_DOMAIN_CHR_DEVICE_TYPE_LAST:
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected chardev device type %d"),
chr->deviceType);
return -1;
}
diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c
index 585f0255ee..13fcd5a6a8 100644
--- a/src/qemu/qemu_block.c
+++ b/src/qemu/qemu_block.c
@@ -515,11 +515,17 @@ qemuBlockStorageSourceBuildJSONSocketAddress(virStorageNetHostDefPtr
host,
break;
case VIR_STORAGE_NET_HOST_TRANS_RDMA:
- case VIR_STORAGE_NET_HOST_TRANS_LAST:
virReportError(VIR_ERR_INTERNAL_ERROR,
_("transport protocol '%s' is not yet
supported"),
virStorageNetHostTransportTypeToString(host->transport));
goto cleanup;
+
+ case VIR_STORAGE_NET_HOST_TRANS_LAST:
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected storage transport %d"),
+ host->transport);
+ goto cleanup;
}
VIR_STEAL_PTR(ret, server);
@@ -1005,7 +1011,9 @@ qemuBlockStorageSourceGetBackendProps(virStorageSourcePtr src)
case VIR_STORAGE_TYPE_VOLUME:
case VIR_STORAGE_TYPE_NONE:
- case VIR_STORAGE_TYPE_LAST:
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("Unsupported storage type %s"),
+ virStorageTypeToString(actualType));
return NULL;
case VIR_STORAGE_TYPE_NETWORK:
@@ -1056,9 +1064,19 @@ qemuBlockStorageSourceGetBackendProps(virStorageSourcePtr src)
case VIR_STORAGE_NET_PROTOCOL_NONE:
case VIR_STORAGE_NET_PROTOCOL_LAST:
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected storage protocol %d"),
+ src->protocol);
return NULL;
}
break;
+
+ case VIR_STORAGE_TYPE_LAST:
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected storage type %d"), actualType);
+ return NULL;
}
if (virJSONValueObjectAdd(fileprops, "S:node-name", src->nodestorage,
NULL) < 0) {
diff --git a/src/qemu/qemu_blockjob.c b/src/qemu/qemu_blockjob.c
index 617e4ee564..2a08e09d99 100644
--- a/src/qemu/qemu_blockjob.c
+++ b/src/qemu/qemu_blockjob.c
@@ -199,6 +199,7 @@ qemuBlockJobEventProcess(virQEMUDriverPtr driver,
break;
case VIR_DOMAIN_BLOCK_JOB_LAST:
+ default:
break;
}
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index b5eb8cf46a..a07bf00ebc 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -2598,9 +2598,12 @@ virQEMUCapsGetHostModel(virQEMUCapsPtr qemuCaps,
/* 'full' is non-NULL only if we have data from both QEMU and
* virCPUGetHost */
return cpuData->full ? cpuData->full : cpuData->reported;
- }
- return NULL;
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected CPU model type %d"), cpuType);
+ return NULL;
+ }
}
@@ -2643,11 +2646,10 @@ virQEMUCapsIsCPUModeSupported(virQEMUCapsPtr qemuCaps,
cpus = qemuCaps->tcgCPUModels;
return cpus && cpus->nmodels > 0;
+ default:
case VIR_CPU_MODE_LAST:
- break;
+ return false;
}
-
- return false;
}
@@ -3447,7 +3449,10 @@ virQEMUCapsInitCPUModelX86(virQEMUCapsPtr qemuCaps,
break;
case QEMU_MONITOR_CPU_PROPERTY_LAST:
- break;
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected monitor CPU property type %d"),
prop->type);
+ goto cleanup;
}
}
@@ -3705,7 +3710,10 @@ virQEMUCapsLoadHostCPUModelInfo(virQEMUCapsPtr qemuCaps,
break;
case QEMU_MONITOR_CPU_PROPERTY_LAST:
- break;
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected monitor CPU property type %d"),
prop->type);
+ goto cleanup;
}
if ((str = virXMLPropString(ctxt->node, "migratable"))) {
@@ -4161,6 +4169,7 @@ virQEMUCapsFormatHostCPUModelInfo(virQEMUCapsPtr qemuCaps,
break;
case QEMU_MONITOR_CPU_PROPERTY_LAST:
+ default:
break;
}
diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c
index b604edb31c..6c32303c18 100644
--- a/src/qemu/qemu_cgroup.c
+++ b/src/qemu/qemu_cgroup.c
@@ -239,7 +239,10 @@ qemuSetupTPMCgroup(virDomainObjPtr vm)
ret = qemuSetupChrSourceCgroup(vm, &dev->data.passthrough.source);
break;
case VIR_DOMAIN_TPM_TYPE_LAST:
- break;
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected TPM type %d"), dev->type);
+ return -1;
}
return ret;
@@ -263,6 +266,8 @@ qemuSetupInputCgroup(virDomainObjPtr vm,
VIR_CGROUP_DEVICE_RW, false);
virDomainAuditCgroupPath(vm, priv->cgroup, "allow",
dev->source.evdev, "rw", ret);
break;
+ default:
+ break;
}
return ret;
@@ -286,6 +291,8 @@ qemuTeardownInputCgroup(virDomainObjPtr vm,
VIR_CGROUP_DEVICE_RWM, false);
virDomainAuditCgroupPath(vm, priv->cgroup, "deny",
dev->source.evdev, "rwm", ret);
break;
+ default:
+ break;
}
return ret;
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 33ca1e0960..71e697dd41 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -642,7 +642,13 @@ qemuBuildGeneralSecinfoURI(virURIPtr uri,
break;
case VIR_DOMAIN_SECRET_INFO_TYPE_AES:
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("Unsupported secret info type aes"));
+ return -1;
case VIR_DOMAIN_SECRET_INFO_TYPE_LAST:
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected secret info type %d"), secinfo->type);
return -1;
}
@@ -690,6 +696,9 @@ qemuBuildRBDSecinfoURI(virBufferPtr buf,
break;
case VIR_DOMAIN_SECRET_INFO_TYPE_LAST:
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected secret info type %d"), secinfo->type);
return -1;
}
@@ -1013,9 +1022,9 @@ qemuBuildNetworkDriveStr(virStorageSourcePtr src,
case VIR_STORAGE_NET_PROTOCOL_LAST:
case VIR_STORAGE_NET_PROTOCOL_NONE:
+ default:
virReportError(VIR_ERR_INTERNAL_ERROR,
- _("Unexpected network protocol '%s'"),
- virStorageNetProtocolTypeToString(src->protocol));
+ _("Unexpected network protocol %d"),
src->protocol);
goto cleanup;
}
@@ -1056,8 +1065,12 @@ qemuGetDriveSourceString(virStorageSourcePtr src,
case VIR_STORAGE_TYPE_VOLUME:
case VIR_STORAGE_TYPE_NONE:
- case VIR_STORAGE_TYPE_LAST:
break;
+ case VIR_STORAGE_TYPE_LAST:
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected storage type %d"), actualType);
+ goto cleanup;
}
ret = 0;
@@ -1259,7 +1272,7 @@ qemuCheckDiskConfig(virDomainDiskDefPtr disk,
}
}
- switch (disk->bus) {
+ switch ((virDomainDiskBus)disk->bus) {
case VIR_DOMAIN_DISK_BUS_SCSI:
if (disk->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
@@ -1319,7 +1332,14 @@ qemuCheckDiskConfig(virDomainDiskDefPtr disk,
case VIR_DOMAIN_DISK_BUS_VIRTIO:
case VIR_DOMAIN_DISK_BUS_XEN:
case VIR_DOMAIN_DISK_BUS_SD:
+ case VIR_DOMAIN_DISK_BUS_USB:
+ case VIR_DOMAIN_DISK_BUS_UML:
+ case VIR_DOMAIN_DISK_BUS_SATA:
break;
+ case VIR_DOMAIN_DISK_BUS_LAST:
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected disk bus %d"), disk->bus);
}
if (disk->src->readonly &&
@@ -1868,11 +1888,15 @@ qemuCheckIOThreads(const virDomainDef *def,
case VIR_DOMAIN_DISK_BUS_UML:
case VIR_DOMAIN_DISK_BUS_SATA:
case VIR_DOMAIN_DISK_BUS_SD:
- case VIR_DOMAIN_DISK_BUS_LAST:
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("IOThreads not available for bus %s target %s"),
virDomainDiskBusTypeToString(disk->bus), disk->dst);
return false;
+ case VIR_DOMAIN_DISK_BUS_LAST:
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected disk bus %d"), disk->bus);
+ return false;
}
/* Can we find the disk iothread in the iothreadid list? */
@@ -2277,7 +2301,7 @@ qemuBuildDiskDriveCommandLine(virCommandPtr cmd,
/* bootDevs will get translated into either bootindex=N or boot=on
* depending on what qemu supports */
for (i = 0; i < def->os.nBootDevs; i++) {
- switch (def->os.bootDevs[i]) {
+ switch ((virDomainBootOrder)def->os.bootDevs[i]) {
case VIR_DOMAIN_BOOT_CDROM:
bootCD = i + 1;
break;
@@ -2287,6 +2311,13 @@ qemuBuildDiskDriveCommandLine(virCommandPtr cmd,
case VIR_DOMAIN_BOOT_DISK:
bootDisk = i + 1;
break;
+ case VIR_DOMAIN_BOOT_NET:
+ break;
+ case VIR_DOMAIN_BOOT_LAST:
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected disk boot device %d"),
def->os.bootDevs[i]);
+ return -1;
}
}
}
@@ -2308,7 +2339,7 @@ qemuBuildDiskDriveCommandLine(virCommandPtr cmd,
if (disk->info.bootIndex) {
bootindex = disk->info.bootIndex;
} else {
- switch (disk->device) {
+ switch ((virDomainDiskDevice)disk->device) {
case VIR_DOMAIN_DISK_DEVICE_CDROM:
bootindex = bootCD;
bootCD = 0;
@@ -2322,6 +2353,11 @@ qemuBuildDiskDriveCommandLine(virCommandPtr cmd,
bootindex = bootDisk;
bootDisk = 0;
break;
+ case VIR_DOMAIN_DISK_DEVICE_LAST:
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected disk device type %d"),
disk->device);
+ return -1;
}
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_BOOTINDEX)) {
driveBoot = !!bootindex;
@@ -2677,6 +2713,7 @@ qemuBuildControllerDevStr(const virDomainDef *domainDef,
goto error;
case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_DEFAULT:
case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LAST:
+ default:
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Unexpected SCSI controller model %d"),
def->model);
@@ -2782,6 +2819,7 @@ qemuBuildControllerDevStr(const virDomainDef *domainDef,
goto error;
case VIR_DOMAIN_CONTROLLER_MODEL_PCI_DEFAULT:
case VIR_DOMAIN_CONTROLLER_MODEL_PCI_LAST:
+ default:
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Unexpected PCI controller model %d"),
def->model);
@@ -2791,11 +2829,15 @@ qemuBuildControllerDevStr(const virDomainDef *domainDef,
case VIR_DOMAIN_CONTROLLER_TYPE_IDE:
case VIR_DOMAIN_CONTROLLER_TYPE_FDC:
- case VIR_DOMAIN_CONTROLLER_TYPE_LAST:
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Unsupported controller type: %s"),
virDomainControllerTypeToString(def->type));
goto error;
+ case VIR_DOMAIN_CONTROLLER_TYPE_LAST:
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected controller type %d"), def->type);
+ goto error;
}
if (def->queues)
@@ -3146,8 +3188,12 @@ qemuBuildMemoryBackendStr(virJSONValuePtr *backendProps,
break;
case VIR_DOMAIN_MEMORY_ACCESS_DEFAULT:
- case VIR_DOMAIN_MEMORY_ACCESS_LAST:
break;
+ case VIR_DOMAIN_MEMORY_ACCESS_LAST:
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected memory access mode %d"), memAccess);
+ goto cleanup;
}
} else {
*backendType = "memory-backend-ram";
@@ -3329,9 +3375,13 @@ qemuBuildMemoryDeviceStr(virDomainMemoryDefPtr mem)
break;
case VIR_DOMAIN_MEMORY_MODEL_NONE:
- case VIR_DOMAIN_MEMORY_MODEL_LAST:
break;
+ case VIR_DOMAIN_MEMORY_MODEL_LAST:
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected memory model %d"), mem->model);
+ return NULL;
}
if (virBufferCheckError(&buf) < 0)
@@ -3664,8 +3714,12 @@ qemuBuildHostNetStr(virDomainNetDefPtr net,
case VIR_DOMAIN_NET_TYPE_HOSTDEV:
/* Should have been handled earlier via PCI/USB hotplug code. */
- case VIR_DOMAIN_NET_TYPE_LAST:
break;
+ case VIR_DOMAIN_NET_TYPE_LAST:
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected net type %d"), netType);
+ goto cleanup;
}
if (vlan >= 0) {
@@ -3959,7 +4013,10 @@ qemuBuildVirtioInputDevStr(const virDomainDef *def,
virQEMUBuildBufferEscapeComma(&buf, dev->source.evdev);
break;
case VIR_DOMAIN_INPUT_TYPE_LAST:
- break;
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected input type %d"), dev->type);
+ goto error;
}
if (qemuBuildDeviceAddressStr(&buf, def, &dev->info, qemuCaps) < 0)
@@ -3985,7 +4042,7 @@ qemuBuildUSBInputDevStr(const virDomainDef *def,
{
virBuffer buf = VIR_BUFFER_INITIALIZER;
- switch (dev->type) {
+ switch ((virDomainInputType)dev->type) {
case VIR_DOMAIN_INPUT_TYPE_MOUSE:
virBufferAsprintf(&buf, "usb-mouse,id=%s", dev->info.alias);
break;
@@ -4001,6 +4058,16 @@ qemuBuildUSBInputDevStr(const virDomainDef *def,
}
virBufferAsprintf(&buf, "usb-kbd,id=%s", dev->info.alias);
break;
+ case VIR_DOMAIN_INPUT_TYPE_PASSTHROUGH:
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("Unsupported input type %s"),
+ virDomainInputTypeToString(dev->type));
+ goto error;
+ case VIR_DOMAIN_INPUT_TYPE_LAST:
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected input type %d"), dev->type);
+ goto error;
}
if (qemuBuildDeviceAddressStr(&buf, def, &dev->info, qemuCaps) < 0)
@@ -4023,7 +4090,7 @@ qemuBuildInputDevStr(char **devstr,
virDomainInputDefPtr input,
virQEMUCapsPtr qemuCaps)
{
- switch (input->bus) {
+ switch ((virDomainInputBus)input->bus) {
case VIR_DOMAIN_INPUT_BUS_USB:
if (!(*devstr = qemuBuildUSBInputDevStr(def, input, qemuCaps)))
return -1;
@@ -4033,6 +4100,21 @@ qemuBuildInputDevStr(char **devstr,
if (!(*devstr = qemuBuildVirtioInputDevStr(def, input, qemuCaps)))
return -1;
break;
+
+ case VIR_DOMAIN_INPUT_BUS_PS2:
+ /* nada */
+ break;
+ case VIR_DOMAIN_INPUT_BUS_XEN:
+ case VIR_DOMAIN_INPUT_BUS_PARALLELS:
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("Unsupported input bus %s"),
+ virDomainInputBusTypeToString(input->bus));
+ return -1;
+ case VIR_DOMAIN_INPUT_BUS_LAST:
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected input bus %d"), input->bus);
+ return -1;
}
return 0;
}
@@ -4105,11 +4187,15 @@ qemuBuildSoundDevStr(const virDomainDef *def,
model = "sb16";
break;
case VIR_DOMAIN_SOUND_MODEL_PCSPK: /* pc-speaker is handled separately */
- case VIR_DOMAIN_SOUND_MODEL_LAST:
- virReportError(VIR_ERR_INTERNAL_ERROR,
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("sound card model '%s' is not supported by
qemu"),
virDomainSoundModelTypeToString(sound->model));
goto error;
+ case VIR_DOMAIN_SOUND_MODEL_LAST:
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected sound model %d"), sound->model);
+ goto error;
}
virBufferAsprintf(&buf, "%s,id=%s", model, sound->info.alias);
@@ -4488,11 +4574,15 @@ qemuBuildPCIHostdevDevStr(const virDomainDef *def,
case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_DEFAULT:
case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_XEN:
- case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_TYPE_LAST:
virReportError(VIR_ERR_INTERNAL_ERROR,
_("invalid PCI passthrough type '%s'"),
virDomainHostdevSubsysPCIBackendTypeToString(backend));
goto error;
+ case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_TYPE_LAST:
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected hostdev PCI backend %d"), backend);
+ goto error;
}
virBufferAddLit(&buf, ",host=");
@@ -5432,13 +5522,30 @@ qemuBuildSclpDevStr(virDomainChrDefPtr dev)
{
virBuffer buf = VIR_BUFFER_INITIALIZER;
if (dev->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE) {
- switch (dev->targetType) {
+ switch ((virDomainChrConsoleTargetType)dev->targetType) {
case VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SCLP:
virBufferAddLit(&buf, "sclpconsole");
break;
case VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SCLPLM:
virBufferAddLit(&buf, "sclplmconsole");
break;
+ case VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE:
+ case VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL:
+ case VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN:
+ case VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_UML:
+ case VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_VIRTIO:
+ case VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_LXC:
+ case VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_OPENVZ:
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("Unsupported console target type %s"),
+ virDomainChrConsoleTargetTypeToString(dev->targetType));
+ goto error;
+ case VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_LAST:
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected console target type %d"),
+ dev->targetType);
+ goto error;
}
} else {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
@@ -5472,7 +5579,6 @@ qemuBuildRNGBackendChrdevStr(virLogManagerPtr logManager,
switch ((virDomainRNGBackend) rng->backend) {
case VIR_DOMAIN_RNG_BACKEND_RANDOM:
- case VIR_DOMAIN_RNG_BACKEND_LAST:
/* no chardev backend is needed */
return 0;
@@ -5482,6 +5588,12 @@ qemuBuildRNGBackendChrdevStr(virLogManagerPtr logManager,
rng->info.alias, qemuCaps, true,
chardevStdioLogd)))
return -1;
+ break;
+ case VIR_DOMAIN_RNG_BACKEND_LAST:
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected RNG backend %d"), rng->backend);
+ return -1;
}
return 0;
@@ -5533,8 +5645,9 @@ qemuBuildRNGBackendProps(virDomainRNGDefPtr rng,
break;
case VIR_DOMAIN_RNG_BACKEND_LAST:
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
- _("unknown rng-random backend"));
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected RNG backend %d"), rng->backend);
goto cleanup;
}
@@ -6028,6 +6141,11 @@ qemuBuildClockArgStr(virDomainClockDefPtr def)
case VIR_DOMAIN_TIMER_TRACK_WALL:
virBufferAddLit(&buf, ",clock=host");
break;
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected timer tracking mode %d"),
+ def->timers[i]->track);
+ goto error;
}
switch (def->timers[i]->tickpolicy) {
@@ -6046,6 +6164,11 @@ qemuBuildClockArgStr(virDomainClockDefPtr def)
_("unsupported rtc timer tickpolicy
'%s'"),
virDomainTimerTickpolicyTypeToString(def->timers[i]->tickpolicy));
goto error;
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected timer tick policy %d"),
+ def->timers[i]->tickpolicy);
+ goto error;
}
break; /* no need to check other timers - there is only one rtc */
}
@@ -6115,7 +6238,6 @@ qemuBuildClockCommandLine(virCommandPtr cmd,
case VIR_DOMAIN_TIMER_NAME_KVMCLOCK:
case VIR_DOMAIN_TIMER_NAME_HYPERVCLOCK:
/* Timers above are handled when building -cpu. */
- case VIR_DOMAIN_TIMER_NAME_LAST:
break;
case VIR_DOMAIN_TIMER_NAME_RTC:
@@ -6137,6 +6259,11 @@ qemuBuildClockCommandLine(virCommandPtr cmd,
_("unsupported rtc tickpolicy
'%s'"),
virDomainTimerTickpolicyTypeToString(def->clock.timers[i]->tickpolicy));
return -1;
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected timer tick policy %d"),
+ def->clock.timers[i]->tickpolicy);
+ return -1;
}
} else if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_RTC) &&
(def->clock.timers[i]->tickpolicy
@@ -6191,6 +6318,11 @@ qemuBuildClockCommandLine(virCommandPtr cmd,
_("unsupported pit tickpolicy '%s'"),
virDomainTimerTickpolicyTypeToString(def->clock.timers[i]->tickpolicy));
return -1;
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected timer tick policy %d"),
+ def->clock.timers[i]->tickpolicy);
+ return -1;
}
break;
@@ -6215,6 +6347,12 @@ qemuBuildClockCommandLine(virCommandPtr cmd,
}
}
break;
+ case VIR_DOMAIN_TIMER_NAME_LAST:
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected timer name %d"),
+ def->clock.timers[i]->name);
+ return -1;
}
}
@@ -6480,7 +6618,11 @@ qemuBuildIOMMUCommandLine(virCommandPtr cmd,
}
break;
case VIR_DOMAIN_IOMMU_MODEL_LAST:
- break;
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unsupported iommu model %d"),
+ iommu->model);
+ return -1;
}
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_MACHINE_IOMMU))
@@ -6519,13 +6661,19 @@ qemuBuildIOMMUCommandLine(virCommandPtr cmd,
virBufferAsprintf(&opts, ",device-iotlb=%s",
virTristateSwitchTypeToString(iommu->iotlb));
}
- case VIR_DOMAIN_IOMMU_MODEL_LAST:
break;
+ case VIR_DOMAIN_IOMMU_MODEL_LAST:
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unsupported iommu model %d"),
+ iommu->model);
+ goto cleanup;
}
virCommandAddArg(cmd, "-device");
virCommandAddArgBuffer(cmd, &opts);
ret = 0;
+ cleanup:
virBufferFreeAndReset(&opts);
return ret;
}
@@ -6641,7 +6789,11 @@ qemuBuildCpuModelArgStr(virQEMUDriverPtr driver,
break;
case VIR_CPU_MODE_LAST:
- break;
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected CPU mode %d"),
+ cpu->mode);
+ goto cleanup;
}
if (ARCH_IS_S390(def->os.arch) && cpu->features &&
@@ -6674,8 +6826,13 @@ qemuBuildCpuModelArgStr(virQEMUDriverPtr driver,
break;
case VIR_CPU_FEATURE_OPTIONAL:
- case VIR_CPU_FEATURE_LAST:
break;
+ case VIR_CPU_FEATURE_LAST:
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected CPU feature policy %d"),
+ cpu->features[i].policy);
+ goto cleanup;
}
}
@@ -6811,6 +6968,7 @@ qemuBuildCpuCommandLine(virCommandPtr cmd,
/* coverity[dead_error_begin] */
case VIR_DOMAIN_HYPERV_LAST:
+ default:
break;
}
}
@@ -6833,6 +6991,7 @@ qemuBuildCpuCommandLine(virCommandPtr cmd,
/* coverity[dead_error_begin] */
case VIR_DOMAIN_KVM_LAST:
+ default:
break;
}
}
@@ -6865,7 +7024,11 @@ qemuBuildCpuCommandLine(virCommandPtr cmd,
break;
case VIR_CPU_CACHE_MODE_LAST:
- break;
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected CPU cache mode %d"),
+ cache->mode);
+ goto cleanup;
}
if (hostOff &&
@@ -7226,12 +7389,16 @@ qemuBuildMachineCommandLine(virCommandPtr cmd,
_("IOMMU device: '%s' is only supported
with "
"Q35 machines"),
virDomainIOMMUModelTypeToString(def->iommu->model));
- return -1;
+ goto cleanup;
}
virBufferAddLit(&buf, ",iommu=on");
break;
case VIR_DOMAIN_IOMMU_MODEL_LAST:
- break;
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected iommu model %d"),
+ def->iommu->model);
+ goto cleanup;
}
}
@@ -7268,7 +7435,11 @@ qemuBuildMachineCommandLine(virCommandPtr cmd,
virBufferAddLit(&buf, ",kernel_irqchip=on");
break;
case VIR_DOMAIN_IOAPIC_LAST:
- break;
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected ioapic type %d"),
+ def->ioapic);
+ goto cleanup;
}
}
@@ -7757,7 +7928,11 @@ qemuBuildGraphicsVNCCommandLine(virQEMUDriverConfigPtr cfg,
break;
case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_LAST:
- break;
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected graphics listen type %d"),
+ glisten->type);
+ goto error;
}
if (graphics->data.vnc.sharePolicy) {
@@ -7888,7 +8063,11 @@ qemuBuildGraphicsSPICECommandLine(virQEMUDriverConfigPtr cfg,
hasInsecure = true;
break;
case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_LAST:
- break;
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected graphics listen type %d"),
+ glisten->type);
+ goto error;
}
if (cfg->spiceSASL) {
@@ -7952,9 +8131,14 @@ qemuBuildGraphicsSPICECommandLine(virQEMUDriverConfigPtr cfg,
virBufferAddLit(&opt, "plaintext-channel=default,");
break;
case VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_MODE_ANY:
- case VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_MODE_LAST:
/* nothing */
break;
+ case VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_MODE_LAST:
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected spice channel mode %d"),
+ graphics->data.spice.defaultMode);
+ goto error;
}
for (i = 0; i < VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_LAST; i++) {
@@ -7985,6 +8169,12 @@ qemuBuildGraphicsSPICECommandLine(virQEMUDriverConfigPtr cfg,
case VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_MODE_ANY:
break;
+ case VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_MODE_LAST:
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected spice channel mode %d"),
+ graphics->data.spice.channels[i]);
+ goto error;
}
}
@@ -8110,11 +8300,15 @@ qemuBuildGraphicsCommandLine(virQEMUDriverConfigPtr cfg,
case VIR_DOMAIN_GRAPHICS_TYPE_RDP:
case VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP:
- case VIR_DOMAIN_GRAPHICS_TYPE_LAST:
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unsupported graphics type '%s'"),
virDomainGraphicsTypeToString(graphics->type));
return -1;
+ case VIR_DOMAIN_GRAPHICS_TYPE_LAST:
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected graphics type %d"), graphics->type);
+ return -1;
}
return 0;
@@ -8163,11 +8357,16 @@ qemuBuildVhostuserCommandLine(virQEMUDriverPtr driver,
case VIR_DOMAIN_CHR_TYPE_SPICEVMC:
case VIR_DOMAIN_CHR_TYPE_SPICEPORT:
case VIR_DOMAIN_CHR_TYPE_NMDM:
- case VIR_DOMAIN_CHR_TYPE_LAST:
- virReportError(VIR_ERR_INTERNAL_ERROR,
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("vhost-user type '%s' not supported"),
virDomainChrTypeToString(net->data.vhostuser->type));
goto error;
+ case VIR_DOMAIN_CHR_TYPE_LAST:
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected chardev type %d"),
+ net->data.vhostuser->type);
+ goto error;
}
if (queues > 1 &&
@@ -8349,14 +8548,12 @@ qemuBuildInterfaceCommandLine(virQEMUDriverPtr driver,
*/
ret = 0;
goto cleanup;
- break;
case VIR_DOMAIN_NET_TYPE_VHOSTUSER:
ret = qemuBuildVhostuserCommandLine(driver, logManager, cmd, def,
net, qemuCaps, bootindex,
chardevStdioLogd);
goto cleanup;
- break;
case VIR_DOMAIN_NET_TYPE_USER:
case VIR_DOMAIN_NET_TYPE_SERVER:
@@ -8364,9 +8561,13 @@ qemuBuildInterfaceCommandLine(virQEMUDriverPtr driver,
case VIR_DOMAIN_NET_TYPE_MCAST:
case VIR_DOMAIN_NET_TYPE_INTERNAL:
case VIR_DOMAIN_NET_TYPE_UDP:
- case VIR_DOMAIN_NET_TYPE_LAST:
/* nada */
break;
+ case VIR_DOMAIN_NET_TYPE_LAST:
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected net type %d"), actualType);
+ goto cleanup;
}
/* For types whose implementations use a netdev on the host, add
@@ -8400,7 +8601,6 @@ qemuBuildInterfaceCommandLine(virQEMUDriverPtr driver,
case VIR_DOMAIN_NET_TYPE_UDP:
case VIR_DOMAIN_NET_TYPE_INTERNAL:
case VIR_DOMAIN_NET_TYPE_HOSTDEV:
- case VIR_DOMAIN_NET_TYPE_LAST:
/* These types don't use a network device on the host, but
* instead use some other type of connection to the emulated
* device in the qemu process.
@@ -8411,7 +8611,12 @@ qemuBuildInterfaceCommandLine(virQEMUDriverPtr driver,
* up in the list of interfaces on the host - it's just some
* PCI device.)
*/
- break;
+ break;
+ case VIR_DOMAIN_NET_TYPE_LAST:
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected net type %d"), actualType);
+ goto cleanup;
}
/* Set bandwidth or warn if requested and not supported. */
@@ -8926,7 +9131,10 @@ qemuBuildShmemCommandLine(virLogManagerPtr logManager,
break;
case VIR_DOMAIN_SHMEM_MODEL_LAST:
- break;
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected shmem model %d"), shmem->model);
+ return -1;
}
if (!devstr)
@@ -8970,10 +9178,9 @@ qemuChrSerialTargetModelToCaps(virDomainChrSerialTargetModel
targetModel)
return QEMU_CAPS_DEVICE_PL011;
case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_NONE:
case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_LAST:
- break;
+ default:
+ return 0;
}
-
- return 0;
}
@@ -9127,7 +9334,7 @@ qemuBuildChannelsCommandLine(virLogManagerPtr logManager,
virDomainChrDefPtr channel = def->channels[i];
char *devstr;
- switch (channel->targetType) {
+ switch ((virDomainChrChannelTargetType)channel->targetType) {
case VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_GUESTFWD:
if (!(devstr = qemuBuildChrChardevStr(logManager, cmd, cfg, def,
channel->source,
@@ -9167,6 +9374,19 @@ qemuBuildChannelsCommandLine(virLogManagerPtr logManager,
if (qemuBuildChrDeviceCommandLine(cmd, def, channel, qemuCaps) < 0)
return -1;
break;
+
+ case VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_NONE:
+ case VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_XEN:
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("Unsupported channel target type %s"),
+
virDomainChrChannelTargetTypeToString(channel->targetType));
+ return -1;
+
+ case VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_LAST:
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected channel target type %d"),
channel->targetType);
+ return -1;
}
}
@@ -9387,7 +9607,7 @@ qemuBuildRedirdevCommandLine(virLogManagerPtr logManager,
}
-static void
+static int
qemuBuildDomainLoaderCommandLine(virCommandPtr cmd,
virDomainDefPtr def)
{
@@ -9396,7 +9616,7 @@ qemuBuildDomainLoaderCommandLine(virCommandPtr cmd,
int unit = 0;
if (!loader)
- return;
+ return 0;
switch ((virDomainLoader) loader->type) {
case VIR_DOMAIN_LOADER_TYPE_ROM:
@@ -9438,11 +9658,14 @@ qemuBuildDomainLoaderCommandLine(virCommandPtr cmd,
break;
case VIR_DOMAIN_LOADER_TYPE_LAST:
- /* nada */
- break;
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected loader type %d"), loader->type);
+ return -1;
}
virBufferFreeAndReset(&buf);
+ return 0;
}
@@ -9496,8 +9719,13 @@ qemuBuildTPMBackendStr(const virDomainDef *def,
switch (tpm->type) {
case VIR_DOMAIN_TPM_TYPE_PASSTHROUGH:
- if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_TPM_PASSTHROUGH))
- goto no_support;
+ if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_TPM_PASSTHROUGH)) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("The QEMU executable %s does not support TPM "
+ "backend type %s"),
+ def->emulator, type);
+ goto error;
+ }
tpmdev = tpm->data.passthrough.source.data.file.path;
if (!(cancel_path = virTPMCreateCancelPath(tpmdev)))
@@ -9543,6 +9771,9 @@ qemuBuildTPMBackendStr(const virDomainDef *def,
break;
case VIR_DOMAIN_TPM_TYPE_LAST:
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected TPM type %d"), tpm->type);
goto error;
}
@@ -9551,12 +9782,6 @@ qemuBuildTPMBackendStr(const virDomainDef *def,
return virBufferContentAndReset(&buf);
- no_support:
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- _("The QEMU executable %s does not support TPM "
- "backend type %s"),
- def->emulator, type);
-
error:
VIR_FREE(devset);
VIR_FREE(cancel_path);
@@ -9730,8 +9955,13 @@ qemuBuildPanicCommandLine(virCommandPtr cmd,
/* default model value was changed before in post parse */
case VIR_DOMAIN_PANIC_MODEL_DEFAULT:
- case VIR_DOMAIN_PANIC_MODEL_LAST:
break;
+ case VIR_DOMAIN_PANIC_MODEL_LAST:
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected panic model %d"),
+ def->panics[i]->model);
+ return -1;
}
}
@@ -9787,7 +10017,7 @@ qemuBuildCommandLineValidate(virQEMUDriverPtr driver,
}
for (i = 0; i < def->ngraphics; ++i) {
- switch (def->graphics[i]->type) {
+ switch ((virDomainGraphicsType)def->graphics[i]->type) {
case VIR_DOMAIN_GRAPHICS_TYPE_SDL:
++sdl;
break;
@@ -9799,8 +10029,16 @@ qemuBuildCommandLineValidate(virQEMUDriverPtr driver,
break;
case VIR_DOMAIN_GRAPHICS_TYPE_RDP:
case VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP:
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("Unsupported graphics type %s"),
+ virDomainGraphicsTypeToString(def->graphics[i]->type));
+ return -1;
case VIR_DOMAIN_GRAPHICS_TYPE_LAST:
- break;
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected graphics type %d"),
+ def->graphics[i]->type);
+ return -1;
}
}
@@ -9900,7 +10138,8 @@ qemuBuildCommandLine(virQEMUDriverPtr driver,
if (qemuBuildCpuCommandLine(cmd, driver, def, qemuCaps) < 0)
goto error;
- qemuBuildDomainLoaderCommandLine(cmd, def);
+ if (qemuBuildDomainLoaderCommandLine(cmd, def) < 0)
+ goto error;
if (!migrateURI && !snapshot && qemuDomainAlignMemorySizes(def) <
0)
goto error;
@@ -10144,14 +10383,18 @@ qemuBuildSerialChrDeviceStr(char **deviceStr,
case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PL011:
case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_NONE:
- case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_LAST:
- /* Except from _LAST, which is just a guard value and will never
- * be used, all of the above are platform devices, which means
+ /* All of the above are platform devices, which means
* qemuBuildSerialCommandLine() will have taken the appropriate
* branch and we will not have ended up here. */
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Invalid target model for serial device"));
goto error;
+ case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_LAST:
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected serial target model %d"),
+ serial->targetModel);
+ goto error;
}
virBufferAsprintf(&cmd, "%s,chardev=char%s,id=%s",
@@ -10213,8 +10456,16 @@ qemuBuildChannelChrDeviceStr(char **deviceStr,
case VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_XEN:
case VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_NONE:
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("unsupported channel target type %s"),
+ virDomainChrChannelTargetTypeToString(chr->targetType));
+ goto cleanup;
case VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_LAST:
- return ret;
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected channel target type %d"),
+ chr->targetType);
+ goto cleanup;
}
ret = 0;
@@ -10251,10 +10502,15 @@ qemuBuildConsoleChrDeviceStr(char **deviceStr,
case VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_UML:
case VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_LXC:
case VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_OPENVZ:
- case VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_LAST:
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unsupported console target type %s"),
-
NULLSTR(virDomainChrConsoleTargetTypeToString(chr->targetType)));
+ virDomainChrConsoleTargetTypeToString(chr->targetType));
+ goto cleanup;
+ case VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_LAST:
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected console target type %d"),
+ chr->targetType);
goto cleanup;
}
@@ -10289,6 +10545,9 @@ qemuBuildChrDeviceStr(char **deviceStr,
break;
case VIR_DOMAIN_CHR_DEVICE_TYPE_LAST:
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected chardev device type %d"),
chr->deviceType);
return ret;
}
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 7697de69e4..28aba63fb3 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -175,9 +175,9 @@ qemuDomainAsyncJobPhaseToString(qemuDomainAsyncJob job,
case QEMU_ASYNC_JOB_NONE:
case QEMU_ASYNC_JOB_LAST:
ATTRIBUTE_FALLTHROUGH;
+ default:
+ return "none";
}
-
- return "none";
}
int
@@ -199,12 +199,12 @@ qemuDomainAsyncJobPhaseFromString(qemuDomainAsyncJob job,
case QEMU_ASYNC_JOB_NONE:
case QEMU_ASYNC_JOB_LAST:
ATTRIBUTE_FALLTHROUGH;
+ default:
+ if (STREQ(phase, "none"))
+ return 0;
+ else
+ return -1;
}
-
- if (STREQ(phase, "none"))
- return 0;
- else
- return -1;
}
@@ -416,9 +416,6 @@ static virDomainJobType
qemuDomainJobStatusToType(qemuDomainJobStatus status)
{
switch (status) {
- case QEMU_DOMAIN_JOB_STATUS_NONE:
- break;
-
case QEMU_DOMAIN_JOB_STATUS_ACTIVE:
case QEMU_DOMAIN_JOB_STATUS_MIGRATING:
case QEMU_DOMAIN_JOB_STATUS_QEMU_COMPLETED:
@@ -434,9 +431,11 @@ qemuDomainJobStatusToType(qemuDomainJobStatus status)
case QEMU_DOMAIN_JOB_STATUS_CANCELED:
return VIR_DOMAIN_JOB_CANCELLED;
- }
- return VIR_DOMAIN_JOB_NONE;
+ case QEMU_DOMAIN_JOB_STATUS_NONE:
+ default:
+ return VIR_DOMAIN_JOB_NONE;
+ }
}
int
@@ -473,6 +472,7 @@ qemuDomainJobInfoToInfo(qemuDomainJobInfoPtr jobInfo,
break;
case QEMU_DOMAIN_JOB_STATS_TYPE_NONE:
+ default:
break;
}
@@ -716,10 +716,12 @@ qemuDomainJobInfoToParams(qemuDomainJobInfoPtr jobInfo,
return qemuDomainDumpJobInfoToParams(jobInfo, type, params, nparams);
case QEMU_DOMAIN_JOB_STATS_TYPE_NONE:
- break;
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected job stats type %d"),
jobInfo->statsType);
+ return -1;
}
- return -1;
}
@@ -973,6 +975,7 @@ qemuDomainSecretInfoFree(qemuDomainSecretInfoPtr *secinfo)
break;
case VIR_DOMAIN_SECRET_INFO_TYPE_LAST:
+ default:
break;
}
@@ -3186,7 +3189,10 @@ qemuDomainDefCPUPostParse(virDomainDefPtr def)
break;
case VIR_CPU_CACHE_MODE_LAST:
- break;
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected CPU cache mode %d"), cache->mode);
+ return -1;
}
}
@@ -3216,7 +3222,10 @@ qemuDomainDefCPUPostParse(virDomainDefPtr def)
break;
case VIR_CPU_MODE_LAST:
- break;
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected CPU mode %d"), def->cpu->mode);
+ return -1;
}
return 0;
@@ -3498,6 +3507,7 @@ qemuDomainNetSupportsCoalesce(virDomainNetType type)
case VIR_DOMAIN_NET_TYPE_INTERNAL:
case VIR_DOMAIN_NET_TYPE_UDP:
case VIR_DOMAIN_NET_TYPE_LAST:
+ default:
break;
}
return false;
@@ -3544,6 +3554,7 @@ qemuDomainChrSourceDefValidate(const virDomainChrSourceDef *def)
case VIR_DOMAIN_CHR_TYPE_SPICEPORT:
case VIR_DOMAIN_CHR_TYPE_NMDM:
case VIR_DOMAIN_CHR_TYPE_LAST:
+ default:
break;
}
@@ -3567,10 +3578,9 @@ qemuDomainChrSerialTargetTypeToAddressType(int targetType)
case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SCLP:
case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_LAST:
case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE:
- break;
+ default:
+ return VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE;
}
-
- return VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE;
}
@@ -3593,10 +3603,9 @@ qemuDomainChrSerialTargetModelToTargetType(int targetModel)
return VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SCLP;
case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_NONE:
case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_LAST:
- break;
+ default:
+ return VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE;
}
-
- return VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE;
}
@@ -3639,8 +3648,12 @@ qemuDomainChrTargetDefValidate(const virDomainChrDef *chr)
break;
case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE:
- case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_LAST:
break;
+ case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_LAST:
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected serial target type %d"),
chr->targetType);
+ return -1;
}
/* Validate target model */
@@ -3665,17 +3678,25 @@ qemuDomainChrTargetDefValidate(const virDomainChrDef *chr)
break;
case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_NONE:
- case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_LAST:
break;
+ case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_LAST:
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected serial target model %d"),
chr->targetModel);
+ return -1;
}
break;
case VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE:
case VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL:
case VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL:
- case VIR_DOMAIN_CHR_DEVICE_TYPE_LAST:
/* Nothing to do */
break;
+ case VIR_DOMAIN_CHR_DEVICE_TYPE_LAST:
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected chardev device type %d"),
chr->deviceType);
+ return -1;
}
return 0;
@@ -3809,7 +3830,10 @@ qemuDomainWatchdogDefValidate(const virDomainWatchdogDef *dev,
break;
case VIR_DOMAIN_WATCHDOG_MODEL_LAST:
- break;
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected watchdog model %d"), dev->model);
+ return -1;
}
return 0;
@@ -3932,11 +3956,12 @@ qemuDomainDeviceDefValidateHostdev(const virDomainHostdevDef
*hostdev,
static int
qemuDomainDeviceDefValidateVideo(const virDomainVideoDef *video)
{
- switch (video->type) {
+ switch ((virDomainVideoType)video->type) {
case VIR_DOMAIN_VIDEO_TYPE_XEN:
case VIR_DOMAIN_VIDEO_TYPE_VBOX:
case VIR_DOMAIN_VIDEO_TYPE_PARALLELS:
case VIR_DOMAIN_VIDEO_TYPE_DEFAULT:
+ case VIR_DOMAIN_VIDEO_TYPE_GOP:
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("video type '%s' is not supported with
QEMU"),
virDomainVideoTypeToString(video->type));
@@ -3946,8 +3971,12 @@ qemuDomainDeviceDefValidateVideo(const virDomainVideoDef *video)
case VIR_DOMAIN_VIDEO_TYPE_VMVGA:
case VIR_DOMAIN_VIDEO_TYPE_QXL:
case VIR_DOMAIN_VIDEO_TYPE_VIRTIO:
- case VIR_DOMAIN_VIDEO_TYPE_LAST:
break;
+ case VIR_DOMAIN_VIDEO_TYPE_LAST:
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected video type %d"), video->type);
+ return -1;
}
if (!video->primary &&
@@ -4125,6 +4154,7 @@ qemuDomainCheckSCSIControllerModel(virQEMUCapsPtr qemuCaps,
return false;
case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_DEFAULT:
case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LAST:
+ default:
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Unexpected SCSI controller model %d"),
model);
@@ -4216,8 +4246,12 @@ qemuDomainDeviceDefValidateControllerSCSI(const
virDomainControllerDef *controll
case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_IBMVSCSI:
case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSISAS1078:
case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_DEFAULT:
- case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LAST:
break;
+ case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LAST:
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected controller SCSI model %d"),
controller->model);
+ return -1;
}
return 0;
@@ -4264,8 +4298,12 @@ qemuDomainDeviceDefValidateControllerPCI(const
virDomainControllerDef *controlle
case VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT:
case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT:
case VIR_DOMAIN_CONTROLLER_MODEL_PCI_DEFAULT:
- case VIR_DOMAIN_CONTROLLER_MODEL_PCI_LAST:
break;
+ case VIR_DOMAIN_CONTROLLER_MODEL_PCI_LAST:
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected controller PCI model %d"), model);
+ return -1;
}
pciopts = &controller->opts.pciopts;
@@ -4495,9 +4533,13 @@ qemuDomainDeviceDefValidateControllerPCI(const
virDomainControllerDef *controlle
break;
case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT:
- case VIR_DOMAIN_CONTROLLER_MODEL_PCI_LAST:
case VIR_DOMAIN_CONTROLLER_MODEL_PCI_DEFAULT:
break;
+ case VIR_DOMAIN_CONTROLLER_MODEL_PCI_LAST:
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected controller PCI model %d"), model);
+ return -1;
}
return 0;
@@ -4563,8 +4605,12 @@ qemuDomainDeviceDefValidateController(const virDomainControllerDef
*controller,
case VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL:
case VIR_DOMAIN_CONTROLLER_TYPE_CCID:
case VIR_DOMAIN_CONTROLLER_TYPE_USB:
- case VIR_DOMAIN_CONTROLLER_TYPE_LAST:
break;
+ case VIR_DOMAIN_CONTROLLER_TYPE_LAST:
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected controller type %d"),
controller->type);
+ return -1;
}
return ret;
@@ -4667,8 +4713,12 @@ qemuDomainDeviceDefValidate(const virDomainDeviceDef *dev,
case VIR_DOMAIN_DEVICE_PANIC:
case VIR_DOMAIN_DEVICE_IOMMU:
case VIR_DOMAIN_DEVICE_NONE:
- case VIR_DOMAIN_DEVICE_LAST:
break;
+ case VIR_DOMAIN_DEVICE_LAST:
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected device type %d"), dev->type);
+ return -1;
}
virObjectUnref(qemuCaps);
@@ -4969,8 +5019,12 @@ qemuDomainControllerDefPostParse(virDomainControllerDefPtr cont,
case VIR_DOMAIN_CONTROLLER_TYPE_CCID:
case VIR_DOMAIN_CONTROLLER_TYPE_IDE:
case VIR_DOMAIN_CONTROLLER_TYPE_FDC:
- case VIR_DOMAIN_CONTROLLER_TYPE_LAST:
break;
+ case VIR_DOMAIN_CONTROLLER_TYPE_LAST:
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected controller type %d"), cont->type);
+ return -1;
}
return 0;
@@ -5027,9 +5081,12 @@ qemuDomainChrDefPostParse(virDomainChrDefPtr chr,
chr->targetModel = VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SCLPCONSOLE;
break;
case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE:
- case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_LAST:
- /* Nothing to do */
break;
+ case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_LAST:
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected serial target type %d"),
chr->targetType);
+ return -1;
}
}
@@ -5951,9 +6008,14 @@ qemuDomainDefFormatBufInternal(virQEMUDriverPtr driver,
case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_USB:
case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SCLP:
case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE:
- case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_LAST:
/* Nothing to do */
break;
+ case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_LAST:
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected serial target type %d"),
+ serial->targetType);
+ goto cleanup;
}
}
}
@@ -6919,8 +6981,8 @@ qemuDomainCheckDiskStartupPolicy(virQEMUDriverPtr driver,
break;
case VIR_DOMAIN_STARTUP_POLICY_LAST:
- /* this should never happen */
- break;
+ default:
+ return -1;
}
qemuDomainCheckRemoveOptionalDisk(driver, vm, diskIndex);
@@ -8117,6 +8179,9 @@ qemuDomainDefValidateMemoryHotplugDevice(const virDomainMemoryDef
*mem,
case VIR_DOMAIN_MEMORY_MODEL_NONE:
case VIR_DOMAIN_MEMORY_MODEL_LAST:
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected memory model %d"), mem->model);
return -1;
}
@@ -8203,8 +8268,12 @@ qemuDomainDefValidateMemoryHotplug(const virDomainDef *def,
break;
case VIR_DOMAIN_MEMORY_MODEL_NONE:
- case VIR_DOMAIN_MEMORY_MODEL_LAST:
break;
+ case VIR_DOMAIN_MEMORY_MODEL_LAST:
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected memory model %d"),
def->mems[i]->model);
+ return -1;
}
/* already existing devices don't need to be checked on hotplug */
@@ -8821,9 +8890,9 @@ qemuDomainNetSupportsMTU(virDomainNetType type)
case VIR_DOMAIN_NET_TYPE_HOSTDEV:
case VIR_DOMAIN_NET_TYPE_UDP:
case VIR_DOMAIN_NET_TYPE_LAST:
- break;
+ default:
+ return false;
}
- return false;
}
int
@@ -9276,14 +9345,22 @@ qemuDomainGetHostdevPath(virDomainDefPtr def,
perm = VIR_CGROUP_DEVICE_RW;
break;
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_LAST:
- break;
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected hostdev subsystem type %d"),
+ dev->source.subsys.type);
+ goto cleanup;
}
break;
case VIR_DOMAIN_HOSTDEV_MODE_CAPABILITIES:
- case VIR_DOMAIN_HOSTDEV_MODE_LAST:
/* nada */
break;
+ case VIR_DOMAIN_HOSTDEV_MODE_LAST:
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected hostdev mode %d"), dev->mode);
+ goto cleanup;
}
if (tmpPath) {
@@ -9965,8 +10042,10 @@ qemuDomainSetupTPM(virQEMUDriverConfigPtr cfg ATTRIBUTE_UNUSED,
break;
case VIR_DOMAIN_TPM_TYPE_LAST:
- /* nada */
- break;
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected TPM type %d"), dev->type);
+ return -1;
}
VIR_DEBUG("Setup TPM");
@@ -10054,9 +10133,12 @@ qemuDomainSetupRNG(virQEMUDriverConfigPtr cfg ATTRIBUTE_UNUSED,
return -1;
case VIR_DOMAIN_RNG_BACKEND_EGD:
- case VIR_DOMAIN_RNG_BACKEND_LAST:
- /* nada */
break;
+ case VIR_DOMAIN_RNG_BACKEND_LAST:
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected RNG backend %d"), rng->backend);
+ return -1;
}
return 0;
@@ -10110,7 +10192,10 @@ qemuDomainSetupLoader(virQEMUDriverConfigPtr cfg
ATTRIBUTE_UNUSED,
break;
case VIR_DOMAIN_LOADER_TYPE_LAST:
- break;
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected loader type %d"), loader->type);
+ goto cleanup;
}
}
@@ -10319,6 +10404,7 @@ qemuDomainNamespaceAvailable(qemuDomainNamespace ns
ATTRIBUTE_UNUSED)
# endif
break;
case QEMU_DOMAIN_NS_LAST:
+ default:
break;
}
@@ -10988,8 +11074,12 @@ qemuDomainNamespaceSetupRNG(virDomainObjPtr vm,
break;
case VIR_DOMAIN_RNG_BACKEND_EGD:
- case VIR_DOMAIN_RNG_BACKEND_LAST:
break;
+ case VIR_DOMAIN_RNG_BACKEND_LAST:
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected RNG backend %d"), rng->backend);
+ return -1;
}
if (path && qemuDomainNamespaceMknodPath(vm, path) < 0)
@@ -11011,8 +11101,12 @@ qemuDomainNamespaceTeardownRNG(virDomainObjPtr vm,
break;
case VIR_DOMAIN_RNG_BACKEND_EGD:
- case VIR_DOMAIN_RNG_BACKEND_LAST:
break;
+ case VIR_DOMAIN_RNG_BACKEND_LAST:
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected RNG backend %d"), rng->backend);
+ return -1;
}
if (path && qemuDomainNamespaceUnlinkPath(vm, path) < 0)
@@ -11529,6 +11623,7 @@ qemuProcessEventFree(struct qemuProcessEvent *event)
VIR_FREE(event->data);
break;
case QEMU_PROCESS_EVENT_LAST:
+ default:
break;
}
VIR_FREE(event);
diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c
index de565dbf74..8695e7cc07 100644
--- a/src/qemu/qemu_domain_address.c
+++ b/src/qemu/qemu_domain_address.c
@@ -542,6 +542,7 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev,
case VIR_DOMAIN_CONTROLLER_MODEL_USB_QUSB2: /* xen only */
case VIR_DOMAIN_CONTROLLER_MODEL_USB_NONE:
case VIR_DOMAIN_CONTROLLER_MODEL_USB_LAST:
+ default:
return 0;
}
@@ -573,6 +574,7 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev,
return pciFlags;
case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LAST:
+ default:
return 0;
}
@@ -582,6 +584,7 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev,
case VIR_DOMAIN_CONTROLLER_TYPE_FDC:
case VIR_DOMAIN_CONTROLLER_TYPE_CCID:
case VIR_DOMAIN_CONTROLLER_TYPE_LAST:
+ default:
/* should be 0 */
return pciFlags;
}
@@ -625,6 +628,7 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev,
case VIR_DOMAIN_SOUND_MODEL_PCSPK:
case VIR_DOMAIN_SOUND_MODEL_USB:
case VIR_DOMAIN_SOUND_MODEL_LAST:
+ default:
return 0;
}
@@ -642,6 +646,7 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev,
case VIR_DOMAIN_DISK_BUS_SATA:
case VIR_DOMAIN_DISK_BUS_SD:
case VIR_DOMAIN_DISK_BUS_LAST:
+ default:
return 0;
}
@@ -754,6 +759,7 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev,
case VIR_DOMAIN_MEMBALLOON_MODEL_XEN:
case VIR_DOMAIN_MEMBALLOON_MODEL_NONE:
case VIR_DOMAIN_MEMBALLOON_MODEL_LAST:
+ default:
return 0;
}
@@ -763,6 +769,7 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev,
return virtioFlags;
case VIR_DOMAIN_RNG_MODEL_LAST:
+ default:
return 0;
}
@@ -775,6 +782,7 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev,
case VIR_DOMAIN_WATCHDOG_MODEL_IB700:
case VIR_DOMAIN_WATCHDOG_MODEL_DIAG288:
case VIR_DOMAIN_WATCHDOG_MODEL_LAST:
+ default:
return 0;
}
@@ -795,6 +803,7 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev,
case VIR_DOMAIN_VIDEO_TYPE_DEFAULT:
case VIR_DOMAIN_VIDEO_TYPE_GOP:
case VIR_DOMAIN_VIDEO_TYPE_LAST:
+ default:
return 0;
}
@@ -811,6 +820,7 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev,
case VIR_DOMAIN_INPUT_BUS_XEN:
case VIR_DOMAIN_INPUT_BUS_PARALLELS:
case VIR_DOMAIN_INPUT_BUS_LAST:
+ default:
return 0;
}
@@ -826,6 +836,7 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev,
case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SCLP:
case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE:
case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_LAST:
+ default:
return 0;
}
@@ -841,17 +852,14 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev,
case VIR_DOMAIN_DEVICE_LEASE:
case VIR_DOMAIN_DEVICE_GRAPHICS:
case VIR_DOMAIN_DEVICE_IOMMU:
+ return 0;
case VIR_DOMAIN_DEVICE_LAST:
case VIR_DOMAIN_DEVICE_NONE:
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected device type %d"), dev->type);
return 0;
}
-
- /* We can never get here, because all cases are covered in the
- * switch, and they all return, but the compiler will still
- * complain "control reaches end of non-void function" unless
- * we add the following return.
- */
- return 0;
}
@@ -1576,7 +1584,7 @@ qemuDomainValidateDevicePCISlotsQ35(virDomainDefPtr def,
for (i = 0; i < def->ncontrollers; i++) {
virDomainControllerDefPtr cont = def->controllers[i];
- switch (cont->type) {
+ switch ((virDomainControllerType)cont->type) {
case VIR_DOMAIN_CONTROLLER_TYPE_SATA:
/* Verify that the first SATA controller is at 00:1F.2 the
* q35 machine type *always* has a SATA controller at this
@@ -1660,6 +1668,19 @@ qemuDomainValidateDevicePCISlotsQ35(virDomainDefPtr 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:
+ break;
+
+ case VIR_DOMAIN_CONTROLLER_TYPE_LAST:
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected controller type %d"), cont->type);
+ goto cleanup;
}
}
@@ -1958,6 +1979,8 @@ qemuDomainAssignDevicePCISlots(virDomainDefPtr def,
addr.function = 2;
addr.multi = VIR_TRISTATE_SWITCH_ABSENT;
break;
+ default:
+ break;
}
if (foundAddr) {
@@ -2187,6 +2210,7 @@ qemuDomainPCIControllerSetDefaultModelName(virDomainControllerDefPtr
cont,
case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT:
case VIR_DOMAIN_CONTROLLER_MODEL_PCI_DEFAULT:
case VIR_DOMAIN_CONTROLLER_MODEL_PCI_LAST:
+ default:
break;
}
}
@@ -2574,8 +2598,12 @@ qemuDomainAssignPCIAddresses(virDomainDefPtr def,
case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_SWITCH_UPSTREAM_PORT:
case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT:
case VIR_DOMAIN_CONTROLLER_MODEL_PCI_DEFAULT:
- case VIR_DOMAIN_CONTROLLER_MODEL_PCI_LAST:
break;
+ case VIR_DOMAIN_CONTROLLER_MODEL_PCI_LAST:
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected controller PCI model %d"),
cont->model);
+ goto cleanup;
}
/* check if every PCI bridge controller's index is larger than
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 0b8976010f..54da651c65 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -4563,6 +4563,8 @@ syncNicRxFilterMultiMode(char *ifname, virNetDevRxFilterPtr
guestFilter,
ifname);
}
break;
+ default:
+ break;
}
}
}
@@ -4889,6 +4891,7 @@ static void qemuProcessEventHandler(void *data, void *opaque)
processMonitorEOFEvent(driver, vm);
break;
case QEMU_PROCESS_EVENT_LAST:
+ default:
break;
}
@@ -7753,11 +7756,15 @@ qemuDomainAttachDeviceLive(virDomainObjPtr vm,
case VIR_DOMAIN_DEVICE_TPM:
case VIR_DOMAIN_DEVICE_PANIC:
case VIR_DOMAIN_DEVICE_IOMMU:
- case VIR_DOMAIN_DEVICE_LAST:
virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
_("live attach of device '%s' is not
supported"),
virDomainDeviceTypeToString(dev->type));
break;
+ case VIR_DOMAIN_DEVICE_LAST:
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected device type %d"), dev->type);
+ return -1;
}
if (alias) {
@@ -7852,11 +7859,15 @@ qemuDomainDetachDeviceLive(virDomainObjPtr vm,
case VIR_DOMAIN_DEVICE_TPM:
case VIR_DOMAIN_DEVICE_PANIC:
case VIR_DOMAIN_DEVICE_IOMMU:
- case VIR_DOMAIN_DEVICE_LAST:
virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
_("live detach of device '%s' is not
supported"),
virDomainDeviceTypeToString(dev->type));
break;
+ case VIR_DOMAIN_DEVICE_LAST:
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected device type %d"), dev->type);
+ return -1;
}
if (ret == 0)
@@ -7968,11 +7979,15 @@ qemuDomainUpdateDeviceLive(virConnectPtr conn,
case VIR_DOMAIN_DEVICE_TPM:
case VIR_DOMAIN_DEVICE_PANIC:
case VIR_DOMAIN_DEVICE_IOMMU:
- case VIR_DOMAIN_DEVICE_LAST:
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("live update of device '%s' is not
supported"),
virDomainDeviceTypeToString(dev->type));
break;
+ case VIR_DOMAIN_DEVICE_LAST:
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected device type %d"), dev->type);
+ return -1;
}
return ret;
@@ -8155,11 +8170,15 @@ qemuDomainAttachDeviceConfig(virDomainDefPtr vmdef,
case VIR_DOMAIN_DEVICE_TPM:
case VIR_DOMAIN_DEVICE_PANIC:
case VIR_DOMAIN_DEVICE_IOMMU:
- case VIR_DOMAIN_DEVICE_LAST:
virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
_("persistent attach of device '%s' is not
supported"),
virDomainDeviceTypeToString(dev->type));
return -1;
+ case VIR_DOMAIN_DEVICE_LAST:
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected device type %d"), dev->type);
+ return -1;
}
if (virDomainDefPostParse(vmdef, caps, parse_flags, xmlopt, NULL) < 0)
@@ -8338,11 +8357,15 @@ qemuDomainDetachDeviceConfig(virDomainDefPtr vmdef,
case VIR_DOMAIN_DEVICE_TPM:
case VIR_DOMAIN_DEVICE_PANIC:
case VIR_DOMAIN_DEVICE_IOMMU:
- case VIR_DOMAIN_DEVICE_LAST:
virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
_("persistent detach of device '%s' is not
supported"),
virDomainDeviceTypeToString(dev->type));
return -1;
+ case VIR_DOMAIN_DEVICE_LAST:
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected device type %d"), dev->type);
+ return -1;
}
if (virDomainDefPostParse(vmdef, caps, parse_flags, xmlopt, NULL) < 0)
@@ -8425,11 +8448,15 @@ qemuDomainUpdateDeviceConfig(virDomainDefPtr vmdef,
case VIR_DOMAIN_DEVICE_TPM:
case VIR_DOMAIN_DEVICE_PANIC:
case VIR_DOMAIN_DEVICE_IOMMU:
- case VIR_DOMAIN_DEVICE_LAST:
virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
_("persistent update of device '%s' is not
supported"),
virDomainDeviceTypeToString(dev->type));
return -1;
+ case VIR_DOMAIN_DEVICE_LAST:
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected device type %d"), dev->type);
+ return -1;
}
if (virDomainDefPostParse(vmdef, caps, parse_flags, xmlopt, NULL) < 0)
@@ -13268,6 +13295,11 @@ qemuDomainGetJobInfoDumpStats(virQEMUDriverPtr driver,
VIR_DEBUG("dump completed, bytes written='%llu'",
jobInfo->stats.dump.completed);
break;
+
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected dump status %d"),
jobInfo->stats.dump.status);
+ return -1;
}
return 0;
@@ -13329,6 +13361,11 @@ qemuDomainGetJobStatsInternal(virQEMUDriverPtr driver,
case QEMU_DOMAIN_JOB_STATS_TYPE_NONE:
break;
+
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected job stats type %d"),
jobInfo->statsType);
+ goto cleanup;
}
ret = 0;
@@ -14120,23 +14157,30 @@
qemuDomainSnapshotPrepareDiskExternalInactive(virDomainSnapshotDiskDefPtr snapdi
case VIR_STORAGE_NET_PROTOCOL_TFTP:
case VIR_STORAGE_NET_PROTOCOL_SSH:
case VIR_STORAGE_NET_PROTOCOL_VXHS:
- case VIR_STORAGE_NET_PROTOCOL_LAST:
virReportError(VIR_ERR_INTERNAL_ERROR,
_("external inactive snapshots are not supported on
"
"'network' disks using '%s'
protocol"),
virStorageNetProtocolTypeToString(domdisk->src->protocol));
return -1;
+ case VIR_STORAGE_NET_PROTOCOL_LAST:
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected storage protocol %d"),
snapdisk->src->protocol);
+ return -1;
}
break;
case VIR_STORAGE_TYPE_DIR:
case VIR_STORAGE_TYPE_VOLUME:
case VIR_STORAGE_TYPE_NONE:
- case VIR_STORAGE_TYPE_LAST:
virReportError(VIR_ERR_INTERNAL_ERROR,
_("external inactive snapshots are not supported on "
"'%s' disks"),
virStorageTypeToString(domDiskType));
return -1;
+ case VIR_STORAGE_TYPE_LAST:
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected storage type %d"), domDiskType);
}
switch ((virStorageType) snapDiskType) {
@@ -14148,11 +14192,14 @@
qemuDomainSnapshotPrepareDiskExternalInactive(virDomainSnapshotDiskDefPtr snapdi
case VIR_STORAGE_TYPE_DIR:
case VIR_STORAGE_TYPE_VOLUME:
case VIR_STORAGE_TYPE_NONE:
- case VIR_STORAGE_TYPE_LAST:
virReportError(VIR_ERR_INTERNAL_ERROR,
_("external inactive snapshots are not supported on "
"'%s' disks"),
virStorageTypeToString(snapDiskType));
return -1;
+ case VIR_STORAGE_TYPE_LAST:
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected storage type %d"), snapDiskType);
}
if (qemuDomainSnapshotPrepareDiskShared(snapdisk, domdisk) < 0)
@@ -14197,24 +14244,31 @@
qemuDomainSnapshotPrepareDiskExternalActive(virDomainSnapshotDiskDefPtr snapdisk
case VIR_STORAGE_NET_PROTOCOL_TFTP:
case VIR_STORAGE_NET_PROTOCOL_SSH:
case VIR_STORAGE_NET_PROTOCOL_VXHS:
- case VIR_STORAGE_NET_PROTOCOL_LAST:
virReportError(VIR_ERR_INTERNAL_ERROR,
_("external active snapshots are not supported on "
"'network' disks using '%s'
protocol"),
virStorageNetProtocolTypeToString(snapdisk->src->protocol));
return -1;
-
+ case VIR_STORAGE_NET_PROTOCOL_LAST:
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected storage protocol %d"),
snapdisk->src->protocol);
+ return -1;
}
break;
case VIR_STORAGE_TYPE_DIR:
case VIR_STORAGE_TYPE_VOLUME:
case VIR_STORAGE_TYPE_NONE:
- case VIR_STORAGE_TYPE_LAST:
virReportError(VIR_ERR_INTERNAL_ERROR,
_("external active snapshots are not supported on "
"'%s' disks"),
virStorageTypeToString(actualType));
return -1;
+ case VIR_STORAGE_TYPE_LAST:
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected storage type %d"), actualType);
+ return -1;
}
if (qemuDomainSnapshotPrepareDiskShared(snapdisk, domdisk) < 0)
@@ -14315,23 +14369,31 @@ qemuDomainSnapshotPrepareDiskInternal(virConnectPtr conn,
case VIR_STORAGE_NET_PROTOCOL_TFTP:
case VIR_STORAGE_NET_PROTOCOL_SSH:
case VIR_STORAGE_NET_PROTOCOL_VXHS:
- case VIR_STORAGE_NET_PROTOCOL_LAST:
virReportError(VIR_ERR_INTERNAL_ERROR,
_("internal inactive snapshots are not supported on
"
"'network' disks using '%s'
protocol"),
virStorageNetProtocolTypeToString(disk->src->protocol));
return -1;
+ case VIR_STORAGE_NET_PROTOCOL_LAST:
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected storage protocol %d"),
disk->src->protocol);
+ return -1;
}
break;
case VIR_STORAGE_TYPE_DIR:
case VIR_STORAGE_TYPE_VOLUME:
case VIR_STORAGE_TYPE_NONE:
- case VIR_STORAGE_TYPE_LAST:
virReportError(VIR_ERR_INTERNAL_ERROR,
_("internal inactive snapshots are not supported on "
"'%s' disks"),
virStorageTypeToString(actualType));
return -1;
+ case VIR_STORAGE_TYPE_LAST:
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected storage type %d"), actualType);
+ return -1;
}
return 0;
@@ -14425,10 +14487,14 @@ qemuDomainSnapshotPrepare(virConnectPtr conn,
break;
case VIR_DOMAIN_SNAPSHOT_LOCATION_DEFAULT:
- case VIR_DOMAIN_SNAPSHOT_LOCATION_LAST:
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("unexpected code path"));
goto cleanup;
+ case VIR_DOMAIN_SNAPSHOT_LOCATION_LAST:
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected snapshot location type %d"),
disk->snapshot);
+ goto cleanup;
}
}
@@ -15176,10 +15242,14 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain,
/* invalid states */
case VIR_DOMAIN_NOSTATE:
case VIR_DOMAIN_BLOCKED: /* invalid state, unused in qemu */
- case VIR_DOMAIN_LAST:
virReportError(VIR_ERR_INTERNAL_ERROR, _("Invalid domain state %s"),
virDomainStateTypeToString(vm->state.state));
goto cleanup;
+ case VIR_DOMAIN_LAST:
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected domain state %d"), vm->state.state);
+ goto endjob;
}
/* We are going to modify the domain below. Internal snapshots would use
@@ -16089,12 +16159,16 @@ qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
case VIR_DOMAIN_NOSTATE:
case VIR_DOMAIN_BLOCKED:
- case VIR_DOMAIN_LAST:
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Invalid target domain state '%s'. Refusing "
"snapshot reversion"),
virDomainStateTypeToString(snap->def->state));
goto endjob;
+ case VIR_DOMAIN_LAST:
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected domain state %d"),
snap->def->state);
+ goto endjob;
}
ret = 0;
@@ -21182,6 +21256,7 @@ qemuDomainModifyLifecycleAction(virDomainDefPtr def,
def->onCrash = action;
break;
case VIR_DOMAIN_LIFECYCLE_LAST:
+ default:
break;
}
}
diff --git a/src/qemu/qemu_hostdev.c b/src/qemu/qemu_hostdev.c
index 73d26f4c63..724a72867a 100644
--- a/src/qemu/qemu_hostdev.c
+++ b/src/qemu/qemu_hostdev.c
@@ -240,7 +240,10 @@ qemuHostdevPreparePCIDevicesCheckSupport(virDomainHostdevDefPtr
*hostdevs,
case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_XEN:
case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_TYPE_LAST:
- break;
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected hostdev PCI backend %d"), *backend);
+ return false;
}
}
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 0d7d02c25b..ac66df9ab9 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -778,15 +778,23 @@ qemuDomainAttachDeviceDiskLive(virConnectPtr conn,
case VIR_DOMAIN_DISK_BUS_UML:
case VIR_DOMAIN_DISK_BUS_SATA:
case VIR_DOMAIN_DISK_BUS_SD:
- case VIR_DOMAIN_DISK_BUS_LAST:
virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
_("disk bus '%s' cannot be hotplugged."),
virDomainDiskBusTypeToString(disk->bus));
+ goto cleanup;
+ case VIR_DOMAIN_DISK_BUS_LAST:
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected disk bus %d"), disk->bus);
+ goto cleanup;
}
break;
case VIR_DOMAIN_DISK_DEVICE_LAST:
- break;
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected disk device type %d"), disk->device);
+ goto cleanup;
}
cleanup:
@@ -986,11 +994,16 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver,
case VIR_DOMAIN_NET_TYPE_MCAST:
case VIR_DOMAIN_NET_TYPE_INTERNAL:
case VIR_DOMAIN_NET_TYPE_UDP:
- case VIR_DOMAIN_NET_TYPE_LAST:
virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
_("hotplug of interface type of %s is not implemented
yet"),
virDomainNetTypeToString(actualType));
goto cleanup;
+
+ case VIR_DOMAIN_NET_TYPE_LAST:
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected net type %d"), actualType);
+ goto cleanup;
}
/* Set device online immediately */
@@ -1297,12 +1310,15 @@ qemuDomainAttachHostPCIDevice(virQEMUDriverPtr driver,
break;
case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_XEN:
- case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_TYPE_LAST:
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("QEMU does not support device assignment mode
'%s'"),
virDomainHostdevSubsysPCIBackendTypeToString(backend));
goto error;
- break;
+ case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_TYPE_LAST:
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected hostdev PCI backend %d"), backend);
+ goto error;
}
/* Temporarily add the hostdev to the domain definition. This is needed
@@ -2662,6 +2678,9 @@ qemuDomainAttachShmemDevice(virQEMUDriverPtr driver,
virDomainShmemModelTypeToString(shmem->model));
ATTRIBUTE_FALLTHROUGH;
case VIR_DOMAIN_SHMEM_MODEL_LAST:
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected shmem device type %d"), shmem->model);
return -1;
}
@@ -3590,9 +3609,15 @@ qemuDomainChangeGraphics(virQEMUDriverPtr driver,
break;
case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NONE:
- case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_LAST:
/* nada */
break;
+
+ case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_LAST:
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected graphics listen type %d"),
+ newlisten->type);
+ goto cleanup;
}
}
@@ -4077,7 +4102,11 @@ qemuDomainRemoveHostDevice(virQEMUDriverPtr driver,
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_MDEV:
break;
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_LAST:
- break;
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected hostdev subsystem type %d"),
+ hostdev->source.subsys.type);
+ goto cleanup;
}
virDomainHostdevDefFree(hostdev);
@@ -4536,11 +4565,15 @@ qemuDomainRemoveDevice(virQEMUDriverPtr driver,
case VIR_DOMAIN_DEVICE_TPM:
case VIR_DOMAIN_DEVICE_PANIC:
case VIR_DOMAIN_DEVICE_IOMMU:
- case VIR_DOMAIN_DEVICE_LAST:
virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
_("don't know how to remove a %s device"),
virDomainDeviceTypeToString(dev->type));
break;
+ case VIR_DOMAIN_DEVICE_LAST:
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected device type %d"), dev->type);
+ break;
}
return ret;
}
@@ -5153,6 +5186,9 @@ qemuDomainDetachShmemDevice(virQEMUDriverPtr driver,
virDomainShmemModelTypeToString(shmem->model));
ATTRIBUTE_FALLTHROUGH;
case VIR_DOMAIN_SHMEM_MODEL_LAST:
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected shmem model %d"), shmem->model);
return -1;
}
@@ -6282,10 +6318,14 @@ qemuDomainDetachInputDevice(virDomainObjPtr vm,
virDomainInputBusTypeToString(input->bus));
return -1;
- case VIR_DOMAIN_INPUT_BUS_LAST:
case VIR_DOMAIN_INPUT_BUS_USB:
case VIR_DOMAIN_INPUT_BUS_VIRTIO:
break;
+ case VIR_DOMAIN_INPUT_BUS_LAST:
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected input bus %d"), input->bus);
+ return -1;
}
qemuDomainMarkDeviceForRemoval(vm, &input->info);
diff --git a/src/qemu/qemu_interface.c b/src/qemu/qemu_interface.c
index cebb490221..93f5a9185a 100644
--- a/src/qemu/qemu_interface.c
+++ b/src/qemu/qemu_interface.c
@@ -122,9 +122,13 @@ qemuInterfaceStartDevice(virDomainNetDefPtr net)
case VIR_DOMAIN_NET_TYPE_UDP:
case VIR_DOMAIN_NET_TYPE_INTERNAL:
case VIR_DOMAIN_NET_TYPE_HOSTDEV:
- case VIR_DOMAIN_NET_TYPE_LAST:
/* these types all require no action */
break;
+ case VIR_DOMAIN_NET_TYPE_LAST:
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected net type %d"), actualType);
+ goto cleanup;
}
ret = 0;
@@ -210,9 +214,13 @@ qemuInterfaceStopDevice(virDomainNetDefPtr net)
case VIR_DOMAIN_NET_TYPE_UDP:
case VIR_DOMAIN_NET_TYPE_INTERNAL:
case VIR_DOMAIN_NET_TYPE_HOSTDEV:
- case VIR_DOMAIN_NET_TYPE_LAST:
/* these types all require no action */
break;
+ case VIR_DOMAIN_NET_TYPE_LAST:
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected net type %d"), actualType);
+ goto cleanup;
}
ret = 0;
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index fe3342b38d..39d4ba7709 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -352,11 +352,15 @@ qemuMigrationPrecreateDisk(virConnectPtr conn,
case VIR_STORAGE_TYPE_BLOCK:
case VIR_STORAGE_TYPE_DIR:
case VIR_STORAGE_TYPE_NONE:
- case VIR_STORAGE_TYPE_LAST:
virReportError(VIR_ERR_INTERNAL_ERROR,
_("cannot precreate storage for disk type
'%s'"),
virStorageTypeToString(disk->src->type));
goto cleanup;
+ case VIR_STORAGE_TYPE_LAST:
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unespected storage type %d"),
disk->src->type);
+ goto cleanup;
}
if ((vol = virStorageVolLookupByName(pool, volName))) {
@@ -775,6 +779,11 @@ qemuMigrationCancelOneDriveMirror(virQEMUDriverPtr driver,
case VIR_DOMAIN_BLOCK_JOB_COMPLETED:
ret = 1;
goto cleanup;
+
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("UJnexpected block job status %d"), status);
+ goto cleanup;
}
if (!(diskAlias = qemuAliasFromDisk(disk)))
@@ -1400,6 +1409,7 @@ qemuMigrationUpdateJobType(qemuDomainJobInfoPtr jobInfo)
case QEMU_MONITOR_MIGRATION_STATUS_ACTIVE:
case QEMU_MONITOR_MIGRATION_STATUS_CANCELLING:
case QEMU_MONITOR_MIGRATION_STATUS_LAST:
+ default:
break;
}
}
@@ -1500,6 +1510,11 @@ qemuMigrationCheckJobStatus(virQEMUDriverPtr driver,
case QEMU_DOMAIN_JOB_STATUS_POSTCOPY:
case QEMU_DOMAIN_JOB_STATUS_PAUSED:
break;
+
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected job status %d"), jobInfo->status);
+ goto cleanup;
}
ret = 0;
@@ -1603,6 +1618,7 @@ qemuMigrationCompleted(virQEMUDriverPtr driver,
case QEMU_DOMAIN_JOB_STATUS_ACTIVE:
case QEMU_DOMAIN_JOB_STATUS_COMPLETED:
case QEMU_DOMAIN_JOB_STATUS_NONE:
+ default:
/* Impossible. */
break;
}
@@ -1961,6 +1977,7 @@ qemuMigrationCleanup(virDomainObjPtr vm,
/* single phase outgoing migration; unreachable */
case QEMU_MIGRATION_PHASE_NONE:
case QEMU_MIGRATION_PHASE_LAST:
+ default:
/* unreachable */
;
}
@@ -3899,6 +3916,11 @@ qemuMigrationRun(virQEMUDriverPtr driver,
spec->dest.fd.qemu);
VIR_FORCE_CLOSE(spec->dest.fd.qemu);
break;
+
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected migration dest type %d"),
spec->destType);
+ goto exit_monitor;
}
if (qemuDomainObjExitMonitor(driver, vm) < 0 || rc < 0)
diff --git a/src/qemu/qemu_migration_cookie.c b/src/qemu/qemu_migration_cookie.c
index 945530c409..5c721e7fe1 100644
--- a/src/qemu/qemu_migration_cookie.c
+++ b/src/qemu/qemu_migration_cookie.c
@@ -340,8 +340,12 @@ qemuMigrationCookieAddGraphics(qemuMigrationCookiePtr mig,
case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET:
case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NONE:
- case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_LAST:
break;
+ case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_LAST:
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected graphics listen type %d"),
glisten->type);
+ return -1;
}
/* Seamless migration is supported only for one graphics. */
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index 9b5ad72cf9..455a4eff17 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -2234,9 +2234,11 @@ qemuMonitorBlockIOStatusToError(const char *status)
/* unreachable */
case QEMU_MONITOR_BLOCK_IO_STATUS_LAST:
- break;
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected block IO status %d"), st);
+ return -1;
}
- return -1;
}
@@ -3680,6 +3682,7 @@ qemuMonitorVMStatusToPausedReason(const char *status)
/* unreachable from this point on */
case QEMU_MONITOR_VM_STATUS_LAST:
+ default:
;
}
return VIR_DOMAIN_PAUSED_UNKNOWN;
@@ -3865,7 +3868,10 @@ qemuMonitorCPUModelInfoCopy(const qemuMonitorCPUModelInfo *orig)
break;
case QEMU_MONITOR_CPU_PROPERTY_LAST:
- break;
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected CPU property %d"),
orig->props[i].type);
+ goto error;
}
}
@@ -4366,6 +4372,7 @@ qemuMonitorGuestPanicEventInfoFormatMsg(qemuMonitorEventPanicInfoPtr
info)
case QEMU_MONITOR_EVENT_PANIC_INFO_TYPE_NONE:
case QEMU_MONITOR_EVENT_PANIC_INFO_TYPE_LAST:
+ default:
break;
}
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 242b92ea3f..790ea0277c 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -899,6 +899,7 @@ qemuMonitorJSONHandleBlockJobImpl(qemuMonitorPtr mon,
break;
case VIR_DOMAIN_BLOCK_JOB_FAILED:
case VIR_DOMAIN_BLOCK_JOB_LAST:
+ default:
VIR_DEBUG("should not get here");
break;
}
@@ -1619,7 +1620,7 @@ qemuMonitorJSONUpdateVideoMemorySize(qemuMonitorPtr mon,
{0}
};
- switch (video->type) {
+ switch ((virDomainVideoType)video->type) {
case VIR_DOMAIN_VIDEO_TYPE_VGA:
if (qemuMonitorJSONGetObjectProperty(mon, path, "vgamem_mb", &prop)
< 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -1663,10 +1664,22 @@ qemuMonitorJSONUpdateVideoMemorySize(qemuMonitorPtr mon,
video->vram = prop.val.ul * 1024;
break;
case VIR_DOMAIN_VIDEO_TYPE_CIRRUS:
+ case VIR_DOMAIN_VIDEO_TYPE_DEFAULT:
+ case VIR_DOMAIN_VIDEO_TYPE_VIRTIO:
+ break;
case VIR_DOMAIN_VIDEO_TYPE_XEN:
case VIR_DOMAIN_VIDEO_TYPE_VBOX:
+ case VIR_DOMAIN_VIDEO_TYPE_GOP:
+ case VIR_DOMAIN_VIDEO_TYPE_PARALLELS:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unsupported video type %s"),
+ virDomainVideoTypeToString(video->type));
+ return -1;
case VIR_DOMAIN_VIDEO_TYPE_LAST:
- break;
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected video type %d"), video->type);
+ return -1;
}
return 0;
@@ -1689,7 +1702,7 @@ qemuMonitorJSONUpdateVideoVram64Size(qemuMonitorPtr mon,
{0}
};
- switch (video->type) {
+ switch ((virDomainVideoType)video->type) {
case VIR_DOMAIN_VIDEO_TYPE_QXL:
if (video->vram64 != 0) {
if (qemuMonitorJSONGetObjectProperty(mon, path,
@@ -1705,10 +1718,22 @@ qemuMonitorJSONUpdateVideoVram64Size(qemuMonitorPtr mon,
case VIR_DOMAIN_VIDEO_TYPE_VGA:
case VIR_DOMAIN_VIDEO_TYPE_VMVGA:
case VIR_DOMAIN_VIDEO_TYPE_CIRRUS:
+ case VIR_DOMAIN_VIDEO_TYPE_DEFAULT:
+ case VIR_DOMAIN_VIDEO_TYPE_VIRTIO:
+ break;
case VIR_DOMAIN_VIDEO_TYPE_XEN:
case VIR_DOMAIN_VIDEO_TYPE_VBOX:
+ case VIR_DOMAIN_VIDEO_TYPE_GOP:
+ case VIR_DOMAIN_VIDEO_TYPE_PARALLELS:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unsupported video type %s"),
+ virDomainVideoTypeToString(video->type));
+ return -1;
case VIR_DOMAIN_VIDEO_TYPE_LAST:
- break;
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected video type %d"), video->type);
+ return -1;
}
return 0;
@@ -3075,6 +3100,11 @@ qemuMonitorJSONGetMigrationStatsReply(virJSONValuePtr reply,
}
}
break;
+
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected migration status %d"), stats->status);
+ return -1;
}
return 0;
@@ -5297,6 +5327,11 @@ qemuMonitorJSONParseCPUModelProperty(const char *key,
case VIR_JSON_TYPE_ARRAY:
case VIR_JSON_TYPE_NULL:
return 0;
+
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected JSON value type %d"), value->type);
+ return -1;
}
machine_model->nprops++;
@@ -5351,6 +5386,10 @@ qemuMonitorJSONGetCPUModelExpansion(qemuMonitorPtr mon,
case QEMU_MONITOR_CPU_MODEL_EXPANSION_FULL:
typeStr = "full";
break;
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected CPU model expansion %d"), type);
+ goto cleanup;
}
if (!(cmd = qemuMonitorJSONMakeCommand("query-cpu-model-expansion",
@@ -5935,11 +5974,11 @@ int qemuMonitorJSONGetObjectProperty(qemuMonitorPtr mon,
ret = 0;
break;
case QEMU_MONITOR_OBJECT_PROPERTY_LAST:
+ default:
virReportError(VIR_ERR_INTERNAL_ERROR,
_("qom-get invalid object property type %d"),
prop->type);
goto cleanup;
- break;
}
if (ret == -1) {
@@ -5998,6 +6037,7 @@ int qemuMonitorJSONSetObjectProperty(qemuMonitorPtr mon,
MAKE_SET_CMD("s:value", prop->val.str);
break;
case QEMU_MONITOR_OBJECT_PROPERTY_LAST:
+ default:
virReportError(VIR_ERR_INTERNAL_ERROR,
_("qom-set invalid object property type %d"),
prop->type);
@@ -6708,16 +6748,15 @@ qemuMonitorJSONAttachCharDevCommand(const char *chrID,
case VIR_DOMAIN_CHR_TYPE_PIPE:
case VIR_DOMAIN_CHR_TYPE_STDIO:
case VIR_DOMAIN_CHR_TYPE_NMDM:
+ virReportError(VIR_ERR_OPERATION_FAILED,
+ _("Hotplug unsupported for char device type
'%s'"),
+ virDomainChrTypeToString(chr->type));
+ goto cleanup;
case VIR_DOMAIN_CHR_TYPE_LAST:
- if (virDomainChrTypeToString(chr->type)) {
- virReportError(VIR_ERR_OPERATION_FAILED,
- _("Hotplug unsupported for char device type
'%s'"),
- virDomainChrTypeToString(chr->type));
- } else {
- virReportError(VIR_ERR_OPERATION_FAILED,
- _("Hotplug unsupported for char device type
'%d'"),
- chr->type);
- }
+ default:
+ virReportError(VIR_ERR_OPERATION_FAILED,
+ _("Unexpected chardev type %d"),
+ chr->type);
goto cleanup;
}
diff --git a/src/qemu/qemu_monitor_text.c b/src/qemu/qemu_monitor_text.c
index 2db71548cb..ddab0e7d5a 100644
--- a/src/qemu/qemu_monitor_text.c
+++ b/src/qemu/qemu_monitor_text.c
@@ -618,6 +618,9 @@ static int parseMemoryStat(char **text, unsigned int tag,
case VIR_DOMAIN_MEMORY_STAT_UNUSED:
case VIR_DOMAIN_MEMORY_STAT_AVAILABLE:
value >>= 10;
+ break;
+ default:
+ break;
}
mstat->tag = tag;
mstat->val = value;
diff --git a/src/qemu/qemu_parse_command.c b/src/qemu/qemu_parse_command.c
index 5fe3f97d03..3f5c4c0cbc 100644
--- a/src/qemu/qemu_parse_command.c
+++ b/src/qemu/qemu_parse_command.c
@@ -1577,7 +1577,10 @@ qemuParseCommandLineCPU(virDomainDefPtr dom,
break;
case VIR_DOMAIN_HYPERV_LAST:
- break;
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected hyperv feature %d"), f);
+ goto cleanup;
}
virStringListFree(hv_tokens);
hv_tokens = NULL;
@@ -2174,10 +2177,15 @@ qemuParseCommandLine(virCapsPtr caps,
case VIR_STORAGE_NET_PROTOCOL_FTPS:
case VIR_STORAGE_NET_PROTOCOL_TFTP:
case VIR_STORAGE_NET_PROTOCOL_SSH:
- case VIR_STORAGE_NET_PROTOCOL_LAST:
case VIR_STORAGE_NET_PROTOCOL_NONE:
/* ignored for now */
break;
+ case VIR_STORAGE_NET_PROTOCOL_LAST:
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected storage protocol %d"),
+ disk->src->protocol);
+ goto error;
}
}
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index b86ecda93f..9f30e80046 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -2702,7 +2702,7 @@ qemuProcessUpdateVideoRamSize(virQEMUDriverPtr driver,
for (i = 0; i < vm->def->nvideos; i++) {
video = vm->def->videos[i];
- switch (video->type) {
+ switch ((virDomainVideoType)video->type) {
case VIR_DOMAIN_VIDEO_TYPE_VGA:
if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VGA_VGAMEM)) {
if (qemuMonitorUpdateVideoMemorySize(priv->mon, video,
"VGA") < 0)
@@ -2740,10 +2740,22 @@ qemuProcessUpdateVideoRamSize(virQEMUDriverPtr driver,
}
break;
case VIR_DOMAIN_VIDEO_TYPE_CIRRUS:
+ case VIR_DOMAIN_VIDEO_TYPE_DEFAULT:
+ case VIR_DOMAIN_VIDEO_TYPE_VIRTIO:
+ break;
+ case VIR_DOMAIN_VIDEO_TYPE_GOP:
+ case VIR_DOMAIN_VIDEO_TYPE_PARALLELS:
case VIR_DOMAIN_VIDEO_TYPE_XEN:
case VIR_DOMAIN_VIDEO_TYPE_VBOX:
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("Unsupported video type %s"),
+ virDomainVideoTypeToString(video->type));
+ goto error;
case VIR_DOMAIN_VIDEO_TYPE_LAST:
- break;
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected video type %d"), video->type);
+ goto error;
}
}
@@ -3092,6 +3104,11 @@ qemuProcessRecoverMigrationIn(virQEMUDriverPtr driver,
return -1;
}
break;
+
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected migration phase %d"), phase);
+ return -1;
}
qemuMigrationReset(driver, vm, QEMU_ASYNC_JOB_NONE);
@@ -3172,6 +3189,11 @@ qemuProcessRecoverMigrationOut(virQEMUDriverPtr driver,
/* migration completed, we need to kill the domain here */
*stopFlags |= VIR_QEMU_PROCESS_STOP_MIGRATED;
return -1;
+
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected migration phase %d"), phase);
+ return -1;
}
if (resume) {
@@ -3253,8 +3275,12 @@ qemuProcessRecoverJob(virQEMUDriverPtr driver,
break;
case QEMU_ASYNC_JOB_NONE:
- case QEMU_ASYNC_JOB_LAST:
break;
+ case QEMU_ASYNC_JOB_LAST:
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected job type %d"), job->asyncJob);
+ return -1;
}
if (!virDomainObjIsActive(vm))
@@ -3290,8 +3316,12 @@ qemuProcessRecoverJob(virQEMUDriverPtr driver,
case QEMU_JOB_ASYNC_NESTED:
/* async job was already handled above */
case QEMU_JOB_NONE:
- case QEMU_JOB_LAST:
break;
+ case QEMU_JOB_LAST:
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected job type %d"), job->active);
+ return -1;
}
return 0;
@@ -3612,6 +3642,12 @@ qemuProcessSPICEAllocatePorts(virQEMUDriverPtr driver,
case VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_MODE_ANY:
/* default mode will be used */
break;
+
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected SPICE channel mode %d"),
+ graphics->data.spice.channels[i]);
+ goto cleanup;
}
}
switch (defaultMode) {
@@ -3628,6 +3664,12 @@ qemuProcessSPICEAllocatePorts(virQEMUDriverPtr driver,
needTLSPort = true;
needPort = true;
break;
+
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected SPICE channel mode %d"),
+ defaultMode);
+ goto cleanup;
}
}
@@ -3748,6 +3790,7 @@ qemuProcessVerifyHypervFeatures(virDomainDefPtr def,
/* coverity[dead_error_begin] */
case VIR_DOMAIN_HYPERV_VENDOR_ID:
case VIR_DOMAIN_HYPERV_LAST:
+ default:
break;
}
}
@@ -4297,10 +4340,18 @@ qemuProcessGraphicsReservePorts(virQEMUDriverPtr driver,
break;
case VIR_DOMAIN_GRAPHICS_TYPE_SDL:
+ break;
case VIR_DOMAIN_GRAPHICS_TYPE_RDP:
case VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP:
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("Unsupported graphics type %s"),
+ virDomainGraphicsTypeToString(graphics->type));
+ return -1;
case VIR_DOMAIN_GRAPHICS_TYPE_LAST:
- break;
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected graphics type %d"), graphics->type);
+ return -1;
}
return 0;
@@ -4335,9 +4386,17 @@ qemuProcessGraphicsAllocatePorts(virQEMUDriverPtr driver,
break;
case VIR_DOMAIN_GRAPHICS_TYPE_SDL:
+ break;
case VIR_DOMAIN_GRAPHICS_TYPE_RDP:
case VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP:
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("Unsupported graphics type %s"),
+ virDomainGraphicsTypeToString(graphics->type));
+ return -1;
case VIR_DOMAIN_GRAPHICS_TYPE_LAST:
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected graphics type %d"), graphics->type);
break;
}
@@ -4371,7 +4430,7 @@ qemuProcessGetNetworkAddress(virConnectPtr conn,
if (!netdef)
goto cleanup;
- switch (netdef->forward.type) {
+ switch ((virNetworkForwardType)netdef->forward.type) {
case VIR_NETWORK_FORWARD_NONE:
case VIR_NETWORK_FORWARD_NAT:
case VIR_NETWORK_FORWARD_ROUTE:
@@ -4408,6 +4467,16 @@ qemuProcessGetNetworkAddress(virConnectPtr conn,
goto cleanup;
}
break;
+
+ case VIR_NETWORK_FORWARD_HOSTDEV:
+ break;
+
+ case VIR_NETWORK_FORWARD_LAST:
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected network forward type %d"),
+ netdef->forward.type);
+ goto cleanup;
}
if (dev_name) {
@@ -4484,10 +4553,18 @@ qemuProcessGraphicsSetupListen(virConnectPtr conn,
break;
case VIR_DOMAIN_GRAPHICS_TYPE_SDL:
+ break;
case VIR_DOMAIN_GRAPHICS_TYPE_RDP:
case VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP:
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("Unsupported graphics type %s"),
+ virDomainGraphicsTypeToString(graphics->type));
+ goto cleanup;
case VIR_DOMAIN_GRAPHICS_TYPE_LAST:
- break;
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected graphics type %d"), graphics->type);
+ goto cleanup;
}
for (i = 0; i < graphics->nListens; i++) {
@@ -4534,8 +4611,12 @@ qemuProcessGraphicsSetupListen(virConnectPtr conn,
break;
case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NONE:
- case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_LAST:
break;
+ case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_LAST:
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected graphics listen type %d"),
glisten->type);
+ goto cleanup;
}
}
@@ -4773,10 +4854,18 @@ qemuProcessStartValidateGraphics(virDomainObjPtr vm)
break;
case VIR_DOMAIN_GRAPHICS_TYPE_SDL:
+ break;
case VIR_DOMAIN_GRAPHICS_TYPE_RDP:
case VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP:
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("Unsupported graphics type %s"),
+ virDomainGraphicsTypeToString(graphics->type));
+ return -1;
case VIR_DOMAIN_GRAPHICS_TYPE_LAST:
- break;
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected graphics type %d"),
graphics->type);
+ return -1;
}
}
@@ -6708,6 +6797,7 @@ void qemuProcessStop(virQEMUDriverPtr driver,
case VIR_DOMAIN_NET_TYPE_HOSTDEV:
case VIR_DOMAIN_NET_TYPE_UDP:
case VIR_DOMAIN_NET_TYPE_LAST:
+ default:
/* No special cleanup procedure for these types. */
break;
}
--
2.14.3