Re: [PATCH 4/3] ioapic: change pre_save/post_load methods to get/put

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2012-10-30 13:16, Paolo Bonzini wrote:
> 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.

Also here: I don't see a benefit and prefer the current style.

Jan

> 
> Signed-off-by: Paolo Bonzini <pbonzini@xxxxxxxxxx>
> ---
>  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;
>  }
> 


Attachment: signature.asc
Description: OpenPGP digital signature


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux