diff -r 9f08c4e82037 tools/examples/xend-config.sxp --- a/tools/examples/xend-config.sxp Mon Jul 12 18:39:18 2010 +0100 +++ b/tools/examples/xend-config.sxp Mon Jul 12 22:05:56 2010 +0200 @@ -205,6 +205,11 @@ # enable-dom0-ballooning below) and for xm mem-set when applied to dom0. (dom0-min-mem 196) +# Dom0 will need at least specified amount of free space for +# /var/lib/xen otherwise it will refuse to start up any new +# guests. Value is in MB and setting it to 0 disables the check. +(dom0-min-space 0) + # Whether to enable auto-ballooning of dom0 to allow domUs to be created. # If enable-dom0-ballooning = no, dom0 will never balloon out. (enable-dom0-ballooning yes) diff -r 9f08c4e82037 tools/python/xen/xend/XendDomainInfo.py --- a/tools/python/xen/xend/XendDomainInfo.py Mon Jul 12 18:39:18 2010 +0100 +++ b/tools/python/xen/xend/XendDomainInfo.py Mon Jul 12 22:05:56 2010 +0200 @@ -2837,6 +2837,16 @@ self._configureBootloader() + # Check whether dom0 does have enough free space to create the guest + stat = os.statvfs("/var/lib/xen") + free = int((stat.f_bsize * stat.f_bavail) / 1048576) + log.debug("Free space for Xen files on dom0: %s MiB" % free) + dom0_min_space = xoptions.instance().get_dom0_min_space() + if dom0_min_space > 0 and free < dom0_min_space: + raise XendError('Dom0 requires at least %s MiBs free space for ' + '/var/lib/xen but only %s MiBs is available.' % + (dom0_min_space, free)) + try: self.image = image.create(self, self.info) diff -r 9f08c4e82037 tools/python/xen/xend/XendOptions.py --- a/tools/python/xen/xend/XendOptions.py Mon Jul 12 18:39:18 2010 +0100 +++ b/tools/python/xen/xend/XendOptions.py Mon Jul 12 22:05:56 2010 +0200 @@ -105,6 +105,8 @@ dom0_min_mem_default = 0 + dom0_min_space_default = 0 + reserved_memory_default = 0 dom0_vcpus_default = 0 @@ -359,6 +361,9 @@ def get_dom0_min_mem(self): return self.get_config_int('dom0-min-mem', self.dom0_min_mem_default) + def get_dom0_min_space(self): + return self.get_config_int('dom0-min-space', self.dom0_min_space_default) + def get_enable_dom0_ballooning(self): enable_dom0_ballooning_default = 'yes' if self.get_dom0_min_mem() == 0: