Signed-off-by: Pavel Hrdina <phrdina@xxxxxxxxxx> --- examples/object-events/event-test.c | 39 ++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/examples/object-events/event-test.c b/examples/object-events/event-test.c index d6cfe46..afdc7f1 100644 --- a/examples/object-events/event-test.c +++ b/examples/object-events/event-test.c @@ -464,6 +464,35 @@ static int myNetworkEventCallback(virConnectPtr conn ATTRIBUTE_UNUSED, return 0; } +static int +myDomainEventCputuneCallback(virConnectPtr conn ATTRIBUTE_UNUSED, + virDomainPtr dom, + virDomainCputuneInfoPtr cputune, + void *opaque ATTRIBUTE_UNUSED) +{ + printf("%s EVENT: Domain %s(%d) cputune updated:\n", + __func__, virDomainGetName(dom), virDomainGetID(dom)); + if (cputune->sharesSpecified) { + printf("\tshares: %llu\n", cputune->shares); + } else { + printf("\tshares: not specified\n"); + } + printf("\tperiod: %llu\n\tquota: %lld\n", cputune->period, cputune->quota); + printf("\temulator_period: %llu\n\temulator_quota: %lld\n", + cputune->emulatorPeriod, cputune->emulatorQuota); + if (cputune->emulatorpin.map) { + printf("\temulatorpin: %x\n", *cputune->emulatorpin.map); + } + if (cputune->vcpupin) { + size_t i; + for (i = 0; i < cputune->nvcpupin; i++) { + printf("\tvcpupin (vcpuid: %d): %x\n", + cputune->vcpupin[i].vcpuid, + *cputune->vcpupin[i].cpumask.map); + } + } + return 0; +} static void myFreeFunc(void *opaque) { @@ -506,6 +535,7 @@ int main(int argc, char **argv) int callback14ret = -1; int callback15ret = -1; int callback16ret = -1; + int callback17ret = -1; struct sigaction action_stop; memset(&action_stop, 0, sizeof(action_stop)); @@ -624,6 +654,11 @@ int main(int argc, char **argv) VIR_NETWORK_EVENT_ID_LIFECYCLE, VIR_NETWORK_EVENT_CALLBACK(myNetworkEventCallback), strdup("net callback"), myFreeFunc); + callback17ret = virConnectDomainEventRegisterAny(dconn, + NULL, + VIR_DOMAIN_EVENT_ID_CPUTUNE, + VIR_DOMAIN_EVENT_CALLBACK(myDomainEventCputuneCallback), + strdup("cputune"), myFreeFunc); if ((callback1ret != -1) && (callback2ret != -1) && @@ -639,7 +674,8 @@ int main(int argc, char **argv) (callback13ret != -1) && (callback14ret != -1) && (callback15ret != -1) && - (callback16ret != -1)) { + (callback16ret != -1) && + (callback17ret != -1)) { if (virConnectSetKeepAlive(dconn, 5, 3) < 0) { virErrorPtr err = virGetLastError(); fprintf(stderr, "Failed to start keepalive protocol: %s\n", @@ -671,6 +707,7 @@ int main(int argc, char **argv) virConnectDomainEventDeregisterAny(dconn, callback14ret); virConnectDomainEventDeregisterAny(dconn, callback15ret); virConnectNetworkEventDeregisterAny(dconn, callback16ret); + virConnectDomainEventDeregisterAny(dconn, callback17ret); if (callback8ret != -1) virConnectDomainEventDeregisterAny(dconn, callback8ret); } -- 1.8.5.5 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list