From nobody Sun Feb 8 18:15:24 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=1606245683; cv=none; d=zohomail.com; s=zohoarc; b=eL5MsxqQYUxxWUgn1heCt1kuYhEomfxPi8UIyYKIyqfjJiiKBQIzCpFjJGATGw5iOLW9EF0ef3q2iv20B1FKL1naNQ2TG5gS4qHPkEmZLQHxKkloibDtRagBQZ4ST2AwCUa9kQC+YmfWnopabuVy+9Fs1qmBDLvbAY08nCGgQrY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1606245683; 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=GlNd2uEebkxsCFiHjwL97uhR79JLwnPdY/2vt5LQPvQ=; b=nylVvSsv+XD/wxRDGOWGWZyUqFgAPBb8RCDXMGy9WhiBmVEJ+V3PlswBpcNFkBCqDY64pL6A5FnScCJHZApDpLoxir5AgC+QLfd2zkWRSzt/8ueGrukVlsHSaZiCIRNLaWZZJqL3zTQMweSisKWghJgGKTYrfJJEaE5dDB6VDBo= 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 1606245683174128.86021792539793; Tue, 24 Nov 2020 11:21:23 -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-357-1VC_u2cdMBCP89TEHo4A9w-1; Tue, 24 Nov 2020 14:21:18 -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 2408F81C478; Tue, 24 Nov 2020 19:21:09 +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 F19655D71B; Tue, 24 Nov 2020 19:21:08 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id B934B1809CA6; Tue, 24 Nov 2020 19:21:08 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0AOJL6dx004102 for ; Tue, 24 Nov 2020 14:21:06 -0500 Received: by smtp.corp.redhat.com (Postfix) id E8B3E2166B2C; Tue, 24 Nov 2020 19:21:05 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast06.extmail.prod.ext.rdu2.redhat.com [10.11.55.22]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E345D2166B2A for ; Tue, 24 Nov 2020 19:21:03 +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 BAFDE186E128 for ; Tue, 24 Nov 2020 19:21:03 +0000 (UTC) Received: from mail-qt1-f170.google.com (mail-qt1-f170.google.com [209.85.160.170]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-273-X-CJqYCkOE6XQDVai4LKAA-1; Tue, 24 Nov 2020 14:20:59 -0500 Received: by mail-qt1-f170.google.com with SMTP id e60so7723912qtd.3 for ; Tue, 24 Nov 2020 11:20:58 -0800 (PST) Received: from rekt.redhat.com ([2804:431:c7c7:d88a:482:7c39:5cca:96f6]) by smtp.gmail.com with ESMTPSA id l79sm88837qke.1.2020.11.24.11.20.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Nov 2020 11:20:57 -0800 (PST) X-MC-Unique: 1VC_u2cdMBCP89TEHo4A9w-1 X-MC-Unique: X-CJqYCkOE6XQDVai4LKAA-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=GlNd2uEebkxsCFiHjwL97uhR79JLwnPdY/2vt5LQPvQ=; b=oyEI9PZ14b7eW7l9h25wMRpSvw/PqVjlCJURVI2okFkm0mzqNnbxwCcoWVR0QwNyZu EAkd/cHHkoSq7ZlaKgx0DB4x3qjU6nhUolnO/dnJjfdJs8mMaWNjZXh6tvQqTP5xqZlq nSSHBix+TfIcsnpLW8QfSjtqDUAFs5uJbApEJmxVteoPLBN9S+wnvD94G70EoTGvcXp2 7mBb8rIR07rB1/9gjl9Kfmc8nFHgaaGQnvfRxGLjwEdcJs30k1rXpPwe1FcJQORnd+2K yXtyvJ5Tm4v7ChdN7IRAEMpjttUuq6TvZhbrDmUvdztWX6iXSBrFMBHsE0G6vCTHbUH8 qvQQ== X-Gm-Message-State: AOAM531tGuMxkqQQNiYm8G8hpW2p0JSJlEhnF1PBthAsDUnf4HafHzIP tz8rvjn+uqfrqPHvGPVxyJcWrdciyBo= X-Google-Smtp-Source: ABdhPJxj/icFlL+rZvxMFWLwnRrlMcBbyf0MUuu1Abd+dnuHt8pRI0IT+EwHfnofUEZpjBjLs4sxfg== X-Received: by 2002:ac8:548e:: with SMTP id h14mr5955577qtq.326.1606245658167; Tue, 24 Nov 2020 11:20:58 -0800 (PST) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH 04/21] domain_conf.c: move boot related timeouts check to post parse Date: Tue, 24 Nov 2020 16:20:18 -0300 Message-Id: <20201124192035.2343063-5-danielhb413@gmail.com> In-Reply-To: <20201124192035.2343063-1-danielhb413@gmail.com> References: <20201124192035.2343063-1-danielhb413@gmail.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-loop: libvir-list@redhat.com Cc: Daniel Henrique Barboza X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.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" This patch creates a new function, virDomainDefBootPostParse(), to host the validation of boot menu timeout and rebootTimeout to post 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 +++++++++++++++++++++++++++++++---------- 1 file changed, 31 insertions(+), 10 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index f0300b870d..c2e5ed5680 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -5847,6 +5847,28 @@ virDomainDefBootOrderPostParse(virDomainDefPtr def) } =20 =20 +static int +virDomainDefBootPostParse(virDomainDefPtr 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 virDomainDefPostParseVideo(virDomainDefPtr def, void *opaque) @@ -5917,6 +5939,9 @@ virDomainDefPostParseCommon(virDomainDefPtr def, if (virDomainDefRejectDuplicatePanics(def) < 0) return -1; =20 + if (virDomainDefBootPostParse(def) < 0) + return -1; + if (def->os.type =3D=3D VIR_DOMAIN_OSTYPE_HVM && !(data->xmlopt->config.features & VIR_DOMAIN_DEF_FEATURE_NO_BOOT_O= RDER) && virDomainDefBootOrderPostParse(def) < 0) @@ -18935,11 +18960,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; @@ -18960,11 +18983,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; --=20 2.26.2