From patchwork Wed Apr 15 15:22:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 11491485 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C9A5E14B4 for ; Wed, 15 Apr 2020 15:24:58 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9FA132078B for ; Wed, 15 Apr 2020 15:24:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="AX06IJQE" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9FA132078B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:51646 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jOjuL-0007NF-Px for patchwork-qemu-devel@patchwork.kernel.org; Wed, 15 Apr 2020 11:24:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54998) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jOjs1-0002rT-Nu for qemu-devel@nongnu.org; Wed, 15 Apr 2020 11:22:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jOjs0-00027w-Lu for qemu-devel@nongnu.org; Wed, 15 Apr 2020 11:22:33 -0400 Received: from mail-oi1-x241.google.com ([2607:f8b0:4864:20::241]:36463) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jOjs0-00027Y-HT for qemu-devel@nongnu.org; Wed, 15 Apr 2020 11:22:32 -0400 Received: by mail-oi1-x241.google.com with SMTP id s202so10559102oih.3 for ; Wed, 15 Apr 2020 08:22:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=fhbbqO70eYReDnemV03U2WqJFqhr9unuoXv8ipfHzp0=; b=AX06IJQEKORp7aGrXSGKiWy40OXVGXaMk4bJo1xIsP58znfKxFjcqDZl2J8Ihr9U67 ywPEtl4eYDnW7nZl+uepZEIbP5Bm8NymXcSygoTtrx3qXSkvT7annRASvfwIiNWhyT+M Xrjjlg9z0EympAQz5gVAOoCpqekXoGGiVS4K0rwnZ7lcYZxed1lLBZHZRZf+Ag9Idts5 SN8kYE1OUASbJM2Q9CB3lycQLaHK7qS2bN5SbehcmVrtuyow3kH8dW6qQ2Oxwj/plf9H F3jpcUkUPWoiRgY5aRr+upp32lMRGL/dmQY5SXqO6RJkYhuq7IG8m5PVWasgRiYpw10t 83eA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=fhbbqO70eYReDnemV03U2WqJFqhr9unuoXv8ipfHzp0=; b=LahU/32jjJAbcEWtr68t6mCTphh5nh20dC0TTZIVXD88kGec6Tf8hRT6qxrxWlXZvH T+ao2G2/zyMOYaeWulCDb/j1OEJ5lZV1zkEQ9TMcGgGSxzWAW2tNtSBe7GU0xjw7dhbF 5xKSNQ9Ip8wa4P9wgZsu+s16X0EYLWSvqUhTmIxr52uYQFK0DU4aBuJ04OB4thXngslv nRhk8WsHIaz3S2QpsgrZBsBwVOjIaURaSZWBMMlj84D2mZf5UyjKHRcBs/Zy9aMBGDyW BwRi4oqEg65lpj9Fda6wNhNqWU1h6NPAn5o2cpLfEElC8dyCvI/BcpFMnbdinrXXfT0i n0JA== X-Gm-Message-State: AGi0PuYZmvfcMPeSLv5h1MobqvDjQotD0wY3+c7WdwTa2R1QNX9CY7cC adEPdRIHEUoO0zE2NqYRvHNbW7tJVdM= X-Google-Smtp-Source: APiQypLkZtRRQf9o/aISmQ0qf8TD3FnDYVBtyAVxiVTgOdNIpwY5A8C4y8iGbGb2ngMYqiiVVRy17w== X-Received: by 2002:aca:cd0e:: with SMTP id d14mr18041804oig.167.1586964151457; Wed, 15 Apr 2020 08:22:31 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id h14sm2685171oov.11.2020.04.15.08.22.30 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 15 Apr 2020 08:22:31 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Subject: [PULL for-5.0 2/4] qga: Extract guest_file_handle_find() to commands-common.h Date: Wed, 15 Apr 2020 10:22:00 -0500 Message-Id: <20200415152202.14463-3-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200415152202.14463-1-mdroth@linux.vnet.ibm.com> References: <20200415152202.14463-1-mdroth@linux.vnet.ibm.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::241 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: peter.maydell@linaro.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Philippe Mathieu-Daudé As we are going to reuse this method, declare it in common header. Signed-off-by: Philippe Mathieu-Daudé Signed-off-by: Michael Roth --- 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 later. + * 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 cc69b82704..c59c32185c 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" #ifdef HAVE_UTMPX #include @@ -237,12 +238,12 @@ typedef enum { RW_STATE_WRITING, } RwState; -typedef struct GuestFileHandle { +struct GuestFileHandle { uint64_t id; FILE *fh; RwState state; QTAILQ_ENTRY(GuestFileHandle) next; -} GuestFileHandle; +}; static struct { QTAILQ_HEAD(, GuestFileHandle) filehandles; @@ -268,7 +269,7 @@ static int64_t guest_file_handle_add(FILE *fh, Error **errp) return handle; } -static GuestFileHandle *guest_file_handle_find(int64_t id, Error **errp) +GuestFileHandle *guest_file_handle_find(int64_t id, Error **errp) { GuestFileHandle *gfh; 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" #ifndef SHTDN_REASON_FLAG_PLANNED #define SHTDN_REASON_FLAG_PLANNED 0x80000000 @@ -50,11 +51,11 @@ #define INVALID_SET_FILE_POINTER ((DWORD)-1) -typedef struct GuestFileHandle { +struct GuestFileHandle { int64_t id; HANDLE fh; QTAILQ_ENTRY(GuestFileHandle) next; -} GuestFileHandle; +}; static struct { QTAILQ_HEAD(, GuestFileHandle) filehandles; @@ -126,7 +127,7 @@ static int64_t guest_file_handle_add(HANDLE fh, Error **errp) return handle; } -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) {