Revision 55061f27 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 |
|
1168 |
kvm_path = hvp[constants.HV_KVM_PATH] |
|
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 |
|
1169 | 1186 |
|
1170 | 1187 |
# whether this is an older KVM version that uses the boot=on flag |
1171 | 1188 |
# on devices |
... | ... | |
1177 | 1194 |
if disk_type == constants.HT_DISK_PARAVIRTUAL: |
1178 | 1195 |
if_val = ",if=%s" % self._VIRTIO |
1179 | 1196 |
try: |
1180 |
devlist = self._GetKVMOutput(kvm_path, self._KVMOPT_DEVICELIST) |
|
1181 | 1197 |
if self._VIRTIO_BLK_RE.search(devlist): |
1182 | 1198 |
if_val = ",if=none" |
1183 | 1199 |
# will be passed in -device option as driver |
... | ... | |
1707 | 1723 |
# related parameters we'll use up_hvp |
1708 | 1724 |
tapfds = [] |
1709 | 1725 |
taps = [] |
1726 |
devlist = self._GetKVMOutput(kvm_path, self._KVMOPT_DEVICELIST) |
|
1710 | 1727 |
if not kvm_nics: |
1711 | 1728 |
kvm_cmd.extend(["-net", "none"]) |
1712 | 1729 |
else: |
... | ... | |
1716 | 1733 |
if nic_type == constants.HT_NIC_PARAVIRTUAL: |
1717 | 1734 |
nic_model = self._VIRTIO |
1718 | 1735 |
try: |
1719 |
devlist = self._GetKVMOutput(kvm_path, self._KVMOPT_DEVICELIST) |
|
1720 | 1736 |
if self._VIRTIO_NET_RE.search(devlist): |
1721 | 1737 |
nic_model = self._VIRTIO_NET_PCI |
1722 | 1738 |
vnet_hdr = up_hvp[constants.HV_VNET_HDR] |
... | ... | |
1797 | 1813 |
|
1798 | 1814 |
bdev_opts = self._GenerateKVMBlockDevicesOptions(instance, |
1799 | 1815 |
block_devices, |
1800 |
kvmhelp) |
|
1816 |
kvmhelp, |
|
1817 |
devlist) |
|
1801 | 1818 |
kvm_cmd.extend(bdev_opts) |
1802 | 1819 |
# CPU affinity requires kvm to start paused, so we set this flag if the |
1803 | 1820 |
# instance is not already paused and if we are not going to accept a |
Also available in: Unified diff