From nobody Mon Feb 9 14:00:51 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; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1618587576; cv=none; d=zohomail.com; s=zohoarc; b=ODT8zi9rTCOeNzDIOCv88yEtzJv5ptA+2rvsNZxji4MO+6TwB0jZbffH+nFd7as+ECtcmzEZbqZuBpgkMeCzAoaWbYa0URgpPzz4NcOp2MYK4Hbd8e5BEdE6JGBN543HbA/5/JtdEgXAH0En4py5t90RYNSPcQKIa5O7Ak7If08= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618587576; h=Content-Type:Content-Transfer-Encoding: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=KE5Jk9w+iHVMwpUnLHQ+GxcgySWqpyycpr9y2NbXT6M=; b=i3gP05CzVlopyag2rVkNE77DnQ0gyaddWG1MjpOW1/4P9vj63MoecCzbbc1xSXLqRsO+G6lu5GIQwFXDgj7DeJobFnAfj2+Jo9YzFPT3NF50FDBGq2ghA3wsysrfuRviXNOIQ0GUyA+YDcdDVRNPhcrUxBYKOm6u1YOhVlgWDYo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass 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 1618587576531937.4421429345947; Fri, 16 Apr 2021 08:39:36 -0700 (PDT) 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-213-GA0aErGfOAOZ0jxMz5HKsg-1; Fri, 16 Apr 2021 11:39:33 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4F295814256; Fri, 16 Apr 2021 15:39:27 +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 2C10D37DD; Fri, 16 Apr 2021 15:39:27 +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 E9FCD1806D18; Fri, 16 Apr 2021 15:39:26 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 13GFZ1HY009327 for ; Fri, 16 Apr 2021 11:35:01 -0400 Received: by smtp.corp.redhat.com (Postfix) id 03D6C5C3DF; Fri, 16 Apr 2021 15:35:01 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5B3125C257 for ; Fri, 16 Apr 2021 15:35:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618587575; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=KE5Jk9w+iHVMwpUnLHQ+GxcgySWqpyycpr9y2NbXT6M=; b=SP9mdyQtrW7BxJBrWHImJ8q1K7SsM0/RgyZkvKAD9QD5kfh5kZraS+UGNfxbnmhTcX4fI0 CpdGgh9WgOIo6O28Q9EDW57IhJ9QeQ3A4ZtqlCslchuCyN4buA4HF9EjNgD55V0bDtkTPa bVDVuLeGdt0XBaXh2Eq7bi/wxODrFBw= X-MC-Unique: GA0aErGfOAOZ0jxMz5HKsg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 11/25] conf: Move disk vendor and product pritability check to domain_validate Date: Fri, 16 Apr 2021 17:34:29 +0200 Message-Id: <1eaf6a90d33e2d61b88ffaa5410d333f5394cc87.1618587222.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com 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.12 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 X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa --- src/conf/domain_conf.c | 12 ------------ src/conf/domain_validate.c | 37 +++++++++++++++++++++++++++---------- 2 files changed, 27 insertions(+), 22 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index c8c0476a42..0738bf7f1f 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -9433,22 +9433,10 @@ virDomainDiskDefParseXML(virDomainXMLOption *xmlopt, virXMLNodeNameEqual(cur, "vendor")) { if (!(vendor =3D virXMLNodeContentString(cur))) return NULL; - - if (!virStringIsPrintable(vendor)) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("disk vendor is not printable string")); - return NULL; - } } else if (!product && virXMLNodeNameEqual(cur, "product")) { if (!(product =3D virXMLNodeContentString(cur))) return NULL; - - if (!virStringIsPrintable(product)) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("disk product is not printable string")); - return NULL; - } } else if (virXMLNodeNameEqual(cur, "boot")) { /* boot is parsed as part of virDomainDeviceInfoParseXML */ } else if ((flags & VIR_DOMAIN_DEF_PARSE_STATUS) && diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c index 97fa218252..b2780b3562 100644 --- a/src/conf/domain_validate.c +++ b/src/conf/domain_validate.c @@ -27,6 +27,7 @@ #include "virconftypes.h" #include "virlog.h" #include "virutil.h" +#include "virstring.h" #define VIR_FROM_THIS VIR_FROM_DOMAIN @@ -607,18 +608,34 @@ virDomainDiskDefValidate(const virDomainDef *def, 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->vendor) { + if (!virStringIsPrintable(disk->vendor)) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("disk vendor is not printable string")); + return -1; + } + + if (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->product) { + if (!virStringIsPrintable(disk->product)) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("disk product is not printable string")); + return -1; + } + + if (strlen(disk->product) > PRODUCT_LEN) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("disk product is more than %d characters"), + PRODUCT_LEN); + return -1; + } } if (disk->device =3D=3D VIR_DOMAIN_DISK_DEVICE_FLOPPY && --=20 2.30.2