Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/libvirt_private.syms | 1 +
src/util/virutil.c | 32 ++++++++++++++++++++++++++++++++
src/util/virutil.h | 2 ++
3 files changed, 35 insertions(+)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 684f06c..afd7832 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -2418,6 +2418,7 @@ virUSBDeviceSetUsedBy;
# util/virutil.h
+virCrash;
virDoubleToStr;
virEnumFromString;
virEnumToString;
diff --git a/src/util/virutil.c b/src/util/virutil.c
index b401f8d..44e6c9b 100644
--- a/src/util/virutil.c
+++ b/src/util/virutil.c
@@ -2669,3 +2669,35 @@ virMemoryMaxValue(bool capped)
else
return LLONG_MAX;
}
+
+static int
+virRecursive(void)
+{
+ virRecursive();
+ return 0;
+}
+
+int
+virCrash(int mode)
+{
+ const char *s = "Hello world!";
+ char **tmp;
+ char *n = NULL;
+
+ switch ((virConnectCrashMode) mode) {
+ case VIR_CONNECT_CRASH_WRITE_RO:
+ tmp = (char **) &s;
+ **tmp = 'h';
+ break;
+
+ case VIR_CONNECT_CRASH_NULL_DEREF:
+ *n = 'L';
+ break;
+
+ case VIR_CONNECT_CRASH_STACK_OVERFLOW:
+ virRecursive();
+ break;
+ }
+
+ return 0;
+}
diff --git a/src/util/virutil.h b/src/util/virutil.h
index b121de0..e5997e4 100644
--- a/src/util/virutil.h
+++ b/src/util/virutil.h
@@ -265,4 +265,6 @@ unsigned long long virMemoryMaxValue(bool ulong);
# define VIR_ASSIGN_IS_OVERFLOW(lvalue, rvalue) \
(((lvalue) = (rvalue)) != (rvalue))
+int virCrash(int mode);
+
#endif /* __VIR_UTIL_H__ */
--
2.7.3