From: Avihai Horon <avihaih@nvidia.com>
To: Peter Xu <peterx@redhat.com>
Cc: "Fabiano Rosas" <farosas@suse.de>,
"Markus Armbruster" <armbru@redhat.com>,
"Joao Martins" <joao.m.martins@oracle.com>,
"Alex Williamson" <alex.williamson@redhat.com>,
"Cédric Le Goater" <clg@redhat.com>,
"Michael Roth" <michael.roth@amd.com>,
"Eric Blake" <eblake@redhat.com>,
"Maor Gottlieb" <maorg@nvidia.com>,
qemu-devel@nongnu.org
Subject: Re: [PATCH 2/3] vfio/migration: Emit VFIO device migration state change QAPI event
Date: Tue, 7 May 2024 19:21:41 +0300 [thread overview]
Message-ID: <c19fb398-8b14-4856-aec9-fe596183b19b@nvidia.com> (raw)
In-Reply-To: <ZjpOAm3kXE-7Rg6G@x1n>
On 07/05/2024 18:51, Peter Xu wrote:
> External email: Use caution opening links or attachments
>
>
> On Tue, May 07, 2024 at 10:47:13AM +0300, Avihai Horon wrote:
>>> While at it, another trivial comment is maybe it's nice to have a helper to
>>> both update the vfio migration state, plus emitting events when necessary.
>> I think vfio_migration_set_state() does exactly that, no?
> Ah yes, looks so. It's just that I saw some common patterns, like:
>
> ===8<===
> @@ -126,11 +167,13 @@ static int vfio_migration_set_state(VFIODevice *vbasedev,
> }
>
> migration->device_state = recover_state;
> + vfio_migration_send_state_change_event(vbasedev);
>
> return ret;
> }
>
> migration->device_state = new_state;
> + vfio_migration_send_state_change_event(vbasedev);
> if (mig_state->data_fd != -1) {
> if (migration->data_fd != -1) {
> /*
> @@ -157,6 +200,7 @@ reset_device:
> }
>
> migration->device_state = VFIO_DEVICE_STATE_RUNNING;
> + vfio_migration_send_state_change_event(vbasedev);
>
> return ret;
> }
> ===8<===
>
> So maybe some more internal helpers? It doesn't look like to cover all
> updates to device_state, but I really didn't read into it. Not a huge deal
> really, feel free to keep it as-is if maintainers are happy.
Oh, I see what you mean.
Cedric, would you like me to add the following?
===8<===
--- a/hw/vfio/migration.c
+++ b/hw/vfio/migration.c
@@ -122,6 +122,14 @@ static void vfio_migration_send_event(VFIODevice
*vbasedev)
dev->id, qom_path,
mig_state_to_qapi_state(migration->device_state));
}
+static void set_state(VFIODevice *vbasedev, enum vfio_device_mig_state
state)
+{
+ VFIOMigration *migration = vbasedev->migration;
+
+ migration->device_state = state;
+ vfio_migration_send_event(vbasedev);
+}
+
static int vfio_migration_set_state(VFIODevice *vbasedev,
enum vfio_device_mig_state new_state,
enum vfio_device_mig_state
recover_state)
@@ -171,14 +179,12 @@ static int vfio_migration_set_state(VFIODevice
*vbasedev,
goto reset_device;
}
- migration->device_state = recover_state;
- vfio_migration_send_event(vbasedev);
+ set_state(vbasedev, recover_state);
return ret;
}
- migration->device_state = new_state;
- vfio_migration_send_event(vbasedev);
+ set_state(vbasedev, new_state);
if (mig_state->data_fd != -1) {
if (migration->data_fd != -1) {
/*
@@ -204,8 +210,7 @@ reset_device:
strerror(errno));
}
- migration->device_state = VFIO_DEVICE_STATE_RUNNING;
- vfio_migration_send_event(vbasedev);
+ set_state(vbasedev, VFIO_DEVICE_STATE_RUNNING);
return ret;
}
===8<===
next prev parent reply other threads:[~2024-05-07 16:27 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-30 5:16 [PATCH 0/3] qapi/vfio: Add VFIO device migration state change QAPI event Avihai Horon
2024-04-30 5:16 ` [PATCH 1/3] " Avihai Horon
2024-05-01 11:50 ` Joao Martins
2024-05-01 12:08 ` Avihai Horon
2024-05-06 4:52 ` Markus Armbruster
2024-05-06 10:07 ` Avihai Horon
2024-05-06 10:36 ` Markus Armbruster
2024-05-06 10:57 ` Avihai Horon
2024-05-02 11:19 ` Markus Armbruster
2024-05-05 7:48 ` Avihai Horon
2024-05-06 4:35 ` Markus Armbruster
2024-05-06 9:59 ` Avihai Horon
2024-04-30 5:16 ` [PATCH 2/3] vfio/migration: Emit " Avihai Horon
2024-05-01 11:50 ` Joao Martins
2024-05-01 12:28 ` Avihai Horon
2024-05-02 10:22 ` Joao Martins
2024-05-05 7:28 ` Avihai Horon
2024-05-06 4:56 ` Markus Armbruster
2024-05-06 14:38 ` Fabiano Rosas
2024-05-06 15:07 ` Peter Xu
2024-05-07 7:47 ` Avihai Horon
2024-05-07 15:51 ` Peter Xu
2024-05-07 16:21 ` Avihai Horon [this message]
2024-04-30 5:16 ` [PATCH 3/3] vfio/migration: Don't emit STOP_COPY state change event twice Avihai Horon
2024-05-06 14:39 ` Cédric Le Goater
2024-05-06 15:01 ` Avihai Horon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c19fb398-8b14-4856-aec9-fe596183b19b@nvidia.com \
--to=avihaih@nvidia.com \
--cc=alex.williamson@redhat.com \
--cc=armbru@redhat.com \
--cc=clg@redhat.com \
--cc=eblake@redhat.com \
--cc=farosas@suse.de \
--cc=joao.m.martins@oracle.com \
--cc=maorg@nvidia.com \
--cc=michael.roth@amd.com \
--cc=peterx@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).