Blame SOURCES/bz1242558-virtualdomain-may-remove-config-file.patch

add258
diff -uNr a/heartbeat/VirtualDomain b/heartbeat/VirtualDomain
add258
--- a/heartbeat/VirtualDomain	2015-11-20 11:52:58.314263831 +0100
add258
+++ b/heartbeat/VirtualDomain	2015-11-20 11:53:55.247196256 +0100
add258
@@ -340,13 +340,32 @@
add258
 	return $rc
add258
 }
add258
 
add258
+# virsh undefine removes configuration files if they are in
add258
+# directories which are managed by libvirt. such directories
add258
+# include also subdirectories of /etc (for instance
add258
+# /etc/libvirt/*) which may be surprising. VirtualDomain didn't
add258
+# include the undefine call before, hence this wasn't an issue
add258
+# before.
add258
+#
add258
+# There seems to be no way to find out which directories are
add258
+# managed by libvirt.
add258
+#
add258
 verify_undefined() {
add258
-	for dom in `virsh --connect=${OCF_RESKEY_hypervisor} list --all --name 2>/dev/null`; do
add258
-		if [ "$dom" = "$DOMAIN_NAME" ]; then
add258
+	local tmpf
add258
+	if virsh --connect=${OCF_RESKEY_hypervisor} list --all --name 2>/dev/null | grep -wqs "$DOMAIN_NAME"
add258
+	then
add258
+		tmpf=$(mktemp -t vmcfgsave.XXXXXX)
add258
+		if [ ! -r "$tmpf" ]; then
add258
+			ocf_log warn "unable to create temp file, disk full?"
add258
+			# we must undefine the domain
add258
 			virsh $VIRSH_OPTIONS undefine $DOMAIN_NAME > /dev/null 2>&1
add258
-			return
add258
+		else
add258
+			cp -p $OCF_RESKEY_config $tmpf
add258
+			virsh $VIRSH_OPTIONS undefine $DOMAIN_NAME > /dev/null 2>&1
add258
+			[ -f $OCF_RESKEY_config ] || cp -f $tmpf $OCF_RESKEY_config
add258
+			rm -f $tmpf
add258
 		fi
add258
-	done
add258
+	fi
add258
 }
add258
 
add258
 VirtualDomain_Start() {