From ec1c16c8b2495739356a73e465b200e715c66305 Mon Sep 17 00:00:00 2001 From: Vaishnavi Vejella Date: Mon, 19 Dec 2022 17:06:05 +0000 Subject: [PATCH] Adding requirements to support ARM instance - If arch is ARM, SendCtrlAltDel is not supported and Skip testPing Signed-off-by: Vaishnavi Vejella --- .hack/go.mod | 1 + .hack/go.sum | 2 ++ Makefile | 4 ++-- machine.go | 10 +++++++++- network_test.go | 7 +++++-- 5 files changed, 19 insertions(+), 5 deletions(-) diff --git a/.hack/go.mod b/.hack/go.mod index cb7f5ed6..fbe5b321 100644 --- a/.hack/go.mod +++ b/.hack/go.mod @@ -12,4 +12,5 @@ go 1.11 require ( github.com/awslabs/tc-redirect-tap v0.0.0-20220715050423-f2af44521093 // indirect github.com/containernetworking/plugins v1.1.1 // indirect + github.com/kunalkushwaha/ltag v0.2.3 // indirect ) diff --git a/.hack/go.sum b/.hack/go.sum index 4fd35e10..ec8b2c97 100644 --- a/.hack/go.sum +++ b/.hack/go.sum @@ -393,6 +393,8 @@ github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfn github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/pty v1.1.5/go.mod h1:9r2w37qlBe7rQ6e1fg1S/9xpWHSnaqNdHD3WcMdbPDA= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/kunalkushwaha/ltag v0.2.3 h1:5rwJiC1oQ/OiamZ8JNCHQGUe7OkHTFrRtyNon3VYPok= +github.com/kunalkushwaha/ltag v0.2.3/go.mod h1:w1hVMWOh870f+WAv/UIoZAy0bHCbPP4+W6JxNcPUiQA= github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= diff --git a/Makefile b/Makefile index a23ebffc..f0971043 100644 --- a/Makefile +++ b/Makefile @@ -17,7 +17,8 @@ DISABLE_ROOT_TESTS?=1 DOCKER_IMAGE_TAG?=latest EXTRAGOARGS:= FIRECRACKER_DIR=build/firecracker -FIRECRACKER_TARGET?=x86_64-unknown-linux-musl +arch=$(shell uname -m) +FIRECRACKER_TARGET?=$(arch)-unknown-linux-musl FC_TEST_DATA_PATH?=testdata FC_TEST_BIN_PATH:=$(FC_TEST_DATA_PATH)/bin @@ -28,7 +29,6 @@ UID = $(shell id -u) GID = $(shell id -g) firecracker_version=v1.0.0 -arch=$(shell uname -m) # The below files are needed and can be downloaded from the internet release_url=https://github.com/firecracker-microvm/firecracker/releases/download/$(firecracker_version)/firecracker-$(firecracker_version)-$(arch).tgz diff --git a/machine.go b/machine.go index 437b83f3..56fa3e25 100644 --- a/machine.go +++ b/machine.go @@ -24,6 +24,7 @@ import ( "os/exec" "os/signal" "path/filepath" + "runtime" "strconv" "strings" "sync" @@ -65,6 +66,9 @@ type SeccompConfig struct { // be started again. var ErrAlreadyStarted = errors.New("firecracker: machine already started") +// ErrGraceShutdown signifies that the Machine will shutdown gracefully and SendCtrlAltDelete is unable to send +//var ErrGraceShutdown = errors.New("Shutdown gracefully: SendCtrlAltDelete is not supported if the arch is ARM64") + type MMDSVersion string const ( @@ -456,7 +460,11 @@ func (m *Machine) Start(ctx context.Context) error { // Shutdown requests a clean shutdown of the VM by sending CtrlAltDelete on the virtual keyboard func (m *Machine) Shutdown(ctx context.Context) error { m.logger.Debug("Called machine.Shutdown()") - return m.sendCtrlAltDel(ctx) + if runtime.GOARCH != "arm64" { + return m.sendCtrlAltDel(ctx) + } else { + return m.StopVMM() + } } // Wait will wait until the firecracker process has finished. Wait is safe to diff --git a/network_test.go b/network_test.go index 24358ca4..346b5cf3 100644 --- a/network_test.go +++ b/network_test.go @@ -20,6 +20,7 @@ import ( "net" "os" "path/filepath" + "runtime" "sync" "testing" "time" @@ -253,7 +254,7 @@ func testNetworkMachineCNI(t *testing.T, useConfFile bool) { } fctesting.RequiresRoot(t) - cniBinPath := []string{"/opt/cni/bin", testDataBin} + cniBinPath := []string{testDataBin, "/opt/cni/bin"} dir, err := ioutil.TempDir("", fsSafeTestName.Replace(t.Name())) require.NoError(t, err) @@ -312,6 +313,9 @@ func testNetworkMachineCNI(t *testing.T, useConfFile bool) { require.NoError(t, err, "cni conf should parse") } + if runtime.GOARCH == "arm64" { + return + } numVMs := 10 vmIPs := make(chan string, numVMs) @@ -405,7 +409,6 @@ func newCNIMachine(t *testing.T, MachineCfg: models.MachineConfiguration{ VcpuCount: Int64(2), MemSizeMib: Int64(256), - Smt: Bool(true), }, Drives: []models.Drive{ {