From nobody Mon Sep 16 20:06:57 2024 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=1694440487; cv=none; d=zohomail.com; s=zohoarc; b=cqwedR6MA3NgkKhRBKwRR3EeO8pg/K+97+VLRR1FQHY+I+7l4J8WfSs1WJhYF0jMfdJX+kT3kIPKszzzHg73/rOfaQhRu0/5Kf9yfwL//bLhorJCPhDA+rkX9t0JEK+vJWIrtETDC0pBADT+8Hb5w/h96gzD6zHC1qmLidOTB2o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694440487; 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=L/kDh95e5MBzb3BY0xfYsUsPUrcKjk1VJdpOBGh8HQw=; b=QvXLO7dN9IEn+Nl7dxiAcd0ZkFWvKwikQLKPXm2+yh6dQSrTYHiVDAG7BL12OrqS78hcfHrJ+grOHGfXVzofpYYXqihwW956jJjEMxUANzv2nssmmMyFjwiugApBx19fq7YehToA7EdPw/BNCtpTELGbdfpfhLLIRH+YAJGiZl4= 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 1694440487842570.6052639468348; Mon, 11 Sep 2023 06:54:47 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx-ext.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-255-blkUOZg8PT-izlJwP2Y_7A-1; Mon, 11 Sep 2023 09:52:35 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (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 83EA73815F00; Mon, 11 Sep 2023 13:52:32 +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 6E4F421B2413; Mon, 11 Sep 2023 13:52:32 +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 147CA19465B3; Mon, 11 Sep 2023 13:52:32 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 5B7F619465A2 for ; Mon, 11 Sep 2023 13:52:30 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 3A0BD1006B56; Mon, 11 Sep 2023 13:52:30 +0000 (UTC) Received: from fedora.. (unknown [10.43.2.118]) by smtp.corp.redhat.com (Postfix) with ESMTP id D55C610F1BE8 for ; Mon, 11 Sep 2023 13:52:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1694440486; 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=L/kDh95e5MBzb3BY0xfYsUsPUrcKjk1VJdpOBGh8HQw=; b=HvkP+uYeKlgDWW9+Uo7dEUCTLFaM61Jp+8Wk9iz90a9UbvGWGCNwk0HuVJjkGuKrkEK89j ORTQHpt5PG3stZ1m7waAsTx4bRTsobs4RIMSROcpWTcO8YxfNkOGslOMe9MdYBwsDWtSF/ DV9sZM5c1552y9+7wJCyzxj9u5cYKk0= X-MC-Unique: blkUOZg8PT-izlJwP2Y_7A-1 X-Original-To: libvir-list@listman.corp.redhat.com From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCHv1 3/8] conf: move idmap parsing earlier Date: Mon, 11 Sep 2023 15:51:23 +0200 Message-ID: <2e68dabe3777c95215755eed6a0477a6a79f8aed.1694440288.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 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.6 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1694440490114100001 Signed-off-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 98 +++++++++++++++++++++--------------------- 1 file changed, 49 insertions(+), 49 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 2c8727de54..dd67e7f21b 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -8581,6 +8581,55 @@ virDomainNetGenerateMAC(virDomainXMLOption *xmlopt, } =20 =20 +static int virDomainIdMapEntrySort(const void *a, const void *b) +{ + const virDomainIdMapEntry *entrya =3D a; + const virDomainIdMapEntry *entryb =3D b; + + if (entrya->start > entryb->start) + return 1; + else if (entrya->start < entryb->start) + return -1; + else + return 0; +} + +/* Parse the XML definition for user namespace id map. + * + * idmap has the form of + * + * + * + */ +static virDomainIdMapEntry * +virDomainIdmapDefParseXML(xmlXPathContextPtr ctxt, + xmlNodePtr *node, + size_t num) +{ + size_t i; + virDomainIdMapEntry *idmap =3D NULL; + VIR_XPATH_NODE_AUTORESTORE(ctxt) + + idmap =3D g_new0(virDomainIdMapEntry, num); + + for (i =3D 0; i < num; i++) { + ctxt->node =3D node[i]; + if (virXPathUInt("string(./@start)", ctxt, &idmap[i].start) < 0 || + virXPathUInt("string(./@target)", ctxt, &idmap[i].target) < 0 = || + virXPathUInt("string(./@count)", ctxt, &idmap[i].count) < 0) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("invalid idmap start/target/count settings")); + VIR_FREE(idmap); + return NULL; + } + } + + qsort(idmap, num, sizeof(idmap[0]), virDomainIdMapEntrySort); + + return idmap; +} + + static virDomainFSDef * virDomainFSDefParseXML(virDomainXMLOption *xmlopt, xmlNodePtr node, @@ -15711,55 +15760,6 @@ virDomainDefParseBootXML(xmlXPathContextPtr ctxt, return 0; } =20 - -static int virDomainIdMapEntrySort(const void *a, const void *b) -{ - const virDomainIdMapEntry *entrya =3D a; - const virDomainIdMapEntry *entryb =3D b; - - if (entrya->start > entryb->start) - return 1; - else if (entrya->start < entryb->start) - return -1; - else - return 0; -} - -/* Parse the XML definition for user namespace id map. - * - * idmap has the form of - * - * - * - */ -static virDomainIdMapEntry * -virDomainIdmapDefParseXML(xmlXPathContextPtr ctxt, - xmlNodePtr *node, - size_t num) -{ - size_t i; - virDomainIdMapEntry *idmap =3D NULL; - VIR_XPATH_NODE_AUTORESTORE(ctxt) - - idmap =3D g_new0(virDomainIdMapEntry, num); - - for (i =3D 0; i < num; i++) { - ctxt->node =3D node[i]; - if (virXPathUInt("string(./@start)", ctxt, &idmap[i].start) < 0 || - virXPathUInt("string(./@target)", ctxt, &idmap[i].target) < 0 = || - virXPathUInt("string(./@count)", ctxt, &idmap[i].count) < 0) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("invalid idmap start/target/count settings")); - VIR_FREE(idmap); - return NULL; - } - } - - qsort(idmap, num, sizeof(idmap[0]), virDomainIdMapEntrySort); - - return idmap; -} - /* Parse the XML definition for an IOThread ID * * Format is : --=20 2.41.0