Skip to contentSkip to conversation

how to change the memory size of a VM

DISCUSSION Jia Rao 3 participants 7 messages Nov 2, 2009

lore
Share & tools
lore

Jia Rao

author
#0 lore raw

Hi all,

I am looking into a problem that when the memory size of a VM is changed which part of the original memory is taken away by xen.
For example, if I change the memory size of a VM from 2048MB --> 1024MB, how can I tell which are the 1024M byte that will be taken away (I do not want the xen to take the memory spaces that are caching useful data).

The command for memory size reconfiguration is "xm mem-set", so I looked the source code of xm.
It turned out to be the following python calls:

tools/python/xen/xm/main.py: setMemoryTarget(dom, mem_target) tools/python/xen/xend/XendDomainInfo.py: setMemoryTarget:
self._safe_set_memory('memory_dynamic_min', target * MiB)
self._safe_set_memory('memory_dynamic_max', target * MiB)

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

author
#1 lore raw
Quoted 11 lines

I am looking into a problem that when the memory size of a VM is changed which part of the original memory is taken away by xen.
For example, if I change the memory size of a VM from 2048MB --> 1024MB, how can I tell which are the 1024M byte that will be taken away (I do not want the xen to take the memory spaces that are caching useful data).

The command for memory size reconfiguration is "xm mem-set", so I looked the source code of xm.
It turned out to be the following python calls:

Quoted 5 lines

tools/python/xen/xm/main.py: *setMemoryTarget*(dom, mem_target)

tools/python/xen/xend/XendDomainInfo.py: setMemoryTarget:

self.*_safe_set_memory*('memory_dynamic_min', target * MiB)

Quoted 2 lines

self.*_safe_set_memory*('memory_dynamic_max', target * MiB)

xen.xend.XendDomain.instance().*managed_config_save*(self)

tools/python/xen/xend/XendDomainInfo.py: *_safe_set_memory*
self.info[‘memory_dynamic_min’] = target self.info[‘memory_dynamic_max’] = target

It seems that to change the memory size of a VM, you just need to save the new size in somewhere, xenstore?
How would the new size take effect? the memory mapping of the VM must be modified somewhere.

Look forward to replies, sorry if the question is stupid, a newbie here ^_^ Thanks in advance

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#2 lore raw

There must be a balloon driver in the guest for memory to be dynamically removed from the guest. Then when Xen tells the balloon driver to take memory, the guest decides which pages of memory to give away (thinking that it is giving the memory to an especially hungry device driver). Google for "balloon driver" for more info on how this works on Xen, VMware, other VMMs.

If you are interested in much more detail on this, google for "self-ballooning Xen" and "transcendent memory".
-----Original Message-----
From: Jia Rao [mailto:[email protected]]
Sent: Monday, November 02, 2009 1:54 PM
To: [email protected]
Subject: [Xen-devel] Re: how to change the memory size of a VM

I am looking into a problem that when the memory size of a VM is changed which part of the original memory is taken away by xen.
For example, if I change the memory size of a VM from 2048MB --> 1024MB, how can I tell which are the 1024M byte that will be taken away (I do not want the xen to take the memory spaces that are caching useful data).

The command for memory size reconfiguration is "xm mem-set", so I looked the source code of xm. It turned out to be the following python calls:

tools/python/xen/xm/main.py: setMemoryTarget(dom, mem_target)

tools/python/xen/xend/XendDomainInfo.py: setMemoryTarget:
self._safe_set_memory('memory_dynamic_min', target * MiB) self._safe_set_memory('memory_dynamic_max', target * MiB)

xen.xend.XendDomain.instance().managed_config_save(self)

tools/python/xen/xend/XendDomainInfo.py: _safe_set_memory
self.info[‘memory_dynamic_min’] = target self.info[‘memory_dynamic_max’] = target

It seems that to change the memory size of a VM, you just need to save the new size in somewhere, xenstore? How would the new size take effect? the memory mapping of the VM must be modified somewhere.

Look forward to replies, sorry if the question is stupid, a newbie here ^_^ Thanks in advance

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

author
#3 lore raw

Thanks for the reply,
I am using xen 3.3 and linux-2.6.18.8.
I did not configure the guest to use balloon driver. Is the balloon driver enabled by default?

Quoted 44 lines · Dan Magenheimer

There must be a balloon driver in the guest for memory to be dynamically
removed from the guest. Then when Xen tells the balloon driver to take memory, the guest decides which pages of memory to give away (thinking that it is giving the memory to an especially hungry device driver). Google for "balloon driver" for more info on how this works on Xen, VMware, other VMMs.

If you are interested in much more detail on this, google for "self-ballooning Xen" and "transcendent memory".

-----Original Message-----
*From:* Jia Rao [mailto:[email protected]]
*Sent:* Monday, November 02, 2009 1:54 PM
*To:* [email protected]
*Subject:* [Xen-devel] Re: how to change the memory size of a VM

Quoted 10 lines

I am looking into a problem that when the memory size of a VM is changed which part of the original memory is taken away by xen.
For example, if I change the memory size of a VM from 2048MB --> 1024MB, how can I tell which are the 1024M byte that will be taken away (I do not want the xen to take the memory spaces that are caching useful data).

The command for memory size reconfiguration is "xm mem-set", so I looked the source code of xm.
It turned out to be the following python calls:

Quoted 5 lines

tools/python/xen/xm/main.py: *setMemoryTarget*(dom, mem_target)

tools/python/xen/xend/XendDomainInfo.py: setMemoryTarget:

self.*_safe_set_memory*('memory_dynamic_min', target * MiB)

Quoted 3 lines

self.*_safe_set_memory*('memory_dynamic_max', target *
MiB)

xen.xend.XendDomain.instance().*managed_config_save*(self)

tools/python/xen/xend/XendDomainInfo.py: *_safe_set_memory*
self.info[‘memory_dynamic_min’] = target self.info[‘memory_dynamic_max’] = target

Quoted 10 lines

It seems that to change the memory size of a VM, you just need to save the new size in somewhere, xenstore?
How would the new size take effect? the memory mapping of the VM must be modified somewhere.

Look forward to replies, sorry if the question is stupid, a newbie here ^_^ Thanks in advance

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#4 lore raw

If by linux-2.6.18.8 you mean the default Xen-ified kernel from xen.org, yes, the balloon driver should be built by default. If you mean a kernel.org 2.6.18.8 kernel running as a HVM (fully virtualized), no, the balloon driver will not be there by default.

If you can type to a command line in your guest, if "cat /proc/xen/balloon" works, the balloon driver is enabled in that guest.
-----Original Message-----
From: Jia Rao [mailto:[email protected]]
Sent: Monday, November 02, 2009 2:38 PM
To: Dan Magenheimer
Cc: [email protected]
Subject: Re: [Xen-devel] Re: how to change the memory size of a VM

Thanks for the reply,
I am using xen 3.3 and linux-2.6.18.8.
I did not configure the guest to use balloon driver. Is the balloon driver enabled by default?

On Mon, Nov 2, 2009 at 4:31 PM, Dan Magenheimer <[email protected]> wrote:

There must be a balloon driver in the guest for memory to be dynamically removed from the guest. Then when Xen tells the balloon driver to take memory, the guest decides which pages of memory to give away (thinking that it is giving the memory to an especially hungry device driver). Google for "balloon driver" for more info on how this works on Xen, VMware, other VMMs.

If you are interested in much more detail on this, google for "self-ballooning Xen" and "transcendent memory".
-----Original Message-----
From: Jia Rao [mailto:[email protected]]
Sent: Monday, November 02, 2009 1:54 PM
To: [email protected]
Subject: [Xen-devel] Re: how to change the memory size of a VM

I am looking into a problem that when the memory size of a VM is changed which part of the original memory is taken away by xen.
For example, if I change the memory size of a VM from 2048MB --> 1024MB, how can I tell which are the 1024M byte that will be taken away (I do not want the xen to take the memory spaces that are caching useful data).

The command for memory size reconfiguration is "xm mem-set", so I looked the source code of xm. It turned out to be the following python calls:

tools/python/xen/xm/main.py: setMemoryTarget(dom, mem_target)

tools/python/xen/xend/XendDomainInfo.py: setMemoryTarget:
self._safe_set_memory('memory_dynamic_min', target * MiB) self._safe_set_memory('memory_dynamic_max', target * MiB)

xen.xend.XendDomain.instance().managed_config_save(self)

tools/python/xen/xend/XendDomainInfo.py: _safe_set_memory
self.info[‘memory_dynamic_min’] = target self.info[‘memory_dynamic_max’] = target

It seems that to change the memory size of a VM, you just need to save the new size in somewhere, xenstore? How would the new size take effect? the memory mapping of the VM must be modified somewhere.

Look forward to replies, sorry if the question is stupid, a newbie here ^_^ Thanks in advance

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#5 lore raw
In reply to Jia Rao
Quoted 4 lines · Jia Rao

It seems that to change the memory size of a VM, you just need to save the new size in somewhere, xenstore?
How would the new size take effect? the memory mapping of the VM must be modified somewhere.

The VM itself gives up memory back to Xen, after reading the updated memory size from xenstore.

-- Keir

author
#6 lore raw

What I understand here is:

Although configured with 2GB memory, the guest only used part of the assigned memory(active onees), gives the unused memory back to xen. Upon reconfigured to 1GB, the guest got informed from xenstore about the new size, and updates its own view of the memory info, like the number in /proc/meminfo.

Is it correct ?

Quoted 4 lines · Keir Fraser
Quoted 1 line · Jia Rao

It seems that to change the memory size of a VM, you just need to save

the new

Quoted 11 lines
Quoted 3 lines

size in somewhere, xenstore?
How would the new size take effect? the memory mapping of the VM must be modified somewhere.

The VM itself gives up memory back to Xen, after reading the updated memory size from xenstore.

-- Keir

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel