1
0
Fork 0

fix: do not continue retrying when qemu is dead

master
dump_stack() 2023-05-24 18:47:46 +00:00
parent b8058bffb0
commit 7d0ee9a1dc
Signed by: dump_stack
GPG Key ID: BE44DA8C062D87DC
1 changed files with 10 additions and 2 deletions

View File

@ -374,13 +374,17 @@ func (q *System) WaitForSSH(timeout time.Duration) error {
return errors.New("no ssh (timeout)") return errors.New("no ssh (timeout)")
} }
func (q System) ssh(user string) (client *ssh.Client, err error) { func (q *System) ssh(user string) (client *ssh.Client, err error) {
cfg := &ssh.ClientConfig{ cfg := &ssh.ClientConfig{
User: user, User: user,
HostKeyCallback: ssh.InsecureIgnoreHostKey(), HostKeyCallback: ssh.InsecureIgnoreHostKey(),
} }
for retries := q.SSH.Retries; retries > 0; retries-- { for retries := q.SSH.Retries; retries > 0; retries-- {
if q.Died {
return
}
client, err = ssh.Dial("tcp", q.SSH.AddrPort, cfg) client, err = ssh.Dial("tcp", q.SSH.AddrPort, cfg)
if err == nil { if err == nil {
break break
@ -512,8 +516,12 @@ func (q System) scp(user, localPath, remotePath string, recursive bool) (err err
return return
} }
func (q System) scpWithRetry(user, localPath, remotePath string, recursive bool) (err error) { func (q *System) scpWithRetry(user, localPath, remotePath string, recursive bool) (err error) {
for retries := q.SSH.Retries; retries > 0; retries-- { for retries := q.SSH.Retries; retries > 0; retries-- {
if q.Died {
return
}
err = q.scp(user, localPath, remotePath, recursive) err = q.scp(user, localPath, remotePath, recursive)
if err == nil { if err == nil {
break break