← Back to team overview

openstack team mailing list archive

Re: File injection support

 

On Fri, 8 Jun 2012, Pádraig Brady wrote:

> On 06/08/2012 09:20 AM, Fredric Morenius wrote:
> > Hello All,
> >
> > An update on the use of the qemu-nbd/kpartx based solution to inject files into VM images:
> >
> > After some more testing it has turned out that injection into the UEC version of CirrOS (this: https://launchpad.net/cirros/trunk/0.3.0/+download/cirros-0.3.0-x86_64-uec.tar.gz) works fine, but injection into the qcow2 version of the image produces the error given in the previous mail, so there seems to be robustness problems with these tools.
>
> Yes it's seems that qemu-nbd has issues with this image?
>
> # rpm -qf $(which qemu-nbd)
> qemu-common-1.0-17.fc17.x86_64
> # qemu-img info cirros-0.3.0-x86_64-disk.img
> image: cirros-0.3.0-x86_64-disk.img
> file format: qcow2
> virtual size: 39M (41126400 bytes)
> disk size: 9.3M
> cluster_size: 65536
> # qemu-nbd -c /dev/nbd15 $PWD/cirros-0.3.0-x86_64-disk.img
> # ls -la /sys/block/nbd15/pid
> -r--r--r--. 1 root root 4096 Jun  8 10:19 /sys/block/nbd15/pid
> # kpartx -a /dev/nbd15
> device-mapper: resume ioctl on nbd15p1 failed: Invalid argument
> create/reload failed on nbd15p1
>
> If I convert to raw with qemu-img, I can mount loopback fine.

Well, interesting. It does seem to work here:
$ dpkg-query --show qemu-utils
qemu-utils  1.0+noroms-0ubuntu13
$ cd /tmp
$ wget -q https://launchpad.net/cirros/trunk/0.3.0/+download/cirros-0.3.0-x86_64-disk.img
$ md5sum cirros-0.3.0-x86_64-disk.img
6654705afc4b74fda3e1f4330559d066  cirros-0.3.0-x86_64-disk.img
$ qemu-img info cirros-0.3.0-x86_64-disk.img
image: cirros-0.3.0-x86_64-disk.img
file format: qcow2
virtual size: 39M (41126400 bytes)
disk size: 11M
cluster_size: 65536
$ sudo qemu-nbd -c /dev/nbd15 $PWD/cirros-0.3.0-x86_64-disk.img
$ ls -l /dev/nbd15*
brw-rw---- 1 root disk 43, 240 Jun  8 11:32 /dev/nbd15
brw-rw---- 1 root disk 43, 241 Jun  8 11:32 /dev/nbd15p1
$ sudo mount /dev/nbd15p1 /mnt
$ ls /mnt
bin   etc   initrd.img  lost+found  opt   run   tmp  vmlinuz
boot  home  lib         mnt         proc  sbin  usr
dev   init  linuxrc     old-root    root  sys   var
$ sudo umount /mnt
$ sudo qemu-nbd -d /dev/nbd15
/dev/nbd15 disconnected

Follow ups

References