From nobody Fri May 17 03:12:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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 170.10.133.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=1655209745; cv=none; d=zohomail.com; s=zohoarc; b=iNp4z5bW2KGAzLeTopd2EJWCURfyEwLDzR6CnufPkJuIpAuac+jKCgKsSxwehwyby8nRrTovQXNKRCQCwUT7tYp5kLeg7c08qgwwCbbwtcCR0TgUhQXkKhsid5V0wm7SUIHGYv0QSNzVCaODiZzQhJeLPoR2QX6yNgdiA2Trbtk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1655209745; 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=u11a4e9/6c8U+1cnFPMm68ybIpGkXnbdSfQ3JFM9rYA=; b=MLVIkYo+Vlvh3amcRvsbtKlcrBTt75zslfP1GqO+ORni4n4pTza7Ep719JfdfpxLAovtf3B+iHeJOyRhKNH/Sib4I7xW/XeGQLD0sNtGxZ/A5b7952V+fWDXu1CFu6SUyNOIi5fvzk0dWTqYUdM0p6z60ucpSjZeinO8pchxs4Q= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.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 [170.10.133.124]) by mx.zohomail.com with SMTPS id 1655209745736717.72303766769; Tue, 14 Jun 2022 05:29:05 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-20-FvJfgVi4N4ObC_UR3SP4BA-1; Tue, 14 Jun 2022 08:29:02 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 841261E7DCC4; Tue, 14 Jun 2022 12:28:57 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3A06B2026D64; Tue, 14 Jun 2022 12:28:57 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id B04AB1947B86; Tue, 14 Jun 2022 12:28:56 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 8BB3F1947067 for ; Tue, 14 Jun 2022 12:28:55 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 71B60C28118; Tue, 14 Jun 2022 12:28:55 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id AA05BC23DBF for ; Tue, 14 Jun 2022 12:28:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655209744; 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=u11a4e9/6c8U+1cnFPMm68ybIpGkXnbdSfQ3JFM9rYA=; b=frphjoH6nR+2IG0KT6wT6DUfaWSVS9r3rGG/TKhTS+ZqbHkUZf8X57b2tMI699AjkvPsvM 4H1opSipTg9TdUs7564jCCL9739U5vzQiR7N1A0UgkcDCFuvtzMhlLoWg9SM69owb5tD86 tMFT737x5yLHO2IdK/Sh1BDjt3KFnew= X-MC-Unique: FvJfgVi4N4ObC_UR3SP4BA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 1/4] virDomainDiskDefValidate: Improve error messages for 'startupPolicy' checks Date: Tue, 14 Jun 2022 14:28:49 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 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: 1655209747936100001 Content-Type: text/plain; charset="utf-8" Remove linebreak and mention the attribute name. Also prepare the error messages for future by substituting the type of offending access. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_validate.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c index 1e18826bc1..3e11e00ee4 100644 --- a/src/conf/domain_validate.c +++ b/src/conf/domain_validate.c @@ -855,9 +855,9 @@ virDomainDiskDefValidate(const virDomainDef *def, if (disk->startupPolicy !=3D VIR_DOMAIN_STARTUP_POLICY_DEFAULT) { if (disk->src->type =3D=3D VIR_STORAGE_TYPE_NETWORK) { virReportError(VIR_ERR_XML_ERROR, - _("Setting disk %s is not allowed for " - "disk of network type"), - virDomainStartupPolicyTypeToString(disk->startu= pPolicy)); + _("disk startupPolicy '%s' is not allowed for d= isk of '%s' type"), + virDomainStartupPolicyTypeToString(disk->startu= pPolicy), + virStorageTypeToString(disk->src->type)); return -1; } @@ -865,8 +865,7 @@ virDomainDiskDefValidate(const virDomainDef *def, disk->device !=3D VIR_DOMAIN_DISK_DEVICE_FLOPPY && disk->startupPolicy =3D=3D VIR_DOMAIN_STARTUP_POLICY_REQUISITE= ) { virReportError(VIR_ERR_XML_ERROR, "%s", - _("Setting disk 'requisite' is allowed only for= " - "cdrom or floppy")); + _("disk startupPolicy 'requisite' is allowed on= ly for cdrom or floppy")); return -1; } } --=20 2.36.1 From nobody Fri May 17 03:12:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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 170.10.129.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=1655209747; cv=none; d=zohomail.com; s=zohoarc; b=LJ4mFLC15vKtWKCuE8+qahH3UNwyYsCxUdnHPFIsQvhuwp7HbUj09xpd0FYyzxMvD8j9oJ+3mxdz57EX00m9NwBSlUd6P/ltFFCw9nTzhxJyCjLi75s1Z/W0d462ZL3ce6qBrFUMegE2qi/G1LCu5hk4K15kFC9PflPjDClnwOw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1655209747; 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=k1rNaNFH3jvJaJpWFPZ4lQ6p9Gz1pYM0SpclsrNYBF0=; b=dONN9eDxV7u7ozFpq4GeYZ1IwuSd8/1YcRQxYWItL2lZUIb8DpSTOKuLU7UAGsAjBSm7qNnewinQY31zzIKQyfRN4v4hPrUJx8rR5xAEIbAzjaoFmQmuoW4voXNEw5JJ2jRWWianzrS8UL1fcMdJdMTvwKKtQVcQqopBZ/8EHN0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.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 [170.10.129.124]) by mx.zohomail.com with SMTPS id 1655209747305193.78776936247868; Tue, 14 Jun 2022 05:29:07 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-669-oKZjrUD9PcCjvFAJoSSDAg-1; Tue, 14 Jun 2022 08:29:05 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 89E9F800124; Tue, 14 Jun 2022 12:28:58 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7480C2166B26; Tue, 14 Jun 2022 12:28:58 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 038C61947070; Tue, 14 Jun 2022 12:28:58 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 970191947076 for ; Tue, 14 Jun 2022 12:28:56 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 6F95CC28119; Tue, 14 Jun 2022 12:28:56 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id E61E8C28118 for ; Tue, 14 Jun 2022 12:28:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655209746; 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=k1rNaNFH3jvJaJpWFPZ4lQ6p9Gz1pYM0SpclsrNYBF0=; b=SCmRaIm9egjdWOKBxc1Fio1zL/ocYdWGS5mpbGdwfm6Qci740/JGNef3BDFsjBy402kTc2 JjUMrtpKslIShCeRHOSdHoiLKBp8duDgMLpOuHAvuJ5exBgiO61FdI4x+RnSc2FD5CX8hD /ExyyhvxT7hI65hoovIF/DPRIZVyEFs= X-MC-Unique: oKZjrUD9PcCjvFAJoSSDAg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 2/4] domain_validate: Split out validation of disk startup policy Date: Tue, 14 Jun 2022 14:28:50 +0200 Message-Id: <2a720fc152ed0c4aaab4363b6c586453e5f24937.1655209670.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 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: 1655209747939100002 Content-Type: text/plain; charset="utf-8" Move the code into 'virDomainDiskDefValidateStartupPolicy' which will be later reused in the qemu driver. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_validate.c | 45 ++++++++++++++++++++++++-------------- src/conf/domain_validate.h | 2 ++ src/libvirt_private.syms | 1 + 3 files changed, 31 insertions(+), 17 deletions(-) diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c index 3e11e00ee4..70e9167eac 100644 --- a/src/conf/domain_validate.c +++ b/src/conf/domain_validate.c @@ -632,6 +632,32 @@ virDomainDiskDefSourceLUNValidate(const virStorageSour= ce *src) } +int +virDomainDiskDefValidateStartupPolicy(const virDomainDiskDef *disk) +{ + if (disk->startupPolicy =3D=3D VIR_DOMAIN_STARTUP_POLICY_DEFAULT) + return 0; + + if (disk->src->type =3D=3D VIR_STORAGE_TYPE_NETWORK) { + virReportError(VIR_ERR_XML_ERROR, + _("disk startupPolicy '%s' is not allowed for disk = of '%s' type"), + virDomainStartupPolicyTypeToString(disk->startupPol= icy), + virStorageTypeToString(disk->src->type)); + return -1; + } + + if (disk->device !=3D VIR_DOMAIN_DISK_DEVICE_CDROM && + disk->device !=3D VIR_DOMAIN_DISK_DEVICE_FLOPPY && + disk->startupPolicy =3D=3D VIR_DOMAIN_STARTUP_POLICY_REQUISITE) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("disk startupPolicy 'requisite' is allowed only f= or cdrom or floppy")); + return -1; + } + + return 0; +} + + static int virDomainDiskDefValidate(const virDomainDef *def, const virDomainDiskDef *disk) @@ -852,23 +878,8 @@ virDomainDiskDefValidate(const virDomainDef *def, return -1; } - if (disk->startupPolicy !=3D VIR_DOMAIN_STARTUP_POLICY_DEFAULT) { - if (disk->src->type =3D=3D VIR_STORAGE_TYPE_NETWORK) { - virReportError(VIR_ERR_XML_ERROR, - _("disk startupPolicy '%s' is not allowed for d= isk of '%s' type"), - virDomainStartupPolicyTypeToString(disk->startu= pPolicy), - virStorageTypeToString(disk->src->type)); - return -1; - } - - if (disk->device !=3D VIR_DOMAIN_DISK_DEVICE_CDROM && - disk->device !=3D VIR_DOMAIN_DISK_DEVICE_FLOPPY && - disk->startupPolicy =3D=3D VIR_DOMAIN_STARTUP_POLICY_REQUISITE= ) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("disk startupPolicy 'requisite' is allowed on= ly for cdrom or floppy")); - return -1; - } - } + if (virDomainDiskDefValidateStartupPolicy(disk) < 0) + return -1; if (disk->wwn && !virValidateWWN(disk->wwn)) return -1; diff --git a/src/conf/domain_validate.h b/src/conf/domain_validate.h index 430d61fd3c..07b99195e3 100644 --- a/src/conf/domain_validate.h +++ b/src/conf/domain_validate.h @@ -41,4 +41,6 @@ int virDomainDeviceDefValidate(const virDomainDeviceDef *= dev, int virDomainDiskDefValidateSource(const virStorageSource *src); +int virDomainDiskDefValidateStartupPolicy(const virDomainDiskDef *disk); + int virDomainDiskDefSourceLUNValidate(const virStorageSource *src); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 770dfe459a..76bcc64eb0 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -779,6 +779,7 @@ virDomainActualNetDefValidate; virDomainDefValidate; virDomainDeviceValidateAliasForHotplug; virDomainDiskDefSourceLUNValidate; +virDomainDiskDefValidateStartupPolicy; # conf/interface_conf.h --=20 2.36.1 From nobody Fri May 17 03:12:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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 170.10.133.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=1655209815; cv=none; d=zohomail.com; s=zohoarc; b=c/HWcbmIpzLpbGNKUq2H1SFImlSCDi1bgcetuCbE8kSPREHuVlo59Cqx/r/0XgZo/AjODMgX8RrsQyDyKtQOJPw5NXIUgzdYwTqA1GZMDTKl04mDpNVOiGM6turGvuayuNzBMpUxu4kg7M7c+nFe5jwfz3KFf6CHwyu6hc8Ve0g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1655209815; 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=Y7SbtI+KOdhUyXPlF06GwiiQ347PA+DRoHS7kH2Ql4A=; b=hSllhoUDli0dFYzw2Fp712P/j66pZgg9SsoSOpoKJfPZLrEG3LFXlogvgBwh+ajeu6KMrnA3ZwhklXdVSPZlI2Xhv5eG2wg1P5Oy7WqLuiRL4x8Wli7RzMhaNryZaNLAT+aQM/4aw46y5nUNP7ofgVxdXL5sy9S0dKF07HdC+1k= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.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 [170.10.133.124]) by mx.zohomail.com with SMTPS id 1655209815385202.01993526960916; Tue, 14 Jun 2022 05:30:15 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-175-ZNW87wZ5NjCVoChYWuX1Ig-1; Tue, 14 Jun 2022 08:29:06 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 552A029DD98F; Tue, 14 Jun 2022 12:28:59 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3AF72404E4C2; Tue, 14 Jun 2022 12:28:59 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id DC551194707B; Tue, 14 Jun 2022 12:28:58 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id DBD1A1947070 for ; Tue, 14 Jun 2022 12:28:57 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id B710FC23DBF; Tue, 14 Jun 2022 12:28:57 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id F298FC28118 for ; Tue, 14 Jun 2022 12:28:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655209814; 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=Y7SbtI+KOdhUyXPlF06GwiiQ347PA+DRoHS7kH2Ql4A=; b=UK3DfgZ80f3+NrU2VLwLLHarm5TNbQMaXcuKp/ZX2gHu5/AEvMRsIuU9XXBWbSXlb3644h qMbhMpeQSiJ+4u1A4ZJ+leReGMjRv7AmaRG4rjQ1IIKhuMo4qUkqvOsz7+AfXCSOzgOU0i QCclUq9UYf65LusMv0NZ2gpiIRuR470= X-MC-Unique: ZNW87wZ5NjCVoChYWuX1Ig-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 3/4] virDomainDiskDefValidateStartupPolicy: Validate disk type better Date: Tue, 14 Jun 2022 14:28:51 +0200 Message-Id: <8ee0f0fc1f21ed36073bba0ccc1f48fdec26da45.1655209670.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 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: 1655209816521100001 Content-Type: text/plain; charset="utf-8" Our startup policy checkers work only for local paths, so disk sources such as NVMe, or vhost-user can't be used with startup policy. Unfortunately the validation did not catch these cases. Fix it. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_validate.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c index 70e9167eac..9c55d05cac 100644 --- a/src/conf/domain_validate.c +++ b/src/conf/domain_validate.c @@ -638,7 +638,10 @@ virDomainDiskDefValidateStartupPolicy(const virDomainD= iskDef *disk) if (disk->startupPolicy =3D=3D VIR_DOMAIN_STARTUP_POLICY_DEFAULT) return 0; - if (disk->src->type =3D=3D VIR_STORAGE_TYPE_NETWORK) { + /* We want to allow any startup policy for un-translated _TYPE_VOLUME = disks. + * virStorageSourceGetActualType returns _TYPE_VOLUME in such case */ + if (virStorageSourceGetActualType(disk->src) !=3D VIR_STORAGE_TYPE_VOL= UME && + !virStorageSourceIsLocalStorage(disk->src)) { virReportError(VIR_ERR_XML_ERROR, _("disk startupPolicy '%s' is not allowed for disk = of '%s' type"), virDomainStartupPolicyTypeToString(disk->startupPol= icy), --=20 2.36.1 From nobody Fri May 17 03:12:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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 170.10.129.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=1655209748; cv=none; d=zohomail.com; s=zohoarc; b=O9ZD8WeiTDl2z2jmvAfhOtorzUIe1Sl0YopnbfUcsGO/Bc1mFw5MmTHNc/KgqK9x6V5NV96uWWDmLJ+QlwtM7nRotSoFgH0tivVO67luLQS/DKcdrMHbMj4CvAMQBhx951pxUNsX4fSaydqAfdTy266hbqLOVzPocQAXlI41afU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1655209748; 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=BNS2hReQhWXqqJgWmJX3go5A8KulIqt1q6nwOqOBjAw=; b=CqLlIg8uOdsAlE2GKtjK+BtiiMm1mW507HlOAGZvwrP+cReXEKAIFMaqz5+q4yPGZLw6JHgfi9YexCAfNekAr5bhmGnh/cp6yQN99QMdHgTxq0eTRe0KxpHhBVdlXzzpdymDabuvXCgmSbN2p7XPa4h7xsOoycthgaMCQBF2jRk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.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 [170.10.129.124]) by mx.zohomail.com with SMTPS id 1655209748435778.3624474694483; Tue, 14 Jun 2022 05:29:08 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-325-kC1AeNGcMOewxva6oeerSA-1; Tue, 14 Jun 2022 08:29:06 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B04C4181E07F; Tue, 14 Jun 2022 12:29:00 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 96CE4475006; Tue, 14 Jun 2022 12:29:00 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 4C1451947070; Tue, 14 Jun 2022 12:29:00 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id CB791194706D for ; Tue, 14 Jun 2022 12:28:58 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id AFC29C28125; Tue, 14 Jun 2022 12:28:58 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id 21B88C28118 for ; Tue, 14 Jun 2022 12:28:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655209747; 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=BNS2hReQhWXqqJgWmJX3go5A8KulIqt1q6nwOqOBjAw=; b=P1yW1lBT3XIgXUVU+HMA3FDZa5vErS0KP3j24E7IMepGCu/AOczYERs4tCzKDYL75SwIyu i0+R/AYeko+rmg4LJ9jeUa5Nw7lkuKFUeRFiAcTp2/cxdKvlDYI/MzzfV+YwnU5adIxI2/ XRBVuv7DGl4y/SZNFSTzKukJAzmVWSQ= X-MC-Unique: kC1AeNGcMOewxva6oeerSA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 4/4] virDomainDiskTranslateSourcePool: Fix check of 'startupPolicy' definition Date: Tue, 14 Jun 2022 14:28:52 +0200 Message-Id: <660ef370ebd4fe5d6aca2f55535d47702bd0efd4.1655209670.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 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: 1655209749958100005 Content-Type: text/plain; charset="utf-8" The check was historically done only for _TYPE_VOLUME disks, but refactors to allow _TYPE_VOLUME disks in the backing chain caused a regression where we'd reject startupPolicy also for _TYPE_BLOCK disks which historically worked well. Fix it by using the 'virDomainDiskDefValidateStartupPolicy' helper and use it only when the top level image is a _TYPE_VOLUME as in other cases it was already validated. This also allows _TYPE_BLOCK volumes to use startup policy. Fixes: 37f01262eed9f37dd5eb7de8b83edd2fea741054 Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=3D2095758 Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 761c3f4d87..d5c5a10a8c 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -31433,13 +31433,13 @@ virDomainDiskTranslateSourcePool(virDomainDiskDef= *def) if (virDomainStorageSourceTranslateSourcePool(n, conn) < 0) return -1; - } - if (def->startupPolicy !=3D 0 && - virStorageSourceGetActualType(def->src) !=3D VIR_STORAGE_TYPE_FILE= ) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("'startupPolicy' is only valid for 'file' type vo= lume")); - return -1; + /* The validity of 'startupPolicy' setting is checked only for the= top + * level image. For any other subsequent images we honour it only = if + * possible */ + if (n =3D=3D def->src && + virDomainDiskDefValidateStartupPolicy(def) < 0) + return -1; } return 0; --=20 2.36.1