From nobody Mon Feb 9 13:22:32 2026 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1585663759; cv=none; d=zohomail.com; s=zohoarc; b=Puk3pJ2sNrYPQYvTXBhdjYHE+Um89uWK6dSdgo6NUp7sVnZOwUxrY+3yI1j2lo3+3RSuHInsS1/pTHZj1gKsUKGGg2k6/7jRJO5Yft6M8R5Jt4jK8ZJGIdpIPrDVMyrwJGLrtHhLpkx3uxLkW7IPDuFkM56tWJ2JSN/f9vpWQv4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1585663759; h=Content-Type:Content-Transfer-Encoding:Cc: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=zkNtSCtIYbWxg0wZGTTo9fxfXzvj4QaHwWA1k8gShSk=; b=OjQfhXUefig5uSJGYRgd8w0vZWh/0+iRm4oZydEScKULP1HIpVHwDZy+uNCT0bf48Ej6Acw5w/XPxF5Y9yUdhkISetAZ59sx+nxWFoPfbUF3lCLEi2r1ekkAg2rt3ajr46HivDQ020MVZD6sCfAgkwN3flufrykzme+ERF710wE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1585663759158802.9986133141805; Tue, 31 Mar 2020 07:09:19 -0700 (PDT) Received: from localhost ([::1]:38640 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jJHZt-0006GS-UI for importer@patchew.org; Tue, 31 Mar 2020 10:09:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47899) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jJHXd-0002N5-U6 for qemu-devel@nongnu.org; Tue, 31 Mar 2020 10:06:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jJHXc-0007hR-P4 for qemu-devel@nongnu.org; Tue, 31 Mar 2020 10:06:57 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:24099 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jJHXc-0007h5-LD for qemu-devel@nongnu.org; Tue, 31 Mar 2020 10:06:56 -0400 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-439-geFL6d9LMbCL2LEf6lwwxw-1; Tue, 31 Mar 2020 10:06:54 -0400 Received: by mail-wm1-f70.google.com with SMTP id w9so741520wmi.2 for ; Tue, 31 Mar 2020 07:06:54 -0700 (PDT) Received: from localhost.localdomain (116.red-83-42-57.dynamicip.rima-tde.net. [83.42.57.116]) by smtp.gmail.com with ESMTPSA id f25sm4037019wml.11.2020.03.31.07.06.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Mar 2020 07:06:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1585663616; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zkNtSCtIYbWxg0wZGTTo9fxfXzvj4QaHwWA1k8gShSk=; b=Xdrhr3GKGQZnCKh3zTcc9Lry10E88sCtW3cOJUVql37/iF1JIGFFTVC2d2tZ2MBfw9iIt0 wcMNaiZXMWDynOqz0bl92JRTzCqXlt407ezD7QlP1Tz2A6395bGl71P5VaG99vIptnc1En uE+sbq946wwX9InQXeK6nvs3+pvtz4w= X-MC-Unique: geFL6d9LMbCL2LEf6lwwxw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=KJ4Xx0iYJ5ZjT+1t9JtBr+h6MON+xROPqbtySIMxmOo=; b=fD6l6AZpf+9Bw1PvBCfQNkdiq9rZX4jQWgAyA1dV2PZKzBrx5CJdbbMhx0Lpk/gSFr v5PAhkhQfNgBi6H6bkuUVOtJJH/I09cAzVT2TsoWKSK3ahk2Fq/EkkupuZsm5igaPp2d wbnq+9WOIZI+G1D3I+ft5fIfqRhfFyl6dkh6VacCsPkgcgxJv3fX70U2jqnSbaXuM+CK Ti/qTt5h/arMFo5JsLSOOhGeilY+QuHSru5FrRsPUtPOEAbJulJo3Md37V5DZ6Jhc6vf SQIEMALt4XJbh1VMqvmU7kXc7i1yd0eTi/yEWv1CLLndqlk04fmrdIqLEJj1OKzkyxu1 IYMQ== X-Gm-Message-State: ANhLgQ2wtJRcJ1edGhRp6U9BeBBIDRLTOOlJHTe2bB9Gnw0AS8tZwVzm vJfbGcOymLlpu64O1znuP7A+zA3jIm4kB8/Cb6gBeqn8AAX/cw4DueTwemqAC/S33MkgCLyJ/gt vj9DttCd0GF5TDGo= X-Received: by 2002:a1c:3281:: with SMTP id y123mr3532552wmy.140.1585663613094; Tue, 31 Mar 2020 07:06:53 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvGPEGcY23cYxAh+NtbwxCtHyglDNiRuqbwSnDN7q0NZj8RIfNTqguEjMRR6Tr322n1siC98A== X-Received: by 2002:a1c:3281:: with SMTP id y123mr3532533wmy.140.1585663612822; Tue, 31 Mar 2020 07:06:52 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH-for-5.0 v2 2/4] qga: Extract guest_file_handle_find() to commands-common.h Date: Tue, 31 Mar 2020 16:06:36 +0200 Message-Id: <20200331140638.16464-3-philmd@redhat.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200331140638.16464-1-philmd@redhat.com> References: <20200331140638.16464-1-philmd@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Markus Armbruster , Michael Roth , Fakhri Zulkifli , "Dr . David Alan Gilbert" , Sameeh Jubran , Basil Salman , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Dietmar Maurer Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8"; text/plain; charset="utf-8" As we are going to reuse this method, declare it in common header. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- qga/commands-common.h | 18 ++++++++++++++++++ qga/commands-posix.c | 7 ++++--- qga/commands-win32.c | 7 ++++--- 3 files changed, 26 insertions(+), 6 deletions(-) create mode 100644 qga/commands-common.h diff --git a/qga/commands-common.h b/qga/commands-common.h new file mode 100644 index 0000000000..af90e5481e --- /dev/null +++ b/qga/commands-common.h @@ -0,0 +1,18 @@ +/* + * QEMU Guest Agent common/cross-platform common commands + * + * Copyright (c) 2020 Red Hat, Inc. + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ +#ifndef QGA_COMMANDS_COMMON_H +#define QGA_COMMANDS_COMMON_H + +#include "qga-qapi-types.h" + +typedef struct GuestFileHandle GuestFileHandle; + +GuestFileHandle *guest_file_handle_find(int64_t id, Error **errp); + +#endif diff --git a/qga/commands-posix.c b/qga/commands-posix.c index 93474ff770..2199b3b6d9 100644 --- a/qga/commands-posix.c +++ b/qga/commands-posix.c @@ -26,6 +26,7 @@ #include "qemu/sockets.h" #include "qemu/base64.h" #include "qemu/cutils.h" +#include "commands-common.h" =20 #ifdef HAVE_UTMPX #include @@ -237,12 +238,12 @@ typedef enum { RW_STATE_WRITING, } RwState; =20 -typedef struct GuestFileHandle { +struct GuestFileHandle { uint64_t id; FILE *fh; RwState state; QTAILQ_ENTRY(GuestFileHandle) next; -} GuestFileHandle; +}; =20 static struct { QTAILQ_HEAD(, GuestFileHandle) filehandles; @@ -268,7 +269,7 @@ static int64_t guest_file_handle_add(FILE *fh, Error **= errp) return handle; } =20 -static GuestFileHandle *guest_file_handle_find(int64_t id, Error **errp) +GuestFileHandle *guest_file_handle_find(int64_t id, Error **errp) { GuestFileHandle *gfh; =20 diff --git a/qga/commands-win32.c b/qga/commands-win32.c index 46cea7d1d9..cfaf6b84b8 100644 --- a/qga/commands-win32.c +++ b/qga/commands-win32.c @@ -37,6 +37,7 @@ #include "qemu/queue.h" #include "qemu/host-utils.h" #include "qemu/base64.h" +#include "commands-common.h" =20 #ifndef SHTDN_REASON_FLAG_PLANNED #define SHTDN_REASON_FLAG_PLANNED 0x80000000 @@ -50,11 +51,11 @@ =20 #define INVALID_SET_FILE_POINTER ((DWORD)-1) =20 -typedef struct GuestFileHandle { +struct GuestFileHandle { int64_t id; HANDLE fh; QTAILQ_ENTRY(GuestFileHandle) next; -} GuestFileHandle; +}; =20 static struct { QTAILQ_HEAD(, GuestFileHandle) filehandles; @@ -126,7 +127,7 @@ static int64_t guest_file_handle_add(HANDLE fh, Error *= *errp) return handle; } =20 -static GuestFileHandle *guest_file_handle_find(int64_t id, Error **errp) +GuestFileHandle *guest_file_handle_find(int64_t id, Error **errp) { GuestFileHandle *gfh; QTAILQ_FOREACH(gfh, &guest_file_state.filehandles, next) { --=20 2.21.1