From patchwork Fri Feb 2 15:36:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 769234 Delivered-To: patch@linaro.org Received: by 2002:adf:9bca:0:b0:33a:e5bd:fedd with SMTP id e10csp974003wrc; Fri, 2 Feb 2024 07:39:42 -0800 (PST) X-Google-Smtp-Source: AGHT+IG2snc56omzdG7EAkFw46NSizEf8pR+ftXByLEKxPVEVLZqpcBG7griE2PO5wIxXkBUviNL X-Received: by 2002:a05:6358:2489:b0:178:6ea7:6fef with SMTP id m9-20020a056358248900b001786ea76fefmr2211551rwc.8.1706888382541; Fri, 02 Feb 2024 07:39:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1706888382; cv=none; d=google.com; s=arc-20160816; b=zrwY6Jlat40YKuQz+Kf8tHImGiKgN8Utk61ZHOOykK/Xf9Ab3PJFj0Zq+h28f/aY+J mNpvg3fXkvLJtAPDXe3lOaYItHyRhyzu5genzu9RHQOAv5x06HHZGo0n5k+Fz0NLqfjN 3GWvSF2U6IDZtCT2u/pxMGfEcIRon75qVuRypM5Opsi7Ff+EARlB2UKnBSceijmZcLNF DojLF7/cGGtfPMyoH8uHDRgAultYePoRBOnZtV58/t1JOdABV8GKYEkuoO1aOW2wNdBa K9ds75GO0apA0xqGGFWyF7vuS5wxFb8HcZoq2hey2OUyYaVtKr9vgj4YYwVbnGt5IaKi xqAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=dM1ag+hc6Tlr+SofgNgQWcacda8AUiOk3VlHdLXApxg=; fh=h4XyLL69ueluNaAzJqqhbV9hpKbHLlbo1qHQmLufCvU=; b=GN9Wugir23/TZkXC/vBFveOx+hyp8pXGyEzEGjSGA7SYSsqRWvwlabiaNCnQun6+ci 9xHuljvJlN3U0FKpMBqWvRXT3FcMYIVKW8FUY6daP505MZrQSi5/DmS8UaqV/x6IYKco mujFeJSNEyeFQX9S4VzVkw8eUmyXkm+lmpmF0vPkWM6vq2EUsUVgWoCZG0qCIYlHxgHL OINX8x/gtcvQLVomrulcgNBpCrrEIquSVwZOzaK1Qbk3URL/bReTxXxHD8+XJltki8om 41aNqi421zGwu4pPLnms34j9avzYFTeH/Xez8bL+c1gN0KmWOV48P8jFjzPAykl0aZlf g2Sg==; darn=linaro.org ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KGHJBymG; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org X-Forwarded-Encrypted: i=0; AJvYcCVO/6w0acZ8n9eK1YEQrF4IhJu/WT22nVqjTIypqqxEwQy6MpXIekFJhLY4rjFTZuL+JQCIVtXVbXhqCxRZGhqL Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id n8-20020a0cec48000000b0068c7b64a468si2192665qvq.232.2024.02.02.07.39.42 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 02 Feb 2024 07:39:42 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KGHJBymG; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rVvb6-0000OC-Vd; Fri, 02 Feb 2024 10:36:56 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rVvb4-0000N4-Rn for qemu-devel@nongnu.org; Fri, 02 Feb 2024 10:36:54 -0500 Received: from mail-lf1-x12b.google.com ([2a00:1450:4864:20::12b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rVvb2-0004XF-P0 for qemu-devel@nongnu.org; Fri, 02 Feb 2024 10:36:54 -0500 Received: by mail-lf1-x12b.google.com with SMTP id 2adb3069b0e04-51121637524so3291047e87.1 for ; Fri, 02 Feb 2024 07:36:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1706888211; x=1707493011; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=dM1ag+hc6Tlr+SofgNgQWcacda8AUiOk3VlHdLXApxg=; b=KGHJBymGGw6ISJjzXuCGcMuKUFgF0qzw2ggCMNkQVqbckwJnxTRahOWQ7krE3w3nYs lTDOGFJeJM4pinum63vtEHnKjS8vF7ZFuy7J6ZCnga4/ioS+9O6SYL1YN37M6q2rC7PP 1i0LrU1bmyH2rvntOYhJ2O18iFo/u9fqYhB+0amgmwCG2i2h508I4vvGhkzPqPmN3Yov ZhhLasjXW5KEqxtZgWFX4UYNk639D5/DYOrOesFW0bBZxF5wPQrVFmpzugAkD/WEUvS9 0o80c4mT4Y1tTyMzYlZR2D9+2+hR0c6/zogmPA/UqPnpS5wI/vDN2lCCgNSWCXgMAEHC cFFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706888211; x=1707493011; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dM1ag+hc6Tlr+SofgNgQWcacda8AUiOk3VlHdLXApxg=; b=o6n5h70QtL2d/6nhq33Ec1HM0AxhTe9CtnwrGR81SR/iVGBU70DguSA5pEixlkyPNc HDX/zW7Qf6uDY0zqYnnmCOop//18/3WjqFKvTGIftzIecWhL0TnOwqIg+9rActaHYSDV qyESV/ml7r/gTdqr2rCdFsXcEoPNFW6pC2RorJdsf9oCWWSuVbCK02CIs8iDB2hbYh7Y zQWlutuosuVRUBXFNfFAO6ejezGNFxZAPbOv4otWdprTZmsC23eCPaOn7BRvRGOzIxAL 6V2T6FPa/Fln/0lhkgw5BmNMrV/CLASnggtshVb+hxftsaplr9ACGQI3WvcfhQSarJsI moDg== X-Gm-Message-State: AOJu0YxLnHLhWZQOGlyhLqDNVbwNAfvfU+d4t0ibRksHHc9c93JUQmda KFYwcjvFVyNmH3WBxm3d616Pe2NzgPjsFid7k7vmGXlPbEuHqfAqA0FR37Rcv0rvMzlPbrIlbj3 x X-Received: by 2002:ac2:592d:0:b0:511:3460:925c with SMTP id v13-20020ac2592d000000b005113460925cmr1719006lfi.65.1706888211220; Fri, 02 Feb 2024 07:36:51 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id k2-20020a05600c1c8200b0040fafd84095sm214735wms.41.2024.02.02.07.36.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 07:36:50 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 27/36] hw/xen/xen-hvm-common.c: convert DPRINTF to tracepoints Date: Fri, 2 Feb 2024 15:36:28 +0000 Message-Id: <20240202153637.3710444-28-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240202153637.3710444-1-peter.maydell@linaro.org> References: <20240202153637.3710444-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::12b; envelope-from=peter.maydell@linaro.org; helo=mail-lf1-x12b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Manos Pitsidianakis Tracing DPRINTFs to stderr might not be desired. A developer that relies on tracepoints should be able to opt-in to each tracepoint and rely on QEMU's log redirection, instead of stderr by default. This commit converts DPRINTFs in this file that are used for tracing into tracepoints. Signed-off-by: Manos Pitsidianakis Reviewed-by: Alex Bennée Message-id: b000ab73022dfeb7a7ab0ee8fd0f41fb208adaf0.1706544115.git.manos.pitsidianakis@linaro.org Signed-off-by: Peter Maydell --- hw/xen/xen-hvm-common.c | 35 ++++++++++++++++++----------------- hw/xen/trace-events | 10 +++++++++- 2 files changed, 27 insertions(+), 18 deletions(-) diff --git a/hw/xen/xen-hvm-common.c b/hw/xen/xen-hvm-common.c index 47e6cb1db3a..05a29c6f11a 100644 --- a/hw/xen/xen-hvm-common.c +++ b/hw/xen/xen-hvm-common.c @@ -169,11 +169,12 @@ static ioreq_t *cpu_get_ioreq_from_shared_memory(XenIOState *state, int vcpu) ioreq_t *req = xen_vcpu_ioreq(state->shared_page, vcpu); if (req->state != STATE_IOREQ_READY) { - DPRINTF("I/O request not ready: " - "%x, ptr: %x, port: %"PRIx64", " - "data: %"PRIx64", count: %u, size: %u\n", - req->state, req->data_is_ptr, req->addr, - req->data, req->count, req->size); + trace_cpu_get_ioreq_from_shared_memory_req_not_ready(req->state, + req->data_is_ptr, + req->addr, + req->data, + req->count, + req->size); return NULL; } @@ -601,10 +602,9 @@ static void xen_main_loop_prepare(XenIOState *state) if (evtchn_fd != -1) { CPUState *cpu_state; - DPRINTF("%s: Init cpu_by_vcpu_id\n", __func__); CPU_FOREACH(cpu_state) { - DPRINTF("%s: cpu_by_vcpu_id[%d]=%p\n", - __func__, cpu_state->cpu_index, cpu_state); + trace_xen_main_loop_prepare_init_cpu(cpu_state->cpu_index, + cpu_state); state->cpu_by_vcpu_id[cpu_state->cpu_index] = cpu_state; } qemu_set_fd_handler(evtchn_fd, cpu_handle_ioreq, NULL, state); @@ -681,7 +681,7 @@ static int xen_map_ioreq_server(XenIOState *state) } if (state->shared_page == NULL) { - DPRINTF("shared page at pfn %lx\n", ioreq_pfn); + trace_xen_map_ioreq_server_shared_page(ioreq_pfn); state->shared_page = xenforeignmemory_map(xen_fmem, xen_domid, PROT_READ | PROT_WRITE, @@ -693,7 +693,7 @@ static int xen_map_ioreq_server(XenIOState *state) } if (state->buffered_io_page == NULL) { - DPRINTF("buffered io page at pfn %lx\n", bufioreq_pfn); + trace_xen_map_ioreq_server_buffered_io_page(bufioreq_pfn); state->buffered_io_page = xenforeignmemory_map(xen_fmem, xen_domid, PROT_READ | PROT_WRITE, @@ -709,7 +709,7 @@ static int xen_map_ioreq_server(XenIOState *state) return -1; } - DPRINTF("buffered io evtchn is %x\n", bufioreq_evtchn); + trace_xen_map_ioreq_server_buffered_io_evtchn(bufioreq_evtchn); state->bufioreq_remote_port = bufioreq_evtchn; @@ -737,16 +737,17 @@ void destroy_hvm_domain(bool reboot) xc_handle = xc_interface_open(0, 0, 0); if (xc_handle == NULL) { - fprintf(stderr, "Cannot acquire xenctrl handle\n"); + trace_destroy_hvm_domain_cannot_acquire_handle(); } else { sts = xc_domain_shutdown(xc_handle, xen_domid, reason); if (sts != 0) { - fprintf(stderr, "xc_domain_shutdown failed to issue %s, " - "sts %d, %s\n", reboot ? "reboot" : "poweroff", - sts, strerror(errno)); + trace_destroy_hvm_domain_failed_action( + reboot ? "reboot" : "poweroff", sts, strerror(errno) + ); } else { - fprintf(stderr, "Issued domain %d %s\n", xen_domid, - reboot ? "reboot" : "poweroff"); + trace_destroy_hvm_domain_action( + xen_domid, reboot ? "reboot" : "poweroff" + ); } xc_interface_close(xc_handle); } diff --git a/hw/xen/trace-events b/hw/xen/trace-events index a65dc0e55fd..d1b27f6c11b 100644 --- a/hw/xen/trace-events +++ b/hw/xen/trace-events @@ -42,7 +42,7 @@ xs_node_vscanf(char *path, char *value) "%s %s" xs_node_watch(char *path) "%s" xs_node_unwatch(char *path) "%s" -# xen-hvm.c +# xen-hvm-common.c xen_ram_alloc(unsigned long ram_addr, unsigned long size) "requested: 0x%lx, size 0x%lx" xen_client_set_memory(uint64_t start_addr, unsigned long size, bool log_dirty) "0x%"PRIx64" size 0x%lx, log_dirty %i" handle_ioreq(void *req, uint32_t type, uint32_t dir, uint32_t df, uint32_t data_is_ptr, uint64_t addr, uint64_t data, uint32_t count, uint32_t size) "I/O=%p type=%d dir=%d df=%d ptr=%d port=0x%"PRIx64" data=0x%"PRIx64" count=%d size=%d" @@ -55,6 +55,14 @@ cpu_ioreq_move(void *req, uint32_t dir, uint32_t df, uint32_t data_is_ptr, uint6 xen_map_resource_ioreq(uint32_t id, void *addr) "id: %u addr: %p" cpu_ioreq_config_read(void *req, uint32_t sbdf, uint32_t reg, uint32_t size, uint32_t data) "I/O=%p sbdf=0x%x reg=%u size=%u data=0x%x" cpu_ioreq_config_write(void *req, uint32_t sbdf, uint32_t reg, uint32_t size, uint32_t data) "I/O=%p sbdf=0x%x reg=%u size=%u data=0x%x" +cpu_get_ioreq_from_shared_memory_req_not_ready(int state, int data_is_ptr, uint64_t addr, uint64_t data, uint32_t count, uint32_t size) "I/O request not ready: 0x%x, ptr: 0x%x, port: 0x%"PRIx64", data: 0x%"PRIx64", count: %u, size: %u" +xen_main_loop_prepare_init_cpu(int id, void *cpu) "cpu_by_vcpu_id[%d]=%p" +xen_map_ioreq_server_shared_page(long unsigned int ioreq_pfn) "shared page at pfn 0x%lx" +xen_map_ioreq_server_buffered_io_page(long unsigned int ioreq_pfn) "buffered io page at pfn 0x%lx" +xen_map_ioreq_server_buffered_io_evtchn(int bufioreq_evtchn) "buffered io evtchn is 0x%x" +destroy_hvm_domain_cannot_acquire_handle(void) "Cannot acquire xenctrl handle" +destroy_hvm_domain_failed_action(const char *action, int sts, char *errno_s) "xc_domain_shutdown failed to issue %s, sts %d, %s" +destroy_hvm_domain_action(int xen_domid, const char *action) "Issued domain %d %s" # xen-mapcache.c xen_map_cache(uint64_t phys_addr) "want 0x%"PRIx64