Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/ericb/tags/pull-nbd-2021-03-09'…
Browse files Browse the repository at this point in the history
… into staging

nbd patches for 2021-03-09

- Add Vladimir as NBD co-maintainer
- Fix reporting of holes in NBD_CMD_BLOCK_STATUS
- Improve command-line parsing accuracy of large numbers (anything going
through qemu_strtosz), including the deprecation of hex+suffix
- Improve some error reporting in the block layer

# gpg: Signature made Tue 09 Mar 2021 15:38:10 GMT
# gpg:                using RSA key 71C2CC22B1C4602927D2F3AAA7A16B4A2527436A
# gpg: Good signature from "Eric Blake <[email protected]>" [full]
# gpg:                 aka "Eric Blake (Free Software Programmer) <[email protected]>" [full]
# gpg:                 aka "[jpeg image of size 6874]" [full]
# Primary key fingerprint: 71C2 CC22 B1C4 6029 27D2  F3AA A7A1 6B4A 2527 436A

* remotes/ericb/tags/pull-nbd-2021-03-09:
  block/qcow2: refactor qcow2_update_options_prepare error paths
  block/qed: bdrv_qed_do_open: deal with errp
  block/qcow2: simplify qcow2_co_invalidate_cache()
  block/qcow2: read_cache_sizes: return status value
  block/qcow2-bitmap: return status from qcow2_store_persistent_dirty_bitmaps
  block/qcow2-bitmap: improve qcow2_load_dirty_bitmaps() interface
  block/qcow2: qcow2_get_specific_info(): drop error propagation
  blockjob: return status from block_job_set_speed()
  block/mirror: drop extra error propagation in commit_active_start()
  block: drop extra error propagation for bdrv_set_backing_hd
  blockdev: fix drive_backup_prepare() missed error
  block: check return value of bdrv_open_child and drop error propagation
  utils: Deprecate hex-with-suffix sizes
  utils: Improve qemu_strtosz() to have 64 bits of precision
  utils: Enhance testsuite for do_strtosz()
  nbd: server: Report holes for raw images
  MAINTAINERS: add Vladimir as co-maintainer of NBD

Signed-off-by: Peter Maydell <[email protected]>
  • Loading branch information
pm215 committed Mar 11, 2021
2 parents 363fc96 + 1184b41 commit 9abda42
Show file tree
Hide file tree
Showing 25 changed files with 408 additions and 208 deletions.
2 changes: 2 additions & 0 deletions MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -3050,6 +3050,7 @@ F: block/iscsi-opts.c

Network Block Device (NBD)
M: Eric Blake <[email protected]>
M: Vladimir Sementsov-Ogievskiy <[email protected]>
L: [email protected]
S: Maintained
F: block/nbd*
Expand All @@ -3060,6 +3061,7 @@ F: blockdev-nbd.c
F: docs/interop/nbd.txt
F: docs/interop/qemu-nbd.rst
T: git https://repo.or.cz/qemu/ericb.git nbd
T: git https://src.openvz.org/scm/~vsementsov/qemu.git nbd

NFS
M: Peter Lieven <[email protected]>
Expand Down
6 changes: 2 additions & 4 deletions block.c
Original file line number Diff line number Diff line change
Expand Up @@ -2995,11 +2995,9 @@ int bdrv_open_backing_file(BlockDriverState *bs, QDict *parent_options,

/* Hook up the backing file link; drop our reference, bs owns the
* backing_hd reference now */
bdrv_set_backing_hd(bs, backing_hd, &local_err);
ret = bdrv_set_backing_hd(bs, backing_hd, errp);
bdrv_unref(backing_hd);
if (local_err) {
error_propagate(errp, local_err);
ret = -EINVAL;
if (ret < 0) {
goto free_exit;
}

Expand Down
6 changes: 2 additions & 4 deletions block/blkdebug.c
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,6 @@ static int blkdebug_open(BlockDriverState *bs, QDict *options, int flags,
{
BDRVBlkdebugState *s = bs->opaque;
QemuOpts *opts;
Error *local_err = NULL;
int ret;
uint64_t align;

Expand Down Expand Up @@ -494,10 +493,9 @@ static int blkdebug_open(BlockDriverState *bs, QDict *options, int flags,
bs->file = bdrv_open_child(qemu_opt_get(opts, "x-image"), options, "image",
bs, &child_of_bds,
BDRV_CHILD_FILTERED | BDRV_CHILD_PRIMARY,
false, &local_err);
if (local_err) {
false, errp);
if (!bs->file) {
ret = -EINVAL;
error_propagate(errp, local_err);
goto out;
}

Expand Down
10 changes: 4 additions & 6 deletions block/blklogwrites.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,19 +157,17 @@ static int blk_log_writes_open(BlockDriverState *bs, QDict *options, int flags,
/* Open the file */
bs->file = bdrv_open_child(NULL, options, "file", bs, &child_of_bds,
BDRV_CHILD_FILTERED | BDRV_CHILD_PRIMARY, false,
&local_err);
if (local_err) {
errp);
if (!bs->file) {
ret = -EINVAL;
error_propagate(errp, local_err);
goto fail;
}

/* Open the log file */
s->log_file = bdrv_open_child(NULL, options, "log", bs, &child_of_bds,
BDRV_CHILD_METADATA, false, &local_err);
if (local_err) {
BDRV_CHILD_METADATA, false, errp);
if (!s->log_file) {
ret = -EINVAL;
error_propagate(errp, local_err);
goto fail;
}

Expand Down
6 changes: 2 additions & 4 deletions block/blkreplay.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,14 @@ typedef struct Request {
static int blkreplay_open(BlockDriverState *bs, QDict *options, int flags,
Error **errp)
{
Error *local_err = NULL;
int ret;

/* Open the image file */
bs->file = bdrv_open_child(NULL, options, "image", bs, &child_of_bds,
BDRV_CHILD_FILTERED | BDRV_CHILD_PRIMARY,
false, &local_err);
if (local_err) {
false, errp);
if (!bs->file) {
ret = -EINVAL;
error_propagate(errp, local_err);
goto fail;
}

Expand Down
11 changes: 4 additions & 7 deletions block/blkverify.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ static int blkverify_open(BlockDriverState *bs, QDict *options, int flags,
{
BDRVBlkverifyState *s = bs->opaque;
QemuOpts *opts;
Error *local_err = NULL;
int ret;

opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort);
Expand All @@ -125,20 +124,18 @@ static int blkverify_open(BlockDriverState *bs, QDict *options, int flags,
bs->file = bdrv_open_child(qemu_opt_get(opts, "x-raw"), options, "raw",
bs, &child_of_bds,
BDRV_CHILD_FILTERED | BDRV_CHILD_PRIMARY,
false, &local_err);
if (local_err) {
false, errp);
if (!bs->file) {
ret = -EINVAL;
error_propagate(errp, local_err);
goto fail;
}

/* Open the test file */
s->test_file = bdrv_open_child(qemu_opt_get(opts, "x-image"), options,
"test", bs, &child_of_bds, BDRV_CHILD_DATA,
false, &local_err);
if (local_err) {
false, errp);
if (!s->test_file) {
ret = -EINVAL;
error_propagate(errp, local_err);
goto fail;
}

Expand Down
12 changes: 5 additions & 7 deletions block/mirror.c
Original file line number Diff line number Diff line change
Expand Up @@ -1860,8 +1860,7 @@ BlockJob *commit_active_start(const char *job_id, BlockDriverState *bs,
bool auto_complete, Error **errp)
{
bool base_read_only;
Error *local_err = NULL;
BlockJob *ret;
BlockJob *job;

base_read_only = bdrv_is_read_only(base);

Expand All @@ -1871,19 +1870,18 @@ BlockJob *commit_active_start(const char *job_id, BlockDriverState *bs,
}
}

ret = mirror_start_job(
job = mirror_start_job(
job_id, bs, creation_flags, base, NULL, speed, 0, 0,
MIRROR_LEAVE_BACKING_CHAIN, false,
on_error, on_error, true, cb, opaque,
&commit_active_job_driver, false, base, auto_complete,
filter_node_name, false, MIRROR_COPY_MODE_BACKGROUND,
&local_err);
if (local_err) {
error_propagate(errp, local_err);
errp);
if (!job) {
goto error_restore_flags;
}

return ret;
return job;

error_restore_flags:
/* ignore error and errp for bdrv_reopen, because we want to propagate
Expand Down
65 changes: 35 additions & 30 deletions block/qcow2-bitmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -950,25 +950,27 @@ static void set_readonly_helper(gpointer bitmap, gpointer value)
bdrv_dirty_bitmap_set_readonly(bitmap, (bool)value);
}

/* qcow2_load_dirty_bitmaps()
* Return value is a hint for caller: true means that the Qcow2 header was
* updated. (false doesn't mean that the header should be updated by the
* caller, it just means that updating was not needed or the image cannot be
* written to).
* On failure the function returns false.
/*
* Return true on success, false on failure.
* If header_updated is not NULL then it is set appropriately regardless of
* the return value.
*/
bool qcow2_load_dirty_bitmaps(BlockDriverState *bs, Error **errp)
bool qcow2_load_dirty_bitmaps(BlockDriverState *bs, bool *header_updated,
Error **errp)
{
BDRVQcow2State *s = bs->opaque;
Qcow2BitmapList *bm_list;
Qcow2Bitmap *bm;
GSList *created_dirty_bitmaps = NULL;
bool header_updated = false;
bool needs_update = false;

if (header_updated) {
*header_updated = false;
}

if (s->nb_bitmaps == 0) {
/* No bitmaps - nothing to do */
return false;
return true;
}

bm_list = bitmap_list_load(bs, s->bitmap_directory_offset,
Expand Down Expand Up @@ -1024,7 +1026,9 @@ bool qcow2_load_dirty_bitmaps(BlockDriverState *bs, Error **errp)
error_setg_errno(errp, -ret, "Can't update bitmap directory");
goto fail;
}
header_updated = true;
if (header_updated) {
*header_updated = true;
}
}

if (!can_write(bs)) {
Expand All @@ -1035,7 +1039,7 @@ bool qcow2_load_dirty_bitmaps(BlockDriverState *bs, Error **errp)
g_slist_free(created_dirty_bitmaps);
bitmap_list_free(bm_list);

return header_updated;
return true;

fail:
g_slist_foreach(created_dirty_bitmaps, release_dirty_bitmap_helper, bs);
Expand Down Expand Up @@ -1077,30 +1081,32 @@ static Qcow2BitmapInfoFlagsList *get_bitmap_info_flags(uint32_t flags)
/*
* qcow2_get_bitmap_info_list()
* Returns a list of QCOW2 bitmap details.
* In case of no bitmaps, the function returns NULL and
* the @errp parameter is not set.
* When bitmap information can not be obtained, the function returns
* NULL and the @errp parameter is set.
* On success return true with info_list set (note, that if there are no
* bitmaps, info_list is set to NULL).
* On failure return false with errp set.
*/
Qcow2BitmapInfoList *qcow2_get_bitmap_info_list(BlockDriverState *bs,
Error **errp)
bool qcow2_get_bitmap_info_list(BlockDriverState *bs,
Qcow2BitmapInfoList **info_list, Error **errp)
{
BDRVQcow2State *s = bs->opaque;
Qcow2BitmapList *bm_list;
Qcow2Bitmap *bm;
Qcow2BitmapInfoList *list = NULL;
Qcow2BitmapInfoList **tail = &list;
Qcow2BitmapInfoList **tail;

if (s->nb_bitmaps == 0) {
return NULL;
*info_list = NULL;
return true;
}

bm_list = bitmap_list_load(bs, s->bitmap_directory_offset,
s->bitmap_directory_size, errp);
if (bm_list == NULL) {
return NULL;
if (!bm_list) {
return false;
}

*info_list = NULL;
tail = info_list;

QSIMPLEQ_FOREACH(bm, bm_list, entry) {
Qcow2BitmapInfo *info = g_new0(Qcow2BitmapInfo, 1);
info->granularity = 1U << bm->granularity_bits;
Expand All @@ -1111,7 +1117,7 @@ Qcow2BitmapInfoList *qcow2_get_bitmap_info_list(BlockDriverState *bs,

bitmap_list_free(bm_list);

return list;
return true;
}

int qcow2_reopen_bitmaps_rw(BlockDriverState *bs, Error **errp)
Expand Down Expand Up @@ -1513,9 +1519,10 @@ int coroutine_fn qcow2_co_remove_persistent_dirty_bitmap(BlockDriverState *bs,
* readonly to begin with, and whether we opened directly or reopened to that
* state shouldn't matter for the state we get afterward.
*/
void qcow2_store_persistent_dirty_bitmaps(BlockDriverState *bs,
bool qcow2_store_persistent_dirty_bitmaps(BlockDriverState *bs,
bool release_stored, Error **errp)
{
ERRP_GUARD();
BdrvDirtyBitmap *bitmap;
BDRVQcow2State *s = bs->opaque;
uint32_t new_nb_bitmaps = s->nb_bitmaps;
Expand All @@ -1535,7 +1542,7 @@ void qcow2_store_persistent_dirty_bitmaps(BlockDriverState *bs,
bm_list = bitmap_list_load(bs, s->bitmap_directory_offset,
s->bitmap_directory_size, errp);
if (bm_list == NULL) {
return;
return false;
}
}

Expand Down Expand Up @@ -1650,7 +1657,7 @@ void qcow2_store_persistent_dirty_bitmaps(BlockDriverState *bs,
}

bitmap_list_free(bm_list);
return;
return true;

fail:
QSIMPLEQ_FOREACH(bm, bm_list, entry) {
Expand All @@ -1668,16 +1675,14 @@ void qcow2_store_persistent_dirty_bitmaps(BlockDriverState *bs,
}

bitmap_list_free(bm_list);
return false;
}

int qcow2_reopen_bitmaps_ro(BlockDriverState *bs, Error **errp)
{
BdrvDirtyBitmap *bitmap;
Error *local_err = NULL;

qcow2_store_persistent_dirty_bitmaps(bs, false, &local_err);
if (local_err != NULL) {
error_propagate(errp, local_err);
if (!qcow2_store_persistent_dirty_bitmaps(bs, false, errp)) {
return -EINVAL;
}

Expand Down
Loading

0 comments on commit 9abda42

Please sign in to comment.