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.
---
There is a race between this patch and Matthias' libvirt.c cleanup
(
https://www.redhat.com/archives/libvir-list/2011-May/msg01105.html);
whoever pushes first wins and the other better remember to
rebase the patch to do NULL parameter checking on today's new API.
include/libvirt/libvirt.h.in | 8 ++--
python/generator.py | 1 +
src/driver.h | 8 ++++
src/libvirt.c | 84 +++++++++++++++++++++++++++++++++++++----
src/libvirt_public.syms | 1 +
5 files changed, 89 insertions(+), 13 deletions(-)
diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index 7cd6e13..efd205b 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -383,6 +383,10 @@ typedef virSchedParameter *virSchedParameterPtr;
int virDomainGetSchedulerParameters (virDomainPtr domain,
virSchedParameterPtr params,
int *nparams);
+int virDomainGetSchedulerParametersFlags (virDomainPtr domain,
+ virSchedParameterPtr params,
+ int *nparams,
+ unsigned int flags);
/*
* Change scheduler parameters
@@ -390,10 +394,6 @@ int virDomainGetSchedulerParameters (virDomainPtr domain,
int virDomainSetSchedulerParameters (virDomainPtr domain,
virSchedParameterPtr params,
int nparams);
-
-/*
- * Change scheduler parameters
- */
int virDomainSetSchedulerParametersFlags (virDomainPtr domain,
virSchedParameterPtr 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 450dd53..b8417d1 100644
--- a/src/driver.h
+++ b/src/driver.h
@@ -280,6 +280,13 @@ typedef int
int *nparams);
typedef int
+ (*virDrvDomainGetSchedulerParametersFlags)
+ (virDomainPtr domain,
+ virSchedParameterPtr params,
+ int *nparams,
+ unsigned int flags);
+
+typedef int
(*virDrvDomainSetSchedulerParameters)
(virDomainPtr domain,
virSchedParameterPtr params,
@@ -683,6 +690,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 56b1257..a72bdf7 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -5021,7 +5021,9 @@ error:
* nparams of virDomainGetSchedulerType)
*
* Get the scheduler parameters, the @params array will be filled with the
- * values.
+ * values. 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.
*/
@@ -5058,14 +5060,76 @@ 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,
+ virSchedParameterPtr params, int *nparams,
+ unsigned int flags)
+{
+ virConnectPtr conn;
+
+ VIR_DOMAIN_DEBUG(domain, "params=%p, nparams=%p, flags=%u",
+ params, nparams, flags);
+
+ virResetLastError();
+
+ if (!(flags & (VIR_DOMAIN_SCHEDPARAM_LIVE |
+ VIR_DOMAIN_SCHEDPARAM_CONFIG |
+ VIR_DOMAIN_SCHEDPARAM_CURRENT))) {
+ virLibDomainError(VIR_ERR_INVALID_ARG, __FUNCTION__);
+ virDispatchError(NULL);
+ return -1;
+ }
+
+ if (!VIR_IS_CONNECTED_DOMAIN(domain)) {
+ virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
+ virDispatchError(NULL);
+ return -1;
+ }
+ 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
- * @nparams: number of scheduler parameter
- * (this value should be same or less than the returned value
- * nparams of virDomainGetSchedulerType)
+ * @nparams: number of scheduler parameter (should be non-zero, and the
+ * same or less than the returned value nparams of virDomainGetSchedulerType)
*
- * Change the scheduler parameters
+ * Change 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.
*/
@@ -5110,12 +5174,14 @@ error:
* virDomainSetSchedulerParametersFlags:
* @domain: pointer to domain object
* @params: pointer to scheduler parameter objects
- * @nparams: number of scheduler parameter
- * (this value should be same or less than the returned value
- * nparams of virDomainGetSchedulerType)
+ * @nparams: number of scheduler parameter (should be non-zero, and the
+ * same or less than the returned value nparams of virDomainGetSchedulerType)
* @flags: virDomainSchedParameterFlags
*
- * Change the scheduler parameters
+ * Change the 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 0590535..b7bede9 100644
--- a/src/libvirt_public.syms
+++ b/src/libvirt_public.syms
@@ -438,6 +438,7 @@ LIBVIRT_0.9.0 {
LIBVIRT_0.9.2 {
global:
+ virDomainGetSchedulerParametersFlags;
virDomainGetState;
virDomainInjectNMI;
virDomainScreenshot;
--
1.7.4.4