go-qemu
go-qemu copied to clipboard
Support set deadline for qmp socket connection
If some other process(e.g. libvirtd) occupy the qmp socket, run command will hang.
Sometimes we use go-qemu to take over VM when libvirtd stopped, but libvirtd service will start automatically at an undetermined time. Deadline could prevent the impact of race condition.
example: `
socket, err := qmp.NewSocketMonitor("unix", sockFile, timeout)
if err != nil {
return nil, err
}
if err := socket.SetRWDeadline(time.Now().Add(timeout)); err != nil {
return nil, err
}
if err := socket.Connect(); err != nil {
return nil, err
}
defer socket.Disconnect()
`