From nobody Tue Nov 26 08:21:59 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=virtuozzo.com ARC-Seal: i=1; a=rsa-sha256; t=1709314203; cv=none; d=zohomail.com; s=zohoarc; b=EUPyXuYp4EDMe/hvz0r42LW8wWigDeL+O7i7ieK4UfgLeja8VRR+gIGFiJFOEI1EK3jBeuY5AhBYHJEDm6pG9/HtWDfBaLgeGLp3akefVfzm4n62Tzq5aRI7QXOZdpA+kp99KdyKfbfdlOFTTSaFwlMLJ3AL8OO4m7Z58Env0k0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709314203; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=FgvpgkvZbPaUxVLeqEy30dvsqfYQF42BbnXb+x7RtN4=; b=ZJ3MPJSzO3mgsroYsJzX8faAN4XhKdWQlDqolhkDNysnrGYnS/03qrS58HEch1f1ITUVsFHbP2HfRBUjOMu6cPXaUOdX24koRfnSwNzFu3kndb5qM/HI1FxJcTtbj78PEM4btC3koo1n2QXwDMi87F42B2RYWlHsKpuPRCpAAvE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1709314203232380.01562229574006; Fri, 1 Mar 2024 09:30:03 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rg6h5-0003p7-U9; Fri, 01 Mar 2024 12:29:11 -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 1rg6h1-0003mV-Qm for qemu-devel@nongnu.org; Fri, 01 Mar 2024 12:29:07 -0500 Received: from relay.virtuozzo.com ([130.117.225.111]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rg6gx-0005d4-Vb for qemu-devel@nongnu.org; Fri, 01 Mar 2024 12:29:07 -0500 Received: from [130.117.225.1] (helo=dev005.ch-qa.vzint.dev) by relay.virtuozzo.com with esmtp (Exim 4.96) (envelope-from ) id 1rg6fM-0022sZ-0x; Fri, 01 Mar 2024 18:28:57 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=virtuozzo.com; s=relay; h=MIME-Version:Message-Id:Date:Subject:From: Content-Type; bh=FgvpgkvZbPaUxVLeqEy30dvsqfYQF42BbnXb+x7RtN4=; b=FUUJSPzQE4x5 8cezk+wrQHFHabBhiDJ6709BS4y8cu+IXIIWylwvc/xF8rI+rsKDAvlQQHNV1LO4/jH4pa1R0uM/m U46RlZqiNXVkuQOqofcK8VqcpWQJHFkH6y9PIZXheFp+uTd2iKRxr0ITPuDhCmXT+59EdIn0wnL+7 vSMLOu/5IU3nuXzJU9gDB9nTn8ApKFYCt9h5kM234V4Sqwh9mpJ3e6zgTH9kt/qNkfJMpBlu4HF7I pbyQX98P1SqX5ke4R+RJS6VzpsqhQyuIAGo13fbwXIIux+HDa2LZrmWsNiEf66xj3uoIWBwFPq0wA bwAdccmZgNTksZvqmJ/oLw==; From: Andrey Drobyshev To: qemu-devel@nongnu.org Cc: michael.roth@amd.com, kkostiuk@redhat.com, marcandre.lureau@redhat.com, philmd@linaro.org, andrey.drobyshev@virtuozzo.com, den@virtuozzo.com Subject: [PATCH v2 3/7] qga/commands-posix: qmp_guest_shutdown: use ga_run_command helper Date: Fri, 1 Mar 2024 19:28:54 +0200 Message-Id: <20240301172858.665135-4-andrey.drobyshev@virtuozzo.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240301172858.665135-1-andrey.drobyshev@virtuozzo.com> References: <20240301172858.665135-1-andrey.drobyshev@virtuozzo.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=130.117.225.111; envelope-from=andrey.drobyshev@virtuozzo.com; helo=relay.virtuozzo.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @virtuozzo.com) X-ZM-MESSAGEID: 1709314204729100003 Content-Type: text/plain; charset="utf-8" Also remove the G_GNUC_UNUSED attribute added in the previous commit from the helper. Signed-off-by: Andrey Drobyshev --- qga/commands-posix.c | 39 ++++++--------------------------------- 1 file changed, 6 insertions(+), 33 deletions(-) diff --git a/qga/commands-posix.c b/qga/commands-posix.c index 781498418f..003054891f 100644 --- a/qga/commands-posix.c +++ b/qga/commands-posix.c @@ -103,7 +103,6 @@ static void ga_pipe_read_str(int fd[2], char **str, siz= e_t *len) * sending string to stdin and taking error message from * stdout/err. */ -G_GNUC_UNUSED static int ga_run_command(const char *argv[], const char *in_str, const char *action, Error **errp) { @@ -220,8 +219,6 @@ void qmp_guest_shutdown(const char *mode, Error **errp) { const char *shutdown_flag; Error *local_err =3D NULL; - pid_t pid; - int status; =20 #ifdef CONFIG_SOLARIS const char *powerdown_flag =3D "-i5"; @@ -250,46 +247,22 @@ void qmp_guest_shutdown(const char *mode, Error **err= p) return; } =20 - pid =3D fork(); - if (pid =3D=3D 0) { - /* child, start the shutdown */ - setsid(); - reopen_fd_to_null(0); - reopen_fd_to_null(1); - reopen_fd_to_null(2); - + const char *argv[] =3D {"/sbin/shutdown", #ifdef CONFIG_SOLARIS - execl("/sbin/shutdown", "shutdown", shutdown_flag, "-g0", "-y", - "hypervisor initiated shutdown", (char *)NULL); + shutdown_flag, "-g0", "-y", #elif defined(CONFIG_BSD) - execl("/sbin/shutdown", "shutdown", shutdown_flag, "+0", - "hypervisor initiated shutdown", (char *)NULL); + shutdown_flag, "+0", #else - execl("/sbin/shutdown", "shutdown", "-h", shutdown_flag, "+0", - "hypervisor initiated shutdown", (char *)NULL); + "-h", shutdown_flag, "+0", #endif - _exit(EXIT_FAILURE); - } else if (pid < 0) { - error_setg_errno(errp, errno, "failed to create child process"); - return; - } + "hypervisor initiated shutdown", (char *) NULL}; =20 - ga_wait_child(pid, &status, &local_err); + ga_run_command(argv, NULL, "shutdown", &local_err); if (local_err) { error_propagate(errp, local_err); return; } =20 - if (!WIFEXITED(status)) { - error_setg(errp, "child process has terminated abnormally"); - return; - } - - if (WEXITSTATUS(status)) { - error_setg(errp, "child process has failed to shutdown"); - return; - } - /* succeeded */ } =20 --=20 2.39.3