From nobody Mon May 13 23:31:26 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1683194288; cv=none; d=zohomail.com; s=zohoarc; b=WVOAl/F09b9DyfL/YPcJHhs0aMhqqt++MCAUOOQY1kCoDMLEDP2NoQQMgTuIO2nrCOT3OUlS4NHLaPafMk80PHUeBfVM9A998pmHnziKHc5vqK9jrp1ahEyf8+zV+EO4ZI4CY7m1gA9YziefBuUCIf174qg5+uhXyOv+5gIJLd8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683194288; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=MHwEATHGRcZaIors0VxWFOpTto4ArNZd/WM5jdb98Co=; b=kjJGndt8W6jP315Jk1VFBJYvrga3nsTe8O1BKBW8OHtKO0lq+oupDsfEsWgnOacq85FzskFEuQGSx6PYGeyNkKr4eY/tt5bqrt7+YgoES2BUt9mmx0SvVatIBl5NAuIRqZqM82g4lqWaHY9DjG0/8MJGPrmabcwCt/mPhMBjQLc= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1683194288908988.0262329559574; Thu, 4 May 2023 02:58:08 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1puVi0-0002HO-Nd; Thu, 04 May 2023 05:57:08 -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 1puVhy-0002Gm-7q for qemu-devel@nongnu.org; Thu, 04 May 2023 05:57:06 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1puVhw-00070d-CM for qemu-devel@nongnu.org; Thu, 04 May 2023 05:57:05 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-325-GFyYCm9GM4S-oeYi-KyeBA-1; Thu, 04 May 2023 05:57:01 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 744C1886063; Thu, 4 May 2023 09:57:01 +0000 (UTC) Received: from kostyanf14nb.redhat.com (unknown [10.45.225.218]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B6FFD492C13; Thu, 4 May 2023 09:57:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683194223; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=MHwEATHGRcZaIors0VxWFOpTto4ArNZd/WM5jdb98Co=; b=FNH2z4NXPwFAWtGaxi1tiN2a1qtDfbYvsQrYtH/6ds5eAvQgNxerX66AkLRrrt70zX9qR/ axcYbjc13Fq4cTYKKgm56tYH4Cj9dHAveJVhHJy5I1zKvbyyhRIEcVxKcCSSQCpj7uVlh3 DlKCg2onlkQds+wsKpF9tFX3cZwSAc8= X-MC-Unique: GFyYCm9GM4S-oeYi-KyeBA-1 From: Konstantin Kostiuk To: qemu-devel@nongnu.org, Peter Maydell Subject: [PULL 1/6] qga/linux: add usb support to guest-get-fsinfo Date: Thu, 4 May 2023 12:56:52 +0300 Message-Id: <20230504095657.239048-2-kkostiuk@redhat.com> In-Reply-To: <20230504095657.239048-1-kkostiuk@redhat.com> References: <20230504095657.239048-1-kkostiuk@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 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=170.10.129.124; envelope-from=kkostiuk@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.161, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, 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 @redhat.com) X-ZM-MESSAGEID: 1683194289696100007 Content-Type: text/plain; charset="utf-8" From: Kfir Manor Signed-off-by: Kfir Manor Reviewed-by: Konstantin Kostiuk Signed-off-by: Konstantin Kostiuk --- qga/commands-posix.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/qga/commands-posix.c b/qga/commands-posix.c index 079689d79a..97754930c1 100644 --- a/qga/commands-posix.c +++ b/qga/commands-posix.c @@ -879,7 +879,9 @@ static bool build_guest_fsinfo_for_pci_dev(char const *= syspath, g_str_equal(driver, "sym53c8xx") || g_str_equal(driver, "virtio-pci") || g_str_equal(driver, "ahci") || - g_str_equal(driver, "nvme"))) { + g_str_equal(driver, "nvme") || + g_str_equal(driver, "xhci_hcd") || + g_str_equal(driver, "ehci-pci"))) { break; } =20 @@ -976,6 +978,8 @@ static bool build_guest_fsinfo_for_pci_dev(char const *= syspath, } } else if (strcmp(driver, "nvme") =3D=3D 0) { disk->bus_type =3D GUEST_DISK_BUS_TYPE_NVME; + } else if (strcmp(driver, "ehci-pci") =3D=3D 0 || strcmp(driver, "xhci= _hcd") =3D=3D 0) { + disk->bus_type =3D GUEST_DISK_BUS_TYPE_USB; } else { g_debug("unknown driver '%s' (sysfs path '%s')", driver, syspath); goto cleanup; --=20 2.25.1 From nobody Mon May 13 23:31:26 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1683194262; cv=none; d=zohomail.com; s=zohoarc; b=X3jQQD/qPK33plPpRQdSOKI8o6VxwdVhLOnenG3EKpBPouCCsm7tC7Yo3HK/rt0fUXJil8cl+o6Ukd/abIJxbhWvTnBnhFEElVQPcvdH+gSSf3PkWZOY+SnMRrDZ3JMWBkkpN6lHssn+I0mf3X4ajC9r5Oxo9BgtCQWJXGe+v+I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683194262; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=hfXKFgitjjZI2xNN7tEyXGacbeusHdyA+/CrrkS5Os0=; b=KTSDm5m9vHMxoo2CfbXO8LVVSfJe0Por/WlXZAF/E+rm/jJ/OSSpXvT019Qm7vk8f6ecYV5NMAjItfoweZJLOzDAcbfggDlwyYi4rK1BB0rXJiCL2ihf7HStYdLdbO3TMCPGT12KtzYBA3vJfJtSHvvuqDU4xTzOFL0uFWAG/V0= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1683194262409540.3537788276149; Thu, 4 May 2023 02:57:42 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1puVi3-0002IX-FR; Thu, 04 May 2023 05:57:11 -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 1puVi0-0002HZ-JF for qemu-devel@nongnu.org; Thu, 04 May 2023 05:57:08 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1puVhz-000719-0u for qemu-devel@nongnu.org; Thu, 04 May 2023 05:57:08 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-365-F7wAkQj2NP6MLa8WOy-7IQ-1; Thu, 04 May 2023 05:57:03 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id ABE2B88B7A1; Thu, 4 May 2023 09:57:02 +0000 (UTC) Received: from kostyanf14nb.redhat.com (unknown [10.45.225.218]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D472C492C13; Thu, 4 May 2023 09:57:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683194226; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hfXKFgitjjZI2xNN7tEyXGacbeusHdyA+/CrrkS5Os0=; b=DdVcwPLtV4JjxIMgZnCc8zY1HiKlqgxBhrXzy4la+LG49hLOpsx6nV2+oTOw+hd7/paFu9 xbf926qsEDmptplIB4iMaIbClzrq06MfQEAS/dwGLZSXUL58/VMy3xH0sNCHPbAGbBj5QM 1l8yUaDzhzRob7fCZRjnS3uvgUAs3Cc= X-MC-Unique: F7wAkQj2NP6MLa8WOy-7IQ-1 From: Konstantin Kostiuk To: qemu-devel@nongnu.org, Peter Maydell Subject: [PULL 2/6] qga: Refactor guest-exec capture-output to take enum Date: Thu, 4 May 2023 12:56:53 +0300 Message-Id: <20230504095657.239048-3-kkostiuk@redhat.com> In-Reply-To: <20230504095657.239048-1-kkostiuk@redhat.com> References: <20230504095657.239048-1-kkostiuk@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 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=170.10.129.124; envelope-from=kkostiuk@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.161, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, 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 @redhat.com) X-ZM-MESSAGEID: 1683194263852100001 From: Daniel Xu Previously capture-output was an optional boolean flag that either captured all output or captured none. While this is OK in most cases, it lacks flexibility for more advanced capture cases, such as wanting to only capture stdout. This commits refactors guest-exec qapi to take an enum for capture mode instead while preserving backwards compatibility. Suggested-by: Daniel P. Berrang=C3=A9 Reviewed-by: Daniel P. Berrang=C3=A9 Signed-off-by: Daniel Xu Signed-off-by: Konstantin Kostiuk --- qga/commands.c | 37 ++++++++++++++++++++++++++++++++++--- qga/qapi-schema.json | 33 ++++++++++++++++++++++++++++++++- 2 files changed, 66 insertions(+), 4 deletions(-) diff --git a/qga/commands.c b/qga/commands.c index 172826f8f8..01f68b45ab 100644 --- a/qga/commands.c +++ b/qga/commands.c @@ -379,11 +379,23 @@ close: return false; } =20 +static GuestExecCaptureOutputMode ga_parse_capture_output( + GuestExecCaptureOutput *capture_output) +{ + if (!capture_output) + return GUEST_EXEC_CAPTURE_OUTPUT_MODE_NONE; + else if (capture_output->type =3D=3D QTYPE_QBOOL) + return capture_output->u.flag ? GUEST_EXEC_CAPTURE_OUTPUT_MODE_SEP= ARATED + : GUEST_EXEC_CAPTURE_OUTPUT_MODE_NON= E; + else + return capture_output->u.mode; +} + GuestExec *qmp_guest_exec(const char *path, bool has_arg, strList *arg, bool has_env, strList *env, const char *input_data, - bool has_capture_output, bool capture_output, + GuestExecCaptureOutput *capture_output, Error **errp) { GPid pid; @@ -396,7 +408,8 @@ GuestExec *qmp_guest_exec(const char *path, gint in_fd, out_fd, err_fd; GIOChannel *in_ch, *out_ch, *err_ch; GSpawnFlags flags; - bool has_output =3D (has_capture_output && capture_output); + bool has_output =3D false; + GuestExecCaptureOutputMode output_mode; g_autofree uint8_t *input =3D NULL; size_t ninput =3D 0; =20 @@ -415,8 +428,26 @@ GuestExec *qmp_guest_exec(const char *path, =20 flags =3D G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD | G_SPAWN_SEARCH_PATH_FROM_ENVP; - if (!has_output) { + + output_mode =3D ga_parse_capture_output(capture_output); + switch (output_mode) { + case GUEST_EXEC_CAPTURE_OUTPUT_MODE_NONE: flags |=3D G_SPAWN_STDOUT_TO_DEV_NULL | G_SPAWN_STDERR_TO_DEV_NULL; + break; + case GUEST_EXEC_CAPTURE_OUTPUT_MODE_STDOUT: + has_output =3D true; + flags |=3D G_SPAWN_STDERR_TO_DEV_NULL; + break; + case GUEST_EXEC_CAPTURE_OUTPUT_MODE_STDERR: + has_output =3D true; + flags |=3D G_SPAWN_STDOUT_TO_DEV_NULL; + break; + case GUEST_EXEC_CAPTURE_OUTPUT_MODE_SEPARATED: + has_output =3D true; + break; + case GUEST_EXEC_CAPTURE_OUTPUT_MODE__MAX: + /* Silence warning; impossible branch */ + break; } =20 ret =3D g_spawn_async_with_pipes(NULL, argv, envp, flags, diff --git a/qga/qapi-schema.json b/qga/qapi-schema.json index 6a20eeb297..44e44c2a5c 100644 --- a/qga/qapi-schema.json +++ b/qga/qapi-schema.json @@ -1200,6 +1200,37 @@ { 'struct': 'GuestExec', 'data': { 'pid': 'int'} } =20 +## +# @GuestExecCaptureOutputMode: +# +# An enumeration of guest-exec capture modes. +# +# @none: do not capture any output +# @stdout: only capture stdout +# @stderr: only capture stderr +# @separated: capture both stdout and stderr, but separated into +# GuestExecStatus out-data and err-data, respectively +# +# Since: 8.0 +## + { 'enum': 'GuestExecCaptureOutputMode', + 'data': [ 'none', 'stdout', 'stderr', 'separated' ] } + +## +# @GuestExecCaptureOutput: +# +# Controls what guest-exec output gets captures. +# +# @flag: captures both stdout and stderr if true. Equivalent +# to GuestExecCaptureOutputMode::all. (since 2.5) +# @mode: capture mode; preferred interface +# +# Since: 8.0 +## + { 'alternate': 'GuestExecCaptureOutput', + 'data': { 'flag': 'bool', + 'mode': 'GuestExecCaptureOutputMode'} } + ## # @guest-exec: # @@ -1218,7 +1249,7 @@ ## { 'command': 'guest-exec', 'data': { 'path': 'str', '*arg': ['str'], '*env': ['str'], - '*input-data': 'str', '*capture-output': 'bool' }, + '*input-data': 'str', '*capture-output': 'GuestExecCaptureO= utput' }, 'returns': 'GuestExec' } =20 =20 --=20 2.25.1 From nobody Mon May 13 23:31:26 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1683194264; cv=none; d=zohomail.com; s=zohoarc; b=h+vHSDCv7XXNcGBN8zuEQ2cIFT1AYy9uzkFeXo7QybTODX2GBV0iB/c0+9iMTEHO7GTg17jsg/mFoGd1h6qCyHPILyO5IkOcWeopmj+Vj6KhWurLdvT4xQJATtBOhw516KcWPiFQHegTJQy45ozm4b3DqDFKK7YhMgML2aIxKAU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683194264; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=vyuKRxaLkz1B5iAJ1LQlzYpb1bDdlxXzh5htwDQA5YI=; b=gD5WDlywklnYoYymM0K8IdmRn5T8H5clxhrsIwwamviwZ/YSuYguub0AvdT2fszIyNEZKpenp5CF9vpL/GavgxM7JRWNfxHEqdd2qYektteZGvMeEi9G0HHAoaR2YmkPiqdkbLNG6PQy6Zn5kbDc51ht0VC6U3tCByNYG50NQ7I= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1683194264674811.1290275501843; Thu, 4 May 2023 02:57:44 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1puVi1-0002IB-UU; Thu, 04 May 2023 05:57:09 -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 1puVhz-0002H9-OK for qemu-devel@nongnu.org; Thu, 04 May 2023 05:57:07 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1puVhy-00070x-4f for qemu-devel@nongnu.org; Thu, 04 May 2023 05:57:07 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-413-1dmbtRP6NIWOHWL01uxccw-1; Thu, 04 May 2023 05:57:04 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E9F7A2807D64; Thu, 4 May 2023 09:57:03 +0000 (UTC) Received: from kostyanf14nb.redhat.com (unknown [10.45.225.218]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 18E27492C14; Thu, 4 May 2023 09:57:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683194225; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vyuKRxaLkz1B5iAJ1LQlzYpb1bDdlxXzh5htwDQA5YI=; b=CcW+01sWyJE6MhuRYg5FooGpSSgltnu3LMAgH/N1FTzqlT14ElFaAy7zK3/JPH+na/NclZ pqmdM/bsQrTUiKO4wo/sS8i5qvb/tL6L6CRJG6bVQAVVxfdzmX5QKHpSCg65kGpOULAwBK /mxORgaP/RGAb7juLTgzbO6ZAD7/weY= X-MC-Unique: 1dmbtRP6NIWOHWL01uxccw-1 From: Konstantin Kostiuk To: qemu-devel@nongnu.org, Peter Maydell Subject: [PULL 3/6] qga: Add `merged` variant to GuestExecCaptureOutputMode Date: Thu, 4 May 2023 12:56:54 +0300 Message-Id: <20230504095657.239048-4-kkostiuk@redhat.com> In-Reply-To: <20230504095657.239048-1-kkostiuk@redhat.com> References: <20230504095657.239048-1-kkostiuk@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 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=170.10.129.124; envelope-from=kkostiuk@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.161, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, 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 @redhat.com) X-ZM-MESSAGEID: 1683194266842100002 From: Daniel Xu Currently, any captured output (via `capture-output`) is segregated into separate GuestExecStatus fields (`out-data` and `err-data`). This means that downstream consumers have no way to reassemble the captured data back into the original stream. This is relevant for chatty and semi-interactive (ie. read only) CLI tools. Such tools may deliberately interleave stdout and stderr for visual effect. If segregated, the output becomes harder to visually understand. This commit adds a new enum variant to the GuestExecCaptureOutputMode qapi to merge the output streams such that consumers can have a pristine view of the original command output. Signed-off-by: Daniel Xu Reviewed-by: Daniel P. Berrang=C3=A9 Signed-off-by: Konstantin Kostiuk --- qga/commands.c | 25 +++++++++++++++++++++++-- qga/qapi-schema.json | 5 ++++- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/qga/commands.c b/qga/commands.c index 01f68b45ab..09c683e263 100644 --- a/qga/commands.c +++ b/qga/commands.c @@ -270,12 +270,26 @@ static void guest_exec_child_watch(GPid pid, gint sta= tus, gpointer data) g_spawn_close_pid(pid); } =20 -/** Reset ignored signals back to default. */ static void guest_exec_task_setup(gpointer data) { #if !defined(G_OS_WIN32) + bool has_merge =3D *(bool *)data; struct sigaction sigact; =20 + if (has_merge) { + /* + * FIXME: When `GLIB_VERSION_MIN_REQUIRED` is bumped to 2.58+, use + * g_spawn_async_with_fds() to be portable on windows. The current + * logic does not work on windows b/c `GSpawnChildSetupFunc` is run + * inside the parent, not the child. + */ + if (dup2(STDOUT_FILENO, STDERR_FILENO) !=3D 0) { + slog("dup2() failed to merge stderr into stdout: %s", + strerror(errno)); + } + } + + /* Reset ignored signals back to default. */ memset(&sigact, 0, sizeof(struct sigaction)); sigact.sa_handler =3D SIG_DFL; =20 @@ -409,6 +423,7 @@ GuestExec *qmp_guest_exec(const char *path, GIOChannel *in_ch, *out_ch, *err_ch; GSpawnFlags flags; bool has_output =3D false; + bool has_merge =3D false; GuestExecCaptureOutputMode output_mode; g_autofree uint8_t *input =3D NULL; size_t ninput =3D 0; @@ -445,13 +460,19 @@ GuestExec *qmp_guest_exec(const char *path, case GUEST_EXEC_CAPTURE_OUTPUT_MODE_SEPARATED: has_output =3D true; break; +#if !defined(G_OS_WIN32) + case GUEST_EXEC_CAPTURE_OUTPUT_MODE_MERGED: + has_output =3D true; + has_merge =3D true; + break; +#endif case GUEST_EXEC_CAPTURE_OUTPUT_MODE__MAX: /* Silence warning; impossible branch */ break; } =20 ret =3D g_spawn_async_with_pipes(NULL, argv, envp, flags, - guest_exec_task_setup, NULL, &pid, input_data ? &in_fd : NULL, + guest_exec_task_setup, &has_merge, &pid, input_data ? &in_fd := NULL, has_output ? &out_fd : NULL, has_output ? &err_fd : NULL, &ger= r); if (!ret) { error_setg(errp, QERR_QGA_COMMAND_FAILED, gerr->message); diff --git a/qga/qapi-schema.json b/qga/qapi-schema.json index 44e44c2a5c..5a75e81be2 100644 --- a/qga/qapi-schema.json +++ b/qga/qapi-schema.json @@ -1210,11 +1210,14 @@ # @stderr: only capture stderr # @separated: capture both stdout and stderr, but separated into # GuestExecStatus out-data and err-data, respectively +# @merged: capture both stdout and stderr, but merge together +# into out-data. not effective on windows guests. # # Since: 8.0 ## { 'enum': 'GuestExecCaptureOutputMode', - 'data': [ 'none', 'stdout', 'stderr', 'separated' ] } + 'data': [ 'none', 'stdout', 'stderr', 'separated', + { 'name': 'merged', 'if': { 'not': 'CONFIG_WIN32' } } ] } =20 ## # @GuestExecCaptureOutput: --=20 2.25.1 From nobody Mon May 13 23:31:26 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1683194298; cv=none; d=zohomail.com; s=zohoarc; b=neYW6kocHFN01vcxDv+OQbs74XX1ClZ5eYY1pXL/ylXyv/5BWgBSjGn5wXSZ3p338sSF0CQxYnZ8iQtrFQwnjhtJdYFh/DCz0hVo1H19ySyh1W3/IsFWZqfxq6IMwiY6+Y+NXvqrAQVzErqddNP002nluJXcbqm9jTrM94zJv9s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683194298; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=U7hiO6XwdD0JqgeO6wIJ1gbxYZ12dZI8DL7+6aUnnhI=; b=jaNhrRUA8lsO8DxOlMxmt25pzgVCAcwug8T8kiAcBD4QlFimodMb7lR1bcL0TvqXGUkrjWDKyiEoBUUAmQCVyR+NPlLYxeT5RifoYAB4T6SvSJnIwTGIv8pHOKQGl9/xA3uVbe7PgY1IA9PkjHeH2QwA3QTolLhbEELlI7E7o8s= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1683194298144579.5686963927138; Thu, 4 May 2023 02:58:18 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1puVi4-0002Iu-2G; Thu, 04 May 2023 05:57:12 -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 1puVi2-0002IP-SW for qemu-devel@nongnu.org; Thu, 04 May 2023 05:57:10 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1puVi1-00071X-3H for qemu-devel@nongnu.org; Thu, 04 May 2023 05:57:10 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-570-hr9iV1H5NLe9VYVNXT1tTg-1; Thu, 04 May 2023 05:57:07 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E6A921C060CF; Thu, 4 May 2023 09:57:06 +0000 (UTC) Received: from kostyanf14nb.redhat.com (unknown [10.45.225.218]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 82271492C13; Thu, 4 May 2023 09:57:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683194228; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=U7hiO6XwdD0JqgeO6wIJ1gbxYZ12dZI8DL7+6aUnnhI=; b=hEz0PtO1VLO8qTKihxbRPOtQmkINT4NcOBBKIm5KeQzbu164sQqvvxDfu3N6fCVEFRJfYH 4CM2s/IRafjDrHERYFJhHplcUsrKpWgeCVlqZbS+FNVtiFyTapuxICvdDSy5XtFMh27ORC HozQoXNbgekjStmGCpPWTyhootDImZg= X-MC-Unique: hr9iV1H5NLe9VYVNXT1tTg-1 From: Konstantin Kostiuk To: qemu-devel@nongnu.org, Peter Maydell Subject: [PULL 4/6] qga: test: Add tests for `merged` flag Date: Thu, 4 May 2023 12:56:55 +0300 Message-Id: <20230504095657.239048-5-kkostiuk@redhat.com> In-Reply-To: <20230504095657.239048-1-kkostiuk@redhat.com> References: <20230504095657.239048-1-kkostiuk@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 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=170.10.133.124; envelope-from=kkostiuk@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.161, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, 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 @redhat.com) X-ZM-MESSAGEID: 1683194298396100001 From: Daniel Xu This commit adds a test to ensure `merged` functions as expected. We also add a negative test to ensure we haven't regressed previous functionality. Reviewed-by: Daniel P. Berrang=C3=A9 Signed-off-by: Daniel Xu Signed-off-by: Konstantin Kostiuk --- tests/unit/test-qga.c | 158 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 141 insertions(+), 17 deletions(-) diff --git a/tests/unit/test-qga.c b/tests/unit/test-qga.c index b4e0a14573..360b4cab23 100644 --- a/tests/unit/test-qga.c +++ b/tests/unit/test-qga.c @@ -755,6 +755,31 @@ static void test_qga_fsfreeze_status(gconstpointer fix) g_assert_cmpstr(status, =3D=3D, "thawed"); } =20 +static QDict *wait_for_guest_exec_completion(int fd, int64_t pid) +{ + QDict *ret =3D NULL; + int64_t now; + bool exited; + QDict *val; + + now =3D g_get_monotonic_time(); + do { + ret =3D qmp_fd(fd, + "{'execute': 'guest-exec-status'," + " 'arguments': { 'pid': %" PRId64 " } }", pid); + g_assert_nonnull(ret); + val =3D qdict_get_qdict(ret, "return"); + exited =3D qdict_get_bool(val, "exited"); + if (!exited) { + qobject_unref(ret); + } + } while (!exited && + g_get_monotonic_time() < now + 5 * G_TIME_SPAN_SECOND); + g_assert(exited); + + return ret; +} + static void test_qga_guest_exec(gconstpointer fix) { const TestFixture *fixture =3D fix; @@ -762,9 +787,8 @@ static void test_qga_guest_exec(gconstpointer fix) QDict *val; const gchar *out; g_autofree guchar *decoded =3D NULL; - int64_t pid, now, exitcode; + int64_t pid, exitcode; gsize len; - bool exited; =20 /* exec 'echo foo bar' */ ret =3D qmp_fd(fixture->fd, "{'execute': 'guest-exec', 'arguments': {" @@ -777,23 +801,10 @@ static void test_qga_guest_exec(gconstpointer fix) g_assert_cmpint(pid, >, 0); qobject_unref(ret); =20 - /* wait for completion */ - now =3D g_get_monotonic_time(); - do { - ret =3D qmp_fd(fixture->fd, - "{'execute': 'guest-exec-status'," - " 'arguments': { 'pid': %" PRId64 " } }", pid); - g_assert_nonnull(ret); - val =3D qdict_get_qdict(ret, "return"); - exited =3D qdict_get_bool(val, "exited"); - if (!exited) { - qobject_unref(ret); - } - } while (!exited && - g_get_monotonic_time() < now + 5 * G_TIME_SPAN_SECOND); - g_assert(exited); + ret =3D wait_for_guest_exec_completion(fixture->fd, pid); =20 /* check stdout */ + val =3D qdict_get_qdict(ret, "return"); exitcode =3D qdict_get_int(val, "exitcode"); g_assert_cmpint(exitcode, =3D=3D, 0); out =3D qdict_get_str(val, "out-data"); @@ -802,6 +813,115 @@ static void test_qga_guest_exec(gconstpointer fix) g_assert_cmpstr((char *)decoded, =3D=3D, "\" test_str \""); } =20 +#if defined(G_OS_WIN32) +static void test_qga_guest_exec_separated(gconstpointer fix) +{ +} +static void test_qga_guest_exec_merged(gconstpointer fix) +{ + const TestFixture *fixture =3D fix; + g_autoptr(QDict) ret =3D NULL; + QDict *val; + const gchar *class, *desc; + g_autofree guchar *decoded =3D NULL; + + /* exec 'echo foo bar' */ + ret =3D qmp_fd(fixture->fd, "{'execute': 'guest-exec', 'arguments': {" + " 'path': 'echo'," + " 'arg': [ 'execution never reaches here' ]," + " 'capture-output': 'merged' } }"); + + g_assert_nonnull(ret); + val =3D qdict_get_qdict(ret, "error"); + g_assert_nonnull(val); + class =3D qdict_get_str(val, "class"); + desc =3D qdict_get_str(val, "desc"); + g_assert_cmpstr(class, =3D=3D, "GenericError"); + g_assert_cmpint(strlen(desc), >, 0); +} +#else +static void test_qga_guest_exec_separated(gconstpointer fix) +{ + const TestFixture *fixture =3D fix; + g_autoptr(QDict) ret =3D NULL; + QDict *val; + const gchar *out, *err; + g_autofree guchar *out_decoded =3D NULL; + g_autofree guchar *err_decoded =3D NULL; + int64_t pid, exitcode; + gsize len; + + /* exec 'echo foo bar' */ + ret =3D qmp_fd(fixture->fd, "{'execute': 'guest-exec', 'arguments': {" + " 'path': '/bin/bash'," + " 'arg': [ '-c', 'for i in $(seq 4); do if (( $i %% 2 ));= then echo stdout; else echo stderr 1>&2; fi; done;' ]," + " 'capture-output': 'separated' } }"); + g_assert_nonnull(ret); + qmp_assert_no_error(ret); + val =3D qdict_get_qdict(ret, "return"); + pid =3D qdict_get_int(val, "pid"); + g_assert_cmpint(pid, >, 0); + qobject_unref(ret); + + ret =3D wait_for_guest_exec_completion(fixture->fd, pid); + + val =3D qdict_get_qdict(ret, "return"); + exitcode =3D qdict_get_int(val, "exitcode"); + g_assert_cmpint(exitcode, =3D=3D, 0); + + /* check stdout */ + out =3D qdict_get_str(val, "out-data"); + out_decoded =3D g_base64_decode(out, &len); + g_assert_cmpint(len, =3D=3D, 14); + g_assert_cmpstr((char *)out_decoded, =3D=3D, "stdout\nstdout\n"); + + /* check stderr */ + err =3D qdict_get_try_str(val, "err-data"); + err_decoded =3D g_base64_decode(err, &len); + g_assert_cmpint(len, =3D=3D, 14); + g_assert_cmpstr((char *)err_decoded, =3D=3D, "stderr\nstderr\n"); +} + +static void test_qga_guest_exec_merged(gconstpointer fix) +{ + const TestFixture *fixture =3D fix; + g_autoptr(QDict) ret =3D NULL; + QDict *val; + const gchar *out, *err; + g_autofree guchar *decoded =3D NULL; + int64_t pid, exitcode; + gsize len; + + /* exec 'echo foo bar' */ + ret =3D qmp_fd(fixture->fd, "{'execute': 'guest-exec', 'arguments': {" + " 'path': '/bin/bash'," + " 'arg': [ '-c', 'for i in $(seq 4); do if (( $i %% 2 ));= then echo stdout; else echo stderr 1>&2; fi; done;' ]," + " 'capture-output': 'merged' } }"); + g_assert_nonnull(ret); + qmp_assert_no_error(ret); + val =3D qdict_get_qdict(ret, "return"); + pid =3D qdict_get_int(val, "pid"); + g_assert_cmpint(pid, >, 0); + qobject_unref(ret); + + ret =3D wait_for_guest_exec_completion(fixture->fd, pid); + + val =3D qdict_get_qdict(ret, "return"); + exitcode =3D qdict_get_int(val, "exitcode"); + g_assert_cmpint(exitcode, =3D=3D, 0); + + /* check stdout */ + out =3D qdict_get_str(val, "out-data"); + decoded =3D g_base64_decode(out, &len); + g_assert_cmpint(len, =3D=3D, 28); + g_assert_cmpstr((char *)decoded, =3D=3D, "stdout\nstderr\nstdout\nstde= rr\n"); + + /* check stderr */ + err =3D qdict_get_try_str(val, "err-data"); + g_assert_null(err); +} +#endif + static void test_qga_guest_exec_invalid(gconstpointer fix) { const TestFixture *fixture =3D fix; @@ -972,6 +1092,10 @@ int main(int argc, char **argv) g_test_add_data_func("/qga/blockedrpcs", NULL, test_qga_blockedrpcs); g_test_add_data_func("/qga/config", NULL, test_qga_config); g_test_add_data_func("/qga/guest-exec", &fix, test_qga_guest_exec); + g_test_add_data_func("/qga/guest-exec-separated", &fix, + test_qga_guest_exec_separated); + g_test_add_data_func("/qga/guest-exec-merged", &fix, + test_qga_guest_exec_merged); g_test_add_data_func("/qga/guest-exec-invalid", &fix, test_qga_guest_exec_invalid); g_test_add_data_func("/qga/guest-get-osinfo", &fix, --=20 2.25.1 From nobody Mon May 13 23:31:26 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1683194291; cv=none; d=zohomail.com; s=zohoarc; b=CXVIjOKcp26+ygyjzVHySMysVeQdHAQEUGlW0rU2PxBDUe6/CcQSCDasO1Ylm9vmjSwKBHh+QVw92CrILnYqlRMTJKf8TjwoLgEeJqgonSdJqoL3I/NZIll8j/SkXIpSk3JfKFeHcy6abobTb2HxwzwPgpHvAc3jVoI1RuxQnfM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683194291; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=h80tO33HC7sjInE8GOS+QicJSI6yD7AQUYhSBWamUAI=; b=gD8sYKxMNbO/ywG270Kol8AHo4DXwiraMJquEYN0m6/BgUX4BqGsWLuGepR7tvITwGfMd66TGf7t8pZN+IpWYLdYuLQEbQyvZ87C45+QP/LAyuWS45o8SSGSviqeFf6YZKeFK7OzBgeCYe5SFppz8/+BCBa6gEuBMcKbE34aEt0= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 168319429114987.45425748104742; Thu, 4 May 2023 02:58:11 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1puVi5-0002JS-Nl; Thu, 04 May 2023 05:57:13 -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 1puVi4-0002Iw-5x for qemu-devel@nongnu.org; Thu, 04 May 2023 05:57:12 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1puVi2-00071d-LS for qemu-devel@nongnu.org; Thu, 04 May 2023 05:57:11 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-392-m1UeufUkM7Wp7utTbi6bNQ-1; Thu, 04 May 2023 05:57:08 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 20426886063; Thu, 4 May 2023 09:57:08 +0000 (UTC) Received: from kostyanf14nb.redhat.com (unknown [10.45.225.218]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 48E10492C13; Thu, 4 May 2023 09:57:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683194229; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=h80tO33HC7sjInE8GOS+QicJSI6yD7AQUYhSBWamUAI=; b=Nys3S8qPKXGOSmkRni30CK0VOPLBq7cjNNpj63vW0V630vzGy7N93Eqc5yEV0RYX1konRW PLAZ6UhrlBDNQH6Z8FLFNRgFQTNvsN/OAREsjvi9ujS+U//yD3iyR3bjrr40orc3+ETgNi eziYgXVEt3vn0D+c8+/11b3gNS6IvyA= X-MC-Unique: m1UeufUkM7Wp7utTbi6bNQ-1 From: Konstantin Kostiuk To: qemu-devel@nongnu.org, Peter Maydell Subject: [PULL 5/6] qga/commands-win32.c: Drop the check for _WIN32_WINNT >= 0x0601 Date: Thu, 4 May 2023 12:56:56 +0300 Message-Id: <20230504095657.239048-6-kkostiuk@redhat.com> In-Reply-To: <20230504095657.239048-1-kkostiuk@redhat.com> References: <20230504095657.239048-1-kkostiuk@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 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=170.10.133.124; envelope-from=kkostiuk@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.161, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, 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 @redhat.com) X-ZM-MESSAGEID: 1683194291572100009 From: Thomas Huth All current versions of glib require _WIN32_WINNT set to 0x0601 or higher already, and we also use this value as a minimum in our osdep.h header file, so there is no way to still compile this code with an older version of the Windows ABI. Thus we can drop this check now. Signed-off-by: Thomas Huth Reviewed-by: Daniel P. Berrang=C3=A9 Reviewed-by: Konstantin Kostiuk Signed-off-by: Konstantin Kostiuk --- qga/commands-win32.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/qga/commands-win32.c b/qga/commands-win32.c index b5fee6a2cd..d23875264f 100644 --- a/qga/commands-win32.c +++ b/qga/commands-win32.c @@ -484,7 +484,6 @@ static GuestDiskBusType win2qemu[] =3D { [BusTypeSata] =3D GUEST_DISK_BUS_TYPE_SATA, [BusTypeSd] =3D GUEST_DISK_BUS_TYPE_SD, [BusTypeMmc] =3D GUEST_DISK_BUS_TYPE_MMC, -#if (_WIN32_WINNT >=3D 0x0601) [BusTypeVirtual] =3D GUEST_DISK_BUS_TYPE_VIRTUAL, [BusTypeFileBackedVirtual] =3D GUEST_DISK_BUS_TYPE_FILE_BACKED_VIRTUAL, /* @@ -492,7 +491,6 @@ static GuestDiskBusType win2qemu[] =3D { */ [BusTypeSpaces] =3D GUEST_DISK_BUS_TYPE_UNKNOWN, [BusTypeNvme] =3D GUEST_DISK_BUS_TYPE_NVME, -#endif }; =20 static GuestDiskBusType find_bus_type(STORAGE_BUS_TYPE bus) --=20 2.25.1 From nobody Mon May 13 23:31:26 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1683194287; cv=none; d=zohomail.com; s=zohoarc; b=Gh9NgFRqWitzhqZDnE5EVI0VDQUQaav8nzZAOHqwSCznLmubqSTgJpI2WhxRs08pDTeyhawLBF4wX3kE1uGiRTANmmhDpsmr5sOwNxbpLDdgK2VQxZsZeeVutC3OMuoUaZwwUw/YsWwJGqobXxoW9sbtbmeViYsbRKZT+IuC/6A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683194287; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=80AM+5RyIwhaCcbwOaL5+0xN1QqywYmR4e9Rab2Poi4=; b=IoDIDyVadeSZkYHca3sqQn9q1becyuEwIyGZpFnrjNb4HRUFANCU0uat5Fa1fh5If1lh69xW9030E1aigLnuHWdhS0WCoGKfcaLIPraepd812TnaLfyNRtWGiK0Msu/LYCdz5Vw0g3k3Leq7IGlmDvdxGshhhft/jjGt/pkrItw= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1683194287516358.24265961226706; Thu, 4 May 2023 02:58:07 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1puVi6-0002JX-2U; Thu, 04 May 2023 05:57:14 -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 1puVi5-0002JK-Ac for qemu-devel@nongnu.org; Thu, 04 May 2023 05:57:13 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1puVi3-00071x-Us for qemu-devel@nongnu.org; Thu, 04 May 2023 05:57:13 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-440-r_4AvVeJNVWkfvcQFW_kVg-1; Thu, 04 May 2023 05:57:09 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A37B41C060CD; Thu, 4 May 2023 09:57:09 +0000 (UTC) Received: from kostyanf14nb.redhat.com (unknown [10.45.225.218]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 81227492C13; Thu, 4 May 2023 09:57:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683194231; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=80AM+5RyIwhaCcbwOaL5+0xN1QqywYmR4e9Rab2Poi4=; b=GVsIPmWAEe8NOBam4sAvgDMrxmaKZfHihYe3TcJjxlsfU15Md18h+tPQkOs2J5OGT2iC4q 7yiijJnNKkeSS6wM52QYgEDT8djexCY3inWqEuALQTvj1yssLDEP11oFcobs4z556B0fxN SowQpi5+AisiAngqSO1Qv485AKdIlf8= X-MC-Unique: r_4AvVeJNVWkfvcQFW_kVg-1 From: Konstantin Kostiuk To: qemu-devel@nongnu.org, Peter Maydell Subject: [PULL 6/6] qga: Fix suspend on Linux guests without systemd Date: Thu, 4 May 2023 12:56:57 +0300 Message-Id: <20230504095657.239048-7-kkostiuk@redhat.com> In-Reply-To: <20230504095657.239048-1-kkostiuk@redhat.com> References: <20230504095657.239048-1-kkostiuk@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 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=170.10.133.124; envelope-from=kkostiuk@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.161, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, 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 @redhat.com) X-ZM-MESSAGEID: 1683194289611100004 Content-Type: text/plain; charset="utf-8" From: Mark Somerville Allow the Linux guest agent to attempt each of the suspend methods (systemctl, pm-* and writing to /sys) in turn. Prior to this guests without systemd failed to suspend due to `guest_suspend` returning early regardless of the return value of `systemd_supports_mode`. Signed-off-by: Mark Somerville Reviewed-by: Konstantin Kostiuk Signed-off-by: Konstantin Kostiuk --- qga/commands-posix.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/qga/commands-posix.c b/qga/commands-posix.c index 97754930c1..def857d773 100644 --- a/qga/commands-posix.c +++ b/qga/commands-posix.c @@ -1922,10 +1922,10 @@ static void guest_suspend(SuspendMode mode, Error *= *errp) if (systemd_supports_mode(mode, &local_err)) { mode_supported =3D true; systemd_suspend(mode, &local_err); - } =20 - if (!local_err) { - return; + if (!local_err) { + return; + } } =20 error_free(local_err); @@ -1934,10 +1934,10 @@ static void guest_suspend(SuspendMode mode, Error *= *errp) if (pmutils_supports_mode(mode, &local_err)) { mode_supported =3D true; pmutils_suspend(mode, &local_err); - } =20 - if (!local_err) { - return; + if (!local_err) { + return; + } } =20 error_free(local_err); --=20 2.25.1