
On Wed, Sep 17, 2014 at 17:18:38 +0200, Peter Krempa wrote:
Move them to the single corresponding function rather than having them in the common chunk of code. --- src/qemu/qemu_driver.c | 76 +++++++++++++++++++++++++++----------------------- 1 file changed, 41 insertions(+), 35 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 0151fd2..1d82e93 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c ... @@ -5477,18 +5489,6 @@ qemuDomainSaveImageOpen(virQEMUDriverPtr driver, goto error; }
- if (edit && STREQ(xml, xmlin) && - (state < 0 || state == header.was_running)) { - VIR_FREE(xml); - if (VIR_CLOSE(fd) < 0) { - virReportSystemError(errno, _("cannot close file: %s"), path); - goto error; - } - return -2; - } - if (state >= 0) - header.was_running = state; - /* Create a domain from this XML */ if (!(def = virDomainDefParseString(xml, caps, driver->xmlopt, QEMU_EXPECTED_VIRT_TYPES, ... @@ -5763,22 +5762,30 @@ qemuDomainSaveImageDefineXML(virConnectPtr conn, const char *path, else if (flags & VIR_DOMAIN_SAVE_PAUSED) state = 0;
- fd = qemuDomainSaveImageOpen(driver, path, &def, &header, NULL, - false, NULL, dxml, state, true, false); + fd = qemuDomainSaveImageOpen(driver, path, &def, &header, &xml, + false, NULL, true, false);
- if (fd < 0) { - /* Check for special case of no change needed. */ - if (fd == -2) - ret = 0; + if (fd < 0) goto cleanup; - }
if (virDomainSaveImageDefineXMLEnsureACL(conn, def) < 0) goto cleanup;
+ if (STREQ(xml, dxml) && + (state < 0 || state == header.was_running)) { + /* no change to the XML */ + ret = 0; + goto cleanup; + } + + if (state > 0) + header.was_running = state;
I believe the condition should be state >= 0.
+ if (!(newdef = qemuDomainSaveImageUpdateDef(driver, def, dxml))) goto cleanup;
+ VIR_FREE(xml); + xml = qemuDomainDefFormatXML(driver, newdef, VIR_DOMAIN_XML_INACTIVE | VIR_DOMAIN_XML_SECURE | ...
ACK Jirka