]> xenbits.xensource.com Git - xen.git/commitdiff
xend: Check for valid CPU_CAP value when creating new domain
authorKeir Fraser <keir.fraser@citrix.com>
Tue, 31 Mar 2009 12:19:07 +0000 (13:19 +0100)
committerKeir Fraser <keir.fraser@citrix.com>
Tue, 31 Mar 2009 12:19:07 +0000 (13:19 +0100)
Signed-off-by: Michal Novotny <minovotn@redhat.com>
Signed-off-by: Masaki Kanno <kanno.masaki@jp.fujitsu.com>
tools/python/xen/xend/XendDomainInfo.py

index 1fa0b338adeb654279fcc6e83051bcc8a25ac07b..7497c7e435b2a36ba18d07884075973ac53822b0 100644 (file)
@@ -2313,6 +2313,21 @@ class XendDomainInfo:
         # Set maximum number of vcpus in domain
         xc.domain_max_vcpus(self.domid, int(self.info['VCPUs_max']))
 
+        # Check for cpu_{cap|weight} validity for credit scheduler
+        if XendNode.instance().xenschedinfo() == 'credit':
+            cap = self.getCap()
+            weight = self.getWeight()
+
+            assert type(weight) == int
+            assert type(cap) == int
+
+            if weight < 1 or weight > 65535:
+                raise VmError("Cpu weight out of range, valid values are within range from 1 to 65535")
+
+            if cap < 0 or cap > dominfo.getVCpuCount() * 100:
+                raise VmError("Cpu cap out of range, valid range is from 0 to %s for specified number of vcpus" %
+                              (dominfo.getVCpuCount() * 100))
+
         # Test whether the devices can be assigned with VT-d
         pci = self.info["platform"].get("pci")
         pci_str = ''