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

storagefile: Add externalDataStoreRaw member

Add the plumbing to track a qcow2 external data file path in
virStorageSource
Reviewed-by: NDaniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: NMichal Privoznik <mprivozn@redhat.com>
Signed-off-by: NCole Robinson <crobinso@redhat.com>
上级 9f0d3647
...@@ -202,6 +202,7 @@ qedGetBackingStore(char **, int *, const char *, size_t); ...@@ -202,6 +202,7 @@ qedGetBackingStore(char **, int *, const char *, size_t);
#define QCOW2_HDR_EXTENSION_END 0 #define QCOW2_HDR_EXTENSION_END 0
#define QCOW2_HDR_EXTENSION_BACKING_FORMAT 0xE2792ACA #define QCOW2_HDR_EXTENSION_BACKING_FORMAT 0xE2792ACA
#define QCOW2_HDR_EXTENSION_DATA_FILE 0x44415441
#define QCOW2v3_HDR_FEATURES_INCOMPATIBLE (QCOW2_HDR_TOTAL_SIZE) #define QCOW2v3_HDR_FEATURES_INCOMPATIBLE (QCOW2_HDR_TOTAL_SIZE)
#define QCOW2v3_HDR_FEATURES_COMPATIBLE (QCOW2v3_HDR_FEATURES_INCOMPATIBLE+8) #define QCOW2v3_HDR_FEATURES_COMPATIBLE (QCOW2v3_HDR_FEATURES_INCOMPATIBLE+8)
...@@ -429,7 +430,8 @@ cowGetBackingStore(char **res, ...@@ -429,7 +430,8 @@ cowGetBackingStore(char **res,
static int static int
qcow2GetExtensions(const char *buf, qcow2GetExtensions(const char *buf,
size_t buf_size, size_t buf_size,
int *backingFormat) int *backingFormat,
char **externalDataStoreRaw)
{ {
size_t offset; size_t offset;
size_t extension_start; size_t extension_start;
...@@ -505,6 +507,9 @@ qcow2GetExtensions(const char *buf, ...@@ -505,6 +507,9 @@ qcow2GetExtensions(const char *buf,
switch (magic) { switch (magic) {
case QCOW2_HDR_EXTENSION_BACKING_FORMAT: { case QCOW2_HDR_EXTENSION_BACKING_FORMAT: {
VIR_AUTOFREE(char *) tmp = NULL; VIR_AUTOFREE(char *) tmp = NULL;
if (!backingFormat)
break;
if (VIR_ALLOC_N(tmp, len + 1) < 0) if (VIR_ALLOC_N(tmp, len + 1) < 0)
return -1; return -1;
memcpy(tmp, buf + offset, len); memcpy(tmp, buf + offset, len);
...@@ -516,6 +521,19 @@ qcow2GetExtensions(const char *buf, ...@@ -516,6 +521,19 @@ qcow2GetExtensions(const char *buf,
break; break;
} }
case QCOW2_HDR_EXTENSION_DATA_FILE: {
if (!externalDataStoreRaw)
break;
if (VIR_ALLOC_N(*externalDataStoreRaw, len + 1) < 0)
return -1;
memcpy(*externalDataStoreRaw, buf + offset, len);
(*externalDataStoreRaw)[len] = '\0';
VIR_DEBUG("parsed externalDataStoreRaw='%s'",
*externalDataStoreRaw);
break;
}
case QCOW2_HDR_EXTENSION_END: case QCOW2_HDR_EXTENSION_END:
goto done; goto done;
} }
...@@ -567,7 +585,7 @@ qcowXGetBackingStore(char **res, ...@@ -567,7 +585,7 @@ qcowXGetBackingStore(char **res,
memcpy(*res, buf + offset, size); memcpy(*res, buf + offset, size);
(*res)[size] = '\0'; (*res)[size] = '\0';
if (qcow2GetExtensions(buf, buf_size, format) < 0) if (qcow2GetExtensions(buf, buf_size, format, NULL) < 0)
return BACKING_STORE_INVALID; return BACKING_STORE_INVALID;
return BACKING_STORE_OK; return BACKING_STORE_OK;
...@@ -2259,6 +2277,7 @@ virStorageSourceCopy(const virStorageSource *src, ...@@ -2259,6 +2277,7 @@ virStorageSourceCopy(const virStorageSource *src,
VIR_STRDUP(def->volume, src->volume) < 0 || VIR_STRDUP(def->volume, src->volume) < 0 ||
VIR_STRDUP(def->relPath, src->relPath) < 0 || VIR_STRDUP(def->relPath, src->relPath) < 0 ||
VIR_STRDUP(def->backingStoreRaw, src->backingStoreRaw) < 0 || VIR_STRDUP(def->backingStoreRaw, src->backingStoreRaw) < 0 ||
VIR_STRDUP(def->externalDataStoreRaw, src->externalDataStoreRaw) < 0 ||
VIR_STRDUP(def->snapshot, src->snapshot) < 0 || VIR_STRDUP(def->snapshot, src->snapshot) < 0 ||
VIR_STRDUP(def->configFile, src->configFile) < 0 || VIR_STRDUP(def->configFile, src->configFile) < 0 ||
VIR_STRDUP(def->nodeformat, src->nodeformat) < 0 || VIR_STRDUP(def->nodeformat, src->nodeformat) < 0 ||
...@@ -2534,6 +2553,7 @@ virStorageSourceClear(virStorageSourcePtr def) ...@@ -2534,6 +2553,7 @@ virStorageSourceClear(virStorageSourcePtr def)
virStorageSourceSeclabelsClear(def); virStorageSourceSeclabelsClear(def);
virStoragePermsFree(def->perms); virStoragePermsFree(def->perms);
VIR_FREE(def->timestamps); VIR_FREE(def->timestamps);
VIR_FREE(def->externalDataStoreRaw);
virStorageNetHostDefFree(def->nhosts, def->hosts); virStorageNetHostDefFree(def->nhosts, def->hosts);
virStorageAuthDefFree(def->auth); virStorageAuthDefFree(def->auth);
......
...@@ -302,6 +302,8 @@ struct _virStorageSource { ...@@ -302,6 +302,8 @@ struct _virStorageSource {
/* Name of the child backing store recorded in metadata of the /* Name of the child backing store recorded in metadata of the
* current file. */ * current file. */
char *backingStoreRaw; char *backingStoreRaw;
/* Name of the child data file recorded in metadata of the current file. */
char *externalDataStoreRaw;
/* metadata that allows identifying given storage source */ /* metadata that allows identifying given storage source */
char *nodeformat; /* name of the format handler object */ char *nodeformat; /* name of the format handler object */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册