If we can choose live or config when setting, then we need to be able to choose which one we are querying.
Also, make the documentation clear that set must use a non-empty subset (some of the hypervisors fail if params is NULL). * include/libvirt/libvirt.h.in (virDomainGetSchedulerParametersFlags): New prototype. * src/libvirt.c (virDomainGetSchedulerParametersFlags): Implement it. * src/libvirt_public.syms: Export it. * python/generator.py (skip_impl): Don't auto-generate. * src/driver.h (virDrvDomainGetSchedulerParametersFlags): New callback. --- diffs in v3: rework libvirt.c to match other recent changes (no flags checking, but do check for NULL arguments). All other 7 patches in this series are unchanged from v2. include/libvirt/libvirt.h.in | 8 ++-- python/generator.py | 1 + src/driver.h | 8 ++++ src/libvirt.c | 74 ++++++++++++++++++++++++++++++++++++++++-- src/libvirt_public.syms | 5 ++- 5 files changed, 87 insertions(+), 9 deletions(-) diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in index c1d028a..4a72a24 100644 --- a/include/libvirt/libvirt.h.in +++ b/include/libvirt/libvirt.h.in @@ -350,6 +350,10 @@ typedef enum { int virDomainGetSchedulerParameters (virDomainPtr domain, virTypedParameterPtr params, int *nparams); +int virDomainGetSchedulerParametersFlags (virDomainPtr domain, + virTypedParameterPtr params, + int *nparams, + unsigned int flags); /* * Change scheduler parameters @@ -357,10 +361,6 @@ int virDomainGetSchedulerParameters (virDomainPtr domain, int virDomainSetSchedulerParameters (virDomainPtr domain, virTypedParameterPtr params, int nparams); - -/* - * Change scheduler parameters - */ int virDomainSetSchedulerParametersFlags (virDomainPtr domain, virTypedParameterPtr params, int nparams, diff --git a/python/generator.py b/python/generator.py index 1741bba..7c38fdd 100755 --- a/python/generator.py +++ b/python/generator.py @@ -323,6 +323,7 @@ skip_impl = ( 'virNodeGetCellsFreeMemory', 'virDomainGetSchedulerType', 'virDomainGetSchedulerParameters', + 'virDomainGetSchedulerParametersFlags', 'virDomainSetSchedulerParameters', 'virDomainSetSchedulerParametersFlags', 'virDomainSetBlkioParameters', diff --git a/src/driver.h b/src/driver.h index 6ef19af..2e01bc6 100644 --- a/src/driver.h +++ b/src/driver.h @@ -280,6 +280,13 @@ typedef int int *nparams); typedef int + (*virDrvDomainGetSchedulerParametersFlags) + (virDomainPtr domain, + virTypedParameterPtr params, + int *nparams, + unsigned int flags); + +typedef int (*virDrvDomainSetSchedulerParameters) (virDomainPtr domain, virTypedParameterPtr params, @@ -686,6 +693,7 @@ struct _virDriver { virDrvDomainSetAutostart domainSetAutostart; virDrvDomainGetSchedulerType domainGetSchedulerType; virDrvDomainGetSchedulerParameters domainGetSchedulerParameters; + virDrvDomainGetSchedulerParametersFlags domainGetSchedulerParametersFlags; virDrvDomainSetSchedulerParameters domainSetSchedulerParameters; virDrvDomainSetSchedulerParametersFlags domainSetSchedulerParametersFlags; virDrvDomainMigratePrepare domainMigratePrepare; diff --git a/src/libvirt.c b/src/libvirt.c index 8317d14..4c8831a 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -5428,7 +5428,9 @@ error: * * Get all scheduler parameters, the @params array will be filled with the * values and @nparams will be updated to the number of valid elements in - * @params. + * @params. It is hypervisor specific whether this returns the live or + * persistent state; for more control, use + * virDomainGetSchedulerParametersFlags. * * Returns -1 in case of error, 0 in case of success. */ @@ -5471,6 +5473,65 @@ error: } /** + * virDomainGetSchedulerParametersFlags: + * @domain: pointer to domain object + * @params: pointer to scheduler parameter object + * (return value) + * @nparams: pointer to number of scheduler parameter + * (this value should be same than the returned value + * nparams of virDomainGetSchedulerType) + * @flags: virDomainSchedParameterFlags + * + * Get the scheduler parameters, the @params array will be filled with the + * values. + * + * The value of @flags can be exactly VIR_DOMAIN_SCHEDPARAM_CURRENT, + * VIR_DOMAIN_SCHEDPARAM_LIVE, or VIR_DOMAIN_SCHEDPARAM_CONFIG. + * + * Returns -1 in case of error, 0 in case of success. + */ +int +virDomainGetSchedulerParametersFlags(virDomainPtr domain, + virTypedParameterPtr params, int *nparams, + unsigned int flags) +{ + virConnectPtr conn; + + VIR_DOMAIN_DEBUG(domain, "params=%p, nparams=%p, flags=%u", + params, nparams, flags); + + virResetLastError(); + + if (!VIR_IS_CONNECTED_DOMAIN(domain)) { + virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); + virDispatchError(NULL); + return -1; + } + + if (params == NULL || nparams == NULL || *nparams <= 0) { + virLibDomainError(VIR_ERR_INVALID_ARG, __FUNCTION__); + goto error; + } + + conn = domain->conn; + + if (conn->driver->domainGetSchedulerParametersFlags) { + int ret; + ret = conn->driver->domainGetSchedulerParametersFlags (domain, params, + nparams, flags); + if (ret < 0) + goto error; + return ret; + } + + virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + +error: + virDispatchError(domain->conn); + return -1; +} + +/** * virDomainSetSchedulerParameters: * @domain: pointer to domain object * @params: pointer to scheduler parameter objects @@ -5478,7 +5539,10 @@ error: * (this value can be the same or less than the returned value * nparams of virDomainGetSchedulerType) * - * Change all or a subset or the scheduler parameters. + * Change all or a subset or the scheduler parameters. It is + * hypervisor-specific whether this sets live, persistent, or both + * settings; for more control, use + * virDomainSetSchedulerParametersFlags. * * Returns -1 in case of error, 0 in case of success. */ @@ -5534,7 +5598,11 @@ error: * nparams of virDomainGetSchedulerType) * @flags: virDomainSchedParameterFlags * - * Change a subset or all scheduler parameters. + * Change a subset or all scheduler parameters. The value of @flags + * should be either VIR_DOMAIN_SCHEDPARAM_CURRENT, or a bitwise-or of + * values from VIR_DOMAIN_SCHEDPARAM_LIVE and + * VIR_DOMAIN_SCHEDPARAM_CURRENT, although hypervisors vary in which + * flags are supported. * * Returns -1 in case of error, 0 in case of success. */ diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms index cd23f69..d3488d8 100644 --- a/src/libvirt_public.syms +++ b/src/libvirt_public.syms @@ -438,12 +438,13 @@ LIBVIRT_0.9.0 { LIBVIRT_0.9.2 { global: + virDomainGetSchedulerParametersFlags; virDomainGetState; virDomainInjectNMI; + virDomainMigrate2; + virDomainMigrateToURI2; virDomainScreenshot; virDomainSetSchedulerParametersFlags; - virDomainMigrate2; - virDomainMigrateToURI2; } LIBVIRT_0.9.0; # .... define new API here using predicted next version number .... -- 1.7.4.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list