[pve-devel] [PATCH v2 qemu 2/6] PVE: Introduce generic CoCtxData struct
Stefan Reiter
s.reiter at proxmox.com
Thu Oct 29 14:10:32 CET 2020
Adapted from ProxmoxBackupWaker for more general use cases as well.
Signed-off-by: Stefan Reiter <s.reiter at proxmox.com>
---
v2: new, makes patch 4 and 5 cleaner
proxmox-backup-client.c | 20 +++++++-------------
proxmox-backup-client.h | 6 ++++++
2 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/proxmox-backup-client.c b/proxmox-backup-client.c
index 0e9c584701..4ce7bc0b5e 100644
--- a/proxmox-backup-client.c
+++ b/proxmox-backup-client.c
@@ -12,12 +12,6 @@ typedef struct BlockOnCoroutineWrapper {
bool finished;
} BlockOnCoroutineWrapper;
-// Waker implementaion to syncronice with proxmox backup rust code
-typedef struct ProxmoxBackupWaker {
- Coroutine *co;
- AioContext *ctx;
-} ProxmoxBackupWaker;
-
static void coroutine_fn block_on_coroutine_wrapper(void *opaque)
{
BlockOnCoroutineWrapper *wrapper = opaque;
@@ -44,7 +38,7 @@ void block_on_coroutine_fn(CoroutineEntry *entry, void *entry_arg)
// This is called from another thread, so we use aio_co_schedule()
static void proxmox_backup_schedule_wake(void *data) {
- ProxmoxBackupWaker *waker = (ProxmoxBackupWaker *)data;
+ CoCtxData *waker = (CoCtxData *)data;
aio_co_schedule(waker->ctx, waker->co);
}
@@ -53,7 +47,7 @@ proxmox_backup_co_connect(ProxmoxBackupHandle *pbs, Error **errp)
{
Coroutine *co = qemu_coroutine_self();
AioContext *ctx = qemu_get_current_aio_context();
- ProxmoxBackupWaker waker = { .co = co, .ctx = ctx };
+ CoCtxData waker = { .co = co, .ctx = ctx };
char *pbs_err = NULL;
int pbs_res = -1;
@@ -76,7 +70,7 @@ proxmox_backup_co_add_config(
{
Coroutine *co = qemu_coroutine_self();
AioContext *ctx = qemu_get_current_aio_context();
- ProxmoxBackupWaker waker = { .co = co, .ctx = ctx };
+ CoCtxData waker = { .co = co, .ctx = ctx };
char *pbs_err = NULL;
int pbs_res = -1;
@@ -100,7 +94,7 @@ proxmox_backup_co_register_image(
{
Coroutine *co = qemu_coroutine_self();
AioContext *ctx = qemu_get_current_aio_context();
- ProxmoxBackupWaker waker = { .co = co, .ctx = ctx };
+ CoCtxData waker = { .co = co, .ctx = ctx };
char *pbs_err = NULL;
int pbs_res = -1;
@@ -121,7 +115,7 @@ proxmox_backup_co_finish(
{
Coroutine *co = qemu_coroutine_self();
AioContext *ctx = qemu_get_current_aio_context();
- ProxmoxBackupWaker waker = { .co = co, .ctx = ctx };
+ CoCtxData waker = { .co = co, .ctx = ctx };
char *pbs_err = NULL;
int pbs_res = -1;
@@ -143,7 +137,7 @@ proxmox_backup_co_close_image(
{
Coroutine *co = qemu_coroutine_self();
AioContext *ctx = qemu_get_current_aio_context();
- ProxmoxBackupWaker waker = { .co = co, .ctx = ctx };
+ CoCtxData waker = { .co = co, .ctx = ctx };
char *pbs_err = NULL;
int pbs_res = -1;
@@ -168,7 +162,7 @@ proxmox_backup_co_write_data(
{
Coroutine *co = qemu_coroutine_self();
AioContext *ctx = qemu_get_current_aio_context();
- ProxmoxBackupWaker waker = { .co = co, .ctx = ctx };
+ CoCtxData waker = { .co = co, .ctx = ctx };
char *pbs_err = NULL;
int pbs_res = -1;
diff --git a/proxmox-backup-client.h b/proxmox-backup-client.h
index a4781c5851..8cbf645b2c 100644
--- a/proxmox-backup-client.h
+++ b/proxmox-backup-client.h
@@ -5,6 +5,12 @@
#include "qemu/coroutine.h"
#include "proxmox-backup-qemu.h"
+typedef struct CoCtxData {
+ Coroutine *co;
+ AioContext *ctx;
+ void *data;
+} CoCtxData;
+
// FIXME: Remove once coroutines are supported for QMP
void block_on_coroutine_fn(CoroutineEntry *entry, void *entry_arg);
--
2.20.1
More information about the pve-devel
mailing list