fix: correctly handle NFS metalink templates - mount export dir, compute real file size - #13934
Open
waterWang wants to merge 2 commits into
Open
fix: correctly handle NFS metalink templates - mount export dir, compute real file size#13934waterWang wants to merge 2 commits into
waterWang wants to merge 2 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #13916
Fixes #13917
Description
Fixes two related bugs in NFS direct download for metalink templates:
Bug 1: Template size is incorrect (#13916)
NfsDirectTemplateDownloader.getRemoteFileSize()returnednullunconditionally, so the template size was never computed for NFS metalink URLs. This caused the template size to be stored as a garbage value (e.g.,7235435666033759572bytes ≈ 6580590 TB).Fix: Implement
getRemoteFileSize()inNfsDirectTemplateDownloader:QCOW2Utils.getVirtualSize()File.length()Bug 2: Unable to launch VM with NFS metalink template (#13917)
Two issues in the NFS downloader:
Mount path was wrong:
NfsDirectTemplateDownloader.parseUrl()used the full NFS path (including the file name) as the mount source.mount -t nfs host:/export/templates/file.qcow2tries to mount a file as a filesystem, which fails with exit code 32. The fix splits the URL path into the export directory (mountable) and the file name.Wrong downloader type in metalink:
MetalinkDirectTemplateDownloader.getRemoteFileSize()used the metalink-level downloader (typicallyHttpDirectTemplateDownloader) to check inner URLs of all types, including NFS URLs. This causedcheckUrl()andgetRemoteFileSize()to be called on the wrong downloader type. The fix creates the correct downloader per URL type usingcreateDownloaderForMetalinks().Changes
NfsDirectTemplateDownloader.java:
fileNamefield to store the file name extracted from the NFS URLparseUrl(): split the NFS path into export directory (srcPath) and file name (fileName)downloadTemplate(): mount the export directory, copy the file from the correct mount point pathgetRemoteFileSize(): NEW implementation — mount NFS, read file size, unmount. Supports qcow2 virtual size viaQCOW2UtilsMetalinkDirectTemplateDownloader.java:
getRemoteFileSize(): usecreateDownloaderForMetalinks()to create the correct downloader type per inner URL, instead of reusing the outer metalink downloader