Revision 994ccaf2
b/lib/hypervisor/hv_kvm.py | ||
---|---|---|
538 | 538 |
|
539 | 539 |
_VIRTIO = "virtio" |
540 | 540 |
_VIRTIO_NET_PCI = "virtio-net-pci" |
541 |
_VIRTIO_BLK_PCI = "virtio-blk-pci" |
|
541 | 542 |
|
542 | 543 |
_MIGRATION_STATUS_RE = re.compile("Migration\s+status:\s+(\w+)", |
543 | 544 |
re.M | re.I) |
... | ... | |
567 | 568 |
_NETDEV_RE = re.compile(r"^-netdev\s", re.M) |
568 | 569 |
_DISPLAY_RE = re.compile(r"^-display\s", re.M) |
569 | 570 |
_MACHINE_RE = re.compile(r"^-machine\s", re.M) |
570 |
_NEW_VIRTIO_RE = re.compile(r"^name \"%s\"" % _VIRTIO_NET_PCI, re.M) |
|
571 |
_VIRTIO_NET_RE = re.compile(r"^name \"%s\"" % _VIRTIO_NET_PCI, re.M) |
|
572 |
_VIRTIO_BLK_RE = re.compile(r"^name \"%s\"" % _VIRTIO_BLK_PCI, re.M) |
|
571 | 573 |
# match -drive.*boot=on|off on different lines, but in between accept only |
572 | 574 |
# dashes not preceeded by a new line (which would mean another option |
573 | 575 |
# different than -drive is starting) |
... | ... | |
1025 | 1027 |
|
1026 | 1028 |
hvp = instance.hvparams |
1027 | 1029 |
boot_disk = hvp[constants.HV_BOOT_ORDER] == constants.HT_BO_DISK |
1030 |
kvm_path = hvp[constants.HV_KVM_PATH] |
|
1028 | 1031 |
|
1029 | 1032 |
# whether this is an older KVM version that uses the boot=on flag |
1030 | 1033 |
# on devices |
1031 | 1034 |
needs_boot_flag = self._BOOT_RE.search(kvmhelp) |
1032 | 1035 |
|
1033 | 1036 |
dev_opts = [] |
1037 |
device_driver = None |
|
1034 | 1038 |
disk_type = hvp[constants.HV_DISK_TYPE] |
1035 | 1039 |
if disk_type == constants.HT_DISK_PARAVIRTUAL: |
1036 | 1040 |
if_val = ",if=%s" % self._VIRTIO |
1041 |
try: |
|
1042 |
devlist = self._GetKVMOutput(kvm_path, self._KVMOPT_DEVICELIST) |
|
1043 |
if self._VIRTIO_BLK_RE.search(devlist): |
|
1044 |
# TODO: uncomment when -device is used |
|
1045 |
# if_val = ",if=none" |
|
1046 |
# will be passed in -device option as driver |
|
1047 |
device_driver = self._VIRTIO_BLK_PCI |
|
1048 |
except errors.HypervisorError, _: |
|
1049 |
pass |
|
1037 | 1050 |
else: |
1038 | 1051 |
if_val = ",if=%s" % disk_type |
1039 | 1052 |
# Cache mode |
... | ... | |
1063 | 1076 |
drive_val = "file=%s,format=raw%s%s%s" % \ |
1064 | 1077 |
(dev_path, if_val, boot_val, cache_val) |
1065 | 1078 |
|
1079 |
if device_driver: |
|
1080 |
pass |
|
1066 | 1081 |
dev_opts.extend(["-drive", drive_val]) |
1067 | 1082 |
|
1068 | 1083 |
return dev_opts |
... | ... | |
1536 | 1551 |
nic_model = self._VIRTIO |
1537 | 1552 |
try: |
1538 | 1553 |
devlist = self._GetKVMOutput(kvm_path, self._KVMOPT_DEVICELIST) |
1539 |
if self._NEW_VIRTIO_RE.search(devlist):
|
|
1554 |
if self._VIRTIO_NET_RE.search(devlist):
|
|
1540 | 1555 |
nic_model = self._VIRTIO_NET_PCI |
1541 | 1556 |
vnet_hdr = up_hvp[constants.HV_VNET_HDR] |
1542 | 1557 |
except errors.HypervisorError, _: |
Also available in: Unified diff