File libvirt-qemu-Cancel-migration-if-guest-encoutners-I-O-error-while-migrating.patch of Package libvirt
From 3ab34c57eae0f1486c7b38c525257e15a9de8f0b Mon Sep 17 00:00:00 2001
Message-Id: <3ab34c57eae0f1486c7b38c525257e15a9de8f0b.1373885147.git.jdenemar@redhat.com>
From: Peter Krempa <pkrempa@redhat.com>
Date: Thu, 4 Jul 2013 11:50:21 +0200
Subject: [PATCH] qemu: Cancel migration if guest encoutners I/O error while
migrating
https://bugzilla.redhat.com/show_bug.cgi?id=972675
During a live migration the guest may receive a disk access I/O error.
In this state the guest is unable to continue running on a remote host
after migration as some state may be present in the kernel and not
migrated.
With this patch, the migration is canceled in such case so it can either
continue on the source if the I/O issues are recovered or has to be
destroyed anyways.
(cherry picked from commit caa467db626c8691d993e8e15d2cbb0bb043312c)
---
src/qemu/qemu_migration.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index e0a4743..d946c27 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -1041,6 +1041,7 @@ qemuMigrationWaitForCompletion(struct qemud_driver *driver, virDomainObjPtr vm,
{
qemuDomainObjPrivatePtr priv = vm->privateData;
const char *job;
+ int pauseReason;
switch (priv->job.asyncJob) {
case QEMU_ASYNC_JOB_MIGRATION_OUT:
@@ -1062,6 +1063,12 @@ qemuMigrationWaitForCompletion(struct qemud_driver *driver, virDomainObjPtr vm,
/* Poll every 50ms for progress & to allow cancellation */
struct timespec ts = { .tv_sec = 0, .tv_nsec = 50 * 1000 * 1000ull };
+ /* cancel migration if disk I/O error is emitted while migrating */
+ if (priv->job.asyncJob == QEMU_ASYNC_JOB_MIGRATION_OUT &&
+ virDomainObjGetState(vm, &pauseReason) == VIR_DOMAIN_PAUSED &&
+ pauseReason == VIR_DOMAIN_PAUSED_IOERROR)
+ goto cancel;
+
if (qemuMigrationUpdateJobStatus(driver, vm, job, asyncJob) < 0)
goto cleanup;
@@ -1085,6 +1092,20 @@ cleanup:
return 0;
else
return -1;
+
+cancel:
+ if (virDomainObjIsActive(vm)) {
+ if (qemuDomainObjEnterMonitorAsync(driver, vm,
+ priv->job.asyncJob) == 0) {
+ qemuMonitorMigrateCancel(priv->mon);
+ qemuDomainObjExitMonitor(driver, vm);
+ }
+ }
+
+ priv->job.info.type = VIR_DOMAIN_JOB_FAILED;
+ virReportError(VIR_ERR_OPERATION_FAILED,
+ _("%s: %s"), job, _("failed due to I/O error"));
+ return -1;
}
--
1.8.3.2