提交 44551275 编写于 作者: P Peter Krempa

storage: Move disk->backingChain to the recursive disk->src.backingStore

Switch over to storing of the backing chain as a recursive
virStorageSource structure.

This is a string based move. Currently the first element will be present
twice in the backing chain as currently the retrieval function stores
the parent in the newly detected chain. This will be fixed later.
上级 b627b8fd
...@@ -1190,7 +1190,6 @@ virDomainDiskDefFree(virDomainDiskDefPtr def) ...@@ -1190,7 +1190,6 @@ virDomainDiskDefFree(virDomainDiskDefPtr def)
virStorageSourceClear(&def->src); virStorageSourceClear(&def->src);
VIR_FREE(def->serial); VIR_FREE(def->serial);
VIR_FREE(def->dst); VIR_FREE(def->dst);
virStorageSourceFree(def->backingChain);
VIR_FREE(def->mirror); VIR_FREE(def->mirror);
VIR_FREE(def->wwn); VIR_FREE(def->wwn);
VIR_FREE(def->vendor); VIR_FREE(def->vendor);
...@@ -18514,7 +18513,7 @@ virDomainSmartcardDefForeach(virDomainDefPtr def, ...@@ -18514,7 +18513,7 @@ virDomainSmartcardDefForeach(virDomainDefPtr def,
/* Call iter(disk, name, depth, opaque) for each element of disk and /* Call iter(disk, name, depth, opaque) for each element of disk and
* its backing chain in the pre-populated disk->backingChain. * its backing chain in the pre-populated disk->src.backingStore.
* ignoreOpenFailure determines whether to warn about a chain that * ignoreOpenFailure determines whether to warn about a chain that
* mentions a backing file without also having metadata on that * mentions a backing file without also having metadata on that
* file. */ * file. */
...@@ -18540,7 +18539,7 @@ virDomainDiskDefForeachPath(virDomainDiskDefPtr disk, ...@@ -18540,7 +18539,7 @@ virDomainDiskDefForeachPath(virDomainDiskDefPtr disk,
goto cleanup; goto cleanup;
/* XXX: temporarily we need to select the second element of the backing /* 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. */ * chain to start as the first is the copy of the disk itself. */
tmp = disk->backingChain ? disk->backingChain->backingStore : NULL; tmp = disk->src.backingStore ? disk->src.backingStore->backingStore : NULL;
while (tmp && virStorageIsFile(tmp->path)) { while (tmp && virStorageIsFile(tmp->path)) {
if (!ignoreOpenFailure && tmp->backingStoreRaw && !tmp->backingStore) { if (!ignoreOpenFailure && tmp->backingStoreRaw && !tmp->backingStore) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
......
...@@ -605,7 +605,6 @@ struct _virDomainDiskDef { ...@@ -605,7 +605,6 @@ struct _virDomainDiskDef {
char *dst; char *dst;
int tray_status; /* enum virDomainDiskTray */ int tray_status; /* enum virDomainDiskTray */
int removable; /* enum virDomainFeatureState */ int removable; /* enum virDomainFeatureState */
virStorageSourcePtr backingChain;
char *mirror; char *mirror;
int mirrorFormat; /* enum virStorageFileFormat */ int mirrorFormat; /* enum virStorageFileFormat */
......
...@@ -2239,10 +2239,10 @@ qemuDiskChainCheckBroken(virDomainDiskDefPtr disk) ...@@ -2239,10 +2239,10 @@ qemuDiskChainCheckBroken(virDomainDiskDefPtr disk)
{ {
char *brokenFile = NULL; char *brokenFile = NULL;
if (!virDomainDiskGetSource(disk) || !disk->backingChain) if (!virDomainDiskGetSource(disk) || !disk->src.backingStore)
return 0; return 0;
if (virStorageFileChainGetBroken(disk->backingChain, &brokenFile) < 0) if (virStorageFileChainGetBroken(disk->src.backingStore, &brokenFile) < 0)
return -1; return -1;
if (brokenFile) { if (brokenFile) {
...@@ -2408,10 +2408,10 @@ qemuDomainDetermineDiskChain(virQEMUDriverPtr driver, ...@@ -2408,10 +2408,10 @@ qemuDomainDetermineDiskChain(virQEMUDriverPtr driver,
type == VIR_STORAGE_TYPE_VOLUME) type == VIR_STORAGE_TYPE_VOLUME)
goto cleanup; goto cleanup;
if (disk->backingChain) { if (disk->src.backingStore) {
if (force) { if (force) {
virStorageSourceFree(disk->backingChain); virStorageSourceFree(disk->src.backingStore);
disk->backingChain = NULL; disk->src.backingStore = NULL;
} else { } else {
goto cleanup; goto cleanup;
} }
...@@ -2419,11 +2419,11 @@ qemuDomainDetermineDiskChain(virQEMUDriverPtr driver, ...@@ -2419,11 +2419,11 @@ qemuDomainDetermineDiskChain(virQEMUDriverPtr driver,
qemuDomainGetImageIds(cfg, vm, disk, &uid, &gid); qemuDomainGetImageIds(cfg, vm, disk, &uid, &gid);
disk->backingChain = virStorageFileGetMetadata(src, disk->src.backingStore = virStorageFileGetMetadata(src,
virDomainDiskGetFormat(disk), virDomainDiskGetFormat(disk),
uid, gid, uid, gid,
cfg->allowDiskFormatProbing); cfg->allowDiskFormatProbing);
if (!disk->backingChain) if (!disk->src.backingStore)
ret = -1; ret = -1;
cleanup: cleanup:
......
...@@ -12011,14 +12011,14 @@ qemuDomainPrepareDiskChainElement(virQEMUDriverPtr driver, ...@@ -12011,14 +12011,14 @@ qemuDomainPrepareDiskChainElement(virQEMUDriverPtr driver,
* temporarily modify the disk in place. */ * temporarily modify the disk in place. */
char *origsrc = disk->src.path; char *origsrc = disk->src.path;
int origformat = disk->src.format; int origformat = disk->src.format;
virStorageSourcePtr origchain = disk->backingChain; virStorageSourcePtr origchain = disk->src.backingStore;
bool origreadonly = disk->readonly; bool origreadonly = disk->readonly;
int ret = -1; int ret = -1;
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver); virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
disk->src.path = (char *) file; /* casting away const is safe here */ disk->src.path = (char *) file; /* casting away const is safe here */
disk->src.format = VIR_STORAGE_FILE_RAW; disk->src.format = VIR_STORAGE_FILE_RAW;
disk->backingChain = NULL; disk->src.backingStore = NULL;
disk->readonly = mode == VIR_DISK_CHAIN_READ_ONLY; disk->readonly = mode == VIR_DISK_CHAIN_READ_ONLY;
if (mode == VIR_DISK_CHAIN_NO_ACCESS) { if (mode == VIR_DISK_CHAIN_NO_ACCESS) {
...@@ -12043,7 +12043,7 @@ qemuDomainPrepareDiskChainElement(virQEMUDriverPtr driver, ...@@ -12043,7 +12043,7 @@ qemuDomainPrepareDiskChainElement(virQEMUDriverPtr driver,
cleanup: cleanup:
disk->src.path = origsrc; disk->src.path = origsrc;
disk->src.format = origformat; disk->src.format = origformat;
disk->backingChain = origchain; disk->src.backingStore = origchain;
disk->readonly = origreadonly; disk->readonly = origreadonly;
virObjectUnref(cfg); virObjectUnref(cfg);
return ret; return ret;
...@@ -12719,13 +12719,13 @@ qemuDomainSnapshotCreateSingleDiskActive(virQEMUDriverPtr driver, ...@@ -12719,13 +12719,13 @@ qemuDomainSnapshotCreateSingleDiskActive(virQEMUDriverPtr driver,
if (virAsprintf(&device, "drive-%s", disk->info.alias) < 0) if (virAsprintf(&device, "drive-%s", disk->info.alias) < 0)
goto cleanup; goto cleanup;
/* XXX Here, we know we are about to alter disk->backingChain if /* XXX Here, we know we are about to alter disk->src.backingStore if
* successful, so we nuke the existing chain so that future commands will * successful, so we nuke the existing chain so that future commands will
* recompute it. Better would be storing the chain ourselves rather than * recompute it. Better would be storing the chain ourselves rather than
* reprobing, but this requires modifying domain_conf and our XML to fully * reprobing, but this requires modifying domain_conf and our XML to fully
* track the chain across libvirtd restarts. */ * track the chain across libvirtd restarts. */
virStorageSourceFree(disk->backingChain); virStorageSourceFree(disk->src.backingStore);
disk->backingChain = NULL; disk->src.backingStore = NULL;
if (virStorageFileInit(&snap->src) < 0) if (virStorageFileInit(&snap->src) < 0)
goto cleanup; goto cleanup;
...@@ -14763,14 +14763,14 @@ qemuDomainBlockPivot(virConnectPtr conn, ...@@ -14763,14 +14763,14 @@ qemuDomainBlockPivot(virConnectPtr conn,
* we know for sure that there is a backing chain. */ * we know for sure that there is a backing chain. */
oldsrc = disk->src.path; oldsrc = disk->src.path;
oldformat = disk->src.format; oldformat = disk->src.format;
oldchain = disk->backingChain; oldchain = disk->src.backingStore;
disk->src.path = disk->mirror; disk->src.path = disk->mirror;
disk->src.format = disk->mirrorFormat; disk->src.format = disk->mirrorFormat;
disk->backingChain = NULL; disk->src.backingStore = NULL;
if (qemuDomainDetermineDiskChain(driver, vm, disk, false) < 0) { if (qemuDomainDetermineDiskChain(driver, vm, disk, false) < 0) {
disk->src.path = oldsrc; disk->src.path = oldsrc;
disk->src.format = oldformat; disk->src.format = oldformat;
disk->backingChain = oldchain; disk->src.backingStore = oldchain;
goto cleanup; goto cleanup;
} }
if (disk->mirrorFormat && disk->mirrorFormat != VIR_STORAGE_FILE_RAW && if (disk->mirrorFormat && disk->mirrorFormat != VIR_STORAGE_FILE_RAW &&
...@@ -14781,7 +14781,7 @@ qemuDomainBlockPivot(virConnectPtr conn, ...@@ -14781,7 +14781,7 @@ qemuDomainBlockPivot(virConnectPtr conn,
disk) < 0)) { disk) < 0)) {
disk->src.path = oldsrc; disk->src.path = oldsrc;
disk->src.format = oldformat; disk->src.format = oldformat;
disk->backingChain = oldchain; disk->src.backingStore = oldchain;
goto cleanup; goto cleanup;
} }
...@@ -14812,8 +14812,8 @@ qemuDomainBlockPivot(virConnectPtr conn, ...@@ -14812,8 +14812,8 @@ qemuDomainBlockPivot(virConnectPtr conn,
* success case, there's security labeling to worry about. */ * success case, there's security labeling to worry about. */
disk->src.path = oldsrc; disk->src.path = oldsrc;
disk->src.format = oldformat; disk->src.format = oldformat;
virStorageSourceFree(disk->backingChain); virStorageSourceFree(disk->src.backingStore);
disk->backingChain = oldchain; disk->src.backingStore = oldchain;
VIR_FREE(disk->mirror); VIR_FREE(disk->mirror);
} }
disk->mirrorFormat = VIR_STORAGE_FILE_NONE; disk->mirrorFormat = VIR_STORAGE_FILE_NONE;
...@@ -15123,7 +15123,7 @@ qemuDomainBlockCopy(virDomainObjPtr vm, ...@@ -15123,7 +15123,7 @@ qemuDomainBlockCopy(virDomainObjPtr vm,
if ((flags & VIR_DOMAIN_BLOCK_REBASE_SHALLOW) && if ((flags & VIR_DOMAIN_BLOCK_REBASE_SHALLOW) &&
STREQ_NULLABLE(format, "raw") && STREQ_NULLABLE(format, "raw") &&
disk->backingChain->backingStore->path) { disk->src.backingStore->backingStore->path) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("disk '%s' has backing file, so raw shallow copy " _("disk '%s' has backing file, so raw shallow copy "
"is not possible"), "is not possible"),
...@@ -15330,8 +15330,8 @@ qemuDomainBlockCommit(virDomainPtr dom, const char *path, const char *base, ...@@ -15330,8 +15330,8 @@ qemuDomainBlockCommit(virDomainPtr dom, const char *path, const char *base,
if (!top) { if (!top) {
top_canon = disk->src.path; top_canon = disk->src.path;
top_meta = disk->backingChain; top_meta = disk->src.backingStore;
} else if (!(top_canon = virStorageFileChainLookup(disk->backingChain, } else if (!(top_canon = virStorageFileChainLookup(disk->src.backingStore,
top, &top_meta, top, &top_meta,
&top_parent))) { &top_parent))) {
goto endjob; goto endjob;
......
...@@ -1148,7 +1148,7 @@ virSecuritySELinuxRestoreSecurityImageLabelInt(virSecurityManagerPtr mgr, ...@@ -1148,7 +1148,7 @@ virSecuritySELinuxRestoreSecurityImageLabelInt(virSecurityManagerPtr mgr,
* be tracked in domain XML, at which point labelskip should be a * be tracked in domain XML, at which point labelskip should be a
* per-file attribute instead of a disk attribute. */ * per-file attribute instead of a disk attribute. */
if (disk_seclabel && disk_seclabel->labelskip && if (disk_seclabel && disk_seclabel->labelskip &&
!disk->backingChain) !disk->src.backingStore)
return 0; return 0;
/* Don't restore labels on readoly/shared disks, because /* Don't restore labels on readoly/shared disks, because
......
...@@ -950,11 +950,11 @@ get_files(vahControl * ctl) ...@@ -950,11 +950,11 @@ get_files(vahControl * ctl)
/* XXX - if we knew the qemu user:group here we could send it in /* XXX - if we knew the qemu user:group here we could send it in
* so that the open could be re-tried as that user:group. * so that the open could be re-tried as that user:group.
*/ */
if (!disk->backingChain) { if (!disk->src.backingStore) {
bool probe = ctl->allowDiskFormatProbing; bool probe = ctl->allowDiskFormatProbing;
disk->backingChain = virStorageFileGetMetadata(src, disk->src.backingStore = virStorageFileGetMetadata(src,
virDomainDiskGetFormat(disk), virDomainDiskGetFormat(disk),
-1, -1, probe); -1, -1, probe);
} }
/* XXX passing ignoreOpenFailure = true to get back to the behavior /* XXX passing ignoreOpenFailure = true to get back to the behavior
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册