From patchwork Tue May 7 13:34:31 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 242205 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id B78172C0178 for ; Tue, 7 May 2013 23:35:13 +1000 (EST) Received: from localhost ([::1]:53693 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UZi2x-00019c-Va for incoming@patchwork.ozlabs.org; Tue, 07 May 2013 09:35:11 -0400 Received: from eggs.gnu.org ([208.118.235.92]:43568) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UZi2T-000193-KD for qemu-devel@nongnu.org; Tue, 07 May 2013 09:34:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UZi2R-0007Wy-Cf for qemu-devel@nongnu.org; Tue, 07 May 2013 09:34:41 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54353) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UZi2R-0007WE-1I for qemu-devel@nongnu.org; Tue, 07 May 2013 09:34:39 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r47DYcbr010813 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 7 May 2013 09:34:38 -0400 Received: from rincewind.home.kraxel.org (ovpn-116-34.ams2.redhat.com [10.36.116.34]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r47DYb5d027890; Tue, 7 May 2013 09:34:37 -0400 Received: by rincewind.home.kraxel.org (Postfix, from userid 500) id CDD2440AC6; Tue, 7 May 2013 15:34:36 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Tue, 7 May 2013 15:34:31 +0200 Message-Id: <1367933676-21854-2-git-send-email-kraxel@redhat.com> In-Reply-To: <1367933676-21854-1-git-send-email-kraxel@redhat.com> References: <1367933676-21854-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Gerd Hoffmann , "Michael S. Tsirkin" Subject: [Qemu-devel] [PATCH 1/6] pci: add VMSTATE_MSIX X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Using a trick cut+pasted from vmstate_scsi_device to wind up msix_save and msix_load. Signed-off-by: Gerd Hoffmann Acked-by: Michael S. Tsirkin --- hw/pci/msix.c | 33 +++++++++++++++++++++++++++++++++ include/hw/pci/msix.h | 11 +++++++++++ 2 files changed, 44 insertions(+) diff --git a/hw/pci/msix.c b/hw/pci/msix.c index e231a0d..6da75ec 100644 --- a/hw/pci/msix.c +++ b/hw/pci/msix.c @@ -569,3 +569,36 @@ void msix_unset_vector_notifiers(PCIDevice *dev) dev->msix_vector_release_notifier = NULL; dev->msix_vector_poll_notifier = NULL; } + +static void put_msix_state(QEMUFile *f, void *pv, size_t size) +{ + msix_save(pv, f); +} + +static int get_msix_state(QEMUFile *f, void *pv, size_t size) +{ + msix_load(pv, f); + return 0; +} + +static VMStateInfo vmstate_info_msix = { + .name = "msix state", + .get = get_msix_state, + .put = put_msix_state, +}; + +const VMStateDescription vmstate_msix = { + .name = "msix", + .fields = (VMStateField[]) { + { + .name = "msix", + .version_id = 0, + .field_exists = NULL, + .size = 0, /* ouch */ + .info = &vmstate_info_msix, + .flags = VMS_SINGLE, + .offset = 0, + }, + VMSTATE_END_OF_LIST() + } +}; diff --git a/include/hw/pci/msix.h b/include/hw/pci/msix.h index e648410..954d82b 100644 --- a/include/hw/pci/msix.h +++ b/include/hw/pci/msix.h @@ -43,4 +43,15 @@ int msix_set_vector_notifiers(PCIDevice *dev, MSIVectorReleaseNotifier release_notifier, MSIVectorPollNotifier poll_notifier); void msix_unset_vector_notifiers(PCIDevice *dev); + +extern const VMStateDescription vmstate_msix; + +#define VMSTATE_MSIX(_field, _state) { \ + .name = (stringify(_field)), \ + .size = sizeof(PCIDevice), \ + .vmsd = &vmstate_msix, \ + .flags = VMS_STRUCT, \ + .offset = vmstate_offset_value(_state, _field, PCIDevice), \ +} + #endif