block: reject persistent bitmaps a node can never store
v2 cover block: reject persistent bitmaps a node can never store
qmp_block_dirty_bitmap_add() and the incoming-migration bitmap loader both create a persistent bitmap with bdrv_create_dirty_bitmap(), which always creates it writable, without checking whether the node can actually be written to. A persistent bitmap added to an already read-only or inactive node stays writable in memory on a node that can never store it, and the next global inactivation (migration completion, save, or any other bdrv_inactivate_all() caller) fails trying to flush it back:
Lost persistent bitmaps during inactivation of node '<node>': No write access migration_block_inactivate: bdrv_inactivate_all() failed: -22
Patch 1 rejects this at block-dirty-bitmap-add (and, wrapped in a transaction, denies the whole transaction). Patch 2 closes the same hole on the incoming-migration path. Patch 3 fixes a knock-on regression from patch 1's approach: a bitmap that was rejected from ever being written can still exist in memory read-only and must remain removable without requiring write access.
v1 -> v2
* approach changed to deny rather than adopt (Vladimir)
* added patch to add permission check on migration path
* added patch to change permissions check on bitmap drop to more natural
Denis V. Lunev (3):
block/monitor: reject persistent bitmap add on a read-only node migration/block-dirty-bitmap: reject bitmap load onto ro node block/monitor: allow dropping a bitmap never stored on disk
block/monitor/bitmap-qmp-cmds.c | 19 +++++++---- block/qcow2-bitmap.c | 9 +++++ migration/block-dirty-bitmap.c | 22 +++++++++---- qapi/block-core.json | 4 ++- tests/qemu-iotests/tests/migrate-bitmaps-test | 33 +++++++++++++++++++ .../tests/migrate-bitmaps-test.out | 4 +-- .../tests/remove-bitmap-from-backing | 29 +++++++++++++++- .../tests/remove-bitmap-from-backing.out | 22 ++++++++++++- 8 files changed, 124 insertions(+), 18 deletions(-)
Signature · 1 line
2.53.0
PATCH v2 1/3 block/monitor: reject persistent bitmap add on a read-only node
qmp_block_dirty_bitmap_add() marks a new bitmap persistent without checking write access to its node. bdrv_create_dirty_bitmap() always creates bitmaps writable, so a persistent bitmap added to an already read-only node stays writable in memory on a node that can never store it, and the next global inactivation fails:
Lost persistent bitmaps during inactivation of node '<node>': No write access migration_block_inactivate: bdrv_inactivate_all() failed: -22
Forcing it read-only instead does not help: it was never stored, so it stays unpromotable on the next reopen to read-write and can trip bdrv_set_dirty()'s readonly assert on the first write. Reject the add instead, for both read-only and inactive nodes -- an already-inactive node skips qcow2_inactivate() on close, so a bitmap added during that window would never get stored either. Wrapped in a transaction, this denies the whole transaction, since qmp_transaction() is already all-or-none.
--- block/monitor/bitmap-qmp-cmds.c | 15 +++++++--- qapi/block-core.json | 4 ++- .../tests/remove-bitmap-from-backing | 29 ++++++++++++++++++- .../tests/remove-bitmap-from-backing.out | 20 +++++++++++++ 4 files changed, 62 insertions(+), 6 deletions(-)
block/monitor/bitmap-qmp-cmds.c +11 -4
@@ -125,10 +125,17 @@ void qmp_block_dirty_bitmap_add(const char *node, const char *name, disabled = false; } -if (persistent && - !bdrv_can_store_new_dirty_bitmap (bs, name, granularity, errp)) - { -return ; +if (persistent) { +if (!bdrv_is_writable (bs)) { +error_setg (errp,"Cannot add a persistent bitmap to " +"read-only or inactive node '%s'" , +bdrv_get_node_name (bs)); +return ; + } + +if (!bdrv_can_store_new_dirty_bitmap (bs, name, granularity, errp)) { +return ; + } } bitmap =bdrv_create_dirty_bitmap (bs, granularity, name, errp);
qapi/block-core.json +3 -1
@@ -2353,7 +2353,9 @@ # @persistent: the bitmap is persistent, i.e. it will be saved to the # corresponding block device image file on its close. For now # only Qcow2 disks support persistent bitmaps. Default is false -# for `block-dirty-bitmap-add`. (Since: 2.10) +# for `block-dirty-bitmap-add`. This fails if the node is +# read-only or inactive, since such a bitmap could never be +# stored. (Since: 2.10) # # @disabled: the bitmap is created in the disabled state, which means # that it will not track drive changes. The bitmap may be enabled
tests/qemu-iotests/tests/remove-bitmap-from-backing +28 -1
@@ -35,7 +35,7 @@ qemu_img('bitmap', '--add', base, 'bitmap0') # Just assert that our method of checking bitmaps in the image works. assert 'bitmaps' in qemu_img_info(base)['format-specific']['data'] -vm = iotests.VM().add_drive(top, 'backing.node-name=base') +vm = iotests.VM().add_drive(top, 'node-name=top,backing.node-name=base') vm.launch() log('Trying to remove persistent bitmap from r-o base node, should fail:')
@@ -66,6 +66,33 @@ result = vm.qmp('blockdev-reopen', **new_base_opts) if result != {'return': {}}: log('Failed to reopen: ' + str(result)) +log('Adding a persistent bitmap to the r-o base node, should fail:') +vm.qmp_log('block-dirty-bitmap-add', node='base', name='bitmap1', + persistent=True) + +log('Same add inside a transaction, preceded by an otherwise valid') +log('action: the whole transaction must fail and roll back the') +log('already-succeeded first action too:') +vm.qmp_log('transaction', actions=[ + {'type': 'block-dirty-bitmap-add', + 'data': {'node': 'top', 'name': 'bitmap2', 'persistent': True}}, + {'type': 'block-dirty-bitmap-add', + 'data': {'node': 'base', 'name': 'bitmap1', 'persistent': True}}, +]) + +log('bitmap2 on the rw top node must not have survived the rollback:') +vm.qmp_log('block-dirty-bitmap-remove', node='top', name='bitmap2') + +log('Marking the rw top node inactive:') +vm.qmp_log('blockdev-set-active', **{'node-name': 'top', 'active': False}) + +log('Adding a persistent bitmap to a rw but inactive node, should fail:') +vm.qmp_log('block-dirty-bitmap-add', node='top', name='bitmap3', + persistent=True) + +log('Reactivating the top node:') +vm.qmp_log('blockdev-set-active', **{'node-name': 'top', 'active': True}) + vm.shutdown() if 'bitmaps' in qemu_img_info(base)['format-specific']['data']:
tests/qemu-iotests/tests/remove-bitmap-from-backing.out +20 -0
@@ -4,3 +4,23 @@ Trying to remove persistent bitmap from r-o base node, should fail: Remove persistent bitmap from base node reopened to RW: {"execute": "block-dirty-bitmap-remove", "arguments": {"name": "bitmap0", "node": "base"}} {"return": {}} +Adding a persistent bitmap to the r-o base node, should fail: +{"execute": "block-dirty-bitmap-add", "arguments": {"name": "bitmap1", "node": "base", "persistent": true}} +{"error": {"class": "GenericError", "desc": "Cannot add a persistent bitmap to read-only or inactive node 'base'"}} +Same add inside a transaction, preceded by an otherwise valid +action: the whole transaction must fail and roll back the +already-succeeded first action too: +{"execute": "transaction", "arguments": {"actions": [{"data": {"name": "bitmap2", "node": "top", "persistent": true}, "type": "block-dirty-bitmap-add"}, {"data": {"name": "bitmap1", "node": "base", "persistent": true}, "type": "block-dirty-bitmap-add"}]}} +{"error": {"class": "GenericError", "desc": "Cannot add a persistent bitmap to read-only or inactive node 'base'"}} +bitmap2 on the rw top node must not have survived the rollback: +{"execute": "block-dirty-bitmap-remove", "arguments": {"name": "bitmap2", "node": "top"}} +{"error": {"class": "GenericError", "desc": "Dirty bitmap 'bitmap2' not found"}} +Marking the rw top node inactive: +{"execute": "blockdev-set-active", "arguments": {"active": false, "node-name": "top"}} +{"return": {}} +Adding a persistent bitmap to a rw but inactive node, should fail: +{"execute": "block-dirty-bitmap-add", "arguments": {"name": "bitmap3", "node": "top", "persistent": true}} +{"error": {"class": "GenericError", "desc": "Cannot add a persistent bitmap to read-only or inactive node 'top'"}} +Reactivating the top node: +{"execute": "blockdev-set-active", "arguments": {"active": true, "node-name": "top"}} +{"return": {}}
Signature · 1 line
2.53.0
Re: [PATCH v2 1/3] block/monitor: reject persistent bitmap add on a read-only node
Quoted 18 lines · Denis V. Lunev
qmp_block_dirty_bitmap_add()marks a new bitmap persistent without checking write access to its node.bdrv_create_dirty_bitmap()always creates bitmaps writable, so a persistent bitmap added to an already read-only node stays writable in memory on a node that can never store it, and the next global inactivation fails:Lost persistent bitmaps during inactivation of node '<node>': No write access
migration_block_inactivate:bdrv_inactivate_all()failed: -22Forcing it read-only instead does not help: it was never stored, so it stays unpromotable on the next reopen to read-write and can trip bdrv_set_dirty()'s readonly assert on the first write. Reject the add instead, for both read-only and inactive nodes -- an already-inactive node skips
qcow2_inactivate()on close, so a bitmap added during that window would never get stored either. Wrapped in a transaction, this denies the whole transaction, sinceqmp_transaction()is already all-or-none.
Quoted 5 lines
Signed-off-by Denis V. Lunev <[email protected]>CC Eric Blake <[email protected]>CC Vladimir Sementsov-Ogievskiy <[email protected]>CC John Snow <[email protected]>CC Andrey Drobyshev <[email protected]>
Could it be a scenario, when user intentionally create bitmap in read-only image, and expect, that it would become writeable soon? For example before block-commit.
I don't think that useful.
For usual backup scenario, user will just move bitmaps from top to base, no need to make a bitmap, dirtied by the block-commit operation itself.
If, for some reason we don't have bitmap in top image, but have in base (top is a kind of temporary snapshot), bitmaps in base would become writeable and accept new dirty bits as expected.
Creating a new bitmap, to become actually a block-status bitmap of merged top base seems a strange case.. A kind of combination of snapshot-based and backup-based backup processes?
Anyway, I think, it's quite correct immediately store an empty bitmap to the qcow2 image when creating it with persistent=true, which of course fails if image is read-only. So, I think the change is correct:
Signature · 2 lines
Best regards, Vladimir
Re: [PATCH v2 1/3] block/monitor: reject persistent bitmap add on a read-only node
Quoted 43 lines · Vladimir Sementsov-Ogievskiy
Quoted 18 lines · Denis V. Lunev
qmp_block_dirty_bitmap_add()marks a new bitmap persistent without checking write access to its node.bdrv_create_dirty_bitmap()always creates bitmaps writable, so a persistent bitmap added to an already read-only node stays writable in memory on a node that can never store it, and the next global inactivation fails:Lost persistent bitmaps during inactivation of node '<node>': No write access
migration_block_inactivate:bdrv_inactivate_all()failed: -22Forcing it read-only instead does not help: it was never stored, so it stays unpromotable on the next reopen to read-write and can trip bdrv_set_dirty()'s readonly assert on the first write. Reject the add instead, for both read-only and inactive nodes -- an already-inactive node skips
qcow2_inactivate()on close, so a bitmap added during that window would never get stored either. Wrapped in a transaction, this denies the whole transaction, sinceqmp_transaction()is already all-or-none.Quoted 5 lines
Signed-off-by Denis V. Lunev <[email protected]>CC Eric Blake <[email protected]>CC Vladimir Sementsov-Ogievskiy <[email protected]>CC John Snow <[email protected]>CC Andrey Drobyshev <[email protected]>Could it be a scenario, when user intentionally create bitmap in read-only image, and expect, that it would become writeable soon? For example before block-commit.
I don't think that useful.
For usual backup scenario, user will just move bitmaps from top to base, no need to make a bitmap, dirtied by the block-commit operation itself.
If, for some reason we don't have bitmap in top image, but have in base (top is a kind of temporary snapshot), bitmaps in base would become writeable and accept new dirty bits as expected.
Creating a new bitmap, to become actually a block-status bitmap of merged top base seems a strange case.. A kind of combination of snapshot-based and backup-based backup processes?
Quoted 8 lines
Anyway, I think, it's quite correct immediately store an empty bitmap to the qcow2 image when creating it with persistent=true, which of course fails if image is read-only. So, I think the change is correct:
Reviewed-by Vladimir Sementsov-Ogievskiy <[email protected]>
FYI: in reality this was faced by once once VMs are started to be migrated and are unable to due to CBT over CDROM. Strangely enough from time to time we do have CDROMs over qcow2 images which leads us to this.
Den
PATCH v2 2/3 migration/block-dirty-bitmap: reject bitmap load onto ro node
In reply to Denis V. Lunevdirty_bitmap_load_start() creates an incoming migrated bitmap with bdrv_create_dirty_bitmap() and, if the source marked it persistent, calls bdrv_dirty_bitmap_set_persistence() without checking whether the destination node can be written to. Same gap as qmp_block_dirty_bitmap_add(), reached via incoming migration: a persistent bitmap for a read-only destination (e.g. a migrated CD-ROM-class attachment with dirty-bitmaps migration enabled) ends up writable in memory on a node that can never store it.
Reject it the same way, with one difference from the QMP path:
every destination node is BDRV_O_INACTIVE until migration completes, so bdrv_is_writable() would reject every incoming persistent bitmap, not just read-only ones. Check bdrv_is_read_only() alone.
--- migration/block-dirty-bitmap.c | 22 +++++++++---- tests/qemu-iotests/tests/migrate-bitmaps-test | 33 +++++++++++++++++++ .../tests/migrate-bitmaps-test.out | 4 +-- 3 files changed, 50 insertions(+), 9 deletions(-)
migration/block-dirty-bitmap.c +15 -7
@@ -812,13 +812,6 @@ static int dirty_bitmap_load_start(QEMUFile *f, DBMLoadState *s)error_report ("Bitmap with the same name ('%s') already exists on " "destination" ,bdrv_dirty_bitmap_name (s->bitmap));return -EINVAL ; - }else { - s->bitmap =bdrv_create_dirty_bitmap (s->bs, granularity, - s->bitmap_name, &local_err); -if (!s->bitmap) { -error_report_err (local_err); -return -EINVAL ; - } }if (flags &DIRTY_BITMAP_MIG_START_FLAG_RESERVED_MASK ) {
@@ -835,6 +828,21 @@ static int dirty_bitmap_load_start(QEMUFile *f, DBMLoadState *s) persistent = flags &DIRTY_BITMAP_MIG_START_FLAG_PERSISTENT ; } +/* Not bdrv_is_writable(): nodes stay inactive until migration ends. */ +if (persistent &&bdrv_is_read_only (s->bs)) { +error_report ("Cannot make migrated bitmap '%s' persistent " +"on read-only node '%s'" , s->bitmap_name, +bdrv_get_node_name (s->bs)); +return -EINVAL ; + } + + s->bitmap =bdrv_create_dirty_bitmap (s->bs, granularity, + s->bitmap_name, &local_err); +if (!s->bitmap) { +error_report_err (local_err); +return -EINVAL ; + } +if (persistent) {bdrv_dirty_bitmap_set_persistence (s->bitmap, true); }
tests/qemu-iotests/tests/migrate-bitmaps-test +33 -0
@@ -206,6 +206,39 @@ class TestDirtyBitmapMigration(iotests.QMPTestCase): self.vm_b.launch() self.check_bitmap(self.vm_b, sha256 if persistent else False) + def test_migration_to_readonly_destination(self): + granularity = 512 + mig_caps = [{'capability': 'events', 'state': True}, + {'capability': 'dirty-bitmaps', 'state': True}] + + self.vm_b.add_incoming("defer") + self.vm_b.add_drive(disk_b, 'read-only=on') + + self.add_bitmap(self.vm_a, granularity, True) + self.vm_a.hmp_qemu_io('drive0', 'write 0 4096') + + self.vm_a.cmd('migrate-set-capabilities', capabilities=mig_caps) + self.vm_a.cmd('migrate', uri=mig_cmd) + while True: + event = self.vm_a.event_wait('MIGRATION') + if event['data']['status'] == 'completed': + break + self.vm_a.shutdown() + + self.vm_b.launch() + self.vm_b.cmd('migrate-set-capabilities', capabilities=mig_caps) + self.vm_b.cmd('migrate-incoming', uri=incoming_cmd) + while True: + event = self.vm_b.event_wait('MIGRATION') + if event['data']['status'] in ('completed', 'failed'): + break + + self.assert_qmp(event, 'data/status', 'failed') + + # A failed incoming load makes the destination process exit on + # its own; reap it so tearDown()'s shutdown() is a clean no-op. + self.vm_b.wait() + def inject_test_case(klass, suffix, method, *args, **kwargs): mc = operator.methodcaller(method, *args, **kwargs)
tests/qemu-iotests/tests/migrate-bitmaps-test.out +2 -2
@@ -1,5 +1,5 @@ -..................................... +...................................... ---------------------------------------------------------------------- -Ran 37 tests +Ran 38 tests OK
Signature · 1 line
2.53.0
Re: [PATCH v2 2/3] migration/block-dirty-bitmap: reject bitmap load onto ro node
Quoted 14 lines · Denis V. Lunev
dirty_bitmap_load_start()creates an incoming migrated bitmap withbdrv_create_dirty_bitmap()and, if the source marked it persistent, callsbdrv_dirty_bitmap_set_persistence()without checking whether the destination node can be written to. Same gap asqmp_block_dirty_bitmap_add(), reached via incoming migration: a persistent bitmap for a read-only destination (e.g. a migrated CD-ROM-class attachment with dirty-bitmaps migration enabled) ends up writable in memory on a node that can never store it.Reject it the same way, with one difference from the QMP path:
every destination node isBDRV_O_INACTIVEuntil migration completes, sobdrv_is_writable()would reject every incoming persistent bitmap, not just read-only ones. Checkbdrv_is_read_only()alone.
Quoted 5 lines
Signed-off-by Denis V. Lunev<[email protected]>CC Eric Blake<[email protected]>CC Vladimir Sementsov-Ogievskiy<[email protected]>CC John Snow<[email protected]>CC Andrey Drobyshev<[email protected]>
Signature · 2 lines
Best regards, Vladimir
PATCH v2 3/3 block/monitor: allow dropping a bitmap never stored on disk
In reply to Denis V. Lunevblock-dirty-bitmap-remove refuses any readonly bitmap outright, via the generic BDRV_BITMAP_RO check in bdrv_dirty_bitmap_check(). That check cannot tell whether the bitmap is actually on disk, so it also blocks dropping one that only ever existed in memory, which needs no write at all.
Drop the blanket check and let qcow2 decide: bdrv_remove_persistent_ dirty_bitmap() already treats an absent on-disk entry as a no-op, so such a bitmap is now released with no write attempted. For one that is genuinely stored, qcow2_co_remove_persistent_dirty_bitmap_locked() now checks can_write() before it would update the on-disk directory, so removal still fails there, with a message naming the actual reason instead of just the bitmap's readonly flag.
--- block/monitor/bitmap-qmp-cmds.c | 4 ++-- block/qcow2-bitmap.c | 9 +++++++++ tests/qemu-iotests/tests/remove-bitmap-from-backing.out | 2 +- 3 files changed, 12 insertions(+), 3 deletions(-)
block/monitor/bitmap-qmp-cmds.c +2 -2
@@ -165,11 +165,11 @@ BdrvDirtyBitmap *block_dirty_bitmap_remove(const char *node, const char *name,return NULL ; } -if (bdrv_dirty_bitmap_check (bitmap,BDRV_BITMAP_BUSY |BDRV_BITMAP_RO , - errp)) { +if (bdrv_dirty_bitmap_check (bitmap,BDRV_BITMAP_BUSY , errp)) {return NULL ; } +/* Dropping a bitmap needs no write access unless it is actually stored. */ if (bdrv_dirty_bitmap_get_persistence (bitmap) &&bdrv_remove_persistent_dirty_bitmap (bs, name, errp) <0 ) {
block/qcow2-bitmap.c +9 -0
@@ -1487,6 +1487,15 @@ int coroutine_fn qcow2_co_remove_persistent_dirty_bitmap(BlockDriverState *bs, goto out; } +if (!can_write (bs)) { +error_setg (errp,"Cannot remove persistent bitmap '%s': " +"no write access to node '%s'" , name, +bdrv_get_node_name (bs)); + ret = -EACCES ; + bm =NULL ; + goto out; + } +QSIMPLEQ_REMOVE (bm_list, bm, Qcow2Bitmap, entry); ret =update_ext_header_and_dir (bs, bm_list);
tests/qemu-iotests/tests/remove-bitmap-from-backing.out +1 -1
@@ -1,6 +1,6 @@ Trying to remove persistent bitmap from r-o base node, should fail: {"execute": "block-dirty-bitmap-remove", "arguments": {"name": "bitmap0", "node": "base"}} -{"error": {"class": "GenericError", "desc": "Bitmap 'bitmap0' is readonly and cannot be modified"}} +{"error": {"class": "GenericError", "desc": "Cannot remove persistent bitmap 'bitmap0': no write access to node 'base'"}} Remove persistent bitmap from base node reopened to RW: {"execute": "block-dirty-bitmap-remove", "arguments": {"name": "bitmap0", "node": "base"}} {"return": {}}
Signature · 1 line
2.53.0
Re: [PATCH v2 3/3] block/monitor: allow dropping a bitmap never stored on disk
Quoted 14 lines · Denis V. Lunev
block-dirty-bitmap-remove refuses any readonly bitmap outright, via the generic
BDRV_BITMAP_ROcheck inbdrv_dirty_bitmap_check(). That check cannot tell whether the bitmap is actually on disk, so it also blocks dropping one that only ever existed in memory, which needs no write at all.Drop the blanket check and let qcow2 decide:
bdrv_remove_persistent_dirty_bitmap()already treats an absent on-disk entry as a no-op, so such a bitmap is now released with no write attempted. For one that is genuinely stored,qcow2_co_remove_persistent_dirty_bitmap_locked()now checkscan_write()before it would update the on-disk directory, so removal still fails there, with a message naming the actual reason instead of just the bitmap's readonly flag.
Quoted 5 lines
Signed-off-by Denis V. Lunev<[email protected]>CC Eric Blake<[email protected]>CC Vladimir Sementsov-Ogievskiy<[email protected]>CC John Snow<[email protected]>CC Andrey Drobyshev<[email protected]>
Signature · 2 lines
Best regards, Vladimir
Quoted 37 lines · Denis V. Lunev
This email originated from an IP that might not be authorized by the domain it was sent from. Do not click links or open attachments unless it is an email you expected to receive.
qmp_block_dirty_bitmap_add()and the incoming-migration bitmap loader
both create a persistent bitmap withbdrv_create_dirty_bitmap(), which
always creates it writable, without checking whether the node can
actually be written to. A persistent bitmap added to an already
read-only or inactive node stays writable in memory on a node that
can never store it, and the next global inactivation (migration
completion, save, or any otherbdrv_inactivate_all()caller) fails
trying to flush it back:Lost persistent bitmaps during inactivation of node '<node>': No write access
migration_block_inactivate:bdrv_inactivate_all()failed: -22Patch 1 rejects this at block-dirty-bitmap-add (and, wrapped in a transaction, denies the whole transaction). Patch 2 closes the same hole on the incoming-migration path. Patch 3 fixes a knock-on regression from patch 1's approach: a bitmap that was rejected from ever being written can still exist in memory read-only and must remain removable without requiring write access.
v1 -> v2
* approach changed to deny rather than adopt (Vladimir)
* added patch to add permission check on migration path
* added patch to change permissions check on bitmap drop to more naturalSigned-off-by Denis V. Lunev <[email protected]>CC Eric Blake <[email protected]>CC Vladimir Sementsov-Ogievskiy <[email protected]>CC John Snow <[email protected]>CC Andrey Drobyshev <[email protected]>Denis V. Lunev (3):
block/monitor: reject persistent bitmap add on a read-only node migration/block-dirty-bitmap: reject bitmap load onto ro node block/monitor: allow dropping a bitmap never stored on disk
Quoted 10 lines
block/monitor/bitmap-qmp-cmds.c | 19 +++++++---- block/qcow2-bitmap.c | 9 +++++ migration/block-dirty-bitmap.c | 22 +++++++++---- qapi/block-core.json | 4 ++- tests/qemu-iotests/tests/migrate-bitmaps-test | 33 +++++++++++++++++++ .../tests/migrate-bitmaps-test.out | 4 +-- .../tests/remove-bitmap-from-backing | 29 +++++++++++++++- .../tests/remove-bitmap-from-backing.out | 22 ++++++++++++- 8 files changed, 124 insertions(+), 18 deletions(-)
Hi, Vladimir!
Will this go through your tree? It is looking like nobody else cares.
Den
Quoted 48 lines · Denis V. Lunev
Quoted 37 lines · Denis V. Lunev
This email originated from an IP that might not be authorized by the domain it was sent from. Do not click links or open attachments unless it is an email you expected to receive.
qmp_block_dirty_bitmap_add()and the incoming-migration bitmap loader
both create a persistent bitmap withbdrv_create_dirty_bitmap(), which
always creates it writable, without checking whether the node can
actually be written to. A persistent bitmap added to an already
read-only or inactive node stays writable in memory on a node that
can never store it, and the next global inactivation (migration
completion, save, or any otherbdrv_inactivate_all()caller) fails
trying to flush it back:Lost persistent bitmaps during inactivation of node '<node>': No write access
migration_block_inactivate:bdrv_inactivate_all()failed: -22Patch 1 rejects this at block-dirty-bitmap-add (and, wrapped in a transaction, denies the whole transaction). Patch 2 closes the same hole on the incoming-migration path. Patch 3 fixes a knock-on regression from patch 1's approach: a bitmap that was rejected from ever being written can still exist in memory read-only and must remain removable without requiring write access.
v1 -> v2
* approach changed to deny rather than adopt (Vladimir)
* added patch to add permission check on migration path
* added patch to change permissions check on bitmap drop to more naturalSigned-off-by Denis V. Lunev <[email protected]>CC Eric Blake <[email protected]>CC Vladimir Sementsov-Ogievskiy <[email protected]>CC John Snow <[email protected]>CC Andrey Drobyshev <[email protected]>Denis V. Lunev (3):
block/monitor: reject persistent bitmap add on a read-only node migration/block-dirty-bitmap: reject bitmap load onto ro node block/monitor: allow dropping a bitmap never stored on diskQuoted 10 lines
block/monitor/bitmap-qmp-cmds.c | 19 +++++++---- block/qcow2-bitmap.c | 9 +++++ migration/block-dirty-bitmap.c | 22 +++++++++---- qapi/block-core.json | 4 ++- tests/qemu-iotests/tests/migrate-bitmaps-test | 33 +++++++++++++++++++ .../tests/migrate-bitmaps-test.out | 4 +-- .../tests/remove-bitmap-from-backing | 29 +++++++++++++++- .../tests/remove-bitmap-from-backing.out | 22 ++++++++++++- 8 files changed, 124 insertions(+), 18 deletions(-)
Quoted 4 lines
Hi, Vladimir!
Will this go through your tree? It is looking like nobody else cares.
Yes, seems so. Thanks, applied to my block branch.
There's still a chance to stop me within 2-3 weeks before 11.2 cycle opens.
Signature · 2 lines
Best regards, Vladimir
Quoted 49 lines · Vladimir Sementsov-Ogievskiy
Quoted 48 lines · Denis V. Lunev
Quoted 47 lines · Denis V. Lunev
This email originated from an IP that might not be authorized by the domain it was sent from. Do not click links or open attachments unless it is an email you expected to receive.
qmp_block_dirty_bitmap_add()and the incoming-migration bitmap loader
both create a persistent bitmap withbdrv_create_dirty_bitmap(), which
always creates it writable, without checking whether the node can
actually be written to. A persistent bitmap added to an already
read-only or inactive node stays writable in memory on a node that
can never store it, and the next global inactivation (migration
completion, save, or any otherbdrv_inactivate_all()caller) fails
trying to flush it back:Lost persistent bitmaps during inactivation of node '<node>': No write access
migration_block_inactivate:bdrv_inactivate_all()failed: -22Patch 1 rejects this at block-dirty-bitmap-add (and, wrapped in a transaction, denies the whole transaction). Patch 2 closes the same hole on the incoming-migration path. Patch 3 fixes a knock-on regression from patch 1's approach: a bitmap that was rejected from ever being written can still exist in memory read-only and must remain removable without requiring write access.
v1 -> v2
* approach changed to deny rather than adopt (Vladimir)
* added patch to add permission check on migration path
* added patch to change permissions check on bitmap drop to more naturalSigned-off-by Denis V. Lunev <[email protected]>CC Eric Blake <[email protected]>CC Vladimir Sementsov-Ogievskiy <[email protected]>CC John Snow <[email protected]>CC Andrey Drobyshev <[email protected]>Denis V. Lunev (3):
block/monitor: reject persistent bitmap add on a read-only node migration/block-dirty-bitmap: reject bitmap load onto ro node block/monitor: allow dropping a bitmap never stored on diskblock/monitor/bitmap-qmp-cmds.c | 19 +++++++---- block/qcow2-bitmap.c | 9 +++++ migration/block-dirty-bitmap.c | 22 +++++++++---- qapi/block-core.json | 4 ++- tests/qemu-iotests/tests/migrate-bitmaps-test | 33 +++++++++++++++++++ .../tests/migrate-bitmaps-test.out | 4 +-- .../tests/remove-bitmap-from-backing | 29 +++++++++++++++- .../tests/remove-bitmap-from-backing.out | 22 ++++++++++++- 8 files changed, 124 insertions(+), 18 deletions(-)
Quoted 8 lines
Quoted 4 lines
Hi, Vladimir!
Will this go through your tree? It is looking like nobody else cares.
Yes, seems so. Thanks, applied to my block branch.
There's still a chance to stop me within 2-3 weeks before 11.2 cycle opens.
Hmmm :-)
11.2 seems opened. Is it right time to push?
Thank you in advance,
Den
Quoted 54 lines · Denis V. Lunev
Quoted 53 lines · Vladimir Sementsov-Ogievskiy
Quoted 52 lines · Denis V. Lunev
Quoted 37 lines · Denis V. Lunev
This email originated from an IP that might not be authorized by the domain it was sent from. Do not click links or open attachments unless it is an email you expected to receive.
qmp_block_dirty_bitmap_add()and the incoming-migration bitmap loader
both create a persistent bitmap withbdrv_create_dirty_bitmap(), which
always creates it writable, without checking whether the node can
actually be written to. A persistent bitmap added to an already
read-only or inactive node stays writable in memory on a node that
can never store it, and the next global inactivation (migration
completion, save, or any otherbdrv_inactivate_all()caller) fails
trying to flush it back:Lost persistent bitmaps during inactivation of node '<node>': No write access
migration_block_inactivate:bdrv_inactivate_all()failed: -22Patch 1 rejects this at block-dirty-bitmap-add (and, wrapped in a transaction, denies the whole transaction). Patch 2 closes the same hole on the incoming-migration path. Patch 3 fixes a knock-on regression from patch 1's approach: a bitmap that was rejected from ever being written can still exist in memory read-only and must remain removable without requiring write access.
v1 -> v2
* approach changed to deny rather than adopt (Vladimir)
* added patch to add permission check on migration path
* added patch to change permissions check on bitmap drop to more naturalSigned-off-by Denis V. Lunev <[email protected]>CC Eric Blake <[email protected]>CC Vladimir Sementsov-Ogievskiy <[email protected]>CC John Snow <[email protected]>CC Andrey Drobyshev <[email protected]>Denis V. Lunev (3):
block/monitor: reject persistent bitmap add on a read-only node migration/block-dirty-bitmap: reject bitmap load onto ro node block/monitor: allow dropping a bitmap never stored on diskQuoted 10 lines
block/monitor/bitmap-qmp-cmds.c | 19 +++++++---- block/qcow2-bitmap.c | 9 +++++ migration/block-dirty-bitmap.c | 22 +++++++++---- qapi/block-core.json | 4 ++- tests/qemu-iotests/tests/migrate-bitmaps-test | 33 +++++++++++++++++++ .../tests/migrate-bitmaps-test.out | 4 +-- .../tests/remove-bitmap-from-backing | 29 +++++++++++++++- .../tests/remove-bitmap-from-backing.out | 22 ++++++++++++- 8 files changed, 124 insertions(+), 18 deletions(-)Hi, Vladimir!
Will this go through your tree? It is looking like nobody else cares.
Quoted 8 lines
Quoted 4 lines
Yes, seems so. Thanks, applied to my block branch.
There's still a chance to stop me within 2-3 weeks before 11.2 cycle opens.
Hmmm :-)
11.2 seems opened. Is it right time to push?
Was on vacation :). Will do this week.
Signature · 2 lines
Best regards, Vladimir