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@xxxxxxxxxx> --- src/qemu/qemu_driver.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index a557d75..35ab2f0 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -15297,8 +15297,8 @@ qemuDomainBlockCommit(virDomainPtr dom, const char *path, const char *base, int idx; virDomainDiskDefPtr disk = NULL; virStorageSourcePtr topSource; + virStorageSourcePtr baseSource; const char *top_parent = NULL; - const char *base_canon = NULL; bool clean_access = false; virCheckFlags(VIR_DOMAIN_BLOCK_COMMIT_SHALLOW, -1); @@ -15353,16 +15353,12 @@ qemuDomainBlockCommit(virDomainPtr dom, const char *path, const char *base, } if (!base && (flags & VIR_DOMAIN_BLOCK_COMMIT_SHALLOW)) - base_canon = topSource->backingStore->path; - else if (!(base_canon = virStorageFileChainLookup(topSource, - base, NULL, NULL))) + baseSource = topSource->backingStore; + else if (!(virStorageFileChainLookup(topSource, base, &baseSource, NULL))) 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) && - base_canon != topSource->backingStore->path) { + baseSource != topSource->backingStore) { virReportError(VIR_ERR_INVALID_ARG, _("base '%s' is not immediately below '%s' in chain " "for '%s'"), @@ -15378,7 +15374,7 @@ qemuDomainBlockCommit(virDomainPtr dom, const char *path, const char *base, * operation succeeds, but doing that requires tracking the * operation in XML across libvirtd restarts. */ clean_access = true; - if (qemuDomainPrepareDiskChainElement(driver, vm, disk, base_canon, + if (qemuDomainPrepareDiskChainElement(driver, vm, disk, baseSource->path, VIR_DISK_CHAIN_READ_WRITE) < 0 || (top_parent && top_parent != disk->src.path && qemuDomainPrepareDiskChainElement(driver, vm, disk, @@ -15394,13 +15390,13 @@ qemuDomainBlockCommit(virDomainPtr dom, const char *path, const char *base, qemuDomainObjEnterMonitor(driver, vm); ret = qemuMonitorBlockCommit(priv->mon, device, top ? top : topSource->path, - base ? base : base_canon, bandwidth); + base ? base : baseSource->path, bandwidth); qemuDomainObjExitMonitor(driver, vm); endjob: if (ret < 0 && clean_access) { /* Revert access to read-only, if possible. */ - qemuDomainPrepareDiskChainElement(driver, vm, disk, base_canon, + qemuDomainPrepareDiskChainElement(driver, vm, disk, baseSource->path, VIR_DISK_CHAIN_READ_ONLY); if (top_parent && top_parent != disk->src.path) qemuDomainPrepareDiskChainElement(driver, vm, disk, -- 1.9.2 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list