31 lines
536 B
Go
31 lines
536 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)
|
|
|
|
conn.DomainQemuMonitorEventRegister(nil, "(.*)", QemuEvents, libvirt.CONNECT_DOMAIN_QEMU_MONITOR_EVENT_REGISTER_REGEX)
|
|
|
|
for {
|
|
libvirt.EventRunDefaultImpl()
|
|
}
|
|
}
|