qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Alberto Garcia <berto@igalia.com>
To: qemu-block@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>, Hanna Czenczek <hreitz@redhat.com>,
	qemu-devel@nongnu.org
Subject: Converting images to stdout
Date: Thu, 16 Nov 2023 18:48:09 +0100	[thread overview]
Message-ID: <ZVZV2ZKcxoSargry@zeus.local> (raw)

Hi,

I haven't written here in a while :) but I have something small that I
would like to discuss.

Using qemu-img to convert an image and writing the result directly to
stdout is a question that has already been raised in the past (see
[1] for an example) and it's clear that it's generally not possible
because the images need to be seekable.

While I think that there's almost certainly no generic way to do
something like that for every combination of input and output formats,
I do think that it should be relatively easy to produce a qcow2 file
directly to stdout as long as the input file is on disk.

I'm interested in this use case, and I think that the method would be
as simple as this:

1. Decide a cluster size for the output qcow2 file.
2. Read the input file once to determine which clusters need to be
   allocated in the output file and which ones don't.
3. That infomation is enough to determine the number and contents of
   the refcount table, refcount blocks, and L1/L2 tables.
4. Write the qcow2 header + metadata + allocated data to stdout.

Since this would be qcow2-specific I would probably implement this as
a separate tool instead of adding it directly to qemu-img. This could
go to the scripts/ directory because I can imagine that such a tool
could be useful for other people.

Because this would be an external tool it would only support a qcow2
file with the default options. Other features like compression would
be out of scope.

For the same reason the input would be a raw file for simplicity,
other input files could be presented in raw format using
qemu-storage-daemon.

And that's the general idea, comments and questions are welcome.

Thanks!

Berto

[1] https://lists.nongnu.org/archive/html/qemu-discuss/2020-01/msg00014.html


             reply	other threads:[~2023-11-16 17:49 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-16 17:48 Alberto Garcia [this message]
2023-11-20 23:23 ` Converting images to stdout Eric Blake
2023-11-22 12:15   ` Alberto Garcia

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=ZVZV2ZKcxoSargry@zeus.local \
    --to=berto@igalia.com \
    --cc=hreitz@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).