[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 02/21] qcow2: Add refcount_width to format-specific
From: |
Max Reitz |
Subject: |
[Qemu-devel] [PATCH 02/21] qcow2: Add refcount_width to format-specific info |
Date: |
Mon, 10 Nov 2014 14:45:40 +0100 |
Add the bit width of every refcount entry to the format-specific
information.
This breaks some test outputs, fix them.
Signed-off-by: Max Reitz <address@hidden>
---
block/qcow2.c | 4 +++-
qapi/block-core.json | 5 ++++-
tests/qemu-iotests/060.out | 1 +
tests/qemu-iotests/065 | 23 +++++++++++++++--------
tests/qemu-iotests/067.out | 10 +++++-----
tests/qemu-iotests/082.out | 7 +++++++
tests/qemu-iotests/089.out | 2 ++
7 files changed, 37 insertions(+), 15 deletions(-)
diff --git a/block/qcow2.c b/block/qcow2.c
index f57aff9..d70e927 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -2475,7 +2475,8 @@ static ImageInfoSpecific
*qcow2_get_specific_info(BlockDriverState *bs)
};
if (s->qcow_version == 2) {
*spec_info->qcow2 = (ImageInfoSpecificQCow2){
- .compat = g_strdup("0.10"),
+ .compat = g_strdup("0.10"),
+ .refcount_width = s->refcount_bits,
};
} else if (s->qcow_version == 3) {
*spec_info->qcow2 = (ImageInfoSpecificQCow2){
@@ -2486,6 +2487,7 @@ static ImageInfoSpecific
*qcow2_get_specific_info(BlockDriverState *bs)
.corrupt = s->incompatible_features &
QCOW2_INCOMPAT_CORRUPT,
.has_corrupt = true,
+ .refcount_width = s->refcount_bits,
};
}
diff --git a/qapi/block-core.json b/qapi/block-core.json
index 6b4040f..8394c9b 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -41,13 +41,16 @@
# @corrupt: #optional true if the image has been marked corrupt; only valid for
# compat >= 1.1 (since 2.2)
#
+# @refcount-width: width of a refcount entry in bits (since 2.3)
+#
# Since: 1.7
##
{ 'type': 'ImageInfoSpecificQCow2',
'data': {
'compat': 'str',
'*lazy-refcounts': 'bool',
- '*corrupt': 'bool'
+ '*corrupt': 'bool',
+ 'refcount-width': 'int'
} }
##
diff --git a/tests/qemu-iotests/060.out b/tests/qemu-iotests/060.out
index 9419da1..17b3eaf 100644
--- a/tests/qemu-iotests/060.out
+++ b/tests/qemu-iotests/060.out
@@ -19,6 +19,7 @@ cluster_size: 65536
Format specific information:
compat: 1.1
lazy refcounts: false
+ refcount width: 16
corrupt: true
qemu-io: can't open device TEST_DIR/t.IMGFMT: IMGFMT: Image is corrupt; cannot
be opened read/write
read 512/512 bytes at offset 0
diff --git a/tests/qemu-iotests/065 b/tests/qemu-iotests/065
index 8d3a9c9..8539aeb 100755
--- a/tests/qemu-iotests/065
+++ b/tests/qemu-iotests/065
@@ -88,34 +88,41 @@ class TestQMP(TestImageInfoSpecific):
class TestQCow2(TestQemuImgInfo):
'''Testing a qcow2 version 2 image'''
img_options = 'compat=0.10'
- json_compare = { 'compat': '0.10' }
- human_compare = [ 'compat: 0.10' ]
+ json_compare = { 'compat': '0.10', 'refcount-width': 16 }
+ human_compare = [ 'compat: 0.10', 'refcount width: 16' ]
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, 'corrupt':
False }
- human_compare = [ 'compat: 1.1', 'lazy refcounts: false', 'corrupt: false'
]
+ json_compare = { 'compat': '1.1', 'lazy-refcounts': False,
+ 'refcount-width': 16, 'corrupt': False }
+ human_compare = [ 'compat: 1.1', 'lazy refcounts: false',
+ 'refcount width: 16', '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, 'corrupt': False
}
- human_compare = [ 'compat: 1.1', 'lazy refcounts: true', 'corrupt: false' ]
+ json_compare = { 'compat': '1.1', 'lazy-refcounts': True,
+ 'refcount-width': 16, 'corrupt': False }
+ human_compare = [ 'compat: 1.1', 'lazy refcounts: true',
+ 'refcount width: 16', '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, 'corrupt': False }
+ compare = { 'compat': '1.1', 'lazy-refcounts': False,
+ 'refcount-width': 16, '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, 'corrupt': False }
+ compare = { 'compat': '1.1', 'lazy-refcounts': True,
+ 'refcount-width': 16, 'corrupt': False }
TestImageInfoSpecific = None
TestQemuImgInfo = None
diff --git a/tests/qemu-iotests/067.out b/tests/qemu-iotests/067.out
index 0f72dcf..c04c57e 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, "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": [{"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, "refcount-width":
16, "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, "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": [{"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, "refcount-width": 16, "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, "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": [{"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, "refcount-width":
16, "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, "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": [{"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, "refcount-width":
16, "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, "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": [{"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, "refcount-width": 16, "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 0a3ab5a..4b14b4f 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
+ refcount width: 16
corrupt: false
Testing: create -f qcow2 -o cluster_size=4k -o lazy_refcounts=on -o
cluster_size=8k TEST_DIR/t.qcow2 128M
@@ -35,6 +36,7 @@ cluster_size: 8192
Format specific information:
compat: 1.1
lazy refcounts: true
+ refcount width: 16
corrupt: false
Testing: create -f qcow2 -o cluster_size=4k,cluster_size=8k TEST_DIR/t.qcow2
128M
@@ -199,6 +201,7 @@ cluster_size: 4096
Format specific information:
compat: 1.1
lazy refcounts: true
+ refcount width: 16
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
@@ -212,6 +215,7 @@ cluster_size: 8192
Format specific information:
compat: 1.1
lazy refcounts: true
+ refcount width: 16
corrupt: false
Testing: convert -O qcow2 -o cluster_size=4k,cluster_size=8k TEST_DIR/t.qcow2
TEST_DIR/t.qcow2.base
@@ -361,6 +365,7 @@ cluster_size: 65536
Format specific information:
compat: 1.1
lazy refcounts: true
+ refcount width: 16
corrupt: false
Testing: amend -f qcow2 -o size=130M -o lazy_refcounts=off TEST_DIR/t.qcow2
@@ -374,6 +379,7 @@ cluster_size: 65536
Format specific information:
compat: 1.1
lazy refcounts: false
+ refcount width: 16
corrupt: false
Testing: amend -f qcow2 -o size=8M -o lazy_refcounts=on -o size=132M
TEST_DIR/t.qcow2
@@ -387,6 +393,7 @@ cluster_size: 65536
Format specific information:
compat: 1.1
lazy refcounts: true
+ refcount width: 16
corrupt: false
Testing: amend -f qcow2 -o size=4M,size=148M TEST_DIR/t.qcow2
diff --git a/tests/qemu-iotests/089.out b/tests/qemu-iotests/089.out
index b2b0390..d788b46 100644
--- a/tests/qemu-iotests/089.out
+++ b/tests/qemu-iotests/089.out
@@ -41,6 +41,7 @@ vm state offset: 512 MiB
Format specific information:
compat: 1.1
lazy refcounts: false
+ refcount width: 16
corrupt: false
format name: IMGFMT
cluster size: 64 KiB
@@ -48,5 +49,6 @@ vm state offset: 512 MiB
Format specific information:
compat: 1.1
lazy refcounts: false
+ refcount width: 16
corrupt: false
*** done
--
1.9.3
- [Qemu-devel] [PATCH 00/21] qcow2: Support refcount orders != 4, Max Reitz, 2014/11/10
- [Qemu-devel] [PATCH 01/21] qcow2: Add two new fields to BDRVQcowState, Max Reitz, 2014/11/10
- [Qemu-devel] [PATCH 03/21] qcow2: Use 64 bits for refcount values, Max Reitz, 2014/11/10
- Re: [Qemu-devel] [PATCH 03/21] qcow2: Use 64 bits for refcount values, Eric Blake, 2014/11/10
- Re: [Qemu-devel] [PATCH 03/21] qcow2: Use 64 bits for refcount values, Max Reitz, 2014/11/11
- Re: [Qemu-devel] [PATCH 03/21] qcow2: Use 64 bits for refcount values, Kevin Wolf, 2014/11/11
- Re: [Qemu-devel] [PATCH 03/21] qcow2: Use 64 bits for refcount values, Max Reitz, 2014/11/11
- Re: [Qemu-devel] [PATCH 03/21] qcow2: Use 64 bits for refcount values, Max Reitz, 2014/11/11
- Re: [Qemu-devel] [PATCH 03/21] qcow2: Use 64 bits for refcount values, Kevin Wolf, 2014/11/11
[Qemu-devel] [PATCH 02/21] qcow2: Add refcount_width to format-specific info,
Max Reitz <=
[Qemu-devel] [PATCH 04/21] qcow2: Respect error in qcow2_alloc_bytes(), Max Reitz, 2014/11/10
[Qemu-devel] [PATCH 05/21] qcow2: Refcount overflow and qcow2_alloc_bytes(), Max Reitz, 2014/11/10