[Openstack] Fwd: Defining VM's CPU Socket:Core Topology

Evan Fraser evan.fraser at trademe.co.nz
Mon Sep 30 03:36:35 UTC 2013


Thanks for that John,

I’ve figured it out, it only took minor changes to /usr/share/pyshared/nova/virt/libvirt/{driver,config}.py

I’ve got a patch pasted below:
diff -uNr libvirt.old/config.py libvirt/config.py
--- libvirt.old/config.py       2013-06-07 06:33:51.000000000 +1200
+++ libvirt/config.py   2013-09-30 16:26:12.000000000 +1300
@@ -335,6 +335,10 @@

         self.mode = None
         self.match = "exact"
+        #EF: This sets the default topology
+        self.sockets = '1'
+        self.cores = '4'
+        self.threads = '1'

     def format_dom(self):
         cpu = super(LibvirtConfigGuestCPU, self).format_dom()
@@ -342,7 +346,7 @@
         if self.mode:
             cpu.set("mode", self.mode)
         cpu.set("match", self.match)
-
+       
         return cpu


diff -uNr libvirt.old/driver.py libvirt/driver.py
--- libvirt.old/driver.py       2013-06-07 06:33:51.000000000 +1200
+++ libvirt/driver.py   2013-09-30 16:26:05.000000000 +1300
@@ -2005,7 +2005,6 @@
             msg = _("Passthrough of the host CPU was requested but "
                     "this libvirt version does not support this feature")
             raise exception.NovaException(msg)
-
         return cpu

     def get_guest_disk_config(self, instance, name, disk_mapping, inst_type,
@@ -2152,7 +2151,18 @@
                     setattr(guest, scope[1], value)


         guest.cpu = self.get_guest_cpu_config()
-
+        #EF: Get number of VCPU's, divide that by 8 to get the number of sockets (we are using 8 core CPUs)
+        numSockets = int(guest.vcpus) / 8
+        numCoresRemain = int(guest.vcpus) % 8
+        if numCoresRemain > 0:
+            numSockets = numSockets + 1
+        if numSockets > 0:
+            guest.cpu.sockets = str(numSockets)
+            guest.cpu.cores = '8'
+        else:
+            guest.cpu.sockets = '1'
+            guest.cpu.cores = '8'
+       
         if 'root' in disk_mapping and disk_mapping['root']['dev'] is not None:
             root_device_name = "/dev/" + disk_mapping['root']['dev']
         else:
@@ -2333,6 +2343,7 @@
                   locals())
         conf = self.get_guest_config(instance, network_info, image_meta,
                                      disk_info, rescue, block_device_info)
+
         xml = conf.to_xml()

         if write_to_disk:


From: John Mark Walker [mailto:johnmark at johnmark.org] 
Sent: Thursday, 26 September 2013 8:43 a.m.
To: openstack at lists.openstack.org
Subject: [Openstack] Fwd: Defining VM's CPU Socket:Core Topology

Did anyone else find this message in their spam filter?

---------- Forwarded message ----------
From: Evan Fraser <evan.fraser at trademe.co.nz>
Date: Tue, Sep 24, 2013 at 7:49 PM
Subject: [Openstack] Defining VM's CPU Socket:Core Topology
To: "openstack at lists.openstack.org" <openstack at lists.openstack.org>

Hello,
I am trying to figure out how to define a VM’s CPU Socket:Core:Threads topology.  For licensing reasons we can’t create VM’s that map each core as a separate socket.
 
KVM and libvirt both support the ability to define the socket:core ratio/topology, but I can’t see how to get openstack to request those capabilities.
 
I've tried the libvirt_cpu_mode and libvirt_cpu_model options, but they only seem to control the cpu's name, and what flags are passed through.
 
It seems that if I could only get nova to create the xml file with a topology section eg: <toplogy sockets=’1’ cores=’4’ threads=’1’/> then it would work.
 
This feature request seems related: https://bugs.launchpad.net/nova/+bug/1199019
 
But I’m not sure if it’s possible to define it within nova as yet anyway.
 
Cheers, Evan.
Evan Fraser
Trade Me | Storage Engineer
P
+64 4 803 2756
M
+64 22 087 4032
E   
evan.fraser at trademe.co.nz
 
 

_______________________________________________
Mailing list: http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack
Post to     : openstack at lists.openstack.org
Unsubscribe : http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack



More information about the Openstack mailing list