[libvirt] [PATCH ] send-key: Implement Python API
Wen Congyang
wency at cn.fujitsu.com
Wed Jul 27 07:13:03 UTC 2011
At 07/26/2011 06:26 PM, Daniel P. Berrange Write:
> On Thu, Jul 21, 2011 at 05:21:10PM +0800, Lai Jiangshan wrote:
>>
>> Signed-off-by: Lai Jiangshan <laijs at cn.fujitsu.com>
>> ---
>> diff --git a/python/libvirt-override.c b/python/libvirt-override.c
>> index b713b6a..1ef5bfa 100644
>> --- a/python/libvirt-override.c
>> +++ b/python/libvirt-override.c
>> @@ -3789,6 +3789,53 @@ libvirt_virStreamSend(PyObject *self ATTRIBUTE_UNUSED,
>> return py_retval;
>> }
>>
>> +static PyObject *
>> +libvirt_virDomainSendKey(PyObject *self ATTRIBUTE_UNUSED,
>> + PyObject *args)
>> +{
>> + PyObject *py_retval;
>> + virDomainPtr domain;
>> + PyObject *pyobj_domain;
>> + PyObject *pyobj_list;
>> + int codeset;
>> + int holdtime;
>> + unsigned int flags;
>> + int ret;
>> + int i;
>> + unsigned int keycodes[VIR_DOMAIN_SEND_KEY_MAX_KEYS];
>> + unsigned int nkeycodes;
>> +
>> + if (!PyArg_ParseTuple(args, (char *)"OiiOii:virDomainSendKey",
>> + &pyobj_domain, &codeset, &holdtime, &pyobj_list,
>> + &nkeycodes, &flags)) {
>> + DEBUG("%s failed to parse tuple\n", __FUNCTION__);
>> + return VIR_PY_INT_FAIL;
>> + }
>> + domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
>> +
>> + if (!PyList_Check(pyobj_list)) {
>> + return VIR_PY_INT_FAIL;
>> + }
>> +
>> + if (nkeycodes != PyList_Size(pyobj_list) ||
>> + nkeycodes > VIR_DOMAIN_SEND_KEY_MAX_KEYS) {
>> + return VIR_PY_INT_FAIL;
>> + }
>> +
>> + for (i = 0; i < nkeycodes; i++) {
>> + keycodes[i] = (int)PyInt_AsLong(PyList_GetItem(pyobj_list, i));
>> + }
>> +
>> + LIBVIRT_BEGIN_ALLOW_THREADS;
>> + ret = virDomainSendKey(domain, codeset, holdtime, keycodes, nkeycodes, flags);
>> + LIBVIRT_END_ALLOW_THREADS;
>> +
>> + DEBUG("virDomainSendKey ret=%d\n", ret);
>> +
>> + py_retval = libvirt_intWrap(ret);
>> + return py_retval;
>> +}
>> +
>> /************************************************************************
>> * *
>> * The registration stuff *
>> @@ -3872,6 +3919,7 @@ static PyMethodDef libvirtMethods[] = {
>> {(char *) "virDomainGetJobInfo", libvirt_virDomainGetJobInfo, METH_VARARGS, NULL},
>> {(char *) "virDomainSnapshotListNames", libvirt_virDomainSnapshotListNames, METH_VARARGS, NULL},
>> {(char *) "virDomainRevertToSnapshot", libvirt_virDomainRevertToSnapshot, METH_VARARGS, NULL},
>> + {(char *) "virDomainSendKey", libvirt_virDomainSendKey, METH_VARARGS, NULL},
>> {NULL, NULL, 0, NULL}
>> };
>
> ACK
I read the other patch about implementing Python API, and find that the file
python/libvirt-override-api.xml is updated in the other patch. But it is not updated
in this patch. Is there no need to update this file here?
Thanks
Wen Congyang
>
> Daniel
More information about the libvir-list
mailing list