Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support to set cpu model with more detail #727

Closed
yanxuean opened this issue Jul 26, 2018 · 2 comments · Fixed by #728
Closed

support to set cpu model with more detail #727

yanxuean opened this issue Jul 26, 2018 · 2 comments · Fixed by #728

Comments

@yanxuean
Copy link
Contributor

yanxuean commented Jul 26, 2018

@jellonek
I see that the #696 has supported to set cpu model to "host-model". I don't know the #696 has implemented it before:)
I also implemented a new version based v1.0.0, it can set more cpu features, and set host-model,pass-through,custum etc.
I think the new version is more flexible.
Please take a look if we need the new version. thanks.

some code

 func (va *VirtletAnnotations) parsePodAnnotations(ns string, podAnnotations map[string]string) error {
+       if cpuModeStr, found := podAnnotations[cpuMode]; found {
+               var cpuMode libvirtxml.DomainCPU
+               if err := yaml.Unmarshal([]byte(cpuModeStr), &cpuMode); err != nil {
+                       return err
+               }
+               va.CPUMode = &cpuMode
+       }
+
        if podAnnotations[cloudInitUserDataOverwriteKeyName] == "true" {
                va.UserDataOverwrite = true
        }

@@ -106,18 +106,19 @@ func (ds *domainSettings) createDomain(config *VMConfig) *libvirtxml.Domain {
                // The plan is to enable it via an annotation at some point.
                // It commonly requires kvm_intel module to be loaded like this:
                // modprobe kvm_intel nested=1
-               CPU: &libvirtxml.DomainCPU{
-                       Mode: "host-model",
-                       Model: &libvirtxml.DomainCPUModel{
-                               Fallback: "forbid",
-                       },
-                       Features: []libvirtxml.DomainCPUFeature{
-                               {
-                                       Policy: "require",
-                                       Name:   "avx",
-                               },
-                       },
-               },
+               CPU: config.ParsedAnnotations.CPUMode,

for pod spec:

apiVersion: v1
kind: Pod
metadata:
  name: cirros-vm
  annotations:
    # This tells CRI Proxy that this pod belongs to Virtlet runtime
    kubernetes.io/target-runtime: virtlet.cloud
    # CirrOS doesn't load nocloud data from SCSI CD-ROM for some reason
    VirtletDiskDriver: virtio
    VirtletVCPUCount: "4"
    # for "mode": host-model, host-passthrough,custom
    # for "model": Westmere, SandyBridge
    VirtletCPUMode: |
      mode: custom
      model:
        value: Westmere
      features:
      - name: avx
        policy: disable

@jellonek
Copy link
Contributor

Can you propose a PR which in same time will retain the simplicity of usage provided in #696 with a flexibility of suggestion provided there?
After changes in #696 you can set single string valued annotation without knowing internals of libvirt, to enable nested virtualization. It can be also provided globally for all vm pods, or for vm pods per node - using virtlet configuration.
Having a possibility to pass more details for cpu settings (maybe by having in parallel VirtletCPUMode with a new VirtletCPUSettings based on this proposal?) would be imo very interesting.

@yanxuean
Copy link
Contributor Author

ok, will do later. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants