From: Peter Krempa <[email protected]> The 'path' argument is used only for VIR_DEBUG/VIR_WARN message.
Document the function and allow passing NULL path, in which case the VIR_WARN is skipped. This will be used to allow simpler calling of metadata probing in VM stats code which will not even probe format as VM XMLs now require that format is populated. Signed-off-by: Peter Krempa <[email protected]> --- src/storage_file/storage_file_probe.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/storage_file/storage_file_probe.c b/src/storage_file/storage_file_probe.c index a1f4c25b3d..ff6512db77 100644 --- a/src/storage_file/storage_file_probe.c +++ b/src/storage_file/storage_file_probe.c @@ -854,6 +854,14 @@ virStorageFileMatchesVersion(int versionOffset, } +/** + * virStorageFileProbeFormatFromBuf: + * @path: path of image (used only for logs; may be NULL) + * @buf: buffer to probe format from + * @buflen: length of @buf + * + * Probes the format of the image header passed via @buf. + */ static int virStorageFileProbeFormatFromBuf(const char *path, char *buf, @@ -862,7 +870,7 @@ virStorageFileProbeFormatFromBuf(const char *path, int format = VIR_STORAGE_FILE_RAW; size_t i; int possibleFormat = VIR_STORAGE_FILE_RAW; - VIR_DEBUG("path=%s, buf=%p, buflen=%zu", path, buf, buflen); + VIR_DEBUG("path=%s, buf=%p, buflen=%zu", NULLSTR(path), buf, buflen); /* First check file magic */ for (i = 0; i < VIR_STORAGE_FILE_LAST; i++) { @@ -882,7 +890,7 @@ virStorageFileProbeFormatFromBuf(const char *path, } } - if (possibleFormat != VIR_STORAGE_FILE_RAW) + if (path && possibleFormat != VIR_STORAGE_FILE_RAW) VIR_WARN("File %s matches %s magic, but version is wrong. Please report new version to [email protected]", path, virStorageFileFormatTypeToString(possibleFormat)); -- 2.54.0
