Here's my solution, as a nbdkit plugin written in Perl.
As with Max's solution I don't bother to parse the virtual size out of
the XML file, so you need to specify that on the command line
otherwise the disk will be truncated to the largest extent stored in
the file. Also the ‘.xva’ file must not be compressed.
$ nbdkit perl script=./xva-reader.pl file=./debian8cloud.xva size=4294967296
$ guestfish --ro --format=raw -a nbd://localhost -i
Welcome to guestfish, the guest filesystem shell for
editing virtual machine filesystems and disk images.
Type: 'help' for help on commands
'man' to read the manual
'quit' to quit the shell
Operating system: 8.2
/dev/sda1 mounted on /
<fs> ll /
total 100
drwxr-xr-x 22 root root 4096 Jan 8 2016 .
drwxr-xr-x 19 root root 4096 Nov 16 09:50 ..
drwxrwxr-x 2 root root 4096 Jan 8 2016 bin
drwxr-xr-x 3 root root 4096 Jan 8 2016 boot
drwxr-xr-x 4 root root 4096 Jan 8 2016 dev
drwxr-xr-x 87 root root 4096 Jan 8 2016 etc
drwxr-xr-x 3 root root 4096 Jan 8 2016 home
lrwxrwxrwx 1 root root 31 Jan 8 2016 initrd.img ->
/boot/initrd.img-3.16.0-4-amd64
drwxr-xr-x 14 root root 4096 Jan 8 2016 lib
drwxr-xr-x 2 root root 4096 Jan 8 2016 lib64
drwx------ 2 root root 16384 Jan 8 2016 lost+found
drwxr-xr-x 3 root root 4096 Jan 8 2016 media
drwxr-xr-x 2 root root 4096 Jan 8 2016 mnt
drwxr-xr-x 2 root root 4096 Jan 8 2016 opt
drwxr-xr-x 2 root root 4096 May 4 2015 proc
drwx------ 2 root root 4096 Jan 8 2016 root
drwxr-xr-x 2 root root 4096 Jan 8 2016 run
drwxr-xr-x 2 root root 4096 Jan 8 2016 sbin
drwxr-xr-x 2 root root 4096 Jan 8 2016 srv
drwxr-xr-x 2 root root 4096 Apr 6 2015 sys
drwxrwxrwt 7 root root 4096 Jan 8 2016 tmp
drwxr-xr-x 10 root root 4096 Jan 8 2016 usr
drwxr-xr-x 11 root root 4096 Jan 8 2016 var
lrwxrwxrwx 1 root root 27 Jan 8 2016 vmlinuz -> boot/vmlinuz-3.16.0-4-amd64
I even managed to boot the Debian 8 guest from the sample .xva file:
$ qemu-system-x86_64 -cpu host -machine accel=kvm:tcg -m 2048 -drive
file=nbd:localhost:10809,format=raw,if=virtio,snapshot=on
although it was pretty slow ...
As mentioned before you can use this to do a qemu-img convert using
captive nbdkit:
$ nbdkit -U - \
perl script=./xva-reader.pl file=./debian8cloud.xva size=4294967296 \
--run 'qemu-img convert -f raw $nbd -O qcow2 /var/tmp/output.qcow2 -p'
HTH,
Rich.
--
Richard Jones, Virtualization Group, Red Hat
http://people.redhat.com/~rjones
Read my programming and virtualization blog:
http://rwmj.wordpress.com
virt-builder quickly builds VMs from scratch
http://libguestfs.org/virt-builder.1.html