From nobody Mon Feb 9 00: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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1675259465; cv=none; d=zohomail.com; s=zohoarc; b=i7h4NIoEHXKV1ocOpKnvSgZXfyLLpTSmEO17xAmG5OnLCY/tyG0DcIKGTCIG11tfyr/04jzJWodoKl51yNixJuL08lngQZfjNCD48Y0imCugvyfRehRpBV+oSw+POEEYBNziD7K7Eqd0q7wH9oq+HAdma0O8hHbGKhXRzhlSI7o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675259465; h=Content-Type:Content-Transfer-Encoding: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=86CPh47mnHp+fx2dugH6v3azuRlsHRDUxWetrob7zkg=; b=cFK0Mfnsv2mnj/bUKaXbDwnXIU5gDHTFeVxlNsDR1qOZfv/1F0l+PDZxUGE7colx5LUM1WuyEOObfPe5Sb30Z4EZvbSB2723L74tHjdWPkHIGDl2aRRpXP1EV25s1Vj7L4iXYz2C+PlzQZOlQamtD/5n6F7EFCUAG8HSjmtbpV4= 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=pass 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 1675259465141121.64861561717953; Wed, 1 Feb 2023 05:51:05 -0800 (PST) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-185-F3JaswYrOVGpCg9gZXanqw-1; Wed, 01 Feb 2023 08:49:55 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 36E263C1025A; Wed, 1 Feb 2023 13:49:48 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8183D53A0; Wed, 1 Feb 2023 13:49:47 +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 5C47F1946A61; Wed, 1 Feb 2023 13:49:46 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 7093F19465A4 for ; Wed, 1 Feb 2023 13:49:38 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id F39AD43FBA; Wed, 1 Feb 2023 13:49:37 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9AA0753A0 for ; Wed, 1 Feb 2023 13:49:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675259464; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to: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=86CPh47mnHp+fx2dugH6v3azuRlsHRDUxWetrob7zkg=; b=B//1vXljUT/2sCKQnOB0kSIQiB8q/Qi+P0vmtFQVccS3HDqXI+GXATdqGAEuFqXeZu0Ttc nmXTNizoNIVK6ZYW4kkVsjofidCueHnUIURw0hKM9Z4lRIE+4TGLzuciBiEBDwncp3oczR DWQq7XSUO+QuQJN5ItaNe4swIutuwpg= X-MC-Unique: F3JaswYrOVGpCg9gZXanqw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 4/5] conf: Format and parse private data for virDomainNetDef Date: Wed, 1 Feb 2023 14:49:33 +0100 Message-Id: <44e79df9376b5ff5a24e8c4b741701d32105ad4f.1675259355.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 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: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1675259471549100001 Content-Type: text/plain; charset="utf-8"; x-default="true" The virDomainNetDef struct has privateData (which is currently used by QEMU driver to store FDs opened during cmd line building phase and pass them onto cmd line). Soon, we will need to store additional information that needs to survive daemon restart. Let's introduce machinery for parsing and formatting privateData. Signed-off-by: Michal Privoznik --- src/conf/domain_conf.c | 51 ++++++++++++++++++++++++++++++++++++++++++ src/conf/domain_conf.h | 7 ++++++ 2 files changed, 58 insertions(+) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 4920f04bd0..6e33a4472f 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -9254,6 +9254,29 @@ virDomainNetDefParseXMLRequireSource(virDomainNetDef= *def, } =20 =20 +static int +virDomainNetDefParsePrivateData(xmlXPathContextPtr ctxt, + virDomainNetDef *net, + virDomainXMLOption *xmlopt) +{ + xmlNodePtr private_node =3D virXPathNode("./privateData", ctxt); + VIR_XPATH_NODE_AUTORESTORE(ctxt) + + if (!xmlopt || + !xmlopt->privateData.networkParse || + !private_node) + return 0; + + ctxt->node =3D private_node; + + if (xmlopt->privateData.networkParse(ctxt, net) < 0) + return -1; + + return 0; +} + + + static virDomainNetDef * virDomainNetDefParseXML(virDomainXMLOption *xmlopt, xmlNodePtr node, @@ -9672,6 +9695,10 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, if (virNetworkPortOptionsParseXML(ctxt, &def->isolatedPort) < 0) return NULL; =20 + if (flags & VIR_DOMAIN_DEF_PARSE_STATUS && + virDomainNetDefParsePrivateData(ctxt, def, xmlopt) < 0) + return NULL; + return g_steal_pointer(&def); } =20 @@ -23668,6 +23695,27 @@ virDomainNetPortForwardsFormat(virBuffer *buf, } =20 =20 +static int +virDomainNetDefFormatPrivateData(virBuffer *buf, + virDomainNetDef *net, + unsigned int flags, + virDomainXMLOption *xmlopt) +{ + g_auto(virBuffer) childBuf =3D VIR_BUFFER_INIT_CHILD(buf); + + if (!(flags & VIR_DOMAIN_DEF_FORMAT_STATUS) || + !xmlopt || + !xmlopt->privateData.networkFormat) + return 0; + + if (xmlopt->privateData.networkFormat(net, &childBuf) < 0) + return -1; + + virXMLFormatElement(buf, "privateData", NULL, &childBuf); + return 0; +} + + int virDomainNetDefFormat(virBuffer *buf, virDomainNetDef *def, @@ -23965,6 +24013,9 @@ virDomainNetDefFormat(virBuffer *buf, virDomainDeviceInfoFormat(buf, &def->info, flags | VIR_DOMAIN_DEF_FORM= AT_ALLOW_BOOT | VIR_DOMAIN_DEF_FORM= AT_ALLOW_ROM); =20 + if (virDomainNetDefFormatPrivateData(buf, def, flags, xmlopt) < 0) + return -1; + virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "\n"); return 0; diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 631cef03fd..1a80399c9c 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -3357,6 +3357,11 @@ typedef int (*virDomainXMLPrivateDataTPMParseFunc)(x= mlXPathContextPtr ctxt, typedef int (*virDomainXMLPrivateDataTPMFormatFunc)(const virDomainTPMDef = *tpm, virBuffer *buf); =20 +typedef int (*virDomainXMLPrivateDataNetParseFunc)(xmlXPathContextPtr ctxt, + virDomainNetDef *net); +typedef int (*virDomainXMLPrivateDataNetFormatFunc)(const virDomainNetDef = *net, + virBuffer *buf); + struct _virDomainXMLPrivateDataCallbacks { virDomainXMLPrivateDataAllocFunc alloc; virDomainXMLPrivateDataFreeFunc free; @@ -3371,6 +3376,8 @@ struct _virDomainXMLPrivateDataCallbacks { virDomainXMLPrivateDataNewFunc cryptoNew; virDomainXMLPrivateDataNewFunc graphicsNew; virDomainXMLPrivateDataNewFunc networkNew; + virDomainXMLPrivateDataNetParseFunc networkParse; + virDomainXMLPrivateDataNetFormatFunc networkFormat; virDomainXMLPrivateDataNewFunc videoNew; virDomainXMLPrivateDataNewFunc fsNew; virDomainXMLPrivateDataTPMParseFunc tpmParse; --=20 2.39.1