提交 d65a924b 编写于 作者: J Jiri Denemark

virDomainGetState public API

This API is supposed to replace virDomainGetInfo when the only purpose
of calling it is getting current domain status.
上级 0f9e52da
...@@ -89,6 +89,58 @@ typedef enum { ...@@ -89,6 +89,58 @@ typedef enum {
VIR_DOMAIN_CRASHED = 6 /* the domain is crashed */ VIR_DOMAIN_CRASHED = 6 /* the domain is crashed */
} virDomainState; } 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: * virDomainInfoPtr:
* *
...@@ -682,6 +734,10 @@ char * virDomainScreenshot (virDomainPtr domain, ...@@ -682,6 +734,10 @@ char * virDomainScreenshot (virDomainPtr domain,
*/ */
int virDomainGetInfo (virDomainPtr domain, int virDomainGetInfo (virDomainPtr domain,
virDomainInfoPtr info); virDomainInfoPtr info);
int virDomainGetState (virDomainPtr domain,
int *state,
int *reason,
unsigned int flags);
/* /*
* Return scheduler type in effect 'sedf', 'credit', 'linux' * Return scheduler type in effect 'sedf', 'credit', 'linux'
......
...@@ -293,6 +293,7 @@ skip_impl = ( ...@@ -293,6 +293,7 @@ skip_impl = (
'virConnGetLastError', 'virConnGetLastError',
'virGetLastError', 'virGetLastError',
'virDomainGetInfo', 'virDomainGetInfo',
'virDomainGetState',
'virDomainGetBlockInfo', 'virDomainGetBlockInfo',
'virDomainGetJobInfo', 'virDomainGetJobInfo',
'virNodeGetInfo', 'virNodeGetInfo',
......
...@@ -48,6 +48,12 @@ ...@@ -48,6 +48,12 @@
<return type='int *' info='the list of information or None in case of error'/> <return type='int *' info='the list of information or None in case of error'/>
<arg name='domain' type='virDomainPtr' info='a domain object'/> <arg name='domain' type='virDomainPtr' info='a domain object'/>
</function> </function>
<function name='virDomainGetState' file='python'>
<info>Extract domain state.</info>
<return type='int *' info='the list containing state and reason or None in case of error'/>
<arg name='domain' type='virDomainPtr' info='a domain object'/>
<arg name='flags' type='unsigned int' info='additional flags'/>
</function>
<function name='virDomainGetBlockInfo' file='python'> <function name='virDomainGetBlockInfo' file='python'>
<info>Extract information about a domain block device size</info> <info>Extract information about a domain block device size</info>
<return type='int *' info='the list of information or None in case of error'/> <return type='int *' info='the list of information or None in case of error'/>
......
...@@ -1067,6 +1067,35 @@ libvirt_virDomainGetInfo(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) { ...@@ -1067,6 +1067,35 @@ libvirt_virDomainGetInfo(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
return(py_retval); 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 * static PyObject *
libvirt_virDomainGetBlockInfo(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) { libvirt_virDomainGetBlockInfo(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
PyObject *py_retval; PyObject *py_retval;
...@@ -3527,6 +3556,7 @@ static PyMethodDef libvirtMethods[] = { ...@@ -3527,6 +3556,7 @@ static PyMethodDef libvirtMethods[] = {
{(char *) "virConnectDomainEventRegisterAny", libvirt_virConnectDomainEventRegisterAny, METH_VARARGS, NULL}, {(char *) "virConnectDomainEventRegisterAny", libvirt_virConnectDomainEventRegisterAny, METH_VARARGS, NULL},
{(char *) "virConnectDomainEventDeregisterAny", libvirt_virConnectDomainEventDeregisterAny, METH_VARARGS, NULL}, {(char *) "virConnectDomainEventDeregisterAny", libvirt_virConnectDomainEventDeregisterAny, METH_VARARGS, NULL},
{(char *) "virDomainGetInfo", libvirt_virDomainGetInfo, 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 *) "virDomainGetBlockInfo", libvirt_virDomainGetBlockInfo, METH_VARARGS, NULL},
{(char *) "virNodeGetInfo", libvirt_virNodeGetInfo, METH_VARARGS, NULL}, {(char *) "virNodeGetInfo", libvirt_virNodeGetInfo, METH_VARARGS, NULL},
{(char *) "virDomainGetUUID", libvirt_virDomainGetUUID, METH_VARARGS, NULL}, {(char *) "virDomainGetUUID", libvirt_virDomainGetUUID, METH_VARARGS, NULL},
......
...@@ -438,6 +438,7 @@ LIBVIRT_0.9.0 { ...@@ -438,6 +438,7 @@ LIBVIRT_0.9.0 {
LIBVIRT_0.9.2 { LIBVIRT_0.9.2 {
global: global:
virDomainGetState;
virDomainInjectNMI; virDomainInjectNMI;
virDomainScreenshot; virDomainScreenshot;
} LIBVIRT_0.9.0; } LIBVIRT_0.9.0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册