blockdev: loosen restrictions on drive-backup source node
PATCH v2 1/1 blockdev: loosen restrictions on drive-backup source node
We mandate that the source node must be a root node; but there's no reason I am aware of that it needs to be restricted to such. In some cases, we need to make sure that there's a medium present, but in the general case we can allow the backup job itself to do the graph checking.
This patch helps improve the error message when you try to backup from the same node more than once, which is reflected in the change to test 056.
For backups with bitmaps, it will also show a better error message that the bitmap is in use instead of giving you something cryptic like "need a root node."
--- blockdev.c | 7 ++++++- tests/qemu-iotests/056 | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-)
blockdev.c +6 -1
@@ -3450,11 +3450,16 @@ static BlockJob *do_drive_backup(DriveBackup *backup, JobTxn *txn, backup->compress = false; } - bs =qmp_get_root_bs (backup->device, errp); + bs =bdrv_lookup_bs (backup->device, backup->device, errp);if (!bs) {return NULL ; } +if (!bs->drv) { +error_setg (errp,"Device has no medium" ); +return NULL ; + } + aio_context =bdrv_get_aio_context (bs);aio_context_acquire (aio_context);
tests/qemu-iotests/056 +1 -1
@@ -214,7 +214,7 @@ class BackupTest(iotests.QMPTestCase): res = self.vm.qmp('query-block-jobs') self.assert_qmp(res, 'return[0]/status', 'concluded') # Leave zombie job un-dismissed, observe a failure: - res = self.qmp_backup_and_wait(serror='Need a root block node', + res = self.qmp_backup_and_wait(serror="Node 'drive0' is busy: block device is in use by block job: backup", device='drive0', format=iotests.imgfmt, sync='full', target=self.dest_img, auto_dismiss=False)
Signature · 1 line
2.20.1
Max Reitz
AppliedQuoted 13 lines · John Snow
We mandate that the source node must be a root node; but there's no reason I am aware of that it needs to be restricted to such. In some cases, we need to make sure that there's a medium present, but in the general case we can allow the backup job itself to do the graph checking.
This patch helps improve the error message when you try to backup from the same node more than once, which is reflected in the change to test 056.
For backups with bitmaps, it will also show a better error message that the bitmap is in use instead of giving you something cryptic like "need a root node."
Quoted 6 lines
Signed-off-by John Snow <[email protected]>--- blockdev.c | 7 ++++++- tests/qemu-iotests/056 | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-)
Thanks, applied to my block branch:
https://git.xanclic.moe/XanClic/qemu/commits/branch/block
Let’s see what breaks.
Max