Save forwarded ssh port
This commit is contained in:
parent
a41de84157
commit
dfc1f64841
@ -74,7 +74,8 @@ type QemuSystem struct {
|
|||||||
stderr io.ReadCloser
|
stderr io.ReadCloser
|
||||||
stdout io.ReadCloser
|
stdout io.ReadCloser
|
||||||
}
|
}
|
||||||
died bool
|
died bool
|
||||||
|
sshHostFwd string
|
||||||
|
|
||||||
// accessible after qemu is closed
|
// accessible after qemu is closed
|
||||||
Stdout, Stderr string
|
Stdout, Stderr string
|
||||||
@ -134,7 +135,7 @@ func kvmExists() bool {
|
|||||||
// Start qemu process
|
// Start qemu process
|
||||||
func (q *QemuSystem) Start() (err error) {
|
func (q *QemuSystem) Start() (err error) {
|
||||||
rand.Seed(time.Now().UnixNano()) // Are you sure?
|
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",
|
qemuArgs := []string{"-snapshot", "-nographic",
|
||||||
"-hda", q.drivePath,
|
"-hda", q.drivePath,
|
||||||
"-kernel", q.kernel.Path,
|
"-kernel", q.kernel.Path,
|
||||||
@ -142,7 +143,7 @@ func (q *QemuSystem) Start() (err error) {
|
|||||||
"-smp", fmt.Sprintf("%d", q.Cpus),
|
"-smp", fmt.Sprintf("%d", q.Cpus),
|
||||||
"-m", fmt.Sprintf("%d", q.Memory),
|
"-m", fmt.Sprintf("%d", q.Memory),
|
||||||
"-device", "e1000,netdev=n1",
|
"-device", "e1000,netdev=n1",
|
||||||
"-netdev", "user,id=n1," + hostfwd,
|
"-netdev", "user,id=n1," + q.sshHostFwd,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (q.arch == X86_64 || q.arch == I386) && kvmExists() {
|
if (q.arch == X86_64 || q.arch == I386) && kvmExists() {
|
||||||
|
Loading…
Reference in New Issue
Block a user