diff mbox

Fix non-KVM build

Message ID 1245867226-30604-1-git-send-email-aliguori@us.ibm.com (mailing list archive)
State New, archived
Headers show

Commit Message

Anthony Liguori June 24, 2009, 6:13 p.m. UTC
This introduces some #ifdefs in pcspk to fix the build when KVM isn't enabled.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
---
 hw/pcspk.c |   15 +++++++++------
 1 files changed, 9 insertions(+), 6 deletions(-)

Comments

Dustin Kirkland June 24, 2009, 7:17 p.m. UTC | #1
On Wed, Jun 24, 2009 at 1:13 PM, Anthony Liguori<aliguori@us.ibm.com> wrote:
> This introduces some #ifdefs in pcspk to fix the build when KVM isn't enabled.
>
> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
> ---
>  hw/pcspk.c |   15 +++++++++------
>  1 files changed, 9 insertions(+), 6 deletions(-)
...

Thanks, Anthony.  This patch does solve my pcspk build breakage, and
gets me a bit further in the build, before:

...
  CC    ppc-softmmu/disas.o
  CC    ppc-softmmu/i386-dis.o
  CC    ppc-softmmu/ppc-dis.o
  AR    ppc-softmmu/libqemu.a
  LINK  ppc-softmmu/qemu-system-ppc
machine.o: In function `cpu_load':
/tmp/tmp.wibDyxlHPK/qemu-kvm-0.10.50.20090624132948/target-ppc/machine.c:180:
undefined reference to `cpu_synchronize_state'
machine.o: In function `cpu_save':
/tmp/tmp.wibDyxlHPK/qemu-kvm-0.10.50.20090624132948/target-ppc/machine.c:10:
undefined reference to `cpu_synchronize_state'
ppc440.o: In function `ppc440ep_init':
/tmp/tmp.wibDyxlHPK/qemu-kvm-0.10.50.20090624132948/hw/ppc440.c:48:
undefined reference to `kvm_enabled'
ppc440_bamboo.o: In function `bamboo_init':
/tmp/tmp.wibDyxlHPK/qemu-kvm-0.10.50.20090624132948/hw/ppc440_bamboo.c:183:
undefined reference to `kvm_enabled'
/tmp/tmp.wibDyxlHPK/qemu-kvm-0.10.50.20090624132948/hw/ppc440_bamboo.c:184:
undefined reference to `kvmppc_init'
ppce500_mpc8544ds.o: In function `mpc8544ds_init':
/tmp/tmp.wibDyxlHPK/qemu-kvm-0.10.50.20090624132948/hw/ppce500_mpc8544ds.c:277:
undefined reference to `kvm_enabled'
/tmp/tmp.wibDyxlHPK/qemu-kvm-0.10.50.20090624132948/hw/ppce500_mpc8544ds.c:278:
undefined reference to `kvmppc_init'
libqemu.a(helper.o): In function `ppc_tlb_invalidate_all':
/tmp/tmp.wibDyxlHPK/qemu-kvm-0.10.50.20090624132948/target-ppc/helper.c:1861:
undefined reference to `kvm_enabled'
collect2: ld returned 1 exit status
make[2]: *** [qemu-system-ppc] Error 1
make[1]: *** [subdir-ppc-softmmu] Error 2


:-Dustin
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Michael S. Tsirkin July 15, 2009, 5:53 p.m. UTC | #2
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@us.ibm.com>
> ---
>  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@vger.kernel.org
> 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@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Jan Kiszka July 16, 2009, 8:54 a.m. UTC | #3
Michael S. Tsirkin wrote:
> 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@us.ibm.com>
>> ---
>>  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 {};

It's solved like that in current git. Do you still face problems?

Jan
diff mbox

Patch

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
 
 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)