all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Stefan Reiter <s.reiter@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH v2 qemu 2/6] PVE: Introduce generic CoCtxData struct
Date: Thu, 29 Oct 2020 14:10:32 +0100	[thread overview]
Message-ID: <20201029131036.11786-3-s.reiter@proxmox.com> (raw)
In-Reply-To: <20201029131036.11786-1-s.reiter@proxmox.com>

Adapted from ProxmoxBackupWaker for more general use cases as well.

Signed-off-by: Stefan Reiter <s.reiter@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





  parent reply	other threads:[~2020-10-29 13:11 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-29 13:10 [pve-devel] [PATCH v2 0/6] QEMU backup cancellation fixes Stefan Reiter
2020-10-29 13:10 ` [pve-devel] [PATCH v2 qemu 1/6] PVE: fixup: drop CoMutex on error return Stefan Reiter
2020-10-29 13:10 ` Stefan Reiter [this message]
2020-10-29 13:10 ` [pve-devel] [PATCH v2 qemu 3/6] PVE: Don't expect complete_cb to be called outside coroutine Stefan Reiter
2020-10-29 13:10 ` [pve-devel] [PATCH v2 qemu 4/6] PVE: Don't call job_cancel in coroutines Stefan Reiter
2020-10-29 13:10 ` [pve-devel] [PATCH v2 qemu 5/6] PVE: fix and clean up error handling for create_backup_jobs Stefan Reiter
2020-10-29 13:10 ` [pve-devel] [PATCH v2 qemu 6/6] Several fixes for backup abort and error reporting Stefan Reiter
2020-10-29 17:27   ` [pve-devel] applied: " Thomas Lamprecht

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201029131036.11786-3-s.reiter@proxmox.com \
    --to=s.reiter@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal