From patchwork Thu Jun 18 13:13:06 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 31127 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n5IDGEjw007612 for ; Thu, 18 Jun 2009 13:16:15 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760630AbZFRNQK (ORCPT ); Thu, 18 Jun 2009 09:16:10 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1760494AbZFRNQI (ORCPT ); Thu, 18 Jun 2009 09:16:08 -0400 Received: from mx2.redhat.com ([66.187.237.31]:35172 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757039AbZFRNQH (ORCPT ); Thu, 18 Jun 2009 09:16:07 -0400 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n5IDDTNn021696; Thu, 18 Jun 2009 09:13:29 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n5IDDS5W024563; Thu, 18 Jun 2009 09:13:28 -0400 Received: from redhat.com (vpn-6-65.tlv.redhat.com [10.35.6.65]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n5IDDP8V026062; Thu, 18 Jun 2009 09:13:25 -0400 Date: Thu, 18 Jun 2009 16:13:06 +0300 From: "Michael S. Tsirkin" To: Paul Brook , Avi Kivity , qemu-devel@nongnu.org, Carsten Otte , kvm@vger.kernel.org, Rusty Russell , virtualization@lists.linux-foundation.org, Christian Borntraeger , Blue Swirl , Anthony Liguori , Glauber Costa Subject: [PATCHv5 02/13] qemu: capability bits in pci save/restore Message-ID: <20090618131306.GC19092@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.19 (2009-01-05) X-Scanned-By: MIMEDefang 2.58 on 172.16.27.26 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Add support for capability bits in save/restore for pci. These will be used for MSI, where the capability might be present or not as requested by user, which does not map well into a single version number. Signed-off-by: Michael S. Tsirkin --- hw/pci.c | 17 ++++++++++++++--- hw/pci.h | 4 ++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/hw/pci.c b/hw/pci.c index 840986f..d42fcd9 100644 --- a/hw/pci.c +++ b/hw/pci.c @@ -126,9 +126,13 @@ int pci_bus_num(PCIBus *s) void pci_device_save(PCIDevice *s, QEMUFile *f) { + int version = s->cap_present ? 3 : 2; int i; - qemu_put_be32(f, 2); /* PCI device version */ + /* PCI device version and capabilities */ + qemu_put_be32(f, version); + if (version >= 3) + qemu_put_be32(f, s->cap_present); qemu_put_buffer(f, s->config, 256); for (i = 0; i < 4; i++) qemu_put_be32(f, s->irq_state[i]); @@ -140,15 +144,22 @@ int pci_device_load(PCIDevice *s, QEMUFile *f) int i; version_id = qemu_get_be32(f); - if (version_id > 2) + if (version_id > 3) return -EINVAL; + if (version_id >= 3) + s->cap_present = qemu_get_be32(f); + else + s->cap_present = 0; + + if (s->cap_present & ~s->cap_supported) + return -EINVAL; + qemu_get_buffer(f, s->config, 256); pci_update_mappings(s); if (version_id >= 2) for (i = 0; i < 4; i ++) s->irq_state[i] = qemu_get_be32(f); - return 0; } diff --git a/hw/pci.h b/hw/pci.h index 44aa61b..1226846 100644 --- a/hw/pci.h +++ b/hw/pci.h @@ -174,6 +174,10 @@ struct PCIDevice { /* Current IRQ levels. Used internally by the generic PCI code. */ int irq_state[4]; + + /* Capability bits for save/load */ + uint32_t cap_supported; + uint32_t cap_present; }; PCIDevice *pci_register_device(PCIBus *bus, const char *name,