Revision 525011bc

b/lib/constants.py
580 580
HV_KVM_USE_CHROOT = "use_chroot"
581 581
HV_CPU_MASK = "cpu_mask"
582 582
HV_MEM_PATH = "mem_path"
583
HV_BLOCKDEV_PREFIX = "blockdev_prefix"
583 584

  
584 585
HVS_PARAMETER_TYPES = {
585 586
  HV_BOOT_ORDER: VTYPE_STRING,
......
617 618
  HV_KVM_USE_CHROOT: VTYPE_BOOL,
618 619
  HV_CPU_MASK: VTYPE_STRING,
619 620
  HV_MEM_PATH: VTYPE_STRING,
621
  HV_BLOCKDEV_PREFIX: VTYPE_STRING,
620 622
  }
621 623

  
622 624
HVS_PARAMETERS = frozenset(HVS_PARAMETER_TYPES.keys())
......
953 955
    HV_KERNEL_ARGS: 'ro',
954 956
    HV_MIGRATION_PORT: 8002,
955 957
    HV_MIGRATION_MODE: HT_MIGRATION_LIVE,
958
    HV_BLOCKDEV_PREFIX: "sd",
956 959
    },
957 960
  HT_XEN_HVM: {
958 961
    HV_BOOT_ORDER: "cd",
......
968 971
    HV_MIGRATION_PORT: 8002,
969 972
    HV_MIGRATION_MODE: HT_MIGRATION_NONLIVE,
970 973
    HV_USE_LOCALTIME: False,
974
    HV_BLOCKDEV_PREFIX: "hd",
971 975
    },
972 976
  HT_KVM: {
973 977
    HV_KERNEL_PATH: "/boot/vmlinuz-2.6-kvmU",
b/lib/hypervisor/hv_xen.py
312 312
      return "'xm info' failed: %s, %s" % (result.fail_reason, result.output)
313 313

  
314 314
  @staticmethod
315
  def _GetConfigFileDiskData(block_devices):
315
  def _GetConfigFileDiskData(block_devices, blockdev_prefix):
316 316
    """Get disk directive for xen config file.
317 317

  
318 318
    This method builds the xen config disk directive according to the
......
321 321
    @param block_devices: list of tuples (cfdev, rldev):
322 322
        - cfdev: dict containing ganeti config disk part
323 323
        - rldev: ganeti.bdev.BlockDev object
324
    @param blockdev_prefix: a string containing blockdevice prefix,
325
                            e.g. "sd" for /dev/sda
324 326

  
325 327
    @return: string containing disk directive for xen instance config file
326 328

  
......
333 335
    if len(block_devices) > 24:
334 336
      # 'z' - 'a' = 24
335 337
      raise errors.HypervisorError("Too many disks")
336
    # FIXME: instead of this hardcoding here, each of PVM/HVM should
337
    # directly export their info (currently HVM will just sed this info)
338
    namespace = ["sd" + chr(i + ord('a')) for i in range(24)]
338
    namespace = [blockdev_prefix + chr(i + ord('a')) for i in range(24)]
339 339
    for sd_name, (cfdev, dev_path) in zip(namespace, block_devices):
340 340
      if cfdev.mode == constants.DISK_RDWR:
341 341
        mode = "w"
......
459 459
    constants.HV_KERNEL_ARGS: hv_base.NO_CHECK,
460 460
    constants.HV_MIGRATION_PORT: hv_base.NET_PORT_CHECK,
461 461
    constants.HV_MIGRATION_MODE: hv_base.MIGRATION_MODE_CHECK,
462
    # TODO: Add a check for the blockdev prefix (matching [a-z:] or similar).
463
    constants.HV_BLOCKDEV_PREFIX: hv_base.NO_CHECK,
462 464
    }
463 465

  
464 466
  @classmethod
......
509 511
        nic_str += ", bridge=%s" % nic.nicparams[constants.NIC_LINK]
510 512
      vif_data.append("'%s'" % nic_str)
511 513

  
512
    disk_data = cls._GetConfigFileDiskData(block_devices)
514
    disk_data = cls._GetConfigFileDiskData(block_devices,
515
                                           hvp[constants.HV_BLOCKDEV_PREFIX])
513 516

  
514 517
    config.write("vif = [%s]\n" % ",".join(vif_data))
515 518
    config.write("disk = [%s]\n" % ",".join(disk_data))
......
639 642
      vif_data.append("'%s'" % nic_str)
640 643

  
641 644
    config.write("vif = [%s]\n" % ",".join(vif_data))
642
    disk_data = cls._GetConfigFileDiskData(block_devices)
643
    disk_type = hvp[constants.HV_DISK_TYPE]
644
    if disk_type in (None, constants.HT_DISK_IOEMU):
645
      replacement = ",ioemu:hd"
646
    else:
647
      replacement = ",hd"
648
    disk_data = [line.replace(",sd", replacement) for line in disk_data]
645

  
646
    disk_data = cls._GetConfigFileDiskData(block_devices,
647
                                           hvp[constants.HV_BLOCKDEV_PREFIX])
648

  
649 649
    iso_path = hvp[constants.HV_CDROM_IMAGE_PATH]
650 650
    if iso_path:
651 651
      iso = "'file:%s,hdc:cdrom,r'" % iso_path
b/man/gnt-instance.rst
185 185
    interfaces. This has been fixed in more recent versions and is
186 186
    confirmed to work at least with qemu-kvm 0.11.1.
187 187

  
188
blockdev\_prefix
189
    Valid for the Xen HVM and PVM hypervisors.
190

  
191
    Relevant to nonpvops guest kernels, in which the disk device names are
192
    given by the host.  Allows to specify 'xvd', which helps run Red Hat based
193
    installers, driven by anaconda.
194

  
188 195
cdrom\_image\_path
189 196
    Valid for the Xen HVM and KVM hypervisors.
190 197

  

Also available in: Unified diff