From dc7ca40a13d8f90a2b7248a5c7c15e34fd3b3514 Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Wed, 16 Aug 2023 13:07:34 +0200 Subject: [PATCH] qemu: Retire 'ivshmem' device MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The device was removed in qemu-4.0 and is superseded by 'ivshmem-plain' and 'ivshmem-doorbell'. Always report error when the old version is used and drop the irrelevant tests. Signed-off-by: Peter Krempa Reviewed-by: Ján Tomko --- src/qemu/qemu_command.c | 40 +--------------- src/qemu/qemu_hotplug.c | 14 +----- src/qemu/qemu_migration.c | 5 -- src/qemu/qemu_validate.c | 10 ++-- tests/qemuxml2argvdata/shmem.args | 43 ----------------- tests/qemuxml2argvdata/shmem.err | 1 - tests/qemuxml2argvdata/shmem.xml | 56 ---------------------- tests/qemuxml2argvtest.c | 2 - tests/qemuxml2xmloutdata/shmem.xml | 74 ------------------------------ tests/qemuxml2xmltest.c | 1 - 10 files changed, 5 insertions(+), 241 deletions(-) delete mode 100644 tests/qemuxml2argvdata/shmem.args delete mode 100644 tests/qemuxml2argvdata/shmem.err delete mode 100644 tests/qemuxml2argvdata/shmem.xml delete mode 100644 tests/qemuxml2xmloutdata/shmem.xml diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 77c5335bde..9a6840e870 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -8873,44 +8873,6 @@ qemuBuildSmartcardCommandLine(virCommand *cmd, } -static virJSONValue * -qemuBuildShmemDevLegacyProps(virDomainDef *def, - virDomainShmemDef *shmem) -{ - g_autoptr(virJSONValue) props = NULL; - g_autofree char *size = NULL; - const char *shm = NULL; - g_autofree char *chardev = NULL; - - /* while this would result in a type error with newer qemus, the 'ivshmem' - * device was removed in qemu-4.0, so for the sake of not changing the - * commandline we do this hack */ - size = g_strdup_printf("%llum", shmem->size >> 20); - - if (shmem->server.enabled) - chardev = g_strdup_printf("char%s", shmem->info.alias); - else - shm = shmem->name; - - if (virJSONValueObjectAdd(&props, - "s:driver", "ivshmem", - "s:id", shmem->info.alias, - "s:size", size, - "S:shm", shm, - "S:chardev", chardev, - "B:msi", shmem->msi.enabled, - "p:vectors", shmem->msi.vectors, - "T:ioeventfd", shmem->msi.ioeventfd, - NULL) < 0) - return NULL; - - if (qemuBuildDeviceAddressProps(props, def, &shmem->info) < 0) - return NULL; - - return g_steal_pointer(&props); -} - - virJSONValue * qemuBuildShmemDevProps(virDomainDef *def, virDomainShmemDef *shmem) @@ -9014,7 +8976,7 @@ qemuBuildShmemCommandLine(virCommand *cmd, switch (shmem->model) { case VIR_DOMAIN_SHMEM_MODEL_IVSHMEM: - devProps = qemuBuildShmemDevLegacyProps(def, shmem); + /* unreachable, rejected by validation */ break; case VIR_DOMAIN_SHMEM_MODEL_IVSHMEM_PLAIN: diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 2e3c99760d..f3f0e23fa7 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -2817,19 +2817,7 @@ qemuDomainAttachShmemDevice(virDomainObj *vm, qemuDomainObjPrivate *priv = vm->privateData; virDomainDeviceDef dev = { VIR_DOMAIN_DEVICE_SHMEM, { .shmem = shmem } }; - switch (shmem->model) { - case VIR_DOMAIN_SHMEM_MODEL_IVSHMEM_PLAIN: - case VIR_DOMAIN_SHMEM_MODEL_IVSHMEM_DOORBELL: - break; - - case VIR_DOMAIN_SHMEM_MODEL_IVSHMEM: - virReportError(VIR_ERR_OPERATION_UNSUPPORTED, - _("live attach of shmem model '%1$s' is not supported"), - virDomainShmemModelTypeToString(shmem->model)); - G_GNUC_FALLTHROUGH; - case VIR_DOMAIN_SHMEM_MODEL_LAST: - return -1; - } + /* validation ensures that the legacy 'ivshmem' device is rejected */ qemuAssignDeviceShmemAlias(vm->def, shmem, -1); diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index d21551ab07..9b490a130d 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -1503,11 +1503,6 @@ qemuMigrationSrcIsAllowed(virDomainObj *vm, for (i = 0; i < vm->def->nshmems; i++) { virDomainShmemDef *shmem = vm->def->shmems[i]; - if (shmem->model == VIR_DOMAIN_SHMEM_MODEL_IVSHMEM) { - virReportError(VIR_ERR_OPERATION_INVALID, "%s", - _("migration with legacy shmem device is not supported")); - return false; - } if (shmem->role != VIR_DOMAIN_SHMEM_ROLE_MASTER) { virReportError(VIR_ERR_OPERATION_INVALID, _("shmem device '%1$s' cannot be migrated, only shmem with role='%2$s' can be migrated"), diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index d62d064a25..28e4a4cc99 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -5103,13 +5103,9 @@ qemuValidateDomainDeviceDefShmem(virDomainShmemDef *shmem, { switch (shmem->model) { case VIR_DOMAIN_SHMEM_MODEL_IVSHMEM: - if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_IVSHMEM)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("ivshmem device is not supported " - "with this QEMU binary")); - return -1; - } - break; + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("ivshmem device is no longer supported")); + return -1; case VIR_DOMAIN_SHMEM_MODEL_IVSHMEM_PLAIN: if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_IVSHMEM_PLAIN)) { diff --git a/tests/qemuxml2argvdata/shmem.args b/tests/qemuxml2argvdata/shmem.args deleted file mode 100644 index 1ca9a3354f..0000000000 --- a/tests/qemuxml2argvdata/shmem.args +++ /dev/null @@ -1,43 +0,0 @@ -LC_ALL=C \ -PATH=/bin \ -HOME=/var/lib/libvirt/qemu/domain--1-QEMUGuest1 \ -USER=test \ -LOGNAME=test \ -XDG_DATA_HOME=/var/lib/libvirt/qemu/domain--1-QEMUGuest1/.local/share \ -XDG_CACHE_HOME=/var/lib/libvirt/qemu/domain--1-QEMUGuest1/.cache \ -XDG_CONFIG_HOME=/var/lib/libvirt/qemu/domain--1-QEMUGuest1/.config \ -/usr/bin/qemu-system-x86_64 \ --name guest=QEMUGuest1,debug-threads=on \ --S \ --object secret,id=masterKey0,format=raw,file=/var/lib/libvirt/qemu/domain--1-QEMUGuest1/master-key.aes \ --machine pc,usb=off,dump-guest-core=off \ --accel tcg \ --m size=219136k \ --overcommit mem-lock=off \ --smp 1,sockets=1,cores=1,threads=1 \ --uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ --display none \ --no-user-config \ --nodefaults \ --chardev socket,id=charmonitor,fd=1729,server=on,wait=off \ --mon chardev=charmonitor,id=monitor,mode=control \ --rtc base=utc \ --no-shutdown \ --no-acpi \ --boot strict=on \ --usb \ --audiodev '{"id":"audio1","driver":"none"}' \ --device ivshmem,id=shmem0,size=4m,shm=shmem0,bus=pci.0,addr=0x2 \ --device ivshmem,id=shmem1,size=128m,shm=shmem1,bus=pci.0,addr=0x3 \ --device ivshmem,id=shmem2,size=256m,shm=shmem2,bus=pci.0,addr=0x4 \ --device ivshmem,id=shmem3,size=512m,chardev=charshmem3,bus=pci.0,addr=0x5 \ --chardev socket,id=charshmem3,path=/var/lib/libvirt/shmem-shmem3-sock \ --device ivshmem,id=shmem4,size=1024m,chardev=charshmem4,bus=pci.0,addr=0x6 \ --chardev socket,id=charshmem4,path=/tmp/shmem4-sock \ --device ivshmem,id=shmem5,size=2048m,chardev=charshmem5,msi=on,ioeventfd=off,bus=pci.0,addr=0x7 \ --chardev socket,id=charshmem5,path=/tmp/shmem5-sock \ --device ivshmem,id=shmem6,size=4096m,chardev=charshmem6,msi=on,vectors=16,bus=pci.0,addr=0x8 \ --chardev socket,id=charshmem6,path=/tmp/shmem6-sock \ --device ivshmem,id=shmem7,size=8192m,chardev=charshmem7,msi=on,vectors=32,ioeventfd=on,bus=pci.0,addr=0x9 \ --chardev socket,id=charshmem7,path=/tmp/shmem7-sock \ --msg timestamp=on diff --git a/tests/qemuxml2argvdata/shmem.err b/tests/qemuxml2argvdata/shmem.err deleted file mode 100644 index b9e128edf3..0000000000 --- a/tests/qemuxml2argvdata/shmem.err +++ /dev/null @@ -1 +0,0 @@ -unsupported configuration: ivshmem device is not supported with this QEMU binary diff --git a/tests/qemuxml2argvdata/shmem.xml b/tests/qemuxml2argvdata/shmem.xml deleted file mode 100644 index b6dfe291df..0000000000 --- a/tests/qemuxml2argvdata/shmem.xml +++ /dev/null @@ -1,56 +0,0 @@ - - QEMUGuest1 - c7a5fdbd-edaf-9455-926a-d65c16db1809 - 219136 - 219136 - 1 - - hvm - - - - destroy - restart - destroy - - /usr/bin/qemu-system-x86_64 - - - - - - - - 128 - - - 256 -
- - - - 512 - - - - 1024 - - - - 2048 - - - - - - 4096 - - - - - 8192 - - - - - diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 900a7b4a9d..80f5af84e1 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -2441,8 +2441,6 @@ mymain(void) DO_TEST_CAPS_ARCH_VER_FULL("fips-enabled", "x86_64", "5.1.0", ARG_FLAGS, FLAG_FIPS_HOST); DO_TEST_CAPS_ARCH_LATEST_FULL("fips-enabled", "x86_64", ARG_FLAGS, FLAG_FIPS_HOST); - DO_TEST("shmem", QEMU_CAPS_DEVICE_IVSHMEM); - DO_TEST_PARSE_ERROR_NOCAPS("shmem"); DO_TEST_CAPS_LATEST("shmem-plain-doorbell"); DO_TEST_CAPS_LATEST_FAILURE("shmem-invalid-size"); DO_TEST_CAPS_LATEST_FAILURE("shmem-invalid-address"); diff --git a/tests/qemuxml2xmloutdata/shmem.xml b/tests/qemuxml2xmloutdata/shmem.xml deleted file mode 100644 index bdd273de17..0000000000 --- a/tests/qemuxml2xmloutdata/shmem.xml +++ /dev/null @@ -1,74 +0,0 @@ - - QEMUGuest1 - c7a5fdbd-edaf-9455-926a-d65c16db1809 - 219136 - 219136 - 1 - - hvm - - - - destroy - restart - destroy - - /usr/bin/qemu-system-x86_64 - -
- - - - -