Fix to issues with kvm.h and g++
Hello, I am writing a kvm-based emulation framework in c++. When I included linux/kvm.h I got the following errors: /usr/include/linux/kvm.h:89: error: 'struct kvm_run::anonymous union::kvm_io' invalid; an anonymous union can only have non-static data members /usr/include/linux/kvm.h:230: error: declaration of '__u64 kvm_dirty_log::anonymous union::padding' /usr/include/linux/kvm.h:227: error: conflicts with previous declaration '__u32 kvm_dirty_log::padding' /usr/include/linux/kvm.h:89: error: 'struct kvm_run::anonymous union::kvm_io' invalid; an anonymous union can only have non-static data members /usr/include/linux/kvm.h:230: error: declaration of '__u64 kvm_dirty_log::anonymous union::padding' /usr/include/linux/kvm.h:227: error: conflicts with previous declaration '__u32 kvm_dirty_log::padding' It looks like nobody uses struct kvm_io nor in kernel or user space. The same happens with the two padding fields. The following patch fixes the errors: diff --git a/include/linux/kvm.h b/include/linux/kvm.h index 44fd7fa..f357d50 100644 --- a/include/linux/kvm.h +++ b/include/linux/kvm.h @@ -119,7 +119,7 @@ struct kvm_run { __u32 error_code; } ex; /* KVM_EXIT_IO */ - struct kvm_io { + struct { #define KVM_EXIT_IO_IN 0 #define KVM_EXIT_IO_OUT 1 __u8 direction; @@ -238,10 +238,10 @@ struct kvm_debug_guest { /* for KVM_GET_DIRTY_LOG */ struct kvm_dirty_log { __u32 slot; - __u32 padding; + __u32 padding1; union { void __user *dirty_bitmap; /* one bit per page */ - __u64 padding; + __u64 padding2; }; }; Cheers, Daniel -- 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
KVM_CAP_DEVICE_ASSIGNMENT should depend on CONFIG_PCI
Hello, if you compile the kernel with KVM activated and without PCI support you get the following crash: CC arch/x86/kvm/../../../virt/kvm/kvm_main.o arch/x86/kvm/../../../virt/kvm/kvm_main.c: In function 'kvm_free_assigned_device': arch/x86/kvm/../../../virt/kvm/kvm_main.c:155: error: implicit declaration of function 'pci_reset_function' make[1]: *** [arch/x86/kvm/../../../virt/kvm/kvm_main.o] Error 1 make: *** [arch/x86/kvm] Error 2 This can be reproduced by using the attached config file. Obviously the pci_reset_function should not be called when PCI support is disabled. These changes fix the issue: diff --git a/include/linux/kvm.h b/include/linux/kvm.h index 44fd7fa..d93de2c 100644 --- a/include/linux/kvm.h +++ b/include/linux/kvm.h @@ -387,7 +387,7 @@ struct kvm_trace_rec { #define KVM_CAP_MP_STATE 14 #define KVM_CAP_COALESCED_MMIO 15 #define KVM_CAP_SYNC_MMU 16 /* Changes to host mmap are reflected in guest */ -#if defined(CONFIG_X86)||defined(CONFIG_IA64) +#if (defined(CONFIG_X86)||defined(CONFIG_IA64)) defined(CONFIG_PCI) #define KVM_CAP_DEVICE_ASSIGNMENT 17 #endif #define KVM_CAP_IOMMU 18 diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 9a4a39c..0397c65 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -4148,7 +4148,9 @@ static void kvm_free_vcpus(struct kvm *kvm) void kvm_arch_destroy_vm(struct kvm *kvm) { +#ifdef KVM_CAP_DEVICE_ASSIGNMENT kvm_free_all_assigned_devices(kvm); +#endif kvm_iommu_unmap_guest(kvm); kvm_free_pit(kvm); kfree(kvm-arch.vpic); diff --git a/arch/x86/kernel/pci-dma.c b/arch/x86/kernel/pci-dma.c index 1972266..47c5a7a 100644 --- a/arch/x86/kernel/pci-dma.c +++ b/arch/x86/kernel/pci-dma.c @@ -202,6 +202,7 @@ static __init int iommu_setup(char *p) iommu_merge = 0; if (!strncmp(p, forcesac, 8)) iommu_sac_force = 1; +#ifdef CONFIG_PCI if (!strncmp(p, allowdac, 8)) forbid_dac = 0; if (!strncmp(p, nodac, 5)) @@ -210,6 +211,7 @@ static __init int iommu_setup(char *p) forbid_dac = -1; return 1; } +#endif #ifdef CONFIG_SWIOTLB if (!strncmp(p, soft, 4)) swiotlb = 1; Cheers, Daniel test_config Description: Binary data dep_pci.patch Description: Binary data
Re: KVM-74 and network timeout?
Hi, ive been using a JetFlash usb-storage device with kvm-qemu and Windows XP as a guest. I have seen that before setting up the device properly, Windows resets it 5 or 6 times, which makes the process awfully slow. Diving into the code I found that qemu's emulation was not giving the host the right status when there was a babble or stall situation. After applying the following patch the setup time was cut up by a ~200%. Cheers, Daniel --- old/kvm-75/qemu/usb-linux.c 2008-09-07 18:38:33.0 +0200 +++ new/kvm-75/qemu/usb-linux.c 2008-09-18 15:13:47.0 +0200 @@ -208,9 +208,13 @@ p-len = aurb-urb.actual_length; break; +case -EOVERFLOW: + p-len = USB_RET_BABBLE; + break; case -EPIPE: set_halt(s, p-devep); -/* fall through */ +p-len = USB_RET_STALL; + break; default: p-len = USB_RET_NAK; break; usb_fix.patch Description: Binary data