mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-05 16:53:55 -06:00
nbd: make nbd_drop public
Following commit will reuse it for nbd server too. Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Message-Id: <20170602150150.258222-3-vsementsov@virtuozzo.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
d1fdf257d5
commit
44298024d3
3 changed files with 28 additions and 26 deletions
26
nbd/client.c
26
nbd/client.c
|
@ -86,32 +86,6 @@ static QTAILQ_HEAD(, NBDExport) exports = QTAILQ_HEAD_INITIALIZER(exports);
|
|||
|
||||
*/
|
||||
|
||||
/* Discard length bytes from channel. Return -errno on failure and 0 on
|
||||
* success*/
|
||||
static int nbd_drop(QIOChannel *ioc, size_t size, Error **errp)
|
||||
{
|
||||
ssize_t ret = 0;
|
||||
char small[1024];
|
||||
char *buffer;
|
||||
|
||||
buffer = sizeof(small) >= size ? small : g_malloc(MIN(65536, size));
|
||||
while (size > 0) {
|
||||
ssize_t count = MIN(65536, size);
|
||||
ret = nbd_read(ioc, buffer, MIN(65536, size), errp);
|
||||
|
||||
if (ret < 0) {
|
||||
goto cleanup;
|
||||
}
|
||||
size -= count;
|
||||
}
|
||||
|
||||
cleanup:
|
||||
if (buffer != small) {
|
||||
g_free(buffer);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Send an option request.
|
||||
*
|
||||
* The request is for option @opt, with @data containing @len bytes of
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue