qcow3 - arbitrary metadata
PATCH 1/1 qcow3 - arbitrary metadata
A project I'm working on requires the ability to store arbitrary metadata in the VM disk image. Thus, here is a patch that implements that as qcow3. It basically replaces the header.backing_store_{offset|size} with header.metadata_{offset|size}. Metadata is then defined as NULL-byte separated 'key:value' pairs. The attached qcow3 then stores the backing file as 'Backing-File:/home/me/backing_file.img' in the metadata section. I've included two patches. One is the full patch against the latest SVN (qcow3.patch). The second patch is just the diff between qcow2.c and qcow3.c so that you can easily see the changes.
I've also wondered if it might be possible to backport these changes into qcow2 instead of qcow3. However, this would break older versions of qemu that claim to support qcow2.
Nathaniel
Makefile +1 -1
@@ -42,7 +42,7 @@ BLOCK_OBJS=cutils.o qemu-malloc.o BLOCK_OBJS+=block-cow.o block-qcow.o aes.o block-vmdk.o block-cloop.o BLOCK_OBJS+=block-dmg.o block-bochs.o block-vpc.o block-vvfat.o -BLOCK_OBJS+=block-qcow2.o block-parallels.o block-nbd.o +BLOCK_OBJS+=block-qcow2.o block-parallels.o block-nbd.o block-qcow3.o ###################################################################### # libqemu_common.a: Target independent part of system emulation. The
block.c +2 -1
@@ -357,7 +357,7 @@get_tmp_filename (tmp_filename,sizeof (tmp_filename));realpath (filename, backing_filename); -if (bdrv_create (&bdrv_qcow2, tmp_filename, +if (bdrv_create (&bdrv_qcow3, tmp_filename, total_size, backing_filename,0 ) <0 ) {return -1 ; }
@@ -1333,6 +1333,7 @@bdrv_register (&bdrv_qcow2);bdrv_register (&bdrv_parallels);bdrv_register (&bdrv_nbd); +bdrv_register (&bdrv_qcow3); } void *qemu_aio_get(BlockDriverState *bs, BlockDriverCompletionFunc *cb,
block.h +1 -0
@@ -17,6 +17,7 @@extern BlockDriver bdrv_qcow2;extern BlockDriver bdrv_parallels;extern BlockDriver bdrv_nbd; +extern BlockDriver bdrv_qcow3; typedef struct BlockDriverInfo { /* in bytes, 0 if irrelevant */
qemu-img.c +2 -2
@@ -450,9 +450,9 @@ drv =bdrv_find_format (out_fmt);if (!drv)error ("Unknown file format '%s'" , out_fmt); -if (flags &BLOCK_FLAG_COMPRESS && drv != &bdrv_qcow && drv != &bdrv_qcow2) +if (flags &BLOCK_FLAG_COMPRESS && drv != &bdrv_qcow && drv != &bdrv_qcow2 && drv != &bdrv_qcow3)error ("Compression not supported for this file format" ); -if (flags &BLOCK_FLAG_ENCRYPT && drv != &bdrv_qcow && drv != &bdrv_qcow2) +if (flags &BLOCK_FLAG_ENCRYPT && drv != &bdrv_qcow && drv != &bdrv_qcow2 && drv != &bdrv_qcow3)error ("Encryption not supported for this file format" );if (flags &BLOCK_FLAG_COMPAT6 && drv != &bdrv_vmdk)error ("Alternative compatibility level not supported for this file format" );
block-qcow3.c +2260 -0
2,260 lines not on this page · raw message
block-qcow3.c renamed from block-qcow2.c +42 -34
149 lines not on this page · raw message
Quoted 1 line · Nathaniel McCallum
A project I'm working on requires the ability to store arbitrary metadata in the VM disk image. Thus, here is a patch that implements that as qcow3. It basically replaces the header.backing_store_{offset|size} with header.metadata_{offset|size}. Metadata is then defined as NULL-byte separated 'key:value' pairs. The attached qcow3 then stores the backing file as 'Backing-File:/home/me/backing_file.img' in the metadata section. I've included two patches. One is the full patch against the latest SVN (qcow3.patch). The second patch is just the diff between
qcow2.candqcow3.cso that you can easily see the changes.
Can you provide more information about what the metadata is used for and why it's so important for the metadata to be in the image verses in a separate file?
There are other possible ways of doing this that are less invasive. For instance, you could have a fake snapshot in the image that just contained your key values pairs.
Introducing a whole new format is a pretty big change especially since you're duplicating a ton of code.
Regards,
Anthony Liguori
Quoted 3 lines
I've also wondered if it might be possible to backport these changes into qcow2 instead of qcow3. However, this would break older versions of qemu that claim to support qcow2.
Nathaniel
Quoted 13 lines · Anthony Liguori
Quoted 10 lines · Nathaniel McCallum
A project I'm working on requires the ability to store arbitrary metadata in the VM disk image. Thus, here is a patch that implements that as qcow3.
It basically replaces the header.backing_store_{offset|size} with
header.metadata_{offset|size}. Metadata is then defined as NULL-byte separated 'key:value' pairs. The attached qcow3 then stores the backing file as 'Backing-File:/home/me/backing_file.img' in the metadata section.
I've included two patches. One is the full patch against the latest SVN
(qcow3.patch). The second patch is just the diff betweenqcow2.candqcow3.cso that you can easily see the changes.
Quoted 3 lines
Can you provide more information about what the metadata is used for and why it's so important for the metadata to be in the image verses in a separate file?
Ease of use primarily. Take the case of a VM appliance. I would build a VM appliance and in the metadata I would put:
1. My company's logo (which would show up as the icon on the file in any file browser)
2. All the correct config for how to make the VM implementation start this image
3. A first-run startup message with instructions
4. A click-through license agreement
The user would download and double-click a single file and the VM would start up, ask me to agree to a license, provide me the instructions on how to begin and just start running.
I could put all this in a separate file, but then the user would have to unzip it and how does the emulation platform know what to do, etc...
Quoted 7 lines
There are other possible ways of doing this that are less invasive. For instance, you could have a fake snapshot in the image that just contained your key values pairs.
Introducing a whole new format is a pretty big change especially since you're duplicating a ton of code.
I agree, a less invasive way would be preferred. However, how would you
create a hidden snapshot (so that qemu doesn't try to load it)? Perhaps modify qemu to ignore snapshots named ".hidden"?
Nathaniel
Quoted 9 lines
Ease of use primarily. Take the case of a VM appliance. I would build a VM appliance and in the metadata I would put:
1. My company's logo (which would show up as the icon on the file in any file browser)
2. All the correct config for how to make the VM implementation start this image
3. A first-run startup message with instructions
4. A click-through license agreement
Quoted 3 lines
The user would download and double-click a single file and the VM would start up, ask me to agree to a license, provide me the instructions on how to begin and just start running.
This is already broken because you're assuming a suitable version of qemu is preinstalled on the user's machine. Once you have to install qemu, you can just as easily install a frontend to provide whatever user interface you want.
All modern filesystems have things called "directories" or "folders" than be be used to group sets of related files.
Paul
Quoted 9 lines · Paul Brook
Quoted 9 lines
Ease of use primarily. Take the case of a VM appliance. I would build a VM appliance and in the metadata I would put:
1. My company's logo (which would show up as the icon on the file in any file browser)
2. All the correct config for how to make the VM implementation start this image
3. A first-run startup message with instructions
4. A click-through license agreement
Quoted 7 lines
Quoted 4 lines
The user would download and double-click a single file and the VM would start up, ask me to agree to a license, provide me the instructions on how to begin and just start running.
This is already broken because you're assuming a suitable version of qemu is preinstalled on the user's machine. Once you have to install qemu, you can just as easily install a frontend to provide whatever user interface you want.
If you want to distribute an appliance as a single image and you want to be able to instantly use it, I think you need something like an offset= parameter for the -drive option.
If you put everything in a tarball/zip file, you have to extract it first. You can make it a single-click operation, but you'll still have to wait for the disk to be extracted.
I don't think it's a strong enough use-case to warrant a whole new disk format, but some trickery with the current format could suffice.
Regards,
Anthony Liguori
Quoted 6 lines
All modern filesystems have things called "directories" or "folders" than be be used to group sets of related files.
Paul
Quoted 39 lines · Nathaniel McCallum
On Mon, Jul 28, 2008 at 4:08 PM, Anthony Liguori <[email protected] <mailto:[email protected]>> wrote:
Nathaniel McCallum wrote:
A project I'm working on requires the ability to store arbitrary metadata in the VM disk image. Thus, here is a patch that implements that as qcow3. It basically replaces the header.backing_store_{offset|size} with header.metadata_{offset|size}. Metadata is then defined as NULL-byte separated 'key:value' pairs. The attached qcow3 then stores the backing file as 'Backing-File:/home/me/backing_file.img' in the metadata section. I've included two patches. One is the full patch against the latest SVN (qcow3.patch). The second patch is just the diff between
qcow2.candqcow3.cso that you can easily see the changes.Can you provide more information about what the metadata is used for and why it's so important for the metadata to be in the image verses in a separate file?
Ease of use primarily. Take the case of a VM appliance. I would build a VM appliance and in the metadata I would put:
1. My company's logo (which would show up as the icon on the file in any file browser)
2. All the correct config for how to make the VM implementation start this image
3. A first-run startup message with instructions
4. A click-through license agreementThe user would download and double-click a single file and the VM would start up, ask me to agree to a license, provide me the instructions on how to begin and just start running.
I could put all this in a separate file, but then the user would have to unzip it and how does the emulation platform know what to do, etc...
There are other possible ways of doing this that are less invasive. For instance, you could have a fake snapshot in the image that just contained your key values pairs.
Quoted 6 lines
Introducing a whole new format is a pretty big change especially since you're duplicating a ton of code.
I agree, a less invasive way would be preferred. However, how would
you create a hidden snapshot (so that qemu doesn't try to load it)? Perhaps modify qemu to ignore snapshots named ".hidden"?
Something that would be pretty interesting, but also terribly hacky, would be to have an option that would allow one to use a disk with an offset. For instance:
qemu-system-x86_64 -drive file=foo.img,offset=4096,if=ide
Then you could have whatever stuff you wanted in the first 4096 of the disk image.
Regards,
Anthony Liguori
Quoted 2 lines
Nathaniel
Quoted 56 lines · Anthony Liguori
Nathaniel McCallum wrote:
On Mon, Jul 28, 2008 at 4:08 PM, Anthony Liguori <[email protected]<mailto:
Quoted 44 lines
[email protected]>> wrote:
Nathaniel McCallum wrote:
A project I'm working on requires the ability to store arbitrary metadata in the VM disk image. Thus, here is a patch that implements that as qcow3. It basically replaces the header.backing_store_{offset|size} with header.metadata_{offset|size}. Metadata is then defined as NULL-byte separated 'key:value' pairs. The attached qcow3 then stores the backing file as 'Backing-File:/home/me/backing_file.img' in the metadata section. I've included two patches. One is the full patch against the latest SVN (qcow3.patch). The second patch is just the diff between
qcow2.candqcow3.cso that you can easily see the changes.Can you provide more information about what the metadata is used for and why it's so important for the metadata to be in the image verses in a separate file?
Ease of use primarily. Take the case of a VM appliance. I would build a VM appliance and in the metadata I would put:
1. My company's logo (which would show up as the icon on the file in any file browser)
2. All the correct config for how to make the VM implementation start this image
3. A first-run startup message with instructions
4. A click-through license agreementThe user would download and double-click a single file and the VM would start up, ask me to agree to a license, provide me the instructions on how to begin and just start running.
I could put all this in a separate file, but then the user would have to unzip it and how does the emulation platform know what to do, etc...
There are other possible ways of doing this that are less invasive. For instance, you could have a fake snapshot in the image that just contained your key values pairs.
Quoted 8 lines
Introducing a whole new format is a pretty big change especially since you're duplicating a ton of code.
I agree, a less invasive way would be preferred. However, how would you
create a hidden snapshot (so that qemu doesn't try to load it)? Perhaps modify qemu to ignore snapshots named ".hidden"?
Quoted 6 lines
Something that would be pretty interesting, but also terribly hacky, would be to have an option that would allow one to use a disk with an offset. For instance:
qemu-system-x86_64 -drive file=foo.img,offset=4096,if=ide
I assume this technique is more "mergable"
Quoted 10 lines · Nathaniel McCallum
On Mon, Jul 28, 2008 at 4:50 PM, Anthony Liguori <[email protected] <mailto:[email protected]>> wrote:
Something that would be pretty interesting, but also terribly hacky, would be to have an option that would allow one to use a disk with an offset. For instance:
qemu-system-x86_64 -drive file=foo.img,offset=4096,if=ide
I assume this technique is more "mergable"
Than forking the qcow format? Definitely, although I'm not convinced there isn't a better way to do it that is even less hacky.
Regards,
Anthony Liguori
Quoted 9 lines · Anthony Liguori
Quoted 7 lines · Nathaniel McCallum
On Mon, Jul 28, 2008 at 4:50 PM, Anthony Liguori <[email protected]<mailto:
[email protected]>> wrote:Something that would be pretty interesting, but also terribly hacky, would be to have an option that would allow one to use a disk with an offset. For instance:
Quoted 9 lines
Quoted 5 lines
qemu-system-x86_64 -drive file=foo.img,offset=4096,if=ideI assume this technique is more "mergable"
Than forking the qcow format? Definitely, although I'm not convinced there isn't a better way to do it that is even less hacky.
I'd love to know what that other option could be. Adding an offset option
is going to touch a lot of files...
Quoted 16 lines · Nathaniel McCallum
On Mon, Jul 28, 2008 at 5:17 PM, Anthony Liguori <[email protected] <mailto:[email protected]>> wrote:
Nathaniel McCallum wrote:
On Mon, Jul 28, 2008 at 4:50 PM, Anthony Liguori <[email protected] <mailto:[email protected]> <mailto:[email protected] <mailto:[email protected]>>> wrote:
Something that would be pretty interesting, but also terribly hacky, would be to have an option that would allow one to use a disk with an offset. For instance:
qemu-system-x86_64 -drive file=foo.img,offset=4096,if=ide
Quoted 8 lines
I assume this technique is more "mergable"
Than forking the qcow format? Definitely, although I'm not convinced there isn't a better way to do it that is even less hacky.
I'd love to know what that other option could be. Adding an offset option is going to touch a lot of files...
Actually, it wouldn't. You just need to modify the RAW block driver to add an offset to any of the operations that would seek within the file. There's no clear way to pass individual arguments to a particular block format though so that would make it somewhat hairy.
Regards,
Anthony Liguori
Quoted 3 lines · Anthony Liguori
Can you provide more information about what the metadata is used for and why it's so important for the metadata to be in the image verses in a separate file?
Yeah, I have the opposite problem - too much in the same file :-)
I want to be able to savevm, but some of my VMs don't have any qcow2 images (because I don't trust them for mission-critical VMs since recent discussion, or because they are floppy-only or CD-only VMs with no hard disk).
To enable savevm, at least according to docs, I have to have a qcow2 image somewhere. So I add a redundant minimum-size unpartitioned qcow2 hard disk and hope nobody minds...
That seems a bit hackish. It would be nice if savevm could just write to a named file and loadvm could read it.
-- Jamie
Quoted 12 lines · Jamie Lokier
Quoted 3 lines · Anthony Liguori
Can you provide more information about what the metadata is used for and why it's so important for the metadata to be in the image verses in a separate file?
Yeah, I have the opposite problem - too much in the same file :-)
I want to be able to savevm, but some of my VMs don't have any qcow2 images (because I don't trust them for mission-critical VMs since recent discussion, or because they are floppy-only or CD-only VMs with no hard disk).
Quoted 6 lines
To enable savevm, at least according to docs, I have to have a qcow2 image somewhere. So I add a redundant minimum-size unpartitioned qcow2 hard disk and hope nobody minds...
That seems a bit hackish. It would be nice if savevm could just write to a named file and loadvm could read it.
I think this brings us to the main conceptual point of the discussion:
what does an image file represent? I am now partial to the idea that an image file is nothing more than the representation of some kind of storage device. It's not meant, IMHO, to be the representation of an entire machine.
As Laurent pointed out, he and I proposed and coded a (quite hackish) way of storing command-line options in qcow2 image files, which used empty qcow2 snapshots. This was Avi's original suggestion to make image files self-contained. The goal of this approach was to have a quick and easy way to avoid the QEMU command-line. The use case was to replace launch scripts, not to replace tools as libvirt and virt-manager. A lengthy discussion followed the patches and my conclusion was that there were many valid objections to our approach, but more than that, there were many strong opinions on what the best way to achieve this was.
I remember Anthony Liguori proposing another way of having self-contained images, though I don't remember the particulars of his approach right now. As Laurent also mentions, Fabrice has proposed a configuration file format which I think is a good way of solving the problem. Personally, I just want to have some way of avoiding the command-line options that doesn't involve scripts.
Anyways, the point that I was trying to make was that a good solution would separate concerns: the image file is the disk, the configuration file (in this case) represents the machine. Looking back, I think that storing command-line options in an empty qcow2 snapshot was a quick hack, without much conceptual integrity. I won't deny it, thought, it was extremely useful.
As Jamie exemplifies, storing everything in the image file can be inflexible for some use cases. IMHO, a "virtual appliance" format would bundle an image file and some other configuration files, but that would possibly not be a part of QEMU itself.
Regards,
Jorge
Quoted 52 lines · Jorge Lucángeli Obes
Quoted 12 lines · Jamie Lokier
Quoted 3 lines · Anthony Liguori
Can you provide more information about what the metadata is used for and why it's so important for the metadata to be in the image verses in a separate file?
Yeah, I have the opposite problem - too much in the same file :-)
I want to be able to savevm, but some of my VMs don't have any qcow2 images (because I don't trust them for mission-critical VMs since recent discussion, or because they are floppy-only or CD-only VMs with no hard disk).
Quoted 6 lines
To enable savevm, at least according to docs, I have to have a qcow2 image somewhere. So I add a redundant minimum-size unpartitioned qcow2 hard disk and hope nobody minds...
That seems a bit hackish. It would be nice if savevm could just write to a named file and loadvm could read it.
I think this brings us to the main conceptual point of the discussion:
what does an image file represent? I am now partial to the idea that an image file is nothing more than the representation of some kind of storage device. It's not meant, IMHO, to be the representation of an entire machine.As Laurent pointed out, he and I proposed and coded a (quite hackish) way of storing command-line options in qcow2 image files, which used empty qcow2 snapshots. This was Avi's original suggestion to make image files self-contained. The goal of this approach was to have a quick and easy way to avoid the QEMU command-line. The use case was to replace launch scripts, not to replace tools as libvirt and virt-manager. A lengthy discussion followed the patches and my conclusion was that there were many valid objections to our approach, but more than that, there were many strong opinions on what the best way to achieve this was.
I remember Anthony Liguori proposing another way of having self-contained images, though I don't remember the particulars of his approach right now. As Laurent also mentions, Fabrice has proposed a configuration file format which I think is a good way of solving the problem. Personally, I just want to have some way of avoiding the command-line options that doesn't involve scripts.
Anyways, the point that I was trying to make was that a good solution would separate concerns: the image file is the disk, the configuration file (in this case) represents the machine. Looking back, I think that storing command-line options in an empty qcow2 snapshot was a quick hack, without much conceptual integrity. I won't deny it, thought, it was extremely useful.
Quoted 5 lines
As Jamie exemplifies, storing everything in the image file can be inflexible for some use cases. IMHO, a "virtual appliance" format would bundle an image file and some other configuration files, but that would possibly not be a part of QEMU itself.
I'm not disagreeing, but it is really interesting that something that is "extremely useful" is rejected for lacking "conceptual integrity". I don't have any numbers, but I suspect the most common use case of virtualization is one image file, one configuration and no snapshots. Yet most virtualization solutions go for those designs which have "conceptual integrity" but are far more complex than needed by the majority of users (*cough*VMWare API*cough*). I think those features are important and I don't want to cut them. I just think there should be some way to optimize the user experience for the most common case without sacrificing the rest of the features.
Nathaniel
Quoted 5 lines · Nathaniel McCallum
On Mon, Jul 28, 2008 at 10:11 PM, Jorge Lucángeli Obes <[email protected]>
Quoted 2 lines
problem. Personally, I just want to have some way of avoiding the command-line options that doesn't involve scripts.
Quoted 10 lines
I'm not disagreeing, but it is really interesting that something that is "extremely useful" is rejected for lacking "conceptual integrity". I don't have any numbers, but I suspect the most common use case of virtualization is one image file, one configuration and no snapshots. Yet most virtualization solutions go for those designs which have "conceptual integrity" but are far more complex than needed by the majority of users (*cough*VMWare API*cough*). I think those features are important and I don't want to cut them. I just think there should be some way to optimize the user experience for the most common case without sacrificing the rest of the features.
I agree with your most common use case (which is incidentally my use case), but I also think that the best way of serving that use case is with an image file and a configuration file. As I see it, in that use case, anything better than command-line options and scripts holding them, is "extremely useful" - that's the point I was trying to make. qcow2 snapshots were kind of a quick hack, a configuration file seems more coherent.
Regards,
Jorge
Quoted 10 lines · Jamie Lokier
Quoted 2 lines · Anthony Liguori
Can you provide more information about what the metadata is used for and why it's so important for the metadata to be in the image verses in a separate file?
Yeah, I have the opposite problem - too much in the same file :-)
I want to be able to savevm, but some of my VMs don't have any qcow2 images (because I don't trust them for mission-critical VMs since recent discussion,
How do you snapshot the disk images?
Quoted 10 lines
or because they are floppy-only or CD-only VMs with
no hard disk).To enable savevm, at least according to docs, I have to have a qcow2 image somewhere. So I add a redundant minimum-size unpartitioned qcow2 hard disk and hope nobody minds...
That seems a bit hackish. It would be nice if savevm could just write to a named file and loadvm could read it.
I'm in the process of cleaning up the live migration code from KVM for QEMU. It works quite happily right now, I'm just reorganizing some things.
In the process, I hope to introduce a checkpoint command which provides a live snapshotting mechanism. I think there is certainly room for discussion about whether you should be able to snapshot/savevm to a file besides snapshotting to a qcow2 file.
I think snapshotting to a pipe is actually a really interesting use-case myself for a variety of applications.
Regards,
Anthony Liguori
Quoted 4 lines
-- Jamie
Quoted 7 lines · Anthony Liguori
Quoted 5 lines
Yeah, I have the opposite problem - too much in the same file :-)
I want to be able to savevm, but some of my VMs don't have any qcow2 images (because I don't trust them for mission-critical VMs since recent discussion,
How do you snapshot the disk images?
Does savevm snapshot the disk images too? I thought it was just the machine state. Does that mean non-qcow2 disks (e.g. raw files) are not snapshotted but qcow2 ones are, in the same VM?
It's actually just the machine state I want to save. I want to use savevm to save the state of the VM before quitting, and loadvm to restart. Like suspend-to-RAM, but doesn't require the guest to cooperate. (Does suspend work anyway?)
Quoted 5 lines
Quoted 2 lines
That seems a bit hackish. It would be nice if savevm could just write to a named file and loadvm could read it.
I'm in the process of cleaning up the live migration code from KVM for QEMU. It works quite happily right now, I'm just reorganizing some things.
Excellent, KVM's migration makes a lot of sense in QEMU. Thank you.
Quoted 4 lines
In the process, I hope to introduce a checkpoint command which provides a live snapshotting mechanism. I think there is certainly room for discussion about whether you should be able to snapshot/savevm to a file besides snapshotting to a qcow2 file.
Another thing I wanted, but gave up on, was non-destructive work in a VM, and if I like the work, commit it *without* pausing the VM for ages.
What typically happens is I use -snapshot or branch a temporary qcow2 off my main disk image. That's all fine.
Then I do 'commit' in the monitor when I'm happy with my changes, and the VM pauses for a long time while it writes back the changes.
Even just a few minutes work in Windows XP translates to a large number of megabytes of changes to write back, it takes a while.
What I'd like is -snapshot or temporary qcow2 branch, and 'async_commit' which is my way of saying "I'm happy with the work done so far, commit it, but I'd like to carry on working".
It would need to be atomic to be safe, I guess, and that begs for a new qcow format. I'm dabbling with database backends for another project at the moment, who knows, watch this space.
-- Jamie
Quoted 4 lines · Jamie Lokier
Quoted 2 lines · Anthony Liguori
Quoted 2 lines
Yeah, I have the opposite problem - too much in the same file :-)
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
I want to be able to savevm, but some of my VMs don't have any qcow2 images (because I don't trust them for mission-critical VMs since recent discussion,
How do you snapshot the disk images?
Does savevm snapshot the disk images too?
Yes.
Quoted 4 lines
I thought it was just the
machine state. Does that mean non-qcow2 disks (e.g. raw files) are not snapshotted but qcow2 ones are, in the same VM?
Raw files cannot be snapshotted.
Quoted 5 lines
It's actually just the machine state I want to save. I want to use savevm to save the state of the VM before quitting, and loadvm to restart. Like suspend-to-RAM, but doesn't require the guest to cooperate. (Does suspend work anyway?)
If you do that, you risk having your disk in an improper state. If there are any changes to the disk after you do your savevm, they will not be present after you loadvm. This could cause very subtle data corruption within your file system.
Regards,
Anthony Liguori
Quoted 3 lines · Anthony Liguori
Quoted 1 line
Does savevm snapshot the disk images too?
Yes.
Bah, annoying.
Quoted 5 lines
Quoted 3 lines
I thought it was just the
machine state. Does that mean non-qcow2 disks (e.g. raw files) are not snapshotted but qcow2 ones are, in the same VM?Raw files cannot be snapshotted.
I don't want to :-)
But I do want a consistent vM. According to QEMU docs, you can savevm if there's at least one qcow2 disk image. Does that mean it saves _just_ the state of that disk, or all the qcow2 disks which are attached (e.g. C: drive, D: drive, E: drive)?
Quoted 9 lines
Quoted 5 lines
It's actually just the machine state I want to save. I want to use savevm to save the state of the VM before quitting, and loadvm to restart. Like suspend-to-RAM, but doesn't require the guest to cooperate. (Does suspend work anyway?)
If you do that, you risk having your disk in an improper state. If there are any changes to the disk after you do your savevm, they will not be present after you loadvm. This could cause very subtle data corruption within your file system.
The CPU is stopped before calling savevm And when restarting, the CPU is stopped with -S first, then loadvm, then the CPU is started.
So no disk corruption - assuming QEMU doesn't keep dirty cached sectors in its process after savevm returns.
-- Jamie
Quoted 12 lines · Jamie Lokier
Quoted 3 lines · Anthony Liguori
Can you provide more information about what the metadata is used for and why it's so important for the metadata to be in the image verses in a separate file?
Yeah, I have the opposite problem - too much in the same file :-)
I want to be able to savevm, but some of my VMs don't have any qcow2 images (because I don't trust them for mission-critical VMs since recent discussion, or because they are floppy-only or CD-only VMs with no hard disk).
Quoted 6 lines
To enable savevm, at least according to docs, I have to have a qcow2 image somewhere. So I add a redundant minimum-size unpartitioned qcow2 hard disk and hope nobody minds...
That seems a bit hackish. It would be nice if savevm could just write to a named file and loadvm could read it.
In libvirt we implement what I call 'unmanaged' save/restore to arbitrary files. We intend to add the QEMU style 'managed' save/restore to the disk image too. For the former we actually make use of the 'migrate' command - we just migrate to/from a local file :-) It works pretty nicely, so once Anthony gets KVM's migration support ported to plain QEMU i'd recommend using that technique - conceivably we could have a simple monitor command for making it easier to use in this scenario
Daniel
Signature · 4 lines
|: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
Quoted 6 lines · Nathaniel McCallum
A project I'm working on requires the ability to store arbitrary metadata in the VM disk image. Thus, here is a patch that implements that as qcow3. It basically replaces the header.backing_store_{offset|size} with header.metadata_{offset|size}. Metadata is then defined as NULL-byte separated 'key:value' pairs. The attached qcow3 then stores the backing file as 'Backing-File:/home/me/backing_file.img' in the metadata section. I've included two patches. One is the full patch against the latest SVN (qcow3.patch). The second patch is just the diff between
qcow2.candqcow3.cso that you can easily see the changes.I've also wondered if it might be possible to backport these changes into qcow2 instead of qcow3. However, this would break older versions of qemu that claim to support qcow2.
Nathaniel
<qcow3.patch><qcow2-qcow3.patch>
I think this has already been tried exactly one year ago modifying snapshot...
http://www.mail-archive.com/[email protected]/msg05103.html
but now Fabrice is working on a configuration file, perhaps you can store your metadata in it.
Cheers,
Laurent
----------------------- Laurent Vivier ---------------------- "The best way to predict the future is to invent it."
- Alan Kay
Quoted 21 lines · Laurent Vivier
Le 28 juil. 08 à 21:56, Nathaniel McCallum a écrit :
A project I'm working on requires the ability to store arbitrary metadata
Quoted 9 lines
in the VM disk image. Thus, here is a patch that implements that as qcow3.
It basically replaces the header.backing_store_{offset|size} with
header.metadata_{offset|size}. Metadata is then defined as NULL-byte separated 'key:value' pairs. The attached qcow3 then stores the backing file as 'Backing-File:/home/me/backing_file.img' in the metadata section.
I've included two patches. One is the full patch against the latest SVN
(qcow3.patch). The second patch is just the diff betweenqcow2.candqcow3.cso that you can easily see the changes.Quoted 7 lines
I've also wondered if it might be possible to backport these changes into qcow2 instead of qcow3. However, this would break older versions of qemu that claim to support qcow2.
Nathaniel
<qcow3.patch><qcow2-qcow3.patch>
Quoted 8 lines
I think this has already been tried exactly one year ago modifying snapshot...
http://www.mail-archive.com/[email protected]/msg05103.html
but now Fabrice is working on a configuration file, perhaps you can store your metadata in it.
Well, the point is to not have a separate configuration file.
I've dug up a few more bits of info. First, the offset option will never work without changing at least qcow2's on disk format. This is because when you start qemu in snapshot mode, it creates a new qcow2 image and uses it as the main image. However, the offset was meant to apply to the underlying image and there is no field in qcow2 to specify the offset of the backing_file.
Second, when creating a new qcow2 file, the l1_table_offset is 4096. There does not appear to be anything stored between the end of the header and the 4096. So, in theory, you could put anything you want there. No?
Nathaniel
Quoted 31 lines · Nathaniel McCallum
On Mon, Jul 28, 2008 at 7:04 PM, Laurent Vivier <[email protected] <mailto:[email protected]>> wrote:
Le 28 juil. 08 à 21:56, Nathaniel McCallum a écrit :
A project I'm working on requires the ability to store arbitrary metadata in the VM disk image. Thus, here is a patch that implements that as qcow3. It basically replaces the header.backing_store_{offset|size} with header.metadata_{offset|size}. Metadata is then defined as NULL-byte separated 'key:value' pairs. The attached qcow3 then stores the backing file as 'Backing-File:/home/me/backing_file.img' in the metadata section. I've included two patches. One is the full patch against the latest SVN (qcow3.patch). The second patch is just the diff between
qcow2.candqcow3.cso that you can easily see the changes.I've also wondered if it might be possible to backport these changes into qcow2 instead of qcow3. However, this would break older versions of qemu that claim to support qcow2.
Nathaniel
<qcow3.patch><qcow2-qcow3.patch>I think this has already been tried exactly one year ago modifying snapshot...
Quoted 7 lines
but now Fabrice is working on a configuration file, perhaps you can store your metadata in it.
Well, the point is to not have a separate configuration file.
I've dug up a few more bits of info. First, the offset option will never work without changing at least qcow2's on disk format.
Never is such a strong word. What I was thinking is that you could do the offset thing based on a URI of some sort. For instance:
qemu -drive file=offset:foo.img:offset=32,if=ide
The syntax of -drive erks me here but you get the gist. Then backing files would work fine.
Quoted 4 lines
This is because when you start qemu in snapshot mode, it creates a
new qcow2 image and uses it as the main image. However, the offset was meant to apply to the underlying image and there is no field in qcow2 to specify the offset of thebacking_file.Second, when creating a new qcow2 file, the
l1_table_offsetis 4096. There does not appear to be anything stored between the end of the header and the 4096. So, in theory, you could put anything you want there. No?
There's no guarantee that that space won't be used in future versions of QCOW2 so you can't just cram arbitrary stuff in there.
Regards,
Anthony Liguori
Quoted 2 lines
Nathaniel
Quoted 8 lines · Anthony Liguori
Quoted 5 lines · Nathaniel McCallum
Well, the point is to not have a separate configuration file.
I've dug up a few more bits of info. First, the offset option will never work without changing at least qcow2's on disk format.
Quoted 7 lines
Never is such a strong word. What I was thinking is that you could do the offset thing based on a URI of some sort. For instance:
qemu -drive file=offset:foo.img:offset=32,if=ide
The syntax of -drive erks me here but you get the gist. Then backing files would work fine.
It won't work... See lines 339-366 of block.c.
Quoted 9 lines
This is because when you start qemu in snapshot mode, it creates a new
qcow2 image and uses it as the main image. However, the offset was meant to apply to the underlying image and there is no field in qcow2 to specify the offset of thebacking_file.Second, when creating a new qcow2 file, the
l1_table_offsetis 4096. There does not appear to be anything stored between the end of the header and the 4096. So, in theory, you could put anything you want there. No?
There's no guarantee that that space won't be used in future versions of
Quoted 2 lines
QCOW2 so you can't just cram arbitrary stuff in there.
Yeah, I'm thinking "Could we just add metadata_{offset|size} to the end of QCOW2 and maintain compatibility?"
Nathaniel
For what it's worth from an outsider, imho in-band singnalling (which is what arbitrary meta-data is) is bone-headed.
It's the same reason extended attributes are stupid.
You are going to poison your file format because you think command line arguments are cumbersome. You're then going to need a set of extra tools to modify said metadata, you wont be able to use the standard set of tools sed/grep/awk/ed to change them. You're going to have to add code to parse them and over-ride them; for what ? Because you think a script is untidy.
Plus, for all your talk about the subject you could have coded it up by now!
Plus la change.
Matt
and you're *still* going to need a script / cmd line to specify the offset !
Quoted 11 lines · Nathaniel McCallum
On Mon, Jul 28, 2008 at 7:04 PM, Laurent Vivier <[email protected]> wrote:
Le 28 juil. 08 à 21:56, Nathaniel McCallum a écrit :
A project I'm working on requires the ability to store arbitrary metadata in the VM disk image. Thus, here is a patch that implements that as qcow3. It basically replaces the header.backing_store_{offset|size} with header.metadata_{offset|size}. Metadata is then defined as NULL-byte separated 'key:value' pairs. The attached qcow3 then stores the backing file as 'Backing-File:/home/me/backing_file.img' in the metadata section. I've included two patches. One is the full patch against the latest SVN (qcow3.patch). The second patch is just the diff between
qcow2.candqcow3.cso that you can easily see the changes.I've also wondered if it might be possible to backport these changes into qcow2 instead of qcow3. However, this would break older versions of qemu that claim to support qcow2.
Nathaniel
<qcow3.patch><qcow2-qcow3.patch>
Quoted 7 lines
I think this has already been tried exactly one year ago modifying snapshot...
http://www.mail-archive.com/[email protected]/msg05103.html
but now Fabrice is working on a configuration file, perhaps you can store your metadata in it.
Well, the point is to not have a separate configuration file.
put all you need in a tar file (including qcow2 file, configuration file, description file, ...), write a block-tar.c and access disk data through block-tar instead of block-raw.
Regards,
Lauren
----------------------- Laurent Vivier ---------------------- "The best way to predict the future is to invent it."
- Alan Kay