diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index 1d6b276f3d..f4d0b40f33 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -89,6 +89,58 @@ typedef enum {
VIR_DOMAIN_CRASHED = 6 /* the domain is crashed */
} virDomainState;
+typedef enum {
+ VIR_DOMAIN_NOSTATE_UNKNOWN = 0,
+} virDomainNostateReason;
+
+typedef enum {
+ VIR_DOMAIN_RUNNING_UNKNOWN = 0,
+ VIR_DOMAIN_RUNNING_BOOTED = 1, /* normal startup from boot */
+ VIR_DOMAIN_RUNNING_MIGRATED = 2, /* migrated from another host */
+ VIR_DOMAIN_RUNNING_RESTORED = 3, /* restored from a state file */
+ VIR_DOMAIN_RUNNING_FROM_SNAPSHOT = 4, /* restored from snapshot */
+ VIR_DOMAIN_RUNNING_UNPAUSED = 5, /* returned from paused state */
+ VIR_DOMAIN_RUNNING_MIGRATION_CANCELED = 6, /* returned from migration */
+ VIR_DOMAIN_RUNNING_SAVE_CANCELED = 7, /* returned from failed save process */
+} virDomainRunningReason;
+
+typedef enum {
+ VIR_DOMAIN_BLOCKED_UNKNOWN = 0, /* the reason is unknown */
+} virDomainBlockedReason;
+
+typedef enum {
+ VIR_DOMAIN_PAUSED_UNKNOWN = 0, /* the reason is unknown */
+ VIR_DOMAIN_PAUSED_USER = 1, /* paused on user request */
+ VIR_DOMAIN_PAUSED_MIGRATION = 2, /* paused for offline migration */
+ VIR_DOMAIN_PAUSED_SAVE = 3, /* paused for save */
+ VIR_DOMAIN_PAUSED_DUMP = 4, /* paused for offline core dump */
+ VIR_DOMAIN_PAUSED_IOERROR = 5, /* paused due to a disk I/O error */
+ VIR_DOMAIN_PAUSED_WATCHDOG = 6, /* paused due to a watchdog event */
+ VIR_DOMAIN_PAUSED_FROM_SNAPSHOT = 7, /* restored from a snapshot which was
+ * taken while domain was paused */
+} virDomainPausedReason;
+
+typedef enum {
+ VIR_DOMAIN_SHUTDOWN_UNKNOWN = 0, /* the reason is unknown */
+ VIR_DOMAIN_SHUTDOWN_USER = 1, /* shutting down on user request */
+} virDomainShutdownReason;
+
+typedef enum {
+ VIR_DOMAIN_SHUTOFF_UNKNOWN = 0, /* the reason is unknown */
+ VIR_DOMAIN_SHUTOFF_SHUTDOWN = 1, /* normal shutdown */
+ VIR_DOMAIN_SHUTOFF_DESTROYED = 2, /* forced poweroff */
+ VIR_DOMAIN_SHUTOFF_CRASHED = 3, /* domain crashed */
+ VIR_DOMAIN_SHUTOFF_MIGRATED = 4, /* migrated to another host */
+ VIR_DOMAIN_SHUTOFF_SAVED = 5, /* saved to a file */
+ VIR_DOMAIN_SHUTOFF_FAILED = 6, /* domain failed to start */
+ VIR_DOMAIN_SHUTOFF_FROM_SNAPSHOT = 7, /* restored from a snapshot which was
+ * taken while domain was shutoff */
+} virDomainShutoffReason;
+
+typedef enum {
+ VIR_DOMAIN_CRASHED_UNKNOWN = 0, /* crashed for unknown reason */
+} virDomainCrashedReason;
+
/**
* virDomainInfoPtr:
*
@@ -682,6 +734,10 @@ char * virDomainScreenshot (virDomainPtr domain,
*/
int virDomainGetInfo (virDomainPtr domain,
virDomainInfoPtr info);
+int virDomainGetState (virDomainPtr domain,
+ int *state,
+ int *reason,
+ unsigned int flags);
/*
* Return scheduler type in effect 'sedf', 'credit', 'linux'
diff --git a/python/generator.py b/python/generator.py
index 4fa4f65411..b395caf32a 100755
--- a/python/generator.py
+++ b/python/generator.py
@@ -293,6 +293,7 @@ skip_impl = (
'virConnGetLastError',
'virGetLastError',
'virDomainGetInfo',
+ 'virDomainGetState',
'virDomainGetBlockInfo',
'virDomainGetJobInfo',
'virNodeGetInfo',
diff --git a/python/libvirt-override-api.xml b/python/libvirt-override-api.xml
index 54deeb52d1..ec08e69ea2 100644
--- a/python/libvirt-override-api.xml
+++ b/python/libvirt-override-api.xml
@@ -48,6 +48,12 @@
+
+ Extract domain state.
+
+
+
+
Extract information about a domain block device size
diff --git a/python/libvirt-override.c b/python/libvirt-override.c
index 4a9b432d6c..11e1d0c03e 100644
--- a/python/libvirt-override.c
+++ b/python/libvirt-override.c
@@ -1067,6 +1067,35 @@ libvirt_virDomainGetInfo(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
return(py_retval);
}
+static PyObject *
+libvirt_virDomainGetState(PyObject *self ATTRIBUTE_UNUSED, PyObject *args)
+{
+ PyObject *py_retval;
+ int c_retval;
+ virDomainPtr domain;
+ PyObject *pyobj_domain;
+ int state;
+ int reason;
+ unsigned int flags;
+
+ if (!PyArg_ParseTuple(args, (char *)"Oi:virDomainGetState",
+ &pyobj_domain, &flags))
+ return NULL;
+
+ domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
+
+ LIBVIRT_BEGIN_ALLOW_THREADS;
+ c_retval = virDomainGetState(domain, &state, &reason, flags);
+ LIBVIRT_END_ALLOW_THREADS;
+ if (c_retval < 0)
+ return VIR_PY_NONE;
+
+ py_retval = PyList_New(2);
+ PyList_SetItem(py_retval, 0, libvirt_intWrap(state));
+ PyList_SetItem(py_retval, 1, libvirt_intWrap(reason));
+ return py_retval;
+}
+
static PyObject *
libvirt_virDomainGetBlockInfo(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
PyObject *py_retval;
@@ -3527,6 +3556,7 @@ static PyMethodDef libvirtMethods[] = {
{(char *) "virConnectDomainEventRegisterAny", libvirt_virConnectDomainEventRegisterAny, METH_VARARGS, NULL},
{(char *) "virConnectDomainEventDeregisterAny", libvirt_virConnectDomainEventDeregisterAny, METH_VARARGS, NULL},
{(char *) "virDomainGetInfo", libvirt_virDomainGetInfo, METH_VARARGS, NULL},
+ {(char *) "virDomainGetState", libvirt_virDomainGetState, METH_VARARGS, NULL},
{(char *) "virDomainGetBlockInfo", libvirt_virDomainGetBlockInfo, METH_VARARGS, NULL},
{(char *) "virNodeGetInfo", libvirt_virNodeGetInfo, METH_VARARGS, NULL},
{(char *) "virDomainGetUUID", libvirt_virDomainGetUUID, METH_VARARGS, NULL},
diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms
index a5a93baf35..1444b551a7 100644
--- a/src/libvirt_public.syms
+++ b/src/libvirt_public.syms
@@ -438,6 +438,7 @@ LIBVIRT_0.9.0 {
LIBVIRT_0.9.2 {
global:
+ virDomainGetState;
virDomainInjectNMI;
virDomainScreenshot;
} LIBVIRT_0.9.0;