Message ID | 49563de9ab9c17295ecc2a4894b49ae14afe901e.1570482718.git.crobinso@redhat.com |
---|---|
State | Accepted |
Commit | 86998996928f4baa8d02b6e7349bf09cf92ed0c9 |
Headers | show |
Series | storagefile, security: qcow2 data_file support | expand |
On 10/7/19 6:49 PM, Cole Robinson wrote: > Letting qcowXGetBackingStore fill in format gives the same behavior > we were opencoding in qcow1GetBackingStore > > Signed-off-by: Cole Robinson <crobinso@redhat.com> > --- Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com> > src/util/virstoragefile.c | 19 +++++-------------- > 1 file changed, 5 insertions(+), 14 deletions(-) > > diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c > index 016c8f0799..905e70b1a9 100644 > --- a/src/util/virstoragefile.c > +++ b/src/util/virstoragefile.c > @@ -494,8 +494,7 @@ qcowXGetBackingStore(char **res, > int version; > > *res = NULL; > - if (format) > - *format = VIR_STORAGE_FILE_AUTO; > + *format = VIR_STORAGE_FILE_AUTO; > > if (buf_size < QCOWX_HDR_BACKING_FILE_OFFSET+8+4) > return BACKING_STORE_INVALID; > @@ -504,15 +503,13 @@ qcowXGetBackingStore(char **res, > return BACKING_STORE_INVALID; > > if (offset == 0) { > - if (format) > - *format = VIR_STORAGE_FILE_NONE; > + *format = VIR_STORAGE_FILE_NONE; > return BACKING_STORE_OK; > } > > size = virReadBufInt32BE(buf + QCOWX_HDR_BACKING_FILE_SIZE); > if (size == 0) { > - if (format) > - *format = VIR_STORAGE_FILE_NONE; > + *format = VIR_STORAGE_FILE_NONE; > return BACKING_STORE_OK; > } > if (size > 1023) > @@ -551,7 +548,7 @@ qcowXGetBackingStore(char **res, > * for qcow2 v3 images, the length of the header > * is stored at QCOW2v3_HDR_SIZE > */ > - if (isQCow2 && format) { > + if (isQCow2) { > version = virReadBufInt32BE(buf + QCOWX_HDR_VERSION); > if (version == 2) > start = QCOW2_HDR_TOTAL_SIZE; > @@ -572,15 +569,9 @@ qcow1GetBackingStore(char **res, > const char *buf, > size_t buf_size) > { > - int ret; > - > /* QCow1 doesn't have the extensions capability > * used to store backing format */ > - *format = VIR_STORAGE_FILE_AUTO; > - ret = qcowXGetBackingStore(res, NULL, buf, buf_size, false); > - if (ret == BACKING_STORE_OK && !*res) > - *format = VIR_STORAGE_FILE_NONE; > - return ret; > + return qcowXGetBackingStore(res, format, buf, buf_size, false); > } > > static int -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index 016c8f0799..905e70b1a9 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -494,8 +494,7 @@ qcowXGetBackingStore(char **res, int version; *res = NULL; - if (format) - *format = VIR_STORAGE_FILE_AUTO; + *format = VIR_STORAGE_FILE_AUTO; if (buf_size < QCOWX_HDR_BACKING_FILE_OFFSET+8+4) return BACKING_STORE_INVALID; @@ -504,15 +503,13 @@ qcowXGetBackingStore(char **res, return BACKING_STORE_INVALID; if (offset == 0) { - if (format) - *format = VIR_STORAGE_FILE_NONE; + *format = VIR_STORAGE_FILE_NONE; return BACKING_STORE_OK; } size = virReadBufInt32BE(buf + QCOWX_HDR_BACKING_FILE_SIZE); if (size == 0) { - if (format) - *format = VIR_STORAGE_FILE_NONE; + *format = VIR_STORAGE_FILE_NONE; return BACKING_STORE_OK; } if (size > 1023) @@ -551,7 +548,7 @@ qcowXGetBackingStore(char **res, * for qcow2 v3 images, the length of the header * is stored at QCOW2v3_HDR_SIZE */ - if (isQCow2 && format) { + if (isQCow2) { version = virReadBufInt32BE(buf + QCOWX_HDR_VERSION); if (version == 2) start = QCOW2_HDR_TOTAL_SIZE; @@ -572,15 +569,9 @@ qcow1GetBackingStore(char **res, const char *buf, size_t buf_size) { - int ret; - /* QCow1 doesn't have the extensions capability * used to store backing format */ - *format = VIR_STORAGE_FILE_AUTO; - ret = qcowXGetBackingStore(res, NULL, buf, buf_size, false); - if (ret == BACKING_STORE_OK && !*res) - *format = VIR_STORAGE_FILE_NONE; - return ret; + return qcowXGetBackingStore(res, format, buf, buf_size, false); } static int
Letting qcowXGetBackingStore fill in format gives the same behavior we were opencoding in qcow1GetBackingStore Signed-off-by: Cole Robinson <crobinso@redhat.com> --- src/util/virstoragefile.c | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) -- 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list