mirror of
https://github.com/podman-container-tools/podman.git
synced 2026-08-16 05:39:34 +00:00
this is the second provider done (qemu first). all tests pass on arm64 hardware locally ... the hybrid pull from oci registries limit this to arm64 only. calling gvproxy, waiting for it, and then vfkit seems to still be problematic. this would be an area that should be cleaned up once all providers are implemented. Signed-off-by: Brent Baude <bbaude@redhat.com>
60 lines
1.2 KiB
Go
60 lines
1.2 KiB
Go
package vmconfigs
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
)
|
|
|
|
type VolumeMountType int
|
|
|
|
const (
|
|
NineP VolumeMountType = iota
|
|
VirtIOFS
|
|
Unknown
|
|
)
|
|
|
|
func (v VolumeMountType) String() string {
|
|
switch v {
|
|
case NineP:
|
|
return "9p"
|
|
case VirtIOFS:
|
|
return "virtiofs"
|
|
default:
|
|
return "unknown"
|
|
}
|
|
}
|
|
|
|
func extractSourcePath(paths []string) string {
|
|
return paths[0]
|
|
}
|
|
|
|
func extractMountOptions(paths []string) (bool, string) {
|
|
readonly := false
|
|
securityModel := "none"
|
|
if len(paths) > 2 {
|
|
options := paths[2]
|
|
volopts := strings.Split(options, ",")
|
|
for _, o := range volopts {
|
|
switch {
|
|
case o == "rw":
|
|
readonly = false
|
|
case o == "ro":
|
|
readonly = true
|
|
case strings.HasPrefix(o, "security_model="):
|
|
securityModel = strings.Split(o, "=")[1]
|
|
default:
|
|
fmt.Printf("Unknown option: %s\n", o)
|
|
}
|
|
}
|
|
}
|
|
return readonly, securityModel
|
|
}
|
|
|
|
func SplitVolume(idx int, volume string) (string, string, string, bool, string) {
|
|
tag := fmt.Sprintf("vol%d", idx)
|
|
paths := pathsFromVolume(volume)
|
|
source := extractSourcePath(paths)
|
|
target := extractTargetPath(paths)
|
|
readonly, securityModel := extractMountOptions(paths)
|
|
return tag, source, target, readonly, securityModel
|
|
}
|