|
|
3e5111 |
From 56a60bd1b230c86195778e4fda2f44052faae10c Mon Sep 17 00:00:00 2001
|
|
|
3e5111 |
Message-Id: <56a60bd1b230c86195778e4fda2f44052faae10c@dist-git>
|
|
|
3e5111 |
From: Jiri Denemark <jdenemar@redhat.com>
|
|
|
3e5111 |
Date: Wed, 7 Jun 2017 00:08:25 +0200
|
|
|
3e5111 |
Subject: [PATCH] qemu: Introduce virQEMUSaveData structure
|
|
|
3e5111 |
|
|
|
3e5111 |
The new structure encapsulates save image header and associated data
|
|
|
3e5111 |
(domain XML).
|
|
|
3e5111 |
|
|
|
3e5111 |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
3e5111 |
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
|
|
|
3e5111 |
(cherry picked from commit 47e60ac306273559b8c14527ea15a92c6ac6dd91)
|
|
|
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 | 165 ++++++++++++++++++++++++++-----------------------
|
|
|
3e5111 |
1 file changed, 86 insertions(+), 79 deletions(-)
|
|
|
3e5111 |
|
|
|
3e5111 |
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
|
|
|
3e5111 |
index 1629f27470..7ce0f01f70 100644
|
|
|
3e5111 |
--- a/src/qemu/qemu_driver.c
|
|
|
3e5111 |
+++ b/src/qemu/qemu_driver.c
|
|
|
3e5111 |
@@ -2816,6 +2816,14 @@ struct _virQEMUSaveHeader {
|
|
|
3e5111 |
uint32_t unused[15];
|
|
|
3e5111 |
};
|
|
|
3e5111 |
|
|
|
3e5111 |
+typedef struct _virQEMUSaveData virQEMUSaveData;
|
|
|
3e5111 |
+typedef virQEMUSaveData *virQEMUSaveDataPtr;
|
|
|
3e5111 |
+struct _virQEMUSaveData {
|
|
|
3e5111 |
+ virQEMUSaveHeader header;
|
|
|
3e5111 |
+ char *xml;
|
|
|
3e5111 |
+};
|
|
|
3e5111 |
+
|
|
|
3e5111 |
+
|
|
|
3e5111 |
static inline void
|
|
|
3e5111 |
bswap_header(virQEMUSaveHeaderPtr hdr)
|
|
|
3e5111 |
{
|
|
|
3e5111 |
@@ -2827,31 +2835,39 @@ bswap_header(virQEMUSaveHeaderPtr hdr)
|
|
|
3e5111 |
|
|
|
3e5111 |
|
|
|
3e5111 |
static void
|
|
|
3e5111 |
-virQEMUSaveDataFree(virQEMUSaveHeaderPtr header)
|
|
|
3e5111 |
+virQEMUSaveDataFree(virQEMUSaveDataPtr data)
|
|
|
3e5111 |
{
|
|
|
3e5111 |
- if (!header)
|
|
|
3e5111 |
+ if (!data)
|
|
|
3e5111 |
return;
|
|
|
3e5111 |
|
|
|
3e5111 |
- VIR_FREE(header);
|
|
|
3e5111 |
+ VIR_FREE(data->xml);
|
|
|
3e5111 |
+ VIR_FREE(data);
|
|
|
3e5111 |
}
|
|
|
3e5111 |
|
|
|
3e5111 |
|
|
|
3e5111 |
-static virQEMUSaveHeaderPtr
|
|
|
3e5111 |
-virQEMUSaveDataNew(char *domXML ATTRIBUTE_UNUSED,
|
|
|
3e5111 |
+/**
|
|
|
3e5111 |
+ * This function steals @domXML on success.
|
|
|
3e5111 |
+ */
|
|
|
3e5111 |
+static virQEMUSaveDataPtr
|
|
|
3e5111 |
+virQEMUSaveDataNew(char *domXML,
|
|
|
3e5111 |
bool running,
|
|
|
3e5111 |
int compressed)
|
|
|
3e5111 |
{
|
|
|
3e5111 |
- virQEMUSaveHeaderPtr header = NULL;
|
|
|
3e5111 |
+ virQEMUSaveDataPtr data = NULL;
|
|
|
3e5111 |
+ virQEMUSaveHeaderPtr header;
|
|
|
3e5111 |
|
|
|
3e5111 |
- if (VIR_ALLOC(header) < 0)
|
|
|
3e5111 |
+ if (VIR_ALLOC(data) < 0)
|
|
|
3e5111 |
return NULL;
|
|
|
3e5111 |
|
|
|
3e5111 |
+ VIR_STEAL_PTR(data->xml, domXML);
|
|
|
3e5111 |
+
|
|
|
3e5111 |
+ header = &data->header;
|
|
|
3e5111 |
memcpy(header->magic, QEMU_SAVE_PARTIAL, sizeof(header->magic));
|
|
|
3e5111 |
header->version = QEMU_SAVE_VERSION;
|
|
|
3e5111 |
header->was_running = running ? 1 : 0;
|
|
|
3e5111 |
header->compressed = compressed;
|
|
|
3e5111 |
|
|
|
3e5111 |
- return header;
|
|
|
3e5111 |
+ return data;
|
|
|
3e5111 |
}
|
|
|
3e5111 |
|
|
|
3e5111 |
|
|
|
3e5111 |
@@ -2865,17 +2881,17 @@ virQEMUSaveDataNew(char *domXML ATTRIBUTE_UNUSED,
|
|
|
3e5111 |
* Returns -1 on failure, or 0 on success.
|
|
|
3e5111 |
*/
|
|
|
3e5111 |
static int
|
|
|
3e5111 |
-virQEMUSaveDataWrite(virQEMUSaveHeaderPtr header,
|
|
|
3e5111 |
- const char *xml,
|
|
|
3e5111 |
+virQEMUSaveDataWrite(virQEMUSaveDataPtr data,
|
|
|
3e5111 |
int fd,
|
|
|
3e5111 |
const char *path)
|
|
|
3e5111 |
{
|
|
|
3e5111 |
+ virQEMUSaveHeaderPtr header = &data->header;
|
|
|
3e5111 |
size_t len;
|
|
|
3e5111 |
int ret = -1;
|
|
|
3e5111 |
size_t zerosLen = 0;
|
|
|
3e5111 |
char *zeros = NULL;
|
|
|
3e5111 |
|
|
|
3e5111 |
- len = strlen(xml) + 1;
|
|
|
3e5111 |
+ len = strlen(data->xml) + 1;
|
|
|
3e5111 |
|
|
|
3e5111 |
if (header->data_len > 0) {
|
|
|
3e5111 |
if (len > header->data_len) {
|
|
|
3e5111 |
@@ -2898,7 +2914,7 @@ virQEMUSaveDataWrite(virQEMUSaveHeaderPtr header,
|
|
|
3e5111 |
goto cleanup;
|
|
|
3e5111 |
}
|
|
|
3e5111 |
|
|
|
3e5111 |
- if (safewrite(fd, xml, header->data_len) != header->data_len ||
|
|
|
3e5111 |
+ if (safewrite(fd, data->xml, header->data_len) != header->data_len ||
|
|
|
3e5111 |
safewrite(fd, zeros, zerosLen) != zerosLen) {
|
|
|
3e5111 |
virReportSystemError(errno,
|
|
|
3e5111 |
_("failed to write domain xml to '%s'"),
|
|
|
3e5111 |
@@ -2915,10 +2931,12 @@ virQEMUSaveDataWrite(virQEMUSaveHeaderPtr header,
|
|
|
3e5111 |
|
|
|
3e5111 |
|
|
|
3e5111 |
static int
|
|
|
3e5111 |
-virQEMUSaveDataFinish(virQEMUSaveHeaderPtr header,
|
|
|
3e5111 |
+virQEMUSaveDataFinish(virQEMUSaveDataPtr data,
|
|
|
3e5111 |
int *fd,
|
|
|
3e5111 |
const char *path)
|
|
|
3e5111 |
{
|
|
|
3e5111 |
+ virQEMUSaveHeaderPtr header = &data->header;
|
|
|
3e5111 |
+
|
|
|
3e5111 |
memcpy(header->magic, QEMU_SAVE_MAGIC, sizeof(header->magic));
|
|
|
3e5111 |
|
|
|
3e5111 |
if (safewrite(*fd, header, sizeof(*header)) != sizeof(*header) ||
|
|
|
3e5111 |
@@ -3128,8 +3146,7 @@ static int
|
|
|
3e5111 |
qemuDomainSaveMemory(virQEMUDriverPtr driver,
|
|
|
3e5111 |
virDomainObjPtr vm,
|
|
|
3e5111 |
const char *path,
|
|
|
3e5111 |
- const char *domXML,
|
|
|
3e5111 |
- virQEMUSaveHeaderPtr header,
|
|
|
3e5111 |
+ virQEMUSaveDataPtr data,
|
|
|
3e5111 |
const char *compressedpath,
|
|
|
3e5111 |
unsigned int flags,
|
|
|
3e5111 |
qemuDomainAsyncJob asyncJob)
|
|
|
3e5111 |
@@ -3164,7 +3181,7 @@ qemuDomainSaveMemory(virQEMUDriverPtr driver,
|
|
|
3e5111 |
if (!(wrapperFd = virFileWrapperFdNew(&fd, path, wrapperFlags)))
|
|
|
3e5111 |
goto cleanup;
|
|
|
3e5111 |
|
|
|
3e5111 |
- if (virQEMUSaveDataWrite(header, domXML, fd, path) < 0)
|
|
|
3e5111 |
+ if (virQEMUSaveDataWrite(data, fd, path) < 0)
|
|
|
3e5111 |
goto cleanup;
|
|
|
3e5111 |
|
|
|
3e5111 |
/* Perform the migration */
|
|
|
3e5111 |
@@ -3186,7 +3203,7 @@ qemuDomainSaveMemory(virQEMUDriverPtr driver,
|
|
|
3e5111 |
goto cleanup;
|
|
|
3e5111 |
|
|
|
3e5111 |
if ((fd = qemuOpenFile(driver, vm, path, O_WRONLY, NULL, NULL)) < 0 ||
|
|
|
3e5111 |
- virQEMUSaveDataFinish(header, &fd, path) < 0)
|
|
|
3e5111 |
+ virQEMUSaveDataFinish(data, &fd, path) < 0)
|
|
|
3e5111 |
goto cleanup;
|
|
|
3e5111 |
|
|
|
3e5111 |
ret = 0;
|
|
|
3e5111 |
@@ -3218,7 +3235,7 @@ qemuDomainSaveInternal(virQEMUDriverPtr driver, virDomainPtr dom,
|
|
|
3e5111 |
virObjectEventPtr event = NULL;
|
|
|
3e5111 |
qemuDomainObjPrivatePtr priv = vm->privateData;
|
|
|
3e5111 |
virCapsPtr caps;
|
|
|
3e5111 |
- virQEMUSaveHeaderPtr header = NULL;
|
|
|
3e5111 |
+ virQEMUSaveDataPtr data = NULL;
|
|
|
3e5111 |
|
|
|
3e5111 |
if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
|
|
|
3e5111 |
goto cleanup;
|
|
|
3e5111 |
@@ -3284,10 +3301,11 @@ qemuDomainSaveInternal(virQEMUDriverPtr driver, virDomainPtr dom,
|
|
|
3e5111 |
goto endjob;
|
|
|
3e5111 |
}
|
|
|
3e5111 |
|
|
|
3e5111 |
- if (!(header = virQEMUSaveDataNew(xml, was_running, compressed)))
|
|
|
3e5111 |
+ if (!(data = virQEMUSaveDataNew(xml, was_running, compressed)))
|
|
|
3e5111 |
goto endjob;
|
|
|
3e5111 |
+ xml = NULL;
|
|
|
3e5111 |
|
|
|
3e5111 |
- ret = qemuDomainSaveMemory(driver, vm, path, xml, header, compressedpath,
|
|
|
3e5111 |
+ ret = qemuDomainSaveMemory(driver, vm, path, data, compressedpath,
|
|
|
3e5111 |
flags, QEMU_ASYNC_JOB_SAVE);
|
|
|
3e5111 |
if (ret < 0)
|
|
|
3e5111 |
goto endjob;
|
|
|
3e5111 |
@@ -3321,7 +3339,7 @@ qemuDomainSaveInternal(virQEMUDriverPtr driver, virDomainPtr dom,
|
|
|
3e5111 |
|
|
|
3e5111 |
cleanup:
|
|
|
3e5111 |
VIR_FREE(xml);
|
|
|
3e5111 |
- virQEMUSaveDataFree(header);
|
|
|
3e5111 |
+ virQEMUSaveDataFree(data);
|
|
|
3e5111 |
qemuDomainEventQueue(driver, event);
|
|
|
3e5111 |
virObjectUnref(caps);
|
|
|
3e5111 |
return ret;
|
|
|
3e5111 |
@@ -6238,8 +6256,7 @@ qemuDomainSaveImageUpdateDef(virQEMUDriverPtr driver,
|
|
|
3e5111 |
* @driver: qemu driver data
|
|
|
3e5111 |
* @path: path of the save image
|
|
|
3e5111 |
* @ret_def: returns domain definition created from the XML stored in the image
|
|
|
3e5111 |
- * @ret_header: returns structure filled with data from the image header
|
|
|
3e5111 |
- * @xmlout: returns the XML from the image file (may be NULL)
|
|
|
3e5111 |
+ * @ret_data: returns structure filled with data from the image header
|
|
|
3e5111 |
* @bypass_cache: bypass cache when opening the file
|
|
|
3e5111 |
* @wrapperFd: returns the file wrapper structure
|
|
|
3e5111 |
* @open_write: open the file for writing (for updates)
|
|
|
3e5111 |
@@ -6253,16 +6270,15 @@ static int ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4)
|
|
|
3e5111 |
qemuDomainSaveImageOpen(virQEMUDriverPtr driver,
|
|
|
3e5111 |
const char *path,
|
|
|
3e5111 |
virDomainDefPtr *ret_def,
|
|
|
3e5111 |
- virQEMUSaveHeaderPtr *ret_header,
|
|
|
3e5111 |
- char **xmlout,
|
|
|
3e5111 |
+ virQEMUSaveDataPtr *ret_data,
|
|
|
3e5111 |
bool bypass_cache,
|
|
|
3e5111 |
virFileWrapperFdPtr *wrapperFd,
|
|
|
3e5111 |
bool open_write,
|
|
|
3e5111 |
bool unlink_corrupt)
|
|
|
3e5111 |
{
|
|
|
3e5111 |
int fd = -1;
|
|
|
3e5111 |
- char *xml = NULL;
|
|
|
3e5111 |
- virQEMUSaveHeaderPtr header = NULL;
|
|
|
3e5111 |
+ virQEMUSaveDataPtr data = NULL;
|
|
|
3e5111 |
+ virQEMUSaveHeaderPtr header;
|
|
|
3e5111 |
virDomainDefPtr def = NULL;
|
|
|
3e5111 |
int oflags = open_write ? O_RDWR : O_RDONLY;
|
|
|
3e5111 |
virCapsPtr caps = NULL;
|
|
|
3e5111 |
@@ -6287,9 +6303,10 @@ qemuDomainSaveImageOpen(virQEMUDriverPtr driver,
|
|
|
3e5111 |
VIR_FILE_WRAPPER_BYPASS_CACHE)))
|
|
|
3e5111 |
goto error;
|
|
|
3e5111 |
|
|
|
3e5111 |
- if (VIR_ALLOC(header) < 0)
|
|
|
3e5111 |
+ if (VIR_ALLOC(data) < 0)
|
|
|
3e5111 |
goto error;
|
|
|
3e5111 |
|
|
|
3e5111 |
+ header = &data->header;
|
|
|
3e5111 |
if (saferead(fd, header, sizeof(*header)) != sizeof(*header)) {
|
|
|
3e5111 |
if (unlink_corrupt) {
|
|
|
3e5111 |
if (VIR_CLOSE(fd) < 0 || unlink(path) < 0) {
|
|
|
3e5111 |
@@ -6341,32 +6358,27 @@ qemuDomainSaveImageOpen(virQEMUDriverPtr driver,
|
|
|
3e5111 |
|
|
|
3e5111 |
if (header->data_len <= 0) {
|
|
|
3e5111 |
virReportError(VIR_ERR_OPERATION_FAILED,
|
|
|
3e5111 |
- _("invalid XML length: %d"), header->data_len);
|
|
|
3e5111 |
+ _("invalid header data length: %d"), header->data_len);
|
|
|
3e5111 |
goto error;
|
|
|
3e5111 |
}
|
|
|
3e5111 |
|
|
|
3e5111 |
- if (VIR_ALLOC_N(xml, header->data_len) < 0)
|
|
|
3e5111 |
+ if (VIR_ALLOC_N(data->xml, header->data_len) < 0)
|
|
|
3e5111 |
goto error;
|
|
|
3e5111 |
|
|
|
3e5111 |
- if (saferead(fd, xml, header->data_len) != header->data_len) {
|
|
|
3e5111 |
+ if (saferead(fd, data->xml, header->data_len) != header->data_len) {
|
|
|
3e5111 |
virReportError(VIR_ERR_OPERATION_FAILED,
|
|
|
3e5111 |
- "%s", _("failed to read XML"));
|
|
|
3e5111 |
+ "%s", _("failed to read domain XML"));
|
|
|
3e5111 |
goto error;
|
|
|
3e5111 |
}
|
|
|
3e5111 |
|
|
|
3e5111 |
/* Create a domain from this XML */
|
|
|
3e5111 |
- if (!(def = virDomainDefParseString(xml, caps, driver->xmlopt, NULL,
|
|
|
3e5111 |
+ if (!(def = virDomainDefParseString(data->xml, caps, driver->xmlopt, NULL,
|
|
|
3e5111 |
VIR_DOMAIN_DEF_PARSE_INACTIVE |
|
|
|
3e5111 |
VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE)))
|
|
|
3e5111 |
goto error;
|
|
|
3e5111 |
|
|
|
3e5111 |
- if (xmlout)
|
|
|
3e5111 |
- *xmlout = xml;
|
|
|
3e5111 |
- else
|
|
|
3e5111 |
- VIR_FREE(xml);
|
|
|
3e5111 |
-
|
|
|
3e5111 |
*ret_def = def;
|
|
|
3e5111 |
- *ret_header = header;
|
|
|
3e5111 |
+ *ret_data = data;
|
|
|
3e5111 |
|
|
|
3e5111 |
virObjectUnref(caps);
|
|
|
3e5111 |
|
|
|
3e5111 |
@@ -6374,8 +6386,7 @@ qemuDomainSaveImageOpen(virQEMUDriverPtr driver,
|
|
|
3e5111 |
|
|
|
3e5111 |
error:
|
|
|
3e5111 |
virDomainDefFree(def);
|
|
|
3e5111 |
- VIR_FREE(xml);
|
|
|
3e5111 |
- virQEMUSaveDataFree(header);
|
|
|
3e5111 |
+ virQEMUSaveDataFree(data);
|
|
|
3e5111 |
VIR_FORCE_CLOSE(fd);
|
|
|
3e5111 |
virObjectUnref(caps);
|
|
|
3e5111 |
|
|
|
3e5111 |
@@ -6387,7 +6398,7 @@ qemuDomainSaveImageStartVM(virConnectPtr conn,
|
|
|
3e5111 |
virQEMUDriverPtr driver,
|
|
|
3e5111 |
virDomainObjPtr vm,
|
|
|
3e5111 |
int *fd,
|
|
|
3e5111 |
- virQEMUSaveHeaderPtr header,
|
|
|
3e5111 |
+ virQEMUSaveDataPtr data,
|
|
|
3e5111 |
const char *path,
|
|
|
3e5111 |
bool start_paused,
|
|
|
3e5111 |
qemuDomainAsyncJob asyncJob)
|
|
|
3e5111 |
@@ -6399,6 +6410,7 @@ qemuDomainSaveImageStartVM(virConnectPtr conn,
|
|
|
3e5111 |
virCommandPtr cmd = NULL;
|
|
|
3e5111 |
char *errbuf = NULL;
|
|
|
3e5111 |
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
|
|
|
3e5111 |
+ virQEMUSaveHeaderPtr header = &data->header;
|
|
|
3e5111 |
|
|
|
3e5111 |
if ((header->version == 2) &&
|
|
|
3e5111 |
(header->compressed != QEMU_SAVE_FORMAT_RAW)) {
|
|
|
3e5111 |
@@ -6508,12 +6520,11 @@ qemuDomainRestoreFlags(virConnectPtr conn,
|
|
|
3e5111 |
qemuDomainObjPrivatePtr priv = NULL;
|
|
|
3e5111 |
virDomainDefPtr def = NULL;
|
|
|
3e5111 |
virDomainObjPtr vm = NULL;
|
|
|
3e5111 |
- char *xml = NULL;
|
|
|
3e5111 |
char *xmlout = NULL;
|
|
|
3e5111 |
const char *newxml = dxml;
|
|
|
3e5111 |
int fd = -1;
|
|
|
3e5111 |
int ret = -1;
|
|
|
3e5111 |
- virQEMUSaveHeaderPtr header = NULL;
|
|
|
3e5111 |
+ virQEMUSaveDataPtr data = NULL;
|
|
|
3e5111 |
virFileWrapperFdPtr wrapperFd = NULL;
|
|
|
3e5111 |
bool hook_taint = false;
|
|
|
3e5111 |
|
|
|
3e5111 |
@@ -6524,7 +6535,7 @@ qemuDomainRestoreFlags(virConnectPtr conn,
|
|
|
3e5111 |
|
|
|
3e5111 |
virNWFilterReadLockFilterUpdates();
|
|
|
3e5111 |
|
|
|
3e5111 |
- fd = qemuDomainSaveImageOpen(driver, path, &def, &header, &xml,
|
|
|
3e5111 |
+ fd = qemuDomainSaveImageOpen(driver, path, &def, &data,
|
|
|
3e5111 |
(flags & VIR_DOMAIN_SAVE_BYPASS_CACHE) != 0,
|
|
|
3e5111 |
&wrapperFd, false, false);
|
|
|
3e5111 |
if (fd < 0)
|
|
|
3e5111 |
@@ -6540,7 +6551,7 @@ qemuDomainRestoreFlags(virConnectPtr conn,
|
|
|
3e5111 |
VIR_HOOK_QEMU_OP_RESTORE,
|
|
|
3e5111 |
VIR_HOOK_SUBOP_BEGIN,
|
|
|
3e5111 |
NULL,
|
|
|
3e5111 |
- dxml ? dxml : xml,
|
|
|
3e5111 |
+ dxml ? dxml : data->xml,
|
|
|
3e5111 |
&xmlout)) < 0)
|
|
|
3e5111 |
goto cleanup;
|
|
|
3e5111 |
|
|
|
3e5111 |
@@ -6570,9 +6581,9 @@ qemuDomainRestoreFlags(virConnectPtr conn,
|
|
|
3e5111 |
def = NULL;
|
|
|
3e5111 |
|
|
|
3e5111 |
if (flags & VIR_DOMAIN_SAVE_RUNNING)
|
|
|
3e5111 |
- header->was_running = 1;
|
|
|
3e5111 |
+ data->header.was_running = 1;
|
|
|
3e5111 |
else if (flags & VIR_DOMAIN_SAVE_PAUSED)
|
|
|
3e5111 |
- header->was_running = 0;
|
|
|
3e5111 |
+ data->header.was_running = 0;
|
|
|
3e5111 |
|
|
|
3e5111 |
if (hook_taint) {
|
|
|
3e5111 |
priv = vm->privateData;
|
|
|
3e5111 |
@@ -6582,7 +6593,7 @@ qemuDomainRestoreFlags(virConnectPtr conn,
|
|
|
3e5111 |
if (qemuProcessBeginJob(driver, vm, VIR_DOMAIN_JOB_OPERATION_RESTORE) < 0)
|
|
|
3e5111 |
goto cleanup;
|
|
|
3e5111 |
|
|
|
3e5111 |
- ret = qemuDomainSaveImageStartVM(conn, driver, vm, &fd, header, path,
|
|
|
3e5111 |
+ ret = qemuDomainSaveImageStartVM(conn, driver, vm, &fd, data, path,
|
|
|
3e5111 |
false, QEMU_ASYNC_JOB_START);
|
|
|
3e5111 |
if (virFileWrapperFdClose(wrapperFd) < 0)
|
|
|
3e5111 |
VIR_WARN("Failed to close %s", path);
|
|
|
3e5111 |
@@ -6592,8 +6603,7 @@ qemuDomainRestoreFlags(virConnectPtr conn,
|
|
|
3e5111 |
cleanup:
|
|
|
3e5111 |
virDomainDefFree(def);
|
|
|
3e5111 |
VIR_FORCE_CLOSE(fd);
|
|
|
3e5111 |
- VIR_FREE(xml);
|
|
|
3e5111 |
- virQEMUSaveDataFree(header);
|
|
|
3e5111 |
+ virQEMUSaveDataFree(data);
|
|
|
3e5111 |
VIR_FREE(xmlout);
|
|
|
3e5111 |
virFileWrapperFdFree(wrapperFd);
|
|
|
3e5111 |
if (vm && ret < 0)
|
|
|
3e5111 |
@@ -6618,12 +6628,12 @@ qemuDomainSaveImageGetXMLDesc(virConnectPtr conn, const char *path,
|
|
|
3e5111 |
char *ret = NULL;
|
|
|
3e5111 |
virDomainDefPtr def = NULL;
|
|
|
3e5111 |
int fd = -1;
|
|
|
3e5111 |
- virQEMUSaveHeaderPtr header = NULL;
|
|
|
3e5111 |
+ virQEMUSaveDataPtr data = NULL;
|
|
|
3e5111 |
|
|
|
3e5111 |
/* We only take subset of virDomainDefFormat flags. */
|
|
|
3e5111 |
virCheckFlags(VIR_DOMAIN_XML_SECURE, NULL);
|
|
|
3e5111 |
|
|
|
3e5111 |
- fd = qemuDomainSaveImageOpen(driver, path, &def, &header, NULL,
|
|
|
3e5111 |
+ fd = qemuDomainSaveImageOpen(driver, path, &def, &data,
|
|
|
3e5111 |
false, NULL, false, false);
|
|
|
3e5111 |
|
|
|
3e5111 |
if (fd < 0)
|
|
|
3e5111 |
@@ -6635,7 +6645,7 @@ qemuDomainSaveImageGetXMLDesc(virConnectPtr conn, const char *path,
|
|
|
3e5111 |
ret = qemuDomainDefFormatXML(driver, def, flags);
|
|
|
3e5111 |
|
|
|
3e5111 |
cleanup:
|
|
|
3e5111 |
- virQEMUSaveDataFree(header);
|
|
|
3e5111 |
+ virQEMUSaveDataFree(data);
|
|
|
3e5111 |
virDomainDefFree(def);
|
|
|
3e5111 |
VIR_FORCE_CLOSE(fd);
|
|
|
3e5111 |
return ret;
|
|
|
3e5111 |
@@ -6650,8 +6660,7 @@ qemuDomainSaveImageDefineXML(virConnectPtr conn, const char *path,
|
|
|
3e5111 |
virDomainDefPtr def = NULL;
|
|
|
3e5111 |
virDomainDefPtr newdef = NULL;
|
|
|
3e5111 |
int fd = -1;
|
|
|
3e5111 |
- char *xml = NULL;
|
|
|
3e5111 |
- virQEMUSaveHeaderPtr header = NULL;
|
|
|
3e5111 |
+ virQEMUSaveDataPtr data = NULL;
|
|
|
3e5111 |
int state = -1;
|
|
|
3e5111 |
|
|
|
3e5111 |
virCheckFlags(VIR_DOMAIN_SAVE_RUNNING |
|
|
|
3e5111 |
@@ -6662,7 +6671,7 @@ qemuDomainSaveImageDefineXML(virConnectPtr conn, const char *path,
|
|
|
3e5111 |
else if (flags & VIR_DOMAIN_SAVE_PAUSED)
|
|
|
3e5111 |
state = 0;
|
|
|
3e5111 |
|
|
|
3e5111 |
- fd = qemuDomainSaveImageOpen(driver, path, &def, &header, &xml,
|
|
|
3e5111 |
+ fd = qemuDomainSaveImageOpen(driver, path, &def, &data,
|
|
|
3e5111 |
false, NULL, true, false);
|
|
|
3e5111 |
|
|
|
3e5111 |
if (fd < 0)
|
|
|
3e5111 |
@@ -6671,25 +6680,25 @@ qemuDomainSaveImageDefineXML(virConnectPtr conn, const char *path,
|
|
|
3e5111 |
if (virDomainSaveImageDefineXMLEnsureACL(conn, def) < 0)
|
|
|
3e5111 |
goto cleanup;
|
|
|
3e5111 |
|
|
|
3e5111 |
- if (STREQ(xml, dxml) &&
|
|
|
3e5111 |
- (state < 0 || state == header->was_running)) {
|
|
|
3e5111 |
+ if (STREQ(data->xml, dxml) &&
|
|
|
3e5111 |
+ (state < 0 || state == data->header.was_running)) {
|
|
|
3e5111 |
/* no change to the XML */
|
|
|
3e5111 |
ret = 0;
|
|
|
3e5111 |
goto cleanup;
|
|
|
3e5111 |
}
|
|
|
3e5111 |
|
|
|
3e5111 |
if (state >= 0)
|
|
|
3e5111 |
- header->was_running = state;
|
|
|
3e5111 |
+ data->header.was_running = state;
|
|
|
3e5111 |
|
|
|
3e5111 |
if (!(newdef = qemuDomainSaveImageUpdateDef(driver, def, dxml)))
|
|
|
3e5111 |
goto cleanup;
|
|
|
3e5111 |
|
|
|
3e5111 |
- VIR_FREE(xml);
|
|
|
3e5111 |
+ VIR_FREE(data->xml);
|
|
|
3e5111 |
|
|
|
3e5111 |
- if (!(xml = qemuDomainDefFormatXML(driver, newdef,
|
|
|
3e5111 |
- VIR_DOMAIN_XML_INACTIVE |
|
|
|
3e5111 |
- VIR_DOMAIN_XML_SECURE |
|
|
|
3e5111 |
- VIR_DOMAIN_XML_MIGRATABLE)))
|
|
|
3e5111 |
+ if (!(data->xml = qemuDomainDefFormatXML(driver, newdef,
|
|
|
3e5111 |
+ VIR_DOMAIN_XML_INACTIVE |
|
|
|
3e5111 |
+ VIR_DOMAIN_XML_SECURE |
|
|
|
3e5111 |
+ VIR_DOMAIN_XML_MIGRATABLE)))
|
|
|
3e5111 |
goto cleanup;
|
|
|
3e5111 |
|
|
|
3e5111 |
if (lseek(fd, 0, SEEK_SET) != 0) {
|
|
|
3e5111 |
@@ -6697,7 +6706,7 @@ qemuDomainSaveImageDefineXML(virConnectPtr conn, const char *path,
|
|
|
3e5111 |
goto cleanup;
|
|
|
3e5111 |
}
|
|
|
3e5111 |
|
|
|
3e5111 |
- if (virQEMUSaveDataWrite(header, xml, fd, path) < 0)
|
|
|
3e5111 |
+ if (virQEMUSaveDataWrite(data, fd, path) < 0)
|
|
|
3e5111 |
goto cleanup;
|
|
|
3e5111 |
|
|
|
3e5111 |
if (VIR_CLOSE(fd) < 0) {
|
|
|
3e5111 |
@@ -6711,8 +6720,7 @@ qemuDomainSaveImageDefineXML(virConnectPtr conn, const char *path,
|
|
|
3e5111 |
virDomainDefFree(def);
|
|
|
3e5111 |
virDomainDefFree(newdef);
|
|
|
3e5111 |
VIR_FORCE_CLOSE(fd);
|
|
|
3e5111 |
- VIR_FREE(xml);
|
|
|
3e5111 |
- virQEMUSaveDataFree(header);
|
|
|
3e5111 |
+ virQEMUSaveDataFree(data);
|
|
|
3e5111 |
return ret;
|
|
|
3e5111 |
}
|
|
|
3e5111 |
|
|
|
3e5111 |
@@ -6731,12 +6739,11 @@ qemuDomainObjRestore(virConnectPtr conn,
|
|
|
3e5111 |
qemuDomainObjPrivatePtr priv = vm->privateData;
|
|
|
3e5111 |
int fd = -1;
|
|
|
3e5111 |
int ret = -1;
|
|
|
3e5111 |
- char *xml = NULL;
|
|
|
3e5111 |
char *xmlout = NULL;
|
|
|
3e5111 |
- virQEMUSaveHeaderPtr header = NULL;
|
|
|
3e5111 |
+ virQEMUSaveDataPtr data = NULL;
|
|
|
3e5111 |
virFileWrapperFdPtr wrapperFd = NULL;
|
|
|
3e5111 |
|
|
|
3e5111 |
- fd = qemuDomainSaveImageOpen(driver, path, &def, &header, &xml,
|
|
|
3e5111 |
+ fd = qemuDomainSaveImageOpen(driver, path, &def, &data,
|
|
|
3e5111 |
bypass_cache, &wrapperFd, false, true);
|
|
|
3e5111 |
if (fd < 0) {
|
|
|
3e5111 |
if (fd == -3)
|
|
|
3e5111 |
@@ -6750,7 +6757,7 @@ qemuDomainObjRestore(virConnectPtr conn,
|
|
|
3e5111 |
if ((hookret = virHookCall(VIR_HOOK_DRIVER_QEMU, def->name,
|
|
|
3e5111 |
VIR_HOOK_QEMU_OP_RESTORE,
|
|
|
3e5111 |
VIR_HOOK_SUBOP_BEGIN,
|
|
|
3e5111 |
- NULL, xml, &xmlout)) < 0)
|
|
|
3e5111 |
+ NULL, data->xml, &xmlout)) < 0)
|
|
|
3e5111 |
goto cleanup;
|
|
|
3e5111 |
|
|
|
3e5111 |
if (hookret == 0 && !virStringIsEmpty(xmlout)) {
|
|
|
3e5111 |
@@ -6784,14 +6791,13 @@ qemuDomainObjRestore(virConnectPtr conn,
|
|
|
3e5111 |
virDomainObjAssignDef(vm, def, true, NULL);
|
|
|
3e5111 |
def = NULL;
|
|
|
3e5111 |
|
|
|
3e5111 |
- ret = qemuDomainSaveImageStartVM(conn, driver, vm, &fd, header, path,
|
|
|
3e5111 |
+ ret = qemuDomainSaveImageStartVM(conn, driver, vm, &fd, data, path,
|
|
|
3e5111 |
start_paused, asyncJob);
|
|
|
3e5111 |
if (virFileWrapperFdClose(wrapperFd) < 0)
|
|
|
3e5111 |
VIR_WARN("Failed to close %s", path);
|
|
|
3e5111 |
|
|
|
3e5111 |
cleanup:
|
|
|
3e5111 |
- VIR_FREE(xml);
|
|
|
3e5111 |
- virQEMUSaveDataFree(header);
|
|
|
3e5111 |
+ virQEMUSaveDataFree(data);
|
|
|
3e5111 |
VIR_FREE(xmlout);
|
|
|
3e5111 |
virDomainDefFree(def);
|
|
|
3e5111 |
VIR_FORCE_CLOSE(fd);
|
|
|
3e5111 |
@@ -14364,7 +14370,7 @@ qemuDomainSnapshotCreateActiveExternal(virConnectPtr conn,
|
|
|
3e5111 |
virQEMUDriverConfigPtr cfg = NULL;
|
|
|
3e5111 |
int compressed;
|
|
|
3e5111 |
char *compressedpath = NULL;
|
|
|
3e5111 |
- virQEMUSaveHeaderPtr header = NULL;
|
|
|
3e5111 |
+ virQEMUSaveDataPtr data = NULL;
|
|
|
3e5111 |
|
|
|
3e5111 |
/* If quiesce was requested, then issue a freeze command, and a
|
|
|
3e5111 |
* counterpart thaw command when it is actually sent to agent.
|
|
|
3e5111 |
@@ -14436,10 +14442,11 @@ qemuDomainSnapshotCreateActiveExternal(virConnectPtr conn,
|
|
|
3e5111 |
if (!(xml = qemuDomainDefFormatLive(driver, vm->def, true, true)))
|
|
|
3e5111 |
goto cleanup;
|
|
|
3e5111 |
|
|
|
3e5111 |
- if (!(header = virQEMUSaveDataNew(xml, resume, compressed)))
|
|
|
3e5111 |
+ if (!(data = virQEMUSaveDataNew(xml, resume, compressed)))
|
|
|
3e5111 |
goto cleanup;
|
|
|
3e5111 |
+ xml = NULL;
|
|
|
3e5111 |
|
|
|
3e5111 |
- if ((ret = qemuDomainSaveMemory(driver, vm, snap->def->file, xml, header,
|
|
|
3e5111 |
+ if ((ret = qemuDomainSaveMemory(driver, vm, snap->def->file, data,
|
|
|
3e5111 |
compressedpath, 0,
|
|
|
3e5111 |
QEMU_ASYNC_JOB_SNAPSHOT)) < 0)
|
|
|
3e5111 |
goto cleanup;
|
|
|
3e5111 |
@@ -14509,7 +14516,7 @@ qemuDomainSnapshotCreateActiveExternal(virConnectPtr conn,
|
|
|
3e5111 |
ret = -1;
|
|
|
3e5111 |
}
|
|
|
3e5111 |
|
|
|
3e5111 |
- virQEMUSaveDataFree(header);
|
|
|
3e5111 |
+ virQEMUSaveDataFree(data);
|
|
|
3e5111 |
VIR_FREE(xml);
|
|
|
3e5111 |
VIR_FREE(compressedpath);
|
|
|
3e5111 |
virObjectUnref(cfg);
|
|
|
3e5111 |
--
|
|
|
3e5111 |
2.13.1
|
|
|
3e5111 |
|