diff --git a/kata-containers.spec b/kata-containers.spec index 2405ac4360bc9623ded153c94e54fb51c7a20d5c..c77a6130a0d6d0a9a3b985c5404b1e68d53edfea 100644 --- a/kata-containers.spec +++ b/kata-containers.spec @@ -2,7 +2,7 @@ %global debug_package %{nil} %define VERSION v1.11.1 -%define RELEASE 7 +%define RELEASE 9 Name: kata-containers Version: %{VERSION} @@ -90,6 +90,18 @@ install -p -m 640 -D ./runtime/cli/config/configuration-qemu.toml %{buildroot}/u %changelog +* Thu Jan 7 2021 LiangZhang - 1.11.1-8 +- Type:feature +- ID:NA +- SUG:NA +- DESC:add suport for stratovirt of kata-check cli + * Tue Dec 22 2020 jiangpengfei - 1.11.1-7 - Type:enhancement - ID:NA diff --git a/runtime/patches/0064-runtime-add-support-for-stratovirt-of-kata-check-cli.patch b/runtime/patches/0064-runtime-add-support-for-stratovirt-of-kata-check-cli.patch new file mode 100644 index 0000000000000000000000000000000000000000..d020b11710614386bddef74dd431ae1054f6bb0f --- /dev/null +++ b/runtime/patches/0064-runtime-add-support-for-stratovirt-of-kata-check-cli.patch @@ -0,0 +1,38 @@ +From 5af764ee8aad86f57df64ad78b44611c47067cc9 Mon Sep 17 00:00:00 2001 +From: LiangZhang +Date: Tue, 15 Dec 2020 10:14:10 +0800 +Subject: [PATCH] runtime: add support for stratovirt of kata-check cli + +reason: The current version of kata-check lacks support of stratovirt + +Signed-off-by: LiangZhang +--- + cli/kata-check_amd64.go | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/cli/kata-check_amd64.go b/cli/kata-check_amd64.go +index 8376293..ae62746 100644 +--- a/cli/kata-check_amd64.go ++++ b/cli/kata-check_amd64.go +@@ -107,7 +107,7 @@ func setCPUtype(hypervisorType vc.HypervisorType) error { + fallthrough + case "clh": + fallthrough +- case "qemu": ++ case "qemu", "stratovirt": + archRequiredCPUFlags = map[string]string{ + cpuFlagVMX: "Virtualization support", + cpuFlagLM: "64Bit CPU", +@@ -286,6 +286,8 @@ func archHostCanCreateVMContainer(hypervisorType vc.HypervisorType) error { + switch hypervisorType { + case "qemu": + fallthrough ++ case "stratovirt": ++ fallthrough + case "clh": + fallthrough + case "firecracker": +-- +2.25.1 + + diff --git a/runtime/patches/0065-runtime-fixup-that-the-getPids-function-returns-pid-.patch b/runtime/patches/0065-runtime-fixup-that-the-getPids-function-returns-pid-.patch new file mode 100644 index 0000000000000000000000000000000000000000..08f22e5d263c8528030c82b6ffb59f8274e3d7fb --- /dev/null +++ b/runtime/patches/0065-runtime-fixup-that-the-getPids-function-returns-pid-.patch @@ -0,0 +1,82 @@ +From fde681b4fa01dd6a88824794fceb9b6733b6773d Mon Sep 17 00:00:00 2001 +From: root +Date: Thu, 7 Jan 2021 11:49:53 +0800 +Subject: [PATCH] runtime: fixup that the getPids function returns pid 0 + +Use pidfile to record the real pid of stratovirt, getPids then read the content of pidfile to get pid value. + +Signed-off-by: LiangZhang +--- + runtime/virtcontainers/stratovirt.go | 30 ++++++++++++++++++++++++++-- + 1 file changed, 28 insertions(+), 2 deletions(-) + +diff --git a/runtime/virtcontainers/stratovirt.go b/runtime/virtcontainers/stratovirt.go +index 020135e..e2fdd34 100644 +--- a/runtime/virtcontainers/stratovirt.go ++++ b/runtime/virtcontainers/stratovirt.go +@@ -3,6 +3,7 @@ package virtcontainers + import ( + "context" + "fmt" ++ "io/ioutil" + "os" + "os/exec" + "path/filepath" +@@ -148,6 +149,7 @@ func (s *stratovirt) startSandbox(timeout int) error { + params = append(params, "-smp", fmt.Sprintf("%d", s.config.NumVCPUs)) + params = append(params, "-m", fmt.Sprintf("%d", uint64(s.config.MemorySize)*1024*1024)) + params = append(params, "-chardev", fmt.Sprintf("id=charconsole0,path=%s", s.consolePath)) ++ params = append(params, "-pidfile", filepath.Join(s.store.RunVMStoragePath(), s.id, "pid")) + + // add devices to cmdline + for _, d := range s.devices { +@@ -587,7 +589,26 @@ func (s *stratovirt) cleanup() error { + } + + func (s *stratovirt) getPids() []int { +- return []int{s.pid} ++ var pids []int ++ if s.pid != 0 { ++ pids = append(pids, s.pid) ++ } else { ++ pid, err := ioutil.ReadFile(filepath.Join(s.store.RunVMStoragePath(), s.id, "pid")) ++ if err != nil { ++ s.Logger().WithError(err).Error("Read pid file failed.") ++ return []int{0} ++ } ++ ++ p, err := strconv.Atoi(strings.Trim(string(pid), "\n\t ")) ++ if err != nil { ++ s.Logger().WithError(err).Error("Get pid from pid file failed.") ++ return []int{0} ++ } ++ ++ pids = append(pids, p) ++ } ++ ++ return pids + } + + func (s *stratovirt) fromGrpc(ctx context.Context, hypervisorConfig *HypervisorConfig, j []byte) error { +@@ -611,12 +632,17 @@ func (s *stratovirt) generateSocket(id string, useVsock bool) (interface{}, erro + } + + func (s *stratovirt) save() (p persistapi.HypervisorState) { +- p.Pid = s.pid ++ pids := s.getPids() ++ p.Pid = pids[0] + p.Type = string(StratovirtHypervisor) + return + } + + func (s *stratovirt) load(p persistapi.HypervisorState) { + s.pid = p.Pid ++ if sandbox, err := globalSandboxList.lookupSandbox(s.id); err == nil { ++ s.sandbox = sandbox ++ } ++ + return + } +-- +2.27.0 + diff --git a/runtime/series.conf b/runtime/series.conf index 37b1b5f0cf1dcc29c0ca685509da28f8c3e662ec..462da994e348cbdc0d10b6ed8128e6066507c54a 100644 --- a/runtime/series.conf +++ b/runtime/series.conf @@ -61,3 +61,5 @@ 0061-kata-runtime-retry-inserting-of-CNI-interface.patch 0062-kata-runtime-support-using-CNI-plugin-to-insert-muti.patch 0063-kata-runtime-fix-get-sandbox-cpu-resources-problem.patch +0064-runtime-add-support-for-stratovirt-of-kata-check-cli.patch +0065-runtime-fixup-that-the-getPids-function-returns-pid-.patch