From 6691f801bf97bd6423f17e3f70a6ce0222e1e151 Mon Sep 17 00:00:00 2001 From: JeremyHuang Date: Mon, 20 Jun 2016 17:37:29 +0800 Subject: add a initrd flag for qemu type and display the qemu command. --- config/config.go | 2 ++ example.cfg | 23 +++++++++++++++++++++++ syz-manager/example.cfg | 22 ---------------------- vm/qemu/qemu.go | 6 +++++- vm/vm.go | 1 + 5 files changed, 31 insertions(+), 23 deletions(-) create mode 100644 example.cfg delete mode 100644 syz-manager/example.cfg diff --git a/config/config.go b/config/config.go index a22b6ccff..710d758c0 100644 --- a/config/config.go +++ b/config/config.go @@ -24,6 +24,7 @@ type Config struct { Kernel string // e.g. arch/x86/boot/bzImage Cmdline string // kernel command line Image string // linux image for VMs + Initrd string Cpu int // number of VM CPUs Mem int // amount of VM memory in MBs Sshkey string // root ssh key for the image @@ -197,6 +198,7 @@ func CreateVMConfig(cfg *Config) (*vm.Config, error) { Kernel: cfg.Kernel, Cmdline: cfg.Cmdline, Image: cfg.Image, + Initrd: cfg.Initrd, Sshkey: cfg.Sshkey, Executor: filepath.Join(cfg.Syzkaller, "bin", "syz-executor"), ConsoleDev: cfg.ConsoleDev, diff --git a/example.cfg b/example.cfg new file mode 100644 index 000000000..b90285903 --- /dev/null +++ b/example.cfg @@ -0,0 +1,23 @@ +{ + "http": "localhost:5566", + "workdir": "/home/jeremy/go/src/github.com/google/syzkaller/workdir", + "sshkey": "/home/jeremy/.ssh/id_rsa", + "vmlinux": "/home/jeremy/vm/sles12-sp2-beta1-fuzz/vmlinux", + "image": "/home/jeremy/vm/sles12-sp2-beta1.qcow2", + "initrd": "/home/jeremy/vm/sles12-sp2-beta1-fuzz/initrd-4.4.13-68-default", + "kernel": "/home/jeremy/vm/sles12-sp2-beta1-fuzz/vmlinuz-4.4.13-68-default", + "syzkaller": "/home/jeremy/go/src/github.com/google/syzkaller", + "type": "qemu", + "count": 1, + "procs": 2, + "cpu": 2, + "mem": 2048, + "disable_syscalls": [ + "keyctl", + "add_key", + "request_key" + ], + "suppressions": [ + "some known bug" + ] +} diff --git a/syz-manager/example.cfg b/syz-manager/example.cfg deleted file mode 100644 index cae69d826..000000000 --- a/syz-manager/example.cfg +++ /dev/null @@ -1,22 +0,0 @@ -{ - "http": "myhost.com:56741", - "workdir": "/syzkaller/workdir", - "kernel": "/linux/arch/x86/boot/bzImage", - "vmlinux": "/linux/vmlinux", - "image": "/linux_image/wheezy.img", - "sshkey": "/linux_image/ssh/id_rsa", - "syzkaller": "/syzkaller", - "type": "qemu", - "count": 16, - "procs": 4, - "cpu": 2, - "mem": 2048, - "disable_syscalls": [ - "keyctl", - "add_key", - "request_key" - ], - "suppressions": [ - "some known bug" - ] -} diff --git a/vm/qemu/qemu.go b/vm/qemu/qemu.go index ab669b9b1..97ec1850d 100644 --- a/vm/qemu/qemu.go +++ b/vm/qemu/qemu.go @@ -5,6 +5,7 @@ package qemu import ( "fmt" + "log" "math/rand" "net" "os" @@ -142,14 +143,17 @@ func (inst *instance) Boot() error { "-smp", "sockets=2,cores=2,threads=1", "-usb", "-usbdevice", "mouse", "-usbdevice", "tablet", "-soundhw", "all", + "-initrd", inst.cfg.Initrd, } if inst.cfg.Kernel != "" { args = append(args, "-kernel", inst.cfg.Kernel, - "-append", "console=ttyS0 root=/dev/sda debug earlyprintk=serial slub_debug=UZ "+inst.cfg.Cmdline, + "-append", "\"console=ttyS0 root=/dev/sda debug earlyprintk=serial slub_debug=UZ\" "+inst.cfg.Cmdline, ) } qemu := exec.Command(inst.cfg.Bin, args...) + + log.Printf("qemu command : ", qemu.Args) qemu.Stdout = inst.wpipe qemu.Stderr = inst.wpipe if err := qemu.Start(); err != nil { diff --git a/vm/vm.go b/vm/vm.go index 8ac190264..49bec49a6 100644 --- a/vm/vm.go +++ b/vm/vm.go @@ -33,6 +33,7 @@ type Config struct { Index int Workdir string Bin string + Initrd string Kernel string Cmdline string Image string -- cgit mrf-deployment From 19523ffdccf6291a1c8363af4f9cb84c6b989d7a Mon Sep 17 00:00:00 2001 From: JeremyHuang Date: Tue, 21 Jun 2016 17:09:08 +0800 Subject: added an optional initrd flag. --- CONTRIBUTORS | 4 +++- config/config.go | 2 +- example.cfg | 23 ----------------------- syz-manager/example.cfg | 23 +++++++++++++++++++++++ vm/qemu/qemu.go | 11 ++++++----- 5 files changed, 33 insertions(+), 30 deletions(-) delete mode 100644 example.cfg create mode 100644 syz-manager/example.cfg diff --git a/CONTRIBUTORS b/CONTRIBUTORS index c48c9101d..39d2e0d3d 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -8,4 +8,6 @@ Google Inc. Andrey Konovalov David Drysdale Baozeng Ding -Lorenzo Stoakes + Lorenzo Stoakes +SUSE Inc. + Jeremy Huang diff --git a/config/config.go b/config/config.go index 710d758c0..6dc83fe56 100644 --- a/config/config.go +++ b/config/config.go @@ -24,7 +24,7 @@ type Config struct { Kernel string // e.g. arch/x86/boot/bzImage Cmdline string // kernel command line Image string // linux image for VMs - Initrd string + Initrd string // linux initial ramdisk. (optional) Cpu int // number of VM CPUs Mem int // amount of VM memory in MBs Sshkey string // root ssh key for the image diff --git a/example.cfg b/example.cfg deleted file mode 100644 index b90285903..000000000 --- a/example.cfg +++ /dev/null @@ -1,23 +0,0 @@ -{ - "http": "localhost:5566", - "workdir": "/home/jeremy/go/src/github.com/google/syzkaller/workdir", - "sshkey": "/home/jeremy/.ssh/id_rsa", - "vmlinux": "/home/jeremy/vm/sles12-sp2-beta1-fuzz/vmlinux", - "image": "/home/jeremy/vm/sles12-sp2-beta1.qcow2", - "initrd": "/home/jeremy/vm/sles12-sp2-beta1-fuzz/initrd-4.4.13-68-default", - "kernel": "/home/jeremy/vm/sles12-sp2-beta1-fuzz/vmlinuz-4.4.13-68-default", - "syzkaller": "/home/jeremy/go/src/github.com/google/syzkaller", - "type": "qemu", - "count": 1, - "procs": 2, - "cpu": 2, - "mem": 2048, - "disable_syscalls": [ - "keyctl", - "add_key", - "request_key" - ], - "suppressions": [ - "some known bug" - ] -} diff --git a/syz-manager/example.cfg b/syz-manager/example.cfg new file mode 100644 index 000000000..c5142856f --- /dev/null +++ b/syz-manager/example.cfg @@ -0,0 +1,23 @@ +{ + "http": "myhost.com:56741", + "workdir": "/syzkaller/workdir", + "kernel": "/linux/arch/x86/boot/bzImage", + "initrd": "linux/initrd", + "vmlinux": "/linux/vmlinux", + "image": "/linux_image/wheezy.img", + "sshkey": "/linux_image/ssh/id_rsa", + "syzkaller": "/syzkaller", + "type": "qemu", + "count": 16, + "procs": 4, + "cpu": 2, + "mem": 2048, + "disable_syscalls": [ + "keyctl", + "add_key", + "request_key" + ], + "suppressions": [ + "some known bug" + ] +} diff --git a/vm/qemu/qemu.go b/vm/qemu/qemu.go index 97ec1850d..444e556ca 100644 --- a/vm/qemu/qemu.go +++ b/vm/qemu/qemu.go @@ -5,7 +5,6 @@ package qemu import ( "fmt" - "log" "math/rand" "net" "os" @@ -143,17 +142,19 @@ func (inst *instance) Boot() error { "-smp", "sockets=2,cores=2,threads=1", "-usb", "-usbdevice", "mouse", "-usbdevice", "tablet", "-soundhw", "all", - "-initrd", inst.cfg.Initrd, + } + if inst.cfg.Initrd != "" { + args = append(args, + "-initrd", inst.cfg.Initrd, + ) } if inst.cfg.Kernel != "" { args = append(args, "-kernel", inst.cfg.Kernel, - "-append", "\"console=ttyS0 root=/dev/sda debug earlyprintk=serial slub_debug=UZ\" "+inst.cfg.Cmdline, + "-append", "console=ttyS0 root=/dev/sda debug earlyprintk=serial slub_debug=UZ "+inst.cfg.Cmdline, ) } qemu := exec.Command(inst.cfg.Bin, args...) - - log.Printf("qemu command : ", qemu.Args) qemu.Stdout = inst.wpipe qemu.Stderr = inst.wpipe if err := qemu.Start(); err != nil { -- cgit mrf-deployment