Skip to contentSkip to conversation

Check for valid CPU_CAP value when creating (constructing) new domain

PATCH In review Michal Novotny 2 participants 5 messages Mar 30, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Check for valid CPU_CAP value when creating (constructing) new domain

Hi,

This patch implements check for valid cpu_cap value when creating domain (in range 0 to VcpuCount * 100 as when changing scheduler parameters).

tools/python/xen/xend/XendDomainInfo.py +5 -0
diff -r 0b13d9787622 tools/python/xen/xend/XendDomainInfo.py
@@ -2305,6 +2305,11 @@
         # Set maximum number of vcpus in domain
         xc.domain_max_vcpus(self.domid, int(self.info['VCPUs_max']))
 
+        cap = self.getCap()
+        if cap < 0 or cap > self.info['VCPUs_max'] * 100:
+            raise VmError("Invalid CAP range, valid range is from 0 to %s for specified number of vcpus" %
+                         (int(self.info['VCPUs_max']) * 100) )
+
         # Test whether the devices can be assigned with VT-d
         pci = self.info["platform"].get("pci")
         pci_str = ''

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#1 lore raw

Hi Michal,

Why does the patch implement only CPU_CAP?
You should consider CPU_WEIGHT too.
And you should consider scheduler types too.

Best regards,
Kan

Quoted 13 lines · Michal Novotny

Hi,

This patch implements check for valid cpu_cap value when creating domain ( in range 0 to VcpuCount * 100 as when changing scheduler parameters).

-------------------------------text/plain-------------------------------
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#2 lore raw

Hi Kan,
this is new version of my patch implementing check for both CPU_CAP and CPU_WEIGHT and also considering int type for both (asserting it).

Best regards,
Michal

Quoted 28 lines · Masaki Kanno

Hi Michal,

Why does the patch implement only CPU_CAP?
You should consider CPU_WEIGHT too.
And you should consider scheduler types too.

Best regards,
Kan

Quoted 14 lines · Michal Novotny

Hi,

This patch implements check for valid cpu_cap value when creating domain ( in range 0 to VcpuCount * 100 as when changing scheduler parameters).

-------------------------------text/plain-------------------------------
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

tools/python/xen/xend/XendDomainInfo.py +14 -0
diff -r 0b13d9787622 tools/python/xen/xend/XendDomainInfo.py
@@ -2305,6 +2305,20 @@
         # Set maximum number of vcpus in domain
         xc.domain_max_vcpus(self.domid, int(self.info['VCPUs_max']))
 
+	# Check for cpu_{cap|weight} validity
+	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 = ''

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#3 lore raw

Re: [PATCH] Check for valid CPU_CAP value when creating(constructing) new domain

Hi Michal,

I have added the following fixes to your patch.
- Check scheduler type
- Replace tab-indent with space-indent

How about the patch?

Best regards,
Kan

Quoted 38 lines · Michal Novotny

Hi Kan,
this is new version of my patch implementing check for both CPU_CAP and CPU_WEIGHT and also considering int type for both (asserting it).

Best regards,
Michal

Quoted 28 lines · Masaki Kanno

Hi Michal,

Why does the patch implement only CPU_CAP?
You should consider CPU_WEIGHT too.
And you should consider scheduler types too.

Best regards,
Kan

Quoted 14 lines · Michal Novotny

Hi,

This patch implements check for valid cpu_cap value when creating domain ( in range 0 to VcpuCount * 100 as when changing scheduler parameters).

-------------------------------text/plain-------------------------------
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

Quoted 5 lines

-------------------------------text/plain-------------------------------
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

tools/python/xen/xend/XendDomainInfo.py +15 -0
diff -r 0b13d9787622 tools/python/xen/xend/XendDomainInfo.py
@@ -2305,6 +2305,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 = ''

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#4 lore raw

Re: [PATCH] Check for valid CPU_CAP value when creating(constructing) new domain

Hi Kan,
looks fine to me. Sorry about indents - I forgot I was writing it in gedit now and not Midnight Commander editor - and that I forgot about scheduler type.

Best regards,
Michal

Quoted 62 lines · Masaki Kanno

Hi Michal,

I have added the following fixes to your patch.
- Check scheduler type
- Replace tab-indent with space-indent

How about the patch?

Best regards,
Kan

Quoted 44 lines · Michal Novotny

Hi Kan,
this is new version of my patch implementing check for both CPU_CAP and CPU_WEIGHT and also considering int type for both (asserting it).

Best regards,
Michal

Quoted 30 lines · Masaki Kanno

Hi Michal,

Why does the patch implement only CPU_CAP?
You should consider CPU_WEIGHT too.
And you should consider scheduler types too.

Best regards,
Kan

Quoted 15 lines · Michal Novotny

Hi,

This patch implements check for valid cpu_cap value when creating domain ( in range 0 to VcpuCount * 100 as when changing scheduler parameters).

-------------------------------text/plain-------------------------------
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

-------------------------------text/plain-------------------------------
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel