[gnome-boxes] Assign best possible guest CPU configuration to VMs



commit f1e67ec8f6f33ea590a254e939022437eba5f5db
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Fri Jun 1 07:02:32 2012 +0300

    Assign best possible guest CPU configuration to VMs
    
    - VM's guest CPU topology should match that of host.
    - Let libvirt choose best possible guest CPU for us on domain launch.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=676029

 src/vm-configurator.vala |   13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletions(-)
---
diff --git a/src/vm-configurator.vala b/src/vm-configurator.vala
index aa1f179..c393bc8 100644
--- a/src/vm-configurator.vala
+++ b/src/vm-configurator.vala
@@ -29,7 +29,7 @@ private class Boxes.VMConfigurator {
 
         var best_caps = get_best_guest_caps (caps, install_media);
         domain.memory = install_media.resources.ram / KIBIBYTES;
-        domain.vcpu = install_media.resources.n_cpus;
+        set_cpu_config (domain, caps);
 
         var virt_type = guest_kvm_enabled (best_caps) ? DomainVirtType.KVM : DomainVirtType.QEMU;
         domain.set_virt_type (virt_type);
@@ -170,6 +170,17 @@ private class Boxes.VMConfigurator {
         return pool;
     }
 
+    private static void set_cpu_config (Domain domain, Capabilities caps) {
+        var topology = caps.get_host ().get_cpu ().get_topology ();
+
+        domain.vcpu = topology.get_sockets () * topology.get_cores () * topology.get_threads ();
+
+        var cpu = new DomainCpu ();
+        cpu.set_mode (DomainCpuMode.HOST_MODEL);
+        cpu.set_topology (topology);
+        domain.set_cpu (cpu);
+    }
+
     private static void set_target_media_config (Domain domain, string target_path, InstallerMedia install_media) {
         var disk = new DomainDisk ();
         disk.set_type (DomainDiskType.FILE);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]