Revision cc130cc7

b/lib/constants.py
604 604
# HV parameter names (global namespace)
605 605
HV_BOOT_ORDER = "boot_order"
606 606
HV_CDROM_IMAGE_PATH = "cdrom_image_path"
607
HV_KVM_CDROM2_IMAGE_PATH = "cdrom2_image_path"
608
HV_KVM_FLOPPY_IMAGE_PATH = "floppy_image_path"
607 609
HV_NIC_TYPE = "nic_type"
608 610
HV_DISK_TYPE = "disk_type"
611
HV_KVM_CDROM_DISK_TYPE = "cdrom_disk_type"
609 612
HV_VNC_BIND_ADDRESS = "vnc_bind_address"
610 613
HV_VNC_PASSWORD_FILE = "vnc_password_file"
611 614
HV_VNC_TLS = "vnc_tls"
......
641 644

  
642 645
HVS_PARAMETER_TYPES = {
643 646
  HV_BOOT_ORDER: VTYPE_STRING,
647
  HV_KVM_FLOPPY_IMAGE_PATH: VTYPE_STRING,
644 648
  HV_CDROM_IMAGE_PATH: VTYPE_STRING,
649
  HV_KVM_CDROM2_IMAGE_PATH: VTYPE_STRING,
645 650
  HV_NIC_TYPE: VTYPE_STRING,
646 651
  HV_DISK_TYPE: VTYPE_STRING,
652
  HV_KVM_CDROM_DISK_TYPE: VTYPE_STRING,
647 653
  HV_VNC_PASSWORD_FILE: VTYPE_STRING,
648 654
  HV_VNC_BIND_ADDRESS: VTYPE_STRING,
649 655
  HV_VNC_TLS: VTYPE_BOOL,
......
845 851
HT_KVM_VALID_MOUSE_TYPES = frozenset([HT_MOUSE_MOUSE, HT_MOUSE_TABLET])
846 852

  
847 853
# Boot order
854
HT_BO_FLOPPY = "floppy"
848 855
HT_BO_CDROM = "cdrom"
849 856
HT_BO_DISK = "disk"
850 857
HT_BO_NETWORK = "network"
851 858

  
852
HT_KVM_VALID_BO_TYPES = frozenset([HT_BO_CDROM, HT_BO_DISK, HT_BO_NETWORK])
859
HT_KVM_VALID_BO_TYPES = frozenset([HT_BO_FLOPPY, HT_BO_CDROM,
860
                                   HT_BO_DISK, HT_BO_NETWORK])
853 861

  
854 862
# Security models
855 863
HT_SM_NONE = "none"
......
1177 1185
    HV_VNC_X509: '',
1178 1186
    HV_VNC_X509_VERIFY: False,
1179 1187
    HV_VNC_PASSWORD_FILE: '',
1188
    HV_KVM_FLOPPY_IMAGE_PATH: '',
1180 1189
    HV_CDROM_IMAGE_PATH: '',
1190
    HV_KVM_CDROM2_IMAGE_PATH: '',
1181 1191
    HV_BOOT_ORDER: HT_BO_DISK,
1182 1192
    HV_NIC_TYPE: HT_NIC_PARAVIRTUAL,
1183 1193
    HV_DISK_TYPE: HT_DISK_PARAVIRTUAL,
1194
    HV_KVM_CDROM_DISK_TYPE: '',
1184 1195
    HV_USB_MOUSE: '',
1185 1196
    HV_MIGRATION_PORT: 8102,
1186 1197
    HV_MIGRATION_BANDWIDTH: 32, # MiB/s
b/lib/hypervisor/hv_kvm.py
164 164
    constants.HV_VNC_X509: hv_base.OPT_DIR_CHECK,
165 165
    constants.HV_VNC_X509_VERIFY: hv_base.NO_CHECK,
166 166
    constants.HV_VNC_PASSWORD_FILE: hv_base.OPT_FILE_CHECK,
167
    constants.HV_KVM_FLOPPY_IMAGE_PATH: hv_base.OPT_FILE_CHECK,
167 168
    constants.HV_CDROM_IMAGE_PATH: hv_base.OPT_FILE_CHECK,
169
    constants.HV_KVM_CDROM2_IMAGE_PATH: hv_base.OPT_FILE_CHECK,
168 170
    constants.HV_BOOT_ORDER:
169 171
      hv_base.ParamInSet(True, constants.HT_KVM_VALID_BO_TYPES),
170 172
    constants.HV_NIC_TYPE:
171 173
      hv_base.ParamInSet(True, constants.HT_KVM_VALID_NIC_TYPES),
172 174
    constants.HV_DISK_TYPE:
173 175
      hv_base.ParamInSet(True, constants.HT_KVM_VALID_DISK_TYPES),
176
    constants.HV_KVM_CDROM_DISK_TYPE:
177
      hv_base.ParamInSet(False, constants.HT_KVM_VALID_DISK_TYPES),
174 178
    constants.HV_USB_MOUSE:
175 179
      hv_base.ParamInSet(False, constants.HT_KVM_VALID_MOUSE_TYPES),
176 180
    constants.HV_MIGRATION_PORT: hv_base.NET_PORT_CHECK,
......
517 521
    hvp = instance.hvparams
518 522
    boot_disk = hvp[constants.HV_BOOT_ORDER] == constants.HT_BO_DISK
519 523
    boot_cdrom = hvp[constants.HV_BOOT_ORDER] == constants.HT_BO_CDROM
524
    boot_floppy = hvp[constants.HV_BOOT_ORDER] == constants.HT_BO_FLOPPY
520 525
    boot_network = hvp[constants.HV_BOOT_ORDER] == constants.HT_BO_NETWORK
521 526

  
522 527
    if hvp[constants.HV_KVM_FLAG] == constants.HT_KVM_ENABLED:
......
565 570
                                                cache_val)
566 571
      kvm_cmd.extend(['-drive', drive_val])
567 572

  
573
    #Now we can specify a different device type for CDROM devices.
574
    cdrom_disk_type = hvp[constants.HV_KVM_CDROM_DISK_TYPE]
575
    if not cdrom_disk_type:
576
      cdrom_disk_type = disk_type
577

  
568 578
    iso_image = hvp[constants.HV_CDROM_IMAGE_PATH]
569 579
    if iso_image:
570 580
      options = ',format=raw,media=cdrom'
571 581
      if boot_cdrom:
572 582
        kvm_cmd.extend(['-boot', 'd'])
573
        if disk_type != constants.HT_DISK_IDE:
583
        if cdrom_disk_type != constants.HT_DISK_IDE:
584
          options = '%s,boot=on,if=%s' % (options, constants.HT_DISK_IDE)
585
        else:
574 586
          options = '%s,boot=on' % options
575 587
      else:
576
        if disk_type == constants.HT_DISK_PARAVIRTUAL:
588
        if cdrom_disk_type == constants.HT_DISK_PARAVIRTUAL:
577 589
          if_val = ',if=virtio'
578 590
        else:
579
          if_val = ',if=%s' % disk_type
591
          if_val = ',if=%s' % cdrom_disk_type
580 592
        options = '%s%s' % (options, if_val)
581 593
      drive_val = 'file=%s%s' % (iso_image, options)
582 594
      kvm_cmd.extend(['-drive', drive_val])
583 595

  
596
    iso_image2 = hvp[constants.HV_KVM_CDROM2_IMAGE_PATH]
597
    if iso_image2:
598
      options = ',format=raw,media=cdrom'
599
      if cdrom_disk_type == constants.HT_DISK_PARAVIRTUAL:
600
        if_val = ',if=virtio'
601
      else:
602
        if_val = ',if=%s' % cdrom_disk_type
603
      options = '%s%s' % (options, if_val)
604
      drive_val = 'file=%s%s' % (iso_image2, options)
605
      kvm_cmd.extend(['-drive', drive_val])
606

  
607
    floppy_image = hvp[constants.HV_KVM_FLOPPY_IMAGE_PATH]
608
    if floppy_image:
609
      options = ',format=raw,media=disk'
610
      if boot_floppy:
611
        kvm_cmd.extend(['-boot', 'a'])
612
        options = '%s,boot=on' % options
613
      if_val = ',if=floppy'
614
      options = '%s%s' % (options, if_val)
615
      drive_val = 'file=%s%s' % (floppy_image, options)
616
      kvm_cmd.extend(['-drive', drive_val])
617

  
584 618
    kernel_path = hvp[constants.HV_KERNEL_PATH]
585 619
    if kernel_path:
586 620
      kvm_cmd.extend(['-kernel', kernel_path])

Also available in: Unified diff