Skip to content

Commit 606902f

Browse files
author
kishan
committed
Bug 11931: Add quotes to snapshot name and volume name. Fixed create template from snapshot also by adding quotes
Status 11931: resolved fixed Reviewed-By: Nitin Conflicts: scripts/storage/qcow2/createtmplt.sh
1 parent cbc47b9 commit 606902f

2 files changed

Lines changed: 16 additions & 16 deletions

File tree

scripts/storage/qcow2/createtmplt.sh

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -97,28 +97,28 @@ uncompress() {
9797

9898
create_from_file() {
9999
local tmpltfs=$1
100-
local tmpltimg=$2
100+
local tmpltimg="$2"
101101
local tmpltname=$3
102102
if [ -b $tmpltimg ]; then
103-
$qemu-img convert -f raw -O qcow2 $tmpltimg /$tmpltfs/$tmpltname
103+
$qemu-img convert -f raw -O qcow2 "$tmpltimg" /$tmpltfs/$tmpltname
104104
else
105-
$qemu_img convert -f qcow2 -O qcow2 $tmpltimg /$tmpltfs/$tmpltname >& /dev/null
105+
$qemu_img convert -f qcow2 -O qcow2 "$tmpltimg" /$tmpltfs/$tmpltname >& /dev/null
106106
fi
107107

108108
if [ "$cleanup" == "true" ]
109109
then
110-
rm -f $tmpltimg
110+
rm -f "$tmpltimg"
111111
fi
112112
chmod a+r /$tmpltfs/$tmpltname
113113
}
114114

115115
create_from_snapshot() {
116-
local tmpltImg=$1
117-
local snapshotName=$2
116+
local tmpltImg="$1"
117+
local snapshotName="$2"
118118
local tmpltfs=$3
119119
local tmpltname=$4
120120

121-
$qemu_img convert -f qcow2 -O qcow2 -s $snapshotName $tmpltImg /$tmpltfs/$tmpltname >& /dev/null
121+
$qemu_img convert -f qcow2 -O qcow2 -s "$snapshotName" "$tmpltImg" /$tmpltfs/$tmpltname >& /dev/null
122122
if [ $? -gt 0 ]
123123
then
124124
printf "Failed to create template /$tmplfs/$tmpltname from snapshot $snapshotName on disk $tmpltImg "
@@ -185,17 +185,17 @@ then
185185
exit 3
186186
fi
187187

188-
tmpltimg=$(uncompress $tmpltimg)
188+
tmpltimg=$(uncompress "$tmpltimg")
189189
if [ $? -ne 0 ]
190190
then
191191
printf "failed to uncompress $tmpltimg\n"
192192
fi
193193

194194
if [ "$sflag" == "1" ]
195195
then
196-
create_from_snapshot $tmpltimg $snapshotName $tmpltfs $tmpltname
196+
create_from_snapshot "$tmpltimg" "$snapshotName" $tmpltfs $tmpltname
197197
else
198-
create_from_file $tmpltfs $tmpltimg $tmpltname
198+
create_from_file $tmpltfs "$tmpltimg" $tmpltname
199199
fi
200200

201201
touch /$tmpltfs/template.properties
@@ -209,7 +209,7 @@ echo "description=$descr" >> /$tmpltfs/template.properties
209209

210210
if [ "$cleanup" == "true" ]
211211
then
212-
rm -f $tmpltimg
212+
rm -f "$tmpltimg"
213213
fi
214214

215215
exit 0

scripts/storage/qcow2/managesnapshot.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ fi
4343

4444
create_snapshot() {
4545
local disk=$1
46-
local snapshotname=$2
46+
local snapshotname="$2"
4747
local failed=0
4848

4949
if [ -b "${disk}" ] && lvm lvs "${disk}" >/dev/null 2>&1; then
@@ -160,7 +160,7 @@ destroy_snapshot() {
160160

161161
rollback_snapshot() {
162162
local disk=$1
163-
local snapshotname=$2
163+
local snapshotname="$2"
164164
local failed=0
165165

166166
$qemu_img snapshot -a $snapshotname $disk
@@ -266,19 +266,19 @@ done
266266

267267
if [ "$cflag" == "1" ]
268268
then
269-
create_snapshot $pathval $snapshot
269+
create_snapshot $pathval "$snapshot"
270270
exit $?
271271
elif [ "$dflag" == "1" ]
272272
then
273-
destroy_snapshot $pathval $snapshot $deleteDir
273+
destroy_snapshot $pathval "$snapshot" $deleteDir
274274
exit $?
275275
elif [ "$bflag" == "1" ]
276276
then
277277
backup_snapshot $pathval $snapshot $destPath $tmplName
278278
exit $?
279279
elif [ "$rflag" == "1" ]
280280
then
281-
rollback_snapshot $pathval $snapshot $destPath
281+
rollback_snapshot $pathval "$snapshot" $destPath
282282
exit $?
283283
fi
284284

0 commit comments

Comments
 (0)