mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
qemuDomainBlockCommit: Track virStorageSourcePtr for base
virStorageFileChainLookup is able to give use virStorageSourcePtr which contains the pointer to its canonical path. Let's use a more general virStorageSourcePtr instead of just canonical path. Former base_canon maps to baseSource->path. Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
This commit is contained in:
parent
ca979b0680
commit
f33eb9c115
@ -15286,8 +15286,8 @@ qemuDomainBlockCommit(virDomainPtr dom, const char *path, const char *base,
|
|||||||
int idx;
|
int idx;
|
||||||
virDomainDiskDefPtr disk = NULL;
|
virDomainDiskDefPtr disk = NULL;
|
||||||
virStorageSourcePtr topSource;
|
virStorageSourcePtr topSource;
|
||||||
|
virStorageSourcePtr baseSource;
|
||||||
const char *top_parent = NULL;
|
const char *top_parent = NULL;
|
||||||
const char *base_canon = NULL;
|
|
||||||
bool clean_access = false;
|
bool clean_access = false;
|
||||||
|
|
||||||
virCheckFlags(VIR_DOMAIN_BLOCK_COMMIT_SHALLOW, -1);
|
virCheckFlags(VIR_DOMAIN_BLOCK_COMMIT_SHALLOW, -1);
|
||||||
@ -15342,16 +15342,12 @@ qemuDomainBlockCommit(virDomainPtr dom, const char *path, const char *base,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!base && (flags & VIR_DOMAIN_BLOCK_COMMIT_SHALLOW))
|
if (!base && (flags & VIR_DOMAIN_BLOCK_COMMIT_SHALLOW))
|
||||||
base_canon = topSource->backingStore->path;
|
baseSource = topSource->backingStore;
|
||||||
else if (!(base_canon = virStorageFileChainLookup(topSource,
|
else if (!(virStorageFileChainLookup(topSource, base, &baseSource, NULL)))
|
||||||
base, NULL, NULL)))
|
|
||||||
goto endjob;
|
goto endjob;
|
||||||
|
|
||||||
/* Note that this code exploits the fact that
|
|
||||||
* virStorageFileChainLookup guarantees a simple pointer
|
|
||||||
* comparison will work, rather than needing full-blown STREQ. */
|
|
||||||
if ((flags & VIR_DOMAIN_BLOCK_COMMIT_SHALLOW) &&
|
if ((flags & VIR_DOMAIN_BLOCK_COMMIT_SHALLOW) &&
|
||||||
base_canon != topSource->backingStore->path) {
|
baseSource != topSource->backingStore) {
|
||||||
virReportError(VIR_ERR_INVALID_ARG,
|
virReportError(VIR_ERR_INVALID_ARG,
|
||||||
_("base '%s' is not immediately below '%s' in chain "
|
_("base '%s' is not immediately below '%s' in chain "
|
||||||
"for '%s'"),
|
"for '%s'"),
|
||||||
@ -15367,7 +15363,7 @@ qemuDomainBlockCommit(virDomainPtr dom, const char *path, const char *base,
|
|||||||
* operation succeeds, but doing that requires tracking the
|
* operation succeeds, but doing that requires tracking the
|
||||||
* operation in XML across libvirtd restarts. */
|
* operation in XML across libvirtd restarts. */
|
||||||
clean_access = true;
|
clean_access = true;
|
||||||
if (qemuDomainPrepareDiskChainElement(driver, vm, disk, base_canon,
|
if (qemuDomainPrepareDiskChainElement(driver, vm, disk, baseSource->path,
|
||||||
VIR_DISK_CHAIN_READ_WRITE) < 0 ||
|
VIR_DISK_CHAIN_READ_WRITE) < 0 ||
|
||||||
(top_parent && top_parent != disk->src.path &&
|
(top_parent && top_parent != disk->src.path &&
|
||||||
qemuDomainPrepareDiskChainElement(driver, vm, disk,
|
qemuDomainPrepareDiskChainElement(driver, vm, disk,
|
||||||
@ -15383,13 +15379,13 @@ qemuDomainBlockCommit(virDomainPtr dom, const char *path, const char *base,
|
|||||||
qemuDomainObjEnterMonitor(driver, vm);
|
qemuDomainObjEnterMonitor(driver, vm);
|
||||||
ret = qemuMonitorBlockCommit(priv->mon, device,
|
ret = qemuMonitorBlockCommit(priv->mon, device,
|
||||||
top ? top : topSource->path,
|
top ? top : topSource->path,
|
||||||
base ? base : base_canon, bandwidth);
|
base ? base : baseSource->path, bandwidth);
|
||||||
qemuDomainObjExitMonitor(driver, vm);
|
qemuDomainObjExitMonitor(driver, vm);
|
||||||
|
|
||||||
endjob:
|
endjob:
|
||||||
if (ret < 0 && clean_access) {
|
if (ret < 0 && clean_access) {
|
||||||
/* Revert access to read-only, if possible. */
|
/* Revert access to read-only, if possible. */
|
||||||
qemuDomainPrepareDiskChainElement(driver, vm, disk, base_canon,
|
qemuDomainPrepareDiskChainElement(driver, vm, disk, baseSource->path,
|
||||||
VIR_DISK_CHAIN_READ_ONLY);
|
VIR_DISK_CHAIN_READ_ONLY);
|
||||||
if (top_parent && top_parent != disk->src.path)
|
if (top_parent && top_parent != disk->src.path)
|
||||||
qemuDomainPrepareDiskChainElement(driver, vm, disk,
|
qemuDomainPrepareDiskChainElement(driver, vm, disk,
|
||||||
|
Loading…
Reference in New Issue
Block a user