Skip to content

Commit

Permalink
qemu: help write easy reproduce script
Browse files Browse the repository at this point in the history
Signed-off-by: Fengguang Wu <[email protected]>
Signed-off-by: Philip Li <[email protected]>
  • Loading branch information
Fengguang Wu authored and rli9 committed Nov 10, 2017
1 parent 15c3515 commit 8349681
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/qemu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ cleanup_qemu_drives()
rm -f $VDISK_ROOT/initrd-$vm_name

[[ $persistent_storage ]] || {
rm -f $VDISK_ROOT/disk[0-9]-$vm_name
rm -f $VDISK_ROOT/disk[0-9][0-9]-$vm_name
rm -f $VDISK_ROOT/disk-$vm_name-[0-9]
rm -f $VDISK_ROOT/disk-$vm_name-[0-9][0-9]
}
}

Expand Down Expand Up @@ -37,12 +37,14 @@ setup_qemu_drives()

(( VDISK_NUM )) || return 0

QEMU_IMG_SIZES=()

local i
local disk_names=(vd{a..z})
[[ $qemu_img ]] && string_to_associative_array qemu_img array_qemu_img
for ((i = 0; i < VDISK_NUM; i++))
do
local disk=$VDISK_ROOT/disk$i-$vm_name
local disk=$VDISK_ROOT/disk-$vm_name-$i
local size=256G

[[ $qemu_img ]] && {
Expand All @@ -51,6 +53,8 @@ setup_qemu_drives()
[[ $qemu_img_option =~ ^/dev/.*$ ]] && disk=$qemu_img_option
}

QEMU_IMG_SIZES+=($size)

[[ -e $disk ]] ||
qemu-img create -f qcow2 $disk $size || {
echo "init $disk failed"
Expand Down

0 comments on commit 8349681

Please sign in to comment.