From nobody Sun Feb 8 07:52:49 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=1606245689; cv=none; d=zohomail.com; s=zohoarc; b=QHLlraO/nsxrKBK7g41DLQmipTPRtkDuG5/SiMmGDIinkBfeXudGRZ2lKgKj4hvlGi7sc0lkhlXxosxrKSyWoeuCqgB2+JmOQTN4ksLn1wuJEokJUf0jGpa+nLN1EYyZFlQFBdwz7y9rGQEGfNkoFYKGzMwGtchF92CDx/2sOUA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1606245689; 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=x+BWx2T3M9uwPeY3Gea1MQjFVVCd+XbiBbEDVc18HIE=; b=O48MZUnvt0gPyvKiz5A836MPtR1vKeL7hs392wIluA+QCo1pXyap5coySAcLowe1C+nZC0T3nPlAp9cdn6YbFy9Wo+jIPWwwyBQjwpK5DKAc85q03+USf8STKUdDiuLKPb1OAVMxtSO4Pf3ELsiPlwswq0d6X1KEdGf+3+xlIfM= 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 1606245689920641.4819553108517; Tue, 24 Nov 2020 11:21: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-82-XzSZaRg5OMeNM-hOgxTDgg-1; Tue, 24 Nov 2020 14:21:26 -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 58B6F87309F; Tue, 24 Nov 2020 19:21:20 +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 3263810016FB; Tue, 24 Nov 2020 19:21:20 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id F1B9C1809CAF; Tue, 24 Nov 2020 19:21: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 0AOJLGVk004181 for ; Tue, 24 Nov 2020 14:21:16 -0500 Received: by smtp.corp.redhat.com (Postfix) id 40B279459C; Tue, 24 Nov 2020 19:21:16 +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 3AC959458A for ; Tue, 24 Nov 2020 19:21:16 +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 2788B80088F for ; Tue, 24 Nov 2020 19:21:16 +0000 (UTC) Received: from mail-qk1-f177.google.com (mail-qk1-f177.google.com [209.85.222.177]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-516-W_QauplUOASVQ7DummD9uw-1; Tue, 24 Nov 2020 14:21:12 -0500 Received: by mail-qk1-f177.google.com with SMTP id u4so22109195qkk.10 for ; Tue, 24 Nov 2020 11:21:12 -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.21.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Nov 2020 11:21:11 -0800 (PST) X-MC-Unique: XzSZaRg5OMeNM-hOgxTDgg-1 X-MC-Unique: W_QauplUOASVQ7DummD9uw-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=x+BWx2T3M9uwPeY3Gea1MQjFVVCd+XbiBbEDVc18HIE=; b=KHErytLugj6Duzrl5TPyJ4GVfIV42O3Oeksf2IZ8bazp6Ke0pqJyQYuAHev0Qhblec LcqxUABQUOC9tJUa8TBeW+p+pydgnAu4jT3b2mDw+KqGfl+xX53EJAT9zq44eLiQnTVk VSXllXTrv1BZa8hCLh87eXJmlVDSpuC/Q8jNLJN9EqL5CfIai8hCvxNF98wylCotWxtw qfyTNqmmjs3Nd53mex5rB3Tcf92al7b7jhM/xrj7aDlhhCSCecO5d9ET6ErEsfdm3VKt JNgLUT4c8NA62TB5h1rYwXrC8X8eZ1mAgov8LhRF9Lhkn9d57N+nWmCigkNOwsLj8Ofy nylw== X-Gm-Message-State: AOAM531K3XHblfFTpeXruXfQgrXkERC7STrHrOR0o4zZg7BME5o9kPqF E01yAiKMRlOdi8ibJH+DjoveFog+UTw= X-Google-Smtp-Source: ABdhPJy/LB2fggzklavYizxrGwRgHGmzT2Hjd8vSWGPEEVT+f1rN2GLnONbOwhq2j+VsK49QlpFqSQ== X-Received: by 2002:a37:a694:: with SMTP id p142mr6191437qke.467.1606245671990; Tue, 24 Nov 2020 11:21:11 -0800 (PST) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH 11/21] domain_conf.c: move vendor, product and tray checks to post parse Date: Tue, 24 Nov 2020 16:20:25 -0300 Message-Id: <20201124192035.2343063-12-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.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" The 'tray' check isn't a XML parse specific code and can be pushed to post, in virDomainDiskDefPostParse(). 'vendor' and 'product' string sizes are already checked by the domaincommon.rng schema, but can be of use in post parse time since not all scenarios will go through the XML parsing. Signed-off-by: Daniel Henrique Barboza --- 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 e21f353595..6623abad73 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -5253,6 +5253,9 @@ virDomainDiskExpandGroupIoTune(virDomainDiskDefPtr di= sk, } =20 =20 +#define VENDOR_LEN 8 +#define PRODUCT_LEN 16 + static int virDomainDiskDefPostParse(virDomainDiskDefPtr disk, const virDomainDef *def, @@ -5277,6 +5280,28 @@ virDomainDiskDefPostParse(virDomainDiskDefPtr disk, } } =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; + } + if (disk->src->type =3D=3D VIR_STORAGE_TYPE_NETWORK && disk->src->protocol =3D=3D VIR_STORAGE_NET_PROTOCOL_ISCSI) { virDomainPostParseCheckISCSIPath(&disk->src->path); @@ -10513,9 +10538,6 @@ virDomainDiskDefParsePrivateData(xmlXPathContextPtr= ctxt, } =20 =20 -#define VENDOR_LEN 8 -#define PRODUCT_LEN 16 - static virDomainDiskDefPtr virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt, xmlNodePtr node, @@ -10690,12 +10712,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")); @@ -10706,12 +10722,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")); @@ -10842,13 +10852,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