qemu with hax to log dma reads & writes jcs.org/2018/11/12/vfio

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é <philmd@redhat.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>

authored by

Philippe Mathieu-Daudé and committed by
Michael Roth
5d3586b8 f62ebb63

+26 -6
+18
qga/commands-common.h
··· 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
+4 -3
qga/commands-posix.c
··· 26 26 #include "qemu/sockets.h" 27 27 #include "qemu/base64.h" 28 28 #include "qemu/cutils.h" 29 + #include "commands-common.h" 29 30 30 31 #ifdef HAVE_UTMPX 31 32 #include <utmpx.h> ··· 237 238 RW_STATE_WRITING, 238 239 } RwState; 239 240 240 - typedef struct GuestFileHandle { 241 + struct GuestFileHandle { 241 242 uint64_t id; 242 243 FILE *fh; 243 244 RwState state; 244 245 QTAILQ_ENTRY(GuestFileHandle) next; 245 - } GuestFileHandle; 246 + }; 246 247 247 248 static struct { 248 249 QTAILQ_HEAD(, GuestFileHandle) filehandles; ··· 268 269 return handle; 269 270 } 270 271 271 - static GuestFileHandle *guest_file_handle_find(int64_t id, Error **errp) 272 + GuestFileHandle *guest_file_handle_find(int64_t id, Error **errp) 272 273 { 273 274 GuestFileHandle *gfh; 274 275
+4 -3
qga/commands-win32.c
··· 37 37 #include "qemu/queue.h" 38 38 #include "qemu/host-utils.h" 39 39 #include "qemu/base64.h" 40 + #include "commands-common.h" 40 41 41 42 #ifndef SHTDN_REASON_FLAG_PLANNED 42 43 #define SHTDN_REASON_FLAG_PLANNED 0x80000000 ··· 50 51 51 52 #define INVALID_SET_FILE_POINTER ((DWORD)-1) 52 53 53 - typedef struct GuestFileHandle { 54 + struct GuestFileHandle { 54 55 int64_t id; 55 56 HANDLE fh; 56 57 QTAILQ_ENTRY(GuestFileHandle) next; 57 - } GuestFileHandle; 58 + }; 58 59 59 60 static struct { 60 61 QTAILQ_HEAD(, GuestFileHandle) filehandles; ··· 126 127 return handle; 127 128 } 128 129 129 - static GuestFileHandle *guest_file_handle_find(int64_t id, Error **errp) 130 + GuestFileHandle *guest_file_handle_find(int64_t id, Error **errp) 130 131 { 131 132 GuestFileHandle *gfh; 132 133 QTAILQ_FOREACH(gfh, &guest_file_state.filehandles, next) {