| [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: Vikram Garhwal <vikram.garhwal@xxxxxxx>, qemu-dev@xxxxxxxxxxFrom: Philippe Mathieu-Daudé <philmd@xxxxxxxxxx>Date: Fri, 2 Dec 2022 08:27:39 +0100Cc: 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>, Markus Armbruster <armbru@xxxxxxxxxx>Delivery-date: Fri, 02 Dec 2022 07:27:48 +0000List-id: Xen developer discussion <xen-devel.lists.xenproject.org> 
 
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.
Maybe you are looking for the "qemu/error-report.h" API?
 
          }
          /* well, try the old thing then */
      }
 
 
@@ -857,16 +857,17 @@ void xen_register_ioreq(XenIOState *state, unsigned int 
max_cpus,
                          MemoryListener xen_memory_listener)
  {
      int rc;
+    Error *errp = NULL;
state->xce_handle = xenevtchn_open(NULL, 0);
      if (state->xce_handle == NULL) {
-        perror("xen: event channel open");
+        error_setg_errno(&errp, errno, "xen: event channel open");
          goto err;
      }
state->xenstore = xs_daemon_open();
      if (state->xenstore == NULL) {
-        perror("xen: xenstore open");
+        error_setg_errno(&errp, errno, "xen: xenstore open");
          goto err;
      }
 
Ditto.
 
 |