virDomainShmemDef: Change type of model to virDomainShmemModel

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Tim Wiederhake 2021-04-27 17:04:36 +02:00 committed by Ján Tomko
parent cacde05ad3
commit b3a6daa36d
6 changed files with 16 additions and 5 deletions

View File

@ -13614,15 +13614,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);
}

View File

@ -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;

View File

@ -9097,7 +9097,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;

View File

@ -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;

View File

@ -4893,6 +4893,11 @@ qemuValidateDomainDeviceDefShmem(virDomainShmemDef *shmem,
virDomainShmemModelTypeToString(shmem->model));
return -1;
}
break;
case VIR_DOMAIN_SHMEM_MODEL_LAST:
virReportEnumRangeError(virDomainShmemModel, shmem->model);
return -1;
}
return 0;

View File

@ -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)