All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
To: Eric Blake <eblake@redhat.com>, "Denis V. Lunev" <den@openvz.org>,
	qemu-block@nongnu.org, qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
	Andrey Shinkevich <andrey.shinkevich@virtuozzo.com>,
	"Richard W . M . Jones" <rjones@redhat.com>,
	Max Reitz <mreitz@redhat.com>
Subject: Re: [PATCH for 5.2 1/1] qemu-io: add -V flag for read sub-command
Date: Mon, 10 Aug 2020 18:07:58 +0300	[thread overview]
Message-ID: <433af02b-e577-05de-2824-16cc6f736783@virtuozzo.com> (raw)
In-Reply-To: <d01f2684-e17e-c1b9-1e43-3b6ff57ddf10@redhat.com>

10.08.2020 17:20, Eric Blake wrote:
> On 8/10/20 7:35 AM, Denis V. Lunev wrote:
>> The problem this patch is trying to address is libguestfs behavior on the
>> appliance startup. It starts supporting to use root=UUID definition in
>> the kernel command line of its root filesystem using
>>      file --  /usr/lib64/guestfs/appliance/root
>> This works fine with RAW image, but we are using QCOW2 as a storage to
>> save a bit of file space and in this case we get
>>      QEMU QCOW Image (v3), 1610612736 bytes
>> instead of UUID of the root filesystem.
>>
>> The solution is very simple - we should dump first 256k of the image file
>> like the follows
>>      qemu-io -c "read -V 0 256k" appliance | file -
>> which will provide correct result for all possible types of the appliance
>> storage.
> 
> Is 'appliance' a qcow2 file?  If so, another way to accomplish this could include:
> 
> nbdkit streaming --run 'qemu-img convert --image-opts driver=raw,size=256,file.driver=qcow2,file.file.driver=file,file.file.filename=appliance "$uri"' | file -

This adds a dependency on nbdkit streaming plugin, not installed by default in our RH-based distributive. Probably the simplest thing is just create a temporary file for qemu-img convert (or dd) target, and then call file command on it.

> 
> which says to use qemu-img to open a length-limited view of the file, and stream the entire thing to an NBD server, where nbdkit then provides a way to convert that to a pipeline to feed into file (since qemu's NBD server doesn't directly like writing into a pipe).
> 
> I'm also wondering if the 'nbdcopy' program (not yet released in a stable version, but available in libnbd.git) could be put to use on this front, with some way to quickly combine it with qemu-nbd serving appliance.qcow2.
> 
>>
>> Unfortunately, additional option for qemu-io is the only and the simplest
>> solution as '-v' creates very specific output, which requires to be
>> parsed. 'qemu-img dd of=/dev/stdout' does not work and the fix would be
>> much more intrusive.
> 
> 'qemu-img dd' _should_ be merely syntactic sugar for 'qemu-img convert', but it isn't yet.  Until we rectify that feature parity (there are things that dd can't do like better output control and skipping, and there are things that convert can't do like length limiting and offset selection), hacking up 'qemu-io' (which is for debugging use only) is a tolerable short-term solution; but qemu-io was NEVER intended for stable use cases.  If adding this makes debugging qemu easier, then go for it; but if the real problem is that qemu-img is missing functionality, we should instead be focusing on fixing qemu-img.
> 

Thanks for clarifying this!

If we are going to improve qemu-img at some point, I'm not sure that convert or dd is correct places to do it, as they want target to be a block node. But how to create a block-node on top of /dev/stdout? Detect it and behave another way in img_dd function? Or may be better create another command qemu-img dump, for dumping the contents to stdout?

-- 
Best regards,
Vladimir


      reply	other threads:[~2020-08-10 15:08 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-10 12:35 [PATCH for 5.2 1/1] qemu-io: add -V flag for read sub-command Denis V. Lunev
2020-08-10 12:52 ` Richard W.M. Jones
2020-08-10 12:58   ` Denis V. Lunev
2020-08-10 14:02 ` Vladimir Sementsov-Ogievskiy
2020-08-10 14:40   ` Kevin Wolf
2020-08-10 14:41     ` Denis V. Lunev
2020-08-10 14:20 ` Eric Blake
2020-08-10 15:07   ` Vladimir Sementsov-Ogievskiy [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=433af02b-e577-05de-2824-16cc6f736783@virtuozzo.com \
    --to=vsementsov@virtuozzo.com \
    --cc=andrey.shinkevich@virtuozzo.com \
    --cc=den@openvz.org \
    --cc=eblake@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=rjones@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.