virStorageFileChainLookup is able to give use virStorageSourcePtr which contains the pointer to its canonical path. There's no need for the caller to store both of them. Former top_meta maps to topSource and top_canon maps to topSource->path. Signed-off-by: Jiri Denemark <jdenemar@xxxxxxxxxx> --- src/qemu/qemu_driver.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index c8f3f6f..a557d75 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -15296,8 +15296,7 @@ qemuDomainBlockCommit(virDomainPtr dom, const char *path, const char *base, int ret = -1; int idx; virDomainDiskDefPtr disk = NULL; - const char *top_canon = NULL; - virStorageSourcePtr top_meta = NULL; + virStorageSourcePtr topSource; const char *top_parent = NULL; const char *base_canon = NULL; bool clean_access = false; @@ -15340,22 +15339,22 @@ qemuDomainBlockCommit(virDomainPtr dom, const char *path, const char *base, goto endjob; if (!top) { - top_canon = disk->src.path; - top_meta = &disk->src; - } else if (!(top_canon = virStorageFileChainLookup(&disk->src, - top, &top_meta, - &top_parent))) { + topSource = &disk->src; + } else if (!(virStorageFileChainLookup(&disk->src, + top, &topSource, + &top_parent))) { goto endjob; } - if (!top_meta || !top_meta->backingStore) { + if (!topSource->backingStore) { virReportError(VIR_ERR_INVALID_ARG, _("top '%s' in chain for '%s' has no backing file"), - top_canon, path); + topSource->path, path); goto endjob; } + if (!base && (flags & VIR_DOMAIN_BLOCK_COMMIT_SHALLOW)) - base_canon = top_meta->backingStore->path; - else if (!(base_canon = virStorageFileChainLookup(top_meta, + base_canon = topSource->backingStore->path; + else if (!(base_canon = virStorageFileChainLookup(topSource, base, NULL, NULL))) goto endjob; @@ -15363,11 +15362,11 @@ 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->path) { + base_canon != topSource->backingStore->path) { virReportError(VIR_ERR_INVALID_ARG, _("base '%s' is not immediately below '%s' in chain " "for '%s'"), - base, top_canon, path); + base, topSource->path, path); goto endjob; } @@ -15394,7 +15393,7 @@ qemuDomainBlockCommit(virDomainPtr dom, const char *path, const char *base, * thing if the user specified a relative name). */ qemuDomainObjEnterMonitor(driver, vm); ret = qemuMonitorBlockCommit(priv->mon, device, - top ? top : top_canon, + top ? top : topSource->path, base ? base : base_canon, bandwidth); qemuDomainObjExitMonitor(driver, vm); -- 1.9.2 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list