RFC: implement reopen for nbd driver
cover RFC: implement reopen for nbd driver
Hi,
It looks like nbd driver doesn't have support for reopen, which doesn't allow to commit qcow2 snapshots which have nbd export as a base file.
This is because the base is opened read-only, and only when commit job starts it reopens the base read-write.
Now after talking with Eric Blake, I understood that nbd doesn't have the ability to tell the server to open read/only and then change this on the fly, thus even when opening an export as read-only the server will still allow writes.
This means that an empty .bdrv_reopen_prepare
(well except checking that export is not read-only) is supposed to be enough.
Sending this as RFC, since I am not sure that this is the correct solution.
Best regards,
Maxim Levitsky
Maxim Levitsky (1):
nbd: add empty .bdrv_reopen_prepare
block/nbd.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
Signature · 1 line
2.17.2
PATCH 1/1 nbd: add empty .bdrv_reopen_prepare
Fixes commit job / qemu-img commit, when commiting qcow2 file which is based on nbd export.
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1718727
--- block/nbd.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
block/nbd.c +15 -0
@@ -1158,6 +1158,18 @@ static int coroutine_fn nbd_client_co_block_status(BDRV_BLOCK_OFFSET_VALID ; } +static int nbd_client_reopen_prepare (BDRVReopenState *state, +BlockReopenQueue *queue,Error **errp) +{ +BDRVNBDState *s = (BDRVNBDState *)state->bs->opaque; + +if ((state->flags &BDRV_O_RDWR ) && (s->info.flags &NBD_FLAG_READ_ONLY )) { +error_setg (errp,"Can't reopen read-only NBD mount as read/write" ); +return -EACCES ; + } +return 0 ; +} +static void nbd_client_close (BlockDriverState *bs) {BDRVNBDState *s = (BDRVNBDState *)bs->opaque;
@@ -1798,6 +1810,7 @@ static BlockDriver bdrv_nbd = { .instance_size = sizeof(BDRVNBDState), .bdrv_parse_filename = nbd_parse_filename, .bdrv_file_open = nbd_open, + .bdrv_reopen_prepare = nbd_client_reopen_prepare, .bdrv_co_preadv = nbd_client_co_preadv, .bdrv_co_pwritev = nbd_client_co_pwritev, .bdrv_co_pwrite_zeroes = nbd_client_co_pwrite_zeroes,
@@ -1820,6 +1833,7 @@ static BlockDriver bdrv_nbd_tcp = { .instance_size = sizeof(BDRVNBDState), .bdrv_parse_filename = nbd_parse_filename, .bdrv_file_open = nbd_open, + .bdrv_reopen_prepare = nbd_client_reopen_prepare, .bdrv_co_preadv = nbd_client_co_preadv, .bdrv_co_pwritev = nbd_client_co_pwritev, .bdrv_co_pwrite_zeroes = nbd_client_co_pwrite_zeroes,
@@ -1842,6 +1856,7 @@ static BlockDriver bdrv_nbd_unix = { .instance_size = sizeof(BDRVNBDState), .bdrv_parse_filename = nbd_parse_filename, .bdrv_file_open = nbd_open, + .bdrv_reopen_prepare = nbd_client_reopen_prepare, .bdrv_co_preadv = nbd_client_co_preadv, .bdrv_co_pwritev = nbd_client_co_pwritev, .bdrv_co_pwrite_zeroes = nbd_client_co_pwrite_zeroes,
Signature · 1 line
2.17.2
Max Reitz
AppliedRe: [PATCH 1/1] nbd: add empty .bdrv_reopen_prepare
Quoted 10 lines · Maxim Levitsky
Fixes commit job / qemu-img commit, when commiting qcow2 file which is based on nbd export.
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1718727
Signed-off-by Maxim Levitsky <[email protected]>--- block/nbd.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
Thanks, applied to my block branch:
https://git.xanclic.moe/XanClic/qemu/commits/branch/block
Max
Patchew URL: https://patchew.org/QEMU/[email protected]/
Patchew URL: https://patchew.org/QEMU/[email protected]/
Hi,
This series failed the asan build test. Please find the testing commands and their output below. If you have Docker installed, you can probably reproduce it locally.
=== TEST SCRIPT BEGIN ===
#!/bin/bash
export ARCH=x86_64
make docker-image-fedora V=1 NETWORK=1
time make docker-test-debug@fedora TARGET_LIST=x86_64-softmmu J=14 NETWORK=1 === TEST SCRIPT END ===
The full log is available at
http://patchew.org/logs/[email protected]/testing.asan/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]