| 1 |
// Copyright (c) Meta Platforms, Inc. and affiliates. |
| 2 |
// SPDX-License-Identifier: LGPL-2.1-or-later |
| 3 |
|
| 4 |
/** |
| 5 |
* @file |
| 6 |
* |
| 7 |
* QEMU Machine Protocol (QMP) support. |
| 8 |
*/ |
| 9 |
|
| 10 |
#ifndef DRGN_QEMU_MACHINE_PROTOCOL_H |
| 11 |
#define DRGN_QEMU_MACHINE_PROTOCOL_H |
| 12 |
|
| 13 |
#include "string_builder.h" |
| 14 |
|
| 15 |
struct drgn_error; |
| 16 |
struct drgn_program; |
| 17 |
|
| 18 |
#ifdef WITH_JSON_C |
| 19 |
struct drgn_qmp_conn { |
| 20 |
int fd; |
| 21 |
struct string_builder read_buf; |
| 22 |
struct string_builder write_buf; |
| 23 |
struct json_tokener *json_tok; |
| 24 |
}; |
| 25 |
|
| 26 |
static inline void drgn_qmp_conn_init(struct drgn_qmp_conn *conn) |
| 27 |
{ |
| 28 |
conn->fd = -1; |
| 29 |
conn->read_buf = (struct string_builder)STRING_BUILDER_INIT; |
| 30 |
conn->write_buf = (struct string_builder)STRING_BUILDER_INIT; |
| 31 |
conn->json_tok = NULL; |
| 32 |
} |
| 33 |
|
| 34 |
void drgn_qmp_conn_deinit(struct drgn_qmp_conn *conn); |
| 35 |
#else |
| 36 |
struct drgn_qmp_conn {}; |
| 37 |
|
| 38 |
static inline void drgn_qmp_conn_init(struct drgn_qmp_conn *conn) {} |
| 39 |
static inline void drgn_qmp_conn_deinit(struct drgn_qmp_conn *conn) {} |
| 40 |
#endif |
| 41 |
|
| 42 |
#endif /* DRGN_QEMU_MACHINE_PROTOCOL_H */ |