From e10fe6ecf2d895fe009a080bb34334ff63739f3e Mon Sep 17 00:00:00 2001
From: LiangZhang <zhangliang5@Huawei.com>
Date: Thu, 24 Sep 2020 14:38:04 +0800
Subject: [PATCH] runtime: fix invalid cmdline when start sandbox stratovirt

reason:
  1. MemorySize is in type of uint32, value larger than 4096 will trigger overflow.
  2. cannot disable seccomp now.

Signed-off-by: LiangZhang <zhangliang5@Huawei.com>
---
 virtcontainers/stratovirt.go | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/virtcontainers/stratovirt.go b/virtcontainers/stratovirt.go
index 7c156d5..6db8dc0 100644
--- a/virtcontainers/stratovirt.go
+++ b/virtcontainers/stratovirt.go
@@ -146,7 +146,7 @@ func (s *stratovirt) startSandbox(timeout int) error {
 
 	params = append(params, "-append "+s.getKernelCmdLine())
 	params = append(params, fmt.Sprintf("-smp %d", s.config.NumVCPUs))
-	params = append(params, fmt.Sprintf("-m %d", s.config.MemorySize*1024*1024))
+	params = append(params, fmt.Sprintf("-m %d", uint64(s.config.MemorySize)*1024*1024))
 	params = append(params, fmt.Sprintf("-chardev id=charconsole0,path=%s", s.consolePath))
 
 	// add devices to cmdline
@@ -178,6 +178,11 @@ func (s *stratovirt) startSandbox(timeout int) error {
 		params = append(params, fmt.Sprintf("-D %s/stratovirt.log", dir))
 	}
 
+	// disable Seccomp
+	if s.sandbox.config.DisableGuestSeccomp {
+		params = append(params, "-disable-seccomp")
+	}
+
 	s.Logger().Info("StratoVirt start with params: ", strings.Join(params, " "))
 
 	dir := filepath.Join(store.RunVMStoragePath(), s.id)
-- 
1.8.3.1

