From: Peter Krempa Date: Wed, 28 May 2025 14:09:01 +0000 (+0200) Subject: storage_file_probe: Refactor cowGetBackingStore into cowGetImageSpecific X-Git-Tag: v11.5.0-rc1~98 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a5fdebe901156e80c0260e36d32c2acee00cb642;p=thirdparty%2Flibvirt.git storage_file_probe: Refactor cowGetBackingStore into cowGetImageSpecific Rename the function, adjust parameters and fix the code to fill the virStorageSource fields directly. Signed-off-by: Peter Krempa Reviewed-by: Ján Tomko --- diff --git a/src/storage_file/storage_file_probe.c b/src/storage_file/storage_file_probe.c index 29837792e4..08fd3f2265 100644 --- a/src/storage_file/storage_file_probe.c +++ b/src/storage_file/storage_file_probe.c @@ -102,8 +102,10 @@ struct FileTypeInfo { }; -static int cowGetBackingStore(char **, int *, - const char *, size_t); +static int +cowGetImageSpecific(virStorageSource *meta, + const char *buf, + size_t buf_size); static unsigned long long qcow2GetClusterSize(const char *buf, size_t buf_size); @@ -303,7 +305,7 @@ static struct FileTypeInfo const fileTypeInfo[] = { [VIR_STORAGE_FILE_COW] = { 0, "OOOM", LV_BIG_ENDIAN, 4, 4, {2}, - 4+4+1024+4, 8, 1, NULL, NULL, cowGetBackingStore, NULL, NULL, NULL + 4+4+1024+4, 8, 1, NULL, NULL, NULL, NULL, NULL, cowGetImageSpecific }, [VIR_STORAGE_FILE_QCOW] = { 0, "QFI", @@ -375,23 +377,22 @@ G_STATIC_ASSERT(G_N_ELEMENTS(qcow2IncompatibleFeatureArray) == QCOW2_INCOMPATIBL static int -cowGetBackingStore(char **res, - int *format, - const char *buf, - size_t buf_size) +cowGetImageSpecific(virStorageSource *meta, + const char *buf, + size_t buf_size) { #define COW_FILENAME_MAXLEN 1024 - *res = NULL; - *format = VIR_STORAGE_FILE_AUTO; - if (buf_size < 4+4+ COW_FILENAME_MAXLEN) + g_clear_pointer(&meta->backingStoreRaw, g_free); + + if (buf_size < 4 + 4 + COW_FILENAME_MAXLEN) return 0; - if (buf[4+4] == '\0') { /* cow_header_v2.backing_file[0] */ - *format = VIR_STORAGE_FILE_NONE; + if (buf[4 + 4] == '\0') { /* cow_header_v2.backing_file[0] */ + meta->backingStoreRawFormat = VIR_STORAGE_FILE_NONE; return 0; } - *res = g_strndup((const char *)buf + 4 + 4, COW_FILENAME_MAXLEN); + meta->backingStoreRaw = g_strndup((const char *)buf + 4 + 4, COW_FILENAME_MAXLEN); return 0; }