bhyve Cloning using vm-bhyve

I want confirm my understanding of how "vm clone" works since I'm not finding an answer elsewhere....

Assuming we are using zfs, if we have a client "test" whose disk image is file based the cloning is pretty straightforward.

Code:
# create a snapshot of the client we want to clone
zfs snapshot zdata/bhyve/test@mark

# create the clone
vm clone test@zdata/bhyve/test@mark testclone

However, if disk image is zvol based, things change a bit, we must do the following:

Code:
# create two snapshots, one for the machine and one for the zvol
# the snapshot tags MUST MATCH 
zfs snapshot zdata/bhyve/test@mark
zfs snapshot zdata/bhyve/test/disk0@mark

# now we can create the clone, both the snapshots must exist and must share the same tag
vm clone test@zdata/bhyve/test@mark testclone

This is what empirically works for me but it leaves me wondering if I'm missing some other nuances here?
 
You don't need to take zfs-snapshot(8)s before vm(8) "clone", the utility does this automatically.
Rich (BB code):
    clone name[@snapshot] new-name
             Create a clone of the virtual machine name, as long as it is
             currently powered off.  The new machine will be called new-name,
             and will be ready to boot with a newly assigned UUID and empty
             log file.

             If no snapshot name is given, a new snapshot will be taken of the
             guest and any descendant datasets or ZVOLs.  If you wish to use
             an existing snapshot as the source for the clone, please make
             sure the snapshot exists for the guest and any child ZVOLs,
             otherwise the clone will fail.

             Please note that this function requires ZFS.
Example: vm clone <orig_guest_name> <clone_name>
 
  • Like
Reactions: dkh
Well that makes it a bit simpler. Thanks for highlighting it.

In the past I think I started creating the snapshot first because vm destroy creates one of its own if you don't specify it and then leaves it behind if you destroy the cloned client. The cloned zfs volumes are removed but the "seed" snapshots remain with an apparently random 8 byte hex code, so clean up can be messy. It would be nice if it removed those after the clone operation is completed but I can see arguments for not doing so as well.
 
Back
Top