From 5af87d808f0d4900cefc8cdca1be4c4f20fca165 Mon Sep 17 00:00:00 2001 From: Johannes Meixner Date: Sun, 10 Jun 2018 16:48:27 +0000 Subject: [PATCH] Fix toggling templates When marking a basejail as template, the jail is copied to a dataset containing its full name. When copying back, the unique identifier is not again looked up, so bugs will appear. One of them is you cannot `iocell get state ` for a such modified jail. --- lib/ioc-common | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/ioc-common b/lib/ioc-common index 156c74d..06c9fc7 100644 --- a/lib/ioc-common +++ b/lib/ioc-common @@ -276,6 +276,8 @@ __set_jail_prop () { _spinner='/-\|' printf " INFO: converting ${_template_tag} to a jail: " + _newuuid="$(__get_jail_prop host_hostuuid ${_fulluuid} ${_dataset})" + while true; do printf '\b%.1s' "${_spinner}" _spinner=${_spinner#?}${_spinner%???} @@ -286,18 +288,18 @@ __set_jail_prop () { # Have to manually specify this for later, as it will # still be the old /iocell/templates location - _dataset="${pool}/iocell/jails/${_fulluuid}" + _dataset="${pool}/iocell/jails/${_newuuid}" # Move jail back to the jails dataset zfs rename -f \ "${pool}/iocell/templates/${_template_tag}" \ - "${pool}/iocell/jails/${_fulluuid}" + "${pool}/iocell/jails/${_newuuid}" # Updating the jail tag __link_tag "${_dataset}" "${_template_tag}" # Throw jail through the checking process and unmount # what remains. - __check_basejail "${_fulluuid}" > /dev/null 2>&1 - __umount_basejail "${_fulluuid}" "${_dataset}" \ + __check_basejail "${_newuuid}" > /dev/null 2>&1 + __umount_basejail "${_newuuid}" "${_dataset}" \ > /dev/null 2>&1 _jailed_dataset="${_dataset}/data"