From 6419afbb779b26af853b46d8ad79cfe52b6f7805 Mon Sep 17 00:00:00 2001 From: Greg Steuck Date: Tue, 27 Nov 2018 04:14:06 -0800 Subject: openbsd: run on gce * build/openbsd: minor cleanup (use tuples instead of maps) * Grammar nits in comments. * Simplify openbsd.Create, will defer when there's more than one error exit. * pkg/build: Support copying kernel into GCE image * Simple test for openbsd image copy build. * Cleanup in case something failed before. * Support multi-processor VMs on GCE. * More debug * Reformat * OpenBSD gce image needs to be raw. * GC * Force format to GNU directly on Go 1.10 or newer. * Use vmType passed as a parameter inside openbsd.go * gofmt * more fmt * Can't use GENERIC.mp just yet. * capitalize * Copyright --- vm/gce/gce.go | 13 ++++--------- vm/gce/tar_go1.10.go | 14 ++++++++++++++ vm/gce/tar_go1.9.go | 19 +++++++++++++++++++ 3 files changed, 37 insertions(+), 9 deletions(-) create mode 100644 vm/gce/tar_go1.10.go create mode 100644 vm/gce/tar_go1.9.go (limited to 'vm/gce') diff --git a/vm/gce/gce.go b/vm/gce/gce.go index 52ea87a48..32f3e2947 100644 --- a/vm/gce/gce.go +++ b/vm/gce/gce.go @@ -100,7 +100,7 @@ func ctor(env *vmimpl.Env) (vmimpl.Pool, error) { if cfg.GCEImage == "" { cfg.GCEImage = env.Name gcsImage := filepath.Join(cfg.GCSPath, env.Name+"-image.tar.gz") - log.Logf(0, "uploading image to %v...", gcsImage) + log.Logf(0, "uploading image %v to %v...", env.Image, gcsImage) if err := uploadImageToGCS(env.Image, gcsImage); err != nil { return nil, err } @@ -436,15 +436,10 @@ func uploadImageToGCS(localImage, gcsImage string) error { Mode: 0640, Size: localStat.Size(), ModTime: time.Now(), - // This is hacky but we actually need these large uids. - // GCE understands only the old GNU tar format and - // there is no direct way to force tar package to use GNU format. - // But these large numbers force tar to switch to GNU format. - Uid: 100000000, - Gid: 100000000, - Uname: "syzkaller", - Gname: "syzkaller", + Uname: "syzkaller", + Gname: "syzkaller", } + setGNUFormat(tarHeader) if err := tarWriter.WriteHeader(tarHeader); err != nil { return fmt.Errorf("failed to write image tar header: %v", err) } diff --git a/vm/gce/tar_go1.10.go b/vm/gce/tar_go1.10.go new file mode 100644 index 000000000..88a5d1fda --- /dev/null +++ b/vm/gce/tar_go1.10.go @@ -0,0 +1,14 @@ +// Copyright 2018 syzkaller project authors. All rights reserved. +// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. + +// +build go1.10 + +package gce + +import ( + "archive/tar" +) + +func setGNUFormat(hdr *tar.Header) { + hdr.Format = tar.FormatGNU +} diff --git a/vm/gce/tar_go1.9.go b/vm/gce/tar_go1.9.go new file mode 100644 index 000000000..a26ecbdd5 --- /dev/null +++ b/vm/gce/tar_go1.9.go @@ -0,0 +1,19 @@ +// Copyright 2018 syzkaller project authors. All rights reserved. +// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. + +// +build !go1.10 + +package gce + +import ( + "archive/tar" +) + +func setGNUFormat(hdr *tar.Header) { + // This is hacky but we actually need these large uids. + // GCE understands only the old GNU tar format and prior to Go 1.10 + // there is no direct way to force tar package to use GNU format. + // But these large numbers force tar to switch to GNU format. + hdr.Uid = 100000000 + hdr.Gid = 100000000 +} -- cgit mrf-deployment