int format,
virStorageFileMetadataPtr meta,
char **backingStore,
- int *backingFormat)
+ int *backingFormat,
+ char **backingDirectory)
{
int ret = -1;
meta->backingStoreRaw = meta->backingStore;
meta->backingStore = NULL;
if (virFindBackingFile(directory, backing,
- &meta->directory,
+ backingDirectory,
&meta->backingStore) < 0) {
/* the backing file is (currently) unavailable, treat this
* file as standalone:
if (virStorageFileGetMetadataInternal(path, canonPath, ".", buf, len,
format, ret, backing,
- backingFormat) < 0) {
+ backingFormat, NULL) < 0) {
virStorageFileFreeMetadata(ret);
ret = NULL;
}
int fd,
int format,
virStorageFileMetadataPtr meta,
- int *backingFormat)
+ int *backingFormat,
+ char **backingDirectory)
{
char *buf = NULL;
ssize_t len = VIR_STORAGE_MAX_HEADER;
ret = virStorageFileGetMetadataInternal(path, canonPath, directory,
buf, len, format, meta,
&meta->backingStoreRaw,
- backingFormat);
+ backingFormat, backingDirectory);
if (ret == 0) {
if (S_ISREG(sb.st_mode))
if (VIR_ALLOC(ret) < 0)
goto cleanup;
if (virStorageFileGetMetadataFromFDInternal(path, canonPath, ".",
- fd, format, ret, NULL) < 0) {
+ fd, format, ret,
+ NULL, NULL) < 0) {
virStorageFileFreeMetadata(ret);
ret = NULL;
}
int fd;
int ret = -1;
int backingFormat;
+ char *backingDirectory = NULL;
VIR_DEBUG("path=%s canonPath=%s dir=%s format=%d uid=%d gid=%d probe=%d",
path, canonPath, NULLSTR(directory), format,
ret = virStorageFileGetMetadataFromFDInternal(path, canonPath,
directory,
fd, format, meta,
- &backingFormat);
+ &backingFormat,
+ &backingDirectory);
if (VIR_CLOSE(fd) < 0)
VIR_WARN("could not close file %s", path);
if (VIR_ALLOC(backing) < 0 ||
virStorageFileGetMetadataRecurse(meta->backingStoreRaw,
meta->backingStore,
- meta->directory, backingFormat,
+ backingDirectory, backingFormat,
uid, gid, allow_probe,
cycle, backing) < 0) {
/* If we failed to get backing data, mark the chain broken */
VIR_FREE(meta->backingStore);
VIR_FREE(meta->backingStoreRaw);
VIR_FREE(meta->compat);
- VIR_FREE(meta->directory);
virBitmapFree(meta->features);
virStorageEncryptionFree(meta->encryption);
VIR_FREE(meta);
{
const char *expBackingStore;
const char *expBackingStoreRaw;
- const char *expBackingDirRel;
- const char *expBackingDirAbs;
unsigned long long expCapacity;
bool expEncrypted;
const char *pathRel;
while (elt) {
char *expect = NULL;
char *actual = NULL;
- const char *expBackingDirectory;
const char *expPath;
const char *expRelDir;
goto cleanup;
}
- expBackingDirectory = isAbs ? data->files[i]->expBackingDirAbs
- : data->files[i]->expBackingDirRel;
expPath = isAbs ? data->files[i]->pathAbs
: data->files[i]->pathRel;
expRelDir = isAbs ? data->files[i]->relDirAbs
: data->files[i]->relDirRel;
if (virAsprintf(&expect,
- "store:%s\nraw:%s\ndirectory:%s\nother:%lld %d\n"
+ "store:%s\nraw:%s\nother:%lld %d\n"
"path:%s\ncanon:%s\nrelDir:%s\ntype:%d %d\n",
NULLSTR(data->files[i]->expBackingStore),
NULLSTR(data->files[i]->expBackingStoreRaw),
- NULLSTR(expBackingDirectory),
data->files[i]->expCapacity,
data->files[i]->expEncrypted,
NULLSTR(expPath),
data->files[i]->type,
data->files[i]->format) < 0 ||
virAsprintf(&actual,
- "store:%s\nraw:%s\ndirectory:%s\nother:%lld %d\n"
+ "store:%s\nraw:%s\nother:%lld %d\n"
"path:%s\ncanon:%s\nrelDir:%s\ntype:%d %d\n",
NULLSTR(elt->backingStore),
NULLSTR(elt->backingStoreRaw),
- NULLSTR(elt->directory),
elt->capacity, !!elt->encryption,
NULLSTR(elt->path),
NULLSTR(elt->canonPath),
testFileData qcow2 = {
.expBackingStore = canonraw,
.expBackingStoreRaw = "raw",
- .expBackingDirRel = ".",
- .expBackingDirAbs = datadir,
.expCapacity = 1024,
.pathRel = "qcow2",
.pathAbs = canonqcow2,
if (virCommandRun(cmd, NULL) < 0)
ret = -1;
qcow2.expBackingStoreRaw = absraw;
- qcow2.expBackingDirRel = datadir;
raw.pathRel = absraw;
raw.pathAbs = absraw;
raw.relDirRel = datadir;
testFileData wrap = {
.expBackingStore = canonqcow2,
.expBackingStoreRaw = absqcow2,
- .expBackingDirRel = datadir,
- .expBackingDirAbs = datadir,
.expCapacity = 1024,
.pathRel = "wrap",
.pathAbs = abswrap,
testFileData wrap_as_raw = {
.expBackingStore = canonqcow2,
.expBackingStoreRaw = absqcow2,
- .expBackingDirRel = datadir,
- .expBackingDirAbs = datadir,
.expCapacity = 1024,
.pathRel = "wrap",
.pathAbs = abswrap,
ret = -1;
qcow2.expBackingStore = "nbd:example.org:6000";
qcow2.expBackingStoreRaw = "nbd:example.org:6000";
- qcow2.expBackingDirRel = NULL;
- qcow2.expBackingDirAbs = NULL;
/* Qcow2 file with backing protocol instead of file */
testFileData nbd = {
testFileData qed = {
.expBackingStore = canonraw,
.expBackingStoreRaw = absraw,
- .expBackingDirRel = datadir,
- .expBackingDirAbs = datadir,
.expCapacity = 1024,
.pathRel = "qed",
.pathAbs = absqed,
testFileData link1 = {
.expBackingStore = canonraw,
.expBackingStoreRaw = "../raw",
- .expBackingDirRel = "sub/../sub/..",
- .expBackingDirAbs = datadir "/sub/../sub/..",
.expCapacity = 1024,
.pathRel = "../sub/link1",
.pathAbs = "../sub/link1",
testFileData link2 = {
.expBackingStore = canonqcow2,
.expBackingStoreRaw = "../sub/link1",
- .expBackingDirRel = "sub/../sub",
- .expBackingDirAbs = datadir "/sub/../sub",
.expCapacity = 1024,
.pathRel = "sub/link2",
.pathAbs = abslink2,
ret = -1;
qcow2.expBackingStore = NULL;
qcow2.expBackingStoreRaw = "qcow2";
- qcow2.expBackingDirRel = ".";
- qcow2.expBackingDirAbs = datadir;
/* Behavior of an infinite loop chain */
TEST_CHAIN(16, "qcow2", absqcow2, VIR_STORAGE_FILE_QCOW2,
if (virCommandRun(cmd, NULL) < 0)
ret = -1;
qcow2.expBackingStoreRaw = "wrap";
- qcow2.expBackingDirRel = datadir;
qcow2.pathRel = absqcow2;
qcow2.relDirRel = datadir;