mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-04-29 20:24:31 +00:00
runtime: handle io.katacontainers.config.hypervisor.virtio_fs_extra_args
Users can specify extra arguments for virtiofsd in a pod spec using the io.katacontainers.config.hypervisor.virtio_fs_extra_args annontation. However, this annotation was ignored so far by the runtime. This commit fixes the issue by processing the annotation value (if present) and translating it to the corresponding hypervisor configuration item. Fixes #1523 Signed-off-by: Pavel Mores <pmores@redhat.com>
This commit is contained in:
parent
a4fffa1f22
commit
30ff6ee88b
@ -7,6 +7,7 @@ package oci
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
@ -772,6 +773,15 @@ func addHypervisorVirtioFsOverrides(ocispec specs.Spec, sbConfig *vc.SandboxConf
|
|||||||
sbConfig.HypervisorConfig.VirtioFSDaemon = value
|
sbConfig.HypervisorConfig.VirtioFSDaemon = value
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if value, ok := ocispec.Annotations[vcAnnotations.VirtioFSExtraArgs]; ok {
|
||||||
|
var parsedValue []string
|
||||||
|
err := json.Unmarshal([]byte(value), &parsedValue)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("Error parsing virtiofsd extra arguments: %v", err)
|
||||||
|
}
|
||||||
|
sbConfig.HypervisorConfig.VirtioFSExtraArgs = append(sbConfig.HypervisorConfig.VirtioFSExtraArgs, parsedValue...)
|
||||||
|
}
|
||||||
|
|
||||||
if sbConfig.HypervisorConfig.SharedFS == config.VirtioFS && sbConfig.HypervisorConfig.VirtioFSDaemon == "" {
|
if sbConfig.HypervisorConfig.SharedFS == config.VirtioFS && sbConfig.HypervisorConfig.VirtioFSDaemon == "" {
|
||||||
return fmt.Errorf("cannot enable virtio-fs without daemon path")
|
return fmt.Errorf("cannot enable virtio-fs without daemon path")
|
||||||
}
|
}
|
||||||
|
@ -849,6 +849,7 @@ func TestAddHypervisorAnnotations(t *testing.T) {
|
|||||||
ocispec.Annotations[vcAnnotations.SharedFS] = "virtio-fs"
|
ocispec.Annotations[vcAnnotations.SharedFS] = "virtio-fs"
|
||||||
ocispec.Annotations[vcAnnotations.VirtioFSDaemon] = "/bin/false"
|
ocispec.Annotations[vcAnnotations.VirtioFSDaemon] = "/bin/false"
|
||||||
ocispec.Annotations[vcAnnotations.VirtioFSCache] = "/home/cache"
|
ocispec.Annotations[vcAnnotations.VirtioFSCache] = "/home/cache"
|
||||||
|
ocispec.Annotations[vcAnnotations.VirtioFSExtraArgs] = "[ \"arg0\", \"arg1\" ]"
|
||||||
ocispec.Annotations[vcAnnotations.Msize9p] = "512"
|
ocispec.Annotations[vcAnnotations.Msize9p] = "512"
|
||||||
ocispec.Annotations[vcAnnotations.MachineType] = "q35"
|
ocispec.Annotations[vcAnnotations.MachineType] = "q35"
|
||||||
ocispec.Annotations[vcAnnotations.MachineAccelerators] = "nofw"
|
ocispec.Annotations[vcAnnotations.MachineAccelerators] = "nofw"
|
||||||
@ -886,6 +887,7 @@ func TestAddHypervisorAnnotations(t *testing.T) {
|
|||||||
assert.Equal(config.HypervisorConfig.SharedFS, "virtio-fs")
|
assert.Equal(config.HypervisorConfig.SharedFS, "virtio-fs")
|
||||||
assert.Equal(config.HypervisorConfig.VirtioFSDaemon, "/bin/false")
|
assert.Equal(config.HypervisorConfig.VirtioFSDaemon, "/bin/false")
|
||||||
assert.Equal(config.HypervisorConfig.VirtioFSCache, "/home/cache")
|
assert.Equal(config.HypervisorConfig.VirtioFSCache, "/home/cache")
|
||||||
|
assert.ElementsMatch(config.HypervisorConfig.VirtioFSExtraArgs, [2]string{"arg0", "arg1"})
|
||||||
assert.Equal(config.HypervisorConfig.Msize9p, uint32(512))
|
assert.Equal(config.HypervisorConfig.Msize9p, uint32(512))
|
||||||
assert.Equal(config.HypervisorConfig.HypervisorMachineType, "q35")
|
assert.Equal(config.HypervisorConfig.HypervisorMachineType, "q35")
|
||||||
assert.Equal(config.HypervisorConfig.MachineAccelerators, "nofw")
|
assert.Equal(config.HypervisorConfig.MachineAccelerators, "nofw")
|
||||||
|
Loading…
Reference in New Issue
Block a user