qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 2/3] qapi: Add corrupt field to ImageInfoSpecificQCo


From: Max Reitz
Subject: [Qemu-devel] [PATCH 2/3] qapi: Add corrupt field to ImageInfoSpecificQCow2
Date: Tue, 30 Sep 2014 21:31:28 +0200

Just like lazy-refcounts, this field will be present iff the qcow2
compat level is 1.1 (or probably any future revision).

As expected, this breaks some tests due to the new field present in
qemu-img info output; so fix their output accordingly.

Suggested-by: Eric Blake <address@hidden>
Signed-off-by: Max Reitz <address@hidden>
---
 block/qcow2.c              |  3 +++
 qapi/block-core.json       |  6 +++++-
 tests/qemu-iotests/065     | 12 ++++++------
 tests/qemu-iotests/067.out | 10 +++++-----
 tests/qemu-iotests/082.out |  7 +++++++
 tests/qemu-iotests/089.out |  2 ++
 6 files changed, 28 insertions(+), 12 deletions(-)

diff --git a/block/qcow2.c b/block/qcow2.c
index 778fc1e..fb28493 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -2282,6 +2282,9 @@ static ImageInfoSpecific 
*qcow2_get_specific_info(BlockDriverState *bs)
             .lazy_refcounts     = s->compatible_features &
                                   QCOW2_COMPAT_LAZY_REFCOUNTS,
             .has_lazy_refcounts = true,
+            .corrupt            = s->incompatible_features &
+                                  QCOW2_INCOMPAT_CORRUPT,
+            .has_corrupt        = true,
         };
     }
 
diff --git a/qapi/block-core.json b/qapi/block-core.json
index fa2d1b7..8f7089e 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -38,12 +38,16 @@
 #
 # @lazy-refcounts: #optional on or off; only valid for compat >= 1.1
 #
+# @corrupt: #optional true if the image has been marked corrupt; only valid for
+#           compat >= 1.1 (since 2.2)
+#
 # Since: 1.7
 ##
 { 'type': 'ImageInfoSpecificQCow2',
   'data': {
       'compat': 'str',
-      '*lazy-refcounts': 'bool'
+      '*lazy-refcounts': 'bool',
+      '*corrupt': 'bool'
   } }
 
 ##
diff --git a/tests/qemu-iotests/065 b/tests/qemu-iotests/065
index e89b61d..8d3a9c9 100755
--- a/tests/qemu-iotests/065
+++ b/tests/qemu-iotests/065
@@ -94,28 +94,28 @@ class TestQCow2(TestQemuImgInfo):
 class TestQCow3NotLazy(TestQemuImgInfo):
     '''Testing a qcow2 version 3 image with lazy refcounts disabled'''
     img_options = 'compat=1.1,lazy_refcounts=off'
-    json_compare = { 'compat': '1.1', 'lazy-refcounts': False }
-    human_compare = [ 'compat: 1.1', 'lazy refcounts: false' ]
+    json_compare = { 'compat': '1.1', 'lazy-refcounts': False, 'corrupt': 
False }
+    human_compare = [ 'compat: 1.1', 'lazy refcounts: false', 'corrupt: false' 
]
 
 class TestQCow3Lazy(TestQemuImgInfo):
     '''Testing a qcow2 version 3 image with lazy refcounts enabled'''
     img_options = 'compat=1.1,lazy_refcounts=on'
-    json_compare = { 'compat': '1.1', 'lazy-refcounts': True }
-    human_compare = [ 'compat: 1.1', 'lazy refcounts: true' ]
+    json_compare = { 'compat': '1.1', 'lazy-refcounts': True, 'corrupt': False 
}
+    human_compare = [ 'compat: 1.1', 'lazy refcounts: true', 'corrupt: false' ]
 
 class TestQCow3NotLazyQMP(TestQMP):
     '''Testing a qcow2 version 3 image with lazy refcounts disabled, opening
        with lazy refcounts enabled'''
     img_options = 'compat=1.1,lazy_refcounts=off'
     qemu_options = 'lazy-refcounts=on'
-    compare = { 'compat': '1.1', 'lazy-refcounts': False }
+    compare = { 'compat': '1.1', 'lazy-refcounts': False, 'corrupt': False }
 
 class TestQCow3LazyQMP(TestQMP):
     '''Testing a qcow2 version 3 image with lazy refcounts enabled, opening
        with lazy refcounts disabled'''
     img_options = 'compat=1.1,lazy_refcounts=on'
     qemu_options = 'lazy-refcounts=off'
-    compare = { 'compat': '1.1', 'lazy-refcounts': True }
+    compare = { 'compat': '1.1', 'lazy-refcounts': True, 'corrupt': False }
 
 TestImageInfoSpecific = None
 TestQemuImgInfo = None
diff --git a/tests/qemu-iotests/067.out b/tests/qemu-iotests/067.out
index 7e090b9..0f72dcf 100644
--- a/tests/qemu-iotests/067.out
+++ b/tests/qemu-iotests/067.out
@@ -6,7 +6,7 @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728
 Testing: -drive file=TEST_DIR/t.qcow2,format=qcow2,if=none,id=disk -device 
virtio-blk-pci,drive=disk,id=virtio0
 QMP_VERSION
 {"return": {}}
-{"return": [{"io-status": "ok", "device": "disk", "locked": false, 
"removable": false, "inserted": {"iops_rd": 0, "detect_zeroes": "off", "image": 
{"virtual-size": 134217728, "filename": "TEST_DIR/t.qcow2", "cluster-size": 
65536, "format": "qcow2", "actual-size": SIZE, "format-specific": {"type": 
"qcow2", "data": {"compat": "1.1", "lazy-refcounts": false}}, "dirty-flag": 
false}, "iops_wr": 0, "ro": false, "backing_file_depth": 0, "drv": "qcow2", 
"iops": 0, "bps_wr": 0, "encrypted": false, "bps": 0, "bps_rd": 0, "file": 
"TEST_DIR/t.qcow2", "encryption_key_missing": false}, "type": "unknown"}, 
{"io-status": "ok", "device": "ide1-cd0", "locked": false, "removable": true, 
"tray_open": false, "type": "unknown"}, {"device": "floppy0", "locked": false, 
"removable": true, "tray_open": false, "type": "unknown"}, {"device": "sd0", 
"locked": false, "removable": true, "tray_open": false, "type": "unknown"}]}
+{"return": [{"io-status": "ok", "device": "disk", "locked": false, 
"removable": false, "inserted": {"iops_rd": 0, "detect_zeroes": "off", "image": 
{"virtual-size": 134217728, "filename": "TEST_DIR/t.qcow2", "cluster-size": 
65536, "format": "qcow2", "actual-size": SIZE, "format-specific": {"type": 
"qcow2", "data": {"compat": "1.1", "lazy-refcounts": false, "corrupt": false}}, 
"dirty-flag": false}, "iops_wr": 0, "ro": false, "backing_file_depth": 0, 
"drv": "qcow2", "iops": 0, "bps_wr": 0, "encrypted": false, "bps": 0, "bps_rd": 
0, "file": "TEST_DIR/t.qcow2", "encryption_key_missing": false}, "type": 
"unknown"}, {"io-status": "ok", "device": "ide1-cd0", "locked": false, 
"removable": true, "tray_open": false, "type": "unknown"}, {"device": 
"floppy0", "locked": false, "removable": true, "tray_open": false, "type": 
"unknown"}, {"device": "sd0", "locked": false, "removable": true, "tray_open": 
false, "type": "unknown"}]}
 {"return": {}}
 {"return": {}}
 {"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": 
"DEVICE_DELETED", "data": {"path": 
"/machine/peripheral/virtio0/virtio-backend"}}
@@ -24,7 +24,7 @@ QMP_VERSION
 Testing: -drive file=TEST_DIR/t.qcow2,format=qcow2,if=none,id=disk
 QMP_VERSION
 {"return": {}}
-{"return": [{"device": "disk", "locked": false, "removable": true, "inserted": 
{"iops_rd": 0, "detect_zeroes": "off", "image": {"virtual-size": 134217728, 
"filename": "TEST_DIR/t.qcow2", "cluster-size": 65536, "format": "qcow2", 
"actual-size": SIZE, "format-specific": {"type": "qcow2", "data": {"compat": 
"1.1", "lazy-refcounts": false}}, "dirty-flag": false}, "iops_wr": 0, "ro": 
false, "backing_file_depth": 0, "drv": "qcow2", "iops": 0, "bps_wr": 0, 
"encrypted": false, "bps": 0, "bps_rd": 0, "file": "TEST_DIR/t.qcow2", 
"encryption_key_missing": false}, "tray_open": false, "type": "unknown"}, 
{"io-status": "ok", "device": "ide1-cd0", "locked": false, "removable": true, 
"tray_open": false, "type": "unknown"}, {"device": "floppy0", "locked": false, 
"removable": true, "tray_open": false, "type": "unknown"}, {"device": "sd0", 
"locked": false, "removable": true, "tray_open": false, "type": "unknown"}]}
+{"return": [{"device": "disk", "locked": false, "removable": true, "inserted": 
{"iops_rd": 0, "detect_zeroes": "off", "image": {"virtual-size": 134217728, 
"filename": "TEST_DIR/t.qcow2", "cluster-size": 65536, "format": "qcow2", 
"actual-size": SIZE, "format-specific": {"type": "qcow2", "data": {"compat": 
"1.1", "lazy-refcounts": false, "corrupt": false}}, "dirty-flag": false}, 
"iops_wr": 0, "ro": false, "backing_file_depth": 0, "drv": "qcow2", "iops": 0, 
"bps_wr": 0, "encrypted": false, "bps": 0, "bps_rd": 0, "file": 
"TEST_DIR/t.qcow2", "encryption_key_missing": false}, "tray_open": false, 
"type": "unknown"}, {"io-status": "ok", "device": "ide1-cd0", "locked": false, 
"removable": true, "tray_open": false, "type": "unknown"}, {"device": 
"floppy0", "locked": false, "removable": true, "tray_open": false, "type": 
"unknown"}, {"device": "sd0", "locked": false, "removable": true, "tray_open": 
false, "type": "unknown"}]}
 {"return": {}}
 {"return": {}}
 {"return": {}}
@@ -44,7 +44,7 @@ Testing:
 QMP_VERSION
 {"return": {}}
 {"return": "OK\r\n"}
-{"return": [{"io-status": "ok", "device": "ide1-cd0", "locked": false, 
"removable": true, "tray_open": false, "type": "unknown"}, {"device": 
"floppy0", "locked": false, "removable": true, "tray_open": false, "type": 
"unknown"}, {"device": "sd0", "locked": false, "removable": true, "tray_open": 
false, "type": "unknown"}, {"device": "disk", "locked": false, "removable": 
true, "inserted": {"iops_rd": 0, "detect_zeroes": "off", "image": 
{"virtual-size": 134217728, "filename": "TEST_DIR/t.qcow2", "cluster-size": 
65536, "format": "qcow2", "actual-size": SIZE, "format-specific": {"type": 
"qcow2", "data": {"compat": "1.1", "lazy-refcounts": false}}, "dirty-flag": 
false}, "iops_wr": 0, "ro": false, "backing_file_depth": 0, "drv": "qcow2", 
"iops": 0, "bps_wr": 0, "encrypted": false, "bps": 0, "bps_rd": 0, "file": 
"TEST_DIR/t.qcow2", "encryption_key_missing": false}, "tray_open": false, 
"type": "unknown"}]}
+{"return": [{"io-status": "ok", "device": "ide1-cd0", "locked": false, 
"removable": true, "tray_open": false, "type": "unknown"}, {"device": 
"floppy0", "locked": false, "removable": true, "tray_open": false, "type": 
"unknown"}, {"device": "sd0", "locked": false, "removable": true, "tray_open": 
false, "type": "unknown"}, {"device": "disk", "locked": false, "removable": 
true, "inserted": {"iops_rd": 0, "detect_zeroes": "off", "image": 
{"virtual-size": 134217728, "filename": "TEST_DIR/t.qcow2", "cluster-size": 
65536, "format": "qcow2", "actual-size": SIZE, "format-specific": {"type": 
"qcow2", "data": {"compat": "1.1", "lazy-refcounts": false, "corrupt": false}}, 
"dirty-flag": false}, "iops_wr": 0, "ro": false, "backing_file_depth": 0, 
"drv": "qcow2", "iops": 0, "bps_wr": 0, "encrypted": false, "bps": 0, "bps_rd": 
0, "file": "TEST_DIR/t.qcow2", "encryption_key_missing": false}, "tray_open": 
false, "type": "unknown"}]}
 {"return": {}}
 {"return": {}}
 {"return": {}}
@@ -64,14 +64,14 @@ Testing:
 QMP_VERSION
 {"return": {}}
 {"return": {}}
-{"return": [{"io-status": "ok", "device": "ide1-cd0", "locked": false, 
"removable": true, "tray_open": false, "type": "unknown"}, {"device": 
"floppy0", "locked": false, "removable": true, "tray_open": false, "type": 
"unknown"}, {"device": "sd0", "locked": false, "removable": true, "tray_open": 
false, "type": "unknown"}, {"device": "disk", "locked": false, "removable": 
true, "inserted": {"iops_rd": 0, "detect_zeroes": "off", "image": 
{"virtual-size": 134217728, "filename": "TEST_DIR/t.qcow2", "cluster-size": 
65536, "format": "qcow2", "actual-size": SIZE, "format-specific": {"type": 
"qcow2", "data": {"compat": "1.1", "lazy-refcounts": false}}, "dirty-flag": 
false}, "iops_wr": 0, "ro": false, "backing_file_depth": 0, "drv": "qcow2", 
"iops": 0, "bps_wr": 0, "encrypted": false, "bps": 0, "bps_rd": 0, "file": 
"TEST_DIR/t.qcow2", "encryption_key_missing": false}, "tray_open": false, 
"type": "unknown"}]}
+{"return": [{"io-status": "ok", "device": "ide1-cd0", "locked": false, 
"removable": true, "tray_open": false, "type": "unknown"}, {"device": 
"floppy0", "locked": false, "removable": true, "tray_open": false, "type": 
"unknown"}, {"device": "sd0", "locked": false, "removable": true, "tray_open": 
false, "type": "unknown"}, {"device": "disk", "locked": false, "removable": 
true, "inserted": {"iops_rd": 0, "detect_zeroes": "off", "image": 
{"virtual-size": 134217728, "filename": "TEST_DIR/t.qcow2", "cluster-size": 
65536, "format": "qcow2", "actual-size": SIZE, "format-specific": {"type": 
"qcow2", "data": {"compat": "1.1", "lazy-refcounts": false, "corrupt": false}}, 
"dirty-flag": false}, "iops_wr": 0, "ro": false, "backing_file_depth": 0, 
"drv": "qcow2", "iops": 0, "bps_wr": 0, "encrypted": false, "bps": 0, "bps_rd": 
0, "file": "TEST_DIR/t.qcow2", "encryption_key_missing": false}, "tray_open": 
false, "type": "unknown"}]}
 {"return": {}}
 {"return": {}}
 {"return": {}}
 {"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": 
"DEVICE_DELETED", "data": {"path": 
"/machine/peripheral/virtio0/virtio-backend"}}
 {"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": 
"DEVICE_DELETED", "data": {"device": "virtio0", "path": 
"/machine/peripheral/virtio0"}}
 {"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": 
"RESET"}
-{"return": [{"io-status": "ok", "device": "ide1-cd0", "locked": false, 
"removable": true, "tray_open": false, "type": "unknown"}, {"device": 
"floppy0", "locked": false, "removable": true, "tray_open": false, "type": 
"unknown"}, {"device": "sd0", "locked": false, "removable": true, "tray_open": 
false, "type": "unknown"}, {"io-status": "ok", "device": "disk", "locked": 
false, "removable": true, "inserted": {"iops_rd": 0, "detect_zeroes": "off", 
"image": {"virtual-size": 134217728, "filename": "TEST_DIR/t.qcow2", 
"cluster-size": 65536, "format": "qcow2", "actual-size": SIZE, 
"format-specific": {"type": "qcow2", "data": {"compat": "1.1", 
"lazy-refcounts": false}}, "dirty-flag": false}, "iops_wr": 0, "ro": false, 
"backing_file_depth": 0, "drv": "qcow2", "iops": 0, "bps_wr": 0, "encrypted": 
false, "bps": 0, "bps_rd": 0, "file": "TEST_DIR/t.qcow2", 
"encryption_key_missing": false}, "tray_open": false, "type": "unknown"}]}
+{"return": [{"io-status": "ok", "device": "ide1-cd0", "locked": false, 
"removable": true, "tray_open": false, "type": "unknown"}, {"device": 
"floppy0", "locked": false, "removable": true, "tray_open": false, "type": 
"unknown"}, {"device": "sd0", "locked": false, "removable": true, "tray_open": 
false, "type": "unknown"}, {"io-status": "ok", "device": "disk", "locked": 
false, "removable": true, "inserted": {"iops_rd": 0, "detect_zeroes": "off", 
"image": {"virtual-size": 134217728, "filename": "TEST_DIR/t.qcow2", 
"cluster-size": 65536, "format": "qcow2", "actual-size": SIZE, 
"format-specific": {"type": "qcow2", "data": {"compat": "1.1", 
"lazy-refcounts": false, "corrupt": false}}, "dirty-flag": false}, "iops_wr": 
0, "ro": false, "backing_file_depth": 0, "drv": "qcow2", "iops": 0, "bps_wr": 
0, "encrypted": false, "bps": 0, "bps_rd": 0, "file": "TEST_DIR/t.qcow2", 
"encryption_key_missing": false}, "tray_open": false, "type": "unknown"}]}
 {"return": {}}
 {"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": 
"SHUTDOWN"}
 {"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": 
"DEVICE_TRAY_MOVED", "data": {"device": "ide1-cd0", "tray-open": true}}
diff --git a/tests/qemu-iotests/082.out b/tests/qemu-iotests/082.out
index 249c5e4..0a3ab5a 100644
--- a/tests/qemu-iotests/082.out
+++ b/tests/qemu-iotests/082.out
@@ -21,6 +21,7 @@ cluster_size: 4096
 Format specific information:
     compat: 1.1
     lazy refcounts: true
+    corrupt: false
 
 Testing: create -f qcow2 -o cluster_size=4k -o lazy_refcounts=on -o 
cluster_size=8k TEST_DIR/t.qcow2 128M
 Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=134217728 encryption=off 
cluster_size=8192 lazy_refcounts=on 
@@ -34,6 +35,7 @@ cluster_size: 8192
 Format specific information:
     compat: 1.1
     lazy refcounts: true
+    corrupt: false
 
 Testing: create -f qcow2 -o cluster_size=4k,cluster_size=8k TEST_DIR/t.qcow2 
128M
 Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=134217728 encryption=off 
cluster_size=8192 lazy_refcounts=off 
@@ -197,6 +199,7 @@ cluster_size: 4096
 Format specific information:
     compat: 1.1
     lazy refcounts: true
+    corrupt: false
 
 Testing: convert -O qcow2 -o cluster_size=4k -o lazy_refcounts=on -o 
cluster_size=8k TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.base
 
@@ -209,6 +212,7 @@ cluster_size: 8192
 Format specific information:
     compat: 1.1
     lazy refcounts: true
+    corrupt: false
 
 Testing: convert -O qcow2 -o cluster_size=4k,cluster_size=8k TEST_DIR/t.qcow2 
TEST_DIR/t.qcow2.base
 image: TEST_DIR/t.IMGFMT.base
@@ -357,6 +361,7 @@ cluster_size: 65536
 Format specific information:
     compat: 1.1
     lazy refcounts: true
+    corrupt: false
 
 Testing: amend -f qcow2 -o size=130M -o lazy_refcounts=off TEST_DIR/t.qcow2
 
@@ -369,6 +374,7 @@ cluster_size: 65536
 Format specific information:
     compat: 1.1
     lazy refcounts: false
+    corrupt: false
 
 Testing: amend -f qcow2 -o size=8M -o lazy_refcounts=on -o size=132M 
TEST_DIR/t.qcow2
 
@@ -381,6 +387,7 @@ cluster_size: 65536
 Format specific information:
     compat: 1.1
     lazy refcounts: true
+    corrupt: false
 
 Testing: amend -f qcow2 -o size=4M,size=148M TEST_DIR/t.qcow2
 image: TEST_DIR/t.IMGFMT
diff --git a/tests/qemu-iotests/089.out b/tests/qemu-iotests/089.out
index 4ca2f88..b2b0390 100644
--- a/tests/qemu-iotests/089.out
+++ b/tests/qemu-iotests/089.out
@@ -41,10 +41,12 @@ vm state offset: 512 MiB
 Format specific information:
     compat: 1.1
     lazy refcounts: false
+    corrupt: false
 format name: IMGFMT
 cluster size: 64 KiB
 vm state offset: 512 MiB
 Format specific information:
     compat: 1.1
     lazy refcounts: false
+    corrupt: false
 *** done
-- 
2.1.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]