From patchwork Thu Jun 24 04:41:40 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Williamson X-Patchwork-Id: 56749 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 0F5CFB6F14 for ; Thu, 24 Jun 2010 14:51:55 +1000 (EST) Received: from localhost ([127.0.0.1]:55850 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1ORePZ-0008N8-N3 for incoming@patchwork.ozlabs.org; Thu, 24 Jun 2010 00:51:37 -0400 Received: from [140.186.70.92] (port=37766 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OReGA-00036o-IO for qemu-devel@nongnu.org; Thu, 24 Jun 2010 00:41:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OReG8-0001Py-FV for qemu-devel@nongnu.org; Thu, 24 Jun 2010 00:41:53 -0400 Received: from mx1.redhat.com ([209.132.183.28]:4735) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OReG8-0001Ps-6A for qemu-devel@nongnu.org; Thu, 24 Jun 2010 00:41:52 -0400 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o5O4fgaL014349 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 24 Jun 2010 00:41:42 -0400 Received: from localhost.localdomain (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o5O4feY9018794; Thu, 24 Jun 2010 00:41:40 -0400 From: Alex Williamson To: qemu-devel@nongnu.org Date: Wed, 23 Jun 2010 22:41:40 -0600 Message-ID: <20100624044140.16168.75560.stgit@localhost.localdomain> In-Reply-To: <20100624044046.16168.32804.stgit@localhost.localdomain> References: <20100624044046.16168.32804.stgit@localhost.localdomain> User-Agent: StGIT/0.14.3 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.67 on 10.5.11.16 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: jan.kiszka@siemens.com, armbru@redhat.com, alex.williamson@redhat.com, kraxel@redhat.com, cam@cs.ualberta.ca, paul@codesourcery.com Subject: [Qemu-devel] [PATCH 07/15] virtio-net: Incorporate a DeviceState pointer and let savevm track instances X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Stuff a pointer to the DeviceState into the VirtIONet structure so that we can easily remove the vmstate entry later. Also, let vmstate track the instance number (it should always be zero internally since the device path should now be unique). Signed-off-by: Alex Williamson --- hw/virtio-net.c | 7 ++++--- 1 files changed, 4 insertions(+), 3 deletions(-) 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);