From 884f356f5c5005629591fe8fe2f073989dd42e02 Mon Sep 17 00:00:00 2001
From: Anton Todorov <a.todorov@storpool.com>
Date: Sun, 20 Mar 2016 22:43:36 +0200
Subject: [PATCH] suggestion for bug #4299

Use LIBVIRT_URI from the HV host not the front-end.
The construction of the remote command will substitute the variable with the local one.

Not tested, but looks similar to the way I've implemented it in our addon:
(https://github.com/OpenNebula/addon-storpool/blob/master/tm/storpool/storpool_common.sh#L284)

Aaaand yes, the past chunk should be on separate patch ;)

Kind Regards,
Anton Todorov
---
 src/tm_mad/ceph/snap_create_live  | 4 ++--
 src/tm_mad/qcow2/snap_create_live | 6 +++---
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/tm_mad/ceph/snap_create_live b/src/tm_mad/ceph/snap_create_live
index 24a818f..19fd115 100755
--- a/src/tm_mad/ceph/snap_create_live
+++ b/src/tm_mad/ceph/snap_create_live
@@ -91,8 +91,8 @@ fi
 SNAP_CREATE_CMD=$(cat <<EOF
     set -e
 
-    if virsh -c $LIBVIRT_URI domfsfreeze $DEPLOY_ID ; then
-        trap "virsh -c $LIBVIRT_URI domfsthaw $DEPLOY_ID" EXIT TERM INT HUP
+    if virsh -c \$LIBVIRT_URI domfsfreeze $DEPLOY_ID ; then
+        trap "virsh -c \$LIBVIRT_URI domfsthaw $DEPLOY_ID" EXIT TERM INT HUP
     fi
 
     RBD="${RBD}"
diff --git a/src/tm_mad/qcow2/snap_create_live b/src/tm_mad/qcow2/snap_create_live
index 1bc4679..a42d24d 100755
--- a/src/tm_mad/qcow2/snap_create_live
+++ b/src/tm_mad/qcow2/snap_create_live
@@ -132,11 +132,11 @@ touch $SNAP_PATH
 FILENAME="/tmp/snapshot-$VMID-$DISK_ID-$SNAP_ID"
 echo "$DOC" > \$FILENAME
 
-if virsh -c $LIBVIRT_URI domfsfreeze $DEPLOY_ID ; then
-    trap "virsh -c $LIBVIRT_URI domfsthaw $DEPLOY_ID" EXIT TERM INT HUP
+if virsh -c \$LIBVIRT_URI domfsfreeze $DEPLOY_ID ; then
+    trap "virsh -c \$LIBVIRT_URI domfsthaw $DEPLOY_ID" EXIT TERM INT HUP
 fi
 
-virsh -c qemu:///system snapshot-create $DEPLOY_ID --disk-only --atomic \
+virsh -c \$LIBVIRT_URI snapshot-create $DEPLOY_ID --disk-only --atomic \
     --xmlfile \$FILENAME
 
 rm \${FILENAME}
-- 
2.7.3

