aboutsummaryrefslogtreecommitdiffstats
path: root/vm/gce
diff options
context:
space:
mode:
Diffstat (limited to 'vm/gce')
-rw-r--r--vm/gce/gce.go13
-rw-r--r--vm/gce/tar_go1.10.go14
-rw-r--r--vm/gce/tar_go1.9.go19
3 files changed, 37 insertions, 9 deletions
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
+}