[PATCH 1/5] Introduce virConnectCrash

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 cfg.mk                         |  2 ++
 include/libvirt/libvirt-host.h | 15 ++++++++++++++
 src/driver-hypervisor.h        |  7 +++++++
 src/libvirt-host.c             | 45 ++++++++++++++++++++++++++++++++++++++++++
 src/libvirt_public.syms        |  1 +
 5 files changed, 70 insertions(+)

diff --git a/cfg.mk b/cfg.mk
index 8e8586f..6ff97e3 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -1133,6 +1133,8 @@ _test1=shunloadtest|virnettlscontexttest|virnettlssessiontest|vircgroupmock
 exclude_file_name_regexp--sc_avoid_write = \
   ^(src/($(_src1))|daemon/libvirtd|tools/virsh-console|tests/($(_test1)))\.c$$
 
+exclude_file_name_regexp--sc_flags_debug = ^src/libvirt-host\.c$$
+
 exclude_file_name_regexp--sc_bindtextdomain = ^(tests|examples)/
 
 exclude_file_name_regexp--sc_copyright_usage = \
diff --git a/include/libvirt/libvirt-host.h b/include/libvirt/libvirt-host.h
index 8786fbb..80b27aa 100644
--- a/include/libvirt/libvirt-host.h
+++ b/include/libvirt/libvirt-host.h
@@ -872,5 +872,20 @@ int virNodeAllocPages(virConnectPtr conn,
                       unsigned int cellCount,
                       unsigned int flags);
 
+typedef enum {
+    VIR_CONNECT_CRASH_SERVER = 0,
+    VIR_CONNECT_CRASH_CLIENT,
+} virConnectCrashSide;
+
+typedef enum {
+    VIR_CONNECT_CRASH_WRITE_RO = 0,
+    VIR_CONNECT_CRASH_NULL_DEREF,
+    VIR_CONNECT_CRASH_STACK_OVERFLOW,
+} virConnectCrashMode;
+
+int virConnectCrash(virConnectPtr conn,
+                    int side,
+                    int mode,
+                    unsigned int flags);
 
 #endif /* __VIR_LIBVIRT_HOST_H__ */
diff --git a/src/driver-hypervisor.h b/src/driver-hypervisor.h
index d11ff7f..03e7689 100644
--- a/src/driver-hypervisor.h
+++ b/src/driver-hypervisor.h
@@ -1238,6 +1238,12 @@ typedef int
 (*virDrvConnectUnregisterCloseCallback)(virConnectPtr conn,
                                         virConnectCloseFunc cb);
 
+typedef int
+(*virDrvConnectCrash)(virConnectPtr conn,
+                      int side,
+                      int mode,
+                      unsigned int flags);
+
 typedef struct _virHypervisorDriver virHypervisorDriver;
 typedef virHypervisorDriver *virHypervisorDriverPtr;
 
@@ -1474,6 +1480,7 @@ struct _virHypervisorDriver {
     virDrvConnectRegisterCloseCallback connectRegisterCloseCallback;
     virDrvConnectUnregisterCloseCallback connectUnregisterCloseCallback;
     virDrvDomainMigrateStartPostCopy domainMigrateStartPostCopy;
+    virDrvConnectCrash connectCrash;
 };
 
 
diff --git a/src/libvirt-host.c b/src/libvirt-host.c
index 24277b7..c458087 100644
--- a/src/libvirt-host.c
+++ b/src/libvirt-host.c
@@ -1478,3 +1478,48 @@ virNodeAllocPages(virConnectPtr conn,
     virDispatchError(conn);
     return -1;
 }
+
+
+/**
+ * virConnectCrash:
+ * @conn: pointer to the hypervisor connection
+ * @side: which side should the crash occur on (see virConnectCrashSide)
+ * @mode: which technique should be used to crash (see virConnectCrashMode)
+ * @flags: extra flags; not used yet, so callers should always pass 0
+ *
+ * Invoke a crash in either client or daemon.
+ *
+ * USE THIS API WITH EXTREME CAUTION AS IT MAY CRASH YOUR APPLICATION OR THE DAEMON.
+ *
+ * Returns: 0 on success,
+ *         -1 otherwise
+ */
+int
+virConnectCrash(virConnectPtr conn,
+                int side,
+                int mode,
+                unsigned int flags)
+{
+    VIR_DEBUG("conn=%p side=%d mode=%d flags=%x",
+              conn, side, mode, flags);
+
+    virResetLastError();
+
+    virCheckConnectReturn(conn, -1);
+    virCheckReadOnlyGoto(conn->flags, error);
+
+    if (conn->driver->connectCrash) {
+        int ret;
+
+        ret = conn->driver->connectCrash(conn, side, mode, flags);
+
+        if (ret < 0)
+            goto error;
+        return ret;
+    }
+
+    virReportUnsupportedError();
+ error:
+    virDispatchError(conn);
+    return -1;
+}
diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms
index 1e920d6..2f73e3e 100644
--- a/src/libvirt_public.syms
+++ b/src/libvirt_public.syms
@@ -730,6 +730,7 @@ LIBVIRT_1.3.3 {
         virDomainMigrateStartPostCopy;
         virDomainGetPerfEvents;
         virDomainSetPerfEvents;
+        virConnectCrash;
 } LIBVIRT_1.2.19;
 
 # .... define new API here using predicted next version number ....
-- 
2.7.3

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]