blob: faf8ecc84068a908c25d83609909ed93dd56b483 [file] [log] [blame]
Stefan Hajnoczi298800c2010-12-06 16:08:01 +00001/*
2 * QEMU Enhanced Disk Format
3 *
4 * Copyright IBM, Corp. 2010
5 *
6 * Authors:
7 * Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
8 *
9 * This work is licensed under the terms of the GNU LGPL, version 2 or later.
10 * See the COPYING.LIB file in the top-level directory.
11 *
12 */
13
Peter Maydell80c71a22016-01-18 18:01:42 +000014#include "qemu/osdep.h"
Stefan Hajnoczi298800c2010-12-06 16:08:01 +000015#include "qed.h"
16
Markus Armbruster097310b2014-10-07 13:59:15 +020017void *gencb_alloc(size_t len, BlockCompletionFunc *cb, void *opaque)
Stefan Hajnoczi298800c2010-12-06 16:08:01 +000018{
Anthony Liguori7267c092011-08-20 22:09:37 -050019 GenericCB *gencb = g_malloc(len);
Stefan Hajnoczi298800c2010-12-06 16:08:01 +000020 gencb->cb = cb;
21 gencb->opaque = opaque;
22 return gencb;
23}
24
25void gencb_complete(void *opaque, int ret)
26{
27 GenericCB *gencb = opaque;
Markus Armbruster097310b2014-10-07 13:59:15 +020028 BlockCompletionFunc *cb = gencb->cb;
Stefan Hajnoczi298800c2010-12-06 16:08:01 +000029 void *user_opaque = gencb->opaque;
30
Anthony Liguori7267c092011-08-20 22:09:37 -050031 g_free(gencb);
Stefan Hajnoczi298800c2010-12-06 16:08:01 +000032 cb(user_opaque, ret);
33}