[et-mgmt-tools] [PATCH][RESEND] Add the option to guard maximums ofthenumber of virtual CPU by the number of physical CPU

Masayuki Sunou fj1826dm at aa.jp.fujitsu.com
Fri Mar 23 08:37:41 UTC 2007


Hi,

Would you give me a comment on this patch?
If not, please apply it.

> > Unless you can think of a compelling reason not to allow a user to do 
> > the above, I think we should not take this patch and leave the vcpu 
> > setting unbounded. However if you would like to send a patch that warns 
> > the user without imposing a hard limit, I think that would be reasonable.
> > 
> I accepted your suggestion, and I made a patch again.
> 
> This patch adds the option to warn when the number of virtual CPU is
> more than the number of physical CPU. 

Signed-off-by: Masayuki Sunou <fj1826dm at aa.jp.fujitsu.com>

Thanks,
Masayuki Sunou


===============================================================================
diff -r aec5777422c0 virt-install
--- a/virt-install	Wed Mar 21 13:46:29 2007 -0400
+++ b/virt-install	Fri Mar 23 17:16:26 2007 +0900
@@ -89,12 +89,23 @@ def get_uuid(uuid, guest):
         except ValueError, e:
             print "ERROR: ", e
 
-def get_vcpus(vcpus, guest):
-    if vcpus: 
-        try:
+def get_vcpus(vcpus, check_cpu, guest, conn):
+    while 1:
+        if check_cpu is None:
+            break
+        hostinfo = conn.getInfo()
+        cpu_num = hostinfo[4] * hostinfo[5] * hostinfo[6] * hostinfo[7]
+        if vcpus <= cpu_num:
+            break
+        res = prompt_for_input("Virtual CPU (%d) is more than physical CPU (%d). Would you like to attach virtual CPU more than physical CPU? (yes or no)" %(vcpus, cpu_num))
+        try:
+            if yes_or_no(res):
+                break
+            vcpus = int(prompt_for_input("How many VCPUs should be attached?"))
+        except ValueError, e:
+            print "ERROR: ", e
+    if vcpus:
             guest.vcpus = vcpus
-        except ValueError, e:
-            print "ERROR: ", e
 
 def get_keymap(keymap, guest):
     if keymap:
@@ -296,6 +307,8 @@ def parse_args():
                       help="UUID for the guest; if none is given a random UUID will be generated")
     parser.add_option("", "--vcpus", type="int", dest="vcpus",
                       help="Number of vcpus to configure for your guest")
+    parser.add_option("", "--check-cpu", action="store_true", dest="check_cpu",
+                      help="Check the maximum of physical CPU.")
 
     # disk options
     parser.add_option("-f", "--file", type="string",
@@ -505,7 +518,7 @@ def main():
     get_name(options.name, guest)
     get_memory(options.memory, guest)
     get_uuid(options.uuid, guest)
-    get_vcpus(options.vcpus, guest)
+    get_vcpus(options.vcpus, options.check_cpu, guest, conn)
     get_keymap(options.keymap, guest)
 
     # set up disks
===============================================================================




More information about the et-mgmt-tools mailing list