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