On 2013年01月24日 07:27, Eric Blake wrote:
https://bugzilla.redhat.com/show_bug.cgi?id=876829 complains that
if a guest is put into S3 state (such as via virsh dompmsuspend)
and then an external snapshot is taken, qemu forcefully transitions
the domain to paused, but libvirt doesn't reflect that change
internally. Thus, a user has to use 'virsh suspend' to get libvirt
back in sync with qemu state, and if the user doesn't know this
trick, then the guest appears hung.
* src/qemu/qemu_driver.c (qemuDomainSnapshotCreateActiveExternal):
Track fact that qemu wakes up a suspended domain on migration.
---
src/qemu/qemu_driver.c | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 6d4c1e9..da30dcb 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -1,7 +1,7 @@
/*
* qemu_driver.c: core driver methods for managing qemu guests
*
- * Copyright (C) 2006-2012 Red Hat, Inc.
+ * Copyright (C) 2006-2013 Red Hat, Inc.
* Copyright (C) 2006 Daniel P. Berrange
*
* This library is free software; you can redistribute it and/or
@@ -11124,6 +11124,7 @@ qemuDomainSnapshotCreateActiveExternal(virConnectPtr conn,
bool atomic = !!(flags& VIR_DOMAIN_SNAPSHOT_CREATE_ATOMIC);
bool transaction = qemuCapsGet(priv->caps, QEMU_CAPS_TRANSACTION);
int thaw = 0; /* 1 if freeze succeeded, -1 if freeze failed */
+ bool pmsuspended = false;
if (qemuDomainObjBeginAsyncJobWithDriver(driver, vm,
QEMU_ASYNC_JOB_SNAPSHOT)< 0)
@@ -11144,7 +11145,9 @@ qemuDomainSnapshotCreateActiveExternal(virConnectPtr conn,
}
/* we need to resume the guest only if it was previously running */
As you changed the codes, the comment needs to be changed too.
- if (virDomainObjGetState(vm, NULL) == VIR_DOMAIN_RUNNING) {
+ if (virDomainObjGetState(vm, NULL) == VIR_DOMAIN_PMSUSPENDED) {
+ pmsuspended = true;
+ } else if (virDomainObjGetState(vm, NULL) == VIR_DOMAIN_RUNNING) {
resume = true;
/* For external checkpoints (those with memory), the guest
@@ -11226,6 +11229,18 @@ qemuDomainSnapshotCreateActiveExternal(virConnectPtr conn,
vm = NULL;
if (event)
qemuDomainEventQueue(driver, event);
+ } else if (memory&& pmsuspended) {
+ /* qemu 1.3 is unable to save a domain in pm-suspended (S3)
+ * state; so we must emit an event stating that it was
+ * converted to paused. */
+ virDomainEventPtr event;
+
+ virDomainObjSetState(vm, VIR_DOMAIN_PAUSED,
+ VIR_DOMAIN_PAUSED_FROM_SNAPSHOT);
+ event = virDomainEventNewFromObj(vm, VIR_DOMAIN_EVENT_SUSPENDED,
+ VIR_DOMAIN_EVENT_SUSPENDED_FROM_SNAPSHOT);
+ if (event)
+ qemuDomainEventQueue(driver, event);
}
ret = 0;
ACK with the comment fixed.