qemu: Probe whether an image is 'qcow2 v2' from query-named-block-nodes

Such images don't support stuff like dirty bitmaps. Note that the
synthetic test for detecting bitmaps is used as an example to prevent
adding additional test cases.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
This commit is contained in:
Peter Krempa 2021-01-29 14:35:57 +01:00
parent 9e855e7589
commit 253bce93d3
5 changed files with 18 additions and 1 deletions

View File

@ -732,6 +732,9 @@ struct _qemuBlockNamedNodeData {
/* the cluster size of the image is valid only when > 0 */
unsigned long long clusterSize;
/* image version */
bool qcow2v2;
};
GHashTable *

View File

@ -2978,6 +2978,7 @@ qemuMonitorJSONBlockGetNamedNodeDataWorker(size_t pos G_GNUC_UNUSED,
GHashTable *nodes = opaque;
virJSONValuePtr img;
virJSONValuePtr bitmaps;
virJSONValuePtr format_specific;
const char *nodename;
g_autoptr(qemuBlockNamedNodeData) ent = NULL;
@ -3000,6 +3001,16 @@ qemuMonitorJSONBlockGetNamedNodeDataWorker(size_t pos G_GNUC_UNUSED,
if ((bitmaps = virJSONValueObjectGetArray(val, "dirty-bitmaps")))
qemuMonitorJSONBlockGetNamedNodeDataBitmaps(bitmaps, ent);
/* query qcow2 format specific props */
if ((format_specific = virJSONValueObjectGetObject(img, "format-specific")) &&
STREQ_NULLABLE(virJSONValueObjectGetString(format_specific, "type"), "qcow2")) {
virJSONValuePtr qcow2props = virJSONValueObjectGetObject(format_specific, "data");
if (qcow2props &&
STREQ_NULLABLE(virJSONValueObjectGetString(qcow2props, "compat"), "0.10"))
ent->qcow2v2 = true;
}
if (virHashAddEntry(nodes, nodename, ent) < 0)
return -1;

View File

@ -599,6 +599,8 @@ testQemuDetectBitmapsWorker(GHashTable *nodedata,
return;
virBufferAsprintf(buf, "%s:\n", nodename);
if (data->qcow2v2)
virBufferAddLit(buf, " qcow2 v2\n");
virBufferAdjustIndent(buf, 1);
for (i = 0; i < data->nbitmaps; i++) {

View File

@ -12,7 +12,7 @@
"format-specific": {
"type": "qcow2",
"data": {
"compat": "1.1",
"compat": "0.10",
"compression-type": "zlib",
"lazy-refcounts": false,
"bitmaps": [

View File

@ -1,4 +1,5 @@
libvirt-1-format:
qcow2 v2
current: record:1 busy:0 persist:1 inconsist:1 gran:65536 dirty:0
top-ok: record:1 busy:0 persist:1 inconsist:0 gran:65536 dirty:0
top-inactive: record:0 busy:0 persist:1 inconsist:0 gran:65536 dirty:0