[PATCH] KVM: Device Assignment: Free device structures if IRQ allocation fails
When an IRQ allocation fails, we free up the device structures and disable the device so that we can unregister the device in the userspace and not expose it to the guest at all. Signed-off-by: Amit Shah [EMAIL PROTECTED] --- arch/x86/kvm/x86.c | 86 +++- 1 files changed, 45 insertions(+), 41 deletions(-) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 2134f3e..ba37e15 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -165,6 +165,43 @@ static void kvm_assigned_dev_ack_irq(struct kvm_irq_ack_notifier *kian) enable_irq(dev-host_irq); } +static void kvm_free_assigned_device(struct kvm *kvm, +struct kvm_assigned_dev_kernel +*assigned_dev) +{ + if (irqchip_in_kernel(kvm) assigned_dev-irq_requested) + free_irq(assigned_dev-host_irq, (void *)assigned_dev); + + kvm_unregister_irq_ack_notifier(kvm, assigned_dev-ack_notifier); + + if (cancel_work_sync(assigned_dev-interrupt_work)) + /* We had pending work. That means we will have to take +* care of kvm_put_kvm. +*/ + kvm_put_kvm(kvm); + + pci_release_regions(assigned_dev-dev); + pci_disable_device(assigned_dev-dev); + pci_dev_put(assigned_dev-dev); + + list_del(assigned_dev-list); + kfree(assigned_dev); +} + +static void kvm_free_all_assigned_devices(struct kvm *kvm) +{ + struct list_head *ptr, *ptr2; + struct kvm_assigned_dev_kernel *assigned_dev; + + list_for_each_safe(ptr, ptr2, kvm-arch.assigned_dev_head) { + assigned_dev = list_entry(ptr, + struct kvm_assigned_dev_kernel, + list); + + kvm_free_assigned_device(kvm, assigned_dev); + } +} + static int kvm_vm_ioctl_assign_irq(struct kvm *kvm, struct kvm_assigned_irq *assigned_irq) @@ -193,8 +230,8 @@ static int kvm_vm_ioctl_assign_irq(struct kvm *kvm, if (irqchip_in_kernel(kvm)) { if (!capable(CAP_SYS_RAWIO)) { - return -EPERM; - goto out; + r = -EPERM; + goto out_release; } if (assigned_irq-host_irq) @@ -213,17 +250,18 @@ static int kvm_vm_ioctl_assign_irq(struct kvm *kvm, */ if (request_irq(match-host_irq, kvm_assigned_dev_intr, 0, kvm_assigned_device, (void *)match)) { - printk(KERN_INFO %s: couldn't allocate irq for pv - device\n, __func__); r = -EIO; - goto out; + goto out_release; } } match-irq_requested = true; -out: mutex_unlock(kvm-lock); return r; +out_release: + mutex_unlock(kvm-lock); + kvm_free_assigned_device(kvm, match); + return r; } static int kvm_vm_ioctl_assign_device(struct kvm *kvm, @@ -290,40 +328,6 @@ out_free: return r; } -static void kvm_free_assigned_devices(struct kvm *kvm) -{ - struct list_head *ptr, *ptr2; - struct kvm_assigned_dev_kernel *assigned_dev; - - list_for_each_safe(ptr, ptr2, kvm-arch.assigned_dev_head) { - assigned_dev = list_entry(ptr, - struct kvm_assigned_dev_kernel, - list); - - if (irqchip_in_kernel(kvm) assigned_dev-irq_requested) { - free_irq(assigned_dev-host_irq, -(void *)assigned_dev); - - kvm_unregister_irq_ack_notifier(kvm, - assigned_dev- - ack_notifier); - } - - if (cancel_work_sync(assigned_dev-interrupt_work)) - /* We had pending work. That means we will have to take -* care of kvm_put_kvm. -*/ - kvm_put_kvm(kvm); - - pci_release_regions(assigned_dev-dev); - pci_disable_device(assigned_dev-dev); - pci_dev_put(assigned_dev-dev); - - list_del(assigned_dev-list); - kfree(assigned_dev); - } -} - unsigned long segment_base(u16 selector) { struct descriptor_table gdt; @@ -4282,7 +4286,7 @@ static void kvm_free_vcpus(struct kvm *kvm) void kvm_arch_destroy_vm(struct kvm *kvm) { - kvm_free_assigned_devices(kvm); + kvm_free_all_assigned_devices(kvm); kvm_free_pit(kvm); kfree(kvm-arch.vpic); kfree(kvm-arch.vioapic); -- 1.5.4.3 -- To
Re: kvm userland: Build misses -I kernel include dir
Ben Bucksch wrote: Reason is, as said, that the build assumes that /usr/include/linux/ioctl.h exists, i.e. it just #include linux/ioctl.h Oh, that's not nice. Certainly for me /usr/include/linux will never point to the kernel I'm building against so that's just a problem waiting to happen. , but does not pass the kernel dir *that I explicitly passed to configure* to gcc. If I explicitly pass the kernel dir to configure, I expect that to be used, and only that. Seconded. Especially when building external modules the only path being used should be the one passed in as the KERNELDIR I want to build against. Using /usr/include/linux or something under /lib/modules/$(uname -r)/build is fraught with problems. iggy on IRC noted that kernel source and build dir may be separate. That's true - you probably need two configure flags --kernel-source-dir and --kernel-build-dir. The existing --kerneldir could stay and set both to the same value. That's the issue I found with kvm-74, building the kernel with O= to have seperate source and build dirs fails as the makefile for the external kvm modules assumes that isn't an option. There's a very minimal patch to get that working in this post: http://article.gmane.org/gmane.comp.emulators.kvm.devel/21172 Iain -- 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
Weekly KVM Test report, kernel 2d7a0999 ... userspace 5925d8e5 ... -- One new issue
Hi All, This is our Weekly KVM Testing Report against lastest kvm.git 2d7a06ff26576b1918dfe8e25ba4ffdfc24e and kvm-userspace.git 5925d8e58d1fa4668351b157d9635be016794c79. There is one new issue found, Fail to save restore and live migration which blocks our SR/LM cases. And EPT and VPID testing result is included into our weekly testing report from this week. One New issue: 1. Fail to save restore and live migration https://sourceforge.net/tracker/index.php?func=detailaid=2106661group_id=180599atid=893831 Three Old Issues: 1. 32bits Rhel5/FC6 guest may fail to reboot after installation https://sourceforge.net/tracker/?func=detailatid=893831aid=1991647group_id=180599 2. failure to migrate guests with more than 4GB of RAM https://sourceforge.net/tracker/index.php?func=detailaid=1971512group_id=180599atid=893831 3. OpenSuse10.2 can not be installed http://sourceforge.net/tracker/index.php?func=detailaid=2088475group_id=180599atid=893831 Test environment Platform A Stoakley/Clovertown CPU 4 Memory size 8G' Platform B Nehalem CPU 8 Memory size 4G' Details IA32-pae: 1. boot guest with 256M memory PASS 2. boot guest with 1500M memory PASS 3. boot 4 same guest in parallelPASS 4. boot two windows xp guestPASS 5. boot linux and windows guest in parallel PASS 6. save/restore 32-bit HVM guests FAIL 7. save/restore 32-bit HVM guests with 4 vcpus FAIL 8. live migration 32-bit HVM guests FAIL 9. live migration 32-bit HVM guests with 4 vcpusFAIL 10. boot base kernel linux PASS 11. kernel build on SMP linux guest PASS 12. LTP on linux guest PASS 13. boot Windows 2000 without ACPIPASS 14. boot Windows 2000 with ACPI enabledPASS 15. boot Windows 2003 with ACPI enabled PASS 16. boot Windows xp with ACPI enabled PASS 17. boot Windows vista with ACPI enabledPASS 18. boot SMP Windows 2000 with ACPI enabled PASS 19. boot SMP Windows 2003 with ACPI enabled PASS 20. boot SMP Windows xp with ACPI enabled PASS 21. boot SMP Windows 2008 with ACPI enabled PASS IA32e: 1. boot 32-bit guest with 256M memory PASS 2. boot 64-bit guest with 256M memory PASS 3. boot 32-bit guest with 1500M memory PASS 4. boot 64-bit guest with 1500M memory PASS 5. boot 4G pae guest PASS 6. boot 4G 64-bit guest PASS 7. boot four 32-bit guest in parallel PASS 8. boot four 64-bit guest in parallel PASS 9. boot two 32-bit windows xp in parallelPASS 10. boot 32-bit linux and 32 bit windows guest in parallel PASS 11. boot four 32-bit different guest in para PASS 12. save/restore 32-bit linux guestsFAIL 13. save/restore 64-bit linux guestsFAIL 14. save/restore 64-bit linux guests with 4 vcpus FAIL 15. save/restore 32-bit linux guests with 4 vcpus FAIL 16. live migration 64bit linux guests FAIL 17. live migration 32bit linux guests FAIL 18. live migration 64bit linux guests with 4 vcpus FAIL 19. live migration 32bit linux guests with 4 vcpus FAIL 20. boot 32-bit x-server PASS 21. kernel build in 32-bit linux guest OSPASS 22. kernel build in 64-bit linux guest OSPASS 23. LTP on 32-bit linux guest OS PASS 24. LTP on 64-bit linux guest OS PASS 25. boot 64-bit guests with ACPI enabled PASS 26. boot 32-bit Windows 2000 without ACPIPASS 27. boot 32-bit Windows xp without ACPI PASS 28. boot 64-bit Windows xp with ACPI enabled PASS 29.
Re: [PATCH] usb: Support for removing device by host addr, improved auto filter syntax
Anthony Liguori wrote: Max Krasnyansky wrote: This patch adds support for removing USB devices by host address. Which is usefull for things like libvirtd because there is no easy way to find guest USB address of the host device. In other words you can now do: usb_add host:3.5 ... usb_del host:3.5 Before the patch 'usb_del' did not support 'host:' notation. Applied. Thanks. BTW, I was able to program my harmony remote with QEMU after your last patch series. This brought me great joy as I do not currently have access to a physical Windows system :-) Yeah most of the devices I have did not work before. Now it's exactly the opposite, I cannot seem to find a device that does not work :). Even those that require firmware download (they reset and remunerate after fw is loaded), with the right set of auto filters QEMU just grabs them after reset and things work just fine. And once we get EHCI going it'll be even better (BW wise that is). Thanx for commiting the patches. Max -- 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
Re: Network Overruns
What is the oldest version that doesn't work? (i.e. when was the regression introduced?) I can (almost) be sure the kvm-70 did not have stalls and that kvm 73 certainly has this problem. Never tried 71 and I am not sure about 72 (haven't ran it for long time and upgraded to 73) -- 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
Re: Need help with windows debug tools - HPET problems on win2k864
On Sat, 2008-09-13 at 07:50 +0300, Avi Kivity wrote: Beth Kon wrote: I ran into trouble trying to get the hpet working with win2k864. It hangs very early on (black screen with Windows is loading Files at the bottom). My guess is there are problems with our acpi/bios changes, since they introduce some ACPI 2.0 structures and QEMU/KVM supports ACPI 1.0. We may not have enough 2.0 infrastructure to get it working right for 64 bit. Win2k832 does work with the hpet, but 64 doesn't. So! I need to figure out how to debug Windows and Anthony suggested that there may be some people with experience here. Something that's worked for me is to enable memory dump triggered by ctrl-ctrl-scroll-lock. There's some registry key you set, and on the next hang you can generate a memory dump, which you can then analyze with windbg. Of course, your hang might well occur earlier than disk driver initialization, so this is not bulletproof. The problem is, I've been told (and confirmed with a test) I can't add the hpet after windows is installed. It needs to be present for installation, and I'm getting the black screen at the start of the install. So there is no registry to play with yet. My guess is this is just too early to get useful debug, though I was hoping a checked build would provide information over the serial port even during install. I'll keep trying to see if there's a way to make that happen. Did you need a host and target for the kind of memory dump analysis you did? Or just use windbg on a local dump file? I ask because I'm trying to figure out if the -serial pty and -serial /dev/pts/0 is the right way to set up the null modem cable between 2 guests. -- Elizabeth Kon (Beth) IBM Linux Technology Center Open Hypervisor Team email: [EMAIL PROTECTED] -- 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