Skip to content
This repository was archived by the owner on Jan 6, 2023. It is now read-only.

Commit d96a2b7

Browse files
authored
molecule_vagrant/modules/vagrant.py: Set cpu to qemu64 with qemu driver (#83)
When TCG is used instead of KVM, libvirt defaults to using the EPYC cpu model on some systems (even if the host is an intel cpu). This leads to some weird issues, like ssh-keygen -A hanging at the boot of alpine VM in the CI. In previous works, I've work arounded the issue by switch the VM to using centos instead of alpine but I think it's a good idea to provide good working default, so the vCPU model is set to qemu64 when TCG is used, if the vCPU model is not specified. The tools/Vagrantfile has been updated to match this vCPU model too. Side-note: I'm still wondering if the same thing should be done for systems without KVM, aka automatically default to TCG in this case. Signed-off-by: Arnaud Patard <[email protected]>
1 parent 6f9de3a commit d96a2b7

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

molecule_vagrant/modules/vagrant.py

+12
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,18 @@
321321
provider['options'].each { |key, value|
322322
eval("libvirt.#{key} = #{value}")
323323
}
324+
# When using qemu instead of kvm, some libvirt systems
325+
# will use EPYC as vCPU model inside the new VM.
326+
# This will lead to process hang with ssh-keygen -A on alpine.
327+
# Not sure were the bug is (libvirt or qemu or alpine or all of them) but using QEMU64
328+
# cpu model will work around this. Hopefully, by checking 'cpu_mode' option, it will
329+
# allow people to override the model to use.
330+
if defined?(provider['options']['driver']) && provider['options']['driver'].include?('qemu')
331+
if !provider['options']['cpu_mode']
332+
libvirt.cpu_mode = 'custom'
333+
libvirt.cpu_model = 'qemu64'
334+
end
335+
end
324336
325337
# Raw Configuration
326338
if provider['raw_config_args']

tools/Vagrantfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ Vagrant.configure("2") do |config|
55
l.nic_model_type = "e1000"
66
l.driver = "qemu"
77
l.cpu_mode = 'custom'
8-
l.cpu_model = 'core2duo'
8+
l.cpu_model = 'qemu64'
99
end
1010
end

0 commit comments

Comments
 (0)