Am Donnerstag, 31. Juli 2008 schrieb Avi Kivity: > > +#if defined(__x86_64__) || defined(__i386__) > > +#if defined(KVM_CAP_SET_TSS_ADDR) > > + if (ioctl(kvm->fd, KVM_CHECK_EXTENSION, KVM_CAP_SET_TSS_ADDR) > 0) > > > > Should be <= here?
yes. But with the wrapper you suggest below its again >. > > > + i++; > > +#else > > + i++; > > +#endif > > +#endif > > > > Suggest a helper, kvm_supports_set_tss_addr(), to reduce further > braindamage. Something like that? But then I get the following warning on non-x86: libkvm.c:77: warning: 'kvm_supports_set_tss_addr' defined but not used Should I mask the wrapper with config x86 as well? --- libkvm.c | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) Index: libkvm/libkvm.c =================================================================== --- libkvm.orig/libkvm.c +++ libkvm/libkvm.c @@ -73,27 +73,29 @@ void init_slots(void) slots[i].len = 0; } +static int kvm_supports_set_tss_addr(kvm_context_t kvm) +{ +#if defined(KVM_CAP_SET_TSS_ADDR) + if (ioctl(kvm->fd, KVM_CHECK_EXTENSION, KVM_CAP_SET_TSS_ADDR) > 0) + return 1; +#endif + return 0; +} + int get_free_slot(kvm_context_t kvm) { int i; - int tss_ext; - -#if defined(KVM_CAP_SET_TSS_ADDR) && !defined(__s390__) - tss_ext = ioctl(kvm->fd, KVM_CHECK_EXTENSION, KVM_CAP_SET_TSS_ADDR); -#else - tss_ext = 0; -#endif /* - * on older kernels where the set tss ioctl is not supprted we must save - * slot 0 to hold the extended memory, as the vmx will use the last 3 - * pages of this slot. + * on older x86 kernels where the set tss ioctl is not supported we + * must save slot 0 to hold the extended memory, as the vmx will + * use the last 3 pages of this slot. */ - if (tss_ext > 0) - i = 0; - else - i = 1; - +#if defined(__x86_64__) || defined(__i386__) + i = !kvm_supports_set_tss_addr(kvm); +#else + i = 0; +#endif for (; i < KVM_MAX_NUM_MEM_REGIONS; ++i) if (!slots[i].len) return i; -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html