From nobody Sat May 18 00:01:08 2024 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=1607466073; cv=none; d=zohomail.com; s=zohoarc; b=m5rtpEZq7EqPiigHgIMoxbJxVUPk9yPR3UkStiAyP4A2M+PUNo1JMDxydBaB99RNsmOwottMnqcFNij57/s2O0axQ0q/iAoXUCpwOhX+bLfB9Mygiu/pip6u1/U74MRhckpIjukf9DvJDPMq95M+k6GCPhrwdGP096IQPYFsgyA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607466073; 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=hguOumYfPYevvJRjPnRVffoFQdM2brfNLVbeUZqC37c=; b=STQLE6H0hCAY/M7L/DAAKRd+7kOVZ9wushgdTp1PptZKUzBC9SsjVothmDsl6FojVWvwFuIhGA5nihXIg0DtFVnYQlWszzg9t3qNMb/EpYsjaB8Zr9KJo7IzJoQRbjDDFEMxuLMZEuu4bS7hI/hNkIwfFB3Hz7WmAMjbBHRcfSg= 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 1607466073934432.73290860973293; Tue, 8 Dec 2020 14:21:13 -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-526-xN-2vZaLP2q-Zkjff-E6vg-1; Tue, 08 Dec 2020 17:21:09 -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 97296180A087; Tue, 8 Dec 2020 22:21:03 +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 747E150C0B; Tue, 8 Dec 2020 22:21:03 +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 35D671809CA2; Tue, 8 Dec 2020 22:21:03 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0B8MKwBQ017241 for ; Tue, 8 Dec 2020 17:20:58 -0500 Received: by smtp.corp.redhat.com (Postfix) id 8975BA9FBD; Tue, 8 Dec 2020 22:20:58 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast05.extmail.prod.ext.rdu2.redhat.com [10.11.55.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 81DA8A9FDF for ; Tue, 8 Dec 2020 22:20:56 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.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 34347800C00 for ; Tue, 8 Dec 2020 22:20:56 +0000 (UTC) Received: from mail-qt1-f177.google.com (mail-qt1-f177.google.com [209.85.160.177]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-164-jUELdIPJNLiYxkQAoTO8XA-1; Tue, 08 Dec 2020 17:20:52 -0500 Received: by mail-qt1-f177.google.com with SMTP id l7so13142502qtp.8; Tue, 08 Dec 2020 14:20:51 -0800 (PST) Received: from rekt.redhat.com ([2804:431:c7c7:c1a:69c1:2b22:e880:fc49]) by smtp.gmail.com with ESMTPSA id c14sm75057qtg.85.2020.12.08.14.20.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Dec 2020 14:20:50 -0800 (PST) X-MC-Unique: xN-2vZaLP2q-Zkjff-E6vg-1 X-MC-Unique: jUELdIPJNLiYxkQAoTO8XA-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=hguOumYfPYevvJRjPnRVffoFQdM2brfNLVbeUZqC37c=; b=L+KciOz528iObglHAO/aVw8G5yIlz032wu/C5inyLsDz0xNpKmph79Bam5ad4ownKG GsKcIHEjC8jH14ARMhil+5G6iRYagqPCP2jOPKHxIMhtNmnn9e46mIXOJx/rh70HdMWk GPHCkurOFmI11vC2vE9LoKhhbYZTqoUEi+H9wP0zbuIOfynfEXX9CNy9yvmuD0fL43A6 5eFeuOu1gacekAu+uRf5GiF9fwGKpSzHWn0AoV9jt2P/Ru0I3ieuTpQHj+pnqETxl1Zq yGQqKjc6PgGeLpPYZJt/6rLBPvNMgXzf1V4ZslbOzMtrCbJARepDwDIY4CV96NoB22Pv oofQ== X-Gm-Message-State: AOAM530lPuYN7cjecbUSedfUvIUUqAwLB/1TAMZPtHj6nMwYmPzLw7mL 1JJTXc5CPfvXOQxbzMNwiBHnIAFweK0= X-Google-Smtp-Source: ABdhPJytHmp2DBRxO3/wbOseRoufHNmm8AFpz6+CISBsMlUZ8POW+HHufWVvkrVqYFuKTknjU1M4kQ== X-Received: by 2002:ac8:5911:: with SMTP id 17mr254968qty.218.1607466051211; Tue, 08 Dec 2020 14:20:51 -0800 (PST) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH v3 01/14] domain_conf: move boot timeouts check to domain_validate.c Date: Tue, 8 Dec 2020 19:20:17 -0300 Message-Id: <20201208222030.1302229-2-danielhb413@gmail.com> In-Reply-To: <20201208222030.1302229-1-danielhb413@gmail.com> References: <20201208222030.1302229-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.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Cc: Michal Privoznik , 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.79 on 10.5.11.11 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" This patch creates a new function, virDomainDefBootValidate(), to host the validation of boot menu timeout and rebootTimeout outside of parse time. The checks in virDomainDefParseBootXML() were changed to throw VIR_ERR_XML_ERROR in case of parse error of those values. In an attempt to alleviate the amount of code being stacked inside domain_conf.c, let's put this new function in a new domain_validate.c file that will be used to place these validations. Suggested-by: Michal Privoznik Signed-off-by: Daniel Henrique Barboza Reviewed-by: Michal Privoznik --- po/POTFILES.in | 1 + src/conf/domain_conf.c | 20 +++++++-------- src/conf/domain_validate.c | 51 ++++++++++++++++++++++++++++++++++++++ src/conf/domain_validate.h | 27 ++++++++++++++++++++ src/conf/meson.build | 1 + tests/qemuxml2argvtest.c | 3 ++- 6 files changed, 92 insertions(+), 11 deletions(-) create mode 100644 src/conf/domain_validate.c create mode 100644 src/conf/domain_validate.h diff --git a/po/POTFILES.in b/po/POTFILES.in index 9782b2beb4..14636d4b93 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -26,6 +26,7 @@ @SRCDIR@src/conf/domain_capabilities.c @SRCDIR@src/conf/domain_conf.c @SRCDIR@src/conf/domain_event.c +@SRCDIR@src/conf/domain_validate.c @SRCDIR@src/conf/interface_conf.c @SRCDIR@src/conf/netdev_bandwidth_conf.c @SRCDIR@src/conf/netdev_vlan_conf.c diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 66ee658e7b..4a45c76cf1 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -33,6 +33,7 @@ #include "datatypes.h" #include "domain_addr.h" #include "domain_conf.h" +#include "domain_validate.h" #include "snapshot_conf.h" #include "viralloc.h" #include "virxml.h" @@ -7344,6 +7345,9 @@ virDomainDefValidateInternal(const virDomainDef *def, if (virDomainDefCputuneValidate(def) < 0) return -1; =20 + if (virDomainDefBootValidate(def) < 0) + return -1; + if (virDomainNumaDefValidate(def->numa) < 0) return -1; =20 @@ -18867,11 +18871,9 @@ virDomainDefParseBootXML(xmlXPathContextPtr ctxt, =20 tmp =3D virXMLPropString(node, "timeout"); if (tmp && def->os.bootmenu =3D=3D VIR_TRISTATE_BOOL_YES) { - if (virStrToLong_uip(tmp, NULL, 0, &def->os.bm_timeout) < 0 || - def->os.bm_timeout > 65535) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("invalid value for boot menu timeout, " - "must be in range [0,65535]")); + if (virStrToLong_uip(tmp, NULL, 0, &def->os.bm_timeout) < 0) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("invalid value for boot menu timeout")); return -1; } def->os.bm_timeout_set =3D true; @@ -18892,11 +18894,9 @@ virDomainDefParseBootXML(xmlXPathContextPtr ctxt, if (tmp) { /* that was really just for the check if it is there */ =20 - if (virStrToLong_i(tmp, NULL, 0, &def->os.bios.rt_delay) < 0 || - def->os.bios.rt_delay < -1 || def->os.bios.rt_delay > 6553= 5) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("invalid value for rebootTimeout, " - "must be in range [-1,65535]")); + if (virStrToLong_i(tmp, NULL, 0, &def->os.bios.rt_delay) < 0) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("invalid value for rebootTimeout")); return -1; } def->os.bios.rt_set =3D true; diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c new file mode 100644 index 0000000000..e4d947c553 --- /dev/null +++ b/src/conf/domain_validate.c @@ -0,0 +1,51 @@ +/* + * domain_validate.c: domain general validation functions + * + * Copyright IBM Corp, 2020 + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see + * . + */ + +#include + +#include "domain_validate.h" +#include "domain_conf.h" +#include "virlog.h" +#include "virutil.h" + +#define VIR_FROM_THIS VIR_FROM_DOMAIN + +VIR_LOG_INIT("conf.domain_validate"); + +int +virDomainDefBootValidate(const virDomainDef *def) +{ + if (def->os.bm_timeout_set && def->os.bm_timeout > 65535) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("invalid value for boot menu timeout, " + "must be in range [0,65535]")); + return -1; + } + + if (def->os.bios.rt_set && + (def->os.bios.rt_delay < -1 || def->os.bios.rt_delay > 65535)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("invalid value for rebootTimeout, " + "must be in range [-1,65535]")); + return -1; + } + + return 0; +} diff --git a/src/conf/domain_validate.h b/src/conf/domain_validate.h new file mode 100644 index 0000000000..2b558668a9 --- /dev/null +++ b/src/conf/domain_validate.h @@ -0,0 +1,27 @@ +/* + * domain_validate.h: domain general validation functions + * + * Copyright IBM Corp, 2020 + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see + * . + */ + +#pragma once + +#include + +#include "domain_conf.h" + +int virDomainDefBootValidate(const virDomainDef *def); diff --git a/src/conf/meson.build b/src/conf/meson.build index 03b90aa6f6..8ddcc9968d 100644 --- a/src/conf/meson.build +++ b/src/conf/meson.build @@ -14,6 +14,7 @@ domain_conf_sources =3D [ 'domain_capabilities.c', 'domain_conf.c', 'domain_nwfilter.c', + 'domain_validate.c', 'moment_conf.c', 'numa_conf.c', 'snapshot_conf.c', diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 7c9dc0e641..202fc83ccf 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -1006,7 +1006,8 @@ mymain(void) DO_TEST("boot-menu-enable-with-timeout", QEMU_CAPS_SPLASH_TIMEOUT); DO_TEST_PARSE_ERROR("boot-menu-enable-with-timeout", NONE); - DO_TEST_PARSE_ERROR("boot-menu-enable-with-timeout-invalid", NONE); + DO_TEST_PARSE_ERROR("boot-menu-enable-with-timeout-invalid", + QEMU_CAPS_SPLASH_TIMEOUT); DO_TEST("boot-menu-disable", NONE); DO_TEST("boot-menu-disable-drive", NONE); DO_TEST_PARSE_ERROR("boot-dev+order", --=20 2.26.2 From nobody Sat May 18 00:01:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1607466071; cv=none; d=zohomail.com; s=zohoarc; b=K8y5lLzBDdiajVRMkhyIWwRBgXQyepwj8hvNf3mIeov98mh6jpHJxyx3VpMeLptJLgZdVs1JHwHXu+7SABELitIK3sI2pmW0wTV4Rp8lfQko83xJmyI/itFha6d7Mq4fcTv/JwudCN30sT734d9AsVl1URfZVLcVDMbqX1Il9Eo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607466071; 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=cCOtXQ1cdC9bxzVxmojiH88Cs3LFq9kHpkM5ADOn88s=; b=U5BAlol5/29lNiaJJ0N7yY89Lc5yopoxcuDD2g3ZMh8C1tjihTsuGn1Act7Gmji+G+0uJZq3/YVI8FaS8YL8wjn3wKUl+AjzOsWsxM4SyZyxvM5JfoVO7PrI+1QMSEJVBxLWq0J/lEY7DGT1WuEOPoBHIUbgpZqK9NGWXxJle2w= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 1607466071895872.6621317319474; Tue, 8 Dec 2020 14:21:11 -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-351-3RZB9nczMMejvEOoQdrJrw-1; Tue, 08 Dec 2020 17:21:08 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1E85A802B46; Tue, 8 Dec 2020 22:21:01 +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 EE54E5C1BD; Tue, 8 Dec 2020 22:21:00 +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 B8D89180954D; Tue, 8 Dec 2020 22:21:00 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0B8MKwf9017244 for ; Tue, 8 Dec 2020 17:20:59 -0500 Received: by smtp.corp.redhat.com (Postfix) id B9AFEA9FBE; Tue, 8 Dec 2020 22:20:58 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast03.extmail.prod.ext.rdu2.redhat.com [10.11.55.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B407AA9FB9 for ; Tue, 8 Dec 2020 22:20:58 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) (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 A0D62811E91 for ; Tue, 8 Dec 2020 22:20:58 +0000 (UTC) Received: from mail-qv1-f44.google.com (mail-qv1-f44.google.com [209.85.219.44]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-217-Lac6FuEBOP6JiaOvS9BoPg-1; Tue, 08 Dec 2020 17:20:54 -0500 Received: by mail-qv1-f44.google.com with SMTP id n9so20169qvp.5; Tue, 08 Dec 2020 14:20:54 -0800 (PST) Received: from rekt.redhat.com ([2804:431:c7c7:c1a:69c1:2b22:e880:fc49]) by smtp.gmail.com with ESMTPSA id c14sm75057qtg.85.2020.12.08.14.20.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Dec 2020 14:20:52 -0800 (PST) X-MC-Unique: 3RZB9nczMMejvEOoQdrJrw-1 X-MC-Unique: Lac6FuEBOP6JiaOvS9BoPg-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=cCOtXQ1cdC9bxzVxmojiH88Cs3LFq9kHpkM5ADOn88s=; b=a/GLkBQPFkDloKWW1Tw0jkA4JjT8VWJzBKAAmo3BExGQYwglR6wUvzgKfeZxcnsUkL mBkEi7p8xISbTEzuFwNEaykeq6cbIsJzuqxb7viL+tcRfLyhJYt0Q9MSOlWVnLUMdQKy jShzgegXHsDmpOtjqoBFH4fdQV99L/u4SdhKSeLBGT5zG6xLx/kEbmTwLuTp7ZoKo3z8 s484RjUUBnGvrrVPse3Y2cxr/4Ln1/I7w5zXQXD121IqmjeFJ0TplW69+vVNwDfvRnso NgNx0Bkn+6iRnxBFMrtYlNOhnul64WOrFXM3edZZKG2fGOEqu7tR1yYiikbUyB/rzXQ2 U+RA== X-Gm-Message-State: AOAM532E4rD+utZMvxK/WhtPrgDi+9JRHH4q5mXo6HHDyoJjpnn5f+hu Qk8cBMjHK2haurQdYPjLLNF5QKgq5f4= X-Google-Smtp-Source: ABdhPJwG08iRwzij2iPRUuYucv6zDBBhpK9Z8Xn18YgakGCzv/PAJesysyrYUeyIrgdQ7hVmCYansQ== X-Received: by 2002:a0c:8c86:: with SMTP id p6mr253092qvb.32.1607466053313; Tue, 08 Dec 2020 14:20:53 -0800 (PST) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH v3 02/14] domain_conf.c: move primary video check to validate callback Date: Tue, 8 Dec 2020 19:20:18 -0300 Message-Id: <20201208222030.1302229-3-danielhb413@gmail.com> In-Reply-To: <20201208222030.1302229-1-danielhb413@gmail.com> References: <20201208222030.1302229-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.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Cc: Michal Privoznik , 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.79 on 10.5.11.16 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" This check isn't exclusive to XML parsing. Let's move it to virDomainDefVideoValidate() in domain_validate.c We don't have a failure test for this scenario, so a new test called 'video-multiple-primaries' was added to test this failure case. Reviewed-by: Michal Privoznik Signed-off-by: Daniel Henrique Barboza --- src/conf/domain_conf.c | 10 +++--- src/conf/domain_validate.c | 24 ++++++++++++++ src/conf/domain_validate.h | 1 + .../video-multiple-primaries.err | 1 + .../video-multiple-primaries.xml | 32 +++++++++++++++++++ tests/qemuxml2argvtest.c | 5 +++ 6 files changed, 67 insertions(+), 6 deletions(-) create mode 100644 tests/qemuxml2argvdata/video-multiple-primaries.err create mode 100644 tests/qemuxml2argvdata/video-multiple-primaries.xml diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 4a45c76cf1..a8bd54a368 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -7348,6 +7348,9 @@ virDomainDefValidateInternal(const virDomainDef *def, if (virDomainDefBootValidate(def) < 0) return -1; =20 + if (virDomainDefVideoValidate(def) < 0) + return -1; + if (virDomainNumaDefValidate(def->numa) < 0) return -1; =20 @@ -22141,14 +22144,9 @@ virDomainDefParseXML(xmlDocPtr xml, goto error; =20 if (video->primary) { - if (def->nvideos !=3D 0 && def->videos[0]->primary) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("Only one primary video device is support= ed")); - goto error; - } - insertAt =3D 0; } + if (VIR_INSERT_ELEMENT_INPLACE(def->videos, insertAt, def->nvideos, diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c index e4d947c553..eb2ef6c7fb 100644 --- a/src/conf/domain_validate.c +++ b/src/conf/domain_validate.c @@ -49,3 +49,27 @@ virDomainDefBootValidate(const virDomainDef *def) =20 return 0; } + + +int +virDomainDefVideoValidate(const virDomainDef *def) +{ + size_t i; + + if (def->nvideos =3D=3D 0) + return 0; + + /* Any video marked as primary will be put in index 0 by the + * parser. Ensure that we have only one primary set by the user. */ + if (def->videos[0]->primary) { + for (i =3D 1; i < def->nvideos; i++) { + if (def->videos[i]->primary) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Only one primary video device is support= ed")); + return -1; + } + } + } + + return 0; +} diff --git a/src/conf/domain_validate.h b/src/conf/domain_validate.h index 2b558668a9..df4f35c1dd 100644 --- a/src/conf/domain_validate.h +++ b/src/conf/domain_validate.h @@ -25,3 +25,4 @@ #include "domain_conf.h" =20 int virDomainDefBootValidate(const virDomainDef *def); +int virDomainDefVideoValidate(const virDomainDef *def); diff --git a/tests/qemuxml2argvdata/video-multiple-primaries.err b/tests/qe= muxml2argvdata/video-multiple-primaries.err new file mode 100644 index 0000000000..f81b7275e4 --- /dev/null +++ b/tests/qemuxml2argvdata/video-multiple-primaries.err @@ -0,0 +1 @@ +unsupported configuration: Only one primary video device is supported diff --git a/tests/qemuxml2argvdata/video-multiple-primaries.xml b/tests/qe= muxml2argvdata/video-multiple-primaries.xml new file mode 100644 index 0000000000..977227c5ff --- /dev/null +++ b/tests/qemuxml2argvdata/video-multiple-primaries.xml @@ -0,0 +1,32 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 1048576 + 1048576 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu-system-i386 + + + + +
+ + + + + + + diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 202fc83ccf..0e7d8d5ba3 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -2379,6 +2379,11 @@ mymain(void) DO_TEST_CAPS_ARCH_LATEST("default-video-type-riscv64", "riscv64"); DO_TEST_CAPS_ARCH_LATEST("default-video-type-s390x", "s390x"); =20 + DO_TEST_PARSE_ERROR("video-multiple-primaries", + QEMU_CAPS_DEVICE_QXL, + QEMU_CAPS_DEVICE_VGA, + QEMU_CAPS_DEVICE_VIDEO_PRIMARY); + DO_TEST("virtio-rng-default", QEMU_CAPS_DEVICE_VIRTIO_RNG, QEMU_CAPS_OBJECT_RNG_RANDOM); --=20 2.26.2 From nobody Sat May 18 00:01:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1607466076; cv=none; d=zohomail.com; s=zohoarc; b=nSM28J20JFOgJ4Y6aaqgKmKhnCVr9tTr4UN4CxYcmUFk1bnHXQ5j33H8v67QKdxuaHZF2rySiQ9y+b3+FG8aJJrLAu/YiRWov+IpJCHOOkHc9Mm4zfmK0uZNP+HAab53f9GdVVLZm+10ETcztpF5pSvkfCjd5DqH4eDQ2sjdUsw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607466076; 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=892a/Gkqqd+rYjHM6rXBie7/gKh3cNZpzJFLmXc5IAE=; b=YEK6AzUiFu1lSy9acE/sHZDNFoOQ+YVsUyc+czW51K0wq8IaIFM2rXSg+M1mlPIAE00OpSATxn1YG06gIoy1hFQ9j9FJCJJpj/TZyDUOXonEF/NLB8h+ZIjt0vHw6LklbiUcmxzTtLsXGLVKt45KAfEKuIdj6OIlbrfpTLasBvg= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 1607466076866542.4678899130842; Tue, 8 Dec 2020 14:21:16 -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-95-OkoBh6dDM8OlAl30_dDjhQ-1; Tue, 08 Dec 2020 17:21:12 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3FDF4802B49; Tue, 8 Dec 2020 22:21:05 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1A5745C1BD; Tue, 8 Dec 2020 22:21:05 +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 D8F694E590; Tue, 8 Dec 2020 22:21:04 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0B8ML1i2017263 for ; Tue, 8 Dec 2020 17:21:01 -0500 Received: by smtp.corp.redhat.com (Postfix) id 05C46112D42C; Tue, 8 Dec 2020 22:21:01 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast03.extmail.prod.ext.rdu2.redhat.com [10.11.55.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 00076112D422 for ; Tue, 8 Dec 2020 22:20:58 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) (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 38A92811E85 for ; Tue, 8 Dec 2020 22:20:58 +0000 (UTC) Received: from mail-qk1-f193.google.com (mail-qk1-f193.google.com [209.85.222.193]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-486-rTVXA8wCOA294vVHdy2UsA-1; Tue, 08 Dec 2020 17:20:56 -0500 Received: by mail-qk1-f193.google.com with SMTP id 143so191202qke.10 for ; Tue, 08 Dec 2020 14:20:55 -0800 (PST) Received: from rekt.redhat.com ([2804:431:c7c7:c1a:69c1:2b22:e880:fc49]) by smtp.gmail.com with ESMTPSA id c14sm75057qtg.85.2020.12.08.14.20.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Dec 2020 14:20:54 -0800 (PST) X-MC-Unique: OkoBh6dDM8OlAl30_dDjhQ-1 X-MC-Unique: rTVXA8wCOA294vVHdy2UsA-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=892a/Gkqqd+rYjHM6rXBie7/gKh3cNZpzJFLmXc5IAE=; b=EZ4XJJmgQc0LD0iaLGQoDtt5uJ6Tz8EV8+D++GCfHm5yizJjDb++tOppO3Y8bYTHO9 gCy2Kh3xHnah7aMMuHpjqqyYUxofUsNXB/l+Ka41Ef4TJ23Jcsf6DWh/rySrSJthaZkN stbdQ9pOlTsMVN2aXpgj67Y5YJQ/lRw4B6eZAT38TjSk58l/OoWhcmQXA3ugbn6BSrc+ TNBpy7W5E8taZLrub6O/EzPWx/pV13IicRk8svAWRy6QT80iu6wFKio/Ct3bxxPyqxHJ bKqzanXi+JUz+IZfW+SHbeYXqe/BKPMhOZyM7Y3wy4TFQX4dFOqxxRSLtCXTf3HUzeph nYww== X-Gm-Message-State: AOAM5333bi2W+S7nscr95HfsnfLuLLLJQYcaIBRBHkK/jEmmIgr0Rbef XLSG+7qPd7FlY3mlxIitI1ABwaxT/xI= X-Google-Smtp-Source: ABdhPJwd5+7uvQrQtNC80vZE+CE+iC580egcD0LI2PLQgJSVne8+gHlXRKsDSNNdq8tol9tJ5ZqbEA== X-Received: by 2002:a05:620a:624:: with SMTP id 4mr32223917qkv.351.1607466055332; Tue, 08 Dec 2020 14:20:55 -0800 (PST) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH v3 03/14] domain_conf.c: move virDomainVideoDefValidate() to domain_validate.c Date: Tue, 8 Dec 2020 19:20:19 -0300 Message-Id: <20201208222030.1302229-4-danielhb413@gmail.com> In-Reply-To: <20201208222030.1302229-1-danielhb413@gmail.com> References: <20201208222030.1302229-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.3 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.79 on 10.5.11.16 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" We'll add more video validations into the function in the next patch. Let's move it beforehand to domain_validate.c. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Michal Privoznik --- src/conf/domain_conf.c | 57 -------------------------------------- src/conf/domain_validate.c | 57 ++++++++++++++++++++++++++++++++++++++ src/conf/domain_validate.h | 2 ++ 3 files changed, 59 insertions(+), 57 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index a8bd54a368..d80bc8495e 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -6612,63 +6612,6 @@ virDomainHostdevDefValidate(const virDomainHostdevDe= f *hostdev) } =20 =20 -static int -virDomainVideoDefValidate(const virDomainVideoDef *video, - const virDomainDef *def) -{ - size_t i; - - if (video->type =3D=3D VIR_DOMAIN_VIDEO_TYPE_DEFAULT) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("missing video model and cannot determine default= ")); - return -1; - } - - /* it doesn't make sense to pair video device type 'none' with any oth= er - * types, there can be only a single video device in such case - */ - for (i =3D 0; i < def->nvideos; i++) { - if (def->videos[i]->type =3D=3D VIR_DOMAIN_VIDEO_TYPE_NONE && - def->nvideos > 1) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("a 'none' video type must be the only video d= evice " - "defined for the domain")); - return -1; - } - } - - switch (video->backend) { - case VIR_DOMAIN_VIDEO_BACKEND_TYPE_VHOSTUSER: - if (video->type !=3D VIR_DOMAIN_VIDEO_TYPE_VIRTIO) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("'vhostuser' driver is only supported with 'v= irtio' device")); - return -1; - } - break; - case VIR_DOMAIN_VIDEO_BACKEND_TYPE_DEFAULT: - case VIR_DOMAIN_VIDEO_BACKEND_TYPE_QEMU: - if (video->accel && video->accel->rendernode) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("unsupported rendernode accel attribute witho= ut 'vhostuser'")); - return -1; - } - break; - case VIR_DOMAIN_VIDEO_BACKEND_TYPE_LAST: - default: - virReportEnumRangeError(virDomainInputType, video->backend); - return -1; - } - - if (video->res && (video->res->x =3D=3D 0 || video->res->y =3D=3D 0)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("video resolution values must be greater than 0")= ); - return -1; - } - - return 0; -} - - static int virDomainMemoryDefValidate(const virDomainMemoryDef *mem, const virDomainDef *def) diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c index eb2ef6c7fb..c81fd296b9 100644 --- a/src/conf/domain_validate.c +++ b/src/conf/domain_validate.c @@ -73,3 +73,60 @@ virDomainDefVideoValidate(const virDomainDef *def) =20 return 0; } + + +int +virDomainVideoDefValidate(const virDomainVideoDef *video, + const virDomainDef *def) +{ + size_t i; + + if (video->type =3D=3D VIR_DOMAIN_VIDEO_TYPE_DEFAULT) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("missing video model and cannot determine default= ")); + return -1; + } + + /* it doesn't make sense to pair video device type 'none' with any oth= er + * types, there can be only a single video device in such case + */ + for (i =3D 0; i < def->nvideos; i++) { + if (def->videos[i]->type =3D=3D VIR_DOMAIN_VIDEO_TYPE_NONE && + def->nvideos > 1) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("a 'none' video type must be the only video d= evice " + "defined for the domain")); + return -1; + } + } + + switch (video->backend) { + case VIR_DOMAIN_VIDEO_BACKEND_TYPE_VHOSTUSER: + if (video->type !=3D VIR_DOMAIN_VIDEO_TYPE_VIRTIO) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("'vhostuser' driver is only supported with 'v= irtio' device")); + return -1; + } + break; + case VIR_DOMAIN_VIDEO_BACKEND_TYPE_DEFAULT: + case VIR_DOMAIN_VIDEO_BACKEND_TYPE_QEMU: + if (video->accel && video->accel->rendernode) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("unsupported rendernode accel attribute witho= ut 'vhostuser'")); + return -1; + } + break; + case VIR_DOMAIN_VIDEO_BACKEND_TYPE_LAST: + default: + virReportEnumRangeError(virDomainInputType, video->backend); + return -1; + } + + if (video->res && (video->res->x =3D=3D 0 || video->res->y =3D=3D 0)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("video resolution values must be greater than 0")= ); + return -1; + } + + return 0; +} diff --git a/src/conf/domain_validate.h b/src/conf/domain_validate.h index df4f35c1dd..ed170391f8 100644 --- a/src/conf/domain_validate.h +++ b/src/conf/domain_validate.h @@ -26,3 +26,5 @@ =20 int virDomainDefBootValidate(const virDomainDef *def); int virDomainDefVideoValidate(const virDomainDef *def); +int virDomainVideoDefValidate(const virDomainVideoDef *video, + const virDomainDef *def); --=20 2.26.2 From nobody Sat May 18 00:01:08 2024 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=1607466077; cv=none; d=zohomail.com; s=zohoarc; b=ZN0xFIdO5PZeNtH6wSyCq0edFzUQWy8hVxWzUeBU1nRQCUuZZMB9wW5KMUWrd4X0tIy3HeWy8sI/yo9ZojJRpS/vrxPW4r+JmWMA4nneNpa5NqpHOdEGIMwsGGPPv9AB1c90AF882IkEJ40pp4DXjZhdxrMoLbilVv2VTz+78eM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607466077; 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=aMURdiJzsFL8c6xvAoyPv6bYcifcZOxEwvjFkId2cTA=; b=SlgWZUNIyRAQmM+MMSMWzmG4ZGuvDajkwH7012G2/khrY5axJ5VLqfn7PwnJaQF01XUAic5x397hdaPfhMHXI418N0S3cK1rQY6nyhGSDxv03gqyxRlyskeYN7V7asD9qZU1qOpgo3hfu8sbWMHEq1iNp2p3FDRrfMQvQSGQ1dA= 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 1607466077394804.4634985197368; Tue, 8 Dec 2020 14:21:17 -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-562-GCKmuOdONpG5tmt9mcFmAw-1; Tue, 08 Dec 2020 17:21:13 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5B721180A095; Tue, 8 Dec 2020 22:21:08 +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 393C760877; Tue, 8 Dec 2020 22:21:08 +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 063D01809C9F; Tue, 8 Dec 2020 22:21:08 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0B8ML1CH017270 for ; Tue, 8 Dec 2020 17:21:01 -0500 Received: by smtp.corp.redhat.com (Postfix) id 8515E112D41B; Tue, 8 Dec 2020 22:21:01 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast03.extmail.prod.ext.rdu2.redhat.com [10.11.55.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 81204112D411 for ; Tue, 8 Dec 2020 22:21:01 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.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 6E61B811E76 for ; Tue, 8 Dec 2020 22:21:01 +0000 (UTC) Received: from mail-qt1-f177.google.com (mail-qt1-f177.google.com [209.85.160.177]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-446-TCMEBI-1NeeJYu7MOs1XUQ-1; Tue, 08 Dec 2020 17:20:58 -0500 Received: by mail-qt1-f177.google.com with SMTP id k4so13150149qtj.10; Tue, 08 Dec 2020 14:20:58 -0800 (PST) Received: from rekt.redhat.com ([2804:431:c7c7:c1a:69c1:2b22:e880:fc49]) by smtp.gmail.com with ESMTPSA id c14sm75057qtg.85.2020.12.08.14.20.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Dec 2020 14:20:56 -0800 (PST) X-MC-Unique: GCKmuOdONpG5tmt9mcFmAw-1 X-MC-Unique: TCMEBI-1NeeJYu7MOs1XUQ-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=aMURdiJzsFL8c6xvAoyPv6bYcifcZOxEwvjFkId2cTA=; b=nXS36eRrkYYkfBuAwpPwK0k3fs6oqjfpPb4pErVll0ifJErlzpGN7sccMrcsd1TLV4 yuci3MPTlpdIUNcDuK36Cwa+1AQLTSQvuDr63WwX9miJB4/lH83jA1/o2XQqoj0ELMh6 4YILy9qwuORXDiUAqNIfVu8rx83N9gypcmRPwV5/yDwypYk8Z7Vw3NsmeRpOXWpGSlrR WCUD3z5j+poSF1KH+dYaZaEcxGUxZ/9JllaC1y8YuQ4Q/x5ZOO4vgjKFXiOJ/HEa9BzC Qs6EbAnVVm1SKs+DDtwbqVI1KB3zq2Clazs1zZH64c3q3a4Q5kh34O3QRmHofYu69EVI 4Ryg== X-Gm-Message-State: AOAM533TX67Yhw26J5SmFyl6YqPXQfrc8i5oxbEVADJ3g3tFf51eOxbf 03Nke5HnUgc6maq8+NP9lCzdJwMW29I= X-Google-Smtp-Source: ABdhPJwX1W2NY2Uue8ORAg92y9knqJIVsIYyLiPWOxZoEXtek43FDiXWX4/WkM0W1TNEsFM+3eBPrA== X-Received: by 2002:ac8:51d8:: with SMTP id d24mr202906qtn.73.1607466057561; Tue, 08 Dec 2020 14:20:57 -0800 (PST) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH v3 04/14] domain_conf.c: move QXL attributes check to virDomainVideoDefValidate() Date: Tue, 8 Dec 2020 19:20:20 -0300 Message-Id: <20201208222030.1302229-5-danielhb413@gmail.com> In-Reply-To: <20201208222030.1302229-1-danielhb413@gmail.com> References: <20201208222030.1302229-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.3 X-loop: libvir-list@redhat.com Cc: Michal Privoznik , 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.79 on 10.5.11.13 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" These checks are not related to XML parsing and can be moved to the validate callback. Errors were changed from VIR_ERR_XML_ERROR to VIR_ERR_CONFIG_UNSUPPORTED. Reviewed-by: Michal Privoznik Signed-off-by: Daniel Henrique Barboza --- src/conf/domain_conf.c | 15 --------------- src/conf/domain_validate.c | 20 ++++++++++++++++++++ 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index d80bc8495e..db0ca975fe 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -16132,11 +16132,6 @@ virDomainVideoDefParseXML(virDomainXMLOptionPtr xm= lopt, } =20 if (ram) { - if (def->type !=3D VIR_DOMAIN_VIDEO_TYPE_QXL) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("ram attribute only supported for type of qxl= ")); - return NULL; - } if (virStrToLong_uip(ram, NULL, 10, &def->ram) < 0) { virReportError(VIR_ERR_XML_ERROR, _("cannot parse video ram '%s'"), ram); @@ -16153,11 +16148,6 @@ virDomainVideoDefParseXML(virDomainXMLOptionPtr xm= lopt, } =20 if (vram64) { - if (def->type !=3D VIR_DOMAIN_VIDEO_TYPE_QXL) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("vram64 attribute only supported for type of = qxl")); - return NULL; - } if (virStrToLong_uip(vram64, NULL, 10, &def->vram64) < 0) { virReportError(VIR_ERR_XML_ERROR, _("cannot parse video vram64 '%s'"), vram64); @@ -16166,11 +16156,6 @@ virDomainVideoDefParseXML(virDomainXMLOptionPtr xm= lopt, } =20 if (vgamem) { - if (def->type !=3D VIR_DOMAIN_VIDEO_TYPE_QXL) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("vgamem attribute only supported for type of = qxl")); - return NULL; - } if (virStrToLong_uip(vgamem, NULL, 10, &def->vgamem) < 0) { virReportError(VIR_ERR_XML_ERROR, _("cannot parse video vgamem '%s'"), vgamem); diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c index c81fd296b9..234eb72f11 100644 --- a/src/conf/domain_validate.c +++ b/src/conf/domain_validate.c @@ -128,5 +128,25 @@ virDomainVideoDefValidate(const virDomainVideoDef *vid= eo, return -1; } =20 + if (video->type !=3D VIR_DOMAIN_VIDEO_TYPE_QXL) { + if (video->ram !=3D 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("ram attribute only supported for video type = qxl")); + return -1; + } + + if (video->vram64 !=3D 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("vram64 attribute only supported for video ty= pe qxl")); + return -1; + } + + if (video->vgamem !=3D 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("vgamem attribute only supported for video ty= pe qxl")); + return -1; + } + } + return 0; } --=20 2.26.2 From nobody Sat May 18 00:01:08 2024 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=1607466073; cv=none; d=zohomail.com; s=zohoarc; b=BhekEXN8zozr6K+hAtuKRlrEsuyrZ8X/yLwWE3E68NaqXUIGU/AR1/PWzeEoU+QhXr3XrzhP3TCU0UsHQZXikBznPhaQur23F7QdLs3cA0PZMEsBbY0xCTzvD95AIuX3D2hKVgdt7t1VMdRDPO4UPQIRbz8zQTj1BzLKz0zX1/c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607466073; 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=JqUlLotrGrOw13VZ9EeHrVj+QQBWzqirp3m4WK81/eo=; b=hvT6fIn5WaHofoleEC66J56PYHQtHEX0bLX1mVWo9fVRXCDwvluNXjsFkqI0UGK8weoiuKIgJjH7WdBTwGerPq85ffLp7HO72q2ioMszqpnEbDrepJZEaui7BjhFeFg6XS/JQUuKl4dkM+7vzaG2LU6pK5cioDufGxD/p1GiEoI= 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 1607466073650677.1495178427517; Tue, 8 Dec 2020 14:21:13 -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-382-pJmlOpuAN92O981DITqr9w-1; Tue, 08 Dec 2020 17:21:10 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D265E803620; Tue, 8 Dec 2020 22:21:04 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AFADC5C238; Tue, 8 Dec 2020 22:21:04 +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 797134E58F; Tue, 8 Dec 2020 22:21:04 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0B8ML2Cg017275 for ; Tue, 8 Dec 2020 17:21:02 -0500 Received: by smtp.corp.redhat.com (Postfix) id B6E5CA9FB9; Tue, 8 Dec 2020 22:21:02 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast05.extmail.prod.ext.rdu2.redhat.com [10.11.55.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B1117A9FD5 for ; Tue, 8 Dec 2020 22:21:02 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) (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 98B47800969 for ; Tue, 8 Dec 2020 22:21:02 +0000 (UTC) Received: from mail-qt1-f193.google.com (mail-qt1-f193.google.com [209.85.160.193]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-479-fbE6yL0CPlWavGC-OjncSA-1; Tue, 08 Dec 2020 17:21:00 -0500 Received: by mail-qt1-f193.google.com with SMTP id 7so13182403qtp.1 for ; Tue, 08 Dec 2020 14:21:00 -0800 (PST) Received: from rekt.redhat.com ([2804:431:c7c7:c1a:69c1:2b22:e880:fc49]) by smtp.gmail.com with ESMTPSA id c14sm75057qtg.85.2020.12.08.14.20.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Dec 2020 14:20:59 -0800 (PST) X-MC-Unique: pJmlOpuAN92O981DITqr9w-1 X-MC-Unique: fbE6yL0CPlWavGC-OjncSA-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=JqUlLotrGrOw13VZ9EeHrVj+QQBWzqirp3m4WK81/eo=; b=dZWAubSDUE6kjY5hIOTNEli/0fQGFakY5gEL4iHpJ9sBmTKkHhWKvdCsy7znBRAuVC 9lPG3zeqQQ4UcnQGOS6QBcBTNUps+nWi/MoBxkkf3Wp3TAKQK/uFuZJUcKvVhuX8Li/N jES0r1wJZRThyT8ZdO6m1TeqXFYykP/u7o1loSdzWsjukP4pVwpgx/vxyEE/RVGp/jgs c2Tqvb4xMsDXIZrr7QDM6S7gKBV+31GMEwcIBQrfcMSP/9cmw7PhBLcKlniotKo2v4hx k/Urh7HToPaCPFxY6o2a8j+Tk8/egAkc/OlW00i3rpE0hU0XAW1wHNlCx2OucXW2hvyx OfOQ== X-Gm-Message-State: AOAM5333dTmTAlUfusEQs7F/cd6PcBZSZdnowY9ep76pZ7e5hZhL4YnG XkMR4jTjm6c3WP9dZ+ocnq/jDVADpz8= X-Google-Smtp-Source: ABdhPJzS54R+4FGqlULYdzZHKwEYeeF9952/UBHGD/t+mX4FH/W/wRr5u/zODbV7urZBiIosGlBpNQ== X-Received: by 2002:aed:3064:: with SMTP id 91mr196551qte.151.1607466059758; Tue, 08 Dec 2020 14:20:59 -0800 (PST) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH v3 05/14] domain_conf: move virDomainDiskDefValidate() to domain_validate.c Date: Tue, 8 Dec 2020 19:20:21 -0300 Message-Id: <20201208222030.1302229-6-danielhb413@gmail.com> In-Reply-To: <20201208222030.1302229-1-danielhb413@gmail.com> References: <20201208222030.1302229-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.79 on 10.11.54.5 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.79 on 10.5.11.16 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" Next patch will add more validations to the function. Let's move it beforehand to domain_validate.c. virSecurityDeviceLabelDefValidateXML() is still used inside domain_conf.c, so make it public for now until its current caller (virDomainChrSourceDefValidate()) is also moved to domain_validate.c. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Michal Privoznik --- src/conf/domain_conf.c | 152 ------------------------------------ src/conf/domain_validate.c | 153 +++++++++++++++++++++++++++++++++++++ src/conf/domain_validate.h | 6 ++ 3 files changed, 159 insertions(+), 152 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index db0ca975fe..5aeb75ce59 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -6043,158 +6043,6 @@ virDomainDefPostParse(virDomainDefPtr def, } =20 =20 -/** - * virDomainDiskAddressDiskBusCompatibility: - * @bus: disk bus type - * @addressType: disk address type - * - * Check if the specified disk address type @addressType is compatible - * with the specified disk bus type @bus. This function checks - * compatibility with the bus types SATA, SCSI, FDC, and IDE only, - * because only these are handled in common code. - * - * Returns true if compatible or can't be decided in common code, - * false if known to be not compatible. - */ -static bool -virDomainDiskAddressDiskBusCompatibility(virDomainDiskBus bus, - virDomainDeviceAddressType addres= sType) -{ - if (addressType =3D=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) - return true; - - switch (bus) { - case VIR_DOMAIN_DISK_BUS_IDE: - case VIR_DOMAIN_DISK_BUS_FDC: - case VIR_DOMAIN_DISK_BUS_SCSI: - case VIR_DOMAIN_DISK_BUS_SATA: - return addressType =3D=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE; - case VIR_DOMAIN_DISK_BUS_VIRTIO: - case VIR_DOMAIN_DISK_BUS_XEN: - case VIR_DOMAIN_DISK_BUS_USB: - case VIR_DOMAIN_DISK_BUS_UML: - case VIR_DOMAIN_DISK_BUS_SD: - case VIR_DOMAIN_DISK_BUS_LAST: - return true; - } - - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unexpected bus type '%d'"), - bus); - return true; -} - - -static int -virSecurityDeviceLabelDefValidateXML(virSecurityDeviceLabelDefPtr *seclabe= ls, - size_t nseclabels, - virSecurityLabelDefPtr *vmSeclabels, - size_t nvmSeclabels) -{ - virSecurityDeviceLabelDefPtr seclabel; - size_t i; - size_t j; - - for (i =3D 0; i < nseclabels; i++) { - seclabel =3D seclabels[i]; - - /* find the security label that it's being overridden */ - for (j =3D 0; j < nvmSeclabels; j++) { - if (STRNEQ_NULLABLE(vmSeclabels[j]->model, seclabel->model)) - continue; - - if (!vmSeclabels[j]->relabel) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("label overrides require relabeling to be= " - "enabled at the domain level")); - return -1; - } - } - } - - return 0; -} - - -static int -virDomainDiskDefValidate(const virDomainDef *def, - const virDomainDiskDef *disk) -{ - virStorageSourcePtr next; - - /* Validate LUN configuration */ - if (disk->device =3D=3D VIR_DOMAIN_DISK_DEVICE_LUN) { - /* volumes haven't been translated at this point, so accept them */ - if (!(disk->src->type =3D=3D VIR_STORAGE_TYPE_BLOCK || - disk->src->type =3D=3D VIR_STORAGE_TYPE_VOLUME || - (disk->src->type =3D=3D VIR_STORAGE_TYPE_NETWORK && - disk->src->protocol =3D=3D VIR_STORAGE_NET_PROTOCOL_ISCSI))= ) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("disk '%s' improperly configured for a " - "device=3D'lun'"), disk->dst); - return -1; - } - } - - if (disk->src->pr && - disk->device !=3D VIR_DOMAIN_DISK_DEVICE_LUN) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _(" allowed only for lun devices")); - return -1; - } - - /* Reject disks with a bus type that is not compatible with the - * given address type. The function considers only buses that are - * handled in common code. For other bus types it's not possible - * to decide compatibility in common code. - */ - if (!virDomainDiskAddressDiskBusCompatibility(disk->bus, disk->info.ty= pe)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Invalid address type '%s' for the disk '%s' with= the bus type '%s'"), - virDomainDeviceAddressTypeToString(disk->info.type), - disk->dst, - virDomainDiskBusTypeToString(disk->bus)); - return -1; - } - - if (disk->queues && disk->bus !=3D VIR_DOMAIN_DISK_BUS_VIRTIO) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("queues attribute in disk driver element is only " - "supported by virtio-blk")); - return -1; - } - - if (disk->bus !=3D VIR_DOMAIN_DISK_BUS_VIRTIO && - (disk->model =3D=3D VIR_DOMAIN_DISK_MODEL_VIRTIO || - disk->model =3D=3D VIR_DOMAIN_DISK_MODEL_VIRTIO_TRANSITIONAL || - disk->model =3D=3D VIR_DOMAIN_DISK_MODEL_VIRTIO_NON_TRANSITIONAL)= ) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("disk model '%s' not supported for bus '%s'"), - virDomainDiskModelTypeToString(disk->model), - virDomainDiskBusTypeToString(disk->bus)); - return -1; - } - - if (disk->src->type =3D=3D VIR_STORAGE_TYPE_NVME) { - /* NVMe namespaces start from 1 */ - if (disk->src->nvme->namespc =3D=3D 0) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("NVMe namespace can't be zero")); - return -1; - } - } - - for (next =3D disk->src; next; next =3D next->backingStore) { - if (virSecurityDeviceLabelDefValidateXML(next->seclabels, - next->nseclabels, - def->seclabels, - def->nseclabels) < 0) - return -1; - } - - return 0; -} - bool virDomainDefHasUSB(const virDomainDef *def) { diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c index 234eb72f11..da36bef31a 100644 --- a/src/conf/domain_validate.c +++ b/src/conf/domain_validate.c @@ -150,3 +150,156 @@ virDomainVideoDefValidate(const virDomainVideoDef *vi= deo, =20 return 0; } + + +/** + * virDomainDiskAddressDiskBusCompatibility: + * @bus: disk bus type + * @addressType: disk address type + * + * Check if the specified disk address type @addressType is compatible + * with the specified disk bus type @bus. This function checks + * compatibility with the bus types SATA, SCSI, FDC, and IDE only, + * because only these are handled in common code. + * + * Returns true if compatible or can't be decided in common code, + * false if known to be not compatible. + */ +static bool +virDomainDiskAddressDiskBusCompatibility(virDomainDiskBus bus, + virDomainDeviceAddressType addres= sType) +{ + if (addressType =3D=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) + return true; + + switch (bus) { + case VIR_DOMAIN_DISK_BUS_IDE: + case VIR_DOMAIN_DISK_BUS_FDC: + case VIR_DOMAIN_DISK_BUS_SCSI: + case VIR_DOMAIN_DISK_BUS_SATA: + return addressType =3D=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE; + case VIR_DOMAIN_DISK_BUS_VIRTIO: + case VIR_DOMAIN_DISK_BUS_XEN: + case VIR_DOMAIN_DISK_BUS_USB: + case VIR_DOMAIN_DISK_BUS_UML: + case VIR_DOMAIN_DISK_BUS_SD: + case VIR_DOMAIN_DISK_BUS_LAST: + return true; + } + + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unexpected bus type '%d'"), + bus); + return true; +} + + +int +virSecurityDeviceLabelDefValidateXML(virSecurityDeviceLabelDefPtr *seclabe= ls, + size_t nseclabels, + virSecurityLabelDefPtr *vmSeclabels, + size_t nvmSeclabels) +{ + virSecurityDeviceLabelDefPtr seclabel; + size_t i; + size_t j; + + for (i =3D 0; i < nseclabels; i++) { + seclabel =3D seclabels[i]; + + /* find the security label that it's being overridden */ + for (j =3D 0; j < nvmSeclabels; j++) { + if (STRNEQ_NULLABLE(vmSeclabels[j]->model, seclabel->model)) + continue; + + if (!vmSeclabels[j]->relabel) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("label overrides require relabeling to be= " + "enabled at the domain level")); + return -1; + } + } + } + + return 0; +} + + +int +virDomainDiskDefValidate(const virDomainDef *def, + const virDomainDiskDef *disk) +{ + virStorageSourcePtr next; + + /* Validate LUN configuration */ + if (disk->device =3D=3D VIR_DOMAIN_DISK_DEVICE_LUN) { + /* volumes haven't been translated at this point, so accept them */ + if (!(disk->src->type =3D=3D VIR_STORAGE_TYPE_BLOCK || + disk->src->type =3D=3D VIR_STORAGE_TYPE_VOLUME || + (disk->src->type =3D=3D VIR_STORAGE_TYPE_NETWORK && + disk->src->protocol =3D=3D VIR_STORAGE_NET_PROTOCOL_ISCSI))= ) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("disk '%s' improperly configured for a " + "device=3D'lun'"), disk->dst); + return -1; + } + } + + if (disk->src->pr && + disk->device !=3D VIR_DOMAIN_DISK_DEVICE_LUN) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _(" allowed only for lun devices")); + return -1; + } + + /* Reject disks with a bus type that is not compatible with the + * given address type. The function considers only buses that are + * handled in common code. For other bus types it's not possible + * to decide compatibility in common code. + */ + if (!virDomainDiskAddressDiskBusCompatibility(disk->bus, disk->info.ty= pe)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Invalid address type '%s' for the disk '%s' with= the bus type '%s'"), + virDomainDeviceAddressTypeToString(disk->info.type), + disk->dst, + virDomainDiskBusTypeToString(disk->bus)); + return -1; + } + + if (disk->queues && disk->bus !=3D VIR_DOMAIN_DISK_BUS_VIRTIO) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("queues attribute in disk driver element is only " + "supported by virtio-blk")); + return -1; + } + + if (disk->bus !=3D VIR_DOMAIN_DISK_BUS_VIRTIO && + (disk->model =3D=3D VIR_DOMAIN_DISK_MODEL_VIRTIO || + disk->model =3D=3D VIR_DOMAIN_DISK_MODEL_VIRTIO_TRANSITIONAL || + disk->model =3D=3D VIR_DOMAIN_DISK_MODEL_VIRTIO_NON_TRANSITIONAL)= ) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("disk model '%s' not supported for bus '%s'"), + virDomainDiskModelTypeToString(disk->model), + virDomainDiskBusTypeToString(disk->bus)); + return -1; + } + + if (disk->src->type =3D=3D VIR_STORAGE_TYPE_NVME) { + /* NVMe namespaces start from 1 */ + if (disk->src->nvme->namespc =3D=3D 0) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("NVMe namespace can't be zero")); + return -1; + } + } + + for (next =3D disk->src; next; next =3D next->backingStore) { + if (virSecurityDeviceLabelDefValidateXML(next->seclabels, + next->nseclabels, + def->seclabels, + def->nseclabels) < 0) + return -1; + } + + return 0; +} diff --git a/src/conf/domain_validate.h b/src/conf/domain_validate.h index ed170391f8..fe7c752e8c 100644 --- a/src/conf/domain_validate.h +++ b/src/conf/domain_validate.h @@ -28,3 +28,9 @@ int virDomainDefBootValidate(const virDomainDef *def); int virDomainDefVideoValidate(const virDomainDef *def); int virDomainVideoDefValidate(const virDomainVideoDef *video, const virDomainDef *def); +int virSecurityDeviceLabelDefValidateXML(virSecurityDeviceLabelDefPtr *sec= labels, + size_t nseclabels, + virSecurityLabelDefPtr *vmSeclabe= ls, + size_t nvmSeclabels); +int virDomainDiskDefValidate(const virDomainDef *def, + const virDomainDiskDef *disk); --=20 2.26.2 From nobody Sat May 18 00:01:08 2024 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=1607466078; cv=none; d=zohomail.com; s=zohoarc; b=JEFvm0VuqhTlnCeHa//3G37xQ0450J9SwdkXxebD+LVcf2TnFdl1TvSGxYIPEW2vCUibaM9R173a4aEuGr0rSey8dty5RqIyR3+FrtVnRtxIy1A1UXE0HKBJD+rt9GPoW1uijqtcqq8OUKGs7Ypo4uSemIh3U5Nu8BL3/NLxqVQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607466078; 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=XMkwRN0rStJpoZprwQ2tleZ6A0jl5VCWIMcHqAvVj1Y=; b=S6hWQj/nIylPdV985Nym1aL3ZOsO4b7gm/nriyFYdC2+sqUJeeHu3WTdU07pxT6yHj4Wfn8pX+JiziVt2V3K3AeOivYvqEhd9zknwtFrTUoT5lmICa/I33SY7lzVwcE6/SCacbdKHlvbs+f2X9nWAUzYuD55xfKRMYIo4b3nk3o= 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 1607466078631586.287878139724; Tue, 8 Dec 2020 14:21:18 -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-132-Gm1JKoG1MUqbNQNepvx0jA-1; Tue, 08 Dec 2020 17:21:15 -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 2F19B100F345; Tue, 8 Dec 2020 22:21:09 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 08A23100AE2F; Tue, 8 Dec 2020 22:21:09 +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 CBFC05002D; Tue, 8 Dec 2020 22:21:08 +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 0B8ML6T1017295 for ; Tue, 8 Dec 2020 17:21:06 -0500 Received: by smtp.corp.redhat.com (Postfix) id 4E9EB2166B27; Tue, 8 Dec 2020 22:21:06 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast02.extmail.prod.ext.rdu2.redhat.com [10.11.55.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 49BA72166B29 for ; Tue, 8 Dec 2020 22:21:05 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) (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 CE3DD80122E for ; Tue, 8 Dec 2020 22:21:05 +0000 (UTC) Received: from mail-qt1-f176.google.com (mail-qt1-f176.google.com [209.85.160.176]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-381-TZWg5nQpMrCKzVXxGYXzDA-1; Tue, 08 Dec 2020 17:21:02 -0500 Received: by mail-qt1-f176.google.com with SMTP id l7so13142814qtp.8; Tue, 08 Dec 2020 14:21:02 -0800 (PST) Received: from rekt.redhat.com ([2804:431:c7c7:c1a:69c1:2b22:e880:fc49]) by smtp.gmail.com with ESMTPSA id c14sm75057qtg.85.2020.12.08.14.21.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Dec 2020 14:21:01 -0800 (PST) X-MC-Unique: Gm1JKoG1MUqbNQNepvx0jA-1 X-MC-Unique: TZWg5nQpMrCKzVXxGYXzDA-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=XMkwRN0rStJpoZprwQ2tleZ6A0jl5VCWIMcHqAvVj1Y=; b=kV7Dfc/HeoRujKQp+rgy0fLbe1Kh9NsoCR7mjWkrrn473uRNBk6RLqOG1CBDMr74QP 4FXzEWn2WRKRz/7GbFuWio/djwhn8oKCnYqoQY97V917nmOB9ON/PIqEehQ7eeRv9YlA cUJ6kCYp6QpW1gw/tDwXOJCEPAUBYUUt2Zxu104bJCF5YmGvaNejCojU4BrLcZVvhEX9 vRS994k62ngUIJQK6lIyULzNRJk5jNohKuOIFAUh4Hax19vtF2u+uCGSF9ltT/zyKv33 jNc52pjJkSl6zKWurZgO+dCm+XfG6k31K6BCX7N1FyS7R5fOFqhhfCNfM0RjYTPkADTz nKZw== X-Gm-Message-State: AOAM5308+c/wSQjN+F8jM7MFSeic6eX1hnCv9zeXWMeBSGM/G3hnjNh9 lGYt/b/rMI375O/z5LFm2icEmDhvGIw= X-Google-Smtp-Source: ABdhPJwHzf4kp1uGS9tvo+HuA7F6M+Q2FMlsg50kjVD3aEQcftSWIq1BKWLdU5c85ZLerukX6zxE6Q== X-Received: by 2002:ac8:3656:: with SMTP id n22mr250020qtb.242.1607466061752; Tue, 08 Dec 2020 14:21:01 -0800 (PST) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH v3 06/14] domain_conf: move vendor, product and tray checks to domain_validate.c Date: Tue, 8 Dec 2020 19:20:22 -0300 Message-Id: <20201208222030.1302229-7-danielhb413@gmail.com> In-Reply-To: <20201208222030.1302229-1-danielhb413@gmail.com> References: <20201208222030.1302229-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: Michal Privoznik , 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" The 'tray' check isn't a XML parse specific code and can be pushed to the validate callback, in virDomainDiskDefValidate(). 'vendor' and 'product' string sizes are already checked by the domaincommon.rng schema, but can be of use in the validate callback since not all scenarios will go through the XML parsing. Reviewed-by: Michal Privoznik Signed-off-by: Daniel Henrique Barboza --- src/conf/domain_conf.c | 22 ---------------------- src/conf/domain_validate.c | 25 +++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 22 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 5aeb75ce59..220bb8cdcf 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -10222,9 +10222,6 @@ virDomainDiskDefParsePrivateData(xmlXPathContextPtr= ctxt, } =20 =20 -#define VENDOR_LEN 8 -#define PRODUCT_LEN 16 - static virDomainDiskDefPtr virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt, xmlNodePtr node, @@ -10399,12 +10396,6 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xml= opt, if (!(vendor =3D virXMLNodeContentString(cur))) return NULL; =20 - if (strlen(vendor) > VENDOR_LEN) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("disk vendor is more than 8 characters")); - return NULL; - } - if (!virStringIsPrintable(vendor)) { virReportError(VIR_ERR_XML_ERROR, "%s", _("disk vendor is not printable string")); @@ -10415,12 +10406,6 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xml= opt, if (!(product =3D virXMLNodeContentString(cur))) return NULL; =20 - if (strlen(product) > PRODUCT_LEN) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("disk product is more than 16 characters"= )); - return NULL; - } - if (!virStringIsPrintable(product)) { virReportError(VIR_ERR_XML_ERROR, "%s", _("disk product is not printable string")); @@ -10551,13 +10536,6 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xml= opt, _("unknown disk tray status '%s'"), tray); return NULL; } - - if (def->device !=3D VIR_DOMAIN_DISK_DEVICE_FLOPPY && - def->device !=3D VIR_DOMAIN_DISK_DEVICE_CDROM) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("tray is only valid for cdrom and floppy")); - return NULL; - } } =20 if (removable) { diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c index da36bef31a..bc5ca3f668 100644 --- a/src/conf/domain_validate.c +++ b/src/conf/domain_validate.c @@ -225,6 +225,9 @@ virSecurityDeviceLabelDefValidateXML(virSecurityDeviceL= abelDefPtr *seclabels, } =20 =20 +#define VENDOR_LEN 8 +#define PRODUCT_LEN 16 + int virDomainDiskDefValidate(const virDomainDef *def, const virDomainDiskDef *disk) @@ -301,5 +304,27 @@ virDomainDiskDefValidate(const virDomainDef *def, return -1; } =20 + if (disk->tray_status && + disk->device !=3D VIR_DOMAIN_DISK_DEVICE_FLOPPY && + disk->device !=3D VIR_DOMAIN_DISK_DEVICE_CDROM) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("tray is only valid for cdrom and floppy")); + return -1; + } + + if (disk->vendor && strlen(disk->vendor) > VENDOR_LEN) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("disk vendor is more than %d characters"), + VENDOR_LEN); + return -1; + } + + if (disk->product && strlen(disk->product) > PRODUCT_LEN) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("disk product is more than %d characters"), + PRODUCT_LEN); + return -1; + } + return 0; } --=20 2.26.2 From nobody Sat May 18 00:01:08 2024 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=1607466081; cv=none; d=zohomail.com; s=zohoarc; b=hvCaoEykBcyrsjlZJNg8xUa0z+Kye2ut0MIbNr7gHS28bONCd1wuzGW2lrynNStjAxOuoXcsX7fq0Xm8tWHyN223Wvnc3gcNiLvxu25k0KmGsJPWt3W98rq6Rgpb4k0SISfS7eHrAfHBlXGiavQVEHAwyD8KAWtFURk1/xsPvBQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607466081; 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=JCn92J9EOgdu4c0YmIXOgnmBeKYEhHu712YaEGE1qDI=; b=DbWEJVdY7QEyz+cbgzdQPztiGnu9LvJnzywcmmPTtz0F7s80zBDUQBV2LghEV+w6LT1suXDZcUOdbTR6BNIFSQ8ruvBtWSLrKEUGS4CibFDmxrmwX1kEzNZOZfqWbsR3wr1XE64KixykuIAopf4o5udLJdf9ukBiLXlAdjoqTP0= 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 16074660816351019.5581098184148; Tue, 8 Dec 2020 14:21:21 -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-412-KR-iMSruOzOmdSh-zOa3XA-1; Tue, 08 Dec 2020 17:21:18 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7C23D803620; Tue, 8 Dec 2020 22:21:11 +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 586725D9DD; Tue, 8 Dec 2020 22:21:11 +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 2662A1809CA7; Tue, 8 Dec 2020 22:21:11 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0B8ML6R1017301 for ; Tue, 8 Dec 2020 17:21:07 -0500 Received: by smtp.corp.redhat.com (Postfix) id D84F3112D41B; Tue, 8 Dec 2020 22:21:06 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast06.extmail.prod.ext.rdu2.redhat.com [10.11.55.22]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D420D112D411 for ; Tue, 8 Dec 2020 22:21:06 +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 C0E181875040 for ; Tue, 8 Dec 2020 22:21:06 +0000 (UTC) Received: from mail-qk1-f180.google.com (mail-qk1-f180.google.com [209.85.222.180]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-77-fob8Kyf3NI2ad3oxaL9xoA-1; Tue, 08 Dec 2020 17:21:04 -0500 Received: by mail-qk1-f180.google.com with SMTP id z11so212911qkj.7 for ; Tue, 08 Dec 2020 14:21:04 -0800 (PST) Received: from rekt.redhat.com ([2804:431:c7c7:c1a:69c1:2b22:e880:fc49]) by smtp.gmail.com with ESMTPSA id c14sm75057qtg.85.2020.12.08.14.21.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Dec 2020 14:21:03 -0800 (PST) X-MC-Unique: KR-iMSruOzOmdSh-zOa3XA-1 X-MC-Unique: fob8Kyf3NI2ad3oxaL9xoA-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=JCn92J9EOgdu4c0YmIXOgnmBeKYEhHu712YaEGE1qDI=; b=laVMgQ5VoSjjKg90D/7mqEnZnjTq21rDCWVAi5Ixjz0RdLIRYhntlHDcdmr2A2MTn3 eP9QuHmmmNQ28kwdfoqst/IXZ1OMQibFH+S32TCdj2Wcf08fZSqDKOJ1f/3vC2O8ju5m TFq9TJiwLD3Hi7CvNCIvdMNnkesyiJ+EbT/1Rjk9fRHseKnZfW3vrP7wO6GBVtqeTi57 xR2aPQfh2smZsFugjmeVxK+KN97F18AkiaY4WS6D8dyVkiTFQtMY3DmFVs95anFyWkSP XndVLgUp9+EFvWCm1y6xrSuUBk/GtjEPFlvMz/P59TEkI98leIaYNYTcJrKDpvPiqc3q ePeg== X-Gm-Message-State: AOAM531h/IAjq+CvAlYzh3RE5Wffo0UkzaBvT6FWAmfzVH9e+eN3RcmY KobdQhDjMpGlen0CBjW6N1DnwtjsuUo= X-Google-Smtp-Source: ABdhPJygu6Gbzi/X45sQZgkDCK2bkLlQz10rnLhpx1zuZj9Cn48bGd1MDYwfXmK4Rz47RIJQU2N1mw== X-Received: by 2002:ae9:f306:: with SMTP id p6mr32795082qkg.94.1607466063616; Tue, 08 Dec 2020 14:21:03 -0800 (PST) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH v3 07/14] domain_validate.c: rename virSecurityDeviceLabelDefValidateXML() Date: Tue, 8 Dec 2020 19:20:23 -0300 Message-Id: <20201208222030.1302229-8-danielhb413@gmail.com> In-Reply-To: <20201208222030.1302229-1-danielhb413@gmail.com> References: <20201208222030.1302229-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.3 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.79 on 10.5.11.14 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" The function isn't doing XML validation of any sort. Rename it to be compatible with its actual use. While we're at it, change the VIR_ERR_XML_ERROR error being thrown in the function to VIR_ERR_CONFIG_UNSUPPORTED. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Michal Privoznik --- src/conf/domain_conf.c | 8 ++++---- src/conf/domain_validate.c | 18 +++++++++--------- src/conf/domain_validate.h | 8 ++++---- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 220bb8cdcf..6578055119 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -6164,10 +6164,10 @@ virDomainChrSourceDefValidate(const virDomainChrSou= rceDef *src_def, break; } =20 - if (virSecurityDeviceLabelDefValidateXML(src_def->seclabels, - src_def->nseclabels, - def->seclabels, - def->nseclabels) < 0) + if (virSecurityDeviceLabelDefValidate(src_def->seclabels, + src_def->nseclabels, + def->seclabels, + def->nseclabels) < 0) return -1; =20 return 0; diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c index bc5ca3f668..e9427cffa8 100644 --- a/src/conf/domain_validate.c +++ b/src/conf/domain_validate.c @@ -195,10 +195,10 @@ virDomainDiskAddressDiskBusCompatibility(virDomainDis= kBus bus, =20 =20 int -virSecurityDeviceLabelDefValidateXML(virSecurityDeviceLabelDefPtr *seclabe= ls, - size_t nseclabels, - virSecurityLabelDefPtr *vmSeclabels, - size_t nvmSeclabels) +virSecurityDeviceLabelDefValidate(virSecurityDeviceLabelDefPtr *seclabels, + size_t nseclabels, + virSecurityLabelDefPtr *vmSeclabels, + size_t nvmSeclabels) { virSecurityDeviceLabelDefPtr seclabel; size_t i; @@ -213,7 +213,7 @@ virSecurityDeviceLabelDefValidateXML(virSecurityDeviceL= abelDefPtr *seclabels, continue; =20 if (!vmSeclabels[j]->relabel) { - virReportError(VIR_ERR_XML_ERROR, "%s", + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("label overrides require relabeling to be= " "enabled at the domain level")); return -1; @@ -297,10 +297,10 @@ virDomainDiskDefValidate(const virDomainDef *def, } =20 for (next =3D disk->src; next; next =3D next->backingStore) { - if (virSecurityDeviceLabelDefValidateXML(next->seclabels, - next->nseclabels, - def->seclabels, - def->nseclabels) < 0) + if (virSecurityDeviceLabelDefValidate(next->seclabels, + next->nseclabels, + def->seclabels, + def->nseclabels) < 0) return -1; } =20 diff --git a/src/conf/domain_validate.h b/src/conf/domain_validate.h index fe7c752e8c..aef169a4c9 100644 --- a/src/conf/domain_validate.h +++ b/src/conf/domain_validate.h @@ -28,9 +28,9 @@ int virDomainDefBootValidate(const virDomainDef *def); int virDomainDefVideoValidate(const virDomainDef *def); int virDomainVideoDefValidate(const virDomainVideoDef *video, const virDomainDef *def); -int virSecurityDeviceLabelDefValidateXML(virSecurityDeviceLabelDefPtr *sec= labels, - size_t nseclabels, - virSecurityLabelDefPtr *vmSeclabe= ls, - size_t nvmSeclabels); +int virSecurityDeviceLabelDefValidate(virSecurityDeviceLabelDefPtr *seclab= els, + size_t nseclabels, + virSecurityLabelDefPtr *vmSeclabels, + size_t nvmSeclabels); int virDomainDiskDefValidate(const virDomainDef *def, const virDomainDiskDef *disk); --=20 2.26.2 From nobody Sat May 18 00:01:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1607466082; cv=none; d=zohomail.com; s=zohoarc; b=KTiCHalLlMvXEiEO1ijE4p9V9VspGlLOMmfXl2HCqXIGv00l0YrG1ynw1Vpub7RltHEpDAM37Fn+ViU1tZ4vqHgETgO/bYo1fa7QrBmnu2ep+khziViinCFJlbIYhdfqy0ajXpSBftpvcurTot8Tpr2wvFMKPLiwzxhv3RTQJ2A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607466082; 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=Ya04JWbGk0x6k42je/PO8h97Q7HYsfxgqTeojnzQC08=; b=Ijgf5FoUE3HKRXEoaMxeQ+y2mIejbrjYeE9skW/6NdHXq7rvcAjoc3UX0Yft8s+x9B7r/sdgalRK9nM0fmQYrloi03aACD8Aj8z8es1rF9Wff1DIwvZnwwmf42lVL4OfdcTnqBNCablooCTrjV+/yDKPM/R7TRzM7Gr22p/Z0OY= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 1607466082663158.31875586723731; Tue, 8 Dec 2020 14:21:22 -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-243-IfSG7-UzObqMPrUKZfqxSg-1; Tue, 08 Dec 2020 17:21:18 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A7CE6100F351; Tue, 8 Dec 2020 22:21:11 +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 8632460C0F; Tue, 8 Dec 2020 22:21:11 +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 5333C1809CA8; Tue, 8 Dec 2020 22:21:11 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0B8MLADq017311 for ; Tue, 8 Dec 2020 17:21:10 -0500 Received: by smtp.corp.redhat.com (Postfix) id 1D71AA9FBD; Tue, 8 Dec 2020 22:21:10 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast05.extmail.prod.ext.rdu2.redhat.com [10.11.55.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1590DA9FB9 for ; Tue, 8 Dec 2020 22:21:08 +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 656C0800962 for ; Tue, 8 Dec 2020 22:21:08 +0000 (UTC) Received: from mail-qk1-f176.google.com (mail-qk1-f176.google.com [209.85.222.176]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-247-WwHqCU3cOJOSXD89htKIsg-1; Tue, 08 Dec 2020 17:21:06 -0500 Received: by mail-qk1-f176.google.com with SMTP id c7so254368qke.1 for ; Tue, 08 Dec 2020 14:21:06 -0800 (PST) Received: from rekt.redhat.com ([2804:431:c7c7:c1a:69c1:2b22:e880:fc49]) by smtp.gmail.com with ESMTPSA id c14sm75057qtg.85.2020.12.08.14.21.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Dec 2020 14:21:04 -0800 (PST) X-MC-Unique: IfSG7-UzObqMPrUKZfqxSg-1 X-MC-Unique: WwHqCU3cOJOSXD89htKIsg-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=Ya04JWbGk0x6k42je/PO8h97Q7HYsfxgqTeojnzQC08=; b=NJ/ZTc5JuNVIop/MdthTynzTzHEfVQlCWQQUkg4tlSnRODC4lYaIoiIp5Y6lc6fYMg IuZ0lKdUdg3Q1gR1zAxm08VPISblaWOPfvkshNiMT0G1FM2jVkIwqimmcIayV6y3XHuq fEVlpdVYM7wUKz57m6tZR0OcydoNbmq6kwquo/4XFm0RQvonW5C0zm4APSF7JWC1Tbt8 UaBUF4j7IIr0u8gowbh3RvomXjih7/IF/t/LeCTMq5XZHg86QnPGUv1PEWnFm+mqAsyb hymWBcWFi1sHiisXB1R/EzNZVp04PlVN017zTK6RhG/ughBHosxyElBIDyDOA9p/yMHz hDsQ== X-Gm-Message-State: AOAM531r8ECzZ2BStlNNnXF+H9a9HWXdexR5aulI7V7fWgR+uO8bGBvJ 0RApOFGyViCPqAVQ15Gz96jzy93VoW0= X-Google-Smtp-Source: ABdhPJxfnsA+cOwhgBOqQidU7AlZbfN/yeOYdaan4stpWWw1HXloMJ1MN22eYVHs5MMm/VwOjT6VwQ== X-Received: by 2002:a37:6144:: with SMTP id v65mr16157418qkb.222.1607466065454; Tue, 08 Dec 2020 14:21:05 -0800 (PST) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH v3 08/14] domain_conf: move all ChrSource checks to domain_validate.c Date: Tue, 8 Dec 2020 19:20:24 -0300 Message-Id: <20201208222030.1302229-9-danielhb413@gmail.com> In-Reply-To: <20201208222030.1302229-1-danielhb413@gmail.com> References: <20201208222030.1302229-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.79 on 10.11.54.5 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.79 on 10.5.11.12 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" Next patch will move a validation to virDomainSmartcardDefValidate(), but this function can't be moved alone to domain_validate.c without making virDomainChrSourceDefValidate(), from domain_conf.c, public. Given that the idea is to eventually move all validations to domain_validat= e.c anyways, let's move all ChrSource related validations in a single punch. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Michal Privoznik --- src/conf/domain_conf.c | 161 ------------------------------------- src/conf/domain_validate.c | 161 +++++++++++++++++++++++++++++++++++++ src/conf/domain_validate.h | 8 ++ 3 files changed, 169 insertions(+), 161 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 6578055119..a301ab5c74 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -6058,137 +6058,6 @@ virDomainDefHasUSB(const virDomainDef *def) } =20 =20 -#define SERIAL_CHANNEL_NAME_CHARS \ - "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-." - - -static int -virDomainChrSourceDefValidate(const virDomainChrSourceDef *src_def, - const virDomainChrDef *chr_def, - const virDomainDef *def) -{ - switch ((virDomainChrType) src_def->type) { - case VIR_DOMAIN_CHR_TYPE_NULL: - case VIR_DOMAIN_CHR_TYPE_PTY: - case VIR_DOMAIN_CHR_TYPE_VC: - case VIR_DOMAIN_CHR_TYPE_STDIO: - case VIR_DOMAIN_CHR_TYPE_SPICEVMC: - case VIR_DOMAIN_CHR_TYPE_LAST: - break; - - case VIR_DOMAIN_CHR_TYPE_FILE: - case VIR_DOMAIN_CHR_TYPE_DEV: - case VIR_DOMAIN_CHR_TYPE_PIPE: - if (!src_def->data.file.path) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Missing source path attribute for char devic= e")); - return -1; - } - break; - - case VIR_DOMAIN_CHR_TYPE_NMDM: - if (!src_def->data.nmdm.master) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Missing master path attribute for nmdm devic= e")); - return -1; - } - - if (!src_def->data.nmdm.slave) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Missing slave path attribute for nmdm device= ")); - return -1; - } - break; - - case VIR_DOMAIN_CHR_TYPE_TCP: - if (!src_def->data.tcp.host) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Missing source host attribute for char devic= e")); - return -1; - } - - if (!src_def->data.tcp.service) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Missing source service attribute for char de= vice")); - return -1; - } - - if (src_def->data.tcp.listen && src_def->data.tcp.reconnect.enable= d) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("chardev reconnect is possible only for conne= ct mode")); - return -1; - } - break; - - case VIR_DOMAIN_CHR_TYPE_UDP: - if (!src_def->data.udp.connectService) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Missing source service attribute for char de= vice")); - return -1; - } - break; - - case VIR_DOMAIN_CHR_TYPE_UNIX: - /* The source path can be auto generated for certain specific - * types of channels, but in most cases we should report an - * error if the user didn't provide it */ - if (!src_def->data.nix.path && - !(chr_def && - chr_def->deviceType =3D=3D VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNE= L && - (chr_def->targetType =3D=3D VIR_DOMAIN_CHR_CHANNEL_TARGET_TY= PE_XEN || - chr_def->targetType =3D=3D VIR_DOMAIN_CHR_CHANNEL_TARGET_TY= PE_VIRTIO))) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Missing source path attribute for char devic= e")); - return -1; - } - - if (src_def->data.nix.listen && src_def->data.nix.reconnect.enable= d) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("chardev reconnect is possible only for conne= ct mode")); - return -1; - } - break; - - case VIR_DOMAIN_CHR_TYPE_SPICEPORT: - if (!src_def->data.spiceport.channel) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("Missing source channel attribute for char de= vice")); - return -1; - } - if (strspn(src_def->data.spiceport.channel, - SERIAL_CHANNEL_NAME_CHARS) < strlen(src_def->data.spice= port.channel)) { - virReportError(VIR_ERR_INVALID_ARG, "%s", - _("Invalid character in source channel for char= device")); - return -1; - } - break; - } - - if (virSecurityDeviceLabelDefValidate(src_def->seclabels, - src_def->nseclabels, - def->seclabels, - def->nseclabels) < 0) - return -1; - - return 0; -} - - -static int -virDomainRedirdevDefValidate(const virDomainDef *def, - const virDomainRedirdevDef *redirdev) -{ - if (redirdev->bus =3D=3D VIR_DOMAIN_REDIRDEV_BUS_USB && - !virDomainDefHasUSB(def)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("cannot add redirected USB device: " - "USB is disabled for this domain")); - return -1; - } - - return virDomainChrSourceDefValidate(redirdev->source, NULL, def); -} - =20 static int virDomainNetDefValidatePortOptions(const char *macstr, @@ -6379,36 +6248,6 @@ virDomainControllerDefValidate(const virDomainContro= llerDef *controller) } =20 =20 -static int -virDomainChrDefValidate(const virDomainChrDef *chr, - const virDomainDef *def) -{ - return virDomainChrSourceDefValidate(chr->source, chr, def); -} - - -static int -virDomainSmartcardDefValidate(const virDomainSmartcardDef *smartcard, - const virDomainDef *def) -{ - if (smartcard->type =3D=3D VIR_DOMAIN_SMARTCARD_TYPE_PASSTHROUGH) - return virDomainChrSourceDefValidate(smartcard->data.passthru, NUL= L, def); - - return 0; -} - - -static int -virDomainRNGDefValidate(const virDomainRNGDef *rng, - const virDomainDef *def) -{ - if (rng->backend =3D=3D VIR_DOMAIN_RNG_BACKEND_EGD) - return virDomainChrSourceDefValidate(rng->source.chardev, NULL, de= f); - - return 0; -} - - static int virDomainHostdevDefValidate(const virDomainHostdevDef *hostdev) { diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c index e9427cffa8..882fbdac57 100644 --- a/src/conf/domain_validate.c +++ b/src/conf/domain_validate.c @@ -328,3 +328,164 @@ virDomainDiskDefValidate(const virDomainDef *def, =20 return 0; } + + +#define SERIAL_CHANNEL_NAME_CHARS \ + "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-." + +static int +virDomainChrSourceDefValidate(const virDomainChrSourceDef *src_def, + const virDomainChrDef *chr_def, + const virDomainDef *def) +{ + switch ((virDomainChrType) src_def->type) { + case VIR_DOMAIN_CHR_TYPE_NULL: + case VIR_DOMAIN_CHR_TYPE_PTY: + case VIR_DOMAIN_CHR_TYPE_VC: + case VIR_DOMAIN_CHR_TYPE_STDIO: + case VIR_DOMAIN_CHR_TYPE_SPICEVMC: + case VIR_DOMAIN_CHR_TYPE_LAST: + break; + + case VIR_DOMAIN_CHR_TYPE_FILE: + case VIR_DOMAIN_CHR_TYPE_DEV: + case VIR_DOMAIN_CHR_TYPE_PIPE: + if (!src_def->data.file.path) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Missing source path attribute for char devic= e")); + return -1; + } + break; + + case VIR_DOMAIN_CHR_TYPE_NMDM: + if (!src_def->data.nmdm.master) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Missing master path attribute for nmdm devic= e")); + return -1; + } + + if (!src_def->data.nmdm.slave) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Missing slave path attribute for nmdm device= ")); + return -1; + } + break; + + case VIR_DOMAIN_CHR_TYPE_TCP: + if (!src_def->data.tcp.host) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Missing source host attribute for char devic= e")); + return -1; + } + + if (!src_def->data.tcp.service) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Missing source service attribute for char de= vice")); + return -1; + } + + if (src_def->data.tcp.listen && src_def->data.tcp.reconnect.enable= d) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("chardev reconnect is possible only for conne= ct mode")); + return -1; + } + break; + + case VIR_DOMAIN_CHR_TYPE_UDP: + if (!src_def->data.udp.connectService) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Missing source service attribute for char de= vice")); + return -1; + } + break; + + case VIR_DOMAIN_CHR_TYPE_UNIX: + /* The source path can be auto generated for certain specific + * types of channels, but in most cases we should report an + * error if the user didn't provide it */ + if (!src_def->data.nix.path && + !(chr_def && + chr_def->deviceType =3D=3D VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNE= L && + (chr_def->targetType =3D=3D VIR_DOMAIN_CHR_CHANNEL_TARGET_TY= PE_XEN || + chr_def->targetType =3D=3D VIR_DOMAIN_CHR_CHANNEL_TARGET_TY= PE_VIRTIO))) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Missing source path attribute for char devic= e")); + return -1; + } + + if (src_def->data.nix.listen && src_def->data.nix.reconnect.enable= d) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("chardev reconnect is possible only for conne= ct mode")); + return -1; + } + break; + + case VIR_DOMAIN_CHR_TYPE_SPICEPORT: + if (!src_def->data.spiceport.channel) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("Missing source channel attribute for char de= vice")); + return -1; + } + if (strspn(src_def->data.spiceport.channel, + SERIAL_CHANNEL_NAME_CHARS) < strlen(src_def->data.spice= port.channel)) { + virReportError(VIR_ERR_INVALID_ARG, "%s", + _("Invalid character in source channel for char= device")); + return -1; + } + break; + } + + if (virSecurityDeviceLabelDefValidate(src_def->seclabels, + src_def->nseclabels, + def->seclabels, + def->nseclabels) < 0) + return -1; + + return 0; +} + + +int +virDomainRedirdevDefValidate(const virDomainDef *def, + const virDomainRedirdevDef *redirdev) +{ + if (redirdev->bus =3D=3D VIR_DOMAIN_REDIRDEV_BUS_USB && + !virDomainDefHasUSB(def)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("cannot add redirected USB device: " + "USB is disabled for this domain")); + return -1; + } + + return virDomainChrSourceDefValidate(redirdev->source, NULL, def); +} + + +int +virDomainChrDefValidate(const virDomainChrDef *chr, + const virDomainDef *def) +{ + return virDomainChrSourceDefValidate(chr->source, chr, def); +} + + +int +virDomainRNGDefValidate(const virDomainRNGDef *rng, + const virDomainDef *def) +{ + if (rng->backend =3D=3D VIR_DOMAIN_RNG_BACKEND_EGD) + return virDomainChrSourceDefValidate(rng->source.chardev, NULL, de= f); + + return 0; +} + + +int +virDomainSmartcardDefValidate(const virDomainSmartcardDef *smartcard, + const virDomainDef *def) +{ + if (smartcard->type =3D=3D VIR_DOMAIN_SMARTCARD_TYPE_PASSTHROUGH) + return virDomainChrSourceDefValidate(smartcard->data.passthru, NUL= L, def); + + return 0; +} diff --git a/src/conf/domain_validate.h b/src/conf/domain_validate.h index aef169a4c9..d65de50422 100644 --- a/src/conf/domain_validate.h +++ b/src/conf/domain_validate.h @@ -34,3 +34,11 @@ int virSecurityDeviceLabelDefValidate(virSecurityDeviceL= abelDefPtr *seclabels, size_t nvmSeclabels); int virDomainDiskDefValidate(const virDomainDef *def, const virDomainDiskDef *disk); +int virDomainRedirdevDefValidate(const virDomainDef *def, + const virDomainRedirdevDef *redirdev); +int virDomainChrDefValidate(const virDomainChrDef *chr, + const virDomainDef *def); +int virDomainRNGDefValidate(const virDomainRNGDef *rng, + const virDomainDef *def); +int virDomainSmartcardDefValidate(const virDomainSmartcardDef *smartcard, + const virDomainDef *def); --=20 2.26.2 From nobody Sat May 18 00:01:08 2024 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=1607466086; cv=none; d=zohomail.com; s=zohoarc; b=MF7jLZFcKRlxi6cxuXui+enCX2a9oHqHZQWLWFqokXPTbgc9rlmMpowobKcaRrNk1nICQSt1svgC7FUyWEDPAdluillqABCUW3ERgVygvmQvJuTIArk9IP5qFNWs2d9DUty6iMpBoE+0RnD91yUUPqOdLonnizG7WonfrH/3GrU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607466086; 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=mpVh/x0g+CTzSlB8PtFe0LN0mTd2gGyr9fB7PNwSifU=; b=Hhv4mDcN8gw3paveA2LXx/h6IfoiU3FCC6Sql1HPLLuxoZh5TiP6CZbDHOQKzipJFq/JwNofk700TNZ9vnCAuOYBITEg/8WegduoKxjWouKdPeE1U998M0GZUmQG8dYjveR878oCIdCOhwDz6H/k7l1cmu9z5AJlmwv/P+wtq/M= 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 1607466086686117.18982737999454; Tue, 8 Dec 2020 14:21:26 -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-274-mDkrnEWjOjazLfVfn-MUZQ-1; Tue, 08 Dec 2020 17:21:23 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 90972100F34A; Tue, 8 Dec 2020 22:21:16 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6DA9C60BF3; Tue, 8 Dec 2020 22:21:16 +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 05B2250032; Tue, 8 Dec 2020 22:21:16 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0B8MLE4C017365 for ; Tue, 8 Dec 2020 17:21:14 -0500 Received: by smtp.corp.redhat.com (Postfix) id 6CC401004145; Tue, 8 Dec 2020 22:21:14 +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 686D1112D41B for ; Tue, 8 Dec 2020 22:21:13 +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 847E2100B16A for ; Tue, 8 Dec 2020 22:21:13 +0000 (UTC) Received: from mail-qk1-f196.google.com (mail-qk1-f196.google.com [209.85.222.196]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-515-mrcnLvcLMvG4ktRp2ad1Nw-1; Tue, 08 Dec 2020 17:21:08 -0500 Received: by mail-qk1-f196.google.com with SMTP id 19so206244qkm.8; Tue, 08 Dec 2020 14:21:08 -0800 (PST) Received: from rekt.redhat.com ([2804:431:c7c7:c1a:69c1:2b22:e880:fc49]) by smtp.gmail.com with ESMTPSA id c14sm75057qtg.85.2020.12.08.14.21.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Dec 2020 14:21:07 -0800 (PST) X-MC-Unique: mDkrnEWjOjazLfVfn-MUZQ-1 X-MC-Unique: mrcnLvcLMvG4ktRp2ad1Nw-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=mpVh/x0g+CTzSlB8PtFe0LN0mTd2gGyr9fB7PNwSifU=; b=iDtl7vuO3Rj9NQEtvbRJYMfAF0ntgwup9lULEwzgy6DnvMBDkcFh0HSVEu9YYtg83W hq8gQRHGz6BBvJH5OT7FrLitBKZ6Dm0K5jtO+TS3KJIY64kfh3MVZze2JH6O2Tz9EeRO tgHHqoeG4uKc/zf5W1kqSg0/VXyoywyu34clXu48Vcl+maZpc6q/cEXiVnwW5w2esb1X TV9ZLefTA7bNNUskFFT3syr4m8YPNmBsm1gkZ7K/qL6PCv38nxGXn/NbsQofprx0y43Q NS1FbQkYhyc4RNpETc2RSt0pk6pdkhnCk4uBNsaZuQmkhzLBG8/NbfuT/VAhShXPS8Kz /yEg== X-Gm-Message-State: AOAM5332KaZxDyrBvMo/65Z2UvnzW0tjBVXZqHZFI/Fdsr9TAtnoWSjU wRKwybjdZIu7aGrH9r+hppGG9A76TfI= X-Google-Smtp-Source: ABdhPJwDHJ9inXUQCI/TMOO5mlx+46rTZ++RfpzQLkZqxNTm3GWyh+tlOp8uKyk4sVYPeWCqxFwl0A== X-Received: by 2002:a37:b346:: with SMTP id c67mr25974894qkf.69.1607466067597; Tue, 08 Dec 2020 14:21:07 -0800 (PST) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH v3 09/14] domain_conf.c: move smartcard address check to domain_validate.c Date: Tue, 8 Dec 2020 19:20:25 -0300 Message-Id: <20201208222030.1302229-10-danielhb413@gmail.com> In-Reply-To: <20201208222030.1302229-1-danielhb413@gmail.com> References: <20201208222030.1302229-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.3 X-loop: libvir-list@redhat.com Cc: Michal Privoznik , 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.79 on 10.5.11.12 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" This check is not tied to XML parsing and can be moved to virDomainSmartcardDefValidate(). Reviewed-by: Michal Privoznik Signed-off-by: Daniel Henrique Barboza --- src/conf/domain_conf.c | 7 ------- src/conf/domain_validate.c | 7 +++++++ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index a301ab5c74..a5dcb0bbce 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -13222,13 +13222,6 @@ virDomainSmartcardDefParseXML(virDomainXMLOptionPt= r xmlopt, if (virDomainDeviceInfoParseXML(xmlopt, node, &def->info, flags) < 0) return NULL; =20 - if (def->info.type !=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE && - def->info.type !=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCID) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Controllers must use the 'ccid' address type")); - return NULL; - } - return g_steal_pointer(&def); } =20 diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c index 882fbdac57..6fca604d17 100644 --- a/src/conf/domain_validate.c +++ b/src/conf/domain_validate.c @@ -484,6 +484,13 @@ int virDomainSmartcardDefValidate(const virDomainSmartcardDef *smartcard, const virDomainDef *def) { + if (smartcard->info.type !=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE && + smartcard->info.type !=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCID) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Controllers must use the 'ccid' address type")); + return -1; + } + if (smartcard->type =3D=3D VIR_DOMAIN_SMARTCARD_TYPE_PASSTHROUGH) return virDomainChrSourceDefValidate(smartcard->data.passthru, NUL= L, def); =20 --=20 2.26.2 From nobody Sat May 18 00:01:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1607466100; cv=none; d=zohomail.com; s=zohoarc; b=bJDVWDURCdx+hdduxtObEXwOBLaMTdnuvjrQxWsx6RDLKzP1ta/dEX+1YaZ9bt+0CZioSb0C+9q4grXpqIAtZXPJf9wsSjgFHGmABkA+Hw4JsHFTKvFw6VX0VW8sUmYg3uY9IC1mVlr1q6x6qpv7aAahLHVld4BWFrlhBF4BvVA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607466100; 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=mslKYfvBzp1hPeqeHovj4JcKgAzPZxlZlgp90wnJB3Q=; b=GJ5ku67WcgMrspC+SKutr2o0LMwvyAxHkh7qiUWJz1Ag2/KhQBBT809lvxHGz1X+pU9mft7hinOuj3xTH7GfdG7SmYMDJQFnd2edS+bo3t0tIljsKFExF0GforUqPOZ75H3ygw+7tT1mZ2dkARtTrHGU2/5LkQ1agvVFKbt1pq8= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 1607466100860378.01572382590814; Tue, 8 Dec 2020 14:21:40 -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-237-reuKDHAzMoCBZ0uEXNWcPg-1; Tue, 08 Dec 2020 17:21:37 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 10362803624; Tue, 8 Dec 2020 22:21:30 +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 8FC095D6D5; Tue, 8 Dec 2020 22:21:29 +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 2FE7F1809CB1; Tue, 8 Dec 2020 22:21:29 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0B8MLQMQ017650 for ; Tue, 8 Dec 2020 17:21:26 -0500 Received: by smtp.corp.redhat.com (Postfix) id 50F272026D48; Tue, 8 Dec 2020 22:21:26 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast02.extmail.prod.ext.rdu2.redhat.com [10.11.55.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4A7FB2026D38 for ; Tue, 8 Dec 2020 22:21:24 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) (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 3085B80018D for ; Tue, 8 Dec 2020 22:21:24 +0000 (UTC) Received: from mail-qk1-f170.google.com (mail-qk1-f170.google.com [209.85.222.170]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-488-vLz6TSrVNOmv55yzjsSGJg-1; Tue, 08 Dec 2020 17:21:20 -0500 Received: by mail-qk1-f170.google.com with SMTP id w79so226769qkb.5; Tue, 08 Dec 2020 14:21:20 -0800 (PST) Received: from rekt.redhat.com ([2804:431:c7c7:c1a:69c1:2b22:e880:fc49]) by smtp.gmail.com with ESMTPSA id c14sm75057qtg.85.2020.12.08.14.21.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Dec 2020 14:21:08 -0800 (PST) X-MC-Unique: reuKDHAzMoCBZ0uEXNWcPg-1 X-MC-Unique: vLz6TSrVNOmv55yzjsSGJg-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=mslKYfvBzp1hPeqeHovj4JcKgAzPZxlZlgp90wnJB3Q=; b=mVFfzVfPuFqEe9Vhq1HZ6G7mYOenL0pqyPqUtexm+GuS9sK3xYBgoEyWkmLQFF+q8T gaM+BVBR/QHtSbLM27jxeUkcxhaiNESVt/JOsqYhiItnqfBee5ovD7VWYc64Tw0QLxWA f/XG6FbHomoPLJK/sy01V9duBGTYG7yoS4InddnD1eKlf0U29kcTW1Qu7/XPBwnXqIDW B8l27sAHjEQZBhclme6v9R/NUEIisG8TExQMHWM5Cv3qhuFeejAcavNSb2sU8A2UR4S9 Md3HmLbKVrYj2ibWNvS7MPhfrCi9llvC+BRi7UlK5aorSAsMrREHNAzxrngg0sMRSvqE T3ag== X-Gm-Message-State: AOAM530WYpgLtLIgVKzNCSKYG2dTf7a+6lI/lanNbtSLCRLLcbO4v7k+ L65dwQFoaay6tXpC23RvuPBTA6suR0w= X-Google-Smtp-Source: ABdhPJzfZ7FwxK9CAEztjbfOrnCuDKCQm7WTwWkXWBH5k/9NEYQvwCE4zXI1qZfwdg4fYq1RAvLvZA== X-Received: by 2002:a37:494a:: with SMTP id w71mr6080811qka.132.1607466069695; Tue, 08 Dec 2020 14:21:09 -0800 (PST) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH v3 10/14] domain_conf.c: move blkio path check to domain_validate.c Date: Tue, 8 Dec 2020 19:20:26 -0300 Message-Id: <20201208222030.1302229-11-danielhb413@gmail.com> In-Reply-To: <20201208222030.1302229-1-danielhb413@gmail.com> References: <20201208222030.1302229-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.4 X-loop: libvir-list@redhat.com Cc: Michal Privoznik , 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.79 on 10.5.11.15 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" Move this check to a new virDomainDefTunablesValidate(), which is called by virDomainDefValidateInternal(). Reviewed-by: Michal Privoznik Signed-off-by: Daniel Henrique Barboza --- src/conf/domain_conf.c | 14 ++++---------- src/conf/domain_validate.c | 21 +++++++++++++++++++++ src/conf/domain_validate.h | 1 + 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index a5dcb0bbce..064d77d933 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -6981,6 +6981,9 @@ virDomainDefValidateInternal(const virDomainDef *def, if (virDomainDefVideoValidate(def) < 0) return -1; =20 + if (virDomainDefTunablesValidate(def) < 0) + return -1; + if (virDomainNumaDefValidate(def->numa) < 0) return -1; =20 @@ -20875,7 +20878,7 @@ virDomainDefTunablesParse(virDomainDefPtr def, unsigned int flags) { g_autofree xmlNodePtr *nodes =3D NULL; - size_t i, j; + size_t i; int n; =20 /* Extract blkio cgroup tunables */ @@ -20896,15 +20899,6 @@ virDomainDefTunablesParse(virDomainDefPtr def, &def->blkio.devices[i]) < 0) return -1; def->blkio.ndevices++; - for (j =3D 0; j < i; j++) { - if (STREQ(def->blkio.devices[j].path, - def->blkio.devices[i].path)) { - virReportError(VIR_ERR_XML_ERROR, - _("duplicate blkio device path '%s'"), - def->blkio.devices[i].path); - return -1; - } - } } VIR_FREE(nodes); =20 diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c index 6fca604d17..09ab908ea3 100644 --- a/src/conf/domain_validate.c +++ b/src/conf/domain_validate.c @@ -496,3 +496,24 @@ virDomainSmartcardDefValidate(const virDomainSmartcard= Def *smartcard, =20 return 0; } + + +int +virDomainDefTunablesValidate(const virDomainDef *def) +{ + size_t i, j; + + for (i =3D 0; i < def->blkio.ndevices; i++) { + for (j =3D 0; j < i; j++) { + if (STREQ(def->blkio.devices[j].path, + def->blkio.devices[i].path)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("duplicate blkio device path '%s'"), + def->blkio.devices[i].path); + return -1; + } + } + } + + return 0; +} diff --git a/src/conf/domain_validate.h b/src/conf/domain_validate.h index d65de50422..2bd9e71073 100644 --- a/src/conf/domain_validate.h +++ b/src/conf/domain_validate.h @@ -42,3 +42,4 @@ int virDomainRNGDefValidate(const virDomainRNGDef *rng, const virDomainDef *def); int virDomainSmartcardDefValidate(const virDomainSmartcardDef *smartcard, const virDomainDef *def); +int virDomainDefTunablesValidate(const virDomainDef *def); --=20 2.26.2 From nobody Sat May 18 00:01:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1607466091; cv=none; d=zohomail.com; s=zohoarc; b=NBQ2GY+KgyxLF0RM4AxNBwEL1o2qBbhlzk2R+b8cHuLHxj3dDD1BC4wfH1jwR+aDE6/+0ssxAjL869/5G264Ft7Of++h5rvsp3R4qFAfIMpzJjLxRqbu7RWrNl24dB7Tm1u2IDMgAIRgvz06pldMOovn9Ddr4IubP8GoRtIhO8A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607466091; 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=0GwHzxdJBscHZJnWnV+ycgSfzRIzxR7LF4BHZZ6F/70=; b=VqZFOtQOr4FKXDqKn+vu1RsEIyE7O4j6BcZ1yjDsIKBSV5rvpPqG9xswfWlZ1Sujhw73OVu/Ak77UQbaWFh21IsC436ykzqwWqgLKwLlz3jE1j20PcgauNT2uDxvMaY2HR5asbjzizZ07NU6gSsvl+yZxuUu8Yzu61Q4tLkQAaY= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 1607466091684290.3676129764656; Tue, 8 Dec 2020 14:21:31 -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-351-S-OVHgqQNlaFceXW0U6zBQ-1; Tue, 08 Dec 2020 17:21:27 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 86A4B107ACF7; Tue, 8 Dec 2020 22:21:21 +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 61D3A5D6D5; Tue, 8 Dec 2020 22:21:21 +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 2F7901809CA2; Tue, 8 Dec 2020 22:21:21 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0B8MLJ38017424 for ; Tue, 8 Dec 2020 17:21:19 -0500 Received: by smtp.corp.redhat.com (Postfix) id 26E5DA9FDE; Tue, 8 Dec 2020 22:21:19 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast01.extmail.prod.ext.rdu2.redhat.com [10.11.55.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1FD71AB404 for ; Tue, 8 Dec 2020 22:21:15 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) (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 E8CC2858284 for ; Tue, 8 Dec 2020 22:21:14 +0000 (UTC) Received: from mail-qk1-f196.google.com (mail-qk1-f196.google.com [209.85.222.196]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-322-S36zoZBvNUW2J7RuIEjJHQ-1; Tue, 08 Dec 2020 17:21:12 -0500 Received: by mail-qk1-f196.google.com with SMTP id h20so236896qkk.4 for ; Tue, 08 Dec 2020 14:21:12 -0800 (PST) Received: from rekt.redhat.com ([2804:431:c7c7:c1a:69c1:2b22:e880:fc49]) by smtp.gmail.com with ESMTPSA id c14sm75057qtg.85.2020.12.08.14.21.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Dec 2020 14:21:11 -0800 (PST) X-MC-Unique: S-OVHgqQNlaFceXW0U6zBQ-1 X-MC-Unique: S36zoZBvNUW2J7RuIEjJHQ-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=0GwHzxdJBscHZJnWnV+ycgSfzRIzxR7LF4BHZZ6F/70=; b=tkWDx3KFBfPxNUsg04KyltQS48AKo6LAu8STh6QkXFkG7X9qfBsdoTyWsmtX+Yhp26 LeNb7Q24nn8ZPF/GI7EBl10LScYfKpM5GbyDBYmCRnzsjEB8v0vSnuWo4UkbRwL6Mf/Q HOlwPAatmaidg6dy/n2z+s2sNj3iNR5ebtG1z54juCCBea4GG+kSKRrOxvKKLZ6LiQ8X F/0+Okbwy6BKWjD5hDqYD/oU5UW5bG5wnZtd5j4SIxgA5jje8Rc8I/m2Mzx1yrGN4xLp /Qhny2R9McstyotvOsxfMm2LQLte3kYWRI1GZ8Ez0ti+r36y9Yzt3EiCC3Q1sLqGc2v+ sgDA== X-Gm-Message-State: AOAM530uulWAJo5ck3H+7ewTlJodGEj1EDzyr5mOXvqImHJC3HGZmYAc IhGZ7alk5hB3C1gE9CfXBKROdtyhgkQ= X-Google-Smtp-Source: ABdhPJy9uHfd2GyhASYTZ8G64HRlAQVC1f9QYvafIPHd5g410xK4jYrgcnyvfCiRMmKS6oOGSHROsQ== X-Received: by 2002:a05:620a:1101:: with SMTP id o1mr5502795qkk.489.1607466072129; Tue, 08 Dec 2020 14:21:12 -0800 (PST) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH v3 11/14] domain_conf.c: move virDomainControllerDefValidate() to domain_validate.c Date: Tue, 8 Dec 2020 19:20:27 -0300 Message-Id: <20201208222030.1302229-12-danielhb413@gmail.com> In-Reply-To: <20201208222030.1302229-1-danielhb413@gmail.com> References: <20201208222030.1302229-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.79 on 10.11.54.5 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.79 on 10.5.11.15 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" Next patch will add more validations to this function. Let's move it to domain_validate.c beforehand. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Michal Privoznik --- src/conf/domain_conf.c | 37 ------------------------------------- src/conf/domain_validate.c | 37 +++++++++++++++++++++++++++++++++++++ src/conf/domain_validate.h | 1 + 3 files changed, 38 insertions(+), 37 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 064d77d933..453dc6cf6a 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -6211,43 +6211,6 @@ virDomainNetDefValidate(const virDomainNetDef *net) } =20 =20 -static int -virDomainControllerDefValidate(const virDomainControllerDef *controller) -{ - if (controller->type =3D=3D VIR_DOMAIN_CONTROLLER_TYPE_PCI) { - const virDomainPCIControllerOpts *opts =3D &controller->opts.pciop= ts; - - if (controller->idx > 255) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("PCI controller index %d too high, maximum is= 255"), - controller->idx); - return -1; - } - - /* Only validate the target index if it's been set */ - if (opts->targetIndex !=3D -1) { - - if (opts->targetIndex < 0 || opts->targetIndex > 30) { - virReportError(VIR_ERR_XML_ERROR, - _("PCI controller target index '%d' out of " - "range - must be 0-30"), - opts->targetIndex); - return -1; - } - - if ((controller->idx =3D=3D 0 && opts->targetIndex !=3D 0) || - (controller->idx !=3D 0 && opts->targetIndex =3D=3D 0)) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("Only the PCI controller with index 0 can= " - "have target index 0, and vice versa")); - return -1; - } - } - } - return 0; -} - - static int virDomainHostdevDefValidate(const virDomainHostdevDef *hostdev) { diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c index 09ab908ea3..416c24f97b 100644 --- a/src/conf/domain_validate.c +++ b/src/conf/domain_validate.c @@ -517,3 +517,40 @@ virDomainDefTunablesValidate(const virDomainDef *def) =20 return 0; } + + +int +virDomainControllerDefValidate(const virDomainControllerDef *controller) +{ + if (controller->type =3D=3D VIR_DOMAIN_CONTROLLER_TYPE_PCI) { + const virDomainPCIControllerOpts *opts =3D &controller->opts.pciop= ts; + + if (controller->idx > 255) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("PCI controller index %d too high, maximum is= 255"), + controller->idx); + return -1; + } + + /* Only validate the target index if it's been set */ + if (opts->targetIndex !=3D -1) { + + if (opts->targetIndex < 0 || opts->targetIndex > 30) { + virReportError(VIR_ERR_XML_ERROR, + _("PCI controller target index '%d' out of " + "range - must be 0-30"), + opts->targetIndex); + return -1; + } + + if ((controller->idx =3D=3D 0 && opts->targetIndex !=3D 0) || + (controller->idx !=3D 0 && opts->targetIndex =3D=3D 0)) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("Only the PCI controller with index 0 can= " + "have target index 0, and vice versa")); + return -1; + } + } + } + return 0; +} diff --git a/src/conf/domain_validate.h b/src/conf/domain_validate.h index 2bd9e71073..e8004e358d 100644 --- a/src/conf/domain_validate.h +++ b/src/conf/domain_validate.h @@ -43,3 +43,4 @@ int virDomainRNGDefValidate(const virDomainRNGDef *rng, int virDomainSmartcardDefValidate(const virDomainSmartcardDef *smartcard, const virDomainDef *def); int virDomainDefTunablesValidate(const virDomainDef *def); +int virDomainControllerDefValidate(const virDomainControllerDef *controlle= r); --=20 2.26.2 From nobody Sat May 18 00:01:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1607466092; cv=none; d=zohomail.com; s=zohoarc; b=SH5Q09Y/d8PmKDXU0xa9ddV4gQS6ycGWNikWiOf2Y+3TZf/PLJY2752YYQYxYWwlHarqsmMgwDxeM6Zd2di68Qg9DMl1k35bV9jWQ0Dy4XWEuJ4IN0k9zxGHO1gwzve4srf8NJt8y1PuHwat+g/vDfZM7H1gVrFVEMNjAGRRwvw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607466092; 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=T5dwxDaiDOG3d8lhdG3lXKI0c/SPiieJlZ4rGp+Ez7o=; b=ekxPEra4AyxjKBK3shBfvPhNEgtmVwv4S0sUw8OImA9gGl90+OuC6mupEEUTtBcZ49KE0idty4uga2zRfA+9KZ6L6XmKRI52NQKD9K0RLFDfoZx+cAorHHqbBTBym/iNPZb8PLvCpB7jQqDFFfex98+rCLTpX/6yByYcieFetPI= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 1607466092859114.1739558493307; Tue, 8 Dec 2020 14:21:32 -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-259-AqXod7ENNo-A9uTBAx2ZDg-1; Tue, 08 Dec 2020 17:21:27 -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 E9CCB107AD38; Tue, 8 Dec 2020 22:21:20 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C927160BD8; Tue, 8 Dec 2020 22:21:20 +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 935A550035; Tue, 8 Dec 2020 22:21:20 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0B8MLJWm017423 for ; Tue, 8 Dec 2020 17:21:19 -0500 Received: by smtp.corp.redhat.com (Postfix) id 26BABA9FD5; Tue, 8 Dec 2020 22:21:19 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast03.extmail.prod.ext.rdu2.redhat.com [10.11.55.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1EE9FA9FDF for ; Tue, 8 Dec 2020 22:21:18 +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 15273811E86 for ; Tue, 8 Dec 2020 22:21:18 +0000 (UTC) Received: from mail-qk1-f181.google.com (mail-qk1-f181.google.com [209.85.222.181]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-585-PWwZvgutM_u4eplWwfO75w-1; Tue, 08 Dec 2020 17:21:15 -0500 Received: by mail-qk1-f181.google.com with SMTP id 1so261354qka.0; Tue, 08 Dec 2020 14:21:14 -0800 (PST) Received: from rekt.redhat.com ([2804:431:c7c7:c1a:69c1:2b22:e880:fc49]) by smtp.gmail.com with ESMTPSA id c14sm75057qtg.85.2020.12.08.14.21.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Dec 2020 14:21:13 -0800 (PST) X-MC-Unique: AqXod7ENNo-A9uTBAx2ZDg-1 X-MC-Unique: PWwZvgutM_u4eplWwfO75w-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=T5dwxDaiDOG3d8lhdG3lXKI0c/SPiieJlZ4rGp+Ez7o=; b=cgKx7D75nbNYGDUf2NkBXFEI974s3vFBH4DHIPd135ep9ScuXOKoFlp/D8J9o7iYwv WWY41kFxsoe+QFFEpGSAiratsMAEjPbNdbTgqVa/yX7kd5lDUetTuCwGuAIpkRWZBnTn Sa1OfxTnD/tx/CuzGQaVp94+wx2/2QXNqSOYhhSaRO7TDYBH6FTzyLSZ0mrqHGOAp+rx tffxidX6eFRL9gO+bI3mVIj3/tjIEZ3NZCibK92jTI/WJTVdebTpRIQrms5zhwteuDTs TOGHDDa12hgJiRd49IRfTZyLIxV/IejiNwF98sl0GWtYo3FkvRbEM4+6wlt4ZfE2uy6o A+oA== X-Gm-Message-State: AOAM531szRw5eOQs60zpjCcnWKVxW9CaBGC3k9Dz5unusTm8m+nVKagy yIX7jABT4GTKR9/rUTbIEvdNShJZ1v4= X-Google-Smtp-Source: ABdhPJwYptZB8D83ENZBqOEI0tr6DNBWNOh8mczm6ORMlgpsYxDpNxI2Cz0XEP6mpiVwdheZbolclA== X-Received: by 2002:a37:4816:: with SMTP id v22mr32876961qka.42.1607466073910; Tue, 08 Dec 2020 14:21:13 -0800 (PST) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH v3 12/14] domain_conf: move virDomainPCIControllerOpts checks to domain_validate.c Date: Tue, 8 Dec 2020 19:20:28 -0300 Message-Id: <20201208222030.1302229-13-danielhb413@gmail.com> In-Reply-To: <20201208222030.1302229-1-danielhb413@gmail.com> References: <20201208222030.1302229-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.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Cc: Michal Privoznik , 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.79 on 10.5.11.11 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" virDomainControllerDefParseXML() does a lot of checks with virDomainPCIControllerOpts parameters that can be moved to virDomainControllerDefValidate, sharing the logic with other use cases that does not rely on XML parsing. 'pseries-default-phb-numa-node' parse error was changed to reflect the error that is being thrown by qemuValidateDomainDeviceDefController() via deviceValidateCallback, that is executed before virDomainControllerDefValidate(). Reviewed-by: Michal Privoznik Signed-off-by: Daniel Henrique Barboza --- src/conf/domain_conf.c | 42 +--------------- src/conf/domain_validate.c | 48 +++++++++++++++++++ .../pseries-default-phb-numa-node.err | 2 +- tests/qemuxml2argvtest.c | 6 ++- 4 files changed, 56 insertions(+), 42 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 453dc6cf6a..7adf2700ae 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -10864,14 +10864,6 @@ virDomainControllerDefParseXML(virDomainXMLOptionP= tr xmlopt, chassisNr); return NULL; } - if (def->opts.pciopts.chassisNr < 1 || - def->opts.pciopts.chassisNr > 255) { - virReportError(VIR_ERR_XML_ERROR, - _("PCI controller chassisNr '%s' out of ran= ge " - "- must be 1-255"), - chassisNr); - return NULL; - } } if (chassis) { if (virStrToLong_i(chassis, NULL, 0, @@ -10881,14 +10873,6 @@ virDomainControllerDefParseXML(virDomainXMLOptionP= tr xmlopt, chassis); return NULL; } - if (def->opts.pciopts.chassis < 0 || - def->opts.pciopts.chassis > 255) { - virReportError(VIR_ERR_XML_ERROR, - _("PCI controller chassis '%s' out of range= " - "- must be 0-255"), - chassis); - return NULL; - } } if (port) { if (virStrToLong_i(port, NULL, 0, @@ -10898,14 +10882,6 @@ virDomainControllerDefParseXML(virDomainXMLOptionP= tr xmlopt, port); return NULL; } - if (def->opts.pciopts.port < 0 || - def->opts.pciopts.port > 255) { - virReportError(VIR_ERR_XML_ERROR, - _("PCI controller port '%s' out of range " - "- must be 0-255"), - port); - return NULL; - } } if (busNr) { if (virStrToLong_i(busNr, NULL, 0, @@ -10915,14 +10891,6 @@ virDomainControllerDefParseXML(virDomainXMLOptionP= tr xmlopt, busNr); return NULL; } - if (def->opts.pciopts.busNr < 1 || - def->opts.pciopts.busNr > 254) { - virReportError(VIR_ERR_XML_ERROR, - _("PCI controller busNr '%s' out of range " - "- must be 1-254"), - busNr); - return NULL; - } } if (targetIndex) { if (virStrToLong_i(targetIndex, NULL, 0, @@ -10934,15 +10902,9 @@ virDomainControllerDefParseXML(virDomainXMLOptionP= tr xmlopt, return NULL; } } - if (numaNode >=3D 0) { - if (def->idx =3D=3D 0) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("The PCI controller with index=3D0 can't " - "be associated with a NUMA node")); - return NULL; - } + if (numaNode >=3D 0) def->opts.pciopts.numaNode =3D numaNode; - } + if (hotplug) { int val =3D virTristateSwitchTypeFromString(hotplug); =20 diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c index 416c24f97b..f47e80ca38 100644 --- a/src/conf/domain_validate.c +++ b/src/conf/domain_validate.c @@ -551,6 +551,54 @@ virDomainControllerDefValidate(const virDomainControll= erDef *controller) return -1; } } + + if (opts->chassisNr !=3D -1) { + if (opts->chassisNr < 1 || opts->chassisNr > 255) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("PCI controller chassisNr '%d' out of ran= ge " + "- must be 1-255"), + opts->chassisNr); + return -1; + } + } + + if (opts->chassis !=3D -1) { + if (opts->chassis < 0 || opts->chassis > 255) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("PCI controller chassis '%d' out of range= " + "- must be 0-255"), + opts->chassis); + return -1; + } + } + + if (opts->port !=3D -1) { + if (opts->port < 0 || opts->port > 255) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("PCI controller port '%d' out of range " + "- must be 0-255"), + opts->port); + return -1; + } + } + + if (opts->busNr !=3D -1) { + if (opts->busNr < 1 || opts->busNr > 254) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("PCI controller busNr '%d' out of range " + "- must be 1-254"), + opts->busNr); + return -1; + } + } + + if (opts->numaNode >=3D 0 && controller->idx =3D=3D 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("The PCI controller with index=3D0 can't " + "be associated with a NUMA node")); + return -1; + } } + return 0; } diff --git a/tests/qemuxml2argvdata/pseries-default-phb-numa-node.err b/tes= ts/qemuxml2argvdata/pseries-default-phb-numa-node.err index 5d11109317..e46b710330 100644 --- a/tests/qemuxml2argvdata/pseries-default-phb-numa-node.err +++ b/tests/qemuxml2argvdata/pseries-default-phb-numa-node.err @@ -1 +1 @@ -XML error: The PCI controller with index=3D0 can't be associated with a NU= MA node +unsupported configuration: Option 'numaNode' is not valid for PCI controll= er with index '0', model 'pci-root' and modelName 'spapr-pci-host-bridge' diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 0e7d8d5ba3..9b853c6d59 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -2115,7 +2115,11 @@ mymain(void) QEMU_CAPS_OBJECT_MEMORY_RAM, QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE, QEMU_CAPS_SPAPR_PCI_HOST_BRIDGE_NUMA_NODE); - DO_TEST_PARSE_ERROR("pseries-default-phb-numa-node", NONE); + DO_TEST_PARSE_ERROR("pseries-default-phb-numa-node", + QEMU_CAPS_NUMA, + QEMU_CAPS_OBJECT_MEMORY_RAM, + QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE, + QEMU_CAPS_SPAPR_PCI_HOST_BRIDGE_NUMA_NODE); DO_TEST_PARSE_ERROR("pseries-phb-invalid-target-index-1", NONE); DO_TEST_PARSE_ERROR("pseries-phb-invalid-target-index-2", NONE); DO_TEST_PARSE_ERROR("pseries-phb-invalid-target-index-3", NONE); --=20 2.26.2 From nobody Sat May 18 00:01:08 2024 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=1607466092; cv=none; d=zohomail.com; s=zohoarc; b=UnZtH8RChsJA3iSvLy0eq+dCS8vnpWSfZElHgwBe1CfvzO/zFbwwHQcisp0369NbrtsCB7isvPiZeIFQfmrcUkDcjpbO0VSZthx/JI0PIEpTbUxoUWwzdUTDYrOWyBM4kl24ZiT6Hx75t/t9wZSwc85zS5damSrouWb9aCK/goI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607466092; 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=R+sFuW4vRgHxAzI3jLpsgNzMamngqlf74RN5MtajteY=; b=Ik0yz7G5BN6VYclpr2vlWWNRWAafFr3XWdvnrcuGWJTVECTvR3ZF3OKiPfqtHdDAiwzwQAfGDIx2tQoRqqN8sEjD3jZ49Pifaxh709Gu9exmbakmJgrppIiJmiGe7U3nh3U3LtorWsvPNQTy0md8Q1U7t34+LM7yOOPRJ6gYN8A= 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 1607466092684986.4597619294474; Tue, 8 Dec 2020 14:21:32 -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-382-Um4BB8pBPWinu5uwBqZnoQ-1; Tue, 08 Dec 2020 17:21:29 -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 2C0AE803627; Tue, 8 Dec 2020 22:21:24 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0AD0C13470; Tue, 8 Dec 2020 22:21:24 +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 C757C50034; Tue, 8 Dec 2020 22:21:23 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0B8MLK1g017499 for ; Tue, 8 Dec 2020 17:21:20 -0500 Received: by smtp.corp.redhat.com (Postfix) id AD7F8A9FB9; Tue, 8 Dec 2020 22:21:20 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast05.extmail.prod.ext.rdu2.redhat.com [10.11.55.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A8147A9FBD for ; Tue, 8 Dec 2020 22:21:20 +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 94A52800969 for ; Tue, 8 Dec 2020 22:21:20 +0000 (UTC) Received: from mail-qk1-f178.google.com (mail-qk1-f178.google.com [209.85.222.178]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-493-24KmHZCdN3i7ND-EWJSBpA-1; Tue, 08 Dec 2020 17:21:16 -0500 Received: by mail-qk1-f178.google.com with SMTP id b144so174594qkc.13; Tue, 08 Dec 2020 14:21:16 -0800 (PST) Received: from rekt.redhat.com ([2804:431:c7c7:c1a:69c1:2b22:e880:fc49]) by smtp.gmail.com with ESMTPSA id c14sm75057qtg.85.2020.12.08.14.21.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Dec 2020 14:21:15 -0800 (PST) X-MC-Unique: Um4BB8pBPWinu5uwBqZnoQ-1 X-MC-Unique: 24KmHZCdN3i7ND-EWJSBpA-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=R+sFuW4vRgHxAzI3jLpsgNzMamngqlf74RN5MtajteY=; b=DM5oFxSXUuE4BeF78mV9gmLYyrZTToYpkwt9k/OirzcwpRcOazlQ7cciucK8PX6TsU r/GrPf4WXoRCJ+rIxb0+e/lSHBkDUESbF+QMrZu0JX3lm2T6R01/oFkgBGylFJ6iOtE0 bMhfp0ZnhcAG3Kx0+hKdpcdTGeYs5OmiaN+CFvhugnwpGMtoCzCyCjN4qaTKjWyHYT/J lz4hxlpy6r64gEH9SOLNEgZXBRW8GSJ1gERe93LNGbWuU1jnvnacuUMHXFMqEMY6r0jo tRTRwVysjSCYu8XrTM6x9AMEosXEe4GPf+nOOofgICJeSWZLk0cdWT24BHUim70BbMVE gN5w== X-Gm-Message-State: AOAM533iQQ7USSR5h9+7MWR5iOOJ7PdbC8B9mYtwwVYOOzHdr9Ig2ggI KqPooL7/GRzmREpHm/eDvW8FObRjnVo= X-Google-Smtp-Source: ABdhPJwdb6RWjgam7VQNHKVeikBANeXAK3n4Vq4kN6CuR34Dtgf2kAfOX69P2ikTJGZcevf4XIOm+g== X-Received: by 2002:a05:620a:1265:: with SMTP id b5mr33362264qkl.27.1607466075838; Tue, 08 Dec 2020 14:21:15 -0800 (PST) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH v3 13/14] domain_conf: move pci-root/pcie-root address check to domain_validate.c Date: Tue, 8 Dec 2020 19:20:29 -0300 Message-Id: <20201208222030.1302229-14-danielhb413@gmail.com> In-Reply-To: <20201208222030.1302229-1-danielhb413@gmail.com> References: <20201208222030.1302229-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.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Cc: Michal Privoznik , 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.79 on 10.5.11.11 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" Reviewed-by: Michal Privoznik Signed-off-by: Daniel Henrique Barboza --- src/conf/domain_conf.c | 6 ------ src/conf/domain_validate.c | 10 ++++++++++ tests/qemuxml2argvdata/pci-root-address.err | 2 +- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 7adf2700ae..7a7c9ec85c 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -10820,12 +10820,6 @@ virDomainControllerDefParseXML(virDomainXMLOptionP= tr xmlopt, case VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT: case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT: { unsigned long long bytes; - if (def->info.type !=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("pci-root and pcie-root controllers shoul= d not " - "have an address")); - return NULL; - } if ((rc =3D virParseScaledValue("./pcihole64", NULL, ctxt, &bytes, 1024, 1024ULL * ULONG_MAX, false)) < 0) diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c index f47e80ca38..35deb9f017 100644 --- a/src/conf/domain_validate.c +++ b/src/conf/domain_validate.c @@ -525,6 +525,16 @@ virDomainControllerDefValidate(const virDomainControll= erDef *controller) if (controller->type =3D=3D VIR_DOMAIN_CONTROLLER_TYPE_PCI) { const virDomainPCIControllerOpts *opts =3D &controller->opts.pciop= ts; =20 + if (controller->model =3D=3D VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT = || + controller->model =3D=3D VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT= ) { + if (controller->info.type !=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_= NONE) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("pci-root and pcie-root controllers " + "should not have an address")); + return -1; + } + } + if (controller->idx > 255) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("PCI controller index %d too high, maximum is= 255"), diff --git a/tests/qemuxml2argvdata/pci-root-address.err b/tests/qemuxml2ar= gvdata/pci-root-address.err index 53dad81985..ffe5438224 100644 --- a/tests/qemuxml2argvdata/pci-root-address.err +++ b/tests/qemuxml2argvdata/pci-root-address.err @@ -1 +1 @@ -XML error: pci-root and pcie-root controllers should not have an address +unsupported configuration: pci-root and pcie-root controllers should not h= ave an address --=20 2.26.2 From nobody Sat May 18 00:01:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1607466097; cv=none; d=zohomail.com; s=zohoarc; b=B9LxKGArOShqcqtAAWui1nxahnNmZelnLzb3H7rtPgWFIYdvKnrFf+WD12ZiqLHo4iaYhEHTxWFXZXOCgZpDmHhNDbJEcC/W+WlbsMhXh9Dlc/QeNGtyWDqi9cjJKrK1M5ndTTqurzGMlWuyO6FKFa8dEHIcAhuDTIaB6M5sMs8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607466097; 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=ibn99CVnA74SXerb8ZXk0YhLcrSxRWwbVgD8CGwoopA=; b=O7bkDpvp6obi30heMKir+AoMQclBXWvewhQTWayX2RXWdVK9Xf6+gPqG3lmox6vOYUVuHnSA0LJES2mPV4VIpz2c8KZ5LiKYyY8eyRxVFJBS3FLWS9W40+TVMgrXJ1C4VobdBZRsnb6tEHdVwMChb4mzAmu18LqVjBrMNuAbMP0= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 1607466097683266.48027802403624; Tue, 8 Dec 2020 14:21:37 -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-463-gfXMs-TxM96NXAbhJ9fA3Q-1; Tue, 08 Dec 2020 17:21:33 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E711B1005513; Tue, 8 Dec 2020 22:21:26 +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 C4F5A60C0F; Tue, 8 Dec 2020 22:21:26 +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 906141809CAD; Tue, 8 Dec 2020 22:21:26 +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 0B8MLN2n017577 for ; Tue, 8 Dec 2020 17:21:23 -0500 Received: by smtp.corp.redhat.com (Postfix) id B455A2166B2A; Tue, 8 Dec 2020 22:21:23 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast06.extmail.prod.ext.rdu2.redhat.com [10.11.55.22]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AF52A2166B29 for ; Tue, 8 Dec 2020 22:21:21 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.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 A015A1875042 for ; Tue, 8 Dec 2020 22:21:21 +0000 (UTC) Received: from mail-qt1-f173.google.com (mail-qt1-f173.google.com [209.85.160.173]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-248-9_StCs-jM-2Z3qFtdMl_xA-1; Tue, 08 Dec 2020 17:21:18 -0500 Received: by mail-qt1-f173.google.com with SMTP id c14so3562851qtn.0; Tue, 08 Dec 2020 14:21:18 -0800 (PST) Received: from rekt.redhat.com ([2804:431:c7c7:c1a:69c1:2b22:e880:fc49]) by smtp.gmail.com with ESMTPSA id c14sm75057qtg.85.2020.12.08.14.21.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Dec 2020 14:21:17 -0800 (PST) X-MC-Unique: gfXMs-TxM96NXAbhJ9fA3Q-1 X-MC-Unique: 9_StCs-jM-2Z3qFtdMl_xA-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=ibn99CVnA74SXerb8ZXk0YhLcrSxRWwbVgD8CGwoopA=; b=HhqLbPkGp5w288QQE9XvS8ddHGtvS5qqHfCm+TtEYn959LEeBWtpLPoYNbLssFVXtG Tc/av1aOphanvOzutnaRWR8pqvQ4Rv1Sr0jLkBLi4/Bs4QXqAStGYg3NA6Ga4+C5nCvW XGdULkBhVN909i2D9V4X1QcoT+XooAOxvpqXwcGItTsU3L1vA+fEGsCIwWeSnXMyb6Mi Jwq4iFt5AqrJJYcE5RrJLpuHDqKCF+BNGr2g6RN1JP9WAqhzo7JfbBv6u63k4PnSeWl8 eZIdVvq3ybZe0Ky32CEX4YSyh4XvQm4xK83ZhB7oh0khr6T2qGXxTX5KIQbnnPqwTKNB lxKw== X-Gm-Message-State: AOAM530JIxystdF0QF7+adWHVmWkxEOHq8PgnhAyoGZU5Cvi6vGZJpjB WST9tFlodpbkxBpEONTkOhtvYxYXhnA= X-Google-Smtp-Source: ABdhPJyNH+2cWmdjNaG96uHG3R6ZFaoM4U681KREQLxEWiiE1k5eDk386vVFnkxH8t9aWDYfVQ/30A== X-Received: by 2002:ac8:7146:: with SMTP id h6mr268335qtp.112.1607466077626; Tue, 08 Dec 2020 14:21:17 -0800 (PST) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH v3 14/14] domain_conf.c: move idmapEntry checks to domain_validate.c Date: Tue, 8 Dec 2020 19:20:30 -0300 Message-Id: <20201208222030.1302229-15-danielhb413@gmail.com> In-Reply-To: <20201208222030.1302229-1-danielhb413@gmail.com> References: <20201208222030.1302229-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: Michal Privoznik , 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.79 on 10.5.11.12 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 virDomainDefIdMapValidate() and use it to move these checks out of virDomainIdmapDefParseXML() and virDomainDefParseXML(). Reviewed-by: Michal Privoznik Signed-off-by: Daniel Henrique Barboza --- src/conf/domain_conf.c | 19 +++---------------- src/conf/domain_validate.c | 23 +++++++++++++++++++++++ src/conf/domain_validate.h | 1 + 3 files changed, 27 insertions(+), 16 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 7a7c9ec85c..44f136f530 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -6947,6 +6947,9 @@ virDomainDefValidateInternal(const virDomainDef *def, if (virDomainDefTunablesValidate(def) < 0) return -1; =20 + if (virDomainDefIdMapValidate(def) < 0) + return -1; + if (virDomainNumaDefValidate(def->numa) < 0) return -1; =20 @@ -18463,15 +18466,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 @@ -21961,13 +21955,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 diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c index 35deb9f017..0eed1ba982 100644 --- a/src/conf/domain_validate.c +++ b/src/conf/domain_validate.c @@ -612,3 +612,26 @@ virDomainControllerDefValidate(const virDomainControll= erDef *controller) =20 return 0; } + + +int +virDomainDefIdMapValidate(const virDomainDef *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; +} diff --git a/src/conf/domain_validate.h b/src/conf/domain_validate.h index e8004e358d..497a02b9b3 100644 --- a/src/conf/domain_validate.h +++ b/src/conf/domain_validate.h @@ -44,3 +44,4 @@ int virDomainSmartcardDefValidate(const virDomainSmartcar= dDef *smartcard, const virDomainDef *def); int virDomainDefTunablesValidate(const virDomainDef *def); int virDomainControllerDefValidate(const virDomainControllerDef *controlle= r); +int virDomainDefIdMapValidate(const virDomainDef *def); --=20 2.26.2