mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-25 01:34:11 +03:00
libvirt: implements virDomain{Get,Set}BlkioParameters
Implements virDomainSetBlkioParameters and virDomainGetBlkioParameters and initialization Signed-off-by: Gui Jianfeng <guijianfeng@cn.fujitsu.com>
This commit is contained in:
parent
13c5282122
commit
d55aa8694e
18
src/driver.h
18
src/driver.h
@ -149,6 +149,18 @@ typedef int
|
||||
virMemoryParameterPtr params,
|
||||
int *nparams,
|
||||
unsigned int flags);
|
||||
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
|
||||
(*virDrvDomainGetInfo) (virDomainPtr domain,
|
||||
virDomainInfoPtr info);
|
||||
@ -541,6 +553,10 @@ struct _virDriver {
|
||||
virDrvDomainSetMaxMemory domainSetMaxMemory;
|
||||
virDrvDomainSetMemory domainSetMemory;
|
||||
virDrvDomainSetMemoryFlags domainSetMemoryFlags;
|
||||
virDrvDomainSetMemoryParameters domainSetMemoryParameters;
|
||||
virDrvDomainGetMemoryParameters domainGetMemoryParameters;
|
||||
virDrvDomainSetBlkioParameters domainSetBlkioParameters;
|
||||
virDrvDomainGetBlkioParameters domainGetBlkioParameters;
|
||||
virDrvDomainGetInfo domainGetInfo;
|
||||
virDrvDomainSave domainSave;
|
||||
virDrvDomainRestore domainRestore;
|
||||
@ -616,8 +632,6 @@ struct _virDriver {
|
||||
virDrvDomainRevertToSnapshot domainRevertToSnapshot;
|
||||
virDrvDomainSnapshotDelete domainSnapshotDelete;
|
||||
virDrvQemuDomainMonitorCommand qemuDomainMonitorCommand;
|
||||
virDrvDomainSetMemoryParameters domainSetMemoryParameters;
|
||||
virDrvDomainGetMemoryParameters domainGetMemoryParameters;
|
||||
virDrvDomainOpenConsole domainOpenConsole;
|
||||
};
|
||||
|
||||
|
@ -4594,6 +4594,10 @@ static virDriver esxDriver = {
|
||||
esxDomainSetMaxMemory, /* domainSetMaxMemory */
|
||||
esxDomainSetMemory, /* domainSetMemory */
|
||||
NULL, /* domainSetMemoryFlags */
|
||||
esxDomainSetMemoryParameters, /* domainSetMemoryParameters */
|
||||
esxDomainGetMemoryParameters, /* domainGetMemoryParameters */
|
||||
NULL, /* domainSetBlkioParameters */
|
||||
NULL, /* domainGetBlkioParameters */
|
||||
esxDomainGetInfo, /* domainGetInfo */
|
||||
NULL, /* domainSave */
|
||||
NULL, /* domainRestore */
|
||||
@ -4669,8 +4673,6 @@ static virDriver esxDriver = {
|
||||
esxDomainRevertToSnapshot, /* domainRevertToSnapshot */
|
||||
esxDomainSnapshotDelete, /* domainSnapshotDelete */
|
||||
NULL, /* qemuDomainMonitorCommand */
|
||||
esxDomainSetMemoryParameters, /* domainSetMemoryParameters */
|
||||
esxDomainGetMemoryParameters, /* domainGetMemoryParameters */
|
||||
NULL, /* domainOpenConsole */
|
||||
};
|
||||
|
||||
|
109
src/libvirt.c
109
src/libvirt.c
@ -2907,7 +2907,6 @@ error:
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* virDomainSetMemoryParameters:
|
||||
* @domain: pointer to domain object
|
||||
@ -3034,6 +3033,114 @@ error:
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* virDomainSetBlkioParameters:
|
||||
* @domain: pointer to domain object
|
||||
* @params: pointer to blkio parameter objects
|
||||
* @nparams: number of blkio parameters (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;
|
||||
}
|
||||
|
||||
/**
|
||||
* virDomainGetInfo:
|
||||
* @domain: a domain object
|
||||
|
@ -426,6 +426,8 @@ LIBVIRT_0.8.8 {
|
||||
|
||||
LIBVIRT_0.9.0 {
|
||||
global:
|
||||
virDomainGetBlkioParameters;
|
||||
virDomainSetBlkioParameters;
|
||||
virDomainSetMemoryFlags;
|
||||
virEventRegisterDefaultImpl;
|
||||
virEventRunDefaultImpl;
|
||||
|
@ -2852,6 +2852,10 @@ static virDriver lxcDriver = {
|
||||
lxcDomainSetMaxMemory, /* domainSetMaxMemory */
|
||||
lxcDomainSetMemory, /* domainSetMemory */
|
||||
NULL, /* domainSetMemoryFlags */
|
||||
lxcDomainSetMemoryParameters, /* domainSetMemoryParameters */
|
||||
lxcDomainGetMemoryParameters, /* domainGetMemoryParameters */
|
||||
NULL, /* domainSetBlkioParameters */
|
||||
NULL, /* domainGetBlkioParameters */
|
||||
lxcDomainGetInfo, /* domainGetInfo */
|
||||
NULL, /* domainSave */
|
||||
NULL, /* domainRestore */
|
||||
@ -2927,8 +2931,6 @@ static virDriver lxcDriver = {
|
||||
NULL, /* domainRevertToSnapshot */
|
||||
NULL, /* domainSnapshotDelete */
|
||||
NULL, /* qemuDomainMonitorCommand */
|
||||
lxcDomainSetMemoryParameters, /* domainSetMemoryParameters */
|
||||
lxcDomainGetMemoryParameters, /* domainGetMemoryParameters */
|
||||
lxcDomainOpenConsole, /* domainOpenConsole */
|
||||
};
|
||||
|
||||
|
@ -751,6 +751,10 @@ static virDriver oneDriver = {
|
||||
NULL, /* domainSetMaxMemory */
|
||||
NULL, /* domainSetMemory */
|
||||
NULL, /* domainSetMemoryFlags */
|
||||
NULL, /* domainSetMemoryParameters */
|
||||
NULL, /* domainGetMemoryParameters */
|
||||
NULL, /* domainSetBlkioParameters */
|
||||
NULL, /* domainGetBlkioParameters */
|
||||
oneDomainGetInfo, /* domainGetInfo */
|
||||
NULL, /* domainSave */
|
||||
NULL, /* domainRestore */
|
||||
@ -826,8 +830,6 @@ static virDriver oneDriver = {
|
||||
NULL, /* domainRevertToSnapshot */
|
||||
NULL, /* domainSnapshotDelete */
|
||||
NULL, /* qemuDomainMonitorCommand */
|
||||
NULL, /* domainSetMemoryParameters */
|
||||
NULL, /* domainGetMemoryParameters */
|
||||
NULL, /* domainOpenConsole */
|
||||
};
|
||||
|
||||
|
@ -1572,6 +1572,10 @@ static virDriver openvzDriver = {
|
||||
NULL, /* domainSetMaxMemory */
|
||||
NULL, /* domainSetMemory */
|
||||
NULL, /* domainSetMemoryFlags */
|
||||
NULL, /* domainSetMemoryParameters */
|
||||
NULL, /* domainGetMemoryParameters */
|
||||
NULL, /* domainSetBlkioParameters */
|
||||
NULL, /* domainGetBlkioParameters */
|
||||
openvzDomainGetInfo, /* domainGetInfo */
|
||||
NULL, /* domainSave */
|
||||
NULL, /* domainRestore */
|
||||
@ -1647,8 +1651,6 @@ static virDriver openvzDriver = {
|
||||
NULL, /* domainRevertToSnapshot */
|
||||
NULL, /* domainSnapshotDelete */
|
||||
NULL, /* qemuDomainMonitorCommand */
|
||||
NULL, /* domainSetMemoryParameters */
|
||||
NULL, /* domainGetMemoryParameters */
|
||||
NULL, /* domainOpenConsole */
|
||||
};
|
||||
|
||||
|
@ -3974,6 +3974,10 @@ static virDriver phypDriver = {
|
||||
NULL, /* domainSetMaxMemory */
|
||||
NULL, /* domainSetMemory */
|
||||
NULL, /* domainSetMemoryFlags */
|
||||
NULL, /* domainSetMemoryParameters */
|
||||
NULL, /* domainGetMemoryParameters */
|
||||
NULL, /* domainSetBlkioParameters */
|
||||
NULL, /* domainGetBlkioParameters */
|
||||
phypDomainGetInfo, /* domainGetInfo */
|
||||
NULL, /* domainSave */
|
||||
NULL, /* domainRestore */
|
||||
@ -4049,8 +4053,6 @@ static virDriver phypDriver = {
|
||||
NULL, /* domainRevertToSnapshot */
|
||||
NULL, /* domainSnapshotDelete */
|
||||
NULL, /* qemuMonitorCommand */
|
||||
NULL, /* domainSetMemoryParameters */
|
||||
NULL, /* domainGetMemoryParameters */
|
||||
NULL, /* domainOpenConsole */
|
||||
};
|
||||
|
||||
|
@ -6887,6 +6887,10 @@ static virDriver qemuDriver = {
|
||||
NULL, /* domainSetMaxMemory */
|
||||
qemudDomainSetMemory, /* domainSetMemory */
|
||||
qemudDomainSetMemoryFlags, /* domainSetMemoryFlags */
|
||||
qemuDomainSetMemoryParameters, /* domainSetMemoryParameters */
|
||||
qemuDomainGetMemoryParameters, /* domainGetMemoryParameters */
|
||||
NULL, /* domainSetBlkioParameters */
|
||||
NULL, /* domainGetBlkioParameters */
|
||||
qemudDomainGetInfo, /* domainGetInfo */
|
||||
qemudDomainSave, /* domainSave */
|
||||
qemudDomainRestore, /* domainRestore */
|
||||
@ -6962,8 +6966,6 @@ static virDriver qemuDriver = {
|
||||
qemuDomainRevertToSnapshot, /* domainRevertToSnapshot */
|
||||
qemuDomainSnapshotDelete, /* domainSnapshotDelete */
|
||||
qemuDomainMonitorCommand, /* qemuDomainMonitorCommand */
|
||||
qemuDomainSetMemoryParameters, /* domainSetMemoryParameters */
|
||||
qemuDomainGetMemoryParameters, /* domainGetMemoryParameters */
|
||||
qemuDomainOpenConsole, /* domainOpenConsole */
|
||||
};
|
||||
|
||||
|
@ -10904,6 +10904,10 @@ static virDriver remote_driver = {
|
||||
remoteDomainSetMaxMemory, /* domainSetMaxMemory */
|
||||
remoteDomainSetMemory, /* domainSetMemory */
|
||||
remoteDomainSetMemoryFlags, /* domainSetMemoryFlags */
|
||||
remoteDomainSetMemoryParameters, /* domainSetMemoryParameters */
|
||||
remoteDomainGetMemoryParameters, /* domainGetMemoryParameters */
|
||||
NULL, /* domainSetBlkioParameters */
|
||||
NULL, /* domainGetBlkioParameters */
|
||||
remoteDomainGetInfo, /* domainGetInfo */
|
||||
remoteDomainSave, /* domainSave */
|
||||
remoteDomainRestore, /* domainRestore */
|
||||
@ -10979,8 +10983,6 @@ static virDriver remote_driver = {
|
||||
remoteDomainRevertToSnapshot, /* domainRevertToSnapshot */
|
||||
remoteDomainSnapshotDelete, /* domainSnapshotDelete */
|
||||
remoteQemuDomainMonitorCommand, /* qemuDomainMonitorCommand */
|
||||
remoteDomainSetMemoryParameters, /* domainSetMemoryParameters */
|
||||
remoteDomainGetMemoryParameters, /* domainGetMemoryParameters */
|
||||
remoteDomainOpenConsole, /* domainOpenConsole */
|
||||
};
|
||||
|
||||
|
@ -5366,6 +5366,10 @@ static virDriver testDriver = {
|
||||
testSetMaxMemory, /* domainSetMaxMemory */
|
||||
testSetMemory, /* domainSetMemory */
|
||||
NULL, /* domainSetMemoryFlags */
|
||||
NULL, /* domainSetMemoryParameters */
|
||||
NULL, /* domainGetMemoryParameters */
|
||||
NULL, /* domainSetBlkioParameters */
|
||||
NULL, /* domainGetBlkioParameters */
|
||||
testGetDomainInfo, /* domainGetInfo */
|
||||
testDomainSave, /* domainSave */
|
||||
testDomainRestore, /* domainRestore */
|
||||
@ -5441,8 +5445,6 @@ static virDriver testDriver = {
|
||||
NULL, /* domainRevertToSnapshot */
|
||||
NULL, /* domainSnapshotDelete */
|
||||
NULL, /* qemuDomainMonitorCommand */
|
||||
NULL, /* domainSetMemoryParameters */
|
||||
NULL, /* domainGetMemoryParameters */
|
||||
NULL, /* domainOpenConsole */
|
||||
};
|
||||
|
||||
|
@ -2168,6 +2168,10 @@ static virDriver umlDriver = {
|
||||
umlDomainSetMaxMemory, /* domainSetMaxMemory */
|
||||
umlDomainSetMemory, /* domainSetMemory */
|
||||
NULL, /* domainSetMemoryFlags */
|
||||
NULL, /* domainSetMemoryParameters */
|
||||
NULL, /* domainGetMemoryParameters */
|
||||
NULL, /* domainSetBlkioParameters */
|
||||
NULL, /* domainGetBlkioParameters */
|
||||
umlDomainGetInfo, /* domainGetInfo */
|
||||
NULL, /* domainSave */
|
||||
NULL, /* domainRestore */
|
||||
@ -2243,8 +2247,6 @@ static virDriver umlDriver = {
|
||||
NULL, /* domainRevertToSnapshot */
|
||||
NULL, /* domainSnapshotDelete */
|
||||
NULL, /* qemuDomainMonitorCommand */
|
||||
NULL, /* domainSetMemoryParamters */
|
||||
NULL, /* domainGetMemoryParamters */
|
||||
umlDomainOpenConsole, /* domainOpenConsole */
|
||||
};
|
||||
|
||||
|
@ -8556,6 +8556,10 @@ virDriver NAME(Driver) = {
|
||||
NULL, /* domainSetMaxMemory */
|
||||
vboxDomainSetMemory, /* domainSetMemory */
|
||||
NULL, /* domainSetMemoryFlags */
|
||||
NULL, /* domainSetMemoryParameters */
|
||||
NULL, /* domainGetMemoryParameters */
|
||||
NULL, /* domainSetBlkioParameters */
|
||||
NULL, /* domainGetBlkioParameters */
|
||||
vboxDomainGetInfo, /* domainGetInfo */
|
||||
vboxDomainSave, /* domainSave */
|
||||
NULL, /* domainRestore */
|
||||
@ -8641,8 +8645,6 @@ virDriver NAME(Driver) = {
|
||||
vboxDomainRevertToSnapshot, /* domainRevertToSnapshot */
|
||||
vboxDomainSnapshotDelete, /* domainSnapshotDelete */
|
||||
NULL, /* qemuDomainMonitorCommand */
|
||||
NULL, /* domainSetMemoryParameters */
|
||||
NULL, /* domainGetMemoryParameters */
|
||||
NULL, /* domainOpenConsole */
|
||||
};
|
||||
|
||||
|
@ -926,6 +926,10 @@ static virDriver vmwareDriver = {
|
||||
NULL, /* domainSetMaxMemory */
|
||||
NULL, /* domainSetMemory */
|
||||
NULL, /* domainSetMemoryFlags */
|
||||
NULL, /* domainSetMemoryParameters */
|
||||
NULL, /* domainGetMemoryParameters */
|
||||
NULL, /* domainSetBlkioParameters */
|
||||
NULL, /* domainGetBlkioParameters */
|
||||
vmwareDomainGetInfo, /* domainGetInfo */
|
||||
NULL, /* domainSave */
|
||||
NULL, /* domainRestore */
|
||||
@ -1001,8 +1005,6 @@ static virDriver vmwareDriver = {
|
||||
NULL, /* domainRevertToSnapshot */
|
||||
NULL, /* domainSnapshotDelete */
|
||||
NULL, /* qemuDomainMonitorCommand */
|
||||
NULL, /* domainSetMemoryParameters */
|
||||
NULL, /* domainGetMemoryParameters */
|
||||
NULL, /* domainOpenConsole */
|
||||
};
|
||||
|
||||
|
@ -2035,6 +2035,10 @@ static virDriver xenUnifiedDriver = {
|
||||
xenUnifiedDomainSetMaxMemory, /* domainSetMaxMemory */
|
||||
xenUnifiedDomainSetMemory, /* domainSetMemory */
|
||||
NULL, /*domainSetMemoryFlags */
|
||||
NULL, /* domainSetMemoryParameters */
|
||||
NULL, /* domainGetMemoryParameters */
|
||||
NULL, /* domainSetBlkioParameters */
|
||||
NULL, /* domainGetBlkioParameters */
|
||||
xenUnifiedDomainGetInfo, /* domainGetInfo */
|
||||
xenUnifiedDomainSave, /* domainSave */
|
||||
xenUnifiedDomainRestore, /* domainRestore */
|
||||
@ -2110,8 +2114,6 @@ static virDriver xenUnifiedDriver = {
|
||||
NULL, /* domainRevertToSnapshot */
|
||||
NULL, /* domainSnapshotDelete */
|
||||
NULL, /* qemuDomainMonitorCommand */
|
||||
NULL, /* domainSetMemoryParameters */
|
||||
NULL, /* domainGetMemoryParameters */
|
||||
xenUnifiedDomainOpenConsole, /* domainOpenConsole */
|
||||
};
|
||||
|
||||
|
@ -1804,6 +1804,10 @@ static virDriver xenapiDriver = {
|
||||
xenapiDomainSetMaxMemory, /* domainSetMaxMemory */
|
||||
NULL, /* domainSetMemory */
|
||||
NULL, /* domainSetMemoryFlags */
|
||||
NULL, /* domainSetMemoryParameters */
|
||||
NULL, /* domainGetMemoryParameters */
|
||||
NULL, /* domainSetBlkioParameters */
|
||||
NULL, /* domainGetBlkioParameters */
|
||||
xenapiDomainGetInfo, /* domainGetInfo */
|
||||
NULL, /* domainSave */
|
||||
NULL, /* domainRestore */
|
||||
@ -1879,8 +1883,6 @@ static virDriver xenapiDriver = {
|
||||
NULL, /* domainRevertToSnapshot */
|
||||
NULL, /* domainSnapshotDelete */
|
||||
NULL, /* qemuDomainMonitorCommand */
|
||||
NULL, /* domainSetMemoryParameters */
|
||||
NULL, /* domainGetMemoryParameters */
|
||||
NULL, /* domainOpenConsole */
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user