Revision cc130cc7 lib/hypervisor/hv_kvm.py

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