Add public API for getting migration speed

Includes impl of python binding since the generator was not
able to cope.

Note: Requires gendispatch.pl patch from Matthias Bolte

https://www.redhat.com/archives/libvir-list/2011-August/msg01367.html
This commit is contained in:
Jim Fehlig 2011-08-26 12:10:21 -06:00 committed by Jim Fehlig
parent d1535e668a
commit b12354befe
12 changed files with 122 additions and 2 deletions

View File

@ -1643,7 +1643,8 @@ class CParser:
"virDomainSetMemory" : (False, ("memory")),
"virDomainSetMemoryFlags" : (False, ("memory")),
"virDomainBlockJobSetSpeed" : (False, ("bandwidth")),
"virDomainBlockPull" : (False, ("bandwidth")) }
"virDomainBlockPull" : (False, ("bandwidth")),
"virDomainMigrateGetMaxSpeed" : (False, ("bandwidth")) }
def checkLongLegacyFunction(self, name, return_type, signature):
if "long" in return_type and "long long" not in return_type:

View File

@ -712,6 +712,10 @@ int virDomainMigrateSetMaxSpeed(virDomainPtr domain,
unsigned long bandwidth,
unsigned int flags);
int virDomainMigrateGetMaxSpeed(virDomainPtr domain,
unsigned long *bandwidth,
unsigned int flags);
/**
* VIR_NODEINFO_MAXCPUS:
* @nodeinfo: virNodeInfo instance

View File

@ -372,6 +372,7 @@ skip_impl = (
'virNodeGetCPUStats',
'virNodeGetMemoryStats',
'virDomainGetBlockJobInfo',
'virDomainMigrateGetMaxSpeed',
)

View File

@ -356,5 +356,11 @@
<arg name='flags' type='unsigned int' info='fine-tuning flags, currently unused, pass 0.'/>
<return type='virDomainBlockJobInfo' info='A dictionary containing job information.' />
</function>
<function name='virDomainMigrateGetMaxSpeed' file='python'>
<info>Get currently configured maximum migration speed for a domain</info>
<arg name='domain' type='virDomainPtr' info='a domain object'/>
<arg name='flags' type='unsigned int' info='flags, currently unused, pass 0.'/>
<return type='unsigned long' info='current max migration speed, or None in case of error'/>
</function>
</symbols>
</api>

View File

@ -4543,6 +4543,29 @@ libvirt_virDomainSendKey(PyObject *self ATTRIBUTE_UNUSED,
return py_retval;
}
static PyObject *
libvirt_virDomainMigrateGetMaxSpeed(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
PyObject *py_retval;
int c_retval;
unsigned long bandwidth;
virDomainPtr domain;
PyObject *pyobj_domain;
if (!PyArg_ParseTuple(args, (char *)"O:virDomainMigrateGetMaxSpeed", &pyobj_domain))
return(NULL);
domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
LIBVIRT_BEGIN_ALLOW_THREADS;
c_retval = virDomainMigrateGetMaxSpeed(domain, &bandwidth, 0);
LIBVIRT_END_ALLOW_THREADS;
if (c_retval < 0)
return VIR_PY_INT_FAIL;
py_retval = libvirt_ulongWrap(bandwidth);
return(py_retval);
}
/************************************************************************
* *
* The registration stuff *
@ -4632,6 +4655,7 @@ static PyMethodDef libvirtMethods[] = {
{(char *) "virDomainRevertToSnapshot", libvirt_virDomainRevertToSnapshot, METH_VARARGS, NULL},
{(char *) "virDomainGetBlockJobInfo", libvirt_virDomainGetBlockJobInfo, METH_VARARGS, NULL},
{(char *) "virDomainSendKey", libvirt_virDomainSendKey, METH_VARARGS, NULL},
{(char *) "virDomainMigrateGetMaxSpeed", libvirt_virDomainMigrateGetMaxSpeed, METH_VARARGS, NULL},
{NULL, NULL, 0, NULL}
};

View File

@ -531,6 +531,11 @@ typedef int
unsigned long bandwidth,
unsigned int flags);
typedef int
(*virDrvDomainMigrateGetMaxSpeed)(virDomainPtr domain,
unsigned long *bandwidth,
unsigned int flags);
typedef int
(*virDrvDomainEventRegisterAny)(virConnectPtr conn,
virDomainPtr dom,
@ -828,6 +833,7 @@ struct _virDriver {
virDrvDomainGetJobInfo domainGetJobInfo;
virDrvDomainAbortJob domainAbortJob;
virDrvDomainMigrateSetMaxDowntime domainMigrateSetMaxDowntime;
virDrvDomainMigrateGetMaxSpeed domainMigrateGetMaxSpeed;
virDrvDomainMigrateSetMaxSpeed domainMigrateSetMaxSpeed;
virDrvDomainEventRegisterAny domainEventRegisterAny;
virDrvDomainEventDeregisterAny domainEventDeregisterAny;

View File

@ -15197,6 +15197,57 @@ error:
return -1;
}
/**
* virDomainMigrateGetMaxSpeed:
* @domain: a domain object
* @bandwidth: return value of current migration bandwidth limit in Mbps
* @flags: fine-tuning flags, currently unused, use 0
*
* Get the current maximum bandwidth (in Mbps) that will be used if the
* domain is migrated. Not all hypervisors will support a bandwidth limit.
*
* Returns 0 in case of success, -1 otherwise.
*/
int
virDomainMigrateGetMaxSpeed(virDomainPtr domain,
unsigned long *bandwidth,
unsigned int flags)
{
virConnectPtr conn;
VIR_DOMAIN_DEBUG(domain, "bandwidth = %p, flags=%x", bandwidth, flags);
virResetLastError();
if (!VIR_IS_CONNECTED_DOMAIN(domain)) {
virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
virDispatchError(NULL);
return -1;
}
if (!bandwidth) {
virLibDomainError(VIR_ERR_INVALID_ARG, __FUNCTION__);
goto error;
}
conn = domain->conn;
if (conn->flags & VIR_CONNECT_RO) {
virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__);
goto error;
}
if (conn->driver->domainMigrateGetMaxSpeed) {
if (conn->driver->domainMigrateGetMaxSpeed(domain, bandwidth, flags) < 0)
goto error;
return 0;
}
virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__);
error:
virDispatchError(conn);
return -1;
}
/**
* virConnectDomainEventRegisterAny:
* @conn: pointer to the connection

View File

@ -480,4 +480,9 @@ LIBVIRT_0.9.4 {
virDomainBlockPull;
} LIBVIRT_0.9.3;
LIBVIRT_0.9.5 {
global:
virDomainMigrateGetMaxSpeed;
} LIBVIRT_0.9.4;
# .... define new API here using predicted next version number ....

View File

@ -4335,6 +4335,7 @@ static virDriver remote_driver = {
.domainAbortJob = remoteDomainAbortJob, /* 0.7.7 */
.domainMigrateSetMaxDowntime = remoteDomainMigrateSetMaxDowntime, /* 0.8.0 */
.domainMigrateSetMaxSpeed = remoteDomainMigrateSetMaxSpeed, /* 0.9.0 */
.domainMigrateGetMaxSpeed = remoteDomainMigrateGetMaxSpeed, /* 0.9.5 */
.domainEventRegisterAny = remoteDomainEventRegisterAny, /* 0.8.0 */
.domainEventDeregisterAny = remoteDomainEventDeregisterAny, /* 0.8.0 */
.domainManagedSave = remoteDomainManagedSave, /* 0.8.0 */

View File

@ -1913,6 +1913,16 @@ struct remote_domain_migrate_set_max_speed_args {
unsigned int flags;
};
struct remote_domain_migrate_get_max_speed_args {
remote_nonnull_domain dom;
unsigned int flags;
};
struct remote_domain_migrate_get_max_speed_ret {
unsigned hyper bandwidth; /* insert@1 */
};
struct remote_domain_events_register_any_args {
int eventID;
};
@ -2475,7 +2485,8 @@ enum remote_procedure {
REMOTE_PROC_DOMAIN_BLOCK_JOB_SET_SPEED = 239, /* autogen autogen */
REMOTE_PROC_DOMAIN_BLOCK_PULL = 240, /* autogen autogen */
REMOTE_PROC_DOMAIN_EVENT_BLOCK_JOB = 241 /* skipgen skipgen */
REMOTE_PROC_DOMAIN_EVENT_BLOCK_JOB = 241, /* skipgen skipgen */
REMOTE_PROC_DOMAIN_MIGRATE_GET_MAX_SPEED = 242 /* autogen autogen */
/*
* Notice how the entries are grouped in sets of 10 ?

View File

@ -1429,6 +1429,14 @@ struct remote_domain_migrate_set_max_speed_args {
uint64_t bandwidth;
u_int flags;
};
struct remote_domain_migrate_get_max_speed_args {
remote_nonnull_domain dom;
u_int flags;
};
struct remote_domain_migrate_get_max_speed_ret {
uint64_t bandwidth;
};
struct remote_domain_events_register_any_args {
int eventID;
};
@ -1936,4 +1944,5 @@ enum remote_procedure {
REMOTE_PROC_DOMAIN_BLOCK_JOB_SET_SPEED = 239,
REMOTE_PROC_DOMAIN_BLOCK_PULL = 240,
REMOTE_PROC_DOMAIN_EVENT_BLOCK_JOB = 241,
REMOTE_PROC_DOMAIN_MIGRATE_GET_MAX_SPEED = 242,
};

View File

@ -222,6 +222,7 @@ my $long_legacy = {
NodeGetInfo => { ret => { memory => 1 } },
DomainBlockPull => { arg => { bandwidth => 1 } },
DomainBlockJobSetSpeed => { arg => { bandwidth => 1 } },
DomainMigrateGetMaxSpeed => { ret => { bandwidth => 1 } },
};
sub hyper_to_long