mirror of
https://github.com/mii443/qemu.git
synced 2025-08-22 15:15:46 +00:00
nbd: Merge nbd_export_bitmap into nbd_export_new
We only have one caller that wants to export a bitmap name, which it does right after creation of the export. But there is still a brief window of time where an NBD client could see the export but not the dirty bitmap, which a robust client would have to interpret as meaning the entire image should be treated as dirty. Better is to eliminate the window entirely, by inlining nbd_export_bitmap() into nbd_export_new(), and refusing to create the bitmap in the first place if the requested bitmap can't be located. We also no longer need logic for setting a different bitmap name compared to the bitmap being exported. Signed-off-by: Eric Blake <eblake@redhat.com> Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Message-Id: <20190111194720.15671-8-eblake@redhat.com>
This commit is contained in:
@ -175,7 +175,7 @@ void qmp_nbd_server_add(const char *device, bool has_name, const char *name,
|
||||
writable = false;
|
||||
}
|
||||
|
||||
exp = nbd_export_new(bs, 0, -1, name, NULL,
|
||||
exp = nbd_export_new(bs, 0, -1, name, NULL, bitmap,
|
||||
writable ? 0 : NBD_FLAG_READ_ONLY,
|
||||
NULL, false, on_eject_blk, errp);
|
||||
if (!exp) {
|
||||
@ -186,15 +186,6 @@ void qmp_nbd_server_add(const char *device, bool has_name, const char *name,
|
||||
* our only way of accessing it is through nbd_export_find(), so we can drop
|
||||
* the strong reference that is @exp. */
|
||||
nbd_export_put(exp);
|
||||
|
||||
if (has_bitmap) {
|
||||
Error *err = NULL;
|
||||
nbd_export_bitmap(exp, bitmap, bitmap, &err);
|
||||
if (err) {
|
||||
error_propagate(errp, err);
|
||||
nbd_export_remove(exp, NBD_SERVER_REMOVE_MODE_HARD, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void qmp_nbd_server_remove(const char *name,
|
||||
|
Reference in New Issue
Block a user