lxc/ruby-lxc

clone using overlayfs snapshot

medhamsh opened this issue · 3 comments

Hi,

I am trying to do a snapshot based clone. Though this works fine via command line as
lxc-clone -o source-precise-amd64 --snapshot -B overlayfs -n p2

I am unable to do this via the ruby-lxc bindings. This is what I am doing,

container.clone(@container_info[:name], { 'flags' => 'lxc.LXC_CLONE_SNAPSHOT', 'bdev_type' => 'overlayfs' })

and it takes like the same amount of time as it itakes for the regular clone. How can this be solved?

Can you try it like this:

container.clone(@container_info[:name], { :flags => LXC::LXC_CLONE_SNAPSHOT, :bdev_type => 'overlayfs' })

The option keys to LXC::Container#clone must be symbols, and the flags must use the actual LXC::LXC_* constants, not strings.

@medhamsh as @andrenth said, you have to pass the flags as hash, I have tested this and it works fine:

container.clone(@container_info[:name], flags: LXC::LXC_CLONE_SNAPSHOT, bdev_type: 'overlayfs' )

also you wont have to pass the options as explicit hash, this will work

Thanks both. That worked like a charm.