From: Stefan Hajnoczi <stefanha@redhat.com>
To: Jagannathan Raman <jag.raman@oracle.com>
Cc: elena.ufimtseva@oracle.com, john.g.johnson@oracle.com,
thuth@redhat.com, swapnil.ingle@nutanix.com,
john.levon@nutanix.com, philmd@redhat.com, qemu-devel@nongnu.org,
alex.williamson@redhat.com, marcandre.lureau@gmail.com,
thanos.makatos@nutanix.com, pbonzini@redhat.com,
alex.bennee@linaro.org
Subject: Re: [PATCH v3 11/12] vfio-user: register handlers to facilitate migration
Date: Wed, 27 Oct 2021 19:30:17 +0100 [thread overview]
Message-ID: <YXmauWJFaVBtdUFq@stefanha-x1.localdomain> (raw)
In-Reply-To: <9f85493af346c32d34cca3622e8293053b5c7440.1633929457.git.jag.raman@oracle.com>
[-- Attachment #1: Type: text/plain, Size: 3667 bytes --]
On Mon, Oct 11, 2021 at 01:31:16AM -0400, Jagannathan Raman wrote:
> +static void vfu_mig_state_running(vfu_ctx_t *vfu_ctx)
> +{
> + VfuObject *o = vfu_get_private(vfu_ctx);
> + VfuObjectClass *k = VFU_OBJECT_GET_CLASS(OBJECT(o));
> + static int migrated_devs;
> + Error *local_err = NULL;
> + int ret;
> +
> + /**
> + * TODO: move to VFU_MIGR_STATE_RESUME handler. Presently, the
> + * VMSD data from source is not available at RESUME state.
> + * Working on a fix for this.
> + */
> + if (!o->vfu_mig_file) {
> + o->vfu_mig_file = qemu_fopen_ops(o, &vfu_mig_fops_load, false);
> + }
> +
> + ret = qemu_remote_loadvm(o->vfu_mig_file);
> + if (ret) {
> + error_setg(&error_abort, "vfu: failed to restore device state");
> + return;
> + }
> +
> + qemu_file_shutdown(o->vfu_mig_file);
> + o->vfu_mig_file = NULL;
> +
> + /* VFU_MIGR_STATE_RUNNING begins here */
> + if (++migrated_devs == k->nr_devs) {
See below about migrated_devs.
> + bdrv_invalidate_cache_all(&local_err);
> + if (local_err) {
> + error_report_err(local_err);
> + return;
> + }
> +
> + vm_start();
> + }
> +}
> +
> +static void vfu_mig_state_stop(vfu_ctx_t *vfu_ctx)
> +{
> + VfuObject *o = vfu_get_private(vfu_ctx);
> + VfuObjectClass *k = VFU_OBJECT_GET_CLASS(OBJECT(o));
> + static int migrated_devs;
> +
> + /**
> + * note: calling bdrv_inactivate_all() is not the best approach.
> + *
> + * Ideally, we would identify the block devices (if any) indirectly
> + * linked (such as via a scs-hd device) to each of the migrated devices,
s/scs/scsi/
> + * and inactivate them individually. This is essential while operating
> + * the server in a storage daemon mode, with devices from different VMs.
> + *
> + * However, we currently don't have this capability. As such, we need to
> + * inactivate all devices at the same time when migration is completed.
> + */
> + if (++migrated_devs == k->nr_devs) {
> + bdrv_inactivate_all();
> + vm_stop(RUN_STATE_PAUSED);
The order of these two functions is reversed in migration/migration.c.
First we pause the VM, then we inactivate disks.
I think we need to zero migrated_devs in case migration fails and we try
to migrate again later:
migrated_devs = 0;
This is still not quite right because maybe only a few VfuObjects are
stopped before migration fails. A different approach for counting
devices is necessary, like zeroing migrated_devs in
vfu_mig_state_stop_and_copy().
> @@ -422,6 +722,35 @@ static void vfu_object_machine_done(Notifier *notifier, void *data)
> return;
> }
>
> + /*
> + * TODO: The 0x20000 number used below is a temporary. We are working on
> + * a cleaner fix for this.
> + *
> + * The libvfio-user library assumes that the remote knows the size of
> + * the data to be migrated at boot time, but that is not the case with
> + * VMSDs, as it can contain a variable-size buffer. 0x20000 is used
> + * as a sufficiently large buffer to demonstrate migration, but that
> + * cannot be used as a solution.
> + *
> + */
My question from the previous revision was not answered:
libvfio-user has the vfu_migration_callbacks_t interface that allows the
device to save/load more data regardless of the size of the migration
region. I don't see the issue here since the region doesn't need to be
sized to fit the savevm data?
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2021-10-27 19:09 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-11 5:31 [PATCH v3 00/12] vfio-user server in QEMU Jagannathan Raman
2021-10-11 5:31 ` [PATCH v3 01/12] configure, meson: override C compiler for cmake Jagannathan Raman
2021-10-12 10:44 ` Paolo Bonzini
2021-10-11 5:31 ` [PATCH v3 02/12] vfio-user: build library Jagannathan Raman
2021-10-27 15:17 ` Stefan Hajnoczi
2021-10-29 14:17 ` Jag Raman
2021-11-01 9:56 ` Stefan Hajnoczi
2021-10-11 5:31 ` [PATCH v3 03/12] vfio-user: define vfio-user-server object Jagannathan Raman
2021-10-27 15:40 ` Stefan Hajnoczi
2021-10-29 14:42 ` Jag Raman
2021-11-01 10:34 ` Stefan Hajnoczi
2021-11-04 12:13 ` Markus Armbruster
2021-11-04 14:39 ` Kevin Wolf
2021-11-05 10:08 ` Markus Armbruster
2021-11-05 13:19 ` Kevin Wolf
2021-11-05 13:54 ` Peter Krempa
2021-11-06 6:34 ` Markus Armbruster
2021-11-08 12:05 ` Kevin Wolf
2021-11-08 12:54 ` Peter Krempa
2021-11-04 16:48 ` Stefan Hajnoczi
2021-10-11 5:31 ` [PATCH v3 04/12] vfio-user: instantiate vfio-user context Jagannathan Raman
2021-10-27 15:59 ` Stefan Hajnoczi
2021-10-29 14:59 ` Jag Raman
2021-11-01 10:35 ` Stefan Hajnoczi
2021-10-11 5:31 ` [PATCH v3 05/12] vfio-user: find and init PCI device Jagannathan Raman
2021-10-27 16:05 ` Stefan Hajnoczi
2021-10-29 15:58 ` Jag Raman
2021-11-01 10:38 ` Stefan Hajnoczi
2021-10-11 5:31 ` [PATCH v3 06/12] vfio-user: run vfio-user context Jagannathan Raman
2021-10-27 16:21 ` Stefan Hajnoczi
2021-10-28 21:55 ` John Levon
2021-10-11 5:31 ` [PATCH v3 07/12] vfio-user: handle PCI config space accesses Jagannathan Raman
2021-10-27 16:35 ` Stefan Hajnoczi
2021-10-11 5:31 ` [PATCH v3 08/12] vfio-user: handle DMA mappings Jagannathan Raman
2021-10-11 5:31 ` [PATCH v3 09/12] vfio-user: handle PCI BAR accesses Jagannathan Raman
2021-10-27 16:38 ` Stefan Hajnoczi
2021-10-11 5:31 ` [PATCH v3 10/12] vfio-user: handle device interrupts Jagannathan Raman
2021-10-11 5:31 ` [PATCH v3 11/12] vfio-user: register handlers to facilitate migration Jagannathan Raman
2021-10-27 18:30 ` Stefan Hajnoczi [this message]
2021-12-15 15:49 ` Jag Raman
2021-10-11 5:31 ` [PATCH v3 12/12] vfio-user: acceptance test Jagannathan Raman
2021-10-11 22:26 ` Philippe Mathieu-Daudé
2021-10-27 16:42 ` Stefan Hajnoczi
2021-10-27 18:33 ` [PATCH v3 00/12] vfio-user server in QEMU Stefan Hajnoczi
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=YXmauWJFaVBtdUFq@stefanha-x1.localdomain \
--to=stefanha@redhat.com \
--cc=alex.bennee@linaro.org \
--cc=alex.williamson@redhat.com \
--cc=elena.ufimtseva@oracle.com \
--cc=jag.raman@oracle.com \
--cc=john.g.johnson@oracle.com \
--cc=john.levon@nutanix.com \
--cc=marcandre.lureau@gmail.com \
--cc=pbonzini@redhat.com \
--cc=philmd@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=swapnil.ingle@nutanix.com \
--cc=thanos.makatos@nutanix.com \
--cc=thuth@redhat.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).