mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-06-29 16:57:18 +00:00
kata_agent: use virtio-fs shared dir in CreateSandbox
Use virtio-fs instead of virtio-9p when virtio-fs is enabled. Fixes: #1542 Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
parent
9480978364
commit
82d1a9d6f4
@ -65,6 +65,7 @@ var (
|
|||||||
mountGuest9pTag = "kataShared"
|
mountGuest9pTag = "kataShared"
|
||||||
kataGuestSandboxDir = "/run/kata-containers/sandbox/"
|
kataGuestSandboxDir = "/run/kata-containers/sandbox/"
|
||||||
type9pFs = "9p"
|
type9pFs = "9p"
|
||||||
|
typeVirtioFS = "virtio_fs"
|
||||||
vsockSocketScheme = "vsock"
|
vsockSocketScheme = "vsock"
|
||||||
// port numbers below 1024 are called privileged ports. Only a process with
|
// port numbers below 1024 are called privileged ports. Only a process with
|
||||||
// CAP_NET_BIND_SERVICE capability may bind to these port numbers.
|
// CAP_NET_BIND_SERVICE capability may bind to these port numbers.
|
||||||
@ -74,7 +75,9 @@ var (
|
|||||||
kataBlkDevType = "blk"
|
kataBlkDevType = "blk"
|
||||||
kataSCSIDevType = "scsi"
|
kataSCSIDevType = "scsi"
|
||||||
kataNvdimmDevType = "nvdimm"
|
kataNvdimmDevType = "nvdimm"
|
||||||
|
kataVirtioFSDevType = "virtio-fs"
|
||||||
sharedDir9pOptions = []string{"trans=virtio,version=9p2000.L,cache=mmap", "nodev"}
|
sharedDir9pOptions = []string{"trans=virtio,version=9p2000.L,cache=mmap", "nodev"}
|
||||||
|
sharedDirVirtioFSOptions = []string{"default_permissions,allow_other,rootmode=040000,user_id=0,group_id=0,dax,tag=" + mountGuest9pTag, "nodev"}
|
||||||
shmDir = "shm"
|
shmDir = "shm"
|
||||||
kataEphemeralDevType = "ephemeral"
|
kataEphemeralDevType = "ephemeral"
|
||||||
ephemeralPath = filepath.Join(kataGuestSandboxDir, kataEphemeralDevType)
|
ephemeralPath = filepath.Join(kataGuestSandboxDir, kataEphemeralDevType)
|
||||||
@ -738,13 +741,24 @@ func (k *kataAgent) startSandbox(sandbox *Sandbox) error {
|
|||||||
|
|
||||||
// append 9p shared volume to storages only if filesystem sharing is supported
|
// append 9p shared volume to storages only if filesystem sharing is supported
|
||||||
if caps.IsFsSharingSupported() {
|
if caps.IsFsSharingSupported() {
|
||||||
sharedDir9pOptions = append(sharedDir9pOptions, fmt.Sprintf("msize=%d", sandbox.config.HypervisorConfig.Msize9p))
|
|
||||||
|
|
||||||
// We mount the shared directory in a predefined location
|
// We mount the shared directory in a predefined location
|
||||||
// in the guest.
|
// in the guest.
|
||||||
// This is where at least some of the host config files
|
// This is where at least some of the host config files
|
||||||
// (resolv.conf, etc...) and potentially all container
|
// (resolv.conf, etc...) and potentially all container
|
||||||
// rootfs will reside.
|
// rootfs will reside.
|
||||||
|
if sandbox.config.HypervisorConfig.SharedFS == config.VirtioFS {
|
||||||
|
sharedVolume := &grpc.Storage{
|
||||||
|
Driver: kataVirtioFSDevType,
|
||||||
|
Source: "none",
|
||||||
|
MountPoint: kataGuestSharedDir,
|
||||||
|
Fstype: typeVirtioFS,
|
||||||
|
Options: sharedDirVirtioFSOptions,
|
||||||
|
}
|
||||||
|
|
||||||
|
storages = append(storages, sharedVolume)
|
||||||
|
} else {
|
||||||
|
sharedDir9pOptions = append(sharedDir9pOptions, fmt.Sprintf("msize=%d", sandbox.config.HypervisorConfig.Msize9p))
|
||||||
|
|
||||||
sharedVolume := &grpc.Storage{
|
sharedVolume := &grpc.Storage{
|
||||||
Driver: kata9pDevType,
|
Driver: kata9pDevType,
|
||||||
Source: mountGuest9pTag,
|
Source: mountGuest9pTag,
|
||||||
@ -755,6 +769,7 @@ func (k *kataAgent) startSandbox(sandbox *Sandbox) error {
|
|||||||
|
|
||||||
storages = append(storages, sharedVolume)
|
storages = append(storages, sharedVolume)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if sandbox.shmSize > 0 {
|
if sandbox.shmSize > 0 {
|
||||||
path := filepath.Join(kataGuestSandboxDir, shmDir)
|
path := filepath.Join(kataGuestSandboxDir, shmDir)
|
||||||
|
Loading…
Reference in New Issue
Block a user