Francesco Romani has uploaded a new change for review.
Change subject: vm: add optimizations for hyperv
......................................................................
vm: add optimizations for hyperv
This patch adds support for hyperv optimizations.
The optimizations are both for stability and for performance.
Engine, or any other client, can enable them by supplying a new
optional parameter 'machineType' in the Vm parameters at
creation time.
As default, the new settings are disabled for backward compatibility.
The parameters are hardcoded and not externally configurable
because they are not supposed to be changed very often, if
changed at all; moreover, this patch already implements
the optimal recommended settings.
Change-Id: I28ea1d5adeda07798255484209e1a1d92c2c2bc5
Bug-Url:
https://bugzilla.redhat.com/1083529
Signed-off-by: Francesco Romani <fromani(a)redhat.com>
---
M tests/vmTests.py
M vdsm/virt/vm.py
M vdsm_api/vdsmapi-schema.json
3 files changed, 70 insertions(+), 3 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/19/27619/1
diff --git a/tests/vmTests.py b/tests/vmTests.py
index 1dd75ae..b64f041 100644
--- a/tests/vmTests.py
+++ b/tests/vmTests.py
@@ -264,6 +264,23 @@
domxml.appendFeatures()
self.assertXML(domxml.dom, featuresXML, 'features')
+ def testFeaturesHyperVXML(self):
+ featuresXML = """
+ <features>
+ <acpi/>
+ <hyperv>
+ <relaxed state="on"/>
+ <vapic state="on"/>
+ <spinlocks retries="8191"
state="on"/>
+ </hyperv>
+ </features>"""
+ conf = {'machineType': 'hyperv'}
+ conf.update(self.conf)
+ domxml = vm._DomXML(conf, self.log,
+ caps.Architecture.X86_64)
+ domxml.appendFeatures()
+ self.assertXML(domxml.dom, featuresXML, 'features')
+
def testSysinfoXML(self):
sysinfoXML = """
<sysinfo type="smbios">
diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py
index f1c36f8..5f6b557 100644
--- a/vdsm/virt/vm.py
+++ b/vdsm/virt/vm.py
@@ -647,11 +647,37 @@
<features>
<acpi/>
<features/>
+
+ for hyperv:
+ <features>
+ <acpi/>
+ <hyperv>
+ <relaxed state='on'/>
+ <vapic state='on'/>
+ <spinlocks state='on' retries='8191'/>
+ </hyperv>
+ <features/>
"""
- if utils.tobool(self.conf.get('acpiEnable', 'true')):
+ if (utils.tobool(self.conf.get('acpiEnable', 'true')) or
+ self.conf.get('machineType') == MachineType.HYPERV):
features = self.dom.appendChildWithArgs('features')
+
+ if utils.tobool(self.conf.get('acpiEnable', 'true')):
features.appendChildWithArgs('acpi')
+
+ if self.conf.get('machineType') == MachineType.HYPERV:
+ hyperv = XMLElement('hyperv')
+ features.appendChild(hyperv)
+
+ hyperv.appendChildWithArgs('relaxed', state='on')
+ # turns off an internal Windows watchdog, and by doing so avoids
+ # some high load BSODs.
+ hyperv.appendChildWithArgs('vapic', state='on')
+ hyperv.appendChildWithArgs(
+ 'spinlocks', state='on', retries='8191')
+ # performance optimization flags, that can improve the performance
+ # by 10% to much more (in extreme cases of resources overcommit).
def appendCpu(self):
"""
@@ -1526,6 +1552,10 @@
pass
+class MachineType:
+ HYPERV = "hyperv"
+
+
class Vm(object):
"""
Used for abstracting communication between various parts of the
diff --git a/vdsm_api/vdsmapi-schema.json b/vdsm_api/vdsmapi-schema.json
index d134174..86883ff 100644
--- a/vdsm_api/vdsmapi-schema.json
+++ b/vdsm_api/vdsmapi-schema.json
@@ -898,6 +898,18 @@
{'enum': 'VmType', 'data': ['kvm']}
##
+# @MachineType:
+#
+# Enumeration of supported machine types, with
+# predefined optimized settings.
+#
+# @hyperv: Machine optimized for hyperv
+#
+# Since: 4.15.0
+##
+{'enum': 'MachineType', 'data': ['hyperv']}
+
+##
# @NetInfoNetworkMap:
#
# A mapping of vdsm Network information indexed by network name.
@@ -3131,6 +3143,9 @@
#
# @kvmEnable: Indicates if KVM hardware acceleration is enabled
#
+# @machineType: #optional Indicates the machine profile for the VM.
+# (new in version 4.15.0)
+#
# @maxVCpus: #optional Maximum number of CPU available for the guest
# It is the upper boundry for hot plug CPU action
#
@@ -3180,7 +3195,8 @@
'display': 'VmDisplayType', 'displayIp':
'str',
'displayPort': 'int', 'displaySecurePort':
'int',
'*emulatedMachine': 'str', '*keyboardLayout':
'str',
- 'kvmEnable': 'bool', '*maxVCpus': 'uint',
'memSize': 'uint',
+ 'kvmEnable': 'bool', '*machineType':
'MachineType',
+ '*maxVCpus': 'uint', 'memSize': 'uint',
'memGuaranteedSize': 'uint', 'nicModel': 'str',
'nice': 'int',
'*pauseCode': 'str', 'pid': 'uint',
'smp': 'uint', '*smpCoresPerSocket': 'uint',
'*smpThreadsPerCore': 'uint', 'status':
'VmStatus',
@@ -3209,6 +3225,9 @@
# @display: The type of display
#
# @kvmEnable: Indicates if KVM hardware acceleration is enabled
+#
+# @machineType: #optional Indicates the machine profile for the VM.
+# (new in version 4.15.0)
#
# @memSize: The amount of memory assigned to the VM in MB
#
@@ -3242,7 +3261,8 @@
{'type': 'VmParameters',
'data': {'acpiEnable': 'bool', '*bootMenuEnable':
'bool',
'*cpuShares': 'str', '*custom': 'StringMap',
'*devices': ['VmDevice'],
- 'display': 'VmDisplayType', 'kvmEnable':
'bool', 'memSize': 'uint',
+ 'display': 'VmDisplayType', 'kvmEnable':
'bool',
+ '*machineType': 'MachineType', 'memSize':
'uint',
'nice': 'int', 'smp': 'uint',
'*smpCoresPerSocket': 'uint',
'*smpThreadsPerCore': 'uint', 'timeOffset':
'uint',
'transparentHugePages': 'bool', 'vmId': 'UUID',
'vmName': 'str',
--
To view, visit
http://gerrit.ovirt.org/27619
To unsubscribe, visit
http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I28ea1d5adeda07798255484209e1a1d92c2c2bc5
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Francesco Romani <fromani(a)redhat.com>