B #1585: Resize running KVM VM disks only via libvirt blockresize (#1868)

This commit is contained in:
Vlastimil Holer authored and Tino Vázquez committed 2018-03-15 16:54:19 +01:00
1 parent 435274d256
commit 1d54c3571e
4 files changed
+17 -27

No files matched your search

+8
View File
@@ -99,6 +99,14 @@ if [ -n "$CEPH_CONF" ]; then
RBD="$RBD --conf ${CEPH_CONF}"
fi
###
# for running VMs, leave disk resize on kvm/resize_disk
if [ `lcm_state $VM_ID` -eq 62 ]; then
log "Not resizing disk ${SRC_PATH} for running virt. machine directly"
exit 0
fi
RESIZE_CMD=$(cat <<EOF
$RBD resize --size ${SIZE} $RBD_DST
EOF
+6
View File
@@ -35,5 +35,11 @@ fi
SRC_PATH=$(arg_path $SRC)
SRC_HOST=$(arg_host $SRC)
# for running VMs, leave disk resize on kvm/resize_disk
if [ `lcm_state $VMID` -eq 62 ]; then
log "Not resizing disk ${SRC_PATH} for running virt. machine directly"
exit 0
fi
ssh_exec_and_log "${SRC_HOST}" "qemu-img resize ${SRC_PATH} ${SIZE}M" \
"Error resizing image ${SRC_PATH}"
+1 -1
View File
@@ -105,7 +105,7 @@ function lcm_state
while IFS= read -r -d '' element; do
XPATH_ELEMENTS[i++]="$element"
done < <(onevm show -x $VMID| $XPATH \
done < <(onevm show -x "${1:-$VMID}" | $XPATH \
/VM/LCM_STATE )
LCM_STATE="${XPATH_ELEMENTS[0]}"
+2 -26
View File
@@ -24,31 +24,7 @@ DRV_ACTION=$4
source $(dirname $0)/kvmrc
source $(dirname $0)/../../scripts_common.sh
(
set -e
get_disk_information "DISK_ID=$DISK_ID"
regexp="/domain/devices/disk[target/@dev='${DISK_TARGET}']/alias/@name"
drives="virsh --connect $LIBVIRT_URI dumpxml $DOMAIN"
alias=$($drives | $XPATH --stdin "$regexp")
if [ -n "$alias" ]; then
drive="drive-$alias"
else
error_message "Drive $DISK_TARGET not found"
exit -1
fi
log_info "Resizing $DISK_TARGET to $DISK_SIZE"
virsh --connect $LIBVIRT_URI qemu-monitor-command $DOMAIN --hmp "block_resize $drive ${DISK_SIZE}M"
) > /dev/null
if [ $? -ne 0 ]; then
echo "Could not notify the VM about the disk resize. Poweroff cycle needed."
fi
exec_and_log "virsh --connect ${LIBVIRT_URI} blockresize ${DOMAIN} ${DISK_TARGET} ${DISK_SIZE}M" \
"Failed to resize disk ${DISK_ID} on ${DOMAIN}"