From: Kunkun Jiang <jiangkunkun@huawei.com>
To: "Philippe Mathieu-Daudé" <philmd@redhat.com>,
"Alex Williamson" <alex.williamson@redhat.com>,
"Kirti Wankhede" <kwankhede@nvidia.com>,
"open list:All patches CC here" <qemu-devel@nongnu.org>
Cc: Juan Quintela <quintela@redhat.com>,
"Dr. David Alan Gilbert" <dgilbert@redhat.com>,
qemu-stable@nongnu.org, ganqixin@huawei.com,
Zenghui Yu <yuzenghui@huawei.com>,
wanghaibin.wang@huawei.com, Keqian Zhu <zhukeqian1@huawei.com>
Subject: Re: [PATCH] vfio: Fix unregister SaveVMHandler in vfio_migration_finalize
Date: Fri, 28 May 2021 10:04:35 +0800 [thread overview]
Message-ID: <c9c94ef3-cbb6-3b0c-f67f-94f3d5422910@huawei.com> (raw)
In-Reply-To: <fcfa0ad2-4819-8ea3-b69c-01b4d1e97269@redhat.com>
Hi Philippe,
On 2021/5/27 21:44, Philippe Mathieu-Daudé wrote:
> On 5/27/21 2:31 PM, Kunkun Jiang wrote:
>> In the vfio_migration_init(), the SaveVMHandler is registered for
>> VFIO device. But it lacks the operation of 'unregister'. It will
>> lead to 'Segmentation fault (core dumped)' in
>> qemu_savevm_state_setup(), if performing live migration after a
>> VFIO device is hot deleted.
>>
>> Fixes: 7c2f5f75f94 (vfio: Register SaveVMHandlers for VFIO device)
>> Reported-by: Qixin Gan <ganqixin@huawei.com>
>> Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
> Cc: qemu-stable@nongnu.org
>
>> ---
>> hw/vfio/migration.c | 1 +
>> 1 file changed, 1 insertion(+)
>>
>> diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c
>> index 201642d75e..ef397ebe6c 100644
>> --- a/hw/vfio/migration.c
>> +++ b/hw/vfio/migration.c
>> @@ -892,6 +892,7 @@ void vfio_migration_finalize(VFIODevice *vbasedev)
>>
>> remove_migration_state_change_notifier(&migration->migration_state);
>> qemu_del_vm_change_state_handler(migration->vm_state);
>> + unregister_savevm(VMSTATE_IF(vbasedev->dev), "vfio", vbasedev);
> Hmm what about devices using "%s/vfio" id?
The unregister_savevm() needs 'VMSTATEIf *obj'. If we pass a non-null 'obj'
to unregister_svevm(), it will handle the devices using "%s/vfio" id with
the following code:
> if (obj) {
> char *oid = vmstate_if_get_id(obj);
> if (oid) {
> pstrcpy(id, sizeof(id), oid);
> pstrcat(id, sizeof(id), "/");
> g_free(oid);
> }
> }
> pstrcat(id, sizeof(id), idstr);
By the way, I'm puzzled that register_savevm_live() and unregister_savevm()
handle devices using "%s/vfio" id differently. So I learned the commit
history of register_savevm_live() and unregister_savevm().
In the beginning, both them need 'DeviceState *dev', which are replaced
with VMStateIf in 3cad405babb. Later in ce62df5378b, the 'dev' was removed,
because no caller of register_savevm_live() need to pass a non-null 'dev'
at that time.
So now the vfio devices need to handle the 'id' first and then call
register_savevm_live(). I am wondering whether we need to add
'VMSTATEIf *obj' in register_savevm_live(). What do you think of this?
Thanks,
Kunkun Jiang
>
>> vfio_migration_exit(vbasedev);
>> }
>>
>>
> .
next prev parent reply other threads:[~2021-05-28 2:06 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-27 12:31 [PATCH] vfio: Fix unregister SaveVMHandler in vfio_migration_finalize Kunkun Jiang
2021-05-27 13:44 ` Philippe Mathieu-Daudé
2021-05-28 2:04 ` Kunkun Jiang [this message]
2021-05-28 18:27 ` Kirti Wankhede
2021-06-15 11:42 ` Kunkun Jiang
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=c9c94ef3-cbb6-3b0c-f67f-94f3d5422910@huawei.com \
--to=jiangkunkun@huawei.com \
--cc=alex.williamson@redhat.com \
--cc=dgilbert@redhat.com \
--cc=ganqixin@huawei.com \
--cc=kwankhede@nvidia.com \
--cc=philmd@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-stable@nongnu.org \
--cc=quintela@redhat.com \
--cc=wanghaibin.wang@huawei.com \
--cc=yuzenghui@huawei.com \
--cc=zhukeqian1@huawei.com \
/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 NNTP newsgroup(s).