+ kernel_path = instance.hvparams[constants.HV_KERNEL_PATH]
+ if kernel_path:
+ kvm_cmd.extend(['-kernel', kernel_path])
+ initrd_path = instance.hvparams[constants.HV_INITRD_PATH]
+ if initrd_path:
+ kvm_cmd.extend(['-initrd', initrd_path])
+ root_append = 'root=%s ro' % instance.hvparams[constants.HV_ROOT_PATH]
+ if instance.hvparams[constants.HV_SERIAL_CONSOLE]:
+ kvm_cmd.extend(['-append', 'console=ttyS0,38400 %s' % root_append])
+ else:
+ kvm_cmd.extend(['-append', root_append])
+
+ # FIXME: handle vnc password
+ vnc_bind_address = instance.hvparams[constants.HV_VNC_BIND_ADDRESS]
+ if vnc_bind_address:
+ kvm_cmd.extend(['-usbdevice', 'tablet'])
+ if utils.IsValidIP(vnc_bind_address):
+ if instance.network_port > constants.HT_HVM_VNC_BASE_PORT:
+ display = instance.network_port - constants.HT_HVM_VNC_BASE_PORT
+ if vnc_bind_address == '0.0.0.0':
+ vnc_arg = ':%d' % (display)
+ else:
+ vnc_arg = '%s:%d' % (constants.HV_VNC_BIND_ADDRESS, display)
+ else:
+ logging.error("Network port is not a valid VNC display (%d < %d)."
+ " Not starting VNC" %
+ (instance.network_port,
+ constants.HT_HVM_VNC_BASE_PORT))
+ vnc_arg = 'none'
+
+ # Only allow tls and other option when not binding to a file, for now.
+ # kvm/qemu gets confused otherwise about the filename to use.
+ vnc_append = ''
+ if instance.hvparams[constants.HV_VNC_TLS]:
+ vnc_append = '%s,tls' % vnc_append
+ if instance.hvparams[constants.HV_VNC_X509_VERIFY]:
+ vnc_append = '%s,x509verify=%s' % (vnc_append,
+ instance.hvparams[constants.HV_VNC_X509])
+ elif instance.hvparams[constants.HV_VNC_X509]:
+ vnc_append = '%s,x509=%s' % (vnc_append,
+ instance.hvparams[constants.HV_VNC_X509])
+ vnc_arg = '%s%s' % (vnc_arg, vnc_append)