Skip to content

Commit

Permalink
fix(vm): Use generic model with explicit features for Discovery cpu type
Browse files Browse the repository at this point in the history
- Add empty CPU model to libvirt cpumap.
- Use new CPU model name instead of HostModel, so kubevirt set custom mode for cpu in the libvirt domain.
- Add patch to generate Pod without cpu-model node selector for new CPU model.

Signed-off-by: Ivan Mikheykin <[email protected]>
  • Loading branch information
diafour committed Dec 23, 2024
1 parent 1e32aa0 commit 2f36d28
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
6 changes: 6 additions & 0 deletions images/virt-launcher/generic-cpu/dvp-generic-cpu.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<!-- Empty model for generic CPU. DVP will add features explicitly. -->
<cpus>
<model name='Deckhouse-Virtualization-Platform-Generic'>
<decode host='on' guest='on'/>
</model>
</cpus>
8 changes: 7 additions & 1 deletion images/virt-launcher/werf.inc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ git:
- '**/*'
includePaths:
- scripts
- generic-cpu
# Override libvirt daemon configuration.
- add: /images/{{ $.ImageName }}
to: /etc/libvirt
Expand Down Expand Up @@ -147,7 +148,12 @@ shell:
- mv /usr/bin/virt-launcher-monitor /usr/bin/virt-launcher-monitor-orig
- cp /scripts/virt-launcher-monitor-wrapper.sh /usr/bin/virt-launcher-monitor
- chmod +x /usr/bin/virt-launcher-monitor
# Configure liboverride globally.
# Add dvp generic cpu model.
- cp /generic-cpu/dvp-generic-cpu.xml /usr/share/libvirt/cpu_map/x86_dvp-generic-cpu.xml
# Concatenation-escaping to produce single quotes.
# The 'x86_486.xml' marker should work for later versions of libvirt where CPUs are grouped.
- sed 's#\(filename=.x86_486.xml..>\)#\1 <include filename='"'x86_dvp-generic-cpu.xml'"'/>#' -i /usr/share/libvirt/cpu_map/index.xml
# Configure liboverride globally. It should be done in the last stage (setup) to not break stapel commands.
- cp /etc/ld.so.preload.in /etc/ld.so.preload
# Create qemu group and user.
- groupadd --gid 107 qemu && useradd qemu --uid 107 --gid 107 --shell /bin/bash --create-home
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ func (b *KVVM) SetCPUModel(class *virtv2.VirtualMachineClass) error {
case virtv2.CPUTypeModel:
cpu.Model = class.Spec.CPU.Model
case virtv2.CPUTypeFeatures, virtv2.CPUTypeDiscovery:
cpu.Model = "Deckhouse-Virtualization-Platform-Generic"
features := make([]virtv1.CPUFeature, len(class.Status.CpuFeatures.Enabled))
for i, feature := range class.Status.CpuFeatures.Enabled {
policy := "require"
Expand Down

0 comments on commit 2f36d28

Please sign in to comment.