-----Original Message-----
From: libvir-list-bounces(a)redhat.com [mailto:libvir-list-
bounces(a)redhat.com] On Behalf Of Corey S. McQuay
Sent: Friday, August 5, 2016 8:34 PM
To: jjherne(a)linux.vnet.ibm.com; libvir-list(a)redhat.com
Cc: Corey S. McQuay <csmcquay(a)linux.vnet.ibm.com>
Subject: [libvirt] [PATCH v1] qemu-migration: Disallow migration of read only
disk
From: "Corey S. McQuay" <csmcquay(a)linux.vnet.ibm.com>
Currently Libvirt allows attempts to migrate read only disks. Qemu cannot
handle this as read only disks cannot be written to on the destination system.
The end result is a cryptic error message and a failed migration.
This patch causes migration to fail earlier and provides a meaningful error
message stating that migrating read only disks is not supported.
What will happen if read-only disk is copied to destination prior to migration start?
Currently such scenario works, will it still work with this code?
Signed-off-by: Corey S. McQuay <csmcquay(a)linux.vnet.ibm.com>
Reviewed-by: Jason J. Herne <jjherne(a)linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy(a)linux.vnet.ibm.com>
---
src/qemu/qemu_migration.c | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index d018add..7d0a78f 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -2387,6 +2387,28 @@ qemuMigrationIsSafe(virDomainDefPtr def,
return true;
}
+static bool
+qemuMigrationAreAllDisksRW(virDomainDefPtr def,
+ size_t nmigrate_disks,
+ const char **migrate_disks) {
+ size_t i;
+
+ for (i = 0; i < def->ndisks; i++) {
+ virDomainDiskDefPtr disk = def->disks[i];
+
+ if (qemuMigrateDisk(disk, nmigrate_disks, migrate_disks) &&
+ disk->src->readonly) {
+ virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
+ _("Cannot migrate read-only disk %s"),
+ disk->dst);
+ return false;
+ }
+ }
+
+ return true;
+}
+
/** qemuMigrationSetOffline
* Pause domain for non-live migration.
*/
@@ -3132,6 +3154,9 @@ qemuMigrationBeginPhase(virQEMUDriverPtr
driver,
!qemuMigrationIsSafe(vm->def, nmigrate_disks, migrate_disks))
goto cleanup;
+ if (!qemuMigrationAreAllDisksRW(vm->def, nmigrate_disks,
migrate_disks))
+ goto cleanup;
+
if (flags & VIR_MIGRATE_POSTCOPY &&
(!(flags & VIR_MIGRATE_LIVE) ||
flags & VIR_MIGRATE_PAUSED)) {
--
1.8.3.1
--
libvir-list mailing list
libvir-list(a)redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list