qemuBlockGetBackingStoreString: Add extra wrapping object to JSON strings

QEMU requires an extra wrapper object where only the "file" member is
populated. This is basically a placeholder for establishing the format
layer. We did the same in qemuDiskSourceGetProps for the old-school
JSON usage with -drive but forgot to adopt this for -blockdev.

https://bugzilla.redhat.com/show_bug.cgi?id=1804617

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Peter Krempa 2020-03-23 16:09:31 +01:00
parent 5a70f1048f
commit 7ba2208add
6 changed files with 9 additions and 6 deletions

View File

@ -2104,7 +2104,7 @@ qemuBlockGetBackingStoreString(virStorageSourcePtr src,
if (!(backingJSON = virJSONValueToString(props, pretty))) if (!(backingJSON = virJSONValueToString(props, pretty)))
return NULL; return NULL;
return g_strdup_printf("json:%s", backingJSON); return g_strdup_printf("json:{\"file\":%s}", backingJSON);
} }

View File

@ -10,6 +10,6 @@ format:
"driver": "qcow2", "driver": "qcow2",
"file": "0123456789ABCDEF0123456789ABCDE", "file": "0123456789ABCDEF0123456789ABCDE",
"size": 8589934590, "size": 8589934590,
"backing-file": "json:{\"driver\":\"raw\",\"offset\":1234,\"size\":5768,\"file\":{\"driver\":\"file\",\"filename\":\"/var/lib/libvirt/images/i.qcow2\"}}", "backing-file": "json:{\"file\":{\"driver\":\"raw\",\"offset\":1234,\"size\":5768,\"file\":{\"driver\":\"file\",\"filename\":\"/var/lib/libvirt/images/i.qcow2\"}}}",
"backing-fmt": "qcow2" "backing-fmt": "qcow2"
} }

View File

@ -10,6 +10,6 @@ format:
"driver": "qcow2", "driver": "qcow2",
"file": "0123456789ABCDEF0123456789ABCDE", "file": "0123456789ABCDEF0123456789ABCDE",
"size": 8589934590, "size": 8589934590,
"backing-file": "json:{\"driver\":\"raw\",\"offset\":9876,\"size\":54321,\"file\":{\"driver\":\"file\",\"filename\":\"/var/lib/libvirt/images/i.img\"}}", "backing-file": "json:{\"file\":{\"driver\":\"raw\",\"offset\":9876,\"size\":54321,\"file\":{\"driver\":\"file\",\"filename\":\"/var/lib/libvirt/images/i.img\"}}}",
"backing-fmt": "raw" "backing-fmt": "raw"
} }

View File

@ -16,7 +16,7 @@
] ]
} }
backing store string: backing store string:
json:{ json:{"file":{
"driver": "rbd", "driver": "rbd",
"pool": "rbdpool", "pool": "rbdpool",
"image": "rbdimg", "image": "rbdimg",
@ -31,6 +31,7 @@
} }
] ]
} }
}
) )
( (
source only properties: source only properties:

View File

@ -16,7 +16,7 @@
] ]
} }
backing store string: backing store string:
json:{ json:{"file":{
"driver": "rbd", "driver": "rbd",
"pool": "rbdpool", "pool": "rbdpool",
"image": "rbdimg", "image": "rbdimg",
@ -31,6 +31,7 @@
} }
] ]
} }
}
) )
( (
source only properties: source only properties:

View File

@ -6,9 +6,10 @@
"namespace": 1 "namespace": 1
} }
backing store string: backing store string:
json:{ json:{"file":{
"driver": "nvme", "driver": "nvme",
"device": "0000:01:00.0", "device": "0000:01:00.0",
"namespace": 1 "namespace": 1
} }
}
) )