From nobody Thu May 9 20:48:06 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; spf=none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1709911148127860.564933799243; Fri, 8 Mar 2024 07:19:08 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 035F81DF8; Fri, 8 Mar 2024 10:19:06 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id A09741B8B; Fri, 8 Mar 2024 10:15:45 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 170321AE2; Fri, 8 Mar 2024 10:15:32 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 592831AF8 for ; Fri, 8 Mar 2024 10:15:31 -0500 (EST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-252-2GfCfWCiPj-DpYSDeakx5Q-1; Fri, 08 Mar 2024 10:15:29 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 76E8A8007A6 for ; Fri, 8 Mar 2024 15:15:29 +0000 (UTC) Received: from maggie.brq.redhat.com (unknown [10.43.3.102]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1EF101C05E1C for ; Fri, 8 Mar 2024 15:15:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.4 X-MC-Unique: 2GfCfWCiPj-DpYSDeakx5Q-1 From: Michal Privoznik To: devel@lists.libvirt.org Subject: [PATCH 1/4] tests: Introduce chxml2xmlmock Date: Fri, 8 Mar 2024 16:15:23 +0100 Message-ID: <6bdb552d472296a9e02b663e4467d85d942885a1.1709910136.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: MKKEQCLSVD673LLK4HE2GYPKCCUVDK3S X-Message-ID-Hash: MKKEQCLSVD673LLK4HE2GYPKCCUVDK3S X-MailFrom: mprivozn@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="utf-8"; x-default="true" Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1709911149566100001 As of previous commit, the CH driver checks for /dev/kvm and/or /dev/mshv presence. In order to make chxml2xmltest work regardless of host configuration, introduce a mock that pretends both of these files are accessible. Fixes: 51c14df9670ba2f5d193b700f39e6464e1bc18c6 Signed-off-by: Michal Privoznik Reviewed-by: Peter Krempa --- tests/chxml2xmlmock.c | 33 +++++++++++++++++++++++++++++++++ tests/chxml2xmltest.c | 2 +- tests/meson.build | 3 +++ 3 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 tests/chxml2xmlmock.c diff --git a/tests/chxml2xmlmock.c b/tests/chxml2xmlmock.c new file mode 100644 index 0000000000..73b210f35e --- /dev/null +++ b/tests/chxml2xmlmock.c @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2024 Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see + * . + */ + +#include +#include + +#include "internal.h" +#include "virfile.h" + +bool +virFileExists(const char *path) +{ + if (STREQ(path, "/dev/kvm")) + return true; + if (STREQ(path, "/dev/mshv")) + return true; + return access(path, F_OK) =3D=3D 0; +} diff --git a/tests/chxml2xmltest.c b/tests/chxml2xmltest.c index 97b485dc4a..a5a75a1505 100644 --- a/tests/chxml2xmltest.c +++ b/tests/chxml2xmltest.c @@ -74,4 +74,4 @@ mymain(void) return ret =3D=3D 0 ? EXIT_SUCCESS : EXIT_FAILURE; } =20 -VIR_TEST_MAIN(mymain) +VIR_TEST_MAIN_PRELOAD(mymain, VIR_TEST_MOCK("chxml2xml")) diff --git a/tests/meson.build b/tests/meson.build index 4fc00e27da..3fcfa6b1e0 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -350,6 +350,9 @@ if conf.has('WITH_CH') tests +=3D [ { 'name': 'chxml2xmltest', 'link_with': [ ch_driver_impl ] }, ] + mock_libs +=3D [ + { 'name': 'chxml2xmlmock' }, + ] endif =20 if conf.has('WITH_ESX') --=20 2.43.0 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org From nobody Thu May 9 20:48:06 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; spf=none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1709911227170122.94416198303793; Fri, 8 Mar 2024 07:20:27 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id E25D91B8B; Fri, 8 Mar 2024 10:20:25 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 05C2C1BCA; Fri, 8 Mar 2024 10:15:55 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id A33CB1AE2; Fri, 8 Mar 2024 10:15:34 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 6F07019E2 for ; Fri, 8 Mar 2024 10:15:32 -0500 (EST) Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-606-UkU0nkuENieiVOJBZS1pNg-1; Fri, 08 Mar 2024 10:15:30 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0FDBF38049F6 for ; Fri, 8 Mar 2024 15:15:30 +0000 (UTC) Received: from maggie.brq.redhat.com (unknown [10.43.3.102]) by smtp.corp.redhat.com (Postfix) with ESMTP id AC3CA1C05E1C for ; Fri, 8 Mar 2024 15:15:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.4 X-MC-Unique: UkU0nkuENieiVOJBZS1pNg-1 From: Michal Privoznik To: devel@lists.libvirt.org Subject: [PATCH 2/4] ch: Demote error when CH driver fails to init Date: Fri, 8 Mar 2024 16:15:24 +0100 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: D2SQCEFXWE3THS3KHMKIXHM4H6KUJWBR X-Message-ID-Hash: D2SQCEFXWE3THS3KHMKIXHM4H6KUJWBR X-MailFrom: mprivozn@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="utf-8"; x-default="true" Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1709911228099100001 If the host doesn't have /dev/kvm nor /dev/mshv, i.e. CH driver is unable to run any guests, then an error is reported. But the usual thing to do here is print an info message into the logs and return VIR_DRV_STATE_INIT_SKIPPED. It is a recoverable error after all. Signed-off-by: Michal Privoznik Reviewed-by: Peter Krempa --- src/ch/ch_driver.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/ch/ch_driver.c b/src/ch/ch_driver.c index 2601eea44b..9394924f2d 100644 --- a/src/ch/ch_driver.c +++ b/src/ch/ch_driver.c @@ -893,9 +893,8 @@ static int chStateInitialize(bool privileged, VIR_ARCH_NONE, VIR_DOMAIN_VIRT_KVM= ) && !virCapabilitiesDomainSupported(ch_driver->caps, -1, VIR_ARCH_NONE, VIR_DOMAIN_VIRT_HYP= ERV)) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("/dev/kvm and /dev/mshv are missing. CH driver fa= iled to initialize.")); - return VIR_DRV_STATE_INIT_ERROR; + VIR_INFO("/dev/kvm and /dev/mshv are missing. CH driver failed to = initialize."); + return VIR_DRV_STATE_INIT_SKIPPED; } =20 if (!(ch_driver->xmlopt =3D chDomainXMLConfInit(ch_driver))) --=20 2.43.0 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org From nobody Thu May 9 20:48:06 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; spf=none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 170991133439786.15887939528739; Fri, 8 Mar 2024 07:22:14 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 4D8941852; Fri, 8 Mar 2024 10:22:13 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 625171DC7; Fri, 8 Mar 2024 10:16:03 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id C6F731AE2; Fri, 8 Mar 2024 10:15:34 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id C3E171B3C for ; Fri, 8 Mar 2024 10:15:32 -0500 (EST) Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-477-n14aiB1zOG2zIFaqtUXibw-1; Fri, 08 Mar 2024 10:15:30 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9C06D3C40B51 for ; Fri, 8 Mar 2024 15:15:30 +0000 (UTC) Received: from maggie.brq.redhat.com (unknown [10.43.3.102]) by smtp.corp.redhat.com (Postfix) with ESMTP id 44C891C05E1C for ; Fri, 8 Mar 2024 15:15:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.4 X-MC-Unique: n14aiB1zOG2zIFaqtUXibw-1 From: Michal Privoznik To: devel@lists.libvirt.org Subject: [PATCH 3/4] capabilities: Allow suppressing error message from virCapabilitiesDomainDataLookup() Date: Fri, 8 Mar 2024 16:15:25 +0100 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: RRA2SD2VUHQ62JU2KUNE4JGVTPGAQV73 X-Message-ID-Hash: RRA2SD2VUHQ62JU2KUNE4JGVTPGAQV73 X-MailFrom: mprivozn@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="utf-8"; x-default="true" Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1709911336750100001 In near future we will want to check whether capabilities for given virtType exist, but report an error on our own. Introduce reportError argument which makes the function report an error iff set. In one specific case (virQEMUCapsGetDefaultVersion()) we were even overwriting (more specific) error message reportd by virCapabilitiesDomainDataLookup(). Drop that too. Signed-off-by: Michal Privoznik Reviewed-by: Peter Krempa --- src/conf/capabilities.c | 20 +++++++++++++++----- src/conf/capabilities.h | 3 ++- src/conf/domain_conf.c | 5 ++++- src/libxl/xen_common.c | 5 ++++- src/qemu/qemu_capabilities.c | 10 +++++----- 5 files changed, 30 insertions(+), 13 deletions(-) diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c index 02298e40a3..5a0c7de646 100644 --- a/src/conf/capabilities.c +++ b/src/conf/capabilities.c @@ -591,7 +591,8 @@ virCapabilitiesDomainDataLookupInternal(virCaps *caps, virArch arch, virDomainVirtType domaintype, const char *emulator, - const char *machinetype) + const char *machinetype, + bool reportError) { virCapsGuest *foundguest =3D NULL; virCapsGuestDomain *founddomain =3D NULL; @@ -680,6 +681,10 @@ virCapabilitiesDomainDataLookupInternal(virCaps *caps, /* XXX check default_emulator, see how it uses this */ if (!foundguest) { g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; + + if (!reportError) + return NULL; + if (ostype) virBufferAsprintf(&buf, "ostype=3D%s ", virDomainOSTypeToString(ostype)); @@ -726,6 +731,7 @@ virCapabilitiesDomainDataLookupInternal(virCaps *caps, * @domaintype: domain type to search for, of enum virDomainVirtType * @emulator: Emulator path to search for * @machinetype: Machine type to search for + * @reportError: whether to report error if no match is found * * Search capabilities for the passed values, and if found return * virCapabilitiesDomainDataLookup filled in with the default values @@ -736,7 +742,8 @@ virCapabilitiesDomainDataLookup(virCaps *caps, virArch arch, int domaintype, const char *emulator, - const char *machinetype) + const char *machinetype, + bool reportError) { virCapsDomainData *ret; =20 @@ -745,14 +752,16 @@ virCapabilitiesDomainDataLookup(virCaps *caps, ret =3D virCapabilitiesDomainDataLookupInternal(caps, ostype, caps->host.arch, domaintype, - emulator, machinetyp= e); + emulator, machinetyp= e, + reportError); if (ret) return ret; } =20 return virCapabilitiesDomainDataLookupInternal(caps, ostype, arch, domaintype, - emulator, machinetype); + emulator, machinetype, + reportError); } =20 =20 @@ -767,7 +776,8 @@ virCapabilitiesDomainSupported(virCaps *caps, capsdata =3D virCapabilitiesDomainDataLookup(caps, ostype, arch, virttype, - NULL, NULL); + NULL, NULL, + true); =20 return capsdata !=3D NULL; } diff --git a/src/conf/capabilities.h b/src/conf/capabilities.h index 52e395de14..c67b3ce397 100644 --- a/src/conf/capabilities.h +++ b/src/conf/capabilities.h @@ -309,7 +309,8 @@ virCapabilitiesDomainDataLookup(virCaps *caps, virArch arch, int domaintype, const char *emulator, - const char *machinetype); + const char *machinetype, + bool reportError); =20 bool virCapabilitiesDomainSupported(virCaps *caps, diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 3597959e33..2a64a4a1ad 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -15811,8 +15811,11 @@ virDomainDefGetDefaultEmulator(virDomainDef *def, g_autofree virCapsDomainData *capsdata =3D NULL; =20 if (!(capsdata =3D virCapabilitiesDomainDataLookup(caps, def->os.type, - def->os.arch, def->virtType, NULL, NULL))) + def->os.arch, + def->virtType, NULL, = NULL, + true))) { return NULL; + } =20 retemu =3D g_strdup(capsdata->emulator); =20 diff --git a/src/libxl/xen_common.c b/src/libxl/xen_common.c index d5a0399613..79eb593432 100644 --- a/src/libxl/xen_common.c +++ b/src/libxl/xen_common.c @@ -1387,8 +1387,11 @@ xenParseGeneralMeta(virConf *conf, virDomainDef *def= , virCaps *caps) } =20 if (!(capsdata =3D virCapabilitiesDomainDataLookup(caps, def->os.type, - VIR_ARCH_NONE, def->virtType, NULL, NULL))) + VIR_ARCH_NONE, + def->virtType, NULL, + NULL, true))) { goto out; + } =20 def->os.arch =3D capsdata->arch; def->os.machine =3D g_strdup(capsdata->machinetype); diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index ab11a929a3..9de2626b9b 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -1782,11 +1782,11 @@ int virQEMUCapsGetDefaultVersion(virCaps *caps, =20 hostarch =3D virArchFromHost(); if (!(capsdata =3D virCapabilitiesDomainDataLookup(caps, - VIR_DOMAIN_OSTYPE_HVM, hostarch, VIR_DOMAIN_VIRT_NONE, - NULL, NULL))) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Cannot find suitable emulator for %1$s"), - virArchToString(hostarch)); + VIR_DOMAIN_OSTYPE_HVM, + hostarch, + VIR_DOMAIN_VIRT_NONE, + NULL, NULL, + true))) { return -1; } =20 --=20 2.43.0 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org From nobody Thu May 9 20:48:06 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; spf=none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1709911469231521.4239524587358; Fri, 8 Mar 2024 07:24:29 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id F30C91D29; Fri, 8 Mar 2024 10:24:27 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id C77851B40; Fri, 8 Mar 2024 10:16:11 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 2775E1AF8; Fri, 8 Mar 2024 10:15:37 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 1F81719E2 for ; Fri, 8 Mar 2024 10:15:36 -0500 (EST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-186-KsgNiVNOO-SulUJC027o5g-1; Fri, 08 Mar 2024 10:15:31 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 354FF8007A2 for ; Fri, 8 Mar 2024 15:15:31 +0000 (UTC) Received: from maggie.brq.redhat.com (unknown [10.43.3.102]) by smtp.corp.redhat.com (Postfix) with ESMTP id D1A8B1C060D6 for ; Fri, 8 Mar 2024 15:15:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.4 X-MC-Unique: KsgNiVNOO-SulUJC027o5g-1 From: Michal Privoznik To: devel@lists.libvirt.org Subject: [PATCH 4/4] capabilities: Allow suppressing error message from virCapabilitiesDomainSupported() Date: Fri, 8 Mar 2024 16:15:26 +0100 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: BE44BZCBT7AWV22IHRVFGIVJFZY2Q6SU X-Message-ID-Hash: BE44BZCBT7AWV22IHRVFGIVJFZY2Q6SU X-MailFrom: mprivozn@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="utf-8"; x-default="true" Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1709911471248100001 In a few cases (CH driver) we want virCapabilitiesDomainSupported() just to check whether given virtType is supported and report a different error message (that suggests how to solve the problem). Introduce reportError argument which makes the function report an error iff set. Signed-off-by: Michal Privoznik Reviewed-by: Peter Krempa --- src/bhyve/bhyve_domain.c | 3 ++- src/ch/ch_domain.c | 5 ++++- src/ch/ch_driver.c | 4 ++-- src/ch/ch_process.c | 4 ++-- src/conf/capabilities.c | 5 +++-- src/conf/capabilities.h | 3 ++- src/libxl/libxl_domain.c | 3 ++- src/lxc/lxc_domain.c | 3 ++- src/openvz/openvz_conf.c | 3 ++- src/vmware/vmware_driver.c | 3 ++- src/vmx/vmx.c | 3 ++- src/vz/vz_driver.c | 3 ++- 12 files changed, 27 insertions(+), 15 deletions(-) diff --git a/src/bhyve/bhyve_domain.c b/src/bhyve/bhyve_domain.c index c47ad392a0..684d870749 100644 --- a/src/bhyve/bhyve_domain.c +++ b/src/bhyve/bhyve_domain.c @@ -89,7 +89,8 @@ bhyveDomainDefPostParse(virDomainDef *def, =20 if (!virCapabilitiesDomainSupported(caps, def->os.type, def->os.arch, - def->virtType)) + def->virtType, + true)) return -1; =20 /* Add an implicit PCI root controller */ diff --git a/src/ch/ch_domain.c b/src/ch/ch_domain.c index acadd76edc..8e3e205c8c 100644 --- a/src/ch/ch_domain.c +++ b/src/ch/ch_domain.c @@ -125,11 +125,14 @@ virCHDomainDefPostParse(virDomainDef *def, { virCHDriver *driver =3D opaque; g_autoptr(virCaps) caps =3D virCHDriverGetCapabilities(driver, false); + if (!caps) return -1; + if (!virCapabilitiesDomainSupported(caps, def->os.type, def->os.arch, - def->virtType)) + def->virtType, + true)) return -1; =20 return 0; diff --git a/src/ch/ch_driver.c b/src/ch/ch_driver.c index 9394924f2d..ae550802f5 100644 --- a/src/ch/ch_driver.c +++ b/src/ch/ch_driver.c @@ -890,9 +890,9 @@ static int chStateInitialize(bool privileged, goto cleanup; =20 if (!virCapabilitiesDomainSupported(ch_driver->caps, -1, - VIR_ARCH_NONE, VIR_DOMAIN_VIRT_KVM= ) && + VIR_ARCH_NONE, VIR_DOMAIN_VIRT_KVM= , false) && !virCapabilitiesDomainSupported(ch_driver->caps, -1, - VIR_ARCH_NONE, VIR_DOMAIN_VIRT_HYP= ERV)) { + VIR_ARCH_NONE, VIR_DOMAIN_VIRT_HYP= ERV, false)) { VIR_INFO("/dev/kvm and /dev/mshv are missing. CH driver failed to = initialize."); return VIR_DRV_STATE_INIT_SKIPPED; } diff --git a/src/ch/ch_process.c b/src/ch/ch_process.c index 7488b1d65d..b532f547b3 100644 --- a/src/ch/ch_process.c +++ b/src/ch/ch_process.c @@ -660,7 +660,7 @@ virCHProcessStartValidate(virCHDriver *driver, if (vm->def->virtType =3D=3D VIR_DOMAIN_VIRT_KVM) { VIR_DEBUG("Checking for KVM availability"); if (!virCapabilitiesDomainSupported(driver->caps, -1, - VIR_ARCH_NONE, VIR_DOMAIN_VIRT= _KVM)) { + VIR_ARCH_NONE, VIR_DOMAIN_VIRT= _KVM, false)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("Domain requires KVM, but it is not available= . Check that virtualization is enabled in the host BIOS, and host configura= tion is setup to load the kvm modules.")); return -1; @@ -668,7 +668,7 @@ virCHProcessStartValidate(virCHDriver *driver, } else if (vm->def->virtType =3D=3D VIR_DOMAIN_VIRT_HYPERV) { VIR_DEBUG("Checking for mshv availability"); if (!virCapabilitiesDomainSupported(driver->caps, -1, - VIR_ARCH_NONE, VIR_DOMAIN_VIRT= _HYPERV)) { + VIR_ARCH_NONE, VIR_DOMAIN_VIRT= _HYPERV, false)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("Domain requires MSHV device, but it is not a= vailable. Check that virtualization is enabled in the host BIOS, and host c= onfiguration is setup to load the mshv modules.")); return -1; diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c index 5a0c7de646..c8b897dd10 100644 --- a/src/conf/capabilities.c +++ b/src/conf/capabilities.c @@ -769,7 +769,8 @@ bool virCapabilitiesDomainSupported(virCaps *caps, int ostype, virArch arch, - int virttype) + int virttype, + bool reportError) { g_autofree virCapsDomainData *capsdata =3D NULL; =20 @@ -777,7 +778,7 @@ virCapabilitiesDomainSupported(virCaps *caps, arch, virttype, NULL, NULL, - true); + reportError); =20 return capsdata !=3D NULL; } diff --git a/src/conf/capabilities.h b/src/conf/capabilities.h index c67b3ce397..daea835817 100644 --- a/src/conf/capabilities.h +++ b/src/conf/capabilities.h @@ -316,7 +316,8 @@ bool virCapabilitiesDomainSupported(virCaps *caps, int ostype, virArch arch, - int domaintype); + int domaintype, + bool reportError); =20 =20 void diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c index ad2ad1ce0e..16c2ab973b 100644 --- a/src/libxl/libxl_domain.c +++ b/src/libxl/libxl_domain.c @@ -309,7 +309,8 @@ libxlDomainDefValidate(const virDomainDef *def, =20 if (!virCapabilitiesDomainSupported(cfg->caps, def->os.type, def->os.arch, - def->virtType)) + def->virtType, + true)) return -1; =20 /* Xen+ovmf does not support secure boot */ diff --git a/src/lxc/lxc_domain.c b/src/lxc/lxc_domain.c index cf9bf96a4e..afd8d6e980 100644 --- a/src/lxc/lxc_domain.c +++ b/src/lxc/lxc_domain.c @@ -238,7 +238,8 @@ virLXCDomainDefPostParse(virDomainDef *def, return -1; if (!virCapabilitiesDomainSupported(caps, def->os.type, def->os.arch, - def->virtType)) + def->virtType, + true)) return -1; =20 /* check for emulator and create a default one if needed */ diff --git a/src/openvz/openvz_conf.c b/src/openvz/openvz_conf.c index eab3f748d0..81769eb147 100644 --- a/src/openvz/openvz_conf.c +++ b/src/openvz/openvz_conf.c @@ -1007,7 +1007,8 @@ openvzDomainDefPostParse(virDomainDef *def, struct openvz_driver *driver =3D opaque; if (!virCapabilitiesDomainSupported(driver->caps, def->os.type, def->os.arch, - def->virtType)) + def->virtType, + true)) return -1; =20 /* fill the init path */ diff --git a/src/vmware/vmware_driver.c b/src/vmware/vmware_driver.c index 416ce126e8..e28c732cb0 100644 --- a/src/vmware/vmware_driver.c +++ b/src/vmware/vmware_driver.c @@ -106,7 +106,8 @@ vmwareDomainDefPostParse(virDomainDef *def, struct vmware_driver *driver =3D opaque; if (!virCapabilitiesDomainSupported(driver->caps, def->os.type, def->os.arch, - def->virtType)) + def->virtType, + true)) return -1; =20 return 0; diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c index 69ee66e668..5da67aae60 100644 --- a/src/vmx/vmx.c +++ b/src/vmx/vmx.c @@ -613,7 +613,8 @@ virVMXDomainDefPostParse(virDomainDef *def, virCaps *caps =3D opaque; if (!virCapabilitiesDomainSupported(caps, def->os.type, def->os.arch, - def->virtType)) + def->virtType, + true)) return -1; =20 return 0; diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c index c7ceec2339..380fdcb57e 100644 --- a/src/vz/vz_driver.c +++ b/src/vz/vz_driver.c @@ -241,7 +241,8 @@ vzDomainDefPostParse(virDomainDef *def, struct _vzDriver *driver =3D opaque; if (!virCapabilitiesDomainSupported(driver->caps, def->os.type, def->os.arch, - def->virtType)) + def->virtType, + true)) return -1; =20 if (vzDomainDefAddDefaultInputDevices(def) < 0) --=20 2.43.0 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org