From nobody Sun Feb 8 11:45:43 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=1607466078; cv=none; d=zohomail.com; s=zohoarc; b=JEFvm0VuqhTlnCeHa//3G37xQ0450J9SwdkXxebD+LVcf2TnFdl1TvSGxYIPEW2vCUibaM9R173a4aEuGr0rSey8dty5RqIyR3+FrtVnRtxIy1A1UXE0HKBJD+rt9GPoW1uijqtcqq8OUKGs7Ypo4uSemIh3U5Nu8BL3/NLxqVQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607466078; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=XMkwRN0rStJpoZprwQ2tleZ6A0jl5VCWIMcHqAvVj1Y=; b=S6hWQj/nIylPdV985Nym1aL3ZOsO4b7gm/nriyFYdC2+sqUJeeHu3WTdU07pxT6yHj4Wfn8pX+JiziVt2V3K3AeOivYvqEhd9zknwtFrTUoT5lmICa/I33SY7lzVwcE6/SCacbdKHlvbs+f2X9nWAUzYuD55xfKRMYIo4b3nk3o= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1607466078631586.287878139724; Tue, 8 Dec 2020 14:21:18 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-132-Gm1JKoG1MUqbNQNepvx0jA-1; Tue, 08 Dec 2020 17:21:15 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2F19B100F345; Tue, 8 Dec 2020 22:21:09 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 08A23100AE2F; Tue, 8 Dec 2020 22:21:09 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id CBFC05002D; Tue, 8 Dec 2020 22:21:08 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0B8ML6T1017295 for ; Tue, 8 Dec 2020 17:21:06 -0500 Received: by smtp.corp.redhat.com (Postfix) id 4E9EB2166B27; Tue, 8 Dec 2020 22:21:06 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast02.extmail.prod.ext.rdu2.redhat.com [10.11.55.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 49BA72166B29 for ; Tue, 8 Dec 2020 22:21:05 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CE3DD80122E for ; Tue, 8 Dec 2020 22:21:05 +0000 (UTC) Received: from mail-qt1-f176.google.com (mail-qt1-f176.google.com [209.85.160.176]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-381-TZWg5nQpMrCKzVXxGYXzDA-1; Tue, 08 Dec 2020 17:21:02 -0500 Received: by mail-qt1-f176.google.com with SMTP id l7so13142814qtp.8; Tue, 08 Dec 2020 14:21:02 -0800 (PST) Received: from rekt.redhat.com ([2804:431:c7c7:c1a:69c1:2b22:e880:fc49]) by smtp.gmail.com with ESMTPSA id c14sm75057qtg.85.2020.12.08.14.21.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Dec 2020 14:21:01 -0800 (PST) X-MC-Unique: Gm1JKoG1MUqbNQNepvx0jA-1 X-MC-Unique: TZWg5nQpMrCKzVXxGYXzDA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=XMkwRN0rStJpoZprwQ2tleZ6A0jl5VCWIMcHqAvVj1Y=; b=kV7Dfc/HeoRujKQp+rgy0fLbe1Kh9NsoCR7mjWkrrn473uRNBk6RLqOG1CBDMr74QP 4FXzEWn2WRKRz/7GbFuWio/djwhn8oKCnYqoQY97V917nmOB9ON/PIqEehQ7eeRv9YlA cUJ6kCYp6QpW1gw/tDwXOJCEPAUBYUUt2Zxu104bJCF5YmGvaNejCojU4BrLcZVvhEX9 vRS994k62ngUIJQK6lIyULzNRJk5jNohKuOIFAUh4Hax19vtF2u+uCGSF9ltT/zyKv33 jNc52pjJkSl6zKWurZgO+dCm+XfG6k31K6BCX7N1FyS7R5fOFqhhfCNfM0RjYTPkADTz nKZw== X-Gm-Message-State: AOAM5308+c/wSQjN+F8jM7MFSeic6eX1hnCv9zeXWMeBSGM/G3hnjNh9 lGYt/b/rMI375O/z5LFm2icEmDhvGIw= X-Google-Smtp-Source: ABdhPJwHzf4kp1uGS9tvo+HuA7F6M+Q2FMlsg50kjVD3aEQcftSWIq1BKWLdU5c85ZLerukX6zxE6Q== X-Received: by 2002:ac8:3656:: with SMTP id n22mr250020qtb.242.1607466061752; Tue, 08 Dec 2020 14:21:01 -0800 (PST) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH v3 06/14] domain_conf: move vendor, product and tray checks to domain_validate.c Date: Tue, 8 Dec 2020 19:20:22 -0300 Message-Id: <20201208222030.1302229-7-danielhb413@gmail.com> In-Reply-To: <20201208222030.1302229-1-danielhb413@gmail.com> References: <20201208222030.1302229-1-danielhb413@gmail.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-loop: libvir-list@redhat.com Cc: Michal Privoznik , Daniel Henrique Barboza X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The 'tray' check isn't a XML parse specific code and can be pushed to the validate callback, in virDomainDiskDefValidate(). 'vendor' and 'product' string sizes are already checked by the domaincommon.rng schema, but can be of use in the validate callback since not all scenarios will go through the XML parsing. Reviewed-by: Michal Privoznik Signed-off-by: Daniel Henrique Barboza --- src/conf/domain_conf.c | 22 ---------------------- src/conf/domain_validate.c | 25 +++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 22 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 5aeb75ce59..220bb8cdcf 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -10222,9 +10222,6 @@ virDomainDiskDefParsePrivateData(xmlXPathContextPtr= ctxt, } =20 =20 -#define VENDOR_LEN 8 -#define PRODUCT_LEN 16 - static virDomainDiskDefPtr virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt, xmlNodePtr node, @@ -10399,12 +10396,6 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xml= opt, if (!(vendor =3D virXMLNodeContentString(cur))) return NULL; =20 - if (strlen(vendor) > VENDOR_LEN) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("disk vendor is more than 8 characters")); - return NULL; - } - if (!virStringIsPrintable(vendor)) { virReportError(VIR_ERR_XML_ERROR, "%s", _("disk vendor is not printable string")); @@ -10415,12 +10406,6 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xml= opt, if (!(product =3D virXMLNodeContentString(cur))) return NULL; =20 - if (strlen(product) > PRODUCT_LEN) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("disk product is more than 16 characters"= )); - return NULL; - } - if (!virStringIsPrintable(product)) { virReportError(VIR_ERR_XML_ERROR, "%s", _("disk product is not printable string")); @@ -10551,13 +10536,6 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xml= opt, _("unknown disk tray status '%s'"), tray); return NULL; } - - if (def->device !=3D VIR_DOMAIN_DISK_DEVICE_FLOPPY && - def->device !=3D VIR_DOMAIN_DISK_DEVICE_CDROM) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("tray is only valid for cdrom and floppy")); - return NULL; - } } =20 if (removable) { diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c index da36bef31a..bc5ca3f668 100644 --- a/src/conf/domain_validate.c +++ b/src/conf/domain_validate.c @@ -225,6 +225,9 @@ virSecurityDeviceLabelDefValidateXML(virSecurityDeviceL= abelDefPtr *seclabels, } =20 =20 +#define VENDOR_LEN 8 +#define PRODUCT_LEN 16 + int virDomainDiskDefValidate(const virDomainDef *def, const virDomainDiskDef *disk) @@ -301,5 +304,27 @@ virDomainDiskDefValidate(const virDomainDef *def, return -1; } =20 + if (disk->tray_status && + disk->device !=3D VIR_DOMAIN_DISK_DEVICE_FLOPPY && + disk->device !=3D VIR_DOMAIN_DISK_DEVICE_CDROM) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("tray is only valid for cdrom and floppy")); + return -1; + } + + if (disk->vendor && strlen(disk->vendor) > VENDOR_LEN) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("disk vendor is more than %d characters"), + VENDOR_LEN); + return -1; + } + + if (disk->product && strlen(disk->product) > PRODUCT_LEN) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("disk product is more than %d characters"), + PRODUCT_LEN); + return -1; + } + return 0; } --=20 2.26.2