Re: [PATCH v7 03/48] nvme: move device parameters to separate struct

2020-04-14 Thread Philippe Mathieu-Daudé
On 4/15/20 7:50 AM, Klaus Jensen wrote: From: Klaus Jensen Move device configuration parameters to separate struct to make it explicit what is configurable and what is set internally. Signed-off-by: Klaus Jensen Signed-off-by: Klaus Jensen Acked-by: Keith Busch Reviewed-by: Maxim Levitsky

Re: [PATCH v7 02/48] nvme: remove superfluous breaks

2020-04-14 Thread Philippe Mathieu-Daudé
On 4/15/20 7:50 AM, Klaus Jensen wrote: From: Klaus Jensen These break statements was left over when commit 3036a626e9ef ("nvme: add Get/Set Feature Timestamp support") was merged. Signed-off-by: Klaus Jensen Acked-by: Keith Busch Reviewed-by: Maxim Levitsky --- hw/block/nvme.c | 4

[PATCH v7 41/48] nvme: harden cmb access

2020-04-14 Thread Klaus Jensen
From: Klaus Jensen Since the controller has only supported PRPs so far it has not been required to check the ending address (addr + len - 1) of the CMB access for validity since it has been guaranteed to be in range of the CMB. This changes when the controller adds support for SGLs (next patch),

[PATCH v7 48/48] nvme: make lba data size configurable

2020-04-14 Thread Klaus Jensen
From: Klaus Jensen Signed-off-by: Klaus Jensen Acked-by: Keith Busch Reviewed-by: Maxim Levitsky --- hw/block/nvme-ns.c | 7 ++- hw/block/nvme-ns.h | 4 +++- hw/block/nvme.c| 1 + 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/hw/block/nvme-ns.c b/hw/block/nvme-ns.c i

[PATCH v7 43/48] nvme: add support for sgl bit bucket descriptor

2020-04-14 Thread Klaus Jensen
From: Gollu Appalanaidu This adds support for SGL descriptor type 0x1 (bit bucket descriptor). See the NVM Express v1.3d specification, Section 4.4 ("Scatter Gather List (SGL)"). Signed-off-by: Gollu Appalanaidu Signed-off-by: Klaus Jensen --- hw/block/nvme.c | 33 +++-

Re: [PATCH-for-5.1 v3 02/24] scripts/coccinelle: Script to simplify DeviceClass error propagation

2020-04-14 Thread Philippe Mathieu-Daudé
On 4/14/20 3:17 PM, Markus Armbruster wrote: > Philippe Mathieu-Daudé writes: > >> On 4/14/20 2:24 PM, Markus Armbruster wrote: >>> Philippe Mathieu-Daudé writes: >>> When a device uses an Error* with data not modified before realize(), this call can be moved to init(). Add a Coccinell

[PATCH v7 42/48] nvme: add support for scatter gather lists

2020-04-14 Thread Klaus Jensen
From: Klaus Jensen For now, support the Data Block, Segment and Last Segment descriptor types. See NVM Express 1.3d, Section 4.4 ("Scatter Gather List (SGL)"). Signed-off-by: Klaus Jensen Signed-off-by: Klaus Jensen Acked-by: Keith Busch --- hw/block/nvme.c | 332 +

[PATCH v7 44/48] nvme: refactor identify active namespace id list

2020-04-14 Thread Klaus Jensen
From: Klaus Jensen Prepare to support inactive namespaces. Signed-off-by: Klaus Jensen Reviewed-by: Maxim Levitsky --- hw/block/nvme.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hw/block/nvme.c b/hw/block/nvme.c index f295f027b8e2..05a6fa334a70 100644 --- a/hw

[PATCH v7 47/48] nvme: change controller pci id

2020-04-14 Thread Klaus Jensen
From: Klaus Jensen There are two reasons for changing this: 1. The nvme device currently uses an internal Intel device id. 2. Since commits "nvme: fix write zeroes offset and count" and "nvme: support multiple namespaces" the controller device no longer has the quirks that the Lin

[PATCH v7 46/48] pci: allocate pci id for nvme

2020-04-14 Thread Klaus Jensen
From: Klaus Jensen The emulated nvme device (hw/block/nvme.c) is currently using an internal Intel device id. Prepare to change that by allocating a device id under the 1b36 (Red Hat, Inc.) vendor id. Signed-off-by: Klaus Jensen Cc: Gerd Hoffmann Acked-by: Keith Busch Reviewed-by: Maxim Levi

[PATCH v7 45/48] nvme: support multiple namespaces

2020-04-14 Thread Klaus Jensen
From: Klaus Jensen This adds support for multiple namespaces by introducing a new 'nvme-ns' device model. The nvme device creates a bus named from the device name ('id'). The nvme-ns devices then connect to this and registers themselves with the nvme device. This changes how an nvme device is cr

[PATCH v7 36/48] nvme: allow multiple aios per command

2020-04-14 Thread Klaus Jensen
From: Klaus Jensen This refactors how the device issues asynchronous block backend requests. The NvmeRequest now holds a queue of NvmeAIOs that are associated with the command. This allows multiple aios to be issued for a command. Only when all requests have been completed will the device post a

[PATCH v7 35/48] nvme: remove NvmeCmd parameter

2020-04-14 Thread Klaus Jensen
From: Klaus Jensen Keep a copy of the raw nvme command in the NvmeRequest and remove the now redundant NvmeCmd parameter. Signed-off-by: Klaus Jensen --- hw/block/nvme.c | 177 +--- hw/block/nvme.h | 1 + 2 files changed, 93 insertions(+), 85 delet

[PATCH v7 40/48] nvme: handle dma errors

2020-04-14 Thread Klaus Jensen
From: Klaus Jensen Handling DMA errors gracefully is required for the device to pass the block/011 test ("disable PCI device while doing I/O") in the blktests suite. With this patch the device passes the test by retrying "critical" transfers (posting of completion entries and processing of submi

[PATCH v7 28/48] nvme: pass request along for tracing

2020-04-14 Thread Klaus Jensen
From: Klaus Jensen Signed-off-by: Klaus Jensen Reviewed-by: Maxim Levitsky --- hw/block/nvme.c | 67 +-- hw/block/trace-events | 2 +- 2 files changed, 40 insertions(+), 29 deletions(-) diff --git a/hw/block/nvme.c b/hw/block/nvme.c index 2ff7dd6

[PATCH v7 39/48] pci: pass along the return value of dma_memory_rw

2020-04-14 Thread Klaus Jensen
From: Klaus Jensen The nvme device needs to know the return value of dma_memory_rw to pass block/011 from blktests. So pass it along instead of ignoring it. There are no existing users of the return value, so this patch should be safe. Signed-off-by: Klaus Jensen Reviewed-by: Philippe Mathieu-

[PATCH v7 33/48] nvme: be consistent about zeros vs zeroes

2020-04-14 Thread Klaus Jensen
From: Klaus Jensen The spec in general uses 'zeroes' and not 'zeros'. Now, according to the Oxford dictionary, 'zeroes' is the action of zeroing something, i.e. "he zeroes the range" and 'zeros' is the plural of zero. Thus, Write Zeroes should actually be called Write Zeros, but alas, let us ali

[PATCH v7 23/48] nvme: memset preallocated requests structures

2020-04-14 Thread Klaus Jensen
From: Klaus Jensen This is preparatory to subsequent patches that change how QSGs/IOVs are handled. It is important that the qsg and iov members of the NvmeRequest are initially zeroed. Signed-off-by: Klaus Jensen Reviewed-by: Maxim Levitsky --- hw/block/nvme.c | 2 +- 1 file changed, 1 inser

[PATCH v7 21/48] nvme: provide the mandatory subnqn field

2020-04-14 Thread Klaus Jensen
From: Klaus Jensen Signed-off-by: Klaus Jensen Reviewed-by: Maxim Levitsky --- hw/block/nvme.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hw/block/nvme.c b/hw/block/nvme.c index d88e21a14b77..d5c293476411 100644 --- a/hw/block/nvme.c +++ b/hw/block/nvme.c @@ -1940,6 +1940,9 @@ stat

[PATCH v7 27/48] nvme: refactor dma read/write

2020-04-14 Thread Klaus Jensen
From: Klaus Jensen Refactor the nvme_dma_{read,write}_prp functions into a common function taking a DMADirection parameter. Signed-off-by: Klaus Jensen Reviewed-by: Maxim Levitsky --- hw/block/nvme.c | 88 - 1 file changed, 43 insertions(+), 45

[PATCH v7 30/48] nvme: verify validity of prp lists in the cmb

2020-04-14 Thread Klaus Jensen
From: Klaus Jensen Before this patch the device already supported this, but it did not check for the validity of it nor announced the support in the LISTS field. If some of the PRPs in a PRP list are in the CMB, then ALL entries must be there. This patch makes sure that is verified as well as pr

[PATCH v7 26/48] nvme: remove redundant has_sg member

2020-04-14 Thread Klaus Jensen
From: Klaus Jensen Remove the has_sg member from NvmeRequest since it's redundant. Signed-off-by: Klaus Jensen Reviewed-by: Maxim Levitsky --- hw/block/nvme.c | 11 ++- hw/block/nvme.h | 1 - 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/hw/block/nvme.c b/hw/block/nv

[PATCH v7 37/48] nvme: add nvme_check_rw helper

2020-04-14 Thread Klaus Jensen
From: Klaus Jensen Signed-off-by: Klaus Jensen --- hw/block/nvme.c | 26 -- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/hw/block/nvme.c b/hw/block/nvme.c index c123be10fd0d..ffc49985321b 100644 --- a/hw/block/nvme.c +++ b/hw/block/nvme.c @@ -651,6 +651

[PATCH v7 34/48] nvme: refactor NvmeRequest

2020-04-14 Thread Klaus Jensen
From: Klaus Jensen Add a reference to the NvmeNamespace and move clearing of the structure from "clear before use" to "clear after use". Signed-off-by: Klaus Jensen --- hw/block/nvme.c | 38 +- hw/block/nvme.h | 1 + 2 files changed, 22 insertions(+), 17 de

[PATCH v7 38/48] nvme: use preallocated qsg/iov in nvme_dma_prp

2020-04-14 Thread Klaus Jensen
From: Klaus Jensen Since clean up of the request qsg/iov has been moved to the common nvme_enqueue_req_completion function, there is no need to use a stack allocated qsg/iov in nvme_dma_prp. Signed-off-by: Klaus Jensen Acked-by: Keith Busch Reviewed-by: Maxim Levitsky --- hw/block/nvme.c | 1

[PATCH v7 31/48] nvme: refactor request bounds checking

2020-04-14 Thread Klaus Jensen
From: Klaus Jensen Signed-off-by: Klaus Jensen Reviewed-by: Maxim Levitsky --- hw/block/nvme.c | 28 ++-- 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/hw/block/nvme.c b/hw/block/nvme.c index 3e5e99644a4e..7528d75905d4 100644 --- a/hw/block/nvme.c +++ b

[PATCH v7 20/48] nvme: enforce valid queue creation sequence

2020-04-14 Thread Klaus Jensen
From: Klaus Jensen Support returning Command Sequence Error if Set Features on Number of Queues is called after queues have been created. Signed-off-by: Klaus Jensen Reviewed-by: Maxim Levitsky --- hw/block/nvme.c | 12 hw/block/nvme.h | 1 + 2 files changed, 13 insertions(+) d

[PATCH v7 24/48] nvme: add mapping helpers

2020-04-14 Thread Klaus Jensen
From: Klaus Jensen Add nvme_map_addr, nvme_map_addr_cmb and nvme_addr_to_cmb helpers and use them in nvme_map_prp. This fixes a bug where in the case of a CMB transfer, the device would map to the buffer with a wrong length. Fixes: b2b2b67a00574 ("nvme: Add support for Read Data and Write Data

[PATCH v7 29/48] nvme: add request mapping helper

2020-04-14 Thread Klaus Jensen
From: Klaus Jensen Introduce the nvme_map helper to remove some noise in the main nvme_rw function. Signed-off-by: Klaus Jensen Reviewed-by: Maxim Levitsky --- hw/block/nvme.c | 13 ++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/hw/block/nvme.c b/hw/block/nvme.c

[PATCH v7 22/48] nvme: bump supported version to v1.3

2020-04-14 Thread Klaus Jensen
From: Klaus Jensen Signed-off-by: Klaus Jensen Reviewed-by: Maxim Levitsky --- hw/block/nvme.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hw/block/nvme.c b/hw/block/nvme.c index d5c293476411..59935d4641a6 100644 --- a/hw/block/nvme.c +++ b/hw/block/nvme.c @@ -44,6 +

[PATCH v7 32/48] nvme: add check for mdts

2020-04-14 Thread Klaus Jensen
From: Klaus Jensen Add 'mdts' device parameter to control the Maximum Data Transfer Size of the controller and check that it is respected. Signed-off-by: Klaus Jensen Reviewed-by: Maxim Levitsky --- hw/block/nvme.c | 29 - hw/block/nvme.h | 4 +++- hw/

[PATCH v7 25/48] nvme: replace dma_acct with blk_acct equivalent

2020-04-14 Thread Klaus Jensen
From: Klaus Jensen The QSG isn't always initialized, so accounting could be wrong. Issue a call to blk_acct_start instead with the size taken from the QSG or IOV depending on the kind of I/O. Signed-off-by: Klaus Jensen Reviewed-by: Maxim Levitsky --- hw/block/nvme.c | 5 - 1 file changed

[PATCH v7 14/48] nvme: add support for the asynchronous event request command

2020-04-14 Thread Klaus Jensen
From: Klaus Jensen Required for compliance with NVMe revision 1.2.1. See NVM Express 1.2.1, Section 5.2 ("Asynchronous Event Request command"). Mostly imported from Keith's qemu-nvme tree. Modified with a max number of queued events (controllable with the aer_max_queued device parameter). The sp

[PATCH v7 16/48] nvme: additional tracing

2020-04-14 Thread Klaus Jensen
From: Klaus Jensen Also, streamline nvme_identify_ns and nvme_identify_ns_list. They do not need to repeat the command, it is already in the trace name. Signed-off-by: Klaus Jensen --- hw/block/nvme.c | 20 hw/block/trace-events | 13 +++-- 2 files changed, 3

[PATCH v7 19/48] nvme: support identify namespace descriptor list

2020-04-14 Thread Klaus Jensen
From: Klaus Jensen Since we are not providing the NGUID or EUI64 fields, we must support the Namespace UUID. We do not have any way of storing a persistent unique identifier, so conjure up a UUID that is just the namespace id. Signed-off-by: Klaus Jensen --- hw/block/nvme.c | 39

[PATCH v7 17/48] nvme: make sure ncqr and nsqr is valid

2020-04-14 Thread Klaus Jensen
From: Klaus Jensen 0x is not an allowed value for NCQR and NSQR in Set Features on Number of Queues. Signed-off-by: Klaus Jensen Acked-by: Keith Busch Reviewed-by: Maxim Levitsky --- hw/block/nvme.c | 8 1 file changed, 8 insertions(+) diff --git a/hw/block/nvme.c b/hw/block/nv

[PATCH v7 12/48] nvme: add temperature threshold feature

2020-04-14 Thread Klaus Jensen
From: Klaus Jensen It might seem wierd to implement this feature for an emulated device, but it is mandatory to support and the feature is useful for testing asynchronous event request support, which will be added in a later patch. Signed-off-by: Klaus Jensen Acked-by: Keith Busch Reviewed-by:

[PATCH v7 18/48] nvme: add log specific field to trace events

2020-04-14 Thread Klaus Jensen
From: Klaus Jensen The LSP field is not used directly now, but include it in the trace. Signed-off-by: Klaus Jensen Reviewed-by: Maxim Levitsky --- hw/block/nvme.c | 3 ++- hw/block/trace-events | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/hw/block/nvme.c b/hw/

[PATCH v7 13/48] nvme: add support for the get log page command

2020-04-14 Thread Klaus Jensen
From: Klaus Jensen Add support for the Get Log Page command and basic implementations of the mandatory Error Information, SMART / Health Information and Firmware Slot Information log pages. In violation of the specification, the SMART / Health Information log page does not persist information ov

[PATCH v7 11/48] nvme: refactor device realization

2020-04-14 Thread Klaus Jensen
From: Klaus Jensen This patch splits up nvme_realize into multiple individual functions, each initializing a different subset of the device. Signed-off-by: Klaus Jensen Signed-off-by: Klaus Jensen Acked-by: Keith Busch --- hw/block/nvme.c | 178 +++

[PATCH v7 15/48] nvme: add missing mandatory features

2020-04-14 Thread Klaus Jensen
From: Klaus Jensen Add support for returning a resonable response to Get/Set Features of mandatory features. Signed-off-by: Klaus Jensen Signed-off-by: Klaus Jensen Acked-by: Keith Busch --- hw/block/nvme.c | 60 ++- hw/block/trace-events | 2 ++

[PATCH v7 07/48] nvme: add support for the abort command

2020-04-14 Thread Klaus Jensen
From: Klaus Jensen Required for compliance with NVMe revision 1.2.1. See NVM Express 1.2.1, Section 5.1 ("Abort command"). The Abort command is a best effort command; for now, the device always fails to abort the given command. Signed-off-by: Klaus Jensen Signed-off-by: Klaus Jensen Acked-by:

[PATCH v7 09/48] nvme: add max_ioqpairs device parameter

2020-04-14 Thread Klaus Jensen
From: Klaus Jensen The num_queues device paramater has a slightly confusing meaning because it accounts for the admin queue pair which is not really optional. Secondly, it is really a maximum value of queues allowed. Add a new max_ioqpairs parameter that only accounts for I/O queue pairs, but ke

[PATCH v7 05/48] nvme: use constants in identify

2020-04-14 Thread Klaus Jensen
From: Klaus Jensen Signed-off-by: Klaus Jensen Reviewed-by: Maxim Levitsky --- hw/block/nvme.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hw/block/nvme.c b/hw/block/nvme.c index 088668f28bae..622103c42d0a 100644 --- a/hw/block/nvme.c +++ b/hw/block/nvme.c @@ -6

[PATCH v7 01/48] nvme: rename trace events to nvme_dev

2020-04-14 Thread Klaus Jensen
From: Klaus Jensen Change the prefix of all nvme device related trace events to 'nvme_dev' to not clash with trace events from the nvme block driver. Signed-off-by: Klaus Jensen Acked-by: Keith Busch Reviewed-by: Maxim Levitsky --- hw/block/nvme.c | 190 +---

[PATCH v7 04/48] nvme: bump spec data structures to v1.3

2020-04-14 Thread Klaus Jensen
From: Klaus Jensen Add missing fields in the Identify Controller and Identify Namespace data structures to bring them in line with NVMe v1.3. This also adds data structures and defines for SGL support which requires a couple of trivial changes to the nvme block driver as well. Signed-off-by: Kl

[PATCH v7 08/48] nvme: fix pci doorbell size calculation

2020-04-14 Thread Klaus Jensen
From: Klaus Jensen The size of the BAR is 0x1000 (main registers) + 8 bytes for each queue. Currently, the size of the BAR is calculated like so: n->reg_size = pow2ceil(0x1004 + 2 * (n->params.num_queues + 1) * 4); Since the 'num_queues' parameter already accounts for the admin queue, this

[PATCH v7 10/48] nvme: remove redundant cmbloc/cmbsz members

2020-04-14 Thread Klaus Jensen
From: Klaus Jensen Signed-off-by: Klaus Jensen --- hw/block/nvme.c | 7 ++- hw/block/nvme.h | 2 -- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/hw/block/nvme.c b/hw/block/nvme.c index f45909dad480..123539a5d0ae 100644 --- a/hw/block/nvme.c +++ b/hw/block/nvme.c @@ -63,7 +

[PATCH v7 06/48] nvme: refactor nvme_addr_read

2020-04-14 Thread Klaus Jensen
From: Klaus Jensen Pull the controller memory buffer check to its own function. The check will be used on its own in later patches. Signed-off-by: Klaus Jensen Acked-by: Keith Busch --- hw/block/nvme.c | 16 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/hw/bl

[PATCH v7 03/48] nvme: move device parameters to separate struct

2020-04-14 Thread Klaus Jensen
From: Klaus Jensen Move device configuration parameters to separate struct to make it explicit what is configurable and what is set internally. Signed-off-by: Klaus Jensen Signed-off-by: Klaus Jensen Acked-by: Keith Busch Reviewed-by: Maxim Levitsky --- hw/block/nvme.c | 44

[PATCH v7 02/48] nvme: remove superfluous breaks

2020-04-14 Thread Klaus Jensen
From: Klaus Jensen These break statements was left over when commit 3036a626e9ef ("nvme: add Get/Set Feature Timestamp support") was merged. Signed-off-by: Klaus Jensen Acked-by: Keith Busch Reviewed-by: Maxim Levitsky --- hw/block/nvme.c | 4 1 file changed, 4 deletions(-) diff --git

[PATCH v7 00/48] nvme: support NVMe v1.3d, SGLs and multiple namespaces

2020-04-14 Thread Klaus Jensen
From: Klaus Jensen Hi, v7 is mostly just changes proposed by Maxim. Also, Gollu's patch for the bit bucket sgl descriptor has been added (patch #43), but it is of a pretty manageable size. Changes since v6 * 01/48 ("nvme: rename trace events to nvme_dev") - indentation nit

[PATCH 4/4] vhost-user-blk: fix crash in realize process

2020-04-14 Thread Li Feng
The crash could be reproduced like this: 1. break vhost_user_write; 2. kill the vhost-user-blk target; 3. let qemu continue running; 4. start vhost-user-blk; 5. see crash! This fix makes changes: 1. set s->connected to true after vhost_dev_init; 2. call vhost_dev_get_config when s->connected is tr

[PATCH 1/4] vhost-user-blk: delay vhost_user_blk_disconnect

2020-04-14 Thread Li Feng
Since commit b0a335e351103bf92f3f9d0bd5759311be8156ac, a socket write may trigger a disconnect events, calling vhost_user_blk_disconnect() and clearing all the vhost_dev strutures. Then the next socket read will encounter an invalid pointer to vhost_dev. Signed-off-by: Li Feng --- hw/block/vhost

[PATCH 2/4] vhost-user-blk: fix invalid memory access

2020-04-14 Thread Li Feng
when s->inflight is freed, vhost_dev_free_inflight may try to access s->inflight->addr, it will retrigger the following issue. ==7309==ERROR: AddressSanitizer: heap-use-after-free on address 0x604001020d18 at pc 0x55ce948a bp 0x7fffb170 sp 0x7fffb160 READ of size 8 at 0x604001020d18 t

[PATCH 0/4] fix crashes when inject errors to vhost-user-blk chardev

2020-04-14 Thread Li Feng
The following patches fix various crashes happened when injecting errors to chardev unix domain socket. The crashes are encountered when the socket is from connected to disconnected at vhost-user-blk realize routine. These crashes could be reproduced like this: 1. gdb break at vhost_user_write; 2

Re: [PATCH-for-5.0 10/12] hw/block/pflash: Check return value of blk_pwrite()

2020-04-14 Thread Mansour Ahmadi
Thank you for fixing the patch, Philippe! On Tue, Apr 14, 2020 at 9:31 AM Philippe Mathieu-Daudé wrote: > From: Mansour Ahmadi > > When updating the PFLASH file contents, we should check for a > possible failure of blk_pwrite(). Similar to commit 3a688294e. > > Signed-off-by: Mansour Ahmadi >

Re: [PATCH-for-5.1 0/3] various: Remove unnecessary casts

2020-04-14 Thread Richard Henderson
On 4/12/20 2:09 PM, Philippe Mathieu-Daudé wrote: > Remove unnecessary casts using coccinelle scripts. > > The CPU()/OBJECT() patches don't introduce logical change, > The DEVICE() one removes various OBJECT_CHECK() calls. > > Philippe Mathieu-Daudé (3): > target: Remove unnecessary CPU() cast

Re: [PATCH for-5.1 8/8] qemu-option: Move is_valid_option_list() to qemu-img.c and rewrite

2020-04-14 Thread Markus Armbruster
Kevin Wolf writes: > Am 14.04.2020 um 16:34 hat Markus Armbruster geschrieben: >> Markus Armbruster writes: >> >> > Eric Blake writes: >> > >> >> On 4/9/20 10:30 AM, Markus Armbruster wrote: >> >>> is_valid_option_list()'s purpose is ensuring qemu-img.c's can safely >> >>> join multiple parame

Re: [PATCH-for-5.1 2/3] various: Remove unnecessary OBJECT() cast

2020-04-14 Thread Corey Minyard
On Sun, Apr 12, 2020 at 11:09:53PM +0200, Philippe Mathieu-Daudé wrote: > The OBJECT() macro is defined as: > > #define OBJECT(obj) ((Object *)(obj)) > > Remove unnecessary OBJECT() casts. For ipmi change: Acked-by: Corey Minyard > > Patch created mechanically using spatch with this script

Re: [PATCH for-5.1 1/8] tests-qemu-opts: Cover has_help_option(), qemu_opt_has_help_opt()

2020-04-14 Thread Markus Armbruster
Kevin Wolf writes: > Am 14.04.2020 um 15:36 hat Markus Armbruster geschrieben: >> Kevin Wolf writes: >> > Am 14.04.2020 um 11:10 hat Markus Armbruster geschrieben: >> >> Eric Blake writes: >> >> > On 4/9/20 10:30 AM, Markus Armbruster wrote: >> >> >> +{ "helpme", false, false, false },

Re: [PATCH v4 07/30] qcow2: Document the Extended L2 Entries feature

2020-04-14 Thread Eric Blake
On 4/14/20 1:23 PM, Eric Blake wrote: On 4/14/20 1:16 PM, Alberto Garcia wrote: On Thu 09 Apr 2020 05:12:16 PM CEST, Eric Blake wrote: Hmm - raw external files are incompatible with backing files. Pre-existing, but I just realized that we are not checking that in qcow2_do_open(), only on _cr

Re: [PATCH v4 07/30] qcow2: Document the Extended L2 Entries feature

2020-04-14 Thread Eric Blake
On 4/14/20 1:16 PM, Alberto Garcia wrote: On Thu 09 Apr 2020 05:12:16 PM CEST, Eric Blake wrote: Hmm - raw external files are incompatible with backing files. Pre-existing, but I just realized that we are not checking that in qcow2_do_open(), only on _create(). I suppose that if we find such

Re: [PATCH v4 07/30] qcow2: Document the Extended L2 Entries feature

2020-04-14 Thread Alberto Garcia
On Thu 09 Apr 2020 05:12:16 PM CEST, Eric Blake wrote: > Hmm - raw external files are incompatible with backing files. Pre-existing, but I just realized that we are not checking that in qcow2_do_open(), only on _create(). I suppose that if we find such an image we should either a) Show an er

Re: [PATCH v4 07/30] qcow2: Document the Extended L2 Entries feature

2020-04-14 Thread Alberto Garcia
On Tue 14 Apr 2020 08:06:38 PM CEST, Vladimir Sementsov-Ogievskiy wrote: >>> In other words, cluster can't be unallocated with data file in use. >> >> I still don't follow... clusters can be unallocated, and when you >> create a new image they are indeed unallocated. > > with external data file?

Re: [PATCH v4 07/30] qcow2: Document the Extended L2 Entries feature

2020-04-14 Thread Vladimir Sementsov-Ogievskiy
14.04.2020 19:30, Alberto Garcia wrote: On Tue 14 Apr 2020 06:19:18 PM CEST, Vladimir Sementsov-Ogievskiy wrote: It still may cache information about zeroed subclusters: gives more detailed block-status. But we should mention somehow external files. Hm. not only for raw external files, but it

Re: [PATCH v4 07/30] qcow2: Document the Extended L2 Entries feature

2020-04-14 Thread Alberto Garcia
On Fri 10 Apr 2020 11:29:59 AM CEST, Vladimir Sementsov-Ogievskiy wrote: >> Hmm - raw external files are incompatible with backing files. Should >> we also document that extended L2 entries are incompatible with raw >> external files? (The text here reminded me about it, but it would be >> the text

[PATCH-for-5.0 01/12] Revert "prevent crash when executing guest-file-read with large count"

2020-04-14 Thread Philippe Mathieu-Daudé
As noted by Daniel Berrangé in [*], the fix from commit 807e2b6fce which replaced malloc() by try_malloc() is not enough, the process can still run out of memory a few line later: 346 buf = g_try_malloc0(count + 1); 347 if (!buf) { 348 error_setg(errp, 349"f

[PATCH-for-5.0 05/12] vhost-user-gpu: Release memory returned by vu_queue_pop() with free()

2020-04-14 Thread Philippe Mathieu-Daudé
vu_queue_pop() returns memory that must be freed with free(). Cc: qemu-sta...@nongnu.org Reported-by: Coverity (CID 1421887 ALLOC_FREE_MISMATCH) Suggested-by: Peter Maydell Reviewed-by: Marc-André Lureau Signed-off-by: Philippe Mathieu-Daudé --- contrib/vhost-user-gpu/vhost-user-gpu.c | 4 ++--

Re: [PATCH for-5.1 1/8] tests-qemu-opts: Cover has_help_option(), qemu_opt_has_help_opt()

2020-04-14 Thread Kevin Wolf
Am 14.04.2020 um 15:36 hat Markus Armbruster geschrieben: > Kevin Wolf writes: > > Am 14.04.2020 um 11:10 hat Markus Armbruster geschrieben: > >> Eric Blake writes: > >> > On 4/9/20 10:30 AM, Markus Armbruster wrote: > >> >> +{ "helpme", false, false, false }, > >> >> +{ "a,help",

Re: [PATCH for-5.1 5/8] qemu-option: Fix has_help_option()'s sloppy parsing

2020-04-14 Thread Kevin Wolf
Am 14.04.2020 um 12:16 hat Markus Armbruster geschrieben: > Eric Blake writes: > > > On 4/9/20 10:30 AM, Markus Armbruster wrote: > >> has_help_option() uses its own parser. It's inconsistent with > >> qemu_opts_parse(), as demonstrated by test-qemu-opts case > >> /qemu-opts/has_help_option. Fi

[PATCH-for-5.0 11/12] gdbstub: Do not use memset() on GByteArray

2020-04-14 Thread Philippe Mathieu-Daudé
Introduce gdb_get_zeroes() to fill a GByteArray with zeroes. Fixes: a010bdbe719 ("extend GByteArray to read register helpers") Suggested-by: Peter Maydell Signed-off-by: Philippe Mathieu-Daudé --- Since v1: Use memset (pm215) --- include/exec/gdbstub.h | 10 ++ target/arm/gdbstub.c

[PATCH-for-5.0 02/12] qga: Extract guest_file_handle_find() to commands-common.h

2020-04-14 Thread Philippe Mathieu-Daudé
As we are going to reuse this method, declare it in common header. Signed-off-by: Philippe Mathieu-Daudé --- qga/commands-common.h | 18 ++ qga/commands-posix.c | 7 --- qga/commands-win32.c | 7 --- 3 files changed, 26 insertions(+), 6 deletions(-) create mode 10064

[PATCH-for-5.0 04/12] qga: Restrict guest-file-read count to 48 MB to avoid crashes

2020-04-14 Thread Philippe Mathieu-Daudé
On [*] Daniel Berrangé commented: The QEMU guest agent protocol is not sensible way to access huge files inside the guest. It requires the inefficient process of reading the entire data into memory than duplicating it again in base64 format, and then copying it again in the JSON serializer

Re: [PATCH for-5.1 8/8] qemu-option: Move is_valid_option_list() to qemu-img.c and rewrite

2020-04-14 Thread Kevin Wolf
Am 14.04.2020 um 16:34 hat Markus Armbruster geschrieben: > Markus Armbruster writes: > > > Eric Blake writes: > > > >> On 4/9/20 10:30 AM, Markus Armbruster wrote: > >>> is_valid_option_list()'s purpose is ensuring qemu-img.c's can safely > >>> join multiple parameter strings separated by ',' l

Re: [PATCH for-5.0] qcow2: Add incompatibility note between backing files and raw external data files

2020-04-14 Thread Kevin Wolf
Am 10.04.2020 um 14:18 hat Alberto Garcia geschrieben: > Backing files and raw external data files are mutually exclusive. > The documentation of the raw external data bit (in autoclear_features) > already indicates that, but we should also mention it on the other > side. > > Suggested-by: Eric Bl

[PATCH-for-5.0 03/12] qga: Extract qmp_guest_file_read() to common commands.c

2020-04-14 Thread Philippe Mathieu-Daudé
Extract the common code shared by both POSIX/Win32 implementations. Signed-off-by: Philippe Mathieu-Daudé --- qga/commands-common.h | 3 +++ qga/commands-posix.c | 22 +++--- qga/commands-win32.c | 20 +++- qga/commands.c| 26 ++

Re: [PATCH for-5.1 1/8] tests-qemu-opts: Cover has_help_option(), qemu_opt_has_help_opt()

2020-04-14 Thread Markus Armbruster
Kevin Wolf writes: > Am 14.04.2020 um 11:10 hat Markus Armbruster geschrieben: >> Eric Blake writes: >> >> > On 4/9/20 10:30 AM, Markus Armbruster wrote: >> >> The two turn out to be inconsistent for "a,b,,help". Test case >> >> marked /* BUG */. >> >> >> >> Signed-off-by: Markus Armbruster >

[PATCH-for-5.0 10/12] hw/block/pflash: Check return value of blk_pwrite()

2020-04-14 Thread Philippe Mathieu-Daudé
From: Mansour Ahmadi When updating the PFLASH file contents, we should check for a possible failure of blk_pwrite(). Similar to commit 3a688294e. Signed-off-by: Mansour Ahmadi Message-Id: <20200408003552.58095-1-mansour...@gmail.com> [PMD: Add missing "qemu/error-report.h" include and TODO comm

Re: [PATCH for-5.1 2/8] qemu-options: Factor out get_opt_name_value() helper

2020-04-14 Thread Kevin Wolf
Am 14.04.2020 um 11:42 hat Markus Armbruster geschrieben: > Eric Blake writes: > > > On 4/9/20 10:30 AM, Markus Armbruster wrote: > >> The next commits will put it to use. > >> > >> Signed-off-by: Markus Armbruster > >> --- > >> util/qemu-option.c | 102 +---

[PATCH-for-5.0 07/12] hw/misc/grlib_ahb_apb_pnp: Avoid crash when writing to AHB PnP registers

2020-04-14 Thread Philippe Mathieu-Daudé
From: Philippe Mathieu-Daudé Similarly to commit 158b659451 with the APB PnP registers, guests can crash QEMU when writting to the AHB PnP registers: $ echo 'writeb 0xf042 69' | qemu-system-sparc -M leon3_generic -S -bios /etc/magic -qtest stdio [I 1571938309.932255] OPENED [R +0.0634

[PATCH-for-5.0 06/12] hw/openrisc/pic_cpu: Use qdev gpio rather than qemu_allocate_irqs()

2020-04-14 Thread Philippe Mathieu-Daudé
From: Philippe Mathieu-Daudé Coverity points out (CID 1421934) that we are leaking the memory returned by qemu_allocate_irqs(). We can avoid this leak by switching to using qdev_init_gpio_in(); the base class finalize will free the irqs that this allocates under the hood. Patch created mechanica

[PATCH] block/nvme: Remove memory leak

2020-04-14 Thread Philippe Mathieu-Daudé
Fixes: bdd6a90a9 ("Add VFIO based NVMe driver") Signed-off-by: Philippe Mathieu-Daudé --- block/nvme.c | 1 + 1 file changed, 1 insertion(+) diff --git a/block/nvme.c b/block/nvme.c index 7b7c0cc5d6..9f3c7ab819 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -163,6 +163,7 @@ static void nvme_ini

Re: [PATCH v4 07/30] qcow2: Document the Extended L2 Entries feature

2020-04-14 Thread Alberto Garcia
On Tue 14 Apr 2020 06:19:18 PM CEST, Vladimir Sementsov-Ogievskiy wrote: >>> It still may cache information about zeroed subclusters: gives more >>> detailed block-status. But we should mention somehow external >>> files. Hm. not only for raw external files, but it is documented that >>> cluster

[PATCH-for-5.0 09/12] hw/display/sm501: Avoid heap overflow in sm501_2d_operation()

2020-04-14 Thread Philippe Mathieu-Daudé
From: Philippe Mathieu-Daudé Zhang Zi Ming reported a heap overflow in the Drawing Engine of the SM501 companion chip model, in particular in the COPY_AREA() macro in sm501_2d_operation(). Add a simple check to avoid the heap overflow. This fixes:

Re: [PATCH for-5.1 2/8] qemu-options: Factor out get_opt_name_value() helper

2020-04-14 Thread Kevin Wolf
Am 09.04.2020 um 17:30 hat Markus Armbruster geschrieben: > The next commits will put it to use. > > Signed-off-by: Markus Armbruster Reviewed-by: Kevin Wolf

[PATCH-for-5.0 00/12] various bugfixes

2020-04-14 Thread Philippe Mathieu-Daudé
Collection of bugfixes for 5.0. Only vhost-user-gpu/grlib_ahb_apb_pnp patches are reviewed. As 5.0-rc3 is tomorrow, I thought it could help to gather them and resend altogether. Regards, Phil. Mansour Ahmadi (1): hw/block/pflash: Check return value of blk_pwrite() Philippe Mathieu-Daudé (11

[PATCH-for-5.0 12/12] gdbstub: Introduce gdb_get_freg32() to get float32 registers

2020-04-14 Thread Philippe Mathieu-Daudé
Since we now use a GByteArray, we can not use stfl_p() directly. Introduce the gdb_get_freg32() helper to load a float32 register. Fixes: a010bdbe719 ("extend GByteArray to read register helpers") Signed-off-by: Philippe Mathieu-Daudé --- include/exec/gdbstub.h | 12 target/sh4/gdbs

Re: [PATCH for-5.1 3/8] qemu-option: Fix sloppy recognition of "id=..." after ",,"

2020-04-14 Thread Kevin Wolf
Am 09.04.2020 um 17:30 hat Markus Armbruster geschrieben: > Signed-off-by: Markus Armbruster Reviewed-by: Kevin Wolf

Re: [PATCH for-5.1 8/8] qemu-option: Move is_valid_option_list() to qemu-img.c and rewrite

2020-04-14 Thread Markus Armbruster
Markus Armbruster writes: > Eric Blake writes: > >> On 4/9/20 10:30 AM, Markus Armbruster wrote: >>> is_valid_option_list()'s purpose is ensuring qemu-img.c's can safely >>> join multiple parameter strings separated by ',' like this: >>> >>> g_strdup_printf("%s,%s", params1, params2); >

Re: [PATCH for-5.1 7/8] qemu-img: Factor out accumulate_options() helper

2020-04-14 Thread Kevin Wolf
Am 09.04.2020 um 17:30 hat Markus Armbruster geschrieben: > Signed-off-by: Markus Armbruster Reviewed-by: Kevin Wolf

Re: [PATCH v4 07/30] qcow2: Document the Extended L2 Entries feature

2020-04-14 Thread Vladimir Sementsov-Ogievskiy
14.04.2020 17:50, Alberto Garcia wrote: On Fri 10 Apr 2020 11:29:59 AM CEST, Vladimir Sementsov-Ogievskiy wrote: Hmm - raw external files are incompatible with backing files. Should we also document that extended L2 entries are incompatible with raw external files? (The text here reminded me abo

[PATCH-for-5.0 08/12] hw/misc/grlib_ahb_apb_pnp: Fix AHB PnP 8-bit accesses

2020-04-14 Thread Philippe Mathieu-Daudé
From: Philippe Mathieu-Daudé The Plug & Play region of the AHB/APB bridge can be accessed by various word size, however the implementation is clearly restricted to 32-bit: static uint64_t grlib_ahb_pnp_read(void *opaque, hwaddr offset, unsigned size) { AHBPnp *ahb_pnp = GRLIB_AHB_PNP(o

Re: [PATCH v4 11/30] qcow2: Add l2_entry_size()

2020-04-14 Thread Alberto Garcia
On Tue 14 Apr 2020 06:01:42 PM CEST, Eric Blake wrote: >>> And all occurrences of pure '8' (not many of them exist) >> >> I think most/all nowadays only refer to the number of bits per byte. > > CHAR_BIT (from ) is good for that. Wow, ok, I wonder if that actually makes the code more readable, b

Re: [PATCH for-5.0] qcow2: Add incompatibility note between backing files and raw external data files

2020-04-14 Thread Alberto Garcia
On Tue 14 Apr 2020 05:31:26 PM CEST, Kevin Wolf wrote: > I don't think this is critical for 5.0, so if I make a pull request > for other reasons, I'll include it, but if you agree, I won't send one > just for this patch. Sure, no problem. Berto

Re: [PATCH for-5.1 6/8] test-qemu-opts: Simplify test_has_help_option() after bug fix

2020-04-14 Thread Kevin Wolf
Am 09.04.2020 um 17:30 hat Markus Armbruster geschrieben: > Signed-off-by: Markus Armbruster Reviewed-by: Kevin Wolf

Re: [PATCH v4 11/30] qcow2: Add l2_entry_size()

2020-04-14 Thread Eric Blake
On 4/14/20 7:20 AM, Alberto Garcia wrote: Hmm. How to avoid it? Maybe, at least, refactor the code, to drop all sizeof(uint64_t), converting them to L2_ENTRY_SIZE, L1_ENTRY_SIZE, REFTABLE_ENTRY_SIZE etc? That wouldn't be a bad thing I guess but, again, for a separate patch or series. And all

Re: [PATCH-for-5.1 v3 01/23] scripts/coccinelle: Catch missing error_propagate() calls in realize()

2020-04-14 Thread Markus Armbruster
Markus Armbruster writes: > Philippe Mathieu-Daudé writes: > >> In some DeviceClass::realize() while we can propagate errors >> to the caller, we forgot to do so. Add a Coccinelle patch to >> automatically add the missing code. >> >> Inspired-by: Peter Maydell >> Signed-off-by: Philippe Mathieu

Re: [PATCH-for-5.1 v3 02/24] scripts/coccinelle: Script to simplify DeviceClass error propagation

2020-04-14 Thread Markus Armbruster
Philippe Mathieu-Daudé writes: > On 4/14/20 2:24 PM, Markus Armbruster wrote: >> Philippe Mathieu-Daudé writes: >> >>> When a device uses an Error* with data not modified before realize(), >>> this call can be moved to init(). Add a Coccinelle patch to find such >>> uses. >>> >>> Signed-off-by:

Re: [PATCH for-5.1 1/8] tests-qemu-opts: Cover has_help_option(), qemu_opt_has_help_opt()

2020-04-14 Thread Kevin Wolf
Am 14.04.2020 um 11:10 hat Markus Armbruster geschrieben: > Eric Blake writes: > > > On 4/9/20 10:30 AM, Markus Armbruster wrote: > >> The two turn out to be inconsistent for "a,b,,help". Test case > >> marked /* BUG */. > >> > >> Signed-off-by: Markus Armbruster > >> --- > >> tests/test-qemu

  1   2   >