From nobody Sun Feb 8 03:57:59 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 --- 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