mirror of
https://github.com/libvirt/libvirt.git
synced 2026-09-03 20:53:04 -05:00
virsh: Implement sparse stream to vol-upload
Similarly to previous commit, implement sparse streams feature for vol-upload. This is, however, slightly different approach, because we must implement a function that will tell us whether we are in a data section or in a hole. But there's no magic hidden in here. Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
@@ -153,6 +153,35 @@ virshStreamSink(virStreamPtr st ATTRIBUTE_UNUSED,
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
virshStreamSource(virStreamPtr st ATTRIBUTE_UNUSED,
|
||||
char *bytes,
|
||||
size_t nbytes,
|
||||
void *opaque)
|
||||
{
|
||||
virshStreamCallbackDataPtr cbData = opaque;
|
||||
int fd = cbData->fd;
|
||||
|
||||
return saferead(fd, bytes, nbytes);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
virshStreamSourceSkip(virStreamPtr st ATTRIBUTE_UNUSED,
|
||||
long long offset,
|
||||
void *opaque)
|
||||
{
|
||||
virshStreamCallbackDataPtr cbData = opaque;
|
||||
int fd = cbData->fd;
|
||||
off_t cur;
|
||||
|
||||
if ((cur = lseek(fd, offset, SEEK_CUR)) == (off_t) -1)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
virshStreamSkip(virStreamPtr st ATTRIBUTE_UNUSED,
|
||||
long long offset,
|
||||
@@ -171,6 +200,24 @@ virshStreamSkip(virStreamPtr st ATTRIBUTE_UNUSED,
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
virshStreamInData(virStreamPtr st ATTRIBUTE_UNUSED,
|
||||
int *inData,
|
||||
long long *offset,
|
||||
void *opaque)
|
||||
{
|
||||
virshStreamCallbackDataPtr cbData = opaque;
|
||||
vshControl *ctl = cbData->ctl;
|
||||
int fd = cbData->fd;
|
||||
int ret;
|
||||
|
||||
if ((ret = virFileInData(fd, inData, offset)) < 0)
|
||||
vshError(ctl, "%s", _("Unable to get current position in stream"));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
virshDomainFree(virDomainPtr dom)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user