* [PATCH 01/24] backup: remove incorrect coroutine_fn annotation
2022-10-13 12:36 [PATCH 00/24] More coroutine_fn fixes Paolo Bonzini
@ 2022-10-13 12:36 ` Paolo Bonzini
2022-10-13 12:36 ` [PATCH 02/24] block: " Paolo Bonzini
` (23 subsequent siblings)
24 siblings, 0 replies; 28+ messages in thread
From: Paolo Bonzini @ 2022-10-13 12:36 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-block, afaria
From: Alberto Faria <afaria@redhat.com>
The .set_speed callback is not called from coroutine.
Signed-off-by: Alberto Faria <afaria@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
block/backup.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/block/backup.c b/block/backup.c
index b2b649e305..6a9ad97a53 100644
--- a/block/backup.c
+++ b/block/backup.c
@@ -309,7 +309,7 @@ static void coroutine_fn backup_pause(Job *job)
}
}
-static void coroutine_fn backup_set_speed(BlockJob *job, int64_t speed)
+static void backup_set_speed(BlockJob *job, int64_t speed)
{
BackupBlockJob *s = container_of(job, BackupBlockJob, common);
--
2.37.3
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [PATCH 02/24] block: remove incorrect coroutine_fn annotation
2022-10-13 12:36 [PATCH 00/24] More coroutine_fn fixes Paolo Bonzini
2022-10-13 12:36 ` [PATCH 01/24] backup: remove incorrect coroutine_fn annotation Paolo Bonzini
@ 2022-10-13 12:36 ` Paolo Bonzini
2022-10-13 12:36 ` [PATCH 03/24] monitor: add missing " Paolo Bonzini
` (22 subsequent siblings)
24 siblings, 0 replies; 28+ messages in thread
From: Paolo Bonzini @ 2022-10-13 12:36 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-block, afaria
From: Alberto Faria <afaria@redhat.com>
Signed-off-by: Alberto Faria <afaria@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
block/io.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/block/io.c b/block/io.c
index d30073036e..236b12da2a 100644
--- a/block/io.c
+++ b/block/io.c
@@ -2739,8 +2739,8 @@ int coroutine_fn bdrv_co_is_zero_fast(BlockDriverState *bs, int64_t offset,
return (pnum == bytes) && (ret & BDRV_BLOCK_ZERO);
}
-int coroutine_fn bdrv_is_allocated(BlockDriverState *bs, int64_t offset,
- int64_t bytes, int64_t *pnum)
+int bdrv_is_allocated(BlockDriverState *bs, int64_t offset, int64_t bytes,
+ int64_t *pnum)
{
int ret;
int64_t dummy;
--
2.37.3
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [PATCH 03/24] monitor: add missing coroutine_fn annotation
2022-10-13 12:36 [PATCH 00/24] More coroutine_fn fixes Paolo Bonzini
2022-10-13 12:36 ` [PATCH 01/24] backup: remove incorrect coroutine_fn annotation Paolo Bonzini
2022-10-13 12:36 ` [PATCH 02/24] block: " Paolo Bonzini
@ 2022-10-13 12:36 ` Paolo Bonzini
2022-10-13 12:36 ` [PATCH 04/24] ssh: " Paolo Bonzini
` (21 subsequent siblings)
24 siblings, 0 replies; 28+ messages in thread
From: Paolo Bonzini @ 2022-10-13 12:36 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-block, afaria
From: Alberto Faria <afaria@redhat.com>
hmp_block_resize and hmp_screendump are defined as a ".coroutine = true" command,
so they must be coroutine_fn.
Signed-off-by: Alberto Faria <afaria@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
block/monitor/block-hmp-cmds.c | 2 +-
include/block/block-hmp-cmds.h | 2 +-
include/monitor/hmp.h | 3 ++-
3 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/block/monitor/block-hmp-cmds.c b/block/monitor/block-hmp-cmds.c
index 939a520d17..b6135e9bfe 100644
--- a/block/monitor/block-hmp-cmds.c
+++ b/block/monitor/block-hmp-cmds.c
@@ -489,7 +489,7 @@ void hmp_nbd_server_stop(Monitor *mon, const QDict *qdict)
hmp_handle_error(mon, err);
}
-void hmp_block_resize(Monitor *mon, const QDict *qdict)
+void coroutine_fn hmp_block_resize(Monitor *mon, const QDict *qdict)
{
const char *device = qdict_get_str(qdict, "device");
int64_t size = qdict_get_int(qdict, "size");
diff --git a/include/block/block-hmp-cmds.h b/include/block/block-hmp-cmds.h
index 50ce0247c3..ba0593c440 100644
--- a/include/block/block-hmp-cmds.h
+++ b/include/block/block-hmp-cmds.h
@@ -38,7 +38,7 @@ void hmp_nbd_server_add(Monitor *mon, const QDict *qdict);
void hmp_nbd_server_remove(Monitor *mon, const QDict *qdict);
void hmp_nbd_server_stop(Monitor *mon, const QDict *qdict);
-void hmp_block_resize(Monitor *mon, const QDict *qdict);
+void coroutine_fn hmp_block_resize(Monitor *mon, const QDict *qdict);
void hmp_block_stream(Monitor *mon, const QDict *qdict);
void hmp_block_passwd(Monitor *mon, const QDict *qdict);
void hmp_block_set_io_throttle(Monitor *mon, const QDict *qdict);
diff --git a/include/monitor/hmp.h b/include/monitor/hmp.h
index a9cf064ee8..dfbc0c9a2f 100644
--- a/include/monitor/hmp.h
+++ b/include/monitor/hmp.h
@@ -15,6 +15,7 @@
#define HMP_H
#include "qemu/readline.h"
+#include "qemu/coroutine.h"
#include "qapi/qapi-types-common.h"
bool hmp_handle_error(Monitor *mon, Error *err);
@@ -81,7 +82,7 @@ void hmp_netdev_del(Monitor *mon, const QDict *qdict);
void hmp_getfd(Monitor *mon, const QDict *qdict);
void hmp_closefd(Monitor *mon, const QDict *qdict);
void hmp_sendkey(Monitor *mon, const QDict *qdict);
-void hmp_screendump(Monitor *mon, const QDict *qdict);
+void coroutine_fn hmp_screendump(Monitor *mon, const QDict *qdict);
void hmp_chardev_add(Monitor *mon, const QDict *qdict);
void hmp_chardev_change(Monitor *mon, const QDict *qdict);
void hmp_chardev_remove(Monitor *mon, const QDict *qdict);
--
2.37.3
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [PATCH 04/24] ssh: add missing coroutine_fn annotation
2022-10-13 12:36 [PATCH 00/24] More coroutine_fn fixes Paolo Bonzini
` (2 preceding siblings ...)
2022-10-13 12:36 ` [PATCH 03/24] monitor: add missing " Paolo Bonzini
@ 2022-10-13 12:36 ` Paolo Bonzini
2022-10-13 12:36 ` [PATCH 05/24] block: add missing coroutine_fn annotation to prototypes Paolo Bonzini
` (20 subsequent siblings)
24 siblings, 0 replies; 28+ messages in thread
From: Paolo Bonzini @ 2022-10-13 12:36 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-block, afaria
From: Alberto Faria <afaria@redhat.com>
ssh_write is only called from ssh_co_writev.
Signed-off-by: Alberto Faria <afaria@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
block/ssh.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/block/ssh.c b/block/ssh.c
index a2dc646536..ceb4f4c5bc 100644
--- a/block/ssh.c
+++ b/block/ssh.c
@@ -1129,9 +1129,9 @@ static coroutine_fn int ssh_co_readv(BlockDriverState *bs,
return ret;
}
-static int ssh_write(BDRVSSHState *s, BlockDriverState *bs,
- int64_t offset, size_t size,
- QEMUIOVector *qiov)
+static coroutine_fn int ssh_write(BDRVSSHState *s, BlockDriverState *bs,
+ int64_t offset, size_t size,
+ QEMUIOVector *qiov)
{
ssize_t r;
size_t written;
--
2.37.3
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [PATCH 05/24] block: add missing coroutine_fn annotation to prototypes
2022-10-13 12:36 [PATCH 00/24] More coroutine_fn fixes Paolo Bonzini
` (3 preceding siblings ...)
2022-10-13 12:36 ` [PATCH 04/24] ssh: " Paolo Bonzini
@ 2022-10-13 12:36 ` Paolo Bonzini
2022-10-13 12:36 ` [PATCH 06/24] coroutine-lock: " Paolo Bonzini
` (19 subsequent siblings)
24 siblings, 0 replies; 28+ messages in thread
From: Paolo Bonzini @ 2022-10-13 12:36 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-block, afaria
From: Alberto Faria <afaria@redhat.com>
The functions are marked coroutine_fn in the definition.
Signed-off-by: Alberto Faria <afaria@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
include/block/block-io.h | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/include/block/block-io.h b/include/block/block-io.h
index 492f95fc05..770ddeb7c8 100644
--- a/include/block/block-io.h
+++ b/include/block/block-io.h
@@ -83,12 +83,13 @@ void bdrv_aio_cancel(BlockAIOCB *acb);
void bdrv_aio_cancel_async(BlockAIOCB *acb);
/* sg packet commands */
-int bdrv_co_ioctl(BlockDriverState *bs, int req, void *buf);
+int coroutine_fn bdrv_co_ioctl(BlockDriverState *bs, int req, void *buf);
/* Ensure contents are flushed to disk. */
int coroutine_fn bdrv_co_flush(BlockDriverState *bs);
-int bdrv_co_pdiscard(BdrvChild *child, int64_t offset, int64_t bytes);
+int coroutine_fn bdrv_co_pdiscard(BdrvChild *child, int64_t offset,
+ int64_t bytes);
bool bdrv_can_write_zeroes_with_unmap(BlockDriverState *bs);
int bdrv_block_status(BlockDriverState *bs, int64_t offset,
int64_t bytes, int64_t *pnum, int64_t *map,
--
2.37.3
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [PATCH 06/24] coroutine-lock: add missing coroutine_fn annotation to prototypes
2022-10-13 12:36 [PATCH 00/24] More coroutine_fn fixes Paolo Bonzini
` (4 preceding siblings ...)
2022-10-13 12:36 ` [PATCH 05/24] block: add missing coroutine_fn annotation to prototypes Paolo Bonzini
@ 2022-10-13 12:36 ` Paolo Bonzini
2022-10-13 12:36 ` [PATCH 07/24] coroutine-io: " Paolo Bonzini
` (18 subsequent siblings)
24 siblings, 0 replies; 28+ messages in thread
From: Paolo Bonzini @ 2022-10-13 12:36 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-block, afaria
From: Alberto Faria <afaria@redhat.com>
The functions are marked coroutine_fn in the definition.
Signed-off-by: Alberto Faria <afaria@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
include/qemu/coroutine.h | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/include/qemu/coroutine.h b/include/qemu/coroutine.h
index aae33cce17..d848489b65 100644
--- a/include/qemu/coroutine.h
+++ b/include/qemu/coroutine.h
@@ -276,7 +276,7 @@ void qemu_co_rwlock_init(CoRwlock *lock);
* of a parallel writer, control is transferred to the caller of the current
* coroutine.
*/
-void qemu_co_rwlock_rdlock(CoRwlock *lock);
+void coroutine_fn qemu_co_rwlock_rdlock(CoRwlock *lock);
/**
* Write Locks the CoRwlock from a reader. This is a bit more efficient than
@@ -285,7 +285,7 @@ void qemu_co_rwlock_rdlock(CoRwlock *lock);
* to the caller of the current coroutine; another writer might run while
* @qemu_co_rwlock_upgrade blocks.
*/
-void qemu_co_rwlock_upgrade(CoRwlock *lock);
+void coroutine_fn qemu_co_rwlock_upgrade(CoRwlock *lock);
/**
* Downgrades a write-side critical section to a reader. Downgrading with
@@ -293,20 +293,20 @@ void qemu_co_rwlock_upgrade(CoRwlock *lock);
* followed by @qemu_co_rwlock_rdlock. This makes it more efficient, but
* may also sometimes be necessary for correctness.
*/
-void qemu_co_rwlock_downgrade(CoRwlock *lock);
+void coroutine_fn qemu_co_rwlock_downgrade(CoRwlock *lock);
/**
* Write Locks the mutex. If the lock cannot be taken immediately because
* of a parallel reader, control is transferred to the caller of the current
* coroutine.
*/
-void qemu_co_rwlock_wrlock(CoRwlock *lock);
+void coroutine_fn qemu_co_rwlock_wrlock(CoRwlock *lock);
/**
* Unlocks the read/write lock and schedules the next coroutine that was
* waiting for this lock to be run.
*/
-void qemu_co_rwlock_unlock(CoRwlock *lock);
+void coroutine_fn qemu_co_rwlock_unlock(CoRwlock *lock);
typedef struct QemuCoSleep {
Coroutine *to_wake;
--
2.37.3
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [PATCH 07/24] coroutine-io: add missing coroutine_fn annotation to prototypes
2022-10-13 12:36 [PATCH 00/24] More coroutine_fn fixes Paolo Bonzini
` (5 preceding siblings ...)
2022-10-13 12:36 ` [PATCH 06/24] coroutine-lock: " Paolo Bonzini
@ 2022-10-13 12:36 ` Paolo Bonzini
2022-10-13 12:36 ` [PATCH 08/24] block: add missing coroutine_fn annotation to BlockDriverState callbacks Paolo Bonzini
` (17 subsequent siblings)
24 siblings, 0 replies; 28+ messages in thread
From: Paolo Bonzini @ 2022-10-13 12:36 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-block, afaria
From: Alberto Faria <afaria@redhat.com>
Signed-off-by: Alberto Faria <afaria@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
include/qemu/coroutine.h | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/include/qemu/coroutine.h b/include/qemu/coroutine.h
index d848489b65..06d323143c 100644
--- a/include/qemu/coroutine.h
+++ b/include/qemu/coroutine.h
@@ -378,8 +378,9 @@ void qemu_coroutine_dec_pool_size(unsigned int additional_pool_size);
* The same interface as qemu_sendv_recvv(), with added yielding.
* XXX should mark these as coroutine_fn
*/
-ssize_t qemu_co_sendv_recvv(int sockfd, struct iovec *iov, unsigned iov_cnt,
- size_t offset, size_t bytes, bool do_send);
+ssize_t coroutine_fn qemu_co_sendv_recvv(int sockfd, struct iovec *iov,
+ unsigned iov_cnt, size_t offset,
+ size_t bytes, bool do_send);
#define qemu_co_recvv(sockfd, iov, iov_cnt, offset, bytes) \
qemu_co_sendv_recvv(sockfd, iov, iov_cnt, offset, bytes, false)
#define qemu_co_sendv(sockfd, iov, iov_cnt, offset, bytes) \
@@ -388,7 +389,8 @@ ssize_t qemu_co_sendv_recvv(int sockfd, struct iovec *iov, unsigned iov_cnt,
/**
* The same as above, but with just a single buffer
*/
-ssize_t qemu_co_send_recv(int sockfd, void *buf, size_t bytes, bool do_send);
+ssize_t coroutine_fn qemu_co_send_recv(int sockfd, void *buf, size_t bytes,
+ bool do_send);
#define qemu_co_recv(sockfd, buf, bytes) \
qemu_co_send_recv(sockfd, buf, bytes, false)
#define qemu_co_send(sockfd, buf, bytes) \
--
2.37.3
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [PATCH 08/24] block: add missing coroutine_fn annotation to BlockDriverState callbacks
2022-10-13 12:36 [PATCH 00/24] More coroutine_fn fixes Paolo Bonzini
` (6 preceding siblings ...)
2022-10-13 12:36 ` [PATCH 07/24] coroutine-io: " Paolo Bonzini
@ 2022-10-13 12:36 ` Paolo Bonzini
2022-10-13 12:36 ` [PATCH 09/24] qcow2: add coroutine_fn annotation for indirect-called functions Paolo Bonzini
` (16 subsequent siblings)
24 siblings, 0 replies; 28+ messages in thread
From: Paolo Bonzini @ 2022-10-13 12:36 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-block, afaria
From: Alberto Faria <afaria@redhat.com>
Signed-off-by: Alberto Faria <afaria@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
block/qcow2.h | 14 +++++++-------
include/block/block_int-common.h | 12 +++++-------
2 files changed, 12 insertions(+), 14 deletions(-)
diff --git a/block/qcow2.h b/block/qcow2.h
index 3e7c5e80b6..ad6e7f65bd 100644
--- a/block/qcow2.h
+++ b/block/qcow2.h
@@ -991,13 +991,13 @@ int qcow2_truncate_bitmaps_check(BlockDriverState *bs, Error **errp);
bool qcow2_store_persistent_dirty_bitmaps(BlockDriverState *bs,
bool release_stored, Error **errp);
int qcow2_reopen_bitmaps_ro(BlockDriverState *bs, Error **errp);
-bool qcow2_co_can_store_new_dirty_bitmap(BlockDriverState *bs,
- const char *name,
- uint32_t granularity,
- Error **errp);
-int qcow2_co_remove_persistent_dirty_bitmap(BlockDriverState *bs,
- const char *name,
- Error **errp);
+bool coroutine_fn qcow2_co_can_store_new_dirty_bitmap(BlockDriverState *bs,
+ const char *name,
+ uint32_t granularity,
+ Error **errp);
+int coroutine_fn qcow2_co_remove_persistent_dirty_bitmap(BlockDriverState *bs,
+ const char *name,
+ Error **errp);
bool qcow2_supports_persistent_dirty_bitmap(BlockDriverState *bs);
uint64_t qcow2_get_persistent_dirty_bitmap_size(BlockDriverState *bs,
uint32_t cluster_size);
diff --git a/include/block/block_int-common.h b/include/block/block_int-common.h
index 8947abab76..16c45d1262 100644
--- a/include/block/block_int-common.h
+++ b/include/block/block_int-common.h
@@ -731,13 +731,11 @@ struct BlockDriver {
void coroutine_fn (*bdrv_co_drain_end)(BlockDriverState *bs);
bool (*bdrv_supports_persistent_dirty_bitmap)(BlockDriverState *bs);
- bool (*bdrv_co_can_store_new_dirty_bitmap)(BlockDriverState *bs,
- const char *name,
- uint32_t granularity,
- Error **errp);
- int (*bdrv_co_remove_persistent_dirty_bitmap)(BlockDriverState *bs,
- const char *name,
- Error **errp);
+ bool coroutine_fn (*bdrv_co_can_store_new_dirty_bitmap)(
+ BlockDriverState *bs, const char *name, uint32_t granularity,
+ Error **errp);
+ int coroutine_fn (*bdrv_co_remove_persistent_dirty_bitmap)(
+ BlockDriverState *bs, const char *name, Error **errp);
};
static inline bool block_driver_can_compress(BlockDriver *drv)
--
2.37.3
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [PATCH 09/24] qcow2: add coroutine_fn annotation for indirect-called functions
2022-10-13 12:36 [PATCH 00/24] More coroutine_fn fixes Paolo Bonzini
` (7 preceding siblings ...)
2022-10-13 12:36 ` [PATCH 08/24] block: add missing coroutine_fn annotation to BlockDriverState callbacks Paolo Bonzini
@ 2022-10-13 12:36 ` Paolo Bonzini
2022-10-13 12:36 ` [PATCH 10/24] blkdebug: add missing " Paolo Bonzini
` (15 subsequent siblings)
24 siblings, 0 replies; 28+ messages in thread
From: Paolo Bonzini @ 2022-10-13 12:36 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-block, afaria
From: Alberto Faria <afaria@redhat.com>
Signed-off-by: Alberto Faria <afaria@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
block/qcow2.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/block/qcow2.c b/block/qcow2.c
index b57f7cc8ee..b7cac50eb3 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -5287,8 +5287,8 @@ static int64_t qcow2_check_vmstate_request(BlockDriverState *bs,
return pos;
}
-static int qcow2_save_vmstate(BlockDriverState *bs, QEMUIOVector *qiov,
- int64_t pos)
+static coroutine_fn int qcow2_save_vmstate(BlockDriverState *bs,
+ QEMUIOVector *qiov, int64_t pos)
{
int64_t offset = qcow2_check_vmstate_request(bs, qiov, pos);
if (offset < 0) {
@@ -5299,8 +5299,8 @@ static int qcow2_save_vmstate(BlockDriverState *bs, QEMUIOVector *qiov,
return bs->drv->bdrv_co_pwritev_part(bs, offset, qiov->size, qiov, 0, 0);
}
-static int qcow2_load_vmstate(BlockDriverState *bs, QEMUIOVector *qiov,
- int64_t pos)
+static coroutine_fn int qcow2_load_vmstate(BlockDriverState *bs,
+ QEMUIOVector *qiov, int64_t pos)
{
int64_t offset = qcow2_check_vmstate_request(bs, qiov, pos);
if (offset < 0) {
--
2.37.3
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [PATCH 10/24] blkdebug: add missing coroutine_fn annotation for indirect-called functions
2022-10-13 12:36 [PATCH 00/24] More coroutine_fn fixes Paolo Bonzini
` (8 preceding siblings ...)
2022-10-13 12:36 ` [PATCH 09/24] qcow2: add coroutine_fn annotation for indirect-called functions Paolo Bonzini
@ 2022-10-13 12:36 ` Paolo Bonzini
2022-10-13 12:36 ` [PATCH 11/24] qcow: manually add more coroutine_fn annotations Paolo Bonzini
` (14 subsequent siblings)
24 siblings, 0 replies; 28+ messages in thread
From: Paolo Bonzini @ 2022-10-13 12:36 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-block, afaria
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
block/blkdebug.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/block/blkdebug.c b/block/blkdebug.c
index bbf2948703..b159a9b825 100644
--- a/block/blkdebug.c
+++ b/block/blkdebug.c
@@ -672,7 +672,7 @@ blkdebug_co_pwritev(BlockDriverState *bs, int64_t offset, int64_t bytes,
return bdrv_co_pwritev(bs->file, offset, bytes, qiov, flags);
}
-static int blkdebug_co_flush(BlockDriverState *bs)
+static int coroutine_fn blkdebug_co_flush(BlockDriverState *bs)
{
int err = rule_check(bs, 0, 0, BLKDEBUG_IO_TYPE_FLUSH);
--
2.37.3
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [PATCH 11/24] qcow: manually add more coroutine_fn annotations
2022-10-13 12:36 [PATCH 00/24] More coroutine_fn fixes Paolo Bonzini
` (9 preceding siblings ...)
2022-10-13 12:36 ` [PATCH 10/24] blkdebug: add missing " Paolo Bonzini
@ 2022-10-13 12:36 ` Paolo Bonzini
2022-10-13 12:36 ` [PATCH 12/24] qcow2: " Paolo Bonzini
` (13 subsequent siblings)
24 siblings, 0 replies; 28+ messages in thread
From: Paolo Bonzini @ 2022-10-13 12:36 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-block, afaria
get_cluster_offset() and decompress_cluster() are only called from
the read and write paths.
The validity of these was double-checked with Alberto Faria's static analyzer.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
block/qcow.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/block/qcow.c b/block/qcow.c
index 311aaa8705..7f07c00c0f 100644
--- a/block/qcow.c
+++ b/block/qcow.c
@@ -92,7 +92,7 @@ typedef struct BDRVQcowState {
static QemuOptsList qcow_create_opts;
-static int decompress_cluster(BlockDriverState *bs, uint64_t cluster_offset);
+static int coroutine_fn decompress_cluster(BlockDriverState *bs, uint64_t cluster_offset);
static int qcow_probe(const uint8_t *buf, int buf_size, const char *filename)
{
@@ -351,10 +351,10 @@ static int qcow_reopen_prepare(BDRVReopenState *state,
* return 0 if not allocated, 1 if *result is assigned, and negative
* errno on failure.
*/
-static int get_cluster_offset(BlockDriverState *bs,
- uint64_t offset, int allocate,
- int compressed_size,
- int n_start, int n_end, uint64_t *result)
+static int coroutine_fn get_cluster_offset(BlockDriverState *bs,
+ uint64_t offset, int allocate,
+ int compressed_size,
+ int n_start, int n_end, uint64_t *result)
{
BDRVQcowState *s = bs->opaque;
int min_index, i, j, l1_index, l2_index, ret;
@@ -585,7 +585,7 @@ static int decompress_buffer(uint8_t *out_buf, int out_buf_size,
return 0;
}
-static int decompress_cluster(BlockDriverState *bs, uint64_t cluster_offset)
+static int coroutine_fn decompress_cluster(BlockDriverState *bs, uint64_t cluster_offset)
{
BDRVQcowState *s = bs->opaque;
int ret, csize;
--
2.37.3
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [PATCH 12/24] qcow2: manually add more coroutine_fn annotations
2022-10-13 12:36 [PATCH 00/24] More coroutine_fn fixes Paolo Bonzini
` (10 preceding siblings ...)
2022-10-13 12:36 ` [PATCH 11/24] qcow: manually add more coroutine_fn annotations Paolo Bonzini
@ 2022-10-13 12:36 ` Paolo Bonzini
2022-10-13 12:37 ` [PATCH 13/24] vmdk: " Paolo Bonzini
` (12 subsequent siblings)
24 siblings, 0 replies; 28+ messages in thread
From: Paolo Bonzini @ 2022-10-13 12:36 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-block, afaria
The validity of these was double-checked with Alberto Faria's static analyzer.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
block/qcow2-bitmap.c | 4 ++--
block/qcow2-cluster.c | 18 +++++++++---------
block/qcow2-refcount.c | 8 ++++----
block/qcow2.h | 18 +++++++++---------
4 files changed, 24 insertions(+), 24 deletions(-)
diff --git a/block/qcow2-bitmap.c b/block/qcow2-bitmap.c
index 7197754843..1ff127647a 100644
--- a/block/qcow2-bitmap.c
+++ b/block/qcow2-bitmap.c
@@ -955,8 +955,8 @@ static void set_readonly_helper(gpointer bitmap, gpointer value)
* If header_updated is not NULL then it is set appropriately regardless of
* the return value.
*/
-bool qcow2_load_dirty_bitmaps(BlockDriverState *bs, bool *header_updated,
- Error **errp)
+bool coroutine_fn qcow2_load_dirty_bitmaps(BlockDriverState *bs, bool *header_updated,
+ Error **errp)
{
BDRVQcow2State *s = bs->opaque;
Qcow2BitmapList *bm_list;
diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
index 0f293950a1..523c37215a 100644
--- a/block/qcow2-cluster.c
+++ b/block/qcow2-cluster.c
@@ -31,7 +31,7 @@
#include "qemu/memalign.h"
#include "trace.h"
-int qcow2_shrink_l1_table(BlockDriverState *bs, uint64_t exact_size)
+int coroutine_fn qcow2_shrink_l1_table(BlockDriverState *bs, uint64_t exact_size)
{
BDRVQcow2State *s = bs->opaque;
int new_l1_size, i, ret;
@@ -823,10 +823,10 @@ static int get_cluster_table(BlockDriverState *bs, uint64_t offset,
*
* Return 0 on success and -errno in error cases
*/
-int qcow2_alloc_compressed_cluster_offset(BlockDriverState *bs,
- uint64_t offset,
- int compressed_size,
- uint64_t *host_offset)
+int coroutine_fn qcow2_alloc_compressed_cluster_offset(BlockDriverState *bs,
+ uint64_t offset,
+ int compressed_size,
+ uint64_t *host_offset)
{
BDRVQcow2State *s = bs->opaque;
int l2_index, ret;
@@ -1488,7 +1488,7 @@ static int coroutine_fn handle_dependencies(BlockDriverState *bs,
*
* -errno: in error cases
*/
-static int handle_copied(BlockDriverState *bs, uint64_t guest_offset,
+static int coroutine_fn handle_copied(BlockDriverState *bs, uint64_t guest_offset,
uint64_t *host_offset, uint64_t *bytes, QCowL2Meta **m)
{
BDRVQcow2State *s = bs->opaque;
@@ -1653,7 +1653,7 @@ static int do_alloc_cluster_offset(BlockDriverState *bs, uint64_t guest_offset,
*
* -errno: in error cases
*/
-static int handle_alloc(BlockDriverState *bs, uint64_t guest_offset,
+static int coroutine_fn handle_alloc(BlockDriverState *bs, uint64_t guest_offset,
uint64_t *host_offset, uint64_t *bytes, QCowL2Meta **m)
{
BDRVQcow2State *s = bs->opaque;
diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c
index 1fbb07ca77..38861ed7c8 100644
--- a/block/qcow2-refcount.c
+++ b/block/qcow2-refcount.c
@@ -97,7 +97,7 @@ static void update_max_refcount_table_index(BDRVQcow2State *s)
s->max_refcount_table_index = i;
}
-int qcow2_refcount_init(BlockDriverState *bs)
+int coroutine_fn qcow2_refcount_init(BlockDriverState *bs)
{
BDRVQcow2State *s = bs->opaque;
unsigned int refcount_table_size2, i;
@@ -3559,8 +3559,8 @@ static int64_t get_refblock_offset(BlockDriverState *bs, uint64_t offset)
return covering_refblock_offset;
}
-static int qcow2_discard_refcount_block(BlockDriverState *bs,
- uint64_t discard_block_offs)
+static int coroutine_fn qcow2_discard_refcount_block(BlockDriverState *bs,
+ uint64_t discard_block_offs)
{
BDRVQcow2State *s = bs->opaque;
int64_t refblock_offs;
@@ -3616,7 +3616,7 @@ static int qcow2_discard_refcount_block(BlockDriverState *bs,
return 0;
}
-int qcow2_shrink_reftable(BlockDriverState *bs)
+int coroutine_fn qcow2_shrink_reftable(BlockDriverState *bs)
{
BDRVQcow2State *s = bs->opaque;
uint64_t *reftable_tmp =
diff --git a/block/qcow2.h b/block/qcow2.h
index ad6e7f65bd..32612e53e5 100644
--- a/block/qcow2.h
+++ b/block/qcow2.h
@@ -846,7 +846,7 @@ int qcow2_validate_table(BlockDriverState *bs, uint64_t offset,
Error **errp);
/* qcow2-refcount.c functions */
-int qcow2_refcount_init(BlockDriverState *bs);
+int coroutine_fn qcow2_refcount_init(BlockDriverState *bs);
void qcow2_refcount_close(BlockDriverState *bs);
int qcow2_get_refcount(BlockDriverState *bs, int64_t cluster_index,
@@ -893,14 +893,14 @@ int qcow2_inc_refcounts_imrt(BlockDriverState *bs, BdrvCheckResult *res,
int qcow2_change_refcount_order(BlockDriverState *bs, int refcount_order,
BlockDriverAmendStatusCB *status_cb,
void *cb_opaque, Error **errp);
-int qcow2_shrink_reftable(BlockDriverState *bs);
+int coroutine_fn qcow2_shrink_reftable(BlockDriverState *bs);
int64_t qcow2_get_last_cluster(BlockDriverState *bs, int64_t size);
int coroutine_fn qcow2_detect_metadata_preallocation(BlockDriverState *bs);
/* qcow2-cluster.c functions */
int qcow2_grow_l1_table(BlockDriverState *bs, uint64_t min_size,
bool exact_size);
-int qcow2_shrink_l1_table(BlockDriverState *bs, uint64_t max_size);
+int coroutine_fn qcow2_shrink_l1_table(BlockDriverState *bs, uint64_t max_size);
int qcow2_write_l1_entry(BlockDriverState *bs, int l1_index);
int qcow2_encrypt_sectors(BDRVQcow2State *s, int64_t sector_num,
uint8_t *buf, int nb_sectors, bool enc, Error **errp);
@@ -911,10 +911,10 @@ int qcow2_get_host_offset(BlockDriverState *bs, uint64_t offset,
int coroutine_fn qcow2_alloc_host_offset(BlockDriverState *bs, uint64_t offset,
unsigned int *bytes,
uint64_t *host_offset, QCowL2Meta **m);
-int qcow2_alloc_compressed_cluster_offset(BlockDriverState *bs,
- uint64_t offset,
- int compressed_size,
- uint64_t *host_offset);
+int coroutine_fn qcow2_alloc_compressed_cluster_offset(BlockDriverState *bs,
+ uint64_t offset,
+ int compressed_size,
+ uint64_t *host_offset);
void qcow2_parse_compressed_l2_entry(BlockDriverState *bs, uint64_t l2_entry,
uint64_t *coffset, int *csize);
@@ -982,8 +982,8 @@ void qcow2_cache_discard(Qcow2Cache *c, void *table);
int qcow2_check_bitmaps_refcounts(BlockDriverState *bs, BdrvCheckResult *res,
void **refcount_table,
int64_t *refcount_table_size);
-bool qcow2_load_dirty_bitmaps(BlockDriverState *bs, bool *header_updated,
- Error **errp);
+bool coroutine_fn qcow2_load_dirty_bitmaps(BlockDriverState *bs, bool *header_updated,
+ Error **errp);
bool qcow2_get_bitmap_info_list(BlockDriverState *bs,
Qcow2BitmapInfoList **info_list, Error **errp);
int qcow2_reopen_bitmaps_rw(BlockDriverState *bs, Error **errp);
--
2.37.3
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [PATCH 13/24] vmdk: manually add more coroutine_fn annotations
2022-10-13 12:36 [PATCH 00/24] More coroutine_fn fixes Paolo Bonzini
` (11 preceding siblings ...)
2022-10-13 12:36 ` [PATCH 12/24] qcow2: " Paolo Bonzini
@ 2022-10-13 12:37 ` Paolo Bonzini
2022-10-13 12:37 ` [PATCH 14/24] commit: switch to *_co_* functions Paolo Bonzini
` (11 subsequent siblings)
24 siblings, 0 replies; 28+ messages in thread
From: Paolo Bonzini @ 2022-10-13 12:37 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-block, afaria
The validity of these was double-checked with Alberto Faria's static analyzer.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
block/vmdk.c | 34 +++++++++++++++++-----------------
1 file changed, 17 insertions(+), 17 deletions(-)
diff --git a/block/vmdk.c b/block/vmdk.c
index f7d8856dfb..c720376aa5 100644
--- a/block/vmdk.c
+++ b/block/vmdk.c
@@ -1404,13 +1404,13 @@ static void vmdk_refresh_limits(BlockDriverState *bs, Error **errp)
* [@skip_start_sector, @skip_end_sector) is not copied or written, and leave
* it for call to write user data in the request.
*/
-static int get_whole_cluster(BlockDriverState *bs,
- VmdkExtent *extent,
- uint64_t cluster_offset,
- uint64_t offset,
- uint64_t skip_start_bytes,
- uint64_t skip_end_bytes,
- bool zeroed)
+static int coroutine_fn get_whole_cluster(BlockDriverState *bs,
+ VmdkExtent *extent,
+ uint64_t cluster_offset,
+ uint64_t offset,
+ uint64_t skip_start_bytes,
+ uint64_t skip_end_bytes,
+ bool zeroed)
{
int ret = VMDK_OK;
int64_t cluster_bytes;
@@ -1485,8 +1485,8 @@ exit:
return ret;
}
-static int vmdk_L2update(VmdkExtent *extent, VmdkMetaData *m_data,
- uint32_t offset)
+static int coroutine_fn vmdk_L2update(VmdkExtent *extent, VmdkMetaData *m_data,
+ uint32_t offset)
{
offset = cpu_to_le32(offset);
/* update L2 table */
@@ -1537,14 +1537,14 @@ static int vmdk_L2update(VmdkExtent *extent, VmdkMetaData *m_data,
* VMDK_UNALLOC if cluster is not mapped and @allocate is false.
* VMDK_ERROR if failed.
*/
-static int get_cluster_offset(BlockDriverState *bs,
- VmdkExtent *extent,
- VmdkMetaData *m_data,
- uint64_t offset,
- bool allocate,
- uint64_t *cluster_offset,
- uint64_t skip_start_bytes,
- uint64_t skip_end_bytes)
+static int coroutine_fn get_cluster_offset(BlockDriverState *bs,
+ VmdkExtent *extent,
+ VmdkMetaData *m_data,
+ uint64_t offset,
+ bool allocate,
+ uint64_t *cluster_offset,
+ uint64_t skip_start_bytes,
+ uint64_t skip_end_bytes)
{
unsigned int l1_index, l2_offset, l2_index;
int min_index, i, j;
--
2.37.3
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [PATCH 14/24] commit: switch to *_co_* functions
2022-10-13 12:36 [PATCH 00/24] More coroutine_fn fixes Paolo Bonzini
` (12 preceding siblings ...)
2022-10-13 12:37 ` [PATCH 13/24] vmdk: " Paolo Bonzini
@ 2022-10-13 12:37 ` Paolo Bonzini
2022-10-13 12:37 ` [PATCH 15/24] block: " Paolo Bonzini
` (10 subsequent siblings)
24 siblings, 0 replies; 28+ messages in thread
From: Paolo Bonzini @ 2022-10-13 12:37 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-block, afaria
From: Alberto Faria <afaria@redhat.com>
Signed-off-by: Alberto Faria <afaria@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
block/commit.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/block/commit.c b/block/commit.c
index 38571510cb..945945de05 100644
--- a/block/commit.c
+++ b/block/commit.c
@@ -135,7 +135,7 @@ static int coroutine_fn commit_run(Job *job, Error **errp)
}
if (base_len < len) {
- ret = blk_truncate(s->base, len, false, PREALLOC_MODE_OFF, 0, NULL);
+ ret = blk_co_truncate(s->base, len, false, PREALLOC_MODE_OFF, 0, NULL);
if (ret) {
return ret;
}
--
2.37.3
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [PATCH 15/24] block: switch to *_co_* functions
2022-10-13 12:36 [PATCH 00/24] More coroutine_fn fixes Paolo Bonzini
` (13 preceding siblings ...)
2022-10-13 12:37 ` [PATCH 14/24] commit: switch to *_co_* functions Paolo Bonzini
@ 2022-10-13 12:37 ` Paolo Bonzini
2022-10-13 12:37 ` [PATCH 16/24] mirror: " Paolo Bonzini
` (9 subsequent siblings)
24 siblings, 0 replies; 28+ messages in thread
From: Paolo Bonzini @ 2022-10-13 12:37 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-block, afaria
From: Alberto Faria <afaria@redhat.com>
Signed-off-by: Alberto Faria <afaria@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
block.c | 2 +-
block/io.c | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/block.c b/block.c
index 1fbf6b9e69..e44801fd28 100644
--- a/block.c
+++ b/block.c
@@ -643,7 +643,7 @@ create_file_fallback_zero_first_sector(BlockBackend *blk,
bytes_to_clear = MIN(current_size, BDRV_SECTOR_SIZE);
if (bytes_to_clear) {
- ret = blk_pwrite_zeroes(blk, 0, bytes_to_clear, BDRV_REQ_MAY_UNMAP);
+ ret = blk_co_pwrite_zeroes(blk, 0, bytes_to_clear, BDRV_REQ_MAY_UNMAP);
if (ret < 0) {
error_setg_errno(errp, -ret,
"Failed to clear the new image's first sector");
diff --git a/block/io.c b/block/io.c
index 236b12da2a..5518a9d1e6 100644
--- a/block/io.c
+++ b/block/io.c
@@ -2729,8 +2729,8 @@ int coroutine_fn bdrv_co_is_zero_fast(BlockDriverState *bs, int64_t offset,
return 1;
}
- ret = bdrv_common_block_status_above(bs, NULL, false, false, offset,
- bytes, &pnum, NULL, NULL, NULL);
+ ret = bdrv_co_common_block_status_above(bs, NULL, false, false, offset,
+ bytes, &pnum, NULL, NULL, NULL);
if (ret < 0) {
return ret;
--
2.37.3
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [PATCH 16/24] mirror: switch to *_co_* functions
2022-10-13 12:36 [PATCH 00/24] More coroutine_fn fixes Paolo Bonzini
` (14 preceding siblings ...)
2022-10-13 12:37 ` [PATCH 15/24] block: " Paolo Bonzini
@ 2022-10-13 12:37 ` Paolo Bonzini
2022-10-13 12:37 ` [PATCH 17/24] parallels: " Paolo Bonzini
` (8 subsequent siblings)
24 siblings, 0 replies; 28+ messages in thread
From: Paolo Bonzini @ 2022-10-13 12:37 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-block, afaria
From: Alberto Faria <afaria@redhat.com>
Signed-off-by: Alberto Faria <afaria@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
block/mirror.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/block/mirror.c b/block/mirror.c
index 80c0109d39..95677c8969 100644
--- a/block/mirror.c
+++ b/block/mirror.c
@@ -922,8 +922,8 @@ static int coroutine_fn mirror_run(Job *job, Error **errp)
* active layer. */
if (s->base == blk_bs(s->target)) {
if (s->bdev_length > target_length) {
- ret = blk_truncate(s->target, s->bdev_length, false,
- PREALLOC_MODE_OFF, 0, NULL);
+ ret = blk_co_truncate(s->target, s->bdev_length, false,
+ PREALLOC_MODE_OFF, 0, NULL);
if (ret < 0) {
goto immediate_exit;
}
--
2.37.3
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [PATCH 17/24] parallels: switch to *_co_* functions
2022-10-13 12:36 [PATCH 00/24] More coroutine_fn fixes Paolo Bonzini
` (15 preceding siblings ...)
2022-10-13 12:37 ` [PATCH 16/24] mirror: " Paolo Bonzini
@ 2022-10-13 12:37 ` Paolo Bonzini
2022-10-13 12:37 ` [PATCH 18/24] qcow: " Paolo Bonzini
` (7 subsequent siblings)
24 siblings, 0 replies; 28+ messages in thread
From: Paolo Bonzini @ 2022-10-13 12:37 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-block, afaria
From: Alberto Faria <afaria@redhat.com>
Signed-off-by: Alberto Faria <afaria@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
block/parallels.c | 28 ++++++++++++++--------------
1 file changed, 14 insertions(+), 14 deletions(-)
diff --git a/block/parallels.c b/block/parallels.c
index c1523e7dab..7f2c1a335d 100644
--- a/block/parallels.c
+++ b/block/parallels.c
@@ -205,18 +205,18 @@ static coroutine_fn int64_t allocate_clusters(BlockDriverState *bs,
* force the safer-but-slower fallocate.
*/
if (s->prealloc_mode == PRL_PREALLOC_MODE_TRUNCATE) {
- ret = bdrv_truncate(bs->file,
- (s->data_end + space) << BDRV_SECTOR_BITS,
- false, PREALLOC_MODE_OFF, BDRV_REQ_ZERO_WRITE,
- NULL);
+ ret = bdrv_co_truncate(bs->file,
+ (s->data_end + space) << BDRV_SECTOR_BITS,
+ false, PREALLOC_MODE_OFF,
+ BDRV_REQ_ZERO_WRITE, NULL);
if (ret == -ENOTSUP) {
s->prealloc_mode = PRL_PREALLOC_MODE_FALLOCATE;
}
}
if (s->prealloc_mode == PRL_PREALLOC_MODE_FALLOCATE) {
- ret = bdrv_pwrite_zeroes(bs->file,
- s->data_end << BDRV_SECTOR_BITS,
- space << BDRV_SECTOR_BITS, 0);
+ ret = bdrv_co_pwrite_zeroes(bs->file,
+ s->data_end << BDRV_SECTOR_BITS,
+ space << BDRV_SECTOR_BITS, 0);
}
if (ret < 0) {
return ret;
@@ -278,8 +278,8 @@ static coroutine_fn int parallels_co_flush_to_os(BlockDriverState *bs)
if (off + to_write > s->header_size) {
to_write = s->header_size - off;
}
- ret = bdrv_pwrite(bs->file, off, to_write, (uint8_t *)s->header + off,
- 0);
+ ret = bdrv_co_pwrite(bs->file, off, to_write,
+ (uint8_t *)s->header + off, 0);
if (ret < 0) {
qemu_co_mutex_unlock(&s->lock);
return ret;
@@ -504,8 +504,8 @@ static int coroutine_fn parallels_co_check(BlockDriverState *bs,
* In order to really repair the image, we must shrink it.
* That means we have to pass exact=true.
*/
- ret = bdrv_truncate(bs->file, res->image_end_offset, true,
- PREALLOC_MODE_OFF, 0, &local_err);
+ ret = bdrv_co_truncate(bs->file, res->image_end_offset, true,
+ PREALLOC_MODE_OFF, 0, &local_err);
if (ret < 0) {
error_report_err(local_err);
res->check_errors++;
@@ -600,12 +600,12 @@ static int coroutine_fn parallels_co_create(BlockdevCreateOptions* opts,
memset(tmp, 0, sizeof(tmp));
memcpy(tmp, &header, sizeof(header));
- ret = blk_pwrite(blk, 0, BDRV_SECTOR_SIZE, tmp, 0);
+ ret = blk_co_pwrite(blk, 0, BDRV_SECTOR_SIZE, tmp, 0);
if (ret < 0) {
goto exit;
}
- ret = blk_pwrite_zeroes(blk, BDRV_SECTOR_SIZE,
- (bat_sectors - 1) << BDRV_SECTOR_BITS, 0);
+ ret = blk_co_pwrite_zeroes(blk, BDRV_SECTOR_SIZE,
+ (bat_sectors - 1) << BDRV_SECTOR_BITS, 0);
if (ret < 0) {
goto exit;
}
--
2.37.3
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [PATCH 18/24] qcow: switch to *_co_* functions
2022-10-13 12:36 [PATCH 00/24] More coroutine_fn fixes Paolo Bonzini
` (16 preceding siblings ...)
2022-10-13 12:37 ` [PATCH 17/24] parallels: " Paolo Bonzini
@ 2022-10-13 12:37 ` Paolo Bonzini
2022-10-13 12:37 ` [PATCH 19/24] qcow2: " Paolo Bonzini
` (6 subsequent siblings)
24 siblings, 0 replies; 28+ messages in thread
From: Paolo Bonzini @ 2022-10-13 12:37 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-block, afaria
From: Alberto Faria <afaria@redhat.com>
Signed-off-by: Alberto Faria <afaria@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
block/qcow.c | 44 ++++++++++++++++++++++----------------------
1 file changed, 22 insertions(+), 22 deletions(-)
diff --git a/block/qcow.c b/block/qcow.c
index 7f07c00c0f..133705f4ff 100644
--- a/block/qcow.c
+++ b/block/qcow.c
@@ -381,9 +381,9 @@ static int coroutine_fn get_cluster_offset(BlockDriverState *bs,
s->l1_table[l1_index] = l2_offset;
tmp = cpu_to_be64(l2_offset);
BLKDBG_EVENT(bs->file, BLKDBG_L1_UPDATE);
- ret = bdrv_pwrite_sync(bs->file,
- s->l1_table_offset + l1_index * sizeof(tmp),
- sizeof(tmp), &tmp, 0);
+ ret = bdrv_co_pwrite_sync(bs->file,
+ s->l1_table_offset + l1_index * sizeof(tmp),
+ sizeof(tmp), &tmp, 0);
if (ret < 0) {
return ret;
}
@@ -414,14 +414,14 @@ static int coroutine_fn get_cluster_offset(BlockDriverState *bs,
BLKDBG_EVENT(bs->file, BLKDBG_L2_LOAD);
if (new_l2_table) {
memset(l2_table, 0, s->l2_size * sizeof(uint64_t));
- ret = bdrv_pwrite_sync(bs->file, l2_offset,
- s->l2_size * sizeof(uint64_t), l2_table, 0);
+ ret = bdrv_co_pwrite_sync(bs->file, l2_offset,
+ s->l2_size * sizeof(uint64_t), l2_table, 0);
if (ret < 0) {
return ret;
}
} else {
- ret = bdrv_pread(bs->file, l2_offset, s->l2_size * sizeof(uint64_t),
- l2_table, 0);
+ ret = bdrv_co_pread(bs->file, l2_offset,
+ s->l2_size * sizeof(uint64_t), l2_table, 0);
if (ret < 0) {
return ret;
}
@@ -453,8 +453,8 @@ static int coroutine_fn get_cluster_offset(BlockDriverState *bs,
cluster_offset = QEMU_ALIGN_UP(cluster_offset, s->cluster_size);
/* write the cluster content */
BLKDBG_EVENT(bs->file, BLKDBG_WRITE_AIO);
- ret = bdrv_pwrite(bs->file, cluster_offset, s->cluster_size,
- s->cluster_cache, 0);
+ ret = bdrv_co_pwrite(bs->file, cluster_offset, s->cluster_size,
+ s->cluster_cache, 0);
if (ret < 0) {
return ret;
}
@@ -469,8 +469,8 @@ static int coroutine_fn get_cluster_offset(BlockDriverState *bs,
if (cluster_offset + s->cluster_size > INT64_MAX) {
return -E2BIG;
}
- ret = bdrv_truncate(bs->file, cluster_offset + s->cluster_size,
- false, PREALLOC_MODE_OFF, 0, NULL);
+ ret = bdrv_co_truncate(bs->file, cluster_offset + s->cluster_size,
+ false, PREALLOC_MODE_OFF, 0, NULL);
if (ret < 0) {
return ret;
}
@@ -492,9 +492,9 @@ static int coroutine_fn get_cluster_offset(BlockDriverState *bs,
return -EIO;
}
BLKDBG_EVENT(bs->file, BLKDBG_WRITE_AIO);
- ret = bdrv_pwrite(bs->file, cluster_offset + i,
- BDRV_SECTOR_SIZE,
- s->cluster_data, 0);
+ ret = bdrv_co_pwrite(bs->file, cluster_offset + i,
+ BDRV_SECTOR_SIZE,
+ s->cluster_data, 0);
if (ret < 0) {
return ret;
}
@@ -514,8 +514,8 @@ static int coroutine_fn get_cluster_offset(BlockDriverState *bs,
} else {
BLKDBG_EVENT(bs->file, BLKDBG_L2_UPDATE);
}
- ret = bdrv_pwrite_sync(bs->file, l2_offset + l2_index * sizeof(tmp),
- sizeof(tmp), &tmp, 0);
+ ret = bdrv_co_pwrite_sync(bs->file, l2_offset + l2_index * sizeof(tmp),
+ sizeof(tmp), &tmp, 0);
if (ret < 0) {
return ret;
}
@@ -596,7 +596,7 @@ static int coroutine_fn decompress_cluster(BlockDriverState *bs, uint64_t cluste
csize = cluster_offset >> (63 - s->cluster_bits);
csize &= (s->cluster_size - 1);
BLKDBG_EVENT(bs->file, BLKDBG_READ_COMPRESSED);
- ret = bdrv_pread(bs->file, coffset, csize, s->cluster_data, 0);
+ ret = bdrv_co_pread(bs->file, coffset, csize, s->cluster_data, 0);
if (ret < 0)
return -1;
if (decompress_buffer(s->cluster_cache, s->cluster_size,
@@ -890,14 +890,14 @@ static int coroutine_fn qcow_co_create(BlockdevCreateOptions *opts,
}
/* write all the data */
- ret = blk_pwrite(qcow_blk, 0, sizeof(header), &header, 0);
+ ret = blk_co_pwrite(qcow_blk, 0, sizeof(header), &header, 0);
if (ret < 0) {
goto exit;
}
if (qcow_opts->has_backing_file) {
- ret = blk_pwrite(qcow_blk, sizeof(header), backing_filename_len,
- qcow_opts->backing_file, 0);
+ ret = blk_co_pwrite(qcow_blk, sizeof(header), backing_filename_len,
+ qcow_opts->backing_file, 0);
if (ret < 0) {
goto exit;
}
@@ -906,8 +906,8 @@ static int coroutine_fn qcow_co_create(BlockdevCreateOptions *opts,
tmp = g_malloc0(BDRV_SECTOR_SIZE);
for (i = 0; i < DIV_ROUND_UP(sizeof(uint64_t) * l1_size, BDRV_SECTOR_SIZE);
i++) {
- ret = blk_pwrite(qcow_blk, header_size + BDRV_SECTOR_SIZE * i,
- BDRV_SECTOR_SIZE, tmp, 0);
+ ret = blk_co_pwrite(qcow_blk, header_size + BDRV_SECTOR_SIZE * i,
+ BDRV_SECTOR_SIZE, tmp, 0);
if (ret < 0) {
g_free(tmp);
goto exit;
--
2.37.3
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [PATCH 19/24] qcow2: switch to *_co_* functions
2022-10-13 12:36 [PATCH 00/24] More coroutine_fn fixes Paolo Bonzini
` (17 preceding siblings ...)
2022-10-13 12:37 ` [PATCH 18/24] qcow: " Paolo Bonzini
@ 2022-10-13 12:37 ` Paolo Bonzini
2022-10-27 17:05 ` Kevin Wolf
2022-10-13 12:37 ` [PATCH 20/24] qed: " Paolo Bonzini
` (5 subsequent siblings)
24 siblings, 1 reply; 28+ messages in thread
From: Paolo Bonzini @ 2022-10-13 12:37 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-block, afaria
From: Alberto Faria <afaria@redhat.com>
Signed-off-by: Alberto Faria <afaria@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
block/qcow2-cluster.c | 8 ++++----
block/qcow2-refcount.c | 10 +++++-----
block/qcow2-snapshot.c | 6 +++---
block/qcow2.c | 24 ++++++++++++------------
4 files changed, 24 insertions(+), 24 deletions(-)
diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
index 523c37215a..f480a29ae3 100644
--- a/block/qcow2-cluster.c
+++ b/block/qcow2-cluster.c
@@ -47,14 +47,14 @@ int coroutine_fn qcow2_shrink_l1_table(BlockDriverState *bs, uint64_t exact_size
#endif
BLKDBG_EVENT(bs->file, BLKDBG_L1_SHRINK_WRITE_TABLE);
- ret = bdrv_pwrite_zeroes(bs->file, s->l1_table_offset +
- new_l1_size * L1E_SIZE,
- (s->l1_size - new_l1_size) * L1E_SIZE, 0);
+ ret = bdrv_co_pwrite_zeroes(bs->file, s->l1_table_offset +
+ new_l1_size * L1E_SIZE,
+ (s->l1_size - new_l1_size) * L1E_SIZE, 0);
if (ret < 0) {
goto fail;
}
- ret = bdrv_flush(bs->file->bs);
+ ret = bdrv_co_flush(bs->file->bs);
if (ret < 0) {
goto fail;
}
diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c
index 38861ed7c8..c7cb48b0c4 100644
--- a/block/qcow2-refcount.c
+++ b/block/qcow2-refcount.c
@@ -118,8 +118,8 @@ int coroutine_fn qcow2_refcount_init(BlockDriverState *bs)
goto fail;
}
BLKDBG_EVENT(bs->file, BLKDBG_REFTABLE_LOAD);
- ret = bdrv_pread(bs->file, s->refcount_table_offset,
- refcount_table_size2, s->refcount_table, 0);
+ ret = bdrv_co_pread(bs->file, s->refcount_table_offset,
+ refcount_table_size2, s->refcount_table, 0);
if (ret < 0) {
goto fail;
}
@@ -3657,9 +3657,9 @@ int coroutine_fn qcow2_shrink_reftable(BlockDriverState *bs)
reftable_tmp[i] = unused_block ? 0 : cpu_to_be64(s->refcount_table[i]);
}
- ret = bdrv_pwrite_sync(bs->file, s->refcount_table_offset,
- s->refcount_table_size * REFTABLE_ENTRY_SIZE,
- reftable_tmp, 0);
+ ret = bdrv_co_pwrite_sync(bs->file, s->refcount_table_offset,
+ s->refcount_table_size * REFTABLE_ENTRY_SIZE,
+ reftable_tmp, 0);
/*
* If the write in the reftable failed the image may contain a partially
* overwritten reftable. In this case it would be better to clear the
diff --git a/block/qcow2-snapshot.c b/block/qcow2-snapshot.c
index d1d46facbf..62e8a0335d 100644
--- a/block/qcow2-snapshot.c
+++ b/block/qcow2-snapshot.c
@@ -441,9 +441,9 @@ int coroutine_fn qcow2_check_read_snapshot_table(BlockDriverState *bs,
} QEMU_PACKED snapshot_table_pointer;
/* qcow2_do_open() discards this information in check mode */
- ret = bdrv_pread(bs->file, offsetof(QCowHeader, nb_snapshots),
- sizeof(snapshot_table_pointer), &snapshot_table_pointer,
- 0);
+ ret = bdrv_co_pread(bs->file, offsetof(QCowHeader, nb_snapshots),
+ sizeof(snapshot_table_pointer), &snapshot_table_pointer,
+ 0);
if (ret < 0) {
result->check_errors++;
fprintf(stderr, "ERROR failed to read the snapshot table pointer from "
diff --git a/block/qcow2.c b/block/qcow2.c
index b7cac50eb3..8d6e576f28 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -1306,7 +1306,7 @@ static int coroutine_fn qcow2_do_open(BlockDriverState *bs, QDict *options,
uint64_t l1_vm_state_index;
bool update_header = false;
- ret = bdrv_pread(bs->file, 0, sizeof(header), &header, 0);
+ ret = bdrv_co_pread(bs->file, 0, sizeof(header), &header, 0);
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not read qcow2 header");
goto fail;
@@ -1382,9 +1382,9 @@ static int coroutine_fn qcow2_do_open(BlockDriverState *bs, QDict *options,
if (header.header_length > sizeof(header)) {
s->unknown_header_fields_size = header.header_length - sizeof(header);
s->unknown_header_fields = g_malloc(s->unknown_header_fields_size);
- ret = bdrv_pread(bs->file, sizeof(header),
- s->unknown_header_fields_size,
- s->unknown_header_fields, 0);
+ ret = bdrv_co_pread(bs->file, sizeof(header),
+ s->unknown_header_fields_size,
+ s->unknown_header_fields, 0);
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not read unknown qcow2 header "
"fields");
@@ -1579,8 +1579,8 @@ static int coroutine_fn qcow2_do_open(BlockDriverState *bs, QDict *options,
ret = -ENOMEM;
goto fail;
}
- ret = bdrv_pread(bs->file, s->l1_table_offset, s->l1_size * L1E_SIZE,
- s->l1_table, 0);
+ ret = bdrv_co_pread(bs->file, s->l1_table_offset, s->l1_size * L1E_SIZE,
+ s->l1_table, 0);
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not read L1 table");
goto fail;
@@ -1699,8 +1699,8 @@ static int coroutine_fn qcow2_do_open(BlockDriverState *bs, QDict *options,
}
s->image_backing_file = g_malloc(len + 1);
- ret = bdrv_pread(bs->file, header.backing_file_offset, len,
- s->image_backing_file, 0);
+ ret = bdrv_co_pread(bs->file, header.backing_file_offset, len,
+ bs->auto_backing_file, 0);
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not read backing file name");
goto fail;
@@ -3679,7 +3679,7 @@ qcow2_co_create(BlockdevCreateOptions *create_options, Error **errp)
cpu_to_be64(QCOW2_INCOMPAT_EXTL2);
}
- ret = blk_pwrite(blk, 0, cluster_size, header, 0);
+ ret = blk_co_pwrite(blk, 0, cluster_size, header, 0);
g_free(header);
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not write qcow2 header");
@@ -3689,7 +3689,7 @@ qcow2_co_create(BlockdevCreateOptions *create_options, Error **errp)
/* Write a refcount table with one refcount block */
refcount_table = g_malloc0(2 * cluster_size);
refcount_table[0] = cpu_to_be64(2 * cluster_size);
- ret = blk_pwrite(blk, cluster_size, 2 * cluster_size, refcount_table, 0);
+ ret = blk_co_pwrite(blk, cluster_size, 2 * cluster_size, refcount_table, 0);
g_free(refcount_table);
if (ret < 0) {
@@ -3744,8 +3744,8 @@ qcow2_co_create(BlockdevCreateOptions *create_options, Error **errp)
}
/* Okay, now that we have a valid image, let's give it the right size */
- ret = blk_truncate(blk, qcow2_opts->size, false, qcow2_opts->preallocation,
- 0, errp);
+ ret = blk_co_truncate(blk, qcow2_opts->size, false,
+ qcow2_opts->preallocation, 0, errp);
if (ret < 0) {
error_prepend(errp, "Could not resize image: ");
goto out;
--
2.37.3
^ permalink raw reply related [flat|nested] 28+ messages in thread
* Re: [PATCH 19/24] qcow2: switch to *_co_* functions
2022-10-13 12:37 ` [PATCH 19/24] qcow2: " Paolo Bonzini
@ 2022-10-27 17:05 ` Kevin Wolf
0 siblings, 0 replies; 28+ messages in thread
From: Kevin Wolf @ 2022-10-27 17:05 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: qemu-devel, qemu-block, afaria
Am 13.10.2022 um 14:37 hat Paolo Bonzini geschrieben:
> From: Alberto Faria <afaria@redhat.com>
>
> Signed-off-by: Alberto Faria <afaria@redhat.com>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> @@ -1699,8 +1699,8 @@ static int coroutine_fn qcow2_do_open(BlockDriverState *bs, QDict *options,
> }
>
> s->image_backing_file = g_malloc(len + 1);
> - ret = bdrv_pread(bs->file, header.backing_file_offset, len,
> - s->image_backing_file, 0);
> + ret = bdrv_co_pread(bs->file, header.backing_file_offset, len,
> + bs->auto_backing_file, 0);
This was an incorrect conflict resolution, it reverts part of commit
ec64b1ca081 (s->image_backing_file vs. bs->auto_backing_file).
I'll fix this while applying.
Kevin
^ permalink raw reply [flat|nested] 28+ messages in thread
* [PATCH 20/24] qed: switch to *_co_* functions
2022-10-13 12:36 [PATCH 00/24] More coroutine_fn fixes Paolo Bonzini
` (18 preceding siblings ...)
2022-10-13 12:37 ` [PATCH 19/24] qcow2: " Paolo Bonzini
@ 2022-10-13 12:37 ` Paolo Bonzini
2022-10-13 12:37 ` [PATCH 21/24] vdi: " Paolo Bonzini
` (4 subsequent siblings)
24 siblings, 0 replies; 28+ messages in thread
From: Paolo Bonzini @ 2022-10-13 12:37 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-block, afaria
From: Alberto Faria <afaria@redhat.com>
Signed-off-by: Alberto Faria <afaria@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
block/qed-table.c | 2 +-
block/qed.c | 12 ++++++------
2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/block/qed-table.c b/block/qed-table.c
index 1cc844b1a5..aa203f2627 100644
--- a/block/qed-table.c
+++ b/block/qed-table.c
@@ -100,7 +100,7 @@ static int coroutine_fn qed_write_table(BDRVQEDState *s, uint64_t offset,
}
if (flush) {
- ret = bdrv_flush(s->bs);
+ ret = bdrv_co_flush(s->bs);
if (ret < 0) {
goto out;
}
diff --git a/block/qed.c b/block/qed.c
index bda00e6257..90682f7a15 100644
--- a/block/qed.c
+++ b/block/qed.c
@@ -387,7 +387,7 @@ static int coroutine_fn bdrv_qed_do_open(BlockDriverState *bs, QDict *options,
int64_t file_size;
int ret;
- ret = bdrv_pread(bs->file, 0, sizeof(le_header), &le_header, 0);
+ ret = bdrv_co_pread(bs->file, 0, sizeof(le_header), &le_header, 0);
if (ret < 0) {
error_setg(errp, "Failed to read QED header");
return ret;
@@ -492,7 +492,7 @@ static int coroutine_fn bdrv_qed_do_open(BlockDriverState *bs, QDict *options,
}
/* From here on only known autoclear feature bits are valid */
- bdrv_flush(bs->file->bs);
+ bdrv_co_flush(bs->file->bs);
}
s->l1_table = qed_alloc_table(s);
@@ -693,7 +693,7 @@ static int coroutine_fn bdrv_qed_co_create(BlockdevCreateOptions *opts,
* The QED format associates file length with allocation status,
* so a new file (which is empty) must have a length of 0.
*/
- ret = blk_truncate(blk, 0, true, PREALLOC_MODE_OFF, 0, errp);
+ ret = blk_co_truncate(blk, 0, true, PREALLOC_MODE_OFF, 0, errp);
if (ret < 0) {
goto out;
}
@@ -712,18 +712,18 @@ static int coroutine_fn bdrv_qed_co_create(BlockdevCreateOptions *opts,
}
qed_header_cpu_to_le(&header, &le_header);
- ret = blk_pwrite(blk, 0, sizeof(le_header), &le_header, 0);
+ ret = blk_co_pwrite(blk, 0, sizeof(le_header), &le_header, 0);
if (ret < 0) {
goto out;
}
- ret = blk_pwrite(blk, sizeof(le_header), header.backing_filename_size,
+ ret = blk_co_pwrite(blk, sizeof(le_header), header.backing_filename_size,
qed_opts->backing_file, 0);
if (ret < 0) {
goto out;
}
l1_table = g_malloc0(l1_size);
- ret = blk_pwrite(blk, header.l1_table_offset, l1_size, l1_table, 0);
+ ret = blk_co_pwrite(blk, header.l1_table_offset, l1_size, l1_table, 0);
if (ret < 0) {
goto out;
}
--
2.37.3
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [PATCH 21/24] vdi: switch to *_co_* functions
2022-10-13 12:36 [PATCH 00/24] More coroutine_fn fixes Paolo Bonzini
` (19 preceding siblings ...)
2022-10-13 12:37 ` [PATCH 20/24] qed: " Paolo Bonzini
@ 2022-10-13 12:37 ` Paolo Bonzini
2022-10-13 12:37 ` [PATCH 22/24] vhdx: " Paolo Bonzini
` (3 subsequent siblings)
24 siblings, 0 replies; 28+ messages in thread
From: Paolo Bonzini @ 2022-10-13 12:37 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-block, afaria
From: Alberto Faria <afaria@redhat.com>
Signed-off-by: Alberto Faria <afaria@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
block/vdi.c | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/block/vdi.c b/block/vdi.c
index e942325455..2ecf47216a 100644
--- a/block/vdi.c
+++ b/block/vdi.c
@@ -664,7 +664,8 @@ vdi_co_pwritev(BlockDriverState *bs, int64_t offset, int64_t bytes,
* so this full-cluster write does not overlap a partial write
* of the same cluster, issued from the "else" branch.
*/
- ret = bdrv_pwrite(bs->file, data_offset, s->block_size, block, 0);
+ ret = bdrv_co_pwrite(bs->file, data_offset, s->block_size, block,
+ 0);
qemu_co_rwlock_unlock(&s->bmap_lock);
} else {
nonallocating_write:
@@ -709,7 +710,7 @@ nonallocating_write:
assert(VDI_IS_ALLOCATED(bmap_first));
*header = s->header;
vdi_header_to_le(header);
- ret = bdrv_pwrite(bs->file, 0, sizeof(*header), header, 0);
+ ret = bdrv_co_pwrite(bs->file, 0, sizeof(*header), header, 0);
g_free(header);
if (ret < 0) {
@@ -726,8 +727,8 @@ nonallocating_write:
base = ((uint8_t *)&s->bmap[0]) + bmap_first * SECTOR_SIZE;
logout("will write %u block map sectors starting from entry %u\n",
n_sectors, bmap_first);
- ret = bdrv_pwrite(bs->file, offset * SECTOR_SIZE,
- n_sectors * SECTOR_SIZE, base, 0);
+ ret = bdrv_co_pwrite(bs->file, offset * SECTOR_SIZE,
+ n_sectors * SECTOR_SIZE, base, 0);
}
return ret;
@@ -845,7 +846,7 @@ static int coroutine_fn vdi_co_do_create(BlockdevCreateOptions *create_options,
vdi_header_print(&header);
}
vdi_header_to_le(&header);
- ret = blk_pwrite(blk, offset, sizeof(header), &header, 0);
+ ret = blk_co_pwrite(blk, offset, sizeof(header), &header, 0);
if (ret < 0) {
error_setg(errp, "Error writing header");
goto exit;
@@ -866,7 +867,7 @@ static int coroutine_fn vdi_co_do_create(BlockdevCreateOptions *create_options,
bmap[i] = VDI_UNALLOCATED;
}
}
- ret = blk_pwrite(blk, offset, bmap_size, bmap, 0);
+ ret = blk_co_pwrite(blk, offset, bmap_size, bmap, 0);
if (ret < 0) {
error_setg(errp, "Error writing bmap");
goto exit;
@@ -875,8 +876,8 @@ static int coroutine_fn vdi_co_do_create(BlockdevCreateOptions *create_options,
}
if (image_type == VDI_TYPE_STATIC) {
- ret = blk_truncate(blk, offset + blocks * block_size, false,
- PREALLOC_MODE_OFF, 0, errp);
+ ret = blk_co_truncate(blk, offset + blocks * block_size, false,
+ PREALLOC_MODE_OFF, 0, errp);
if (ret < 0) {
error_prepend(errp, "Failed to statically allocate file");
goto exit;
--
2.37.3
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [PATCH 22/24] vhdx: switch to *_co_* functions
2022-10-13 12:36 [PATCH 00/24] More coroutine_fn fixes Paolo Bonzini
` (20 preceding siblings ...)
2022-10-13 12:37 ` [PATCH 21/24] vdi: " Paolo Bonzini
@ 2022-10-13 12:37 ` Paolo Bonzini
2022-10-13 12:37 ` [PATCH 23/24] vmdk: " Paolo Bonzini
` (2 subsequent siblings)
24 siblings, 0 replies; 28+ messages in thread
From: Paolo Bonzini @ 2022-10-13 12:37 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-block, afaria
From: Alberto Faria <afaria@redhat.com>
Signed-off-by: Alberto Faria <afaria@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
block/vhdx.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/block/vhdx.c b/block/vhdx.c
index e10e78ebfd..f7dd4eb092 100644
--- a/block/vhdx.c
+++ b/block/vhdx.c
@@ -2012,15 +2012,15 @@ static int coroutine_fn vhdx_co_create(BlockdevCreateOptions *opts,
creator = g_utf8_to_utf16("QEMU v" QEMU_VERSION, -1, NULL,
&creator_items, NULL);
signature = cpu_to_le64(VHDX_FILE_SIGNATURE);
- ret = blk_pwrite(blk, VHDX_FILE_ID_OFFSET, sizeof(signature), &signature,
- 0);
+ ret = blk_co_pwrite(blk, VHDX_FILE_ID_OFFSET, sizeof(signature), &signature,
+ 0);
if (ret < 0) {
error_setg_errno(errp, -ret, "Failed to write file signature");
goto delete_and_exit;
}
if (creator) {
- ret = blk_pwrite(blk, VHDX_FILE_ID_OFFSET + sizeof(signature),
- creator_items * sizeof(gunichar2), creator, 0);
+ ret = blk_co_pwrite(blk, VHDX_FILE_ID_OFFSET + sizeof(signature),
+ creator_items * sizeof(gunichar2), creator, 0);
if (ret < 0) {
error_setg_errno(errp, -ret, "Failed to write creator field");
goto delete_and_exit;
--
2.37.3
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [PATCH 23/24] vmdk: switch to *_co_* functions
2022-10-13 12:36 [PATCH 00/24] More coroutine_fn fixes Paolo Bonzini
` (21 preceding siblings ...)
2022-10-13 12:37 ` [PATCH 22/24] vhdx: " Paolo Bonzini
@ 2022-10-13 12:37 ` Paolo Bonzini
2022-10-27 17:07 ` Kevin Wolf
2022-10-13 12:37 ` [PATCH 24/24] monitor: " Paolo Bonzini
2022-10-27 17:15 ` [PATCH 00/24] More coroutine_fn fixes Kevin Wolf
24 siblings, 1 reply; 28+ messages in thread
From: Paolo Bonzini @ 2022-10-13 12:37 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-block, afaria
From: Alberto Faria <afaria@redhat.com>
Signed-off-by: Alberto Faria <afaria@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
block/vmdk.c | 56 ++++++++++++++++++++++++++--------------------------
1 file changed, 28 insertions(+), 28 deletions(-)
diff --git a/block/vmdk.c b/block/vmdk.c
index c720376aa5..2802501466 100644
--- a/block/vmdk.c
+++ b/block/vmdk.c
@@ -1441,16 +1441,16 @@ static int coroutine_fn get_whole_cluster(BlockDriverState *bs,
if (copy_from_backing) {
/* qcow2 emits this on bs->file instead of bs->backing */
BLKDBG_EVENT(extent->file, BLKDBG_COW_READ);
- ret = bdrv_pread(bs->backing, offset, skip_start_bytes,
- whole_grain, 0);
+ ret = bdrv_co_pread(bs->backing, offset, skip_start_bytes,
+ whole_grain, 0);
if (ret < 0) {
ret = VMDK_ERROR;
goto exit;
}
}
BLKDBG_EVENT(extent->file, BLKDBG_COW_WRITE);
- ret = bdrv_pwrite(extent->file, cluster_offset, skip_start_bytes,
- whole_grain, 0);
+ ret = bdrv_co_pwrite(extent->file, cluster_offset, skip_start_bytes,
+ whole_grain, 0);
if (ret < 0) {
ret = VMDK_ERROR;
goto exit;
@@ -1461,18 +1461,18 @@ static int coroutine_fn get_whole_cluster(BlockDriverState *bs,
if (copy_from_backing) {
/* qcow2 emits this on bs->file instead of bs->backing */
BLKDBG_EVENT(extent->file, BLKDBG_COW_READ);
- ret = bdrv_pread(bs->backing, offset + skip_end_bytes,
- cluster_bytes - skip_end_bytes,
- whole_grain + skip_end_bytes, 0);
+ ret = bdrv_co_pread(bs->backing, offset + skip_end_bytes,
+ cluster_bytes - skip_end_bytes,
+ whole_grain + skip_end_bytes, 0);
if (ret < 0) {
ret = VMDK_ERROR;
goto exit;
}
}
BLKDBG_EVENT(extent->file, BLKDBG_COW_WRITE);
- ret = bdrv_pwrite(extent->file, cluster_offset + skip_end_bytes,
- cluster_bytes - skip_end_bytes,
- whole_grain + skip_end_bytes, 0);
+ ret = bdrv_co_pwrite(extent->file, cluster_offset + skip_end_bytes,
+ cluster_bytes - skip_end_bytes,
+ whole_grain + skip_end_bytes, 0);
if (ret < 0) {
ret = VMDK_ERROR;
goto exit;
@@ -1491,23 +1491,23 @@ static int coroutine_fn vmdk_L2update(VmdkExtent *extent, VmdkMetaData *m_data,
offset = cpu_to_le32(offset);
/* update L2 table */
BLKDBG_EVENT(extent->file, BLKDBG_L2_UPDATE);
- if (bdrv_pwrite(extent->file,
- ((int64_t)m_data->l2_offset * 512)
- + (m_data->l2_index * sizeof(offset)),
- sizeof(offset), &offset, 0) < 0) {
+ if (bdrv_co_pwrite(extent->file,
+ ((int64_t)m_data->l2_offset * 512)
+ + (m_data->l2_index * sizeof(offset)),
+ sizeof(offset), &offset, 0) < 0) {
return VMDK_ERROR;
}
/* update backup L2 table */
if (extent->l1_backup_table_offset != 0) {
m_data->l2_offset = extent->l1_backup_table[m_data->l1_index];
- if (bdrv_pwrite(extent->file,
- ((int64_t)m_data->l2_offset * 512)
- + (m_data->l2_index * sizeof(offset)),
- sizeof(offset), &offset, 0) < 0) {
+ if (bdrv_co_pwrite(extent->file,
+ ((int64_t)m_data->l2_offset * 512)
+ + (m_data->l2_index * sizeof(offset)),
+ sizeof(offset), &offset, 0) < 0) {
return VMDK_ERROR;
}
}
- if (bdrv_flush(extent->file->bs) < 0) {
+ if (bdrv_co_flush(extent->file->bs) < 0) {
return VMDK_ERROR;
}
if (m_data->l2_cache_entry) {
@@ -1624,12 +1624,11 @@ static int coroutine_fn get_cluster_offset(BlockDriverState *bs,
}
l2_table = (char *)extent->l2_cache + (min_index * l2_size_bytes);
BLKDBG_EVENT(extent->file, BLKDBG_L2_LOAD);
- if (bdrv_pread(extent->file,
+ if (bdrv_co_pread(extent->file,
(int64_t)l2_offset * 512,
l2_size_bytes,
- l2_table,
- 0
- ) < 0) {
+ l2_table, 0
+ ) != l2_size_bytes) {
return VMDK_ERROR;
}
@@ -1899,7 +1898,8 @@ vmdk_read_extent(VmdkExtent *extent, int64_t cluster_offset,
cluster_buf = g_malloc(buf_bytes);
uncomp_buf = g_malloc(cluster_bytes);
BLKDBG_EVENT(extent->file, BLKDBG_READ_COMPRESSED);
- ret = bdrv_pread(extent->file, cluster_offset, buf_bytes, cluster_buf, 0);
+ ret = bdrv_co_pread(extent->file, cluster_offset, buf_bytes, cluster_buf,
+ 0);
if (ret < 0) {
goto out;
}
@@ -2144,8 +2144,8 @@ vmdk_co_pwritev_compressed(BlockDriverState *bs, int64_t offset, int64_t bytes,
return length;
}
length = QEMU_ALIGN_UP(length, BDRV_SECTOR_SIZE);
- ret = bdrv_truncate(s->extents[i].file, length, false,
- PREALLOC_MODE_OFF, 0, NULL);
+ ret = bdrv_co_truncate(s->extents[i].file, length, false,
+ PREALLOC_MODE_OFF, 0, NULL);
if (ret < 0) {
return ret;
}
@@ -2586,7 +2586,7 @@ static int coroutine_fn vmdk_co_do_create(int64_t size,
desc_offset = 0x200;
}
- ret = blk_pwrite(blk, desc_offset, desc_len, desc, 0);
+ ret = blk_co_pwrite(blk, desc_offset, desc_len, desc, 0);
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not write description");
goto exit;
@@ -2594,7 +2594,7 @@ static int coroutine_fn vmdk_co_do_create(int64_t size,
/* bdrv_pwrite write padding zeros to align to sector, we don't need that
* for description file */
if (desc_offset == 0) {
- ret = blk_truncate(blk, desc_len, false, PREALLOC_MODE_OFF, 0, errp);
+ ret = blk_co_truncate(blk, desc_len, false, PREALLOC_MODE_OFF, 0, errp);
if (ret < 0) {
goto exit;
}
--
2.37.3
^ permalink raw reply related [flat|nested] 28+ messages in thread
* Re: [PATCH 23/24] vmdk: switch to *_co_* functions
2022-10-13 12:37 ` [PATCH 23/24] vmdk: " Paolo Bonzini
@ 2022-10-27 17:07 ` Kevin Wolf
0 siblings, 0 replies; 28+ messages in thread
From: Kevin Wolf @ 2022-10-27 17:07 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: qemu-devel, qemu-block, afaria
Am 13.10.2022 um 14:37 hat Paolo Bonzini geschrieben:
> From: Alberto Faria <afaria@redhat.com>
>
> Signed-off-by: Alberto Faria <afaria@redhat.com>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> @@ -1624,12 +1624,11 @@ static int coroutine_fn get_cluster_offset(BlockDriverState *bs,
> }
> l2_table = (char *)extent->l2_cache + (min_index * l2_size_bytes);
> BLKDBG_EVENT(extent->file, BLKDBG_L2_LOAD);
> - if (bdrv_pread(extent->file,
> + if (bdrv_co_pread(extent->file,
> (int64_t)l2_offset * 512,
> l2_size_bytes,
> - l2_table,
> - 0
> - ) < 0) {
> + l2_table, 0
> + ) != l2_size_bytes) {
Another incorrect conflict resolution, this would revert part of commit
353a5d84b25. Fixing it up as well.
Kevin
^ permalink raw reply [flat|nested] 28+ messages in thread
* [PATCH 24/24] monitor: switch to *_co_* functions
2022-10-13 12:36 [PATCH 00/24] More coroutine_fn fixes Paolo Bonzini
` (22 preceding siblings ...)
2022-10-13 12:37 ` [PATCH 23/24] vmdk: " Paolo Bonzini
@ 2022-10-13 12:37 ` Paolo Bonzini
2022-10-27 17:15 ` [PATCH 00/24] More coroutine_fn fixes Kevin Wolf
24 siblings, 0 replies; 28+ messages in thread
From: Paolo Bonzini @ 2022-10-13 12:37 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-block, afaria
From: Alberto Faria <afaria@redhat.com>
Signed-off-by: Alberto Faria <afaria@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
blockdev.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/blockdev.c b/blockdev.c
index a32bafc07a..47d47d5b18 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -2448,7 +2448,7 @@ void coroutine_fn qmp_block_resize(bool has_device, const char *device,
bdrv_co_unlock(bs);
old_ctx = bdrv_co_enter(bs);
- blk_truncate(blk, size, false, PREALLOC_MODE_OFF, 0, errp);
+ blk_co_truncate(blk, size, false, PREALLOC_MODE_OFF, 0, errp);
bdrv_co_leave(bs, old_ctx);
bdrv_co_lock(bs);
--
2.37.3
^ permalink raw reply related [flat|nested] 28+ messages in thread
* Re: [PATCH 00/24] More coroutine_fn fixes
2022-10-13 12:36 [PATCH 00/24] More coroutine_fn fixes Paolo Bonzini
` (23 preceding siblings ...)
2022-10-13 12:37 ` [PATCH 24/24] monitor: " Paolo Bonzini
@ 2022-10-27 17:15 ` Kevin Wolf
24 siblings, 0 replies; 28+ messages in thread
From: Kevin Wolf @ 2022-10-27 17:15 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: qemu-devel, qemu-block, afaria
Am 13.10.2022 um 14:36 hat Paolo Bonzini geschrieben:
> Most of these were extracted from Alberto's static analysis series.
> After this series, the only errors reported by the analyzer are:
>
> - a call to bs->drv->bdrv_co_drain_begin from bdrv_open_driver. This
> relies on bdrv_co_drain_begin not having to yield, which is indeed the
> case right after opening but is iffy
>
> - assigning coroutine_fn to non-coroutine_fn in the human monitor
> for the two coroutine commands screendump and block_resize.
Thanks, fixed up coding style warnings in checkpatch and the mismerges
in patches 19 and 23, and applied to the block branch.
Kevin
^ permalink raw reply [flat|nested] 28+ messages in thread