[PATCH 04/23] chardev/baum: Avoid dynamic stack allocation

2021-05-05 Thread Philippe Mathieu-Daudé
Use autofree heap allocation instead of variable-length array on the stack. Signed-off-by: Philippe Mathieu-Daudé --- chardev/baum.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/chardev/baum.c b/chardev/baum.c index 0822e9ed5f3..bc09cda3471 100644 --- a/chardev/baum.c

[PATCH 08/23] hw/block/nvme: Avoid dynamic stack allocation

2021-05-05 Thread Philippe Mathieu-Daudé
Use autofree heap allocation instead of variable-length array on the stack. Signed-off-by: Philippe Mathieu-Daudé --- hw/block/nvme.c | 15 --- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/hw/block/nvme.c b/hw/block/nvme.c index 2f6d4925826..905c4bb57af 100644 ---

[PATCH 03/23] chardev/baum: Use definitions to avoid dynamic stack allocation

2021-05-05 Thread Philippe Mathieu-Daudé
We know 'x * y' will be at most 'X_MAX * Y_MAX' (which is not a big value, it is actually 84). Instead of having the compiler use variable-length array, declare an array able to hold the maximum 'x * y'. Signed-off-by: Philippe Mathieu-Daudé --- chardev/baum.c | 8 1 file changed, 4

[PATCH 20/23] util/iov: Avoid dynamic stack allocation

2021-05-05 Thread Philippe Mathieu-Daudé
Use autofree heap allocation instead of variable-length array on the stack. Signed-off-by: Philippe Mathieu-Daudé --- util/iov.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/iov.c b/util/iov.c index 58c7b35..fc76d717e14 100644 --- a/util/iov.c +++ b/util/iov.c @@

[PATCH 19/23] ui/vnc-enc-tight: Avoid dynamic stack allocation

2021-05-05 Thread Philippe Mathieu-Daudé
Use autofree heap allocation instead of variable-length array on the stack. Signed-off-by: Philippe Mathieu-Daudé --- ui/vnc-enc-tight.c | 11 ++- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/ui/vnc-enc-tight.c b/ui/vnc-enc-tight.c index cebd35841a9..ff6027cf8d4 100644

[PATCH 18/23] ui/vnc-enc-hextile: Use definitions to avoid dynamic stack allocation

2021-05-05 Thread Philippe Mathieu-Daudé
We know 'pf.bytes_per_pixel' will be at most 'VNC_SERVER_FB_BYTES' (which is actually 4 bytes for 32bpp). Instead of having the compiler use variable-length array, use this 'small' maximum length and autofree to allocate the buffer on the heap. Signed-off-by: Philippe Mathieu-Daudé ---

Re: [PATCH 04/23] chardev/baum: Avoid dynamic stack allocation

2021-05-05 Thread Marc-André Lureau
On Thu, May 6, 2021 at 1:15 AM Philippe Mathieu-Daudé wrote: > Use autofree heap allocation instead of variable-length > array on the stack. > > Signed-off-by: Philippe Mathieu-Daudé > Reviewed-by: Marc-André Lureau --- > chardev/baum.c | 3 ++- > 1 file changed, 2 insertions(+), 1

Re: [PATCH 02/23] chardev/baum: Replace magic values by X_MAX / Y_MAX definitions

2021-05-05 Thread Marc-André Lureau
On Thu, May 6, 2021 at 1:13 AM Philippe Mathieu-Daudé wrote: > Replace '84' magic value by the X_MAX definition, and '1' by Y_MAX. > > Signed-off-by: Philippe Mathieu-Daudé > Reviewed-by: Marc-André Lureau > --- > chardev/baum.c | 11 +++ > 1 file changed, 7 insertions(+), 4

[PATCH 22/23] tests/unit/test-vmstate: Avoid dynamic stack allocation

2021-05-05 Thread Philippe Mathieu-Daudé
Use autofree heap allocation instead of variable-length array on the stack. Signed-off-by: Philippe Mathieu-Daudé --- tests/unit/test-vmstate.c | 7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tests/unit/test-vmstate.c b/tests/unit/test-vmstate.c index

Re: [PATCH 07/23] hw/block/nvme: Use definition to avoid dynamic stack allocation

2021-05-05 Thread Philippe Mathieu-Daudé
+Eric On 5/5/21 11:22 PM, Keith Busch wrote: > On Wed, May 05, 2021 at 11:10:31PM +0200, Philippe Mathieu-Daudé wrote: >> The compiler isn't clever enough to figure 'SEG_CHUNK_SIZE' is >> a constant! Help it by using a definitions instead. > > I don't understand. Neither do I TBH... > It's

[PATCH v3] Document qemu-img options data_file and data_file_raw

2021-05-05 Thread Connor Kuehl
The contents of this patch were initially developed and posted by Han Han[1], however, it appears the original patch was not applied. Since then, the relevant documentation has been moved and adapted to a new format. I've taken most of the original wording and tweaked it according to some of the

[PATCH 10/23] hw/ppc/pnv: Avoid dynamic stack allocation

2021-05-05 Thread Philippe Mathieu-Daudé
Use autofree heap allocation instead of variable-length array on the stack. Signed-off-by: Philippe Mathieu-Daudé --- hw/ppc/pnv.c | 4 ++-- hw/ppc/spapr.c | 8 hw/ppc/spapr_pci_nvlink2.c | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git

[PATCH 21/23] target/ppc/kvm: Avoid dynamic stack allocation

2021-05-05 Thread Philippe Mathieu-Daudé
Use autofree heap allocation instead of variable-length array on the stack. Signed-off-by: Philippe Mathieu-Daudé --- target/ppc/kvm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c index ae62daddf7d..90d0230eb86 100644 ---

[PATCH 11/23] hw/intc/xics: Avoid dynamic stack allocation

2021-05-05 Thread Philippe Mathieu-Daudé
Use autofree heap allocation instead of variable-length array on the stack. Signed-off-by: Philippe Mathieu-Daudé --- hw/intc/xics.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/intc/xics.c b/hw/intc/xics.c index 68f9d44feb4..c293d00d5c4 100644 --- a/hw/intc/xics.c +++

[PATCH 12/23] hw/i386/multiboot: Avoid dynamic stack allocation

2021-05-05 Thread Philippe Mathieu-Daudé
Use autofree heap allocation instead of variable-length array on the stack. Replace the snprintf() call by g_strdup_printf(). Signed-off-by: Philippe Mathieu-Daudé --- hw/i386/multiboot.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/hw/i386/multiboot.c

[PATCH 23/23] configure: Prohibit variable-length allocations by using -Wvla CPPFLAG

2021-05-05 Thread Philippe Mathieu-Daudé
Now that we converted all variable-length allocations in the repository, add the -Wvla CPPFLAG to trigger a build failure if such allocation is used. This should help avoiding vulnerabilities such CVE-2021-3527 (see commit range 3f67e2e7f13..05a40b172e4). Inspired-by: Gerd Hoffmann

Re: [PATCH 03/23] chardev/baum: Use definitions to avoid dynamic stack allocation

2021-05-05 Thread Samuel Thibault
Philippe Mathieu-Daudé, le mer. 05 mai 2021 23:10:27 +0200, a ecrit: > We know 'x * y' will be at most 'X_MAX * Y_MAX' (which is not > a big value, it is actually 84). Instead of having the compiler > use variable-length array, declare an array able to hold the > maximum 'x * y'. > >

Re: [PATCH] block/snapshot: Clarify goto fallback behavior

2021-05-05 Thread Vladimir Sementsov-Ogievskiy
05.05.2021 19:25, Max Reitz wrote: On 05.05.21 17:05, Vladimir Sementsov-Ogievskiy wrote: 03.05.2021 12:54, Max Reitz wrote: In the bdrv_snapshot_goto() fallback code, we work with a pointer to either bs->file or bs->backing. We close that child, Do we? We *detach it. close the node

[PATCH 14/23] hw/usb/hcd-ohci: Use definition to avoid dynamic stack allocation

2021-05-05 Thread Philippe Mathieu-Daudé
The compiler isn't clever enough to figure 'width' is a constant, so help it by using a definitions instead. Signed-off-by: Philippe Mathieu-Daudé --- hw/usb/hcd-ohci.c | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/hw/usb/hcd-ohci.c b/hw/usb/hcd-ohci.c index

[PATCH 07/23] hw/block/nvme: Use definition to avoid dynamic stack allocation

2021-05-05 Thread Philippe Mathieu-Daudé
The compiler isn't clever enough to figure 'SEG_CHUNK_SIZE' is a constant! Help it by using a definitions instead. Signed-off-by: Philippe Mathieu-Daudé --- hw/block/nvme.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/block/nvme.c b/hw/block/nvme.c index

[PATCH 02/23] chardev/baum: Replace magic values by X_MAX / Y_MAX definitions

2021-05-05 Thread Philippe Mathieu-Daudé
Replace '84' magic value by the X_MAX definition, and '1' by Y_MAX. Signed-off-by: Philippe Mathieu-Daudé --- chardev/baum.c | 11 +++ 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/chardev/baum.c b/chardev/baum.c index 5deca778bc4..adc3d7b3b56 100644 --- a/chardev/baum.c

[PATCH 01/23] block/vpc: Avoid dynamic stack allocation

2021-05-05 Thread Philippe Mathieu-Daudé
Use autofree heap allocation instead of variable-length array on the stack. Signed-off-by: Philippe Mathieu-Daudé --- block/vpc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/block/vpc.c b/block/vpc.c index 17a705b482a..9ed144331fd 100644 --- a/block/vpc.c +++

[PATCH 00/23] misc: Remove variable-length arrays on the stack

2021-05-05 Thread Philippe Mathieu-Daudé
Hi, This series is inspired by Gerd Hoffmann and CVE-2021-3527. It removes all uses of variable-length arrays in the repository, then enable the '-Wvla' warning to avoid new code using vla to be merged. Mostly trivial patches using GLib autofree. Please review, Phil. (based on usb-20210505

[PATCH 15/23] net: Avoid dynamic stack allocation

2021-05-05 Thread Philippe Mathieu-Daudé
Use autofree heap allocation instead of variable-length array on the stack. Signed-off-by: Philippe Mathieu-Daudé --- hw/net/fsl_etsec/rings.c | 9 - hw/net/rocker/rocker_of_dpa.c | 2 +- net/dump.c| 2 +- net/tap.c | 2 +- 4 files changed, 7

[PATCH 17/23] ui/spice-display: Avoid dynamic stack allocation

2021-05-05 Thread Philippe Mathieu-Daudé
Use autofree heap allocation instead of variable-length array on the stack. Signed-off-by: Philippe Mathieu-Daudé --- ui/spice-display.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/spice-display.c b/ui/spice-display.c index d22781a23d0..61c4259363b 100644 ---

[PATCH 13/23] hw/usb/hcd-xhci: Avoid dynamic stack allocation

2021-05-05 Thread Philippe Mathieu-Daudé
Use autofree heap allocation instead of variable-length array on the stack. Signed-off-by: Philippe Mathieu-Daudé --- hw/usb/hcd-xhci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c index 7acfb8137bc..59a267e3c8b 100644 ---

Re: [PATCH 04/23] chardev/baum: Avoid dynamic stack allocation

2021-05-05 Thread Samuel Thibault
Philippe Mathieu-Daudé, le mer. 05 mai 2021 23:10:28 +0200, a ecrit: > Use autofree heap allocation instead of variable-length > array on the stack. > > Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Samuel Thibault > --- > chardev/baum.c | 3 ++- > 1 file changed, 2 insertions(+), 1

Re: [PATCH 07/23] hw/block/nvme: Use definition to avoid dynamic stack allocation

2021-05-05 Thread Warner Losh
On Wed, May 5, 2021, 5:10 PM Eric Blake wrote: > On 5/5/21 5:07 PM, Philippe Mathieu-Daudé wrote: > > +Eric > > > > On 5/5/21 11:22 PM, Keith Busch wrote: > >> On Wed, May 05, 2021 at 11:10:31PM +0200, Philippe Mathieu-Daudé wrote: > >>> The compiler isn't clever enough to figure

Re: [PATCH v2 9/9] block/write-threshold: drop extra includes

2021-05-05 Thread Vladimir Sementsov-Ogievskiy
05.05.2021 19:23, Max Reitz wrote: On 04.05.21 10:25, Vladimir Sementsov-Ogievskiy wrote: Signed-off-by: Vladimir Sementsov-Ogievskiy ---   block/write-threshold.c | 3 ---   1 file changed, 3 deletions(-) diff --git a/block/write-threshold.c b/block/write-threshold.c index

[PATCH 16/23] ui/curses: Avoid dynamic stack allocation

2021-05-05 Thread Philippe Mathieu-Daudé
Use autofree heap allocation instead of variable-length array on the stack. Signed-off-by: Philippe Mathieu-Daudé --- ui/curses.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/curses.c b/ui/curses.c index e4f9588c3e8..f490b2d839d 100644 --- a/ui/curses.c +++

Re: [PATCH 07/23] hw/block/nvme: Use definition to avoid dynamic stack allocation

2021-05-05 Thread Eric Blake
On 5/5/21 5:07 PM, Philippe Mathieu-Daudé wrote: > +Eric > > On 5/5/21 11:22 PM, Keith Busch wrote: >> On Wed, May 05, 2021 at 11:10:31PM +0200, Philippe Mathieu-Daudé wrote: >>> The compiler isn't clever enough to figure 'SEG_CHUNK_SIZE' is >>> a constant! Help it by using a definitions instead.

[PATCH 06/23] hw/block/dataplane/virtio-blk: Avoid dynamic stack allocation

2021-05-05 Thread Philippe Mathieu-Daudé
Use autofree heap allocation instead of variable-length array on the stack. Signed-off-by: Philippe Mathieu-Daudé --- hw/block/dataplane/virtio-blk.c | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/hw/block/dataplane/virtio-blk.c b/hw/block/dataplane/virtio-blk.c

[PATCH 05/23] io/channel-websock: Replace strlen(const_str) by sizeof(const_str) - 1

2021-05-05 Thread Philippe Mathieu-Daudé
The combined_key[... QIO_CHANNEL_WEBSOCK_GUID_LEN ...] array in qio_channel_websock_handshake_send_res_ok() expands to a call to strlen(QIO_CHANNEL_WEBSOCK_GUID), and the compiler doesn't realize the string is const, so consider combined_key[] being a variable-length array. To remove the

[PATCH 09/23] hw/net/e1000e_core: Use definition to avoid dynamic stack allocation

2021-05-05 Thread Philippe Mathieu-Daudé
The compiler isn't clever enough to figure 'min_buf_size' is a constant, so help it by using a definitions instead. Signed-off-by: Philippe Mathieu-Daudé --- hw/net/e1000e_core.c | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/hw/net/e1000e_core.c

Re: [PATCH 07/23] hw/block/nvme: Use definition to avoid dynamic stack allocation

2021-05-05 Thread Keith Busch
On Wed, May 05, 2021 at 11:10:31PM +0200, Philippe Mathieu-Daudé wrote: > The compiler isn't clever enough to figure 'SEG_CHUNK_SIZE' is > a constant! Help it by using a definitions instead. I don't understand. It's labeled 'const', so any reasonable compiler will place it in the 'text' segment

Re: [PATCH 03/23] chardev/baum: Use definitions to avoid dynamic stack allocation

2021-05-05 Thread Marc-André Lureau
On Thu, May 6, 2021 at 1:14 AM Philippe Mathieu-Daudé wrote: > We know 'x * y' will be at most 'X_MAX * Y_MAX' (which is not > a big value, it is actually 84). Instead of having the compiler > use variable-length array, declare an array able to hold the > maximum 'x * y'. > > Signed-off-by:

Re: [PATCH 03/23] chardev/baum: Use definitions to avoid dynamic stack allocation

2021-05-05 Thread Samuel Thibault
Marc-André Lureau, le jeu. 06 mai 2021 01:27:25 +0400, a ecrit: > @@ -408,7 +408,7 @@ static int baum_eat_packet(BaumChardev *baum, const > uint8_t *buf, int len) >          } >          timer_del(baum->cellCount_timer); > > -        memset(zero, 0, sizeof(zero)); > +     

Re: [PATCH 02/23] chardev/baum: Replace magic values by X_MAX / Y_MAX definitions

2021-05-05 Thread Samuel Thibault
Philippe Mathieu-Daudé, le mer. 05 mai 2021 23:10:26 +0200, a ecrit: > Replace '84' magic value by the X_MAX definition, and '1' by Y_MAX. > > Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Samuel Thibault > --- > chardev/baum.c | 11 +++ > 1 file changed, 7 insertions(+), 4

Re: [PATCH 11/23] hw/intc/xics: Avoid dynamic stack allocation

2021-05-05 Thread David Gibson
On Wed, May 05, 2021 at 11:10:35PM +0200, Philippe Mathieu-Daudé wrote: > Use autofree heap allocation instead of variable-length > array on the stack. > > Signed-off-by: Philippe Mathieu-Daudé Acked-by: David Gibson > --- > hw/intc/xics.c | 2 +- > 1 file changed, 1 insertion(+), 1

Re: [PATCH 21/23] target/ppc/kvm: Avoid dynamic stack allocation

2021-05-05 Thread David Gibson
On Wed, May 05, 2021 at 11:10:45PM +0200, Philippe Mathieu-Daudé wrote: > Use autofree heap allocation instead of variable-length > array on the stack. > > Signed-off-by: Philippe Mathieu-Daudé Acked-by: David Gibson > --- > target/ppc/kvm.c | 2 +- > 1 file changed, 1 insertion(+), 1

Re: [PATCH 09/23] hw/net/e1000e_core: Use definition to avoid dynamic stack allocation

2021-05-05 Thread Jason Wang
在 2021/5/6 上午5:10, Philippe Mathieu-Daudé 写道: The compiler isn't clever enough to figure 'min_buf_size' is a constant, so help it by using a definitions instead. Signed-off-by: Philippe Mathieu-Daudé Acked-by: Jason Wang --- hw/net/e1000e_core.c | 7 --- 1 file changed, 4

Re: [PATCH 07/23] hw/block/nvme: Use definition to avoid dynamic stack allocation

2021-05-05 Thread Keith Busch
On Wed, May 05, 2021 at 06:09:10PM -0500, Eric Blake wrote: > On 5/5/21 5:07 PM, Philippe Mathieu-Daudé wrote: > > +Eric > > > > On 5/5/21 11:22 PM, Keith Busch wrote: > >> On Wed, May 05, 2021 at 11:10:31PM +0200, Philippe Mathieu-Daudé wrote: > >>> The compiler isn't clever enough to figure

Re: [PATCH 15/23] net: Avoid dynamic stack allocation

2021-05-05 Thread David Gibson
On Wed, May 05, 2021 at 11:10:39PM +0200, Philippe Mathieu-Daudé wrote: > Use autofree heap allocation instead of variable-length > array on the stack. > > Signed-off-by: Philippe Mathieu-Daudé fsl_etsec parts Acked-by: David Gibson > --- > hw/net/fsl_etsec/rings.c | 9 - >

Re: [PATCH 10/23] hw/ppc/pnv: Avoid dynamic stack allocation

2021-05-05 Thread David Gibson
On Wed, May 05, 2021 at 11:10:34PM +0200, Philippe Mathieu-Daudé wrote: > Use autofree heap allocation instead of variable-length > array on the stack. > > Signed-off-by: Philippe Mathieu-Daudé Acked-by: David Gibson > --- > hw/ppc/pnv.c | 4 ++-- > hw/ppc/spapr.c |

Re: [PATCH 1/7] migration: use GDateTime for formatting timestamp in snapshot names

2021-05-05 Thread Brad Smith
Thank you. On 5/5/2021 6:36 AM, Daniel P. Berrangé wrote: The GDateTime APIs provided by GLib avoid portability pitfalls, such as some platforms where 'struct timeval.tv_sec' field is still 'long' instead of 'time_t'. When combined with automatic cleanup, GDateTime often results in simpler code

[PATCH v2 09/10] qcow2-refcount: check_refcounts_l1(): check reserved bits

2021-05-05 Thread Vladimir Sementsov-Ogievskiy
Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Eric Blake --- block/qcow2.h | 1 + block/qcow2-refcount.c | 6 ++ 2 files changed, 7 insertions(+) diff --git a/block/qcow2.h b/block/qcow2.h index b8b1093b61..58fd7f1678 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@

[PATCH v2 07/10] qcow2-refcount: check_refcounts_l2(): check reserved bits

2021-05-05 Thread Vladimir Sementsov-Ogievskiy
Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Eric Blake --- block/qcow2.h | 1 + block/qcow2-refcount.c | 12 +++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/block/qcow2.h b/block/qcow2.h index c0e1e83796..b8b1093b61 100644 --- a/block/qcow2.h

[PATCH v2 08/10] qcow2-refcount: improve style of check_refcounts_l1()

2021-05-05 Thread Vladimir Sementsov-Ogievskiy
- use g_autofree for l1_table - better name for size in bytes variable - reduce code blocks nesting - whitespaces, braces, newlines Signed-off-by: Vladimir Sementsov-Ogievskiy --- block/qcow2-refcount.c | 98 +- 1 file changed, 50 insertions(+), 48

[PATCH v2 02/10] qcow2: compressed read: simplify cluster descriptor passing

2021-05-05 Thread Vladimir Sementsov-Ogievskiy
Let's pass the whole L2 entry and not bother with L2E_COMPRESSED_OFFSET_SIZE_MASK. It also helps further refactoring that adds generic qcow2_parse_compressed_l2_entry() helper. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Eric Blake --- block/qcow2.h | 1 -

[PATCH v2 05/10] qcow2-refcount: fix_l2_entry_by_zero(): also zero L2 entry bitmap

2021-05-05 Thread Vladimir Sementsov-Ogievskiy
We'll reuse the function to fix wrong L2 entry bitmap. Support it now. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Eric Blake --- block/qcow2-refcount.c | 18 +++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/block/qcow2-refcount.c

[PATCH v2 06/10] qcow2-refcount: check_refcounts_l2(): check l2_bitmap

2021-05-05 Thread Vladimir Sementsov-Ogievskiy
Check subcluster bitmap of the l2 entry for different types of clusters: - for compressed it must be zero - for allocated check consistency of two parts of the bitmap - for unallocated all subclusters should be unallocated (or zero-plain) For unallocated clusters we can safely fix the

[PATCH v2 10/10] qcow2-refcount: check_refblocks(): add separate message for reserved

2021-05-05 Thread Vladimir Sementsov-Ogievskiy
Split checking for reserved bits out of aligned offset check. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Eric Blake --- block/qcow2.h | 1 + block/qcow2-refcount.c | 10 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/block/qcow2.h

[PATCH v2 03/10] qcow2: introduce qcow2_parse_compressed_l2_entry() helper

2021-05-05 Thread Vladimir Sementsov-Ogievskiy
Add helper to parse compressed l2_entry and use it everywhere instead of open-coding. Note, that in most places we move to precise coffset/csize instead of sector-aligned. Still it should work good enough for updating refcounts. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Eric

[PATCH v2 00/10] qcow2 check: check some reserved bits and subcluster bitmaps

2021-05-05 Thread Vladimir Sementsov-Ogievskiy
Hi all! Here are some good refactorings and new (qemu-img check) checks for qcow2. v2: Fix wording and typos found by Eric, and add r-bs to all except 08. 08: move g_try_malloc down Vladimir Sementsov-Ogievskiy (10): qcow2-refcount: improve style of check_refcounts_l2() qcow2: compressed

[PATCH v2 01/10] qcow2-refcount: improve style of check_refcounts_l2()

2021-05-05 Thread Vladimir Sementsov-Ogievskiy
- don't use same name for size in bytes and in entries - use g_autofree for l2_table - add whitespace - fix block comment style Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Eric Blake --- block/qcow2-refcount.c | 47 +- 1 file changed, 24

[PATCH v2 04/10] qcow2-refcount: introduce fix_l2_entry_by_zero()

2021-05-05 Thread Vladimir Sementsov-Ogievskiy
Split fix_l2_entry_by_zero() out of check_refcounts_l2() to be reused in further patch. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Eric Blake --- block/qcow2-refcount.c | 87 +- 1 file changed, 60 insertions(+), 27 deletions(-) diff --git

Re: [PATCH v2 1/3] hw/block/nand: Register machine reset handler

2021-05-05 Thread Markus Armbruster
Peter Maydell writes: > On Sun, 2 May 2021 at 21:31, Philippe Mathieu-Daudé wrote: >> >> The TYPE_NAND device is bus-less, thus isn't reset automatically. >> Register a reset handler to get reset with the machine. >> >> Fixed: 7426aa72c36 ("nand: Don't inherit from Sysbus") >> Signed-off-by:

Re: [PATCH v4 00/36] block: update graph permissions update

2021-05-05 Thread Vladimir Sementsov-Ogievskiy
28.04.2021 22:50, Vladimir Sementsov-Ogievskiy wrote: 28.04.2021 20:03, Kevin Wolf wrote: Am 28.04.2021 um 17:17 hat Vladimir Sementsov-Ogievskiy geschrieben: Hi all! And here is v4. Thanks, applied to the block branch. Thanks! And thanks a lot for reviewing! Though the error message

Re: [PATCH 10/10] qcow2-refcount: check_refblocks(): add separate message for reserved

2021-05-05 Thread Vladimir Sementsov-Ogievskiy
04.05.2021 22:54, Eric Blake wrote: On 5/4/21 10:20 AM, Vladimir Sementsov-Ogievskiy wrote: Split checking for reserved bits out of aligned offset check. Signed-off-by: Vladimir Sementsov-Ogievskiy --- block/qcow2.h | 1 + block/qcow2-refcount.c | 10 +- 2 files changed,

Re: [PATCH 08/10] qcow2-refcount: improve style of check_refcounts_l1()

2021-05-05 Thread Vladimir Sementsov-Ogievskiy
04.05.2021 22:53, Eric Blake wrote: On 5/4/21 10:20 AM, Vladimir Sementsov-Ogievskiy wrote: - use g_autofree for l1_table - better name for size in bytes variable - reduce code blocks nesting - whitespaces, braces, newlines Signed-off-by: Vladimir Sementsov-Ogievskiy ---

[PATCH v5 07/11] block: use int64_t instead of int in driver write_zeroes handlers

2021-05-05 Thread Vladimir Sementsov-Ogievskiy
We are generally moving to int64_t for both offset and bytes parameters on all io paths. Main motivation is realization of 64-bit write_zeroes operation for fast zeroing large disk chunks, up to the whole disk. We chose signed type, to be consistent with off_t (which is signed) and with

Prevent compiler warning on block.c

2021-05-05 Thread Miroslav Rezanina
Commit 3108a15cf (block: introduce bdrv_drop_filter()) introduced uninitialized variable to_cow_parent in bdrv_replace_node_common function that is used only when detach_subchain is true. It is used in two places. First if block properly initialize the variable and second block use it. However,

Re: [PATCH v5 00/11] 64bit block-layer: part II

2021-05-05 Thread no-reply
Patchew URL: https://patchew.org/QEMU/20210505075001.45041-1-vsement...@virtuozzo.com/ Hi, This series seems to have some coding style problems. See output below for more information: Type: series Message-id: 20210505075001.45041-1-vsement...@virtuozzo.com Subject: [PATCH v5 00/11] 64bit

Re: [PATCH v2 1/8] block: prepare write threshold code for thread safety

2021-05-05 Thread Stefan Hajnoczi
On Mon, Apr 19, 2021 at 10:55:34AM +0200, Emanuele Giuseppe Esposito wrote: No commit description. What about write thresholds makes them thread unsafe? Without a commit description reviewers have to reverse-engineer the patch to figure out the author's intention, which can lead to

Re: [PATCH v2 8/8] block: do not take AioContext around reopen

2021-05-05 Thread Stefan Hajnoczi
On Mon, Apr 19, 2021 at 10:55:41AM +0200, Emanuele Giuseppe Esposito wrote: > block/block-backend.c | 4 > block/mirror.c| 9 - > blockdev.c| 19 ++- > 3 files changed, 6 insertions(+), 26 deletions(-) There are still many

Re: Prevent compiler warning on block.c

2021-05-05 Thread Paolo Bonzini
On 05/05/21 10:05, Vladimir Sementsov-Ogievskiy wrote: diff --git a/block.c b/block.c index 874c22c43e..3ca27bd2d9 100644 --- a/block.c +++ b/block.c @@ -4851,7 +4851,7 @@ static int bdrv_replace_node_common(BlockDriverState *from,   Transaction *tran = tran_new();  

Re: [for-6.1 3/4] virtio-scsi: Set host notifiers and callbacks separately

2021-05-05 Thread Stefan Hajnoczi
On Wed, Apr 07, 2021 at 04:35:00PM +0200, Greg Kurz wrote: > Host notifiers are guaranteed to be idle until the callbacks are > hooked up with virtio_queue_aio_set_host_notifier_handler(). They > thus don't need to be set or unset with the AioContext lock held. > > Do this outside the critical

Re: Prevent compiler warning on block.c

2021-05-05 Thread Vladimir Sementsov-Ogievskiy
05.05.2021 13:03, Paolo Bonzini wrote: On 05/05/21 10:05, Vladimir Sementsov-Ogievskiy wrote: diff --git a/block.c b/block.c index 874c22c43e..3ca27bd2d9 100644 --- a/block.c +++ b/block.c @@ -4851,7 +4851,7 @@ static int bdrv_replace_node_common(BlockDriverState *from,   Transaction *tran

[PATCH 5/7] io: use GDateTime for formatting timestamp for websock headers

2021-05-05 Thread Daniel P . Berrangé
The GDateTime APIs provided by GLib avoid portability pitfalls, such as some platforms where 'struct timeval.tv_sec' field is still 'long' instead of 'time_t'. When combined with automatic cleanup, GDateTime often results in simpler code too. Signed-off-by: Daniel P. Berrangé ---

[PATCH v5 04/11] block: use int64_t instead of uint64_t in driver write handlers

2021-05-05 Thread Vladimir Sementsov-Ogievskiy
We are generally moving to int64_t for both offset and bytes parameters on all io paths. Main motivation is realization of 64-bit write_zeroes operation for fast zeroing large disk chunks, up to the whole disk. We chose signed type, to be consistent with off_t (which is signed) and with

[PATCH v5 03/11] block: use int64_t instead of uint64_t in driver read handlers

2021-05-05 Thread Vladimir Sementsov-Ogievskiy
We are going to convert .bdrv_co_preadv_part and .bdrv_co_pwritev_part to int64_t type for offset and bytes parameters (as it's already done for generic block/io.c layer). In qcow2 .bdrv_co_preadv_part is used in some places, so let's add corresponding checks and assertions. Signed-off-by:

[PATCH v5 05/11] block: use int64_t instead of uint64_t in copy_range driver handlers

2021-05-05 Thread Vladimir Sementsov-Ogievskiy
We are generally moving to int64_t for both offset and bytes parameters on all io paths. Main motivation is realization of 64-bit write_zeroes operation for fast zeroing large disk chunks, up to the whole disk. We chose signed type, to be consistent with off_t (which is signed) and with

[PATCH v5 10/11] block: use int64_t instead of int in driver discard handlers

2021-05-05 Thread Vladimir Sementsov-Ogievskiy
We are generally moving to int64_t for both offset and bytes parameters on all io paths. Main motivation is realization of 64-bit write_zeroes operation for fast zeroing large disk chunks, up to the whole disk. We chose signed type, to be consistent with off_t (which is signed) and with

[PATCH v5 06/11] block: make BlockLimits::max_pwrite_zeroes 64bit

2021-05-05 Thread Vladimir Sementsov-Ogievskiy
We are going to support 64 bit write-zeroes requests. Now update the limit variable. It's absolutely safe. The variable is set in some drivers, and used in bdrv_co_do_pwrite_zeroes(). Update also max_write_zeroes variable in bdrv_co_do_pwrite_zeroes(), so that bdrv_co_do_pwrite_zeroes() is now

Re: [PATCH 0/4] iotests/297: Cover tests/

2021-05-05 Thread Vladimir Sementsov-Ogievskiy
Hi! Kindly remind. Didn't you forget? I'm responsible for these two tests, let me know if you don't have time, and I'll resend this series :) 29.03.2021 16:26, Max Reitz wrote: Hi, When reviewing Vladimir’s new addition to tests/, I noticed that 297 so far does not cover named tests. That

Re: Prevent compiler warning on block.c

2021-05-05 Thread Vladimir Sementsov-Ogievskiy
05.05.2021 10:59, Miroslav Rezanina wrote: Commit 3108a15cf (block: introduce bdrv_drop_filter()) introduced uninitialized variable to_cow_parent in bdrv_replace_node_common function that is used only when detach_subchain is true. It is used in two places. First if block properly initialize

Re: [PATCH v2 7/8] block/replication: do not acquire AioContext

2021-05-05 Thread Stefan Hajnoczi
On Mon, Apr 19, 2021 at 10:55:40AM +0200, Emanuele Giuseppe Esposito wrote: > @@ -210,7 +212,7 @@ static int replication_return_value(BDRVReplicationState > *s, int ret) > } > > if (ret < 0) { > -s->error = ret; > +qatomic_set(>error, ret); > ret = 0; > }

Re: [for-6.1 4/4] virtio-scsi: Configure all host notifiers in a single MR transaction

2021-05-05 Thread Stefan Hajnoczi
On Wed, Apr 07, 2021 at 04:35:01PM +0200, Greg Kurz wrote: > This allows the virtio-scsi-pci device to batch the setup of all its > host notifiers. This significantly improves boot time of VMs with a > high number of vCPUs, e.g. from 6m5.563s down to 1m2.884s for a > pseries machine with 384

Re: [PATCH 0/2] block: Fix Transaction leaks

2021-05-05 Thread Kevin Wolf
Am 04.05.2021 um 08:56 hat Vladimir Sementsov-Ogievskiy geschrieben: > 03.05.2021 14:05, Kevin Wolf wrote: > > These are two follow-up fixes for Vladimir's "block: update graph > > permissions update". The bugs were reported by Coverity. > > > > Kevin Wolf (2): > >block: Fix Transaction leak

[PATCH 2/7] block: use GDateTime for formatting timestamp when dumping snapshot info

2021-05-05 Thread Daniel P . Berrangé
The GDateTime APIs provided by GLib avoid portability pitfalls, such as some platforms where 'struct timeval.tv_sec' field is still 'long' instead of 'time_t'. When combined with automatic cleanup, GDateTime often results in simpler code too. Signed-off-by: Daniel P. Berrangé --- block/qapi.c |

Re: Prevent compiler warning on block.c

2021-05-05 Thread Miroslav Rezanina
- Original Message - > From: "Peter Maydell" > To: "Miroslav Rezanina" > Cc: "QEMU Developers" , "Vladimir Sementsov-Ogievskiy" > , > "Qemu-block" > Sent: Wednesday, May 5, 2021 12:43:44 PM > Subject: Re: Prevent compiler warning on block.c > > On Wed, 5 May 2021 at 09:06, Miroslav

Re: [PATCH v2 2/8] block: protect write threshold QMP commands from concurrent requests

2021-05-05 Thread Stefan Hajnoczi
On Mon, Apr 19, 2021 at 10:55:35AM +0200, Emanuele Giuseppe Esposito wrote: > For simplicity, use bdrv_drained_begin/end to avoid concurrent > writes to the write threshold, or reading it while it is being set. > qmp_block_set_write_threshold is protected by the BQL. > > Reviewed-by: Stefan

Re: [PATCH v2 1/8] block: prepare write threshold code for thread safety

2021-05-05 Thread Vladimir Sementsov-Ogievskiy
Hi Stefan! Note my "[PATCH v2 0/9] block: refactor write threshold", it's a kind of counter-proposal for first half of this series. 05.05.2021 11:50, Stefan Hajnoczi wrote: On Mon, Apr 19, 2021 at 10:55:34AM +0200, Emanuele Giuseppe Esposito wrote: No commit description. What about write

Re: [PATCH] qcow2: set bdi->is_dirty

2021-05-05 Thread Kevin Wolf
Am 04.05.2021 um 18:06 hat Vladimir Sementsov-Ogievskiy geschrieben: > Set bdi->is_dirty, so that qemu-img info could show dirty flag. > > After this commit the following check will show '"dirty-flag": true': > > ./build/qemu-img create -f qcow2 -o lazy_refcounts=on x 1M > ./build/qemu-io x >

Re: [PATCH v2 6/8] block: do not acquire AioContext in check_to_replace_node

2021-05-05 Thread Paolo Bonzini
On 19/04/21 10:55, Emanuele Giuseppe Esposito wrote: + * + * Called with AioContext lock held. ... for @to_replace_bs. aio_context_acquire(replace_aio_context); +if (!check_to_replace_node(bs, to_replace_bs, replaces, errp)) { A release is missing here. Paolo +

Re: [PATCH v2 7/8] block/replication: do not acquire AioContext

2021-05-05 Thread Paolo Bonzini
On 19/04/21 10:55, Emanuele Giuseppe Esposito wrote: Replication functions are mostly called when the BDS is quiescent and does not have any pending I/O. They do not need to synchronize on anything since BDS and BB are now thread-safe. Signed-off-by: Paolo Bonzini Signed-off-by: Emanuele

[PATCH 4/7] usb/dev-mtp: use GDateTime for formatting timestamp for objects

2021-05-05 Thread Daniel P . Berrangé
The GDateTime APIs provided by GLib avoid portability pitfalls, such as some platforms where 'struct timeval.tv_sec' field is still 'long' instead of 'time_t'. When combined with automatic cleanup, GDateTime often results in simpler code too. Signed-off-by: Daniel P. Berrangé ---

Re: Prevent compiler warning on block.c

2021-05-05 Thread Peter Maydell
On Wed, 5 May 2021 at 09:06, Miroslav Rezanina wrote: > > Commit 3108a15cf (block: introduce bdrv_drop_filter()) introduced > uninitialized > variable to_cow_parent in bdrv_replace_node_common function that is used only > when > detach_subchain is true. It is used in two places. First if block

[PATCH v5 01/11] block/io: bring request check to bdrv_co_(read, write)v_vmstate

2021-05-05 Thread Vladimir Sementsov-Ogievskiy via
There are only two drivers supporting vmstate: qcow2 and sheepdog. Sheepdog is deprecated. In qcow2 these requests go through .bdrv_co_p{read,write}v_part handlers. So, let's do our basic check for the request on vmstate generic handlers. Signed-off-by: Vladimir Sementsov-Ogievskiy ---

[PATCH v5 00/11] 64bit block-layer: part II

2021-05-05 Thread Vladimir Sementsov-Ogievskiy
Hi all! v5: rebase on master, fix block comments style and over-80 line. 01: s/{}/()/ in subject, so that email not to be mangled. part II aims to update block drivers to int64_t. I remind that main aim of this update of the whole block-layer to 64bit is to implement 64bit write-zeroes NBD

Re: [PATCH v2 3/8] util: use RCU accessors for notifiers

2021-05-05 Thread Stefan Hajnoczi
On Mon, Apr 19, 2021 at 10:55:36AM +0200, Emanuele Giuseppe Esposito wrote: What is the goal? Making the notifier APIs usable from multiple threads (when callers respect RCU)? > Note that calling rcu_read_lock() is left to the caller. In fact, > if the notifier is really only used within the

Re: [PATCH v2 5/8] block: add a few more notes on locking

2021-05-05 Thread Stefan Hajnoczi
On Mon, Apr 19, 2021 at 10:55:38AM +0200, Emanuele Giuseppe Esposito wrote: > Reviewed-by: Stefan Hajnoczi > Signed-off-by: Paolo Bonzini > Signed-off-by: Emanuele Giuseppe Esposito > --- > include/block/block_int.h | 5 - > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git

Re: [PATCH] block: simplify write-threshold and drop write notifiers

2021-05-05 Thread Stefan Hajnoczi
On Thu, Apr 22, 2021 at 01:09:50AM +0300, Vladimir Sementsov-Ogievskiy wrote: > @@ -1981,8 +1985,15 @@ bdrv_co_write_req_prepare(BdrvChild *child, int64_t > offset, int64_t bytes, > } else { > assert(child->perm & BLK_PERM_WRITE); > } > -return

Re: [PATCH] block: simplify write-threshold and drop write notifiers

2021-05-05 Thread Vladimir Sementsov-Ogievskiy
05.05.2021 13:10, Stefan Hajnoczi wrote: On Thu, Apr 22, 2021 at 01:09:50AM +0300, Vladimir Sementsov-Ogievskiy wrote: @@ -1981,8 +1985,15 @@ bdrv_co_write_req_prepare(BdrvChild *child, int64_t offset, int64_t bytes, } else { assert(child->perm & BLK_PERM_WRITE);

[PATCH 1/7] migration: use GDateTime for formatting timestamp in snapshot names

2021-05-05 Thread Daniel P . Berrangé
The GDateTime APIs provided by GLib avoid portability pitfalls, such as some platforms where 'struct timeval.tv_sec' field is still 'long' instead of 'time_t'. When combined with automatic cleanup, GDateTime often results in simpler code too. Signed-off-by: Daniel P. Berrangé ---

[PATCH 3/7] net/rocker: use GDateTime for formatting timestamp in debug messages

2021-05-05 Thread Daniel P . Berrangé
The GDateTime APIs provided by GLib avoid portability pitfalls, such as some platforms where 'struct timeval.tv_sec' field is still 'long' instead of 'time_t'. When combined with automatic cleanup, GDateTime often results in simpler code too. Signed-off-by: Daniel P. Berrangé ---

[PATCH 0/7] replace all use of strftime() with g_date_time_format()

2021-05-05 Thread Daniel P . Berrangé
The GDateTime APIs provided by GLib avoid portability pitfalls, such as some platforms where 'struct timeval.tv_sec' field is still 'long' instead of 'time_t'. When combined with automatic cleanup, GDateTime often results in simpler code too. Daniel P. Berrangé (7): migration: use GDateTime for

[PATCH 7/7] virtiofsd: use GDateTime for formatting timestamp for debug messages

2021-05-05 Thread Daniel P . Berrangé
The GDateTime APIs provided by GLib avoid portability pitfalls, such as some platforms where 'struct timeval.tv_sec' field is still 'long' instead of 'time_t'. When combined with automatic cleanup, GDateTime often results in simpler code too. Signed-off-by: Daniel P. Berrangé ---

[PATCH v5 02/11] qcow2: check request on vmstate save/load path

2021-05-05 Thread Vladimir Sementsov-Ogievskiy
We modify the request by adding an offset to vmstate. Let's check the modified request. It will help us to safely move .bdrv_co_preadv_part and .bdrv_co_pwritev_part to int64_t type of offset and bytes. Signed-off-by: Vladimir Sementsov-Ogievskiy --- include/block/block_int.h | 3 +++

[PATCH v5 09/11] block: make BlockLimits::max_pdiscard 64bit

2021-05-05 Thread Vladimir Sementsov-Ogievskiy
We are going to support 64 bit discard requests. Now update the limit variable. It's absolutely safe. The variable is set in some drivers, and used in bdrv_co_pdiscard(). Update also max_pdiscard variable in bdrv_co_pdiscard(), so that bdrv_co_pdiscard() is now prepared to 64bit requests. The

  1   2   >