From patchwork Thu Nov 17 17:35:46 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Cedric Bosdonnat X-Patchwork-Id: 9434835 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 C9DC86047D for ; Thu, 17 Nov 2016 17:39:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BC40E29687 for ; Thu, 17 Nov 2016 17:39:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B0ECD29689; Thu, 17 Nov 2016 17:39:01 +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 0177829687 for ; Thu, 17 Nov 2016 17:39:01 +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 1c7Qbx-0008CE-LN; Thu, 17 Nov 2016 17:36:33 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c7Qbw-0008BK-E0 for xen-devel@lists.xen.org; Thu, 17 Nov 2016 17:36:32 +0000 Received: from [85.158.139.211] by server-17.bemta-5.messagelabs.com id 95/75-04629-F9AED285; Thu, 17 Nov 2016 17:36:31 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprAIsWRWlGSWpSXmKPExsVyuP0uq+68V7o RBsdWW1ks+biYxYHR4+ju30wBjFGsmXlJ+RUJrBlb/p1hK2gKrvi5/Q9TA+M16y5GLg4hgSWM EtOmr2LuYuTkYBOwl+j6c5QJxBYRkJa49vkyI4jNLFAisfdpB5gtLGAm0TxvLpjNIqAqsev4K 7BeXgFziYmTHoHFJQTkJS5cPcUCYnMKWEgcOHwOrEYIqObNmwVMEPWCEidnPgGq4QCary6xfp 4QxCp5ieats5knMPLOQlI1C6FqFpKqBYzMqxg1ilOLylKLdI3M9ZKKMtMzSnITM3N0DQ1M9XJ Ti4sT01NzEpOK9ZLzczcxAkOqnoGBcQfj1S1+hxglOZiURHmZX+pGCPEl5adUZiQWZ8QXleak Fh9ilOHgUJLgLQDJCRalpqdWpGXmAIMbJi3BwaMkwisJkuYtLkjMLc5Mh0idYlSUEucNA0kIg CQySvPg2mARdYlRVkqYl5GBgUGIpyC1KDezBFX+FaM4B6OSMO8ikCk8mXklcNNfAS1mAlq8R0 AHZHFJIkJKqoGRhdtW75bbSYGEmmlvPBr2bezw+aYpt6ElIbZ43pVfbDrBwu+zKz9nn+5h7Cl /u/PukUBLRjG3wmab7Qe2dxm5bjGz5VBcfG6h+5aYlJP7Qu5GqFXvqdHhdi7iV6wV6XEXDu19 5BOwkKdF+Pibcyn95WdlJO0uux74co+BK6DBLsTyfrJcgRJLcUaioRZzUXEiAEExF52jAgAA X-Env-Sender: cbosdonnat@suse.com X-Msg-Ref: server-6.tower-206.messagelabs.com!1479404189!70651338!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 53517 invoked from network); 17 Nov 2016 17:36:30 -0000 Received: from smtp.nue.novell.com (HELO smtp.nue.novell.com) (195.135.221.5) by server-6.tower-206.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 17 Nov 2016 17:36:30 -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); Thu, 17 Nov 2016 18:36:28 +0100 From: =?UTF-8?q?C=C3=A9dric=20Bosdonnat?= To: xen-devel@lists.xen.org Date: Thu, 17 Nov 2016 18:35:46 +0100 Message-Id: <20161117173617.6697-5-cbosdonnat@suse.com> X-Mailer: git-send-email 2.10.1 In-Reply-To: <20161117173617.6697-1-cbosdonnat@suse.com> References: <20161117173617.6697-1-cbosdonnat@suse.com> MIME-Version: 1.0 Cc: Wei Liu , Ian Jackson , Cedric Bosdonnat Subject: [Xen-devel] [PATCH v2 04/35] libxl.c: switch to LOG*D use 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 From: Cedric Bosdonnat 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 includes all LOG* to LOG*D changes where the domain ID is not just a domid variable. We want the domain ID provided to the LOG*D functions to be the one of the publicly known domain, not a stubdom one. Signed-off-by: Cédric Bosdonnat --- tools/libxl/libxl.c | 79 +++++++++++++++++++++++++++-------------------------- 1 file changed, 41 insertions(+), 38 deletions(-) diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c index 0ee7d9f..6fd4fe1 100644 --- a/tools/libxl/libxl.c +++ b/tools/libxl/libxl.c @@ -1125,7 +1125,7 @@ static void domain_death_occurred(libxl__egc *egc, EGC_GC; libxl_evgen_domain_death *const evg = *evg_upd; - LOG(DEBUG, "%s", why); + LOGD(DEBUG, evg->domid, "%s", why); libxl_evgen_domain_death *evg_next = LIBXL_TAILQ_NEXT(evg, entry); *evg_upd = evg_next; @@ -1165,10 +1165,10 @@ static void domain_death_xswatch_callback(libxl__egc *egc, libxl__ev_xswatch *w, } gotend = &domaininfos[rc]; - LOG(DEBUG, "[evg=%p:%"PRIu32"] nentries=%d rc=%d %ld..%ld", - evg, evg->domid, nentries, rc, - rc>0 ? (long)domaininfos[0].domain : 0, - rc>0 ? (long)domaininfos[rc-1].domain : 0); + LOGD(DEBUG, evg->domid, "[evg=%p] nentries=%d rc=%d %ld..%ld", + evg, nentries, rc, + rc>0 ? (long)domaininfos[0].domain : 0, + rc>0 ? (long)domaininfos[rc-1].domain : 0); for (;;) { if (!evg) { @@ -1176,10 +1176,10 @@ static void domain_death_xswatch_callback(libxl__egc *egc, libxl__ev_xswatch *w, goto all_reported; } - LOG(DEBUG, "[evg=%p:%"PRIu32"]" - " got=domaininfos[%d] got->domain=%ld", - evg, evg->domid, (int)(got - domaininfos), - got < gotend ? (long)got->domain : -1L); + LOGD(DEBUG, evg->domid, "[evg=%p]" + " got=domaininfos[%d] got->domain=%ld", + evg, (int)(got - domaininfos), + got < gotend ? (long)got->domain : -1L); if (!rc) { domain_death_occurred(egc, &evg, "empty list"); @@ -1204,8 +1204,8 @@ static void domain_death_xswatch_callback(libxl__egc *egc, libxl__ev_xswatch *w, } assert(evg->domid == got->domain); - LOG(DEBUG, " exists shutdown_reported=%d"" dominf.flags=%x", - evg->shutdown_reported, got->flags); + LOGD(DEBUG, evg->domid, "Exists shutdown_reported=%d"" dominf.flags=%x", + evg->shutdown_reported, got->flags); if (got->flags & XEN_DOMINF_dying) { domain_death_occurred(egc, &evg, "dying"); @@ -1455,7 +1455,7 @@ static void domain_destroy_cb(libxl__egc *egc, libxl__domain_destroy_state *dds, STATE_AO_GC(dds->ao); if (rc) - LOG(ERROR, "destruction of domain %u failed", dds->domid); + LOGD(ERROR, dds->domid, "Destruction of domain failed"); libxl__ao_complete(egc, ao, rc); } @@ -1504,7 +1504,8 @@ static void stubdom_destroy_callback(libxl__egc *egc, const char *savefile; if (rc) { - LOG(ERROR, "unable to destroy stubdom with domid %u", dis->domid); + LOGD(ERROR, dds->domain.domid, "Unable to destroy stubdom with domid %u", + dis->domid); dds->rc = rc; } @@ -1512,7 +1513,8 @@ static void stubdom_destroy_callback(libxl__egc *egc, savefile = libxl__device_model_savefile(gc, dis->domid); rc = libxl__remove_file(gc, savefile); if (rc) { - LOG(ERROR, "failed to remove device-model savefile %s", savefile); + LOGD(ERROR, dds->domain.domid, "Failed to remove device-model savefile %s", + savefile); } destroy_finish_check(egc, dds); @@ -1526,7 +1528,7 @@ static void domain_destroy_callback(libxl__egc *egc, libxl__domain_destroy_state *dds = CONTAINER_OF(dis, *dds, domain); if (rc) { - LOG(ERROR, "unable to destroy guest with domid %u", dis->domid); + LOGD(ERROR, dis->domid, "Unable to destroy guest"); dds->rc = rc; } @@ -1723,8 +1725,8 @@ static void domain_destroy_domid_cb(libxl__egc *egc, if (status) { if (WIFEXITED(status) && WEXITSTATUS(status)<126) { - LOGEV(ERROR, WEXITSTATUS(status), - "xc_domain_destroy failed for %"PRIu32"", dis->domid); + LOGEVD(ERROR, WEXITSTATUS(status), dis->domid, + "xc_domain_destroy failed"); } else { libxl_report_child_exitstatus(CTX, XTL_ERROR, "async domain destroy", pid, status); @@ -1999,7 +2001,7 @@ void device_addrm_aocomplete(libxl__egc *egc, libxl__ao_device *aodev) if (aodev->rc) { if (aodev->dev) { - LOG(ERROR, "unable to %s %s with id %u", + LOGD(ERROR, aodev->dev->domid, "Unable to %s %s with id %u", libxl__device_action_to_string(aodev->action), libxl__device_kind_to_string(aodev->dev->kind), aodev->dev->devid); @@ -2905,9 +2907,9 @@ char *libxl__device_disk_find_local_path(libxl__gc *gc, char *be_path, *pdpath; int rc; - LOG(DEBUG, - "Run from a script; checking for physical-device-path (vdev %s)", - disk->vdev); + LOGD(DEBUG, guest_domid, + "Run from a script; checking for physical-device-path (vdev %s)", + disk->vdev); rc = libxl__device_from_disk(gc, guest_domid, disk, &device); if (rc < 0) @@ -2917,13 +2919,13 @@ char *libxl__device_disk_find_local_path(libxl__gc *gc, pdpath = libxl__sprintf(gc, "%s/physical-device-path", be_path); - LOG(DEBUG, "Attempting to read node %s", pdpath); + LOGD(DEBUG, guest_domid, "Attempting to read node %s", pdpath); path = libxl__xs_read(gc, XBT_NULL, pdpath); if (path) - LOG(DEBUG, "Accessing cooked block device %s", path); + LOGD(DEBUG, guest_domid, "Accessing cooked block device %s", path); else - LOG(DEBUG, "No physical-device-path, can't access locally."); + LOGD(DEBUG, guest_domid, "No physical-device-path, can't access locally."); goto out; } @@ -3064,10 +3066,10 @@ static void local_device_detach_cb(libxl__egc *egc, libxl__ao_device *aodev) int rc; if (aodev->rc) { - LOGE(ERROR, "unable to %s %s with id %u", - libxl__device_action_to_string(aodev->action), - libxl__device_kind_to_string(aodev->dev->kind), - aodev->dev->devid); + LOGED(ERROR, aodev->dev->domid, "Unable to %s %s with id %u", + libxl__device_action_to_string(aodev->action), + libxl__device_kind_to_string(aodev->dev->kind), + aodev->dev->devid); goto out; } @@ -3728,8 +3730,8 @@ static void qdisk_spawn_outcome(libxl__egc *egc, libxl__dm_spawn_state *dmss, { STATE_AO_GC(dmss->spawn.ao); - LOG(DEBUG, "qdisk backend spawn for domain %u %s", dmss->guest_domid, - rc ? "failed" : "succeed"); + LOGD(DEBUG, dmss->guest_domid, "qdisk backend spawn %s", + rc ? "failed" : "succeed"); libxl__nested_ao_free(dmss->spawn.ao); } @@ -3882,8 +3884,7 @@ static void backend_watch_callback(libxl__egc *egc, libxl__ev_xswatch *watch, dguest->domid = dev->domid; LIBXL_SLIST_INIT(&dguest->devices); LIBXL_SLIST_INSERT_HEAD(&ddomain->guests, dguest, next); - LOG(DEBUG, "added domain %u to the list of active guests", - dguest->domid); + LOGD(DEBUG, dguest->domid, "Added domain to the list of active guests"); } ddev = search_for_device(dguest, dev); if (ddev == NULL && state == XenbusStateClosed) { @@ -3900,7 +3901,8 @@ static void backend_watch_callback(libxl__egc *egc, libxl__ev_xswatch *watch, ddev = libxl__zalloc(NOGC, sizeof(*ddev)); ddev->dev = dev; LIBXL_SLIST_INSERT_HEAD(&dguest->devices, ddev, next); - LOG(DEBUG, "added device %s to the list of active devices", path); + LOGD(DEBUG, dev->domid, "Added device %s to the list of active devices", + path); rc = add_device(egc, nested_ao, dguest, ddev); if (rc > 0) free_ao = true; @@ -3914,7 +3916,8 @@ static void backend_watch_callback(libxl__egc *egc, libxl__ev_xswatch *watch, */ LIBXL_SLIST_REMOVE(&dguest->devices, ddev, libxl__ddomain_device, next); - LOG(DEBUG, "removed device %s from the list of active devices", path); + LOGD(DEBUG, dev->domid, "Removed device %s from the list of active devices", + path); rc = remove_device(egc, nested_ao, dguest, ddev); if (rc > 0) free_ao = true; @@ -3925,8 +3928,7 @@ static void backend_watch_callback(libxl__egc *egc, libxl__ev_xswatch *watch, if (num_devs == 0) { LIBXL_SLIST_REMOVE(&ddomain->guests, dguest, libxl__ddomain_guest, next); - LOG(DEBUG, "removed domain %u from the list of active guests", - dguest->domid); + LOGD(DEBUG, dguest->domid, "Removed domain from the list of active guests"); /* Clear any leftovers in libxl/ */ libxl__xs_rm_checked(gc, XBT_NULL, GCSPRINTF("libxl/%u", dguest->domid)); @@ -4111,7 +4113,7 @@ retry_transaction: if (target) { *target_memkb = strtoull(target, &endptr, 10); if (*endptr != '\0') { - LOGE(ERROR, "invalid memory target %s from %s\n", target, + LOGED(ERROR, 0, "Invalid memory target %s from %s\n", target, target_path); rc = ERROR_FAIL; goto out; @@ -4121,7 +4123,8 @@ retry_transaction: if (staticmax) { *max_memkb = strtoull(staticmax, &endptr, 10); if (*endptr != '\0') { - LOGE(ERROR, "invalid memory static-max %s from %s\n", staticmax, + LOGED(ERROR, 0, "Invalid memory static-max %s from %s\n", + staticmax, max_path); rc = ERROR_FAIL; goto out;