+ vnc_bind_address = hvparams[constants.HV_VNC_BIND_ADDRESS]
+ if vnc_bind_address:
+ if not utils.IsValidIP(vnc_bind_address):
+ if not os.path.isabs(vnc_bind_address):
+ raise errors.HypervisorError("The VNC bind address must be either"
+ " a valid IP address or an absolute"
+ " pathname. '%s' given" %
+ vnc_bind_address)
+
+ if hvparams[constants.HV_VNC_X509_VERIFY] and \
+ not hvparams[constants.HV_VNC_X509]:
+ raise errors.HypervisorError("%s must be defined, if %s is" %
+ (constants.HV_VNC_X509,
+ constants.HV_VNC_X509_VERIFY))
+
+ if hvparams[constants.HV_VNC_X509]:
+ if not os.path.isabs(hvparams[constants.HV_VNC_X509]):
+ raise errors.HypervisorError("The vnc x509 path must an absolute path"
+ ", if defined")
+
+ iso_path = hvparams[constants.HV_CDROM_IMAGE_PATH]
+ if iso_path and not os.path.isabs(iso_path):
+ raise errors.HypervisorError("The path to the CDROM image must be"
+ " an absolute path, if defined")
+
+ boot_order = hvparams[constants.HV_BOOT_ORDER]
+ 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))
+