Skip to content

Commit 68e22ab

Browse files
committed
Adding requirements to support ARM instance
- If arch is ARM, SendCtrlAltDel is not supported and Skip testPing Signed-off-by: Vaishnavi Vejella <[email protected]>
1 parent 7af7903 commit 68e22ab

File tree

6 files changed

+25
-8
lines changed

6 files changed

+25
-8
lines changed

.hack/go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@ go 1.11
1212
require (
1313
github.com/awslabs/tc-redirect-tap v0.0.0-20220715050423-f2af44521093 // indirect
1414
github.com/containernetworking/plugins v1.1.1 // indirect
15+
github.com/kunalkushwaha/ltag v0.2.3 // indirect
1516
)

.hack/go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,8 @@ github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfn
393393
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
394394
github.com/kr/pty v1.1.5/go.mod h1:9r2w37qlBe7rQ6e1fg1S/9xpWHSnaqNdHD3WcMdbPDA=
395395
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
396+
github.com/kunalkushwaha/ltag v0.2.3 h1:5rwJiC1oQ/OiamZ8JNCHQGUe7OkHTFrRtyNon3VYPok=
397+
github.com/kunalkushwaha/ltag v0.2.3/go.mod h1:w1hVMWOh870f+WAv/UIoZAy0bHCbPP4+W6JxNcPUiQA=
396398
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
397399
github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
398400
github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ DISABLE_ROOT_TESTS?=1
1717
DOCKER_IMAGE_TAG?=latest
1818
EXTRAGOARGS:=
1919
FIRECRACKER_DIR=build/firecracker
20-
FIRECRACKER_TARGET?=x86_64-unknown-linux-musl
20+
arch=$(shell uname -m)
21+
FIRECRACKER_TARGET?=$(arch)-unknown-linux-musl
2122

2223
FC_TEST_DATA_PATH?=testdata
2324
FC_TEST_BIN_PATH:=$(FC_TEST_DATA_PATH)/bin
@@ -28,7 +29,6 @@ UID = $(shell id -u)
2829
GID = $(shell id -g)
2930

3031
firecracker_version=v1.0.0
31-
arch=$(shell uname -m)
3232

3333
# The below files are needed and can be downloaded from the internet
3434
release_url=https://github.com/firecracker-microvm/firecracker/releases/download/$(firecracker_version)/firecracker-$(firecracker_version)-$(arch).tgz

machine.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
"os/exec"
2525
"os/signal"
2626
"path/filepath"
27+
"runtime"
2728
"strconv"
2829
"strings"
2930
"sync"
@@ -65,6 +66,9 @@ type SeccompConfig struct {
6566
// be started again.
6667
var ErrAlreadyStarted = errors.New("firecracker: machine already started")
6768

69+
// ErrGraceShutdown signifies that the Machine will shutdown gracefully and SendCtrlAltDelete is unable to send
70+
var ErrGraceShutdown = errors.New("Shutdown gracefully: SendCtrlAltDelete is not supported if the arch is ARM64")
71+
6872
type MMDSVersion string
6973

7074
const (
@@ -456,7 +460,10 @@ func (m *Machine) Start(ctx context.Context) error {
456460
// Shutdown requests a clean shutdown of the VM by sending CtrlAltDelete on the virtual keyboard
457461
func (m *Machine) Shutdown(ctx context.Context) error {
458462
m.logger.Debug("Called machine.Shutdown()")
459-
return m.sendCtrlAltDel(ctx)
463+
if runtime.GOARCH != "arm64" {
464+
return m.sendCtrlAltDel(ctx)
465+
}
466+
return ErrGraceShutdown
460467
}
461468

462469
// Wait will wait until the firecracker process has finished. Wait is safe to

machine_test.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727
"os/signal"
2828
"path/filepath"
2929
"regexp"
30+
"runtime"
3031
"strconv"
3132
"strings"
3233
"sync"
@@ -865,8 +866,10 @@ func TestStopVMMCleanup(t *testing.T) {
865866

866867
func testShutdown(ctx context.Context, t *testing.T, m *Machine) {
867868
err := m.Shutdown(ctx)
868-
if err != nil {
869-
t.Errorf("machine.Shutdown() failed: %s", err)
869+
if runtime.GOARCH == "arm64" {
870+
assert.ErrorIs(t, err, ErrGraceShutdown)
871+
} else {
872+
assert.NoError(t, err, "machine.Shutdown() failed")
870873
}
871874
}
872875

network_test.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"net"
2121
"os"
2222
"path/filepath"
23+
"runtime"
2324
"sync"
2425
"testing"
2526
"time"
@@ -253,7 +254,7 @@ func testNetworkMachineCNI(t *testing.T, useConfFile bool) {
253254
}
254255
fctesting.RequiresRoot(t)
255256

256-
cniBinPath := []string{"/opt/cni/bin", testDataBin}
257+
cniBinPath := []string{testDataBin, "/opt/cni/bin"}
257258

258259
dir, err := ioutil.TempDir("", fsSafeTestName.Replace(t.Name()))
259260
require.NoError(t, err)
@@ -344,7 +345,11 @@ func testNetworkMachineCNI(t *testing.T, useConfFile bool) {
344345

345346
assert.FileExists(t, expectedCacheDirPath, "CNI cache dir doesn't exist after vm startup")
346347

347-
testPing(t, vmIP, 3, 5*time.Second)
348+
if runtime.GOARCH != "arm64" {
349+
testPing(t, vmIP, 3, 5*time.Second)
350+
} else {
351+
m.StopVMM()
352+
}
348353

349354
require.NoError(t, m.StopVMM(), "failed to stop machine")
350355
waitCtx, waitCancel := context.WithTimeout(ctx, 3*time.Second)
@@ -405,7 +410,6 @@ func newCNIMachine(t *testing.T,
405410
MachineCfg: models.MachineConfiguration{
406411
VcpuCount: Int64(2),
407412
MemSizeMib: Int64(256),
408-
Smt: Bool(true),
409413
},
410414
Drives: []models.Drive{
411415
{

0 commit comments

Comments
 (0)