From nobody Tue Feb 10 11:55:57 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=riseup.net ARC-Seal: i=1; a=rsa-sha256; t=1687787771; cv=none; d=zohomail.com; s=zohoarc; b=I7bPo3nqXX5jzrh8lXodTy7sAJM5yo/BenE7fmct3SX08fpK4IgkBav9rmIRJp93SaRLNFUaAmkDhkJxkqJ5oIBfd6x/Sr/emNMy5s8MCYqwDf4pSGr7B9p7uzI3fX/61ZJpBnje9JsJT632s1RbwFHNrmDVPu4zLnebZrOKd+0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1687787771; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=2uKiy0VpT8IX/A3zmS5CnjJ+x7sfBTzCCKGtD8A3Fyw=; b=nHJxztmDA7+3XuI2D4mmMa/oBzjYU1ZdbIBbt6pMmV2Zj3r634Qacb0STv7S1lhDbtmXPF/pWPtidzISi00nYHwFr0Z1Mm4J93Gtbg2ssmTHftmIgYx+x2HTjVSaYeZoHnTA7ECH4JunqOewGuDa9753F2EJXj1v41KwZCrMr0c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1687787771324254.9646083346413; Mon, 26 Jun 2023 06:56:11 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-635--PKGcxhaOK6HKeLWUx2mrw-1; Mon, 26 Jun 2023 09:56:07 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id AFC738C80E4; Mon, 26 Jun 2023 13:55:49 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 99A68207B2C3; Mon, 26 Jun 2023 13:55:49 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 812D01946588; Mon, 26 Jun 2023 13:55:49 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id D08101946594 for ; Mon, 26 Jun 2023 13:55:47 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id C46CA2166B27; Mon, 26 Jun 2023 13:55:47 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast07.extmail.prod.ext.rdu2.redhat.com [10.11.55.23]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BC5302166B26 for ; Mon, 26 Jun 2023 13:55:47 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-inbound-delivery-1.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 83D803C0F699 for ; Mon, 26 Jun 2023 13:55:47 +0000 (UTC) Received: from mx1.riseup.net (mx1.riseup.net [198.252.153.129]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-596-yWDaGiAxPci3fa7_nDnuIA-1; Mon, 26 Jun 2023 09:55:45 -0400 Received: from fews02-sea.riseup.net (fews02-sea-pn.riseup.net [10.0.1.112]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx1.riseup.net (Postfix) with ESMTPS id 4QqTrc0cxQzDqM3 for ; Mon, 26 Jun 2023 13:55:44 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by fews02-sea.riseup.net (Postfix) with ESMTPSA id 4QqTrZ5zs7zFpcn; Mon, 26 Jun 2023 13:55:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687787770; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=2uKiy0VpT8IX/A3zmS5CnjJ+x7sfBTzCCKGtD8A3Fyw=; b=c3ixejvZOgZC0NlVum59kqzmQbmTKzftemMFFAMgF3XSnXEF7czHaaSiMZiS0do6qPQnyI yzobLk1CigwWhpKRTTNDq5wRW84toxxdYV0X6XWHyWk2iscvo3Gw25yYy1rVeCQa8vRbtx 9rQWZBF5SXUnVFTSwnT0wLxiObaGgyQ= X-MC-Unique: -PKGcxhaOK6HKeLWUx2mrw-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: yWDaGiAxPci3fa7_nDnuIA-1 X-Riseup-User-ID: BAA1126F46C36682D00D2B81E5AAFAA04FCF9B53E82F0AAB695D6F6F8488F220 From: K Shiva To: libvir-list@redhat.com Subject: [libvirt PATCH v3 3/8] Added Metadata change events Date: Mon, 26 Jun 2023 19:25:18 +0530 Message-ID: <20230626135523.18404-4-shiva_kr@riseup.net> In-Reply-To: <20230626135523.18404-1-shiva_kr@riseup.net> References: <20230626135523.18404-1-shiva_kr@riseup.net> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: K Shiva Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: riseup.net Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1687787771790100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Added: - Methods to handle metadata change events. Signed-off-by: K Shiva --- po/POTFILES | 1 + src/conf/network_event.c | 115 +++++++++++++++++++++++++++++++++++++++ src/conf/network_event.h | 11 ++++ 3 files changed, 127 insertions(+) diff --git a/po/POTFILES b/po/POTFILES index 5d6ec195b4..933a2e07a4 100644 --- a/po/POTFILES +++ b/po/POTFILES @@ -39,6 +39,7 @@ src/conf/netdev_bandwidth_conf.c src/conf/netdev_vlan_conf.c src/conf/netdev_vport_profile_conf.c src/conf/network_conf.c +src/conf/network_event.c src/conf/networkcommon_conf.c src/conf/node_device_conf.c src/conf/node_device_util.c diff --git a/src/conf/network_event.c b/src/conf/network_event.c index 6f25e43711..0e12cc2687 100644 --- a/src/conf/network_event.c +++ b/src/conf/network_event.c @@ -26,6 +26,9 @@ #include "object_event_private.h" #include "datatypes.h" #include "virlog.h" +#include "virerror.h" + +#define VIR_FROM_THIS VIR_FROM_NETWORK =20 VIR_LOG_INIT("conf.network_event"); =20 @@ -45,10 +48,21 @@ struct _virNetworkEventLifecycle { }; typedef struct _virNetworkEventLifecycle virNetworkEventLifecycle; =20 +struct _virNetworkEventMetadataChange { + virNetworkEvent parent; + + int type; + char *nsuri; +}; +typedef struct _virNetworkEventMetadataChange virNetworkEventMetadataChang= e; + static virClass *virNetworkEventClass; static virClass *virNetworkEventLifecycleClass; +static virClass *virNetworkEventMetadataChangeClass; + static void virNetworkEventDispose(void *obj); static void virNetworkEventLifecycleDispose(void *obj); +static void virNetworkEventMetadataChangeDispose(void *obj); =20 static int virNetworkEventsOnceInit(void) @@ -59,6 +73,9 @@ virNetworkEventsOnceInit(void) if (!VIR_CLASS_NEW(virNetworkEventLifecycle, virNetworkEventClass)) return -1; =20 + if (!VIR_CLASS_NEW(virNetworkEventMetadataChange, virNetworkEventClass= )) + return -1; + return 0; } =20 @@ -104,9 +121,22 @@ virNetworkEventDispatchDefaultFunc(virConnectPtr conn, return; } =20 + case VIR_NETWORK_EVENT_ID_METADATA_CHANGE: + { + virNetworkEventMetadataChange *metadataChangeEvent; + + metadataChangeEvent =3D (virNetworkEventMetadataChange *)event; + ((virConnectNetworkEventMetadataChangeCallback)cb)(conn, net, + metadataChan= geEvent->type, + metadataChan= geEvent->nsuri, + cbopaque); + return; + } + case VIR_NETWORK_EVENT_ID_LAST: break; } + VIR_WARN("Unexpected event ID %d", event->eventID); } =20 @@ -231,3 +261,88 @@ virNetworkEventLifecycleNew(const char *name, =20 return (virObjectEvent *)event; } + + +static void * +virNetworkEventNew(virClass *klass, + int eventID, + const char *name, + const unsigned char *uuid) +{ + virNetworkEvent *event; + char uuidstr[VIR_UUID_STRING_BUFLEN]; + + if (virNetworkEventsInitialize() < 0) + return NULL; + + if (!virClassIsDerivedFrom(klass, virNetworkEventClass)) { + virReportInvalidArg(klass, + _("Class %1$s must derive from virNetworkEvent= "), + virClassName(klass)); + return NULL; + } + + /* We use uuid for matching key. We ignore 'name' because + * Xen sometimes renames guests during migration, thus + * 'uuid' is the only truly reliable key we can use. */ + virUUIDFormat(uuid, uuidstr); + if (!(event =3D virObjectEventNew(klass, + virNetworkEventDispatchDefaultFunc, + eventID, + 0, name, uuid, uuidstr))) + return NULL; + + return (virObjectEvent *)event; +} + + +static void +virNetworkEventMetadataChangeDispose(void *obj) +{ + virNetworkEventMetadataChange *event =3D obj; + VIR_DEBUG("obj=3D%p", event); + + g_free(event->nsuri); +} + + +static virObjectEvent * +virNetworkEventMetadataChangeNew(const char *name, + unsigned char *uuid, + int type, + const char *nsuri) +{ + virNetworkEventMetadataChange *ev; + + if (virNetworkEventsInitialize() < 0) + return NULL; + + if (!(ev =3D virNetworkEventNew(virNetworkEventMetadataChangeClass, + VIR_NETWORK_EVENT_ID_METADATA_CHANGE, + name, uuid))) + return NULL; + + ev->type =3D type; + if (nsuri) + ev->nsuri =3D g_strdup(nsuri); + + return (virObjectEvent *)ev; +} + +virObjectEvent * +virNetworkEventMetadataChangeNewFromObj(virNetworkObj *obj, + int type, + const char *nsuri) +{ + return virNetworkEventMetadataChangeNew(obj->def->name, + obj->def->uuid, type, nsuri); +} + +virObjectEvent * +virNetworkEventMetadataChangeNewFromNet(virNetworkPtr net, + int type, + const char *nsuri) +{ + return virNetworkEventMetadataChangeNew(net->name, net->uuid, + type, nsuri); +} diff --git a/src/conf/network_event.h b/src/conf/network_event.h index 4502bfcaef..7c98a6ac92 100644 --- a/src/conf/network_event.h +++ b/src/conf/network_event.h @@ -23,6 +23,7 @@ =20 #include "internal.h" #include "object_event.h" +#include "virnetworkobj.h" =20 int virNetworkEventStateRegisterID(virConnectPtr conn, @@ -53,3 +54,13 @@ virNetworkEventLifecycleNew(const char *name, const unsigned char *uuid, int type, int detail); + +virObjectEvent * +virNetworkEventMetadataChangeNewFromObj(virNetworkObj *obj, + int type, + const char *nsuri); + +virObjectEvent * +virNetworkEventMetadataChangeNewFromNet(virNetworkPtr net, + int type, + const char *nsuri); --=20 2.41.0