qcow2: Avoid making the L1 table too big
cover qcow2: Avoid making the L1 table too big
See https://bugs.launchpad.net/qemu/+bug/1592590 for a bug report.
Reproducer:
$ ./qemu-img create -f qcow2 test.qcow2 1M Formatting 'test.qcow2', fmt=qcow2 size=1048576 encryption=off cluster_size=65536 lazy_refcounts=off refcount_bits=16 $ ./qemu-img resize test.qcow2 100000T Image resized. $ ./qemu-img info test.qcow2 qemu-img: Could not open 'test.qcow2': Active L1 table too large
After this series:
$ ./qemu-img resize test.qcow2 100000T qemu-img: Error resizing image: File too large
Max Reitz (2):
qemu-img: Use strerror() for generic resize error
qcow2: Avoid making the L1 table too big
block/qcow2-cluster.c | 2 +- qemu-img.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
Signature · 1 line
2.8.3
PATCH 1/2 qemu-img: Use strerror() for generic resize error
Emitting the plain error number is not very helpful. Use strerror() instead.
--- qemu-img.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
qemu-img.c +1 -1
@@ -3277,7 +3277,7 @@ static int img_resize(int argc, char **argv)error_report ("Image is read-only" );break ;default : -error_report ("Error resizing image (%d)" , -ret); +error_report ("Error resizing image: %s" ,strerror (-ret));break ; } out:
Signature · 1 line
2.8.3
Re: [Qemu-devel] [PATCH 1/2] qemu-img: Use strerror() for generic resize error
Quoted 13 lines · Max Reitz
Emitting the plain error number is not very helpful. Use
strerror()instead.Signed-off-by Max Reitz <[email protected]>--- qemu-img.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)qemu-img.c +0
-0
qemu-img.c static int img_resize(int argc, char **argv) · line 3281
Quoted 6 lines
qemu-img.c +1
-1@@ -3277,7 +3277,7 @@ static int img_resize(int argc, char **argv)error_report ("Image is read-only" );break ;default : -error_report ("Error resizing image (%d)" , -ret); +error_report ("Error resizing image: %s" ,strerror (-ret));break ;
I've argued in the past that we have lots of error_report() callers using strerror(), and may want to add an error_report_errno() (similar to error_setg_errno()); this just adds to the list of things that would benefit. But such a conversion would be a separate BiteSized task, and doesn't invalidate your patch.
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
PATCH 2/2 qcow2: Avoid making the L1 table too big
In reply to Max ReitzWe refuse to open images whose L1 table we deem "too big". Consequently, we should not produce such images ourselves.
--- block/qcow2-cluster.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
block/qcow2-cluster.c +1 -1
@@ -65,7 +65,7 @@ int qcow2_grow_l1_table(BlockDriverState *bs, uint64_t min_size, } } -if (new_l1_size >INT_MAX /sizeof (uint64_t )) { +if (new_l1_size >QCOW_MAX_L1_SIZE /sizeof (uint64_t )) {return -EFBIG ; }
Signature · 1 line
2.8.3
Quoted 8 lines · Max Reitz
We refuse to open images whose L1 table we deem "too big". Consequently, we should not produce such images ourselves.
Signed-off-by Max Reitz <[email protected]>--- block/qcow2-cluster.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 15 lines
block/qcow2-cluster.c +1
-1@@ -65,7 +65,7 @@ int qcow2_grow_l1_table(BlockDriverState *bs, uint64_t min_size, } } -if (new_l1_size >INT_MAX /sizeof (uint64_t )) { +if (new_l1_size >QCOW_MAX_L1_SIZE /sizeof (uint64_t )) {return -EFBIG ; }
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Am 15.06.2016 um 17:36 hat Max Reitz geschrieben:
Quoted 14 lines
We refuse to open images whose L1 table we deem "too big". Consequently, we should not produce such images ourselves.
Signed-off-by Max Reitz <[email protected]>--- block/qcow2-cluster.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)block/qcow2-cluster.c +0
-0
block/qcow2-cluster.c int qcow2_grow_l1_table(BlockDriverState *bs, uint64_t min_size, · line 70
Quoted 7 lines
block/qcow2-cluster.c +1
-1@@ -65,7 +65,7 @@ int qcow2_grow_l1_table(BlockDriverState *bs, uint64_t min_size, } } -if (new_l1_size >INT_MAX /sizeof (uint64_t )) { +if (new_l1_size >QCOW_MAX_L1_SIZE /sizeof (uint64_t )) {return -EFBIG ; }
Maybe add a QEMU_BUILD_BUG_ON(QCOW_MAX_L1_SIZE > INT_MAX)?
Kevin
Quoted 18 lines · Kevin Wolf
Am 15.06.2016 um 17:36 hat Max Reitz geschrieben:
Quoted 17 lines
We refuse to open images whose L1 table we deem "too big". Consequently, we should not produce such images ourselves.
Signed-off-by Max Reitz <[email protected]>--- block/qcow2-cluster.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)block/qcow2-cluster.c +0
-0@@ -65,7 +65,7 @@ int qcow2_grow_l1_table(BlockDriverState *bs, uint64_t min_size, } }
Quoted 6 lines
block/qcow2-cluster.c int qcow2_grow_l1_table(BlockDriverState *bs, uint64_t min_size, · line 70
Quoted 4 lines
block/qcow2-cluster.c +1
-1-if (new_l1_size >INT_MAX /sizeof (uint64_t )) { +if (new_l1_size >QCOW_MAX_L1_SIZE /sizeof (uint64_t )) {return -EFBIG ; }Maybe add a
QEMU_BUILD_BUG_ON(QCOW_MAX_L1_SIZE > INT_MAX)?
Good idea, did that. I changed it directly in my block branch, or do you think a v2 mail necessary?
Max
Am 06.07.2016 um 14:47 hat Max Reitz geschrieben:
Quoted 26 lines · Kevin Wolf
Quoted 18 lines
Am 15.06.2016 um 17:36 hat Max Reitz geschrieben:
Quoted 17 lines
We refuse to open images whose L1 table we deem "too big". Consequently, we should not produce such images ourselves.
Signed-off-by Max Reitz <[email protected]>--- block/qcow2-cluster.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)block/qcow2-cluster.c +0
-0@@ -65,7 +65,7 @@ int qcow2_grow_l1_table(BlockDriverState *bs, uint64_t min_size, } }Quoted 6 lines
block/qcow2-cluster.c int qcow2_grow_l1_table(BlockDriverState *bs, uint64_t min_size, · line 70
Quoted 4 lines
block/qcow2-cluster.c +1
-1-if (new_l1_size >INT_MAX /sizeof (uint64_t )) { +if (new_l1_size >QCOW_MAX_L1_SIZE /sizeof (uint64_t )) {return -EFBIG ; }Maybe add a
QEMU_BUILD_BUG_ON(QCOW_MAX_L1_SIZE > INT_MAX)?
Quoted 2 lines
Good idea, did that. I changed it directly in my block branch, or do you think a v2 mail necessary?
No, letting you apply it directly is what I intended.
Kevin
Max Reitz
AppliedQuoted 18 lines · Max Reitz
See https://bugs.launchpad.net/qemu/+bug/1592590 for a bug report.
Reproducer:
$ ./qemu-img create -f qcow2 test.qcow2 1M Formatting 'test.qcow2', fmt=qcow2 size=1048576 encryption=off cluster_size=65536 lazy_refcounts=off refcount_bits=16 $ ./qemu-img resize test.qcow2 100000T Image resized. $ ./qemu-img info test.qcow2 qemu-img: Could not open 'test.qcow2': Active L1 table too largeAfter this series:
$ ./qemu-img resize test.qcow2 100000T qemu-img: Error resizing image: File too large
Quoted 7 lines
Max Reitz (2):
qemu-img: Usestrerror()for generic resize error
qcow2: Avoid making the L1 table too bigblock/qcow2-cluster.c | 2 +- qemu-img.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
Applied to my block branch.
Max