From fed4626ac0e11eabf6fc616c8c5c00ccbfba7fee Mon Sep 17 00:00:00 2001 From: Roger Luethi Date: Mon, 15 Sep 2014 14:24:28 +0200 Subject: [PATCH] labs: fix shared folder restore after export Fix the code responsible for reattaching shared directories after VMs have been exported. For OVA export: - use saved share names instead of default name (for the sake of correctness; it is unlikely that a user will change the name) For dir export: - save and reattach shared directories after export Change-Id: I79162c1ec788aa1d89104aa92aebeae2bb05adf5 --- labs/lib/osbash/virtualbox.functions | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/labs/lib/osbash/virtualbox.functions b/labs/lib/osbash/virtualbox.functions index bef96252..870ed11c 100644 --- a/labs/lib/osbash/virtualbox.functions +++ b/labs/lib/osbash/virtualbox.functions @@ -410,7 +410,7 @@ function vm_export_ova { local ii=0 for node in $nodes; do if [ -n "${share_paths[$ii]}" ]; then - vm_add_share "$node" "$SHARE_DIR" "$SHARE_NAME" + vm_add_share "$node" "${share_paths[$ii]}" "$SHARE_NAME" fi ii=$(($ii + 1)) done @@ -430,7 +430,11 @@ function vm_export_dir { $VBM controlvm "$node" poweroff fi sleep 1 - vm_rm_share "$node" "$SHARE_NAME" + local share_path=$(vm_get_share_path "$node") + if [ -n "$share_path" ]; then + echo >&2 "Removing shared folder for export" + vm_rm_share "$node" "$SHARE_NAME" + fi sleep 1 echo "Exporting VM $node to $export_dir" # Use all: machineandchildren works only if --snapshot is given as UUID @@ -440,6 +444,10 @@ function vm_export_dir { --name "$node" \ --groups "/$VM_GROUP" \ --basefolder "$export_dir" + if [ -n "$share_path" ]; then + echo >&2 "Reattaching shared folder" + vm_add_share "$node" "$share_path" "$SHARE_NAME" + fi done }