|
|
3e5111 |
From 81bbd5e5673d2ed1b10b3a54876ed7945cd5f97c Mon Sep 17 00:00:00 2001
|
|
|
3e5111 |
Message-Id: <81bbd5e5673d2ed1b10b3a54876ed7945cd5f97c@dist-git>
|
|
|
3e5111 |
From: Jiri Denemark <jdenemar@redhat.com>
|
|
|
3e5111 |
Date: Tue, 6 Jun 2017 22:49:11 +0200
|
|
|
3e5111 |
Subject: [PATCH] qemu: Introduce virQEMUSaveDataFinish
|
|
|
3e5111 |
|
|
|
3e5111 |
The function is supposed to update the save image header after a
|
|
|
3e5111 |
successful migration to the save image file.
|
|
|
3e5111 |
|
|
|
3e5111 |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
3e5111 |
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
|
|
|
3e5111 |
(cherry picked from commit ec986bc5727b88b0631236ad0cdecb0a8568d5cd)
|
|
|
3e5111 |
|
|
|
3e5111 |
https://bugzilla.redhat.com/show_bug.cgi?id=1441662
|
|
|
3e5111 |
|
|
|
3e5111 |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
3e5111 |
---
|
|
|
3e5111 |
src/qemu/qemu_driver.c | 34 +++++++++++++++++++++-------------
|
|
|
3e5111 |
1 file changed, 21 insertions(+), 13 deletions(-)
|
|
|
3e5111 |
|
|
|
3e5111 |
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
|
|
|
3e5111 |
index 4a05793339..a0b607b419 100644
|
|
|
3e5111 |
--- a/src/qemu/qemu_driver.c
|
|
|
3e5111 |
+++ b/src/qemu/qemu_driver.c
|
|
|
3e5111 |
@@ -2882,6 +2882,25 @@ qemuDomainSaveHeader(int fd, const char *path, const char *xml,
|
|
|
3e5111 |
}
|
|
|
3e5111 |
|
|
|
3e5111 |
|
|
|
3e5111 |
+static int
|
|
|
3e5111 |
+virQEMUSaveDataFinish(virQEMUSaveHeaderPtr header,
|
|
|
3e5111 |
+ int *fd,
|
|
|
3e5111 |
+ const char *path)
|
|
|
3e5111 |
+{
|
|
|
3e5111 |
+ memcpy(header->magic, QEMU_SAVE_MAGIC, sizeof(header->magic));
|
|
|
3e5111 |
+
|
|
|
3e5111 |
+ if (safewrite(*fd, header, sizeof(*header)) != sizeof(*header) ||
|
|
|
3e5111 |
+ VIR_CLOSE(*fd) < 0) {
|
|
|
3e5111 |
+ virReportSystemError(errno,
|
|
|
3e5111 |
+ _("failed to write header to domain save file '%s'"),
|
|
|
3e5111 |
+ path);
|
|
|
3e5111 |
+ return -1;
|
|
|
3e5111 |
+ }
|
|
|
3e5111 |
+
|
|
|
3e5111 |
+ return 0;
|
|
|
3e5111 |
+}
|
|
|
3e5111 |
+
|
|
|
3e5111 |
+
|
|
|
3e5111 |
static virCommandPtr
|
|
|
3e5111 |
qemuCompressGetCommand(virQEMUSaveFormat compression)
|
|
|
3e5111 |
{
|
|
|
3e5111 |
@@ -3135,21 +3154,10 @@ qemuDomainSaveMemory(virQEMUDriverPtr driver,
|
|
|
3e5111 |
if (virFileWrapperFdClose(wrapperFd) < 0)
|
|
|
3e5111 |
goto cleanup;
|
|
|
3e5111 |
|
|
|
3e5111 |
- if ((fd = qemuOpenFile(driver, vm, path, O_WRONLY, NULL, NULL)) < 0)
|
|
|
3e5111 |
+ if ((fd = qemuOpenFile(driver, vm, path, O_WRONLY, NULL, NULL)) < 0 ||
|
|
|
3e5111 |
+ virQEMUSaveDataFinish(header, &fd, path) < 0)
|
|
|
3e5111 |
goto cleanup;
|
|
|
3e5111 |
|
|
|
3e5111 |
- memcpy(header->magic, QEMU_SAVE_MAGIC, sizeof(header->magic));
|
|
|
3e5111 |
-
|
|
|
3e5111 |
- if (safewrite(fd, &header, sizeof(header)) != sizeof(header)) {
|
|
|
3e5111 |
- virReportSystemError(errno, _("unable to write %s"), path);
|
|
|
3e5111 |
- goto cleanup;
|
|
|
3e5111 |
- }
|
|
|
3e5111 |
-
|
|
|
3e5111 |
- if (VIR_CLOSE(fd) < 0) {
|
|
|
3e5111 |
- virReportSystemError(errno, _("unable to close %s"), path);
|
|
|
3e5111 |
- goto cleanup;
|
|
|
3e5111 |
- }
|
|
|
3e5111 |
-
|
|
|
3e5111 |
ret = 0;
|
|
|
3e5111 |
|
|
|
3e5111 |
cleanup:
|
|
|
3e5111 |
--
|
|
|
3e5111 |
2.13.1
|
|
|
3e5111 |
|