[lxc-devel] [PATCH v2] add support for qcow2
Serge Hallyn
serge.hallyn at ubuntu.com
Wed May 14 19:59:11 UTC 2014
Quoting Dwight Engen (dwight.engen at oracle.com):
> On Mon, 12 May 2014 18:02:28 +0000
> Serge Hallyn <serge.hallyn at ubuntu.com> wrote:
>
> > qcow2 backing stores can be attached to a nbd block device using
> > qemu-nbd. This user-space process (pair) stays around for the
> > duration of the device attachment. Obviously we want it to go
> > away when the container shuts down, but not before the filesystems
> > have been cleanly unmounted.
> >
> > The device attachment is done from the task which will become the
> > container monitor before the container setup+init task is spawned.
> > That task starts in a new pid namespace to ensure that the qemu-nbd
> > process will be killed if need be. It sets its parent death signal
> > to sighup, and, on receiving sighup, attempts to do a clean
> > qemu-device detach, then exits. This should ensure that the
> > device is detached if the qemu monitor crashes or exits.
> >
> > It may be worth adding a delay before the qemu-nbd is detached, but
> > my brief tests haven't seen any data corruption.
> >
> > Only the parts required for running a qcow2-backed container are
> > implemented here. Create, destroy, and clone are not. The first
> > use of this that I imagine is for people to use downloaded
> > qcow2-backed images (like ubuntu cloud images, or anything previously
> > used with qemu). I imagine people will want to create/clone/destroy
> > out of band using qemu-img, but if I'm wrong about that we can
> > implement the rest later.
> >
> > Because attach_block_device() is done before the bdev is initialized,
> > and bdev_init needs to know the nbd index so that it can mount the
> > filesystem, we now need to pass the lxc_conf.
> >
> > file_exists() is moved to utils.c so we can use it from bdev.c
> >
> > The nbd attach/detach should lay the groundwork for trivial
> > implementation of qed and raw images.
> >
> > changelog (may 12): qcow: fix idx check at detach
>
> Hey Serge, I had to check the code for how to use this so maybe we
> should document somewhere what the rootfs line needs to look like (ie.
> lxc.rootfs = qcow2:/path/to/diskimg:1).
>
> Also, I used this against a .vdi image just fine, so maybe we should be
> more generic than just qcow2 and call it qemu? Not sure if qemu-nbd
> supports all the same image formats as qemu-img.
so,
nbd:/file[:partition]
?
More information about the lxc-devel
mailing list