Fix nil exception when agent polling can't reach libvirt
@@ -190,7 +190,13 @@ func (l *LibvirtConnection) ListAllDomains(flags libvirt.ConnectListAllDomainsFl
// command - the qemu command, for example this gets the interfaces: {"execute":"guest-network-get-interfaces"}
// domainName - the qemu domain name
func (l *LibvirtConnection) QemuAgentCommand(command string, domainName string) (string, error) {
+ if err := l.reconnectIfNecessary(); err != nil {
+ return "", err
+ }
domain, err := l.Connect.LookupDomainByName(domainName)
+ if err != nil {
+ return "", err
+ }
result, err := domain.QemuAgentCommand(command, libvirt.DOMAIN_QEMU_AGENT_COMMAND_DEFAULT, uint32(0))
return result, err
}
