From: "Cédric Bosdonnat" <cbosdonnat@suse.com>
To: xen-devel@lists.xen.org
Cc: "Wei Liu" <wei.liu2@citrix.com>,
"Ian Jackson" <ian.jackson@eu.citrix.com>,
"Cédric Bosdonnat" <cbosdonnat@suse.com>
Subject: [PATCH 03/35] libxl.c: switch to LOG*D use (refactored messages)
Date: Tue, 15 Nov 2016 11:18:41 +0100 [thread overview]
Message-ID: <20161115101913.10396-4-cbosdonnat@suse.com> (raw)
In-Reply-To: <20161115101913.10396-1-cbosdonnat@suse.com>
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 <cbosdonnat@suse.com>
---
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);
--
2.10.1
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2016-11-15 10:18 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-15 10:18 [PATCH 00/35] libxl LOG*D functions Cédric Bosdonnat
2016-11-15 10:18 ` [PATCH 01/35] libxl: add LIBXL_LOGD_* and LOG*D function families Cédric Bosdonnat
2016-11-17 14:41 ` Wei Liu
2016-11-17 16:01 ` Cedric Bosdonnat
2016-11-17 16:12 ` Wei Liu
2016-11-17 16:29 ` Ian Jackson
2016-11-17 16:34 ` Wei Liu
2016-11-17 16:36 ` Ian Jackson
2016-11-17 16:38 ` Wei Liu
2016-11-15 10:18 ` [PATCH 02/35] libxl.c: switch to LOG*D use Cédric Bosdonnat
2016-11-15 10:18 ` Cédric Bosdonnat [this message]
2016-11-15 10:18 ` [PATCH 04/35] " Cédric Bosdonnat
2016-11-17 14:50 ` Wei Liu
2016-11-17 16:03 ` Cedric Bosdonnat
2016-11-17 16:15 ` Wei Liu
2016-11-17 16:30 ` Ian Jackson
2016-11-15 10:18 ` [PATCH 05/35] libxl/libxl_bootloader.c: used LOG*D functions Cédric Bosdonnat
2016-11-15 10:18 ` [PATCH 06/35] libxl/libxl_checkpoint_device.c: " Cédric Bosdonnat
2016-11-15 10:18 ` [PATCH 07/35] libxl/libxl_colo.h: " Cédric Bosdonnat
2016-11-15 10:18 ` [PATCH 08/35] libxl/libxl_colo_nic.c: " Cédric Bosdonnat
2016-11-15 10:18 ` [PATCH 09/35] libxl/libxl_colo_proxy.c: " Cédric Bosdonnat
2016-11-15 10:18 ` [PATCH 10/35] libxl/libxl_colo_qdisk.c: " Cédric Bosdonnat
2016-11-15 10:18 ` [PATCH 11/35] libxl/libxl_colo_restore.c: " Cédric Bosdonnat
2016-11-15 10:18 ` [PATCH 12/35] libxl/libxl_colo_save.c: " Cédric Bosdonnat
2016-11-15 10:18 ` [PATCH 13/35] libxl/libxl_create.c: " Cédric Bosdonnat
2016-11-15 10:18 ` [PATCH 14/35] libxl/libxl_device.c: " Cédric Bosdonnat
2016-11-15 10:18 ` [PATCH 15/35] libxl/libxl_dm.c: " Cédric Bosdonnat
2016-11-15 10:18 ` [PATCH 16/35] libxl/libxl_dom_save.c: " Cédric Bosdonnat
2016-11-15 10:18 ` [PATCH 17/35] libxl/libxl_dom_suspend.c: " Cédric Bosdonnat
2016-11-15 10:18 ` [PATCH 18/35] libxl/libxl_freebsd.c: " Cédric Bosdonnat
2016-11-15 10:18 ` [PATCH 19/35] libxl/libxl_internal.c: " Cédric Bosdonnat
2016-11-15 10:18 ` [PATCH 20/35] libxl/libxl_linux.c: " Cédric Bosdonnat
2016-11-15 10:18 ` [PATCH 21/35] libxl/libxl_netbsd.c: " Cédric Bosdonnat
2016-11-15 10:19 ` [PATCH 22/35] libxl/libxl_netbuffer.c: " Cédric Bosdonnat
2016-11-15 10:19 ` [PATCH 23/35] libxl/libxl_nic.c: " Cédric Bosdonnat
2016-11-15 10:19 ` [PATCH 24/35] libxl/libxl_no_colo.c: " Cédric Bosdonnat
2016-11-15 10:19 ` [PATCH 25/35] libxl/libxl_pci.c: " Cédric Bosdonnat
2016-11-15 10:19 ` [PATCH 26/35] libxl/libxl_psr.c: " Cédric Bosdonnat
2016-11-15 10:19 ` [PATCH 27/35] libxl/libxl_pvusb.c: " Cédric Bosdonnat
2016-11-15 10:19 ` [PATCH 28/35] libxl/libxl_qmp.c: " Cédric Bosdonnat
2016-11-15 10:19 ` [PATCH 29/35] libxl/libxl_remus.c: " Cédric Bosdonnat
2016-11-15 10:19 ` [PATCH 30/35] libxl/libxl_save_callout.c: " Cédric Bosdonnat
2016-11-15 10:19 ` [PATCH 31/35] libxl/libxl_stream_write.c: " Cédric Bosdonnat
2016-11-15 10:19 ` [PATCH 32/35] libxl/libxl_vnuma.c: " Cédric Bosdonnat
2016-11-15 10:19 ` [PATCH 33/35] libxl/libxl_vtpm.c: " Cédric Bosdonnat
2016-11-15 10:19 ` [PATCH 34/35] libxl/libxl_x86.c: " Cédric Bosdonnat
2016-11-15 10:19 ` [PATCH 35/35] libxl/libxl_xshelp.c: " Cédric Bosdonnat
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20161115101913.10396-4-cbosdonnat@suse.com \
--to=cbosdonnat@suse.com \
--cc=ian.jackson@eu.citrix.com \
--cc=wei.liu2@citrix.com \
--cc=xen-devel@lists.xen.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).