Revision 6e6bb8d5 lib/hypervisor/hv_kvm.py

b/lib/hypervisor/hv_kvm.py
62 62
    constants.HV_VNC_TLS: hv_base.NO_CHECK,
63 63
    constants.HV_VNC_X509: hv_base.OPT_DIR_CHECK,
64 64
    constants.HV_VNC_X509_VERIFY: hv_base.NO_CHECK,
65
    constants.HV_VNC_PASSWORD_FILE: hv_base.OPT_FILE_CHECK,
65 66
    constants.HV_CDROM_IMAGE_PATH: hv_base.OPT_FILE_CHECK,
66 67
    constants.HV_BOOT_ORDER:
67 68
      hv_base.ParamInSet(True, constants.HT_KVM_VALID_BO_TYPES),
......
330 331
      kvm_cmd.extend(['-usb'])
331 332
      kvm_cmd.extend(['-usbdevice', mouse_type])
332 333

  
333
    # FIXME: handle vnc password
334 334
    vnc_bind_address = hvp[constants.HV_VNC_BIND_ADDRESS]
335 335
    if vnc_bind_address:
336 336
      if utils.IsValidIP(vnc_bind_address):
......
358 358
          elif hvp[constants.HV_VNC_X509]:
359 359
            vnc_append = '%s,x509=%s' % (vnc_append,
360 360
                                         hvp[constants.HV_VNC_X509])
361
        if hvp[constants.HV_VNC_PASSWORD_FILE]:
362
          vnc_append = '%s,password' % vnc_append
363

  
361 364
        vnc_arg = '%s%s' % (vnc_arg, vnc_append)
362 365

  
363 366
      else:
......
432 435

  
433 436
    """
434 437
    pidfile, pid, alive = self._InstancePidAlive(instance.name)
438
    hvp = instance.hvparams
435 439
    if alive:
436 440
      raise errors.HypervisorError("Failed to start instance %s: %s" %
437 441
                                   (instance.name, "already running"))
......
460 464
      target, port = incoming
461 465
      kvm_cmd.extend(['-incoming', 'tcp:%s:%s' % (target, port)])
462 466

  
467
    vnc_pwd_file = hvp[constants.HV_VNC_PASSWORD_FILE]
468
    vnc_pwd = None
469
    if vnc_pwd_file:
470
      try:
471
        vnc_pwd = utils.ReadFile(vnc_pwd_file)
472
      except EnvironmentError, err:
473
        raise errors.HypervisorError("Failed to open VNC password file %s: %s"
474
                                     % (vnc_pwd_file, err))
475

  
463 476
    result = utils.RunCmd(kvm_cmd)
464 477
    if result.failed:
465 478
      raise errors.HypervisorError("Failed to start instance %s: %s (%s)" %
......
470 483
      raise errors.HypervisorError("Failed to start instance %s: %s" %
471 484
                                   (instance.name))
472 485

  
486
    if vnc_pwd:
487
      change_cmd = 'change vnc password %s' % vnc_pwd
488
      self._CallMonitorCommand(instance.name, change_cmd)
489

  
473 490
    for filename in temp_files:
474 491
      utils.RemoveFile(filename)
475 492

  

Also available in: Unified diff