Refactor
This commit is contained in:
parent
844f5a5580
commit
6ee5530554
@ -178,6 +178,24 @@ func (q *System) panicWatcher() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (q System) cmdline() (s string) {
|
||||||
|
s = "root=/dev/sda ignore_loglevel console=ttyS0 rw"
|
||||||
|
|
||||||
|
if q.noKASLR {
|
||||||
|
s += " nokaslr"
|
||||||
|
}
|
||||||
|
|
||||||
|
if q.noSMEP {
|
||||||
|
s += " nosmep"
|
||||||
|
}
|
||||||
|
|
||||||
|
if q.noSMAP {
|
||||||
|
s += " nosmap"
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// Start qemu process
|
// Start qemu process
|
||||||
func (q *System) Start() (err error) {
|
func (q *System) Start() (err error) {
|
||||||
rand.Seed(time.Now().UnixNano()) // Are you sure?
|
rand.Seed(time.Now().UnixNano()) // Are you sure?
|
||||||
@ -192,24 +210,10 @@ func (q *System) Start() (err error) {
|
|||||||
"-netdev", "user,id=n1," + hostfwd,
|
"-netdev", "user,id=n1," + hostfwd,
|
||||||
}
|
}
|
||||||
|
|
||||||
cmdline := "root=/dev/sda ignore_loglevel console=ttyS0 rw"
|
|
||||||
|
|
||||||
if q.debug {
|
if q.debug {
|
||||||
qemuArgs = append(qemuArgs, "-gdb", q.gdb)
|
qemuArgs = append(qemuArgs, "-gdb", q.gdb)
|
||||||
}
|
}
|
||||||
|
|
||||||
if q.noKASLR {
|
|
||||||
cmdline += " nokaslr"
|
|
||||||
}
|
|
||||||
|
|
||||||
if q.noSMEP {
|
|
||||||
cmdline += " nosmep"
|
|
||||||
}
|
|
||||||
|
|
||||||
if q.noSMAP {
|
|
||||||
cmdline += " nosmap"
|
|
||||||
}
|
|
||||||
|
|
||||||
if q.kernel.InitrdPath != "" {
|
if q.kernel.InitrdPath != "" {
|
||||||
qemuArgs = append(qemuArgs, "-initrd", q.kernel.InitrdPath)
|
qemuArgs = append(qemuArgs, "-initrd", q.kernel.InitrdPath)
|
||||||
}
|
}
|
||||||
@ -222,7 +226,7 @@ func (q *System) Start() (err error) {
|
|||||||
qemuArgs = append(qemuArgs, "-accel", "hvf", "-cpu", "host")
|
qemuArgs = append(qemuArgs, "-accel", "hvf", "-cpu", "host")
|
||||||
}
|
}
|
||||||
|
|
||||||
qemuArgs = append(qemuArgs, "-append", cmdline)
|
qemuArgs = append(qemuArgs, "-append", q.cmdline())
|
||||||
|
|
||||||
q.cmd = exec.Command("qemu-system-"+string(q.arch), qemuArgs...)
|
q.cmd = exec.Command("qemu-system-"+string(q.arch), qemuArgs...)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user