- 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")
+ if boot_order not in constants.HT_KVM_VALID_BO_TYPES:
+ raise errors.HypervisorError(\
+ "The boot order must be one of %s" %
+ utils.CommaJoin(constants.HT_KVM_VALID_BO_TYPES))
+
+ if boot_order == constants.HT_BO_CDROM and not iso_path:
+ raise errors.HypervisorError("Cannot boot from cdrom without an"
+ " ISO path")
+
+ nic_type = hvparams[constants.HV_NIC_TYPE]
+ if nic_type not in constants.HT_KVM_VALID_NIC_TYPES:
+ raise errors.HypervisorError(\
+ "Invalid NIC type %s specified for the KVM"
+ " hypervisor. Please choose one of: %s" %
+ (nic_type, utils.CommaJoin(constants.HT_KVM_VALID_NIC_TYPES)))
+ elif (boot_order == constants.HT_BO_NETWORK and
+ nic_type == constants.HT_NIC_PARAVIRTUAL):
+ raise errors.HypervisorError("Cannot boot from a paravirtual NIC. Please"
+ " change the NIC type.")
+
+ disk_type = hvparams[constants.HV_DISK_TYPE]
+ if disk_type not in constants.HT_KVM_VALID_DISK_TYPES:
+ raise errors.HypervisorError(\
+ "Invalid disk type %s specified for the KVM"
+ " hypervisor. Please choose one of: %s" %
+ (disk_type, utils.CommaJoin(constants.HT_KVM_VALID_DISK_TYPES)))
+
+ mouse_type = hvparams[constants.HV_USB_MOUSE]
+ if mouse_type and mouse_type not in constants.HT_KVM_VALID_MOUSE_TYPES:
+ raise errors.HypervisorError(\
+ "Invalid usb mouse type %s specified for the KVM hypervisor. Please"
+ " choose one of %s" %
+ utils.CommaJoin(constants.HT_KVM_VALID_MOUSE_TYPES))