Permalink
Browse files

OS-1709 add support for creating, deleting and rolling-back snapshots…

… on OS VMs which have no extra datasets.
  • Loading branch information...
1 parent 927cfb6 commit cdac1f3baec0ccf6488ae40857af31e1c449dca9 @joshwilsdon joshwilsdon committed Dec 9, 2012
Showing with 962 additions and 174 deletions.
  1. +10 −1 src/vm/etc/vmadm.completion
  2. +86 −0 src/vm/man/vmadm.1m.md
  3. +333 −23 src/vm/node_modules/VM.js
  4. +58 −0 src/vm/sbin/vmadm.js
  5. +475 −150 src/vm/tests/test-snapshots.js
@@ -4,7 +4,7 @@ _vmadm()
COMPREPLY=()
# NOTE: we don't want the aliases boot,halt,destroy,etc here because we
# want people to use the 'proper' commands when they can.
- COMMANDS="console create delete get info list lookup reboot receive send start stop sysrq update"
+ COMMANDS="console create create-snapshot delete delete-snapshot get info list lookup reboot receive rollback-snapshot send start stop sysrq update"
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
@@ -34,6 +34,15 @@ _vmadm()
cut -d':' -f5 | sort | uniq)
COMPREPLY=( $(compgen -W "${vms_uuids}" -- ${cur}) )
+ elif [[ ${prev} == 'create-snapshot'
+ || ${prev} == 'delete-snapshot'
+ || ${prev} == 'rollback-snapshot' ]]; then
+
+ # OS only commands
+ vms_uuids=$(zoneadm list -cp | grep -v ':global:' \
+ | grep -v ":kvm:excl:" | cut -d':' -f5 | sort | uniq)
+ COMPREPLY=( $(compgen -W "${vms_uuids}" -- ${cur}) )
+
elif [[ ${prev} == 'vmadm' ]]; then
COMPREPLY=( $(compgen -W "${COMMANDS}" -- ${cur}) )
View
@@ -30,6 +30,23 @@ tab-complete UUIDs rather than having to type them out for every command.
See the 'PROPERTIES' or 'EXAMPLES' sections below for details on what
to put in the JSON payload.
+ create-snapshot <uuid> <snapname>
+
+ Support for snapshots is currently experimental. It only works for OS
+ VMS which also have no additional datasets.
+
+ The <snapname> parameter specifies the name of the snapshot to take
+ of the specified VM. The snapname must be 64 characters or less and
+ must only contain alphanumeric characters and characters in the set
+ [-_.:%] to comply with ZFS restrictions.
+
+ You can use delete-snapshot or rollback-snapshot in the future on a
+ snapshot you've created with create-snapshot, so long as that snapshot
+ still exists.
+
+ See the 'SNAPSHOTS' section below for some more details on how to use
+ these snapshots, and their restrictions.
+
console <uuid>
Connect to the text console for a running VM. For OS VMs, this will be
@@ -50,6 +67,19 @@ tab-complete UUIDs rather than having to type them out for every command.
Note: this command is not interactive, take care to delete the right
VM.
+ delete-snapshot <uuid> <snapname>
+
+ Support for snapshots is currently experimental. It only works for OS
+ VMS which also have no additional datasets.
+
+ This command deletes the ZFS snapshot that exists with the name
+ <snapname> from the VM with the specified uuid. You cannot undo this
+ operation and it will no longer be possible to rollback to the specified
+ snapshot.
+
+ See the 'SNAPSHOTS' section below for some more details on how to use
+ these snapshots, and their restrictions.
+
get <uuid>
Output the JSON object describing a VM. The JSON object will be dumped
@@ -190,6 +220,26 @@ tab-complete UUIDs rather than having to type them out for every command.
reboot will be much faster but will not necessarily give the VM any
time to shut down its processes.
+ rollback-snapshot <uuid> <snapname>
+
+ Support for snapshots is currently experimental. It only works for OS
+ VMS which also have no additional datasets.
+
+ This command rolls the dataset backing the the VM with the specified
+ uuid back to its state at the point when the snapshot with snapname was
+ taken. You cannot undo this except by rolling back to an even older
+ snapshot if one exists.
+
+ IMPORTANT: when you rollback to a snapshot, all other snapshots newer
+ than the one you're rolling back to will be deleted. It will no longer
+ be possible to rollback to a snapshot newer than <snapname> for this VM.
+ Also note: your VM will be stopped if it is running when you start a
+ rollback-snapshot and will be booted after the snapshot has been
+ restored.
+
+ See the 'SNAPSHOTS' section below for some more details on how to use
+ these snapshots, and their restrictions.
+
start <uuid> [option=value ...]
Start a VM which is in the 'off' state. For OS VMs, this doesn't take
@@ -345,6 +395,30 @@ tab-complete UUIDs rather than having to type them out for every command.
restarted. Other properties will require a reboot in order to take
effect.
+## SNAPSHOTS
+
+ Snapshots are currently only implemented for OS VMs, and only for those
+ that do not utilize delegated datasets or any other datasets other than
+ the zoneroot dataset.
+
+ When you create a snapshot with create-snapshot, it will create a ZFS
+ snapshot of that dataset with the name dataset@vmsnap-<snapname> and the
+ .snapshots member of VM objects returned by things like vmadm get will
+ only include those snapshots that have been created using this pattern.
+
+ That allows vmadm to distinguish between snapshots it has taken and
+ snapshots that could have been taken using other tools.
+
+ To delete a snapshot you can use the delete-snapshot command. That will
+ destroy the snapshot in ZFS and it will automatically be removed from the
+ machine's snapshot list. It will no longer be possible to rollback to it.
+
+ To rollback a VM to its state at the time of a previous snapshot, you can
+ use the rollback-snapshot command. This will stop the VM rollback the
+ zoneroot dataset to the specified snapshot and start the VM again.
+ IMPORTANT: rollback-snapshot will automatically delete all snapshots newer
+ than the one you're rolling back to. This cannot be undone.
+
## PROPERTIES
Every VM has a number of properties. The properties for a VM can be listed
@@ -1300,6 +1374,18 @@ tab-complete UUIDs rather than having to type them out for every command.
create: yes
update: yes (but unused after create for OS VMs)
+ snapshots (EXPERIMENTAL):
+
+ For OS VMs, this will display a list of snapshots from which you can
+ restore the root dataset for your VM. Currently this is only supported
+ when your VM does not have any delegated datasets.
+
+ type: array
+ vmtype: OS
+ listable: no
+ create: no (but you can use create-snapshot)
+ update: no (but you can use rollback-snapshot and delete-snapshot)
+
spice_opts (EXPERIMENTAL):
This property allows you to add additional -spice options when you are
Oops, something went wrong.

0 comments on commit cdac1f3

Please sign in to comment.