On Fri, 6 Nov 2015 16:02:44 +0800 Jason Wang <jasow...@redhat.com> wrote:
> We don't migrate the followings fields for virtio-pci: > > uint32_t dfselect; > uint32_t gfselect; > uint32_t guest_features[2]; > struct { > uint16_t num; > bool enabled; > uint32_t desc[2]; > uint32_t avail[2]; > uint32_t used[2]; > } vqs[VIRTIO_QUEUE_MAX]; > > This will confuse driver if migrating during initialization. Solves > this issue by: > > - introduce transport specific callbacks to load and store extra > virtqueue states. > - add a new subsection for virtio to migrate transport specific modern > device state. > - implement pci specific callbacks. > - add a new property for virtio-pci for whether or not to migrate > extra state. > - compat the migration for 2.4 and elder machine types > > Cc: Michael S. Tsirkin <m...@redhat.com> > Signed-off-by: Jason Wang <jasow...@redhat.com> > --- > hw/virtio/virtio-pci.c | 129 > +++++++++++++++++++++++++++++++++++++++++ > hw/virtio/virtio-pci.h | 20 ++++--- > hw/virtio/virtio.c | 58 ++++++++++++++++++ > include/hw/compat.h | 4 ++ > include/hw/virtio/virtio-bus.h | 3 + > 5 files changed, 207 insertions(+), 7 deletions(-) > @@ -133,6 +256,7 @@ static int virtio_pci_load_queue(DeviceState *d, int n, > QEMUFile *f) > if (vector != VIRTIO_NO_VECTOR) { > return msix_vector_use(&proxy->pci_dev, vector); > } > + whitespace change :) > return 0; > } > (...) > +static void put_extra_state(QEMUFile *f, void *pv, size_t size) > +{ > + VirtIODevice *vdev = pv; > + BusState *qbus = qdev_get_parent_bus(DEVICE(vdev)); > + VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus); > + I'd probably put an 'assert(k->save_extra_state)' here. (I think we have discussed this before, but I can't recall the outcome.) > + k->save_extra_state(qbus->parent, f); > +} Otherwise, this looks good to me. With or with out the assert, Reviewed-by: Cornelia Huck <cornelia.h...@de.ibm.com>