Revision 6e6bb8d5

b/lib/constants.py
367 367
HV_NIC_TYPE = "nic_type"
368 368
HV_DISK_TYPE = "disk_type"
369 369
HV_VNC_BIND_ADDRESS = "vnc_bind_address"
370
HV_VNC_PASSWORD_FILE = "vnc_password_file"
370 371
HV_VNC_TLS = "vnc_tls"
371 372
HV_VNC_X509 = "vnc_x509_path"
372 373
HV_VNC_X509_VERIFY = "vnc_x509_verify"
......
389 390
  HV_CDROM_IMAGE_PATH: VTYPE_STRING,
390 391
  HV_NIC_TYPE: VTYPE_STRING,
391 392
  HV_DISK_TYPE: VTYPE_STRING,
393
  HV_VNC_PASSWORD_FILE: VTYPE_STRING,
392 394
  HV_VNC_BIND_ADDRESS: VTYPE_STRING,
393 395
  HV_VNC_TLS: VTYPE_BOOL,
394 396
  HV_VNC_X509: VTYPE_STRING,
......
604 606
    HV_NIC_TYPE: HT_NIC_RTL8139,
605 607
    HV_DISK_TYPE: HT_DISK_PARAVIRTUAL,
606 608
    HV_VNC_BIND_ADDRESS: '0.0.0.0',
609
    HV_VNC_PASSWORD_FILE: VNC_PASSWORD_FILE,
607 610
    HV_ACPI: True,
608 611
    HV_PAE: True,
609 612
    HV_KERNEL_PATH: "/usr/lib/xen/boot/hvmloader",
......
620 623
    HV_VNC_TLS: False,
621 624
    HV_VNC_X509: '',
622 625
    HV_VNC_X509_VERIFY: False,
626
    HV_VNC_PASSWORD_FILE: '',
623 627
    HV_CDROM_IMAGE_PATH: '',
624 628
    HV_BOOT_ORDER: HT_BO_DISK,
625 629
    HV_NIC_TYPE: HT_NIC_PARAVIRTUAL,
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

  
b/lib/hypervisor/hv_xen.py
526 526
       "VNC bind address is not a valid IP address", None, None),
527 527
    constants.HV_KERNEL_PATH: hv_base.REQ_FILE_CHECK,
528 528
    constants.HV_DEVICE_MODEL: hv_base.REQ_FILE_CHECK,
529
    constants.HV_VNC_PASSWORD_FILE: hv_base.REQ_FILE_CHECK,
529 530
    }
530 531

  
531 532
  @classmethod
......
574 575
      config.write("# vncdisplay = 1\n")
575 576
      config.write("vncunused = 1\n")
576 577

  
578
    vnc_pwd_file = hvp[constants.HV_VNC_PASSWORD_FILE]
577 579
    try:
578
      password = utils.ReadFile(constants.VNC_PASSWORD_FILE)
580
      password = utils.ReadFile(vnc_pwd_file)
579 581
    except EnvironmentError, err:
580 582
      raise errors.HypervisorError("Failed to open VNC password file %s: %s" %
581
                                   (constants.VNC_PASSWORD_FILE, err))
583
                                   (vnc_pwd_file, err))
582 584

  
583 585
    config.write("vncpasswd = '%s'\n" % password.rstrip())
584 586

  

Also available in: Unified diff