[PATCH v2] net: vhost-user: add QAPI events to report connection state

2025-02-14 Thread Laurent Vivier
The netdev reports NETDEV_VHOST_USER_CONNECTED event when the chardev is connected, and NETDEV_VHOST_USER_DISCONNECTED when it is disconnected. The NETDEV_VHOST_USER_CONNECTED event includes the ChardevInfo (label, filename and frontend_open). This allows a system manager like libvirt to detect w

Re: [PATCH v2] vfio: Add property documentation

2025-02-14 Thread Corvin Köhne
On Thu, 2025-02-13 at 14:45 -0700, Alex Williamson wrote: > On Thu, 13 Feb 2025 14:50:50 +0100 > Cédric Le Goater wrote: > > +    /* > > + * IGD > > + */ > > + > > +    object_class_property_set_description(klass, /* 2.7 */ > > +  "x-igd-opregion", >

Re: [PATCH v3 2/2] KVM: SEV: Configure "ALLOWED_SEV_FEATURES" VMCB Field

2025-02-14 Thread Kim Phillips
On 2/13/25 6:55 PM, Sean Christopherson wrote: On Thu, Feb 13, 2025, Kim Phillips wrote: On 2/11/25 3:46 PM, Sean Christopherson wrote: On Mon, Feb 10, 2025, Tom Lendacky wrote: On 2/7/25 17:34, Kim Phillips wrote: diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c index a2a794c3

[PULL 19/22] guestperf: Support deferred migration for multifd

2025-02-14 Thread Fabiano Rosas
From: Hyman Huang The way to enable multifd migration has been changed by commit, 82137e6c8c (migration: enforce multifd and postcopy preempt to be set before incoming), and guestperf has not made the necessary changes. If multifd migration had been enabled in the previous manner, the following e

[PULL 10/22] migration: Unify migration_cancel and migrate_fd_cancel

2025-02-14 Thread Fabiano Rosas
There's no need for two separate functions and this _fd_ is a historic artifact that makes little sense nowadays. Reviewed-by: Peter Xu Message-ID: <20250213175927.19642-3-faro...@suse.de> Signed-off-by: Fabiano Rosas --- migration/migration.c | 18 +++--- migration/trace-events |

Re: [PATCH V2] migration: ram block cpr blockers

2025-02-14 Thread Steven Sistare
On 2/14/2025 4:21 PM, David Hildenbrand wrote: On 14.02.25 21:12, Steve Sistare wrote: Unlike cpr-reboot mode, cpr-transfer mode cannot save volatile ram blocks in the migration stream file and recreate them later, because the physical memory for the blocks is pinned and registered for vfio.  Ad

[PULL 14/22] migration: Don't set FAILED state when cancelling

2025-02-14 Thread Fabiano Rosas
The expected outcome from qmp_migrate_cancel() is that the source migration goes to the terminal state MIGRATION_STATUS_CANCELLED. Anything different from this is a bug when cancelling. Make sure there is never a state transition from an unspecified state into FAILED. Code that sets FAILED, should

[PULL 18/22] migration: use parameters.mode in cpr_state_save

2025-02-14 Thread Fabiano Rosas
From: Steve Sistare qmp_migrate guarantees that cpr_channel is not null for MIG_MODE_CPR_TRANSFER when cpr_state_save is called: qmp_migrate() if (s->parameters.mode == MIG_MODE_CPR_TRANSFER && !cpr_channel) { return; } cpr_state_save(cpr_channel) but cpr

Re: [PATCH V2 28/45] vfio: return mr from vfio_get_xlat_addr

2025-02-14 Thread Peter Xu
On Fri, Feb 14, 2025 at 03:40:57PM -0500, Steven Sistare wrote: > > > diff --git a/system/memory.c b/system/memory.c > > > index 4c82979..755eafe 100644 > > > --- a/system/memory.c > > > +++ b/system/memory.c > > > @@ -2183,9 +2183,8 @@ void > > > ram_discard_manager_unregister_listener(RamDiscard

[PULL 04/22] io: Add flags argument to qio_channel_readv_full_all_eof

2025-02-14 Thread Fabiano Rosas
We want to pass flags into qio_channel_tls_readv() but qio_channel_readv_full_all_eof() doesn't take a flags argument. No functional change. Reviewed-by: Daniel P. Berrangé Acked-by: Daniel P. Berrangé Signed-off-by: Fabiano Rosas --- hw/remote/mpqemu-link.c | 2 +- include/io/channel.h|

[PULL 21/22] guestperf: Introduce multifd compression option

2025-02-14 Thread Fabiano Rosas
From: Hyman Huang Guestperf tool does not cover the multifd compression option currently, it is worth supporting so that developers can analysis the migration performance with different compression algorithms. Multifd support 4 compression algorithms currently: zlib, zstd, qpl, uadk To request

[PULL 20/22] guestperf: Nitpick the inconsistent parameters

2025-02-14 Thread Fabiano Rosas
From: Hyman Huang Signed-off-by: Hyman Huang Reviewed-by: Fabiano Rosas Reviewed-by: Daniel P. Berrangé Message-ID: Signed-off-by: Fabiano Rosas --- tests/migration-stress/guestperf/comparison.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/migration-stress/gue

[PULL 22/22] guestperf: Add test result data into report

2025-02-14 Thread Fabiano Rosas
From: Hyman Huang The migration result data is not included in the guestperf report information; include the result as a report entry so the developer can check whether the migration was successful after running guestperf. Signed-off-by: Hyman Huang Message-ID: <6303400c2983ffe5647f07caa6406f0

[PULL 02/22] io: tls: Add qio_channel_tls_bye

2025-02-14 Thread Fabiano Rosas
Add a task dispatcher for gnutls_bye similar to the qio_channel_tls_handshake_task(). The gnutls_bye() call might be interrupted and so it needs to be rescheduled. The migration code will make use of this to help the migration destination identify a premature EOF. Once the session termination is i

Re: [PATCH v4 27/33] vfio/migration: Multifd device state transfer support - received buffers queuing

2025-02-14 Thread Maciej S. Szmigiero
On 12.02.2025 14:47, Cédric Le Goater wrote: On 1/30/25 11:08, Maciej S. Szmigiero wrote: From: "Maciej S. Szmigiero" The multifd received data needs to be reassembled since device state packets sent via different multifd channels can arrive out-of-order. Therefore, each VFIO device state pac

Re: [PATCH v4 32/33] vfio/migration: Add x-migration-multifd-transfer VFIO property

2025-02-14 Thread Maciej S. Szmigiero
On 12.02.2025 18:10, Cédric Le Goater wrote: On 1/30/25 11:08, Maciej S. Szmigiero wrote: From: "Maciej S. Szmigiero" This property allows configuring at runtime whether to transfer the particular device state via multifd channels when live migrating that device. It defaults to AUTO, which me

Re: [PATCH v4 26/33] vfio/migration: Multifd device state transfer support - receive init/cleanup

2025-02-14 Thread Maciej S. Szmigiero
On 12.02.2025 11:55, Cédric Le Goater wrote: On 1/30/25 11:08, Maciej S. Szmigiero wrote: From: "Maciej S. Szmigiero" Add support for VFIOMultifd data structure that will contain most of the receive-side data together with its init/cleanup methods. Signed-off-by: Maciej S. Szmigiero ---   hw

Re: [PATCH V2 28/45] vfio: return mr from vfio_get_xlat_addr

2025-02-14 Thread Steven Sistare
On 2/14/2025 11:48 AM, Peter Xu wrote: On Fri, Feb 14, 2025 at 06:14:10AM -0800, Steve Sistare wrote: Modify memory_get_xlat_addr and vfio_get_xlat_addr to return the memory region that the translated address is found in. This will be needed by CPR in a subsequent patch to map blocks using IOMM

[PULL 17/22] migration: Update migrate_cancel documentation

2025-02-14 Thread Fabiano Rosas
Update the migrate_cancel command documentation with a few words about postcopy and the expected state of the machine after migration. Acked-by: Markus Armbruster Reviewed-by: Peter Xu Message-ID: <20250213175927.19642-10-faro...@suse.de> Signed-off-by: Fabiano Rosas --- qapi/migration.json |

Re: [PATCH V2] migration: ram block cpr blockers

2025-02-14 Thread David Hildenbrand
On 14.02.25 21:12, Steve Sistare wrote: Unlike cpr-reboot mode, cpr-transfer mode cannot save volatile ram blocks in the migration stream file and recreate them later, because the physical memory for the blocks is pinned and registered for vfio. Add a blocker for volatile ram blocks. Also add a

[PULL 07/22] migration/multifd: Add a compat property for TLS termination

2025-02-14 Thread Fabiano Rosas
We're currently changing the way the source multifd migration handles the shutdown of the multifd channels when TLS is in use to perform a clean termination by calling gnutls_bye(). Older src QEMUs will always close the channel without terminating the TLS session. New dst QEMUs treat an unclean te

[PULL 12/22] migration: Fix hang after error in destination setup phase

2025-02-14 Thread Fabiano Rosas
If the destination side fails at migration_ioc_process_incoming() before starting the coroutine, it will report the error but QEMU will not exit. Set the migration state to FAILED and exit the process if exit-on-error allows. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2633 Reported-b

Re: [PATCH] migration: ram block cpr blockers

2025-02-14 Thread Steven Sistare
On 1/30/2025 12:01 PM, Peter Xu wrote: On Wed, Jan 29, 2025 at 01:20:13PM -0500, Steven Sistare wrote: On 1/17/2025 6:57 PM, Peter Xu wrote: On Fri, Jan 17, 2025 at 02:10:14PM -0500, Steven Sistare wrote: On 1/17/2025 1:16 PM, Peter Xu wrote: On Fri, Jan 17, 2025 at 09:46:11AM -0800, Steve Si

[PATCH V2] migration: ram block cpr blockers

2025-02-14 Thread Steve Sistare
Unlike cpr-reboot mode, cpr-transfer mode cannot save volatile ram blocks in the migration stream file and recreate them later, because the physical memory for the blocks is pinned and registered for vfio. Add a blocker for volatile ram blocks. Also add a blocker for RAM_GUEST_MEMFD. Preserving

[PULL 11/22] migration: Change migrate_fd_ to migration_

2025-02-14 Thread Fabiano Rosas
Remove all instances of _fd_ from the migration generic code. These functions have grown over time and the _fd_ part is now just confusing. migration_fd_error() -> migration_error() makes it a little vague. Since it's only used for migration_connect() failures, change it to migration_connect_set_e

[PULL 05/22] io: Add a read flag for relaxed EOF

2025-02-14 Thread Fabiano Rosas
Add a read flag that can inform a channel that it's ok to receive an EOF at any moment. Channels that have some form of strict EOF tracking, such as TLS session termination, may choose to ignore EOF errors with the use of this flag. This is being added for compatibility with older migration stream

[PULL 03/22] crypto: Remove qcrypto_tls_session_get_handshake_status

2025-02-14 Thread Fabiano Rosas
The correct way of calling qcrypto_tls_session_handshake() requires calling qcrypto_tls_session_get_handshake_status() right after it so there's no reason to have a separate method. Refactor qcrypto_tls_session_handshake() to inform the status in its own return value and alter the callers accordin

[PATCH v4 04/11] qapi: golang: Generate struct types

2025-02-14 Thread Victor Toso
This patch handles QAPI struct types and generates the equivalent types in Go. The following patch adds extra logic when a member of the struct has a Type that can take JSON Null value (e.g: StrOrNull in QEMU) The highlights of this implementation are: 1. Generating a Go struct that requires a @b

[PULL 13/22] migration: Reject qmp_migrate_cancel after postcopy

2025-02-14 Thread Fabiano Rosas
After postcopy has started, it's not possible to recover the source machine in case a migration error occurs because the destination has already been changing the state of the machine. For that same reason, it doesn't make sense to try to cancel the migration after postcopy has started. Reject the

[PULL 06/22] migration/multifd: Terminate the TLS connection

2025-02-14 Thread Fabiano Rosas
The multifd recv side has been getting a TLS error of GNUTLS_E_PREMATURE_TERMINATION at the end of migration when the send side closes the sockets without ending the TLS session. This has been masked by the code not checking the migration error after loadvm. Start ending the TLS session at multifd

[PULL 01/22] crypto: Allow gracefully ending the TLS session

2025-02-14 Thread Fabiano Rosas
QEMU's TLS session code provides no way to call gnutls_bye() to terminate a TLS session. Callers of qcrypto_tls_session_read() can choose to ignore a GNUTLS_E_PREMATURE_TERMINATION error by setting the gracefulTermination argument. The QIOChannelTLS ignores the premature termination error whenever

[PULL 15/22] tests/qtest/migration: Introduce migration_test_add_suffix

2025-02-14 Thread Fabiano Rosas
Introduce a new migration_test_add_suffix to allow programmatic creation of tests based on a suffix. Pass the test name into the test so it can know which variant to run. Reviewed-by: Peter Xu Message-ID: <20250213175927.19642-8-faro...@suse.de> Signed-off-by: Fabiano Rosas --- tests/qtest/migr

[PATCH v4 00/11]

2025-02-14 Thread Victor Toso
Hi again, This patch series intent is to introduce a generator that produces a Go module for Go applications to interact over QMP with QEMU. Previous version (10 Jan 2025) https://lists.gnu.org/archive/html/qemu-devel/2025-01/msg01530.html The generated code was mostly tested using existing

[PATCH v4 01/11] qapi: golang: first level unmarshalling type

2025-02-14 Thread Victor Toso
This first patch introduces protocol.go. It introduces the Message Go struct type that can unmarshall any QMP message. It does not handle deeper than 1st layer of the JSON object, that is, with: 1. { "execute": "query-machines", "arguments": { "compat-props": true } } 2. {

[PATCH v4 02/11] qapi: golang: Generate enum type

2025-02-14 Thread Victor Toso
This patch handles QAPI enum types and generates its equivalent in Go. We sort the output based on enum's type name. Enums are being handled as strings in Golang. 1. For each QAPI enum, we will define a string type in Go to be the assigned type of this specific enum. 2. Naming: CamelCase will

[PATCH v4 03/11] qapi: golang: Generate alternate types

2025-02-14 Thread Victor Toso
This patch handles QAPI alternate types and generates data structures in Go that handles it. Alternate types are similar to Union but without a discriminator that can be used to identify the underlying value on the wire. 1. Over the wire, we need to infer underlying value by its type 2. Pointer

[PATCH v4 07/11] qapi: golang: Generate event type

2025-02-14 Thread Victor Toso
This patch handles QAPI event types and generates data structures in Go that handles it. Note that the timestamp is part of the first layer of unmarshal, so it s a member of protocol.go's Message type. Example: qapi: | ## | # @MEMORY_DEVICE_SIZE_CHANGE: | # | # Emitted when the size of a memo

[PATCH v4 10/11] qapi: golang: Generate Command sync/async interfaces

2025-02-14 Thread Victor Toso
The Command interface is an abstraction that can be used by client and server to the manager the Command types albeit with a different implementation for sending and receiving. The proposal for Sync is defined as Command while the Async is named CommandAsync. The implementation of client/server i

[PATCH v4 09/11] qapi: golang: Generate command type

2025-02-14 Thread Victor Toso
This patch handles QAPI command types and generates data structures in Go that handles it. Note that command's id is part of the first layer of unmarshal, so it is a member of protocol.go's Message type. qapi: | ## | # @add-fd: | # | # Add a file descriptor, that was passed via SCM rights, to

[PULL 16/22] tests/qtest/migration: Add a cancel test

2025-02-14 Thread Fabiano Rosas
The qmp_migrate_cancel() command is poorly tested and code inspection reveals that there might be concurrency issues with its usage. Add a test that runs a migration and calls qmp_migrate_cancel() at specific moments. In order to make the test more deterministic, instead of calling qmp_migrate_can

[PATCH v4 05/11] qapi: golang: structs: Address nullable members

2025-02-14 Thread Victor Toso
Explaining why this is needed needs some context, so taking the example of StrOrNull alternate type and considering a simplified struct that has two fields: qapi: | { 'struct': 'MigrationExample', | 'data': { '*label': 'StrOrNull', | 'target': 'StrOrNull' } } We have an optional

[PULL 09/22] migration: Set migration error outside of migrate_cancel

2025-02-14 Thread Fabiano Rosas
There's no point passing the error into migration cancel only for it to call migrate_set_error(). Reviewed-by: Peter Xu Message-ID: <20250213175927.19642-2-faro...@suse.de> Signed-off-by: Fabiano Rosas --- migration/migration.c | 7 ++- migration/migration.h | 2 +- migration/ram.c |

[PATCH v4 06/11] qapi: golang: Generate union type

2025-02-14 Thread Victor Toso
This patch handles QAPI union types and generates the equivalent data structures and methods in Go to handle it. The QAPI union type has two types of fields: The @base and the @Variants members. The @base fields can be considered common members for the union while only one field maximum is set for

[PULL 00/22] Migration patches for 2025-02-14

2025-02-14 Thread Fabiano Rosas
The following changes since commit 495de0fd82d8bb2d7035f82d9869cfeb48de2f9e: Merge tag 'pull-trivial-patches' of https://gitlab.com/mjt0k/qemu into staging (2025-02-14 08:19:05 -0500) are available in the Git repository at: https://gitlab.com/farosas/qemu.git tags/migration-202

[PATCH V2 36/45] vfio/iommufd: invariant device name

2025-02-14 Thread Steve Sistare
cpr-transfer will use the device name as a key to find the value of the device descriptor in new QEMU. However, if the descriptor number is specified by a command-line fd parameter, then vfio_device_get_name creates a name that includes the fd number. This causes a chicken-and-egg problem: new QEM

[PATCH V2 19/45] vfio/pci: vfio_notifier_init

2025-02-14 Thread Steve Sistare
Move event_notifier_init calls to a helper vfio_notifier_init. This version is trivial, but it will be expanded to support CPR in subsequent patches. No functional change. Signed-off-by: Steve Sistare --- hw/vfio/pci.c | 40 +--- 1 file changed, 25 insertions

Re: [PATCH] net: vhost-user: add QAPI events to report connection state

2025-02-14 Thread Daniel P . Berrangé
On Fri, Feb 14, 2025 at 01:59:20PM +, Daniel P. Berrangé wrote: > On Fri, Feb 14, 2025 at 11:18:55AM +0100, Laurent Vivier wrote: > > On 14/02/2025 11:06, Markus Armbruster wrote: > > > Laurent Vivier writes: > > > > > > > The netdev reports NETDEV_VHOST_USER_CONNECTED event when > > > > the

[PATCH V2 12/45] vfio/container: restore DMA vaddr

2025-02-14 Thread Steve Sistare
In new QEMU, do not register the memory listener at device creation time. Register it later, in the container post_load handler, after all vmstate that may affect regions and mapping boundaries has been loaded. The post_load registration will cause the listener to invoke its callback on each flat

[PATCH V2 45/45] vfio/container: delete old cpr register

2025-02-14 Thread Steve Sistare
vfio_cpr_[un]register_container is no longer used since they were subsumed by container type-specific registration. Delete them. Signed-off-by: Steve Sistare --- hw/vfio/cpr.c | 14 -- include/hw/vfio/vfio-common.h | 3 --- 2 files changed, 17 deletions(-) diff --g

[PATCH V2 40/45] vfio/iommufd: reconstruct device

2025-02-14 Thread Steve Sistare
Reconstruct userland device state after CPR. During vfio_realize, skip all ioctls that configure the device, as it was already configured in old QEMU. Save the ioas_id in vmstate, and skip its allocation in vfio_realize. Because we skip ioctl's, it is not needed at realize time. However, we do n

[PATCH V2 13/45] vfio/container: mdev cpr blocker

2025-02-14 Thread Steve Sistare
During CPR, after VFIO_DMA_UNMAP_FLAG_VADDR, the vaddr is temporarily invalid, so mediated devices cannot be supported. Add a blocker for them. This restriction will not apply to iommufd containers when CPR is added for them in a future patch. Signed-off-by: Steve Sistare --- hw/vfio/container.

[PATCH V2 07/45] vfio/container: vfio_container_group_add

2025-02-14 Thread Steve Sistare
Add vfio_container_group_add to de-dup some code. No functional change. Signed-off-by: Steve Sistare --- hw/vfio/container.c | 47 +-- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/hw/vfio/container.c b/hw/vfio/container.c index c668

[PATCH V2 02/45] migration: cpr helpers

2025-02-14 Thread Steve Sistare
Add cpr_needed_for_reuse, cpr_resave_fd helpers, cpr_is_incoming, and cpr_open_fd, for use when adding cpr support for vfio and iommufd. Signed-off-by: Steve Sistare --- include/migration/cpr.h | 6 ++ migration/cpr.c | 44 2 files change

[PATCH V2 16/45] pci: skip reset during cpr

2025-02-14 Thread Steve Sistare
Do not reset a vfio-pci device during CPR. Signed-off-by: Steve Sistare --- hw/pci/pci.c | 13 + 1 file changed, 13 insertions(+) diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 2afa423..2fa8884 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -32,6 +32,8 @@ #include "hw/pci/pci_host

[PATCH V2 00/45] Live update: vfio and iommufd

2025-02-14 Thread Steve Sistare
Support vfio and iommufd devices with the cpr-transfer live migration mode. Devices that do not support live migration can still support cpr-transfer, allowing live update to a new version of QEMU on the same host, with no loss of guest connectivity. No user-visible interfaces are added. For lega

[PATCH V2 34/45] vfio/iommufd: export iommufd_cdev_get_info_iova_range

2025-02-14 Thread Steve Sistare
Export iommufd_cdev_get_info_iova_range, for use by CPR in a subsequent patch to reconstruct the userland device state. No functional change. Signed-off-by: Steve Sistare --- hw/vfio/iommufd.c | 4 ++-- include/hw/vfio/vfio-common.h | 3 +++ 2 files changed, 5 insertions(+), 2 delet

[PATCH V2 28/45] vfio: return mr from vfio_get_xlat_addr

2025-02-14 Thread Steve Sistare
Modify memory_get_xlat_addr and vfio_get_xlat_addr to return the memory region that the translated address is found in. This will be needed by CPR in a subsequent patch to map blocks using IOMMU_IOAS_MAP_FILE. Also return the xlat offset, so we can simplify the interface by removing the out param

Re: [PATCH] rust: tests: do not import bindings::*

2025-02-14 Thread Paolo Bonzini
First of all, thanks for taking a look!! > > prelude::*, > > Should this be expanded too if we want to discourage wildcard imports ? The prelude is a bit special; it provides a subset of items that most users will want to include into the namespace. You're right that it goes against the rule

Re: [PATCH v3] vfio: Add property documentation

2025-02-14 Thread Alex Williamson
On Fri, 14 Feb 2025 15:34:15 +0100 Cédric Le Goater wrote: > Investigate the git history to uncover when and why the VFIO > properties were introduced and update the models. This is mostly > targeting vfio-pci device, since vfio-platform, vfio-ap and vfio-ccw > devices are simpler. > > Sort the

Re: [PATCH] qom: Use command line syntax for default values in help

2025-02-14 Thread Paolo Bonzini
Queued, thanks. Paolo

[PATCH V2 05/45] vfio/container: ram discard disable helper

2025-02-14 Thread Steve Sistare
Define a helper to set ram discard disable, generate error messages, and cleanup on failure. The second vfio_ram_block_discard_disable call site now performs VFIO_GROUP_UNSET_CONTAINER immediately on failure, instead of relying on the close of the container fd to do so in the kernel, but this is e

[PATCH V2 04/45] vfio: vfio_find_ram_discard_listener

2025-02-14 Thread Steve Sistare
Define vfio_find_ram_discard_listener as a subroutine so additional calls to it may be added in a subsequent patch. Signed-off-by: Steve Sistare Reviewed-by: Cédric Le Goater --- hw/vfio/common.c | 35 ++- include/hw/vfio/vfio-common.h | 3 +++ 2 fi

[PATCH V2 03/45] migration: lower handler priority

2025-02-14 Thread Steve Sistare
Define a vmstate priority that is lower than the default, so its handlers run after all default priority handlers. Since 0 is no longer the default priority, translate an uninitialized priority of 0 to MIG_PRI_DEFAULT. CPR for vfio will use this to install handlers for containers that run after h

[PATCH V2 09/45] vfio/container: preserve descriptors

2025-02-14 Thread Steve Sistare
At vfio creation time, save the value of vfio container, group, and device descriptors in CPR state. On qemu restart, vfio_realize() finds and uses the saved descriptors, and remembers the reused status for subsequent patches. The reused status is cleared when vmstate load finishes. During reuse

[PATCH V2 35/45] vfio/iommufd: define hwpt constructors

2025-02-14 Thread Steve Sistare
Extract hwpt creation code from iommufd_cdev_autodomains_get into the helpers iommufd_cdev_set_hwpt and iommufd_cdev_make_hwpt. These will be used by CPR in a subsequent patch. No functional change. Signed-off-by: Steve Sistare --- hw/vfio/iommufd.c | 52 ++-

[PATCH V2 27/45] migration: cpr_get_fd_param helper

2025-02-14 Thread Steve Sistare
Add the helper function cpr_get_fd_param, to use when preserving a file descriptor that is opened externally and passed to QEMU. cpr_get_fd_param returns a descriptor number either from a QEMU command-line parameter, from a getfd command, or from CPR state. When a descriptor is passed to new QEMU

[PATCH V2 01/45] MAINTAINERS: Add reviewer for CPR

2025-02-14 Thread Steve Sistare
CPR is integrated with live migration, and has the same maintainers. But, add a CPR section to add a reviewer. Signed-off-by: Steve Sistare --- MAINTAINERS | 11 +++ 1 file changed, 11 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 3848d37..2f9a6da 100644 --- a/MAINTAINERS +

[PATCH V2 33/45] vfio/iommufd: use IOMMU_IOAS_MAP_FILE

2025-02-14 Thread Steve Sistare
Use IOMMU_IOAS_MAP_FILE when the mapped region is backed by a file. Such a mapping can be preserved without modification during CPR, because it depends on the file's address space, which does not change, rather than on the process's address space, which does change. Signed-off-by: Steve Sistare -

[PATCH V2 20/45] vfio/pci: pass vector to virq functions

2025-02-14 Thread Steve Sistare
Pass the vector number to vfio_connect_kvm_msi_virq and vfio_remove_kvm_msi_virq, so it can be passed to their subroutines in a subsequent patch. No functional change. Signed-off-by: Steve Sistare --- hw/vfio/pci.c | 13 +++-- 1 file changed, 7 insertions(+), 6 deletions(-) diff --git

[PATCH V2 31/45] backends/iommufd: change process ioctl

2025-02-14 Thread Steve Sistare
Define the change process ioctl Signed-off-by: Steve Sistare --- backends/iommufd.c | 20 backends/trace-events| 1 + include/system/iommufd.h | 2 ++ 3 files changed, 23 insertions(+) diff --git a/backends/iommufd.c b/backends/iommufd.c index 612de78..cc3dcff 1

[PATCH V2 38/45] vfio/iommufd: register container for cpr

2025-02-14 Thread Steve Sistare
Register a vfio iommufd container and device for CPR, replacing the generic CPR register call with a more specific iommufd register call. Add a blocker if the kernel does not support IOMMU_IOAS_CHANGE_PROCESS. This is mostly boiler plate. The fields to to saved and restored are added in subseque

[PATCH V2 43/45] vfio/iommufd: change process

2025-02-14 Thread Steve Sistare
Finish CPR by change the owning process of the iommufd device in post load. Signed-off-by: Steve Sistare --- hw/vfio/cpr-iommufd.c | 30 ++ 1 file changed, 30 insertions(+) diff --git a/hw/vfio/cpr-iommufd.c b/hw/vfio/cpr-iommufd.c index 4b78ebf..92b101d 100644 --- a

Re: [PATCH] net: vhost-user: add QAPI events to report connection state

2025-02-14 Thread Stefano Brivio
On Fri, 14 Feb 2025 14:54:33 +0100 Markus Armbruster wrote: > Laurent Vivier writes: > > > On 14/02/2025 11:06, Markus Armbruster wrote: > >> Laurent Vivier writes: > >> > >>> The netdev reports NETDEV_VHOST_USER_CONNECTED event when > >>> the chardev is connected, and NETDEV_VHOST_USER_D

[PATCH V2 21/45] vfio/pci: vfio_notifier_init cpr parameters

2025-02-14 Thread Steve Sistare
Pass vdev and nr to vfio_notifier_init, for use by CPR in a subsequent patch. No functional change. Signed-off-by: Steve Sistare --- hw/vfio/pci.c | 22 ++ 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index 7b2d185..63fb2d9 100

Re: [PATCH] net: vhost-user: add QAPI events to report connection state

2025-02-14 Thread Stefano Brivio
On Fri, 14 Feb 2025 13:59:20 + Daniel P. Berrangé wrote: > On Fri, Feb 14, 2025 at 11:18:55AM +0100, Laurent Vivier wrote: > > On 14/02/2025 11:06, Markus Armbruster wrote: > > > Laurent Vivier writes: > > > > > > > The netdev reports NETDEV_VHOST_USER_CONNECTED event when > > > > the c

[PATCH V2 11/45] vfio/container: discard old DMA vaddr

2025-02-14 Thread Steve Sistare
In the container pre_save handler, discard the virtual addresses in DMA mappings with VFIO_DMA_UNMAP_FLAG_VADDR, because guest RAM will be remapped at a different VA after in new QEMU. DMA to already-mapped pages continues. Signed-off-by: Steve Sistare --- hw/vfio/cpr-legacy.c | 29

[PATCH V2 22/45] vfio/pci: vfio_notifier_cleanup

2025-02-14 Thread Steve Sistare
Move event_notifier_cleanup calls to a helper vfio_notifier_cleanup. This version is trivial, and does not yet use the vdev and nr parameters. No functional change. Signed-off-by: Steve Sistare --- hw/vfio/pci.c | 28 +--- 1 file changed, 17 insertions(+), 11 deletions(-)

[PATCH V2 24/45] vfio-pci: preserve MSI

2025-02-14 Thread Steve Sistare
Save the MSI message area as part of vfio-pci vmstate, and preserve the interrupt and notifier eventfd's. migrate_incoming loads the MSI data, then the vfio-pci post_load handler finds the eventfds in CPR state, rebuilds vector data structures, and attaches the interrupts to the new KVM instance.

[PATCH V2 23/45] vfio/pci: export MSI functions

2025-02-14 Thread Steve Sistare
Export various MSI functions, for use by CPR in subsequent patches. No functional change. Signed-off-by: Steve Sistare --- hw/vfio/pci.c | 21 ++--- hw/vfio/pci.h | 12 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c ind

[PATCH V2 39/45] vfio/iommufd: preserve descriptors

2025-02-14 Thread Steve Sistare
Save the iommu and vfio device fd in CPR state when it is created. After CPR, the fd number is found in CPR state and reused. Remember the reused status for subsequent patches. The reused status is cleared when vmstate load finishes. Signed-off-by: Steve Sistare --- backends/iommufd.c |

[PATCH V2 14/45] vfio/container: recover from unmap-all-vaddr failure

2025-02-14 Thread Steve Sistare
If there are multiple containers and unmap-all fails for some container, we need to remap vaddr for the other containers for which unmap-all succeeded. Recover by walking all address ranges of all containers to restore the vaddr for each. Do so by invoking the vfio listener callback, and passing a

[PATCH V2 29/45] vfio: pass ramblock to vfio_container_dma_map

2025-02-14 Thread Steve Sistare
Pass ramblock to vfio_container_dma_map for use in a subsequent patch. The ramblock's attributes will be needed to map the block using IOMMU_IOAS_MAP_FILE. No functional change. Signed-off-by: Steve Sistare --- hw/vfio/common.c | 8 +--- hw/vfio/container-base.c

[PATCH V2 41/45] vfio/iommufd: reconstruct hw_caps

2025-02-14 Thread Steve Sistare
hw_caps is normally derived during realize, at vfio_device_hiod_realize -> hiod_iommufd_vfio_realize -> iommufd_backend_get_device_info. However, this depends on the devid, which is not preserved during CPR. Save devid in vmstate. Defer the vfio_device_hiod_realize call to post_load time, after

Re: [PATCH V2 01/45] MAINTAINERS: Add reviewer for CPR

2025-02-14 Thread Peter Xu
On Fri, Feb 14, 2025 at 06:13:43AM -0800, Steve Sistare wrote: > CPR is integrated with live migration, and has the same maintainers. > But, add a CPR section to add a reviewer. > > Signed-off-by: Steve Sistare > --- > MAINTAINERS | 11 +++ > 1 file changed, 11 insertions(+) > > diff --

Re: [PATCH V2 26/45] migration: close kvm after cpr

2025-02-14 Thread Steven Sistare
cc kvm reviewers. The series is here: https://lore.kernel.org/qemu-devel/1739542467-226739-1-git-send-email-steven.sist...@oracle.com/ - Steve On 2/14/2025 9:14 AM, Steve Sistare wrote: cpr-transfer breaks vfio network connectivity to and from the guest, and the host system log shows: ir

Re: [PATCH v2] target/sparc: Fix gdbstub incorrectly handling registers f32-f62

2025-02-14 Thread Richard Henderson
On 2/13/25 23:03, Mikael Szreder wrote: The gdbstub implementation for the Sparc architecture would incorrectly calculate the the floating point register offset. This resulted in, for example, registers f32 and f34 to point to the same value. The issue was caused by the confusion between even re

Re: [PATCH V2 00/45] Live update: vfio and iommufd

2025-02-14 Thread Steven Sistare
Hi all, it would be nice to get this into qemu 10.0. Without it, the basic support for cpr-transfer already in 10.0 is much less interesting. Soft feature freeze is 2024-03-12. - Steve On 2/14/2025 9:13 AM, Steve Sistare wrote: Support vfio and iommufd devices with the cpr-transfer live migrat

Re: [PATCH v5] hw/misc/vmfwupdate: Introduce hypervisor fw-cfg interface support

2025-02-14 Thread Alexander Graf
On 14.02.25 16:35, Ani Sinha wrote: On Mon, Feb 3, 2025 at 3:50 AM Alexander Graf wrote: Hey Ani! On 28.01.25 22:31, Ani Sinha wrote: [...] diff --git a/hw/core/machine.c b/hw/core/machine.c index c23b399496..0eaf8aa3ba 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -34,6 +3

Question: how to add CLI options for custom hw model

2025-02-14 Thread Mark Nesky
Hello, I am new to the QEMU code base and I am working on a project involving a custom hardware model representing a customized ppc board. What is the best way to add command line arguments applicable to my model? I see options in qemu-options.hx + vl.c, but I am not sure if that is the right pl

Re: [PATCH V2 03/45] migration: lower handler priority

2025-02-14 Thread Peter Xu
On Fri, Feb 14, 2025 at 06:13:45AM -0800, Steve Sistare wrote: > Define a vmstate priority that is lower than the default, so its handlers > run after all default priority handlers. Since 0 is no longer the default > priority, translate an uninitialized priority of 0 to MIG_PRI_DEFAULT. > > CPR f

Re: [PATCH v6 00/10] Support virtio-gpu DRM native context

2025-02-14 Thread Dmitry Osipenko
On 2/14/25 17:33, Alex Bennée wrote: > Dmitry Osipenko writes: > >> This patchset adds DRM native context support to VirtIO-GPU on Qemu. >> >> Contarary to Virgl and Venus contexts that mediates high level GFX APIs, >> DRM native context [1] mediates lower level kernel driver UAPI, which >> refle

Re: [PATCH V2 00/45] Live update: vfio and iommufd

2025-02-14 Thread Peter Xu
On Fri, Feb 14, 2025 at 10:56:02AM -0500, Steven Sistare wrote: > Hi all, it would be nice to get this into qemu 10.0. Without it, the > basic support for cpr-transfer already in 10.0 is much less interesting. True.. > Soft feature freeze is 2024-03-12. Said that, targeting 10.0 for such a huge

Re: [PATCH] ui/gtk-gl-area: Remove extra draw call in refresh

2025-02-14 Thread Alex Bennée
dongwon@intel.com writes: > From: Dongwon Kim > > This partially reverts commit 77bf310084dad38b3a2badf01766c659056f1cf2 > which causes some guest display corruption when gtk-gl-area > is used for GTK rendering (e.g. Wayland Compositor) possibly due to > simulataneous accesses on the guest fr

Re: [PATCH v2 1/3] hw/cxl/cxl-mailbox-utils: Add support for Media operations discovery commands (8.2.9.9.5.3)

2025-02-14 Thread Jonathan Cameron via
On Thu, 13 Feb 2025 14:45:56 +0530 Vinayak Holikatti wrote: > CXL spec 3.1 section 8.2.9.9.5.3 describes media operations commands. Given the CXL consortium only makes the latest spec available, generally we try to reference that. It's move to 8.2.10.9.5.3 in r3.2 Otherwise mostly minor style c

[PATCH] rust: tests: do not import bindings::*

2025-02-14 Thread Paolo Bonzini
Similar to the devices, spell the exact set of C functions that are called directly. Signed-off-by: Paolo Bonzini --- rust/qemu-api/tests/tests.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rust/qemu-api/tests/tests.rs b/rust/qemu-api/tests/tests.rs index 92dbfb8a0c8..

Re: [PATCH] net: vhost-user: add QAPI events to report connection state

2025-02-14 Thread Daniel P . Berrangé
On Fri, Feb 14, 2025 at 11:18:55AM +0100, Laurent Vivier wrote: > On 14/02/2025 11:06, Markus Armbruster wrote: > > Laurent Vivier writes: > > > > > The netdev reports NETDEV_VHOST_USER_CONNECTED event when > > > the chardev is connected, and NETDEV_VHOST_USER_DISCONNECTED > > > when it is discon

Re: [PATCH] net: vhost-user: add QAPI events to report connection state

2025-02-14 Thread Stefano Brivio
On Fri, 14 Feb 2025 14:31:33 + Daniel P. Berrangé wrote: > On Fri, Feb 14, 2025 at 03:28:34PM +0100, Stefano Brivio wrote: > > On Fri, 14 Feb 2025 14:19:13 + > > Daniel P. Berrangé wrote: > > > > > On Fri, Feb 14, 2025 at 01:59:20PM +, Daniel P. Berrangé wrote: > > > > On Fri, F

[PATCH V2 26/45] migration: close kvm after cpr

2025-02-14 Thread Steve Sistare
cpr-transfer breaks vfio network connectivity to and from the guest, and the host system log shows: irq bypass consumer (token a03c32e5) registration fails: -16 which is EBUSY. This occurs because KVM descriptors are still open in the old QEMU process. Close them. Signed-off-by: Steve

Re: [PATCH v2] vfio: Add property documentation

2025-02-14 Thread Cédric Le Goater
On 2/13/25 22:45, Alex Williamson wrote: On Thu, 13 Feb 2025 14:50:50 +0100 Cédric Le Goater wrote: Investigate the git history to uncover when and why the VFIO properties were introduced and update the models. This is mostly targeting vfio-pci device, since vfio-plateform, vfio-ap and vfio-cc

Re: [PATCH] net: vhost-user: add QAPI events to report connection state

2025-02-14 Thread Markus Armbruster
Laurent Vivier writes: > On 14/02/2025 11:06, Markus Armbruster wrote: >> Laurent Vivier writes: >> >>> The netdev reports NETDEV_VHOST_USER_CONNECTED event when >>> the chardev is connected, and NETDEV_VHOST_USER_DISCONNECTED >>> when it is disconnected. >>> >>> The NETDEV_VHOST_USER_CONNECTED

  1   2   >