The close callbacks hash are keyed by a UUID-string, but
virCloseCallbacksRun was attempting to remove them by raw UUID. This
patch ensures the callback entries are removed by UUID-string as well.
This bug could cause problems when guest migrations were abnormally aborted:
# timeout --signal KILL 1 \
virsh migrate example qemu+tls://remote/system \
--verbose --compressed --live --auto-converge \
--abort-on-error --unsafe --persistent \
--undefinesource --copy-storage-all --xml example.xml
Killed
# virsh migrate example qemu+tls://remote/system \
--verbose --compressed --live --auto-converge \
--abort-on-error --unsafe --persistent \
--undefinesource --copy-storage-all --xml example.xml
error: Requested operation is not valid: domain 'example' is not being migrated
Signed-off-by: Michael Chapman <mike(a)very.puzzling.org>
---
src/util/virclosecallbacks.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/src/util/virclosecallbacks.c b/src/util/virclosecallbacks.c
index 4128057..b0a1a9e 100644
--- a/src/util/virclosecallbacks.c
+++ b/src/util/virclosecallbacks.c
@@ -236,6 +236,7 @@ typedef struct _virCloseCallbacksListEntry
virCloseCallbacksListEntry;
typedef virCloseCallbacksListEntry *virCloseCallbacksListEntryPtr;
struct _virCloseCallbacksListEntry {
unsigned char uuid[VIR_UUID_BUFLEN];
+ char uuidstr[VIR_UUID_STRING_BUFLEN];
virCloseCallback callback;
};
@@ -279,6 +280,8 @@ virCloseCallbacksGetOne(void *payload,
memcpy(data->list->entries[data->list->nentries - 1].uuid,
uuid, VIR_UUID_BUFLEN);
+ memcpy(data->list->entries[data->list->nentries - 1].uuidstr,
+ uuidstr, VIR_UUID_STRING_BUFLEN);
data->list->entries[data->list->nentries - 1].callback =
closeDef->cb;
}
@@ -332,7 +335,7 @@ virCloseCallbacksRun(virCloseCallbacksPtr closeCallbacks,
for (i = 0; i < list->nentries; i++) {
virHashRemoveEntry(closeCallbacks->list,
- list->entries[i].uuid);
+ list->entries[i].uuidstr);
}
virObjectUnlock(closeCallbacks);
@@ -341,9 +344,8 @@ virCloseCallbacksRun(virCloseCallbacksPtr closeCallbacks,
if (!(vm = virDomainObjListFindByUUID(domains,
list->entries[i].uuid))) {
- char uuidstr[VIR_UUID_STRING_BUFLEN];
- virUUIDFormat(list->entries[i].uuid, uuidstr);
- VIR_DEBUG("No domain object with UUID %s", uuidstr);
+ VIR_DEBUG("No domain object with UUID %s",
+ list->entries[i].uuidstr);
continue;
}
--
2.1.0