From patchwork Mon Jun 14 05:51:47 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Williamson X-Patchwork-Id: 105871 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o5E5ppK2031075 for ; Mon, 14 Jun 2010 05:51:51 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752607Ab0FNFvt (ORCPT ); Mon, 14 Jun 2010 01:51:49 -0400 Received: from qmta15.emeryville.ca.mail.comcast.net ([76.96.27.228]:37307 "EHLO qmta15.emeryville.ca.mail.comcast.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752579Ab0FNFvs (ORCPT ); Mon, 14 Jun 2010 01:51:48 -0400 Received: from omta16.emeryville.ca.mail.comcast.net ([76.96.30.72]) by qmta15.emeryville.ca.mail.comcast.net with comcast id Vhmv1e00A1ZMdJ4AFhrodx; Mon, 14 Jun 2010 05:51:48 +0000 Received: from localhost.localdomain ([75.71.122.219]) by omta16.emeryville.ca.mail.comcast.net with comcast id Vhrn1e0024k7Kz78chrnxm; Mon, 14 Jun 2010 05:51:48 +0000 From: Alex Williamson Subject: [RFC PATCH 5/5] virtio-net: Incorporate a DeviceState pointer and let savevm track instances To: qemu-devel@nongnu.org Cc: kvm@vger.kernel.org, avi@redhat.com, anthony@codemonkey.ws, paul@codesourcery.com, kraxel@redhat.com, chrisw@redhat.com, alex.williamson@redhat.com Date: Sun, 13 Jun 2010 23:51:47 -0600 Message-ID: <20100614055147.879.31075.stgit@localhost.localdomain> In-Reply-To: <20100614054923.879.33717.stgit@localhost.localdomain> References: <20100614054923.879.33717.stgit@localhost.localdomain> User-Agent: StGIT/0.14.3 MIME-Version: 1.0 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Mon, 14 Jun 2010 05:51:51 +0000 (UTC) diff --git a/hw/virtio-net.c b/hw/virtio-net.c index e9768e0..f41db45 100644 --- a/hw/virtio-net.c +++ b/hw/virtio-net.c @@ -60,6 +60,7 @@ typedef struct VirtIONet uint8_t *macs; } mac_table; uint32_t *vlans; + DeviceState *qdev; } VirtIONet; /* TODO @@ -890,7 +891,6 @@ static void virtio_net_vmstate_change(void *opaque, int running, int reason) VirtIODevice *virtio_net_init(DeviceState *dev, NICConf *conf) { VirtIONet *n; - static int virtio_net_id; n = (VirtIONet *)virtio_common_init("virtio-net", VIRTIO_ID_NET, sizeof(struct virtio_net_config), @@ -923,7 +923,8 @@ VirtIODevice *virtio_net_init(DeviceState *dev, NICConf *conf) n->vlans = qemu_mallocz(MAX_VLAN >> 3); - register_savevm(NULL, "virtio-net", virtio_net_id++, VIRTIO_NET_VM_VERSION, + n->qdev = dev; + register_savevm(dev, "virtio-net", -1, VIRTIO_NET_VM_VERSION, virtio_net_save, virtio_net_load, n); n->vmstate = qemu_add_vm_change_state_handler(virtio_net_vmstate_change, n); @@ -941,7 +942,7 @@ void virtio_net_exit(VirtIODevice *vdev) qemu_purge_queued_packets(&n->nic->nc); - unregister_savevm(NULL, "virtio-net", n); + unregister_savevm(n->qdev, "virtio-net", n); qemu_free(n->mac_table.macs); qemu_free(n->vlans);