From: tgh Subject: Re: question about running vm change its mem maxsize Date: Mon, 19 Mar 2007 20:21:38 +0800 Message-ID: <45FE8052.7080805@ncic.ac.cn> References: <31436f4a0703171215m3f18a72an583b5633b6a8b66a@mail.gmail.com> <45FDE561.5060504@ncic.ac.cn> <1174298445.4337.26.camel@lapbode42.lrr.in.tum.de> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable Return-path: In-Reply-To: <1174298445.4337.26.camel@lapbode42.lrr.in.tum.de> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Daniel Stodden Cc: Xen Developers List-Id: xen-devel@lists.xenproject.org Thank you for your reply Daniel Stodden =E5=86=99=E9=81=93: > On Mon, 2007-03-19 at 09:20 +0800, tgh wrote: > =20 >> hi >> I read the code of xc_linux_build() and xc_domain_setmaxmem(),and I = am=20 >> confused about how does "xm mem-max" change the max size of mem fo= r =20 >> a running VM >> >> In xc_domain_setmaxmem() ,the XEN_DOMCTL_max_mem has been called ,and= =20 >> just does "d->max_pages =3D new_max;" >> =20 > > that variable determines the maximum size. the code verifies that the > new size won't be below the previous one, and therefore just needs to > readjust it. > > it doesn't actually have to allocate memory. this is done on demand, > i.e. as soon as the domain references a new page frame within it's > virtual machine address space. > > =20 I see >> while in the xc_linux_build(), before the vm boots up,the maxsize pfn= =20 >> is alloced in an array with fixsize, page_array =3D malloc(nr_pages *=20 >> sizeof(unsigned long)) >> =20 > > i suppose you misunderstood what that call really does. it's not > changing the maximum vm size, but allocating the initial number of page= s > required to load the guest operating system image into. that's typicall= y > much less than d->max_pages. > > =20 "page_array =3D malloc(nr_pages *sizeof(unsigned long))" in xc_linux_buil= d() is not to allocate the physical memory to the VM,then which code or f= unction allocate the phy-mem to the VM? I am confused about it >> then how does a running vm changes its mem maxsize ,especially for=20 >> expanding its mem maxsize? >> =20 > > for an unprivileged guest os, there is no such call. similar in the way > your desktop machine (hopefully) won't call dell ordering more RAM > without your knowledge. > > changing machine size is an administrative operation. it is defined > during VM creating, and potential subject to refinement by the > administrator on dom0. > =20 I see it is domain0 who has the control interface to set and change the=20 max-size of the VM memory when VM is running, we can "xm mem-set " or "xm mem-max "in the=20 domain0'console to change the vm memory I have used it , and want to know what happen in the xen ,espacially =20 in a paravirtVM could you help me Thanks in advance > what the guest system does in order to get 'more memory' is, from the > guest system point of view, more or less equivalent to what the guest > operating system on a physical host would do: manage physical memory, > find a free page frame, map it in one or more page tables, then start > using it. xen detects that process of mapping this page frame, and > performs the allocation. but, how this is done in detail largely depend= s > on the type of VM (hardware-based, paravirtual, etc), and even then > there are different variants. > > hth. > > regards, > daniel > > =20