From patchwork Tue Oct 30 12:16:33 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 1670151 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id B78163FC36 for ; Tue, 30 Oct 2012 12:17:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933516Ab2J3MRF (ORCPT ); Tue, 30 Oct 2012 08:17:05 -0400 Received: from mail-pb0-f46.google.com ([209.85.160.46]:42309 "EHLO mail-pb0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933424Ab2J3MRD (ORCPT ); Tue, 30 Oct 2012 08:17:03 -0400 Received: by mail-pb0-f46.google.com with SMTP id rr4so143424pbb.19 for ; Tue, 30 Oct 2012 05:17:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=cIeTfSadcaqd1gOLEZcZuSbhAICZi5XKJMab56j/ZTY=; b=Nel73hqOyGPz+vfGVLo4D9dM69iXG80oa6TtD0cyZL75BrrZaSQ/O82VBWPqs/fez9 xSRCZ5PVvEL8IuBu9YCwTIBCLtR77/VJn/QG7zvG3neb1mtWYZah+7KO1ht9B5lpjm2u 0QUfQ9vtfGMFkEuFRDP90SjUlXUM5OOtgDz+oSTWPxNfNF+dReVrvp9odtwsw5zPPqZX 29GG/byRh7XWfZjIke1wO8p02wt2gf5qxjGgZjCRpy9JJqUPIvSbvZtzyacFRYbwGZw0 9IZRlfs5IUnQDAVs4Gq3EVtYafoYp974bYznhChAikYF9edyFdPMDjYctntTgXDv2dpN OKPg== Received: by 10.68.229.201 with SMTP id ss9mr101484997pbc.80.1351599423097; Tue, 30 Oct 2012 05:17:03 -0700 (PDT) Received: from yakj.usersys.redhat.com (93-34-169-1.ip50.fastwebnet.it. [93.34.169.1]) by mx.google.com with ESMTPS id o10sm319041paz.37.2012.10.30.05.16.59 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 30 Oct 2012 05:17:01 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: avi@redhat.com, mtosatti@redhat.com, jan.kiszka@siemens.com, kvm@vger.kernel.org Subject: [PATCH 4/3] ioapic: change pre_save/post_load methods to get/put Date: Tue, 30 Oct 2012 13:16:33 +0100 Message-Id: <1351599394-24876-5-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.7.12.1 In-Reply-To: <1351599394-24876-1-git-send-email-pbonzini@redhat.com> References: <1351599394-24876-1-git-send-email-pbonzini@redhat.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Similar to the APIC, add get/put methods that can be called from common IOAPIC code. Use them already for pre_save/post_load, since they are exact replacements. Signed-off-by: Paolo Bonzini --- hw/ioapic_common.c | 40 +++++++++++++++++++++++++--------------- hw/ioapic_internal.h | 4 ++-- hw/kvm/ioapic.c | 4 ++-- 3 files changed, 29 insertions(+), 19 deletions(-) diff --git a/hw/ioapic_common.c b/hw/ioapic_common.c index 653eef2..1f3ea37 100644 --- a/hw/ioapic_common.c +++ b/hw/ioapic_common.c @@ -23,7 +23,25 @@ #include "ioapic_internal.h" #include "sysbus.h" -void ioapic_reset_common(DeviceState *dev) +static void ioapic_get(IOAPICCommonState *s) +{ + IOAPICCommonClass *info = IOAPIC_COMMON_GET_CLASS(s); + + if (info->get) { + info->get(s); + } +} + +static void ioapic_put(IOAPICCommonState *s) +{ + IOAPICCommonClass *info = IOAPIC_COMMON_GET_CLASS(s); + + if (info->put) { + info->put(s); + } +} + +static void ioapic_reset_common(DeviceState *dev) { IOAPICCommonState *s = IOAPIC_COMMON(dev); int i; @@ -36,24 +54,16 @@ void ioapic_reset_common(DeviceState *dev) } } -static void ioapic_dispatch_pre_save(void *opaque) +static void ioapic_pre_save(void *opaque) { IOAPICCommonState *s = IOAPIC_COMMON(opaque); - IOAPICCommonClass *info = IOAPIC_COMMON_GET_CLASS(s); - - if (info->pre_save) { - info->pre_save(s); - } + ioapic_get(s); } -static int ioapic_dispatch_post_load(void *opaque, int version_id) +static int ioapic_post_load(void *opaque, int version_id) { IOAPICCommonState *s = IOAPIC_COMMON(opaque); - IOAPICCommonClass *info = IOAPIC_COMMON_GET_CLASS(s); - - if (info->post_load) { - info->post_load(s); - } + ioapic_put(s); return 0; } @@ -81,8 +91,8 @@ static const VMStateDescription vmstate_ioapic_common = { .version_id = 3, .minimum_version_id = 1, .minimum_version_id_old = 1, - .pre_save = ioapic_dispatch_pre_save, - .post_load = ioapic_dispatch_post_load, + .pre_save = ioapic_pre_save, + .post_load = ioapic_post_load, .fields = (VMStateField[]) { VMSTATE_UINT8(id, IOAPICCommonState), VMSTATE_UINT8(ioregsel, IOAPICCommonState), diff --git a/hw/ioapic_internal.h b/hw/ioapic_internal.h index e04c9f3..7311ad0 100644 --- a/hw/ioapic_internal.h +++ b/hw/ioapic_internal.h @@ -84,8 +84,8 @@ typedef struct IOAPICCommonState IOAPICCommonState; typedef struct IOAPICCommonClass { SysBusDeviceClass parent_class; void (*init)(IOAPICCommonState *s, int instance_no); - void (*pre_save)(IOAPICCommonState *s); - void (*post_load)(IOAPICCommonState *s); + void (*get)(IOAPICCommonState *s); + void (*put)(IOAPICCommonState *s); } IOAPICCommonClass; struct IOAPICCommonState { diff --git a/hw/kvm/ioapic.c b/hw/kvm/ioapic.c index 6c3b8fe..03cb36c 100644 --- a/hw/kvm/ioapic.c +++ b/hw/kvm/ioapic.c @@ -104,8 +104,8 @@ static void kvm_ioapic_class_init(ObjectClass *klass, void *data) DeviceClass *dc = DEVICE_CLASS(klass); k->init = kvm_ioapic_init; - k->pre_save = kvm_ioapic_get; - k->post_load = kvm_ioapic_put; + k->get = kvm_ioapic_get; + k->put = kvm_ioapic_put; dc->reset = kvm_ioapic_reset; dc->props = kvm_ioapic_properties; }