Re: [PATCH] Fix non-KVM build

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

 



On Wed, Jun 24, 2009 at 01:13:46PM -0500, Anthony Liguori wrote:
> This introduces some #ifdefs in pcspk to fix the build when KVM isn't enabled.
> 
> Signed-off-by: Anthony Liguori <aliguori@xxxxxxxxxx>
> ---
>  hw/pcspk.c |   15 +++++++++------
>  1 files changed, 9 insertions(+), 6 deletions(-)
> 
> diff --git a/hw/pcspk.c b/hw/pcspk.c
> index 9e1b59a..236995a 100644
> --- a/hw/pcspk.c
> +++ b/hw/pcspk.c
> @@ -80,11 +80,6 @@ static void kvm_set_pit_ch2(PITState *pit,
>          kvm_set_pit(kvm_context, inkernel_state);
>      }
>  }
> -#else
> -static inline void kvm_get_pit_ch2(PITState *pit,
> -                                   kvm_pit_state *inkernel_state) { }
> -static inline void kvm_set_pit_ch2(PITState *pit,
> -                                   kvm_pit_state *inkernel_state) { }
>  #endif
>  

The version with stubs looks cleaner to me. IMO we really should be
moving away from ifdefs for features, and only use them for
compiler-specific things.  If for no other reason, then because it
increases the common code that is compiled for all platforms,
decreasing the chance that people submit a patch that does not
build on soe platform.

Is the issue with struct kvm_pit_state?
Can't we just stub it out as well?

struct kvm_pit_state {};

>  static inline void generate_samples(PCSpkState *s)
> @@ -111,7 +106,9 @@ static void pcspk_callback(void *opaque, int free)
>      PCSpkState *s = opaque;
>      unsigned int n;
>  
> +#ifdef USE_KVM_PIT
>      kvm_get_pit_ch2(s->pit, NULL);
> +#endif
>  
>      if (pit_get_mode(s->pit, 2) != 3)
>          return;
> @@ -158,7 +155,9 @@ static uint32_t pcspk_ioport_read(void *opaque, uint32_t addr)
>      PCSpkState *s = opaque;
>      int out;
>  
> +#ifdef USE_KVM_PIT
>      kvm_get_pit_ch2(s->pit, NULL);
> +#endif
>  
>      s->dummy_refresh_clock ^= (1 << 4);
>      out = pit_get_out(s->pit, 2, qemu_get_clock(vm_clock)) << 5;
> @@ -168,11 +167,13 @@ static uint32_t pcspk_ioport_read(void *opaque, uint32_t addr)
>  
>  static void pcspk_ioport_write(void *opaque, uint32_t addr, uint32_t val)
>  {
> -    struct kvm_pit_state inkernel_state;
>      PCSpkState *s = opaque;
>      const int gate = val & 1;
> +#ifdef USE_KVM_PIT
> +    struct kvm_pit_state inkernel_state;
>  
>      kvm_get_pit_ch2(s->pit, &inkernel_state);
> +#endif
>  
>      s->data_on = (val >> 1) & 1;
>      pit_set_gate(s->pit, 2, gate);
> @@ -182,7 +183,9 @@ static void pcspk_ioport_write(void *opaque, uint32_t addr, uint32_t val)
>          AUD_set_active_out(s->voice, gate & s->data_on);
>      }
>  
> +#ifdef USE_KVM_PIT
>      kvm_set_pit_ch2(s->pit, &inkernel_state);
> +#endif
>  }
>  
>  void pcspk_init(PITState *pit)
> -- 
> 1.6.2.5
> 
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@xxxxxxxxxxxxxxx
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[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