From nobody Sun Feb 8 15:25:28 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=1631204140; cv=none; d=zohomail.com; s=zohoarc; b=I/hopE6t1YS/1QNZg6QzRn/8z+wU2Aq8oedtCJCYXOkQa4z6DJGed9nukIzjuCeaOWvaIOE+RVfekZSDJ6nuZpF3moFPJ/8qZ5nYvnxft6OLIMmxTcKFha++WW2GqJVyjOLPyxmMNjPkRy65P6hNPZZieAXv1eJ4qqKOUyVZHqM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1631204140; 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=z3Mlo8V7o5pAesjuLbN/QvWhs1dBs+uMF4Oq2ijSJiI=; b=k7LsdE9d+mN6E+bCmkr75hNvEMuPCVhemaSH7obiWHq6O2292GIoC4f67MBIZUbdSnzkXlVYWpLeedreHCLr0co7O7nUjHuP5MJqaLAk0HIOgYJA3JtlZs9yGgBLMhfTQ8mtGSmB04JRcvmpiBTfFfYEGP/Ew66SDvlcDQ8R6hA= 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) 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 1631204140243511.52620341642285; Thu, 9 Sep 2021 09:15:40 -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-123-o7pNzAO-PziaiHKx2PF2Eg-1; Thu, 09 Sep 2021 12:15:37 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1799018DB8AB; Thu, 9 Sep 2021 16:15:31 +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 85FCA5C25D; Thu, 9 Sep 2021 16:15:30 +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 8EF8E4E58F; Thu, 9 Sep 2021 16:15:29 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 189GDS6R009984 for ; Thu, 9 Sep 2021 12:13:28 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5369D4180; Thu, 9 Sep 2021 16:13:28 +0000 (UTC) Received: from antique-work.lan (unknown [10.40.192.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id C7D0153E08 for ; Thu, 9 Sep 2021 16:13:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631204139; 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=z3Mlo8V7o5pAesjuLbN/QvWhs1dBs+uMF4Oq2ijSJiI=; b=jDGtaNeaCV78VZ0jpsnfIBkXBuC7o7ZmD8FalC0CKWcS+JhWfoK3fK9cyU8fQV1VjOssvs zWR7k0WUFQmT+ICHuHnBHEHZHWdcNeBUgIV5CrGAdn4No7UtGzTHdunGq/fCOsCT7EfaEp SdXaKpOcdz5wi78/bVy+5hOwW3PpDG4= X-MC-Unique: o7pNzAO-PziaiHKx2PF2Eg-1 From: Pavel Hrdina To: libvir-list@redhat.com Subject: [RFC REPOST 1/7] conf: extract appid validation to virDomainDefResourceAppidValidate Date: Thu, 9 Sep 2021 18:13:17 +0200 Message-Id: <093c9897f08dfb924b35cf6aed6a97c96400516e.1631203909.git.phrdina@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 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.16 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) X-ZM-MESSAGEID: 1631204141981100001 Content-Type: text/plain; charset="utf-8" This will be needed by future patches adding appid API to allow changing it for running VMs. Signed-off-by: Pavel Hrdina --- src/conf/domain_validate.c | 42 +++++++++++++++++++++++--------------- src/conf/domain_validate.h | 2 ++ src/libvirt_private.syms | 1 + 3 files changed, 28 insertions(+), 17 deletions(-) diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c index 1bc62c364d..3ab864bbeb 100644 --- a/src/conf/domain_validate.c +++ b/src/conf/domain_validate.c @@ -58,29 +58,37 @@ virDomainDefBootValidate(const virDomainDef *def) #define APPID_LEN_MIN 1 #define APPID_LEN_MAX 128 =20 +int +virDomainDefResourceAppidValidate(const char *appid) +{ + int len; + + if (!virStringIsPrintable(appid)) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("Fibre Channel 'appid' is not a printable string"= )); + return -1; + } + + len =3D strlen(appid); + if (len < APPID_LEN_MIN || len > APPID_LEN_MAX) { + virReportError(VIR_ERR_INVALID_ARG, + _("Fibre Channel 'appid' string length must be betw= een [%d, %d]"), + APPID_LEN_MIN, APPID_LEN_MAX); + return -1; + } + + return 0; +} + + static int virDomainDefResourceValidate(const virDomainDef *def) { if (!def->resource) return 0; =20 - if (def->resource->appid) { - int len; - - if (!virStringIsPrintable(def->resource->appid)) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("Fibre Channel 'appid' is not a printable str= ing")); - return -1; - } - - len =3D strlen(def->resource->appid); - if (len < APPID_LEN_MIN || len > APPID_LEN_MAX) { - virReportError(VIR_ERR_INVALID_ARG, - _("Fibre Channel 'appid' string length must be = between [%d, %d]"), - APPID_LEN_MIN, APPID_LEN_MAX); - return -1; - } - } + if (def->resource->appid) + return virDomainDefResourceAppidValidate(def->resource->appid); =20 return 0; } diff --git a/src/conf/domain_validate.h b/src/conf/domain_validate.h index 430d61fd3c..02fc16b17d 100644 --- a/src/conf/domain_validate.h +++ b/src/conf/domain_validate.h @@ -42,3 +42,5 @@ int virDomainDeviceDefValidate(const virDomainDeviceDef *= dev, int virDomainDiskDefValidateSource(const virStorageSource *src); =20 int virDomainDiskDefSourceLUNValidate(const virStorageSource *src); + +int virDomainDefResourceAppidValidate(const char *appid); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 2778fe7f8f..d1f5dc2080 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -765,6 +765,7 @@ virDomainConfVMNWFilterTeardown; =20 # conf/domain_validate.h virDomainActualNetDefValidate; +virDomainDefResourceAppidValidate; virDomainDefValidate; virDomainDeviceValidateAliasForHotplug; virDomainDiskDefSourceLUNValidate; --=20 2.31.1