From mboxrd@z Thu Jan 1 00:00:00 1970 From: Anthony Liguori Subject: Re: [PATCH] Virtio network device migration support Date: Mon, 03 Mar 2008 09:27:03 -0600 Message-ID: <47CC18C7.9070909@us.ibm.com> References: <1204549143.8413.14.camel@localhost.localdomain> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: kvm-devel , Avi Kivity To: dor.laor@qumranet.com Return-path: In-Reply-To: <1204549143.8413.14.camel@localhost.localdomain> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: kvm-devel-bounces@lists.sourceforge.net Errors-To: kvm-devel-bounces@lists.sourceforge.net List-Id: kvm.vger.kernel.org Hi Dor, Dor Laor wrote: > void *virtio_net_init(PCIBus *bus, NICInfo *nd, int devfn) > { > VirtIONet *n; > + const char *info_str = "virtio-net"; > > - n = (VirtIONet *)virtio_init_pci(bus, "virtio-net", 6900, 0x1000, > + n = (VirtIONet *)virtio_init_pci(bus, info_str, 6900, 0x1000, > 0, VIRTIO_ID_NET, > 0x02, 0x00, 0x00, > 6, sizeof(VirtIONet)); > @@ -308,5 +353,11 @@ void *virtio_net_init(PCIBus *bus, NICInfo *nd, int devfn) > n->tx_timer = qemu_new_timer(vm_clock, virtio_net_tx_timer, n); > n->tx_timer_active = 0; > > + snprintf(n->vc->info_str, sizeof(n->vc->info_str), > + "%s macaddr=%02x:%02x:%02x:%02x:%02x:%02x", info_str, > + nd->macaddr[0], nd->macaddr[1], nd->macaddr[2], > + nd->macaddr[3], nd->macaddr[4], nd->macaddr[5]); > + register_savevm(info_str, 1, 1, virtio_net_save, virtio_net_load, n); > I think we need to maintain an instance id and increment it here like we do for the rest of the network cards. > return &n->vdev; > } > diff --git a/qemu/hw/virtio.c b/qemu/hw/virtio.c > index 634f869..69fe810 100644 > --- a/qemu/hw/virtio.c > +++ b/qemu/hw/virtio.c > @@ -180,6 +180,59 @@ void virtio_reset(void *opaque) > } > } > > +void virtio_dev_save(QEMUFile *f, VirtIODevice *vdev) > +{ > + int i; > + > + qemu_put_be32s(f, &vdev->features); > + qemu_put_be16s(f, &vdev->queue_sel); > + qemu_put_8s(f, &vdev->status); > + qemu_put_8s(f, &vdev->isr); > + > + for(i = 0; i < VIRTIO_PCI_QUEUE_MAX; i++) { > + if (!vdev->vq[i].vring.num) > + continue; > + qemu_put_be32s(f, &vdev->vq[i].pfn); > + qemu_put_be16s(f, &vdev->vq[i].last_avail_idx); > + qemu_put_be32s(f, &vdev->vq[i].index); > + > + /* Save the descriptor ring instead of constantly mark them dirty */ > + qemu_put_buffer(f, (uint8_t*)vdev->vq[i].vring.desc, vdev->vq[i].vring.num * sizeof(VRingDesc)); > + qemu_put_buffer(f, (uint8_t*)vdev->vq[i].vring.avail, TARGET_PAGE_SIZE); > + qemu_put_buffer(f, (uint8_t*)vdev->vq[i].vring.used, TARGET_PAGE_SIZE); > I think these two need to be sizeof(VRingAvail) * vring.num and sizeof(VringUsed) * vring.num Regards, Anthony Liguori ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/