From nobody Sun Feb 8 05:09:33 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1607349326; cv=none; d=zohomail.com; s=zohoarc; b=kMtbNdmrOLgmYVfnSLD6O5hCK18hj58A7vnnWofb1E8m2bIRk9xN6SIzXT8cGN7YWhYBeFLyixQVH5v8/h0T1FJkkxC5F4JRMAAiI2EkONv21EWaOiFKcs5lBaFGNMTtY6NeVKdYal7RMwTVsNXdEiRFrrdiDX5DOyBnvM1jH/M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607349326; 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=8pxzY81qAJVgTIxQV3Wk383zMWpCJToxkkdOJDEZpQE=; b=DyPZmi++iDiTo58Q9vs62K0lF/NCpTo18RLkGwfCu/Ekld6sMxE35I3Cw84zj+H7uxHPGTGb2Tkr5hCEdO1p1wJfecR/GLg5Gr/Lh9XUoXhL2WoXcQ6qQanstdGmYlzfdX3laH/kQAlaVNVkTInx/hmVqkdpAM3/hQhSKJivgVE= 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 160734932616645.44496052660577; Mon, 7 Dec 2020 05:55: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-58-EyDFbda4MKKdxBR6n-P-gQ-1; Mon, 07 Dec 2020 08:55:22 -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 1A4BE1E7D2; Mon, 7 Dec 2020 13:55:17 +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 EA75B620DE; Mon, 7 Dec 2020 13:55: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 B35E14EEEE; Mon, 7 Dec 2020 13:55:16 +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 0B7Dsuj7012924 for ; Mon, 7 Dec 2020 08:54:56 -0500 Received: by smtp.corp.redhat.com (Postfix) id 711352166B2D; Mon, 7 Dec 2020 13:54:56 +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 6B81B2166B2B for ; Mon, 7 Dec 2020 13:54:54 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.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 0B8AE801231 for ; Mon, 7 Dec 2020 13:54:54 +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-240-17mJqYjrNHORqT8smcU6XQ-1; Mon, 07 Dec 2020 08:54:52 -0500 Received: by mail-qk1-f180.google.com with SMTP id 1so12529654qka.0 for ; Mon, 07 Dec 2020 05:54:51 -0800 (PST) Received: from rekt.redhat.com ([2804:431:c7c7:c1a:69c1:2b22:e880:fc49]) by smtp.gmail.com with ESMTPSA id n95sm12233701qte.43.2020.12.07.05.54.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Dec 2020 05:54:50 -0800 (PST) X-MC-Unique: EyDFbda4MKKdxBR6n-P-gQ-1 X-MC-Unique: 17mJqYjrNHORqT8smcU6XQ-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=8pxzY81qAJVgTIxQV3Wk383zMWpCJToxkkdOJDEZpQE=; b=hIJRfUTtgdMdV3GT7pN+mB2SUtXKXxhH+5NPGrj0ZoqBFjLRCPvjIu/+QIa9ATGaDh o9mV2b4984XpeDtDLOMgxbM5ZIfo9JDDJmUiO8lco1mjsNUWaXzMo/bU/eUHqtNLts1C QOrPqinhB78hNrjet3jwXITHj7sCeSeB6MFzCPpfx1xqRe6kDlJKo9OgrbvqOspb3F+I arNOxlEh//bIYs180GJwvFqhVRgkoFnQ61exJ4Zthiz8kaAXaoJnvce992zuZ/jRLVqz yyCj+3LhcvMO0EOgWjNg3DLxhOPmrVs4Br2fXN/djn1iaRElM/nWpvOlUF5FPt1OUMzx xiXg== X-Gm-Message-State: AOAM531lzQrwPKU3+cVhkPTWkcsPYq5W58pNDAGNOTRVoEgkrnRj+yF7 lRZCPw1QHHEWDdGsFgWNPeSAAG9oB10= X-Google-Smtp-Source: ABdhPJyOfe/u/lnZSBdyX0991cx4sS6P/kBtHZmFbnDU78cBlDbsi/GuLgtKsp9eFfp9pXB3wMtBKA== X-Received: by 2002:a37:aace:: with SMTP id t197mr7520261qke.400.1607349291211; Mon, 07 Dec 2020 05:54:51 -0800 (PST) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH v2 1/9] domain_conf.c: move boot related timeouts check to validate callback Date: Mon, 7 Dec 2020 10:54:27 -0300 Message-Id: <20201207135435.884594-2-danielhb413@gmail.com> In-Reply-To: <20201207135435.884594-1-danielhb413@gmail.com> References: <20201207135435.884594-1-danielhb413@gmail.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-loop: libvir-list@redhat.com Cc: Daniel Henrique Barboza X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.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. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Michal Privoznik --- src/conf/domain_conf.c | 41 ++++++++++++++++++++++++++++++---------- tests/qemuxml2argvtest.c | 3 ++- 2 files changed, 33 insertions(+), 11 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 66ee658e7b..e53a7372fc 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -7299,6 +7299,28 @@ virDomainDefOSValidate(const virDomainDef *def, } =20 =20 +static 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; +} + + static int virDomainDefValidateInternal(const virDomainDef *def, virDomainXMLOptionPtr xmlopt) @@ -7344,6 +7366,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 +18892,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 +18915,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/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 Sun Feb 8 05:09:33 2026 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=1607349314; cv=none; d=zohomail.com; s=zohoarc; b=TTRDHLabdr/JDqFrnvYnqu3ZIrG1y31EZAkCxrvVyMBDtPDwSOK7Q0GqQja1rfGOobhoDlGWUgm7pax19xzcMt6VSzBjjXGAm5OHxoQUzccd2cqRf6Eu0vuPlw1OFl55QOBx5WwW4Os69D5rg++DkGKiXUEzdYebak4quhrf0o8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607349314; 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=jQrj9qeyfFQTclk1D+Eb8bvBoNGNe4Ko+aHU6Ngn3g8=; b=K0w/MCcPgkcHZP4Pn2eMBMuG3JyEiPkU/J1wPiTlv2aCkdpEfy2fI5kZqp8gvFD5Ywl+yk46KBCA9kOfvMqJcgfMVMBKZzI3fy1Rq8pRVy8oszojGZUyjONrUm/rHMBKq0gwemk4aQef5jOdQ/4Y/c8A93KH8Fl3EsEvALN1cTo= 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 1607349314934486.2040505072532; Mon, 7 Dec 2020 05:55:14 -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-309-72ha6tPqMce-XkurmHU9Kw-1; Mon, 07 Dec 2020 08:55:11 -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 4699C809DCC; Mon, 7 Dec 2020 13:55:05 +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 118515C1A1; Mon, 7 Dec 2020 13:55: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 130BE1809CA2; Mon, 7 Dec 2020 13:55:03 +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 0B7DsxSa012946 for ; Mon, 7 Dec 2020 08:54:59 -0500 Received: by smtp.corp.redhat.com (Postfix) id 76062202319B; Mon, 7 Dec 2020 13:54:59 +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 6FBA62023199 for ; Mon, 7 Dec 2020 13:54:57 +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 0BC5F811E86 for ; Mon, 7 Dec 2020 13:54:57 +0000 (UTC) Received: from mail-qv1-f41.google.com (mail-qv1-f41.google.com [209.85.219.41]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-465-zU44S5FQOR6Zee7Ok5YhsQ-1; Mon, 07 Dec 2020 08:54:53 -0500 Received: by mail-qv1-f41.google.com with SMTP id x13so6476441qvk.8 for ; Mon, 07 Dec 2020 05:54:53 -0800 (PST) Received: from rekt.redhat.com ([2804:431:c7c7:c1a:69c1:2b22:e880:fc49]) by smtp.gmail.com with ESMTPSA id n95sm12233701qte.43.2020.12.07.05.54.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Dec 2020 05:54:52 -0800 (PST) X-MC-Unique: 72ha6tPqMce-XkurmHU9Kw-1 X-MC-Unique: zU44S5FQOR6Zee7Ok5YhsQ-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=jQrj9qeyfFQTclk1D+Eb8bvBoNGNe4Ko+aHU6Ngn3g8=; b=paWkAwx4vOq648zJ/l7Pd1HwYB/gDCwW9oLdbKmthqST0MzQ2HyJndRFVgt/gpqvax ffxH955YrEkGgwJjgqQdNMiVp+dmQ0t17WQLzzrICvMnzJdNzWGex0y7ckJsMjE/c+hy hjoNUydF+uNGtGwsx+N54TFTndq9IfAGNDZIhFUDZTFgsiECBOJs8mg6p2B/I+BH78yz 5KN952NiploLbpyCS1uz7d68RMV5jR+ZfMbjcRBhczzLtIEq6WRuAW5GKyzmuWOfhC21 QT0PKZLfGW423XbG14tBkQMalBKPqN/RaNU68otbgDdR62pZ4U5Z8YsmrYFUjXxju7R0 MnXw== X-Gm-Message-State: AOAM532Yuo/sIjwIm16Yg9a2Vjcm5hiz0ErGihFkkumNFuQRfs8ok2W8 XI7HsEqHbTeEcvF8sJSdTQXOzoimRBs= X-Google-Smtp-Source: ABdhPJwLrnOVJHKYm22L5QyNznKsq0tigLYquhL7JwoZQ6qTNuRHfbyGXqD2K7WV2lhaZfotmpIqdg== X-Received: by 2002:a0c:9ba6:: with SMTP id o38mr21369188qve.56.1607349293034; Mon, 07 Dec 2020 05:54:53 -0800 (PST) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH v2 2/9] domain_conf.c: move primary video check to validate callback Date: Mon, 7 Dec 2020 10:54:28 -0300 Message-Id: <20201207135435.884594-3-danielhb413@gmail.com> In-Reply-To: <20201207135435.884594-1-danielhb413@gmail.com> References: <20201207135435.884594-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: 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" Move this check to virDomainDefVideoValidate() since it's not related to XML parsing. 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. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Michal Privoznik --- src/conf/domain_conf.c | 34 +++++++++++++++---- .../video-multiple-primaries.err | 1 + .../video-multiple-primaries.xml | 32 +++++++++++++++++ tests/qemuxml2argvtest.c | 5 +++ 4 files changed, 66 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 e53a7372fc..4b5cab87e7 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -7321,6 +7321,30 @@ virDomainDefBootValidate(const virDomainDef *def) } =20 =20 +static 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; +} + + static int virDomainDefValidateInternal(const virDomainDef *def, virDomainXMLOptionPtr xmlopt) @@ -7369,6 +7393,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 @@ -22162,14 +22189,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/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 Sun Feb 8 05:09:33 2026 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=1607349332; cv=none; d=zohomail.com; s=zohoarc; b=nle3rn2nNXGG6ThgXW5UMWN4UjdDM7J7FKi103/i8cjf8hD2R+EZDpPDSBzWSuFzuq6hWMjqQRqzybkZKso/HD7Nl7iNjKB0PkxT2giqMb9+OB8h07ApQYvnQ9QN4aIYkp2mhNUWEXLeSuZzTiazhEK+KmB0I3tNHwvodVIZ+Jg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607349332; 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=KMG4QDw3RtuXpmzlpN4hqDvRxybO6Dg/ZZVcDmnmM/E=; b=kz4SmQoW+XK13hCxakHex+5KaOEslqhRaAHoXikZVGK5rLLVpdVv4ZX9c7WnnvS9hfICZnZRDY4LIIcnvJi3MX8QlG+ccx7rwj/blow2xnvl2R6PWzvQQlSvFJIuvNdd8uZ3ebOT0TfIcFIzT3eE5mPgJi87BX9ZMolrrlvqttA= 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 1607349332781681.513914678677; Mon, 7 Dec 2020 05:55: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-305-tR8UL7EkPwiCys8dnjeBpQ-1; Mon, 07 Dec 2020 08:55:29 -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 E37918015F4; Mon, 7 Dec 2020 13:55:19 +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 C00B95D6D5; Mon, 7 Dec 2020 13:55:19 +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 8A3F850031; Mon, 7 Dec 2020 13:55:19 +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 0B7DsvYh012932 for ; Mon, 7 Dec 2020 08:54:57 -0500 Received: by smtp.corp.redhat.com (Postfix) id 5F0096B42D; Mon, 7 Dec 2020 13:54:57 +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 5923C4405A for ; Mon, 7 Dec 2020 13:54:57 +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 46470100FBC9 for ; Mon, 7 Dec 2020 13:54:57 +0000 (UTC) Received: from mail-qt1-f174.google.com (mail-qt1-f174.google.com [209.85.160.174]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-118-Dp6uUtwLM7i6N1rg_7T-bg-1; Mon, 07 Dec 2020 08:54:55 -0500 Received: by mail-qt1-f174.google.com with SMTP id z9so9367882qtn.4 for ; Mon, 07 Dec 2020 05:54:55 -0800 (PST) Received: from rekt.redhat.com ([2804:431:c7c7:c1a:69c1:2b22:e880:fc49]) by smtp.gmail.com with ESMTPSA id n95sm12233701qte.43.2020.12.07.05.54.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Dec 2020 05:54:54 -0800 (PST) X-MC-Unique: tR8UL7EkPwiCys8dnjeBpQ-1 X-MC-Unique: Dp6uUtwLM7i6N1rg_7T-bg-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=KMG4QDw3RtuXpmzlpN4hqDvRxybO6Dg/ZZVcDmnmM/E=; b=aMVtCTMJqsjkM31STRgN+uaO9rFztzOPN8PeCxRlafRKUoWTYMaluZx7fd4h7rV8Yy TZ6Sid6iYnLGA23ZDmWMTTsCIQBE87hGSLhLE4DoP3h53dLM/wUApbA/+1XiXVta8Z5P GWHzvY6H4TpWGKr66CsGFFqxXpAM+lzPjLC8HOXIs1XC3Di97wYzmP66yf/s/4iiqiZ6 0yeuYVIalHLeNfqdDBMiYyKXmop0mFlNI8gZhemF4Cf8VnwUBfSkz4w+LJY2/qg79e2d rsGJOBeMexKnQQhbQuJpa3bbTayjX0qffxk91ZCSQOzN2YL6XkMEE2k8vDQ3G+4MH1mS 8s3g== X-Gm-Message-State: AOAM530rKpz+OjKRiAkANR4iYagcnGfoIWowUARIgWUXy2JxxW64FB4p qR2kdUVs6FVc5TBORXz1NOgwg0Uo/0w= X-Google-Smtp-Source: ABdhPJwEeEJ5E+b+UpLetXoekvObIQfPXKn4X5x/Jrh9t8kx01HR+WAz+pGubhjFMCk/I20huGkuPQ== X-Received: by 2002:ac8:120c:: with SMTP id x12mr10169303qti.388.1607349294771; Mon, 07 Dec 2020 05:54:54 -0800 (PST) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH v2 3/9] domain_conf.c: move QXL attributes check to virDomainVideoDefValidate() Date: Mon, 7 Dec 2020 10:54:29 -0300 Message-Id: <20201207135435.884594-4-danielhb413@gmail.com> In-Reply-To: <20201207135435.884594-1-danielhb413@gmail.com> References: <20201207135435.884594-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" 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. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Michal Privoznik --- src/conf/domain_conf.c | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 4b5cab87e7..bc09577e39 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -6664,6 +6664,26 @@ virDomainVideoDefValidate(const virDomainVideoDef *v= ideo, 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 @@ -16234,11 +16254,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); @@ -16255,11 +16270,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); @@ -16268,11 +16278,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); --=20 2.26.2 From nobody Sun Feb 8 05:09:33 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1607349331; cv=none; d=zohomail.com; s=zohoarc; b=D+lfbAQtKxyUOjRo8oyf+5XbUdpeSCV7P+6z9mfX8fucPvxuJg+1Vy7eGkRPwue2uErbCjFS9MUlIciTE35XDD5dYrdJEG2oiP4TTP2O1orHL3+g3nxkvA0IKiaNXhP4xKYpCyEa3NaR08E1VRzEO/Z3GriTSOZv4G6K8hoOqTo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607349331; 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=pEsMqx4OOuyRWt4oNaM+FR+1LoT34KkAHUtGzy5Q+0U=; b=R0oTLPQrtpk4f0slsMvtbLukOIaPz0Yuk+vo8BwBpG+Sl6f4z22r/nuP7/iZKatlPd9wgYGxVgzJXIgQ6pNlXm3Yv+s05zNZ807elBI468H70GTorw50Ys5NWAcDMUs9MPFQ8uqymP1JeVtHPJe2KBkziQHYwo0zTe4t3kgrPr0= 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 1607349331732652.904481627789; Mon, 7 Dec 2020 05:55: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-444-Jup9i0epMPyxp4W2rYRqfA-1; Mon, 07 Dec 2020 08:55:28 -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 A97D01E7CB; Mon, 7 Dec 2020 13:55:22 +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 813E05D9DE; Mon, 7 Dec 2020 13:55:22 +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 485DA50032; Mon, 7 Dec 2020 13:55:22 +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 0B7DsxkH012948 for ; Mon, 7 Dec 2020 08:54:59 -0500 Received: by smtp.corp.redhat.com (Postfix) id 837162023197; Mon, 7 Dec 2020 13:54:59 +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 7C5D82023198 for ; Mon, 7 Dec 2020 13:54:59 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.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 66DC7803DD8 for ; Mon, 7 Dec 2020 13:54:59 +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-592-6NYw47jZMeikKIw46KzYzg-1; Mon, 07 Dec 2020 08:54:57 -0500 Received: by mail-qt1-f177.google.com with SMTP id h19so7122447qtq.13 for ; Mon, 07 Dec 2020 05:54:57 -0800 (PST) Received: from rekt.redhat.com ([2804:431:c7c7:c1a:69c1:2b22:e880:fc49]) by smtp.gmail.com with ESMTPSA id n95sm12233701qte.43.2020.12.07.05.54.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Dec 2020 05:54:56 -0800 (PST) X-MC-Unique: Jup9i0epMPyxp4W2rYRqfA-1 X-MC-Unique: 6NYw47jZMeikKIw46KzYzg-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=pEsMqx4OOuyRWt4oNaM+FR+1LoT34KkAHUtGzy5Q+0U=; b=JcwQUE7TlU5Jv6xF/BbxnTD+Qj/rrQIE/F+ZAunZ0TCoMHnVw+0RBNzwD5ZLIki0L2 pjVyXVNnHiPV82KJW2IF7GXuxgkGbogErzfzmBbAvZw19Z1q39GBnBQtoQusWMOZV1tg fNG3cMAV6Xj/JETXXti7UMDY4Xhppj/y6yQEWuBrvL04IOH8CcCZmemmAyOkREWfiF9Y HYLxsB3bX1QlIgpDzFixxbGa46M5IVX6p7SAaXiYWRLbffmT1UU9+Sqimh82T4YaGmmC F0z4YqxNJTuTizZ4B7TdGuwSelPfcSg2BXtngz+Fb4E3KC6JEi/3uPQqRjDyPj2HeN3k hr2Q== X-Gm-Message-State: AOAM532SJ9HZPH0bWvtKEivD/gR68d9oO7VskXmQZoBYHyZg60T+O1Os u1j3cTkgeVIN8gJrxE9tLuB51tX150A= X-Google-Smtp-Source: ABdhPJzFzeDc10boWRasNQfPFw3a3oQcAXrjWC3pNCKuRyxu1xWVXy/F527ObMFVK6YDL53KuR/3Eg== X-Received: by 2002:ac8:7604:: with SMTP id t4mr23891029qtq.366.1607349296694; Mon, 07 Dec 2020 05:54:56 -0800 (PST) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH v2 4/9] domain_conf.c: move vendor, product and tray checks to validate callback Date: Mon, 7 Dec 2020 10:54:30 -0300 Message-Id: <20201207135435.884594-5-danielhb413@gmail.com> In-Reply-To: <20201207135435.884594-1-danielhb413@gmail.com> References: <20201207135435.884594-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: 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 '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. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Michal Privoznik --- src/conf/domain_conf.c | 47 ++++++++++++++++++++++-------------------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index bc09577e39..e9bafd189f 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -6115,6 +6115,9 @@ virSecurityDeviceLabelDefValidateXML(virSecurityDevic= eLabelDefPtr *seclabels, } =20 =20 +#define VENDOR_LEN 8 +#define PRODUCT_LEN 16 + static int virDomainDiskDefValidate(const virDomainDef *def, const virDomainDiskDef *disk) @@ -6191,6 +6194,28 @@ 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 @@ -10496,9 +10521,6 @@ virDomainDiskDefParsePrivateData(xmlXPathContextPtr= ctxt, } =20 =20 -#define VENDOR_LEN 8 -#define PRODUCT_LEN 16 - static virDomainDiskDefPtr virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt, xmlNodePtr node, @@ -10673,12 +10695,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")); @@ -10689,12 +10705,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")); @@ -10825,13 +10835,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) { --=20 2.26.2 From nobody Sun Feb 8 05:09:33 2026 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=1607349478; cv=none; d=zohomail.com; s=zohoarc; b=dOmiv5/5TBx3uLzYXILVi+a9vxwKrKqRyLlcTFuUB1SzJD/RH/W9XsYIRg8nv2fT3vmeAsJ85qdTo+9yIYRX6TeFy0eZnTZSKFJWalnM//zxd7oVBbDbIdoNF3OERI6529SwpiMJIcuzCvUTmkBrji6ltCB0amMZO5eYCohjYbU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607349478; 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=XYP+Xrjovt+xKQqP3t0kvin0RA36VzX7sAvd7nBWJI8=; b=NrJW9VA4sq+ZrWMyzNrjTgya/7uXHrpmxaonFagYg4vQ4wmy6DvFr3f8AZwtohMfkD8jefmb94OrdA3yAs5dTbzSk+tBlb/O3KP1rQJmJyfdgkpGQrisQgMpIxD4c60h2FtMNIEGvkq8f90++YpzmxANlf0rNtlB8N0s+Z68wG8= 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 1607349478118332.610150052638; Mon, 7 Dec 2020 05:57:58 -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-345-qPWEZ1QnMQuAbtNAKdxbRQ-1; Mon, 07 Dec 2020 08:55:32 -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 94B651E7E9; Mon, 7 Dec 2020 13:55:25 +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 43E606EF41; Mon, 7 Dec 2020 13:55:25 +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 03EA01809CA2; Mon, 7 Dec 2020 13:55:25 +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 0B7Dt1H9012960 for ; Mon, 7 Dec 2020 08:55:01 -0500 Received: by smtp.corp.redhat.com (Postfix) id 73ECF6B42D; Mon, 7 Dec 2020 13:55:01 +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 6E0806379C for ; Mon, 7 Dec 2020 13:55:01 +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 5B0D485829F for ; Mon, 7 Dec 2020 13:55:01 +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-430-7jmFUrRiPNmB2lXgYycSfw-1; Mon, 07 Dec 2020 08:54:59 -0500 Received: by mail-qk1-f196.google.com with SMTP id 19so4913757qkm.8 for ; Mon, 07 Dec 2020 05:54:59 -0800 (PST) Received: from rekt.redhat.com ([2804:431:c7c7:c1a:69c1:2b22:e880:fc49]) by smtp.gmail.com with ESMTPSA id n95sm12233701qte.43.2020.12.07.05.54.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Dec 2020 05:54:58 -0800 (PST) X-MC-Unique: qPWEZ1QnMQuAbtNAKdxbRQ-1 X-MC-Unique: 7jmFUrRiPNmB2lXgYycSfw-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=XYP+Xrjovt+xKQqP3t0kvin0RA36VzX7sAvd7nBWJI8=; b=Ny5LuE7zyi8rfUdTJgeKx6stxY86TXkeXrj8WDPSvO9B2UlFvrK5bt38RVtGcRl1u1 bWtnqIqquY9fmjDueQUzftszrBFU9FYMac1xaZteDqfkIO6KSwejXdHcWflz1Y9ss1j1 DkDRZrwDZtmzeissKsDrbBkSkYchAExiLTsBoqdPh5Cm72ugd+8RL7Pi3VDAjvmyeJFP Kp1BbaH7JRergg4v+OfT7QQBOZc+ja92LYsDU/kZVb4xcoAdNDGqMi6MnZsk/g5mRNl1 0FafSwpDOqhCW+UaSe7mKweza1X6ZL+d+vgM1zFKxinN/nd6z+2F0JVVzX0B3qoQASXo g12A== X-Gm-Message-State: AOAM533Mn9WXhhqfs/3zGur827CNyIN1msutxIPWMQorMvT8hXt4j4yg w8imc431fA7IFAaNycY0lYbpO05AV3o= X-Google-Smtp-Source: ABdhPJyZ5teUD8go1AUpm6lbH1+aea3QbtEBbzJqGfSWrA4K9Akjr678RU8UyiPAwbg07FOmjjLRoQ== X-Received: by 2002:a05:620a:882:: with SMTP id b2mr24218157qka.118.1607349298564; Mon, 07 Dec 2020 05:54:58 -0800 (PST) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH v2 5/9] domain_conf.c: move smartcard address check to validate callback Date: Mon, 7 Dec 2020 10:54:31 -0300 Message-Id: <20201207135435.884594-6-danielhb413@gmail.com> In-Reply-To: <20201207135435.884594-1-danielhb413@gmail.com> References: <20201207135435.884594-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.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" This check is not tied to XML parsing and can be moved to virDomainSmartcardDefValidate(). Signed-off-by: Daniel Henrique Barboza Reviewed-by: Michal Privoznik --- src/conf/domain_conf.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index e9bafd189f..230e89e786 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -6567,6 +6567,13 @@ static 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 @@ -13682,13 +13689,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 --=20 2.26.2 From nobody Sun Feb 8 05:09:33 2026 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=1607349318; cv=none; d=zohomail.com; s=zohoarc; b=Ma/1eUyqwyT5BooPh/lfw0cKur/TrMXTTLN4FkU53/eRllubGZrM1O3KPe4dz/R/w7heQ2IjiNeFY+TC2LbcwbwqwWvPmszuFKbCQowb2+5/zz3Sme6YHbJxqbVFSklErC0x337rJ47ekjiyYw6EcBd/eAOEmT7oXMWJLwfO3lA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607349318; 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=9LqT3t7tVjmiFvG4ttFJ0SFYL5+PW0BudKoWPdDtIpU=; b=HTCxuC7vekY999Fh9A2/rpNe0Vd0QOlWun7jj8Mp1u9HUovNfDQlZjhRVp0lSHqa35T9fMDx/PE/KJCOIVRiw3qx+oGVF4hJw8ZIE/BhqBeD3uavXdi1hYTAlJ0ixWFO27Y/89iQGNLqEelr83yEWj+qFCn8Pj5UGcjz/0WNayU= 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 1607349318763157.7643640278145; Mon, 7 Dec 2020 05:55: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-435-JFVJqdJvMvi1iZIXj2ZHww-1; Mon, 07 Dec 2020 08:55:13 -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 B3BBF1E7C2; Mon, 7 Dec 2020 13:55:06 +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 8D28D5C1A1; Mon, 7 Dec 2020 13:55:06 +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 4FC944EA6C; Mon, 7 Dec 2020 13:55:06 +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 0B7Dt3XA012984 for ; Mon, 7 Dec 2020 08:55:03 -0500 Received: by smtp.corp.redhat.com (Postfix) id 4C4C44405A; Mon, 7 Dec 2020 13:55:03 +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 467D463796 for ; Mon, 7 Dec 2020 13:55:03 +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 32AB6811E85 for ; Mon, 7 Dec 2020 13:55:03 +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-202-e9NtS89rPee0bKfXmrCAdA-1; Mon, 07 Dec 2020 08:55:01 -0500 Received: by mail-qk1-f193.google.com with SMTP id u4so12471084qkk.10 for ; Mon, 07 Dec 2020 05:55:01 -0800 (PST) Received: from rekt.redhat.com ([2804:431:c7c7:c1a:69c1:2b22:e880:fc49]) by smtp.gmail.com with ESMTPSA id n95sm12233701qte.43.2020.12.07.05.54.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Dec 2020 05:54:59 -0800 (PST) X-MC-Unique: JFVJqdJvMvi1iZIXj2ZHww-1 X-MC-Unique: e9NtS89rPee0bKfXmrCAdA-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=9LqT3t7tVjmiFvG4ttFJ0SFYL5+PW0BudKoWPdDtIpU=; b=Mqkej9fD++fDq432quGpvPPvAyY9bkflYHpSVBMkw2Jb9DUgaO1RYUGRVeot3sz25o BiLYmvG+UbdrMMP5ARJUXwnHco+8TjzyFbn4Ng5687T24iB1+VV4z6Lob48j4waKuTbG TyWaw3G+nhz4kEsl9l8V1SwAHaV2QBawFPQcw6tr9Nhq631LuvSVB4+SZQBlfDvIuceK /fNuMLHkWdZHjOjcKzxw28dSxqMpeh8rI1C0tA9GIyYefLnK+PICPrOQ7n8BPTBynqQ0 jDHCSbPXZE2Hx0322LyWZgrqoRTpuxmPaaqS985VS+pee1Pys5byARPDMw2nLyG5D6KT A/cA== X-Gm-Message-State: AOAM533IrAiWiwqrV7msGBxlQkzUTEpJPbaQEBnDMgKdbm6xneqcbO9A 5Iodc+fO3unWYQl20gqi/6vO3uBckc8= X-Google-Smtp-Source: ABdhPJwsvmsfOHALG2iDykuLqGx/t6NW4LH0sy0OXeuNWKQbis9HITWf9M1qAi7dLqdm0Cv3gtjZJQ== X-Received: by 2002:a05:620a:569:: with SMTP id p9mr23874954qkp.119.1607349300372; Mon, 07 Dec 2020 05:55:00 -0800 (PST) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH v2 6/9] domain_conf.c: move blkio path check to validate callback Date: Mon, 7 Dec 2020 10:54:32 -0300 Message-Id: <20201207135435.884594-7-danielhb413@gmail.com> In-Reply-To: <20201207135435.884594-1-danielhb413@gmail.com> References: <20201207135435.884594-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" Move this check to a new virDomainDefTunablesValidate(), which is called by virDomainDefValidateInternal(). Signed-off-by: Daniel Henrique Barboza Reviewed-by: Michal Privoznik --- src/conf/domain_conf.c | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 230e89e786..290930cc85 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -7397,6 +7397,27 @@ virDomainDefVideoValidate(const virDomainDef *def) } =20 =20 +static 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; +} + + static int virDomainDefValidateInternal(const virDomainDef *def, virDomainXMLOptionPtr xmlopt) @@ -7448,6 +7469,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 @@ -21342,7 +21366,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 */ @@ -21363,15 +21387,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 --=20 2.26.2 From nobody Sun Feb 8 05:09:33 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1607349326; cv=none; d=zohomail.com; s=zohoarc; b=Tp6kQVbhNeWNuQgpWa7YRJmdtfioS/1o6WiPc+2MxH3sbj2vJo1QGwNhAQZTp3VqQv2cec87baP9Qn4qlhLn3xI7eNOor8WxCgMn7pgERhvDpOPNEmcGPSSwvK3imbUYG3DSpM6YktDerx8agtfVtJVzr589jNBgSCW9nSlFoAU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607349326; 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=94GFwhTs4IPi8FrzDiuAqalKawwum6lQk08HEnGF4xs=; b=mcfegcjK6bizx04y2fdO0WzatXx+lk9/lnStRRvBHTA4gLIna9R8gvypgkZxTfa/4/eM4TtHt88qTQ+UsS0YBsFo3e7KAx6UXy95BaE0TxFnqhOSpPKj9YqyxInxpqN0B2cCoJsjRSdi3+W1XejY8bw1kW5SEG5v4XRospQeSrs= 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 1607349326115644.163594745971; Mon, 7 Dec 2020 05:55: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-510-aBsRM-CqP9WjWS959KIy4A-1; Mon, 07 Dec 2020 08:55:22 -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 8C2078015B1; Mon, 7 Dec 2020 13:55:16 +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 5DB2C10016F5; Mon, 7 Dec 2020 13:55: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 E03DE1809CA5; Mon, 7 Dec 2020 13:55:15 +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 0B7Dt790013015 for ; Mon, 7 Dec 2020 08:55:07 -0500 Received: by smtp.corp.redhat.com (Postfix) id 411F94405A; Mon, 7 Dec 2020 13:55:07 +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 37F5E6B435 for ; Mon, 7 Dec 2020 13:55:04 +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 CCAFF800140 for ; Mon, 7 Dec 2020 13:55:04 +0000 (UTC) Received: from mail-qv1-f50.google.com (mail-qv1-f50.google.com [209.85.219.50]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-592-iBp3v8YKOKSOwfE3BmmBcQ-1; Mon, 07 Dec 2020 08:55:02 -0500 Received: by mail-qv1-f50.google.com with SMTP id a13so1406793qvv.0 for ; Mon, 07 Dec 2020 05:55:02 -0800 (PST) Received: from rekt.redhat.com ([2804:431:c7c7:c1a:69c1:2b22:e880:fc49]) by smtp.gmail.com with ESMTPSA id n95sm12233701qte.43.2020.12.07.05.55.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Dec 2020 05:55:01 -0800 (PST) X-MC-Unique: aBsRM-CqP9WjWS959KIy4A-1 X-MC-Unique: iBp3v8YKOKSOwfE3BmmBcQ-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=94GFwhTs4IPi8FrzDiuAqalKawwum6lQk08HEnGF4xs=; b=rJxzxIlrWs0Re5bVQStrrGVc9iKYcKn/kdlmXCLv6QP/gIO7/znr3UzqouvTYIN3GE 1oaYCqqLkoFulOTd2vsAwExp1j+vqNUXmNyTfcoOxYQQoyWWHphnOYCVXjLyVk7ppqq2 DRzyo7loQJvJdWjvYZ6tAKjkZfcWDqiJx+Fe3FUfB9oZRdSOZ+XwyqLeQmsi5KIlPG2v CInkBnjQTT4DtXzA4VxgwZ4hjifeSmxi+qB67dkQVcJBTMKRmHEQYs6eDyW15kXbKpqC VgB3V09K3RS0kfaFR0aOeXLBmjiS+H8R5RdYqMIt+luIQSae0BzooQj8/vBHhyS4tjx8 3lYw== X-Gm-Message-State: AOAM531zvrWEHIJb7PRM+ELg7yP/zdy+109qhzgRQ9JfeSzOUEsk/dBX /M/jZhcbJMbpb7nOwFIRHdjHSiqyzrM= X-Google-Smtp-Source: ABdhPJyMn8+ftP9J1pcI9LHajsLziRz7zIDEHmbFct3l0p6c+qYuvh54pGIFxxgZ/v5a33cjXzV9mg== X-Received: by 2002:ad4:476c:: with SMTP id d12mr8602813qvx.20.1607349302133; Mon, 07 Dec 2020 05:55:02 -0800 (PST) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH v2 7/9] domain_conf.c: move virDomainPCIControllerOpts checks to validate callback Date: Mon, 7 Dec 2020 10:54:33 -0300 Message-Id: <20201207135435.884594-8-danielhb413@gmail.com> In-Reply-To: <20201207135435.884594-1-danielhb413@gmail.com> References: <20201207135435.884594-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.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" 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(). Signed-off-by: Daniel Henrique Barboza Reviewed-by: Michal Privoznik --- src/conf/domain_conf.c | 89 ++++++++++--------- .../pseries-default-phb-numa-node.err | 2 +- tests/qemuxml2argvtest.c | 6 +- 3 files changed, 55 insertions(+), 42 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 290930cc85..8ede532e2a 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -6550,6 +6550,53 @@ virDomainControllerDefValidate(const virDomainContro= llerDef *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; } @@ -11389,14 +11436,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, @@ -11406,14 +11445,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, @@ -11423,14 +11454,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, @@ -11440,14 +11463,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, @@ -11459,15 +11474,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/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 Sun Feb 8 05:09:33 2026 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=1607349326; cv=none; d=zohomail.com; s=zohoarc; b=cCbvmOqY38IG+rB6zgz1Qr8P3d8jGU1nY52U+iYnsCA2lSHEqJMJkoSeijdHp8T7Dpy/HTTKlR0stz/U5IQLiysEVTWUNuKHeG/qf2itMk2bgW2L0+/HYxkvqCB3qu4QB7nALDEAxymwm4xL9u5puDXjM2fGJ0lSuyydEjP/8NM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607349326; 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=acdZu16D5nehWPDC4M34CPl9kUCfYSJ8H8ihgBK1ZR8=; b=eQvLb/AAQTBeRdelqj7z4UEQKpUgTuVdiuYHNnDhTCdp0wAT0SqyySgNnzlbGjGvvezSQgI1xaKQ5AkPdFpSNnV5+7V4rS+BabIGp6YCHeRFC8WOJ8BFoZnQsIeNoNz4CnWqUpgFZ3a5QX2sCuwi1mZsxDD1AxZHMlNC94KcQ6s= 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 1607349326150758.7018206657984; Mon, 7 Dec 2020 05:55: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-247-hywDMDyiOd6PIyVLo-cnqA-1; Mon, 07 Dec 2020 08:55:22 -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 8BB28180A094; Mon, 7 Dec 2020 13:55:16 +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 612875D9DE; Mon, 7 Dec 2020 13:55: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 E8CE11809CA6; Mon, 7 Dec 2020 13:55:15 +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 0B7Dt9hl013026 for ; Mon, 7 Dec 2020 08:55:09 -0500 Received: by smtp.corp.redhat.com (Postfix) id 4691B1111447; Mon, 7 Dec 2020 13:55:09 +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 431F31111445 for ; Mon, 7 Dec 2020 13:55:07 +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 F3BC185828B for ; Mon, 7 Dec 2020 13:55:06 +0000 (UTC) Received: from mail-qt1-f175.google.com (mail-qt1-f175.google.com [209.85.160.175]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-368-HT6WA10qPOWej-U9m0vmCA-1; Mon, 07 Dec 2020 08:55:04 -0500 Received: by mail-qt1-f175.google.com with SMTP id y15so1804335qtv.5 for ; Mon, 07 Dec 2020 05:55:04 -0800 (PST) Received: from rekt.redhat.com ([2804:431:c7c7:c1a:69c1:2b22:e880:fc49]) by smtp.gmail.com with ESMTPSA id n95sm12233701qte.43.2020.12.07.05.55.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Dec 2020 05:55:03 -0800 (PST) X-MC-Unique: hywDMDyiOd6PIyVLo-cnqA-1 X-MC-Unique: HT6WA10qPOWej-U9m0vmCA-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=acdZu16D5nehWPDC4M34CPl9kUCfYSJ8H8ihgBK1ZR8=; b=Ta+KNV5/26dyy3M2Iiuf3kj2oF5V0y2bfHYcnzvJMzlHo8L3HY9HydI8MZl3bPLPGw b/ahT7SHULoMRyk8ckeUz7VdM3QTUKHb2Ch+PWAf6d9a/jV39xebe4PWkvKbHkXSFPMj EiCfWiNRdaxf7IzzCKzipAWWGZpOxv3ZhZmR8wznUvce/cfbC3ocF30Koe5tnD/195YH Ct7hYT38bUNEeaZIT6GkiJWVypcniOH9zoM5mXyZI1vZJtVGv5CTJ4gtF0ptdJTl1c5f uOcZ2OBFQ7jXFd64HGtzVqI0RjSZdDSHVP5sLoXXk7TTuN/O0C/mHOej8nJcFI5ZJO++ gl+A== X-Gm-Message-State: AOAM530h5tfck6Jbl+YuFj847NZoTG9NH4hxcg+2f0hk4FHwQWSgJ9xp m51JPQLoMxN2WrAdwGk5pFZr8StlaYg= X-Google-Smtp-Source: ABdhPJy8lIEcvYXVnw9Y++/W1izT7W5QeyDIEXzgHKnIDik+VVD0VUCpnxO0+wIlkEsTPhFnbD2hKA== X-Received: by 2002:ac8:6f59:: with SMTP id n25mr11432641qtv.304.1607349303977; Mon, 07 Dec 2020 05:55:03 -0800 (PST) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH v2 8/9] domain_conf.c: move pci-root/pcie-root address check to validateCB Date: Mon, 7 Dec 2020 10:54:34 -0300 Message-Id: <20201207135435.884594-9-danielhb413@gmail.com> In-Reply-To: <20201207135435.884594-1-danielhb413@gmail.com> References: <20201207135435.884594-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" Signed-off-by: Daniel Henrique Barboza Reviewed-by: Michal Privoznik --- src/conf/domain_conf.c | 16 ++++++++++------ tests/qemuxml2argvdata/pci-root-address.err | 2 +- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 8ede532e2a..11711ba05d 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -6524,6 +6524,16 @@ virDomainControllerDefValidate(const virDomainContro= llerDef *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"), @@ -11392,12 +11402,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/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 Sun Feb 8 05:09:33 2026 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=1607349329; cv=none; d=zohomail.com; s=zohoarc; b=kAzWNVWYrpWaDV1x0w7eom1NhuA5KLvXh0kgnSsaM65DFMKnywLA4kXRyCuye6Y0YtKcep/EkMMMuGMhFr9UaNyIk7j52pRg5IwF7tZYpldDxDDyvbbs72imVd/lbRAjDJvPXXkzp+rnoFM6SQOWihwREOGuMgLPMNoXtSbm2es= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607349329; 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=adCTGfKWw+cEAbI4cBNejmmL8rDzmd9xRTxmyBshCUk=; b=LVfNT0PxFDx3yS7s3zbTmnHIabPqhUc7km/bq9NJz2rw7U8xIjuzaIAw4Youoy2PjiLnzzmDSSI4QJsX92nAzOtKCGn+5/Sr0zRCCjSCvD00bYE5n4QhmKvVKxNrGeLKA1xrSKWewcjvSGbjMaelT44AgFPYQ/aSFWyAYc9NVPY= 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 1607349329981377.8767180773708; Mon, 7 Dec 2020 05:55:29 -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-563-6ENkXhw3OLW2k0bfMa4SwA-1; Mon, 07 Dec 2020 08:55:26 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A33181E7CD; Mon, 7 Dec 2020 13:55:19 +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 716C419C59; Mon, 7 Dec 2020 13:55:19 +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 D867E5002D; Mon, 7 Dec 2020 13:55:18 +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 0B7DtEJT013044 for ; Mon, 7 Dec 2020 08:55:14 -0500 Received: by smtp.corp.redhat.com (Postfix) id 9A55264021; Mon, 7 Dec 2020 13:55:14 +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 9438A4405A for ; Mon, 7 Dec 2020 13:55:11 +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 86EE0811E76 for ; Mon, 7 Dec 2020 13:55:11 +0000 (UTC) Received: from mail-qv1-f42.google.com (mail-qv1-f42.google.com [209.85.219.42]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-486-l_8lnWyCMGG-aq_PtGTuzQ-1; Mon, 07 Dec 2020 08:55:06 -0500 Received: by mail-qv1-f42.google.com with SMTP id l7so1134612qvt.4 for ; Mon, 07 Dec 2020 05:55:06 -0800 (PST) Received: from rekt.redhat.com ([2804:431:c7c7:c1a:69c1:2b22:e880:fc49]) by smtp.gmail.com with ESMTPSA id n95sm12233701qte.43.2020.12.07.05.55.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Dec 2020 05:55:05 -0800 (PST) X-MC-Unique: 6ENkXhw3OLW2k0bfMa4SwA-1 X-MC-Unique: l_8lnWyCMGG-aq_PtGTuzQ-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=adCTGfKWw+cEAbI4cBNejmmL8rDzmd9xRTxmyBshCUk=; b=EBH7F0kBImf4Ypy2iT77/bRzdSpSuvsLRWIFck0h+iWEHVkS18XaXIMgPHfTmx4yqc xK5G+O8OXQyxeTMST1sJasQ1Y9r84JyX/O2F1f9n8uZB1vCuuKeux6LDA8dnm3UpeJg2 7cYYMwDXDqUGuSeVJXBfq4XNc8mfW9eyQWk2O7Wvcvva72StX0TX6wfP2bdqqm3JKD2f NimkjLaS/ZnYfThH/WA6NqNsPKQSWNzmciNsEOAfMCftkYOcXeWn4MZlTEX+Nz+9JcHl 9Lq+y428gXAj3I0l1YpO9NdVhM8GQhc/8HvhlQr+a1qhRkHFX/famvdYYO7GBo9exSki 9MTA== X-Gm-Message-State: AOAM530gFsL4oF4vc6wDEuoKq65R0dmwSxBNzIDnWRxiXxwePjAkxBQ9 32enmd3Eba+edgaNrJAuzSbWTGlMpnU= X-Google-Smtp-Source: ABdhPJz5XvzemvO2eqxJfq4AbZDMvIYrH1o0kX1MrbO5DtKrvLM0m04NCWV+LdI5TewyBTyMVEKOew== X-Received: by 2002:a0c:a181:: with SMTP id e1mr21233026qva.53.1607349305762; Mon, 07 Dec 2020 05:55:05 -0800 (PST) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH v2 9/9] domain_conf.c: move idmapEntry checks to validate callback Date: Mon, 7 Dec 2020 10:54:35 -0300 Message-Id: <20201207135435.884594-10-danielhb413@gmail.com> In-Reply-To: <20201207135435.884594-1-danielhb413@gmail.com> References: <20201207135435.884594-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.84 on 10.5.11.23 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(). Signed-off-by: Daniel Henrique Barboza Reviewed-by: Michal Privoznik --- src/conf/domain_conf.c | 42 ++++++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 11711ba05d..471de235a1 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -7475,6 +7475,29 @@ virDomainDefTunablesValidate(const virDomainDef *def) } =20 =20 +static 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; +} + + static int virDomainDefValidateInternal(const virDomainDef *def, virDomainXMLOptionPtr xmlopt) @@ -7529,6 +7552,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 @@ -19045,15 +19071,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 @@ -22543,13 +22560,6 @@ virDomainDefParseXML(xmlDocPtr xml, } VIR_FREE(nodes); =20 - if ((def->idmap.uidmap && !def->idmap.gidmap) || - (!def->idmap.uidmap && def->idmap.gidmap)) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("uid and gid should be mapped both")); - goto error; - } - if ((n =3D virXPathNodeSet("./sysinfo", ctxt, &nodes)) < 0) goto error; =20 --=20 2.26.2