From nobody Sun Apr 12 13:54:27 2026 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1715761673; cv=none; d=zohomail.com; s=zohoarc; b=jiDTQdDEjLHZX/87+XJf6CJ2l1tcEnzu+Pn7fkS1yB8bcmZ1ilTS74QGKqgUfTRJ3z82JhNY0yBkTkAQ6rNtgUv/FCjX18o0frbMuxrxa4xrTJ6WoE98pebJZGQnRUsMwPcHw7u6z+mRjg9VLnPkoR+xo1+F3fzbQy81XyXiuu4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1715761673; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=4Bgf6LSCanad63R5/DOmThzZldzMNUcREVOk9W2jQS4=; b=IFl5yfoBrbWgFmYtajRspXNGUGBduiI7KsGGlKgbUgU3O7UInLtAuQPVTs1Kg92e7O6E65TIfbETck40nKiz1VyGTV8PnuYtA0WzVNlxuDNd6RKyU9deyCn5fDOd7f+0XZP0vuH5/u9BG3hKktoy29ckXqPUOrO7I0rooKYsx1g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 171576167370445.97895892985309; Wed, 15 May 2024 01:27:53 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s79vT-00022o-23; Wed, 15 May 2024 04:23:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s79vP-000219-Db for qemu-devel@nongnu.org; Wed, 15 May 2024 04:23:47 -0400 Received: from mgamail.intel.com ([198.175.65.18]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s79vN-00074Z-Rg for qemu-devel@nongnu.org; Wed, 15 May 2024 04:23:47 -0400 Received: from orviesa006.jf.intel.com ([10.64.159.146]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 May 2024 01:23:43 -0700 Received: from unknown (HELO SPR-S2600BT.bj.intel.com) ([10.240.192.124]) by orviesa006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 May 2024 01:23:41 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1715761425; x=1747297425; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=WKdlfZRZ+uV5fBUr0kfvuBkrXP/k7AsBL/srbsncrLI=; b=dGn4CQCFVUdON0nAsjD900tf9ef/Cg7b3wThU2ipitGNBrJTCbF8otGk ANN5eY636n+TsyTGjrij5NW3IkThhRIG+8KTylQd+m8aCZB39IRBo6h43 JeXJVd3OCjl8nIipT9fxQBzmA3gVqbJsuLuKTZGD9BnOlYdN2J1nn99pD WIDgYZVkEFvZF5nGyOPo96lJAyumZAMvKzsWLBnFQ/sfOW0j1HAGxcNu0 8gKkFCL4cnPfS5NkL12GTWqiCe0GbPh+XlA6Ar2XR6rIEsb7NWvtgYGte SgDDv1XQ5QZ2pj6XSDogLiQI11bWxzmLlL5ADCTwDnknopVMakhdYHqly A==; X-CSE-ConnectionGUID: d220hxoLTbWMmgwWK6Escg== X-CSE-MsgGUID: yppCUdcZQEG+fS5FFOgcXA== X-IronPort-AV: E=McAfee;i="6600,9927,11073"; a="11961508" X-IronPort-AV: E=Sophos;i="6.08,161,1712646000"; d="scan'208";a="11961508" X-CSE-ConnectionGUID: Xhh9an+xQBSm7sNINrg3CQ== X-CSE-MsgGUID: xIw4OxI1RbiAOXJyVJxXig== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,161,1712646000"; d="scan'208";a="31396225" From: Zhenzhong Duan To: qemu-devel@nongnu.org Cc: alex.williamson@redhat.com, clg@redhat.com, eric.auger@redhat.com, chao.p.peng@intel.com, Zhenzhong Duan , Gerd Hoffmann Subject: [PATCH 01/16] vfio/display: Fix error path in call site of ramfb_setup() Date: Wed, 15 May 2024 16:20:26 +0800 Message-Id: <20240515082041.556571-2-zhenzhong.duan@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240515082041.556571-1-zhenzhong.duan@intel.com> References: <20240515082041.556571-1-zhenzhong.duan@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=198.175.65.18; envelope-from=zhenzhong.duan@intel.com; helo=mgamail.intel.com X-Spam_score_int: -53 X-Spam_score: -5.4 X-Spam_bar: ----- X-Spam_report: (-5.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.974, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1715761675595100006 Content-Type: text/plain; charset="utf-8" vfio_display_dmabuf_init() and vfio_display_region_init() calls ramfb_setup() without checking its return value. So we may run into a situation that vfio_display_probe() succeed but errp is set. This is risky and may lead to assert failure in error_setv(). Cc: Gerd Hoffmann Fixes: b290659fc3d ("hw/vfio/display: add ramfb support") Signed-off-by: Zhenzhong Duan Reviewed-by: C=C3=A9dric Le Goater --- hw/vfio/display.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hw/vfio/display.c b/hw/vfio/display.c index 1aa440c663..57c5ae0b2a 100644 --- a/hw/vfio/display.c +++ b/hw/vfio/display.c @@ -359,6 +359,9 @@ static int vfio_display_dmabuf_init(VFIOPCIDevice *vdev= , Error **errp) vdev); if (vdev->enable_ramfb) { vdev->dpy->ramfb =3D ramfb_setup(errp); + if (!vdev->dpy->ramfb) { + return -EINVAL; + } } vfio_display_edid_init(vdev); return 0; @@ -486,6 +489,9 @@ static int vfio_display_region_init(VFIOPCIDevice *vdev= , Error **errp) vdev); if (vdev->enable_ramfb) { vdev->dpy->ramfb =3D ramfb_setup(errp); + if (!vdev->dpy->ramfb) { + return -EINVAL; + } } return 0; } --=20 2.34.1 From nobody Sun Apr 12 13:54:27 2026 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1715761480; cv=none; d=zohomail.com; s=zohoarc; b=L4BKM6J8UtJs0o5nCm0iOG/2y1XuQJtryy8h7xB4mB5HqLoXIdTnoAdhB/xrBKIGyHlXdMVF0hA3bLpOL/6OtPCRfbVYLo9fmwfaqNOsEF/x75LQfhol7m8Kttg4+dETO1CgRrbtHR4A7XSALh4T9xsYS7TxmOZW1mK4pEDGTT0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1715761480; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=c3Ziy2AdBYSZFIWFRXQx4nnihJ3NL/yjhwwyeRxo6+s=; b=QHJugzUj8bcPkGmQv5fXMVbOLpiVqr8e67ozA1fX0Z+OYVaytUA32VsEbqWgTlX8QOE/9/6CgTD8uJBq3walLVAh6v1ku8ZudpdrESgl/lPwa0wvoZwSYdyJtG1is99qhbtHqEZPbFjCyhuBL/bRAXBVIdRMpRrmLUzOBqnUPGk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1715761480655774.984947373598; Wed, 15 May 2024 01:24:40 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s79vU-00025H-Os; Wed, 15 May 2024 04:23:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s79vQ-00022h-Gl for qemu-devel@nongnu.org; Wed, 15 May 2024 04:23:48 -0400 Received: from mgamail.intel.com ([198.175.65.18]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s79vO-00074o-Gt for qemu-devel@nongnu.org; Wed, 15 May 2024 04:23:48 -0400 Received: from orviesa006.jf.intel.com ([10.64.159.146]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 May 2024 01:23:45 -0700 Received: from unknown (HELO SPR-S2600BT.bj.intel.com) ([10.240.192.124]) by orviesa006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 May 2024 01:23:43 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1715761426; x=1747297426; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=JOzScZJ2jsxihaHCSeW8J3dqNSmB6ca86sov/7puN0I=; b=SSsoQeGsUFahbveYGtyvAEqbJaix9DxwDx1wlvlpAoXqCWaE4xU4ctm0 ZoJdKFxmO5ZyJHJHafjrE3JG8QI5OV8UHRUqWAl+D9xWMrtHlJtlZawVg xl+CktI6iIHM/xhFBKxBdqWLwGpp/+Ed5193IAYSPGHfZ0J76mJgPU4iM FXbky+uJ+XyDxl9SQNzP2/5yeYlM7PQaotLsUHGQOOQfOH0B8UbumXgoK n1PCCS3LP3zNE4g17DKbG+k/MKpX56CHle+Nioxy/BNUQ4yNu/q4VA46h zGI1Tdu8ZeF83sRe7uE+/Hza8Iqhrnq7mGiCuMyO0CJ8uQGWOiPDVcLrz A==; X-CSE-ConnectionGUID: MVAgABJGRDGVTWh5BAao2Q== X-CSE-MsgGUID: Gku6g596SvOyAzLlOR1nKA== X-IronPort-AV: E=McAfee;i="6600,9927,11073"; a="11961514" X-IronPort-AV: E=Sophos;i="6.08,161,1712646000"; d="scan'208";a="11961514" X-CSE-ConnectionGUID: V5bVsuC6SnGjI7R2cvku0Q== X-CSE-MsgGUID: 4svTlRkWQoW0cmuYjeUhzA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,161,1712646000"; d="scan'208";a="31396243" From: Zhenzhong Duan To: qemu-devel@nongnu.org Cc: alex.williamson@redhat.com, clg@redhat.com, eric.auger@redhat.com, chao.p.peng@intel.com, Zhenzhong Duan Subject: [PATCH 02/16] vfio/display: Make vfio_display_*() return bool Date: Wed, 15 May 2024 16:20:27 +0800 Message-Id: <20240515082041.556571-3-zhenzhong.duan@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240515082041.556571-1-zhenzhong.duan@intel.com> References: <20240515082041.556571-1-zhenzhong.duan@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=198.175.65.18; envelope-from=zhenzhong.duan@intel.com; helo=mgamail.intel.com X-Spam_score_int: -53 X-Spam_score: -5.4 X-Spam_bar: ----- X-Spam_report: (-5.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.974, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1715761482766100011 This is to follow the coding standand in qapi/error.h to return bool for bool-valued functions. Suggested-by: C=C3=A9dric Le Goater Signed-off-by: Zhenzhong Duan Reviewed-by: C=C3=A9dric Le Goater --- hw/vfio/pci.h | 2 +- hw/vfio/display.c | 20 ++++++++++---------- hw/vfio/pci.c | 3 +-- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/hw/vfio/pci.h b/hw/vfio/pci.h index 92cd62d115..a5ac9efd4b 100644 --- a/hw/vfio/pci.h +++ b/hw/vfio/pci.h @@ -232,7 +232,7 @@ int vfio_pci_igd_opregion_init(VFIOPCIDevice *vdev, Error **errp); =20 void vfio_display_reset(VFIOPCIDevice *vdev); -int vfio_display_probe(VFIOPCIDevice *vdev, Error **errp); +bool vfio_display_probe(VFIOPCIDevice *vdev, Error **errp); void vfio_display_finalize(VFIOPCIDevice *vdev); =20 extern const VMStateDescription vfio_display_vmstate; diff --git a/hw/vfio/display.c b/hw/vfio/display.c index 57c5ae0b2a..b562f4be74 100644 --- a/hw/vfio/display.c +++ b/hw/vfio/display.c @@ -346,11 +346,11 @@ static const GraphicHwOps vfio_display_dmabuf_ops =3D= { .ui_info =3D vfio_display_edid_ui_info, }; =20 -static int vfio_display_dmabuf_init(VFIOPCIDevice *vdev, Error **errp) +static bool vfio_display_dmabuf_init(VFIOPCIDevice *vdev, Error **errp) { if (!display_opengl) { error_setg(errp, "vfio-display-dmabuf: opengl not available"); - return -1; + return false; } =20 vdev->dpy =3D g_new0(VFIODisplay, 1); @@ -360,11 +360,11 @@ static int vfio_display_dmabuf_init(VFIOPCIDevice *vd= ev, Error **errp) if (vdev->enable_ramfb) { vdev->dpy->ramfb =3D ramfb_setup(errp); if (!vdev->dpy->ramfb) { - return -EINVAL; + return false; } } vfio_display_edid_init(vdev); - return 0; + return true; } =20 static void vfio_display_dmabuf_exit(VFIODisplay *dpy) @@ -481,7 +481,7 @@ static const GraphicHwOps vfio_display_region_ops =3D { .gfx_update =3D vfio_display_region_update, }; =20 -static int vfio_display_region_init(VFIOPCIDevice *vdev, Error **errp) +static bool vfio_display_region_init(VFIOPCIDevice *vdev, Error **errp) { vdev->dpy =3D g_new0(VFIODisplay, 1); vdev->dpy->con =3D graphic_console_init(DEVICE(vdev), 0, @@ -490,10 +490,10 @@ static int vfio_display_region_init(VFIOPCIDevice *vd= ev, Error **errp) if (vdev->enable_ramfb) { vdev->dpy->ramfb =3D ramfb_setup(errp); if (!vdev->dpy->ramfb) { - return -EINVAL; + return false; } } - return 0; + return true; } =20 static void vfio_display_region_exit(VFIODisplay *dpy) @@ -508,7 +508,7 @@ static void vfio_display_region_exit(VFIODisplay *dpy) =20 /* ---------------------------------------------------------------------- = */ =20 -int vfio_display_probe(VFIOPCIDevice *vdev, Error **errp) +bool vfio_display_probe(VFIOPCIDevice *vdev, Error **errp) { struct vfio_device_gfx_plane_info probe; int ret; @@ -531,11 +531,11 @@ int vfio_display_probe(VFIOPCIDevice *vdev, Error **e= rrp) =20 if (vdev->display =3D=3D ON_OFF_AUTO_AUTO) { /* not an error in automatic mode */ - return 0; + return true; } =20 error_setg(errp, "vfio: device doesn't support any (known) display met= hod"); - return -1; + return false; } =20 void vfio_display_finalize(VFIOPCIDevice *vdev) diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index c1adef5cf8..a447013a1d 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -3200,8 +3200,7 @@ static void vfio_realize(PCIDevice *pdev, Error **err= p) } =20 if (vdev->display !=3D ON_OFF_AUTO_OFF) { - ret =3D vfio_display_probe(vdev, errp); - if (ret) { + if (!vfio_display_probe(vdev, errp)) { goto out_deregister; } } --=20 2.34.1 From nobody Sun Apr 12 13:54:27 2026 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1715761480; cv=none; d=zohomail.com; s=zohoarc; b=dv1rLOsUiF10u5bjb5M5RD5vrzZhHrtf2Jwx/+WHQmlN7e66o2vdcbDpj/iIA2j7+hBnZhgJF4gBUGa/6VtGbT5ALfiu2hyqCuZVVOTO8vvKaONKyMGgW+m8jNbgEM65fsstlXKDnDpcyPNPynyYztvCS67F7b6uiNh1lIXyaP0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1715761480; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=B+90PjytwkJfci+5QuyMikal/rNxhN7qftwCvOKo+h8=; b=dmi0mdWL01ts3GSooAuf/q14KjmnVcBfB+dBIG/zQ1dE1SzuvW98grIVgpwL+mEBK+22b7Fpk90a1eduR+4wxsmeYxLNPNeGgFTCY27RwyuUTpBnEtgIQENIBNdV2GOJrRn6UpLANTfoDzYy78NzJGd9JklypJZigDz3mfyeGcA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17157614801611001.5245891005502; Wed, 15 May 2024 01:24:40 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s79vW-00025N-Du; Wed, 15 May 2024 04:23:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s79vT-00024u-Ll for qemu-devel@nongnu.org; Wed, 15 May 2024 04:23:51 -0400 Received: from mgamail.intel.com ([198.175.65.18]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s79vQ-00074Z-4f for qemu-devel@nongnu.org; Wed, 15 May 2024 04:23:49 -0400 Received: from orviesa006.jf.intel.com ([10.64.159.146]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 May 2024 01:23:47 -0700 Received: from unknown (HELO SPR-S2600BT.bj.intel.com) ([10.240.192.124]) by orviesa006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 May 2024 01:23:46 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1715761428; x=1747297428; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=VlvBMGhf60hfdjyVlOQFajbnzmL35wKO33aDoRdZ4yQ=; b=AU5JDGtA4moi1IghHFU1bJTH4AONY9nWikOaGsH/W9noqmxARxaHt/XX LnSveXEQXQQMyVxSgxWh+jbUHvTPXMlXojhp4zbJ9UQTPS2sjffJUsKsa 9AntcyBAF0PfE79jBbi7p+d207m5InHQCKKEF2WRDR0SjEKn9vJ3ohmO+ XkyxbBw9IStYlqAMEBzlo/fOlT6k+xnxWfNt0AdpYA1jLv45F4WJhDjpF PSQApNdALZHJMUAZxSCuhwephWsKiopqqdZpOjfYnqOaUOYsjn0phrc7r nqE+omGuQ0gxlC5IJ+0WvPIh7JgVy8BNx3NlE/1mwSolED1FI+tsObrtA w==; X-CSE-ConnectionGUID: sO9k9fcsRDyhPyJostEiIQ== X-CSE-MsgGUID: 5C3PlVMFTdqhARORZH0nwA== X-IronPort-AV: E=McAfee;i="6600,9927,11073"; a="11961521" X-IronPort-AV: E=Sophos;i="6.08,161,1712646000"; d="scan'208";a="11961521" X-CSE-ConnectionGUID: TpSNSSeIRa6LIfIzU+juxQ== X-CSE-MsgGUID: /au0eGn0Qs28TDlnELG2DQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,161,1712646000"; d="scan'208";a="31396255" From: Zhenzhong Duan To: qemu-devel@nongnu.org Cc: alex.williamson@redhat.com, clg@redhat.com, eric.auger@redhat.com, chao.p.peng@intel.com, Zhenzhong Duan Subject: [PATCH 03/16] vfio/helpers: Use g_autofree in hw/vfio/helpers.c Date: Wed, 15 May 2024 16:20:28 +0800 Message-Id: <20240515082041.556571-4-zhenzhong.duan@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240515082041.556571-1-zhenzhong.duan@intel.com> References: <20240515082041.556571-1-zhenzhong.duan@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=198.175.65.18; envelope-from=zhenzhong.duan@intel.com; helo=mgamail.intel.com X-Spam_score_int: -53 X-Spam_score: -5.4 X-Spam_bar: ----- X-Spam_report: (-5.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.974, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1715761481180100003 Content-Type: text/plain; charset="utf-8" Changed functions include vfio_set_irq_signaling() and vfio_region_setup(). Signed-off-by: Zhenzhong Duan --- hw/vfio/helpers.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/hw/vfio/helpers.c b/hw/vfio/helpers.c index 47b4096c05..0bb7b40a6a 100644 --- a/hw/vfio/helpers.c +++ b/hw/vfio/helpers.c @@ -111,7 +111,7 @@ int vfio_set_irq_signaling(VFIODevice *vbasedev, int in= dex, int subindex, int action, int fd, Error **errp) { ERRP_GUARD(); - struct vfio_irq_set *irq_set; + g_autofree struct vfio_irq_set *irq_set =3D NULL; int argsz, ret =3D 0; const char *name; int32_t *pfd; @@ -130,7 +130,6 @@ int vfio_set_irq_signaling(VFIODevice *vbasedev, int in= dex, int subindex, if (ioctl(vbasedev->fd, VFIO_DEVICE_SET_IRQS, irq_set)) { ret =3D -errno; } - g_free(irq_set); =20 if (!ret) { return 0; @@ -348,7 +347,7 @@ static int vfio_setup_region_sparse_mmaps(VFIORegion *r= egion, int vfio_region_setup(Object *obj, VFIODevice *vbasedev, VFIORegion *regio= n, int index, const char *name) { - struct vfio_region_info *info; + g_autofree struct vfio_region_info *info =3D NULL; int ret; =20 ret =3D vfio_get_region_info(vbasedev, index, &info); @@ -381,8 +380,6 @@ int vfio_region_setup(Object *obj, VFIODevice *vbasedev= , VFIORegion *region, } } =20 - g_free(info); - trace_vfio_region_setup(vbasedev->name, index, name, region->flags, region->fd_offset, region->size= ); return 0; --=20 2.34.1 From nobody Sun Apr 12 13:54:27 2026 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1715761539; cv=none; d=zohomail.com; s=zohoarc; b=hgSretX7lR2We1H/kKFof+4fwYv6W1T3UyCljwT39Ycxoq3RPln87ea3ugHz1SGvEq9+5MKzZ09Gy8i9bP3o5AUJCbSHtgkYvRD/IxCRelIcttweWgCfXCWhjQ+ioHtaVupvqB8ase2vDO46Nr0b7SF/XKstOnxn0C/Jm1ox7Ew= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1715761539; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=X5qzTxRjAoRENfK5cufbpQAv01JkF16w/volKm9N38c=; b=PFRM3YwPRnQNLigvzky8yNjcsejnJFQ4QAVRC/43J+2tNJ5AcJ2GHtQ1wRRKIfqoFjhcOhxfjhaVBFwAvs/pHHFbTMxzPiLduCOn4geeuEJHlbqqvFs+w692dTlKrz1W6wIR4ZJI5x1nPl9Gm2MUWwhb/SC7XMlrGu1WnqodzK0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1715761539453454.7203057086342; Wed, 15 May 2024 01:25:39 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s79vh-00027M-PS; Wed, 15 May 2024 04:24:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s79vY-000264-Tn; Wed, 15 May 2024 04:23:58 -0400 Received: from mgamail.intel.com ([198.175.65.18]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s79vV-00074Z-Nz; Wed, 15 May 2024 04:23:56 -0400 Received: from orviesa006.jf.intel.com ([10.64.159.146]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 May 2024 01:23:51 -0700 Received: from unknown (HELO SPR-S2600BT.bj.intel.com) ([10.240.192.124]) by orviesa006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 May 2024 01:23:48 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1715761433; x=1747297433; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ME8Ccft99hyp80mUdi/tVCtqy8NkyAzb5bwAQgSzodI=; b=EJAR7gLn+WcZO/hUb/ny4Cn2jteB94URWP4f4co7xU+9PnYSGitQAE06 88KPj/fOqglU5Bk6GV81obJMtoIYRmK5rc4DYp9NT3fHQKfIMQrfuBjbM 6RnrhvfAfcU4FcCRrnhz96UmPxHoS9QOP6yWYiWOJ+vhZJQKEj4FMdbgs lUlh5qab4wnaDXTbrvSshV+ArRJ5reFg70x5Uqt6W3qLy4L5hLzRZ7wWc Z3w06e5lPJ32HaizQOWEJKaRPEtGR84WXn4CRGK9AE27AJryyqUa6NYMb nRy+iOOWd2qiDcR+oQDn4s7nLZx6P0iJ7Qx5SCnuG2nG1PuxIstDds4d5 A==; X-CSE-ConnectionGUID: 7WuG/o6AQ4mijq1ES0ba3A== X-CSE-MsgGUID: wpPYXl3tSWGZeoUmtL9n6A== X-IronPort-AV: E=McAfee;i="6600,9927,11073"; a="11961534" X-IronPort-AV: E=Sophos;i="6.08,161,1712646000"; d="scan'208";a="11961534" X-CSE-ConnectionGUID: ONlcJmBfSkexF3Ho1jW2IQ== X-CSE-MsgGUID: u/Jal/LhQgG0QBf1nZXEjQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,161,1712646000"; d="scan'208";a="31396276" From: Zhenzhong Duan To: qemu-devel@nongnu.org Cc: alex.williamson@redhat.com, clg@redhat.com, eric.auger@redhat.com, chao.p.peng@intel.com, Zhenzhong Duan , Thomas Huth , Tony Krowiak , Halil Pasic , Jason Herne , Eric Farman , Matthew Rosato , qemu-s390x@nongnu.org (open list:S390 general arch...) Subject: [PATCH 04/16] vfio/helpers: Make vfio_set_irq_signaling() return bool Date: Wed, 15 May 2024 16:20:29 +0800 Message-Id: <20240515082041.556571-5-zhenzhong.duan@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240515082041.556571-1-zhenzhong.duan@intel.com> References: <20240515082041.556571-1-zhenzhong.duan@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=198.175.65.18; envelope-from=zhenzhong.duan@intel.com; helo=mgamail.intel.com X-Spam_score_int: -53 X-Spam_score: -5.4 X-Spam_bar: ----- X-Spam_report: (-5.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.974, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1715761541100100003 This is to follow the coding standand in qapi/error.h to return bool for bool-valued functions. Suggested-by: C=C3=A9dric Le Goater Signed-off-by: Zhenzhong Duan Reviewed-by: C=C3=A9dric Le Goater --- include/hw/vfio/vfio-common.h | 4 ++-- hw/vfio/ap.c | 8 +++---- hw/vfio/ccw.c | 8 +++---- hw/vfio/helpers.c | 18 ++++++---------- hw/vfio/pci.c | 40 ++++++++++++++++++----------------- hw/vfio/platform.c | 18 +++++++--------- 6 files changed, 46 insertions(+), 50 deletions(-) diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h index 2d8da32df4..fdce13f0f2 100644 --- a/include/hw/vfio/vfio-common.h +++ b/include/hw/vfio/vfio-common.h @@ -207,8 +207,8 @@ void vfio_spapr_container_deinit(VFIOContainer *contain= er); void vfio_disable_irqindex(VFIODevice *vbasedev, int index); void vfio_unmask_single_irqindex(VFIODevice *vbasedev, int index); void vfio_mask_single_irqindex(VFIODevice *vbasedev, int index); -int vfio_set_irq_signaling(VFIODevice *vbasedev, int index, int subindex, - int action, int fd, Error **errp); +bool vfio_set_irq_signaling(VFIODevice *vbasedev, int index, int subindex, + int action, int fd, Error **errp); void vfio_region_write(void *opaque, hwaddr addr, uint64_t data, unsigned size); uint64_t vfio_region_read(void *opaque, diff --git a/hw/vfio/ap.c b/hw/vfio/ap.c index ba653ef70f..d8a9615fee 100644 --- a/hw/vfio/ap.c +++ b/hw/vfio/ap.c @@ -117,8 +117,8 @@ static bool vfio_ap_register_irq_notifier(VFIOAPDevice = *vapdev, fd =3D event_notifier_get_fd(notifier); qemu_set_fd_handler(fd, fd_read, NULL, vapdev); =20 - if (vfio_set_irq_signaling(vdev, irq, 0, VFIO_IRQ_SET_ACTION_TRIGGER, = fd, - errp)) { + if (!vfio_set_irq_signaling(vdev, irq, 0, VFIO_IRQ_SET_ACTION_TRIGGER,= fd, + errp)) { qemu_set_fd_handler(fd, NULL, NULL, vapdev); event_notifier_cleanup(notifier); } @@ -141,8 +141,8 @@ static void vfio_ap_unregister_irq_notifier(VFIOAPDevic= e *vapdev, return; } =20 - if (vfio_set_irq_signaling(&vapdev->vdev, irq, 0, - VFIO_IRQ_SET_ACTION_TRIGGER, -1, &err)) { + if (!vfio_set_irq_signaling(&vapdev->vdev, irq, 0, + VFIO_IRQ_SET_ACTION_TRIGGER, -1, &err)) { warn_reportf_err(err, VFIO_MSG_PREFIX, vapdev->vdev.name); } =20 diff --git a/hw/vfio/ccw.c b/hw/vfio/ccw.c index 89bb980167..1f578a3c75 100644 --- a/hw/vfio/ccw.c +++ b/hw/vfio/ccw.c @@ -434,8 +434,8 @@ static bool vfio_ccw_register_irq_notifier(VFIOCCWDevic= e *vcdev, fd =3D event_notifier_get_fd(notifier); qemu_set_fd_handler(fd, fd_read, NULL, vcdev); =20 - if (vfio_set_irq_signaling(vdev, irq, 0, - VFIO_IRQ_SET_ACTION_TRIGGER, fd, errp)) { + if (!vfio_set_irq_signaling(vdev, irq, 0, + VFIO_IRQ_SET_ACTION_TRIGGER, fd, errp)) { qemu_set_fd_handler(fd, NULL, NULL, vcdev); event_notifier_cleanup(notifier); } @@ -464,8 +464,8 @@ static void vfio_ccw_unregister_irq_notifier(VFIOCCWDev= ice *vcdev, return; } =20 - if (vfio_set_irq_signaling(&vcdev->vdev, irq, 0, - VFIO_IRQ_SET_ACTION_TRIGGER, -1, &err)) { + if (!vfio_set_irq_signaling(&vcdev->vdev, irq, 0, + VFIO_IRQ_SET_ACTION_TRIGGER, -1, &err)) { warn_reportf_err(err, VFIO_MSG_PREFIX, vcdev->vdev.name); } =20 diff --git a/hw/vfio/helpers.c b/hw/vfio/helpers.c index 0bb7b40a6a..93e6fef6de 100644 --- a/hw/vfio/helpers.c +++ b/hw/vfio/helpers.c @@ -107,12 +107,12 @@ static const char *index_to_str(VFIODevice *vbasedev,= int index) } } =20 -int vfio_set_irq_signaling(VFIODevice *vbasedev, int index, int subindex, - int action, int fd, Error **errp) +bool vfio_set_irq_signaling(VFIODevice *vbasedev, int index, int subindex, + int action, int fd, Error **errp) { ERRP_GUARD(); g_autofree struct vfio_irq_set *irq_set =3D NULL; - int argsz, ret =3D 0; + int argsz; const char *name; int32_t *pfd; =20 @@ -127,15 +127,11 @@ int vfio_set_irq_signaling(VFIODevice *vbasedev, int = index, int subindex, pfd =3D (int32_t *)&irq_set->data; *pfd =3D fd; =20 - if (ioctl(vbasedev->fd, VFIO_DEVICE_SET_IRQS, irq_set)) { - ret =3D -errno; + if (!ioctl(vbasedev->fd, VFIO_DEVICE_SET_IRQS, irq_set)) { + return true; } =20 - if (!ret) { - return 0; - } - - error_setg_errno(errp, -ret, "VFIO_DEVICE_SET_IRQS failure"); + error_setg_errno(errp, errno, "VFIO_DEVICE_SET_IRQS failure"); =20 name =3D index_to_str(vbasedev, index); if (name) { @@ -146,7 +142,7 @@ int vfio_set_irq_signaling(VFIODevice *vbasedev, int in= dex, int subindex, error_prepend(errp, "Failed to %s %s eventfd signaling for interrupt ", fd < 0 ? "tear down" : "set up", action_to_str(action)); - return ret; + return false; } =20 /* diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index a447013a1d..358da4497b 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -147,10 +147,10 @@ static void vfio_intx_enable_kvm(VFIOPCIDevice *vdev,= Error **errp) goto fail_irqfd; } =20 - if (vfio_set_irq_signaling(&vdev->vbasedev, VFIO_PCI_INTX_IRQ_INDEX, 0, - VFIO_IRQ_SET_ACTION_UNMASK, - event_notifier_get_fd(&vdev->intx.unmask), - errp)) { + if (!vfio_set_irq_signaling(&vdev->vbasedev, VFIO_PCI_INTX_IRQ_INDEX, = 0, + VFIO_IRQ_SET_ACTION_UNMASK, + event_notifier_get_fd(&vdev->intx.unmask), + errp)) { goto fail_vfio; } =20 @@ -295,8 +295,8 @@ static int vfio_intx_enable(VFIOPCIDevice *vdev, Error = **errp) fd =3D event_notifier_get_fd(&vdev->intx.interrupt); qemu_set_fd_handler(fd, vfio_intx_interrupt, NULL, vdev); =20 - if (vfio_set_irq_signaling(&vdev->vbasedev, VFIO_PCI_INTX_IRQ_INDEX, 0, - VFIO_IRQ_SET_ACTION_TRIGGER, fd, errp)) { + if (!vfio_set_irq_signaling(&vdev->vbasedev, VFIO_PCI_INTX_IRQ_INDEX, = 0, + VFIO_IRQ_SET_ACTION_TRIGGER, fd, errp)) { qemu_set_fd_handler(fd, NULL, NULL, vdev); event_notifier_cleanup(&vdev->intx.interrupt); return -errno; @@ -590,9 +590,10 @@ static int vfio_msix_vector_do_use(PCIDevice *pdev, un= signed int nr, fd =3D event_notifier_get_fd(&vector->interrupt); } =20 - if (vfio_set_irq_signaling(&vdev->vbasedev, - VFIO_PCI_MSIX_IRQ_INDEX, nr, - VFIO_IRQ_SET_ACTION_TRIGGER, fd, &e= rr)) { + if (!vfio_set_irq_signaling(&vdev->vbasedev, + VFIO_PCI_MSIX_IRQ_INDEX, nr, + VFIO_IRQ_SET_ACTION_TRIGGER, fd, + &err)) { error_reportf_err(err, VFIO_MSG_PREFIX, vdev->vbasedev.nam= e); } } @@ -634,8 +635,9 @@ static void vfio_msix_vector_release(PCIDevice *pdev, u= nsigned int nr) int32_t fd =3D event_notifier_get_fd(&vector->interrupt); Error *err =3D NULL; =20 - if (vfio_set_irq_signaling(&vdev->vbasedev, VFIO_PCI_MSIX_IRQ_INDE= X, nr, - VFIO_IRQ_SET_ACTION_TRIGGER, fd, &err))= { + if (!vfio_set_irq_signaling(&vdev->vbasedev, VFIO_PCI_MSIX_IRQ_IND= EX, + nr, VFIO_IRQ_SET_ACTION_TRIGGER, fd, + &err)) { error_reportf_err(err, VFIO_MSG_PREFIX, vdev->vbasedev.name); } } @@ -2873,8 +2875,8 @@ static void vfio_register_err_notifier(VFIOPCIDevice = *vdev) fd =3D event_notifier_get_fd(&vdev->err_notifier); qemu_set_fd_handler(fd, vfio_err_notifier_handler, NULL, vdev); =20 - if (vfio_set_irq_signaling(&vdev->vbasedev, VFIO_PCI_ERR_IRQ_INDEX, 0, - VFIO_IRQ_SET_ACTION_TRIGGER, fd, &err)) { + if (!vfio_set_irq_signaling(&vdev->vbasedev, VFIO_PCI_ERR_IRQ_INDEX, 0, + VFIO_IRQ_SET_ACTION_TRIGGER, fd, &err)) { error_reportf_err(err, VFIO_MSG_PREFIX, vdev->vbasedev.name); qemu_set_fd_handler(fd, NULL, NULL, vdev); event_notifier_cleanup(&vdev->err_notifier); @@ -2890,8 +2892,8 @@ static void vfio_unregister_err_notifier(VFIOPCIDevic= e *vdev) return; } =20 - if (vfio_set_irq_signaling(&vdev->vbasedev, VFIO_PCI_ERR_IRQ_INDEX, 0, - VFIO_IRQ_SET_ACTION_TRIGGER, -1, &err)) { + if (!vfio_set_irq_signaling(&vdev->vbasedev, VFIO_PCI_ERR_IRQ_INDEX, 0, + VFIO_IRQ_SET_ACTION_TRIGGER, -1, &err)) { error_reportf_err(err, VFIO_MSG_PREFIX, vdev->vbasedev.name); } qemu_set_fd_handler(event_notifier_get_fd(&vdev->err_notifier), @@ -2938,8 +2940,8 @@ static void vfio_register_req_notifier(VFIOPCIDevice = *vdev) fd =3D event_notifier_get_fd(&vdev->req_notifier); qemu_set_fd_handler(fd, vfio_req_notifier_handler, NULL, vdev); =20 - if (vfio_set_irq_signaling(&vdev->vbasedev, VFIO_PCI_REQ_IRQ_INDEX, 0, - VFIO_IRQ_SET_ACTION_TRIGGER, fd, &err)) { + if (!vfio_set_irq_signaling(&vdev->vbasedev, VFIO_PCI_REQ_IRQ_INDEX, 0, + VFIO_IRQ_SET_ACTION_TRIGGER, fd, &err)) { error_reportf_err(err, VFIO_MSG_PREFIX, vdev->vbasedev.name); qemu_set_fd_handler(fd, NULL, NULL, vdev); event_notifier_cleanup(&vdev->req_notifier); @@ -2956,8 +2958,8 @@ static void vfio_unregister_req_notifier(VFIOPCIDevic= e *vdev) return; } =20 - if (vfio_set_irq_signaling(&vdev->vbasedev, VFIO_PCI_REQ_IRQ_INDEX, 0, - VFIO_IRQ_SET_ACTION_TRIGGER, -1, &err)) { + if (!vfio_set_irq_signaling(&vdev->vbasedev, VFIO_PCI_REQ_IRQ_INDEX, 0, + VFIO_IRQ_SET_ACTION_TRIGGER, -1, &err)) { error_reportf_err(err, VFIO_MSG_PREFIX, vdev->vbasedev.name); } qemu_set_fd_handler(event_notifier_get_fd(&vdev->req_notifier), diff --git a/hw/vfio/platform.c b/hw/vfio/platform.c index 2bd16096bb..3233ca8691 100644 --- a/hw/vfio/platform.c +++ b/hw/vfio/platform.c @@ -115,18 +115,17 @@ static int vfio_set_trigger_eventfd(VFIOINTp *intp, VFIODevice *vbasedev =3D &intp->vdev->vbasedev; int32_t fd =3D event_notifier_get_fd(intp->interrupt); Error *err =3D NULL; - int ret; =20 qemu_set_fd_handler(fd, (IOHandler *)handler, NULL, intp); =20 - ret =3D vfio_set_irq_signaling(vbasedev, intp->pin, 0, - VFIO_IRQ_SET_ACTION_TRIGGER, fd, &err); - if (ret) { + if (!vfio_set_irq_signaling(vbasedev, intp->pin, 0, + VFIO_IRQ_SET_ACTION_TRIGGER, fd, &err)) { error_reportf_err(err, VFIO_MSG_PREFIX, vbasedev->name); qemu_set_fd_handler(fd, NULL, NULL, NULL); + return -EINVAL; } =20 - return ret; + return 0; } =20 /* @@ -355,15 +354,14 @@ static int vfio_set_resample_eventfd(VFIOINTp *intp) int32_t fd =3D event_notifier_get_fd(intp->unmask); VFIODevice *vbasedev =3D &intp->vdev->vbasedev; Error *err =3D NULL; - int ret; =20 qemu_set_fd_handler(fd, NULL, NULL, NULL); - ret =3D vfio_set_irq_signaling(vbasedev, intp->pin, 0, - VFIO_IRQ_SET_ACTION_UNMASK, fd, &err); - if (ret) { + if (!vfio_set_irq_signaling(vbasedev, intp->pin, 0, + VFIO_IRQ_SET_ACTION_UNMASK, fd, &err)) { error_reportf_err(err, VFIO_MSG_PREFIX, vbasedev->name); + return -EINVAL; } - return ret; + return 0; } =20 /** --=20 2.34.1 From nobody Sun Apr 12 13:54:27 2026 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1715761480; cv=none; d=zohomail.com; s=zohoarc; b=gBJ3xeJhXdZDmI6V1V5Uctl4Oo3zSG/IgtmS5aBrvgJi2AMuKPXWArKpi9uBWaDxCR+2Q6rFuceFvqOqavtGfj8RYziFo9w5NRqK7+oeFxKYoLXsZ3uoTIDAJ5h4IMbLY01pdkjQkxTnGf/0VfCqzPideV5wBMZoLnkw13PI4bo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1715761480; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=QQy5I6RCaqkX0m8UhMO+pspnwQGfoAjiWnK7u1OJ5yE=; b=a7H8cbMfzfdr+sP9J4HWkA4rK/iMuB9vh9l58eS3CPZK7ixMQDHUsKU/rTIeJYxxsWdt+NS/hv46DXVFSOut6gk75Y2zuOpJ7ruKBQzwizLTnwsLOlf06Yu9qNiX1YxZQvHLXlSh5jjh8C8zjgEmLM0mRe3HQI5VLHqStFAmwOs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1715761480115505.0458598223802; Wed, 15 May 2024 01:24:40 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s79vk-00027P-4L; Wed, 15 May 2024 04:24:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s79vb-00026P-Ld; Wed, 15 May 2024 04:23:59 -0400 Received: from mgamail.intel.com ([198.175.65.18]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s79vZ-00076W-Kn; Wed, 15 May 2024 04:23:59 -0400 Received: from orviesa006.jf.intel.com ([10.64.159.146]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 May 2024 01:23:56 -0700 Received: from unknown (HELO SPR-S2600BT.bj.intel.com) ([10.240.192.124]) by orviesa006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 May 2024 01:23:52 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1715761437; x=1747297437; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Lntkgw5PKO06tI9Qq8U0Gkr91xV1qgI/qTGyCh5HD30=; b=Om5BBTBTET6OwwcjxI7/txH7KiLXfcFYrcSWP+gI7d/MhIIgQxRjlOs2 2kAmxu/loaGh4F/LZ2K8C4+lizVHel6qFv9eARpGMHhXNl3GxBKjSAx5O ziZGSrvaluW7tYH4X6UR0nfkPYEEMavjRj0sgQhV+9iTISje7CTY6E/zG vIHtptyZu1O2hgPIcbxi1IIw+jrkOxS9RXKp9bcSp0dpgtFxGeg9PJxkY h+PFWRWOR2SElbuRLyi2/NAkZIri7x1O4VVTxKThBHpA4FjzQ3baYkh7L chD/pxU9N0Q27U5Ajv7sPD7C4ezGfv8uA8wkcIV7oCKvxC77gXO9oX4Ly w==; X-CSE-ConnectionGUID: S3/7PRLMR6KDBSx6JJUkvw== X-CSE-MsgGUID: t25HXJIQTLGe9UjFR8oOSw== X-IronPort-AV: E=McAfee;i="6600,9927,11073"; a="11961541" X-IronPort-AV: E=Sophos;i="6.08,161,1712646000"; d="scan'208";a="11961541" X-CSE-ConnectionGUID: XaIfAKVJSsWywiMZP16a9g== X-CSE-MsgGUID: KN9xB6OJTkWUYGetvuMpxg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,161,1712646000"; d="scan'208";a="31396286" From: Zhenzhong Duan To: qemu-devel@nongnu.org Cc: alex.williamson@redhat.com, clg@redhat.com, eric.auger@redhat.com, chao.p.peng@intel.com, Zhenzhong Duan , Thomas Huth , Tony Krowiak , Halil Pasic , Jason Herne , Eric Farman , Matthew Rosato , qemu-s390x@nongnu.org (open list:S390 general arch...) Subject: [PATCH 05/16] vfio/helpers: Make vfio_device_get_name() return bool Date: Wed, 15 May 2024 16:20:30 +0800 Message-Id: <20240515082041.556571-6-zhenzhong.duan@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240515082041.556571-1-zhenzhong.duan@intel.com> References: <20240515082041.556571-1-zhenzhong.duan@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=198.175.65.18; envelope-from=zhenzhong.duan@intel.com; helo=mgamail.intel.com X-Spam_score_int: -53 X-Spam_score: -5.4 X-Spam_bar: ----- X-Spam_report: (-5.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.974, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1715761481003100001 This is to follow the coding standand in qapi/error.h to return bool for bool-valued functions. Suggested-by: C=C3=A9dric Le Goater Signed-off-by: Zhenzhong Duan Reviewed-by: Anthony Krowiak Reviewed-by: C=C3=A9dric Le Goater --- include/hw/vfio/vfio-common.h | 2 +- hw/vfio/ap.c | 2 +- hw/vfio/ccw.c | 2 +- hw/vfio/helpers.c | 8 ++++---- hw/vfio/pci.c | 2 +- hw/vfio/platform.c | 5 ++--- 6 files changed, 10 insertions(+), 11 deletions(-) diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h index fdce13f0f2..d9891c796f 100644 --- a/include/hw/vfio/vfio-common.h +++ b/include/hw/vfio/vfio-common.h @@ -280,7 +280,7 @@ int vfio_get_dirty_bitmap(const VFIOContainerBase *bcon= tainer, uint64_t iova, uint64_t size, ram_addr_t ram_addr, Error **errp= ); =20 /* Returns 0 on success, or a negative errno. */ -int vfio_device_get_name(VFIODevice *vbasedev, Error **errp); +bool vfio_device_get_name(VFIODevice *vbasedev, Error **errp); void vfio_device_set_fd(VFIODevice *vbasedev, const char *str, Error **err= p); void vfio_device_init(VFIODevice *vbasedev, int type, VFIODeviceOps *ops, DeviceState *dev, bool ram_discard); diff --git a/hw/vfio/ap.c b/hw/vfio/ap.c index d8a9615fee..c12531a788 100644 --- a/hw/vfio/ap.c +++ b/hw/vfio/ap.c @@ -158,7 +158,7 @@ static void vfio_ap_realize(DeviceState *dev, Error **e= rrp) VFIOAPDevice *vapdev =3D VFIO_AP_DEVICE(dev); VFIODevice *vbasedev =3D &vapdev->vdev; =20 - if (vfio_device_get_name(vbasedev, errp) < 0) { + if (!vfio_device_get_name(vbasedev, errp)) { return; } =20 diff --git a/hw/vfio/ccw.c b/hw/vfio/ccw.c index 1f578a3c75..8850ca17c8 100644 --- a/hw/vfio/ccw.c +++ b/hw/vfio/ccw.c @@ -588,7 +588,7 @@ static void vfio_ccw_realize(DeviceState *dev, Error **= errp) } } =20 - if (vfio_device_get_name(vbasedev, errp) < 0) { + if (!vfio_device_get_name(vbasedev, errp)) { return; } =20 diff --git a/hw/vfio/helpers.c b/hw/vfio/helpers.c index 93e6fef6de..a69b4411e5 100644 --- a/hw/vfio/helpers.c +++ b/hw/vfio/helpers.c @@ -605,7 +605,7 @@ bool vfio_has_region_cap(VFIODevice *vbasedev, int regi= on, uint16_t cap_type) return ret; } =20 -int vfio_device_get_name(VFIODevice *vbasedev, Error **errp) +bool vfio_device_get_name(VFIODevice *vbasedev, Error **errp) { ERRP_GUARD(); struct stat st; @@ -614,7 +614,7 @@ int vfio_device_get_name(VFIODevice *vbasedev, Error **= errp) if (stat(vbasedev->sysfsdev, &st) < 0) { error_setg_errno(errp, errno, "no such host device"); error_prepend(errp, VFIO_MSG_PREFIX, vbasedev->sysfsdev); - return -errno; + return false; } /* User may specify a name, e.g: VFIO platform device */ if (!vbasedev->name) { @@ -623,7 +623,7 @@ int vfio_device_get_name(VFIODevice *vbasedev, Error **= errp) } else { if (!vbasedev->iommufd) { error_setg(errp, "Use FD passing only with iommufd backend"); - return -EINVAL; + return false; } /* * Give a name with fd so any function printing out vbasedev->name @@ -634,7 +634,7 @@ int vfio_device_get_name(VFIODevice *vbasedev, Error **= errp) } } =20 - return 0; + return true; } =20 void vfio_device_set_fd(VFIODevice *vbasedev, const char *str, Error **err= p) diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index 358da4497b..aad012c348 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -2999,7 +2999,7 @@ static void vfio_realize(PCIDevice *pdev, Error **err= p) vdev->host.slot, vdev->host.function); } =20 - if (vfio_device_get_name(vbasedev, errp) < 0) { + if (!vfio_device_get_name(vbasedev, errp)) { return; } =20 diff --git a/hw/vfio/platform.c b/hw/vfio/platform.c index 3233ca8691..e1a32863d9 100644 --- a/hw/vfio/platform.c +++ b/hw/vfio/platform.c @@ -545,9 +545,8 @@ static int vfio_base_device_init(VFIODevice *vbasedev, = Error **errp) vbasedev->name); } =20 - ret =3D vfio_device_get_name(vbasedev, errp); - if (ret) { - return ret; + if (!vfio_device_get_name(vbasedev, errp)) { + return -EINVAL; } =20 if (!vfio_attach_device(vbasedev->name, vbasedev, --=20 2.34.1 From nobody Sun Apr 12 13:54:27 2026 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1715761675; cv=none; d=zohomail.com; s=zohoarc; b=RshZj8/KQP9HEGqoG5D4FDpMjiEy5Y2v2LNbAI/Le5GGVqLG88IwO3qGLJQ91u2IWks/7EV7B5swrN0EB8EM2vWuOGem5FdPOzkLkNDa7+A4kYTYR1V+HqCNCC0rSU7PFS1YRJb8zrcHfVJLpFgXXR+aE9Se0pw+Pn/yeaSoJfE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1715761675; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=9++hyv8IyB3KbVZEAjKBt9kHUMaf+771C8e6yFpVWGE=; b=cZkkfBYnlxNB+BsCzFhBx9vwH/uljdn/KdDGcuFLoRqSPOC26aeABkbp7I29YoXxtqave1pKvNDwR01QUmsCS9PQBXq3YFcg0tTPwBMISpV/gOxKAvpIWuqetzCfJhDiUpZKC/A/2LqRx7Ikj36KyCez/LETUsCrNN6bd4upWwI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1715761675819781.4550338915426; Wed, 15 May 2024 01:27:55 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s79vq-00028e-7p; Wed, 15 May 2024 04:24:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s79vd-00026Z-11 for qemu-devel@nongnu.org; Wed, 15 May 2024 04:24:01 -0400 Received: from mgamail.intel.com ([198.175.65.18]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s79va-00074Z-MZ for qemu-devel@nongnu.org; Wed, 15 May 2024 04:24:00 -0400 Received: from orviesa006.jf.intel.com ([10.64.159.146]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 May 2024 01:23:58 -0700 Received: from unknown (HELO SPR-S2600BT.bj.intel.com) ([10.240.192.124]) by orviesa006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 May 2024 01:23:56 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1715761438; x=1747297438; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=RS2o5MSumh7P4PM1sc4bKQuA+A9psNU/xRJ8H8A86Q0=; b=nWcCbMVxo7yC4inr1PFjEzQuYjb4hugbQv5fFl20xkWdOO9qrhoWpOtf QlQboHCoh0dgnuQbs1tQjH8n6pdHIxoKVIWoNA0DRIHUghlQfJqYWmVFj XXcwVAj+LBusEevjYXcwipKFBEizQEgfM5hbdcpHrkaj3iX+tWVswIfEZ /r6BtybuDVyHhOpapmvpNHm19Dp8VGmT9p31ATUvJts7IqSAwRB42zHNI e0Q0yHsqS7wjY0gypYgijGer7iveVFeTVQsRMFczOgbr1JkLSnuFAC0NU rSNp0xeEhEiFRXO5i4lAPWA6BrM8U3sKrTyV2rmd3BWcAbd+ycxgZx+dq w==; X-CSE-ConnectionGUID: pUQzI9S5QVaIl6RSkmDFYw== X-CSE-MsgGUID: lVjarqjbTfWJyuKbYYauRA== X-IronPort-AV: E=McAfee;i="6600,9927,11073"; a="11961546" X-IronPort-AV: E=Sophos;i="6.08,161,1712646000"; d="scan'208";a="11961546" X-CSE-ConnectionGUID: s0TqyAyBQWGrcOb0d05lNg== X-CSE-MsgGUID: js/AocQdSbuxZwzFgP1q3A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,161,1712646000"; d="scan'208";a="31396295" From: Zhenzhong Duan To: qemu-devel@nongnu.org Cc: alex.williamson@redhat.com, clg@redhat.com, eric.auger@redhat.com, chao.p.peng@intel.com, Zhenzhong Duan Subject: [PATCH 06/16] vfio/platform: Make vfio_populate_device() and vfio_base_device_init() return bool Date: Wed, 15 May 2024 16:20:31 +0800 Message-Id: <20240515082041.556571-7-zhenzhong.duan@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240515082041.556571-1-zhenzhong.duan@intel.com> References: <20240515082041.556571-1-zhenzhong.duan@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=198.175.65.18; envelope-from=zhenzhong.duan@intel.com; helo=mgamail.intel.com X-Spam_score_int: -53 X-Spam_score: -5.4 X-Spam_bar: ----- X-Spam_report: (-5.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.974, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1715761677567100011 This is to follow the coding standand in qapi/error.h to return bool for bool-valued functions. Suggested-by: C=C3=A9dric Le Goater Signed-off-by: Zhenzhong Duan Reviewed-by: C=C3=A9dric Le Goater --- hw/vfio/platform.c | 40 +++++++++++++++++----------------------- 1 file changed, 17 insertions(+), 23 deletions(-) diff --git a/hw/vfio/platform.c b/hw/vfio/platform.c index e1a32863d9..a85c199c76 100644 --- a/hw/vfio/platform.c +++ b/hw/vfio/platform.c @@ -441,7 +441,7 @@ static int vfio_platform_hot_reset_multi(VFIODevice *vb= asedev) * @errp: error object * */ -static int vfio_populate_device(VFIODevice *vbasedev, Error **errp) +static bool vfio_populate_device(VFIODevice *vbasedev, Error **errp) { VFIOINTp *intp, *tmp; int i, ret =3D -1; @@ -450,7 +450,7 @@ static int vfio_populate_device(VFIODevice *vbasedev, E= rror **errp) =20 if (!(vbasedev->flags & VFIO_DEVICE_FLAGS_PLATFORM)) { error_setg(errp, "this isn't a platform device"); - return ret; + return false; } =20 vdev->regions =3D g_new0(VFIORegion *, vbasedev->num_regions); @@ -487,12 +487,11 @@ static int vfio_populate_device(VFIODevice *vbasedev,= Error **errp) irq.flags); intp =3D vfio_init_intp(vbasedev, irq, errp); if (!intp) { - ret =3D -1; goto irq_err; } } } - return 0; + return true; irq_err: timer_del(vdev->mmap_timer); QLIST_FOREACH_SAFE(intp, &vdev->intp_list, next, tmp) { @@ -507,7 +506,7 @@ reg_error: g_free(vdev->regions[i]); } g_free(vdev->regions); - return ret; + return false; } =20 /* specialized functions for VFIO Platform devices */ @@ -527,10 +526,8 @@ static VFIODeviceOps vfio_platform_ops =3D { * fd retrieval, resource query. * Precondition: the device name must be initialized */ -static int vfio_base_device_init(VFIODevice *vbasedev, Error **errp) +static bool vfio_base_device_init(VFIODevice *vbasedev, Error **errp) { - int ret; - /* @fd takes precedence over @sysfsdev which takes precedence over @ho= st */ if (vbasedev->fd < 0 && vbasedev->sysfsdev) { g_free(vbasedev->name); @@ -538,7 +535,7 @@ static int vfio_base_device_init(VFIODevice *vbasedev, = Error **errp) } else if (vbasedev->fd < 0) { if (!vbasedev->name || strchr(vbasedev->name, '/')) { error_setg(errp, "wrong host device name"); - return -EINVAL; + return false; } =20 vbasedev->sysfsdev =3D g_strdup_printf("/sys/bus/platform/devices/= %s", @@ -546,20 +543,20 @@ static int vfio_base_device_init(VFIODevice *vbasedev= , Error **errp) } =20 if (!vfio_device_get_name(vbasedev, errp)) { - return -EINVAL; + return false; } =20 if (!vfio_attach_device(vbasedev->name, vbasedev, &address_space_memory, errp)) { - return -EINVAL; + return false; } =20 - ret =3D vfio_populate_device(vbasedev, errp); - if (ret) { - vfio_detach_device(vbasedev); + if (vfio_populate_device(vbasedev, errp)) { + return true; } =20 - return ret; + vfio_detach_device(vbasedev); + return false; } =20 /** @@ -576,7 +573,7 @@ static void vfio_platform_realize(DeviceState *dev, Err= or **errp) VFIOPlatformDevice *vdev =3D VFIO_PLATFORM_DEVICE(dev); SysBusDevice *sbdev =3D SYS_BUS_DEVICE(dev); VFIODevice *vbasedev =3D &vdev->vbasedev; - int i, ret; + int i; =20 qemu_mutex_init(&vdev->intp_mutex); =20 @@ -584,9 +581,8 @@ static void vfio_platform_realize(DeviceState *dev, Err= or **errp) vbasedev->sysfsdev : vbasedev->name, vdev->compat); =20 - ret =3D vfio_base_device_init(vbasedev, errp); - if (ret) { - goto out; + if (!vfio_base_device_init(vbasedev, errp)) { + goto init_err; } =20 if (!vdev->compat) { @@ -618,11 +614,9 @@ static void vfio_platform_realize(DeviceState *dev, Er= ror **errp) } sysbus_init_mmio(sbdev, vdev->regions[i]->mem); } -out: - if (!ret) { - return; - } + return; =20 +init_err: if (vdev->vbasedev.name) { error_prepend(errp, VFIO_MSG_PREFIX, vdev->vbasedev.name); } else { --=20 2.34.1 From nobody Sun Apr 12 13:54:27 2026 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1715761644; cv=none; d=zohomail.com; s=zohoarc; b=LneLUBD+tyuKkbsfr2h4yOyRECVII5vyFRo+pYWYBOZ+Ro0g61Ia73kaGvGYunma4+/9hhxe8bxN9S8m3Upk2f/34GOLWoYXt9ZMwu90mdSQVmnlcN6Jyvb3A0Qv79QQ/GKrna4cHn1q//CyEtqHFYduXNoAPqny6wn2J96d5JA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1715761644; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=47yuZS2oUW0WmoEhoMkiyP4x4lqMPOcNd87j20q6GJM=; b=ScgwLDHJOsUGfn3o47x5jUOtEMt8KCwYQdlx3ATbXY3eoeMuqMEN7zOowmI+F7KpNFn7p2W5SPJAeGlFKvzkKcXJmTNFk+0XCszvHsW0yExbaLmoIqjUyrEITgNZYeC0AWoFxsalYw/PJHtDnjB55xyc6n9CL+PAlARJhkgUOWs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1715761644189670.8480809539448; Wed, 15 May 2024 01:27:24 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s79vr-00029X-0P; Wed, 15 May 2024 04:24:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s79vh-00027N-0t; Wed, 15 May 2024 04:24:05 -0400 Received: from mgamail.intel.com ([198.175.65.18]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s79vf-00077F-75; Wed, 15 May 2024 04:24:04 -0400 Received: from orviesa006.jf.intel.com ([10.64.159.146]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 May 2024 01:24:01 -0700 Received: from unknown (HELO SPR-S2600BT.bj.intel.com) ([10.240.192.124]) by orviesa006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 May 2024 01:23:58 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1715761443; x=1747297443; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=pVxkfsRntqgELQhLG2u4uTRx0dfHIDo1WV5Xy3ttNnE=; b=KkEITxhSucd32jtTMVhVVUps9/jpUSRj7IHCpJmFQzkENKMvBThjsWkX zoWjTE8qjz92XLm59vXxKCrWoEnh3urxnCJOW1AZLjPV0kFFg/3cnbUE9 ZKydOq7TUhwPJRANqdNcLVIRiDWa+ucAX4tG7rl/7j/VT9AFCRkwSbbBp LlZStWzrsAAOTXAxhF2xw4qSWcN+YLzpXVarpCaoiSur/5pVQbDhm3Vpx BQZ2VpZpXyakJMnNPz7+EQ5VAWz/HQ3E8j495aS+yedX+/Rex9hvqtDwE IHTZRqD4s09Th+CHzSLy3S8rmsaW2G8WfjWqWkaeV1wpNnykWPzik5O39 A==; X-CSE-ConnectionGUID: 6PAsQVAPS/qtOcoZLDM3oA== X-CSE-MsgGUID: zu9qQNe8Twu1XTI9YzVYEw== X-IronPort-AV: E=McAfee;i="6600,9927,11073"; a="11961549" X-IronPort-AV: E=Sophos;i="6.08,161,1712646000"; d="scan'208";a="11961549" X-CSE-ConnectionGUID: 3LlnXr7tRraG1w9Q1YFgew== X-CSE-MsgGUID: KoCGEP9vSEWvncZ0IO+Ruw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,161,1712646000"; d="scan'208";a="31396304" From: Zhenzhong Duan To: qemu-devel@nongnu.org Cc: alex.williamson@redhat.com, clg@redhat.com, eric.auger@redhat.com, chao.p.peng@intel.com, Zhenzhong Duan , Thomas Huth , Eric Farman , Matthew Rosato , qemu-s390x@nongnu.org (open list:S390 general arch...) Subject: [PATCH 07/16] vfio/ccw: Make vfio_ccw_get_region() return a bool Date: Wed, 15 May 2024 16:20:32 +0800 Message-Id: <20240515082041.556571-8-zhenzhong.duan@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240515082041.556571-1-zhenzhong.duan@intel.com> References: <20240515082041.556571-1-zhenzhong.duan@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=198.175.65.18; envelope-from=zhenzhong.duan@intel.com; helo=mgamail.intel.com X-Spam_score_int: -53 X-Spam_score: -5.4 X-Spam_bar: ----- X-Spam_report: (-5.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.974, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1715761645425100002 Content-Type: text/plain; charset="utf-8" Since vfio_populate_device() takes an 'Error **' argument, best practices suggest to return a bool. See the qapi/error.h Rules section. Signed-off-by: Zhenzhong Duan Reviewed-by: C=C3=A9dric Le Goater --- hw/vfio/ccw.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/hw/vfio/ccw.c b/hw/vfio/ccw.c index 8850ca17c8..2600e62e37 100644 --- a/hw/vfio/ccw.c +++ b/hw/vfio/ccw.c @@ -474,7 +474,7 @@ static void vfio_ccw_unregister_irq_notifier(VFIOCCWDev= ice *vcdev, event_notifier_cleanup(notifier); } =20 -static void vfio_ccw_get_region(VFIOCCWDevice *vcdev, Error **errp) +static bool vfio_ccw_get_region(VFIOCCWDevice *vcdev, Error **errp) { VFIODevice *vdev =3D &vcdev->vdev; struct vfio_region_info *info; @@ -483,7 +483,7 @@ static void vfio_ccw_get_region(VFIOCCWDevice *vcdev, E= rror **errp) /* Sanity check device */ if (!(vdev->flags & VFIO_DEVICE_FLAGS_CCW)) { error_setg(errp, "vfio: Um, this isn't a vfio-ccw device"); - return; + return false; } =20 /* @@ -493,13 +493,13 @@ static void vfio_ccw_get_region(VFIOCCWDevice *vcdev,= Error **errp) if (vdev->num_regions < VFIO_CCW_CONFIG_REGION_INDEX + 1) { error_setg(errp, "vfio: too few regions (%u), expected at least %u= ", vdev->num_regions, VFIO_CCW_CONFIG_REGION_INDEX + 1); - return; + return false; } =20 ret =3D vfio_get_region_info(vdev, VFIO_CCW_CONFIG_REGION_INDEX, &info= ); if (ret) { error_setg_errno(errp, -ret, "vfio: Error getting config info"); - return; + return false; } =20 vcdev->io_region_size =3D info->size; @@ -553,7 +553,7 @@ static void vfio_ccw_get_region(VFIOCCWDevice *vcdev, E= rror **errp) g_free(info); } =20 - return; + return true; =20 out_err: g_free(vcdev->crw_region); @@ -561,7 +561,7 @@ out_err: g_free(vcdev->async_cmd_region); g_free(vcdev->io_region); g_free(info); - return; + return false; } =20 static void vfio_ccw_put_region(VFIOCCWDevice *vcdev) @@ -597,8 +597,7 @@ static void vfio_ccw_realize(DeviceState *dev, Error **= errp) goto out_attach_dev_err; } =20 - vfio_ccw_get_region(vcdev, &err); - if (err) { + if (!vfio_ccw_get_region(vcdev, &err)) { goto out_region_err; } =20 --=20 2.34.1 From nobody Sun Apr 12 13:54:27 2026 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1715761674; cv=none; d=zohomail.com; s=zohoarc; b=J3KJqzz0BbgMwhAeyGgz4KDsvpF2aVALw/HO2rB3jKc20jVTDRJkII46HYSz4QLBuBQlgGBFZZScWMrFqxxMgC1iHuK7+kwm4NHHMMKcbo7PKanQD9VuZ5F4WTZvSYv+Fr9gEe15vOymw6QHkI1EbHkNACxKFznCnumuxoYTVco= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1715761674; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Qovi9xGF20AdJ8YWsmZPXZO6J1d3g/QDLbrCY+rkZic=; b=YKBfv8mVRFDOd35h3L8Dz6tBWivYHphD6uzF2oeCdjqvl6B7Gzp0gcjG1YtY5u4oripqb/+G3rQMQahpF6kUGjcA2pR205G/9u1t3gBZACjCAaWwNdyic1+JdUOpraG4qG4VQ+wBv1EaPyaBkNnTgAceeZxk60ioxjQkB4+haHs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1715761674154816.9335660817769; Wed, 15 May 2024 01:27:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s79vq-00028h-7u; Wed, 15 May 2024 04:24:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s79vj-00027U-PC for qemu-devel@nongnu.org; Wed, 15 May 2024 04:24:08 -0400 Received: from mgamail.intel.com ([198.175.65.18]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s79vg-00077f-HH for qemu-devel@nongnu.org; Wed, 15 May 2024 04:24:06 -0400 Received: from orviesa006.jf.intel.com ([10.64.159.146]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 May 2024 01:24:03 -0700 Received: from unknown (HELO SPR-S2600BT.bj.intel.com) ([10.240.192.124]) by orviesa006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 May 2024 01:24:01 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1715761444; x=1747297444; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=cBfce4notNHYUMmAQiEeB90TnixUBjEhqnkhKjUAII4=; b=IC3UMrdtmLQcCaot0OBhJEqB9Yf31ruunNrlQy3sDGKiJ512gsaJG9HH WKPlMVwPrgtRSi2ObeZPyzCWzYG7oJ/3//nAVvBSxGdMtbCs9pq/6oy83 Hf2qsxiq2sA9wnGky9uQWXBTgvoevNHbK3vyL2fsyWrWcR3UjTkJQsx9+ EZMXqCn9i44mIVf1i/7/M5bGIfQTB7dDFS9TflqTrlcCOe2IDGqISpzBA bRnBwIgHP3Gm1uGiqvJxPBuFl9P7RHZMkD21RqFZMymyzZccNmlZH8skY 0RbpgBb91I51ibY5zAEByFr4oujmOMNOAWgn0SnYcp8/kTFRI314mP3TE w==; X-CSE-ConnectionGUID: j2u8Q1KrRU6zkkztCE7SqA== X-CSE-MsgGUID: UOuX/IsdTTukapVzJbzFTw== X-IronPort-AV: E=McAfee;i="6600,9927,11073"; a="11961552" X-IronPort-AV: E=Sophos;i="6.08,161,1712646000"; d="scan'208";a="11961552" X-CSE-ConnectionGUID: u4GGzq+WSnad5naacd16Lw== X-CSE-MsgGUID: M5SzkOMKSsyOe9LK+3xjrw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,161,1712646000"; d="scan'208";a="31396322" From: Zhenzhong Duan To: qemu-devel@nongnu.org Cc: alex.williamson@redhat.com, clg@redhat.com, eric.auger@redhat.com, chao.p.peng@intel.com, Zhenzhong Duan Subject: [PATCH 08/16] vfio/pci: Make vfio_intx_enable_kvm() return a bool Date: Wed, 15 May 2024 16:20:33 +0800 Message-Id: <20240515082041.556571-9-zhenzhong.duan@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240515082041.556571-1-zhenzhong.duan@intel.com> References: <20240515082041.556571-1-zhenzhong.duan@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=198.175.65.18; envelope-from=zhenzhong.duan@intel.com; helo=mgamail.intel.com X-Spam_score_int: -53 X-Spam_score: -5.4 X-Spam_bar: ----- X-Spam_report: (-5.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.974, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1715761675558100005 Content-Type: text/plain; charset="utf-8" Since vfio_intx_enable_kvm() takes an 'Error **' argument, best practices suggest to return a bool. See the qapi/error.h Rules section. Signed-off-by: Zhenzhong Duan Reviewed-by: C=C3=A9dric Le Goater --- hw/vfio/pci.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index aad012c348..12fb534d79 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -116,7 +116,7 @@ static void vfio_intx_eoi(VFIODevice *vbasedev) vfio_unmask_single_irqindex(vbasedev, VFIO_PCI_INTX_IRQ_INDEX); } =20 -static void vfio_intx_enable_kvm(VFIOPCIDevice *vdev, Error **errp) +static bool vfio_intx_enable_kvm(VFIOPCIDevice *vdev, Error **errp) { #ifdef CONFIG_KVM int irq_fd =3D event_notifier_get_fd(&vdev->intx.interrupt); @@ -124,7 +124,7 @@ static void vfio_intx_enable_kvm(VFIOPCIDevice *vdev, E= rror **errp) if (vdev->no_kvm_intx || !kvm_irqfds_enabled() || vdev->intx.route.mode !=3D PCI_INTX_ENABLED || !kvm_resamplefds_enabled()) { - return; + return true; } =20 /* Get to a known interrupt state */ @@ -161,7 +161,7 @@ static void vfio_intx_enable_kvm(VFIOPCIDevice *vdev, E= rror **errp) =20 trace_vfio_intx_enable_kvm(vdev->vbasedev.name); =20 - return; + return true; =20 fail_vfio: kvm_irqchip_remove_irqfd_notifier_gsi(kvm_state, &vdev->intx.interrupt, @@ -171,6 +171,9 @@ fail_irqfd: fail: qemu_set_fd_handler(irq_fd, vfio_intx_interrupt, NULL, vdev); vfio_unmask_single_irqindex(&vdev->vbasedev, VFIO_PCI_INTX_IRQ_INDEX); + return false; +#else + return true; #endif } =20 @@ -226,8 +229,7 @@ static void vfio_intx_update(VFIOPCIDevice *vdev, PCIIN= TxRoute *route) return; } =20 - vfio_intx_enable_kvm(vdev, &err); - if (err) { + if (!vfio_intx_enable_kvm(vdev, &err)) { warn_reportf_err(err, VFIO_MSG_PREFIX, vdev->vbasedev.name); } =20 @@ -302,8 +304,7 @@ static int vfio_intx_enable(VFIOPCIDevice *vdev, Error = **errp) return -errno; } =20 - vfio_intx_enable_kvm(vdev, &err); - if (err) { + if (!vfio_intx_enable_kvm(vdev, &err)) { warn_reportf_err(err, VFIO_MSG_PREFIX, vdev->vbasedev.name); } =20 --=20 2.34.1 From nobody Sun Apr 12 13:54:27 2026 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1715761655; cv=none; d=zohomail.com; s=zohoarc; b=W3BBX1RcF5RsRxZ0jbrkSQxqHoLdDF7jK7/+ZYaSkzmztuCUhswgZlFBXKRI3TFBnwAFsf9rUSg+4jTtopPG2GA0m/dGaGY4O4vObQDp1Ft/L0TnzSKWfLUSsHa99zLoOkwZZhCNg63AYf6NY2reSi2asrgRZOVNw/hi6lJU0ZU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1715761655; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=FkRYm0UcEBEnB4AU/KbTNJL74fnGJa8zcmUL2317tq8=; b=PjXCZYh/crt2V3z4KUCzMw2kQUx6p6tEpW4aDJnOSR3aVWvDTyOaO3NqDYqRxYy84dn8tBqkPm5cjTmV/PGlSw3sDnKY04Y7rKGve499Cy86qj+figtAS9skalPBoF44+dAQpCCfJ1L/Q5cOTiIH73FMKoiFaTv3mtYDVWml4vE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1715761655892765.8079526238579; Wed, 15 May 2024 01:27:35 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s79vu-0002CK-4V; Wed, 15 May 2024 04:24:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s79vk-00027Y-2n for qemu-devel@nongnu.org; Wed, 15 May 2024 04:24:08 -0400 Received: from mgamail.intel.com ([198.175.65.18]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s79vi-00077F-4h for qemu-devel@nongnu.org; Wed, 15 May 2024 04:24:07 -0400 Received: from orviesa006.jf.intel.com ([10.64.159.146]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 May 2024 01:24:05 -0700 Received: from unknown (HELO SPR-S2600BT.bj.intel.com) ([10.240.192.124]) by orviesa006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 May 2024 01:24:04 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1715761446; x=1747297446; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=3F9TJNc91782pIR+urG++O32ZvDEvSmI38+CJJPu0Qc=; b=NS0mNBm+ymIUjRFyqxSGLc8RXfNYFvHy/1pKfmyE/+SZ+VfiobrxTDgX igVxSz0x4Usqaxh0Jarfl7Pn+RBs5H0aYEjVaZMoJNonOAb5kuCWqLM+j kHfqFi7Ao2aY/94NRIA4nI1KwMLHYVyqgP6iKqF2T5a/wxoDu4vmr06Ik Xny1LSuZssd/DBpiXko/1oOe+Xrt0Gx6Gh9YNb3LmfResvBBurxCKdBao 8OeeUntXD29j4VJ1c9PckfLW+OsOCnI6T2jrNly9SyNzi6lieg8kxNWWy DtUmaT6UytZksDg+qOPoaQqWB/xBcCtgvtkGprnFRdOY7MimaHogM+o23 g==; X-CSE-ConnectionGUID: ifXxBBxhSCyxcZY7+bnk6Q== X-CSE-MsgGUID: OdL6Nf4uRVyYWxh0Z5Ih9A== X-IronPort-AV: E=McAfee;i="6600,9927,11073"; a="11961554" X-IronPort-AV: E=Sophos;i="6.08,161,1712646000"; d="scan'208";a="11961554" X-CSE-ConnectionGUID: 9Kmycv1RQX+bGzppb813mQ== X-CSE-MsgGUID: yzCV3LItQ8qLrq2Ta4D3mg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,161,1712646000"; d="scan'208";a="31396337" From: Zhenzhong Duan To: qemu-devel@nongnu.org Cc: alex.williamson@redhat.com, clg@redhat.com, eric.auger@redhat.com, chao.p.peng@intel.com, Zhenzhong Duan Subject: [PATCH 09/16] vfio/pci: Make vfio_pci_relocate_msix() and vfio_msix_early_setup() return a bool Date: Wed, 15 May 2024 16:20:34 +0800 Message-Id: <20240515082041.556571-10-zhenzhong.duan@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240515082041.556571-1-zhenzhong.duan@intel.com> References: <20240515082041.556571-1-zhenzhong.duan@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=198.175.65.18; envelope-from=zhenzhong.duan@intel.com; helo=mgamail.intel.com X-Spam_score_int: -53 X-Spam_score: -5.4 X-Spam_bar: ----- X-Spam_report: (-5.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.974, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1715761657503100003 Content-Type: text/plain; charset="utf-8" Since vfio_pci_relocate_msix() and vfio_msix_early_setup() takes an 'Error **' argument, best practices suggest to return a bool. See the qapi/error.h Rules section. Signed-off-by: Zhenzhong Duan --- hw/vfio/pci.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index 12fb534d79..379cbad757 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -1450,13 +1450,13 @@ static void vfio_pci_fixup_msix_region(VFIOPCIDevic= e *vdev) } } =20 -static void vfio_pci_relocate_msix(VFIOPCIDevice *vdev, Error **errp) +static bool vfio_pci_relocate_msix(VFIOPCIDevice *vdev, Error **errp) { int target_bar =3D -1; size_t msix_sz; =20 if (!vdev->msix || vdev->msix_relo =3D=3D OFF_AUTOPCIBAR_OFF) { - return; + return true; } =20 /* The actual minimum size of MSI-X structures */ @@ -1479,7 +1479,7 @@ static void vfio_pci_relocate_msix(VFIOPCIDevice *vde= v, Error **errp) if (target_bar < 0) { error_setg(errp, "No automatic MSI-X relocation available for " "device %04x:%04x", vdev->vendor_id, vdev->device_i= d); - return; + return false; } } else { target_bar =3D (int)(vdev->msix_relo - OFF_AUTOPCIBAR_BAR0); @@ -1489,7 +1489,7 @@ static void vfio_pci_relocate_msix(VFIOPCIDevice *vde= v, Error **errp) if (vdev->bars[target_bar].ioport) { error_setg(errp, "Invalid MSI-X relocation BAR %d, " "I/O port BAR", target_bar); - return; + return false; } =20 /* Cannot use a BAR in the "shadow" of a 64-bit BAR */ @@ -1497,7 +1497,7 @@ static void vfio_pci_relocate_msix(VFIOPCIDevice *vde= v, Error **errp) target_bar > 0 && vdev->bars[target_bar - 1].mem64) { error_setg(errp, "Invalid MSI-X relocation BAR %d, " "consumed by 64-bit BAR %d", target_bar, target_bar - 1= ); - return; + return false; } =20 /* 2GB max size for 32-bit BARs, cannot double if already > 1G */ @@ -1505,7 +1505,7 @@ static void vfio_pci_relocate_msix(VFIOPCIDevice *vde= v, Error **errp) !vdev->bars[target_bar].mem64) { error_setg(errp, "Invalid MSI-X relocation BAR %d, " "no space to extend 32-bit BAR", target_bar); - return; + return false; } =20 /* @@ -1540,6 +1540,7 @@ static void vfio_pci_relocate_msix(VFIOPCIDevice *vde= v, Error **errp) =20 trace_vfio_msix_relo(vdev->vbasedev.name, vdev->msix->table_bar, vdev->msix->table_offset); + return true; } =20 /* @@ -1550,7 +1551,7 @@ static void vfio_pci_relocate_msix(VFIOPCIDevice *vde= v, Error **errp) * need to first look for where the MSI-X table lives. So we * unfortunately split MSI-X setup across two functions. */ -static void vfio_msix_early_setup(VFIOPCIDevice *vdev, Error **errp) +static bool vfio_msix_early_setup(VFIOPCIDevice *vdev, Error **errp) { uint8_t pos; uint16_t ctrl; @@ -1562,25 +1563,25 @@ static void vfio_msix_early_setup(VFIOPCIDevice *vd= ev, Error **errp) =20 pos =3D pci_find_capability(&vdev->pdev, PCI_CAP_ID_MSIX); if (!pos) { - return; + return true; } =20 if (pread(fd, &ctrl, sizeof(ctrl), vdev->config_offset + pos + PCI_MSIX_FLAGS) !=3D sizeof(ctrl= )) { error_setg_errno(errp, errno, "failed to read PCI MSIX FLAGS"); - return; + return false; } =20 if (pread(fd, &table, sizeof(table), vdev->config_offset + pos + PCI_MSIX_TABLE) !=3D sizeof(tabl= e)) { error_setg_errno(errp, errno, "failed to read PCI MSIX TABLE"); - return; + return false; } =20 if (pread(fd, &pba, sizeof(pba), vdev->config_offset + pos + PCI_MSIX_PBA) !=3D sizeof(pba)) { error_setg_errno(errp, errno, "failed to read PCI MSIX PBA"); - return; + return false; } =20 ctrl =3D le16_to_cpu(ctrl); @@ -1598,7 +1599,7 @@ static void vfio_msix_early_setup(VFIOPCIDevice *vdev= , Error **errp) if (ret < 0) { error_setg_errno(errp, -ret, "failed to get MSI-X irq info"); g_free(msix); - return; + return false; } =20 msix->noresize =3D !!(irq_info.flags & VFIO_IRQ_INFO_NORESIZE); @@ -1630,7 +1631,7 @@ static void vfio_msix_early_setup(VFIOPCIDevice *vdev= , Error **errp) error_setg(errp, "hardware reports invalid configuration, " "MSIX PBA outside of specified BAR"); g_free(msix); - return; + return false; } } =20 @@ -1641,7 +1642,7 @@ static void vfio_msix_early_setup(VFIOPCIDevice *vdev= , Error **errp) =20 vfio_pci_fixup_msix_region(vdev); =20 - vfio_pci_relocate_msix(vdev, errp); + return vfio_pci_relocate_msix(vdev, errp); } =20 static int vfio_msix_setup(VFIOPCIDevice *vdev, int pos, Error **errp) @@ -3130,8 +3131,7 @@ static void vfio_realize(PCIDevice *pdev, Error **err= p) =20 vfio_bars_prepare(vdev); =20 - vfio_msix_early_setup(vdev, &err); - if (err) { + if (!vfio_msix_early_setup(vdev, &err)) { error_propagate(errp, err); goto error; } --=20 2.34.1 From nobody Sun Apr 12 13:54:27 2026 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1715761573; cv=none; d=zohomail.com; s=zohoarc; b=cE43nooBmTKdxKuehV+6cu7RUHusxNRSb0ymM+gxfltdjbGg8xV8Ysb2QMFMDixIz0nU6GyE2/ZVPJlnwzE4+hoVr/Kvas8MpfYA2w4m/2ebiUv4VovgruoSJww6lfgdTIFGOq6F/U2DtNevHmjvF4NUHvXeDb3sNRtAVOyyKgI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1715761573; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=3020UUdYYwh0ngA1vASP5oiMceUoyE/BuChOtGg3Pzw=; b=K4aB3TaPCWNA0VidyW1MPQLuAXNApqyfyAka2wb7sYuyOBRXzBKGHpXVtHhQ4Mr1KSeutdOWSJvo9OEI4qofaDRoxeVwYFwavwkIKWF3aZWsmdKcBe3r3vsh2KXprcF4/APGeq+wSAPW9WFiNHcqwJYYHSCjTP/SzBf8jFTwK/U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1715761573971361.88790211091236; Wed, 15 May 2024 01:26:13 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s79vv-0002D4-3S; Wed, 15 May 2024 04:24:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s79vm-00027x-3K for qemu-devel@nongnu.org; Wed, 15 May 2024 04:24:11 -0400 Received: from mgamail.intel.com ([198.175.65.18]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s79vk-00077f-BQ for qemu-devel@nongnu.org; Wed, 15 May 2024 04:24:09 -0400 Received: from orviesa006.jf.intel.com ([10.64.159.146]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 May 2024 01:24:07 -0700 Received: from unknown (HELO SPR-S2600BT.bj.intel.com) ([10.240.192.124]) by orviesa006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 May 2024 01:24:06 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1715761448; x=1747297448; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=RbeV441iM22XR842XrI5xKUNjvxFueaKXj0QFB2gaYg=; b=CmunakbtPibqwtBvlubYyq2zjlMJgIzAdZCaGOQ0E9aGIYNFeV5PovUq hI+i2eKBvCJDqnfhj+QXPR1tiIWVObfBVWjzLLMKxmlI5STFtnM6Z0jWP Tm9t/YaOaMZTrxnXKtthTpU/PPZn+IFe+SI5cp81y+9pWpBnu+Y2CPttZ G2CcFszC6WM97lRRGHM+BBTsfMaaz2RVIpIkWXFdiw/EJA/UFDwE79oZ6 /VBb7F1eWOsPhkyuvbV87odeUGc2G4UMw163/gO+ux8pKzZBzwjkGCDSx JoD3LOCkHRqevgDIhgD3xwdYkfI4PNqL5a/fK+g/HtVqd5pDJHJ/0GiJN w==; X-CSE-ConnectionGUID: PtSqgykVTdqdgIwt48rnxw== X-CSE-MsgGUID: Wu2mAkK1ToaPiQHL0lohHA== X-IronPort-AV: E=McAfee;i="6600,9927,11073"; a="11961557" X-IronPort-AV: E=Sophos;i="6.08,161,1712646000"; d="scan'208";a="11961557" X-CSE-ConnectionGUID: v8vu6oSETlmQABlObGkGLA== X-CSE-MsgGUID: 2YDYzfceS8W2YCaACdlurg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,161,1712646000"; d="scan'208";a="31396347" From: Zhenzhong Duan To: qemu-devel@nongnu.org Cc: alex.williamson@redhat.com, clg@redhat.com, eric.auger@redhat.com, chao.p.peng@intel.com, Zhenzhong Duan Subject: [PATCH 10/16] vfio/pci: Make vfio_populate_device() return a bool Date: Wed, 15 May 2024 16:20:35 +0800 Message-Id: <20240515082041.556571-11-zhenzhong.duan@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240515082041.556571-1-zhenzhong.duan@intel.com> References: <20240515082041.556571-1-zhenzhong.duan@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=198.175.65.18; envelope-from=zhenzhong.duan@intel.com; helo=mgamail.intel.com X-Spam_score_int: -53 X-Spam_score: -5.4 X-Spam_bar: ----- X-Spam_report: (-5.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.974, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1715761575142100003 Content-Type: text/plain; charset="utf-8" Since vfio_populate_device() takes an 'Error **' argument, best practices suggest to return a bool. See the qapi/error.h Rules section. Signed-off-by: Zhenzhong Duan --- hw/vfio/pci.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index 379cbad757..c091d21adf 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -2740,7 +2740,7 @@ int vfio_populate_vga(VFIOPCIDevice *vdev, Error **er= rp) return 0; } =20 -static void vfio_populate_device(VFIOPCIDevice *vdev, Error **errp) +static bool vfio_populate_device(VFIOPCIDevice *vdev, Error **errp) { VFIODevice *vbasedev =3D &vdev->vbasedev; struct vfio_region_info *reg_info; @@ -2750,18 +2750,18 @@ static void vfio_populate_device(VFIOPCIDevice *vde= v, Error **errp) /* Sanity check device */ if (!(vbasedev->flags & VFIO_DEVICE_FLAGS_PCI)) { error_setg(errp, "this isn't a PCI device"); - return; + return false; } =20 if (vbasedev->num_regions < VFIO_PCI_CONFIG_REGION_INDEX + 1) { error_setg(errp, "unexpected number of io regions %u", vbasedev->num_regions); - return; + return false; } =20 if (vbasedev->num_irqs < VFIO_PCI_MSIX_IRQ_INDEX + 1) { error_setg(errp, "unexpected number of irqs %u", vbasedev->num_irq= s); - return; + return false; } =20 for (i =3D VFIO_PCI_BAR0_REGION_INDEX; i < VFIO_PCI_ROM_REGION_INDEX; = i++) { @@ -2773,7 +2773,7 @@ static void vfio_populate_device(VFIOPCIDevice *vdev,= Error **errp) =20 if (ret) { error_setg_errno(errp, -ret, "failed to get region %d info", i= ); - return; + return false; } =20 QLIST_INIT(&vdev->bars[i].quirks); @@ -2783,7 +2783,7 @@ static void vfio_populate_device(VFIOPCIDevice *vdev,= Error **errp) VFIO_PCI_CONFIG_REGION_INDEX, ®_info); if (ret) { error_setg_errno(errp, -ret, "failed to get config info"); - return; + return false; } =20 trace_vfio_populate_device_config(vdev->vbasedev.name, @@ -2804,7 +2804,7 @@ static void vfio_populate_device(VFIOPCIDevice *vdev,= Error **errp) if (ret) { error_append_hint(errp, "device does not support " "requested feature x-vga\n"); - return; + return false; } } =20 @@ -2821,6 +2821,8 @@ static void vfio_populate_device(VFIOPCIDevice *vdev,= Error **errp) "Could not enable error recovery for the device", vbasedev->name); } + + return true; } =20 static void vfio_pci_put_device(VFIOPCIDevice *vdev) @@ -3036,8 +3038,7 @@ static void vfio_realize(PCIDevice *pdev, Error **err= p) goto error; } =20 - vfio_populate_device(vdev, &err); - if (err) { + if (!vfio_populate_device(vdev, &err)) { error_propagate(errp, err); goto error; } --=20 2.34.1 From nobody Sun Apr 12 13:54:27 2026 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1715761565; cv=none; d=zohomail.com; s=zohoarc; b=ZvP/RlJCfphndi/hIy/PTJpbJ/9HzVDEh/uGd8v5w6ADzOTK7toG+/FogJYGKan4Dddsntq9fUenfQ47H6t+LWrHkB8Dr7SUpVdIi4HuZOwdGhZ2HW7gpjxIiIPi/k/97rMSDk55h8yQcPeOOIskRhvm9in/+yRchFs0nWd00DI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1715761565; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=LEwbbCIN9znq1vE87VGZJ9TfqcOfexTmBDk+fMeKMok=; b=J+hO1cdk/AbiS/hdz2Q21I0RIRIfeoxMXslebfCYNd3zG8KV6XKu6HzycqBDS2+FAA7QpccRZArtlcHIOqhFLz0n4JVljb/lHSaoQL9NdhjgaUTwKjBVMcabRzf1ChFQMd0N+G9qUIDd9DYIX0ekMxdacPYZg4G7N6Ua45aOKV4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1715761565043478.842168565817; Wed, 15 May 2024 01:26:05 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s79vw-0002Da-1e; Wed, 15 May 2024 04:24:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s79vo-00028n-P9 for qemu-devel@nongnu.org; Wed, 15 May 2024 04:24:13 -0400 Received: from mgamail.intel.com ([198.175.65.18]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s79vn-00078x-1h for qemu-devel@nongnu.org; Wed, 15 May 2024 04:24:12 -0400 Received: from orviesa006.jf.intel.com ([10.64.159.146]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 May 2024 01:24:09 -0700 Received: from unknown (HELO SPR-S2600BT.bj.intel.com) ([10.240.192.124]) by orviesa006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 May 2024 01:24:08 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1715761451; x=1747297451; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=BUGi0U9N5ZD36HyQ6NXb96H8zb9zwlvSMAPDhI+SDCg=; b=Dj3k9H+BkuwGwBvLoUYnFtdGxq/GZzGaz7PgQPUebwU2imfXe5DnfAjM OVzATAJefBMcdcFi05YbcEUyzvPkqqIzCrFjktaHvmaQPACYyrypSXFkS 2J2N+zbhGwXZejKBXtJnpUin2VQPQMoQSMdcBL6V+TqR/QDIfVF45yYCL moETIQKC58K+Yxw8i+TV2XnCxBwBaSBMSV/oRX80ljXBalJMNbmon9QLZ +67v8NKIosCxXwxxFF+h8Q68Lllnr90DvLRyPmWs2L6NY6NNcWGmqUNw4 MgkB59LQ78QdIfqgqKnfTJ79OGrqYSe9Otl2/sUPDlAQ9CTuyAbeTNzHd A==; X-CSE-ConnectionGUID: KtluAC4pQjCiMUgzsDlhcg== X-CSE-MsgGUID: CxbYKvU4RDGZ/KsEyZb6lg== X-IronPort-AV: E=McAfee;i="6600,9927,11073"; a="11961561" X-IronPort-AV: E=Sophos;i="6.08,161,1712646000"; d="scan'208";a="11961561" X-CSE-ConnectionGUID: RaSaG/jxTsKNhli0dVN48Q== X-CSE-MsgGUID: lwECR40SQ+muPHhO3QG5sA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,161,1712646000"; d="scan'208";a="31396358" From: Zhenzhong Duan To: qemu-devel@nongnu.org Cc: alex.williamson@redhat.com, clg@redhat.com, eric.auger@redhat.com, chao.p.peng@intel.com, Zhenzhong Duan Subject: [PATCH 11/16] vfio/pci: Make vfio_intx_enable() return bool Date: Wed, 15 May 2024 16:20:36 +0800 Message-Id: <20240515082041.556571-12-zhenzhong.duan@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240515082041.556571-1-zhenzhong.duan@intel.com> References: <20240515082041.556571-1-zhenzhong.duan@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=198.175.65.18; envelope-from=zhenzhong.duan@intel.com; helo=mgamail.intel.com X-Spam_score_int: -53 X-Spam_score: -5.4 X-Spam_bar: ----- X-Spam_report: (-5.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.974, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1715761567151100003 This is to follow the coding standand in qapi/error.h to return bool for bool-valued functions. Suggested-by: C=C3=A9dric Le Goater Signed-off-by: Zhenzhong Duan Reviewed-by: C=C3=A9dric Le Goater --- hw/vfio/pci.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index c091d21adf..e2ca4507f8 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -261,7 +261,7 @@ static void vfio_irqchip_change(Notifier *notify, void = *data) vfio_intx_update(vdev, &vdev->intx.route); } =20 -static int vfio_intx_enable(VFIOPCIDevice *vdev, Error **errp) +static bool vfio_intx_enable(VFIOPCIDevice *vdev, Error **errp) { uint8_t pin =3D vfio_pci_read_config(&vdev->pdev, PCI_INTERRUPT_PIN, 1= ); Error *err =3D NULL; @@ -270,7 +270,7 @@ static int vfio_intx_enable(VFIOPCIDevice *vdev, Error = **errp) =20 =20 if (!pin) { - return 0; + return true; } =20 vfio_disable_interrupts(vdev); @@ -292,7 +292,7 @@ static int vfio_intx_enable(VFIOPCIDevice *vdev, Error = **errp) ret =3D event_notifier_init(&vdev->intx.interrupt, 0); if (ret) { error_setg_errno(errp, -ret, "event_notifier_init failed"); - return ret; + return false; } fd =3D event_notifier_get_fd(&vdev->intx.interrupt); qemu_set_fd_handler(fd, vfio_intx_interrupt, NULL, vdev); @@ -301,7 +301,7 @@ static int vfio_intx_enable(VFIOPCIDevice *vdev, Error = **errp) VFIO_IRQ_SET_ACTION_TRIGGER, fd, errp)) { qemu_set_fd_handler(fd, NULL, NULL, vdev); event_notifier_cleanup(&vdev->intx.interrupt); - return -errno; + return false; } =20 if (!vfio_intx_enable_kvm(vdev, &err)) { @@ -311,7 +311,7 @@ static int vfio_intx_enable(VFIOPCIDevice *vdev, Error = **errp) vdev->interrupt =3D VFIO_INT_INTx; =20 trace_vfio_intx_enable(vdev->vbasedev.name); - return 0; + return true; } =20 static void vfio_intx_disable(VFIOPCIDevice *vdev) @@ -836,8 +836,7 @@ static void vfio_msix_disable(VFIOPCIDevice *vdev) vfio_disable_irqindex(&vdev->vbasedev, VFIO_PCI_MSIX_IRQ_INDEX); =20 vfio_msi_disable_common(vdev); - vfio_intx_enable(vdev, &err); - if (err) { + if (!vfio_intx_enable(vdev, &err)) { error_reportf_err(err, VFIO_MSG_PREFIX, vdev->vbasedev.name); } =20 @@ -2450,8 +2449,7 @@ void vfio_pci_post_reset(VFIOPCIDevice *vdev) Error *err =3D NULL; int nr; =20 - vfio_intx_enable(vdev, &err); - if (err) { + if (!vfio_intx_enable(vdev, &err)) { error_reportf_err(err, VFIO_MSG_PREFIX, vdev->vbasedev.name); } =20 @@ -3197,8 +3195,7 @@ static void vfio_realize(PCIDevice *pdev, Error **err= p) vfio_intx_routing_notifier); vdev->irqchip_change_notifier.notify =3D vfio_irqchip_change; kvm_irqchip_add_change_notifier(&vdev->irqchip_change_notifier); - ret =3D vfio_intx_enable(vdev, errp); - if (ret) { + if (!vfio_intx_enable(vdev, errp)) { goto out_deregister; } } --=20 2.34.1 From nobody Sun Apr 12 13:54:27 2026 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1715761545; cv=none; d=zohomail.com; s=zohoarc; b=YqFlF3Xpa6eXOOHg+7Rc6o3zWVnqEIU83tE+F7PFbWj879DKKtNbISt/eJpCTHlkgr1vWDAQKqrmhrmUZW67GJ5O2SINXqcCk/pyhwqNUhKDRiMYIspaTRAnxmFZJNBvAQf0q7jht5aCu6l3zu80CNfhCvKhatyXFwtiNhLAP7o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1715761545; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=o1Z0uRsGdp/mQoujJkSxgvFgYhe7C2Qe4uSB76eCTXM=; b=DqX+jh6E7Hy7bCkqM02qA8qD6PDLUMJqEt4SrsoMZoNUqEO7kIeXMVpI6dCB60M3q9EGoSX74wwA6Br111YV7ea16vCqrjcCAiX+DmdtmYty7F/5s8CZ5nOXXQ4RxiQnKhaB5HWsYD/AyNqVm9WOpDilmrKWYI1Zp42PfHC2LNg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1715761545030506.87399304566736; Wed, 15 May 2024 01:25:45 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s79w3-0002EA-Db; Wed, 15 May 2024 04:24:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s79w1-0002Dq-H8 for qemu-devel@nongnu.org; Wed, 15 May 2024 04:24:25 -0400 Received: from mgamail.intel.com ([198.175.65.18]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s79vy-00078z-QK for qemu-devel@nongnu.org; Wed, 15 May 2024 04:24:25 -0400 Received: from orviesa006.jf.intel.com ([10.64.159.146]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 May 2024 01:24:12 -0700 Received: from unknown (HELO SPR-S2600BT.bj.intel.com) ([10.240.192.124]) by orviesa006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 May 2024 01:24:10 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1715761462; x=1747297462; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=QdLjTGnHcXqx8H4sHtwILLStf345rO73jW1Xhafi9Wk=; b=Qy3z7LNjl1uBgpX6qlfiGKkKNehrrEcsHrUK/O60ZO52DiT7/ogAAGgu xIIPNCR3y3MVKcDDkIMDSipHXq552B4qPfWMYzPFYYsAviJk0PsP7YP8G fCp0jTvJwalTE5cvQhAnNOFM4wyXPhCjEtKGLjDZ3Eae9RNgh5nsk6ALX Do43RSzghx2WW3NFHkEOqo/WHndxiZbhblnNSeNo0DOAlsZstJ+N9cVxG y62CiR+YVFhfzFWcZjthulHra8mWm5hIez907fYxkGq6aetGPwfnwpTuJ 3+iP+yk7dTg9Pdd/uxMob16qT9Q3Tdme3g/cvgHHrrZDNXWES4pybyrY0 Q==; X-CSE-ConnectionGUID: vi7XEmmuR/mlTOyuhn1MVg== X-CSE-MsgGUID: OOluqSSVTXW8nSR+LshDmA== X-IronPort-AV: E=McAfee;i="6600,9927,11073"; a="11961563" X-IronPort-AV: E=Sophos;i="6.08,161,1712646000"; d="scan'208";a="11961563" X-CSE-ConnectionGUID: SWyJeqBbSrO+P3maszc4Yw== X-CSE-MsgGUID: y+svfSVkQvygJ9MFglwRrA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,161,1712646000"; d="scan'208";a="31396364" From: Zhenzhong Duan To: qemu-devel@nongnu.org Cc: alex.williamson@redhat.com, clg@redhat.com, eric.auger@redhat.com, chao.p.peng@intel.com, Zhenzhong Duan Subject: [PATCH 12/16] vfio/pci: Make vfio_populate_vga() return bool Date: Wed, 15 May 2024 16:20:37 +0800 Message-Id: <20240515082041.556571-13-zhenzhong.duan@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240515082041.556571-1-zhenzhong.duan@intel.com> References: <20240515082041.556571-1-zhenzhong.duan@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=198.175.65.18; envelope-from=zhenzhong.duan@intel.com; helo=mgamail.intel.com X-Spam_score_int: -53 X-Spam_score: -5.4 X-Spam_bar: ----- X-Spam_report: (-5.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.974, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1715761547017100003 This is to follow the coding standand in qapi/error.h to return bool for bool-valued functions. Suggested-by: C=C3=A9dric Le Goater Signed-off-by: Zhenzhong Duan Reviewed-by: C=C3=A9dric Le Goater --- hw/vfio/pci.h | 2 +- hw/vfio/igd.c | 2 +- hw/vfio/pci.c | 11 +++++------ 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/hw/vfio/pci.h b/hw/vfio/pci.h index a5ac9efd4b..7914f019d5 100644 --- a/hw/vfio/pci.h +++ b/hw/vfio/pci.h @@ -225,7 +225,7 @@ bool vfio_pci_host_match(PCIHostDeviceAddress *addr, co= nst char *name); int vfio_pci_get_pci_hot_reset_info(VFIOPCIDevice *vdev, struct vfio_pci_hot_reset_info **info_= p); =20 -int vfio_populate_vga(VFIOPCIDevice *vdev, Error **errp); +bool vfio_populate_vga(VFIOPCIDevice *vdev, Error **errp); =20 int vfio_pci_igd_opregion_init(VFIOPCIDevice *vdev, struct vfio_region_info *info, diff --git a/hw/vfio/igd.c b/hw/vfio/igd.c index b31ee79c60..ffe57c5954 100644 --- a/hw/vfio/igd.c +++ b/hw/vfio/igd.c @@ -478,7 +478,7 @@ void vfio_probe_igd_bar4_quirk(VFIOPCIDevice *vdev, int= nr) * try to enable it. Probably shouldn't be using legacy mode without = VGA, * but also no point in us enabling VGA if disabled in hardware. */ - if (!(gmch & 0x2) && !vdev->vga && vfio_populate_vga(vdev, &err)) { + if (!(gmch & 0x2) && !vdev->vga && !vfio_populate_vga(vdev, &err)) { error_reportf_err(err, VFIO_MSG_PREFIX, vdev->vbasedev.name); error_report("IGD device %s failed to enable VGA access, " "legacy mode disabled", vdev->vbasedev.name); diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index e2ca4507f8..1922593253 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -2670,7 +2670,7 @@ static VFIODeviceOps vfio_pci_ops =3D { .vfio_load_config =3D vfio_pci_load_config, }; =20 -int vfio_populate_vga(VFIOPCIDevice *vdev, Error **errp) +bool vfio_populate_vga(VFIOPCIDevice *vdev, Error **errp) { VFIODevice *vbasedev =3D &vdev->vbasedev; struct vfio_region_info *reg_info; @@ -2681,7 +2681,7 @@ int vfio_populate_vga(VFIOPCIDevice *vdev, Error **er= rp) error_setg_errno(errp, -ret, "failed getting region info for VGA region index = %d", VFIO_PCI_VGA_REGION_INDEX); - return ret; + return false; } =20 if (!(reg_info->flags & VFIO_REGION_INFO_FLAG_READ) || @@ -2691,7 +2691,7 @@ int vfio_populate_vga(VFIOPCIDevice *vdev, Error **er= rp) (unsigned long)reg_info->flags, (unsigned long)reg_info->size); g_free(reg_info); - return -EINVAL; + return false; } =20 vdev->vga =3D g_new0(VFIOVGA, 1); @@ -2735,7 +2735,7 @@ int vfio_populate_vga(VFIOPCIDevice *vdev, Error **er= rp) &vdev->vga->region[QEMU_PCI_VGA_IO_LO].mem, &vdev->vga->region[QEMU_PCI_VGA_IO_HI].mem); =20 - return 0; + return true; } =20 static bool vfio_populate_device(VFIOPCIDevice *vdev, Error **errp) @@ -2798,8 +2798,7 @@ static bool vfio_populate_device(VFIOPCIDevice *vdev,= Error **errp) g_free(reg_info); =20 if (vdev->features & VFIO_FEATURE_ENABLE_VGA) { - ret =3D vfio_populate_vga(vdev, errp); - if (ret) { + if (!vfio_populate_vga(vdev, errp)) { error_append_hint(errp, "device does not support " "requested feature x-vga\n"); return false; --=20 2.34.1 From nobody Sun Apr 12 13:54:27 2026 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1715761500; cv=none; d=zohomail.com; s=zohoarc; b=h+5Foy4by7IOtdbuPqvF6H+UQnXWDs+32bcJWSDdliSJh/q3nFR7AG+D/wrRcXvIx/dmqVr3ziDtMABGO2Qiw33Q8YHvuhc79XcHPpVlsQEzJHwyxm6QdbLaT9/4CPBu0w6etrnK5FAlslGdCeSXvSxDJANNwasx9Z+y1BEoVkI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1715761500; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=o2BvEmIBxEnSOOpmZuXetf7UMSTOZ+dO5adNR4b5tME=; b=YDswJB0b9RyPP2K7TI8uYmPoQo2H0r15rCu7wJpX9ys/ijDXcAh0kwiO/cRd9MMyAMx1Bfb/P6XG0YZfyfere0rx8neB5jLeCmcVaAOWIX4d57i7wGO0nzK5Ve0oyCmlJltYN4+XkY5gBa9lM/h1P5ADkCaTw2BxzxfupFn/mGM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 171576150071354.86539896129159; Wed, 15 May 2024 01:25:00 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s79w4-0002Ei-Ie; Wed, 15 May 2024 04:24:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s79w3-0002E2-1C for qemu-devel@nongnu.org; Wed, 15 May 2024 04:24:27 -0400 Received: from mgamail.intel.com ([198.175.65.18]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s79w0-00078x-Ui for qemu-devel@nongnu.org; Wed, 15 May 2024 04:24:26 -0400 Received: from orviesa006.jf.intel.com ([10.64.159.146]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 May 2024 01:24:14 -0700 Received: from unknown (HELO SPR-S2600BT.bj.intel.com) ([10.240.192.124]) by orviesa006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 May 2024 01:24:12 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1715761465; x=1747297465; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=T+eVqA9MCcvs1IE+2O2X5MUuXFs0um/6d7ZD8zXzByU=; b=OJk9lZAEmMxVMn4d+Cuw3wXVYNainaC0dey4saGb8mgQvSPkL3e/MXD0 dD+l7MqStHpXNjYEk9DdEXU6iPLjIoEQ1RTH7IUwq7ghDmO1FG5Ix1jx/ trbmGNi4wqxeWURFsXehARuF0Kpcp1VG3OscA5O05FyGQpw0u9yjgb85J 8u9u+8fTTLgOeuAtFunAggY4B652QpbJvNE4oQdCY0cZpVMXrjY3kHjyX tT1YsApQXi0FtKpc3fXkKPL7/mogbSzubSpw/g63+As8WoYljFjykajFr J+dBGiUM5kHucoBDZDSAJRK6z3iLu7uD8rP4LYunMh1hPs1HbqHfTo51b A==; X-CSE-ConnectionGUID: 88U/r/3sRAWLochPXIcUPA== X-CSE-MsgGUID: X72/Xi+eRYiv8mfeyCySvQ== X-IronPort-AV: E=McAfee;i="6600,9927,11073"; a="11961565" X-IronPort-AV: E=Sophos;i="6.08,161,1712646000"; d="scan'208";a="11961565" X-CSE-ConnectionGUID: SahBJXL2Q5+LhBCdqlntKw== X-CSE-MsgGUID: UriCO2PZTzmwogkvH1xOKg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,161,1712646000"; d="scan'208";a="31396369" From: Zhenzhong Duan To: qemu-devel@nongnu.org Cc: alex.williamson@redhat.com, clg@redhat.com, eric.auger@redhat.com, chao.p.peng@intel.com, Zhenzhong Duan Subject: [PATCH 13/16] vfio/pci: Make capability related functions return bool Date: Wed, 15 May 2024 16:20:38 +0800 Message-Id: <20240515082041.556571-14-zhenzhong.duan@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240515082041.556571-1-zhenzhong.duan@intel.com> References: <20240515082041.556571-1-zhenzhong.duan@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=198.175.65.18; envelope-from=zhenzhong.duan@intel.com; helo=mgamail.intel.com X-Spam_score_int: -53 X-Spam_score: -5.4 X-Spam_bar: ----- X-Spam_report: (-5.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.974, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1715761500887100001 Content-Type: text/plain; charset="utf-8" The functions operating on capability don't have a consistent return style. Below functions are in bool-valued functions style: vfio_msi_setup() vfio_msix_setup() vfio_add_std_cap() vfio_add_capabilities() Below two are integer-valued functions: vfio_add_vendor_specific_cap() vfio_setup_pcie_cap() But the returned integer is only used for check succeed/failure. Change them all to return bool so now all capability related functions follow the coding standand in qapi/error.h to return bool. Signed-off-by: Zhenzhong Duan Reviewed-by: C=C3=A9dric Le Goater --- hw/vfio/pci.c | 77 ++++++++++++++++++++++++--------------------------- 1 file changed, 36 insertions(+), 41 deletions(-) diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index 1922593253..ecfbb9619f 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -1339,7 +1339,7 @@ static void vfio_disable_interrupts(VFIOPCIDevice *vd= ev) } } =20 -static int vfio_msi_setup(VFIOPCIDevice *vdev, int pos, Error **errp) +static bool vfio_msi_setup(VFIOPCIDevice *vdev, int pos, Error **errp) { uint16_t ctrl; bool msi_64bit, msi_maskbit; @@ -1349,7 +1349,7 @@ static int vfio_msi_setup(VFIOPCIDevice *vdev, int po= s, Error **errp) if (pread(vdev->vbasedev.fd, &ctrl, sizeof(ctrl), vdev->config_offset + pos + PCI_CAP_FLAGS) !=3D sizeof(ctrl)= ) { error_setg_errno(errp, errno, "failed reading MSI PCI_CAP_FLAGS"); - return -errno; + return false; } ctrl =3D le16_to_cpu(ctrl); =20 @@ -1362,14 +1362,14 @@ static int vfio_msi_setup(VFIOPCIDevice *vdev, int = pos, Error **errp) ret =3D msi_init(&vdev->pdev, pos, entries, msi_64bit, msi_maskbit, &e= rr); if (ret < 0) { if (ret =3D=3D -ENOTSUP) { - return 0; + return true; } error_propagate_prepend(errp, err, "msi_init failed: "); - return ret; + return false; } vdev->msi_cap_size =3D 0xa + (msi_maskbit ? 0xa : 0) + (msi_64bit ? 0x= 4 : 0); =20 - return 0; + return true; } =20 static void vfio_pci_fixup_msix_region(VFIOPCIDevice *vdev) @@ -1644,7 +1644,7 @@ static bool vfio_msix_early_setup(VFIOPCIDevice *vdev= , Error **errp) return vfio_pci_relocate_msix(vdev, errp); } =20 -static int vfio_msix_setup(VFIOPCIDevice *vdev, int pos, Error **errp) +static bool vfio_msix_setup(VFIOPCIDevice *vdev, int pos, Error **errp) { int ret; Error *err =3D NULL; @@ -1660,11 +1660,11 @@ static int vfio_msix_setup(VFIOPCIDevice *vdev, int= pos, Error **errp) if (ret < 0) { if (ret =3D=3D -ENOTSUP) { warn_report_err(err); - return 0; + return true; } =20 error_propagate(errp, err); - return ret; + return false; } =20 /* @@ -1698,7 +1698,7 @@ static int vfio_msix_setup(VFIOPCIDevice *vdev, int p= os, Error **errp) memory_region_set_enabled(&vdev->pdev.msix_table_mmio, false); } =20 - return 0; + return true; } =20 static void vfio_teardown_msi(VFIOPCIDevice *vdev) @@ -1977,8 +1977,8 @@ static void vfio_pci_disable_rp_atomics(VFIOPCIDevice= *vdev) } } =20 -static int vfio_setup_pcie_cap(VFIOPCIDevice *vdev, int pos, uint8_t size, - Error **errp) +static bool vfio_setup_pcie_cap(VFIOPCIDevice *vdev, int pos, uint8_t size, + Error **errp) { uint16_t flags; uint8_t type; @@ -1992,7 +1992,7 @@ static int vfio_setup_pcie_cap(VFIOPCIDevice *vdev, i= nt pos, uint8_t size, =20 error_setg(errp, "assignment of PCIe type 0x%x " "devices is not currently supported", type); - return -EINVAL; + return false; } =20 if (!pci_bus_is_express(pci_get_bus(&vdev->pdev))) { @@ -2025,7 +2025,7 @@ static int vfio_setup_pcie_cap(VFIOPCIDevice *vdev, i= nt pos, uint8_t size, } =20 if (pci_bus_is_express(bus)) { - return 0; + return true; } =20 } else if (pci_bus_is_root(pci_get_bus(&vdev->pdev))) { @@ -2063,7 +2063,7 @@ static int vfio_setup_pcie_cap(VFIOPCIDevice *vdev, i= nt pos, uint8_t size, * Legacy endpoints don't belong on the root complex. Windows * seems to be happier with devices if we skip the capability. */ - return 0; + return true; } =20 } else { @@ -2099,12 +2099,12 @@ static int vfio_setup_pcie_cap(VFIOPCIDevice *vdev,= int pos, uint8_t size, pos =3D pci_add_capability(&vdev->pdev, PCI_CAP_ID_EXP, pos, size, errp); if (pos < 0) { - return pos; + return false; } =20 vdev->pdev.exp.exp_cap =3D pos; =20 - return pos; + return true; } =20 static void vfio_check_pcie_flr(VFIOPCIDevice *vdev, uint8_t pos) @@ -2137,14 +2137,14 @@ static void vfio_check_af_flr(VFIOPCIDevice *vdev, = uint8_t pos) } } =20 -static int vfio_add_vendor_specific_cap(VFIOPCIDevice *vdev, int pos, - uint8_t size, Error **errp) +static bool vfio_add_vendor_specific_cap(VFIOPCIDevice *vdev, int pos, + uint8_t size, Error **errp) { PCIDevice *pdev =3D &vdev->pdev; =20 pos =3D pci_add_capability(pdev, PCI_CAP_ID_VNDR, pos, size, errp); if (pos < 0) { - return pos; + return false; } =20 /* @@ -2156,15 +2156,15 @@ static int vfio_add_vendor_specific_cap(VFIOPCIDevi= ce *vdev, int pos, memset(pdev->cmask + pos + 3, 0, size - 3); } =20 - return pos; + return true; } =20 -static int vfio_add_std_cap(VFIOPCIDevice *vdev, uint8_t pos, Error **errp) +static bool vfio_add_std_cap(VFIOPCIDevice *vdev, uint8_t pos, Error **err= p) { ERRP_GUARD(); PCIDevice *pdev =3D &vdev->pdev; uint8_t cap_id, next, size; - int ret; + bool ret; =20 cap_id =3D pdev->config[pos]; next =3D pdev->config[pos + PCI_CAP_LIST_NEXT]; @@ -2185,9 +2185,8 @@ static int vfio_add_std_cap(VFIOPCIDevice *vdev, uint= 8_t pos, Error **errp) * will be changed as we unwind the stack. */ if (next) { - ret =3D vfio_add_std_cap(vdev, next, errp); - if (ret) { - return ret; + if (!vfio_add_std_cap(vdev, next, errp)) { + return false; } } else { /* Begin the rebuild, use QEMU emulated list bits */ @@ -2197,7 +2196,7 @@ static int vfio_add_std_cap(VFIOPCIDevice *vdev, uint= 8_t pos, Error **errp) =20 ret =3D vfio_add_virt_caps(vdev, errp); if (ret) { - return ret; + return false; } } =20 @@ -2221,28 +2220,27 @@ static int vfio_add_std_cap(VFIOPCIDevice *vdev, ui= nt8_t pos, Error **errp) case PCI_CAP_ID_PM: vfio_check_pm_reset(vdev, pos); vdev->pm_cap =3D pos; - ret =3D pci_add_capability(pdev, cap_id, pos, size, errp); + ret =3D pci_add_capability(pdev, cap_id, pos, size, errp) >=3D 0; break; case PCI_CAP_ID_AF: vfio_check_af_flr(vdev, pos); - ret =3D pci_add_capability(pdev, cap_id, pos, size, errp); + ret =3D pci_add_capability(pdev, cap_id, pos, size, errp) >=3D 0; break; case PCI_CAP_ID_VNDR: ret =3D vfio_add_vendor_specific_cap(vdev, pos, size, errp); break; default: - ret =3D pci_add_capability(pdev, cap_id, pos, size, errp); + ret =3D pci_add_capability(pdev, cap_id, pos, size, errp) >=3D 0; break; } =20 - if (ret < 0) { + if (!ret) { error_prepend(errp, "failed to add PCI capability 0x%x[0x%x]@0x%x: ", cap_id, size, pos); - return ret; } =20 - return 0; + return ret; } =20 static int vfio_setup_rebar_ecap(VFIOPCIDevice *vdev, uint16_t pos) @@ -2388,23 +2386,21 @@ static void vfio_add_ext_cap(VFIOPCIDevice *vdev) return; } =20 -static int vfio_add_capabilities(VFIOPCIDevice *vdev, Error **errp) +static bool vfio_add_capabilities(VFIOPCIDevice *vdev, Error **errp) { PCIDevice *pdev =3D &vdev->pdev; - int ret; =20 if (!(pdev->config[PCI_STATUS] & PCI_STATUS_CAP_LIST) || !pdev->config[PCI_CAPABILITY_LIST]) { - return 0; /* Nothing to add */ + return true; /* Nothing to add */ } =20 - ret =3D vfio_add_std_cap(vdev, pdev->config[PCI_CAPABILITY_LIST], errp= ); - if (ret) { - return ret; + if (!vfio_add_std_cap(vdev, pdev->config[PCI_CAPABILITY_LIST], errp)) { + return false; } =20 vfio_add_ext_cap(vdev); - return 0; + return true; } =20 void vfio_pci_pre_reset(VFIOPCIDevice *vdev) @@ -3136,8 +3132,7 @@ static void vfio_realize(PCIDevice *pdev, Error **err= p) =20 vfio_bars_register(vdev); =20 - ret =3D vfio_add_capabilities(vdev, errp); - if (ret) { + if (!vfio_add_capabilities(vdev, errp)) { goto out_teardown; } =20 --=20 2.34.1 From nobody Sun Apr 12 13:54:27 2026 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1715761559; cv=none; d=zohomail.com; s=zohoarc; b=ieNtwbcM+NMhMn7lH0h2lPGCfhYVrLlH/SCM1XW/iczY9aYiZh37BUT17/6rxRp4YkU2JoOVvkVeX3LQiWloH/f14HUv7BqHPJzkFvNeaNx8kN0EJ60exJXUXlssJqy96weTZ3MG1P+7Pqo6QX1LAkcKrlqduJi4gtUXN8PVA1g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1715761559; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=8V96JaL5d+BDmzTOUvOuvSy27gTQ4ZnV2iuMig2H0Sg=; b=DbfAqb8RgpS4TDINBYnmZu5WsQInoFrRO7Rf1OM/7YbRPDUnIZEHLqRuxbEvfvonF5ir+d3RVFd3RCT2ZR9U/P9NyANknLs1dRI4HVBK8zZ3ACP5DNnaxpmDUwGeXxRtmIyaB7DvbytRff5mixJjr1NNNtFI3REXjVXjvnHs2c4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1715761559723119.80786694367225; Wed, 15 May 2024 01:25:59 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s79w7-0002Gd-0G; Wed, 15 May 2024 04:24:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s79w5-0002F6-Er for qemu-devel@nongnu.org; Wed, 15 May 2024 04:24:29 -0400 Received: from mgamail.intel.com ([198.175.65.18]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s79w3-0007B1-SG for qemu-devel@nongnu.org; Wed, 15 May 2024 04:24:29 -0400 Received: from orviesa006.jf.intel.com ([10.64.159.146]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 May 2024 01:24:16 -0700 Received: from unknown (HELO SPR-S2600BT.bj.intel.com) ([10.240.192.124]) by orviesa006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 May 2024 01:24:15 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1715761467; x=1747297467; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=DTf3l3gNL+/MEzKemJXwdZjfqVeaFHkkSy2ozo0sBso=; b=EjSrBYibYu2+Z5kwUxMJahvutqIt3BQ5umI6qzk0i1v0/ZjA0w8pQTq7 DpgdrEtT3OMyLGutSuFEc5LScJVGUcbodaoRv+90kWS/4loXgtwlHBQFT LMRlSIFIPDTrE9nP6/x4/sHjkaNTXiB1Ud9g2s6RDPI4hVMXQetY0OH6g YRcl5hqOfDxiMFemRvc/ajOeRvOo49crMe666LJbxrLLMwwwbFHHsZoyV PxwTiHNR7tSxNWDWS48DEZXgr7IbjMYSxkV0UuwNRdj/fJ4YDS+5dr0av vkgqrm5QYsjsMIzfbQG8QFde62iocxYq/EfbSuhBGcRcDS2VRj77TkVis Q==; X-CSE-ConnectionGUID: AFsgf+UEQbGM3J2xhpHW+A== X-CSE-MsgGUID: jR9IM7AcQ0G3cHK4FQ9LFw== X-IronPort-AV: E=McAfee;i="6600,9927,11073"; a="11961569" X-IronPort-AV: E=Sophos;i="6.08,161,1712646000"; d="scan'208";a="11961569" X-CSE-ConnectionGUID: UCGlrDnUSgmk7QB8BHZCRg== X-CSE-MsgGUID: uxRQkFMZS/2N97n2PuWkTg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,161,1712646000"; d="scan'208";a="31396374" From: Zhenzhong Duan To: qemu-devel@nongnu.org Cc: alex.williamson@redhat.com, clg@redhat.com, eric.auger@redhat.com, chao.p.peng@intel.com, Zhenzhong Duan Subject: [PATCH 14/16] vfio/pci: Use g_autofree for vfio_region_info pointer Date: Wed, 15 May 2024 16:20:39 +0800 Message-Id: <20240515082041.556571-15-zhenzhong.duan@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240515082041.556571-1-zhenzhong.duan@intel.com> References: <20240515082041.556571-1-zhenzhong.duan@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=198.175.65.18; envelope-from=zhenzhong.duan@intel.com; helo=mgamail.intel.com X-Spam_score_int: -53 X-Spam_score: -5.4 X-Spam_bar: ----- X-Spam_report: (-5.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.974, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1715761561042100003 Content-Type: text/plain; charset="utf-8" Pointer opregion is freed after vfio_pci_igd_opregion_init(). Use 'g_autofree' to avoid the g_free() calls. Signed-off-by: Zhenzhong Duan Reviewed-by: C=C3=A9dric Le Goater --- hw/vfio/pci.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index ecfbb9619f..be87478716 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -3146,7 +3146,7 @@ static void vfio_realize(PCIDevice *pdev, Error **err= p) =20 if (!vdev->igd_opregion && vdev->features & VFIO_FEATURE_ENABLE_IGD_OPREGION) { - struct vfio_region_info *opregion; + g_autofree struct vfio_region_info *opregion =3D NULL; =20 if (vdev->pdev.qdev.hotplugged) { error_setg(errp, @@ -3165,7 +3165,6 @@ static void vfio_realize(PCIDevice *pdev, Error **err= p) } =20 ret =3D vfio_pci_igd_opregion_init(vdev, opregion, errp); - g_free(opregion); if (ret) { goto out_teardown; } --=20 2.34.1 From nobody Sun Apr 12 13:54:27 2026 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1715761500; cv=none; d=zohomail.com; s=zohoarc; b=hSufbhRCzxLizmQfO3pgL3e/EEf91jCGaRrlYUYK806MZ1Jqtwo2caexrzzRa291Fkt1dy0SRk5+j0dOCx7vl6HevFa/s526+hKIyNlpJXiC6JiFzewDyWGBN4yCS/VX7y8m+H52GFul3CRbvIk4mEsaHnuCJ9A9SQpsbB2PJNQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1715761500; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=eS6/j6phQ6Z4v8L78xBR/OYHpjUIQgKvOYN8MBTR/IM=; b=T89/1Q1Miff8X7j+EiYw2WKJR1aljLoMdgt4Z/7C8+weHfEB+BgXX4EBi9idNc4R7wLrS/CQaSkM6/jJG1EFviYFTlz8qjDufqBdDE/+8AA9/dV2xyKuXZOF4oV2+lQ53EeqMweN6BYVEruKXcuLAYNhexg4rUYwXy2/Ob926sc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1715761500452400.09866865725064; Wed, 15 May 2024 01:25:00 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s79wJ-0002yB-ML; Wed, 15 May 2024 04:24:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s79wF-0002jY-W0 for qemu-devel@nongnu.org; Wed, 15 May 2024 04:24:40 -0400 Received: from mgamail.intel.com ([198.175.65.18]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s79wB-00078z-UN for qemu-devel@nongnu.org; Wed, 15 May 2024 04:24:39 -0400 Received: from orviesa006.jf.intel.com ([10.64.159.146]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 May 2024 01:24:18 -0700 Received: from unknown (HELO SPR-S2600BT.bj.intel.com) ([10.240.192.124]) by orviesa006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 May 2024 01:24:17 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1715761476; x=1747297476; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=mDjA7DC0v0StCa3vgu8vJHYyYIkvKHnGv9rk64Ck0mc=; b=kwU1xkKqFyL6ZKNBNeBxP/HJFsbf2s6MtHNtqBhkHi4EX/YmKk/7ea+p Bs1inh6TE1L636BhplwpboSuRY+4sqQYcr54BYss8aEdMtekcCKLCswE+ mp3yPCk+gnBijs5srepghsYXAin3sqc7Wpe9DgkjDImjE+ASi0WFl/eV9 xFRvZuhrWjcMWWPG4npDBo7PTtyTWxlYnaV8Nasj74Hng2fHGh0xp4ZmB fFKx2wazoIr+OS4s+zOvb/jnnzpUQb/X28PsntaMTxhDU30MfbSQZrqJe BmUngaN6zn34At8kfD4//UWT8Op8s/JbNUEruS9rjtS1GQ8IGxrzqZVyW Q==; X-CSE-ConnectionGUID: zBYzy5uxS7aoNm3498E7RQ== X-CSE-MsgGUID: Z6F+Y+0QRJmiFtYNqN1RbQ== X-IronPort-AV: E=McAfee;i="6600,9927,11073"; a="11961574" X-IronPort-AV: E=Sophos;i="6.08,161,1712646000"; d="scan'208";a="11961574" X-CSE-ConnectionGUID: 6nKQ7Co8R3OQyNioNyNVbQ== X-CSE-MsgGUID: 6XfXVEKeRyuVaGDRfYxeUA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,161,1712646000"; d="scan'208";a="31396379" From: Zhenzhong Duan To: qemu-devel@nongnu.org Cc: alex.williamson@redhat.com, clg@redhat.com, eric.auger@redhat.com, chao.p.peng@intel.com, Zhenzhong Duan Subject: [PATCH 15/16] vfio/pci-quirks: Make vfio_pci_igd_opregion_init() return bool Date: Wed, 15 May 2024 16:20:40 +0800 Message-Id: <20240515082041.556571-16-zhenzhong.duan@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240515082041.556571-1-zhenzhong.duan@intel.com> References: <20240515082041.556571-1-zhenzhong.duan@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=198.175.65.18; envelope-from=zhenzhong.duan@intel.com; helo=mgamail.intel.com X-Spam_score_int: -53 X-Spam_score: -5.4 X-Spam_bar: ----- X-Spam_report: (-5.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.974, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1715761500893100002 This is to follow the coding standand in qapi/error.h to return bool for bool-valued functions. Suggested-by: C=C3=A9dric Le Goater Signed-off-by: Zhenzhong Duan Reviewed-by: C=C3=A9dric Le Goater --- hw/vfio/pci.h | 6 +++--- hw/vfio/igd.c | 3 +-- hw/vfio/pci-quirks.c | 8 ++++---- hw/vfio/pci.c | 3 +-- 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/hw/vfio/pci.h b/hw/vfio/pci.h index 7914f019d5..f158681072 100644 --- a/hw/vfio/pci.h +++ b/hw/vfio/pci.h @@ -227,9 +227,9 @@ int vfio_pci_get_pci_hot_reset_info(VFIOPCIDevice *vdev, =20 bool vfio_populate_vga(VFIOPCIDevice *vdev, Error **errp); =20 -int vfio_pci_igd_opregion_init(VFIOPCIDevice *vdev, - struct vfio_region_info *info, - Error **errp); +bool vfio_pci_igd_opregion_init(VFIOPCIDevice *vdev, + struct vfio_region_info *info, + Error **errp); =20 void vfio_display_reset(VFIOPCIDevice *vdev); bool vfio_display_probe(VFIOPCIDevice *vdev, Error **errp); diff --git a/hw/vfio/igd.c b/hw/vfio/igd.c index ffe57c5954..402fc5ce1d 100644 --- a/hw/vfio/igd.c +++ b/hw/vfio/igd.c @@ -502,8 +502,7 @@ void vfio_probe_igd_bar4_quirk(VFIOPCIDevice *vdev, int= nr) } =20 /* Setup OpRegion access */ - ret =3D vfio_pci_igd_opregion_init(vdev, opregion, &err); - if (ret) { + if (!vfio_pci_igd_opregion_init(vdev, opregion, &err)) { error_append_hint(&err, "IGD legacy mode disabled\n"); error_reportf_err(err, VFIO_MSG_PREFIX, vdev->vbasedev.name); goto out; diff --git a/hw/vfio/pci-quirks.c b/hw/vfio/pci-quirks.c index 496fd1ee86..ca27917159 100644 --- a/hw/vfio/pci-quirks.c +++ b/hw/vfio/pci-quirks.c @@ -1169,8 +1169,8 @@ static void vfio_probe_rtl8168_bar2_quirk(VFIOPCIDevi= ce *vdev, int nr) * the table and to write the base address of that memory to the ASLS regi= ster * of the IGD device. */ -int vfio_pci_igd_opregion_init(VFIOPCIDevice *vdev, - struct vfio_region_info *info, Error **errp) +bool vfio_pci_igd_opregion_init(VFIOPCIDevice *vdev, + struct vfio_region_info *info, Error **err= p) { int ret; =20 @@ -1181,7 +1181,7 @@ int vfio_pci_igd_opregion_init(VFIOPCIDevice *vdev, error_setg(errp, "failed to read IGD OpRegion"); g_free(vdev->igd_opregion); vdev->igd_opregion =3D NULL; - return -EINVAL; + return false; } =20 /* @@ -1206,7 +1206,7 @@ int vfio_pci_igd_opregion_init(VFIOPCIDevice *vdev, pci_set_long(vdev->pdev.wmask + IGD_ASLS, ~0); pci_set_long(vdev->emulated_config_bits + IGD_ASLS, ~0); =20 - return 0; + return true; } =20 /* diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index be87478716..15823c359a 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -3164,8 +3164,7 @@ static void vfio_realize(PCIDevice *pdev, Error **err= p) goto out_teardown; } =20 - ret =3D vfio_pci_igd_opregion_init(vdev, opregion, errp); - if (ret) { + if (!vfio_pci_igd_opregion_init(vdev, opregion, errp)) { goto out_teardown; } } --=20 2.34.1 From nobody Sun Apr 12 13:54:27 2026 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1715761583; cv=none; d=zohomail.com; s=zohoarc; b=heoEf0V69pW84eIMXqe+lxW9CDTGEgR5wPCbca6MKH9bu97aQvxbrCpQGcyA1WYkdfTlo8WUUrOr1SRSkGVmURgo8wx/wtW7hgKCgGN8iZTo4fNMh/jMVvhdJqt7sZwu8XAtrfENfqpzTO4CHRjlLG3G6su+9878G/AaClZ80V4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1715761583; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=INg/oPifTOVeWCXeAm/R+1u79FC+BWlrG5dpmTO/qE4=; b=Uks58Wy2bpbgFUWDfG54c7WXe8t+gIvNYU+/As56Br3dGSYDOYe6PquJ/cnoVBBsUhCxUquQyjCnCMCQwvz5YVOgpUYUzYRNAvWgMH/dWT4RT3DKrbbmwUu9Oe+K+i8DeND/V1BVihAZQfwWH1GMv9kF0TGbUm5SySs6oyP+WHg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1715761583778249.3283114654289; Wed, 15 May 2024 01:26:23 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s79wL-00038Y-NN; Wed, 15 May 2024 04:24:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s79wF-0002jX-Vz for qemu-devel@nongnu.org; Wed, 15 May 2024 04:24:40 -0400 Received: from mgamail.intel.com ([198.175.65.18]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s79wD-00078x-CF for qemu-devel@nongnu.org; Wed, 15 May 2024 04:24:39 -0400 Received: from orviesa006.jf.intel.com ([10.64.159.146]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 May 2024 01:24:21 -0700 Received: from unknown (HELO SPR-S2600BT.bj.intel.com) ([10.240.192.124]) by orviesa006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 May 2024 01:24:19 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1715761477; x=1747297477; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=BdHAZyQKJuGjQWqZcdFKJFkJUkIYl5OLSP3d97qMKJE=; b=DFgZxu/5MTH2QYqJ/BTuoCMlc0xJKGhzXfNFkFqHDOKr1gp7JKUU88Z5 z/RXujOa4koxATXVEeekj4NUo/miNdH4W5DfiQZP/ZLRs//uHSMC/a8xQ KG/Xug5zHPothK1aur1/DXuSBXFm3D9xq2vaVT03u7sbO32IVT1urgOUf 0O65WsSI6NidegWZ151MTqQTJXy/lyFxI1pxNzQerP3s0DiyHXF+wx9E4 UetQWnH51hwlDDo08Ge8CHAxnZnW37ClQHWKzDG7JS1y5sMcWOefLaEKJ fWNY0IV84f0FoTt1aS0XB/ZCcPC4GggiG85gx9Xhlkq80qnWJGFSHlr7i g==; X-CSE-ConnectionGUID: 0QC4/gXtSJO9iqRyQ3iBMg== X-CSE-MsgGUID: L6YtgqXnROqIKkQCQyjzRQ== X-IronPort-AV: E=McAfee;i="6600,9927,11073"; a="11961579" X-IronPort-AV: E=Sophos;i="6.08,161,1712646000"; d="scan'208";a="11961579" X-CSE-ConnectionGUID: Y4kqdQc5Sg2Sm8czTXt5yg== X-CSE-MsgGUID: Nan8b20KT2KU0oBwkNA+aA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,161,1712646000"; d="scan'208";a="31396385" From: Zhenzhong Duan To: qemu-devel@nongnu.org Cc: alex.williamson@redhat.com, clg@redhat.com, eric.auger@redhat.com, chao.p.peng@intel.com, Zhenzhong Duan Subject: [PATCH 16/16] vfio/pci-quirks: Make vfio_add_*_cap() return bool Date: Wed, 15 May 2024 16:20:41 +0800 Message-Id: <20240515082041.556571-17-zhenzhong.duan@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240515082041.556571-1-zhenzhong.duan@intel.com> References: <20240515082041.556571-1-zhenzhong.duan@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=198.175.65.18; envelope-from=zhenzhong.duan@intel.com; helo=mgamail.intel.com X-Spam_score_int: -53 X-Spam_score: -5.4 X-Spam_bar: ----- X-Spam_report: (-5.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.974, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1715761585224100003 This is to follow the coding standand in qapi/error.h to return bool for bool-valued functions. Include below functions: vfio_add_virt_caps() vfio_add_nv_gpudirect_cap() vfio_add_vmd_shadow_cap() Suggested-by: C=C3=A9dric Le Goater Signed-off-by: Zhenzhong Duan Reviewed-by: C=C3=A9dric Le Goater --- hw/vfio/pci.h | 2 +- hw/vfio/pci-quirks.c | 42 +++++++++++++++++++----------------------- hw/vfio/pci.c | 3 +-- 3 files changed, 21 insertions(+), 26 deletions(-) diff --git a/hw/vfio/pci.h b/hw/vfio/pci.h index f158681072..bf67df2fbc 100644 --- a/hw/vfio/pci.h +++ b/hw/vfio/pci.h @@ -212,7 +212,7 @@ void vfio_bar_quirk_setup(VFIOPCIDevice *vdev, int nr); void vfio_bar_quirk_exit(VFIOPCIDevice *vdev, int nr); void vfio_bar_quirk_finalize(VFIOPCIDevice *vdev, int nr); void vfio_setup_resetfn_quirk(VFIOPCIDevice *vdev); -int vfio_add_virt_caps(VFIOPCIDevice *vdev, Error **errp); +bool vfio_add_virt_caps(VFIOPCIDevice *vdev, Error **errp); void vfio_quirk_reset(VFIOPCIDevice *vdev); VFIOQuirk *vfio_quirk_alloc(int nr_mem); void vfio_probe_igd_bar4_quirk(VFIOPCIDevice *vdev, int nr); diff --git a/hw/vfio/pci-quirks.c b/hw/vfio/pci-quirks.c index ca27917159..39dae72497 100644 --- a/hw/vfio/pci-quirks.c +++ b/hw/vfio/pci-quirks.c @@ -1536,7 +1536,7 @@ static bool is_valid_std_cap_offset(uint8_t pos) pos <=3D (PCI_CFG_SPACE_SIZE - PCI_CAP_SIZEOF)); } =20 -static int vfio_add_nv_gpudirect_cap(VFIOPCIDevice *vdev, Error **errp) +static bool vfio_add_nv_gpudirect_cap(VFIOPCIDevice *vdev, Error **errp) { ERRP_GUARD(); PCIDevice *pdev =3D &vdev->pdev; @@ -1545,18 +1545,18 @@ static int vfio_add_nv_gpudirect_cap(VFIOPCIDevice = *vdev, Error **errp) uint8_t tmp; =20 if (vdev->nv_gpudirect_clique =3D=3D 0xFF) { - return 0; + return true; } =20 if (!vfio_pci_is(vdev, PCI_VENDOR_ID_NVIDIA, PCI_ANY_ID)) { error_setg(errp, "NVIDIA GPUDirect Clique ID: invalid device vendo= r"); - return -EINVAL; + return false; } =20 if (pci_get_byte(pdev->config + PCI_CLASS_DEVICE + 1) !=3D PCI_BASE_CLASS_DISPLAY) { error_setg(errp, "NVIDIA GPUDirect Clique ID: unsupported PCI clas= s"); - return -EINVAL; + return false; } =20 /* @@ -1572,7 +1572,7 @@ static int vfio_add_nv_gpudirect_cap(VFIOPCIDevice *v= dev, Error **errp) vdev->config_offset + PCI_CAPABILITY_LIST); if (ret !=3D 1 || !is_valid_std_cap_offset(tmp)) { error_setg(errp, "NVIDIA GPUDirect Clique ID: error getting cap li= st"); - return -EINVAL; + return false; } =20 do { @@ -1590,13 +1590,13 @@ static int vfio_add_nv_gpudirect_cap(VFIOPCIDevice = *vdev, Error **errp) pos =3D 0xD4; } else { error_setg(errp, "NVIDIA GPUDirect Clique ID: invalid config space= "); - return -EINVAL; + return false; } =20 ret =3D pci_add_capability(pdev, PCI_CAP_ID_VNDR, pos, 8, errp); if (ret < 0) { error_prepend(errp, "Failed to add NVIDIA GPUDirect cap: "); - return ret; + return false; } =20 memset(vdev->emulated_config_bits + pos, 0xFF, 8); @@ -1608,7 +1608,7 @@ static int vfio_add_nv_gpudirect_cap(VFIOPCIDevice *v= dev, Error **errp) pci_set_byte(pdev->config + pos++, vdev->nv_gpudirect_clique << 3); pci_set_byte(pdev->config + pos, 0); =20 - return 0; + return true; } =20 /* @@ -1629,7 +1629,7 @@ static int vfio_add_nv_gpudirect_cap(VFIOPCIDevice *v= dev, Error **errp) */ #define VMD_SHADOW_CAP_VER 1 #define VMD_SHADOW_CAP_LEN 24 -static int vfio_add_vmd_shadow_cap(VFIOPCIDevice *vdev, Error **errp) +static bool vfio_add_vmd_shadow_cap(VFIOPCIDevice *vdev, Error **errp) { ERRP_GUARD(); uint8_t membar_phys[16]; @@ -1639,7 +1639,7 @@ static int vfio_add_vmd_shadow_cap(VFIOPCIDevice *vde= v, Error **errp) vfio_pci_is(vdev, PCI_VENDOR_ID_INTEL, 0x467F) || vfio_pci_is(vdev, PCI_VENDOR_ID_INTEL, 0x4C3D) || vfio_pci_is(vdev, PCI_VENDOR_ID_INTEL, 0x9A0B))) { - return 0; + return true; } =20 ret =3D pread(vdev->vbasedev.fd, membar_phys, 16, @@ -1647,14 +1647,14 @@ static int vfio_add_vmd_shadow_cap(VFIOPCIDevice *v= dev, Error **errp) if (ret !=3D 16) { error_report("VMD %s cannot read MEMBARs (%d)", vdev->vbasedev.name, ret); - return -EFAULT; + return false; } =20 ret =3D pci_add_capability(&vdev->pdev, PCI_CAP_ID_VNDR, pos, VMD_SHADOW_CAP_LEN, errp); if (ret < 0) { error_prepend(errp, "Failed to add VMD MEMBAR Shadow cap: "); - return ret; + return false; } =20 memset(vdev->emulated_config_bits + pos, 0xFF, VMD_SHADOW_CAP_LEN); @@ -1664,22 +1664,18 @@ static int vfio_add_vmd_shadow_cap(VFIOPCIDevice *v= dev, Error **errp) pci_set_long(vdev->pdev.config + pos, 0x53484457); /* SHDW */ memcpy(vdev->pdev.config + pos + 4, membar_phys, 16); =20 - return 0; + return true; } =20 -int vfio_add_virt_caps(VFIOPCIDevice *vdev, Error **errp) +bool vfio_add_virt_caps(VFIOPCIDevice *vdev, Error **errp) { - int ret; - - ret =3D vfio_add_nv_gpudirect_cap(vdev, errp); - if (ret) { - return ret; + if (!vfio_add_nv_gpudirect_cap(vdev, errp)) { + return false; } =20 - ret =3D vfio_add_vmd_shadow_cap(vdev, errp); - if (ret) { - return ret; + if (!vfio_add_vmd_shadow_cap(vdev, errp)) { + return false; } =20 - return 0; + return true; } diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index 15823c359a..1254650d4a 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -2194,8 +2194,7 @@ static bool vfio_add_std_cap(VFIOPCIDevice *vdev, uin= t8_t pos, Error **errp) vdev->emulated_config_bits[PCI_CAPABILITY_LIST] =3D 0xff; vdev->emulated_config_bits[PCI_STATUS] |=3D PCI_STATUS_CAP_LIST; =20 - ret =3D vfio_add_virt_caps(vdev, errp); - if (ret) { + if (!vfio_add_virt_caps(vdev, errp)) { return false; } } --=20 2.34.1