Skip to contentSkip to conversation

HLFS driver for QEMU

PATCH In review [email protected] 3 participants 9 messages Mar 18, 2013 – Mar 28, 2013 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 HLFS driver for QEMU

From: Harry Wei <[email protected]>

HLFS is HDFS-based(Hadoop Distributed File System) Log-Structured File System. Actually, HLFS, currently, is not a FS but a block-storage system, which we simplify LFS to fit block-level storage. So you could also call HLFS as HLBS (HDFS-based Log-Structured Block-storage System). HLFS has two mode, which are local mode and HDFS mode. HDFS is once write and many read so HLFS realize LBS(Log-Structured Block-storage System) to achieve reading and writing randomly. LBS is based on LFS's basic theories but is different from LFS, which LBS fits block storage better. See
http://code.google.com/p/cloudxy/wiki/WHAT_IS_CLOUDXY
about HLFS in details.

Currently, HLFS support following features:

1, Portions of POSIX --- Just realize some interfaces VM image need. 2, Randomly Read/Write.
3, Large file storage (TB).
4, Support snapshots(Linear snapshots and tree snapshots), Clone, Block compression, Cache, etc.
5, A copy of the data more.
6, Cluster system can dynamic expand.
...

---
 block/Makefile.objs |    2 +-
 block/hlfs.c        |  515 +++++++++++++++++++++++++++++++++++++++++++++++++++
 configure           |   51 +++++
 3 files changed, 567 insertions(+), 1 deletion(-)
 create mode 100644 block/hlfs.c
block/Makefile.objs +1 -1
index c067f38..723c7a5 100644
@@ -8,7 +8,7 @@ block-obj-$(CONFIG_POSIX) += raw-posix.o
 block-obj-$(CONFIG_LINUX_AIO) += linux-aio.o
 
 ifeq ($(CONFIG_POSIX),y)
-block-obj-y += nbd.o sheepdog.o
+block-obj-y += nbd.o sheepdog.o hlfs.o
 block-obj-$(CONFIG_LIBISCSI) += iscsi.o
 block-obj-$(CONFIG_CURL) += curl.o
 block-obj-$(CONFIG_RBD) += rbd.o
block/hlfs.c new file +514 -0

514 lines not on this page · raw message

+ if (log4c_init()) {
+ g_message("log4c_init error!");
+ }
+ bdrv_register(&bdrv_hlbs);
+}
+block_init(bdrv_hlbs_init);

configure +51 -0

87 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#1 lore raw
Quoted 24 lines · On Mon, Mar 18, 2013 at 02:47:44PM +0800, [email protected] wrote:

From: Harry Wei <[email protected]>

HLFS is HDFS-based(Hadoop Distributed File System) Log-Structured File System. Actually, HLFS, currently, is not a FS but a block-storage system, which we simplify LFS to fit block-level storage. So you could also call HLFS as HLBS (HDFS-based Log-Structured Block-storage System). HLFS has two mode, which are local mode and HDFS mode. HDFS is once write and many read so HLFS realize LBS(Log-Structured Block-storage System) to achieve reading and writing randomly. LBS is based on LFS's basic theories but is different from LFS, which LBS fits block storage better. See
http://code.google.com/p/cloudxy/wiki/WHAT_IS_CLOUDXY
about HLFS in details.

Currently, HLFS support following features:

1, Portions of POSIX --- Just realize some interfaces VM image need. 2, Randomly Read/Write.
3, Large file storage (TB).
4, Support snapshots(Linear snapshots and tree snapshots), Clone, Block compression, Cache, etc.
5, A copy of the data more.
6, Cluster system can dynamic expand.
...

Quoted 1 line

Is HLFS making releases that distros can package? I don't see packages in Debian or Fedora.

Block drivers in qemu.git should have active and sustainable communities behind them. For example, if this is a research project where the team will move on within a year, then it may not be appropriate to merge the code into QEMU. Can you share some background on the HLFS community and where the project is heading?

Quoted 12 lines
---
 block/Makefile.objs |    2 +-
 block/hlfs.c        |  515 +++++++++++++++++++++++++++++++++++++++++++++++++++
 configure           |   51 +++++
 3 files changed, 567 insertions(+), 1 deletion(-)
 create mode 100644 block/hlfs.c
block/Makefile.objs +0 -0
index c067f38..723c7a5 100644

block/Makefile.objs block-obj-$(CONFIG_POSIX) += raw-posix.o · line 11

Quoted 5 lines
block/Makefile.objs +1 -1
@@ -8,7 +8,7 @@ block-obj-$(CONFIG_POSIX) += raw-posix.o
 block-obj-$(CONFIG_LINUX_AIO) += linux-aio.o
 
 ifeq ($(CONFIG_POSIX),y)
-block-obj-y += nbd.o sheepdog.o
+block-obj-y += nbd.o sheepdog.o hlfs.o

Missing CONFIG_HLFS to compile out hlfs.o.

Quoted 25 lines
block/Makefile.objs +25 -0
+static int hlbs_write(BlockDriverState *bs, int64_t sector_num, const uint8_t
+        *buf, int nb_sectors)
+{
+    int ret;
+    BDRVHLBSState *s = bs->opaque;
+    uint32_t write_size = nb_sectors * 512;
+    uint64_t offset = sector_num * 512;
+    ret = hlfs_write(s->hctrl, (char *)buf, write_size, offset);
+    if (ret != write_size) {
+        return -EIO;
+    }
+    return 0;
+}
+
+static int hlbs_read(BlockDriverState *bs, int64_t sector_num, uint8_t *buf,
+        int nb_sectors)
+{
+    int ret;
+    BDRVHLBSState *s = bs->opaque;
+    uint32_t read_size = nb_sectors * 512;
+    uint64_t offset = sector_num * 512;
+    ret = hlfs_read(s->hctrl, (char *)buf, read_size, offset);
+    if (ret != read_size) {
+        return -EIO;
+    }

block/Makefile.objs block-obj-$(CONFIG_POSIX) += raw-posix.o

Quoted 10 lines
block/Makefile.objs +10 -0
+    return 0;
+}
+
+static int hlbs_flush(BlockDriverState *bs)
+{
+    int ret;
+    BDRVHLBSState *s = bs->opaque;
+    ret = hlfs_flush(s->hctrl);
+    return ret;
+}

read/write/flush should be either .bdrv_co_* or .bdrv_aio_*.

The current code pauses the guest while I/O is in progress! Try running disk I/O benchmarks inside the guest and you'll see that performance and interactivity are poor.

QEMU has two ways of implementing efficient block drivers:

1. Coroutines - .bdrv_co_*

Good for image formats or block drivers that have internal logic.

Each request runs inside a coroutine - see include/block/coroutine.h. In order to wait for I/O, submit an asynchronous request or worker thread and yield the coroutine. When the request completes, re-enter the coroutine and continue.

Examples: block/sheepdog.c or block/qcow2.c.

2. Asynchronous I/O - .bdrv_aio_*

Good for low-level block drivers that have little logic.

The request processing code is split into callbacks. I/O requests are submitted and then the code returns back to QEMU's main loop. When the I/O request completes, a callback is invoked.

Examples: block/rbd.c or block/qed.c.

block/Makefile.objs

Quoted 3 lines
block/Makefile.objs +3 -0
+static int hlbs_snapshot_delete(BlockDriverState *bs, const char *snapshot)
+{
+    /* FIXME: Delete specified snapshot id.  */

Outdated comment?

block/Makefile.objs

Quoted 10 lines
block/Makefile.objs +10 -0
+    BDRVHLBSState *s = bs->opaque;
+    int ret = 0;
+    ret = hlfs_rm_snapshot(s->hctrl->storage->uri, snapshot);
+    return ret;
+}
+
+static int hlbs_snapshot_list(BlockDriverState *bs, QEMUSnapshotInfo **psn_tab)
+{
+    BDRVHLBSState *s = bs->opaque;
+    /*Fixed: num_entries must be inited 0*/

Comment can be dropped?

block/Makefile.objs

Quoted 2 lines
block/Makefile.objs +2 -0
+    int num_entries = 0;
+    struct snapshot *snapshots = hlfs_get_all_snapshots(s->hctrl->storage->uri,

I suggest using "hlfs_" as a prefix for libhlfs structs. Otherwise you risk name collisions.

block/Makefile.objs

Quoted 3 lines
block/Makefile.objs +3 -0
+        &num_entries);
+    dprintf("snapshot count:%d\n", num_entries);
+    /*Fixed: snapshots is NULL condition*/

Comment can be dropped?

block/Makefile.objs

Quoted 10 lines
block/Makefile.objs +10 -0
+    if (NULL == snapshots) {
+        dprintf("snapshots is NULL, may be no snapshots, check it please!\n");
+        return num_entries;
+    }
+    QEMUSnapshotInfo *sn_tab = NULL;
+    struct snapshot *snapshot = snapshots;
+    sn_tab = g_malloc0(num_entries * sizeof(*sn_tab));
+    int i;
+    for (i = 0; i < num_entries; i++) {
+        printf("---snapshot:%s----", snapshot->sname);

Debugging code?

block/Makefile.objs

Quoted 7 lines
block/Makefile.objs +7 -0
+        sn_tab[i].date_sec = snapshot->timestamp * 1000;
+        sn_tab[i].date_nsec = 0;
+        sn_tab[i].vm_state_size = 0;
+        sn_tab[i].vm_clock_nsec = 0;
+        snprintf(sn_tab[i].id_str, sizeof(sn_tab[i].id_str), "%u", 0);
+        strncpy(sn_tab[i].name, snapshot->sname, MIN(sizeof(sn_tab[i].name),
+                    strlen(snapshot->sname)));

Please use snprintf() instead. strncpy() does not NUL-terminate when strlen(input) >= bufsize.

block/Makefile.objs

Quoted 6 lines
block/Makefile.objs +6 -0
+        snapshot++;
+    }
+    *psn_tab = sn_tab;
+    if (snapshots != NULL) {
+        g_free(snapshots);
+    }

g_free(NULL) is a nop, the if is not needed.

Quoted 19 lines
block/Makefile.objs +19 -0
+    return num_entries;
+}
+
+static QEMUOptionParameter hlbs_create_options[] = {
+    {
+        .name = BLOCK_OPT_SIZE,
+        .type = OPT_SIZE,
+        .help = "Virtual disk size"
+    }, {
+        .name = BLOCK_OPT_BACKING_FILE,
+        .type = OPT_STRING,
+        .help = "File name of a base image"
+    }, {
+        .name = BLOCK_OPT_PREALLOC,
+        .type = OPT_STRING,
+        .help = "Preallocation mode (allowed values: off, full)"
+    }, { NULL }
+};
+

block/Makefile.objs

Quoted 10 lines
block/Makefile.objs +10 -0
+static BlockDriver bdrv_hlbs = {
+    .format_name    = "hlfs",
+    .protocol_name  = "hlfs",
+    .instance_size  = sizeof(BDRVHLBSState),
+    .bdrv_file_open = hlbs_open,
+    .bdrv_close     = hlbs_close,
+    .bdrv_create    = hlbs_create,
+    .bdrv_getlength = hlbs_getlength,
+    .bdrv_read  = hlbs_read,
+    .bdrv_write = hlbs_write,

.bdrv_flush is missing.

block/Makefile.objs

Quoted 13 lines
block/Makefile.objs +13 -0
+    .bdrv_get_allocated_file_size  = hlbs_get_allocated_file_size,
+    .bdrv_snapshot_create   = hlbs_snapshot_create,
+    .bdrv_snapshot_goto     = hlbs_snapshot_goto,
+    .bdrv_snapshot_delete   = hlbs_snapshot_delete,
+    .bdrv_snapshot_list     = hlbs_snapshot_list,
+    .create_options = hlbs_create_options,
+};
+
+static void bdrv_hlbs_init(void)
+{
+    if (log4c_init()) {
+        g_message("log4c_init error!");
+    }

This seems to be for libhlfs since the QEMU code doesn't use log4c. If it's safe to call this function more than once, please put it into libhlfs instead of requiring the program that links to your library to call it for you.

Quoted 4 lines
block/Makefile.objs +0 -0
@@ -2813,6 +2820,45 @@ if compile_prog "" "" ; then
 fi
 
 ##########################################

block/Makefile.objs if compile_prog "" "" ; then · line 2832

Quoted 10 lines
block/Makefile.objs +10 -0
+# hlfs probe
+if test "$hlfs" != "no" ; then
+    cat > $TMPC <<EOF
+#include <stdio.h>
+#include <api/hlfs.h>
+    int main(void) {
+            return 0;
+    }
+EOF
+    INC_GLIB_DIR=`pkg-config --cflags glib-2.0`

QEMU uses gthread-2.0 instead of the single-threaded glib-2.0.

You can reuse glib_cflags instead of probing again here.

block/Makefile.objs if compile_prog "" "" ; then · line 2841

Quoted 9 lines
block/Makefile.objs +9 -0
+    HLFS_DIR=`echo $HLFS_INSTALL_PATH`
+    JVM_DIR=`echo $JAVA_HOME`
+
+    if [ `getconf LONG_BIT` -eq "64" ];then
+    CLIBS="-L$JVM_DIR/jre/lib/amd64/server/ $CLIBS"
+    fi
+    if [ `getconf LONG_BIT` -eq "32" ];then
+    CLIBS="-L$JVM_DIR/jre/lib/i386/server/ $CLIBS"
+    fi

Hopefully there is a cleaner and portable way to do this (e.g. pkg-config).

block/Makefile.objs if compile_prog "" "" ; then · line 2846

Quoted 5 lines
block/Makefile.objs +5 -0
+    CLIBS="-L$HLFS_DIR/lib/ $CLIBS"
+    CFLAGS="-I$HLFS_DIR/include $CFLAGS"
+    CFLAGS="$INC_GLIB_DIR $CFLAGS"
+
+    hlfs_libs="$CLIBS -lhlfs -llog4c -lglib-2.0 -lgthread-2.0 -lrt -lhdfs -ljvm"

libhlfs should support pkg-config so that QEMU does not need to know about -llog4c -lhdfs -ljvm.

block/Makefile.objs if compile_prog "" "" ; then · line 2848

Quoted 2 lines
block/Makefile.objs +2 -0
+    echo "999 CLIBS is $CLIBS\n"
+    echo "999 CFLAGS is $CFLAGS\n"

Debugging?

author
#2 lore raw

On Mon, Mar 18, 2013 at 7:10 PM, Stefan Hajnoczi <[email protected]> wrote:
Hi Stefan,

Quoted 2 lines

Is HLFS making releases that distros can package? I don't see packages in Debian or Fedora.

We will make packages for Debian and Fedora.

Quoted 3 lines

Block drivers in qemu.git should have active and sustainable communities behind them.

Cloudxy is an active and sustainable community, which HLFS is just a sub-project of it.

Quoted 3 lines

For example, if this is a research project where the team
will move on within a year, then it may not be appropriate to merge the code into QEMU.

HLFS have been developed for two years.

Quoted 2 lines

Can you share some background on the HLFS community and where the project is heading?

See http://code.google.com/p/cloudxy/ (Our Main Website) for details (in Chinese).
See http://code.google.com/p/cloudxy/wiki/WHAT_IS_CLOUDXY for details.(in English)

Quoted 15 lines
Quoted 15 lines
---
 block/Makefile.objs |    2 +-
 block/hlfs.c        |  515 +++++++++++++++++++++++++++++++++++++++++++++++++++
 configure           |   51 +++++
 3 files changed, 567 insertions(+), 1 deletion(-)
 create mode 100644 block/hlfs.c
block/Makefile.objs +0 -0
index c067f38..723c7a5 100644
@@ -8,7 +8,7 @@ block-obj-$(CONFIG_POSIX) += raw-posix.o
 block-obj-$(CONFIG_LINUX_AIO) += linux-aio.o
 
Quoted 5 lines

block/Makefile.objs block-obj-$(CONFIG_POSIX) += raw-posix.o · line 11

Quoted 3 lines
block/Makefile.objs +1 -1
 ifeq ($(CONFIG_POSIX),y)
-block-obj-y += nbd.o sheepdog.o
+block-obj-y += nbd.o sheepdog.o hlfs.o

Missing CONFIG_HLFS to compile out hlfs.o.

I changed this according to sheepdog. I cannot see any CONFIG_SHEEPDOG.

[...]

Quoted 5 lines

block/Makefile.objs block-obj-$(CONFIG_POSIX) += raw-posix.o · line 13

Quoted 3 lines
block/Makefile.objs +2 -0
+    echo "999 CLIBS is $CLIBS\n"
+    echo "999 CFLAGS is $CFLAGS\n"

Debugging?

I will fix these problems you said. Thanks very much.

Signature · 2 lines
Thanks
Harry Wei
#3 lore raw
Quoted 21 lines · harryxiyou

On Mon, Mar 18, 2013 at 7:10 PM, Stefan Hajnoczi <[email protected]> wrote:
Hi Stefan,

Quoted 2 lines

Is HLFS making releases that distros can package? I don't see packages in Debian or Fedora.

We will make packages for Debian and Fedora.

Quoted 3 lines

Block drivers in qemu.git should have active and sustainable communities behind them.

Cloudxy is an active and sustainable community, which HLFS is just a sub-project of it.

Quoted 3 lines

For example, if this is a research project where the team
will move on within a year, then it may not be appropriate to merge the code into QEMU.

HLFS have been developed for two years.

Quoted 7 lines
Quoted 2 lines

Can you share some background on the HLFS community and where the project is heading?

See http://code.google.com/p/cloudxy/ (Our Main Website) for details (in Chinese).
See http://code.google.com/p/cloudxy/wiki/WHAT_IS_CLOUDXY for details.(in English)

I looked at the Google Code project before, it looks like a repo that a few people are hacking on. The site is developer-focussed and there is no evidence of users. This is why I asked about the background of the community.

There are references to "workshop3" and "linux lab" in the source code. Xiyou and XUPT is http://www.xiyou.edu.cn/.

What I'm concerned about is that there are no users and the developers leave when they graduate. In that case integrating the patches into QEMU is wasted effort.

So what *is* the background of cloudxy (HLFS)?

Quoted 16 lines
Quoted 16 lines
Quoted 16 lines

---
 block/Makefile.objs |    2 +-
 block/hlfs.c        |  515 +++++++++++++++++++++++++++++++++++++++++++++++++++
 configure           |   51 +++++
 3 files changed, 567 insertions(+), 1 deletion(-)
 create mode 100644 block/hlfs.c
block/Makefile.objs +0 -0
index c067f38..723c7a5 100644
@@ -8,7 +8,7 @@ block-obj-$(CONFIG_POSIX) += raw-posix.o
 block-obj-$(CONFIG_LINUX_AIO) += linux-aio.o
 
Quoted 7 lines
Quoted 5 lines

block/Makefile.objs block-obj-$(CONFIG_POSIX) += raw-posix.o · line 11

Quoted 3 lines
block/Makefile.objs +1 -1
 ifeq ($(CONFIG_POSIX),y)
-block-obj-y += nbd.o sheepdog.o
+block-obj-y += nbd.o sheepdog.o hlfs.o

Missing CONFIG_HLFS to compile out hlfs.o.

I changed this according to sheepdog. I cannot see any CONFIG_SHEEPDOG.

Sheepdog has no dependencies, it can always be built.

Stefan

author
#4 lore raw

On Mon, Mar 18, 2013 at 11:16 PM, Stefan Hajnoczi <[email protected]> wrote:
[...]

Quoted 5 lines

I looked at the Google Code project before, it looks like a repo that a few people are hacking on. The site is developer-focussed and there is no evidence of users. This is why I asked about the background of the community.

Cloudxy is developing and we will popularize it.

Quoted 3 lines

There are references to "workshop3" and "linux lab" in the source code. Xiyou and XUPT is http://www.xiyou.edu.cn/.

Some developers are from XUPT.

Quoted 4 lines

What I'm concerned about is that there are no users and the developers leave when they graduate. In that case integrating the patches into QEMU is wasted effort.

There are some developers from XUPT but not *ALL*. Be sure that our key developers will maintain this project forever like Kang Hua <[email protected]>,
Zhang Dianbo <[email protected]>, Wang Sen <[email protected]> and Harry Wei <[email protected]>.

We will broadcast our project so that there will be more users.

Quoted 1 line

So what *is* the background of cloudxy (HLFS)?

Be sure that we have enough developers. Users will be more if Cloudxy has more influences.

Signature · 2 lines
Thanks
Harry Wei
#5 lore raw
Quoted 9 lines · harryxiyou

On Mon, Mar 18, 2013 at 11:16 PM, Stefan Hajnoczi <[email protected]> wrote:
[...]

Quoted 5 lines

I looked at the Google Code project before, it looks like a repo that a few people are hacking on. The site is developer-focussed and there is no evidence of users. This is why I asked about the background of the community.

Cloudxy is developing and we will popularize it.

Most important for QEMU is easy building and testing, so let's focus on that.

Ceph and GlusterFS have packages available in popular distros. This allows us to hook them into QEMU's buildbot
(http://buildbot.b1-systems.de/qemu/grid) so their code does not bitrot.

Sheepdog's QEMU block driver has no external dependencies so it's even easier to build.

I'd like to see packages for popular distros and a "Getting Started" page for users instead of developers. Then I can follow the steps to set up HLFS using the packages and the QEMU buildbot can build the HLFS block driver.

Stefan

author
#6 lore raw
Quoted 9 lines · Stefan Hajnoczi
Quoted 8 lines · harryxiyou

On Mon, Mar 18, 2013 at 11:16 PM, Stefan Hajnoczi <[email protected]> wrote:
[...]

Quoted 5 lines

I looked at the Google Code project before, it looks like a repo that a few people are hacking on. The site is developer-focussed and there is no evidence of users. This is why I asked about the background of the community.

Quoted 4 lines
Quoted 1 line

Cloudxy is developing and we will popularize it.

Most important for QEMU is easy building and testing, so let's focus on that.

Yup, this is wonderful ;-)

Quoted 4 lines

Ceph and GlusterFS have packages available in popular distros. This allows us to hook them into QEMU's buildbot
(http://buildbot.b1-systems.de/qemu/grid) so their code does not bitrot.

We will make debian and RPM packages.

Quoted 3 lines

Sheepdog's QEMU block driver has no external dependencies so it's even easier to build.

Yup.

Quoted 6 lines

I'd like to see packages for popular distros and a "Getting Started" page for users instead of developers. Then I can follow the steps to set up HLFS using the packages and the QEMU buildbot can build the HLFS block driver.

Actually, we have "Get started" wiki pages in Chinese and i will give them in English. You can visit Chinese "Get started" wiki pages by following link.
http://code.google.com/p/cloudxy/wiki/HlfsUserManual

We also have "one key install script", which is located here.
http://cloudxy.googlecode.com/svn/branches/hlfs/person/zhangdianbo/scripts/

All the wiki pages for Cloudxy are here(In Chinese).
http://code.google.com/p/cloudxy/w/list

Signature · 2 lines
Thanks
Harry Wei
author
#7 lore raw
In reply to Stefan Hajnoczi

On Mon, Mar 18, 2013 at 7:10 PM, Stefan Hajnoczi <[email protected]> wrote:
[...]

Quoted 21 lines

read/write/flush should be either .bdrv_co_* or .bdrv_aio_*.

The current code pauses the guest while I/O is in progress! Try running disk I/O benchmarks inside the guest and you'll see that performance and interactivity are poor.

QEMU has two ways of implementing efficient block drivers:

1. Coroutines - .bdrv_co_*

Good for image formats or block drivers that have internal logic.

Each request runs inside a coroutine - see include/block/coroutine.h. In order to wait for I/O, submit an asynchronous request or worker thread and yield the coroutine. When the request completes, re-enter the coroutine and continue.

Examples: block/sheepdog.c or block/qcow2.c.

2. Asynchronous I/O - .bdrv_aio_*

Quoted 8 lines

Good for low-level block drivers that have little logic.

The request processing code is split into callbacks. I/O requests are submitted and then the code returns back to QEMU's main loop. When the I/O request completes, a callback is invoked.

Examples: block/rbd.c or block/qed.c.

HLFS do not use QEMU's AIO way. HLFS, itself, has realized internal AIO.

Signature · 2 lines
Thanks
Harry Wei
#8 lore raw
Quoted 25 lines · harryxiyou

On Mon, Mar 18, 2013 at 7:10 PM, Stefan Hajnoczi <[email protected]> wrote:
[...]

Quoted 23 lines

read/write/flush should be either .bdrv_co_* or .bdrv_aio_*.

The current code pauses the guest while I/O is in progress! Try running disk I/O benchmarks inside the guest and you'll see that performance and interactivity are poor.

QEMU has two ways of implementing efficient block drivers:

1. Coroutines - .bdrv_co_*

Good for image formats or block drivers that have internal logic.

Each request runs inside a coroutine - see include/block/coroutine.h. In order to wait for I/O, submit an asynchronous request or worker thread and yield the coroutine. When the request completes, re-enter the coroutine and continue.

Examples: block/sheepdog.c or block/qcow2.c.

2. Asynchronous I/O - .bdrv_aio_*

Good for low-level block drivers that have little logic.

Quoted 8 lines
Quoted 6 lines

The request processing code is split into callbacks. I/O requests are submitted and then the code returns back to QEMU's main loop. When the I/O request completes, a callback is invoked.

Examples: block/rbd.c or block/qed.c.

HLFS do not use QEMU's AIO way. HLFS, itself, has realized internal AIO.

You need to perform I/O in a way that does not block QEMU's main loop. The code you posted blocks the caller until I/O completes, and therefore blocks QEMU's main loop.

Either you need to use a worker thread approach or add async APIs to HLFS so it can be integrated into the application (QEMU) main loop properly.

Stefan