[Libvir] Relative paths in domain XML

Daniel P. Berrange berrange at redhat.com
Sun Apr 13 15:16:15 UTC 2008

On Sun, Apr 13, 2008 at 09:28:59AM +0100, Richard W.M. Jones wrote:
> What would be really useful is to allow paths (eg. to file-backed
> block devices) to be relative in a useful way.  This would let you
> have the domain XML configuration file & the block device files sit
> next to each other to give a machine description:
>   mydomain.hda.img
>   mydomain.xml		# refers to <source file="mydomain.hda.img">
> This isn't possible at the moment as far as I can tell, which means
> you need to know which directory the files are located in, and you
> can't move them around.

Having relative paths to disk files in the XML isn't useful because 
the drivers make no guarentees about where the XML files will be
stored - if indeed they're stored at all. Full-qualified paths to
disks are the only sensible option for domain XML IMHO.

> [As an aside, at present the QEMU driver makes no attempt to check
> that the source file is an absolute path, it just passes whatever it
> finds to the '-hdc' argument to qemu.]
> For the command:
>   virsh define mydomain.xml
> One implementation would be to have virsh rewriting paths, but that
> requires special knowledge of the XML format in virsh so I don't think
> it's a workable idea.  Another would be to allow virsh to supply a
> 'base URI' (basically, the current directory) to the
> virDomainDefineXML call.
> Any thoughts?

I think this is mixing up two concepts really - the domain XML is used
to represent a specific instantiation of a domain and as such it should
fully specify things like paths.

The use case of keeping disk images & XML alongside each other is really
in the realms of appliance images. The virt-image tool provides a format
for describing appliances and does support having relative paths. It then
turns this into the domain XML for the specific instantiation using a
fully qualfied path.

|: Red Hat, Engineering, Boston   -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 :|

More information about the libvir-list mailing list