From 131fddd429bc9a3e20b4ec1fb549bf4889fc6517 Mon Sep 17 00:00:00 2001 From: Masayoshi Mizuma Date: Mon, 30 Aug 2021 00:30:43 -0400 Subject: [PATCH] qemuValidateDomainDeviceDefDiskTransient: Validate that qemu doesn't terminate early Setup of a disk with option issues a reset of qemu. In cases when QEMU didn't yet support the 'set-action' QMP libvirt would in certain cases setup the commandline without '-no-shutdown' which caused qemu to exit during startup. Forbid this specific scenario. Signed-off-by: Masayoshi Mizuma Reviewed-by: Peter Krempa --- src/qemu/qemu_validate.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index 8906aa52d9..1a470f1ff5 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -24,6 +24,7 @@ #include "qemu_block.h" #include "qemu_command.h" #include "qemu_domain.h" +#include "qemu_process.h" #include "domain_conf.h" #include "virlog.h" #include "virutil.h" @@ -2991,6 +2992,7 @@ qemuValidateDomainDeviceDefDiskBlkdeviotune(const virDomainDiskDef *disk, static int qemuValidateDomainDeviceDefDiskTransient(const virDomainDiskDef *disk, + const virDomainDef *def, virQEMUCaps *qemuCaps) { @@ -3033,6 +3035,13 @@ qemuValidateDomainDeviceDefDiskTransient(const virDomainDiskDef *disk, } if (disk->transientShareBacking == VIR_TRISTATE_BOOL_YES) { + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_SET_ACTION) && + !qemuProcessRebootAllowed(def)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("transient disk backing image sharing with destroy action of lifecycle isn't supported by this QEMU binary")); + return -1; + } + /* sharing the backing file requires hotplug of the disk in the qemu driver */ switch (disk->bus) { case VIR_DOMAIN_DISK_BUS_USB: @@ -3077,7 +3086,7 @@ qemuValidateDomainDeviceDefDisk(const virDomainDiskDef *disk, if (qemuValidateDomainDeviceDefDiskBlkdeviotune(disk, def) < 0) return -1; - if (qemuValidateDomainDeviceDefDiskTransient(disk, qemuCaps) < 0) + if (qemuValidateDomainDeviceDefDiskTransient(disk, def, qemuCaps) < 0) return -1; if (disk->src->shared && !disk->src->readonly &&