[libvirt] [PATCH] qemu:Fix snapshot creating with vm xml persistent

Bobo Du posted 1 patch 5 years, 9 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/1532588584-30937-2-git-send-email-dubo163@126.com
Test syntax-check passed
src/qemu/qemu_blockjob.c | 2 +-
src/qemu/qemu_driver.c   | 3 ++-
2 files changed, 3 insertions(+), 2 deletions(-)
[libvirt] [PATCH] qemu:Fix snapshot creating with vm xml persistent
Posted by Bobo Du 5 years, 9 months ago
it is a bug when the vm is undefined after started.
blockcommit interface also has the bug with above.

Signed-off-by: Bobo Du <dubobo@didichuxing.com
---
 src/qemu/qemu_blockjob.c | 2 +-
 src/qemu/qemu_driver.c   | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/qemu/qemu_blockjob.c b/src/qemu/qemu_blockjob.c
index 0f52996..90af797 100644
--- a/src/qemu/qemu_blockjob.c
+++ b/src/qemu/qemu_blockjob.c
@@ -204,7 +204,7 @@ qemuBlockJobEventProcess(virQEMUDriverPtr driver,
     if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver->caps) < 0)
         VIR_WARN("Unable to save status on vm %s after block job", vm->def->name);
 
-    if (status == VIR_DOMAIN_BLOCK_JOB_COMPLETED && vm->newDef) {
+    if (status == VIR_DOMAIN_BLOCK_JOB_COMPLETED && vm->newDef && vm->persistent) {
         if (virDomainSaveConfig(cfg->configDir, driver->caps, vm->newDef) < 0)
             VIR_WARN("Unable to update persistent definition on vm %s "
                      "after block job", vm->def->name);
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index fb0d4a8..202c1ba 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -15055,7 +15055,8 @@ qemuDomainSnapshotCreateDiskActive(virQEMUDriverPtr driver,
 
     if (ret == 0 || !do_transaction) {
         if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver->caps) < 0 ||
-            (persist && virDomainSaveConfig(cfg->configDir, driver->caps,
+                (vm->persistent && persist && virDomainSaveConfig(cfg->configDir,
+                                            driver->caps,
                                             vm->newDef) < 0))
             ret = -1;
     }
-- 
1.8.3.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] qemu:Fix snapshot creating with vm xml persistent
Posted by Peter Krempa 5 years, 8 months ago
On Thu, Jul 26, 2018 at 03:03:04 -0400, Bobo Du wrote:
> it is a bug when the vm is undefined after started.
> blockcommit interface also has the bug with above.

Could you please specify steps and the outcome when this breaks?

vm->newDef should not be present if the VM is not persistent so the code
below should be correct as is now. I think there might be some other
bug.

> 
> Signed-off-by: Bobo Du <dubobo@didichuxing.com

Missing closing angle bracket. Please use the '-s' switch for git commit
which will add the signoff line in the correct format.

> ---
>  src/qemu/qemu_blockjob.c | 2 +-
>  src/qemu/qemu_driver.c   | 3 ++-
>  2 files changed, 3 insertions(+), 2 deletions(-)
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list