internal/agent/cloudhv/console.go
Ref: Size: 777 B History
package cloudhv
import (
"io"
"net"
)
// ConsoleSource opens a VM's guest console by dialling the unix socket
// cloud-hypervisor serves the serial line on (--serial socket=…). It satisfies
// serialpump.ConsoleSource; the func it wraps resolves a VM's socket path
// (production: state.Store.SerialSocketPath).
//
// The socket serves ONE client at a time — a new connection kicks the old one —
// so the pump must be its only client. Do not connect socat or similar.
type ConsoleSource func(vmID string) string
// Open dials vmID's serial socket. It fails while the VM is down or the socket
// has not yet been created; the pump's reopen loop is the retry.
func (s ConsoleSource) Open(vmID string) (io.ReadWriteCloser, error) {
return net.Dial("unix", s(vmID))
}