mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-10-14 00:27:53 +00:00
qemu: use x-ignore-shared to implement vm template
qemu upstream has x-ignore-shared that works similar to our private bypass-shared-memory. We can use it to implement the vm template feature. Fixes: #1798 Depends-on: github.com/kata-containers/packaging#641 Signed-off-by: Peng Tao <bergwolf@hyper.sh>
This commit is contained in:
@@ -13,7 +13,9 @@ import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
govmmQemu "github.com/intel/govmm/qemu"
|
||||
"github.com/kata-containers/runtime/virtcontainers/device/config"
|
||||
@@ -561,3 +563,50 @@ func createQemuSandboxConfig() (*Sandbox, error) {
|
||||
|
||||
return &sandbox, nil
|
||||
}
|
||||
|
||||
func TestQemuVirtiofsdArgs(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
||||
q := &qemu{
|
||||
id: "foo",
|
||||
config: HypervisorConfig{
|
||||
VirtioFSCache: "none",
|
||||
Debug: true,
|
||||
},
|
||||
}
|
||||
|
||||
savedKataHostSharedDir := kataHostSharedDir
|
||||
kataHostSharedDir = "test-share-dir"
|
||||
defer func() {
|
||||
kataHostSharedDir = savedKataHostSharedDir
|
||||
}()
|
||||
|
||||
result := "-o vhost_user_socket=bar1 -o source=test-share-dir/foo -o cache=none -d"
|
||||
args := q.virtiofsdArgs("bar1")
|
||||
assert.Equal(strings.Join(args, " "), result)
|
||||
|
||||
q.config.Debug = false
|
||||
result = "-o vhost_user_socket=bar2 -o source=test-share-dir/foo -o cache=none -f"
|
||||
args = q.virtiofsdArgs("bar2")
|
||||
assert.Equal(strings.Join(args, " "), result)
|
||||
}
|
||||
|
||||
func TestQemuWaitVirtiofsd(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
||||
q := &qemu{}
|
||||
|
||||
ready := make(chan error, 1)
|
||||
timeout := 5
|
||||
|
||||
ready <- nil
|
||||
remain, err := q.waitVirtiofsd(time.Now(), timeout, ready, "")
|
||||
assert.Nil(err)
|
||||
assert.True(remain <= timeout)
|
||||
assert.True(remain >= 0)
|
||||
|
||||
timeout = 0
|
||||
remain, err = q.waitVirtiofsd(time.Now(), timeout, ready, "")
|
||||
assert.NotNil(err)
|
||||
assert.True(remain == 0)
|
||||
}
|
||||
|
Reference in New Issue
Block a user