Revision 4f580fef

b/lib/constants.py
630 630
HV_ROOT_PATH = "root_path"
631 631
HV_SERIAL_CONSOLE = "serial_console"
632 632
HV_USB_MOUSE = "usb_mouse"
633
HV_KEYMAP = "keymap"
633 634
HV_DEVICE_MODEL = "device_model"
634 635
HV_INIT_SCRIPT = "init_script"
635 636
HV_MIGRATION_PORT = "migration_port"
......
671 672
  HV_ROOT_PATH: VTYPE_MAYBE_STRING,
672 673
  HV_SERIAL_CONSOLE: VTYPE_BOOL,
673 674
  HV_USB_MOUSE: VTYPE_STRING,
675
  HV_KEYMAP: VTYPE_STRING,
674 676
  HV_DEVICE_MODEL: VTYPE_STRING,
675 677
  HV_INIT_SCRIPT: VTYPE_STRING,
676 678
  HV_MIGRATION_PORT: VTYPE_INT,
......
1212 1214
    HV_DISK_TYPE: HT_DISK_PARAVIRTUAL,
1213 1215
    HV_KVM_CDROM_DISK_TYPE: '',
1214 1216
    HV_USB_MOUSE: '',
1217
    HV_KEYMAP: "",
1215 1218
    HV_MIGRATION_PORT: 8102,
1216 1219
    HV_MIGRATION_BANDWIDTH: 32, # MiB/s
1217 1220
    HV_MIGRATION_DOWNTIME: 30,  # ms
b/lib/hypervisor/hv_kvm.py
137 137
  _CTRL_DIR = _ROOT_DIR + "/ctrl" # contains instances control sockets
138 138
  _CONF_DIR = _ROOT_DIR + "/conf" # contains instances startup data
139 139
  _NICS_DIR = _ROOT_DIR + "/nic" # contains instances nic <-> tap associations
140
  _KEYMAP_DIR = _ROOT_DIR + "/keymap" # contains instances keymaps
140 141
  # KVM instances with chroot enabled are started in empty chroot directories.
141 142
  _CHROOT_DIR = _ROOT_DIR + "/chroot" # for empty chroot directories
142 143
  # After an instance is stopped, its chroot directory is removed.
......
177 178
      hv_base.ParamInSet(False, constants.HT_KVM_VALID_DISK_TYPES),
178 179
    constants.HV_USB_MOUSE:
179 180
      hv_base.ParamInSet(False, constants.HT_KVM_VALID_MOUSE_TYPES),
181
    constants.HV_KEYMAP: hv_base.NO_CHECK,
180 182
    constants.HV_MIGRATION_PORT: hv_base.NET_PORT_CHECK,
181 183
    constants.HV_MIGRATION_BANDWIDTH: hv_base.NO_CHECK,
182 184
    constants.HV_MIGRATION_DOWNTIME: hv_base.NO_CHECK,
......
357 359
    return utils.PathJoin(cls._InstanceNICDir(instance_name), str(seq))
358 360

  
359 361
  @classmethod
362
  def _InstanceKeymapFile(cls, instance_name):
363
    """Returns the name of the file containing the keymap for a given instance
364

  
365
    """
366
    return utils.PathJoin(cls._KEYMAP_DIR, instance_name)
367

  
368
  @classmethod
360 369
  def _TryReadUidFile(cls, uid_file):
361 370
    """Try to read a uid file
362 371

  
......
380 389
    utils.RemoveFile(cls._InstanceMonitor(instance_name))
381 390
    utils.RemoveFile(cls._InstanceSerial(instance_name))
382 391
    utils.RemoveFile(cls._InstanceKVMRuntime(instance_name))
392
    utils.RemoveFile(cls._InstanceKeymapFile(instance_name))
383 393
    uid_file = cls._InstanceUidFile(instance_name)
384 394
    uid = cls._TryReadUidFile(uid_file)
385 395
    utils.RemoveFile(uid_file)
......
644 654
    elif vnc_bind_address:
645 655
      kvm_cmd.extend(['-usbdevice', constants.HT_MOUSE_TABLET])
646 656

  
657
    keymap = hvp[constants.HV_KEYMAP]
658
    if keymap:
659
      keymap_path = self._InstanceKeymapFile(instance.name)
660
      # If a keymap file is specified, KVM won't use its internal defaults. By
661
      # first including the "en-us" layout, an error on loading the actual
662
      # layout (e.g. because it can't be found) won't lead to a non-functional
663
      # keyboard. A keyboard with incorrect keys is still better than none.
664
      utils.WriteFile(keymap_path, data="include en-us\ninclude %s\n" % keymap)
665
      kvm_cmd.extend(["-k", keymap_path])
666

  
647 667
    if vnc_bind_address:
648 668
      if netutils.IP4Address.IsValid(vnc_bind_address):
649 669
        if instance.network_port > constants.VNC_BASE_PORT:
b/man/gnt-instance.rst
433 433
    "mouse" or "tablet". When using VNC it's recommended to set it to
434 434
    "tablet".
435 435

  
436
keymap
437
    Valid for the KVM hypervisor.
438

  
439
    This option specifies the keyboard mapping to be used. It is only
440
    needed when using the VNC console. For example: "fr" or "en-gb".
441

  
436 442

  
437 443
The ``-O (--os-parameters)`` option allows customisation of the OS
438 444
parameters. The actual parameter names and values depends on the OS

Also available in: Unified diff