Remove the obsolete field replaced by data in "path". The testsuite requires tweaking as the name of the backing file is now stored one layer deeper in the backking chain linked list. --- src/conf/domain_conf.c | 13 ++++++------ src/qemu/qemu_driver.c | 8 ++++---- src/util/virstoragefile.c | 5 ----- src/util/virstoragefile.h | 5 ----- tests/virstoragetest.c | 50 +++++++++++++++++++++++------------------------ 5 files changed, 36 insertions(+), 45 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 05fa3f9..006aa96 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -18565,16 +18565,17 @@ virDomainDiskDefForeachPath(virDomainDiskDefPtr disk, if (iter(disk, path, 0, opaque) < 0) goto cleanup; - - tmp = disk->backingChain; - while (tmp && virStorageIsFile(tmp->backingStore)) { - if (!ignoreOpenFailure && !tmp->backingMeta) { + /* XXX: temporarily we need to select the second element of the backing + * chain to start as the first is the copy of the disk itself. */ + tmp = disk->backingChain ? disk->backingChain->backingMeta : NULL; + while (tmp && virStorageIsFile(tmp->path)) { + if (!ignoreOpenFailure && tmp->backingStoreRaw && !tmp->backingMeta) { virReportError(VIR_ERR_INTERNAL_ERROR, _("unable to visit backing chain file %s"), - tmp->backingStore); + tmp->backingStoreRaw); goto cleanup; } - if (iter(disk, tmp->backingStore, ++depth, opaque) < 0) + if (iter(disk, tmp->path, ++depth, opaque) < 0) goto cleanup; tmp = tmp->backingMeta; } diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index e58fa3f..c242104 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -15134,7 +15134,7 @@ qemuDomainBlockCopy(virDomainObjPtr vm, if ((flags & VIR_DOMAIN_BLOCK_REBASE_SHALLOW) && STREQ_NULLABLE(format, "raw") && - disk->backingChain->backingStore) { + disk->backingChain->backingMeta->path) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("disk '%s' has backing file, so raw shallow copy " "is not possible"), @@ -15347,14 +15347,14 @@ qemuDomainBlockCommit(virDomainPtr dom, const char *path, const char *base, &top_parent))) { goto endjob; } - if (!top_meta || !top_meta->backingStore) { + if (!top_meta || !top_meta->backingMeta) { virReportError(VIR_ERR_INVALID_ARG, _("top '%s' in chain for '%s' has no backing file"), top_canon, path); goto endjob; } if (!base && (flags & VIR_DOMAIN_BLOCK_COMMIT_SHALLOW)) - base_canon = top_meta->backingStore; + base_canon = top_meta->backingMeta->path; else if (!(base_canon = virStorageFileChainLookup(top_meta, base, NULL, NULL))) goto endjob; @@ -15363,7 +15363,7 @@ qemuDomainBlockCommit(virDomainPtr dom, const char *path, const char *base, * virStorageFileChainLookup guarantees a simple pointer * comparison will work, rather than needing full-blown STREQ. */ if ((flags & VIR_DOMAIN_BLOCK_COMMIT_SHALLOW) && - base_canon != top_meta->backingStore) { + base_canon != top_meta->backingMeta->path) { virReportError(VIR_ERR_INVALID_ARG, _("base '%s' is not immediately below '%s' in chain " "for '%s'"), diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index 2077839..2d6be17 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -1182,9 +1182,6 @@ virStorageFileGetMetadataRecurse(const char *path, const char *canonPath, return -1; } - if (VIR_STRDUP(meta->backingStore, backingPath) < 0) - return -1; - virStorageFileMetadataPtr backing; if (backingFormat == VIR_STORAGE_FILE_AUTO && !allow_probe) @@ -1198,7 +1195,6 @@ virStorageFileGetMetadataRecurse(const char *path, const char *canonPath, uid, gid, allow_probe, cycle, backing) < 0) { /* If we failed to get backing data, mark the chain broken */ - VIR_FREE(meta->backingStore); virStorageFileFreeMetadata(backing); } else { meta->backingMeta = backing; @@ -1326,7 +1322,6 @@ virStorageFileFreeMetadata(virStorageFileMetadata *meta) VIR_FREE(meta->relDir); virStorageFileFreeMetadata(meta->backingMeta); - VIR_FREE(meta->backingStore); VIR_FREE(meta->backingStoreRaw); VIR_FREE(meta->compat); virBitmapFree(meta->features); diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h index 3f072b6..2e9312f 100644 --- a/src/util/virstoragefile.h +++ b/src/util/virstoragefile.h @@ -148,11 +148,6 @@ struct _virStorageFileMetadata { unsigned long long capacity; virBitmapPtr features; /* bits described by enum virStorageFileFeature */ char *compat; - - /* Fields I'm trying to delete, because it is confusing to have to - * query the parent metadata for details about the backing - * store. */ - char *backingStore; /* Canonical name (absolute file, or protocol). Should be same as backingMeta->canonPath */ }; diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c index dabaa99..646c15e 100644 --- a/tests/virstoragetest.c +++ b/tests/virstoragetest.c @@ -336,7 +336,7 @@ testStorageChain(const void *args) virAsprintf(&actual, "store:%s\nraw:%s\nother:%lld %d\n" "relPath:%s\npath:%s\nrelDir:%s\ntype:%d %d\n", - NULLSTR(elt->backingStore), + NULLSTR(elt->backingMeta ? elt->backingMeta->path : NULL), NULLSTR(elt->backingStoreRaw), elt->capacity, !!elt->encryption, NULLSTR(elt->relPath), @@ -841,16 +841,16 @@ mymain(void) TEST_LOOKUP(0, "bogus", NULL, NULL, NULL); TEST_LOOKUP(1, "wrap", chain->path, chain, NULL); TEST_LOOKUP(2, abswrap, chain->path, chain, NULL); - TEST_LOOKUP(3, "qcow2", chain->backingStore, chain->backingMeta, + TEST_LOOKUP(3, "qcow2", chain->backingMeta->path, chain->backingMeta, chain->path); - TEST_LOOKUP(4, absqcow2, chain->backingStore, chain->backingMeta, + TEST_LOOKUP(4, absqcow2, chain->backingMeta->path, chain->backingMeta, chain->path); - TEST_LOOKUP(5, "raw", chain->backingMeta->backingStore, - chain->backingMeta->backingMeta, chain->backingStore); - TEST_LOOKUP(6, absraw, chain->backingMeta->backingStore, - chain->backingMeta->backingMeta, chain->backingStore); - TEST_LOOKUP(7, NULL, chain->backingMeta->backingStore, - chain->backingMeta->backingMeta, chain->backingStore); + TEST_LOOKUP(5, "raw", chain->backingMeta->backingMeta->path, + chain->backingMeta->backingMeta, chain->backingMeta->path); + TEST_LOOKUP(6, absraw, chain->backingMeta->backingMeta->path, + chain->backingMeta->backingMeta, chain->backingMeta->path); + TEST_LOOKUP(7, NULL, chain->backingMeta->backingMeta->path, + chain->backingMeta->backingMeta, chain->backingMeta->path); /* Rewrite wrap and qcow2 back to 3-deep chain, relative backing */ virCommandFree(cmd); @@ -877,16 +877,16 @@ mymain(void) TEST_LOOKUP(8, "bogus", NULL, NULL, NULL); TEST_LOOKUP(9, "wrap", chain->path, chain, NULL); TEST_LOOKUP(10, abswrap, chain->path, chain, NULL); - TEST_LOOKUP(11, "qcow2", chain->backingStore, chain->backingMeta, + TEST_LOOKUP(11, "qcow2", chain->backingMeta->path, chain->backingMeta, chain->path); - TEST_LOOKUP(12, absqcow2, chain->backingStore, chain->backingMeta, + TEST_LOOKUP(12, absqcow2, chain->backingMeta->path, chain->backingMeta, chain->path); - TEST_LOOKUP(13, "raw", chain->backingMeta->backingStore, - chain->backingMeta->backingMeta, chain->backingStore); - TEST_LOOKUP(14, absraw, chain->backingMeta->backingStore, - chain->backingMeta->backingMeta, chain->backingStore); - TEST_LOOKUP(15, NULL, chain->backingMeta->backingStore, - chain->backingMeta->backingMeta, chain->backingStore); + TEST_LOOKUP(13, "raw", chain->backingMeta->backingMeta->path, + chain->backingMeta->backingMeta, chain->backingMeta->path); + TEST_LOOKUP(14, absraw, chain->backingMeta->backingMeta->path, + chain->backingMeta->backingMeta, chain->backingMeta->path); + TEST_LOOKUP(15, NULL, chain->backingMeta->backingMeta->path, + chain->backingMeta->backingMeta, chain->backingMeta->path); /* Use link to wrap with cross-directory relative backing */ virCommandFree(cmd); @@ -908,17 +908,17 @@ mymain(void) TEST_LOOKUP(17, "sub/link2", chain->path, chain, NULL); TEST_LOOKUP(18, "wrap", chain->path, chain, NULL); TEST_LOOKUP(19, abswrap, chain->path, chain, NULL); - TEST_LOOKUP(20, "../qcow2", chain->backingStore, chain->backingMeta, + TEST_LOOKUP(20, "../qcow2", chain->backingMeta->path, chain->backingMeta, chain->path); TEST_LOOKUP(21, "qcow2", NULL, NULL, NULL); - TEST_LOOKUP(22, absqcow2, chain->backingStore, chain->backingMeta, + TEST_LOOKUP(22, absqcow2, chain->backingMeta->path, chain->backingMeta, chain->path); - TEST_LOOKUP(23, "raw", chain->backingMeta->backingStore, - chain->backingMeta->backingMeta, chain->backingStore); - TEST_LOOKUP(24, absraw, chain->backingMeta->backingStore, - chain->backingMeta->backingMeta, chain->backingStore); - TEST_LOOKUP(25, NULL, chain->backingMeta->backingStore, - chain->backingMeta->backingMeta, chain->backingStore); + TEST_LOOKUP(23, "raw", chain->backingMeta->backingMeta->path, + chain->backingMeta->backingMeta, chain->backingMeta->path); + TEST_LOOKUP(24, absraw, chain->backingMeta->backingMeta->path, + chain->backingMeta->backingMeta, chain->backingMeta->path); + TEST_LOOKUP(25, NULL, chain->backingMeta->backingMeta->path, + chain->backingMeta->backingMeta, chain->backingMeta->path); cleanup: /* Final cleanup */ -- 1.9.1 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list