Implements virDomainSetBlkioParameters and virDomainGetBlkioParameters and initialization
Signed-off-by: Gui Jianfeng <guijianfeng(a)cn.fujitsu.com>
---
src/driver.h | 14 ++++++
src/esx/esx_driver.c | 2 +
src/libvirt.c | 108 ++++++++++++++++++++++++++++++++++++++++++++
src/libvirt_public.syms | 6 +++
src/lxc/lxc_driver.c | 2 +
src/openvz/openvz_driver.c | 2 +
src/phyp/phyp_driver.c | 2 +
src/qemu/qemu_driver.c | 2 +
src/remote/remote_driver.c | 2 +
src/test/test_driver.c | 2 +
src/uml/uml_driver.c | 2 +
src/vmware/vmware_driver.c | 2 +
src/xen/xen_driver.c | 2 +
13 files changed, 148 insertions(+), 0 deletions(-)
diff --git a/src/driver.h b/src/driver.h
index 7451004..608efe9 100644
--- a/src/driver.h
+++ b/src/driver.h
@@ -135,6 +135,18 @@ typedef int
(*virDrvDomainSetMemory) (virDomainPtr domain,
unsigned long memory);
typedef int
+ (*virDrvDomainSetBlkioParameters)
+ (virDomainPtr domain,
+ virBlkioParameterPtr params,
+ int nparams,
+ unsigned int flags);
+typedef int
+ (*virDrvDomainGetBlkioParameters)
+ (virDomainPtr domain,
+ virBlkioParameterPtr params,
+ int *nparams,
+ unsigned int flags);
+typedef int
(*virDrvDomainSetMemoryParameters)
(virDomainPtr domain,
virMemoryParameterPtr params,
@@ -615,6 +627,8 @@ struct _virDriver {
virDrvDomainSetMemoryParameters domainSetMemoryParameters;
virDrvDomainGetMemoryParameters domainGetMemoryParameters;
virDrvDomainOpenConsole domainOpenConsole;
+ virDrvDomainSetBlkioParameters domainSetBlkioParameters;
+ virDrvDomainGetBlkioParameters domainGetBlkioParameters;
};
typedef int
diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c
index 116ad0f..675c266 100644
--- a/src/esx/esx_driver.c
+++ b/src/esx/esx_driver.c
@@ -4655,6 +4655,8 @@ static virDriver esxDriver = {
esxDomainSetMemoryParameters, /* domainSetMemoryParameters */
esxDomainGetMemoryParameters, /* domainGetMemoryParameters */
NULL, /* domainOpenConsole */
+ NULL, /* domainSetBlkioParameters */
+ NULL, /* domainGetBlkioParameters */
};
diff --git a/src/libvirt.c b/src/libvirt.c
index f65cc24..b79f3c2 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -2847,6 +2847,114 @@ error:
}
/**
+ * virDomainSetBlkioParameters:
+ * @domain: pointer to domain object
+ * @params: pointer to blkio parameter objects
+ * @nparams: number of blkio parameter (this value should be same or
+ * less than the number of parameters supported)
+ * @flags: currently unused, for future extension
+ *
+ * Change the blkio tunables
+ * This function requires privileged access to the hypervisor.
+ *
+ * Returns -1 in case of error, 0 in case of success.
+ */
+int
+virDomainSetBlkioParameters(virDomainPtr domain,
+ virBlkioParameterPtr params,
+ int nparams, unsigned int flags)
+{
+ virConnectPtr conn;
+
+ VIR_DOMAIN_DEBUG(domain, "params=%p, nparams=%d, flags=%u",
+ params, nparams, flags);
+
+ virResetLastError();
+
+ if (!VIR_IS_CONNECTED_DOMAIN(domain)) {
+ virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
+ virDispatchError(NULL);
+ return -1;
+ }
+ if (domain->conn->flags & VIR_CONNECT_RO) {
+ virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__);
+ goto error;
+ }
+ if ((nparams <= 0) || (params == NULL)) {
+ virLibDomainError(VIR_ERR_INVALID_ARG, __FUNCTION__);
+ goto error;
+ }
+ conn = domain->conn;
+
+ if (conn->driver->domainSetBlkioParameters) {
+ int ret;
+ ret = conn->driver->domainSetBlkioParameters (domain, params, nparams,
flags);
+ if (ret < 0)
+ goto error;
+ return ret;
+ }
+
+ virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ virDispatchError(domain->conn);
+ return -1;
+}
+
+/**
+ * virDomainGetBlkioParameters:
+ * @domain: pointer to domain object
+ * @params: pointer to blkio parameter object
+ * (return value, allocated by the caller)
+ * @nparams: pointer to number of blkio parameters
+ * @flags: currently unused, for future extension
+ *
+ * Get the blkio parameters, the @params array will be filled with the values
+ * equal to the number of parameters suggested by @nparams
+ *
+ * This function requires privileged access to the hypervisor. This function
+ * expects the caller to allocate the @params.
+ *
+ * Returns -1 in case of error, 0 in case of success.
+ */
+int
+virDomainGetBlkioParameters(virDomainPtr domain,
+ virBlkioParameterPtr params,
+ int *nparams, unsigned int flags)
+{
+ virConnectPtr conn;
+
+ VIR_DOMAIN_DEBUG(domain, "params=%p, nparams=%d, flags=%u",
+ params, (nparams) ? *nparams : -1, flags);
+
+ virResetLastError();
+
+ if (!VIR_IS_CONNECTED_DOMAIN(domain)) {
+ virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
+ virDispatchError(NULL);
+ return -1;
+ }
+ if ((nparams == NULL) || (*nparams < 0)) {
+ virLibDomainError(VIR_ERR_INVALID_ARG, __FUNCTION__);
+ goto error;
+ }
+ conn = domain->conn;
+
+ if (conn->driver->domainGetBlkioParameters) {
+ int ret;
+ ret = conn->driver->domainGetBlkioParameters (domain, params, nparams,
flags);
+ if (ret < 0)
+ goto error;
+ return ret;
+ }
+ virLibConnError (VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ virDispatchError(domain->conn);
+ return -1;
+}
+
+/**
* virDomainSetMemoryParameters:
* @domain: pointer to domain object
* @params: pointer to memory parameter objects
diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms
index 1a45be1..9dea737 100644
--- a/src/libvirt_public.syms
+++ b/src/libvirt_public.syms
@@ -424,4 +424,10 @@ LIBVIRT_0.8.8 {
virConnectGetSysinfo;
} LIBVIRT_0.8.6;
+LIBVIRT_0.8.9 {
+ global:
+ virDomainSetBlkioParameters;
+ virDomainGetBlkioParameters;
+} LIBVIRT_0.8.8;
+
# .... define new API here using predicted next version number ....
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index 0f78579..1940a16 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -2930,6 +2930,8 @@ static virDriver lxcDriver = {
lxcDomainSetMemoryParameters, /* domainSetMemoryParameters */
lxcDomainGetMemoryParameters, /* domainGetMemoryParameters */
lxcDomainOpenConsole, /* domainOpenConsole */
+ NULL, /* domainSetBlkioParameters */
+ NULL, /* domainGetBlkioParameters */
};
static virStateDriver lxcStateDriver = {
diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c
index 00d378a..5dec2c6 100644
--- a/src/openvz/openvz_driver.c
+++ b/src/openvz/openvz_driver.c
@@ -1669,6 +1669,8 @@ static virDriver openvzDriver = {
NULL, /* domainSetMemoryParameters */
NULL, /* domainGetMemoryParameters */
NULL, /* domainOpenConsole */
+ NULL, /* domainSetBlkioParameters */
+ NULL, /* domainGetBlkioParameters */
};
int openvzRegister(void) {
diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c
index d954f2a..a93efde 100644
--- a/src/phyp/phyp_driver.c
+++ b/src/phyp/phyp_driver.c
@@ -4051,6 +4051,8 @@ static virDriver phypDriver = {
NULL, /* domainSetMemoryParameters */
NULL, /* domainGetMemoryParameters */
NULL, /* domainOpenConsole */
+ NULL, /* domainSetBlkioParameters */
+ NULL, /* domainGetBlkioParameters */
};
static virStorageDriver phypStorageDriver = {
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 0f25a2a..6b63ca1 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -6864,6 +6864,8 @@ static virDriver qemuDriver = {
qemuDomainSetMemoryParameters, /* domainSetMemoryParameters */
qemuDomainGetMemoryParameters, /* domainGetMemoryParameters */
qemuDomainOpenConsole, /* domainOpenConsole */
+ NULL, /* domainSetBlkioParameters */
+ NULL, /* domainGetBlkioParameters */
};
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index 4ca0d3b..6d148f1 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -10946,6 +10946,8 @@ static virDriver remote_driver = {
remoteDomainSetMemoryParameters, /* domainSetMemoryParameters */
remoteDomainGetMemoryParameters, /* domainGetMemoryParameters */
remoteDomainOpenConsole, /* domainOpenConsole */
+ NULL, /* domainSetBlkioParameters */
+ NULL, /* domainGetBlkioParameters */
};
static virNetworkDriver network_driver = {
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index 1937da0..081652d 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -5443,6 +5443,8 @@ static virDriver testDriver = {
NULL, /* domainSetMemoryParameters */
NULL, /* domainGetMemoryParameters */
NULL, /* domainOpenConsole */
+ NULL, /* domainSetBlkioParameters */
+ NULL, /* domainGetBlkioParameters */
};
static virNetworkDriver testNetworkDriver = {
diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c
index 2af8002..ef11070 100644
--- a/src/uml/uml_driver.c
+++ b/src/uml/uml_driver.c
@@ -2245,6 +2245,8 @@ static virDriver umlDriver = {
NULL, /* domainSetMemoryParamters */
NULL, /* domainGetMemoryParamters */
umlDomainOpenConsole, /* domainOpenConsole */
+ NULL, /* domainSetBlkioParameters */
+ NULL, /* domainGetBlkioParameters */
};
static int
diff --git a/src/vmware/vmware_driver.c b/src/vmware/vmware_driver.c
index 22b29d1..37e3346 100644
--- a/src/vmware/vmware_driver.c
+++ b/src/vmware/vmware_driver.c
@@ -1005,6 +1005,8 @@ static virDriver vmwareDriver = {
NULL, /* domainSetMemoryParameters */
NULL, /* domainGetMemoryParameters */
NULL, /* domainOpenConsole */
+ NULL, /* domainSetBlkioParameters */
+ NULL, /* domainGetBlkioParameters */
};
int
diff --git a/src/xen/xen_driver.c b/src/xen/xen_driver.c
index b14c8db..508ed40 100644
--- a/src/xen/xen_driver.c
+++ b/src/xen/xen_driver.c
@@ -2101,6 +2101,8 @@ static virDriver xenUnifiedDriver = {
NULL, /* domainSetMemoryParameters */
NULL, /* domainGetMemoryParameters */
xenUnifiedDomainOpenConsole, /* domainOpenConsole */
+ NULL, /* domainSetBlkioParameters */
+ NULL, /* domainGetBlkioParameters */
};
/**
--
1.7.1