From nobody Sun Feb 8 10:48:36 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 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=1575469309; cv=none; d=zohomail.com; s=zohoarc; b=ND5HVzAdsO5LFrhkxRRPSEjBVLjuqBL8sgQLicKWwQABfjEAhelfZy/YH9xlMNG9/xNzzFMO6j/HrR1H3LzcWlaG/owR6mGPSiONX3YHdFR5q0c50oESdaB6goqwB0HSaWElXOzZpEO6eUK3ps8Ghry2h1Bi2OkK623xXQv45jE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575469309; 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=gLrXFhAtA3MIHkvjptJzEKzlXnfWPY8sFxFuZgmzSh4=; b=NWGxwCKnVnA+Sykplx/XzO2evpG+Pp+DWX/WHHwZ13jWJDDowpJPEACDqiFcfgH0dY6Lvk+2kT72cAljBKcHLQqnYWhHWcMSG/sF9ZOSimFMERc8WQORPhTpDWH/LsGpacSjMEsY2baJoJIMpXdU2qcxA68A4+MBz+kdy7jW84A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1575469309746418.8525607145772; Wed, 4 Dec 2019 06:21:49 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-69-q2xoeXhMPU2CW8FrISVMzw-1; Wed, 04 Dec 2019 09:21:46 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E0F4F1B18BE4; Wed, 4 Dec 2019 14:21:38 +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 B94D3600CC; Wed, 4 Dec 2019 14:21:38 +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 78BF918089D5; Wed, 4 Dec 2019 14:21:38 +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 xB4ELSr4008137 for ; Wed, 4 Dec 2019 09:21:28 -0500 Received: by smtp.corp.redhat.com (Postfix) id C486B1D1; Wed, 4 Dec 2019 14:21:28 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-112-55.ams2.redhat.com [10.36.112.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0C15669184; Wed, 4 Dec 2019 14:21:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575469308; 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=gLrXFhAtA3MIHkvjptJzEKzlXnfWPY8sFxFuZgmzSh4=; b=d+aTJI5w5SH8oxiRROcqtioDyXvcez2lynAsKbEpL1DXyLW0s/Wmu5rAqGRYxt4yrLxyR+ lXTD19KPda9lHGTBSBeCh7h0Aj5Sg5eTjmjbwgmAIQhl5e/sivYvo1rqf5syi9kp/Wt7Fz 5ZOlz3c6yRJGp+3FQSXRDjjA5hu5BsA= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Wed, 4 Dec 2019 14:20:51 +0000 Message-Id: <20191204142113.2961028-9-berrange@redhat.com> In-Reply-To: <20191204142113.2961028-1-berrange@redhat.com> References: <20191204142113.2961028-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 08/30] conf: pass netprefix in the domain parser config struct 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-MC-Unique: q2xoeXhMPU2CW8FrISVMzw-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Instead of using the virCapsPtr information, pass the driver specific netprefix in the domain parser struct. This eliminates one more use of virCapsPtr from the XML parsing/formatting code. Signed-off-by: Daniel P. Berrang=C3=A9 --- src/conf/domain_conf.c | 24 +++++++----------------- src/conf/domain_conf.h | 3 ++- src/libxl/libxl_domain.c | 1 + 3 files changed, 10 insertions(+), 18 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 6abe15f721..b45ca4a4d0 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -11446,7 +11446,6 @@ static virDomainNetDefPtr virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt, xmlNodePtr node, xmlXPathContextPtr ctxt, - char *prefix, unsigned int flags) { virDomainNetDefPtr def; @@ -11494,6 +11493,7 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlop= t, g_autofree char *vhostuser_type =3D NULL; g_autofree char *trustGuestRxFilters =3D NULL; g_autofree char *vhost_path =3D NULL; + const char *prefix =3D xmlopt ? xmlopt->config.netPrefix : NULL; =20 if (!(def =3D virDomainNetDefNew(xmlopt))) return NULL; @@ -16385,7 +16385,6 @@ virDomainDeviceDefParse(const char *xmlStr, xmlNodePtr node; g_autoptr(xmlXPathContext) ctxt =3D NULL; g_autofree virDomainDeviceDefPtr dev =3D NULL; - char *netprefix; =20 if (!(xml =3D virXMLParseStringCtxt(xmlStr, _("(device_definition)"), = &ctxt))) return NULL; @@ -16428,9 +16427,7 @@ virDomainDeviceDefParse(const char *xmlStr, return NULL; break; case VIR_DOMAIN_DEVICE_NET: - netprefix =3D caps->host.netprefix; - if (!(dev->data.net =3D virDomainNetDefParseXML(xmlopt, node, ctxt, - netprefix, flags))) + if (!(dev->data.net =3D virDomainNetDefParseXML(xmlopt, node, ctxt= , flags))) return NULL; break; case VIR_DOMAIN_DEVICE_INPUT: @@ -19759,7 +19756,6 @@ virDomainDefParseXML(xmlDocPtr xml, bool usb_none =3D false; bool usb_other =3D false; bool usb_master =3D false; - char *netprefix =3D NULL; g_autofree xmlNodePtr *nodes =3D NULL; g_autofree char *tmp =3D NULL; =20 @@ -20872,12 +20868,10 @@ virDomainDefParseXML(xmlDocPtr xml, goto error; if (n && VIR_ALLOC_N(def->nets, n) < 0) goto error; - netprefix =3D caps->host.netprefix; for (i =3D 0; i < n; i++) { virDomainNetDefPtr net =3D virDomainNetDefParseXML(xmlopt, nodes[i], ctxt, - netprefix, flags); if (!net) goto error; @@ -25362,7 +25356,7 @@ virDomainChrSourceReconnectDefFormat(virBufferPtr b= uf, int virDomainNetDefFormat(virBufferPtr buf, virDomainNetDefPtr def, - char *prefix, + virDomainXMLOptionPtr xmlopt, unsigned int flags) { virDomainNetType actualType =3D virDomainNetGetActualType(def); @@ -25372,6 +25366,7 @@ virDomainNetDefFormat(virBufferPtr buf, virDomainHostdevDefPtr hostdef =3D NULL; char macstr[VIR_MAC_STRING_BUFLEN]; g_auto(virBuffer) attrBuf =3D VIR_BUFFER_INITIALIZER; + const char *prefix =3D xmlopt ? xmlopt->config.netPrefix : NULL; =20 /* publicActual is true if we should report the current state in * def->data.network.actual *instead of* the config (*not* in @@ -28294,7 +28289,7 @@ virDomainDefFormatInternal(virDomainDefPtr def, int virDomainDefFormatInternalSetRootName(virDomainDefPtr def, virDomainXMLOptionPtr xmlopt, - virCapsPtr caps, + virCapsPtr caps G_GNUC_UNUSED, virBufferPtr buf, const char *rootname, unsigned int flags) @@ -28304,7 +28299,6 @@ virDomainDefFormatInternalSetRootName(virDomainDefP= tr def, const char *type =3D NULL; int n; size_t i; - char *netprefix =3D NULL; =20 virCheckFlags(VIR_DOMAIN_DEF_FORMAT_COMMON_FLAGS | VIR_DOMAIN_DEF_FORMAT_STATUS | @@ -28660,10 +28654,8 @@ virDomainDefFormatInternalSetRootName(virDomainDef= Ptr def, if (virDomainFSDefFormat(buf, def->fss[n], flags) < 0) goto error; =20 - if (caps) - netprefix =3D caps->host.netprefix; for (n =3D 0; n < def->nnets; n++) - if (virDomainNetDefFormat(buf, def->nets[n], netprefix, flags) < 0) + if (virDomainNetDefFormat(buf, def->nets[n], xmlopt, flags) < 0) goto error; =20 for (n =3D 0; n < def->nsmartcards; n++) @@ -29834,7 +29826,6 @@ virDomainDeviceDefCopy(virDomainDeviceDefPtr src, g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; int flags =3D VIR_DOMAIN_DEF_FORMAT_INACTIVE | VIR_DOMAIN_DEF_FORMAT_S= ECURE; int rc =3D -1; - char *netprefix; g_autofree char *xmlStr =3D NULL; =20 switch ((virDomainDeviceType) src->type) { @@ -29848,8 +29839,7 @@ virDomainDeviceDefCopy(virDomainDeviceDefPtr src, rc =3D virDomainFSDefFormat(&buf, src->data.fs, flags); break; case VIR_DOMAIN_DEVICE_NET: - netprefix =3D caps->host.netprefix; - rc =3D virDomainNetDefFormat(&buf, src->data.net, netprefix, flags= ); + rc =3D virDomainNetDefFormat(&buf, src->data.net, xmlopt, flags); break; case VIR_DOMAIN_DEVICE_INPUT: rc =3D virDomainInputDefFormat(&buf, src->data.input, flags); diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index e1622f2112..037cebae64 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2706,6 +2706,7 @@ struct _virDomainDefParserConfig { unsigned int features; /* virDomainDefFeatures */ unsigned char macPrefix[VIR_MAC_PREFIX_BUFLEN]; virArch defArch; + const char *netPrefix; }; =20 typedef void *(*virDomainXMLPrivateDataAllocFunc)(void *); @@ -3146,7 +3147,7 @@ virDomainDiskBackingStoreFormat(virBufferPtr buf, =20 int virDomainNetDefFormat(virBufferPtr buf, virDomainNetDefPtr def, - char *prefix, + virDomainXMLOptionPtr xmlopt, unsigned int flags); =20 typedef enum { diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c index f202f0fc3e..dfac04bf59 100644 --- a/src/libxl/libxl_domain.c +++ b/src/libxl/libxl_domain.c @@ -437,6 +437,7 @@ libxlDomainDefPostParse(virDomainDefPtr def, =20 virDomainDefParserConfig libxlDomainDefParserConfig =3D { .macPrefix =3D { 0x00, 0x16, 0x3e }, + .netPrefix =3D LIBXL_GENERATED_PREFIX_XEN, .devicesPostParseCallback =3D libxlDomainDeviceDefPostParse, .domainPostParseCallback =3D libxlDomainDefPostParse, .features =3D VIR_DOMAIN_DEF_FEATURE_NET_MODEL_STRING, --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list