Revision c8cd2315
b/lib/hypervisor/hv_kvm.py | ||
---|---|---|
1197 | 1197 |
data.append(info) |
1198 | 1198 |
return data |
1199 | 1199 |
|
1200 |
def _GenerateKVMBlockDevicesOptions(self, instance, block_devices, kvmhelp): |
|
1200 |
def _GenerateKVMBlockDevicesOptions(self, instance, block_devices, |
|
1201 |
kvmhelp, devlist): |
|
1202 |
"""Generate KVM options regarding instance's block devices. |
|
1201 | 1203 |
|
1204 |
@type instance: L{objects.Instance} |
|
1205 |
@param instance: the instance object |
|
1206 |
@type block_devices: list of tuples |
|
1207 |
@param block_devices: list of tuples [(disk, link_name, uri)..] |
|
1208 |
@type kvmhelp: string |
|
1209 |
@param kvmhelp: output of kvm --help |
|
1210 |
@type devlist: string |
|
1211 |
@param devlist: output of kvm -device ? |
|
1212 |
@rtype: list |
|
1213 |
@return: list of command line options eventually used by kvm executable |
|
1214 |
|
|
1215 |
""" |
|
1202 | 1216 |
hvp = instance.hvparams |
1203 |
boot_disk = hvp[constants.HV_BOOT_ORDER] == constants.HT_BO_DISK |
|
1217 |
kernel_path = hvp[constants.HV_KERNEL_PATH] |
|
1218 |
if kernel_path: |
|
1219 |
boot_disk = False |
|
1220 |
else: |
|
1221 |
boot_disk = hvp[constants.HV_BOOT_ORDER] == constants.HT_BO_DISK |
|
1204 | 1222 |
kvm_path = hvp[constants.HV_KVM_PATH] |
1205 | 1223 |
|
1206 | 1224 |
# whether this is an older KVM version that uses the boot=on flag |
... | ... | |
1213 | 1231 |
if disk_type == constants.HT_DISK_PARAVIRTUAL: |
1214 | 1232 |
if_val = ",if=%s" % self._VIRTIO |
1215 | 1233 |
try: |
1216 |
devlist = self._GetKVMOutput(kvm_path, self._KVMOPT_DEVICELIST) |
|
1217 | 1234 |
if self._VIRTIO_BLK_RE.search(devlist): |
1218 | 1235 |
if_val = ",if=none" |
1219 | 1236 |
# will be passed in -device option as driver |
... | ... | |
1753 | 1770 |
# related parameters we'll use up_hvp |
1754 | 1771 |
tapfds = [] |
1755 | 1772 |
taps = [] |
1773 |
devlist = self._GetKVMOutput(kvm_path, self._KVMOPT_DEVICELIST) |
|
1756 | 1774 |
if not kvm_nics: |
1757 | 1775 |
kvm_cmd.extend(["-net", "none"]) |
1758 | 1776 |
else: |
... | ... | |
1762 | 1780 |
if nic_type == constants.HT_NIC_PARAVIRTUAL: |
1763 | 1781 |
nic_model = self._VIRTIO |
1764 | 1782 |
try: |
1765 |
devlist = self._GetKVMOutput(kvm_path, self._KVMOPT_DEVICELIST) |
|
1766 | 1783 |
if self._VIRTIO_NET_RE.search(devlist): |
1767 | 1784 |
nic_model = self._VIRTIO_NET_PCI |
1768 | 1785 |
vnet_hdr = up_hvp[constants.HV_VNET_HDR] |
... | ... | |
1843 | 1860 |
|
1844 | 1861 |
bdev_opts = self._GenerateKVMBlockDevicesOptions(instance, |
1845 | 1862 |
block_devices, |
1846 |
kvmhelp) |
|
1863 |
kvmhelp, |
|
1864 |
devlist) |
|
1847 | 1865 |
kvm_cmd.extend(bdev_opts) |
1848 | 1866 |
# CPU affinity requires kvm to start paused, so we set this flag if the |
1849 | 1867 |
# instance is not already paused and if we are not going to accept a |
Also available in: Unified diff