From nobody Mon Feb 9 14:24:10 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=1687930160; cv=none; d=zohomail.com; s=zohoarc; b=BDDwBFMd3fvx8Mb+LTvemWRBdyjszG42J2Dwjlyn/69/BHTL6cC3KoXA20BhUXQhwINm2SVFJy67J7QWUaLSf4IVA+fbm2Fh+0OfM/hpX0XKZZVJtozQAE/s6+F3jglasuRouBVe9/ejLXQ9xkRsEENM4/ln4fqxb0ChKleTZs0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1687930160; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=0JSUoPdCxAnZJVfX+qo/L/6nA29XEPazlEJn6vcwjjk=; b=RAFxIGvbXO418pNqo6EqplxDryt5QqgjdyRjphLJwdnGdolzuW9SNLrMF7xwyg+Br+xlPSy41KJAgyo1XWjo3Y4luZGmCBgjcAfdHXQ3C7t+BodDlzwdweYDyXD6fReqPt7eklS/FoSZJhDPF6HvHGW/XIcYwcRFX25lVGphB+k= 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 1687930160830239.504635361405; Tue, 27 Jun 2023 22:29:20 -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-639-sS2uaBBTPy2HdjgJIU6Xsw-1; Wed, 28 Jun 2023 01:29:17 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1A44092E4D1; Wed, 28 Jun 2023 05:29:16 +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 E76BB111F3B6; Wed, 28 Jun 2023 05:29:13 +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 A23D21946587; Wed, 28 Jun 2023 05:29:13 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id E2FE81946586 for ; Wed, 28 Jun 2023 05:29:10 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id D2E2040D1A4; Wed, 28 Jun 2023 05:29:10 +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 CBC0F400F54 for ; Wed, 28 Jun 2023 05:29:10 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (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 AD7573C025D9 for ; Wed, 28 Jun 2023 05:29:10 +0000 (UTC) Received: from mx0.riseup.net (mx0.riseup.net [198.252.153.6]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-379-snPFBJF_Px-kJjkYNLC2IA-1; Wed, 28 Jun 2023 01:29:08 -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 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "mail.riseup.net", Issuer "R3" (not verified)) by mx0.riseup.net (Postfix) with ESMTPS id 4QrVW70qVlz9s85 for ; Wed, 28 Jun 2023 05:29:07 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by fews02-sea.riseup.net (Postfix) with ESMTPSA id 4QrVVt6HvKzFryt; Wed, 28 Jun 2023 05:28:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687930159; 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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=0JSUoPdCxAnZJVfX+qo/L/6nA29XEPazlEJn6vcwjjk=; b=Q25D0i2EjjaR46I6t17dvbA5SBBl5FzYCFaQ516lyW0qz2Q29zUWAJgtIkb1Uwy5RActl/ oaFGq9+KUj0JlmGGGCuCuC+5gvWPoiRzQlWy/k1sZH8raliRgmZBbci7n8sNVXSQ6kUuLu m+PUi0339CaqGsv3MiJDPCtbYozszE8= X-MC-Unique: sS2uaBBTPy2HdjgJIU6Xsw-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: snPFBJF_Px-kJjkYNLC2IA-1 X-Riseup-User-ID: C7BF42696D6D976BDB48FE858E1FC57BEB0CCD7D82B9B9F08B23713513323B2B From: K Shiva Kiran To: libvir-list@redhat.com Subject: [libvirt PATCH v2] Add and <description> for Network Objects Date: Wed, 28 Jun 2023 10:58:20 +0530 Message-ID: <20230628052820.23231-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.10 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools <libvir-list.redhat.com> List-Unsubscribe: <https://listman.redhat.com/mailman/options/libvir-list>, <mailto:libvir-list-request@redhat.com?subject=unsubscribe> List-Archive: <http://listman.redhat.com/archives/libvir-list/> List-Post: <mailto:libvir-list@redhat.com> List-Help: <mailto:libvir-list-request@redhat.com?subject=help> List-Subscribe: <https://listman.redhat.com/mailman/listinfo/libvir-list>, <mailto:libvir-list-request@redhat.com?subject=subscribe> Cc: K Shiva <shiva_kr@riseup.net> Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" <libvir-list-bounces@redhat.com> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 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: 1687930161375100001 Content-Type: text/plain; charset="utf-8"; x-default="true" From: K Shiva <shiva_kr@riseup.net> This patch adds new elements <title> and <description> to the Network XML. - The <title> attribute holds a short title defined by the user and cannot contain newlines. - The <description> attribute holds any documentation that the user wants to store. - Schema definitions of <title> and <description> have been moved from domaincommon.rng to basictypes.rng for use by network and future objects. Signed-off-by: K Shiva Kiran <shiva_kr@riseup.net> --- This is a v2 of: https://listman.redhat.com/archives/libvir-list/2023-June/240473.html diff to v1: - Corrected commit message. - Adds <title> and <description> XML strings to virBuffer. docs/formatnetwork.rst | 11 +++++++++++ src/conf/network_conf.c | 18 ++++++++++++++++++ src/conf/network_conf.h | 2 ++ src/conf/schemas/basictypes.rng | 15 +++++++++++++++ src/conf/schemas/domaincommon.rng | 15 --------------- src/conf/schemas/network.rng | 10 ++++++++++ 6 files changed, 56 insertions(+), 15 deletions(-) diff --git a/docs/formatnetwork.rst b/docs/formatnetwork.rst index b5dc29db07..ee07f7d505 100644 --- a/docs/formatnetwork.rst +++ b/docs/formatnetwork.rst @@ -30,6 +30,8 @@ The first elements provide basic metadata about the virtu= al network. <network ipv6=3D'yes' trustGuestRxFilters=3D'no'> <name>default</name> <uuid>3e3fce45-4f53-4fa7-bb32-11f34168b82b</uuid> + <title>A short description - title - of the network + Some human readable description .. .. @@ -47,6 +49,7 @@ The first elements provide basic metadata about the virtu= al network. the virtual network. The format must be RFC 4122 compliant, eg ``3e3fce45-4f53-4fa7-bb32-11f34168b82b``. If omitted when defining/crea= ting a new network, a random UUID is generated. :since:`Since 0.3.0` +``metadata`` The ``metadata`` node can be used by applications to store custom metad= ata in the form of XML nodes/trees. Applications must use custom namespaces on= their XML nodes/trees, with only one top-level element per namespace (if the @@ -65,6 +68,14 @@ The first elements provide basic metadata about the virt= ual network. documentation for more details. Note that an explicit setting of this attribute in a portgroup or the individual domain interface will overri= de the setting in the network. +``title`` + The optional element ``title`` provides space for a short description o= f the + network. The title should not contain any newlines. :since:`Since 9.5.0= ` . +``description`` + The content of the ``description`` element provides a human readable + description of the network. This data is not used by libvirt in any + way, it can contain any information the user wants. :since:`Since 9.5.0` + =20 Connectivity ~~~~~~~~~~~~ diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c index 73788b6d87..427635250c 100644 --- a/src/conf/network_conf.c +++ b/src/conf/network_conf.c @@ -281,6 +281,8 @@ virNetworkDefFree(virNetworkDef *def) virNetDevBandwidthFree(def->bandwidth); virNetDevVlanClear(&def->vlan); =20 + g_free(def->title); + g_free(def->description); xmlFreeNode(def->metadata); =20 if (def->namespaceData && def->ns.free) @@ -1599,6 +1601,17 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt, def->uuid_specified =3D true; } =20 + /* Extract short description of network (title) */ + def->title =3D virXPathString("string(./title[1])", ctxt); + if (def->title && strchr(def->title, '\n')) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("Network title can't contain newlines")); + return NULL; + } + + /* Extract documentation if present */ + def->description =3D virXPathString("string(./description[1])", ctxt); + /* check if definitions with no IPv6 gateway addresses is to * allow guest-to-guest communications. */ @@ -2311,6 +2324,11 @@ virNetworkDefFormatBuf(virBuffer *buf, virUUIDFormat(uuid, uuidstr); virBufferAsprintf(buf, "%s\n", uuidstr); =20 + virBufferEscapeString(buf, "%s\n", def->title); + + virBufferEscapeString(buf, "%s\n", + def->description); + if (virXMLFormatMetadata(buf, def->metadata) < 0) return -1; =20 diff --git a/src/conf/network_conf.h b/src/conf/network_conf.h index 2b2e9d15f0..5a1bdb1284 100644 --- a/src/conf/network_conf.h +++ b/src/conf/network_conf.h @@ -249,6 +249,8 @@ struct _virNetworkDef { unsigned char uuid[VIR_UUID_BUFLEN]; bool uuid_specified; char *name; + char *title; + char *description; int connections; /* # of guest interfaces connected to this network = */ =20 char *bridge; /* Name of bridge device */ diff --git a/src/conf/schemas/basictypes.rng b/src/conf/schemas/basictypes.= rng index 2d6f1a2c84..26eb538077 100644 --- a/src/conf/schemas/basictypes.rng +++ b/src/conf/schemas/basictypes.rng @@ -610,6 +610,21 @@ =20 + + + + + + + + + + + + + diff --git a/src/conf/schemas/domaincommon.rng b/src/conf/schemas/domaincom= mon.rng index fcf9e00600..a4360a4036 100644 --- a/src/conf/schemas/domaincommon.rng +++ b/src/conf/schemas/domaincommon.rng @@ -8,21 +8,6 @@ =20 - - - - - - - - - - - - - 0[0-7]{3}|[0-7]{1,3} diff --git a/src/conf/schemas/network.rng b/src/conf/schemas/network.rng index 4317572208..cda174ab4b 100644 --- a/src/conf/schemas/network.rng +++ b/src/conf/schemas/network.rng @@ -37,6 +37,16 @@ =20 + + + + + + + + + + --=20 2.41.0