Skip to contentSkip to conversation

Making qemu images executable (and store command line arguments in them =P)

Qemu-devel Ben Taylor 6 participants 8 messages Aug 16, 2007 – Aug 19, 2007 2 messages not in the archive KVM

lore
Share & tools
lore

Ben Taylor

author
#0 lore raw
Quoted 11 lines · ---- "Jorge Lucángeli Obes

I've been giving some thought to Anthony's idea:

http://kvm.qumranet.com/kvmwiki/Specs/StoringCommandLineInImage

However, maybe I'm just too much on vacations, but I don't seem to come up with a nice way of doing this. Everything keeps coming back to creating a new 'container' image format and then implementing block layer functions that only add the number of sectors occupied by the command-line to the read and write calls made by QEMU, and then just relay those calls to the image-specific functions. That doesn't sound very efficient.

No, and it fundamentally breaks using a real disk with QEMU.

Quoted 2 lines

The '#!' trick works nice with scripts, but I don't see it playing very well with images. ¿Comments? ¿Pointers?

Personally, I'm not sure why we wouldn't just write out the command line data to a file tied to the primary image file, with some kind of time stamp to correlate the data from the command line and the last updated time of the primary image file. It's intuitive, and doesn't require a bucket of programming to make work. The down side is if qemu crashes, the time stamp between the parameter file and the image file may indicate the potential for "difference", but this can just be a notice (just as snapshots used to do with the image files in 0.7.x)

The only hard part here is when a real physical disk is used with QEMU since it's harder to make sure the name is valid.

Thoughts?

Ben

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
kvm-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/kvm-devel

#2 lore raw
In reply to a message not in the archive
Quoted 2 lines · Ben Taylor

Personally, I'm not sure why we wouldn't just write out the command line data to a file tied to the primary image file

What about a compatible change to the file format: the last 1024 bytes are either undefined, or, if a certain marker is present, an executable commandline? (I was going to say one standard sector, then I thought of how quickly i18n filenames add up.)

This is metadata, I have a feeling that if we think about it there will be quite a lot of other metadata we'd like to store with the image.

Quoted 2 lines

with some kind of time stamp to correlate the data from the command line and the last updated time of the primary image file.

If there have to be separate files I'd prefer a weak hash to timestamps to avoid the common problems with unexpected drift and no way to calculate which changed and why.

Signature · 8 lines
Dan Shearer
[email protected]

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
#3 lore raw
In reply to a message not in the archive
Quoted 15 lines · Ben Taylor
Quoted 4 lines · ---- "Jorge Lucángeli Obes

I've been giving some thought to Anthony's idea:

http://kvm.qumranet.com/kvmwiki/Specs/StoringCommandLineInImage

Quoted 8 lines

However, maybe I'm just too much on vacations, but I don't seem to come up with a nice way of doing this. Everything keeps coming back to creating a new 'container' image format and then implementing block layer functions that only add the number of sectors occupied by the command-line to the read and write calls made by QEMU, and then just relay those calls to the image-specific functions. That doesn't sound very efficient.

Quoted 3 lines

No, and it fundamentally breaks using a real disk with QEMU.

Why? It's optional.

Quoted 4 lines
Quoted 3 lines

The '#!' trick works nice with scripts, but I don't see it playing very well with images. ¿Comments? ¿Pointers?

Quoted 9 lines

Personally, I'm not sure why we wouldn't just write out the command line data to a file tied to the primary image file, with some kind of time stamp to correlate the data from the command line and the last updated time of the primary image file. It's intuitive, and doesn't require a bucket of programming to make work. The down side is if qemu crashes, the time stamp between the parameter file and the image file may indicate the potential for "difference", but this can just be a notice (just as snapshots used to do with the image files in 0.7.x)

It's not easy to use: if you move the image, you need to move the file. I'd like to have exactly one entity to worry about when using a virtual machine.

Signature · 12 lines
Do not meddle in the internals of kernels, for they are subtle and quick to panic.


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
kvm-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/kvm-devel
#4 lore raw
Quoted 3 lines · Avi Kivity

It's not easy to use: if you move the image, you need to move the file. I'd like to have exactly one entity to worry about when using a virtual machine.

As I wrote previously, there is already such a thing on every modern operating system, one entity that can be used to wrap several others: it's a directory. Putting things together into a directory, and then treating that directory as a single entity, is a tried and tested technique (in particular in NeXTStep and its successors, up to and including Mac OS X).

Simply put, I think that it makes excellent sense to keep the data (disk image) and the metadata (qemu configuration) separate, at least in this particular case where keeping the data separate makes it more easily reusable. Specifically, disk images that are simply disk images are much more likely to be usable by more than one emulator / virtual machine, than some other file format that combines a disk image with some metadata that is going to be fundamentally non-portable and indeed specific to one emulator or vm.

As I see it, the easiest and most portable thing to do is to define a simple file format that qemu can use for its configuration. Place the configuration file and the associated disk image(s) together in the same directory, and you have created a single entity that includes both the data and the metadata. Add a little bit of functionality to the emulatir, such that if it is given as a suitable argument the name of a directory, then look for the configuration file at a specific name in that directory, and only allow references from that config file to other files in that directory (thus enforcing the encapsulation). Now you have a system where you can either keep things completely manual (specify everything on the command line, automated but separate (specify the configuration file and have it explicitly reference full paths) or automated and encapsulated (data and metadata all kept together in a single container). And all of this without having to change the formats of any existing files, all without introducing any backwards incompatibility.

One thing that would be useful would be if there were some portable way of describing the machine you are trying to virtualize or emulate. This could then be read by various different virtual machines / emulators. Such a portable description might be possible to embed in a disk image. However, it would take some doing to construct such a standard and indeed get it accepted by a significant fraction of the emulators / virtual machines in the marketplace today.

So to summarize, my preferred solution would be:
1) Define a configuration file format
2) Make the program allow specifying a directory as the virtual machine, in which case the configuration is read from and data are kept in that directory

Best wishes,

// Christian Brunschen

#6 lore raw
In reply to a message not in the archive
Quoted 7 lines · Christian Brunschen
Quoted 3 lines · Avi Kivity

It's not easy to use: if you move the image, you need to move the file. I'd like to have exactly one entity to worry about when using a virtual machine.

Quoted 6 lines

As I wrote previously, there is already such a thing on every modern operating system, one entity that can be used to wrap several others: it's a directory. Putting things together into a directory, and then treating that directory as a single entity, is a tried and tested technique (in particular in NeXTStep and its successors, up to and including Mac OS X).

Simply put, I think that it makes excellent sense to keep the data (disk image) and the metadata (qemu configuration) separate, at least in this particular case where keeping the data separate makes it more easily reusable. Specifically, disk images that are simply disk images are much more likely to be usable by more than one emulator / virtual machine, than some other file format that combines a disk image with some metadata that is going to be fundamentally non-portable and indeed specific to one emulator or vm.

As I see it, the easiest and most portable thing to do is to define a simple file format that qemu can use for its configuration. Place the configuration file and the associated disk image(s) together in the same directory, and you have created a single entity that includes both the data and the metadata. Add a little bit of functionality to the emulatir, such that if it is given as a suitable argument the name of a directory, then look for the configuration file at a specific name in that directory, and only allow references from that config file to other files in that directory (thus enforcing the encapsulation). Now you have a system where you can either keep things completely manual (specify everything on the command line, automated but separate (specify the configuration file and have it explicitly reference full paths) or automated and encapsulated (data and metadata all kept together in a single container). And all of this without having to change the formats of any existing files, all without introducing any backwards incompatibility.

It does make a lot of sense. The only drawbacks I can find are:
- you can't directly execute the directory
- this deviates from standard Unix (and Windows) practice. Arguably the OS X way is superior, but qemu is perhaps not the best vehicle to introduce it to other OSes.

While this implementation won't be my first choice, I find it acceptable and good enough for my use case.

Signature · 1 line
error compiling committee.c: too many arguments to function
#7 lore raw

Am 19.08.2007 um 12:35 schrieb Avi Kivity:

Quoted 2 lines

- this deviates from standard Unix (and Windows) practice.
Arguably the OS X way is superior, but qemu is perhaps not the best vehicle to introduce it to other OSes.

NeXTstep introduced this into the Unix world and GNUstep uses it today. So, there's prior art.

Markus

- - - - - - - - - - - - - - - - - - -
Dipl. Ing. Markus Hitter
http://www.jump-ing.de/

#8 lore raw
Quoted 10 lines · Markus Hitter

Am 19.08.2007 um 12:35 schrieb Avi Kivity:

Quoted 3 lines

- this deviates from standard Unix (and Windows) practice.
Arguably the OS X way is superior, but qemu is perhaps not the best vehicle to introduce it to other OSes.

NeXTstep introduced this into the Unix world and GNUstep uses it today. So, there's prior art.

Nothing on my machine uses it today, as far as I can tell.

(I don't oppose this use in Linux -- I think it's an excellent way to package apps -- but I'm not sure qemu should be the first app to do this. It needs buy-in from distros)

((but we're actually talking about something slightly different; packaging data vs packaging apps))

Signature · 1 line
error compiling committee.c: too many arguments to function
#9 lore raw
Quoted 6 lines · Avi Kivity
Quoted 5 lines · Markus Hitter

Am 19.08.2007 um 12:35 schrieb Avi Kivity:

Quoted 2 lines

- this deviates from standard Unix (and Windows) practice.
Arguably the OS X way is superior, but qemu is perhaps not the best vehicle to introduce it to other OSes.

Quoted 7 lines
Quoted 1 line

NeXTstep introduced this into the Unix world and GNUstep uses it today. So, there's prior art.

Nothing on my machine uses it today, as far as I can tell.

(I don't oppose this use in Linux -- I think it's an excellent way to package apps -- but I'm not sure qemu should be the first app to do this. It needs buy-in from distros)

((but we're actually talking about something slightly different; packaging data vs packaging apps))

This has been the preferred way to package _any_ 'bundle' of data, whether it be an application, a framework, a rich-text file with images (the '.rtfd' format), since its introduction in NeXTStep, and ever since then it has been and remains the preferred way in OPENSTEP, Mac OS X, and GNUStep.

There is *ample* precedent, so qemu would not be the first app on Linux or on any other Unix either. Remember also that OpenStep was available for Solaris for a while, and that NeXT/Apple's WebObjects, which included a development environment and various applications, also ran on Solaris, HP-UX and even on Windows NT and 2000. So this NeXT/Apple-style bundling of related files into a directory which is then treated as a single unit has been used successfully on a wide variety of systems, including Linux and any other plaftorm that can run GNUStep, as well as various Unixen and Windows. And I am talking about this very much in the sense of packaging *data*, not 'just' applications.

So there is ample precedent, it is a successfully and widely used idea that has been previously successully used on multiple platforms, and in fact is the standard on the most widely used unix today (Mac OS X).

Plus, there's ample precedent for similar things: Many administrators keep various interconnected configuration files for (for instance) apache in a directory that is apache-configuration-specific, effectively treating 'apache configuration' as a single unit with multiple parts - the parts (configuration files for specific aspects) being bundled together in a directory to show the fact that they are a unit and do belong together.

Best wishes,

// Christian Brunschen