From e081236077fc986db3664081f7e8d1140c7db44b Mon Sep 17 00:00:00 2001 From: Daniel Veillard Date: Thu, 13 Apr 2006 17:18:49 +0000 Subject: [PATCH] * include/libvirt.h include/libvirt.h.in doc/*: added new entry point virDomainSetMemory to set up the target memory use for a domain * src/driver.h src/libvirt.c src/xen_internal.c src/xend_internal.[ch] src/xs_internal.[ch]: added a new entry point in the drivers for this, also fixed the xen store entry, as changing /local/domain/$$/memory/target affects the target memory not the max, apparently max is not visible at the xenstore level (or I missed it) Daniel --- ChangeLog | 10 ++++ docs/APIchunk0.html | 9 ++++ docs/APIchunk1.html | 5 ++ docs/APIchunk2.html | 8 +++ docs/APIfiles.html | 1 + docs/APIfunctions.html | 2 + docs/APIsymbols.html | 1 + docs/html/libvirt-libvirt.html | 3 ++ docs/libvirt-api.xml | 7 +++ docs/libvirt-refs.xml | 31 ++++++++++++ include/libvirt.h | 2 + include/libvirt.h.in | 2 + include/libvirt/libvirt.h | 2 + include/libvirt/libvirt.h.in | 2 + src/driver.h | 4 ++ src/libvirt.c | 91 +++++++++++++++++++++++++--------- src/xen_internal.c | 1 + src/xend_internal.c | 63 ++++++++++++----------- src/xend_internal.h | 22 +------- src/xs_internal.c | 7 +-- src/xs_internal.h | 2 +- 21 files changed, 198 insertions(+), 77 deletions(-) diff --git a/ChangeLog b/ChangeLog index ee86491736..95dcb79595 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +Thu Apr 13 17:19:25 EDT 2006 Daniel Veillard + + * include/libvirt.h include/libvirt.h.in doc/*: added new entry point + virDomainSetMemory to set up the target memory use for a domain + * src/driver.h src/libvirt.c src/xen_internal.c src/xend_internal.[ch] + src/xs_internal.[ch]: added a new entry point in the drivers for this, + also fixed the xen store entry, as changing + /local/domain/$$/memory/target affects the target memory not the max, + apparently max is not visible at the xenstore level (or I missed it) + Mon Apr 10 15:15:13 CEST 2006 Daniel Veillard * NEWS configure.in libvirt.spec.in docs/*: documented and diff --git a/docs/APIchunk0.html b/docs/APIchunk0.html index 63587f9a4f..0f4367adf9 100644 --- a/docs/APIchunk0.html +++ b/docs/APIchunk0.html @@ -18,7 +18,9 @@
Destroy
virDomainDestroy
Domain0
virDomainGetMaxMemory
virDomainSetMaxMemory
+virDomainSetMemory
Dynamically
virDomainSetMaxMemory
+virDomainSetMemory

Letter E:

Extract
virDomainGetInfo
virNodeGetInfo

Letter F:

Free
virDomainFree
@@ -52,6 +54,7 @@ virDomainLookupByName
virDomainLookupByUUID
virDomainSetMaxMemory
+virDomainSetMemory
virGetLastError
virGetVersion
virSetErrorFunc
@@ -93,6 +96,7 @@ virDomainResume
virDomainSave
virDomainSetMaxMemory
+virDomainSetMemory
virDomainSuspend
Try
virDomainLookupByID
virDomainLookupByName
@@ -114,6 +118,7 @@ virDomainDestroy
virDomainResume
virDomainSetMaxMemory
+virDomainSetMemory
virDomainSuspend
accesses
virConnGetLastError
virGetLastError
@@ -131,16 +136,19 @@
allocated
virDomainGetInfo
virDomainGetMaxMemory
virDomainSetMaxMemory
+virDomainSetMemory
virDomainSuspend
virNodeGetInfo
allowed
_virDomainInfo
already
virDomainDestroy
amount
virDomainGetMaxMemory
virDomainSetMaxMemory
+virDomainSetMemory
anymore
virDomainSave
application
virConnectClose
virDomainGetMaxMemory
virDomainSetMaxMemory
+virDomainSetMemory
applications
virInitialize
are
virConnectClose
virConnectOpenReadOnly
@@ -201,6 +209,7 @@ virSetErrorFunc
cell
_virNodeInfo
change
virDomainSetMaxMemory
+virDomainSetMemory
clean
virResetError
closes
virConnectClose
code
_virError
diff --git a/docs/APIchunk1.html b/docs/APIchunk1.html index 47d9fed224..dfdce2e51c 100644 --- a/docs/APIchunk1.html +++ b/docs/APIchunk1.html @@ -43,6 +43,7 @@ virDomainResume
virDomainSave
virDomainSetMaxMemory
+virDomainSetMemory
virDomainShutdown
virDomainSuspend
virGetVersion
@@ -93,6 +94,7 @@ virDomainDestroy
virDomainResume
virDomainSetMaxMemory
+virDomainSetMemory
virDomainSuspend
virErrorFunc
virSetErrorFunc
@@ -148,6 +150,7 @@
kilobytes
_virNodeInfo
virDomainGetMaxMemory
virDomainSetMaxMemory
+virDomainSetMemory
knowing
virDomainShutdown

Letter l:

lack
virConnectGetVersion
last
virConnCopyLastError
@@ -194,6 +197,7 @@ virDomainReboot
virDomainResume
virDomainSave
+virDomainSetMemory
virDomainShutdown
virDomainSuspend
virGetLastError
@@ -203,6 +207,7 @@ virDomainGetMaxMemory
virDomainSave
virDomainSetMaxMemory
+virDomainSetMemory
virDomainSuspend
message
_virError
method
virDomainRestore
diff --git a/docs/APIchunk2.html b/docs/APIchunk2.html index 72473307f5..3793d7f629 100644 --- a/docs/APIchunk2.html +++ b/docs/APIchunk2.html @@ -58,6 +58,7 @@ virDomainResume
virDomainSave
virDomainSetMaxMemory
+virDomainSetMemory
virDomainShutdown
virDomainSuspend
occured
virConnGetLastError
@@ -92,6 +93,7 @@
per
_virNodeInfo
physical
virDomainGetMaxMemory
virDomainSetMaxMemory
+virDomainSetMemory
pointed
virResetError
pointer
virConnCopyLastError
virConnGetLastError
@@ -125,6 +127,7 @@ virDomainDestroy
virDomainResume
virDomainSetMaxMemory
+virDomainSetMemory
virDomainSuspend
problem
virDomainSave
process
virDomainResume
@@ -154,9 +157,11 @@ virDomainDestroy
virDomainResume
virDomainSetMaxMemory
+virDomainSetMemory
virDomainSuspend
reserved
virDomainGetMaxMemory
virDomainSetMaxMemory
+virDomainSetMemory
reset
virConnSetErrorFunc
virSetErrorFunc
resources
virDomainDestroy
@@ -187,6 +192,7 @@ virDomainSave
runs
virDomainGetMaxMemory
virDomainSetMaxMemory
+virDomainSetMemory

Letter s:

same
virDomainGetName
save
virDomainSave
saved
virDomainRestore
@@ -207,6 +213,7 @@ virConnectListDomains
virDomainGetMaxMemory
virDomainSetMaxMemory
+virDomainSetMemory
socket
_virNodeInfo
software
virConnectGetType
startup
virInitialize
@@ -242,6 +249,7 @@ virDomainResume
virDomainSave
virDomainSetMaxMemory
+virDomainSetMemory
virDomainShutdown
virDomainSuspend
virInitialize
diff --git a/docs/APIfiles.html b/docs/APIfiles.html index dbf3b0e94c..865e4bdea1 100644 --- a/docs/APIfiles.html +++ b/docs/APIfiles.html @@ -56,6 +56,7 @@ virDomainResume
virDomainSave
virDomainSetMaxMemory
+virDomainSetMemory
virDomainShutdown
virDomainState
virDomainSuspend
diff --git a/docs/APIfunctions.html b/docs/APIfunctions.html index 27170a689e..fd6a23c09c 100644 --- a/docs/APIfunctions.html +++ b/docs/APIfunctions.html @@ -6,6 +6,7 @@

Type unsigned int:

virDomainCreateLinux
virDomainReboot

Type unsigned long:

virDomainSetMaxMemory
+virDomainSetMemory

Type unsigned long *:

virConnectGetVersion
virGetVersion

Type virConnectPtr:

virConnCopyLastError
@@ -37,6 +38,7 @@ virDomainResume
virDomainSave
virDomainSetMaxMemory
+virDomainSetMemory
virDomainShutdown
virDomainSuspend

Type virErrorFunc:

virConnSetErrorFunc
diff --git a/docs/APIsymbols.html b/docs/APIsymbols.html index c44eb90909..7269a2de50 100644 --- a/docs/APIsymbols.html +++ b/docs/APIsymbols.html @@ -100,6 +100,7 @@ virDomainResume
virDomainSave
virDomainSetMaxMemory
+virDomainSetMemory
virDomainShutdown
virDomainState
virDomainSuspend
diff --git a/docs/html/libvirt-libvirt.html b/docs/html/libvirt-libvirt.html index cb9be52be1..691ae37dfd 100644 --- a/docs/html/libvirt-libvirt.html +++ b/docs/html/libvirt-libvirt.html @@ -41,6 +41,7 @@ The content of this structure is not made public by the API.

int	virDomainResume			(virDomainPtr domain)
int	virDomainSave			(virDomainPtr domain, 
const char * to)
int	virDomainSetMaxMemory		(virDomainPtr domain, 
unsigned long memory)
+
int	virDomainSetMemory		(virDomainPtr domain, 
unsigned long memory)
int	virDomainShutdown		(virDomainPtr domain)
int	virDomainSuspend		(virDomainPtr domain)
int	virGetVersion			(unsigned long * libVer, 
const char * type,
unsigned long * typeVer)
@@ -156,6 +157,8 @@ The content of this structure is not made public by the API.

This method will suspend a domain and save its memory contents to a file on disk. After the call, if successful, the domain is not listed as running anymore (this may be a problem). Use virDomainRestore() to restore a domain after saving.

domain:a domain object
to:path for the output file
Returns:0 in case of success and -1 in case of failure.

Function: virDomainSetMaxMemory

int	virDomainSetMaxMemory		(virDomainPtr domain, 
unsigned long memory)

Dynamically change the maximum 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 function requires priviledged access to the hypervisor.

+
domain:a domain object or NULL
memory:the memory size in kilobytes
Returns:0 in case of success and -1 in case of failure.

Function: virDomainSetMemory

int	virDomainSetMemory		(virDomainPtr domain, 
unsigned long memory)
+

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 function may requires priviledged access to the hypervisor.

domain:a domain object or NULL
memory:the memory size in kilobytes
Returns:0 in case of success and -1 in case of failure.

Function: virDomainShutdown

int	virDomainShutdown		(virDomainPtr domain)

Shutdown a domain, the domain object is still usable there after but the domain OS is being stopped. Note that the guest OS may ignore the request. TODO: should we add an option for reboot, knowing it may not be doable in the general case ?

domain:a domain object
Returns:0 in case of success and -1 in case of failure.

Function: virDomainSuspend

int	virDomainSuspend		(virDomainPtr domain)
diff --git a/docs/libvirt-api.xml b/docs/libvirt-api.xml index a69776bac7..3488203747 100644 --- a/docs/libvirt-api.xml +++ b/docs/libvirt-api.xml @@ -65,6 +65,7 @@ + @@ -421,6 +422,12 @@ + + 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 function may requires priviledged access to the hypervisor. + + + + Shutdown a domain, the domain object is still usable there after but the domain OS is being stopped. Note that the guest OS may ignore the request. TODO: should we add an option for reboot, knowing it may not be doable in the general case ? diff --git a/docs/libvirt-refs.xml b/docs/libvirt-refs.xml index e58a67f117..7c52d18088 100644 --- a/docs/libvirt-refs.xml +++ b/docs/libvirt-refs.xml @@ -101,6 +101,7 @@ + @@ -228,6 +229,7 @@ + @@ -286,6 +288,7 @@ + @@ -325,6 +328,7 @@ + @@ -406,6 +410,7 @@ + @@ -510,9 +515,11 @@ + + @@ -586,6 +593,7 @@ + @@ -673,6 +681,7 @@ + @@ -720,6 +729,7 @@ + @@ -753,6 +763,7 @@ + @@ -765,6 +776,7 @@ + @@ -773,6 +785,7 @@ + @@ -887,6 +900,7 @@ + @@ -1038,6 +1052,7 @@ + @@ -1116,6 +1131,7 @@ + @@ -1235,6 +1251,7 @@ + @@ -1317,6 +1334,7 @@ + @@ -1330,6 +1348,7 @@ + @@ -1444,6 +1463,7 @@ + @@ -1512,6 +1532,7 @@ + @@ -1557,6 +1578,7 @@ + @@ -1620,11 +1642,13 @@ + + @@ -1685,6 +1709,7 @@ + @@ -1725,6 +1750,7 @@ + @@ -1786,6 +1812,7 @@ + @@ -1814,6 +1841,7 @@ + @@ -1835,6 +1863,7 @@ + @@ -1852,6 +1881,7 @@ + @@ -1990,6 +2020,7 @@ + diff --git a/include/libvirt.h b/include/libvirt.h index fd5cf3ac80..f1848d0636 100644 --- a/include/libvirt.h +++ b/include/libvirt.h @@ -266,6 +266,8 @@ char * virDomainGetOSType (virDomainPtr domain); unsigned long virDomainGetMaxMemory (virDomainPtr domain); int virDomainSetMaxMemory (virDomainPtr domain, unsigned long memory); +int virDomainSetMemory (virDomainPtr domain, + unsigned long memory); /* * XML domain description */ diff --git a/include/libvirt.h.in b/include/libvirt.h.in index f90292f5ee..d4dc2a24bc 100644 --- a/include/libvirt.h.in +++ b/include/libvirt.h.in @@ -266,6 +266,8 @@ char * virDomainGetOSType (virDomainPtr domain); unsigned long virDomainGetMaxMemory (virDomainPtr domain); int virDomainSetMaxMemory (virDomainPtr domain, unsigned long memory); +int virDomainSetMemory (virDomainPtr domain, + unsigned long memory); /* * XML domain description */ diff --git a/include/libvirt/libvirt.h b/include/libvirt/libvirt.h index fd5cf3ac80..f1848d0636 100644 --- a/include/libvirt/libvirt.h +++ b/include/libvirt/libvirt.h @@ -266,6 +266,8 @@ char * virDomainGetOSType (virDomainPtr domain); unsigned long virDomainGetMaxMemory (virDomainPtr domain); int virDomainSetMaxMemory (virDomainPtr domain, unsigned long memory); +int virDomainSetMemory (virDomainPtr domain, + unsigned long memory); /* * XML domain description */ diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in index f90292f5ee..d4dc2a24bc 100644 --- a/include/libvirt/libvirt.h.in +++ b/include/libvirt/libvirt.h.in @@ -266,6 +266,8 @@ char * virDomainGetOSType (virDomainPtr domain); unsigned long virDomainGetMaxMemory (virDomainPtr domain); int virDomainSetMaxMemory (virDomainPtr domain, unsigned long memory); +int virDomainSetMemory (virDomainPtr domain, + unsigned long memory); /* * XML domain description */ diff --git a/src/driver.h b/src/driver.h index 5489e7fcba..17c8cec318 100644 --- a/src/driver.h +++ b/src/driver.h @@ -80,6 +80,9 @@ typedef unsigned long typedef int (*virDrvDomainSetMaxMemory) (virDomainPtr domain, unsigned long memory); +typedef int + (*virDrvDomainSetMemory) (virDomainPtr domain, + unsigned long memory); typedef int (*virDrvDomainGetInfo) (virDomainPtr domain, virDomainInfoPtr info); @@ -125,6 +128,7 @@ struct _virDriver { virDrvDomainGetOSType domainGetOSType; virDrvDomainGetMaxMemory domainGetMaxMemory; virDrvDomainSetMaxMemory domainSetMaxMemory; + virDrvDomainSetMemory domainSetMemory; virDrvDomainGetInfo domainGetInfo; virDrvDomainSave domainSave; virDrvDomainRestore domainRestore; diff --git a/src/libvirt.c b/src/libvirt.c index 5f5365cc51..6692fb4347 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -610,7 +610,7 @@ virDomainLookupByID(virConnectPtr conn, int id) if (name == NULL) goto error; - ret = virGetDomain(conn, name, &uuid[0]); + ret = virGetDomain(conn, name, (const char *)&uuid[0]); if (ret == NULL) { virLibConnError(conn, VIR_ERR_NO_MEMORY, "Allocating domain"); goto error; @@ -678,7 +678,7 @@ virDomainLookupByUUID(virConnectPtr conn, const unsigned char *uuid) if (name == NULL) return (NULL); - ret = virGetDomain(conn, name, &uuid[0]); + ret = virGetDomain(conn, name, (const char *)&uuid[0]); if (ret == NULL) { if (name != NULL) free(name); @@ -1188,8 +1188,8 @@ virDomainGetMaxMemory(virDomainPtr domain) int virDomainSetMaxMemory(virDomainPtr domain, unsigned long memory) { - int ret; - char s[256], v[30]; + int ret = -1 , i; + virConnectPtr conn; if (memory < 4096) { virLibDomainError(domain, VIR_ERR_INVALID_ARG, __FUNCTION__); @@ -1203,32 +1203,77 @@ virDomainSetMaxMemory(virDomainPtr domain, unsigned long memory) virLibDomainError(domain, VIR_ERR_INVALID_DOMAIN, __FUNCTION__); return (-1); } + conn = domain->conn; if (domain->conn->flags & VIR_CONNECT_RO) return (-1); - ret = xenDaemonDomainSetMaxMemory(domain, memory); - if (ret == 0) - return(0); + /* + * in that case instead of trying only though one method try all availble. + * If needed that can be changed back if it's a performcance problem. + */ + for (i = 0;i < conn->nb_drivers;i++) { + if ((conn->drivers[i] != NULL) && + (conn->drivers[i]->domainSetMaxMemory != NULL)) { + if (conn->drivers[i]->domainSetMaxMemory(domain, memory) == 0) + ret = 0; + } + } + if (ret != 0) { + virLibConnError(conn, VIR_ERR_CALL_FAILED, __FUNCTION__); + return (-1); + } + return (ret); +} - ret = xenHypervisorSetMaxMemory(domain, memory); - if (ret < 0) +/** + * virDomainSetMemory: + * @domain: a domain object or NULL + * @memory: the memory size in kilobytes + * + * 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 function may requires priviledged access to the hypervisor. + * + * Returns 0 in case of success and -1 in case of failure. + */ +int +virDomainSetMemory(virDomainPtr domain, unsigned long memory) +{ + int ret = -1 , i; + virConnectPtr conn; + + if (memory < 4096) { + virLibDomainError(domain, VIR_ERR_INVALID_ARG, __FUNCTION__); + return (-1); + } + if (domain == NULL) { + TODO + return (-1); + } + if (!VIR_IS_CONNECTED_DOMAIN(domain)) { + virLibDomainError(domain, VIR_ERR_INVALID_DOMAIN, __FUNCTION__); + return (-1); + } + conn = domain->conn; + if (domain->conn->flags & VIR_CONNECT_RO) return (-1); - if (domain->conn->xshandle != NULL) { - /* - * try to update at the Xenstore level too - * Failing to do so should not be considered fatal though as long - * as the hypervisor call succeeded - */ - snprintf(s, 255, "/local/domain/%d/memory/target", domain->handle); - s[255] = 0; - snprintf(v, 29, "%lu", memory); - v[30] = 0; - - if (!xs_write(domain->conn->xshandle, 0, &s[0], &v[0], strlen(v))) - ret = -1; + /* + * in that case instead of trying only though one method try all availble. + * If needed that can be changed back if it's a performcance problem. + */ + for (i = 0;i < conn->nb_drivers;i++) { + if ((conn->drivers[i] != NULL) && + (conn->drivers[i]->domainSetMemory != NULL)) { + if (conn->drivers[i]->domainSetMemory(domain, memory) == 0) + ret = 0; + } + } + if (ret != 0) { + virLibConnError(conn, VIR_ERR_CALL_FAILED, __FUNCTION__); + return (-1); } - return (ret); } diff --git a/src/xen_internal.c b/src/xen_internal.c index b579831367..8a99cf6204 100644 --- a/src/xen_internal.c +++ b/src/xen_internal.c @@ -66,6 +66,7 @@ static virDriver xenHypervisorDriver = { NULL, /* domainGetOSType */ NULL, /* domainGetMaxMemory */ xenHypervisorSetMaxMemory, /* domainSetMaxMemory */ + NULL, /* domainSetMemory */ xenHypervisorGetDomainInfo, /* domainGetInfo */ NULL, /* domainSave */ NULL /* domainRestore */ diff --git a/src/xend_internal.c b/src/xend_internal.c index baa2ed397f..cb0ef70db2 100644 --- a/src/xend_internal.c +++ b/src/xend_internal.c @@ -64,6 +64,7 @@ static virDriver xenDaemonDriver = { NULL, /* domainGetOSType */ NULL, /* domainGetMaxMemory */ xenDaemonDomainSetMaxMemory, /* domainSetMaxMemory */ + xenDaemonDomainSetMemory, /* domainMaxMemory */ xenDaemonDomainGetInfo, /* domainGetInfo */ xenDaemonDomainSave, /* domainSave */ xenDaemonDomainRestore /* domainRestore */ @@ -1081,34 +1082,6 @@ xenDaemonDomainCreateLinux(virConnectPtr xend, const char *sexpr) return ret; } -/** - * xend_set_memory: - * @xend: A xend instance - * @name: The name of the domain - * @value: The desired allocation in bytes - * - * This method will set a target memory allocation for a given domain and - * request that the guest meet this target. The guest may or may not actually - * achieve this target. When this function returns, it does not signify that - * the domain has actually reached that target. - * - * Memory for a domain can only be allocated up to the maximum memory setting. - * There is no safe guard for allocations that are too small so be careful - * when using this function to reduce a domain's memory usage. - * - * Returns 0 for success; -1 (with errno) on error - */ -int -xend_set_memory(virConnectPtr xend, const char *name, uint64_t value) -{ - char buf[1024]; - - snprintf(buf, sizeof(buf), "%llu", value >> 20); - return xend_op(xend, name, "op", "mem_target_set", "target", buf, - NULL); -} - - /** * xenDaemonDomainLookupByName_ids: * @xend: A xend instance @@ -1886,8 +1859,7 @@ xenDaemonDomainGetMaxMemory(virDomainPtr domain) * * This method will set the maximum amount of memory that can be allocated to * a domain. Please note that a domain is able to allocate up to this amount - * on its own (although under normal circumstances, memory allocation for a - * domain is only done through xend_set_memory()). + * on its own. * * Returns 0 for success; -1 (with errno) on error */ @@ -1906,6 +1878,37 @@ xenDaemonDomainSetMaxMemory(virDomainPtr domain, unsigned long memory) buf, NULL); } +/** + * xenDaemonDomainSetMemory: + * @domain: pointer to the Domain block + * @memory: The target memory in kilobytes + * + * This method will set a target memory allocation for a given domain and + * request that the guest meet this target. The guest may or may not actually + * achieve this target. When this function returns, it does not signify that + * the domain has actually reached that target. + * + * Memory for a domain can only be allocated up to the maximum memory setting. + * There is no safe guard for allocations that are too small so be careful + * when using this function to reduce a domain's memory usage. + * + * Returns 0 for success; -1 (with errno) on error + */ +int +xenDaemonDomainSetMemory(virDomainPtr domain, unsigned long memory) +{ + char buf[1024]; + + if ((domain == NULL) || (domain->conn == NULL) || (domain->name == NULL)) { + virXendError((domain ? domain->conn : NULL), VIR_ERR_INVALID_ARG, + __FUNCTION__); + return(-1); + } + snprintf(buf, sizeof(buf), "%lu", memory >> 10); + return xend_op(domain->conn, domain->name, "op", "mem_target_set", + "target", buf, NULL); +} + /** * xenDaemonDomainDumpXML: * @domain: a domain object diff --git a/src/xend_internal.h b/src/xend_internal.h index 1deead8d66..e00c482d96 100644 --- a/src/xend_internal.h +++ b/src/xend_internal.h @@ -531,25 +531,6 @@ int xenDaemonOpen_unix(virConnectPtr xend, const char *path); */ int xenDaemonDomainCreateLinux(virConnectPtr xend, const char *sexpr); -/** - * \brief Set the memory allocation for a domain - * \param xend A xend instance - * \param name The name of the domain - * \param value The desired allocation in bytes - * \return 0 for success; -1 (with errno) on error - * - * This method will set a target memory allocation for a given domain and - * request that the guest meet this target. The guest may or may not actually - * achieve this target. When this function returns, it does not signify that - * the domain has actually reached that target. - * - * Memory for a domain can only be allocated up to the maximum memory setting. - * There is no safe guard for allocations that are too small so be careful - * when using this function to reduce a domain's memory usage. - */ - int xend_set_memory(virConnectPtr xend, const char *name, - uint64_t value); - /** * \brief Lookup the id of a domain * \param xend A xend instance @@ -559,7 +540,7 @@ int xenDaemonOpen_unix(virConnectPtr xend, const char *path); * * This method looks up the ids of a domain */ - int xenDaemonDomainLookupByName_ids(virConnectPtr xend, +int xenDaemonDomainLookupByName_ids(virConnectPtr xend, const char *name, unsigned char *uuid); @@ -636,6 +617,7 @@ int xenDaemonDomainReboot(virDomainPtr domain, unsigned int flags); int xenDaemonDomainDestroy(virDomainPtr domain); int xenDaemonDomainSave(virDomainPtr domain, const char *filename); int xenDaemonDomainRestore(virConnectPtr conn, const char *filename); +int xenDaemonDomainSetMemory(virDomainPtr domain, unsigned long memory); int xenDaemonDomainSetMaxMemory(virDomainPtr domain, unsigned long memory); int xenDaemonDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info); char *xenDaemonDomainDumpXML(virDomainPtr domain); diff --git a/src/xs_internal.c b/src/xs_internal.c index 9785261f4c..b31f91d287 100644 --- a/src/xs_internal.c +++ b/src/xs_internal.c @@ -55,7 +55,8 @@ static virDriver xenStoreDriver = { NULL, /* domainGetUUID */ NULL, /* domainGetOSType */ xenStoreDomainGetMaxMemory, /* domainGetMaxMemory */ - xenStoreDomainSetMaxMemory, /* domainSetMaxMemory */ + NULL, /* domainSetMaxMemory */ + xenStoreDomainSetMemory, /* domainSetMemory */ xenStoreGetDomainInfo, /* domainGetInfo */ NULL, /* domainSave */ NULL /* domainRestore */ @@ -385,7 +386,7 @@ xenStoreGetDomainInfo(virDomainPtr domain, virDomainInfoPtr info) } /** - * xenStoreDomainSetMaxMemory: + * xenStoreDomainSetMemory: * @domain: pointer to the domain block * @memory: the max memory size in kilobytes. * @@ -394,7 +395,7 @@ xenStoreGetDomainInfo(virDomainPtr domain, virDomainInfoPtr info) * Returns 0 in case of success, -1 in case of error. */ int -xenStoreDomainSetMaxMemory(virDomainPtr domain, unsigned long memory) +xenStoreDomainSetMemory(virDomainPtr domain, unsigned long memory) { int ret; char value[20]; diff --git a/src/xs_internal.h b/src/xs_internal.h index 17c1d1c32e..dcdb4e125c 100644 --- a/src/xs_internal.h +++ b/src/xs_internal.h @@ -29,7 +29,7 @@ int xenStoreListDomains (virConnectPtr conn, virDomainPtr xenStoreDomainLookupByName(virConnectPtr conn, const char *name); unsigned long xenStoreGetMaxMemory (virDomainPtr domain); -int xenStoreDomainSetMaxMemory(virDomainPtr domain, +int xenStoreDomainSetMemory (virDomainPtr domain, unsigned long memory); unsigned long xenStoreDomainGetMaxMemory(virDomainPtr domain); int xenStoreDomainShutdown (virDomainPtr domain);