diff options
author | Kevin Wolf <kwolf@redhat.com> | 2020-09-24 17:26:53 +0200 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2020-10-02 15:46:40 +0200 |
commit | 9b562c646bc0ad5fca3cfa00720e431c7e72769a (patch) | |
tree | 59134ba5b6a31c3058328a7ddbf2540a8373c6e9 /block | |
parent | b57e4de079d90caca05fed5b45aeb642c6c29aa0 (diff) | |
download | qemu-9b562c646bc0ad5fca3cfa00720e431c7e72769a.zip qemu-9b562c646bc0ad5fca3cfa00720e431c7e72769a.tar.gz qemu-9b562c646bc0ad5fca3cfa00720e431c7e72769a.tar.bz2 |
block/export: Remove magic from block-export-add
nbd-server-add tries to be convenient and adds two questionable
features that we don't want to share in block-export-add, even for NBD
exports:
1. When requesting a writable export of a read-only device, the export
is silently downgraded to read-only. This should be an error in the
context of block-export-add.
2. When using a BlockBackend name, unplugging the device from the guest
will automatically stop the NBD server, too. This may sometimes be
what you want, but it could also be very surprising. Let's keep
things explicit with block-export-add. If the user wants to stop the
export, they should tell us so.
Move these things into the nbd-server-add QMP command handler so that
they apply only there.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Message-Id: <20200924152717.287415-8-kwolf@redhat.com>
Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block')
-rw-r--r-- | block/export/export.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/block/export/export.c b/block/export/export.c index fd65541..05bc5e3 100644 --- a/block/export/export.c +++ b/block/export/export.c @@ -13,6 +13,8 @@ #include "qemu/osdep.h" +#include "block/block.h" +#include "sysemu/block-backend.h" #include "block/export.h" #include "block/nbd.h" #include "qapi/error.h" @@ -34,15 +36,20 @@ static const BlockExportDriver *blk_exp_find_driver(BlockExportType type) return NULL; } -void qmp_block_export_add(BlockExportOptions *export, Error **errp) +BlockExport *blk_exp_add(BlockExportOptions *export, Error **errp) { const BlockExportDriver *drv; drv = blk_exp_find_driver(export->type); if (!drv) { error_setg(errp, "No driver found for the requested export type"); - return; + return NULL; } - drv->create(export, errp); + return drv->create(export, errp); +} + +void qmp_block_export_add(BlockExportOptions *export, Error **errp) +{ + blk_exp_add(export, errp); } |