qcow2: Add refcount_bits to format-specific info
Add the bit width of every refcount entry to the format-specific information. In contrast to lazy_refcounts and the corrupt flag, this should be always emitted, even for compat=0.10 although it does not support any refcount width other than 16 bits. This is because if a boolean is optional, one normally assumes it to be false when omitted; but if an integer is not specified, it is rather difficult to guess its value. This new field breaks some test outputs, fix them. Signed-off-by: Max Reitz <mreitz@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
parent
346a53df38
commit
0709c5a153
@ -2482,7 +2482,8 @@ static ImageInfoSpecific *qcow2_get_specific_info(BlockDriverState *bs)
|
|||||||
};
|
};
|
||||||
if (s->qcow_version == 2) {
|
if (s->qcow_version == 2) {
|
||||||
*spec_info->qcow2 = (ImageInfoSpecificQCow2){
|
*spec_info->qcow2 = (ImageInfoSpecificQCow2){
|
||||||
.compat = g_strdup("0.10"),
|
.compat = g_strdup("0.10"),
|
||||||
|
.refcount_bits = s->refcount_bits,
|
||||||
};
|
};
|
||||||
} else if (s->qcow_version == 3) {
|
} else if (s->qcow_version == 3) {
|
||||||
*spec_info->qcow2 = (ImageInfoSpecificQCow2){
|
*spec_info->qcow2 = (ImageInfoSpecificQCow2){
|
||||||
@ -2493,6 +2494,7 @@ static ImageInfoSpecific *qcow2_get_specific_info(BlockDriverState *bs)
|
|||||||
.corrupt = s->incompatible_features &
|
.corrupt = s->incompatible_features &
|
||||||
QCOW2_INCOMPAT_CORRUPT,
|
QCOW2_INCOMPAT_CORRUPT,
|
||||||
.has_corrupt = true,
|
.has_corrupt = true,
|
||||||
|
.refcount_bits = s->refcount_bits,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,13 +41,16 @@
|
|||||||
# @corrupt: #optional true if the image has been marked corrupt; only valid for
|
# @corrupt: #optional true if the image has been marked corrupt; only valid for
|
||||||
# compat >= 1.1 (since 2.2)
|
# compat >= 1.1 (since 2.2)
|
||||||
#
|
#
|
||||||
|
# @refcount-bits: width of a refcount entry in bits (since 2.3)
|
||||||
|
#
|
||||||
# Since: 1.7
|
# Since: 1.7
|
||||||
##
|
##
|
||||||
{ 'type': 'ImageInfoSpecificQCow2',
|
{ 'type': 'ImageInfoSpecificQCow2',
|
||||||
'data': {
|
'data': {
|
||||||
'compat': 'str',
|
'compat': 'str',
|
||||||
'*lazy-refcounts': 'bool',
|
'*lazy-refcounts': 'bool',
|
||||||
'*corrupt': 'bool'
|
'*corrupt': 'bool',
|
||||||
|
'refcount-bits': 'int'
|
||||||
} }
|
} }
|
||||||
|
|
||||||
##
|
##
|
||||||
|
@ -18,6 +18,7 @@ cluster_size: 65536
|
|||||||
Format specific information:
|
Format specific information:
|
||||||
compat: 1.1
|
compat: 1.1
|
||||||
lazy refcounts: false
|
lazy refcounts: false
|
||||||
|
refcount bits: 16
|
||||||
corrupt: true
|
corrupt: true
|
||||||
qemu-io: can't open device TEST_DIR/t.IMGFMT: IMGFMT: Image is corrupt; cannot be opened read/write
|
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
|
read 512/512 bytes at offset 0
|
||||||
|
@ -88,34 +88,41 @@ class TestQMP(TestImageInfoSpecific):
|
|||||||
class TestQCow2(TestQemuImgInfo):
|
class TestQCow2(TestQemuImgInfo):
|
||||||
'''Testing a qcow2 version 2 image'''
|
'''Testing a qcow2 version 2 image'''
|
||||||
img_options = 'compat=0.10'
|
img_options = 'compat=0.10'
|
||||||
json_compare = { 'compat': '0.10' }
|
json_compare = { 'compat': '0.10', 'refcount-bits': 16 }
|
||||||
human_compare = [ 'compat: 0.10' ]
|
human_compare = [ 'compat: 0.10', 'refcount bits: 16' ]
|
||||||
|
|
||||||
class TestQCow3NotLazy(TestQemuImgInfo):
|
class TestQCow3NotLazy(TestQemuImgInfo):
|
||||||
'''Testing a qcow2 version 3 image with lazy refcounts disabled'''
|
'''Testing a qcow2 version 3 image with lazy refcounts disabled'''
|
||||||
img_options = 'compat=1.1,lazy_refcounts=off'
|
img_options = 'compat=1.1,lazy_refcounts=off'
|
||||||
json_compare = { 'compat': '1.1', 'lazy-refcounts': False, 'corrupt': False }
|
json_compare = { 'compat': '1.1', 'lazy-refcounts': False,
|
||||||
human_compare = [ 'compat: 1.1', 'lazy refcounts: false', 'corrupt: false' ]
|
'refcount-bits': 16, 'corrupt': False }
|
||||||
|
human_compare = [ 'compat: 1.1', 'lazy refcounts: false',
|
||||||
|
'refcount bits: 16', 'corrupt: false' ]
|
||||||
|
|
||||||
class TestQCow3Lazy(TestQemuImgInfo):
|
class TestQCow3Lazy(TestQemuImgInfo):
|
||||||
'''Testing a qcow2 version 3 image with lazy refcounts enabled'''
|
'''Testing a qcow2 version 3 image with lazy refcounts enabled'''
|
||||||
img_options = 'compat=1.1,lazy_refcounts=on'
|
img_options = 'compat=1.1,lazy_refcounts=on'
|
||||||
json_compare = { 'compat': '1.1', 'lazy-refcounts': True, 'corrupt': False }
|
json_compare = { 'compat': '1.1', 'lazy-refcounts': True,
|
||||||
human_compare = [ 'compat: 1.1', 'lazy refcounts: true', 'corrupt: false' ]
|
'refcount-bits': 16, 'corrupt': False }
|
||||||
|
human_compare = [ 'compat: 1.1', 'lazy refcounts: true',
|
||||||
|
'refcount bits: 16', 'corrupt: false' ]
|
||||||
|
|
||||||
class TestQCow3NotLazyQMP(TestQMP):
|
class TestQCow3NotLazyQMP(TestQMP):
|
||||||
'''Testing a qcow2 version 3 image with lazy refcounts disabled, opening
|
'''Testing a qcow2 version 3 image with lazy refcounts disabled, opening
|
||||||
with lazy refcounts enabled'''
|
with lazy refcounts enabled'''
|
||||||
img_options = 'compat=1.1,lazy_refcounts=off'
|
img_options = 'compat=1.1,lazy_refcounts=off'
|
||||||
qemu_options = 'lazy-refcounts=on'
|
qemu_options = 'lazy-refcounts=on'
|
||||||
compare = { 'compat': '1.1', 'lazy-refcounts': False, 'corrupt': False }
|
compare = { 'compat': '1.1', 'lazy-refcounts': False,
|
||||||
|
'refcount-bits': 16, 'corrupt': False }
|
||||||
|
|
||||||
|
|
||||||
class TestQCow3LazyQMP(TestQMP):
|
class TestQCow3LazyQMP(TestQMP):
|
||||||
'''Testing a qcow2 version 3 image with lazy refcounts enabled, opening
|
'''Testing a qcow2 version 3 image with lazy refcounts enabled, opening
|
||||||
with lazy refcounts disabled'''
|
with lazy refcounts disabled'''
|
||||||
img_options = 'compat=1.1,lazy_refcounts=on'
|
img_options = 'compat=1.1,lazy_refcounts=on'
|
||||||
qemu_options = 'lazy-refcounts=off'
|
qemu_options = 'lazy-refcounts=off'
|
||||||
compare = { 'compat': '1.1', 'lazy-refcounts': True, 'corrupt': False }
|
compare = { 'compat': '1.1', 'lazy-refcounts': True,
|
||||||
|
'refcount-bits': 16, 'corrupt': False }
|
||||||
|
|
||||||
TestImageInfoSpecific = None
|
TestImageInfoSpecific = None
|
||||||
TestQemuImgInfo = None
|
TestQemuImgInfo = None
|
||||||
|
@ -32,6 +32,7 @@ Testing: -drive file=TEST_DIR/t.qcow2,format=qcow2,if=none,id=disk -device virti
|
|||||||
"data": {
|
"data": {
|
||||||
"compat": "1.1",
|
"compat": "1.1",
|
||||||
"lazy-refcounts": false,
|
"lazy-refcounts": false,
|
||||||
|
"refcount-bits": 16,
|
||||||
"corrupt": false
|
"corrupt": false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -208,6 +209,7 @@ Testing: -drive file=TEST_DIR/t.qcow2,format=qcow2,if=none,id=disk
|
|||||||
"data": {
|
"data": {
|
||||||
"compat": "1.1",
|
"compat": "1.1",
|
||||||
"lazy-refcounts": false,
|
"lazy-refcounts": false,
|
||||||
|
"refcount-bits": 16,
|
||||||
"corrupt": false
|
"corrupt": false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -414,6 +416,7 @@ Testing:
|
|||||||
"data": {
|
"data": {
|
||||||
"compat": "1.1",
|
"compat": "1.1",
|
||||||
"lazy-refcounts": false,
|
"lazy-refcounts": false,
|
||||||
|
"refcount-bits": 16,
|
||||||
"corrupt": false
|
"corrupt": false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -599,6 +602,7 @@ Testing:
|
|||||||
"data": {
|
"data": {
|
||||||
"compat": "1.1",
|
"compat": "1.1",
|
||||||
"lazy-refcounts": false,
|
"lazy-refcounts": false,
|
||||||
|
"refcount-bits": 16,
|
||||||
"corrupt": false
|
"corrupt": false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -710,6 +714,7 @@ Testing:
|
|||||||
"data": {
|
"data": {
|
||||||
"compat": "1.1",
|
"compat": "1.1",
|
||||||
"lazy-refcounts": false,
|
"lazy-refcounts": false,
|
||||||
|
"refcount-bits": 16,
|
||||||
"corrupt": false
|
"corrupt": false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -18,6 +18,7 @@ cluster_size: 4096
|
|||||||
Format specific information:
|
Format specific information:
|
||||||
compat: 1.1
|
compat: 1.1
|
||||||
lazy refcounts: true
|
lazy refcounts: true
|
||||||
|
refcount bits: 16
|
||||||
corrupt: false
|
corrupt: false
|
||||||
|
|
||||||
Testing: create -f qcow2 -o cluster_size=4k -o lazy_refcounts=on -o cluster_size=8k TEST_DIR/t.qcow2 128M
|
Testing: create -f qcow2 -o cluster_size=4k -o lazy_refcounts=on -o cluster_size=8k TEST_DIR/t.qcow2 128M
|
||||||
@ -29,6 +30,7 @@ cluster_size: 8192
|
|||||||
Format specific information:
|
Format specific information:
|
||||||
compat: 1.1
|
compat: 1.1
|
||||||
lazy refcounts: true
|
lazy refcounts: true
|
||||||
|
refcount bits: 16
|
||||||
corrupt: false
|
corrupt: false
|
||||||
|
|
||||||
Testing: create -f qcow2 -o cluster_size=4k,cluster_size=8k TEST_DIR/t.qcow2 128M
|
Testing: create -f qcow2 -o cluster_size=4k,cluster_size=8k TEST_DIR/t.qcow2 128M
|
||||||
@ -190,6 +192,7 @@ cluster_size: 4096
|
|||||||
Format specific information:
|
Format specific information:
|
||||||
compat: 1.1
|
compat: 1.1
|
||||||
lazy refcounts: true
|
lazy refcounts: true
|
||||||
|
refcount bits: 16
|
||||||
corrupt: false
|
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
|
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
|
||||||
@ -200,6 +203,7 @@ cluster_size: 8192
|
|||||||
Format specific information:
|
Format specific information:
|
||||||
compat: 1.1
|
compat: 1.1
|
||||||
lazy refcounts: true
|
lazy refcounts: true
|
||||||
|
refcount bits: 16
|
||||||
corrupt: false
|
corrupt: false
|
||||||
|
|
||||||
Testing: convert -O qcow2 -o cluster_size=4k,cluster_size=8k TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.base
|
Testing: convert -O qcow2 -o cluster_size=4k,cluster_size=8k TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.base
|
||||||
@ -346,6 +350,7 @@ cluster_size: 65536
|
|||||||
Format specific information:
|
Format specific information:
|
||||||
compat: 1.1
|
compat: 1.1
|
||||||
lazy refcounts: true
|
lazy refcounts: true
|
||||||
|
refcount bits: 16
|
||||||
corrupt: false
|
corrupt: false
|
||||||
|
|
||||||
Testing: amend -f qcow2 -o size=130M -o lazy_refcounts=off TEST_DIR/t.qcow2
|
Testing: amend -f qcow2 -o size=130M -o lazy_refcounts=off TEST_DIR/t.qcow2
|
||||||
@ -356,6 +361,7 @@ cluster_size: 65536
|
|||||||
Format specific information:
|
Format specific information:
|
||||||
compat: 1.1
|
compat: 1.1
|
||||||
lazy refcounts: false
|
lazy refcounts: false
|
||||||
|
refcount bits: 16
|
||||||
corrupt: false
|
corrupt: false
|
||||||
|
|
||||||
Testing: amend -f qcow2 -o size=8M -o lazy_refcounts=on -o size=132M TEST_DIR/t.qcow2
|
Testing: amend -f qcow2 -o size=8M -o lazy_refcounts=on -o size=132M TEST_DIR/t.qcow2
|
||||||
@ -366,6 +372,7 @@ cluster_size: 65536
|
|||||||
Format specific information:
|
Format specific information:
|
||||||
compat: 1.1
|
compat: 1.1
|
||||||
lazy refcounts: true
|
lazy refcounts: true
|
||||||
|
refcount bits: 16
|
||||||
corrupt: false
|
corrupt: false
|
||||||
|
|
||||||
Testing: amend -f qcow2 -o size=4M,size=148M TEST_DIR/t.qcow2
|
Testing: amend -f qcow2 -o size=4M,size=148M TEST_DIR/t.qcow2
|
||||||
|
@ -43,6 +43,7 @@ vm state offset: 512 MiB
|
|||||||
Format specific information:
|
Format specific information:
|
||||||
compat: 1.1
|
compat: 1.1
|
||||||
lazy refcounts: false
|
lazy refcounts: false
|
||||||
|
refcount bits: 16
|
||||||
corrupt: false
|
corrupt: false
|
||||||
format name: IMGFMT
|
format name: IMGFMT
|
||||||
cluster size: 64 KiB
|
cluster size: 64 KiB
|
||||||
@ -50,5 +51,6 @@ vm state offset: 512 MiB
|
|||||||
Format specific information:
|
Format specific information:
|
||||||
compat: 1.1
|
compat: 1.1
|
||||||
lazy refcounts: false
|
lazy refcounts: false
|
||||||
|
refcount bits: 16
|
||||||
corrupt: false
|
corrupt: false
|
||||||
*** done
|
*** done
|
||||||
|
Loading…
Reference in New Issue
Block a user