From nobody Fri May 3 06:38:37 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1553862407529675.5806824901744; Fri, 29 Mar 2019 05:26:47 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id D882E3099FC9; Fri, 29 Mar 2019 12:26:45 +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 B3FB11001DD6; Fri, 29 Mar 2019 12:26:45 +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 EFAEF180338A; Fri, 29 Mar 2019 12:26:43 +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 x2TCQeU0011875 for ; Fri, 29 Mar 2019 08:26:40 -0400 Received: by smtp.corp.redhat.com (Postfix) id DDC3F83E8A; Fri, 29 Mar 2019 12:26:40 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6454783E89 for ; Fri, 29 Mar 2019 12:26:40 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 29 Mar 2019 13:26:29 +0100 Message-Id: <31b4d1bc31b0a394fb2370086da3b372d0eca578.1553862332.git.pkrempa@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 Subject: [libvirt] [PATCH 1/6] qemu: caps: Separate capabilities based on qemu version 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Fri, 29 Mar 2019 12:26:46 +0000 (UTC) Content-Type: text/plain; charset="utf-8" virQEMUCapsInitQMPMonitor is massive now since it collects calls to the various probing functions and also version based capabilities. Split out the version based caps into a separate function. Signed-off-by: Peter Krempa Reviewed-by: Erik Skultety --- src/qemu/qemu_capabilities.c | 124 +++++++++++++++++++---------------- 1 file changed, 69 insertions(+), 55 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 56228e7a36..04199b1a76 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -4145,6 +4145,73 @@ virQEMUCapsInitQMPBasicArch(virQEMUCapsPtr qemuCaps) } +/** + * virQEMUCapsInitQMPVersionCaps: + * @qemuCaps: QEMU capabilities + * + * Add all QEMU capabilities based on version of QEMU. + */ +static void +virQEMUCapsInitQMPVersionCaps(virQEMUCapsPtr qemuCaps) +{ + if (qemuCaps->version >=3D 1006000) + virQEMUCapsSet(qemuCaps, QEMU_CAPS_DEVICE_VIDEO_PRIMARY); + + /* vmport option is supported v2.2.0 onwards */ + if (qemuCaps->version >=3D 2002000) + virQEMUCapsSet(qemuCaps, QEMU_CAPS_MACHINE_VMPORT_OPT); + + /* -cpu ...,aarch64=3Doff supported in v2.3.0 and onwards. But it + isn't detectable via qmp at this point */ + if (qemuCaps->arch =3D=3D VIR_ARCH_AARCH64 && + qemuCaps->version >=3D 2003000) + virQEMUCapsSet(qemuCaps, QEMU_CAPS_CPU_AARCH64_OFF); + + /* vhost-user supports multi-queue from v2.4.0 onwards, + * but there is no way to query for that capability */ + if (qemuCaps->version >=3D 2004000) + virQEMUCapsSet(qemuCaps, QEMU_CAPS_VHOSTUSER_MULTIQUEUE); + + /* smm option is supported from v2.4.0 */ + if (qemuCaps->version >=3D 2004000) + virQEMUCapsSet(qemuCaps, QEMU_CAPS_MACHINE_SMM_OPT); + + /* sdl -gl option is supported from v2.4.0 (qemu commit id 0b71a5d5) */ + if (qemuCaps->version >=3D 2004000) + virQEMUCapsSet(qemuCaps, QEMU_CAPS_SDL_GL); + + /* Since 2.4.50 ARM virt machine supports gic-version option */ + if (qemuCaps->version >=3D 2004050) + virQEMUCapsSet(qemuCaps, QEMU_CAPS_MACH_VIRT_GIC_VERSION); + + /* no way to query if -machine kernel_irqchip supports split */ + if (qemuCaps->version >=3D 2006000) + virQEMUCapsSet(qemuCaps, QEMU_CAPS_MACHINE_KERNEL_IRQCHIP_SPLIT); + + /* HPT resizing is supported since QEMU 2.10 on ppc64; unfortunately + * there's no sane way to probe for it */ + if (qemuCaps->version >=3D 2010000 && + ARCH_IS_PPC64(qemuCaps->arch)) { + virQEMUCapsSet(qemuCaps, QEMU_CAPS_MACHINE_PSERIES_RESIZE_HPT); + } + + /* '-display egl-headless' cmdline option is supported since QEMU 2.10= , but + * there's no way to probe it */ + if (qemuCaps->version >=3D 2010000) + virQEMUCapsSet(qemuCaps, QEMU_CAPS_EGL_HEADLESS); + + /* no way to query for -numa dist */ + if (qemuCaps->version >=3D 2010000) + virQEMUCapsSet(qemuCaps, QEMU_CAPS_NUMA_DIST); + + /* no way to query max-cpu-compat */ + if (qemuCaps->version >=3D 2010000 && + ARCH_IS_PPC64(qemuCaps->arch)) { + virQEMUCapsSet(qemuCaps, QEMU_CAPS_MACHINE_PSERIES_MAX_CPU_COMPAT); + } +} + + static int virQEMUCapsProbeQMPSchemaCapabilities(virQEMUCapsPtr qemuCaps, qemuMonitorPtr mon) @@ -4223,61 +4290,8 @@ virQEMUCapsInitQMPMonitor(virQEMUCapsPtr qemuCaps, virQEMUCapsInitQMPBasicArch(qemuCaps); - if (qemuCaps->version >=3D 1006000) - virQEMUCapsSet(qemuCaps, QEMU_CAPS_DEVICE_VIDEO_PRIMARY); - - /* vmport option is supported v2.2.0 onwards */ - if (qemuCaps->version >=3D 2002000) - virQEMUCapsSet(qemuCaps, QEMU_CAPS_MACHINE_VMPORT_OPT); - - /* -cpu ...,aarch64=3Doff supported in v2.3.0 and onwards. But it - isn't detectable via qmp at this point */ - if (qemuCaps->arch =3D=3D VIR_ARCH_AARCH64 && - qemuCaps->version >=3D 2003000) - virQEMUCapsSet(qemuCaps, QEMU_CAPS_CPU_AARCH64_OFF); - - /* vhost-user supports multi-queue from v2.4.0 onwards, - * but there is no way to query for that capability */ - if (qemuCaps->version >=3D 2004000) - virQEMUCapsSet(qemuCaps, QEMU_CAPS_VHOSTUSER_MULTIQUEUE); - - /* smm option is supported from v2.4.0 */ - if (qemuCaps->version >=3D 2004000) - virQEMUCapsSet(qemuCaps, QEMU_CAPS_MACHINE_SMM_OPT); - - /* sdl -gl option is supported from v2.4.0 (qemu commit id 0b71a5d5) */ - if (qemuCaps->version >=3D 2004000) - virQEMUCapsSet(qemuCaps, QEMU_CAPS_SDL_GL); - - /* Since 2.4.50 ARM virt machine supports gic-version option */ - if (qemuCaps->version >=3D 2004050) - virQEMUCapsSet(qemuCaps, QEMU_CAPS_MACH_VIRT_GIC_VERSION); - - /* no way to query if -machine kernel_irqchip supports split */ - if (qemuCaps->version >=3D 2006000) - virQEMUCapsSet(qemuCaps, QEMU_CAPS_MACHINE_KERNEL_IRQCHIP_SPLIT); - - /* HPT resizing is supported since QEMU 2.10 on ppc64; unfortunately - * there's no sane way to probe for it */ - if (qemuCaps->version >=3D 2010000 && - ARCH_IS_PPC64(qemuCaps->arch)) { - virQEMUCapsSet(qemuCaps, QEMU_CAPS_MACHINE_PSERIES_RESIZE_HPT); - } - - /* '-display egl-headless' cmdline option is supported since QEMU 2.10= , but - * there's no way to probe it */ - if (qemuCaps->version >=3D 2010000) - virQEMUCapsSet(qemuCaps, QEMU_CAPS_EGL_HEADLESS); - - /* no way to query for -numa dist */ - if (qemuCaps->version >=3D 2010000) - virQEMUCapsSet(qemuCaps, QEMU_CAPS_NUMA_DIST); - - /* no way to query max-cpu-compat */ - if (qemuCaps->version >=3D 2010000 && - ARCH_IS_PPC64(qemuCaps->arch)) { - virQEMUCapsSet(qemuCaps, QEMU_CAPS_MACHINE_PSERIES_MAX_CPU_COMPAT); - } + /* initiate all capapbilities based on qemu version */ + virQEMUCapsInitQMPVersionCaps(qemuCaps); if (virQEMUCapsProbeQMPCommands(qemuCaps, mon) < 0) goto cleanup; --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 06:38:37 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1553862421018331.0637680603385; Fri, 29 Mar 2019 05:27:01 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B2E0B308794D; Fri, 29 Mar 2019 12:26:59 +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 8EB0F183A5; Fri, 29 Mar 2019 12:26:59 +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 41A23181A006; Fri, 29 Mar 2019 12:26:59 +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 x2TCQfuC011883 for ; Fri, 29 Mar 2019 08:26:41 -0400 Received: by smtp.corp.redhat.com (Postfix) id AE01283E8E; Fri, 29 Mar 2019 12:26:41 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 35D0783E89 for ; Fri, 29 Mar 2019 12:26:41 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 29 Mar 2019 13:26:30 +0100 Message-Id: <690779854527cdd9b4533457c73d9a3f6f369c9f.1553862332.git.pkrempa@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 Subject: [libvirt] [PATCH 2/6] qemu: caps: Aggregate all caps post-processing into a function 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Fri, 29 Mar 2019 12:27:00 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Some caps are cleared according to some more advanced logic after detection. Split all that logic out into virQEMUCapsInitProcessCaps. Signed-off-by: Peter Krempa Reviewed-by: Erik Skultety --- src/qemu/qemu_capabilities.c | 85 +++++++++++++++++++++--------------- 1 file changed, 50 insertions(+), 35 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 04199b1a76..0e48022fdb 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -4212,6 +4212,55 @@ virQEMUCapsInitQMPVersionCaps(virQEMUCapsPtr qemuCap= s) } +/** + * virQEMUCapsInitProcessCaps: + * @qemuCaps: QEMU capabilities + * + * Some capability bits are enabled or disabled according to specific logi= c. + * This function collects all capability processing after the capabilities + * are detected. + */ +static void +virQEMUCapsInitProcessCaps(virQEMUCapsPtr qemuCaps) +{ + /* 'intel-iommu' shows up as a device since 2.2.0, but can + * not be used with -device until 2.7.0. Before that it + * requires -machine iommu=3Don. So we must clear the device + * capability we detected on older QEMUs + */ + if (qemuCaps->version < 2007000 && + virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_INTEL_IOMMU)) { + virQEMUCapsClear(qemuCaps, QEMU_CAPS_DEVICE_INTEL_IOMMU); + virQEMUCapsSet(qemuCaps, QEMU_CAPS_MACHINE_IOMMU); + } + + /* Prealloc on NVDIMMs is broken on older QEMUs leading to + * user data corruption. If we are dealing with such version + * of QEMU pretend we don't know how to NVDIMM. */ + if (qemuCaps->version < 2009000 && + virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_NVDIMM)) + virQEMUCapsClear(qemuCaps, QEMU_CAPS_DEVICE_NVDIMM); + + if (ARCH_IS_X86(qemuCaps->arch) && + virQEMUCapsGet(qemuCaps, QEMU_CAPS_QUERY_CPU_MODEL_EXPANSION)) + virQEMUCapsSet(qemuCaps, QEMU_CAPS_CPU_CACHE); + + if (ARCH_IS_S390(qemuCaps->arch)) { + /* Legacy assurance for QEMU_CAPS_CCW */ + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_CCW) && + virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_CCW)) + virQEMUCapsSet(qemuCaps, QEMU_CAPS_CCW); + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_CCW_CSSID_UNRESTRICTED)) + virQEMUCapsClear(qemuCaps, QEMU_CAPS_DEVICE_VFIO_CCW); + } + + /* To avoid guest ABI regression, blockdev shall be enabled only when + * we are able to pass the custom 'device_id' for SCSI disks and cdrom= s. */ + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_SCSI_DISK_DEVICE_ID)) + virQEMUCapsClear(qemuCaps, QEMU_CAPS_BLOCKDEV); +} + + static int virQEMUCapsProbeQMPSchemaCapabilities(virQEMUCapsPtr qemuCaps, qemuMonitorPtr mon) @@ -4320,17 +4369,6 @@ virQEMUCapsInitQMPMonitor(virQEMUCapsPtr qemuCaps, if (virQEMUCapsProbeQMPHostCPU(qemuCaps, mon, false) < 0) goto cleanup; - /* 'intel-iommu' shows up as a device since 2.2.0, but can - * not be used with -device until 2.7.0. Before that it - * requires -machine iommu=3Don. So we must clear the device - * capability we detected on older QEMUs - */ - if (qemuCaps->version < 2007000 && - virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_INTEL_IOMMU)) { - virQEMUCapsClear(qemuCaps, QEMU_CAPS_DEVICE_INTEL_IOMMU); - virQEMUCapsSet(qemuCaps, QEMU_CAPS_MACHINE_IOMMU); - } - /* GIC capabilities, eg. available GIC versions */ if ((qemuCaps->arch =3D=3D VIR_ARCH_AARCH64 || qemuCaps->arch =3D=3D VIR_ARCH_ARMV6L || @@ -4338,26 +4376,6 @@ virQEMUCapsInitQMPMonitor(virQEMUCapsPtr qemuCaps, virQEMUCapsProbeQMPGICCapabilities(qemuCaps, mon) < 0) goto cleanup; - /* Prealloc on NVDIMMs is broken on older QEMUs leading to - * user data corruption. If we are dealing with such version - * of QEMU pretend we don't know how to NVDIMM. */ - if (qemuCaps->version < 2009000 && - virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_NVDIMM)) - virQEMUCapsClear(qemuCaps, QEMU_CAPS_DEVICE_NVDIMM); - - if (ARCH_IS_X86(qemuCaps->arch) && - virQEMUCapsGet(qemuCaps, QEMU_CAPS_QUERY_CPU_MODEL_EXPANSION)) - virQEMUCapsSet(qemuCaps, QEMU_CAPS_CPU_CACHE); - - if (ARCH_IS_S390(qemuCaps->arch)) { - /* Legacy assurance for QEMU_CAPS_CCW */ - if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_CCW) && - virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_CCW)) - virQEMUCapsSet(qemuCaps, QEMU_CAPS_CCW); - if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_CCW_CSSID_UNRESTRICTED)) - virQEMUCapsClear(qemuCaps, QEMU_CAPS_DEVICE_VFIO_CCW); - } - /* Probe for SEV capabilities */ if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_SEV_GUEST)) { int rc =3D virQEMUCapsProbeQMPSEVCapabilities(qemuCaps, mon); @@ -4369,10 +4387,7 @@ virQEMUCapsInitQMPMonitor(virQEMUCapsPtr qemuCaps, virQEMUCapsClear(qemuCaps, QEMU_CAPS_SEV_GUEST); } - /* To avoid guest ABI regression, blockdev shall be enabled only when - * we are able to pass the custom 'device_id' for SCSI disks and cdrom= s. */ - if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_SCSI_DISK_DEVICE_ID)) - virQEMUCapsClear(qemuCaps, QEMU_CAPS_BLOCKDEV); + virQEMUCapsInitProcessCaps(qemuCaps); ret =3D 0; cleanup: --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 06:38:37 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 15538624075255.401154301565157; Fri, 29 Mar 2019 05:26:47 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B89DD30832CB; Fri, 29 Mar 2019 12:26:45 +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 15B67183C1; Fri, 29 Mar 2019 12:26:45 +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 65EC81803389; Fri, 29 Mar 2019 12:26:43 +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 x2TCQghx011890 for ; Fri, 29 Mar 2019 08:26:42 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8043E83E8A; Fri, 29 Mar 2019 12:26:42 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 07C3783E89 for ; Fri, 29 Mar 2019 12:26:41 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 29 Mar 2019 13:26:31 +0100 Message-Id: <7e393f116fcde74cbb96705b4425c4d61ed848e7.1553862332.git.pkrempa@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 Subject: [libvirt] [PATCH 3/6] qemu: capabilities: Move logic deciding whether to probe into probing functions 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Fri, 29 Mar 2019 12:26:46 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Most probing functions in virQEMUCapsInitQMPMonitor decide internally if there's anything to do and return success if there isn't. Move the decision logic for virQEMUCapsProbeQMPGICCapabilities, virQEMUCapsProbeQMPSEVCapabilities, and virQEMUCapsProbeQMPSchemaCapabiliti= es into the function itself so that virQEMUCapsInitQMPMonitor looks tidy. Signed-off-by: Peter Krempa Reviewed-by: Erik Skultety --- src/qemu/qemu_capabilities.c | 47 ++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 0e48022fdb..4c52dfc714 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -2738,6 +2738,11 @@ virQEMUCapsProbeQMPGICCapabilities(virQEMUCapsPtr qe= muCaps, virGICCapability *caps =3D NULL; int ncaps; + if (!(qemuCaps->arch =3D=3D VIR_ARCH_AARCH64 || + qemuCaps->arch =3D=3D VIR_ARCH_ARMV6L || + qemuCaps->arch =3D=3D VIR_ARCH_ARMV7L)) + return 0; + if ((ncaps =3D qemuMonitorGetGICCapabilities(mon, &caps)) < 0) return -1; @@ -2747,7 +2752,6 @@ virQEMUCapsProbeQMPGICCapabilities(virQEMUCapsPtr qem= uCaps, } -/* Returns -1 on error, 0 if SEV is not supported, 1 if SEV is supported */ static int virQEMUCapsProbeQMPSEVCapabilities(virQEMUCapsPtr qemuCaps, qemuMonitorPtr mon) @@ -2755,12 +2759,21 @@ virQEMUCapsProbeQMPSEVCapabilities(virQEMUCapsPtr q= emuCaps, int rc =3D -1; virSEVCapability *caps =3D NULL; - if ((rc =3D qemuMonitorGetSEVCapabilities(mon, &caps)) <=3D 0) - return rc; + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_SEV_GUEST)) + return 0; + + if ((rc =3D qemuMonitorGetSEVCapabilities(mon, &caps)) < 0) + return -1; + + /* SEV isn't actually supported */ + if (rc =3D=3D 0) { + virQEMUCapsClear(qemuCaps, QEMU_CAPS_SEV_GUEST); + return 0; + } virSEVCapabilitiesFree(qemuCaps->sevCapabilities); qemuCaps->sevCapabilities =3D caps; - return rc; + return 0; } @@ -4270,6 +4283,9 @@ virQEMUCapsProbeQMPSchemaCapabilities(virQEMUCapsPtr = qemuCaps, virHashTablePtr schema =3D NULL; size_t i; + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_QUERY_QMP_SCHEMA)) + return 0; + if (!(schemareply =3D qemuMonitorQueryQMPSchema(mon))) return -1; @@ -4363,29 +4379,14 @@ virQEMUCapsInitQMPMonitor(virQEMUCapsPtr qemuCaps, goto cleanup; if (virQEMUCapsProbeQMPMigrationCapabilities(qemuCaps, mon) < 0) goto cleanup; - if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_QUERY_QMP_SCHEMA) && - virQEMUCapsProbeQMPSchemaCapabilities(qemuCaps, mon) < 0) + if (virQEMUCapsProbeQMPSchemaCapabilities(qemuCaps, mon) < 0) goto cleanup; if (virQEMUCapsProbeQMPHostCPU(qemuCaps, mon, false) < 0) goto cleanup; - - /* GIC capabilities, eg. available GIC versions */ - if ((qemuCaps->arch =3D=3D VIR_ARCH_AARCH64 || - qemuCaps->arch =3D=3D VIR_ARCH_ARMV6L || - qemuCaps->arch =3D=3D VIR_ARCH_ARMV7L) && - virQEMUCapsProbeQMPGICCapabilities(qemuCaps, mon) < 0) + if (virQEMUCapsProbeQMPGICCapabilities(qemuCaps, mon) < 0) + goto cleanup; + if (virQEMUCapsProbeQMPSEVCapabilities(qemuCaps, mon) < 0) goto cleanup; - - /* Probe for SEV capabilities */ - if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_SEV_GUEST)) { - int rc =3D virQEMUCapsProbeQMPSEVCapabilities(qemuCaps, mon); - - if (rc < 0) - goto cleanup; - - if (rc =3D=3D 0) - virQEMUCapsClear(qemuCaps, QEMU_CAPS_SEV_GUEST); - } virQEMUCapsInitProcessCaps(qemuCaps); --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 06:38:37 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1553862428278836.9392966607896; Fri, 29 Mar 2019 05:27:08 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 0BEF936883; Fri, 29 Mar 2019 12:27:07 +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 D83911001E85; Fri, 29 Mar 2019 12:27:06 +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 944D83FB16; Fri, 29 Mar 2019 12:27:06 +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 x2TCQhbD011917 for ; Fri, 29 Mar 2019 08:26:43 -0400 Received: by smtp.corp.redhat.com (Postfix) id 536DB83E89; Fri, 29 Mar 2019 12:26:43 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id CE70D83E8D for ; Fri, 29 Mar 2019 12:26:42 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 29 Mar 2019 13:26:32 +0100 Message-Id: <37c2cb76dbe84a09c15a965578d938873c7cfbd5.1553862332.git.pkrempa@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 Subject: [libvirt] [PATCH 4/6] qemu: caps: Don't leak package name string in virQEMUCapsInitQMPMonitor 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Fri, 29 Mar 2019 12:27:07 +0000 (UTC) Content-Type: text/plain; charset="utf-8" If the detected qemu version is below our required version 'package' would be leaked. Signed-off-by: Peter Krempa Reviewed-by: Erik Skultety --- src/qemu/qemu_capabilities.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 4c52dfc714..e3db7ce71c 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -4322,7 +4322,7 @@ virQEMUCapsInitQMPMonitor(virQEMUCapsPtr qemuCaps, { int ret =3D -1; int major, minor, micro; - char *package =3D NULL; + VIR_AUTOFREE(char *) package =3D NULL; /* @mon is supposed to be locked by callee */ @@ -4347,7 +4347,7 @@ virQEMUCapsInitQMPMonitor(virQEMUCapsPtr qemuCaps, } qemuCaps->version =3D major * 1000000 + minor * 1000 + micro; - qemuCaps->package =3D package; + VIR_STEAL_PTR(qemuCaps->package, package); qemuCaps->usedQMP =3D true; if (virQEMUCapsInitQMPArch(qemuCaps, mon) < 0) --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 06:38:37 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1553862421171511.5563470174642; Fri, 29 Mar 2019 05:27:01 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AF49CC057F31; Fri, 29 Mar 2019 12:26:59 +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 874985D9D1; Fri, 29 Mar 2019 12:26:59 +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 3FF913FB10; Fri, 29 Mar 2019 12:26:59 +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 x2TCQieA012022 for ; Fri, 29 Mar 2019 08:26:44 -0400 Received: by smtp.corp.redhat.com (Postfix) id 22AF983E8A; Fri, 29 Mar 2019 12:26:44 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9F74183E89 for ; Fri, 29 Mar 2019 12:26:43 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 29 Mar 2019 13:26:33 +0100 Message-Id: <26c6338b1301f7d86eb731d91f855b9739d2ada5.1553862332.git.pkrempa@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 Subject: [libvirt] [PATCH 5/6] qemu: caps: Remove cleanup section in virQEMUCapsInitQMPMonitor 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Fri, 29 Mar 2019 12:27:00 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa Reviewed-by: Erik Skultety --- src/qemu/qemu_capabilities.c | 37 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index e3db7ce71c..2127cfb85c 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -4320,7 +4320,6 @@ int virQEMUCapsInitQMPMonitor(virQEMUCapsPtr qemuCaps, qemuMonitorPtr mon) { - int ret =3D -1; int major, minor, micro; VIR_AUTOFREE(char *) package =3D NULL; @@ -4331,7 +4330,7 @@ virQEMUCapsInitQMPMonitor(virQEMUCapsPtr qemuCaps, &package) < 0) { VIR_DEBUG("Failed to query monitor version %s", virGetLastErrorMessage()); - goto cleanup; + return -1; } VIR_DEBUG("Got version %d.%d.%d (%s)", @@ -4343,7 +4342,7 @@ virQEMUCapsInitQMPMonitor(virQEMUCapsPtr qemuCaps, _("QEMU version >=3D %d.%d.%d is required, but %d.%= d.%d found"), QEMU_MIN_MAJOR, QEMU_MIN_MINOR, QEMU_MIN_MICRO, major, minor, micro); - goto cleanup; + return -1; } qemuCaps->version =3D major * 1000000 + minor * 1000 + micro; @@ -4351,7 +4350,7 @@ virQEMUCapsInitQMPMonitor(virQEMUCapsPtr qemuCaps, qemuCaps->usedQMP =3D true; if (virQEMUCapsInitQMPArch(qemuCaps, mon) < 0) - goto cleanup; + return -1; virQEMUCapsInitQMPBasicArch(qemuCaps); @@ -4359,40 +4358,38 @@ virQEMUCapsInitQMPMonitor(virQEMUCapsPtr qemuCaps, virQEMUCapsInitQMPVersionCaps(qemuCaps); if (virQEMUCapsProbeQMPCommands(qemuCaps, mon) < 0) - goto cleanup; + return -1; /* Some capabilities may differ depending on KVM state */ if (virQEMUCapsProbeQMPKVMState(qemuCaps, mon) < 0) - goto cleanup; + return -1; if (virQEMUCapsProbeQMPEvents(qemuCaps, mon) < 0) - goto cleanup; + return -1; if (virQEMUCapsProbeQMPDevices(qemuCaps, mon) < 0) - goto cleanup; + return -1; if (virQEMUCapsProbeQMPMachineTypes(qemuCaps, mon) < 0) - goto cleanup; + return -1; if (virQEMUCapsProbeQMPCPUDefinitions(qemuCaps, mon, false) < 0) - goto cleanup; + return -1; if (virQEMUCapsProbeQMPTPM(qemuCaps, mon) < 0) - goto cleanup; + return -1; if (virQEMUCapsProbeQMPCommandLine(qemuCaps, mon) < 0) - goto cleanup; + return -1; if (virQEMUCapsProbeQMPMigrationCapabilities(qemuCaps, mon) < 0) - goto cleanup; + return -1; if (virQEMUCapsProbeQMPSchemaCapabilities(qemuCaps, mon) < 0) - goto cleanup; + return -1; if (virQEMUCapsProbeQMPHostCPU(qemuCaps, mon, false) < 0) - goto cleanup; + return -1; if (virQEMUCapsProbeQMPGICCapabilities(qemuCaps, mon) < 0) - goto cleanup; + return -1; if (virQEMUCapsProbeQMPSEVCapabilities(qemuCaps, mon) < 0) - goto cleanup; + return -1; virQEMUCapsInitProcessCaps(qemuCaps); - ret =3D 0; - cleanup: - return ret; + return 0; } --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 06:38:37 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1553862421185438.33227931419526; Fri, 29 Mar 2019 05:27:01 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AD6DF3E7; Fri, 29 Mar 2019 12:26:59 +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 886F85D9D4; Fri, 29 Mar 2019 12:26:59 +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 42C3D3FB11; Fri, 29 Mar 2019 12:26:59 +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 x2TCQiJl012061 for ; Fri, 29 Mar 2019 08:26:44 -0400 Received: by smtp.corp.redhat.com (Postfix) id E83A183E8A; Fri, 29 Mar 2019 12:26:44 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 700CA83E89 for ; Fri, 29 Mar 2019 12:26:44 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 29 Mar 2019 13:26:34 +0100 Message-Id: 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 Subject: [libvirt] [PATCH 6/6] qemu: caps: Remove pointless debug message in virQEMUCapsInitQMPMonitor 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Fri, 29 Mar 2019 12:27:00 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Failure of qemuMonitorGetVersion is fatal now that we only support QMP based qemus. Remove the debug message since we report an error already. Signed-off-by: Peter Krempa Reviewed-by: Erik Skultety --- src/qemu/qemu_capabilities.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 2127cfb85c..eb91295f93 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -4325,13 +4325,8 @@ virQEMUCapsInitQMPMonitor(virQEMUCapsPtr qemuCaps, /* @mon is supposed to be locked by callee */ - if (qemuMonitorGetVersion(mon, - &major, &minor, µ, - &package) < 0) { - VIR_DEBUG("Failed to query monitor version %s", - virGetLastErrorMessage()); + if (qemuMonitorGetVersion(mon, &major, &minor, µ, &package) < 0) return -1; - } VIR_DEBUG("Got version %d.%d.%d (%s)", major, minor, micro, NULLSTR(package)); --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list