Change in vdsm[ovirt-3.6]: vm: snapshot - use r+ to open vm conf file

derez at redhat.com derez at redhat.com
Sun Nov 22 11:46:25 UTC 2015


Hello Francesco Romani,

I'd like you to do a code review.  Please visit

    https://gerrit.ovirt.org/48912

to review the following change.

Change subject: vm: snapshot - use r+ to open vm conf file
......................................................................

vm: snapshot - use r+ to open vm conf file

Since commit 0b61c4851a528fd6354d9ab77a68085c41f35dc9
copy of internal raw volumes is done using 'qemu-img convert'
instead of invoking 'dd'. Hence, we should avoid changing
the file size by opening it in a non-truncate mode to avoid
qemu-img from hanging during the convert operation.

The issue reproduces for files size of multiplicity of 512.
E.g.
Doesn't work:
$ dd if=/dev/zero of=/tmp/test.raw bs=5474 count=1
$ ./qemu-img convert -p -t none -T none -O raw /tmp/test.raw
/tmp/dest.raw

Works:
$ dd if=/dev/zero of=/tmp/test.raw bs=5120 count=1
$ ./qemu-img convert -p -t none -T none -O raw /tmp/test.raw
/tmp/dest.raw

Change-Id: Ic6799e07898155fd4a630bfaf4151ea9ccdcee49
Bug-Url: https://bugzilla.redhat.com/1282239
Relates-To: https://bugzilla.redhat.com/1229394
Signed-off-by: Daniel Erez <derez at redhat.com>
Reviewed-on: https://gerrit.ovirt.org/48776
Reviewed-by: Nir Soffer <nsoffer at redhat.com>
Continuous-Integration: Nir Soffer <nsoffer at redhat.com>
Reviewed-by: Francesco Romani <fromani at redhat.com>
---
M vdsm/virt/vm.py
1 file changed, 2 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/12/48912/1

diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py
index a5eead1..27d9826 100644
--- a/vdsm/virt/vm.py
+++ b/vdsm/virt/vm.py
@@ -3133,7 +3133,8 @@
             vmConfVolPath = self.cif.prepareVolumePath(vmConfVol)
             vmConf = _vmConfForMemorySnapshot()
             try:
-                with open(vmConfVolPath, "w") as f:
+                # Use r+ to avoid truncating the file, see BZ#1282239
+                with open(vmConfVolPath, "r+") as f:
                     pickle.dump(vmConf, f)
             finally:
                 self.cif.teardownVolumePath(vmConfVol)


-- 
To view, visit https://gerrit.ovirt.org/48912
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic6799e07898155fd4a630bfaf4151ea9ccdcee49
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: ovirt-3.6
Gerrit-Owner: Daniel Erez <derez at redhat.com>
Gerrit-Reviewer: Francesco Romani <fromani at redhat.com>


More information about the vdsm-patches mailing list