|
|
05afe3 |
diff -uNr a/heartbeat/VirtualDomain b/heartbeat/VirtualDomain
|
|
|
05afe3 |
--- a/heartbeat/VirtualDomain 2018-06-29 14:05:02.000000000 +0200
|
|
|
05afe3 |
+++ b/heartbeat/VirtualDomain 2018-07-03 14:01:25.892705351 +0200
|
|
|
05afe3 |
@@ -26,6 +26,9 @@
|
|
|
05afe3 |
OCF_RESKEY_CRM_meta_timeout_default=90000
|
|
|
05afe3 |
OCF_RESKEY_save_config_on_stop_default=false
|
|
|
05afe3 |
OCF_RESKEY_sync_config_on_stop_default=false
|
|
|
05afe3 |
+OCF_RESKEY_backingfile_default=""
|
|
|
05afe3 |
+OCF_RESKEY_stateless_default="false"
|
|
|
05afe3 |
+OCF_RESKEY_copyindirs_default=""
|
|
|
05afe3 |
|
|
|
05afe3 |
: ${OCF_RESKEY_migration_downtime=${OCF_RESKEY_migration_downtime_default}}
|
|
|
05afe3 |
: ${OCF_RESKEY_migration_speed=${OCF_RESKEY_migration_speed_default}}
|
|
|
05afe3 |
@@ -36,6 +39,9 @@
|
|
|
05afe3 |
: ${OCF_RESKEY_CRM_meta_timeout=${OCF_RESKEY_CRM_meta_timeout_default}}
|
|
|
05afe3 |
: ${OCF_RESKEY_save_config_on_stop=${OCF_RESKEY_save_config_on_stop_default}}
|
|
|
05afe3 |
: ${OCF_RESKEY_sync_config_on_stop=${OCF_RESKEY_sync_config_on_stop_default}}
|
|
|
05afe3 |
+: ${OCF_RESKEY_backingfile=${OCF_RESKEY_backingfile_default}}
|
|
|
05afe3 |
+: ${OCF_RESKEY_stateless=${OCF_RESKEY_stateless_default}}
|
|
|
05afe3 |
+: ${OCF_RESKEY_copyindirs=${OCF_RESKEY_copyindirs_default}}
|
|
|
05afe3 |
|
|
|
05afe3 |
if ocf_is_true ${OCF_RESKEY_sync_config_on_stop}; then
|
|
|
05afe3 |
OCF_RESKEY_save_config_on_stop="true"
|
|
|
05afe3 |
@@ -271,6 +277,35 @@
|
|
|
05afe3 |
<content type="string" default=""/>
|
|
|
05afe3 |
</parameter>
|
|
|
05afe3 |
|
|
|
05afe3 |
+<parameter name="backingfile" unique="0" required="0">
|
|
|
05afe3 |
+<longdesc lang="en">
|
|
|
05afe3 |
+When the VM is used in Copy-On-Write mode, this is the backing file to use (with its full path).
|
|
|
05afe3 |
+The VMs image will be created based on this backing file.
|
|
|
05afe3 |
+This backing file will never be changed during the life of the VM.
|
|
|
05afe3 |
+</longdesc>
|
|
|
05afe3 |
+<shortdesc lang="en">If the VM is wanted to work with Copy-On-Write mode, this is the backing file to use (with its full path)</shortdesc>
|
|
|
05afe3 |
+<content type="string" default="${OCF_RESKEY_backingfile_default}" />
|
|
|
05afe3 |
+</parameter>
|
|
|
05afe3 |
+
|
|
|
05afe3 |
+<parameter name="stateless" unique="0" required="0">
|
|
|
05afe3 |
+<longdesc lang="en">
|
|
|
05afe3 |
+If set to true and backingfile is defined, the start of the VM will systematically create a new qcow2 based on
|
|
|
05afe3 |
+the backing file, therefore the VM will always be stateless. If set to false, the start of the VM will use the
|
|
|
05afe3 |
+COW (<vmname>.qcow2) file if it exists, otherwise the first start will create a new qcow2 based on the backing
|
|
|
05afe3 |
+file given as backingfile.
|
|
|
05afe3 |
+</longdesc>
|
|
|
05afe3 |
+<shortdesc lang="en">If set to true, the (<vmname>.qcow2) file will be re-created at each start, based on the backing file (if defined)</shortdesc>
|
|
|
05afe3 |
+<content type="boolean" default="${OCF_RESKEY_stateless_default}" />
|
|
|
05afe3 |
+</parameter>
|
|
|
05afe3 |
+
|
|
|
05afe3 |
+<parameter name="copyindirs" unique="0" required="0">
|
|
|
05afe3 |
+<longdesc lang="en">
|
|
|
05afe3 |
+List of directories for the virt-copy-in before booting the VM. Used only in stateless mode.
|
|
|
05afe3 |
+</longdesc>
|
|
|
05afe3 |
+<shortdesc lang="en">List of directories for the virt-copy-in before booting the VM stateless mode.</shortdesc>
|
|
|
05afe3 |
+<content type="string" default="${OCF_RESKEY_copyindirs_default}" />
|
|
|
05afe3 |
+</parameter>
|
|
|
05afe3 |
+
|
|
|
05afe3 |
<parameter name="shutdown_mode">
|
|
|
05afe3 |
<longdesc lang="en">
|
|
|
05afe3 |
virsh shutdown method to use. Please verify that it is supported by your virsh toolsed with 'virsh help shutdown'
|
|
|
05afe3 |
@@ -545,11 +580,49 @@
|
|
|
05afe3 |
# is restored to an 'undefined' state before creating.
|
|
|
05afe3 |
verify_undefined
|
|
|
05afe3 |
|
|
|
05afe3 |
- virsh $VIRSH_OPTIONS create ${OCF_RESKEY_config}
|
|
|
05afe3 |
- rc=$?
|
|
|
05afe3 |
- if [ $rc -ne 0 ]; then
|
|
|
05afe3 |
- ocf_exit_reason "Failed to start virtual domain ${DOMAIN_NAME}."
|
|
|
05afe3 |
- return $OCF_ERR_GENERIC
|
|
|
05afe3 |
+ if [ -z "${OCF_RESKEY_backingfile}" ]; then
|
|
|
05afe3 |
+ virsh $VIRSH_OPTIONS create ${OCF_RESKEY_config}
|
|
|
05afe3 |
+ if [ $? -ne 0 ]; then
|
|
|
05afe3 |
+ ocf_exit_reason "Failed to start virtual domain ${DOMAIN_NAME}."
|
|
|
05afe3 |
+ return $OCF_ERR_GENERIC
|
|
|
05afe3 |
+ fi
|
|
|
05afe3 |
+ else
|
|
|
05afe3 |
+ if ocf_is_true "${OCF_RESKEY_stateless}" || [ ! -s "${OCF_RESKEY_config%%.*}.qcow2" ]; then
|
|
|
05afe3 |
+ # Create the Stateless image
|
|
|
05afe3 |
+ dirconfig=`dirname ${OCF_RESKEY_config}`
|
|
|
05afe3 |
+ qemu-img create -f qcow2 -b ${OCF_RESKEY_backingfile} ${OCF_RESKEY_config%%.*}.qcow2
|
|
|
05afe3 |
+ if [ $? -ne 0 ]; then
|
|
|
05afe3 |
+ ocf_exit_reason "Failed qemu-img create ${DOMAIN_NAME} with backing file ${OCF_RESKEY_backingfile}."
|
|
|
05afe3 |
+ return $OCF_ERR_GENERIC
|
|
|
05afe3 |
+ fi
|
|
|
05afe3 |
+
|
|
|
05afe3 |
+ virsh define ${OCF_RESKEY_config}
|
|
|
05afe3 |
+ if [ $? -ne 0 ]; then
|
|
|
05afe3 |
+ ocf_exit_reason "Failed to define virtual domain ${DOMAIN_NAME}."
|
|
|
05afe3 |
+ return $OCF_ERR_GENERIC
|
|
|
05afe3 |
+ fi
|
|
|
05afe3 |
+
|
|
|
05afe3 |
+ if [ -n "${OCF_RESKEY_copyindirs}" ]; then
|
|
|
05afe3 |
+ # Inject copyindirs directories and files
|
|
|
05afe3 |
+ virt-copy-in -d ${DOMAIN_NAME} ${OCF_RESKEY_copyindirs} /
|
|
|
05afe3 |
+ if [ $? -ne 0 ]; then
|
|
|
05afe3 |
+ ocf_exit_reason "Failed on virt-copy-in command ${DOMAIN_NAME}."
|
|
|
05afe3 |
+ return $OCF_ERR_GENERIC
|
|
|
05afe3 |
+ fi
|
|
|
05afe3 |
+ fi
|
|
|
05afe3 |
+ else
|
|
|
05afe3 |
+ virsh define ${OCF_RESKEY_config}
|
|
|
05afe3 |
+ if [ $? -ne 0 ]; then
|
|
|
05afe3 |
+ ocf_exit_reason "Failed to define virtual domain ${DOMAIN_NAME}."
|
|
|
05afe3 |
+ return $OCF_ERR_GENERIC
|
|
|
05afe3 |
+ fi
|
|
|
05afe3 |
+ fi
|
|
|
05afe3 |
+
|
|
|
05afe3 |
+ virsh $VIRSH_OPTIONS start ${DOMAIN_NAME}
|
|
|
05afe3 |
+ if [ $? -ne 0 ]; then
|
|
|
05afe3 |
+ ocf_exit_reason "Failed to start virtual domain ${DOMAIN_NAME}."
|
|
|
05afe3 |
+ return $OCF_ERR_GENERIC
|
|
|
05afe3 |
+ fi
|
|
|
05afe3 |
fi
|
|
|
05afe3 |
|
|
|
05afe3 |
while ! VirtualDomain_monitor; do
|
|
|
05afe3 |
@@ -926,6 +999,11 @@
|
|
|
05afe3 |
ocf_exit_reason "migration_downtime has to be a decimal value"
|
|
|
05afe3 |
return $OCF_ERR_CONFIGURED
|
|
|
05afe3 |
fi
|
|
|
05afe3 |
+
|
|
|
05afe3 |
+ if ocf_is_true "${OCF_RESKEY_stateless}" && [ -z "${OCF_RESKEY_backingfile}" ]; then
|
|
|
05afe3 |
+ ocf_exit_reason "Stateless functionality can't be achieved without a backing file."
|
|
|
05afe3 |
+ return $OCF_ERR_CONFIGURED
|
|
|
05afe3 |
+ fi
|
|
|
05afe3 |
}
|
|
|
05afe3 |
|
|
|
05afe3 |
VirtualDomain_getconfig() {
|