tools: support autoballooning of xenstore domain
cover tools: support autoballooning of xenstore domain
Support xenstore domain autoballooning by:
- adding --maxmem parameter to init-xenstore-domain
- build xenstore stubdom with Mini-OS CONFIG_BALLOON set
- add XENSTORE_MAX_DOMAIN_SIZE parameter to sysconfig.xencommons
This series requires Mini-OS ballooning support, of course. I'm posting it now because this will make it easier to test my Mini-OS series.
Juergen Gross (3):
tools: add --maxmem parameter to init-xenstore-domain
stubdom: add CONFIG_BALLOON to xenstore config
tools: add config parameter for maximum memory of xenstore domain
stubdom/xenstore-minios.cfg | 1 + tools/helpers/init-xenstore-domain.c | 83 +++++++++++++++++++++- tools/hotplug/Linux/init.d/sysconfig.xencommons.in | 11 +++ tools/hotplug/Linux/launch-xenstore.in | 1 + 4 files changed, 94 insertions(+), 2 deletions(-)
Signature · 7 lines
2.6.6 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH 1/3 tools: add --maxmem parameter to init-xenstore-domain
Add a parameter to specify the maximum memory size of the xenstore domain. In case the xenstore domain supports ballooning it will be capable to adjust its own size according to its memory needs.
The maximum memory size can be specified as an absolute value in MiB, as a fraction of the host's memory, or as a combination of both (the maximum of the absolute and the fraction value):
--maxmem <m> maxmem is <m> MiB --maxmem <a>/<b> maxmem is hostmem * a / b --maxmem <m>:<a>/<b> maxmem is max(<m> MiB, hostmem * a / b)
--- tools/helpers/init-xenstore-domain.c | 83 +++++++++++++++++++++++++++++++++++- 1 file changed, 81 insertions(+), 2 deletions(-)
tools/helpers/init-xenstore-domain.c +81 -2
@@ -23,6 +23,7 @@ static char *flask;static char *param;static char *name ="Xenstore" ;static int memory; +static int maxmem;static struct option options[] = { {"kernel" ,1 ,NULL ,'k' },
@@ -31,6 +32,7 @@ static struct option options[] = { { "ramdisk", 1, NULL, 'r' }, { "param", 1, NULL, 'p' }, { "name", 1, NULL, 'n' }, + { "maxmem", 1, NULL, 'M' }, { NULL, 0, NULL, 0 } };
@@ -48,7 +50,11 @@ static void usage(void)" --flask <flask-label> optional flask label of the domain\n" " --ramdisk <ramdisk-file> optional ramdisk file for the domain\n" " --param <cmdline> optional additional parameters for the domain\n" -" --name <name> name of the domain (default: Xenstore)\n"); +" --name <name> name of the domain (default: Xenstore)\n" +" --maxmem <max size> maximum memory size in the format:\n" +" <MB val>|<a>/<b>|<MB val>:<a>/<b>\n" +" (an absolute value in MB, a fraction a/b of\n" +" the host memory, or the maximum of both)\n"); }static int build (xc_interface *xch)
@@ -58,7 +64,7 @@ static int build(xc_interface *xch)xen_domain_handle_t handle = {0 };int rv, xs_fd;struct xc_dom_image *dom =NULL ; -int limit_kb = (memory +1 ) *1024 ; +int limit_kb = (maxmem ? : (memory +1 )) *1024 ; xs_fd =open ("/dev/xen/xenbus_backend" ,O_RDWR );if ( xs_fd ==-1 )
@@ -223,6 +229,63 @@ static int check_domain(xc_interface *xch)return 0 ; } +static int parse_maxmem (xc_interface *xch,char *str) +{ +xc_physinfo_t info; +int rv; +unsigned long mb =0 , a =0 , b =0 ; +unsigned long val; +unsigned long *res; +char buf[16 ]; +char *p; +char *s = str; + + rv =xc_physinfo (xch, &info); +if ( rv ) + { +fprintf (stderr,"xc_physinfo failed\n" ); +return -1 ; + } + + res = &mb; +for (p = s; *p; s = p +1 ) + { + val =strtoul (s, &p,10 ); +if ( val ==0 || val >=INT_MAX /1024 ) + goto err; +if ( *p =='/' ) + { +if ( res != &mb || a !=0 ) + goto err; + a = val; + res = &b; +continue ; + } +if ( *res !=0 ) + goto err; + *res = val; +if ( *p !=0 && *p !=':' ) + goto err; + res = &mb; + } +if ( a && !b ) + goto err; + + val = a ? info.total_pages * a / (b *1024 *1024 /XC_PAGE_SIZE ) :0 ; +if ( val >=INT_MAX /1024 ) + goto err; + + maxmem = mb < val ? val : mb; +if ( maxmem < memory ) + maxmem =0 ; + +return maxmem; + +err: +fprintf (stderr,"illegal value for maxmem: %s\n" , str); +return -1 ; +} +static void do_xs_write (struct xs_handle *xsh,char *path,char *val) {if ( !xs_write (xsh,XBT_NULL , path, val,strlen (val)) )
@@ -244,6 +307,7 @@ int main(int argc, char** argv)struct xs_handle *xsh;char buf[16 ];int rv, fd; +char *maxmem_str =NULL ;while ( (opt =getopt_long (argc, argv,"" , options,NULL )) !=-1 ) {
@@ -267,6 +331,9 @@ int main(int argc, char** argv)case 'n' : name = optarg;break ; +case 'M' : + maxmem_str = optarg; +break ;default :usage ();return 2 ;
@@ -286,6 +353,16 @@ int main(int argc, char** argv)return 1 ; } +if ( maxmem_str ) + { + maxmem =parse_maxmem (xch, maxmem_str); +if ( maxmem <0 ) + { +xc_interface_close (xch); +return 1 ; + } + } + rv =check_domain (xch);if ( !rv )
@@ -314,6 +391,8 @@ int main(int argc, char** argv)do_xs_write_dom (xsh,"name" , name);snprintf (buf,16 ,"%d" , memory *1024 );do_xs_write_dom (xsh,"memory/target" , buf); +if (maxmem) +snprintf (buf,16 ,"%d" , maxmem *1024 );do_xs_write_dom (xsh,"memory/static-max" , buf);xs_close (xsh);
Signature · 7 lines
2.6.6 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH 2/3 stubdom: add CONFIG_BALLOON to xenstore config
In reply to Juergen GrossCompile xenstore stubdom with ballooning support.
--- stubdom/xenstore-minios.cfg | 1 + 1 file changed, 1 insertion(+)
stubdom/xenstore-minios.cfg +1 -0
@@ -5,3 +5,4 @@ CONFIG_KBDFRONT=n CONFIG_CONSFRONT=n CONFIG_XENBUS=n CONFIG_LWIP=n +CONFIG_BALLOON=y
Signature · 7 lines
2.6.6 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH 3/3 tools: add config parameter for maximum memory of xenstore domain
In reply to Juergen GrossAdd a parameter to xencommons configuration file for specifying the maximum memory size of the xenstore domain.
--- tools/hotplug/Linux/init.d/sysconfig.xencommons.in | 11 +++++++++++ tools/hotplug/Linux/launch-xenstore.in | 1 + 2 files changed, 12 insertions(+)
tools/hotplug/Linux/init.d/sysconfig.xencommons.in +11 -0
@@ -70,6 +70,17 @@ XENSTORED_ARGS= #XENSTORE_DOMAIN_SIZE=8 ## Type: string +## Default: not set, no autoballooning of xenstore domain +# +# Maximum xenstore domain memory size. Can be specified as: +# - plain integer value for max size in MiB +# - fraction of host memory, e.g. 1/100 +# - combination of both in form of <val>:<frac> (e.g. 8:1/100), resulting +# value will be the higher of both specifications +# Only evaluated if XENSTORETYPE is "domain". +#XENSTORE_MAX_DOMAIN_SIZE= + +## Type: string ## Default: "" # # Additional arguments for starting the xenstore domain.
tools/hotplug/Linux/launch-xenstore.in +1 -0
@@ -75,6 +75,7 @@ test -f @CONFIG_DIR@/@CONFIG_LEAF_DIR@/xencommons && . @CONFIG_DIR@/@CONFIG_LEAF XENSTORE_DOMAIN_ARGS="$XENSTORE_DOMAIN_ARGS --kernel $XENSTORE_DOMAIN_KERNEL" [ -z "$XENSTORE_DOMAIN_SIZE" ] && XENSTORE_DOMAIN_SIZE=8 XENSTORE_DOMAIN_ARGS="$XENSTORE_DOMAIN_ARGS --memory $XENSTORE_DOMAIN_SIZE" + [ -z "$XENSTORE_MAX_DOMAIN_SIZE" ] || XENSTORE_DOMAIN_ARGS="$XENSTORE_DOMAIN_ARGS --maxmem $XENSTORE_MAX_DOMAIN_SIZE" echo -n Starting $XENSTORE_DOMAIN_KERNEL... ${LIBEXEC_BIN}/init-xenstore-domain $XENSTORE_DOMAIN_ARGS || exit 1
Signature · 7 lines
2.6.6 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Juergen Gross writes ("[PATCH 0/3] tools: support autoballooning of xenstore domain"):
Quoted 7 lines
Support xenstore domain autoballooning by:
- adding --maxmem parameter to init-xenstore-domain
- build xenstore stubdom with Mini-OSCONFIG_BALLOONset
- addXENSTORE_MAX_DOMAIN_SIZEparameter to sysconfig.xencommonsThis series requires Mini-OS ballooning support, of course. I'm posting it now because this will make it easier to test my Mini-OS series.
The basic idea seems sound enough, and I didn't spot much wrong with the implementation, although I have some questions/observations:
* AFAICT this is going to take effect for C xenstored. But ISTM that we probably want to be moving away from C xenstored; its code is difficult, it has a history of hard to fathom bugs, and I'm concerned about its security properties.
* I find that the pointer-arithmetic-based parsing style (as seen in patch 1) very hard to read. I haven't reviewed it. But I think it is not exposed to untrusted input so I don't think I care.
* If we are going in this direction, this feature probably wants to be enabled by default. Do you have a good idea of default parameters ?
Thanks,
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 9 lines · Ian Jackson
Juergen Gross writes ("[PATCH 0/3] tools: support autoballooning of xenstore domain"):
Quoted 7 lines
Support xenstore domain autoballooning by:
- adding --maxmem parameter to init-xenstore-domain
- build xenstore stubdom with Mini-OSCONFIG_BALLOONset
- addXENSTORE_MAX_DOMAIN_SIZEparameter to sysconfig.xencommonsThis series requires Mini-OS ballooning support, of course. I'm posting it now because this will make it easier to test my Mini-OS series.
Quoted 7 lines
The basic idea seems sound enough, and I didn't spot much wrong with the implementation, although I have some questions/observations:
* AFAICT this is going to take effect for C xenstored. But ISTM that we probably want to be moving away from C xenstored; its code is difficult, it has a history of hard to fathom bugs, and I'm concerned about its security properties.
This should work for ocaml based xenstore domain, too. I've been told that is based on Mini-OS, so there is no reason it shouldn't work.
Quoted 3 lines
* I find that the pointer-arithmetic-based parsing style (as seen in patch 1) very hard to read. I haven't reviewed it. But I think it is not exposed to untrusted input so I don't think I care.
I wouldn't mind another way to do it. This variant seemed to be most compact and passed all verification testing I did (and I tried a lot of nonsense).
Quoted 3 lines
* If we are going in this direction, this feature probably wants to be enabled by default. Do you have a good idea of default parameters ?
Hmm, that's not too easy. For a "normal" guest about a quarter MB of memory for Xenstore seems to be a lot. I guess these days most guests have at least 256 MB, so 1/1000 of host memory seems to be appropriate. We don't risk anything going a little bit higher, as Mini-OS doesn't have anything like page structures consuming memory for the not yet taken domain memory. Of course we need some MB (e.g. 4) as a starting point as the kernel needs some memory even if the host is very small. So what about 4:1/512 ? This would give us 4 MB at minimum and on a 16 TB machine we could go up to 32 GB which still wouldn't blow up the theoretical boundaries of Mini-OS.
Juergen
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 3/3] tools: add config parameter for maximum memory of xenstore domain
In reply to Juergen GrossQuoted 4 lines · Juergen Gross
Add a parameter to xencommons configuration file for specifying the maximum memory size of the xenstore domain.
Signed-off-by Juergen Gross <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 1/3] tools: add --maxmem parameter to init-xenstore-domain
In reply to Juergen GrossQuoted 8 lines · Juergen Gross
Add a parameter to specify the maximum memory size of the xenstore domain. In case the xenstore domain supports ballooning it will be capable to adjust its own size according to its memory needs.
The maximum memory size can be specified as an absolute value in MiB, as a fraction of the host's memory, or as a combination of both (the maximum of the absolute and the fraction value):
Quoted 5 lines
--maxmem <m> maxmem is <m> MiB --maxmem <a>/<b> maxmem is hostmem * a / b --maxmem <m>:<a>/<b> maxmem is max(<m> MiB, hostmem * a / b)Signed-off-by Juergen Gross <[email protected]>
Code looks OK.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 2/3] stubdom: add CONFIG_BALLOON to xenstore config
In reply to Juergen GrossQuoted 3 lines · Juergen Gross
Compile xenstore stubdom with ballooning support.
Signed-off-by Juergen Gross <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 33 lines · Juergen Gross
Quoted 9 lines · Ian Jackson
Juergen Gross writes ("[PATCH 0/3] tools: support autoballooning of xenstore domain"):
Quoted 7 lines
Support xenstore domain autoballooning by:
- adding --maxmem parameter to init-xenstore-domain
- build xenstore stubdom with Mini-OSCONFIG_BALLOONset
- addXENSTORE_MAX_DOMAIN_SIZEparameter to sysconfig.xencommonsThis series requires Mini-OS ballooning support, of course. I'm posting it now because this will make it easier to test my Mini-OS series.
Quoted 7 lines
The basic idea seems sound enough, and I didn't spot much wrong with the implementation, although I have some questions/observations:
* AFAICT this is going to take effect for C xenstored. But ISTM that we probably want to be moving away from C xenstored; its code is difficult, it has a history of hard to fathom bugs, and I'm concerned about its security properties.
This should work for ocaml based xenstore domain, too. I've been told that is based on Mini-OS, so there is no reason it shouldn't work.
Quoted 3 lines
* I find that the pointer-arithmetic-based parsing style (as seen in patch 1) very hard to read. I haven't reviewed it. But I think it is not exposed to untrusted input so I don't think I care.
I wouldn't mind another way to do it. This variant seemed to be most compact and passed all verification testing I did (and I tried a lot of nonsense).
Quoted 3 lines
* If we are going in this direction, this feature probably wants to be enabled by default. Do you have a good idea of default parameters ?
Quoted 12 lines
Hmm, that's not too easy. For a "normal" guest about a quarter MB of memory for Xenstore seems to be a lot. I guess these days most guests have at least 256 MB, so 1/1000 of host memory seems to be appropriate. We don't risk anything going a little bit higher, as Mini-OS doesn't have anything like page structures consuming memory for the not yet taken domain memory. Of course we need some MB (e.g. 4) as a starting point as the kernel needs some memory even if the host is very small. So what about 4:1/512 ? This would give us 4 MB at minimum and on a 16 TB machine we could go up to 32 GB which still wouldn't blow up the theoretical boundaries of Mini-OS.
Ian, are all your concerns addressed?
Wei.
Quoted 1 line
Juergen
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 5 lines · Juergen Gross
Support xenstore domain autoballooning by:
- adding --maxmem parameter to init-xenstore-domain
- build xenstore stubdom with Mini-OSCONFIG_BALLOONset
- addXENSTORE_MAX_DOMAIN_SIZEparameter to sysconfig.xencommons
Quoted 7 lines
This series requires Mini-OS ballooning support, of course. I'm posting it now because this will make it easier to test my Mini-OS series.
Juergen Gross (3):
tools: add --maxmem parameter to init-xenstore-domain
stubdom: addCONFIG_BALLOONto xenstore config
tools: add config parameter for maximum memory of xenstore domain
So Mini-OS ballooning is available now. Anything missing from my side for this series to be accepted?
Juergen
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 9 lines · Juergen Gross
Quoted 8 lines · Juergen Gross
Support xenstore domain autoballooning by:
- adding --maxmem parameter to init-xenstore-domain
- build xenstore stubdom with Mini-OSCONFIG_BALLOONset
- addXENSTORE_MAX_DOMAIN_SIZEparameter to sysconfig.xencommonsThis series requires Mini-OS ballooning support, of course. I'm posting it now because this will make it easier to test my Mini-OS series.
Quoted 8 lines
Quoted 4 lines
Juergen Gross (3):
tools: add --maxmem parameter to init-xenstore-domain
stubdom: addCONFIG_BALLOONto xenstore config
tools: add config parameter for maximum memory of xenstore domainSo Mini-OS ballooning is available now. Anything missing from my side for this series to be accepted?
I'm waiting for Ian to confirm if his concerns are addressed.
Wei.
Quoted 3 lines
Juergen
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 13 lines · Juergen Gross
Support xenstore domain autoballooning by:
- adding --maxmem parameter to init-xenstore-domain
- build xenstore stubdom with Mini-OSCONFIG_BALLOONset
- addXENSTORE_MAX_DOMAIN_SIZEparameter to sysconfig.xencommonsThis series requires Mini-OS ballooning support, of course. I'm posting it now because this will make it easier to test my Mini-OS series.
Juergen Gross (3):
tools: add --maxmem parameter to init-xenstore-domain
stubdom: addCONFIG_BALLOONto xenstore config
tools: add config parameter for maximum memory of xenstore domain
Quoted 6 lines
stubdom/xenstore-minios.cfg | 1 + tools/helpers/init-xenstore-domain.c | 83 +++++++++++++++++++++- tools/hotplug/Linux/init.d/sysconfig.xencommons.in | 11 +++ tools/hotplug/Linux/launch-xenstore.in | 1 + 4 files changed, 94 insertions(+), 2 deletions(-)
Another PING.
Juergen
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Ian Jackson
Acked-byRe: [PATCH 0/3] tools: support autoballooning of xenstore domain [and 1 more messages]
In reply to Wei LiuWei Liu writes ("Re: [Xen-devel] [PATCH 0/3] tools: support autoballooning of xenstore domain"):
Quoted 5 lines · Juergen Gross
Quoted 2 lines
So Mini-OS ballooning is available now. Anything missing from my side for this series to be accepted?
I'm waiting for Ian to confirm if his concerns are addressed.
Sorry, yes, I didn't mean to block this with my questions. I should hzve given my ack earlier.
All three:
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 0/3] tools: support autoballooning of xenstore domain [and 1 more messages]
Quoted 5 lines · Ian Jackson
Wei Liu writes ("Re: [Xen-devel] [PATCH 0/3] tools: support autoballooning of xenstore domain"):
Quoted 4 lines · Juergen Gross
Quoted 2 lines
So Mini-OS ballooning is available now. Anything missing from my side for this series to be accepted?
Quoted 8 lines
Quoted 1 line
I'm waiting for Ian to confirm if his concerns are addressed.
Sorry, yes, I didn't mean to block this with my questions. I should hzve given my ack earlier.
All three:
Acked-by Ian Jackson <[email protected]>
Thanks.
I've pushed this series.
Juergen, patch 2 conflicts with the XEN_INTERFACE_VERSION change. It is rather obvious so I've fixed it up. Please check and shout if my fix is not correct.
Wei.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel