[libvirt] [PATCH 4/6] storage: Make virStorageFileReadHeader more universal

Peter Krempa pkrempa at redhat.com
Tue Jul 11 15:04:11 UTC 2017


On Sat, Jul 01, 2017 at 10:43:09 -0400, John Ferlan wrote:
> 
> 
> On 06/23/2017 09:33 AM, Peter Krempa wrote:
> > Allow specifying offset to read an arbitrary position in the file. This
> > warrants a rename to virStorageFileRead.
> > ---
> >  src/qemu/qemu_driver.c                |  3 +--
> >  src/storage/storage_backend.h         |  9 +++++----
> >  src/storage/storage_backend_fs.c      | 20 +++++++++++++------
> >  src/storage/storage_backend_gluster.c | 37 ++++++++++++++++++++++-------------
> >  src/storage/storage_source.c          | 30 +++++++++++++++-------------
> >  src/storage/storage_source.h          |  7 ++++---
> >  6 files changed, 63 insertions(+), 43 deletions(-)
> > 
> 
> [...]
> 
> > diff --git a/src/storage/storage_backend_gluster.c b/src/storage/storage_backend_gluster.c
> > index 93dce4042..8ea7e603c 100644
> > --- a/src/storage/storage_backend_gluster.c
> > +++ b/src/storage/storage_backend_gluster.c

[...]

> > @@ -292,7 +292,7 @@ virStorageBackendGlusterRefreshVol(virStorageBackendGlusterStatePtr state,
> >          goto cleanup;
> >      }
> > 
> 
> Should :
> 
>     ssize_t len = VIR_STORAGE_MAX_HEADER;
> 
> change to size_t and a new variable "ssize_t read_len" be created and
> used for the following and subsequent virStorageFileGetMetadataFromBuf
> call?  (although that also takes a size_t for the 3rd param).

I actually just used VIR_STORAGE_MAX_HEADER constant directly in the
call of virStorageBackendGlusterRead. The original variable will thus be
used only for the return value, which is signed.


> 
> > -    if ((len = virStorageBackendGlusterReadHeader(fd, name, len, &header)) < 0)
> > +    if ((len = virStorageBackendGlusterRead(fd, name, len, &header)) < 0)
> >          goto cleanup;
> > 
> >      if (!(meta = virStorageFileGetMetadataFromBuf(name, header, len,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20170711/d35afcba/attachment-0001.sig>


More information about the libvir-list mailing list