From patchwork Wed Oct 4 17:31:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 729317 Delivered-To: patch@linaro.org Received: by 2002:a5d:4a4e:0:b0:31d:da82:a3b4 with SMTP id v14csp480834wrs; Wed, 4 Oct 2023 10:40:16 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFJMw6AfYot9d4yA9LTTIduCOnfKtRnI2cRrP20UkXfL0+rGBecSZkf37UGrqnmp/Smw8Ih X-Received: by 2002:a05:622a:1183:b0:418:a0f:90ef with SMTP id m3-20020a05622a118300b004180a0f90efmr3517995qtk.20.1696441216605; Wed, 04 Oct 2023 10:40:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696441216; cv=none; d=google.com; s=arc-20160816; b=Iubbf2AFtgHKw9WOFp/s8uWB+BW/PajIX6pVuaOm/i8Eq0aGLykmotxAV9iZ4QhGCI adTiZu8TdZWQncJoq623J1QhNKwiDY1A0QZNU0T1cVfIXR60iIzLfEBbh6MllikRJELE B80AfF+RBcxzxexUkoqZYhjJbiJY80W/hNZRtcI7j7ek2G8jk4n5B0JWEY05zJEBNgs8 PIj3vKyTlqkx/hIXm2rSL1rwoMKql9qBPqWKoOuvkR5VBPtQAB75WhVKlDUcqKPJkjUo m5NBF2nMl7WiE98qR2IOMZ7rwjwLWWsHsnJ1iqDxnxdPvsw5h4QlbSrBHbnRze9IWxkm YI9A== 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:cc:to :from:dkim-signature; bh=JgzZrOytqrUApWTqn24h2uNs6StZKBnGHRMADJvQBG0=; fh=8qiUTrAt8Z6J+jITn8q3RC5xQQwhIhm+3Dgt8vaKbR0=; b=D5ZFJAjtg7I+9RrbilcaMWjSq5ZpwWB96TcUvikXpoQGhmASRcSnsNX4Ku1JEPuZq5 VsKBbS2UtI3/JjXcht6BQvtAOVg/EhkFPKKmeakX0jtn5CQTOUQP4d4GNc52BYoYmFQD JXDPOKWFGZ/O2bdPHO9AIJkf4bASKRBy+8kYAqXGJzv8ysqL/vwPOcKekdHoLEZPbpry BAXsIQiHDAu0mzEvn+k8MenPlVmxQAEAcUM8jeYzeFMQumnvm+W6PD1pS9lYrkhndL9K /CdxVNv6vA6Ke2XDIl0hdhWkVwOJcBXzioRvA2ABC/ZigDL1fWgVsCoJ32ctS1wZBz3J v/NA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ESdxJKxt; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id z3-20020a05622a028300b0041812c64671si1717674qtw.487.2023.10.04.10.40.16 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 04 Oct 2023 10:40:16 -0700 (PDT) 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=ESdxJKxt; 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 1qo5mY-0006vv-Kd; Wed, 04 Oct 2023 13:35:36 -0400 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 1qo5lN-0005lK-Hb for qemu-devel@nongnu.org; Wed, 04 Oct 2023 13:34:24 -0400 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qo5lH-0001M9-KV for qemu-devel@nongnu.org; Wed, 04 Oct 2023 13:34:20 -0400 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-405417465aaso493345e9.1 for ; Wed, 04 Oct 2023 10:34:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1696440851; x=1697045651; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=JgzZrOytqrUApWTqn24h2uNs6StZKBnGHRMADJvQBG0=; b=ESdxJKxt0pIV9/8opF4/xCqE11XKvMbvHy9zLbfzYLJgakO+TFl68jjWNZc22r/bUe tIT9E2sJ3ujnZYE0FVx5O4tI1J33Z8EYK+agGatUlmOZIplHsURV4mc6pu3qg4iVxin/ SGdNIHOEdoySQADNEUtJVEEbAwRPWEnxPZisgEAXIcYl/GoKF/BZcXmIr0fY/dV5a6AL CstWAFa5QXAutDbvnh/NvL1jiXaNEA4LgQY6wMmYWU9bjyIEDe1REx4VVJ5BMzqDUEGJ Ko7YKvV6649bzuphft2UUKVCGszBL4Z1cUgOqysqc2FRRverNFXkBATtFazQu86VB+x2 Nnjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696440851; x=1697045651; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JgzZrOytqrUApWTqn24h2uNs6StZKBnGHRMADJvQBG0=; b=kd2MhOSaf88lw8bXZWNJgLOub3hsXyUBbYzk2F5g0MFWy4m/oTuI7xBF/XZstykKxl p1Al0qckWoleoDN62HY2pmiu+UteEzsbc17TBHSe35qqQd4FzBj6rhPY5ig6PgPTdFYH cJIzSUF9Tetn+s39ywQz7rw57VhixkfbTBjqAG1D+FTzTBBKsMXTke4GUwq9wMsQcTqP wB/VLQBaUpXe0mXvvikGdo39toyQqKUfYyYl5/aiAqlJXn6HeeJhD/q25r5xPP9nvDQH UDxS2Vxt7f1V7KuXGGjZlBmx6NXhknFPVeD/+AO2WtAjLZJgUDyE4wqzpCfqVeQlaBMh VDlQ== X-Gm-Message-State: AOJu0YyEVjjkhG4sIsNpH/61/+QIqelkAH4tF6sl9tiPV80NJFwWj89C Jj2GmOwzC+b1uhPrJMcpgHHdw4xACPbaIxhaizQ= X-Received: by 2002:a7b:cc8e:0:b0:401:38dc:8916 with SMTP id p14-20020a7bcc8e000000b0040138dc8916mr2831246wma.10.1696440850986; Wed, 04 Oct 2023 10:34:10 -0700 (PDT) Received: from m1x-phil.lan (5ep85-h01-176-173-163-52.dslam.bbox.fr. [176.173.163.52]) by smtp.gmail.com with ESMTPSA id v7-20020a5d4a47000000b00321773bb933sm4520859wrs.77.2023.10.04.10.34.09 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 04 Oct 2023 10:34:10 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Markus Armbruster Cc: qemu-block@nongnu.org, qemu-arm@nongnu.org, qemu-ppc@nongnu.org, qemu-s390x@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Konstantin Kostiuk , Michael Roth Subject: [PATCH 19/21] qapi: Inline and remove QERR_QGA_COMMAND_FAILED definition Date: Wed, 4 Oct 2023 19:31:54 +0200 Message-ID: <20231004173158.42591-20-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231004173158.42591-1-philmd@linaro.org> References: <20231004173158.42591-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::331; envelope-from=philmd@linaro.org; helo=mail-wm1-x331.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 autolearn=unavailable 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 Address the comment added in commit 4629ed1e98 ("qerror: Finally unused, clean up"), from 2015: /* * These macros will go away, please don't use * in new code, and do not add new ones! */ Mechanical transformation using the following coccinelle semantic patch: @match exists@ expression errp; expression errmsg; @@ error_setg(errp, QERR_QGA_COMMAND_FAILED, errmsg); @script:python strformat depends on match@ errmsg << match.errmsg; fixedfmt; // new var @@ # Format skipping '"'. fixedfmt = f'"Guest agent command failed, error was \'{errmsg[1:-1]}\'"' coccinelle.fixedfmt = cocci.make_ident(fixedfmt) @replace@ expression match.errp; expression match.errmsg; identifier strformat.fixedfmt; @@ - error_setg(errp, QERR_QGA_COMMAND_FAILED, errmsg); + error_setg(errp, fixedfmt); then manually removing the definition in include/qapi/qmp/qerror.h. Signed-off-by: Philippe Mathieu-Daudé --- include/qapi/qmp/qerror.h | 3 --- qga/commands-win32.c | 38 ++++++++++++++++++++------------------ qga/commands.c | 7 ++++--- 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/include/qapi/qmp/qerror.h b/include/qapi/qmp/qerror.h index e094f13114..840831cc6a 100644 --- a/include/qapi/qmp/qerror.h +++ b/include/qapi/qmp/qerror.h @@ -17,9 +17,6 @@ * add new ones! */ -#define QERR_QGA_COMMAND_FAILED \ - "Guest agent command failed, error was '%s'" - #define QERR_UNSUPPORTED \ "this feature or command is not currently supported" diff --git a/qga/commands-win32.c b/qga/commands-win32.c index 946dbafbb6..aa8c9770d4 100644 --- a/qga/commands-win32.c +++ b/qga/commands-win32.c @@ -245,7 +245,8 @@ int64_t qmp_guest_file_open(const char *path, const char *mode, Error **errp) done: if (gerr) { - error_setg(errp, QERR_QGA_COMMAND_FAILED, gerr->message); + error_setg(errp, + "Guest agent command failed, error was 'err -> messag'"); g_error_free(gerr); } g_free(w_path); @@ -279,8 +280,8 @@ static void acquire_privilege(const char *name, Error **errp) TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &token)) { if (!LookupPrivilegeValue(NULL, name, &priv.Privileges[0].Luid)) { - error_setg(errp, QERR_QGA_COMMAND_FAILED, - "no luid for requested privilege"); + error_setg(errp, + "Guest agent command failed, error was 'no luid for requested privilege'"); goto out; } @@ -288,14 +289,14 @@ static void acquire_privilege(const char *name, Error **errp) priv.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; if (!AdjustTokenPrivileges(token, FALSE, &priv, 0, NULL, 0)) { - error_setg(errp, QERR_QGA_COMMAND_FAILED, - "unable to acquire requested privilege"); + error_setg(errp, + "Guest agent command failed, error was 'unable to acquire requested privilege'"); goto out; } } else { - error_setg(errp, QERR_QGA_COMMAND_FAILED, - "failed to open privilege token"); + error_setg(errp, + "Guest agent command failed, error was 'failed to open privilege token'"); } out: @@ -309,8 +310,8 @@ static void execute_async(DWORD WINAPI (*func)(LPVOID), LPVOID opaque, { HANDLE thread = CreateThread(NULL, 0, func, opaque, 0, NULL); if (!thread) { - error_setg(errp, QERR_QGA_COMMAND_FAILED, - "failed to dispatch asynchronous command"); + error_setg(errp, + "Guest agent command failed, error was 'failed to dispatch asynchronous command'"); } } @@ -1423,22 +1424,22 @@ static void check_suspend_mode(GuestSuspendMode mode, Error **errp) ZeroMemory(&sys_pwr_caps, sizeof(sys_pwr_caps)); if (!GetPwrCapabilities(&sys_pwr_caps)) { - error_setg(errp, QERR_QGA_COMMAND_FAILED, - "failed to determine guest suspend capabilities"); + error_setg(errp, + "Guest agent command failed, error was 'failed to determine guest suspend capabilities'"); return; } switch (mode) { case GUEST_SUSPEND_MODE_DISK: if (!sys_pwr_caps.SystemS4) { - error_setg(errp, QERR_QGA_COMMAND_FAILED, - "suspend-to-disk not supported by OS"); + error_setg(errp, + "Guest agent command failed, error was 'suspend-to-disk not supported by OS'"); } break; case GUEST_SUSPEND_MODE_RAM: if (!sys_pwr_caps.SystemS3) { - error_setg(errp, QERR_QGA_COMMAND_FAILED, - "suspend-to-ram not supported by OS"); + error_setg(errp, + "Guest agent command failed, error was 'suspend-to-ram not supported by OS'"); } break; default: @@ -1971,7 +1972,8 @@ void qmp_guest_set_user_password(const char *username, done: if (gerr) { - error_setg(errp, QERR_QGA_COMMAND_FAILED, gerr->message); + error_setg(errp, + "Guest agent command failed, error was 'err -> messag'"); g_error_free(gerr); } g_free(user); @@ -2180,8 +2182,8 @@ static void ga_get_win_version(RTL_OSVERSIONINFOEXW *info, Error **errp) HMODULE module = GetModuleHandle("ntdll"); PVOID fun = GetProcAddress(module, "RtlGetVersion"); if (fun == NULL) { - error_setg(errp, QERR_QGA_COMMAND_FAILED, - "Failed to get address of RtlGetVersion"); + error_setg(errp, + "Guest agent command failed, error was 'Failed to get address of RtlGetVersion'"); return; } diff --git a/qga/commands.c b/qga/commands.c index 871210ab0b..936634c50a 100644 --- a/qga/commands.c +++ b/qga/commands.c @@ -475,7 +475,8 @@ GuestExec *qmp_guest_exec(const char *path, guest_exec_task_setup, &has_merge, &pid, input_data ? &in_fd : NULL, has_output ? &out_fd : NULL, has_output ? &err_fd : NULL, &gerr); if (!ret) { - error_setg(errp, QERR_QGA_COMMAND_FAILED, gerr->message); + error_setg(errp, + "Guest agent command failed, error was 'err -> messag'"); g_error_free(gerr); goto done; } @@ -586,8 +587,8 @@ GuestTimezone *qmp_guest_get_timezone(Error **errp) info = g_new0(GuestTimezone, 1); tz = g_time_zone_new_local(); if (tz == NULL) { - error_setg(errp, QERR_QGA_COMMAND_FAILED, - "Couldn't retrieve local timezone"); + error_setg(errp, + "Guest agent command failed, error was 'Couldn't retrieve local timezone'"); goto error; }