
On 06/25/14 00:59, Eric Blake wrote:
On 06/19/2014 07:59 AM, Peter Krempa wrote:
The parent directory doesn't necessarily need to be stored after we don't mangle the path stored in the image. Remove it and tweak the code to avoid using it. --- src/storage/storage_driver.c | 11 ++----- src/util/virstoragefile.c | 68 ++++++++++++++++++-------------------------- src/util/virstoragefile.h | 3 -- tests/virstoragetest.c | 21 -------------- 4 files changed, 30 insertions(+), 73 deletions(-)
@@ -1372,8 +1373,20 @@ virStorageFileChainLookup(virStorageSourcePtr chain, break; if (nameIsFile && (chain->type == VIR_STORAGE_TYPE_FILE || chain->type == VIR_STORAGE_TYPE_BLOCK)) { + if (prev) { + if (!(parentDir = mdir_name(prev->path))) { + virReportOOMError(); + goto error; + } + } else { + if (VIR_STRDUP(parentDir, ".") < 0) + goto error; + } + int result = virFileRelLinkPointsTo(parentDir, name, chain->path);
Maybe you could make virFileRelLinkPointsTo gracefully handle parentDir==NULL as meaning to start from the current directory, and then you wouldn't have to strdup(".") here. But if you do that, make it a separate patch. I'm fine with this one as-is.
ACK
I've tweaked the commits according to your comments and pushed everything up to here. Thank you for the review. Peter