From nobody Sun Feb 8 15:29:27 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1606245705; cv=none; d=zohomail.com; s=zohoarc; b=MVqZWtn6hYG9uQ0B0Fr2bZd2EoVzH5U2A98yPkuK/WBY2A+OZ1I3gow7kmlAEz2A+tHirTOcszpb+wjq3K4oi7jktUr2n99MJV2759p3/rXNkYjObfS3y3akNznYmW7vXgYYDUlPTnt7rqNhXD/yTjMDPetMPcUmp1rCKfZQGgU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1606245705; 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=EPdsAd8X2fTXK0VfGuYCczbfQceF0KqVfqqg9EeE1MU=; b=j1/UM2W/7u96E+iRWY2uCxZXHtKcuJlqACogM7KkZFogyk0AaT2sBJMUEE8Mfb9L1Ng8DTVpzwsMVbUt6CUAwmaCy1FfVwEEZqB3E7d6mzyGOuIDi+4gqHx/f89zI8iwUVwyzJKJ6k22K3An/NILr0FjcP9h86921o+XrE87IKg= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1606245705362342.2650168019735; Tue, 24 Nov 2020 11:21:45 -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-180-4_KaGRqgN3ik-w-FlIHG4Q-1; Tue, 24 Nov 2020 14:21:41 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 828468049D6; Tue, 24 Nov 2020 19:21:36 +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 5CDB51001281; Tue, 24 Nov 2020 19:21:36 +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 E5EA71809CBE; Tue, 24 Nov 2020 19:21:35 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0AOJLYMT004597 for ; Tue, 24 Nov 2020 14:21:34 -0500 Received: by smtp.corp.redhat.com (Postfix) id 3926F2166B2A; Tue, 24 Nov 2020 19:21:34 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast04.extmail.prod.ext.rdu2.redhat.com [10.11.55.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 33E722166B27 for ; Tue, 24 Nov 2020 19:21:34 +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-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1FF42103B80B for ; Tue, 24 Nov 2020 19:21:34 +0000 (UTC) Received: from mail-qk1-f171.google.com (mail-qk1-f171.google.com [209.85.222.171]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-443-H5SaP6C2M6GRS8Jyv4_NQw-1; Tue, 24 Nov 2020 14:21:31 -0500 Received: by mail-qk1-f171.google.com with SMTP id l2so22203153qkf.0 for ; Tue, 24 Nov 2020 11:21:31 -0800 (PST) Received: from rekt.redhat.com ([2804:431:c7c7:d88a:482:7c39:5cca:96f6]) by smtp.gmail.com with ESMTPSA id l79sm88837qke.1.2020.11.24.11.21.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Nov 2020 11:21:30 -0800 (PST) X-MC-Unique: 4_KaGRqgN3ik-w-FlIHG4Q-1 X-MC-Unique: H5SaP6C2M6GRS8Jyv4_NQw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=EPdsAd8X2fTXK0VfGuYCczbfQceF0KqVfqqg9EeE1MU=; b=XqWWlP6EvykWCaL45d7MFWN+pJ2QYaefOU0T1KStsLXgrNeMYnaEc4dFOmqYnifvCJ aR6/0MrG2Qy7ahXAT0SNI9XyS1fNh6DEWc3O1EPBf9ENLebCE19fJFBmEmHfbhR7nJJz RjPAqR7QXMDueWy+fwkdqnVB32+pQcCfwKw4ipbWu202cVqJp6Bf4KczbxXZ/fwmWZcV 7DSvrf1aw3U9HwYGVpusgMlhCn546crSCY6bmijIAdmYCBSjXTSFfJXRiFW5xHD/i52q EbSgdfwGvmqM7aSVQdmRzkSOGpgmJ/eO1inADQVf1KevQDQCjQgJxiiM22O2kSveRAz+ E3FQ== X-Gm-Message-State: AOAM531xKV/CHlOLVY8Ur8VKx+6dtxaZrj2ASks+It1I4ySBSSKnnsQC DyMJC7THUwX6rRB4+WLRzA8SbgXHTmY= X-Google-Smtp-Source: ABdhPJykIKCdKh1YorSYQPpSqF7VNKiFjoQhy/leIl9eVMKLtAdVGDJqWj90PkaTMk0SaukvZX2X9w== X-Received: by 2002:a37:5f84:: with SMTP id t126mr6471665qkb.11.1606245690839; Tue, 24 Nov 2020 11:21:30 -0800 (PST) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH 21/21] domain_conf.c: move idmapEntry checks to post parse Date: Tue, 24 Nov 2020 16:20:35 -0300 Message-Id: <20201124192035.2343063-22-danielhb413@gmail.com> In-Reply-To: <20201124192035.2343063-1-danielhb413@gmail.com> References: <20201124192035.2343063-1-danielhb413@gmail.com> 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 2.78 on 10.11.54.6 X-loop: libvir-list@redhat.com Cc: Daniel Henrique Barboza 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.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Create a new function called virDomainDefIdMapPostParse() and use it to move these checks out of virDomainIdmapDefParseXML(). Signed-off-by: Daniel Henrique Barboza --- src/conf/domain_conf.c | 42 ++++++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index c99c1b60d4..fa21d41c4a 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -6015,6 +6015,29 @@ virDomainDefTunablesPostParse(virDomainDefPtr def) } =20 =20 +static int +virDomainDefIdMapPostParse(virDomainDefPtr def) +{ + if ((def->idmap.uidmap && !def->idmap.gidmap) || + (!def->idmap.uidmap && def->idmap.gidmap)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("uid and gid should be mapped both")); + return -1; + } + + if ((def->idmap.uidmap && def->idmap.uidmap[0].start !=3D 0) || + (def->idmap.gidmap && def->idmap.gidmap[0].start !=3D 0)) { + /* Root user of container hasn't been mapped to any user of host, + * return error. */ + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("You must map the root user of container")); + return -1; + } + + return 0; +} + + static int virDomainDefPostParseVideo(virDomainDefPtr def, void *opaque) @@ -6105,6 +6128,9 @@ virDomainDefPostParseCommon(virDomainDefPtr def, if (virDomainDefTunablesPostParse(def) < 0) return -1; =20 + if (virDomainDefIdMapPostParse(def) < 0) + return -1; + if (def->os.type =3D=3D VIR_DOMAIN_OSTYPE_HVM && !(data->xmlopt->config.features & VIR_DOMAIN_DEF_FEATURE_NO_BOOT_O= RDER) && virDomainDefBootOrderPostParse(def) < 0) @@ -19098,15 +19124,6 @@ virDomainIdmapDefParseXML(xmlXPathContextPtr ctxt, =20 qsort(idmap, num, sizeof(idmap[0]), virDomainIdMapEntrySort); =20 - if (idmap[0].start !=3D 0) { - /* Root user of container hasn't been mapped to any user of host, - * return error. */ - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("You must map the root user of container")); - VIR_FREE(idmap); - return NULL; - } - return idmap; } =20 @@ -22595,13 +22612,6 @@ virDomainDefParseXML(xmlDocPtr xml, } VIR_FREE(nodes); =20 - if ((def->idmap.uidmap && !def->idmap.gidmap) || - (!def->idmap.uidmap && def->idmap.gidmap)) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("uid and gid should be mapped both")); - goto error; - } - if ((n =3D virXPathNodeSet("./sysinfo", ctxt, &nodes)) < 0) goto error; =20 --=20 2.26.2