From nobody Wed May 14 10:13:14 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1527449197817809.4014891002194; Sun, 27 May 2018 12:26:37 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E495BB2DFF; Sun, 27 May 2018 19:26:35 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A79A71691A; Sun, 27 May 2018 19:26:35 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 56A7818033F0; Sun, 27 May 2018 19:26:35 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w4RJQGPM021831 for ; Sun, 27 May 2018 15:26:16 -0400 Received: by smtp.corp.redhat.com (Postfix) id E01735E1CD; Sun, 27 May 2018 19:26:16 +0000 (UTC) Received: from mx1.redhat.com (ext-mx03.extmail.prod.ext.phx2.redhat.com [10.5.110.27]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D6221177D7 for ; Sun, 27 May 2018 19:26:14 +0000 (UTC) Received: from mail-qk0-f181.google.com (mail-qk0-f181.google.com [209.85.220.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 41D07F8055 for ; Sun, 27 May 2018 19:26:03 +0000 (UTC) Received: by mail-qk0-f181.google.com with SMTP id 185-v6so7764187qkk.11 for ; Sun, 27 May 2018 12:26:03 -0700 (PDT) Received: from localhost.localdomain ([186.223.96.215]) by smtp.gmail.com with ESMTPSA id 73-v6sm5901971qkc.96.2018.05.27.12.26.00 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 27 May 2018 12:26:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=VIa/F1UkYGffjVyYTmyFydkq3GPdfp+rEdHWrz2fqns=; b=lxdqy48vJJQeE9kZfeXM3BPQvlQe4DlnY9U7VrGEgkOAlzay7jmXRZUtS5v3n5YD8S KTAaCyh/wu0pFNuABC8P8QZfbdV29EonoNnsOKTVaQptNmYpt1CxUy1qkLVDfgoXeVjM dKNYqnrhkGRSuC+UwXkz9x2cFQTgR1vz2sVS0eOJBvy8it+Uq/GmtzDFI+WS/XX4tEiK fsAPLw1Ihc12wzTDkJ1oCmYf5evhOf/VlU00PEHir6aEAl/eBQg6U9RnsDMJC/zRudm6 F0lrGLdCR7w+xnVCXEl9EwjzDwe0rxPntbkcksloj7vLYyav/vvF6gbOEt7/X7F/ibc9 6cYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=VIa/F1UkYGffjVyYTmyFydkq3GPdfp+rEdHWrz2fqns=; b=TRhEPPET5rWGTLgqJ3Yb93eFHv26RLN4iSTKW9GNtGfxf4/UJSjWBdpXGHz7sZ4xf2 M0UERjg3AEFvEWHFrg2u1r74RO0HRUseiB6naVZvF5BNojhazdG+qu0l+gv6cl2eu/Yv gMzQsnLLlTVZgXQMozXLLmCKkNCILmV29oRYg6NUjGVC6ZC6/dLqoMI2Rx9jP4cBzR7e qShDzS07se3FXVPnIFZ3OF+BP9MNqJUpYNWEe2ocmJZ8uRLPdRFXxFZi2GMqYW+9GQF1 EeQAazzCltdbNNzmaqEeVeYLJ8B/6mEvCEbpu30pI4yjWiwdWLerrvLlJ/vG0XO5dDo7 7t8w== X-Gm-Message-State: ALKqPwfprQrp1Lw4oLeTTf2gSg4U3ZYrNI1NAf12mA+/JRC3XLw+XErO Zu5asTaH+jYYWSVCT4NGOKI2PA== X-Google-Smtp-Source: ADUXVKLOJAFvHHCr5kq5Q7FDY+jCdbfu2jAKkfQR2eGiq1nLlcYv5X3QX8Ifonfj+8/l8+IvC+YNpw== X-Received: by 2002:a37:6f01:: with SMTP id k1-v6mr9118451qkc.140.1527449162231; Sun, 27 May 2018 12:26:02 -0700 (PDT) From: Julio Faracco To: libvir-list@redhat.com Date: Sun, 27 May 2018 16:25:39 -0300 Message-Id: <20180527192539.17922-6-jcfaracco@gmail.com> In-Reply-To: <20180527192539.17922-1-jcfaracco@gmail.com> References: <20180527192539.17922-1-jcfaracco@gmail.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Sun, 27 May 2018 19:26:03 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Sun, 27 May 2018 19:26:03 +0000 (UTC) for IP:'209.85.220.181' DOMAIN:'mail-qk0-f181.google.com' HELO:'mail-qk0-f181.google.com' FROM:'jcfaracco@gmail.com' RCPT:'' X-RedHat-Spam-Score: 1.301 * (DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, NML_ADSP_CUSTOM_MED, RCVD_IN_DNSWL_NONE, SPF_PASS, T_DKIM_INVALID) 209.85.220.181 mail-qk0-f181.google.com 209.85.220.181 mail-qk0-f181.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.27 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 5/5] examples: adding volume events into event-test example. X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Sun, 27 May 2018 19:26:36 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" After including volume events, event-test inside examples needs to be updated with some volume events too. Signed-off-by: Julio Faracco --- examples/object-events/event-test.c | 65 +++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/examples/object-events/event-test.c b/examples/object-events/e= vent-test.c index 8499e0b38e..605490fa68 100644 --- a/examples/object-events/event-test.c +++ b/examples/object-events/event-test.c @@ -366,6 +366,20 @@ storagePoolEventToString(int event) return "unknown"; } =20 +static const char * +storageVolEventToString(int event) +{ + switch ((virStorageVolEventLifecycleType) event) { + case VIR_STORAGE_VOL_EVENT_CREATED: + return "Created"; + case VIR_STORAGE_VOL_EVENT_DELETED: + return "Deleted"; + case VIR_STORAGE_VOL_EVENT_LAST: + break; + } + return "unknown"; +} + static const char * nodeDeviceEventToString(int event) { @@ -730,6 +744,19 @@ myStoragePoolEventRefreshCallback(virConnectPtr conn A= TTRIBUTE_UNUSED, return 0; } =20 +static int +myStorageVolEventCallback(virConnectPtr conn ATTRIBUTE_UNUSED, + virStorageVolPtr vol, + int event, + int detail, + void *opaque ATTRIBUTE_UNUSED) +{ + printf("%s EVENT: Storage volume %s %s %d\n", __func__, + virStorageVolGetName(vol), + storageVolEventToString(event), + detail); + return 0; +} =20 static int myNodeDeviceEventCallback(virConnectPtr conn ATTRIBUTE_UNUSED, @@ -1099,6 +1126,20 @@ struct storagePoolEventData storagePoolEvents[] =3D { STORAGE_POOL_EVENT(VIR_STORAGE_POOL_EVENT_ID_REFRESH, myStoragePoolEve= ntRefreshCallback), }; =20 +struct storageVolEventData { + int event; + int id; + virConnectStorageVolEventGenericCallback cb; + const char *name; +}; + +#define STORAGE_VOL_EVENT(event, callback) \ + {event, -1, VIR_STORAGE_VOL_EVENT_CALLBACK(callback), #event} + +struct storageVolEventData storageVolEvents[] =3D { + STORAGE_VOL_EVENT(VIR_STORAGE_VOL_EVENT_ID_LIFECYCLE, myStorageVolEven= tCallback), +}; + struct nodeDeviceEventData { int event; int id; @@ -1132,6 +1173,7 @@ struct secretEventData secretEvents[] =3D { /* make sure that the events are kept in sync */ verify(ARRAY_CARDINALITY(domainEvents) =3D=3D VIR_DOMAIN_EVENT_ID_LAST); verify(ARRAY_CARDINALITY(storagePoolEvents) =3D=3D VIR_STORAGE_POOL_EVENT_= ID_LAST); +verify(ARRAY_CARDINALITY(storageVolEvents) =3D=3D VIR_STORAGE_VOL_EVENT_ID= _LAST); verify(ARRAY_CARDINALITY(nodeDeviceEvents) =3D=3D VIR_NODE_DEVICE_EVENT_ID= _LAST); verify(ARRAY_CARDINALITY(secretEvents) =3D=3D VIR_SECRET_EVENT_ID_LAST); =20 @@ -1225,6 +1267,22 @@ main(int argc, char **argv) } } =20 + /* register common storage volume callbacks */ + for (i =3D 0; i < ARRAY_CARDINALITY(storageVolEvents); i++) { + struct storageVolEventData *event =3D storageVolEvents + i; + + event->id =3D virConnectStorageVolEventRegisterAny(dconn, NULL, + event->event, + event->cb, + strdup(event->nam= e), + myFreeFunc); + + if (event->id < 0) { + fprintf(stderr, "Failed to register event '%s'\n", event->name= ); + goto cleanup; + } + } + /* register common node device callbacks */ for (i =3D 0; i < ARRAY_CARDINALITY(nodeDeviceEvents); i++) { struct nodeDeviceEventData *event =3D nodeDeviceEvents + i; @@ -1293,6 +1351,13 @@ main(int argc, char **argv) } =20 =20 + printf("Deregistering storage volume event callbacks\n"); + for (i =3D 0; i < ARRAY_CARDINALITY(storageVolEvents); i++) { + if (storageVolEvents[i].id > 0) + virConnectStorageVolEventDeregisterAny(dconn, storageVolEvents= [i].id); + } + + printf("Deregistering node device event callbacks\n"); for (i =3D 0; i < ARRAY_CARDINALITY(nodeDeviceEvents); i++) { if (nodeDeviceEvents[i].id > 0) --=20 2.17.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list