diff options
author | Zeeshan Ali (Khattak) <zeeshanak@gnome.org> | 2012-06-01 07:02:32 +0300 |
---|---|---|
committer | Zeeshan Ali (Khattak) <zeeshanak@gnome.org> | 2012-07-09 22:09:10 +0300 |
commit | f1e67ec8f6f33ea590a254e939022437eba5f5db (patch) | |
tree | 21dea03ed229434853aeddb02c768d7aa5d51bd9 | |
parent | 67487d837242b1c9dac0d6317e9858c290776c3b (diff) |
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
-rw-r--r-- | 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); |