Revision cbfd21da lib/hypervisor/hv_kvm.py

b/lib/hypervisor/hv_kvm.py
1161 1161
        data.append(info)
1162 1162
    return data
1163 1163

  
1164
  def _GenerateKVMBlockDevicesOptions(self, instance, block_devices, kvmhelp):
1164
  def _GenerateKVMBlockDevicesOptions(self, instance, block_devices,
1165
                                      kvmhelp, devlist):
1166
    """Generate KVM options regarding instance's block devices.
1165 1167

  
1168
    @type instance: L{objects.Instance}
1169
    @param instance: the instance object
1170
    @type block_devices: list of tuples
1171
    @param block_devices: list of tuples [(disk, link_name)..]
1172
    @type kvmhelp: string
1173
    @param kvmhelp: output of kvm --help
1174
    @type devlist: string
1175
    @param devlist: output of kvm -device ?
1176
    @rtype: list
1177
    @return: list of command line options eventually used by kvm executable
1178

  
1179
    """
1166 1180
    hvp = instance.hvparams
1167
    boot_disk = hvp[constants.HV_BOOT_ORDER] == constants.HT_BO_DISK
1181
    kernel_path = hvp[constants.HV_KERNEL_PATH]
1182
    if kernel_path:
1183
      boot_disk = False
1184
    else:
1185
      boot_disk = hvp[constants.HV_BOOT_ORDER] == constants.HT_BO_DISK
1168 1186
    kvm_path = hvp[constants.HV_KVM_PATH]
1169 1187

  
1170 1188
    # whether this is an older KVM version that uses the boot=on flag
......
1177 1195
    if disk_type == constants.HT_DISK_PARAVIRTUAL:
1178 1196
      if_val = ",if=%s" % self._VIRTIO
1179 1197
      try:
1180
        devlist = self._GetKVMOutput(kvm_path, self._KVMOPT_DEVICELIST)
1181 1198
        if self._VIRTIO_BLK_RE.search(devlist):
1182 1199
          if_val = ",if=none"
1183 1200
          # will be passed in -device option as driver
......
1707 1724
    # related parameters we'll use up_hvp
1708 1725
    tapfds = []
1709 1726
    taps = []
1727
    devlist = self._GetKVMOutput(kvm_path, self._KVMOPT_DEVICELIST)
1710 1728
    if not kvm_nics:
1711 1729
      kvm_cmd.extend(["-net", "none"])
1712 1730
    else:
......
1716 1734
      if nic_type == constants.HT_NIC_PARAVIRTUAL:
1717 1735
        nic_model = self._VIRTIO
1718 1736
        try:
1719
          devlist = self._GetKVMOutput(kvm_path, self._KVMOPT_DEVICELIST)
1720 1737
          if self._VIRTIO_NET_RE.search(devlist):
1721 1738
            nic_model = self._VIRTIO_NET_PCI
1722 1739
            vnet_hdr = up_hvp[constants.HV_VNET_HDR]
......
1797 1814

  
1798 1815
    bdev_opts = self._GenerateKVMBlockDevicesOptions(instance,
1799 1816
                                                     block_devices,
1800
                                                     kvmhelp)
1817
                                                     kvmhelp,
1818
                                                     devlist)
1801 1819
    kvm_cmd.extend(bdev_opts)
1802 1820
    # CPU affinity requires kvm to start paused, so we set this flag if the
1803 1821
    # instance is not already paused and if we are not going to accept a

Also available in: Unified diff