Skip to contentSkip to conversation

storing machine data in qcow images?

Qemu-devel Michael S. Tsirkin 17 participants 157 messages May 18, 2018 – Jun 11, 2018 Page 2 of 2

lore
Share & tools
lore
#147 lore raw
In reply to Max Reitz
Quoted 124 lines · Max Reitz
Quoted 38 lines · Michal Suchánek
Quoted 35 lines · On Wed, 6 Jun 2018 15:14:03 +0200 Max Reitz <[email protected]> wrote:
Quoted 10 lines · Michal Suchánek
Quoted 7 lines · On Wed, 6 Jun 2018 13:52:35 +0200 Max Reitz <[email protected]> wrote:
Quoted 6 lines · Michal Suchánek
Quoted 3 lines · On Wed, 6 Jun 2018 13:32:47 +0200 Max Reitz <[email protected]> wrote:
Quoted 2 lines · Michal Suchánek

On Wed, 6 Jun 2018 13:02:53 +0200
Max Reitz <[email protected]> wrote:

[...]

Quoted 20 lines
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

What I'm trying to get at is that qcow2 was not designed to be a container format for arbitrary files. If you want to make it such, I'm sure there are existing formats that work better.

Such as?

ext2?

Quoted 7 lines
Quoted 2 lines

So you want an ext2 driver in qemu instead of expanding qcow2 to work not only for a single disk but also for an appliance?

Yes, because ext2 was designed to be a proper filesystem. I'm not an FS designer. Well, not a good one anyway. So I don't trust myself on extending qcow2 to be a good FS -- and why would I, when there are already numerous FS around.

Do you expect that performance of qemu using qcow2 driver over ext2 driver will be better than using qcow driver directly with some part semi-permanently occupied by a configuration blob? My bet is not.

Quoted 6 lines
Quoted 3 lines

If you want to store multiple disk images in a single file? I would think so, yes. With qcow2, I would assume it leads to fragmentation.

How is that different from single disk divided into two partitions internally (without any knowledge on the qcow2 level)?

From how it's going to be fragmented, there is no difference. If you have multiple partitions and write to them concurrently, thus allocating new areas, you get bad fragmentation.

Quoted 3 lines
Quoted 1 line

I would hope that proper filesystems can mitigate this.

Not really. Not without much complexity and repeated maintenance.

Yes, a proper filesystem. Which we'd get for free with multiple files.

Quoted 11 lines
Quoted 9 lines
Quoted 6 lines

The ext* drivers are designed to work with kernel VM infrastructure which must be tuned for different usage scenarios and you would have to duplicate that tuning in qemu to get competitive performance. Also you get qcow2 and ext2 metadata which must be allocated, managed, etc. You get more storage and performance overhead for no good reason.

Yes, there is a good reason. You can add arbitrary configuration options without having to worry about me.

But I will not be able to use the images in qemu so it will be useless.

Neither can you with the current proposal because that is about adding management layer configuration options which are opaque to qemu.

Quoted 2 lines

Well, there is FUSE and that is certainly blazing fast and ubiquitous, I am sure.

If you want to use pre-existing drivers, you'd probably use a loop device.

Otherwise, you'd use the block layer for accessing the disk.

If you want blazingly fast, you probably won't use qcow2 anyway. Or, funnily enough, you'd want to probably split the qcow2 file into a metadata and a data file, so you get even more files. (But that is a proposal for the future.)

Quoted 30 lines
Quoted 30 lines

Seriously, though, a real FS would allow you to be more expressive and really do what you want without having to work around the quirks that adding a not-real-FS in the most simple way possible to qcow2 would bring with it.

Because this is part of my fear, that we now add a very simple blob for just a sprinkle of data. But over time it gets more and more complex because we want to store more and more data to make things ever more convenient[1], we notice that we need more features, the format gets more complex, and in the end we have an FS that is just worse than a real FS.

[1] And note that if I'm convinced to store VM configuration data in qemu, I will agree that we can store any data in there and it would be nice if any VM could be provisioned and used that way.

Quoted 4 lines

On the other hand, qcow is designed for storing VM disk data and hopefully was tuned to do that decently over the years. The primary use case remains storing VM disk data. Adding a configuration blob does not change that.

True. So the argument is that qcow2 may be worse for storing arbitrary data, but we don't have performance requirements for that; but we do have performance requirements for disk data and adding another format below qcow2 will not make it better.

I do think it is possible to not make things worse with a format under qcow2, but that may require additional complexity, that you think is pointless.

Quoted 7 lines
Quoted 3 lines

I understand that you think that, but I still believe that putting the configuration into qcow2 is just the wrong way around and will fall on our feet in the long run.

I think that *if* we want an 'appliance' format that stores a whole VM in a single file to ease VM distribution then the logical place to look in qemu is qcow. The reason have been explained at length.

The reason being that it's the easiest place, yes. That doesn't make it the best place.

Quoted 8 lines
Quoted 2 lines

I understand that for some use cases simplifying the distribution of VMs as much as possible is quite important.

I don't because still nobody has explained it to me.

The only explanation I got so far was "People are lazy and we have defaults for everything, so we don't throw an error if people forget to pass a configuration file."

People don't pass a configuration file today because there's no standard for such a configuration file. qcow2 is already used today as an appliance file format because there's no better option. People download disk images from appliance and OS providers, import them into a cloud system, and it works out of the box because (luckily) "pc" is enough for most of them.

We can specify a true appliance file format, and ask people to use it. But then providers of single-disk appliances and OSes will need to publish two appliance images: qcow2 disk image for old systems that don't support the new format, and one in the new appliance format, for systems that support it.

Quoted 2 lines

Which to me still just makes it an inconvenience.

Well, there are small inconveniences and there are big inconveniences that together make a system unnecessarily hard to use. I'd say this one falls somewhere in the middle.

[...]

Quoted 7 lines

I'm noticing a pattern here, and that is that everybody has a different opinion on what we actually want in the end, and it's just by chance that we find ourselves in two camps ("put it in qcow2" vs. "put it somewhere else").

Maybe we should first discuss what we actually want before we can discuss where to put it.

I'm inclined to agree. Once we figure out a good VM description format, we can justify a proposal to allow embedding the VM description in qcow2 for convenience.

Signature · 1 line
Eduardo
#148 lore raw
Quoted 2 lines · Eduardo Habkost
Quoted 1 line · Max Reitz

On 2018-06-06 15:45, Michal Suchánek wrote:

[...]

Quoted 9 lines
Quoted 8 lines
Quoted 2 lines

I understand that for some use cases simplifying the distribution of VMs as much as possible is quite important.

I don't because still nobody has explained it to me.

The only explanation I got so far was "People are lazy and we have defaults for everything, so we don't throw an error if people forget to pass a configuration file."

Quoted 6 lines

People don't pass a configuration file today because there's no standard for such a configuration file. qcow2 is already used today as an appliance file format because there's no better option. People download disk images from appliance and OS providers, import them into a cloud system, and it works out of the box because (luckily) "pc" is enough for most of them.

OK.

Quoted 5 lines

We can specify a true appliance file format, and ask people to use it. But then providers of single-disk appliances and OSes will need to publish two appliance images: qcow2 disk image for old systems that don't support the new format, and one in the new appliance format, for systems that support it.

True. This is a valid argument for making a compatible change to qcow2.
But: If these options are actually important, the qcow2 file is not
really compatible either. You might end up with a blank screen again.

Depending on how we'd design a new format, it might contain a config file and a qcow2 file which may be easily extractable. If so, users of legacy software could easily extract the qcow2 file and might even be tempted to look at the config file when it doesn't work, and maybe that could even help them.

Also, I think that it is not too unreasonable to ask providers to provide two formats.

But that does not make me disregard your argument. It is still valid, especially with your convenience note below.

(Providers could choose whether it is best for them to include the description in the qcow2 file, or whether to offer an archive that contains e.g. a raw file.)

Quoted 5 lines
Quoted 1 line

Which to me still just makes it an inconvenience.

Well, there are small inconveniences and there are big inconveniences that together make a system unnecessarily hard to use. I'd say this one falls somewhere in the middle.

Hm, OK.

Quoted 6 lines

[...]

Quoted 5 lines

I'm noticing a pattern here, and that is that everybody has a different opinion on what we actually want in the end, and it's just by chance that we find ourselves in two camps ("put it in qcow2" vs. "put it somewhere else").

Quoted 6 lines
Quoted 2 lines

Maybe we should first discuss what we actually want before we can discuss where to put it.

I'm inclined to agree. Once we figure out a good VM description format, we can justify a proposal to allow embedding the VM description in qcow2 for convenience.

OK.

Max

#149 lore raw
In reply to Max Reitz
Quoted 1 line · Max Reitz

ext2?

I wrote an nbdkit plugin for ext2/ext3/ext4 last week.

https://github.com/libguestfs/nbdkit/tree/master/plugins/ext2

It uses libext2fs from e2fsprogs and I think there are some lessons for anyone who wants to use ext2 to store disk images.

(1) You cannot have more than one host process accessing a single filesystem image, even read-only. This is because opening an ext2+ filesystem even read-only causes writes, replaying the journal (for ext3+) or writing to the superblock.

I'm sure there are some common use-cases such as overlays sharing a common backing store which are excluded by this restriction.

(2) Within a single process you cannot have more than one libext2fs handle open on the filesystem image. This could make qemu block drivers a bit awkward (although not impossible) because if two instances of an ext2 qemu block driver both opened different disks in the same filesystem they'd need to share a handle.

(3) You can resize files in the filesystem, although because we're waiting for the NBD resize extension to be finalized my plugin does not do that.

(4) Trim/discard appears to be possible (and it should be possible to punch holes in the filesystem image) but I couldn't actually understand how to make it work. Also fast zeroing.

Rich.

Signature · 4 lines
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
libguestfs lets you edit virtual machines.  Supports shell scripting,
bindings from many languages.  http://libguestfs.org
#150 lore raw
In reply to Max Reitz
Quoted 4 lines · Max Reitz

(I'm wondering if we could write a block driver that could provide such a chunk allocation transparently to qcow2... Note that a qcow2 file does not need to be continuous, so you could in theory indeed store the qcow2 file and its data in completely separate places in a tar file.)

nbdkit-split-plugin
(https://github.com/libguestfs/nbdkit/tree/master/plugins/split). It currently doesn't support resizing although it could do fairly easily.

Quoted 2 lines

Yeah, but why make qcow2 that format? That's what I completely fail to understand.

I started off a long reply here, but I think you're right. If we cannot make people decide on and use a proper disk image + metadata container, then it's also unlikely we'll get them to add sensible metadata to their qcow2 images either :-(

Rich.

Signature · 4 lines
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
libguestfs lets you edit virtual machines.  Supports shell scripting,
bindings from many languages.  http://libguestfs.org
#151 lore raw
Quoted 6 lines · Richard W.M. Jones

I started off a long reply here, but I think you're right. If we cannot make people decide on and use a proper disk image + metadata container, then it's also unlikely we'll get them to add sensible metadata to their qcow2 images either :-(

Rich.

But we can do it for them: ask how to run image, store it in the image forever.

Signature · 1 line
MST
#152 lore raw
In reply to Max Reitz
Quoted 2 lines · Max Reitz

Yeah, but why make qcow2 that format? That's what I completely fail to understand.

Because why not? It's cheap to add it there and is much easier than teaching people about a new container format.

Eric Blake put it very well I think. There are several things that several people would like to see addressed:

(1) A sensible list of guest visible aspects of the VM preserving which across VM restarts we deem critical enough to support starting guests.
At this point this includes at least architecture and machine type.

(2) A compact file format for serializing list (1)

(3) Ability to store file (2) in a qcow2 image

You are asking why store (2) in qcow2 image specifically. The answer is it's just one place where we can store it. The answer is we don't need to involve qemu-block at all for storing it in other places.

But for many people it will be handy to have it in the same file, and qcow2 is popular enough that many people will be well served if it's there.

Signature · 1 line
MT
#153 lore raw
Quoted 6 lines · Michael S. Tsirkin
Quoted 2 lines · Max Reitz

Yeah, but why make qcow2 that format? That's what I completely fail to understand.

Because why not? It's cheap to add it there and is much easier than teaching people about a new container format.

tar is not a new container format, but it is a new format to various toolchains - that said, if we popularize tar as the format for including a config file alongside a qcow2 image, it's not that hard to fix the stack to start passing that file around as the new preferred file type.

Quoted 8 lines

Eric Blake put it very well I think. There are several things that several people would like to see addressed:

(1) A sensible list of guest visible aspects of the VM preserving which across VM restarts we deem critical enough to support starting guests.
At this point this includes at least architecture and machine type.

This part is true no matter where we store it. So as I see it, the question is now whether to store it in qcow2, or whether to store qcow2 + config in a tar file.

Quoted 2 lines

(2) A compact file format for serializing list (1)

tar files already serve this purpose (even if we don't like the current OVA specification for the config side, it at least proves that tar files are usable in this manner)

Quoted 2 lines

(3) Ability to store file (2) in a qcow2 image

As Dan pointed out, if we can FIRST popularize storing a config file + qcow2 in a tar file, THEN we can (for convenience) let qcow2 directly store the same config file, if it helps things (although if popularizing tar files works, we wouldn't need it in qcow2).

Maybe the step we want to take now is to add a new block driver to qemu that supports tar files including resize. That is, where we currently do:

qcow2 -> posix file

we would instead popularize:

qcow2 -> tar driver -> posix file

where the tar driver takes care of finding the right subset within the overall tar file, AND makes it easy to resize (by updating tar metadata any time qcow2 wants to resize larger, and assuming qcow2 is the last member of the tar archive)

Perhaps we can even automate it so that the tar driver is automatically inserted even when not explicitly specified (after all, you can already start qemu by giving just the file name holding a qcow2 image, and qemu can figure out to use the qcow2 driver) - although we DO have to be careful of avoiding CVEs (probing image formats MUST NOT allow a guest to convert a raw image into something that qemu would treat as a tar, any more than it would misinterpret raw as qcow2)

Quoted 5 lines

You are asking why store (2) in qcow2 image specifically. The answer is it's just one place where we can store it. The answer is we don't need to involve qemu-block at all for storing it in other places.

Then why start with qcow2? Let's start with tar files, and enhance qemu-block to make tar files containing qcow2 easier to use in qemu (and NOT with making qcow2 larger just to bypass tar files).

Quoted 5 lines

But for many people it will be handy to have it in the same file, and qcow2 is popular enough that many people will be well served if it's there.

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org
#154 lore raw
Quoted 9 lines · Eric Blake
Quoted 6 lines · Michael S. Tsirkin
Quoted 2 lines · Max Reitz

Yeah, but why make qcow2 that format?  That's what I completely fail to understand.

Because why not? It's cheap to add it there and is much easier than teaching people about a new container format.

tar is not a new container format, but it is a new format to various toolchains - that said, if we popularize tar as the format for including a config file alongside a qcow2 image, it's not that hard to fix the stack to start passing that file around as the new preferred file type.

On a completely different front, 'qcow2' as a file format comes with some psychological baggage. If someone was using it 8 years ago, before we did coroutine optimizations, it was noticeably slower than raw, and relatively easier to get into a corrupted image condition that resulted in data loss. Just one VM lost, and it leaves a sour taste in your mouth, where you are unwilling to trust that file format (even though the file format was not necessarily the cause of the corruption). Marketing-wise, we failed with our improvements ('qcow2v3' is so much more of a mouthful than 'qcow3'), and it took years to flip the defaults from v2 as the default to v3 as the default (moreso in downstream distros than upstream), in part because we couldn't convince people of the improvements they would be gaining by moving to v3. Historically, there's also 'qed' which was promised as a way to fix some of the poor performance of qcow2, but which ended up not being any better than our actual qcow2v3 improvements, so no one ended up switching to that. So, to some extent, various high-level consumers still have the notion that 'raw' files are better/safer/faster than 'qcow2' files because of an anecdote from years ago, even if we have since fixed the speed parity and added locking to eliminate careless data loss.

If we DO add a new tar-file block driver to qemu, that could serve as a marketing opportunity to convince people that the new format has all of the features that you can't get from just a raw file, and does not suffer from the slowness or data corruption they were worried about in qcow2. Thus, even if our new format is just a thin wrapper around a config file plus the existing qcow2v3 we already know and love, the mere fact that it is a new format may get people to move away from raw images in situations where just the name 'qcow2' is unable to do so, at which point we can help them take advantage of the features made possible by qcow2.

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org
#155 lore raw

Hi,

Quoted 5 lines

our actual qcow2v3 improvements, so no one ended up switching to that. So, to some extent, various high-level consumers still have the notion that 'raw' files are better/safer/faster than 'qcow2' files because of an anecdote from years ago, even if we have since fixed the speed parity and added locking to eliminate careless data loss.

When I use raw images the reasons are different ones. Most of the time it is that I want use the image with something which isn't qemu and thus doesn't understand qcow2. Booting a image as container for example (systemd-nspawn -i $image.raw).

cheers,
Gerd

#156 lore raw
In reply to Michael S. Tsirkin
Quoted 6 lines · Michael S. Tsirkin
Quoted 2 lines · Max Reitz

Yeah, but why make qcow2 that format? That's what I completely fail to understand.

Because why not? It's cheap to add it there and is much easier than teaching people about a new container format.

"new" container format? qcow2 is not a container format, so that would be teaching people something new anyway.

Quoted 7 lines

Eric Blake put it very well I think. There are several things that several people would like to see addressed:

(1) A sensible list of guest visible aspects of the VM preserving which across VM restarts we deem critical enough to support starting guests.
At this point this includes at least architecture and machine type.

If you use a whole management layer, that is trivial anyway (and that seems to be Dave's assumption), because that management layer can store its configuration somewhere. Dave's issue was about downloading foreign images, not about restarts.

Quoted 1 line

(2) A compact file format for serializing list (1)

OK.

Quoted 1 line

(3) Ability to store file (2) in a qcow2 image

I see that people are asking this, yes, although I don't quite get the point.

Quoted 7 lines

You are asking why store (2) in qcow2 image specifically. The answer is it's just one place where we can store it. The answer is we don't need to involve qemu-block at all for storing it in other places.

But for many people it will be handy to have it in the same file, and qcow2 is popular enough that many people will be well served if it's there.

Note that I'm also asking why it needs to be a single file. Furthermore, I'm asking what the final scope is intended to be. I don't believe qcow2 to be the correct format for a whole appliance, but I do believe that assuming that people want to provide just a qcow2 file without anything else means already accepting it *is* an appliance. But Dave seems to reject that idea.

Max