From patchwork Tue Jun 2 15:02:13 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: 27479 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 n52F6xaf011479 for ; Tue, 2 Jun 2009 15:06:59 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753864AbZFBPFr (ORCPT ); Tue, 2 Jun 2009 11:05:47 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1756133AbZFBPFq (ORCPT ); Tue, 2 Jun 2009 11:05:46 -0400 Received: from mx2.redhat.com ([66.187.237.31]:47688 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757060AbZFBPFp (ORCPT ); Tue, 2 Jun 2009 11:05:45 -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 n52F3AUU013046; Tue, 2 Jun 2009 11:03:10 -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 n52F38YS011236; Tue, 2 Jun 2009 11:03:08 -0400 Received: from redhat.com (dhcp-0-223.tlv.redhat.com [10.35.0.223]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n52F35pL019233; Tue, 2 Jun 2009 11:03:05 -0400 Date: Tue, 2 Jun 2009 18:02:13 +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 Subject: [PATCHv2 02/13] qemu: capability bits in pci save/restore Message-ID: <20090602150213.GC6554@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.18 (2008-05-17) 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 | 14 ++++++++++++-- hw/pci.h | 4 ++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/hw/pci.c b/hw/pci.c index 1e70e46..5dcfb4e 100644 --- a/hw/pci.c +++ b/hw/pci.c @@ -127,12 +127,15 @@ 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 */ + qemu_put_be32(f, version); /* PCI device version */ qemu_put_buffer(f, s->config, 256); for (i = 0; i < 4; i++) qemu_put_be32(f, s->irq_state[i]); + if (version >= 3) + qemu_put_be32(f, s->cap_present); } int pci_device_load(PCIDevice *s, QEMUFile *f) @@ -141,7 +144,7 @@ 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; qemu_get_buffer(f, s->config, 256); pci_update_mappings(s); @@ -149,6 +152,13 @@ int pci_device_load(PCIDevice *s, QEMUFile *f) if (version_id >= 2) for (i = 0; i < 4; i ++) s->irq_state[i] = qemu_get_be32(f); + 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; return 0; } diff --git a/hw/pci.h b/hw/pci.h index c0c2380..9139504 100644 --- a/hw/pci.h +++ b/hw/pci.h @@ -178,6 +178,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,