aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel P. Berrange <berrange@redhat.com>2011-05-29 20:21:53 +0800
committerDaniel Veillard <veillard@redhat.com>2011-05-29 20:21:53 +0800
commita6135ec1e6fe0bbd90d01a6c1b5a993e795693bd (patch)
treeba6a42f8d18d41d58eba2190f85fd5559a05ff2a /examples
parentsched: provide new API shims for remaining drivers (diff)
downloadlibvirt-a6135ec1e6fe0bbd90d01a6c1b5a993e795693bd.tar.gz
libvirt-a6135ec1e6fe0bbd90d01a6c1b5a993e795693bd.tar.bz2
libvirt-a6135ec1e6fe0bbd90d01a6c1b5a993e795693bd.zip
Introduce a new event emitted when a virtualization failure occurs
This introduces a new domain VIR_DOMAIN_EVENT_ID_CONTROL_ERROR Which uses the existing generic callback typedef void (*virConnectDomainEventGenericCallback)(virConnectPtr conn, virDomainPtr dom, void *opaque); This event is intended to be emitted when there is a failure in some part of the domain virtualization system. Whether the domain continues to run/exist after the failure is an implementation detail specific to the hypervisor. The idea is that with some types of failure, hypervisors may prefer to leave the domain running in a "degraded" mode of operation. For example, if something goes wrong with the QEMU monitor, it is possible to leave the guest OS running quite happily. The mgmt app will simply loose the ability todo various tasks. The mgmt app can then choose how/when to deal with the failure that occured. * daemon/remote.c: Dispatch of new event * examples/domain-events/events-c/event-test.c: Demo catch of event * include/libvirt/libvirt.h.in: Define event ID and callback * src/conf/domain_event.c, src/conf/domain_event.h: Internal event handling * src/remote/remote_driver.c: Receipt of new event from daemon * src/remote/remote_protocol.x: Wire protocol for new event * src/remote_protocol-structs: add new event for checks
Diffstat (limited to 'examples')
-rw-r--r--examples/domain-events/events-c/event-test.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/examples/domain-events/events-c/event-test.c b/examples/domain-events/events-c/event-test.c
index 2da58b8f0..4766a0df3 100644
--- a/examples/domain-events/events-c/event-test.c
+++ b/examples/domain-events/events-c/event-test.c
@@ -245,6 +245,17 @@ static int myDomainEventGraphicsCallback(virConnectPtr conn ATTRIBUTE_UNUSED,
return 0;
}
+static int myDomainEventControlErrorCallback(virConnectPtr conn ATTRIBUTE_UNUSED,
+ virDomainPtr dom,
+ void *opaque ATTRIBUTE_UNUSED)
+{
+ printf("%s EVENT: Domain %s(%d) control error\n", __func__, virDomainGetName(dom),
+ virDomainGetID(dom));
+
+ return 0;
+}
+
+
static void myFreeFunc(void *opaque)
{
char *str = opaque;
@@ -278,6 +289,7 @@ int main(int argc, char **argv)
int callback5ret = -1;
int callback6ret = -1;
int callback7ret = -1;
+ int callback8ret = -1;
struct sigaction action_stop;
memset(&action_stop, 0, sizeof action_stop);
@@ -336,6 +348,11 @@ int main(int argc, char **argv)
VIR_DOMAIN_EVENT_ID_GRAPHICS,
VIR_DOMAIN_EVENT_CALLBACK(myDomainEventGraphicsCallback),
strdup("callback graphics"), myFreeFunc);
+ callback8ret = virConnectDomainEventRegisterAny(dconn,
+ NULL,
+ VIR_DOMAIN_EVENT_ID_CONTROL_ERROR,
+ VIR_DOMAIN_EVENT_CALLBACK(myDomainEventControlErrorCallback),
+ strdup("callback control error"), myFreeFunc);
if ((callback1ret != -1) &&
(callback2ret != -1) &&
@@ -360,6 +377,8 @@ int main(int argc, char **argv)
virConnectDomainEventDeregisterAny(dconn, callback5ret);
virConnectDomainEventDeregisterAny(dconn, callback6ret);
virConnectDomainEventDeregisterAny(dconn, callback7ret);
+ if (callback8ret != -1)
+ virConnectDomainEventDeregisterAny(dconn, callback8ret);
}
VIR_DEBUG("Closing connection");