[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [QEMU][PATCH v2 07/11] hw/xen/xen-hvm-common: Use g_new and error_setg_errno


  • To: Markus Armbruster <armbru@xxxxxxxxxx>, Philippe Mathieu-Daudé <philmd@xxxxxxxxxx>
  • From: Vikram Garhwal <vikram.garhwal@xxxxxxx>
  • Date: Fri, 2 Dec 2022 10:20:59 -0800
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=BZ69CHRlfdN4I3hVCpWV/lfxUwjlocGG+HP+RS/t750=; b=Ndsh+Rr4Kf3tHUiXKYoDLTZZzOP0IX3RrTgpKXkN7lh460Gs9UgHiSSG4tyJ/8gGeKrdSiib7hhCInGGfJrK2tc0nsNf7Dw2IQ2UFplrxmiIrwwBXV3z+4YXkQIY7fDRQW4Oi9pLfkxJ/Ho1HTUVhfA3yhmol9AxtO2B938FuOBD6IxVARgT/slVVI53wygY+NC9pTxYcOaKomYBe5eZD2yz+otRiD2AUabp1hq+05rOO82yCtasqsAbCC2EEdcz2p1Cjsgm9xY8FngunCXFLk3RWYv7raFVsTbcb3zK7+kD2peOQT08yi3/PvlvOs6dXRVfe7cSN9Pcg2GK7vjJmQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=E2WQKw+MzIylEXQmPhnf/4W8M6wgI+baxH74TxpwJerlF7NBl6UvdRlJp/zRn3djoEm20eVDaAVrPqsOC+AMOnZZg/vXJL/tc+ft2+2SEeYfgbNClpIwpg5CnPx/01vDzOWy+TisrR8ZhZoVU4zi+8/fT87gJTMYSsLd35r+Yx1B+Z9VT6hdc7AyoIvjQ75fb0UZ5x1SYCiRE6vs9XPgeLAFnZrCqycsxTys/mz08MRz++Gy+8f7MgCC8PE2ScwQfVZQrpV2P/R7xdw2hF066sKTN6XYVMNDDuXm2kqY09qN8WAzJx5PmkZdUkWlNzqZFyceFiROODORuExY9/gKBw==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com;
  • Cc: qemu-dev@xxxxxxxxxx, stefano.stabellini@xxxxxxx, alex.bennee@xxxxxxxxxx, xen-devel@xxxxxxxxxxxxxxxxxxxx, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Anthony Perard <anthony.perard@xxxxxxxxxx>, Paul Durrant <paul@xxxxxxx>, "open list:All patches CC here" <qemu-devel@xxxxxxxxxx>
  • Delivery-date: Fri, 02 Dec 2022 18:21:29 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Hi Markus & Philippe,

Thanks for reviewing this one. Please see the question below.

On 12/2/22 12:53 AM, Markus Armbruster wrote:
Philippe Mathieu-Daudé <philmd@xxxxxxxxxx> writes:

On 2/12/22 03:59, Vikram Garhwal wrote:
Replace g_malloc with g_new and perror with error_setg_errno.

Signed-off-by: Vikram Garhwal <vikram.garhwal@xxxxxxx>
---
   hw/xen/xen-hvm-common.c | 15 ++++++++-------
   1 file changed, 8 insertions(+), 7 deletions(-)

@@ -717,7 +717,7 @@ void destroy_hvm_domain(bool reboot)
      xc_interface *xc_handle;
      int sts;
      int rc;
-
+    Error *errp = NULL;
      unsigned int reason = reboot ? SHUTDOWN_reboot : SHUTDOWN_poweroff;
if (xen_dmod) {
@@ -726,7 +726,7 @@ void destroy_hvm_domain(bool reboot)
              return;
          }
          if (errno != ENOTTY /* old Xen */) {
-            perror("xendevicemodel_shutdown failed");
+            error_setg_errno(&errp, errno, "xendevicemodel_shutdown failed");
See "qapi/error.h":

   * = Passing errors around =
   *
   * Errors get passed to the caller through the conventional @errp
   * parameter.

Here you are not passing the error to the caller.
Instead, you're leaking its memory.

Maybe you are looking for the "qemu/error-report.h" API?
Plausible.

Also, @errp is the conventional name for the Error ** parameter used to
pass errors to the caller.  Local Error * variables are usually called
@err or @local_err (I prefer the former).

[...]

IIUC, error_set_errno() is not okay as it needs to be called with errp from caller. But error_set(&err, "") is okay with locally defined **err = NULL;
Is that correct understanding?




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.