Signed-off-by: Tim Wiederhake <twiederh(a)redhat.com>
---
src/conf/domain_conf.c | 4 +++-
src/conf/domain_conf.h | 2 +-
src/qemu/qemu_command.c | 2 +-
src/qemu/qemu_hotplug.c | 4 ++--
src/qemu/qemu_validate.c | 5 +++++
src/security/virt-aa-helper.c | 4 ++++
6 files changed, 16 insertions(+), 5 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index c9134c86c5..72d5545068 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -13995,15 +13995,17 @@ virDomainShmemDefParseXML(virDomainXMLOption *xmlopt,
tmp = virXPathString("string(./model/@type)", ctxt);
if (tmp) {
+ int model;
/* If there's none, we will automatically have the first one
* (as default). Unfortunately this has to be done for
* compatibility reasons. */
- if ((def->model = virDomainShmemModelTypeFromString(tmp)) < 0) {
+ if ((model = virDomainShmemModelTypeFromString(tmp)) < 0) {
virReportError(VIR_ERR_XML_ERROR,
_("Unknown shmem model type '%s'"), tmp);
goto cleanup;
}
+ def->model = model;
VIR_FREE(tmp);
}
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index d9c0cb21d2..8afffd2451 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1955,7 +1955,7 @@ typedef enum {
struct _virDomainShmemDef {
char *name;
unsigned long long size;
- int model; /* enum virDomainShmemModel */
+ virDomainShmemModel model;
int role; /* enum virDomainShmemRole */
struct {
bool enabled;
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index d7f1c715b6..8fb331eea0 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -9214,7 +9214,7 @@ qemuBuildShmemCommandLine(virLogManager *logManager,
return -1;
}
- switch ((virDomainShmemModel)shmem->model) {
+ switch (shmem->model) {
case VIR_DOMAIN_SHMEM_MODEL_IVSHMEM:
devstr = qemuBuildShmemDevLegacyStr(def, shmem, qemuCaps);
break;
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 4344edc75b..58afa2fae6 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -2978,7 +2978,7 @@ qemuDomainAttachShmemDevice(virQEMUDriver *driver,
qemuDomainObjPrivate *priv = vm->privateData;
virDomainDeviceDef dev = { VIR_DOMAIN_DEVICE_SHMEM, { .shmem = shmem } };
- switch ((virDomainShmemModel)shmem->model) {
+ switch (shmem->model) {
case VIR_DOMAIN_SHMEM_MODEL_IVSHMEM_PLAIN:
case VIR_DOMAIN_SHMEM_MODEL_IVSHMEM_DOORBELL:
break;
@@ -5583,7 +5583,7 @@ qemuDomainDetachPrepShmem(virDomainObj *vm,
*detach = shmem = vm->def->shmems[idx];
- switch ((virDomainShmemModel)shmem->model) {
+ switch (shmem->model) {
case VIR_DOMAIN_SHMEM_MODEL_IVSHMEM_PLAIN:
case VIR_DOMAIN_SHMEM_MODEL_IVSHMEM_DOORBELL:
break;
diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c
index 774426bceb..1d6881db5b 100644
--- a/src/qemu/qemu_validate.c
+++ b/src/qemu/qemu_validate.c
@@ -4936,6 +4936,11 @@ qemuValidateDomainDeviceDefShmem(virDomainShmemDef *shmem,
virDomainShmemModelTypeToString(shmem->model));
return -1;
}
+ break;
+
+ case VIR_DOMAIN_SHMEM_MODEL_LAST:
+ virReportEnumRangeError(virDomainShmemModel, shmem->model);
+ return -1;
}
return 0;
diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c
index 2331cc6648..e0d78ae309 100644
--- a/src/security/virt-aa-helper.c
+++ b/src/security/virt-aa-helper.c
@@ -1209,6 +1209,10 @@ get_files(vahControl * ctl)
mem_path = g_strdup_printf("/var/lib/libvirt/shmem-%s-sock",
shmem->name);
break;
+ case VIR_DOMAIN_SHMEM_MODEL_LAST:
+ virReportEnumRangeError(virDomainShmemModel,
+ shmem->model);
+ break;
}
if (mem_path != NULL) {
if (vah_add_file(&buf, mem_path, "rw") != 0)
--
2.26.3