-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Events not firing #75
Comments
Hello, you've to call virt.startEventLoop() first to register libvirt event manager with the nodejs event loop. Anthony. |
Thanks. Will try. |
Ok, tried with calling virt.startEventLoop() . It actually works somehow, as it now reacts to events. But not the one that is attached. Just for quick try I attached reboot event and rebooted the vm form virt-manager. The output from console of my app shows GENERIC CALLBACK CALLEDGENERIC CALLBACK CALLED. But not the callback I attached. More, the callback gets executed immediately when registration performs. I've checked in the source and arguments for event registration should be [object, function]. So doing properly. No idea what am I doing wrong now. |
Dug a little further and see that generic is attached to reboot. More, generic emits no event, just prints the above. |
First, use registerEventAsync (the promised version of the function) instead of registerEvent. Then, the libvirt domain acts as a EventEmitter, so you can use something looking like : .then((domain) => {
vapp.domain = domain;
return domain.registerEventAsync({ evtype: virt.VIR_DOMAIN_EVENT_ID_LIFECYCLE })
})
.then((callbackId) => {
vapp.domain.on('lifecycleEvent', (data) => {
console.log("lifecycleEvent fired : "+JSON.stringify(data));
});
return vapp.domain.getInfoAsync();
})
.then((info) => {
....
} You can use callbackId to unregister the event handling : domain.unregisterEventAsync(callbackId).then(.....); Anthony. |
I just thought that there is a way to register an event and attach function in one step (like addEventListener). Apparently must do it in two steps. |
I have a piece of code:
After running the above I get the following error:
libvirt: error : internal error: could not initialize domain event timer
Why is it so?
The text was updated successfully, but these errors were encountered: