mirror of https://github.com/xemu-project/xemu.git
block: Call .bdrv_co_create(_opts) unlocked
These are functions that modify the graph, so they must be able to take
a writer lock. This is impossible if they already hold the reader lock.
If they need a reader lock for some of their operations, they should
take it internally.
Many of them go through blk_*(), which will always take the lock itself.
Direct calls of bdrv_*() need to take the reader lock. Note that while
locking for bdrv_co_*() calls is checked by TSA, this is not the case
for the mixed_coroutine_fns bdrv_*(). Holding the lock is still required
when they are called from coroutine context like here!
This effectively reverts 4ec8df0183
, but adds some internal locking
instead.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Message-Id: <20230510203601.418015-2-kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
parent
41f8b63339
commit
4db7ba3b87
1
block.c
1
block.c
|
@ -533,7 +533,6 @@ int coroutine_fn bdrv_co_create(BlockDriver *drv, const char *filename,
|
||||||
int ret;
|
int ret;
|
||||||
GLOBAL_STATE_CODE();
|
GLOBAL_STATE_CODE();
|
||||||
ERRP_GUARD();
|
ERRP_GUARD();
|
||||||
assert_bdrv_graph_readable();
|
|
||||||
|
|
||||||
if (!drv->bdrv_co_create_opts) {
|
if (!drv->bdrv_co_create_opts) {
|
||||||
error_setg(errp, "Driver '%s' does not support image creation",
|
error_setg(errp, "Driver '%s' does not support image creation",
|
||||||
|
|
|
@ -43,7 +43,6 @@ static int coroutine_fn blockdev_create_run(Job *job, Error **errp)
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
GLOBAL_STATE_CODE();
|
GLOBAL_STATE_CODE();
|
||||||
GRAPH_RDLOCK_GUARD();
|
|
||||||
|
|
||||||
job_progress_set_remaining(&s->common, 1);
|
job_progress_set_remaining(&s->common, 1);
|
||||||
ret = s->drv->bdrv_co_create(s->opts, errp);
|
ret = s->drv->bdrv_co_create(s->opts, errp);
|
||||||
|
|
|
@ -99,12 +99,10 @@ struct BlockCryptoCreateData {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
static int block_crypto_create_write_func(QCryptoBlock *block,
|
static int coroutine_fn GRAPH_UNLOCKED
|
||||||
size_t offset,
|
block_crypto_create_write_func(QCryptoBlock *block, size_t offset,
|
||||||
const uint8_t *buf,
|
const uint8_t *buf, size_t buflen, void *opaque,
|
||||||
size_t buflen,
|
Error **errp)
|
||||||
void *opaque,
|
|
||||||
Error **errp)
|
|
||||||
{
|
{
|
||||||
struct BlockCryptoCreateData *data = opaque;
|
struct BlockCryptoCreateData *data = opaque;
|
||||||
ssize_t ret;
|
ssize_t ret;
|
||||||
|
@ -117,10 +115,9 @@ static int block_crypto_create_write_func(QCryptoBlock *block,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int block_crypto_create_init_func(QCryptoBlock *block,
|
static int coroutine_fn GRAPH_UNLOCKED
|
||||||
size_t headerlen,
|
block_crypto_create_init_func(QCryptoBlock *block, size_t headerlen,
|
||||||
void *opaque,
|
void *opaque, Error **errp)
|
||||||
Error **errp)
|
|
||||||
{
|
{
|
||||||
struct BlockCryptoCreateData *data = opaque;
|
struct BlockCryptoCreateData *data = opaque;
|
||||||
Error *local_error = NULL;
|
Error *local_error = NULL;
|
||||||
|
@ -314,7 +311,7 @@ static int block_crypto_open_generic(QCryptoBlockFormat format,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int coroutine_fn
|
static int coroutine_fn GRAPH_UNLOCKED
|
||||||
block_crypto_co_create_generic(BlockDriverState *bs, int64_t size,
|
block_crypto_co_create_generic(BlockDriverState *bs, int64_t size,
|
||||||
QCryptoBlockCreateOptions *opts,
|
QCryptoBlockCreateOptions *opts,
|
||||||
PreallocMode prealloc, Error **errp)
|
PreallocMode prealloc, Error **errp)
|
||||||
|
@ -627,7 +624,7 @@ static int block_crypto_open_luks(BlockDriverState *bs,
|
||||||
bs, options, flags, errp);
|
bs, options, flags, errp);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int coroutine_fn
|
static int coroutine_fn GRAPH_UNLOCKED
|
||||||
block_crypto_co_create_luks(BlockdevCreateOptions *create_options, Error **errp)
|
block_crypto_co_create_luks(BlockdevCreateOptions *create_options, Error **errp)
|
||||||
{
|
{
|
||||||
BlockdevCreateOptionsLUKS *luks_opts;
|
BlockdevCreateOptionsLUKS *luks_opts;
|
||||||
|
@ -665,7 +662,7 @@ fail:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int coroutine_fn GRAPH_RDLOCK
|
static int coroutine_fn GRAPH_UNLOCKED
|
||||||
block_crypto_co_create_opts_luks(BlockDriver *drv, const char *filename,
|
block_crypto_co_create_opts_luks(BlockDriver *drv, const char *filename,
|
||||||
QemuOpts *opts, Error **errp)
|
QemuOpts *opts, Error **errp)
|
||||||
{
|
{
|
||||||
|
@ -727,7 +724,9 @@ fail:
|
||||||
* beforehand, it has been truncated and corrupted in the process.
|
* beforehand, it has been truncated and corrupted in the process.
|
||||||
*/
|
*/
|
||||||
if (ret) {
|
if (ret) {
|
||||||
|
bdrv_graph_co_rdlock();
|
||||||
bdrv_co_delete_file_noerr(bs);
|
bdrv_co_delete_file_noerr(bs);
|
||||||
|
bdrv_graph_co_rdunlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
bdrv_co_unref(bs);
|
bdrv_co_unref(bs);
|
||||||
|
|
|
@ -522,8 +522,8 @@ out:
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int coroutine_fn parallels_co_create(BlockdevCreateOptions* opts,
|
static int coroutine_fn GRAPH_UNLOCKED
|
||||||
Error **errp)
|
parallels_co_create(BlockdevCreateOptions* opts, Error **errp)
|
||||||
{
|
{
|
||||||
BlockdevCreateOptionsParallels *parallels_opts;
|
BlockdevCreateOptionsParallels *parallels_opts;
|
||||||
BlockDriverState *bs;
|
BlockDriverState *bs;
|
||||||
|
@ -622,7 +622,7 @@ exit:
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int coroutine_fn GRAPH_RDLOCK
|
static int coroutine_fn GRAPH_UNLOCKED
|
||||||
parallels_co_create_opts(BlockDriver *drv, const char *filename,
|
parallels_co_create_opts(BlockDriver *drv, const char *filename,
|
||||||
QemuOpts *opts, Error **errp)
|
QemuOpts *opts, Error **errp)
|
||||||
{
|
{
|
||||||
|
|
|
@ -800,8 +800,8 @@ static void qcow_close(BlockDriverState *bs)
|
||||||
error_free(s->migration_blocker);
|
error_free(s->migration_blocker);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int coroutine_fn qcow_co_create(BlockdevCreateOptions *opts,
|
static int coroutine_fn GRAPH_UNLOCKED
|
||||||
Error **errp)
|
qcow_co_create(BlockdevCreateOptions *opts, Error **errp)
|
||||||
{
|
{
|
||||||
BlockdevCreateOptionsQcow *qcow_opts;
|
BlockdevCreateOptionsQcow *qcow_opts;
|
||||||
int header_size, backing_filename_len, l1_size, shift, i;
|
int header_size, backing_filename_len, l1_size, shift, i;
|
||||||
|
@ -921,7 +921,7 @@ exit:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int coroutine_fn GRAPH_RDLOCK
|
static int coroutine_fn GRAPH_UNLOCKED
|
||||||
qcow_co_create_opts(BlockDriver *drv, const char *filename,
|
qcow_co_create_opts(BlockDriver *drv, const char *filename,
|
||||||
QemuOpts *opts, Error **errp)
|
QemuOpts *opts, Error **errp)
|
||||||
{
|
{
|
||||||
|
|
|
@ -118,8 +118,9 @@ static int qcow2_crypto_hdr_read_func(QCryptoBlock *block, size_t offset,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int qcow2_crypto_hdr_init_func(QCryptoBlock *block, size_t headerlen,
|
static int coroutine_fn GRAPH_RDLOCK
|
||||||
void *opaque, Error **errp)
|
qcow2_crypto_hdr_init_func(QCryptoBlock *block, size_t headerlen, void *opaque,
|
||||||
|
Error **errp)
|
||||||
{
|
{
|
||||||
BlockDriverState *bs = opaque;
|
BlockDriverState *bs = opaque;
|
||||||
BDRVQcow2State *s = bs->opaque;
|
BDRVQcow2State *s = bs->opaque;
|
||||||
|
@ -144,9 +145,7 @@ static int qcow2_crypto_hdr_init_func(QCryptoBlock *block, size_t headerlen,
|
||||||
*/
|
*/
|
||||||
clusterlen = size_to_clusters(s, headerlen) * s->cluster_size;
|
clusterlen = size_to_clusters(s, headerlen) * s->cluster_size;
|
||||||
assert(qcow2_pre_write_overlap_check(bs, 0, ret, clusterlen, false) == 0);
|
assert(qcow2_pre_write_overlap_check(bs, 0, ret, clusterlen, false) == 0);
|
||||||
ret = bdrv_pwrite_zeroes(bs->file,
|
ret = bdrv_co_pwrite_zeroes(bs->file, ret, clusterlen, 0);
|
||||||
ret,
|
|
||||||
clusterlen, 0);
|
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
error_setg_errno(errp, -ret, "Could not zero fill encryption header");
|
error_setg_errno(errp, -ret, "Could not zero fill encryption header");
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -156,9 +155,11 @@ static int qcow2_crypto_hdr_init_func(QCryptoBlock *block, size_t headerlen,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int qcow2_crypto_hdr_write_func(QCryptoBlock *block, size_t offset,
|
/* The graph lock must be held when called in coroutine context */
|
||||||
const uint8_t *buf, size_t buflen,
|
static int coroutine_mixed_fn
|
||||||
void *opaque, Error **errp)
|
qcow2_crypto_hdr_write_func(QCryptoBlock *block, size_t offset,
|
||||||
|
const uint8_t *buf, size_t buflen,
|
||||||
|
void *opaque, Error **errp)
|
||||||
{
|
{
|
||||||
BlockDriverState *bs = opaque;
|
BlockDriverState *bs = opaque;
|
||||||
BDRVQcow2State *s = bs->opaque;
|
BDRVQcow2State *s = bs->opaque;
|
||||||
|
@ -3137,9 +3138,10 @@ static int qcow2_change_backing_file(BlockDriverState *bs,
|
||||||
return qcow2_update_header(bs);
|
return qcow2_update_header(bs);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int qcow2_set_up_encryption(BlockDriverState *bs,
|
static int coroutine_fn GRAPH_RDLOCK
|
||||||
QCryptoBlockCreateOptions *cryptoopts,
|
qcow2_set_up_encryption(BlockDriverState *bs,
|
||||||
Error **errp)
|
QCryptoBlockCreateOptions *cryptoopts,
|
||||||
|
Error **errp)
|
||||||
{
|
{
|
||||||
BDRVQcow2State *s = bs->opaque;
|
BDRVQcow2State *s = bs->opaque;
|
||||||
QCryptoBlock *crypto = NULL;
|
QCryptoBlock *crypto = NULL;
|
||||||
|
@ -3426,7 +3428,7 @@ static uint64_t qcow2_opt_get_refcount_bits_del(QemuOpts *opts, int version,
|
||||||
return refcount_bits;
|
return refcount_bits;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int coroutine_fn
|
static int coroutine_fn GRAPH_UNLOCKED
|
||||||
qcow2_co_create(BlockdevCreateOptions *create_options, Error **errp)
|
qcow2_co_create(BlockdevCreateOptions *create_options, Error **errp)
|
||||||
{
|
{
|
||||||
BlockdevCreateOptionsQcow2 *qcow2_opts;
|
BlockdevCreateOptionsQcow2 *qcow2_opts;
|
||||||
|
@ -3724,8 +3726,10 @@ qcow2_co_create(BlockdevCreateOptions *create_options, Error **errp)
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bdrv_graph_co_rdlock();
|
||||||
ret = qcow2_alloc_clusters(blk_bs(blk), 3 * cluster_size);
|
ret = qcow2_alloc_clusters(blk_bs(blk), 3 * cluster_size);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
|
bdrv_graph_co_rdunlock();
|
||||||
error_setg_errno(errp, -ret, "Could not allocate clusters for qcow2 "
|
error_setg_errno(errp, -ret, "Could not allocate clusters for qcow2 "
|
||||||
"header and refcount table");
|
"header and refcount table");
|
||||||
goto out;
|
goto out;
|
||||||
|
@ -3743,6 +3747,8 @@ qcow2_co_create(BlockdevCreateOptions *create_options, Error **errp)
|
||||||
|
|
||||||
/* Create a full header (including things like feature table) */
|
/* Create a full header (including things like feature table) */
|
||||||
ret = qcow2_update_header(blk_bs(blk));
|
ret = qcow2_update_header(blk_bs(blk));
|
||||||
|
bdrv_graph_co_rdunlock();
|
||||||
|
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
error_setg_errno(errp, -ret, "Could not update qcow2 header");
|
error_setg_errno(errp, -ret, "Could not update qcow2 header");
|
||||||
goto out;
|
goto out;
|
||||||
|
@ -3776,7 +3782,10 @@ qcow2_co_create(BlockdevCreateOptions *create_options, Error **errp)
|
||||||
|
|
||||||
/* Want encryption? There you go. */
|
/* Want encryption? There you go. */
|
||||||
if (qcow2_opts->encrypt) {
|
if (qcow2_opts->encrypt) {
|
||||||
|
bdrv_graph_co_rdlock();
|
||||||
ret = qcow2_set_up_encryption(blk_bs(blk), qcow2_opts->encrypt, errp);
|
ret = qcow2_set_up_encryption(blk_bs(blk), qcow2_opts->encrypt, errp);
|
||||||
|
bdrv_graph_co_rdunlock();
|
||||||
|
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
@ -3813,7 +3822,7 @@ out:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int coroutine_fn GRAPH_RDLOCK
|
static int coroutine_fn GRAPH_UNLOCKED
|
||||||
qcow2_co_create_opts(BlockDriver *drv, const char *filename, QemuOpts *opts,
|
qcow2_co_create_opts(BlockDriver *drv, const char *filename, QemuOpts *opts,
|
||||||
Error **errp)
|
Error **errp)
|
||||||
{
|
{
|
||||||
|
@ -3933,8 +3942,10 @@ qcow2_co_create_opts(BlockDriver *drv, const char *filename, QemuOpts *opts,
|
||||||
ret = qcow2_co_create(create_options, errp);
|
ret = qcow2_co_create(create_options, errp);
|
||||||
finish:
|
finish:
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
|
bdrv_graph_co_rdlock();
|
||||||
bdrv_co_delete_file_noerr(bs);
|
bdrv_co_delete_file_noerr(bs);
|
||||||
bdrv_co_delete_file_noerr(data_bs);
|
bdrv_co_delete_file_noerr(data_bs);
|
||||||
|
bdrv_graph_co_rdunlock();
|
||||||
} else {
|
} else {
|
||||||
ret = 0;
|
ret = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -630,8 +630,8 @@ static void bdrv_qed_close(BlockDriverState *bs)
|
||||||
qemu_vfree(s->l1_table);
|
qemu_vfree(s->l1_table);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int coroutine_fn bdrv_qed_co_create(BlockdevCreateOptions *opts,
|
static int coroutine_fn GRAPH_UNLOCKED
|
||||||
Error **errp)
|
bdrv_qed_co_create(BlockdevCreateOptions *opts, Error **errp)
|
||||||
{
|
{
|
||||||
BlockdevCreateOptionsQed *qed_opts;
|
BlockdevCreateOptionsQed *qed_opts;
|
||||||
BlockBackend *blk = NULL;
|
BlockBackend *blk = NULL;
|
||||||
|
@ -751,7 +751,7 @@ out:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int coroutine_fn GRAPH_RDLOCK
|
static int coroutine_fn GRAPH_UNLOCKED
|
||||||
bdrv_qed_co_create_opts(BlockDriver *drv, const char *filename,
|
bdrv_qed_co_create_opts(BlockDriver *drv, const char *filename,
|
||||||
QemuOpts *opts, Error **errp)
|
QemuOpts *opts, Error **errp)
|
||||||
{
|
{
|
||||||
|
|
|
@ -457,7 +457,7 @@ static int raw_has_zero_init(BlockDriverState *bs)
|
||||||
return bdrv_has_zero_init(bs->file->bs);
|
return bdrv_has_zero_init(bs->file->bs);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int coroutine_fn GRAPH_RDLOCK
|
static int coroutine_fn GRAPH_UNLOCKED
|
||||||
raw_co_create_opts(BlockDriver *drv, const char *filename,
|
raw_co_create_opts(BlockDriver *drv, const char *filename,
|
||||||
QemuOpts *opts, Error **errp)
|
QemuOpts *opts, Error **errp)
|
||||||
{
|
{
|
||||||
|
|
11
block/vdi.c
11
block/vdi.c
|
@ -734,8 +734,9 @@ nonallocating_write:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int coroutine_fn vdi_co_do_create(BlockdevCreateOptions *create_options,
|
static int coroutine_fn GRAPH_UNLOCKED
|
||||||
size_t block_size, Error **errp)
|
vdi_co_do_create(BlockdevCreateOptions *create_options, size_t block_size,
|
||||||
|
Error **errp)
|
||||||
{
|
{
|
||||||
BlockdevCreateOptionsVdi *vdi_opts;
|
BlockdevCreateOptionsVdi *vdi_opts;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
@ -892,13 +893,13 @@ exit:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int coroutine_fn vdi_co_create(BlockdevCreateOptions *create_options,
|
static int coroutine_fn GRAPH_UNLOCKED
|
||||||
Error **errp)
|
vdi_co_create(BlockdevCreateOptions *create_options, Error **errp)
|
||||||
{
|
{
|
||||||
return vdi_co_do_create(create_options, DEFAULT_CLUSTER_SIZE, errp);
|
return vdi_co_do_create(create_options, DEFAULT_CLUSTER_SIZE, errp);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int coroutine_fn GRAPH_RDLOCK
|
static int coroutine_fn GRAPH_UNLOCKED
|
||||||
vdi_co_create_opts(BlockDriver *drv, const char *filename,
|
vdi_co_create_opts(BlockDriver *drv, const char *filename,
|
||||||
QemuOpts *opts, Error **errp)
|
QemuOpts *opts, Error **errp)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1506,7 +1506,7 @@ exit:
|
||||||
* There are 2 headers, and the highest sequence number will represent
|
* There are 2 headers, and the highest sequence number will represent
|
||||||
* the active header
|
* the active header
|
||||||
*/
|
*/
|
||||||
static int coroutine_fn GRAPH_RDLOCK
|
static int coroutine_fn GRAPH_UNLOCKED
|
||||||
vhdx_create_new_headers(BlockBackend *blk, uint64_t image_size,
|
vhdx_create_new_headers(BlockBackend *blk, uint64_t image_size,
|
||||||
uint32_t log_size)
|
uint32_t log_size)
|
||||||
{
|
{
|
||||||
|
@ -1515,6 +1515,8 @@ vhdx_create_new_headers(BlockBackend *blk, uint64_t image_size,
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
VHDXHeader *hdr = NULL;
|
VHDXHeader *hdr = NULL;
|
||||||
|
|
||||||
|
GRAPH_RDLOCK_GUARD();
|
||||||
|
|
||||||
hdr = g_new0(VHDXHeader, 1);
|
hdr = g_new0(VHDXHeader, 1);
|
||||||
|
|
||||||
hdr->signature = VHDX_HEADER_SIGNATURE;
|
hdr->signature = VHDX_HEADER_SIGNATURE;
|
||||||
|
@ -1898,7 +1900,7 @@ exit:
|
||||||
* .---- ~ ----------- ~ ------------ ~ ---------------- ~ -----------.
|
* .---- ~ ----------- ~ ------------ ~ ---------------- ~ -----------.
|
||||||
* 1MB
|
* 1MB
|
||||||
*/
|
*/
|
||||||
static int coroutine_fn GRAPH_RDLOCK
|
static int coroutine_fn GRAPH_UNLOCKED
|
||||||
vhdx_co_create(BlockdevCreateOptions *opts, Error **errp)
|
vhdx_co_create(BlockdevCreateOptions *opts, Error **errp)
|
||||||
{
|
{
|
||||||
BlockdevCreateOptionsVhdx *vhdx_opts;
|
BlockdevCreateOptionsVhdx *vhdx_opts;
|
||||||
|
@ -2060,7 +2062,7 @@ delete_and_exit:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int coroutine_fn GRAPH_RDLOCK
|
static int coroutine_fn GRAPH_UNLOCKED
|
||||||
vhdx_co_create_opts(BlockDriver *drv, const char *filename,
|
vhdx_co_create_opts(BlockDriver *drv, const char *filename,
|
||||||
QemuOpts *opts, Error **errp)
|
QemuOpts *opts, Error **errp)
|
||||||
{
|
{
|
||||||
|
|
27
block/vmdk.c
27
block/vmdk.c
|
@ -2165,10 +2165,9 @@ vmdk_co_pwrite_zeroes(BlockDriverState *bs, int64_t offset, int64_t bytes,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int vmdk_init_extent(BlockBackend *blk,
|
static int GRAPH_UNLOCKED
|
||||||
int64_t filesize, bool flat,
|
vmdk_init_extent(BlockBackend *blk, int64_t filesize, bool flat, bool compress,
|
||||||
bool compress, bool zeroed_grain,
|
bool zeroed_grain, Error **errp)
|
||||||
Error **errp)
|
|
||||||
{
|
{
|
||||||
int ret, i;
|
int ret, i;
|
||||||
VMDK4Header header;
|
VMDK4Header header;
|
||||||
|
@ -2277,7 +2276,7 @@ exit:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int coroutine_fn GRAPH_RDLOCK
|
static int coroutine_fn GRAPH_UNLOCKED
|
||||||
vmdk_create_extent(const char *filename, int64_t filesize, bool flat,
|
vmdk_create_extent(const char *filename, int64_t filesize, bool flat,
|
||||||
bool compress, bool zeroed_grain, BlockBackend **pbb,
|
bool compress, bool zeroed_grain, BlockBackend **pbb,
|
||||||
QemuOpts *opts, Error **errp)
|
QemuOpts *opts, Error **errp)
|
||||||
|
@ -2358,7 +2357,7 @@ static int filename_decompose(const char *filename, char *path, char *prefix,
|
||||||
* non-split format.
|
* non-split format.
|
||||||
* idx >= 1: get the n-th extent if in a split subformat
|
* idx >= 1: get the n-th extent if in a split subformat
|
||||||
*/
|
*/
|
||||||
typedef BlockBackend * coroutine_fn /* GRAPH_RDLOCK */
|
typedef BlockBackend * coroutine_fn GRAPH_UNLOCKED_PTR
|
||||||
(*vmdk_create_extent_fn)(int64_t size, int idx, bool flat, bool split,
|
(*vmdk_create_extent_fn)(int64_t size, int idx, bool flat, bool split,
|
||||||
bool compress, bool zeroed_grain, void *opaque,
|
bool compress, bool zeroed_grain, void *opaque,
|
||||||
Error **errp);
|
Error **errp);
|
||||||
|
@ -2374,7 +2373,7 @@ static void vmdk_desc_add_extent(GString *desc,
|
||||||
g_free(basename);
|
g_free(basename);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int coroutine_fn GRAPH_RDLOCK
|
static int coroutine_fn GRAPH_UNLOCKED
|
||||||
vmdk_co_do_create(int64_t size,
|
vmdk_co_do_create(int64_t size,
|
||||||
BlockdevVmdkSubformat subformat,
|
BlockdevVmdkSubformat subformat,
|
||||||
BlockdevVmdkAdapterType adapter_type,
|
BlockdevVmdkAdapterType adapter_type,
|
||||||
|
@ -2605,7 +2604,7 @@ typedef struct {
|
||||||
QemuOpts *opts;
|
QemuOpts *opts;
|
||||||
} VMDKCreateOptsData;
|
} VMDKCreateOptsData;
|
||||||
|
|
||||||
static BlockBackend * coroutine_fn GRAPH_RDLOCK
|
static BlockBackend * coroutine_fn GRAPH_UNLOCKED
|
||||||
vmdk_co_create_opts_cb(int64_t size, int idx, bool flat, bool split,
|
vmdk_co_create_opts_cb(int64_t size, int idx, bool flat, bool split,
|
||||||
bool compress, bool zeroed_grain, void *opaque,
|
bool compress, bool zeroed_grain, void *opaque,
|
||||||
Error **errp)
|
Error **errp)
|
||||||
|
@ -2647,7 +2646,7 @@ exit:
|
||||||
return blk;
|
return blk;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int coroutine_fn GRAPH_RDLOCK
|
static int coroutine_fn GRAPH_UNLOCKED
|
||||||
vmdk_co_create_opts(BlockDriver *drv, const char *filename,
|
vmdk_co_create_opts(BlockDriver *drv, const char *filename,
|
||||||
QemuOpts *opts, Error **errp)
|
QemuOpts *opts, Error **errp)
|
||||||
{
|
{
|
||||||
|
@ -2756,11 +2755,9 @@ exit:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static BlockBackend * coroutine_fn vmdk_co_create_cb(int64_t size, int idx,
|
static BlockBackend * coroutine_fn GRAPH_UNLOCKED
|
||||||
bool flat, bool split,
|
vmdk_co_create_cb(int64_t size, int idx, bool flat, bool split, bool compress,
|
||||||
bool compress,
|
bool zeroed_grain, void *opaque, Error **errp)
|
||||||
bool zeroed_grain,
|
|
||||||
void *opaque, Error **errp)
|
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
BlockDriverState *bs;
|
BlockDriverState *bs;
|
||||||
|
@ -2809,7 +2806,7 @@ static BlockBackend * coroutine_fn vmdk_co_create_cb(int64_t size, int idx,
|
||||||
return blk;
|
return blk;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int coroutine_fn GRAPH_RDLOCK
|
static int coroutine_fn GRAPH_UNLOCKED
|
||||||
vmdk_co_create(BlockdevCreateOptions *create_options, Error **errp)
|
vmdk_co_create(BlockdevCreateOptions *create_options, Error **errp)
|
||||||
{
|
{
|
||||||
BlockdevCreateOptionsVmdk *opts;
|
BlockdevCreateOptionsVmdk *opts;
|
||||||
|
|
|
@ -967,8 +967,8 @@ static int calculate_rounded_image_size(BlockdevCreateOptionsVpc *vpc_opts,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int coroutine_fn vpc_co_create(BlockdevCreateOptions *opts,
|
static int coroutine_fn GRAPH_UNLOCKED
|
||||||
Error **errp)
|
vpc_co_create(BlockdevCreateOptions *opts, Error **errp)
|
||||||
{
|
{
|
||||||
BlockdevCreateOptionsVpc *vpc_opts;
|
BlockdevCreateOptionsVpc *vpc_opts;
|
||||||
BlockBackend *blk = NULL;
|
BlockBackend *blk = NULL;
|
||||||
|
@ -1087,7 +1087,7 @@ out:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int coroutine_fn GRAPH_RDLOCK
|
static int coroutine_fn GRAPH_UNLOCKED
|
||||||
vpc_co_create_opts(BlockDriver *drv, const char *filename,
|
vpc_co_create_opts(BlockDriver *drv, const char *filename,
|
||||||
QemuOpts *opts, Error **errp)
|
QemuOpts *opts, Error **errp)
|
||||||
{
|
{
|
||||||
|
|
|
@ -58,14 +58,14 @@ BlockDriver *bdrv_find_protocol(const char *filename,
|
||||||
Error **errp);
|
Error **errp);
|
||||||
BlockDriver *bdrv_find_format(const char *format_name);
|
BlockDriver *bdrv_find_format(const char *format_name);
|
||||||
|
|
||||||
int coroutine_fn GRAPH_RDLOCK
|
int coroutine_fn GRAPH_UNLOCKED
|
||||||
bdrv_co_create(BlockDriver *drv, const char *filename, QemuOpts *opts,
|
bdrv_co_create(BlockDriver *drv, const char *filename, QemuOpts *opts,
|
||||||
Error **errp);
|
Error **errp);
|
||||||
|
|
||||||
int co_wrapper_bdrv_rdlock bdrv_create(BlockDriver *drv, const char *filename,
|
int co_wrapper bdrv_create(BlockDriver *drv, const char *filename,
|
||||||
QemuOpts *opts, Error **errp);
|
QemuOpts *opts, Error **errp);
|
||||||
|
|
||||||
int coroutine_fn GRAPH_RDLOCK
|
int coroutine_fn GRAPH_UNLOCKED
|
||||||
bdrv_co_create_file(const char *filename, QemuOpts *opts, Error **errp);
|
bdrv_co_create_file(const char *filename, QemuOpts *opts, Error **errp);
|
||||||
|
|
||||||
BlockDriverState *bdrv_new(void);
|
BlockDriverState *bdrv_new(void);
|
||||||
|
|
|
@ -250,10 +250,10 @@ struct BlockDriver {
|
||||||
BlockDriverState *bs, QDict *options, int flags, Error **errp);
|
BlockDriverState *bs, QDict *options, int flags, Error **errp);
|
||||||
void (*bdrv_close)(BlockDriverState *bs);
|
void (*bdrv_close)(BlockDriverState *bs);
|
||||||
|
|
||||||
int coroutine_fn GRAPH_RDLOCK_PTR (*bdrv_co_create)(
|
int coroutine_fn GRAPH_UNLOCKED_PTR (*bdrv_co_create)(
|
||||||
BlockdevCreateOptions *opts, Error **errp);
|
BlockdevCreateOptions *opts, Error **errp);
|
||||||
|
|
||||||
int coroutine_fn GRAPH_RDLOCK_PTR (*bdrv_co_create_opts)(
|
int coroutine_fn GRAPH_UNLOCKED_PTR (*bdrv_co_create_opts)(
|
||||||
BlockDriver *drv, const char *filename, QemuOpts *opts, Error **errp);
|
BlockDriver *drv, const char *filename, QemuOpts *opts, Error **errp);
|
||||||
|
|
||||||
int (*bdrv_amend_options)(BlockDriverState *bs,
|
int (*bdrv_amend_options)(BlockDriverState *bs,
|
||||||
|
|
Loading…
Reference in New Issue