From 6595937c34ea6357fb93780c3b5548ffc238526d Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Thu, 17 May 2018 14:50:18 +0200 Subject: tools/create-gce-image.sh: support both nbd and loop Pass target OS/arch and VM type to kernel.CreateImage. Use nbd for gce and loop for qemu VM type. --- pkg/kernel/kernel.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'pkg/kernel/kernel.go') diff --git a/pkg/kernel/kernel.go b/pkg/kernel/kernel.go index fce4c1b1f..21612f10a 100644 --- a/pkg/kernel/kernel.go +++ b/pkg/kernel/kernel.go @@ -70,7 +70,14 @@ func Clean(dir string) error { // If cmdlineFile is not empty, contents of the file are appended to the kernel command line. // If sysctlFile is not empty, contents of the file are appended to the image /etc/sysctl.conf. // Produces image and root ssh key in the specified files. -func CreateImage(kernelDir, userspaceDir, cmdlineFile, sysctlFile, image, sshkey string) error { +func CreateImage(targetOS, targetArch, vmType, kernelDir, userspaceDir, cmdlineFile, sysctlFile, + image, sshkey string) error { + if targetOS != "linux" || targetArch != "amd64" { + return fmt.Errorf("only linux/amd64 is supported") + } + if vmType != "qemu" && vmType != "gce" { + return fmt.Errorf("images can be built only for qemu/gce machines") + } tempDir, err := ioutil.TempDir("", "syz-build") if err != nil { return err @@ -85,6 +92,7 @@ func CreateImage(kernelDir, userspaceDir, cmdlineFile, sysctlFile, image, sshkey cmd.Dir = tempDir cmd.Env = append([]string{}, os.Environ()...) cmd.Env = append(cmd.Env, + "SYZ_VM_TYPE="+vmType, "SYZ_CMDLINE_FILE="+osutil.Abs(cmdlineFile), "SYZ_SYSCTL_FILE="+osutil.Abs(sysctlFile), ) -- cgit mrf-deployment