From patchwork Fri Dec 2 15:08:21 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Cedric Bosdonnat X-Patchwork-Id: 9458733 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 59DAB60236 for ; Fri, 2 Dec 2016 15:11:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4B7C628542 for ; Fri, 2 Dec 2016 15:11:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 405922856B; Fri, 2 Dec 2016 15:11:55 +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 5B3C928542 for ; Fri, 2 Dec 2016 15:11:54 +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 1cCpSh-00035u-Tu; Fri, 02 Dec 2016 15:09:19 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cCpSg-0002wK-3g for xen-devel@lists.xen.org; Fri, 02 Dec 2016 15:09:18 +0000 Received: from [85.158.143.35] by server-4.bemta-6.messagelabs.com id 31/CF-28568-D9E81485; Fri, 02 Dec 2016 15:09:17 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupjkeJIrShJLcpLzFFi42I53H6XVXdOn2O EwZ9JahZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8aej8UFdxoYKy7PesDYwLgupIuRi0NIYAmj xMZdT9i6GDk52ATsJbr+HGUCsUUEpCWufb7MCGIzC5RINJ3rZO5i5OAQFnCQWPQgCyTMIqAqc WP3FBaQMK+ApcSVVV4gYQkBeYmF54+ATeEECj9ouQ42RUjAQqL5xh0WEJtXQFDi5MwnYK3MAu oS6+cJQSySl2jeOpt5AiPvLCRVsxCqZiGpWsDIvIpRozi1qCy1SNfIXC+pKDM9oyQ3MTNH19D ATC83tbg4MT01JzGpWC85P3cTIzCcGIBgB+PitYGHGCU5mJREeU1zHCOE+JLyUyozEosz4otK c1KLDzHKcHAoSfD+7QHKCRalpqdWpGXmAAMbJi3BwaMkwqvaC5TmLS5IzC3OTIdInWJUlBLnd QZJCIAkMkrz4Npg0XSJUVZKmJcR6BAhnoLUotzMElT5V4ziHIxKwhBTeDLzSuCmvwJazAS0uO O6PcjikkSElFQDY3CAexAX6+49zeZf1qqF/+mKXtJaHtyVVK50aEGow6uOECOj3vt9/y5v0eW sZtFrTNH31rNU7WW7FcF3/mkt56JFlp1WvqtKqxKD+QOcxa583v7Kq7V+woatwbyVtxIfOHS2 LLn/unw2m/0C5iKJA1MLvk275JBW/uDr/yq7lzZqZhf4VzEqsRRnJBpqMRcVJwIAOT34vqECA AA= X-Env-Sender: cbosdonnat@suse.com X-Msg-Ref: server-8.tower-21.messagelabs.com!1480691356!46257043!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 36383 invoked from network); 2 Dec 2016 15:09:16 -0000 Received: from smtp.nue.novell.com (HELO smtp.nue.novell.com) (195.135.221.5) by server-8.tower-21.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 2 Dec 2016 15:09:16 -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); Fri, 02 Dec 2016 16:09:15 +0100 From: =?UTF-8?q?C=C3=A9dric=20Bosdonnat?= To: xen-devel@lists.xen.org Date: Fri, 2 Dec 2016 16:08:21 +0100 Message-Id: <20161202150841.31227-16-cbosdonnat@suse.com> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20161202150841.31227-1-cbosdonnat@suse.com> References: <20161202150841.31227-1-cbosdonnat@suse.com> MIME-Version: 1.0 Cc: Ian Jackson , Wei Liu , Cedric Bosdonnat Subject: [Xen-devel] [PATCH v2 15/35] libxl/libxl_dm.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: Cedric Bosdonnat Use LOG*D logging functions where possible instead of the LOG* ones. Signed-off-by: Cédric Bosdonnat Acked-by: Wei Liu --- tools/libxl/libxl_dm.c | 111 ++++++++++++++++++++++++++----------------------- 1 file changed, 59 insertions(+), 52 deletions(-) diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c index ad366a8..be928ad 100644 --- a/tools/libxl/libxl_dm.c +++ b/tools/libxl/libxl_dm.c @@ -455,7 +455,7 @@ static int libxl__build_device_model_args_old(libxl__gc *gc, if (vnc->listen) { if (strchr(vnc->listen, ':') != NULL) { if (vnc->display) { - LOG(ERROR, "vncdisplay set, vnclisten contains display"); + LOGD(ERROR, domid, "vncdisplay set, vnclisten contains display"); return ERROR_INVAL; } vncarg = vnc->listen; @@ -502,15 +502,15 @@ static int libxl__build_device_model_args_old(libxl__gc *gc, char *s; if (b_info->kernel) { - LOG(ERROR, "HVM direct kernel boot is not supported by " - "qemu-xen-traditional"); + LOGD(ERROR, domid, "HVM direct kernel boot is not supported by " + "qemu-xen-traditional"); return ERROR_INVAL; } if (b_info->u.hvm.serial || b_info->u.hvm.serial_list) { if ( b_info->u.hvm.serial && b_info->u.hvm.serial_list ) { - LOG(ERROR, "Both serial and serial_list set"); + LOGD(ERROR, domid, "Both serial and serial_list set"); return ERROR_INVAL; } if (b_info->u.hvm.serial) { @@ -550,7 +550,7 @@ static int libxl__build_device_model_args_old(libxl__gc *gc, case LIBXL_VGA_INTERFACE_TYPE_QXL: break; default: - LOG(ERROR, "Invalid emulated video card specified"); + LOGD(ERROR, domid, "Invalid emulated video card specified"); return ERROR_INVAL; } @@ -562,7 +562,7 @@ static int libxl__build_device_model_args_old(libxl__gc *gc, || b_info->u.hvm.usbdevice_list) { if ( b_info->u.hvm.usbdevice && b_info->u.hvm.usbdevice_list ) { - LOG(ERROR, "Both usbdevice and usbdevice_list set"); + LOGD(ERROR, domid, "Both usbdevice and usbdevice_list set"); return ERROR_INVAL; } flexarray_append(dm_args, "-usb"); @@ -632,7 +632,7 @@ static int libxl__build_device_model_args_old(libxl__gc *gc, flexarray_append(dm_args, "-gfx_passthru"); break; default: - LOG(ERROR, "unsupported gfx_passthru_kind."); + LOGD(ERROR, domid, "unsupported gfx_passthru_kind."); return ERROR_INVAL; } } @@ -970,7 +970,7 @@ static int libxl__build_device_model_args_new(libxl__gc *gc, break; default: /* We've forgotten to add the clause */ - LOG(ERROR, "%s: unknown channel connection %d", + LOGD(ERROR, guest_domid, "%s: unknown channel connection %d", __func__, connection); return ERROR_INVAL; } @@ -1014,7 +1014,8 @@ static int libxl__build_device_model_args_new(libxl__gc *gc, if (vnc->listen) { if (strchr(vnc->listen, ':') != NULL) { if (vnc->display) { - LOG(ERROR, "vncdisplay set, vnclisten contains display"); + LOGD(ERROR, guest_domid, + "vncdisplay set, vnclisten contains display"); return ERROR_INVAL; } vncarg = vnc->listen; @@ -1075,7 +1076,7 @@ static int libxl__build_device_model_args_new(libxl__gc *gc, if (b_info->u.hvm.serial || b_info->u.hvm.serial_list) { if ( b_info->u.hvm.serial && b_info->u.hvm.serial_list ) { - LOG(ERROR, "Both serial and serial_list set"); + LOGD(ERROR, guest_domid, "Both serial and serial_list set"); return ERROR_INVAL; } if (b_info->u.hvm.serial) { @@ -1133,7 +1134,7 @@ static int libxl__build_device_model_args_new(libxl__gc *gc, (b_info->video_memkb/2/1024), (b_info->video_memkb/2/1024) ) ); break; default: - LOG(ERROR, "Invalid emulated video card specified"); + LOGD(ERROR, guest_domid, "Invalid emulated video card specified"); return ERROR_INVAL; } @@ -1146,7 +1147,7 @@ static int libxl__build_device_model_args_new(libxl__gc *gc, || b_info->u.hvm.usbdevice_list) { if ( b_info->u.hvm.usbdevice && b_info->u.hvm.usbdevice_list ) { - LOG(ERROR, "Both usbdevice and usbdevice_list set"); + LOGD(ERROR, guest_domid, "Both usbdevice and usbdevice_list set"); return ERROR_INVAL; } flexarray_append(dm_args, "-usb"); @@ -1183,7 +1184,7 @@ static int libxl__build_device_model_args_new(libxl__gc *gc, "-device", "nec-usb-xhci,id=usb", NULL); break; default: - LOG(ERROR, "usbversion parameter is invalid, " + LOGD(ERROR, guest_domid, "usbversion parameter is invalid, " "must be between 1 and 3"); return ERROR_INVAL; } @@ -1196,7 +1197,7 @@ static int libxl__build_device_model_args_new(libxl__gc *gc, GCSPRINTF("usb-redir,chardev=usbrc%d," "id=usbrc%d", i, i), NULL); } else { - LOG(ERROR, "usbredirection parameter is invalid, " + LOGD(ERROR, guest_domid, "usbredirection parameter is invalid, " "it must be between 1 and 4"); return ERROR_INVAL; } @@ -1282,8 +1283,8 @@ static int libxl__build_device_model_args_new(libxl__gc *gc, (b_info->u.hvm.mmio_hole_memkb << 10); if (max_ram_below_4g > HVM_BELOW_4G_MMIO_START) { - LOG(WARN, "mmio_hole_memkb=%"PRIu64 - " invalid ignored.\n", + LOGD(WARN, guest_domid, "mmio_hole_memkb=%"PRIu64 + " invalid ignored.\n", b_info->u.hvm.mmio_hole_memkb); } else { machinearg = GCSPRINTF("%s,max-ram-below-4g=%"PRIu64, @@ -1299,10 +1300,10 @@ static int libxl__build_device_model_args_new(libxl__gc *gc, machinearg = GCSPRINTF("%s,igd-passthru=on", machinearg); break; case LIBXL_GFX_PASSTHRU_KIND_DEFAULT: - LOG(ERROR, "unable to detect required gfx_passthru_kind"); + LOGD(ERROR, guest_domid, "unable to detect required gfx_passthru_kind"); return ERROR_FAIL; default: - LOG(ERROR, "invalid value for gfx_passthru_kind"); + LOGD(ERROR, guest_domid, "invalid value for gfx_passthru_kind"); return ERROR_INVAL; } } @@ -1332,8 +1333,8 @@ static int libxl__build_device_model_args_new(libxl__gc *gc, int colo_mode; if (dev_number == -1) { - LOG(WARN, "unable to determine"" disk number for %s", - disks[i].vdev); + LOGD(WARN, guest_domid, "unable to determine"" disk number for %s", + disks[i].vdev); continue; } @@ -1348,17 +1349,17 @@ static int libxl__build_device_model_args_new(libxl__gc *gc, if (disks[i].format == LIBXL_DISK_FORMAT_EMPTY) { if (!disks[i].is_cdrom) { - LOG(WARN, "Cannot support empty disk format for %s", - disks[i].vdev); + LOGD(WARN, guest_domid, "Cannot support empty disk format for %s", + disks[i].vdev); continue; } } else { if (format == NULL) { - LOG(WARN, - "Unable to determine disk image format: %s\n" - "Disk will be available via PV drivers but not as an" - "emulated disk.", - disks[i].vdev); + LOGD(WARN, guest_domid, + "Unable to determine disk image format: %s\n" + "Disk will be available via PV drivers but not as an" + "emulated disk.", + disks[i].vdev); continue; } @@ -1378,10 +1379,10 @@ static int libxl__build_device_model_args_new(libxl__gc *gc, guest_domid, &disks[i], true); if (!target_path) { - LOG(WARN, "No way to get local access disk to image: %s\n" - "Disk will be available via PV drivers but not as an" - "emulated disk.", - disks[i].vdev); + LOGD(WARN, guest_domid, "No way to get local access disk to image: %s\n" + "Disk will be available via PV drivers but not as an" + "emulated disk.", + disks[i].vdev); continue; } } @@ -1426,7 +1427,8 @@ static int libxl__build_device_model_args_new(libxl__gc *gc, colo_mode); } else if (disk < 6 && b_info->u.hvm.hdtype == LIBXL_HDTYPE_AHCI) { if (!disks[i].readwrite) { - LOG(ERROR, "qemu-xen doesn't support read-only AHCI disk drivers"); + LOGD(ERROR, guest_domid, + "qemu-xen doesn't support read-only AHCI disk drivers"); return ERROR_INVAL; } flexarray_vappend(dm_args, "-drive", @@ -1437,7 +1439,8 @@ static int libxl__build_device_model_args_new(libxl__gc *gc, continue; } else if (disk < 4) { if (!disks[i].readwrite) { - LOG(ERROR, "qemu-xen doesn't support read-only IDE disk drivers"); + LOGD(ERROR, guest_domid, + "qemu-xen doesn't support read-only IDE disk drivers"); return ERROR_INVAL; } if (colo_mode == LIBXL__COLO_SECONDARY) { @@ -1490,14 +1493,14 @@ static int libxl__build_device_model_args_new(libxl__gc *gc, if (ret < 0) return ret; if (ret > 0) { - LOG(WARN, "Could not find user %s%d, falling back to %s", + LOGD(WARN, guest_domid, "Could not find user %s%d, falling back to %s", LIBXL_QEMU_USER_BASE, guest_domid, LIBXL_QEMU_USER_SHARED); goto end_search; } user = NULL; - LOG(DEBUG, "Could not find user %s, starting QEMU as root", - LIBXL_QEMU_USER_SHARED); + LOGD(DEBUG, guest_domid, "Could not find user %s, starting QEMU as root", + LIBXL_QEMU_USER_SHARED); end_search: if (user != NULL && strcmp(user, "root")) { @@ -1536,8 +1539,8 @@ static int libxl__build_device_model_args(libxl__gc *gc, args, envs, state, dm_state_fd); default: - LOGE(ERROR, "unknown device model version %d", - guest_config->b_info.device_model_version); + LOGED(ERROR, guest_domid, "unknown device model version %d", + guest_config->b_info.device_model_version); return ERROR_INVAL; } } @@ -1764,7 +1767,8 @@ void libxl__spawn_stub_dm(libxl__egc *egc, libxl__stub_dm_spawn_state *sdss) "%d", guest_domid); ret = xc_domain_set_target(ctx->xch, dm_domid, guest_domid); if (ret<0) { - LOGE(ERROR, "setting target domain %d -> %d", dm_domid, guest_domid); + LOGED(ERROR, guest_domid, "setting target domain %d -> %d", + dm_domid, guest_domid); ret = ERROR_FAIL; goto out; } @@ -1814,7 +1818,7 @@ static void spawn_stub_launch_dm(libxl__egc *egc, uint32_t dm_domid = sdss->pvqemu.guest_domid; if (ret) { - LOG(ERROR, "error connecting disk devices"); + LOGD(ERROR, guest_domid, "error connecting disk devices"); goto out; } @@ -1929,7 +1933,8 @@ static void stubdom_pvqemu_cb(libxl__egc *egc, libxl__xswait_init(&sdss->xswait); if (rc) { - LOGE(ERROR, "error connecting nics devices"); + LOGED(ERROR, sdss->dm.guest_domid, + "error connecting nics devices"); goto out; } @@ -1960,7 +1965,8 @@ static void stubdom_xswait_cb(libxl__egc *egc, libxl__xswait_state *xswait, if (rc) { if (rc == ERROR_TIMEDOUT) - LOG(ERROR, "%s: startup timed out", xswait->what); + LOGD(ERROR, sdss->dm.guest_domid, + "%s: startup timed out", xswait->what); goto out; } @@ -2021,7 +2027,7 @@ void libxl__spawn_local_dm(libxl__egc *egc, libxl__dm_spawn_state *dmss) goto out; } if (access(dm, X_OK) < 0) { - LOGE(ERROR, "device model %s is not executable", dm); + LOGED(ERROR, domid, "device model %s is not executable", dm); rc = ERROR_FAIL; goto out; } @@ -2064,7 +2070,7 @@ void libxl__spawn_local_dm(libxl__egc *egc, libxl__dm_spawn_state *dmss) } null = open("/dev/null", O_RDONLY); if (null < 0) { - LOGE(ERROR, "unable to open /dev/null"); + LOGED(ERROR, domid, "unable to open /dev/null"); rc = ERROR_FAIL; goto out_close; } @@ -2091,13 +2097,13 @@ retry_transaction: } } - LOG(DEBUG, "Spawning device-model %s with arguments:", dm); + LOGD(DEBUG, domid, "Spawning device-model %s with arguments:", dm); for (arg = args; *arg; arg++) - LOG(DEBUG, " %s", *arg); + LOGD(DEBUG, domid, " %s", *arg); if (*envs) { - LOG(DEBUG, "Spawning device-model %s with additional environment:", dm); + LOGD(DEBUG, domid, "Spawning device-model %s with additional environment:", dm); for (arg = envs; *arg; arg += 2) - LOG(DEBUG, " %s=%s", arg[0], arg[1]); + LOGD(DEBUG, domid, " %s=%s", arg[0], arg[1]); } spawn->what = GCSPRINTF("domain %d device model", domid); @@ -2186,14 +2192,15 @@ static void device_model_spawn_outcome(libxl__egc *egc, int ret2; if (rc) - LOG(ERROR, "%s: spawn failed (rc=%d)", dmss->spawn.what, rc); + LOGD(ERROR, dmss->guest_domid, + "%s: spawn failed (rc=%d)", dmss->spawn.what, rc); libxl__domain_build_state *state = dmss->build_state; if (state->saved_state) { ret2 = unlink(state->saved_state); if (ret2) { - LOGE(ERROR, "%s: failed to remove device-model state %s", + LOGED(ERROR, dmss->guest_domid, "%s: failed to remove device-model state %s", dmss->spawn.what, state->saved_state); rc = ERROR_FAIL; goto out; @@ -2339,7 +2346,7 @@ int libxl__destroy_device_model(libxl__gc *gc, uint32_t domid) { char *path = DEVICE_MODEL_XS_PATH(gc, LIBXL_TOOLSTACK_DOMID, domid, ""); if (!xs_rm(CTX->xsh, XBT_NULL, path)) - LOG(ERROR, "xs_rm failed for %s", path); + LOGD(ERROR, domid, "xs_rm failed for %s", path); /* We should try to destroy the device model anyway. */ return kill_device_model(gc, GCSPRINTF("/local/domain/%d/image/device-model-pid", domid)); @@ -2420,7 +2427,7 @@ int libxl__dm_check_start(libxl__gc *gc, libxl_domain_config *d_config, if (!rc) return 0; - LOG(ERROR, "device model required but not running"); + LOGD(ERROR, domid, "device model required but not running"); rc = ERROR_FAIL; out: