提交 6e945da5 编写于 作者: J Jiri Denemark

Add keepalive support into domain-events examples

上级 e401b0cd
......@@ -416,7 +416,14 @@ int main(int argc, char **argv)
(callback6ret != -1) &&
(callback7ret != -1) &&
(callback9ret != -1)) {
while (run) {
if (virConnectSetKeepAlive(dconn, 5, 3) < 0) {
virErrorPtr err = virGetLastError();
fprintf(stderr, "Failed to start keepalive protocol: %s\n",
err && err->message ? err->message : "Unknown error");
run = 0;
}
while (run && virConnectIsAlive(dconn) == 1) {
if (virEventRunDefaultImpl() < 0) {
virErrorPtr err = virGetLastError();
fprintf(stderr, "Failed to run event loop: %s\n",
......
......@@ -531,11 +531,13 @@ def main():
vc.domainEventRegisterAny(None, libvirt.VIR_DOMAIN_EVENT_ID_GRAPHICS, myDomainEventGraphicsCallback, None)
vc.domainEventRegisterAny(None, libvirt.VIR_DOMAIN_EVENT_ID_DISK_CHANGE, myDomainEventDiskChangeCallback, None)
vc.setKeepAlive(5, 3)
# The rest of your app would go here normally, but for sake
# of demo we'll just go to sleep. The other option is to
# run the event loop in your main thread if your app is
# totally event based.
while 1:
while vc.isAlive() == 1:
time.sleep(1)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册