From nobody Tue Nov 26 11:24:22 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=1708966675; cv=none; d=zohomail.com; s=zohoarc; b=JpYhlxaLXizNYKXVCPqlRNavY2cBBEO9vEVSGuM4obVcj+PuJ+2lcRU60ZZ4PZGVnb9E0uzqdDQmxuLU2jezERdZjpS1xHACU5kWCFtemgZO5RfIeq9v9OWBTqoxHaoNrcSZNCEcZsGo/5NPEHKXZD1ETuRAA4YWYrnEXUGQIlM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708966675; 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=kp8z+p1ZvDrme73dRSAIidGhStbQaeG0VLfyNPijbvw=; b=aUy26HvffFd/XVaZLu4sn9e9/w/Et1Bp7KBjJyQTIdUzKnIaKChmnEyojMjkQRIbla3wEcaqVZ1A21ZFGcB0bpgav4Zw3W9xahJ6nIAnWijJ45U4ArFkSPXBbYMX364At+m2y0twaUy4ZTlqyMyj0M+aFt4LEyoTO5xBX2Y6M+A= 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 1708966675091916.7017295643918; Mon, 26 Feb 2024 08:57:55 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1reeHm-0005YE-Bc; Mon, 26 Feb 2024 11:57:02 -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 1reeHd-0005W7-96 for qemu-devel@nongnu.org; Mon, 26 Feb 2024 11:56:54 -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 1reeHX-0007aM-41 for qemu-devel@nongnu.org; Mon, 26 Feb 2024 11:56:53 -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 1reeG3-001AD7-0j; Mon, 26 Feb 2024 17:56:34 +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=kp8z+p1ZvDrme73dRSAIidGhStbQaeG0VLfyNPijbvw=; b=pilkOaV72yBY LUM1hdb/9jw54xNLi7M9lMvWtJU+UfnvmJ4lePBUOl8f9kOm+VlgXLhDIpjrtL8XYop0QegLmf+td kaHthwzNsNFKFvxXE3myYHTVziNX869bAbDfLPPKqH2sNikNA0YtDVLSPMfLceqIGtxHlqs3MmAwx dQFpRbj7d31fXVEQh9AHWoNKE99Z0CAoq6OIq1DiFgUnoYcuam+nA86VEDTnOQoqJfoFnDZoW8Cti /XXFW/c5WAYjd92njTlaLKXEVlK4gJe9DSRzmkOC1cz+aeJYeAzmZeazZsicKofI0KF4TMvU7XVAM J3NusOtARA20lk/jlOr+UA==; From: Andrey Drobyshev To: qemu-devel@nongnu.org Cc: michael.roth@amd.com, kkostiuk@redhat.com, marcandre.lureau@redhat.com, andrey.drobyshev@virtuozzo.com, den@virtuozzo.com Subject: [PATCH 5/7] qga/commands-posix: execute_fsfreeze_hook: use ga_run_command helper Date: Mon, 26 Feb 2024 18:56:40 +0200 Message-Id: <20240226165642.807350-6-andrey.drobyshev@virtuozzo.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240226165642.807350-1-andrey.drobyshev@virtuozzo.com> References: <20240226165642.807350-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: 1708966677181100003 Content-Type: text/plain; charset="utf-8" There's no need to check for the existence of the hook executable, as the exec() call will do that for us. Signed-off-by: Andrey Drobyshev --- qga/commands-posix.c | 35 +++-------------------------------- 1 file changed, 3 insertions(+), 32 deletions(-) diff --git a/qga/commands-posix.c b/qga/commands-posix.c index b704006c98..6baaabc29e 100644 --- a/qga/commands-posix.c +++ b/qga/commands-posix.c @@ -726,8 +726,6 @@ static const char *fsfreeze_hook_arg_string[] =3D { =20 static void execute_fsfreeze_hook(FsfreezeHookArg arg, Error **errp) { - int status; - pid_t pid; const char *hook; const char *arg_str =3D fsfreeze_hook_arg_string[arg]; Error *local_err =3D NULL; @@ -736,42 +734,15 @@ static void execute_fsfreeze_hook(FsfreezeHookArg arg= , Error **errp) if (!hook) { return; } - if (access(hook, X_OK) !=3D 0) { - error_setg_errno(errp, errno, "can't access fsfreeze hook '%s'", h= ook); - return; - } =20 - slog("executing fsfreeze hook with arg '%s'", arg_str); - pid =3D fork(); - if (pid =3D=3D 0) { - setsid(); - reopen_fd_to_null(0); - reopen_fd_to_null(1); - reopen_fd_to_null(2); - - execl(hook, hook, arg_str, NULL); - _exit(EXIT_FAILURE); - } else if (pid < 0) { - error_setg_errno(errp, errno, "failed to create child process"); - return; - } + const char *argv[] =3D {hook, arg_str, NULL}; =20 - ga_wait_child(pid, &status, &local_err); + slog("executing fsfreeze hook with arg '%s'", arg_str); + ga_run_command(argv, NULL, "execute fsfreeze hook", &local_err); if (local_err) { error_propagate(errp, local_err); return; } - - if (!WIFEXITED(status)) { - error_setg(errp, "fsfreeze hook has terminated abnormally"); - return; - } - - status =3D WEXITSTATUS(status); - if (status) { - error_setg(errp, "fsfreeze hook has failed with status %d", status= ); - return; - } } =20 /* --=20 2.39.3