qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v3] block/file-win32: add reopen handlers


From: Helge Konetzka
Subject: Re: [PATCH v3] block/file-win32: add reopen handlers
Date: Wed, 18 Aug 2021 12:22:00 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0

Am 17.08.21 um 22:21 schrieb Viktor Prutyanov:
Make 'qemu-img commit' work on Windows.

Command 'commit' requires reopening backing file in RW mode. So,
add reopen prepare/commit/abort handlers and change dwShareMode
for CreateFile call in order to allow further read/write reopening.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/418
Suggested-by: Hanna Reitz <hreitz@redhat.com>
Signed-off-by: Viktor Prutyanov <viktor.prutyanov@phystech.edu>
---
  v2:
     - fix indentation in raw_reopen_prepare
     - free rs if raw_reopen_prepare fails
  v3:
     - restore suggested-by field missed in v2

  block/file-win32.c | 90 +++++++++++++++++++++++++++++++++++++++++++++-
  1 file changed, 89 insertions(+), 1 deletion(-)

Test was successful on Windows 10 Pro, 21H1, 19043.1165, build & test environment MSYS2, MINGW64

Tested-by: Helge Konetzka <hk@zapateado.de>

See my test protocol:

$ git clone https://github.com/patchew-project/qemu.git patchew-qemu
$ cd patchew-qemu
$ git checkout tags/patchew/20210817202115.16771-1-viktor.prutyanov@phystech.edu
$ mkdir build-msys2 && cd build-msys2
$ export AR=gcc-ar NM=nm OBJCOPY=objcopy RANLIB=gcc-ranlib STRIP=strip WINDRES=windres
$ ../configure \
  --cross-prefix=x86_64-w64-mingw32- \
  --prefix=/mingw64/opt/patchew-qemu --target-list=x86_64-softmmu \
  --bindir=bin --datadir=share/qemu --localedir=share/locale --mandir=share/man --docdir=share/doc/qemu
$ make -j2 && make install

$ export PATH="/mingw64/opt/patchew-qemu/bin:$PATH"
$ which qemu-img
/mingw64/opt/patchew-qemu/bin/qemu-img
$ qemu-img create -f qcow2 testbacking.qcow2 20G
Formatting 'testbacking.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=21474836480 lazy_refcounts=off refcount_bits=16
$ qemu-img create -F qcow2 -b testbacking.qcow2 -f qcow2 test.qcow2
Formatting 'test.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=21474836480 backing_file=testbacking.qcow2 backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16
$ ls -l test*.qcow2
-rw-r--r-- 1 User Kein 197120 Aug 18 09:38 test.qcow2
-rw-r--r-- 1 User Kein 197120 Aug 18 09:34 testbacking.qcow2
$ qemu-img commit test.qcow2
Image committed.
$ ls -l test*.qcow2
-rw-r--r-- 1 User Kein 262144 Aug 18 09:39 test.qcow2
-rw-r--r-- 1 User Kein 197120 Aug 18 09:34 testbacking.qcow2
# Install Linux to image ...
$ qemu-system-x86_64 -accel whpx,kernel-irqchip=off -m 1G -hda test.qcow2 \
  -cdrom debian-10.8.0-amd64-netinst.iso
Windows Hypervisor Platform accelerator is operational
# Test Linux image before commit  ...
$ qemu-system-x86_64 -accel whpx,kernel-irqchip=off -m 1G -hda test.qcow2
Windows Hypervisor Platform accelerator is operational
$ ls -l test*.qcow2
-rw-r--r-- 1 User Kein 6641090560 Aug 18 10:57 test.qcow2
-rw-r--r-- 1 User Kein     197120 Aug 18 09:34 testbacking.qcow2
$ qemu-img commit test.qcow2
Image committed.
$ ls -l test*.qcow2
-rw-r--r-- 1 User Kein     262144 Aug 18 11:09 test.qcow2
-rw-r--r-- 1 User Kein 6641090560 Aug 18 11:09 testbacking.qcow2
$ rm test.qcow2
# Test Linux image after commit ...
$ qemu-system-x86_64 -accel whpx,kernel-irqchip=off -m 1G -hda testbacking.qcow2




reply via email to

[Prev in Thread] Current Thread [Next in Thread]