qemu-block
[Top][All Lists]
Advanced

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

Re: [PATCH] qemu-img: add seek and -n option to dd command


From: Max Reitz
Subject: Re: [PATCH] qemu-img: add seek and -n option to dd command
Date: Fri, 5 Feb 2021 11:06:36 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0

On 05.02.21 10:16, Max Reitz wrote:
On 05.02.21 09:47, Peter Lieven wrote:
Am 05.02.21 um 09:18 schrieb Max Reitz:
On 04.02.21 21:09, Peter Lieven wrote:
Am 02.02.21 um 16:51 schrieb Eric Blake:
On 1/28/21 8:07 AM, Peter Lieven wrote:
Signed-off-by: Peter Lieven <pl@kamp.de>
Your commit message says 'what', but not 'why'.  Generally, the one-line
'what' works well as the subject line, but you want the commit body to
give an argument why your patch should be applied, rather than blank.

Here's the last time we tried to improve qemu-img dd:
https://lists.gnu.org/archive/html/qemu-devel/2018-08/msg02618.html


I was not aware of that story. My use case is that I want to be

able to "patch" an image that Qemu is able to handle by overwriting

certain sectors. And I especially do not want to "mount" that image

via qemu-nbd because I might not trust it. I totally want to avoid that the host

system tries to analyse that image in terms of scanning the bootsector, partprobe,

lvm etc. pp.

qemu will have FUSE exporting as of 6.0 (didn’t quite make it into 5.2), so you can do something like this:

$ qemu-storage-daemon \
     --blockdev node-name=export,driver=qcow2,\
file.driver=file,file.filename=image.qcow2 \
     --export fuse,id=fuse,node-name=export,mountpoint=image.qcow2

This exports the image on image.qcow2 (i.e., on itself) and so by accessing the image file you then get raw access to its contents (so you can use system tools like dd).

Doesn’t require root rights, and shouldn’t make the kernel scan anything, because it’s exported as just a regular file.


Okay, but that is still more housekeeping than just invoking a single command.

Yes, but I personally see this as much better than copying all of dd’s functionality into qemu-img.

My personal complaint is only that it’s a pain in the ass to invoke QSD this way.  It would be nice to have a script that does the same via

$ qemu-blk-fuse-export image.qcow2

Would probably be trivial to write, but well, first we gotta do it, and have justification to keep it as part of qemu...

And if that’s still too much housekeeping, we could even write a qemu-dd script that scans all file arguments for non-raw images, launches a QSD instance to present them as raw, and then invokes dd.

Since today’s Day of Learning at Red Hat, I decided to have some fun writing a qemu-dd.py script.

Max

Attachment: qemu-dd.py
Description: Text Data


reply via email to

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