[PATCH v4 03/14] vfio/migration: Fix NULL pointer dereference bug

2022-11-30 Thread Avihai Horon
As part of its error flow, vfio_vmstate_change() accesses MigrationState->to_dst_file without any checks. This can cause a NULL pointer dereference if the error flow is taken and MigrationState->to_dst_file is not set. For example, this can happen if VM is started or stopped not during migration a

[PATCH v4 02/14] migration: Simplify migration_iteration_run()

2022-11-30 Thread Avihai Horon
From: Juan Quintela Signed-off-by: Juan Quintela Signed-off-by: Avihai Horon --- migration/migration.c | 25 + 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index edefba954e..630e4af02f 100644 --- a/migrati

[PATCH v4 04/14] vfio/migration: Allow migration without VFIO IOMMU dirty tracking support

2022-11-30 Thread Avihai Horon
Currently, if IOMMU of a VFIO container doesn't support dirty page tracking, migration is blocked. This is because a DMA-able VFIO device can dirty RAM pages without updating QEMU about it, thus breaking the migration. However, this doesn't mean that migration can't be done at all. In such case, a

[PATCH v4 00/14] vfio/migration: Implement VFIO migration protocol v2

2022-11-30 Thread Avihai Horon
Hello, A long time has passed since v2 of this series was posted. During this time we had several KVM calls discussing the problems that were needed to be solved in order to move forward. This version of the series includes quite some changes, and I believe that it addresses all the major problem

[PATCH v4 11/14] vfio: Alphabetize migration section of VFIO trace-events file

2022-11-30 Thread Avihai Horon
Sort the migration section of VFIO trace events file alphabetically and move two misplaced traces to common.c section. Signed-off-by: Avihai Horon --- hw/vfio/trace-events | 20 ++-- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/hw/vfio/trace-events b/hw/vfio/tr

[PATCH v4 12/14] docs/devel: Align vfio-migration docs to VFIO migration v2

2022-11-30 Thread Avihai Horon
Align the vfio-migration documentation to VFIO migration protocol v2. Signed-off-by: Avihai Horon --- docs/devel/vfio-migration.rst | 68 --- 1 file changed, 30 insertions(+), 38 deletions(-) diff --git a/docs/devel/vfio-migration.rst b/docs/devel/vfio-migration.

[PATCH v4 09/14] vfio/migration: Implement VFIO migration protocol v2

2022-11-30 Thread Avihai Horon
Add implementation of VFIO migration protocol v2. The two protocols, v1 and v2, will co-exist and in next patch v1 protocol will be removed. There are several main differences between v1 and v2 protocols: - VFIO device state is now represented as a finite state machine instead of a bitmap. - Mi

[PATCH v4 06/14] vfio/common: Change vfio_devices_all_running_and_saving() logic to equivalent one

2022-11-30 Thread Avihai Horon
vfio_devices_all_running_and_saving() is used to check if migration is in pre-copy phase. This is done by checking if migration is in setup or active states and if all VFIO devices are in pre-copy state, i.e. _SAVING | _RUNNING. In VFIO migration protocol v2 pre-copy support is made optional. Henc

[PATCH v4 08/14] vfio/migration: Rename functions/structs related to v1 protocol

2022-11-30 Thread Avihai Horon
To avoid name collisions, rename functions and structs related to VFIO migration protocol v1. This will allow the two protocols to co-exist when v2 protocol is added, until v1 is removed. No functional changes intended. Signed-off-by: Avihai Horon --- hw/vfio/common.c | 6 +- hw/v

[PATCH v4 13/14] vfio/migration: Use VFIO_DEVICE_FEATURE_MIG_DATA_SIZE ioctl

2022-11-30 Thread Avihai Horon
Use VFIO_DEVICE_FEATURE_MIG_DATA_SIZE ioctl to query the device stop copy data size and report this value in vfio_save_pending() instead of the hardcoded value that is currently used. Use this ioctl in vfio_save_setup() as well, to adjust the migration data buffer size. Signed-off-by: Avihai Horo

[PATCH v4 05/14] migration/qemu-file: Add qemu_file_get_to_fd()

2022-11-30 Thread Avihai Horon
Add new function qemu_file_get_to_fd() that allows reading data from QEMUFile and writing it straight into a given fd. This will be used later in VFIO migration code. Signed-off-by: Avihai Horon Reviewed-by: Vladimir Sementsov-Ogievskiy --- migration/qemu-file.c | 34 ++

[PATCH v4 14/14] vfio/migration: Optimize vfio_save_pending()

2022-11-30 Thread Avihai Horon
During pre-copy phase of migration vfio_save_pending() is called repeatedly and queries the VFIO device for its pending data size. As long as pending RAM size is over the threshold, migration can't converge and be completed. Therefore, during this time there is no point in querying the VFIO device

[PATCH v4 01/14] migration: No save_live_pending() method uses the QEMUFile parameter

2022-11-30 Thread Avihai Horon
From: Juan Quintela So remove it everywhere. Signed-off-by: Juan Quintela Reviewed-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Dr. David Alan Gilbert --- hw/s390x/s390-stattrib.c | 2 +- hw/vfio/migration.c| 3 +-- include/migration/register.h | 3 +-- migration/block-d

[PATCH v4 10/14] vfio/migration: Remove VFIO migration protocol v1

2022-11-30 Thread Avihai Horon
Now that v2 protocol implementation has been added, remove the deprecated v1 implementation. Signed-off-by: Avihai Horon --- hw/vfio/common.c | 19 +- hw/vfio/migration.c | 695 +- hw/vfio/trace-events | 8 - include/hw/vfio/vfio

[PATCH v4 07/14] vfio/migration: Move migration v1 logic to vfio_migration_init()

2022-11-30 Thread Avihai Horon
Move vfio_dev_get_region_info() logic from vfio_migration_probe() to vfio_migration_init(). This logic is specific to v1 protocol and moving it will make it easier to add the v2 protocol implementation later. No functional changes intended. Signed-off-by: Avihai Horon --- hw/vfio/migration.c |

Re: [PATCH v3 7/7] hw/virtio: generalise CHR_EVENT_CLOSED handling

2022-11-30 Thread Alex Bennée
Raphael Norwitz writes: >> On Nov 29, 2022, at 12:30 AM, Michael S. Tsirkin wrote: >> >> On Tue, Nov 29, 2022 at 05:18:58AM +, Raphael Norwitz wrote: On Nov 28, 2022, at 11:41 AM, Alex Bennée wrote: ..and use for both virtio-user-blk and virtio-user-gpio. This avoids

Re: [PATCH v3 7/7] hw/virtio: generalise CHR_EVENT_CLOSED handling

2022-11-30 Thread Michael S. Tsirkin
On Wed, Nov 30, 2022 at 10:25:58AM +, Alex Bennée wrote: > > Raphael Norwitz writes: > > >> On Nov 29, 2022, at 12:30 AM, Michael S. Tsirkin wrote: > >> > >> On Tue, Nov 29, 2022 at 05:18:58AM +, Raphael Norwitz wrote: > On Nov 28, 2022, at 11:41 AM, Alex Bennée wrote: > >

[PATCH v4 4/5] hw/virtio: generalise CHR_EVENT_CLOSED handling

2022-11-30 Thread Alex Bennée
..and use for both virtio-user-blk and virtio-user-gpio. This avoids the circular close by deferring shutdown due to disconnection until a later point. virtio-user-blk already had this mechanism in place so generalise it as a vhost-user helper function and use for both blk and gpio devices. While

[PATCH v4 2/5] vhost: enable vrings in vhost_dev_start() for vhost-user devices

2022-11-30 Thread Alex Bennée
From: Stefano Garzarella Commit 02b61f38d3 ("hw/virtio: incorporate backend features in features") properly negotiates VHOST_USER_F_PROTOCOL_FEATURES with the vhost-user backend, but we forgot to enable vrings as specified in docs/interop/vhost-user.rst: If ``VHOST_USER_F_PROTOCOL_FEATURES``

Re: [PATCH v3 7/7] hw/virtio: generalise CHR_EVENT_CLOSED handling

2022-11-30 Thread Alex Bennée
"Michael S. Tsirkin" writes: > On Wed, Nov 30, 2022 at 10:25:58AM +, Alex Bennée wrote: >> >> Raphael Norwitz writes: >> >> >> On Nov 29, 2022, at 12:30 AM, Michael S. Tsirkin wrote: >> >> >> >> On Tue, Nov 29, 2022 at 05:18:58AM +, Raphael Norwitz wrote: >> On Nov 28, 2022, a

[RESEND PATCH] ide: Add "ide-cf" driver, a CompactFlash card

2022-11-30 Thread Lubomir Rintel
This allows attaching IDE_CFATA device to an IDE bus. Behaves like a CompactFlash card in True IDE mode. Tested with: qemu-system-i386 \ -device driver=ide-cf,drive=cf,bus=ide.0 \ -drive id=cf,index=0,format=raw,if=none,file=cf.img Signed-off-by: Lubomir Rintel --- hw/ide/qdev.c | 32

[RESEND PATCH] ide: Add 8-bit data mode

2022-11-30 Thread Lubomir Rintel
CompactFlash uses features 0x01 and 0x81 to enable/disable 8-bit data path. Implement them. Signed-off-by: Lubomir Rintel --- hw/ide/core.c | 43 ++- include/hw/ide/internal.h | 1 + 2 files changed, 34 insertions(+), 10 deletions(-) diff --git a

Re: [RESEND PATCH] ide: Add 8-bit data mode

2022-11-30 Thread Paolo Bonzini
Queued, thanks. Paolo

Re: [RESEND PATCH] ide: Add "ide-cf" driver, a CompactFlash card

2022-11-30 Thread Paolo Bonzini
Queued, thanks. Paolo

Re: [PATCH v15 1/6] qmp: add QMP command x-query-virtio

2022-11-30 Thread Philippe Mathieu-Daudé
Hi, On 11/8/22 14:24, Jonah Palmer wrote: From: Laurent Vivier This new command lists all the instances of VirtIODevices with their canonical QOM path and name. [Jonah: @virtio_list duplicates information that already exists in the QOM composition tree. However, extracting necessary informa

Re: [PATCH for-7.2] block-backend: avoid bdrv_unregister_buf() NULL pointer deref

2022-11-30 Thread Stefan Hajnoczi
Merged. I will work on supporting graph changes. Stefan

Re: [PATCH for-7.2] vhost: enable vrings in vhost_dev_start() for vhost-user devices

2022-11-30 Thread Stefan Hajnoczi
On Fri, Nov 25, 2022 at 09:12:43AM +0100, Stefano Garzarella wrote: > On Thu, Nov 24, 2022 at 01:36:29PM -0500, Stefan Hajnoczi wrote: > > On Wed, Nov 23, 2022 at 02:16:30PM +0100, Stefano Garzarella wrote: > > > Commit 02b61f38d3 ("hw/virtio: incorporate backend features in features") > > > proper

Re: [PATCH v4 4/5] hw/virtio: generalise CHR_EVENT_CLOSED handling

2022-11-30 Thread Stefan Hajnoczi
On Wed, Nov 30, 2022 at 11:24:38AM +, Alex Bennée wrote: > ..and use for both virtio-user-blk and virtio-user-gpio. This avoids > the circular close by deferring shutdown due to disconnection until a > later point. I thought re-entrancy was already avoided by Patch 3? > virtio-user-blk alread

Re: [PATCH v4 4/5] hw/virtio: generalise CHR_EVENT_CLOSED handling

2022-11-30 Thread Michael S. Tsirkin
On Wed, Nov 30, 2022 at 11:24:38AM +, Alex Bennée wrote: > ..and use for both virtio-user-blk and virtio-user-gpio. This avoids > the circular close by deferring shutdown due to disconnection until a > later point. virtio-user-blk already had this mechanism in place so > generalise it as a vhos

Re: [PATCH for-7.2] vhost: enable vrings in vhost_dev_start() for vhost-user devices

2022-11-30 Thread Michael S. Tsirkin
On Wed, Nov 30, 2022 at 04:03:28PM -0500, Stefan Hajnoczi wrote: > On Fri, Nov 25, 2022 at 09:12:43AM +0100, Stefano Garzarella wrote: > > On Thu, Nov 24, 2022 at 01:36:29PM -0500, Stefan Hajnoczi wrote: > > > On Wed, Nov 23, 2022 at 02:16:30PM +0100, Stefano Garzarella wrote: > > > > Commit 02b61f

[PULL 2/5] vhost: enable vrings in vhost_dev_start() for vhost-user devices

2022-11-30 Thread Michael S. Tsirkin
From: Stefano Garzarella Commit 02b61f38d3 ("hw/virtio: incorporate backend features in features") properly negotiates VHOST_USER_F_PROTOCOL_FEATURES with the vhost-user backend, but we forgot to enable vrings as specified in docs/interop/vhost-user.rst: If ``VHOST_USER_F_PROTOCOL_FEATURES``

[PULL 4/5] hw/virtio: generalise CHR_EVENT_CLOSED handling

2022-11-30 Thread Michael S. Tsirkin
From: Alex Bennée ..and use for both virtio-user-blk and virtio-user-gpio. This avoids the circular close by deferring shutdown due to disconnection until a later point. virtio-user-blk already had this mechanism in place so generalise it as a vhost-user helper function and use for both blk and g