1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-21 14:50:08 +03:00

B #3778: Fail on non-KVM host for live cpds (#1129)

This commit is contained in:
Jan Orel 2021-04-22 12:34:12 +02:00 committed by GitHub
parent 282b94f8f7
commit 3b4f7a4874
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 50 additions and 17 deletions

View File

@ -74,7 +74,9 @@ done < <(onevm show -x $VM_ID| $XPATH \
/VM/TEMPLATE/DISK[DISK_ID=$DISK_ID]/CEPH_USER \
/VM/TEMPLATE/DISK[DISK_ID=$DISK_ID]/CEPH_KEY \
/VM/TEMPLATE/DISK[DISK_ID=$DISK_ID]/CEPH_CONF \
/VM/TEMPLATE/DISK[DISK_ID=$DISK_ID]/TYPE )
/VM/TEMPLATE/DISK[DISK_ID=$DISK_ID]/TYPE \
/VM/LCM_STATE \
/VM/HISTORY_RECORDS/HISTORY[last\(\)]/VM_MAD)
DEPLOY_ID="${XPATH_ELEMENTS[j++]}"
RBD_SRC="${XPATH_ELEMENTS[j++]}"
@ -83,12 +85,23 @@ CEPH_USER="${XPATH_ELEMENTS[j++]}"
CEPH_KEY="${XPATH_ELEMENTS[j++]}"
CEPH_CONF="${XPATH_ELEMENTS[j++]}"
TYPE="${XPATH_ELEMENTS[j++]}"
LCM_STATE="${XPATH_ELEMENTS[j++]}"
VM_MAD="${XPATH_ELEMENTS[j++]}"
#-------------------------------------------------------------------------------
# Copy Image back to the datastore
#-------------------------------------------------------------------------------
if [ "${LCM_STATE}" = '26' -a "${VM_MAD}" != "kvm" ]; then
error_message "cpds.ssh: Live operation not supported on ${VM_MAD}"
exit 1
fi
if [ "$SNAP_ID" != "-1" ]; then
error_message "cpds.ssh: Operation not supported on disk type ${TYPE} with snapshots"
exit 1
fi
if [ -n "$CEPH_USER" ]; then
RBD="$RBD --id ${CEPH_USER}"
fi
@ -105,19 +118,17 @@ if [ "$RBD_FORMAT" = "2" ]; then
FORMAT_OPT="--image-format 2"
fi
if [ "$SNAP_ID" != "-1" ]; then
error_message "$script_name: Operation not supported on disk type ${TYPE} with snapshots"
exit 1
fi
COPY_CMD=$(cat <<EOF
if virsh -c $LIBVIRT_URI domfsfreeze $DEPLOY_ID ; then
trap "virsh -c $LIBVIRT_URI domfsthaw $DEPLOY_ID" EXIT TERM INT HUP
elif virsh -c $LIBVIRT_URI suspend $DEPLOY_ID; then
trap "virsh -c $LIBVIRT_URI resume $DEPLOY_ID" EXIT TERM INT HUP
else
echo "Could not domfsfreeze or suspend domain" >&2
exit 1
if [ "${LCM_STATE}" = '26' ]; then
if virsh -c $LIBVIRT_URI domfsfreeze $DEPLOY_ID ; then
trap "virsh -c $LIBVIRT_URI domfsthaw $DEPLOY_ID" EXIT
elif virsh -c $LIBVIRT_URI suspend $DEPLOY_ID; then
trap "virsh -c $LIBVIRT_URI resume $DEPLOY_ID" EXIT
else
echo "Could not domfsfreeze or suspend domain" >&2
exit 1
fi
fi
$RBD import $FORMAT_OPT $SRC_PATH $DST

View File

@ -114,6 +114,8 @@ MVDS_CMD=$(cat <<EOF
${QEMU_IMG} convert -n \
-f raw "${SRC_PATH}" \
-O rbd "rbd:${RBD_SRC}${QEMU_OPTS}"
rm -f ${SRC_PATH}
EOF
)

View File

@ -59,13 +59,15 @@ done < <(onevm show -x $VMID| $XPATH \
/VM/LCM_STATE \
/VM/TEMPLATE/DISK[DISK_ID=$DISK_ID]/TARGET \
/VM/TEMPLATE/DISK[DISK_ID=$DISK_ID]/SOURCE \
/VM/TEMPLATE/DISK[DISK_ID=$DISK_ID]/CLONE)
/VM/TEMPLATE/DISK[DISK_ID=$DISK_ID]/CLONE \
/VM/HISTORY_RECORDS/HISTORY[last\(\)]/VM_MAD)
DEPLOY_ID="${XPATH_ELEMENTS[j++]}"
LCM_STATE="${XPATH_ELEMENTS[j++]}"
DISK_TARGET="${XPATH_ELEMENTS[j++]}"
DISK_SRC="${XPATH_ELEMENTS[j++]}"
CLONE="${XPATH_ELEMENTS[j++]}"
VM_MAD="${XPATH_ELEMENTS[j++]}"
#-------------------------------------------------------------------------------
# Set dst path and dir
@ -93,6 +95,11 @@ fi
# For current image of the running VMs, don't touch the image directly,
# but export the content via blockcopy. If that's not possible (old QEMU),
# domfsfreeze or suspend the domain before.
if [ "${LCM_STATE}" = '26' -a "${VM_MAD}" != "kvm" ]; then
error_message "cpds: Live operation not supported on ${VM_MAD}"
exit 1
fi
if [ "${LCM_STATE}" = '26' ] && [ "${SNAP_ID}" = '-1' ]; then
CPDS_CMD_EXPORT=$(cat <<EOF
touch ${DST_PATH}

View File

@ -57,11 +57,13 @@ while IFS= read -r -d '' element; do
done < <(onevm show -x $VMID| $XPATH \
/VM/DEPLOY_ID \
/VM/LCM_STATE \
/VM/TEMPLATE/DISK[DISK_ID=$DISK_ID]/TARGET)
/VM/TEMPLATE/DISK[DISK_ID=$DISK_ID]/TARGET \
/VM/HISTORY_RECORDS/HISTORY[last\(\)]/VM_MAD)
DEPLOY_ID="${XPATH_ELEMENTS[j++]}"
LCM_STATE="${XPATH_ELEMENTS[j++]}"
DISK_TARGET="${XPATH_ELEMENTS[j++]}"
VM_MAD="${XPATH_ELEMENTS[j++]}"
#-------------------------------------------------------------------------------
# Set dst path and dir
@ -88,6 +90,11 @@ fi
# For current image of the running VMs, don't touch the image directly,
# but export the content via blockcopy. If that's not possible (old QEMU),
# domfsfreeze or suspend the domain before.
if [ "${LCM_STATE}" = '26' -a "${VM_MAD}" != "kvm" ]; then
error_message "$script_name: Live operation not supported on ${VM_MAD}"
exit 1
fi
if [ "${LCM_STATE}" = '26' ] && [ "${SNAP_ID}" = '-1' ]; then
CPDS_CMD_EXPORT=$(cat <<EOF
touch ${DST_PATH}

View File

@ -56,11 +56,13 @@ while IFS= read -r -d '' element; do
done < <(onevm show -x $VMID| $XPATH \
/VM/DEPLOY_ID \
/VM/LCM_STATE \
/VM/TEMPLATE/DISK[DISK_ID=$DISK_ID]/TARGET)
/VM/TEMPLATE/DISK[DISK_ID=$DISK_ID]/TARGET \
/VM/HISTORY_RECORDS/HISTORY[last\(\)]/VM_MAD)
DEPLOY_ID="${XPATH_ELEMENTS[j++]}"
LCM_STATE="${XPATH_ELEMENTS[j++]}"
DISK_TARGET="${XPATH_ELEMENTS[j++]}"
VM_MAD="${XPATH_ELEMENTS[j++]}"
#-------------------------------------------------------------------------------
# Set src path
@ -80,8 +82,12 @@ fi
# For current image of the running VMs, don't touch the image directly,
# but export the content via blockcopy. If that's not possible (old QEMU),
# domfsfreeze or suspend the domain before.
if [ "${LCM_STATE}" = '26' -a "${VM_MAD}" != "kvm" ]; then
error_message "cpds: Live operation not supported on ${VM_MAD}"
exit 1
fi
if [ "${LCM_STATE}" = '26' ] && [ "${SNAP_ID}" = '-1' ]; then
if [ "${LCM_STATE}" = '26' -a "${SNAP_ID}" = '-1' ]; then
log "VM is running, trying blockcopy, fsfreeze, suspend"
CPDS_CMD_EXPORT=$(cat <<EOF