When stopping a domain on the destination host after a failed migration,
we need to avoid reseting security labels since the domain is still
running on the source host. While we were correctly doing so in some
cases, there were still some paths which did this wrong.
https://bugzilla.redhat.com/show_bug.cgi?id=1242904
Signed-off-by: Jiri Denemark <jdenemar(a)redhat.com>
---
src/qemu/qemu_driver.c | 5 ++++-
src/qemu/qemu_migration.c | 3 ++-
src/qemu/qemu_process.c | 14 ++++++++++----
3 files changed, 16 insertions(+), 6 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 5b22639..b9278f8 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -2187,6 +2187,7 @@ qemuDomainDestroyFlags(virDomainPtr dom,
int ret = -1;
virObjectEventPtr event = NULL;
qemuDomainObjPrivatePtr priv;
+ unsigned int stopFlags = 0;
virCheckFlags(VIR_DOMAIN_DESTROY_GRACEFUL, -1);
@@ -2200,6 +2201,8 @@ qemuDomainDestroyFlags(virDomainPtr dom,
qemuDomainSetFakeReboot(driver, vm, false);
+ if (priv->job.asyncJob == QEMU_ASYNC_JOB_MIGRATION_IN)
+ stopFlags |= VIR_QEMU_PROCESS_STOP_MIGRATED;
/* We need to prevent monitor EOF callback from doing our work (and sending
* misleading events) while the vm is unlocked inside BeginJob/ProcessKill API
@@ -2234,7 +2237,7 @@ qemuDomainDestroyFlags(virDomainPtr dom,
goto endjob;
}
- qemuProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_DESTROYED, 0);
+ qemuProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_DESTROYED, stopFlags);
event = virDomainEventLifecycleNewFromObj(vm,
VIR_DOMAIN_EVENT_STOPPED,
VIR_DOMAIN_EVENT_STOPPED_DESTROYED);
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index f5866c4..364c489 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -3463,7 +3463,8 @@ qemuMigrationPrepareAny(virQEMUDriverPtr driver,
stop:
virDomainAuditStart(vm, "migrated", false);
- qemuProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_FAILED, 0);
+ qemuProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_FAILED,
+ VIR_QEMU_PROCESS_STOP_MIGRATED);
endjob:
qemuMigrationJobFinish(driver, vm);
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 23baa82..978dc21 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -285,6 +285,7 @@ qemuProcessHandleMonitorEOF(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
int eventReason = VIR_DOMAIN_EVENT_STOPPED_SHUTDOWN;
int stopReason = VIR_DOMAIN_SHUTOFF_SHUTDOWN;
const char *auditReason = "shutdown";
+ unsigned int stopFlags = 0;
VIR_DEBUG("Received EOF on %p '%s'", vm, vm->def->name);
@@ -310,14 +311,16 @@ qemuProcessHandleMonitorEOF(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
auditReason = "failed";
}
- if (priv->job.asyncJob == QEMU_ASYNC_JOB_MIGRATION_IN)
+ if (priv->job.asyncJob == QEMU_ASYNC_JOB_MIGRATION_IN) {
+ stopFlags |= VIR_QEMU_PROCESS_STOP_MIGRATED;
qemuMigrationErrorSave(driver, vm->def->name,
qemuMonitorLastError(priv->mon));
+ }
event = virDomainEventLifecycleNewFromObj(vm,
VIR_DOMAIN_EVENT_STOPPED,
eventReason);
- qemuProcessStop(driver, vm, stopReason, 0);
+ qemuProcessStop(driver, vm, stopReason, stopFlags);
virDomainAuditStop(vm, auditReason);
if (!vm->persistent) {
@@ -5693,9 +5696,13 @@ qemuProcessAutoDestroy(virDomainObjPtr dom,
virQEMUDriverPtr driver = opaque;
qemuDomainObjPrivatePtr priv = dom->privateData;
virObjectEventPtr event = NULL;
+ unsigned int stopFlags = 0;
VIR_DEBUG("vm=%s, conn=%p", dom->def->name, conn);
+ if (priv->job.asyncJob == QEMU_ASYNC_JOB_MIGRATION_IN)
+ stopFlags |= VIR_QEMU_PROCESS_STOP_MIGRATED;
+
if (priv->job.asyncJob) {
VIR_DEBUG("vm=%s has long-term job active, cancelling",
dom->def->name);
@@ -5708,8 +5715,7 @@ qemuProcessAutoDestroy(virDomainObjPtr dom,
VIR_DEBUG("Killing domain");
- qemuProcessStop(driver, dom, VIR_DOMAIN_SHUTOFF_DESTROYED,
- VIR_QEMU_PROCESS_STOP_MIGRATED);
+ qemuProcessStop(driver, dom, VIR_DOMAIN_SHUTOFF_DESTROYED, stopFlags);
virDomainAuditStop(dom, "destroyed");
event = virDomainEventLifecycleNewFromObj(dom,
--
2.5.0