Revision e419e42f lib/hypervisor/hv_kvm.py

b/lib/hypervisor/hv_kvm.py
1184 1184
        data.append(info)
1185 1185
    return data
1186 1186

  
1187
  def _GenerateKVMBlockDevicesOptions(self, instance, block_devices, kvmhelp):
1187
  def _GenerateKVMBlockDevicesOptions(self, instance, block_devices,
1188
                                      kvmhelp, devlist):
1189
    """Generate KVM options regarding instance's block devices.
1188 1190

  
1191
    @type instance: L{objects.Instance}
1192
    @param instance: the instance object
1193
    @type block_devices: list of tuples
1194
    @param block_devices: list of tuples [(disk, link_name, uri)..]
1195
    @type kvmhelp: string
1196
    @param kvmhelp: output of kvm --help
1197
    @type devlist: string
1198
    @param devlist: output of kvm -device ?
1199
    @rtype: list
1200
    @return: list of command line options eventually used by kvm executable
1201

  
1202
    """
1189 1203
    hvp = instance.hvparams
1190
    boot_disk = hvp[constants.HV_BOOT_ORDER] == constants.HT_BO_DISK
1204
    kernel_path = hvp[constants.HV_KERNEL_PATH]
1205
    if kernel_path:
1206
      boot_disk = False
1207
    else:
1208
      boot_disk = hvp[constants.HV_BOOT_ORDER] == constants.HT_BO_DISK
1191 1209
    kvm_path = hvp[constants.HV_KVM_PATH]
1192 1210

  
1193 1211
    # whether this is an older KVM version that uses the boot=on flag
......
1200 1218
    if disk_type == constants.HT_DISK_PARAVIRTUAL:
1201 1219
      if_val = ",if=%s" % self._VIRTIO
1202 1220
      try:
1203
        devlist = self._GetKVMOutput(kvm_path, self._KVMOPT_DEVICELIST)
1204 1221
        if self._VIRTIO_BLK_RE.search(devlist):
1205 1222
          if_val = ",if=none"
1206 1223
          # will be passed in -device option as driver
......
1720 1737
    # related parameters we'll use up_hvp
1721 1738
    tapfds = []
1722 1739
    taps = []
1740
    devlist = self._GetKVMOutput(kvm_path, self._KVMOPT_DEVICELIST)
1723 1741
    if not kvm_nics:
1724 1742
      kvm_cmd.extend(["-net", "none"])
1725 1743
    else:
......
1729 1747
      if nic_type == constants.HT_NIC_PARAVIRTUAL:
1730 1748
        nic_model = self._VIRTIO
1731 1749
        try:
1732
          devlist = self._GetKVMOutput(kvm_path, self._KVMOPT_DEVICELIST)
1733 1750
          if self._VIRTIO_NET_RE.search(devlist):
1734 1751
            nic_model = self._VIRTIO_NET_PCI
1735 1752
            vnet_hdr = up_hvp[constants.HV_VNET_HDR]
......
1810 1827

  
1811 1828
    bdev_opts = self._GenerateKVMBlockDevicesOptions(instance,
1812 1829
                                                     block_devices,
1813
                                                     kvmhelp)
1830
                                                     kvmhelp,
1831
                                                     devlist)
1814 1832
    kvm_cmd.extend(bdev_opts)
1815 1833
    # CPU affinity requires kvm to start paused, so we set this flag if the
1816 1834
    # instance is not already paused and if we are not going to accept a

Also available in: Unified diff