提交 e8340a8b 编写于 作者: T Taku Izumi 提交者: Eric Blake

setmem: introduce a new libvirt API (virDomainSetMemoryFlags)

This patch introduces a new libvirt API (virDomainSetMemoryFlags) and
a flag (virDomainMemoryModFlags).
Signed-off-by: NTaku Izumi <izumi.taku@jp.fujitsu.com>
上级 a236732e
......@@ -157,6 +157,7 @@ Patches have also been contributed by:
Christophe Fergeau <teuf@gnome.org>
Markus Groß <gross@univention.de>
Phil Petty <phpetty@cisco.com>
Taku Izumi <izumi.taku@jp.fujitsu.com>
[....send patches to get your name here....]
......
......@@ -780,6 +780,13 @@ int virDomainGetMemoryParameters(virDomainPtr domain,
virMemoryParameterPtr params,
int *nparams, unsigned int flags);
/* Memory size modification flags. */
typedef enum {
VIR_DOMAIN_MEM_LIVE = (1 << 0), /* affect active domain */
VIR_DOMAIN_MEM_CONFIG = (1 << 1), /* affect next boot */
} virDomainMemoryModFlags;
/*
* Dynamic control of domains
*/
......@@ -795,6 +802,9 @@ int virDomainSetMaxMemory (virDomainPtr domain,
unsigned long memory);
int virDomainSetMemory (virDomainPtr domain,
unsigned long memory);
int virDomainSetMemoryFlags (virDomainPtr domain,
unsigned long memory,
unsigned int flags);
int virDomainGetMaxVcpus (virDomainPtr domain);
int virDomainGetSecurityLabel (virDomainPtr domain,
virSecurityLabelPtr seclabel);
......
......@@ -133,6 +133,10 @@ typedef int
typedef int
(*virDrvDomainSetMemory) (virDomainPtr domain,
unsigned long memory);
typedef int
(*virDrvDomainSetMemoryFlags) (virDomainPtr domain,
unsigned long memory,
unsigned int flags);
typedef int
(*virDrvDomainSetMemoryParameters)
(virDomainPtr domain,
......@@ -536,6 +540,7 @@ struct _virDriver {
virDrvDomainGetMaxMemory domainGetMaxMemory;
virDrvDomainSetMaxMemory domainSetMaxMemory;
virDrvDomainSetMemory domainSetMemory;
virDrvDomainSetMemoryFlags domainSetMemoryFlags;
virDrvDomainGetInfo domainGetInfo;
virDrvDomainSave domainSave;
virDrvDomainRestore domainRestore;
......
......@@ -4593,6 +4593,7 @@ static virDriver esxDriver = {
esxDomainGetMaxMemory, /* domainGetMaxMemory */
esxDomainSetMaxMemory, /* domainSetMaxMemory */
esxDomainSetMemory, /* domainSetMemory */
NULL, /* domainSetMemoryFlags */
esxDomainGetInfo, /* domainGetInfo */
NULL, /* domainSave */
NULL, /* domainRestore */
......
......@@ -2846,6 +2846,68 @@ error:
return -1;
}
/*
* virDomainSetMemoryFlags
* @domain: a domain object or NULL
* @memory: the memory size in kilobytes
* @flags: an OR'ed set of virDomainMemoryModFlags
*
* Dynamically change the target amount of physical memory allocated to a
* domain. If domain is NULL, then this change the amount of memory reserved
* to Domain0 i.e. the domain where the application runs.
* This funcation may requires privileged access to the hypervisor.
*
* @flags must include VIR_DOMAIN_MEM_LIVE to affect a running
* domain (which may fail if domain is not active), or
* VIR_DOMAIN_MEM_CONFIG to affect the next boot via the XML
* description of the domain. Both flags may be set.
*
* Returns 0 in case of success, -1 in case of failure.
*/
int
virDomainSetMemoryFlags(virDomainPtr domain, unsigned long memory,
unsigned int flags)
{
virConnectPtr conn;
VIR_DOMAIN_DEBUG(domain, "memory=%lu flags=%u", memory, 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 (memory < 4096 ||
(flags & (VIR_DOMAIN_MEM_LIVE | VIR_DOMAIN_MEM_CONFIG)) == 0) {
virLibDomainError(VIR_ERR_INVALID_ARG, __FUNCTION__);
goto error;
}
conn = domain->conn;
if (conn->driver->domainSetMemoryFlags) {
int ret;
ret = conn->driver->domainSetMemoryFlags(domain, memory, flags);
if (ret < 0)
goto error;
return ret;
}
error:
virDispatchError(domain->conn);
return -1;
}
/**
* virDomainSetMemoryParameters:
* @domain: pointer to domain object
......
......@@ -426,6 +426,7 @@ LIBVIRT_0.8.8 {
LIBVIRT_0.9.0 {
global:
virDomainSetMemoryFlags;
virEventRegisterDefaultImpl;
virEventRunDefaultImpl;
} LIBVIRT_0.8.8;
......
......@@ -2851,6 +2851,7 @@ static virDriver lxcDriver = {
lxcDomainGetMaxMemory, /* domainGetMaxMemory */
lxcDomainSetMaxMemory, /* domainSetMaxMemory */
lxcDomainSetMemory, /* domainSetMemory */
NULL, /* domainSetMemoryFlags */
lxcDomainGetInfo, /* domainGetInfo */
NULL, /* domainSave */
NULL, /* domainRestore */
......
......@@ -750,6 +750,7 @@ static virDriver oneDriver = {
NULL, /* domainGetMaxMemory */
NULL, /* domainSetMaxMemory */
NULL, /* domainSetMemory */
NULL, /* domainSetMemoryFlags */
oneDomainGetInfo, /* domainGetInfo */
NULL, /* domainSave */
NULL, /* domainRestore */
......
......@@ -1571,6 +1571,7 @@ static virDriver openvzDriver = {
NULL, /* domainGetMaxMemory */
NULL, /* domainSetMaxMemory */
NULL, /* domainSetMemory */
NULL, /* domainSetMemoryFlags */
openvzDomainGetInfo, /* domainGetInfo */
NULL, /* domainSave */
NULL, /* domainRestore */
......
......@@ -3973,6 +3973,7 @@ static virDriver phypDriver = {
NULL, /* domainGetMaxMemory */
NULL, /* domainSetMaxMemory */
NULL, /* domainSetMemory */
NULL, /* domainSetMemoryFlags */
phypDomainGetInfo, /* domainGetInfo */
NULL, /* domainSave */
NULL, /* domainRestore */
......
......@@ -6854,6 +6854,7 @@ static virDriver qemuDriver = {
qemudDomainGetMaxMemory, /* domainGetMaxMemory */
NULL, /* domainSetMaxMemory */
qemudDomainSetMemory, /* domainSetMemory */
NULL, /* domainSetMemoryFlags */
qemudDomainGetInfo, /* domainGetInfo */
qemudDomainSave, /* domainSave */
qemudDomainRestore, /* domainRestore */
......
......@@ -10876,6 +10876,7 @@ static virDriver remote_driver = {
remoteDomainGetMaxMemory, /* domainGetMaxMemory */
remoteDomainSetMaxMemory, /* domainSetMaxMemory */
remoteDomainSetMemory, /* domainSetMemory */
NULL, /* domainSetMemoryFlags */
remoteDomainGetInfo, /* domainGetInfo */
remoteDomainSave, /* domainSave */
remoteDomainRestore, /* domainRestore */
......
......@@ -5365,6 +5365,7 @@ static virDriver testDriver = {
testGetMaxMemory, /* domainGetMaxMemory */
testSetMaxMemory, /* domainSetMaxMemory */
testSetMemory, /* domainSetMemory */
NULL, /* domainSetMemoryFlags */
testGetDomainInfo, /* domainGetInfo */
testDomainSave, /* domainSave */
testDomainRestore, /* domainRestore */
......
......@@ -2167,6 +2167,7 @@ static virDriver umlDriver = {
umlDomainGetMaxMemory, /* domainGetMaxMemory */
umlDomainSetMaxMemory, /* domainSetMaxMemory */
umlDomainSetMemory, /* domainSetMemory */
NULL, /* domainSetMemoryFlags */
umlDomainGetInfo, /* domainGetInfo */
NULL, /* domainSave */
NULL, /* domainRestore */
......
......@@ -8555,6 +8555,7 @@ virDriver NAME(Driver) = {
NULL, /* domainGetMaxMemory */
NULL, /* domainSetMaxMemory */
vboxDomainSetMemory, /* domainSetMemory */
NULL, /* domainSetMemoryFlags */
vboxDomainGetInfo, /* domainGetInfo */
vboxDomainSave, /* domainSave */
NULL, /* domainRestore */
......
......@@ -925,6 +925,7 @@ static virDriver vmwareDriver = {
NULL, /* domainGetMaxMemory */
NULL, /* domainSetMaxMemory */
NULL, /* domainSetMemory */
NULL, /* domainSetMemoryFlags */
vmwareDomainGetInfo, /* domainGetInfo */
NULL, /* domainSave */
NULL, /* domainRestore */
......
......@@ -2034,6 +2034,7 @@ static virDriver xenUnifiedDriver = {
xenUnifiedDomainGetMaxMemory, /* domainGetMaxMemory */
xenUnifiedDomainSetMaxMemory, /* domainSetMaxMemory */
xenUnifiedDomainSetMemory, /* domainSetMemory */
NULL, /*domainSetMemoryFlags */
xenUnifiedDomainGetInfo, /* domainGetInfo */
xenUnifiedDomainSave, /* domainSave */
xenUnifiedDomainRestore, /* domainRestore */
......
......@@ -1803,6 +1803,7 @@ static virDriver xenapiDriver = {
xenapiDomainGetMaxMemory, /* domainGetMaxMemory */
xenapiDomainSetMaxMemory, /* domainSetMaxMemory */
NULL, /* domainSetMemory */
NULL, /* domainSetMemoryFlags */
xenapiDomainGetInfo, /* domainGetInfo */
NULL, /* domainSave */
NULL, /* domainRestore */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册