From patchwork Tue Nov 15 10:18:52 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Cedric Bosdonnat X-Patchwork-Id: 9429329 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 20F6860469 for ; Tue, 15 Nov 2016 10:22:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 08DEA286BF for ; Tue, 15 Nov 2016 10:22:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F1AB0286C2; Tue, 15 Nov 2016 10:22:05 +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 5BE1E286B9 for ; Tue, 15 Nov 2016 10:22:05 +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 1c6aqW-0005Sx-Dv; Tue, 15 Nov 2016 10:20:08 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c6aqV-0005Nf-48 for xen-devel@lists.xen.org; Tue, 15 Nov 2016 10:20:07 +0000 Received: from [193.109.254.147] by server-10.bemta-6.messagelabs.com id 84/30-30618-651EA285; Tue, 15 Nov 2016 10:20:06 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprNIsWRWlGSWpSXmKPExsVyuP0uq27oQ60 Ig/kTFS2WfFzM4sDocXT3b6YAxijWzLyk/IoE1oz1T5azFvz2rpj3eBJrA+Mlky5GLg4hgSWM Ele/b2XuYuTkYBOwl+j6c5QJxBYRkJa49vkyI0gRs8AJRomejZvZuhg5OIQFHCWOrMoBqWERU JXoXvKXESTMK2ApcflCPUhYQkBe4sLVUywgNidQ+OfRp+wgtpCAhcSSy91gq3gFBCVOznzCAt LKLKAusX6eEEiYGai1eets5gmMvLOQVM1CqJqFpGoBI/MqRo3i1KKy1CJdIwO9pKLM9IyS3MT MHF1DAzO93NTi4sT01JzEpGK95PzcTYzAgGIAgh2Mv5YFHGKU5GBSEuUVWq0VIcSXlJ9SmZFY nBFfVJqTWnyIUYaDQ0mCV+EBUE6wKDU9tSItMwcY2jBpCQ4eJRHeGJA0b3FBYm5xZjpE6hSjL sebXS8fMAmx5OXnpUqJ8z69D1QkAFKUUZoHNwIWZ5cYZaWEeRmBjhLiKUgtys0sQZV/xSjOwa gkzPsKZApPZl4J3KZXQEcwAR2xy1wD5IiSRISUVAPj9g2L6pjWenrsO56xTc/C5ey192t+7ly npSivHct6+MwDhvd9310uHo7l1CkpbX3WFqZXMuVq9x+vO0KRCfrnzk9+12DV+fLdGbf81zpb cmq3ZS+82K/9N9N199wzwT/+5/ec7j0st+LHmtDe1cmfv10Kal/9YMqLwmSPR7MvtAr76J6+G ep9SImlOCPRUIu5qDgRAL+cLMeuAgAA X-Env-Sender: cbosdonnat@suse.com X-Msg-Ref: server-6.tower-27.messagelabs.com!1479205205!71990154!1 X-Originating-IP: [195.135.221.5] X-SpamReason: No, hits=0.5 required=7.0 tests=BODY_RANDOM_LONG X-StarScan-Received: X-StarScan-Version: 9.0.16; banners=-,-,- X-VirusChecked: Checked Received: (qmail 43699 invoked from network); 15 Nov 2016 10:20:05 -0000 Received: from smtp.nue.novell.com (HELO smtp.nue.novell.com) (195.135.221.5) by server-6.tower-27.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 15 Nov 2016 10:20:05 -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:20:04 +0100 From: =?UTF-8?q?C=C3=A9dric=20Bosdonnat?= To: xen-devel@lists.xen.org Date: Tue, 15 Nov 2016 11:18:52 +0100 Message-Id: <20161115101913.10396-15-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: =?UTF-8?q?C=C3=A9dric=20Bosdonnat?= , Wei Liu , Ian Jackson , =?UTF-8?q?C=C3=A9dric=20Bosdonnat?= Subject: [Xen-devel] [PATCH 14/35] libxl/libxl_device.c: used LOG*D functions 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: Cédric Bosdonnat Use LOG*D logging functions where possible instead of the LOG* ones. Signed-off-by: Cédric Bosdonnat --- tools/libxl/libxl_device.c | 70 ++++++++++++++++++++++++---------------------- 1 file changed, 37 insertions(+), 33 deletions(-) diff --git a/tools/libxl/libxl_device.c b/tools/libxl/libxl_device.c index 3e7a102..5e22866 100644 --- a/tools/libxl/libxl_device.c +++ b/tools/libxl/libxl_device.c @@ -94,13 +94,13 @@ int libxl__nic_type(libxl__gc *gc, libxl__device *dev, libxl_nic_type *nictype) snictype = libxl__xs_read(gc, XBT_NULL, GCSPRINTF("%s/%s", be_path, "type")); if (!snictype) { - LOGE(ERROR, "unable to read nictype from %s", be_path); + LOGED(ERROR, dev->domid, "unable to read nictype from %s", be_path); rc = ERROR_FAIL; goto out; } rc = libxl_nic_type_from_string(snictype, nictype); if (rc) { - LOGE(ERROR, "unable to parse nictype from %s", be_path); + LOGED(ERROR, dev->domid, "unable to parse nictype from %s", be_path); goto out; } @@ -231,7 +231,7 @@ retry_transaction: if (errno == EAGAIN) goto retry_transaction; else { - LOGE(ERROR, "xs transaction failed"); + LOGED(ERROR, device->domid, "xs transaction failed"); return ERROR_FAIL; } } @@ -885,7 +885,7 @@ void libxl__wait_device_connection(libxl__egc *egc, libxl__ao_device *aodev) state_path, XenbusStateInitWait, LIBXL_INIT_TIMEOUT * 1000); if (rc) { - LOG(ERROR, "unable to initialize device %s", be_path); + LOGD(ERROR, aodev->dev->domid, "unable to initialize device %s", be_path); goto out; } @@ -914,14 +914,14 @@ void libxl__initiate_device_generic_remove(libxl__egc *egc, rc = libxl__get_domid(gc, &my_domid); if (rc) { - LOG(ERROR, "unable to get my domid"); + LOGD(ERROR, domid, "unable to get my domid"); goto out; } if (my_domid == LIBXL_TOOLSTACK_DOMID) { rc = libxl_domain_info(CTX, &info, domid); if (rc) { - LOG(ERROR, "unable to get info for domain %d", domid); + LOGD(ERROR, domid, "unable to get info for domain %d", domid); goto out; } if (QEMU_BACKEND(aodev->dev) && @@ -934,8 +934,8 @@ void libxl__initiate_device_generic_remove(libxl__egc *egc, device_qemu_timeout, LIBXL_QEMU_BODGE_TIMEOUT * 1000); if (rc) { - LOG(ERROR, "unable to register timeout for Qemu device %s", - be_path); + LOGD(ERROR, domid, "unable to register timeout for Qemu device %s", + be_path); goto out; } goto out_success; @@ -945,7 +945,7 @@ void libxl__initiate_device_generic_remove(libxl__egc *egc, for (;;) { rc = libxl__xs_transaction_start(gc, &t); if (rc) { - LOG(ERROR, "unable to start transaction"); + LOGD(ERROR, domid, "unable to start transaction"); goto out; } @@ -955,7 +955,7 @@ void libxl__initiate_device_generic_remove(libxl__egc *egc, rc = libxl__xs_read_checked(gc, t, state_path, &state); if (rc) { - LOG(ERROR, "unable to read device state from path %s", state_path); + LOGD(ERROR, domid, "unable to read device state from path %s", state_path); goto out; } @@ -970,7 +970,7 @@ void libxl__initiate_device_generic_remove(libxl__egc *egc, if (state && atoi(state) != XenbusStateClosed) { rc = libxl__xs_write_checked(gc, t, state_path, GCSPRINTF("%d", XenbusStateClosing)); if (rc) { - LOG(ERROR, "unable to write to xenstore path %s", state_path); + LOGD(ERROR, domid, "unable to write to xenstore path %s", state_path); goto out; } } @@ -985,7 +985,7 @@ void libxl__initiate_device_generic_remove(libxl__egc *egc, state_path, XenbusStateClosed, LIBXL_DESTROY_TIMEOUT * 1000); if (rc) { - LOG(ERROR, "unable to remove device %s", be_path); + LOGD(ERROR, domid, "unable to remove device %s", be_path); goto out; } @@ -1019,7 +1019,7 @@ static void device_qemu_timeout(libxl__egc *egc, libxl__ev_time *ev, for (;;) { rc = libxl__xs_transaction_start(gc, &t); if (rc) { - LOG(ERROR, "unable to start transaction"); + LOGD(ERROR, aodev->dev->domid, "unable to start transaction"); goto out; } @@ -1056,22 +1056,22 @@ static void device_backend_callback(libxl__egc *egc, libxl__ev_devstate *ds, libxl__ao_device *aodev = CONTAINER_OF(ds, *aodev, backend_ds); STATE_AO_GC(aodev->ao); - LOG(DEBUG, "calling device_backend_cleanup"); + LOGD(DEBUG, aodev->dev->domid, "calling device_backend_cleanup"); device_backend_cleanup(gc, aodev); if (rc == ERROR_TIMEDOUT && aodev->action == LIBXL__DEVICE_ACTION_REMOVE && !aodev->force) { - LOG(DEBUG, "Timeout reached, initiating forced remove"); + LOGD(DEBUG, aodev->dev->domid, "Timeout reached, initiating forced remove"); aodev->force = 1; libxl__initiate_device_generic_remove(egc, aodev); return; } if (rc) { - LOG(ERROR, "unable to %s device with path %s", - libxl__device_action_to_string(aodev->action), - libxl__device_backend_path(gc, aodev->dev)); + LOGD(ERROR, aodev->dev->domid, "unable to %s device with path %s", + libxl__device_action_to_string(aodev->action), + libxl__device_backend_path(gc, aodev->dev)); goto out; } @@ -1106,12 +1106,13 @@ static void device_hotplug(libxl__egc *egc, libxl__ao_device *aodev) */ rc = libxl__get_domid(gc, &domid); if (rc) { - LOG(ERROR, "Failed to get domid"); + LOGD(ERROR, aodev->dev->domid, "Failed to get domid"); goto out; } if (aodev->dev->backend_domid != domid) { - LOG(DEBUG, "Backend domid %d, domid %d, assuming driver domains", - aodev->dev->backend_domid, domid); + LOGD(DEBUG, aodev->dev->domid, + "Backend domid %d, domid %d, assuming driver domains", + aodev->dev->backend_domid, domid); if (aodev->action != LIBXL__DEVICE_ACTION_REMOVE) { LOG(DEBUG, "Not a remove, not executing hotplug scripts"); @@ -1125,7 +1126,8 @@ static void device_hotplug(libxl__egc *egc, libxl__ao_device *aodev) aodev->xswait.callback = device_destroy_be_watch_cb; rc = libxl__xswait_start(gc, &aodev->xswait); if (rc) { - LOG(ERROR, "Setup of backend removal watch failed (path %s)", be_path); + LOGD(ERROR, aodev->dev->domid, + "Setup of backend removal watch failed (path %s)", be_path); goto out; } @@ -1140,43 +1142,44 @@ static void device_hotplug(libxl__egc *egc, libxl__ao_device *aodev) switch (hotplug) { case 0: /* no hotplug script to execute */ - LOG(DEBUG, "No hotplug script to execute"); + LOGD(DEBUG, aodev->dev->domid, "No hotplug script to execute"); goto out; case 1: /* execute hotplug script */ break; default: /* everything else is an error */ - LOG(ERROR, "unable to get args/env to execute hotplug script for " - "device %s", libxl__device_backend_path(gc, aodev->dev)); + LOGD(ERROR, aodev->dev->domid, + "unable to get args/env to execute hotplug script for " + "device %s", libxl__device_backend_path(gc, aodev->dev)); rc = hotplug; goto out; } assert(args != NULL); - LOG(DEBUG, "calling hotplug script: %s %s", args[0], args[1]); - LOG(DEBUG, "extra args:"); + LOGD(DEBUG, aodev->dev->domid, "calling hotplug script: %s %s", args[0], args[1]); + LOGD(DEBUG, aodev->dev->domid, "extra args:"); { const char *arg; unsigned int x; for (x = 2; (arg = args[x]); x++) - LOG(DEBUG, "\t%s", arg); + LOGD(DEBUG, aodev->dev->domid, "\t%s", arg); } - LOG(DEBUG, "env:"); + LOGD(DEBUG, aodev->dev->domid, "env:"); if (env != NULL) { const char *k, *v; unsigned int x; for (x = 0; (k = env[x]); x += 2) { v = env[x+1]; - LOG(DEBUG, "\t%s: %s", k, v); + LOGD(DEBUG, aodev->dev->domid, "\t%s: %s", k, v); } } nullfd = open("/dev/null", O_RDONLY); if (nullfd < 0) { - LOG(ERROR, "unable to open /dev/null for hotplug script"); + LOGD(ERROR, aodev->dev->domid, "unable to open /dev/null for hotplug script"); rc = ERROR_FAIL; goto out; } @@ -1260,8 +1263,9 @@ static void device_destroy_be_watch_cb(libxl__egc *egc, if (rc) { if (rc == ERROR_TIMEDOUT) - LOG(ERROR, "timed out while waiting for %s to be removed", - xswait->path); + LOGD(ERROR, aodev->dev->domid, + "timed out while waiting for %s to be removed", + xswait->path); aodev->rc = rc; goto out; }