On Fri, Apr 12, 2013 at 01:17:32PM +0200, Igor Mammedov wrote:
[...]
> >
> > > #include "qemu-common.h"
> > > #include "hw/pci/pci.h"
> > >
> > > @@ -47,4 +48,5 @@ static inline bool msi_present(const PCIDevice *dev)
> > > return dev->cap_present & QEMU_PCI_CAP_MSI;
> > > }
> > >
> > > +#endif
> > > #endif /* QEMU_MSI_H */
> > > diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h
> > > index 495e6f8..93cef28 100644
> > > --- a/include/sysemu/kvm.h
> > > +++ b/include/sysemu/kvm.h
> > > @@ -144,10 +144,10 @@ int kvm_cpu_exec(CPUArchState *env);
> > > #if !defined(CONFIG_USER_ONLY)
> > > void *kvm_vmalloc(ram_addr_t size);
> > > void *kvm_arch_vmalloc(ram_addr_t size);
> > > -void kvm_setup_guest_memory(void *start, size_t size);
> > > +#endif
> > >
> > > +void kvm_setup_guest_memory(void *start, size_t size);
> > > void kvm_flush_coalesced_mmio_buffer(void);
> > > -#endif
> > >
> > > int kvm_insert_breakpoint(CPUArchState *current_env, target_ulong addr,
> > > target_ulong len, int type);
> > > diff --git a/kvm-stub.c b/kvm-stub.c
> > > index 82875dd..b34064a 100644
> > > --- a/kvm-stub.c
> > > +++ b/kvm-stub.c
> > > @@ -122,6 +122,7 @@ int kvm_on_sigbus(int code, void *addr)
> > > return 1;
> > > }
> > >
> > > +#ifndef CONFIG_USER_ONLY
> > > int kvm_irqchip_add_msi_route(KVMState *s, MSIMessage msg)
> > > {
> > > return -ENOSYS;
> > > @@ -145,3 +146,4 @@ int kvm_irqchip_remove_irqfd_notifier(KVMState *s,
> > > EventNotifier *n, int virq)
> > > {
> > > return -ENOSYS;
> > > }
> > > +#endif
> >
> > What about making MSIMessage definition available on CONFIG_USER_ONLY,
> > so we don't even need to #ifdef this part?
>
> it might work, but it causes #includes split which I don't like much.
> Anyway here is patch on top of this one. If it looks more acceptable to you
> this way, I'll merge it.
OK, I believe I prefer your original patch. :-)
Having extra CONFIG_USER_ONLY #ifdefs in kvm-stub.c sounds simpler and
better than reordering #include lines to appear below declarations in
pci/msi.h like you did below.
>
> ---
>
> diff --git a/include/hw/pci/msi.h b/include/hw/pci/msi.h
> index d4d0450..c159a15 100644
> --- a/include/hw/pci/msi.h
> +++ b/include/hw/pci/msi.h
> @@ -21,15 +21,15 @@
> #ifndef QEMU_MSI_H
> #define QEMU_MSI_H
>
> -#ifndef CONFIG_USER_ONLY
> #include "qemu-common.h"
By the way, have you tried to eliminate the qemu-common.h include above?
(not important now, but asking just in case you have tried and found issues)
> -#include "hw/pci/pci.h"
>
> struct MSIMessage {
> uint64_t address;
> uint32_t data;
> };
>
> +#ifndef CONFIG_USER_ONLY
> +#include "hw/pci/pci.h"
> extern bool msi_supported;
>
> void msi_set_message(PCIDevice *dev, MSIMessage msg);
> diff --git a/kvm-stub.c b/kvm-stub.c
> index 8cb81c4..b5d4446 100644
> --- a/kvm-stub.c
> +++ b/kvm-stub.c
> @@ -123,7 +123,6 @@ int kvm_on_sigbus(int code, void *addr)
> return 1;
> }
>
> -#ifndef CONFIG_USER_ONLY
> int kvm_irqchip_add_msi_route(KVMState *s, MSIMessage msg)
> {
> return -ENOSYS;
> @@ -147,4 +146,3 @@ int kvm_irqchip_remove_irqfd_notifier(KVMState *s,
> EventNotifier *n, int virq)
> {
> return -ENOSYS;
> }
> -#endif
>
> >
> > --
> > Eduardo
>
>
> --
> Regards,
> Igor
--
Eduardo