# HG changeset patch # User stekloff@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx # Node ID 61acbc181fe4caff86a4a3ec4ba69ed43492b511 # Parent 72f9c751d3ea1f17ff513cd7fc2cbe671a9af7c9 To help the small memory issue, I've added a warning to xm for creating - "xm create" - a domain and setting - "xm mem-set" - a domain's memory with less than 32 MBs. I've added a "--force-mem" option to force creating and setting memory below that mark. I've also patched the man page and the user manual. Signed-off-by: Daniel Stekloff diff -r 72f9c751d3ea -r 61acbc181fe4 docs/man/xm.pod.1 --- a/docs/man/xm.pod.1 Wed Apr 19 17:32:20 2006 +++ b/docs/man/xm.pod.1 Fri Apr 21 14:45:12 2006 @@ -63,7 +63,7 @@ so running curses based interfaces over the console B. Vi tends to get very odd when using it over this interface. -=item B I<[-c]> I I<[name=value]>.. +=item B I<[-c]> I I<[--force-mem]> I<[name=value]>.. The create sub command requires a configfile and can optional take a series of name value pairs that add to or override variables defined @@ -78,6 +78,12 @@ not> mean the guest OS in the domain has actually booted, or is available for input. +B: Creating a domain with insufficient memory may cause out +of memory errors. The domain needs enough memory to boot kernel and +modules. Allocating less than 32MBs is not recommended. Use the +I<--force-mem> option to create a domain with less than 32 MBs of +memory. + B =over 4 @@ -86,6 +92,10 @@ Attache console to the domain as soon as it has started. This is useful for determining issues with crashing domains. + +=item B<--force-mem> + +Force domain creation with less than 32MBs of memory. =back @@ -234,7 +244,7 @@ The mem-max value may not correspond to the actual memory used in the Domain, as it may balloon down it's memory to give more back to the OS. -=item B I I +=item B I I I<[--force-mem]> Set the domain's used memory using the balloon driver. Because this operation requires cooperation from the domain operating system, there @@ -242,7 +252,9 @@ B there is no good way to know in advance how small of a mem-set will make a domain unstable and cause it to crash. Be very -careful when using this command on running domains. +careful when using this command on running domains. Setting a domain +to less than 32 MBs isn't recommended. Use the I<--force-mem> option +to set a domain to less than 32 MBs of memory. =item B I I I<[options]> diff -r 72f9c751d3ea -r 61acbc181fe4 docs/src/user.tex --- a/docs/src/user.tex Wed Apr 19 17:32:20 2006 +++ b/docs/src/user.tex Fri Apr 21 14:45:12 2006 @@ -837,7 +837,10 @@ \item[kernel] Set this to the path of the kernel you compiled for use with Xen (e.g.\ \path{kernel = ``/boot/vmlinuz-2.6-xenU''}) \item[memory] Set this to the size of the domain's memory in megabytes - (e.g.\ \path{memory = 64}) + (e.g.\ \path{memory = 64}) {\bf WARNING}: Creating a domain with + insufficient memory may cause out of memory errors. The domain + needs enough memory to boot kernel and modules. Allocating less + than 32MBs is not recommended. \item[disk] Set the first entry in this list to calculate the offset of the domain's root partition, based on the domain ID\@. Set the second to the location of \path{/usr} if you are sharing it between @@ -1161,6 +1164,10 @@ \path{xmexample2} file, which uses Python code to handle the \path{vmid} variable. +{\bf WARNING}: Creating or setting a domain with insufficient memory +may cause out of memory errors. The domain needs enough memory to +boot kernel and modules. Allocating less than 32MBs is not +recommended. %\part{Advanced Topics} diff -r 72f9c751d3ea -r 61acbc181fe4 tools/python/xen/xm/create.py --- a/tools/python/xen/xm/create.py Wed Apr 19 17:32:20 2006 +++ b/tools/python/xen/xm/create.py Fri Apr 21 14:45:12 2006 @@ -103,6 +103,10 @@ gopts.opt('console_autoconnect', short='c', fn=set_true, default=0, use="Connect to the console after the domain is created.") + +gopts.opt('force-mem', short='m', + fn=set_true, default=0, + use="""Force memory creation even if under recommended 32 MB lower limit.""") gopts.var('vncviewer', val='no|yes', fn=set_bool, default=None, @@ -774,6 +778,20 @@ vnc_host = get_host_addr() vnc = 'VNC_VIEWER=%s:%d' % (vnc_host, vnc_port) vals.extra = vnc + ' ' + vals.extra + +def preprocess_memory(vals): + """Check if memory is set to less than 32 MBs, which is not + recommended. If so, warn and exit if force-mem option isn't set.""" + + if int(vals.memory) < 32 and not gopts.getopt("force-mem"): + + warn( +"""Creating a domain with insufficient memory may cause +out of memory errors. The domain needs enough memory to boot kernel +and modules. Allocating less than 32MBs is not recommended. Use +the \'--force-mem\' option to set memory below 32MBs.\n""") + + sys.exit(1) def preprocess(vals): if not vals.kernel and not vals.bootloader: @@ -785,6 +803,7 @@ preprocess_nfs(vals) preprocess_vnc(vals) preprocess_vtpm(vals) + preprocess_memory(vals) def comma_sep_kv_to_dict(c): diff -r 72f9c751d3ea -r 61acbc181fe4 tools/python/xen/xm/main.py --- a/tools/python/xen/xm/main.py Wed Apr 19 17:32:20 2006 +++ b/tools/python/xen/xm/main.py Fri Apr 21 14:45:12 2006 @@ -50,13 +50,14 @@ # Strings for shorthelp console_help = "console Attach to domain DomId's console." -create_help = """create [-c] +create_help = """create [-c] [--force-mem] [Name=Value].. Create a domain based on Config File""" destroy_help = "destroy Terminate a domain immediately" help_help = "help Display this message" list_help = "list [--long] [DomId, ...] List information about domains" mem_max_help = "mem-max Set maximum memory reservation for a domain" -mem_set_help = "mem-set Adjust the current memory usage for a domain" +mem_set_help = """mem-set [--force-mem] + Adjust the current memory usage for a domain""" migrate_help = "migrate Migrate a domain to another machine" pause_help = "pause Pause execution of a domain" reboot_help = "reboot [-w][-a] Reboot a domain" @@ -566,10 +567,18 @@ server.xend.domain.maxmem_set(dom, mem) def xm_mem_set(args): - arg_check(args, "mem-set", 2) + arg_check(args, "mem-set", 2, 3) + alen = len(args) dom = args[0] mem_target = int_unit(args[1], 'm') + if mem_target < 32 and (alen < 3 or (alen > 2 and args[2] != '--force-mem')): + print """ +Warning: Setting a domain with insufficient memory may cause out of + memory errors. Allocating less than 32MBs is not recommended. + Use the \'--force-mem\' option to set below 32MBs + """ + usage("mem-set") server.xend.domain.setMemoryTarget(dom, mem_target)