1
0

debug: add parameters to set ssh addr/port

This commit is contained in:
2023-02-28 19:11:28 +00:00
parent 71f5530fed
commit 0e153b2763
2 changed files with 17 additions and 1 deletions

View File

@ -127,6 +127,12 @@ func NewSystem(arch arch, kernel Kernel, drivePath string) (q *System, err error
return
}
func (q *System) SetSSHAddrPort(addr string, port int) (err error) {
// TODO validate
q.sshAddrPort = fmt.Sprintf("%s:%d", addr, port)
return
}
func getRandomAddrPort() (addr string) {
// 127.1-255.0-255.0-255:10000-50000
ip := fmt.Sprintf("127.%d.%d.%d",
@ -215,7 +221,9 @@ func (q System) cmdline() (s string) {
// Start qemu process
func (q *System) Start() (err error) {
rand.Seed(time.Now().UnixNano()) // Are you sure?
q.sshAddrPort = getFreeAddrPort()
if q.sshAddrPort == "" {
q.sshAddrPort = getFreeAddrPort()
}
hostfwd := fmt.Sprintf("hostfwd=tcp:%s-:22", q.sshAddrPort)
qemuArgs := []string{"-nographic",
"-hda", q.drivePath,