1
0

Save forwarded ssh port

This commit is contained in:
dump_stack() 2018-09-19 06:18:05 +00:00
parent a41de84157
commit dfc1f64841

View File

@ -75,6 +75,7 @@ type QemuSystem struct {
stdout io.ReadCloser
}
died bool
sshHostFwd string
// accessible after qemu is closed
Stdout, Stderr string
@ -134,7 +135,7 @@ func kvmExists() bool {
// Start qemu process
func (q *QemuSystem) Start() (err error) {
rand.Seed(time.Now().UnixNano()) // Are you sure?
hostfwd := fmt.Sprintf("hostfwd=tcp:%s-:22", getFreeAddrPort())
q.sshHostFwd = fmt.Sprintf("hostfwd=tcp:%s-:22", getFreeAddrPort())
qemuArgs := []string{"-snapshot", "-nographic",
"-hda", q.drivePath,
"-kernel", q.kernel.Path,
@ -142,7 +143,7 @@ func (q *QemuSystem) Start() (err error) {
"-smp", fmt.Sprintf("%d", q.Cpus),
"-m", fmt.Sprintf("%d", q.Memory),
"-device", "e1000,netdev=n1",
"-netdev", "user,id=n1," + hostfwd,
"-netdev", "user,id=n1," + q.sshHostFwd,
}
if (q.arch == X86_64 || q.arch == I386) && kvmExists() {