Revision df5ab9f0 lib/hypervisor/hv_kvm.py

b/lib/hypervisor/hv_kvm.py
239 239
      drive_val = 'file=%s,format=raw%s%s' % (dev_path, if_val, boot_val)
240 240
      kvm_cmd.extend(['-drive', drive_val])
241 241

  
242
    kvm_cmd.extend(['-kernel', instance.hvparams[constants.HV_KERNEL_PATH]])
243

  
244
    initrd_path = instance.hvparams[constants.HV_INITRD_PATH]
245
    if initrd_path:
246
      kvm_cmd.extend(['-initrd', initrd_path])
247

  
248
    root_append = 'root=%s ro' % instance.hvparams[constants.HV_ROOT_PATH]
249
    if instance.hvparams[constants.HV_SERIAL_CONSOLE]:
250
      kvm_cmd.extend(['-append', 'console=ttyS0,38400 %s' % root_append])
251
    else:
252
      kvm_cmd.extend(['-append', root_append])
242
    kernel_path = instance.hvparams[constants.HV_KERNEL_PATH]
243
    if kernel_path:
244
      kvm_cmd.extend(['-kernel', kernel_path])
245
      initrd_path = instance.hvparams[constants.HV_INITRD_PATH]
246
      if initrd_path:
247
        kvm_cmd.extend(['-initrd', initrd_path])
248
      root_append = 'root=%s ro' % instance.hvparams[constants.HV_ROOT_PATH]
249
      if instance.hvparams[constants.HV_SERIAL_CONSOLE]:
250
        kvm_cmd.extend(['-append', 'console=ttyS0,38400 %s' % root_append])
251
      else:
252
        kvm_cmd.extend(['-append', root_append])
253 253

  
254 254
    #"hvm_boot_order",
255 255
    #"hvm_cdrom_image_path",
......
634 634
    """
635 635
    super(KVMHypervisor, cls).CheckParameterSyntax(hvparams)
636 636

  
637
    if not hvparams[constants.HV_KERNEL_PATH]:
638
      raise errors.HypervisorError("Need a kernel for the instance")
639

  
640
    if not os.path.isabs(hvparams[constants.HV_KERNEL_PATH]):
641
      raise errors.HypervisorError("The kernel path must be an absolute path")
637
    kernel_path = hvparams[constants.HV_KERNEL_PATH]
638
    if kernel_path:
639
      if not os.path.isabs(hvparams[constants.HV_KERNEL_PATH]):
640
        raise errors.HypervisorError("The kernel path must be an absolute path"
641
                                     ", if defined")
642 642

  
643
    if not hvparams[constants.HV_ROOT_PATH]:
644
      raise errors.HypervisorError("Need a root partition for the instance")
643
      if not hvparams[constants.HV_ROOT_PATH]:
644
        raise errors.HypervisorError("Need a root partition for the instance"
645
                                     ", if a kernel is defined")
645 646

  
646 647
    if hvparams[constants.HV_INITRD_PATH]:
647 648
      if not os.path.isabs(hvparams[constants.HV_INITRD_PATH]):
648
        raise errors.HypervisorError("The initrd path must be an absolute path"
649
        raise errors.HypervisorError("The initrd path must an absolute path"
649 650
                                     ", if defined")
650 651

  
651 652
  def ValidateParameters(self, hvparams):
......
658 659
    super(KVMHypervisor, self).ValidateParameters(hvparams)
659 660

  
660 661
    kernel_path = hvparams[constants.HV_KERNEL_PATH]
661
    if not os.path.isfile(kernel_path):
662
    if kernel_path and not os.path.isfile(kernel_path):
662 663
      raise errors.HypervisorError("Instance kernel '%s' not found or"
663 664
                                   " not a file" % kernel_path)
664 665
    initrd_path = hvparams[constants.HV_INITRD_PATH]

Also available in: Unified diff