]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: domain: Reject copy_on_read for read-only disks
authorPeter Krempa <pkrempa@redhat.com>
Tue, 10 Jul 2018 08:18:53 +0000 (10:18 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 10 Jul 2018 11:32:53 +0000 (13:32 +0200)
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 <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/qemu/qemu_domain.c

index e29d01c828c1616aaf0b4102ac085b36a85cd1f3..0821ce769b8e1c7f3ca213e800a677922567b4d0 100644 (file)
@@ -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) {