Revision 66d5dbef

b/lib/constants.py
459 459
    HV_VNC_TLS: False,
460 460
    HV_VNC_X509: '',
461 461
    HV_VNC_X509_VERIFY: False,
462
    HV_CDROM_IMAGE_PATH: None,
463
    HV_BOOT_ORDER: "disk",
462 464
    },
463 465
  HT_FAKE: {
464 466
    },
b/lib/hypervisor/hv_kvm.py
58 58
    constants.HV_VNC_TLS,
59 59
    constants.HV_VNC_X509,
60 60
    constants.HV_VNC_X509_VERIFY,
61
    constants.HV_CDROM_IMAGE_PATH,
62
    constants.HV_BOOT_ORDER,
61 63
    ]
62 64

  
63 65
  _MIGRATION_STATUS_RE = re.compile('Migration\s+status:\s+(\w+)',
......
230 232
    if not instance.hvparams[constants.HV_ACPI]:
231 233
      kvm_cmd.extend(['-no-acpi'])
232 234

  
233
    boot_drive = True
235
    boot_disk = (instance.hvparams[constants.HV_BOOT_ORDER] == "disk")
236
    boot_cdrom = (instance.hvparams[constants.HV_BOOT_ORDER] == "cdrom")
234 237
    for cfdev, dev_path in block_devices:
235 238
      if cfdev.mode != constants.DISK_RDWR:
236 239
        raise errors.HypervisorError("Instance has read-only disks which"
237 240
                                     " are not supported by KVM")
238 241
      # TODO: handle FD_LOOP and FD_BLKTAP (?)
239
      if boot_drive:
242
      if boot_disk:
240 243
        boot_val = ',boot=on'
241
        boot_drive = False
244
        boot_disk = False
242 245
      else:
243 246
        boot_val = ''
244 247

  
......
248 251
      drive_val = 'file=%s,format=raw%s%s' % (dev_path, if_val, boot_val)
249 252
      kvm_cmd.extend(['-drive', drive_val])
250 253

  
254
    iso_image = instance.hvparams[constants.HV_CDROM_IMAGE_PATH]
255
    if iso_image:
256
      options = ',format=raw,if=virtio,media=cdrom'
257
      if boot_cdrom:
258
        options = '%s,boot=on' % options
259
      drive_val = 'file=%s%s' % (iso_image, options)
260
      kvm_cmd.extend(['-drive', drive_val])
261

  
251 262
    kernel_path = instance.hvparams[constants.HV_KERNEL_PATH]
252 263
    if kernel_path:
253 264
      kvm_cmd.extend(['-kernel', kernel_path])
......
260 271
      else:
261 272
        kvm_cmd.extend(['-append', root_append])
262 273

  
263
    #"hvm_boot_order",
264
    #"hvm_cdrom_image_path",
265

  
266 274
    # FIXME: handle vnc password
267 275
    vnc_bind_address = instance.hvparams[constants.HV_VNC_BIND_ADDRESS]
268 276
    if vnc_bind_address:
......
722 730
        raise errors.HypervisorError("The vnc x509 path must an absolute path"
723 731
                                     ", if defined")
724 732

  
733
    iso_path = hvparams[constants.HV_CDROM_IMAGE_PATH]
734
    if iso_path and not os.path.isabs(iso_path):
735
      raise errors.HypervisorError("The path to the CDROM image must be"
736
                                   " an absolute path, if defined")
737

  
738
    boot_order = hvparams[constants.HV_BOOT_ORDER]
739
    if boot_order not in ('cdrom', 'disk'):
740
      raise errors.HypervisorError("The boot order must be 'cdrom' or 'disk'")
741

  
725 742
  def ValidateParameters(self, hvparams):
726 743
    """Check the given parameters for validity.
727 744

  
......
751 768
      raise errors.HypervisorError("Instance vnc x509 path '%s' not found"
752 769
                                   " or not a directory" % vnc_x509)
753 770

  
771
    iso_path = hvparams[constants.HV_CDROM_IMAGE_PATH]
772
    if iso_path and not os.path.isfile(iso_path):
773
      raise errors.HypervisorError("Instance cdrom image '%s' not found or"
774
                                   " not a file" % iso_path)
775

  
776

  

Also available in: Unified diff