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

[QEMU][PATCH v8 07/11] hw/xen/xen-hvm-common: Use g_new and error_report


  • To: <qemu-devel@xxxxxxxxxx>
  • From: Vikram Garhwal <vikram.garhwal@xxxxxxx>
  • Date: Wed, 14 Jun 2023 17:03:35 -0700
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=nongnu.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); 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=mOsqWHq5VHxUgGsBfaYThNjh0r5g1aFE14BtltHtrOE=; b=YKV/OBLphnLlthGUJSPvWkVFm5g/GDy/BvK/pXHcSHkFeBRCIggbbSR4IuL3ZdNoyd6zMV6Gdd2yDPOgihattlf+aPzPrX9yxrbfb+HmVOIb6ASxNdZiaZnAbl0YbKNFoFuWg5FJrgIE5KNoucbJZuqC2ggaRB2PLnlPZgLaziqkBEQPP3tq35m+Rji/uSrELEEtsj0EBKGpJFejw2olSZeiAW8Y2qDKjOYg4Rur9idVivNfg0LEeh/hGL7EYD96912+eCmzZHHT/cTzA9W6L1glm/Ixq5Pan9Z8BW6HJogujpzHDR1e1pO8NwOCGBncEkw23+yeLOCzaXFPHpsdxA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jrIvBp3JGh6ZSlnwfU6e0PNgqqUzgE1V8Yp/PrednBbwjJCneUxlTgkTtKNIhaSYeVd5wBJIwzgfzv6+mv4rfOLQOjhpHK9DKH5CFYju9Rc2P1EiszIG+7WuxkNvd67AS3/gRRGLsAnXd43sCbPUVIW9Styq1bRUqZ+cOCRaR01uWvmJnhpbKgiHQNN1j4pckgk209CPlPop9B1q0lO7x3lPloI7gcvPQQ61QHUuSVdfOGGPQ0yNo2qc1ZG3xJ5wBbX2BM9Hj+InxG1udov75a0WXg26FxiFmVqQ2nFtyoH6n+ktsUVTWPw9+RJBiyAI/+Ofj0E4UiM+2GPrZIbXzw==
  • Cc: <sstabellini@xxxxxxxxxx>, Vikram Garhwal <vikram.garhwal@xxxxxxx>, Anthony Perard <anthony.perard@xxxxxxxxxx>, Paul Durrant <paul@xxxxxxx>, "open list:X86 Xen CPUs" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Thu, 15 Jun 2023 00:05:17 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Replace g_malloc with g_new and perror with error_report.

Signed-off-by: Vikram Garhwal <vikram.garhwal@xxxxxxx>
Reviewed-by: Stefano Stabellini <sstabellini@xxxxxxxxxx>
Reviewed-by: Paul Durrant <paul@xxxxxxx>
---
 hw/xen/xen-hvm-common.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/hw/xen/xen-hvm-common.c b/hw/xen/xen-hvm-common.c
index cb82f4b83d..42339c96bd 100644
--- a/hw/xen/xen-hvm-common.c
+++ b/hw/xen/xen-hvm-common.c
@@ -33,7 +33,7 @@ void xen_ram_alloc(ram_addr_t ram_addr, ram_addr_t size, 
MemoryRegion *mr,
     trace_xen_ram_alloc(ram_addr, size);
 
     nr_pfn = size >> TARGET_PAGE_BITS;
-    pfn_list = g_malloc(sizeof (*pfn_list) * nr_pfn);
+    pfn_list = g_new(xen_pfn_t, nr_pfn);
 
     for (i = 0; i < nr_pfn; i++) {
         pfn_list[i] = (ram_addr >> TARGET_PAGE_BITS) + i;
@@ -730,7 +730,7 @@ void destroy_hvm_domain(bool reboot)
             return;
         }
         if (errno != ENOTTY /* old Xen */) {
-            perror("xendevicemodel_shutdown failed");
+            error_report("xendevicemodel_shutdown failed with error %d", 
errno);
         }
         /* well, try the old thing then */
     }
@@ -784,7 +784,7 @@ static void xen_do_ioreq_register(XenIOState *state,
     }
 
     /* Note: cpus is empty at this point in init */
-    state->cpu_by_vcpu_id = g_malloc0(max_cpus * sizeof(CPUState *));
+    state->cpu_by_vcpu_id = g_new0(CPUState *, max_cpus);
 
     rc = xen_set_ioreq_server_state(xen_domid, state->ioservid, true);
     if (rc < 0) {
@@ -793,7 +793,7 @@ static void xen_do_ioreq_register(XenIOState *state,
         goto err;
     }
 
-    state->ioreq_local_port = g_malloc0(max_cpus * sizeof (evtchn_port_t));
+    state->ioreq_local_port = g_new0(evtchn_port_t, max_cpus);
 
     /* FIXME: how about if we overflow the page here? */
     for (i = 0; i < max_cpus; i++) {
@@ -850,13 +850,13 @@ void xen_register_ioreq(XenIOState *state, unsigned int 
max_cpus,
 
     state->xce_handle = qemu_xen_evtchn_open();
     if (state->xce_handle == NULL) {
-        perror("xen: event channel open");
+        error_report("xen: event channel open failed with error %d", errno);
         goto err;
     }
 
     state->xenstore = xs_daemon_open();
     if (state->xenstore == NULL) {
-        perror("xen: xenstore open");
+        error_report("xen: xenstore open failed with error %d", errno);
         goto err;
     }
 
-- 
2.17.1




 


Rackspace

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