allow exposing hyperthreading at guest using metadata topology=oneSocket:hyperthreading 82/1282/2
authortierno <alfonso.tiernosepulveda@telefonica.com>
Fri, 10 Mar 2017 14:20:10 +0000 (15:20 +0100)
committertierno <alfonso.tiernosepulveda@telefonica.com>
Fri, 10 Mar 2017 15:06:44 +0000 (16:06 +0100)
Change-Id: If924551bc588dd530699ea20c124ae9632388ef6
Signed-off-by: tierno <alfonso.tiernosepulveda@telefonica.com>
host_thread.py

index 97c57ba..d8bca2e 100644 (file)
@@ -501,8 +501,12 @@ class host_thread(threading.Thread):
             self.tab()+'<apic/>' +\
             self.tab()+'<pae/>'+ \
             self.dec_tab() +'</features>'
-        if windows_os or topo=="oneSocket":
-            text += self.tab() + "<cpu mode='host-model'> <topology sockets='1' cores='%d' threads='1' /> </cpu>"% vcpus
+        if topo == "oneSocket:hyperthreading":
+            if vcpus % 2 != 0:
+                return -1, 'Cannot expose hyperthreading with an odd number of vcpus'
+            text += self.tab() + "<cpu mode='host-model'> <topology sockets='1' cores='%d' threads='2' /> </cpu>" % vcpus/2
+        elif windows_os or topo == "oneSocket":
+            text += self.tab() + "<cpu mode='host-model'> <topology sockets='1' cores='%d' threads='1' /> </cpu>" % vcpus
         else:
             text += self.tab() + "<cpu mode='host-model'></cpu>"
         text += self.tab() + "<clock offset='utc'/>" +\