提交 b6aedd2f 编写于 作者: M Michal Privoznik

Introduce virStreamRecvHole

This function is basically a counterpart for virStreamSendHole().
If one side of a stream called virStreamSendHole() the other
should call virStreamRecvHole() to get the size of the hole.
Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
上级 69a573d0
...@@ -54,6 +54,10 @@ int virStreamSendHole(virStreamPtr st, ...@@ -54,6 +54,10 @@ int virStreamSendHole(virStreamPtr st,
long long length, long long length,
unsigned int flags); unsigned int flags);
int virStreamRecvHole(virStreamPtr,
long long *length,
unsigned int flags);
/** /**
* virStreamSourceFunc: * virStreamSourceFunc:
......
...@@ -46,6 +46,11 @@ typedef int ...@@ -46,6 +46,11 @@ typedef int
long long length, long long length,
unsigned int flags); unsigned int flags);
typedef int
(*virDrvStreamRecvHole)(virStreamPtr st,
long long *length,
unsigned int flags);
typedef int typedef int
(*virDrvStreamEventAddCallback)(virStreamPtr stream, (*virDrvStreamEventAddCallback)(virStreamPtr stream,
int events, int events,
...@@ -74,6 +79,7 @@ struct _virStreamDriver { ...@@ -74,6 +79,7 @@ struct _virStreamDriver {
virDrvStreamRecv streamRecv; virDrvStreamRecv streamRecv;
virDrvStreamRecvFlags streamRecvFlags; virDrvStreamRecvFlags streamRecvFlags;
virDrvStreamSendHole streamSendHole; virDrvStreamSendHole streamSendHole;
virDrvStreamRecvHole streamRecvHole;
virDrvStreamEventAddCallback streamEventAddCallback; virDrvStreamEventAddCallback streamEventAddCallback;
virDrvStreamEventUpdateCallback streamEventUpdateCallback; virDrvStreamEventUpdateCallback streamEventUpdateCallback;
virDrvStreamEventRemoveCallback streamEventRemoveCallback; virDrvStreamEventRemoveCallback streamEventRemoveCallback;
......
...@@ -405,6 +405,50 @@ virStreamSendHole(virStreamPtr stream, ...@@ -405,6 +405,50 @@ virStreamSendHole(virStreamPtr stream,
} }
/**
* virStreamRecvHole:
* @stream: pointer to the stream object
* @length: number of bytes to skip
* @flags: extra flags; not used yet, so callers should always pass 0
*
* This API is used to determine the @length in bytes of the
* empty space to be created in a @stream's target file when
* uploading or downloading sparsely populated files. This is the
* counterpart to virStreamSendHole().
*
* Returns 0 on success,
* -1 on error or when there's currently no hole in the stream
*/
int
virStreamRecvHole(virStreamPtr stream,
long long *length,
unsigned int flags)
{
VIR_DEBUG("stream=%p, length=%p flags=%x",
stream, length, flags);
virResetLastError();
virCheckStreamReturn(stream, -1);
virCheckNonNullArgReturn(length, -1);
if (stream->driver &&
stream->driver->streamRecvHole) {
int ret;
ret = (stream->driver->streamRecvHole)(stream, length, flags);
if (ret < 0)
goto error;
return ret;
}
virReportUnsupportedError();
error:
virDispatchError(stream->conn);
return -1;
}
/** /**
* virStreamSendAll: * virStreamSendAll:
* @stream: pointer to the stream object * @stream: pointer to the stream object
......
...@@ -762,6 +762,7 @@ LIBVIRT_3.1.0 { ...@@ -762,6 +762,7 @@ LIBVIRT_3.1.0 {
LIBVIRT_3.4.0 { LIBVIRT_3.4.0 {
global: global:
virStreamRecvFlags; virStreamRecvFlags;
virStreamRecvHole;
virStreamSendHole; virStreamSendHole;
} LIBVIRT_3.1.0; } LIBVIRT_3.1.0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册