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