On top of the already submitted series, using regexp matching would look like:
Author: Christophe de Dinechin <email address hidden>
Date: Fri May 15 15:42:08 2020 +0200
config: Match valid virtiofsd using regular expressions
This increases the configuration flexibiliy by allowing free-for-all
annotations with arbitrary restrictions. For example, you can accept
all variants of `virtiofsd` that are somewhere under `/usr`/ as well
as one specifically installed under /opt/kata/bin/virtiofsd by adding
this to the configuration:
if value, ok := ocispec.Annotations[vcAnnotations.VirtioFSDaemon]; ok {
- if !contains(runtime.HypervisorConfig.VirtioFSDaemonList, value) {
+ if !regexpContains(runtime.HypervisorConfig.VirtioFSDaemonList, value) {
return fmt.Errorf("virtiofs daemon %v required from annotation is not valid", value)
}
sbConfig.HypervisorConfig.VirtioFSDaemon = value
On top of the already submitted series, using regexp matching would look like:
Author: Christophe de Dinechin <email address hidden>
Date: Fri May 15 15:42:08 2020 +0200
config: Match valid virtiofsd using regular expressions
This increases the configuration flexibiliy by allowing free-for-all bin/virtiofsd by adding
annotations with arbitrary restrictions. For example, you can accept
all variants of `virtiofsd` that are somewhere under `/usr`/ as well
as one specifically installed under /opt/kata/
this to the configuration:
virtio_ fs_daemon_ list = [ "/opt/kata/ bin/virtiofsd" , "/usr/.*/virtiofsd" ]
Suggested-by: Peng Tao <email address hidden>
Signed-off-by: Christophe de Dinechin <email address hidden>
diff --git a/virtcontainer s/pkg/oci/ utils.go b/virtcontainer s/pkg/oci/ utils.go s/pkg/oci/ utils.go s/pkg/oci/ utils.go
index b47583ec..533f5593 100644
--- a/virtcontainer
+++ b/virtcontainer
@@ -11,6 +11,7 @@ import (
"fmt"
"path/filepath"
goruntime "runtime"
+ "regexp"
"strconv"
"strings"
"syscall"
@@ -194,6 +195,15 @@ func contains(s []string, e string) bool {
return false
}
+func regexpContains(s []string, e string) bool { MatchString( a, e); matched { nfo(d specs.LinuxDevice) (*config. DeviceInfo, error) { Types := []string{"c", "b", "u", "p"}
+ for _, a := range s {
+ if matched, _ := regexp.
+ return true
+ }
+ }
+ return false
+}
+
func newLinuxDeviceI
allowedDevice
@@ -663,7 +673,7 @@ func addHypervisporV irtioFsOverride s(ocispec specs.Spec, sbConfig *vc.SandboxCon
}
if value, ok := ocispec. Annotations[ vcAnnotations. VirtioFSDaemon] ; ok { runtime. HypervisorConfi g.VirtioFSDaemo nList, value) { (runtime. HypervisorConfi g.VirtioFSDaemo nList, value) { "virtiofs daemon %v required from annotation is not valid", value) HypervisorConfi g.VirtioFSDaemo n = value
- if !contains(
+ if !regexpContains
return fmt.Errorf(
}
sbConfig.