35 lines
589 B
Go

package events
import (
"log"
"os"
"libvirt.org/go/libvirt"
)
func Server() {
err := libvirt.EventRegisterDefaultImpl()
if err != nil {
log.Fatalf("Échec d'EventRegisterDefaultImpl: %v", err)
os.Exit(0)
}
conn, err := libvirt.NewConnect("qemu:///system")
if err != nil {
log.Println("Connexion Error")
}
defer conn.Close()
conn.SetKeepAlive(5, 3)
q := NewQemu(conn)
q.Events()
go q.heartbeat()
//conn.DomainQemuMonitorEventRegister(nil, "(.*)", QemuEvents, libvirt.CONNECT_DOMAIN_QEMU_MONITOR_EVENT_REGISTER_REGEX)
for {
libvirt.EventRunDefaultImpl()
}
}