Re: [PATCH v11 08/13] block/nvme: Make ZNS-related definitions

2020-12-08 Thread Klaus Jensen
CC for Stefan (nvme block driver co-maintainer). On Dec 9 05:04, Dmitry Fomichev wrote: > Define values and structures that are needed to support Zoned > Namespace Command Set (NVMe TP 4053). > > Signed-off-by: Dmitry Fomichev > --- > include/block/nvme.h | 114

[PATCH v2] file-posix: detect the lock using the real file

2020-12-08 Thread Li Feng
This patch addresses this issue: When accessing a volume on an NFS filesystem without supporting the file lock, tools, like qemu-img, will complain "Failed to lock byte 100". In the original code, the qemu_has_ofd_lock will test the lock on the "/dev/null" pseudo-file. Actually, the file.locking

Re: [PATCH] file-posix: detect the lock using the real file

2020-12-08 Thread Li Feng
Kevin Wolf 于2020年12月8日周二 下午10:38写道: > > Am 08.12.2020 um 13:59 hat Li Feng geschrieben: > > This patch addresses this issue: > > When accessing a volume on an NFS filesystem without supporting the file > > lock, > > tools, like qemu-img, will complain "Failed to lock byte 100". > > > > In the

Re: [PATCH] file-posix: detect the lock using the real file

2020-12-08 Thread Li Feng
Daniel P. Berrangé 于2020年12月8日周二 下午9:45写道: > > On Tue, Dec 08, 2020 at 08:59:37PM +0800, Li Feng wrote: > > This patch addresses this issue: > > When accessing a volume on an NFS filesystem without supporting the file > > lock, > > tools, like qemu-img, will complain "Failed to lock byte 100". >

Re: [PATCH] hw/block/nvme: fix bad clearing of CAP

2020-12-08 Thread Keith Busch
On Tue, Dec 08, 2020 at 10:16:58AM +0100, Klaus Jensen wrote: > From: Klaus Jensen > > Commit 37712e00b1f0 ("hw/block/nvme: factor out pmr setup") changed the > control flow such that the CAP register is erronously cleared after > nvme_init_pmr() has configured it. Since the entire NvmeCtrl

Re: [PATCH v2] hw/block/nvme: add compare command

2020-12-08 Thread Keith Busch
On Thu, Nov 26, 2020 at 07:56:05PM +0100, Klaus Jensen wrote: > From: Gollu Appalanaidu > > Add the Compare command. > > This implementation uses a bounce buffer to read in the data from > storage and then compare with the host supplied buffer. > > Signed-off-by: Gollu Appalanaidu >

Re: [PATCH v3 2/2] hw/block/nvme: add simple copy command

2020-12-08 Thread Keith Busch
On Tue, Dec 08, 2020 at 09:33:39AM +0100, Klaus Jensen wrote: > +static uint16_t nvme_copy(NvmeCtrl *n, NvmeRequest *req) > +{ > +for (i = 0; i < nr; i++) { > +uint32_t _nlb = le16_to_cpu(range[i].nlb) + 1; > +if (_nlb > le16_to_cpu(ns->id_ns.mssrl)) { > +return

Re: [PATCH v9 08/12] hw/block/nvme: Support Zoned Namespace Command Set

2020-12-08 Thread Klaus Jensen
On Dec 8 20:02, Dmitry Fomichev wrote: > Hi Klaus, > > Thank you for your review! Please see replies below... > > > On Thu, 2020-11-12 at 20:36 +0100, Klaus Jensen wrote: > > Hi Dmitry, > > > > I know you posted v10, but my comments should be relevant to that as > > well. > > > > On Nov 5

[PATCH v11 13/13] hw/block/nvme: Document zoned parameters in usage text

2020-12-08 Thread Dmitry Fomichev
Added brief descriptions of the new device properties that are now available to users to configure features of Zoned Namespace Command Set in the emulator. This patch is for documentation only, no functionality change. Signed-off-by: Dmitry Fomichev Reviewed-by: Niklas Cassel ---

[PATCH v11 12/13] hw/block/nvme: Add injection of Offline/Read-Only zones

2020-12-08 Thread Dmitry Fomichev
ZNS specification defines two zone conditions for the zones that no longer can function properly, possibly because of flash wear or other internal fault. It is useful to be able to "inject" a small number of such zones for testing purposes. This commit defines two optional device properties,

[PATCH v11 10/13] hw/block/nvme: Introduce max active and open zone limits

2020-12-08 Thread Dmitry Fomichev
Add two module properties, "zoned.max_active" and "zoned.max_open" to control the maximum number of zones that can be active or open. Once these variables are set to non-default values, these limits are checked during I/O and Too Many Active or Too Many Open command status is returned if they are

[PATCH v11 11/13] hw/block/nvme: Support Zone Descriptor Extensions

2020-12-08 Thread Dmitry Fomichev
Zone Descriptor Extension is a label that can be assigned to a zone. It can be set to an Empty zone and it stays assigned until the zone is reset. This commit adds a new optional module property, "zoned.descr_ext_size". Its value must be a multiple of 64 bytes. If this value is non-zero, it

[PATCH v11 00/13] hw/block/nvme: Support Namespace Types and Zoned Namespace Command Set

2020-12-08 Thread Dmitry Fomichev
v10 -> v11: - Address review comments by Klaus. - Add a patch to separate the handling of controller reset and subsystem shutdown. Place the patch at the beginning of the series so it can be picked up separately. - Rebase on the current nvme-next branch. v9 -> v10: - Correctly check

[PATCH v11 06/13] hw/block/nvme: Add support for Namespace Types

2020-12-08 Thread Dmitry Fomichev
From: Niklas Cassel Define the structures and constants required to implement Namespace Types support. Namespace Types introduce a new command set, "I/O Command Sets", that allows the host to retrieve the command sets associated with a namespace. Introduce support for the command set and enable

[PATCH v11 08/13] block/nvme: Make ZNS-related definitions

2020-12-08 Thread Dmitry Fomichev
Define values and structures that are needed to support Zoned Namespace Command Set (NVMe TP 4053). Signed-off-by: Dmitry Fomichev --- include/block/nvme.h | 114 ++- 1 file changed, 113 insertions(+), 1 deletion(-) diff --git a/include/block/nvme.h

[PATCH v11 05/13] hw/block/nvme: Add Commands Supported and Effects log

2020-12-08 Thread Dmitry Fomichev
This log page becomes necessary to implement to allow checking for Zone Append command support in Zoned Namespace Command Set. This commit adds the code to report this log page for NVM Command Set only. The parts that are specific to zoned operation will be added later in the series. All

[PATCH v11 04/13] hw/block/nvme: Combine nvme_write_zeroes() and nvme_write()

2020-12-08 Thread Dmitry Fomichev
Move write processing to nvme_do_write() that now handles both WRITE and WRITE ZEROES. Both nvme_write() and nvme_write_zeroes() become inline helper functions. Signed-off-by: Dmitry Fomichev Reviewed-by: Niklas Cassel Acked-by: Klaus Jensen --- hw/block/nvme.c | 78

[PATCH v11 01/13] hw/block/nvme: Process controller reset and shutdown differently

2020-12-08 Thread Dmitry Fomichev
Controller reset ans subsystem shutdown are handled very much the same in the current code, but some of the steps should be different in these two cases. Introduce two new functions, nvme_reset_ctrl() and nvme_shutdown_ctrl(), to separate some portions of the code from nvme_clear_ctrl(). The

Re: [PATCH v9 08/12] hw/block/nvme: Support Zoned Namespace Command Set

2020-12-08 Thread Dmitry Fomichev
Hi Klaus, Thank you for your review! Please see replies below... On Thu, 2020-11-12 at 20:36 +0100, Klaus Jensen wrote: > Hi Dmitry, > > I know you posted v10, but my comments should be relevant to that as > well. > > On Nov 5 11:53, Dmitry Fomichev wrote: > > The emulation code has been

[PATCH v11 09/13] hw/block/nvme: Support Zoned Namespace Command Set

2020-12-08 Thread Dmitry Fomichev
The emulation code has been changed to advertise NVM Command Set when "zoned" device property is not set (default) and Zoned Namespace Command Set otherwise. Define values and structures that are needed to support Zoned Namespace Command Set (NVMe TP 4053) in PCI NVMe controller emulator. Define

[PATCH v11 07/13] hw/block/nvme: Support allocated CNS command variants

2020-12-08 Thread Dmitry Fomichev
From: Niklas Cassel Many CNS commands have "allocated" command variants. These include a namespace as long as it is allocated, that is a namespace is included regardless if it is active (attached) or not. While these commands are optional (they are mandatory for controllers supporting the

[PATCH v11 03/13] hw/block/nvme: Separate read and write handlers

2020-12-08 Thread Dmitry Fomichev
The majority of code in nvme_rw() is becoming read- or write-specific. Move these parts to two separate handlers, nvme_read() and nvme_write() to make the code more readable and to remove multiple is_write checks that has been present in the i/o path. This is a refactoring patch, no change in

[PATCH v11 02/13] hw/block/nvme: Generate namespace UUIDs

2020-12-08 Thread Dmitry Fomichev
In NVMe 1.4, a namespace must report an ID descriptor of UUID type if it doesn't support EUI64 or NGUID. Add a new namespace property, "uuid", that provides the user the option to either specify the UUID explicitly or have a UUID generated automatically every time a namespace is initialized.

[PULL 48/66] libvhost-user: make it a meson subproject

2020-12-08 Thread Michael S. Tsirkin
From: Marc-André Lureau By making libvhost-user a subproject, check it builds standalone (without the global QEMU cflags etc). Note that the library still relies on QEMU include/qemu/atomic.h and linux_headers/. Signed-off-by: Marc-André Lureau Message-Id:

[PULL 55/66] block/export: avoid g_return_val_if() input validation

2020-12-08 Thread Michael S. Tsirkin
From: Stefan Hajnoczi Do not validate input with g_return_val_if(). This API is intended for checking programming errors and is compiled out with -DG_DISABLE_CHECKS. Use an explicit if statement for input validation so it cannot accidentally be compiled out. Suggested-by: Markus Armbruster

Re: [PATCH 3/3] block: Fix deadlock in bdrv_co_yield_to_drain()

2020-12-08 Thread Kevin Wolf
Am 08.12.2020 um 16:33 hat Vladimir Sementsov-Ogievskiy geschrieben: > 03.12.2020 20:23, Kevin Wolf wrote: > > If bdrv_co_yield_to_drain() is called for draining a block node that > > runs in a different AioContext, it keeps that AioContext locked while it > > yields and schedules a BH in the

Re: [PATCH 0/4] block: prepare for 64bit

2020-12-08 Thread Vladimir Sementsov-Ogievskiy
08.12.2020 20:13, Kevin Wolf wrote: Am 03.12.2020 um 23:27 hat Vladimir Sementsov-Ogievskiy geschrieben: Hi all! This is a preparation series for v4 of "[PATCH v3 00/17] 64bit block-layer". The whole thing is in 04, and 01-03 are small preparations. Thanks, applied to the block branch.

Re: [PATCH 0/4] block: prepare for 64bit

2020-12-08 Thread Kevin Wolf
Am 03.12.2020 um 23:27 hat Vladimir Sementsov-Ogievskiy geschrieben: > Hi all! > > This is a preparation series for v4 of "[PATCH v3 00/17] 64bit > block-layer". > > The whole thing is in 04, and 01-03 are small preparations. Thanks, applied to the block branch. Kevin

Re: [PATCH 1/3] block: Simplify qmp_block_resize() error paths

2020-12-08 Thread Kevin Wolf
Am 08.12.2020 um 15:15 hat Vladimir Sementsov-Ogievskiy geschrieben: > 03.12.2020 20:23, Kevin Wolf wrote: > > The only thing that happens after the 'out:' label is blk_unref(blk). > > However, blk = NULL in all of the error cases, so instead of jumping to > > 'out:', we can just return directly.

Re: [PATCH v3 2/2] block: qcow2: remove the created file on initialization error

2020-12-08 Thread Maxim Levitsky
On Tue, 2020-12-08 at 19:54 +0300, Vladimir Sementsov-Ogievskiy wrote: > 08.12.2020 19:27, Maxim Levitsky wrote: > > On Tue, 2020-12-08 at 18:47 +0300, Vladimir Sementsov-Ogievskiy wrote: > > > 08.12.2020 17:21, Maxim Levitsky wrote: > > > > If the qcow initialization fails, we should remove the

Re: [PATCH v3 2/2] block: qcow2: remove the created file on initialization error

2020-12-08 Thread Vladimir Sementsov-Ogievskiy
08.12.2020 19:27, Maxim Levitsky wrote: On Tue, 2020-12-08 at 18:47 +0300, Vladimir Sementsov-Ogievskiy wrote: 08.12.2020 17:21, Maxim Levitsky wrote: If the qcow initialization fails, we should remove the file if it was already created, to avoid leaving stale files around. We already do this

Re: [PATCH 2/3] block: Fix locking in qmp_block_resize()

2020-12-08 Thread Kevin Wolf
Am 08.12.2020 um 15:46 hat Vladimir Sementsov-Ogievskiy geschrieben: > 03.12.2020 20:23, Kevin Wolf wrote: > > The drain functions assume that we hold the AioContext lock of the > > drained block node. Make sure to actually take the lock. > > > > Cc: qemu-sta...@nongnu.org > > Fixes:

Re: [PATCH v3 2/2] block: qcow2: remove the created file on initialization error

2020-12-08 Thread Maxim Levitsky
On Tue, 2020-12-08 at 18:47 +0300, Vladimir Sementsov-Ogievskiy wrote: > 08.12.2020 17:21, Maxim Levitsky wrote: > > If the qcow initialization fails, we should remove the file if it was > > already created, to avoid leaving stale files around. > > > > We already do this for luks raw images. > >

Re: [PATCH v3 2/2] block: qcow2: remove the created file on initialization error

2020-12-08 Thread Vladimir Sementsov-Ogievskiy
08.12.2020 17:21, Maxim Levitsky wrote: If the qcow initialization fails, we should remove the file if it was already created, to avoid leaving stale files around. We already do this for luks raw images. Signed-off-by: Maxim Levitsky --- block/qcow2.c | 13 + 1 file changed, 13

Re: [PATCH 3/3] block: Fix deadlock in bdrv_co_yield_to_drain()

2020-12-08 Thread Vladimir Sementsov-Ogievskiy
03.12.2020 20:23, Kevin Wolf wrote: If bdrv_co_yield_to_drain() is called for draining a block node that runs in a different AioContext, it keeps that AioContext locked while it yields and schedules a BH in the AioContext to do the actual drain. As long as executing the BH is the very next

Re: [PATCH v3 2/2] block: qcow2: remove the created file on initialization error

2020-12-08 Thread Maxim Levitsky
On Tue, 2020-12-08 at 16:26 +0100, Alberto Garcia wrote: > On Tue 08 Dec 2020 03:21:59 PM CET, Maxim Levitsky wrote: > > If the qcow initialization fails, we should remove the file if it was > > already created, to avoid leaving stale files around. > > > > We already do this for luks raw images.

Re: [PATCH v3 1/2] crypto: luks: Fix tiny memory leak

2020-12-08 Thread Alberto Garcia
On Tue 08 Dec 2020 03:21:58 PM CET, Maxim Levitsky wrote: > When the underlying block device doesn't support the > bdrv_co_delete_file interface, an 'Error' object was leaked. > > Signed-off-by: Maxim Levitsky Reviewed-by: Alberto Garcia Berto

Re: [PATCH v3 2/2] block: qcow2: remove the created file on initialization error

2020-12-08 Thread Alberto Garcia
On Tue 08 Dec 2020 03:21:59 PM CET, Maxim Levitsky wrote: > If the qcow initialization fails, we should remove the file if it was > already created, to avoid leaving stale files around. > > We already do this for luks raw images. > > Signed-off-by: Maxim Levitsky Reviewed-by: Alberto Garcia >

Re: [PATCH v1 0/2] Add timeout mechanism to qmp actions

2020-12-08 Thread Glauber Costa
On Tue, Dec 8, 2020 at 8:11 AM Stefan Hajnoczi wrote: > > On Thu, Oct 22, 2020 at 05:29:16PM +0100, Fam Zheng wrote: > > On Tue, 2020-10-20 at 09:34 +0800, Zhenyu Ye wrote: > > > On 2020/10/19 21:25, Paolo Bonzini wrote: > > > > On 19/10/20 14:40, Zhenyu Ye wrote: > > > > > The kernel backtrace

[PATCH] block/nvme: Fix possible array index out of bounds in nvme_process_completion()

2020-12-08 Thread Alex Chen
The range of 'cid' is [1, NVME_QUEUE_SIZE-1], so when 'cid' is equal to NVME_QUEUE_SIZE, it should be continued, otherwise it will lead to array index out of bounds when accessing 'q->reqs[cid-1]' Reported-by: Euler Robot Signed-off-by: Alex Chen --- block/nvme.c | 2 +- 1 file changed, 1

Re: [PATCH 2/3] block: Fix locking in qmp_block_resize()

2020-12-08 Thread Vladimir Sementsov-Ogievskiy
03.12.2020 20:23, Kevin Wolf wrote: The drain functions assume that we hold the AioContext lock of the drained block node. Make sure to actually take the lock. Cc: qemu-sta...@nongnu.org Fixes: eb94b81a94bce112e6b206df846c1551aaf6cab6 Signed-off-by: Kevin Wolf --- blockdev.c | 5 - 1

Re: [PATCH] file-posix: detect the lock using the real file

2020-12-08 Thread Kevin Wolf
Am 08.12.2020 um 13:59 hat Li Feng geschrieben: > This patch addresses this issue: > When accessing a volume on an NFS filesystem without supporting the file lock, > tools, like qemu-img, will complain "Failed to lock byte 100". > > In the original code, the qemu_has_ofd_lock will test the lock

[PATCH v3 2/2] block: qcow2: remove the created file on initialization error

2020-12-08 Thread Maxim Levitsky
If the qcow initialization fails, we should remove the file if it was already created, to avoid leaving stale files around. We already do this for luks raw images. Signed-off-by: Maxim Levitsky --- block/qcow2.c | 13 + 1 file changed, 13 insertions(+) diff --git a/block/qcow2.c

[PATCH v3 1/2] crypto: luks: Fix tiny memory leak

2020-12-08 Thread Maxim Levitsky
When the underlying block device doesn't support the bdrv_co_delete_file interface, an 'Error' object was leaked. Signed-off-by: Maxim Levitsky --- block/crypto.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/block/crypto.c b/block/crypto.c index aef5a5721a..b3a5275132 100644 ---

[PATCH v3 0/2] qcow2: don't leave partially initialized file on image creation

2020-12-08 Thread Maxim Levitsky
Use the bdrv_co_delete_file interface to delete the underlying file if qcow2 initialization fails (e.g due to bad encryption secret) This makes the qcow2 driver behave the same way as the luks driver behaves. Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=1845353 V3: addressed review

Re: [PATCH 1/3] block: Simplify qmp_block_resize() error paths

2020-12-08 Thread Vladimir Sementsov-Ogievskiy
03.12.2020 20:23, Kevin Wolf wrote: The only thing that happens after the 'out:' label is blk_unref(blk). However, blk = NULL in all of the error cases, so instead of jumping to 'out:', we can just return directly. Cc: qemu-sta...@nongnu.org Signed-off-by: Kevin Wolf --- blockdev.c | 7

[PATCH v3] qemu-nbd: Fix a memleak in nbd_client_thread()

2020-12-08 Thread Alex Chen
When the qio_channel_socket_connect_sync() fails we should goto 'out_socket' label to free the 'sioc' instead of goto 'out' label. In addition, there's a lot of redundant code in the successful branch and the error branch, optimize it. Reported-by: Euler Robot Signed-off-by: Alex Chen

Re: [PATCH v2] qemu-nbd: Fix a memleak in nbd_client_thread()

2020-12-08 Thread Alex Chen
On 2020/12/8 21:41, Vladimir Sementsov-Ogievskiy wrote: > 03.12.2020 16:58, Alex Chen wrote: >> When the qio_channel_socket_connect_sync() fails >> we should goto 'out_socket' label to free the 'sioc' instead of >> goto 'out' label. >> In addition, there's a lot of redundant code in the successful

Re: [PATCH] file-posix: detect the lock using the real file

2020-12-08 Thread Daniel P . Berrangé
On Tue, Dec 08, 2020 at 08:59:37PM +0800, Li Feng wrote: > This patch addresses this issue: > When accessing a volume on an NFS filesystem without supporting the file lock, > tools, like qemu-img, will complain "Failed to lock byte 100". > > In the original code, the qemu_has_ofd_lock will test

Re: [PATCH v2] qemu-nbd: Fix a memleak in nbd_client_thread()

2020-12-08 Thread Vladimir Sementsov-Ogievskiy
03.12.2020 16:58, Alex Chen wrote: When the qio_channel_socket_connect_sync() fails we should goto 'out_socket' label to free the 'sioc' instead of goto 'out' label. In addition, there's a lot of redundant code in the successful branch and the error branch, optimize it. Reported-by: Euler Robot

Re: [PATCH v1 0/2] Add timeout mechanism to qmp actions

2020-12-08 Thread Stefan Hajnoczi
On Thu, Oct 22, 2020 at 05:29:16PM +0100, Fam Zheng wrote: > On Tue, 2020-10-20 at 09:34 +0800, Zhenyu Ye wrote: > > On 2020/10/19 21:25, Paolo Bonzini wrote: > > > On 19/10/20 14:40, Zhenyu Ye wrote: > > > > The kernel backtrace for io_submit in GUEST is: > > > > > > > > guest#

[PATCH] file-posix: detect the lock using the real file

2020-12-08 Thread Li Feng
This patch addresses this issue: When accessing a volume on an NFS filesystem without supporting the file lock, tools, like qemu-img, will complain "Failed to lock byte 100". In the original code, the qemu_has_ofd_lock will test the lock on the "/dev/null" pseudo-file. Actually, the file.locking

[PATCH] hw/block/nvme: fix bad clearing of CAP

2020-12-08 Thread Klaus Jensen
From: Klaus Jensen Commit 37712e00b1f0 ("hw/block/nvme: factor out pmr setup") changed the control flow such that the CAP register is erronously cleared after nvme_init_pmr() has configured it. Since the entire NvmeCtrl structure is zero-filled initially, there is no need for the explicit

[PATCH v3 2/2] hw/block/nvme: add simple copy command

2020-12-08 Thread Klaus Jensen
From: Klaus Jensen Add support for TP 4065a ("Simple Copy Command"), v2020.05.04 ("Ratified"). The implementation uses a bounce buffer to first read in the source logical blocks, then issue a write of that bounce buffer. The default maximum number of source logical blocks is 128, translating to

[PATCH v3 1/2] nvme: updated shared header for copy command

2020-12-08 Thread Klaus Jensen
From: Klaus Jensen Add new data structures and types for the Simple Copy command. Signed-off-by: Klaus Jensen Cc: Stefan Hajnoczi Cc: Fam Zheng Reviewed-by: Minwoo Im Acked-by: Stefan Hajnoczi --- include/block/nvme.h | 45 ++-- 1 file changed, 43

[PATCH v3 0/2] hw/block/nvme: add simple copy command

2020-12-08 Thread Klaus Jensen
From: Klaus Jensen Add support for TP 4065 ("Simple Copy Command"). Changes for v3 * rebased on nvme-next * changed the default msrc value to a more reasonable 127 from 255 to better align with the default mcl value of 128. Changes for v2 * prefer style that aligns with existing

Re: [PATCH v2] hw/block/nvme: add compare command

2020-12-08 Thread Klaus Jensen
On Nov 27 07:21, Minwoo Im wrote: > Hello, > > On Fri, Nov 27, 2020 at 3:56 AM Klaus Jensen wrote: > > > > From: Gollu Appalanaidu > > > > Add the Compare command. > > > > This implementation uses a bounce buffer to read in the data from > > storage and then compare with the host supplied