ia64/xen-unstable

changeset 18661:6ca065624051

xend: fix setting vcpus > VCPUs_max

From reading xend code related to changing number of vcpus it appears
setting the number of vcpus to a value greater than VCPUs_max is not
allowed on a running domain. This restriction is not honored by
setVCpuCount() in XendDomainInfo.py. Attached patch makes
setVCpuCount() fail if vcpus > VCPUs_max and domain is running.

Also, I think the changes should be reflected in managed config of
running domain if in fact the domain is managed - so unconditionally
call managed_config_save().

BTW, the original code is rather confusing. Essentially the same
actions are taken regardless if self.info['VCPUs_max'] > vcpus, just
the order of invocation is changed. But this doesn't seem to matter
since self.info['VCPUs_live'] is not subsequently used.

Signed-off-by: Jim Fehlig <jfehlig@novell.com>
author Keir Fraser <keir.fraser@citrix.com>
date Mon Oct 20 15:17:24 2008 +0100 (2008-10-20)
parents 6eb23f7ece78
children bf84c03c38ee
files tools/python/xen/xend/XendDomainInfo.py
line diff
     1.1 --- a/tools/python/xen/xend/XendDomainInfo.py	Mon Oct 20 15:15:19 2008 +0100
     1.2 +++ b/tools/python/xen/xend/XendDomainInfo.py	Mon Oct 20 15:17:24 2008 +0100
     1.3 @@ -1506,23 +1506,18 @@ class XendDomainInfo:
     1.4          return self.info['VCPUs_max']
     1.5  
     1.6      def setVCpuCount(self, vcpus):
     1.7 -        if vcpus <= 0:
     1.8 -            raise XendError('Invalid VCPUs')
     1.9 +        def vcpus_valid(n):
    1.10 +            if vcpus <= 0:
    1.11 +                raise XendError('Zero or less VCPUs is invalid')
    1.12 +            if self.domid >= 0 and vcpus > self.info['VCPUs_max']:
    1.13 +                raise XendError('Cannot set vcpus greater than max vcpus on running domain')
    1.14 +        vcpus_valid(vcpus)
    1.15          
    1.16          self.info['vcpu_avail'] = (1 << vcpus) - 1
    1.17          if self.domid >= 0:
    1.18              self.storeVm('vcpu_avail', self.info['vcpu_avail'])
    1.19 -            # update dom differently depending on whether we are adjusting
    1.20 -            # vcpu number up or down, otherwise _vcpuDomDetails does not
    1.21 -            # disable the vcpus
    1.22 -            if self.info['VCPUs_max'] > vcpus:
    1.23 -                # decreasing
    1.24 -                self._writeDom(self._vcpuDomDetails())
    1.25 -                self.info['VCPUs_live'] = vcpus
    1.26 -            else:
    1.27 -                # same or increasing
    1.28 -                self.info['VCPUs_live'] = vcpus
    1.29 -                self._writeDom(self._vcpuDomDetails())
    1.30 +            self._writeDom(self._vcpuDomDetails())
    1.31 +            self.info['VCPUs_live'] = vcpus
    1.32          else:
    1.33              if self.info['VCPUs_max'] > vcpus:
    1.34                  # decreasing
    1.35 @@ -1532,7 +1527,7 @@ class XendDomainInfo:
    1.36                  for c in range(self.info['VCPUs_max'], vcpus):
    1.37                      self.info['cpus'].append(list())
    1.38              self.info['VCPUs_max'] = vcpus
    1.39 -            xen.xend.XendDomain.instance().managed_config_save(self)
    1.40 +        xen.xend.XendDomain.instance().managed_config_save(self)
    1.41          log.info("Set VCPU count on domain %s to %d", self.info['name_label'],
    1.42                   vcpus)
    1.43