From nobody Thu May 2 12:15:44 2024 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1504971307305407.86913772503397; Sat, 9 Sep 2017 08:35:07 -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 BEABDC0587C1; Sat, 9 Sep 2017 15:35:04 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CDBF360F8C; Sat, 9 Sep 2017 15:35:02 +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 5954B4ED30; Sat, 9 Sep 2017 15:34:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v89FA7Vf004077 for ; Sat, 9 Sep 2017 11:10:07 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2C23860A99; Sat, 9 Sep 2017 15:10:07 +0000 (UTC) Received: from mx1.redhat.com (ext-mx01.extmail.prod.ext.phx2.redhat.com [10.5.110.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 25C4C614C2 for ; Sat, 9 Sep 2017 15:10:03 +0000 (UTC) Received: from mail-qt0-f195.google.com (mail-qt0-f195.google.com [209.85.216.195]) (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 95E1C81DE9 for ; Sat, 9 Sep 2017 15:10:02 +0000 (UTC) Received: by mail-qt0-f195.google.com with SMTP id b1so825928qtc.0 for ; Sat, 09 Sep 2017 08:10:02 -0700 (PDT) Received: from localhost.localdomain ([187.107.180.199]) by smtp.googlemail.com with ESMTPSA id s37sm3043062qts.27.2017.09.09.08.09.58 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 09 Sep 2017 08:10:00 -0700 (PDT) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com BEABDC0587C1 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com BEABDC0587C1 Authentication-Results: mx1.redhat.com; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="u9yChfyG" DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 95E1C81DE9 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=jcfaracco@gmail.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 95E1C81DE9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id; bh=a7dj6HUTTlRG1/ACAJ+mzrZfH0fMLGHJXGP72l14bj4=; b=u9yChfyGuN9QlpHuiNlX7vC2Z3WTtF9oKuPthXKYR+4GofvrtoLO+Sn9a9SEFj7MNl ZskrIZAxzNVaGI03JHU1skzsE7mQ+4fBf0d0rYqNJbyvCSO5W3FQ0Zs4guj4sO0C1Hbc MTK8u2lY4nCNkUFBNFdlfPheT5sxnk38OSAX/iFx0EKiAFWV9EkftR/lvrC9rfPtPkq+ xB88ra9Gp7++4bCmlRua7usKAaKCk7lYlbFkmNdlC3NetSuKUnpDahkyClrVVKGrR9Ny LIl0cJ/8S2PuNWzElqDolIuQbBBkeqg2EzX/RMJVaGlixcPfaddSzQTVGEWvTigc4l1C aUmw== 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; bh=a7dj6HUTTlRG1/ACAJ+mzrZfH0fMLGHJXGP72l14bj4=; b=c7/Dxry3yozpcu05CEclAKHSezRECZvQJSlK/aVW5MIxFPmnJLoh4JXljNAu09G/c+ m16s8r20nKrCzdMFcIQZRYhkxCrD6nZwSqVFy72r9mqAKud6C6tlyHrwDhPUPEp6Pxc1 MW+NmwenarGOvVQORG0Q7AvKj/kSu9i+JS0vherGTrqqvolb1fWyqFsICFLYqq+rhg+o RGtfiUxB46NiRXSo18zOMJwoCkeFdDo//ZhibZ/hkqWTy7y3TgWlsz5WsU1UhRkyS/cn FwMqQxYh6WGUuMw1ac71TkAEso2BJ1/aRnQFTcoWC276S01xYw6/D4j8Au/WBuOmqDLG g52g== X-Gm-Message-State: AHPjjUgnpfp54v3Jmu+cqCWdkB3H5bmlctbx0PkVw0hqu1sHvH2icL6c BSOnYKMQ30zSJHfw X-Google-Smtp-Source: AOwi7QBhCgKhwECjW2OazjqUBYzEEWGmvNve2rLt0yGIrtHyUn1YaeSgHzXDno+MvjMETofYGIXfjA== X-Received: by 10.200.4.158 with SMTP id s30mr9231250qtg.311.1504969801485; Sat, 09 Sep 2017 08:10:01 -0700 (PDT) From: Julio Faracco To: libvir-list@redhat.com Date: Sat, 9 Sep 2017 12:09:49 -0300 Message-Id: <1504969789-4811-1-git-send-email-jcfaracco@gmail.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Sat, 09 Sep 2017 15:10:02 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Sat, 09 Sep 2017 15:10:02 +0000 (UTC) for IP:'209.85.216.195' DOMAIN:'mail-qt0-f195.google.com' HELO:'mail-qt0-f195.google.com' FROM:'jcfaracco@gmail.com' RCPT:'' X-RedHat-Spam-Score: 0.37 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, RCVD_IN_SORBS_SPAM, SPF_PASS) 209.85.216.195 mail-qt0-f195.google.com 209.85.216.195 mail-qt0-f195.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.25 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH] storage: Add new events for *PoolBuild() and *PoolDelete(). 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.32]); Sat, 09 Sep 2017 15:35:06 +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" This commit adds new events for two methods and operations: *PoolBuild() and *PoolDelete(). Using the event-test and the commands set below we have the following outputs: $ sudo ./event-test Registering event callbacks myStoragePoolEventCallback EVENT: Storage pool test Defined 0 myStoragePoolEventCallback EVENT: Storage pool test Created 0 myStoragePoolEventCallback EVENT: Storage pool test Started 0 myStoragePoolEventCallback EVENT: Storage pool test Stopped 0 myStoragePoolEventCallback EVENT: Storage pool test Deleted 0 myStoragePoolEventCallback EVENT: Storage pool test Undefined 0 Another terminal: $ sudo virsh pool-define test.xml Pool test defined from test.xml $ sudo virsh pool-build test Pool test built $ sudo virsh pool-start test Pool test started $ sudo virsh pool-destroy test Pool test destroyed $ sudo virsh pool-delete test Pool test deleted $ sudo virsh pool-undefine test Pool test has been undefined This commits can be a solution for RHBZ #1475227. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=3D1475227 Signed-off-by: Julio Faracco --- examples/object-events/event-test.c | 4 ++++ include/libvirt/libvirt-storage.h | 2 ++ src/storage/storage_driver.c | 17 +++++++++++++++++ src/test/test_driver.c | 14 ++++++++++++++ tools/virsh-pool.c | 4 +++- 5 files changed, 40 insertions(+), 1 deletion(-) diff --git a/examples/object-events/event-test.c b/examples/object-events/e= vent-test.c index 78d2008..a144638 100644 --- a/examples/object-events/event-test.c +++ b/examples/object-events/event-test.c @@ -356,6 +356,10 @@ storagePoolEventToString(int event) return "Started"; case VIR_STORAGE_POOL_EVENT_STOPPED: return "Stopped"; + case VIR_STORAGE_POOL_EVENT_CREATED: + return "Created"; + case VIR_STORAGE_POOL_EVENT_DELETED: + return "Deleted"; case VIR_STORAGE_POOL_EVENT_LAST: break; } diff --git a/include/libvirt/libvirt-storage.h b/include/libvirt/libvirt-st= orage.h index 4517f71..736e2e3 100644 --- a/include/libvirt/libvirt-storage.h +++ b/include/libvirt/libvirt-storage.h @@ -465,6 +465,8 @@ typedef enum { VIR_STORAGE_POOL_EVENT_UNDEFINED =3D 1, VIR_STORAGE_POOL_EVENT_STARTED =3D 2, VIR_STORAGE_POOL_EVENT_STOPPED =3D 3, + VIR_STORAGE_POOL_EVENT_CREATED =3D 4, + VIR_STORAGE_POOL_EVENT_DELETED =3D 5, =20 # ifdef VIR_ENUM_SENTINELS VIR_STORAGE_POOL_EVENT_LAST diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c index 7cf5943..5e50415 100644 --- a/src/storage/storage_driver.c +++ b/src/storage/storage_driver.c @@ -959,6 +959,7 @@ storagePoolBuild(virStoragePoolPtr pool, { virStoragePoolObjPtr obj; virStorageBackendPtr backend; + virObjectEventPtr event =3D NULL; int ret =3D -1; =20 if (!(obj =3D virStoragePoolObjFromStoragePool(pool))) @@ -980,9 +981,17 @@ storagePoolBuild(virStoragePoolPtr pool, if (backend->buildPool && backend->buildPool(pool->conn, obj, flags) < 0) goto cleanup; + + event =3D virStoragePoolEventLifecycleNew(obj->def->name, + obj->def->uuid, + VIR_STORAGE_POOL_EVENT_CREATED, + 0); + ret =3D 0; =20 cleanup: + if (event) + virObjectEventStateQueue(driver->storageEventState, event); virStoragePoolObjUnlock(obj); return ret; } @@ -1062,6 +1071,7 @@ storagePoolDelete(virStoragePoolPtr pool, { virStoragePoolObjPtr obj; virStorageBackendPtr backend; + virObjectEventPtr event =3D NULL; char *stateFile =3D NULL; int ret =3D -1; =20 @@ -1106,9 +1116,16 @@ storagePoolDelete(virStoragePoolPtr pool, if (backend->deletePool(pool->conn, obj, flags) < 0) goto cleanup; =20 + event =3D virStoragePoolEventLifecycleNew(obj->def->name, + obj->def->uuid, + VIR_STORAGE_POOL_EVENT_DELETED, + 0); + ret =3D 0; =20 cleanup: + if (event) + virObjectEventStateQueue(driver->storageEventState, event); virStoragePoolObjUnlock(obj); return ret; } diff --git a/src/test/test_driver.c b/src/test/test_driver.c index aa38f54..0a2cde7 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -4562,13 +4562,20 @@ testStoragePoolBuild(virStoragePoolPtr pool, { testDriverPtr privconn =3D pool->conn->privateData; virStoragePoolObjPtr obj; + virObjectEventPtr event =3D NULL; =20 virCheckFlags(0, -1); =20 if (!(obj =3D testStoragePoolObjFindInactiveByName(privconn, pool->nam= e))) return -1; =20 + event =3D virStoragePoolEventLifecycleNew(pool->name, pool->uuid, + VIR_STORAGE_POOL_EVENT_CREATED, + 0); + virStoragePoolObjUnlock(obj); + + testObjectEventQueue(privconn, event); return 0; } =20 @@ -4653,12 +4660,19 @@ testStoragePoolDelete(virStoragePoolPtr pool, { testDriverPtr privconn =3D pool->conn->privateData; virStoragePoolObjPtr obj; + virObjectEventPtr event =3D NULL; =20 virCheckFlags(0, -1); =20 if (!(obj =3D testStoragePoolObjFindInactiveByName(privconn, pool->nam= e))) return -1; =20 + event =3D virStoragePoolEventLifecycleNew(pool->name, pool->uuid, + VIR_STORAGE_POOL_EVENT_DELETED, + 0); + + testObjectEventQueue(privconn, event); + virStoragePoolObjUnlock(obj); return 0; } diff --git a/tools/virsh-pool.c b/tools/virsh-pool.c index ba9281f..558461b 100644 --- a/tools/virsh-pool.c +++ b/tools/virsh-pool.c @@ -1952,7 +1952,9 @@ VIR_ENUM_IMPL(virshPoolEvent, N_("Defined"), N_("Undefined"), N_("Started"), - N_("Stopped")) + N_("Stopped"), + N_("Created"), + N_("Deleted")) =20 static const char * virshPoolEventToString(int event) --=20 2.7.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list