Hi all,

I'm using libvirt-go and I following code to listen for lifecycle events:

func event_listen() {
    log.Printf("event_listen %s", conf.Libvirt.LocalUrl)
    hv, err := libvirt.NewConnect(conf.Libvirt.LocalUrl)

    lifecycleCallback := func(c *libvirt.Connect, d *libvirt.Domain, event *libvirt.DomainEventLifecycle) {
        event_message(c, d, "lifecycle", event)
    }

    _, err = hv.DomainEventLifecycleRegister(nil, lifecycleCallback)
    if err != nil {
        log.Printf("unable to register event callback")
        return
    }

    log.Printf("Libvirt event listener started")

    go func() {
        for err == nil {
            err = libvirt.EventRunDefaultImpl()
            log.Printf("EventRunDefaultImpl err: %+v", err)
        }
        time.Sleep(time.Second)
        event_listen()
    }()

}

It works ok until I restart libvirtd (service libvirtd restart). After that, the inner go func waits some time and continues without error. But the callback is not working anymore.

My question is, how can I detect hv reconnect (I guess it's happening in background) so I know when to reinitialize callbacks?

Thanks.

BR
Daniel Kucera.