Re: [PATCH 2/4] libvduse: Replace strcpy() with strncpy()

2022-06-27 Thread Yongji Xie
On Tue, Jun 28, 2022 at 8:26 AM Richard Henderson wrote: > > On 6/27/22 14:32, Xie Yongji wrote: > > -strcpy(dev_config->name, name); > > +strncpy(dev_config->name, name, VDUSE_NAME_MAX); > > +dev_config->name[VDUSE_NAME_MAX - 1] = '\0'; > > g_strlcpy > Now we don't have a dependency

Re: [PATCH 3/4] libvduse: Pass positive value to strerror()

2022-06-27 Thread Richard Henderson
On 6/27/22 14:32, Xie Yongji wrote: The value passed to strerror() should be positive. So let's fix it. Fixes: Coverity CID 1490226, 1490223 Signed-off-by: Xie Yongji --- subprojects/libvduse/libvduse.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) Reviewed-by: Richard

Re: [PATCH 2/4] libvduse: Replace strcpy() with strncpy()

2022-06-27 Thread Richard Henderson
On 6/27/22 14:32, Xie Yongji wrote: -strcpy(dev_config->name, name); +strncpy(dev_config->name, name, VDUSE_NAME_MAX); +dev_config->name[VDUSE_NAME_MAX - 1] = '\0'; g_strlcpy r~

Re: [RFC v2] Adding block layer APIs resembling Linux ZoneBlockDevice ioctls.

2022-06-27 Thread Damien Le Moal
On 6/25/22 00:49, Stefan Hajnoczi wrote: > On Fri, Jun 24, 2022 at 11:14:32AM +0800, Sam Li wrote: >> Hi Stefan, >> >> Stefan Hajnoczi 于2022年6月20日周一 15:55写道: >>> >>> On Mon, Jun 20, 2022 at 11:36:11AM +0800, Sam Li wrote: >>> >>> Hi Sam, >>> Is this version 2 of "[RFC v1] Add support for zoned

[PATCH 1/2] hw: m25p80: Add Block Protect and Top Bottom bits for write protect

2022-06-27 Thread Iris Chen
Signed-off-by: Iris Chen --- hw/block/m25p80.c | 74 +++ 1 file changed, 62 insertions(+), 12 deletions(-) diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c index 50b523e5b1..0156a70f5e 100644 --- a/hw/block/m25p80.c +++ b/hw/block/m25p80.c @@ -38,21

[PATCH 2/2] hw: m25p80: add tests for BP and TB bit write protect

2022-06-27 Thread Iris Chen
Signed-off-by: Iris Chen --- tests/qtest/aspeed_smc-test.c | 111 ++ 1 file changed, 111 insertions(+) diff --git a/tests/qtest/aspeed_smc-test.c b/tests/qtest/aspeed_smc-test.c index 1258687eac..05ce941566 100644 --- a/tests/qtest/aspeed_smc-test.c +++

[PATCH 0/2] Add Block Protect (BP) and Top Bottom (TB) bits for write protect

2022-06-27 Thread Iris Chen
Hey everyone, Adding the 3 block protection bits and top bottom bits which configure which parts of the flash are writable and read-only. These patches are based on previous patches I just submitted: hw: m25p80: fixing individual test failure when tests are running in isolation hw: m25p80: add

Re: [PATCH v2 1/4] hw/nvme: claim NVMe 2.0 compliance

2022-06-27 Thread Christoph Hellwig
On Mon, Jun 27, 2022 at 01:47:28PM +0200, Niklas Cassel via wrote: > CRMS.CRWMS bit shall be set to 1 on controllers compliant with versions > later than NVMe 1.4. > > The first version later than NVMe 1.4 is NVMe 2.0 > > Let's claim compliance with NVMe 2.0 such that a follow up patch can > set

Re: [PATCH] hw/nvme: fix example serial in documentation

2022-06-27 Thread Klaus Jensen
On Jun 27 14:39, Niklas Cassel wrote: > The serial prop on the controller is actually describing the nvme > subsystem serial, which has to be identical for all controllers within > the same nvme subsystem. > > This is enforced since commit a859eb9f8f64 ("hw/nvme: enforce common > serial per

[PATCH 0/3] libvhost-user: NEED_REPLY behaviour fixes

2022-06-27 Thread Kevin Wolf
Command handlers shouldn't send replies themselves, but just prepare the message and let vu_dispatch() send it. Otherwise, vu_dispatch() will add a second reply as an ACK when NEED_REPLY was requested. QEMU's vhost-user devices are not affected by these bugs because they don't set NEED_REPLY for

Re: [PATCH 1/3] docs/vhost-user: Fix mismerge

2022-06-27 Thread Peter Maydell
On Mon, 27 Jun 2022 at 14:49, Kevin Wolf wrote: > > This reverts commit 76b1b64370007234279ea4cc8b09c98cbd2523de. > > The commit only duplicated some text that had already been merged in > commit 31009d13cc5. > > Signed-off-by: Kevin Wolf > --- > docs/interop/vhost-user.rst | 16

[PATCH 2/3] libvhost-user: Fix VHOST_USER_GET_MAX_MEM_SLOTS reply

2022-06-27 Thread Kevin Wolf
With REPLY_NEEDED, libvhost-user sends both the acutal result and an additional ACK reply for VHOST_USER_GET_MAX_MEM_SLOTS. This is incorrect, the spec mandates that it behave the same with and without REPLY_NEEDED because it always sends a reply. Fixes: 6fb2e173d20c9bbb5466183d33a3ad7dcd0375fa

[PATCH 1/3] docs/vhost-user: Fix mismerge

2022-06-27 Thread Kevin Wolf
This reverts commit 76b1b64370007234279ea4cc8b09c98cbd2523de. The commit only duplicated some text that had already been merged in commit 31009d13cc5. Signed-off-by: Kevin Wolf --- docs/interop/vhost-user.rst | 16 1 file changed, 16 deletions(-) diff --git

[PATCH 3/3] libvhost-user: Fix VHOST_USER_ADD_MEM_REG reply

2022-06-27 Thread Kevin Wolf
With REPLY_NEEDED, libvhost-user sends both the acutal result and an additional ACK reply for VHOST_USER_ADD_MEM_REG. This is incorrect, the spec mandates that it behave the same with and without REPLY_NEEDED because it always sends a reply. Fixes: ec94c8e621de96c50c2d381c8c9ec94f5beec7c1

[PATCH] hw/nvme: fix example serial in documentation

2022-06-27 Thread Niklas Cassel via
The serial prop on the controller is actually describing the nvme subsystem serial, which has to be identical for all controllers within the same nvme subsystem. This is enforced since commit a859eb9f8f64 ("hw/nvme: enforce common serial per subsystem"). Fix the documentation, so that people

Re: [PATCH v2 18/21] migration: remove the QEMUFileOps 'get_buffer' callback

2022-06-27 Thread Dr. David Alan Gilbert
* Daniel P. Berrangé (berra...@redhat.com) wrote: > This directly implements the get_buffer logic using QIOChannel APIs. > > Reviewed-by: Dr. David Alan Gilbert > Signed-off-by: Daniel P. Berrangé Coverity is pointing out a fun deadcode path from this: > diff --git a/migration/qemu-file.c

[PATCH v2 3/4] hw/nvme: add support for ratified TP4084

2022-06-27 Thread Niklas Cassel via
TP4084 adds a new mode, CC.CRIME, that can be used to mark a namespace as ready independently from the controller. When CC.CRIME is 0 (default), things behave as before, all namespaces are ready when CSTS.RDY gets set to 1. When CC.CRIME is 1, the controller will become ready when CSTS.RDY gets

[PATCH v2 2/4] hw/nvme: store a pointer to the NvmeSubsystem in the NvmeNamespace

2022-06-27 Thread Niklas Cassel via
Each NvmeNamespace can be used by serveral controllers, but a NvmeNamespace can at most belong to a single NvmeSubsystem. Store a pointer to the NvmeSubsystem, if the namespace was realized with a NvmeSubsystem. This will be used by a follow up patch. Signed-off-by: Niklas Cassel ---

[PATCH v2 4/4] hw/nvme: add new never_ready parameter to test the DNR bit

2022-06-27 Thread Niklas Cassel via
Since we verify that "ready_delay" parameter has to be smaller than CRWMT, we know that the namespace will always become ready. Therefore the "Namespace Not Ready" status code will never have the DNR bit set. Add a new parameter "never_ready" that can be used to emulate a namespace that never

[PATCH v2 0/4] hw/nvme: add support for TP4084

2022-06-27 Thread Niklas Cassel via
Hello there, considering that Linux v5.19 will include support for NVMe TP4084: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/drivers/nvme/host/core.c?id=354201c53e61e493017b15327294b0c8ab522d69 I thought that it might be nice to have QEMU support for the same.

[PATCH v2 1/4] hw/nvme: claim NVMe 2.0 compliance

2022-06-27 Thread Niklas Cassel via
CRMS.CRWMS bit shall be set to 1 on controllers compliant with versions later than NVMe 1.4. The first version later than NVMe 1.4 is NVMe 2.0 Let's claim compliance with NVMe 2.0 such that a follow up patch can set the CRMS.CRWMS bit. This is needed since CC.CRIME is only writable when both

Re: [PATCH v4] hw: m25p80: add tests for write protect (WP# and SRWD bit)

2022-06-27 Thread Cédric Le Goater
On 6/24/22 20:30, Iris Chen wrote: Signed-off-by: Iris Chen Reviewed-by: Cédric Le Goater Thanks, C. --- Adding Signed Off By tag -- sorry I missed that ! tests/qtest/aspeed_smc-test.c | 62 +++ 1 file changed, 62 insertions(+) diff --git

[PATCH 3/4] libvduse: Pass positive value to strerror()

2022-06-27 Thread Xie Yongji
The value passed to strerror() should be positive. So let's fix it. Fixes: Coverity CID 1490226, 1490223 Signed-off-by: Xie Yongji --- subprojects/libvduse/libvduse.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/subprojects/libvduse/libvduse.c

[PATCH 4/4] libvduse: Check the return value of some ioctls

2022-06-27 Thread Xie Yongji
Coverity pointed out (CID 1490222, 1490227) that we called ioctl somewhere without checking the return value. This patch fixes these issues. Fixes: Coverity CID 1490222, 1490227 Signed-off-by: Xie Yongji --- subprojects/libvduse/libvduse.c | 10 -- 1 file changed, 8 insertions(+), 2

[PATCH 0/4] Fix some coverity issues on VDUSE

2022-06-27 Thread Xie Yongji
This series fixes some issues reported by coverity. Patch 1 fixes an incorrect function name. Patch 2 fixes Coverity CID 1490224. Patch 3 fixes Coverity CID 1490226, 1490223. Patch 4 fixes Coverity CID 1490222, 1490227. Xie Yongji (4): libvduse: Fix the incorrect function name libvduse:

[PATCH 1/4] libvduse: Fix the incorrect function name

2022-06-27 Thread Xie Yongji
In vduse_name_is_valid(), we actually check whether the name is invalid or not. So let's change the function name to vduse_name_is_invalid() to match the behavior. Signed-off-by: Xie Yongji --- subprojects/libvduse/libvduse.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff

[PATCH 2/4] libvduse: Replace strcpy() with strncpy()

2022-06-27 Thread Xie Yongji
Coverity reported a string overflow issue since we copied "name" to "dev_config->name" without checking the length. This should be a false positive since we already checked the length of "name" in vduse_name_is_invalid(). But anyway, let's replace strcpy() with strncpy() to fix the coverity

Re: [RFC v3 4/5] file-posix: introduce get_sysfs_str_val for device zoned model.

2022-06-27 Thread Sam Li
Hannes Reinecke 于2022年6月27日周一 15:41写道: > > On 6/27/22 02:19, Sam Li wrote: > > --- > > block/file-posix.c | 60 > > include/block/block-common.h | 4 +-- > > 2 files changed, 62 insertions(+), 2 deletions(-) > > > > diff --git

Re: [PULL v2 10/20] libvduse: Add VDUSE (vDPA Device in Userspace) library

2022-06-27 Thread Yongji Xie
On Mon, Jun 27, 2022 at 12:45 PM Markus Armbruster wrote: > > Kevin Wolf writes: > > > From: Xie Yongji > > > > VDUSE [1] is a linux framework that makes it possible to implement > > software-emulated vDPA devices in userspace. This adds a library > > as a subproject to help implementing VDUSE

Re: [RFC v3 3/5] file-posix: introduce get_sysfs_long_val for zoned device information.

2022-06-27 Thread Sam Li
Hannes Reinecke 于2022年6月27日周一 15:31写道: > > On 6/27/22 02:19, Sam Li wrote: > > Use sysfs attribute files to get the zoned device information in case > > that ioctl() commands of zone management interface won't work. It can > > return long type of value like chunk_sectors, zoned_append_max_bytes,

Re: [RFC v3 2/5] qemu-io: add zoned block device operations.

2022-06-27 Thread Sam Li
Hannes Reinecke 于2022年6月27日周一 15:30写道: > > On 6/27/22 02:19, Sam Li wrote: > > --- > > Good coding style would advise to add some text here what the patch does. > > > block/io.c | 21 +++ > > include/block/block-io.h | 13 + > > qemu-io-cmds.c | 121

Re: [RFC v3 1/5] block: add block layer APIs resembling Linux ZonedBlockDevice ioctls.

2022-06-27 Thread Sam Li
Hi Hannes, Hannes Reinecke 于2022年6月27日周一 15:21写道: > > On 6/27/22 02:19, Sam Li wrote: > > By adding zone management operations in BlockDriver, storage > > controller emulation can use the new block layer APIs including > > zone_report and zone_mgmt(open, close, finish, reset). > > --- > >

Re: [RFC v3 5/5] qemu-iotests: add zone operation tests.

2022-06-27 Thread Hannes Reinecke
On 6/27/22 02:19, Sam Li wrote: --- tests/qemu-iotests/tests/zoned.sh | 49 +++ 1 file changed, 49 insertions(+) create mode 100755 tests/qemu-iotests/tests/zoned.sh diff --git a/tests/qemu-iotests/tests/zoned.sh b/tests/qemu-iotests/tests/zoned.sh new file

Re: [RFC v3 4/5] file-posix: introduce get_sysfs_str_val for device zoned model.

2022-06-27 Thread Hannes Reinecke
On 6/27/22 02:19, Sam Li wrote: --- block/file-posix.c | 60 include/block/block-common.h | 4 +-- 2 files changed, 62 insertions(+), 2 deletions(-) diff --git a/block/file-posix.c b/block/file-posix.c index 73c2cdfbca..74c0245e0f 100644 ---

Re: [RFC v3 2/5] qemu-io: add zoned block device operations.

2022-06-27 Thread Hannes Reinecke
On 6/27/22 02:19, Sam Li wrote: --- Good coding style would advise to add some text here what the patch does. block/io.c | 21 +++ include/block/block-io.h | 13 + qemu-io-cmds.c | 121 +++ 3 files changed, 155

Re: [RFC v3 3/5] file-posix: introduce get_sysfs_long_val for zoned device information.

2022-06-27 Thread Hannes Reinecke
On 6/27/22 02:19, Sam Li wrote: Use sysfs attribute files to get the zoned device information in case that ioctl() commands of zone management interface won't work. It can return long type of value like chunk_sectors, zoned_append_max_bytes, max_open_zones, max_active_zones. ---

Re: [RFC v3 1/5] block: add block layer APIs resembling Linux ZonedBlockDevice ioctls.

2022-06-27 Thread Hannes Reinecke
On 6/27/22 02:19, Sam Li wrote: By adding zone management operations in BlockDriver, storage controller emulation can use the new block layer APIs including zone_report and zone_mgmt(open, close, finish, reset). --- block/block-backend.c| 56 block/coroutines.h

[RFC PATCH 04/10] hw/ide/piix: Avoid the isabus global when wiring ISA interrupts for internal devices

2022-06-27 Thread Bernhard Beschow
isa_get_irq() currently always uses the "isabus" global to get the desired qemu_irq. In order to resolve this global, we want isa_get_irq() to determine the ISABus from its *dev parameter using isa_bus_from_device(). As a preparation, all callers who pass NULL as *dev need to be resolved which

[RFC PATCH 05/10] hw/isa/isa-bus: assert() if isa_get_irq() gets passed a NULL ISADevice

2022-06-27 Thread Bernhard Beschow
Now that all call-sites have been fixed to pass non-NULL ISADevices, we can assert() on NULL ISADevices to catch regressions. Signed-off-by: Bernhard Beschow --- hw/isa/isa-bus.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/hw/isa/isa-bus.c b/hw/isa/isa-bus.c index

[RFC PATCH 07/10] hw/pci/pci: Introduce pci_register_portio_list()

2022-06-27 Thread Bernhard Beschow
pci_ide_init_ioport() and pci_register_portio_list() are introduced which mirror their ISA counterparts. But rather than asking for an ISADevice, the functions ask for PCIDevice which can be used in hw/ide/piix which fixes having to pass a NULL ISADevice which is not avialable there. Passing NULL

[RFC PATCH 10/10] hw/isa/isa-bus: Resolve isabus global

2022-06-27 Thread Bernhard Beschow
Now that only isa_bus_new() accesses the isabus global it can be removed assuming that all call sites take care of not passing the same address spaces twice to different isa_bus_new() invocations. Signed-off-by: Bernhard Beschow --- hw/isa/isa-bus.c | 8 ++-- 1 file changed, 2

[RFC PATCH 09/10] hw/isa: Resolve unneeded usage of isabus global

2022-06-27 Thread Bernhard Beschow
Now that all call sites of these functions are fixed to pass non-NULL ISADevices, the ISABus can be determined from the ISADevice argument. Patch based on https://lists.nongnu.org/archive/html/qemu-devel/2021-05/ msg05785.html. Signed-off-by: Bernhard Beschow --- hw/ide/ioport.c | 4 ++--

[RFC PATCH 06/10] hw/ide/ioport: Rename ide_init_ioport() to isa_ide_init_ioport()

2022-06-27 Thread Bernhard Beschow
ide_init_ioport() takes an ISADevice* parameter which eventually gets passed to isa_address_space_io(). Unfortunately, there is no ISADevice in hw/ide/ piix, so NULL gets passed instead. This causes isa_address_space_io() to resort to using the isabus global - which we want to get rid of. To

[RFC PATCH 03/10] hw/i386/pc_piix: Allow for setting properties on "piix3-ide" before realizing it

2022-06-27 Thread Bernhard Beschow
The next patch will introduce a quirk for user-created PIIX IDE devices for backwards compatibility. In order to opt-in to new behavior for builtin devices a property will need to be set until a deprecation period is over. Signed-off-by: Bernhard Beschow --- hw/i386/pc_piix.c | 3 ++- 1 file

[RFC PATCH 08/10] hw/ide/piix: Use pci_ide_init_ioport() rather than isa_ide_init_ioport()

2022-06-27 Thread Bernhard Beschow
This should fix the last caller causing a NULL ISADev to be passed to isa_register_portio_list() which now allows for disusing the isabus global there. Signed-off-by: Bernhard Beschow --- hw/ide/piix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/ide/piix.c

[RFC PATCH 00/10] Resolve isabus global

2022-06-27 Thread Bernhard Beschow
This series resolves the global "isabus" variable and is basically a v2 of [1]. Note that the majority of the work consists of fixing ISA API calls in PIIX IDE which implicitly rely on the usage of the isabus global. Rather than adding an ISABus pointer in PCIIDEState as in "v1" this series uses

[RFC PATCH 02/10] Revert "hw/ide: Fix crash when plugging a piix3-ide device into the x-remote machine"

2022-06-27 Thread Bernhard Beschow
Now that the PIIX IDE device models check for presence of an ISABus before using it, this fix isn't needed any longer. This reverts commit 9405d87be25db6dff4d7b5ab48a81bbf6d083e47. Signed-off-by: Bernhard Beschow --- hw/ide/ioport.c | 16 ++-- hw/ide/piix.c |

[RFC PATCH 01/10] hw/ide/piix: Check for presence of ISABus before using it

2022-06-27 Thread Bernhard Beschow
This is an alternative solution to commit 9405d87be25db6dff4d7b5ab48a81bbf6d083e47 'hw/ide: Fix crash when plugging a piix3-ide device into the x-remote machine' which allows for cleaning up the ISA API while keeping PIIX IDE functions user-createable for an arbitrarily long deprecation period.