From patchwork Wed Jun 10 12:28:12 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: 29276 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 n5ACVmsK027331 for ; Wed, 10 Jun 2009 12:31:48 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756175AbZFJMbn (ORCPT ); Wed, 10 Jun 2009 08:31:43 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1755757AbZFJMbn (ORCPT ); Wed, 10 Jun 2009 08:31:43 -0400 Received: from mx2.redhat.com ([66.187.237.31]:53721 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754097AbZFJMbm (ORCPT ); Wed, 10 Jun 2009 08:31:42 -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 n5ACT8MD004099; Wed, 10 Jun 2009 08:29:08 -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 n5ACT7Xm004478; Wed, 10 Jun 2009 08:29:07 -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 n5ACT3Ia015169; Wed, 10 Jun 2009 08:29:04 -0400 Date: Wed, 10 Jun 2009 15:28:12 +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: [PATCHv4 02/13] qemu: capability bits in pci save/restore Message-ID: <20090610122812.GC27174@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 | 17 ++++++++++++++--- hw/pci.h | 4 ++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/hw/pci.c b/hw/pci.c index 766e0c6..6740b07 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 c50ea50..656badc 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,