Yann Huissoud
Yann Huissoud

Reputation: 1033

libvirt-go DomainEventLifecycleRegister "could not initialize domain event timer"

I have installed libvirt-dev, compiled and run that code on a Ubuntu box:

package main

import (
    "fmt"
    "github.com/libvirt/libvirt-go"
)

func main() {
    conn, _ := libvirt.NewConnect("qemu:///system")
    defer conn.Close()

    cb := func(c *libvirt.Connect, d *libvirt.Domain, event *libvirt.DomainEventLifecycle) {
        fmt.Println(fmt.Sprintf("Event %d", event.Event))
    }

    _, err := conn.DomainEventLifecycleRegister(nil, cb)
    if err != nil {
        panic(fmt.Sprintf("cannot register libvirt domain event: %s", err))
   }
}

And got: cannot register libvirt domain event: virError(Code=1, Domain=0, Message='internal error: could not initialize domain event timer')

I'm using libvirt-go while digital ocean go-libvirt LifecycleEvents just works fine...

Any ideas?

Upvotes: 1

Views: 993

Answers (1)

DanielB
DanielB

Reputation: 2836

You've not registered any event loop implementation.

The easy way is to call EventRegisterDefaultImpl before opening a libvirt connection, and then spawn a goroutine that runs EventRunDefaultImpl in an infinite loop

The harder way is to provide your own custom event loop implementation using EventRegisterImpl

Upvotes: 2

Related Questions