From d7eeafaa4c15cf17c525b69d9667f1ee55c9181b Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Tue, 10 Jul 2018 10:18:53 +0200 Subject: [PATCH] qemu: domain: Reject copy_on_read for read-only disks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The sectors read from the backing image need to be written to the top level image. If a disk is marked read-only the image can't be written. QEMU handled that by disabling copy_on_read and reporting a warning: -drive file=/var/lib/libvirt/images/c,format=qcow2,if=none, id=drive-scsi0-0-1,readonly=on,copy-on-read=on: warning: disabling copy-on-read on read-only drive Signed-off-by: Peter Krempa Reviewed-by: Ján Tomko --- src/qemu/qemu_domain.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index e29d01c828..0821ce769b 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -4650,6 +4650,13 @@ qemuDomainDeviceDefValidateDisk(const virDomainDiskDef *disk, return -1; } + if (disk->src->readonly && disk->copy_on_read == VIR_TRISTATE_SWITCH_ON) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("copy_on_read is not compatible with read-only disk '%s'"), + disk->dst); + return -1; + } + if (disk->geometry.cylinders > 0 && disk->geometry.heads > 0 && disk->geometry.sectors > 0) {