Skip to content

Commit 5d3586b

Browse files
philmdmdroth
authored andcommitted
qga: Extract guest_file_handle_find() to commands-common.h
As we are going to reuse this method, declare it in common header. Signed-off-by: Philippe Mathieu-Daudé <[email protected]> Signed-off-by: Michael Roth <[email protected]>
1 parent f62ebb6 commit 5d3586b

File tree

3 files changed

+26
-6
lines changed

3 files changed

+26
-6
lines changed

qga/commands-common.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*
2+
* QEMU Guest Agent common/cross-platform common commands
3+
*
4+
* Copyright (c) 2020 Red Hat, Inc.
5+
*
6+
* This work is licensed under the terms of the GNU GPL, version 2 or later.
7+
* See the COPYING file in the top-level directory.
8+
*/
9+
#ifndef QGA_COMMANDS_COMMON_H
10+
#define QGA_COMMANDS_COMMON_H
11+
12+
#include "qga-qapi-types.h"
13+
14+
typedef struct GuestFileHandle GuestFileHandle;
15+
16+
GuestFileHandle *guest_file_handle_find(int64_t id, Error **errp);
17+
18+
#endif

qga/commands-posix.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "qemu/sockets.h"
2727
#include "qemu/base64.h"
2828
#include "qemu/cutils.h"
29+
#include "commands-common.h"
2930

3031
#ifdef HAVE_UTMPX
3132
#include <utmpx.h>
@@ -237,12 +238,12 @@ typedef enum {
237238
RW_STATE_WRITING,
238239
} RwState;
239240

240-
typedef struct GuestFileHandle {
241+
struct GuestFileHandle {
241242
uint64_t id;
242243
FILE *fh;
243244
RwState state;
244245
QTAILQ_ENTRY(GuestFileHandle) next;
245-
} GuestFileHandle;
246+
};
246247

247248
static struct {
248249
QTAILQ_HEAD(, GuestFileHandle) filehandles;
@@ -268,7 +269,7 @@ static int64_t guest_file_handle_add(FILE *fh, Error **errp)
268269
return handle;
269270
}
270271

271-
static GuestFileHandle *guest_file_handle_find(int64_t id, Error **errp)
272+
GuestFileHandle *guest_file_handle_find(int64_t id, Error **errp)
272273
{
273274
GuestFileHandle *gfh;
274275

qga/commands-win32.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include "qemu/queue.h"
3838
#include "qemu/host-utils.h"
3939
#include "qemu/base64.h"
40+
#include "commands-common.h"
4041

4142
#ifndef SHTDN_REASON_FLAG_PLANNED
4243
#define SHTDN_REASON_FLAG_PLANNED 0x80000000
@@ -50,11 +51,11 @@
5051

5152
#define INVALID_SET_FILE_POINTER ((DWORD)-1)
5253

53-
typedef struct GuestFileHandle {
54+
struct GuestFileHandle {
5455
int64_t id;
5556
HANDLE fh;
5657
QTAILQ_ENTRY(GuestFileHandle) next;
57-
} GuestFileHandle;
58+
};
5859

5960
static struct {
6061
QTAILQ_HEAD(, GuestFileHandle) filehandles;
@@ -126,7 +127,7 @@ static int64_t guest_file_handle_add(HANDLE fh, Error **errp)
126127
return handle;
127128
}
128129

129-
static GuestFileHandle *guest_file_handle_find(int64_t id, Error **errp)
130+
GuestFileHandle *guest_file_handle_find(int64_t id, Error **errp)
130131
{
131132
GuestFileHandle *gfh;
132133
QTAILQ_FOREACH(gfh, &guest_file_state.filehandles, next) {

0 commit comments

Comments
 (0)