Revision 839642c2

b/lib/hypervisor/hv_kvm.py
523 523
  def _GenerateKVMRuntime(self, instance, block_devices, startup_paused):
524 524
    """Generate KVM information to start an instance.
525 525

  
526
    @attention: this function must not have any side-effects; for
527
        example, it must not write to the filesystem, or read values
528
        from the current system the are expected to differ between
529
        nodes, since it is only run once at instance startup;
530
        actions/kvm arguments that can vary between systems should be
531
        done in L{_ExecuteKVMRuntime}
532

  
526 533
    """
527 534
    _, v_major, v_min, _ = self._GetKVMVersion()
528 535

  
......
675 682
    elif vnc_bind_address:
676 683
      kvm_cmd.extend(["-usbdevice", constants.HT_MOUSE_TABLET])
677 684

  
678
    keymap = hvp[constants.HV_KEYMAP]
679
    if keymap:
680
      keymap_path = self._InstanceKeymapFile(instance.name)
681
      # If a keymap file is specified, KVM won't use its internal defaults. By
682
      # first including the "en-us" layout, an error on loading the actual
683
      # layout (e.g. because it can't be found) won't lead to a non-functional
684
      # keyboard. A keyboard with incorrect keys is still better than none.
685
      utils.WriteFile(keymap_path, data="include en-us\ninclude %s\n" % keymap)
686
      kvm_cmd.extend(["-k", keymap_path])
687

  
688 685
    if vnc_bind_address:
689 686
      if netutils.IP4Address.IsValid(vnc_bind_address):
690 687
        if instance.network_port > constants.VNC_BASE_PORT:
......
720 717

  
721 718
      kvm_cmd.extend(["-vnc", vnc_arg])
722 719
    elif spice_bind:
720
      # FIXME: this is wrong here; the iface ip address differs
721
      # between systems, so it should be done in _ExecuteKVMRuntime
723 722
      if netutils.IsValidInterface(spice_bind):
724 723
        # The user specified a network interface, we have to figure out the IP
725 724
        # address.
......
845 844
      raise errors.HypervisorError("Failed to start instance %s" % name)
846 845

  
847 846
  def _ExecuteKVMRuntime(self, instance, kvm_runtime, incoming=None):
848
    """Execute a KVM cmd, after completing it with some last minute data
847
    """Execute a KVM cmd, after completing it with some last minute data.
849 848

  
850 849
    @type incoming: tuple of strings
851 850
    @param incoming: (target_host_ip, port)
......
876 875
    if security_model == constants.HT_SM_USER:
877 876
      kvm_cmd.extend(["-runas", conf_hvp[constants.HV_SECURITY_DOMAIN]])
878 877

  
878
    keymap = conf_hvp[constants.HV_KEYMAP]
879
    if keymap:
880
      keymap_path = self._InstanceKeymapFile(name)
881
      # If a keymap file is specified, KVM won't use its internal defaults. By
882
      # first including the "en-us" layout, an error on loading the actual
883
      # layout (e.g. because it can't be found) won't lead to a non-functional
884
      # keyboard. A keyboard with incorrect keys is still better than none.
885
      utils.WriteFile(keymap_path, data="include en-us\ninclude %s\n" % keymap)
886
      kvm_cmd.extend(["-k", keymap_path])
887

  
879 888
    # We have reasons to believe changing something like the nic driver/type
880 889
    # upon migration won't exactly fly with the instance kernel, so for nic
881 890
    # related parameters we'll use up_hvp

Also available in: Unified diff