]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: block: Convert disk 'storage' backend JSON props generator to new accessors
authorPeter Krempa <pkrempa@redhat.com>
Mon, 25 Sep 2023 14:44:26 +0000 (16:44 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 17 Oct 2023 12:16:16 +0000 (14:16 +0200)
We need to use the 'effective' storage nodename (one which includes the
optional storage slice 'raw' intermediate layer) in the code which
formats the 'format' layer props.

All other cases need the real storage driver nodename as they either
generate the 'storage' layer props, or the storage slice, which refers
to the proper storage backend.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/qemu/qemu_block.c

index a98caa330e73640b9ee495d94de758b25f067492..1fc36569a9818d814ae5c6f9f22ad34bac063e2b 100644 (file)
@@ -1060,8 +1060,10 @@ qemuBlockStorageSourceGetBackendProps(virStorageSource *src,
         return NULL;
 
     if (!onlytarget) {
-        if (qemuBlockNodeNameValidate(src->nodestorage) < 0 ||
-            virJSONValueObjectAdd(&fileprops, "S:node-name", src->nodestorage, NULL) < 0)
+        if (qemuBlockNodeNameValidate(qemuBlockStorageSourceGetStorageNodename(src)) < 0 ||
+            virJSONValueObjectAdd(&fileprops,
+                                  "S:node-name", qemuBlockStorageSourceGetStorageNodename(src),
+                                  NULL) < 0)
             return NULL;
 
         if (!legacy) {
@@ -1358,10 +1360,6 @@ qemuBlockStorageSourceGetFormatProps(virStorageSource *src,
     g_autoptr(virJSONValue) props = NULL;
     const char *backingFormatterStr = NULL;
     const char *backingNodename = NULL;
-    const char *storagenode = src->nodestorage;
-
-    if (qemuBlockStorageSourceNeedsStorageSliceLayer(src))
-        storagenode = src->sliceStorage->nodename;
 
     if (virStorageSourceIsBacking(backingStore) &&
         src->format < VIR_STORAGE_FILE_BACKING) {
@@ -1386,7 +1384,7 @@ qemuBlockStorageSourceGetFormatProps(virStorageSource *src,
         return NULL;
 
     if (virJSONValueObjectAdd(&props,
-                              "s:file", storagenode,
+                              "s:file", qemuBlockStorageSourceGetEffectiveStorageNodename(src),
                               backingFormatterStr, backingNodename,
                               NULL) < 0)
         return 0;
@@ -1408,7 +1406,7 @@ qemuBlockStorageSourceGetBlockdevStorageSliceProps(virStorageSource *src)
                               "s:node-name", src->sliceStorage->nodename,
                               "U:offset", src->sliceStorage->offset,
                               "U:size", src->sliceStorage->size,
-                              "s:file", src->nodestorage,
+                              "s:file", qemuBlockStorageSourceGetStorageNodename(src),
                               "b:auto-read-only", true,
                               "s:discard", "unmap",
                               NULL) < 0)