From patchwork Tue Nov 15 10:18:41 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Cedric Bosdonnat X-Patchwork-Id: 9429323 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 23C5960469 for ; Tue, 15 Nov 2016 10:21:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0C04E286BF for ; Tue, 15 Nov 2016 10:21:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 01157286C2; Tue, 15 Nov 2016 10:21:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5296E286C4 for ; Tue, 15 Nov 2016 10:21:56 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c6aqO-0004rK-GR; Tue, 15 Nov 2016 10:20:00 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c6aqM-0004px-OJ for xen-devel@lists.xen.org; Tue, 15 Nov 2016 10:19:58 +0000 Received: from [85.158.139.211] by server-15.bemta-5.messagelabs.com id C1/61-13537-E41EA285; Tue, 15 Nov 2016 10:19:58 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprAIsWRWlGSWpSXmKPExsVyuP0uq67vQ60 Ig4eTZS2WfFzM4sDocXT3b6YAxijWzLyk/IoE1ozWYxtYC6bGVfw6w9/A2GTfxcjFISSwhFHi 0bV/bF2MnBxsAvYSXX+OMoHYIgLSEtc+X2YEKWIWaGeU+HBvGytIQljAU+LRl3tgDSwCqhIty 0+zg9i8AhYS69/tZwGxJQTkJS5cPQVmcwpYSvw8+hSsRgioZsnlbmaIekGJkzOfANVwAC1Ql1 g/TwgkzAzU2rx1NvMERt5ZSKpmIVTNQlK1gJF5FaNGcWpRWWqRrpG5XlJRZnpGSW5iZo6uoYG pXm5qcXFiempOYlKxXnJ+7iZGYEjVMzAw7mC8usXvEKMkB5OSKK/Qaq0IIb6k/JTKjMTijPii 0pzU4kOMMhwcShK8Cg+AcoJFqempFWmZOcDghklLcPAoifDGgKR5iwsSc4sz0yFSpxgVpcR5n 94HSgiAJDJK8+DaYBF1iVFWSpiXkYGBQYinILUoN7MEVf4VozgHo5Iw7yuQKTyZeSVw018BLW YCWrzLXANkcUkiQkqqgbF2udVvf+OU2tdm9bFd7+do6qjv+ex+t+SrqYbz4iubnm1M2n1ue13 ytStrGvp+sytkB35P3Hfz15V9RdX8N1kbXln+MyywN5hSOK8gtudp9Lb6zxcYmi7xaW69x6Lh 5nee53lAzqJGnXXvQ0/a9x1pk9l6uXLjdh+7kwLRh6rMvZh6vKu0S5VYijMSDbWYi4oTAYYwB aujAgAA X-Env-Sender: cbosdonnat@suse.com X-Msg-Ref: server-15.tower-206.messagelabs.com!1479205196!56590934!1 X-Originating-IP: [195.135.221.5] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.0.16; banners=-,-,- X-VirusChecked: Checked Received: (qmail 34583 invoked from network); 15 Nov 2016 10:19:57 -0000 Received: from smtp.nue.novell.com (HELO smtp.nue.novell.com) (195.135.221.5) by server-15.tower-206.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 15 Nov 2016 10:19:57 -0000 Received: from laptop.vms (mhy71-2-88-167-63-197.fbx.proxad.net [88.167.63.197]) by smtp.nue.novell.com with ESMTP (TLS encrypted); Tue, 15 Nov 2016 11:19:55 +0100 From: =?UTF-8?q?C=C3=A9dric=20Bosdonnat?= To: xen-devel@lists.xen.org Date: Tue, 15 Nov 2016 11:18:41 +0100 Message-Id: <20161115101913.10396-4-cbosdonnat@suse.com> X-Mailer: git-send-email 2.10.1 In-Reply-To: <20161115101913.10396-1-cbosdonnat@suse.com> References: <20161115101913.10396-1-cbosdonnat@suse.com> MIME-Version: 1.0 Cc: Wei Liu , Ian Jackson , =?UTF-8?q?C=C3=A9dric=20Bosdonnat?= Subject: [Xen-devel] [PATCH 03/35] libxl.c: switch to LOG*D use (refactored messages) X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Use LOG*D functions to output the domain ID in logs as much as possible. This will help consumer code sorting the logs by domain. This commit changes LOG*() into LOG*D(), adds a domid parameter and messages has been altered to remove the domain id from it since it is already contained in the output log string. Signed-off-by: Cédric Bosdonnat --- tools/libxl/libxl.c | 118 ++++++++++++++++++++++++---------------------------- 1 file changed, 55 insertions(+), 63 deletions(-) diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c index b5ff309..0ee7d9f 100644 --- a/tools/libxl/libxl.c +++ b/tools/libxl/libxl.c @@ -428,19 +428,16 @@ int libxl__domain_rename(libxl__gc *gc, uint32_t domid, if (old_name) { got_old_name = xs_read(ctx->xsh, trans, name_path, &got_old_len); if (!got_old_name) { - LOGEV(ERROR, errno, - "check old name for domain %"PRIu32" allegedly named `%s'", - domid, - old_name); + LOGEVD(ERROR, errno, domid, + "Check old name for domain allegedly named `%s'", + old_name); goto x_fail; } if (strcmp(old_name, got_old_name)) { - LOG(ERROR, - "domain %"PRIu32" allegedly named " - "`%s' is actually named `%s' - racing ?", - domid, - old_name, - got_old_name); + LOGD(ERROR, domid, + "Allegedly named `%s' is actually named `%s' - racing ?", + old_name, + got_old_name); free(got_old_name); goto x_fail; } @@ -448,12 +445,11 @@ int libxl__domain_rename(libxl__gc *gc, uint32_t domid, } if (!xs_write(ctx->xsh, trans, name_path, new_name, strlen(new_name))) { - LOG(ERROR, - "failed to write new name `%s'" - " for domain %"PRIu32" previously named `%s'", - new_name, - domid, - old_name); + LOGD(ERROR, domid, + "Failed to write new name `%s'" + " for domain previously named `%s'", + new_name, + old_name); goto x_fail; } @@ -482,20 +478,18 @@ int libxl__domain_rename(libxl__gc *gc, uint32_t domid, if (!xs_transaction_end(ctx->xsh, our_trans, 0)) { trans = our_trans = 0; if (errno != EAGAIN) { - LOG(ERROR, - "failed to commit new name `%s'" - " for domain %"PRIu32" previously named `%s'", - new_name, - domid, - old_name); + LOGD(ERROR, domid, + "Failed to commit new name `%s'" + " for domain previously named `%s'", + new_name, + old_name); goto x_fail; } - LOG(DEBUG, - "need to retry rename transaction" - " for domain %"PRIu32" (name_path=\"%s\", new_name=\"%s\")", - domid, - name_path, - new_name); + LOGD(DEBUG, domid, + "Need to retry rename transaction" + " for domain (name_path=\"%s\", new_name=\"%s\")", + name_path, + new_name); goto retry_transaction; } our_trans = 0; @@ -987,7 +981,7 @@ int libxl_domain_core_dump(libxl_ctx *ctx, uint32_t domid, ret = xc_domain_dumpcore(ctx->xch, domid, filename); if (ret<0) { - LOGE(ERROR, "core dumping domain %d to %s", domid, filename); + LOGED(ERROR, domid, "Core dumping domain to %s", filename); rc = ERROR_FAIL; goto out; } @@ -1016,15 +1010,15 @@ int libxl_domain_unpause(libxl_ctx *ctx, uint32_t domid) LIBXL_DEVICE_MODEL_VERSION_NONE) { rc = libxl__domain_resume_device_model(gc, domid); if (rc < 0) { - LOG(ERROR, "failed to unpause device model for domain %u:%d", - domid, rc); + LOGD(ERROR, domid, "Failed to unpause device model for domain:%d", + rc); goto out; } } } ret = xc_domain_unpause(ctx->xch, domid); if (ret<0) { - LOGE(ERROR, "unpausing domain %d", domid); + LOGED(ERROR, domid, "Unpausing domain"); rc = ERROR_FAIL; } out: @@ -1573,7 +1567,7 @@ void libxl__destroy_domid(libxl__egc *egc, libxl__destroy_domid_state *dis) case 0: break; case ERROR_DOMAIN_NOTFOUND: - LOG(ERROR, "non-existant domain %d", domid); + LOGD(ERROR, domid, "Non-existant domain"); default: goto out; } @@ -1602,14 +1596,14 @@ void libxl__destroy_domid(libxl__egc *egc, libxl__destroy_domid_state *dis) } if (libxl__device_pci_destroy_all(gc, domid) < 0) - LOG(ERROR, "pci shutdown failed for domid %d", domid); + LOGD(ERROR, domid, "Pci shutdown failed"); rc = xc_domain_pause(ctx->xch, domid); if (rc < 0) { - LOGEV(ERROR, rc, "xc_domain_pause failed for %d", domid); + LOGEVD(ERROR, rc, domid, "xc_domain_pause failed"); } if (dm_present) { if (libxl__destroy_device_model(gc, domid) < 0) - LOG(ERROR, "libxl__destroy_device_model failed for %d", domid); + LOGD(ERROR, domid, "libxl__destroy_device_model failed"); libxl__qmp_cleanup(gc, domid); } @@ -1645,7 +1639,7 @@ static void devices_destroy_cb(libxl__egc *egc, } if (rc < 0) - LOG(ERROR, "libxl__devices_destroy failed for %d", domid); + LOGD(ERROR, domid, "libxl__devices_destroy failed"); vm_path = libxl__xs_read(gc, XBT_NULL, GCSPRINTF("%s/vm", dom_path)); if (vm_path) @@ -1704,13 +1698,13 @@ static void devices_destroy_cb(libxl__egc *egc, if (errno > 0 && errno < 126) { _exit(errno); } else { - LOGE(ERROR, - "xc_domain_destroy failed for %d (with difficult errno value %d)", - domid, errno); + LOGED(ERROR, domid, + "xc_domain_destroy failed (with difficult errno value %d)", + errno); _exit(-1); } } - LOG(DEBUG, "forked pid %ld for destroy of domain %d", (long)rc, domid); + LOGD(DEBUG, domid, "Forked pid %ld for destroy of domain", (long)rc); return; @@ -1823,7 +1817,7 @@ int libxl_console_get_tty(libxl_ctx *ctx, uint32_t domid, int cons_num, rc = libxl__console_tty_path(gc, domid, cons_num, type, &tty_path); if (rc) { - LOG(ERROR, "Failed to get tty path for domain %d\n", domid); + LOGD(ERROR, domid, "Failed to get tty path\n"); goto out; } @@ -1921,7 +1915,7 @@ int libxl_vncviewer_exec(libxl_ctx *ctx, uint32_t domid, int autopass) GCSPRINTF( "/local/domain/%d/console/vnc-port", domid)); if (!vnc_port) { - LOG(ERROR, "Cannot get vnc-port of domain %d", domid); + LOGD(ERROR, domid, "Cannot get vnc-port"); goto x_fail; } @@ -4286,11 +4280,10 @@ retry_transaction: memorykb = new_target_memkb + videoram; r = xc_domain_setmaxmem(ctx->xch, domid, memorykb + size); if (r != 0) { - LOGE(ERROR, - "xc_domain_setmaxmem domid=%u memkb=%"PRIu64" failed ""rc=%d\n", - domid, - memorykb + size, - r); + LOGED(ERROR, domid, + "xc_domain_setmaxmem memkb=%"PRIu64" failed ""rc=%d\n", + memorykb + size, + r); abort_transaction = 1; rc = ERROR_FAIL; goto out; @@ -4300,11 +4293,10 @@ retry_transaction: r = xc_domain_set_pod_target(ctx->xch, domid, (new_target_memkb + size) / 4, NULL, NULL, NULL); if (r != 0) { - LOGE(ERROR, - "xc_domain_set_pod_target domid=%d, memkb=%"PRIu64" failed rc=%d\n", - domid, - (new_target_memkb + size) / 4, - r); + LOGED(ERROR, domid, + "xc_domain_set_pod_target memkb=%"PRIu64" failed rc=%d\n", + (new_target_memkb + size) / 4, + r); abort_transaction = 1; rc = ERROR_FAIL; goto out; @@ -5113,7 +5105,7 @@ static int libxl__set_vcpuonline_qmp(libxl__gc *gc, uint32_t domid, libxl_for_each_set_bit(i, final_map) { rc = libxl__qmp_cpu_add(gc, domid, i); if (rc) { - LOG(ERROR, "failed to add cpu %d to domain %d", i, domid); + LOGD(ERROR, domid, "Failed to add cpu %d", i); goto out; } } @@ -6097,7 +6089,7 @@ uint32_t libxl_vm_get_start_time(libxl_ctx *ctx, uint32_t domid) start_time = libxl__xs_read( gc, XBT_NULL, GCSPRINTF("%s/start_time", vm_path)); if (start_time == NULL) { - LOGEV(ERROR, -1, "Can't get start time of domain '%d'", domid); + LOGEVD(ERROR, -1, domid, "Can't get start time of domain"); ret = -1; }else{ ret = strtoul(start_time, NULL, 10); @@ -6691,7 +6683,7 @@ static int libxl__update_avail_vcpus_qmp(libxl__gc *gc, uint32_t domid, rc = libxl__qmp_query_cpus(gc, domid, map); if (rc) { - LOG(ERROR, "fail to get number of cpus for domain %d", domid); + LOGD(ERROR, domid, "Fail to get number of cpus"); goto out; } @@ -6745,7 +6737,7 @@ int libxl_retrieve_domain_configuration(libxl_ctx *ctx, uint32_t domid, rc = libxl__get_domain_configuration(gc, domid, d_config); if (rc) { - LOG(ERROR, "fail to get domain configuration for domain %d", domid); + LOGD(ERROR, domid, "Fail to get domain configuration"); rc = ERROR_FAIL; goto out; } @@ -6755,7 +6747,7 @@ int libxl_retrieve_domain_configuration(libxl_ctx *ctx, uint32_t domid, char *domname; domname = libxl_domid_to_name(ctx, domid); if (!domname) { - LOG(ERROR, "fail to get domain name for domain %d", domid); + LOGD(ERROR, domid, "Fail to get domain name"); goto out; } free(d_config->c_info.name); @@ -6768,7 +6760,7 @@ int libxl_retrieve_domain_configuration(libxl_ctx *ctx, uint32_t domid, libxl_dominfo_init(&info); rc = libxl_domain_info(ctx, &info, domid); if (rc) { - LOG(ERROR, "fail to get domain info for domain %d", domid); + LOGD(ERROR, domid, "Fail to get domain info"); libxl_dominfo_dispose(&info); goto out; } @@ -6814,7 +6806,7 @@ int libxl_retrieve_domain_configuration(libxl_ctx *ctx, uint32_t domid, } if (rc) { - LOG(ERROR, "fail to update available cpu map for domain %d", domid); + LOGD(ERROR, domid, "Fail to update available cpu map"); goto out; } } @@ -6836,7 +6828,7 @@ int libxl_retrieve_domain_configuration(libxl_ctx *ctx, uint32_t domid, /* "target" */ rc = libxl__get_memory_target(gc, domid, &target_memkb, &max_memkb); if (rc) { - LOG(ERROR, "fail to get memory target for domain %d", domid); + LOGD(ERROR, domid, "Fail to get memory target"); goto out; } @@ -6887,8 +6879,8 @@ int libxl_retrieve_domain_configuration(libxl_ctx *ctx, uint32_t domid, num_dev = libxl__device_type_get_num(dt, d_config); p = dt->list(CTX, domid, &num); if (p == NULL) { - LOG(DEBUG, "no %s from xenstore for domain %d", - dt->type, domid); + LOGD(DEBUG, domid, "No %s from xenstore", + dt->type); } devs = libxl__device_type_get_ptr(dt, d_config);