提交 86998996 编写于 作者: C Cole Robinson

storagefile: qcow1: Let qcowXGetBackingStore fill in format

Letting qcowXGetBackingStore fill in format gives the same behavior
we were opencoding in qcow1GetBackingStore
Reviewed-by: NDaniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: NMichal Privoznik <mprivozn@redhat.com>
Signed-off-by: NCole Robinson <crobinso@redhat.com>
上级 b0061687
...@@ -494,8 +494,7 @@ qcowXGetBackingStore(char **res, ...@@ -494,8 +494,7 @@ qcowXGetBackingStore(char **res,
int version; int version;
*res = NULL; *res = NULL;
if (format) *format = VIR_STORAGE_FILE_AUTO;
*format = VIR_STORAGE_FILE_AUTO;
if (buf_size < QCOWX_HDR_BACKING_FILE_OFFSET+8+4) if (buf_size < QCOWX_HDR_BACKING_FILE_OFFSET+8+4)
return BACKING_STORE_INVALID; return BACKING_STORE_INVALID;
...@@ -504,15 +503,13 @@ qcowXGetBackingStore(char **res, ...@@ -504,15 +503,13 @@ qcowXGetBackingStore(char **res,
return BACKING_STORE_INVALID; return BACKING_STORE_INVALID;
if (offset == 0) { if (offset == 0) {
if (format) *format = VIR_STORAGE_FILE_NONE;
*format = VIR_STORAGE_FILE_NONE;
return BACKING_STORE_OK; return BACKING_STORE_OK;
} }
size = virReadBufInt32BE(buf + QCOWX_HDR_BACKING_FILE_SIZE); size = virReadBufInt32BE(buf + QCOWX_HDR_BACKING_FILE_SIZE);
if (size == 0) { if (size == 0) {
if (format) *format = VIR_STORAGE_FILE_NONE;
*format = VIR_STORAGE_FILE_NONE;
return BACKING_STORE_OK; return BACKING_STORE_OK;
} }
if (size > 1023) if (size > 1023)
...@@ -551,7 +548,7 @@ qcowXGetBackingStore(char **res, ...@@ -551,7 +548,7 @@ qcowXGetBackingStore(char **res,
* for qcow2 v3 images, the length of the header * for qcow2 v3 images, the length of the header
* is stored at QCOW2v3_HDR_SIZE * is stored at QCOW2v3_HDR_SIZE
*/ */
if (isQCow2 && format) { if (isQCow2) {
version = virReadBufInt32BE(buf + QCOWX_HDR_VERSION); version = virReadBufInt32BE(buf + QCOWX_HDR_VERSION);
if (version == 2) if (version == 2)
start = QCOW2_HDR_TOTAL_SIZE; start = QCOW2_HDR_TOTAL_SIZE;
...@@ -572,15 +569,9 @@ qcow1GetBackingStore(char **res, ...@@ -572,15 +569,9 @@ qcow1GetBackingStore(char **res,
const char *buf, const char *buf,
size_t buf_size) size_t buf_size)
{ {
int ret;
/* QCow1 doesn't have the extensions capability /* QCow1 doesn't have the extensions capability
* used to store backing format */ * used to store backing format */
*format = VIR_STORAGE_FILE_AUTO; return qcowXGetBackingStore(res, format, buf, buf_size, false);
ret = qcowXGetBackingStore(res, NULL, buf, buf_size, false);
if (ret == BACKING_STORE_OK && !*res)
*format = VIR_STORAGE_FILE_NONE;
return ret;
} }
static int static int
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册