Export the cpu nodes and sockets from Xen
[ganeti-local] / lib / hypervisor / hv_kvm.py
index ec7c073..c3d1db5 100644 (file)
@@ -240,6 +240,7 @@ class KVMHypervisor(hv_base.BaseHypervisor):
                                      " are not supported by KVM")
       # TODO: handle FD_LOOP and FD_BLKTAP (?)
       if boot_disk:
+        kvm_cmd.extend(['-boot', 'c'])
         boot_val = ',boot=on'
         boot_disk = False
       else:
@@ -253,9 +254,12 @@ class KVMHypervisor(hv_base.BaseHypervisor):
 
     iso_image = instance.hvparams[constants.HV_CDROM_IMAGE_PATH]
     if iso_image:
-      options = ',format=raw,if=virtio,media=cdrom'
+      options = ',format=raw,media=cdrom'
       if boot_cdrom:
+        kvm_cmd.extend(['-boot', 'd'])
         options = '%s,boot=on' % options
+      else:
+        options = '%s,if=virtio' % options
       drive_val = 'file=%s%s' % (iso_image, options)
       kvm_cmd.extend(['-drive', drive_val])
 
@@ -635,6 +639,9 @@ class KVMHypervisor(hv_base.BaseHypervisor):
     except EnvironmentError, err:
       raise errors.HypervisorError("Failed to list node info: %s" % err)
     result['cpu_total'] = cpu_total
+    # FIXME: export correct data here
+    result['cpu_nodes'] = 1
+    result['cpu_sockets'] = 1
 
     return result
 
@@ -739,6 +746,9 @@ class KVMHypervisor(hv_base.BaseHypervisor):
     if boot_order not in ('cdrom', 'disk'):
       raise errors.HypervisorError("The boot order must be 'cdrom' or 'disk'")
 
+    if boot_order == 'cdrom' and not iso_path:
+      raise errors.HypervisorError("Cannot boot from cdrom without an ISO path")
+
   def ValidateParameters(self, hvparams):
     """Check the given parameters for validity.
 
@@ -772,5 +782,3 @@ class KVMHypervisor(hv_base.BaseHypervisor):
     if iso_path and not os.path.isfile(iso_path):
       raise errors.HypervisorError("Instance cdrom image '%s' not found or"
                                    " not a file" % iso_path)
-
-