nbd patches for 2020-02-26
- ensure multiple meta contexts work - allow leading / in export names - fix a failure path memory leak -----BEGIN PGP SIGNATURE----- iQEzBAABCAAdFiEEccLMIrHEYCkn0vOqp6FrSiUnQ2oFAl5XIP8ACgkQp6FrSiUn Q2qgWQf/avHGRCHHkvOQ6UIgwtp4FSQ8u2MVYOq9FGjeg2xOEYND1aZtGGQB5+4/ ZntVtMFNLz2pbyx61Wtg1bcczujC5p9pEZ+DtgQ9x+2fqCVaaGYwrXy/zgP2eoUI L8F0YOTJRGmPKDCVOwLNnuISSvwnI/QWK8iCE15HtBx1eEaWovO3gRAAvPlvVVZd YR7ZNTWueltx7oQf56YGj3tPrNXfDz8eU7ZmBtAs7cO6V8ZJI8mVIZQ7LvsBFUT9 aW674jV8UEorDFiZjWYRMI8hq/YKjU2GvoHoMb4cLdpXc9PdymC1gXxlV5vHaQqo EGaZlSUFRJmq/ao6pzJsmgZBrX/iPw== =sv4e -----END PGP SIGNATURE----- Merge remote-tracking branch 'remotes/ericb/tags/pull-nbd-2020-02-26' into staging nbd patches for 2020-02-26 - ensure multiple meta contexts work - allow leading / in export names - fix a failure path memory leak # gpg: Signature made Thu 27 Feb 2020 01:53:03 GMT # gpg: using RSA key 71C2CC22B1C4602927D2F3AAA7A16B4A2527436A # gpg: Good signature from "Eric Blake <eblake@redhat.com>" [full] # gpg: aka "Eric Blake (Free Software Programmer) <ebb9@byu.net>" [full] # gpg: aka "[jpeg image of size 6874]" [full] # Primary key fingerprint: 71C2 CC22 B1C4 6029 27D2 F3AA A7A1 6B4A 2527 436A * remotes/ericb/tags/pull-nbd-2020-02-26: block/nbd: fix memory leak in nbd_open() block/nbd: extract the common cleanup code nbd-client: Support leading / in NBD URI nbd: Fix regression with multiple meta contexts Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
commit
a7cfd219d5
33
block/nbd.c
33
block/nbd.c
@ -95,6 +95,19 @@ typedef struct BDRVNBDState {
|
||||
|
||||
static int nbd_client_connect(BlockDriverState *bs, Error **errp);
|
||||
|
||||
static void nbd_clear_bdrvstate(BDRVNBDState *s)
|
||||
{
|
||||
object_unref(OBJECT(s->tlscreds));
|
||||
qapi_free_SocketAddress(s->saddr);
|
||||
s->saddr = NULL;
|
||||
g_free(s->export);
|
||||
s->export = NULL;
|
||||
g_free(s->tlscredsid);
|
||||
s->tlscredsid = NULL;
|
||||
g_free(s->x_dirty_bitmap);
|
||||
s->x_dirty_bitmap = NULL;
|
||||
}
|
||||
|
||||
static void nbd_channel_error(BDRVNBDState *s, int ret)
|
||||
{
|
||||
if (ret == -EIO) {
|
||||
@ -1528,8 +1541,10 @@ static int nbd_parse_uri(const char *filename, QDict *options)
|
||||
goto out;
|
||||
}
|
||||
|
||||
p = uri->path ? uri->path : "/";
|
||||
p += strspn(p, "/");
|
||||
p = uri->path ? uri->path : "";
|
||||
if (p[0] == '/') {
|
||||
p++;
|
||||
}
|
||||
if (p[0]) {
|
||||
qdict_put_str(options, "export", p);
|
||||
}
|
||||
@ -1877,11 +1892,7 @@ static int nbd_process_options(BlockDriverState *bs, QDict *options,
|
||||
|
||||
error:
|
||||
if (ret < 0) {
|
||||
object_unref(OBJECT(s->tlscreds));
|
||||
qapi_free_SocketAddress(s->saddr);
|
||||
g_free(s->export);
|
||||
g_free(s->tlscredsid);
|
||||
g_free(s->x_dirty_bitmap);
|
||||
nbd_clear_bdrvstate(s);
|
||||
}
|
||||
qemu_opts_del(opts);
|
||||
return ret;
|
||||
@ -1904,6 +1915,7 @@ static int nbd_open(BlockDriverState *bs, QDict *options, int flags,
|
||||
|
||||
ret = nbd_client_connect(bs, errp);
|
||||
if (ret < 0) {
|
||||
nbd_clear_bdrvstate(s);
|
||||
return ret;
|
||||
}
|
||||
/* successfully connected */
|
||||
@ -1960,12 +1972,7 @@ static void nbd_close(BlockDriverState *bs)
|
||||
BDRVNBDState *s = bs->opaque;
|
||||
|
||||
nbd_client_close(bs);
|
||||
|
||||
object_unref(OBJECT(s->tlscreds));
|
||||
qapi_free_SocketAddress(s->saddr);
|
||||
g_free(s->export);
|
||||
g_free(s->tlscredsid);
|
||||
g_free(s->x_dirty_bitmap);
|
||||
nbd_clear_bdrvstate(s);
|
||||
}
|
||||
|
||||
static int64_t nbd_getlength(BlockDriverState *bs)
|
||||
|
12
nbd/server.c
12
nbd/server.c
@ -2384,15 +2384,23 @@ static coroutine_fn int nbd_handle_request(NBDClient *client,
|
||||
!client->export_meta.bitmap,
|
||||
NBD_META_ID_BASE_ALLOCATION,
|
||||
errp);
|
||||
} else { /* client->export_meta.bitmap */
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
if (client->export_meta.bitmap) {
|
||||
ret = nbd_co_send_bitmap(client, request->handle,
|
||||
client->exp->export_bitmap,
|
||||
request->from, request->len,
|
||||
dont_fragment,
|
||||
true, NBD_META_ID_DIRTY_BITMAP, errp);
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
return 0;
|
||||
} else {
|
||||
return nbd_send_generic_reply(client, request->handle, -EINVAL,
|
||||
"CMD_BLOCK_STATUS not negotiated",
|
||||
|
Loading…
Reference in New Issue
Block a user