Added new public APIs for managed-core-dump.
In line with managed-save functionality, there's at most one managed
core-dump per domain.
New APIs:
. virDomainManagedCoreDump
. virDomainHasManagedCoreDump
. virDomainManagedCoreDumpRemove
. virDomainManagedCoreDumpDownload
* include/libvirt/libvirt.h.in: API declarations.
* src/driver.h: driver data structure extension.
* src/libvirt.c: API implementation.
* src/libvirt_public.syms: public symbols.
Signed-off-by: Hong Xiang <hxiang(a)linux.vnet.ibm.com>
---
include/libvirt/libvirt.h.in | 13 +++
src/driver.h | 18 ++++
src/libvirt.c | 187 ++++++++++++++++++++++++++++++++++++++++++
src/libvirt_public.syms | 8 ++
4 files changed, 226 insertions(+), 0 deletions(-)
diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index 7181f62..2abbbf0 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -1168,6 +1168,19 @@ int virDomainCoreDump (virDomainPtr
domain,
unsigned int flags);
/*
+ * Managed domain core dump
+ */
+int virDomainManagedCoreDump (virDomainPtr dom,
+ unsigned int flags);
+int virDomainHasManagedCoreDump(virDomainPtr dom,
+ unsigned int flags);
+int virDomainManagedCoreDumpRemove(virDomainPtr dom,
+ unsigned int flags);
+int virDomainManagedCoreDumpDownload(virDomainPtr dom,
+ virStreamPtr stream,
+ unsigned int flags);
+
+/*
* Screenshot of current domain console
*/
char * virDomainScreenshot (virDomainPtr domain,
diff --git a/src/driver.h b/src/driver.h
index 4c14aaa..25f2edf 100644
--- a/src/driver.h
+++ b/src/driver.h
@@ -740,6 +740,20 @@ typedef int
(*virDrvDomainBlockPull)(virDomainPtr dom, const char *path,
unsigned long bandwidth, unsigned int flags);
+typedef int
+ (*virDrvDomainManagedCoreDump)(virDomainPtr domain, unsigned int flags);
+
+typedef int
+ (*virDrvDomainHasManagedCoreDump)(virDomainPtr domain, unsigned int flags);
+
+typedef int
+ (*virDrvDomainManagedCoreDumpRemove)(virDomainPtr domain,
+ unsigned int flags);
+
+typedef int
+ (*virDrvDomainManagedCoreDumpDownload)(virDomainPtr domain,
+ virStreamPtr stream,
+ unsigned int flags);
/**
* _virDriver:
@@ -899,6 +913,10 @@ struct _virDriver {
virDrvDomainGetBlockJobInfo domainGetBlockJobInfo;
virDrvDomainBlockJobSetSpeed domainBlockJobSetSpeed;
virDrvDomainBlockPull domainBlockPull;
+ virDrvDomainManagedCoreDump domainManagedCoreDump;
+ virDrvDomainHasManagedCoreDump domainHasManagedCoreDump;
+ virDrvDomainManagedCoreDumpRemove domainManagedCoreDumpRemove;
+ virDrvDomainManagedCoreDumpDownload domainManagedCoreDumpDownload;
};
typedef int
diff --git a/src/libvirt.c b/src/libvirt.c
index b0d1e01..b7b17f4 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -17083,3 +17083,190 @@ error:
virDispatchError(dom->conn);
return -1;
}
+
+/**
+ * virDomainManagedCoreDump:
+ * @dom: pointer to the domain
+ * @flags: bitwise-OR of virDomainCoreDumpFlags
+ *
+ * This method differs from virDomainCoreDump only in that caller can not
+ * control where the generated core dump file is stored, it's determined by
+ * the driver.
+ *
+ * Returns 0 in case of success or -1 in case of failure
+ */
+int virDomainManagedCoreDump(virDomainPtr dom, unsigned int flags)
+{
+ virConnectPtr conn;
+
+ VIR_DOMAIN_DEBUG(dom, "flags=%x", flags);
+
+ virResetLastError();
+
+ if (!VIR_IS_CONNECTED_DOMAIN(dom)) {
+ virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
+ virDispatchError(NULL);
+ return -1;
+ }
+
+ conn = dom->conn;
+ if (conn->flags & VIR_CONNECT_RO) {
+ virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__);
+ goto error;
+ }
+
+ if ((flags & VIR_DUMP_CRASH) && (flags & VIR_DUMP_LIVE)) {
+ virLibDomainError(VIR_ERR_INVALID_ARG,
+ _("crash and live flags are mutually exclusive"));
+ goto error;
+ }
+
+ if (conn->driver->domainManagedCoreDump) {
+ int ret;
+
+ ret = conn->driver->domainManagedCoreDump(dom, flags);
+ if (ret < 0)
+ goto error;
+ return ret;
+ }
+
+ virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ virDispatchError(conn);
+ return -1;
+}
+
+/**
+ * virDomainHasManagedCoreDump:
+ * @dom: pointer to the domain
+ * @flags: optional flags currently unused
+ *
+ * Check if a domain has a managed core dump as created by
+ * virDomainManagedCoreDump().
+ *
+ * Returns 0 if no core dump is present, 1 if a core dump is present, and
+ * -1 in case of error
+ */
+int virDomainHasManagedCoreDump(virDomainPtr dom, unsigned int flags)
+{
+ virConnectPtr conn;
+
+ VIR_DOMAIN_DEBUG(dom, "flags=%x", flags);
+
+ virResetLastError();
+
+ if (!VIR_IS_CONNECTED_DOMAIN(dom)) {
+ virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
+ virDispatchError(NULL);
+ return -1;
+ }
+
+ conn = dom->conn;
+
+ if (conn->driver->domainHasManagedCoreDump) {
+ int ret;
+
+ ret = conn->driver->domainHasManagedCoreDump(dom, flags);
+ if (ret < 0)
+ goto error;
+ return ret;
+ }
+
+ virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ virDispatchError(conn);
+ return -1;
+}
+
+/**
+ * virDomainManagedCoreDumpRemove:
+ * @dom: pointer to the domain
+ * @flags: optional flags currently unused
+ *
+ * Remove managed core dump of this domain.
+ *
+ * Returns 0 in case of success, and -1 in case of error
+ */
+int virDomainManagedCoreDumpRemove(virDomainPtr dom, unsigned int flags)
+{
+ virConnectPtr conn;
+
+ VIR_DOMAIN_DEBUG(dom, "flags=%x", flags);
+
+ virResetLastError();
+
+ if (!VIR_IS_CONNECTED_DOMAIN(dom)) {
+ virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
+ virDispatchError(NULL);
+ return -1;
+ }
+
+ conn = dom->conn;
+ if (conn->flags & VIR_CONNECT_RO) {
+ virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__);
+ goto error;
+ }
+
+ if (conn->driver->domainManagedCoreDumpRemove) {
+ int ret;
+
+ ret = conn->driver->domainManagedCoreDumpRemove(dom, flags);
+ if (ret < 0)
+ goto error;
+ return ret;
+ }
+
+ virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ virDispatchError(conn);
+ return -1;
+}
+
+/**
+ * virDomainManagedCoreDumpDownload:
+ * @dom: pointer to the domain
+ * @stream: stream to use as output
+ * @flags: optional flags currently unused
+ *
+ * Download managed core dump of this domain.
+ *
+ * Returns 0 on success and -1 on failure.
+ */
+int
+virDomainManagedCoreDumpDownload(virDomainPtr dom,
+ virStreamPtr stream,
+ unsigned int flags)
+{
+ virConnectPtr conn;
+
+ VIR_DOMAIN_DEBUG(dom, "flags=%x", flags);
+
+ virResetLastError();
+
+ if (!VIR_IS_CONNECTED_DOMAIN(dom)) {
+ virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
+ virDispatchError(NULL);
+ return -1;
+ }
+
+ conn = dom->conn;
+
+ if (conn->driver->domainManagedCoreDumpDownload) {
+ int ret;
+
+ ret = conn->driver->domainManagedCoreDumpDownload(dom, stream, flags);
+
+ if (ret < 0)
+ goto error;
+ return ret;
+ }
+
+ virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ virDispatchError(conn);
+ return -1;
+}
diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms
index bcefb10..dc9cd5d 100644
--- a/src/libvirt_public.syms
+++ b/src/libvirt_public.syms
@@ -498,4 +498,12 @@ LIBVIRT_0.9.7 {
virDomainSnapshotNumChildren;
} LIBVIRT_0.9.5;
+LIBVIRT_0.9.8 {
+ global:
+ virDomainManagedCoreDump;
+ virDomainHasManagedCoreDump;
+ virDomainManagedCoreDumpRemove;
+ virDomainManagedCoreDumpDownload;
+} LIBVIRT_0.9.7;
+
# .... define new API here using predicted next version number ....
--
1.7.1