Received: from eggs.gnu.org ([2001:4830:134:3::10]:48052) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcWba-0001oP-Gv for qemu-devel@nongnu.org; Thu, 17 Sep 2015 06:39:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcWbX-00018K-55 for qemu-devel@nongnu.org; Thu, 17 Sep 2015 06:39:54 -0400 Received: from e06smtp05.uk.ibm.com ([195.75.94.101]:43254) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcWbW-00017Y-TH for qemu-devel@nongnu.org; Thu, 17 Sep 2015 06:39:51 -0400 Received: from /spool/local by e06smtp05.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 17 Sep 2015 11:39:42 +0100 Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by d06dlp02.portsmouth.uk.ibm.com (Postfix) with ESMTP id 2A8B32190019 for ; Thu, 17 Sep 2015 11:39:07 +0100 (BST) Received: from d06av09.portsmouth.uk.ibm.com (d06av09.portsmouth.uk.ibm.com [9.149.37.250]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t8HAdZDu40632474 for ; Thu, 17 Sep 2015 10:39:36 GMT Received: from d06av09.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av09.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t8HAdZHw027627 for ; Thu, 17 Sep 2015 04:39:35 -0600 Date: Thu, 17 Sep 2015 12:39:31 +0200 From: Greg Kurz Message-ID: <20150917123931.11435cf6@bahia.local> In-Reply-To: <1442480761-20548-1-git-send-email-cornelia.huck@de.ibm.com> References: <20150916175511.6328fceb@bahia.local> <1442480761-20548-1-git-send-email-cornelia.huck@de.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH] virtio: add some migration doc List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Cornelia Huck Cc: jasowang@redhat.com, kraxel@redhat.com, qemu-devel@nongnu.org, mst@redhat.com On Thu, 17 Sep 2015 11:06:01 +0200 Cornelia Huck wrote: > Try to cover the basics of virtio migration. >=20 > Signed-off-by: Cornelia Huck > --- > It might help if we add some documentation; at the very least, it will > prevent myself getting a headache everytime I look at that code :) >=20 > Feedback welcome. Excellent ! This is a very good to start with. Reviewed-by: Greg Kurz Just a thought below... > --- > docs/virtio-migration.txt | 101 ++++++++++++++++++++++++++++++++++++++++= ++++++ > 1 file changed, 101 insertions(+) > create mode 100644 docs/virtio-migration.txt >=20 > diff --git a/docs/virtio-migration.txt b/docs/virtio-migration.txt > new file mode 100644 > index 0000000..9c575e6 > --- /dev/null > +++ b/docs/virtio-migration.txt > @@ -0,0 +1,101 @@ > +Virtio devices and migration > +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > + > +Saving and restoring the state of virtio devices is a bit of a twisty ma= ze, > +for several reasons: > +- state is distributed between several parts: > + - virtio core, for common fields like features, number of queues, ... > + - virtio transport (pci, ccw, ...), for the different proxy devices and > + transport specific state (msix vectors, indicators, ...) > + - virtio device (net, blk, ...), for the different device types and th= eir > + state (mac address, request queue, ...) > +- most fields are saved via the stream interface; subsequently, subsecti= ons > + have been added to make cross-version migration possible > + > +This file attempts to document the current procedure and point out some > +caveats. > + > + > +Save state procedure > +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > + > +virtio core virtio transport virtio device > +----------- ---------------- ------------- > + > + save() function regi= stered > + via register_savevm() > +virtio_save() <---------- > + ------> save_config() > + - save proxy device > + - save transport-specific > + device fields > +- save common device > + fields > +- save common virtqueue > + fields > + ------> save_queue() > + - save transport-specific > + virtqueue fields > + ------> save_device() > + - save device-specific > + fields > +- save subsections > + - device endianness, > + if changed from > + default endianness > + - 64 bit features, if > + any high feature bit > + is set > + - virtio-1 virtqueue > + fields, if VERSION_1 > + is set > + > + > +Load state procedure > +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > + > +virtio core virtio transport virtio device > +----------- ---------------- ------------- > + > + load() function regi= stered > + via register_savevm() > +virtio_load() <---------- > + ------> load_config() > + - load proxy device > + - load transport-specific > + device fields > +- load common device > + fields > +- load common virtqueue > + fields > + ------> load_queue() > + - load transport-specific > + virtqueue fields > +- notify guest > + ------> load_device() > + - load device-specific > + fields > +- load subsections > + - device endianness > + - 64 bit features > + - virtio-1 virtqueue > + fields > +- sanitize endianness > +- sanitize features > +- virtqueue index sanity > + check > + - feature-dependent s= etup > + > + > +Implications of this setup > +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D > + > +Devices need to be careful in their state processing during load: The > +load_device() procedure is invoked by the core before subsections have > +been loaded. Any code that depends on information transmitted in subsect= ions > +therefore has to be invoked in the device's load() function _after_ > +virtio_load() returned (like e.g. code depending on features). > + =46rom a VMState standpoint, such code would land in a post-load callback mos= t of the time. Would that help comprehension if we introduce a virtio_post_load() function ? > +Any extension of the state being migrated should be done in subsections > +added to the core for compatibility reasons. If transport or device spec= ific > +state is added, core needs to invoke a callback from the new subsection.