[PATCHv5] uio: add generic driver for PCI 2.3 devices
This adds a generic uio driver that can bind to any PCI device. First user will be virtualization where a qemu userspace process needs to give guest OS access to the device. Interrupts are handled using the Interrupt Disable bit in the PCI command register and Interrupt Status bit in the PCI status register. All devices compliant to PCI 2.3 (circa 2002) and all compliant PCI Express devices should support these bits. Driver detects this support, and won't bind to devices which do not support the Interrupt Disable Bit in the command register. It's expected that more features of interest to virtualization will be added to this driver in the future. Possibilities are: mmap for device resources, MSI/MSI-X, eventfd (to interface with kvm), iommu. Signed-off-by: Michael S. Tsirkin m...@redhat.com Acked-by: Chris Wright chr...@redhat.com Signed-off-by: Hans J. Koch h...@linutronix.de --- Greg, here's a combined patch including documentation, for upstream inclusion. This is intended to solve the problem in virtualization that shared interrupts do not work with assigned devices. Earlier versions of this patch have circulated on k...@vger. Changes since v4: - add documentation in Docbook format Changes since v3: - minor driver version fix Changes since v2: - remove irqcontrol: user can enable interrupts by writing command register directly - don't claim resources as we don't support mmap yet, but note the intent to do so in the commit log Changes since v1: - some naming changes - do a single read to get both command and status register Documentation/DocBook/uio-howto.tmpl | 163 ++ MAINTAINERS |8 ++ drivers/uio/Kconfig | 10 ++ drivers/uio/Makefile |1 + drivers/uio/uio_pci_generic.c| 207 ++ include/linux/pci_regs.h |1 + 6 files changed, 390 insertions(+), 0 deletions(-) create mode 100644 drivers/uio/uio_pci_generic.c diff --git a/Documentation/DocBook/uio-howto.tmpl b/Documentation/DocBook/uio-howto.tmpl index 8f6e3b2..4d4ce0e 100644 --- a/Documentation/DocBook/uio-howto.tmpl +++ b/Documentation/DocBook/uio-howto.tmpl @@ -25,6 +25,10 @@ year2006-2008/year holderHans-Jürgen Koch./holder /copyright +copyright + year2009/year + holderRed Hat Inc, Michael S. Tsirkin (m...@redhat.com)/holder +/copyright legalnotice para @@ -42,6 +46,13 @@ GPL version 2. revhistory revision + revnumber0.9/revnumber + date2009-07-16/date + authorinitialsmst/authorinitials + revremarkAdded generic pci driver + /revremark + /revision + revision revnumber0.8/revnumber date2008-12-24/date authorinitialshjk/authorinitials @@ -809,6 +820,158 @@ framework to set up sysfs files for this region. Simply leave it alone. /chapter +chapter id=uio_pci_generic xreflabel=Using Generic driver for PCI cards +?dbhtml filename=uio_pci_generic.html? +titleGeneric PCI UIO driver/title + para + The generic driver is a kernel module named uio_pci_generic. + It can work with any device compliant to PCI 2.3 (circa 2002) and + any compliant PCI Express device. Using this, you only need to +write the userspace driver, removing the need to write +a hardware-specific kernel module. + /para + +sect1 id=uio_pci_generic_binding +titleMaking the driver recognize the device/title + para +Since the driver does not declare any device ids, it will not get loaded +automatically and will not automatically bind to any devices, you must load it +and allocate id to the driver yourself. For example: + programlisting + modprobe uio_pci_generic + echo quot;8086 10f5quot; gt; /sys/bus/pci/drivers/uio_pci_generic/new_id + /programlisting + /para + para +If there already is a hardware specific kernel driver for your device, the +generic driver still won't bind to it, in this case if you want to use the +generic driver (why would you?) you'll have to manually unbind the hardware +specific driver and bind the generic driver, like this: + programlisting +echo -n :00:19.0 gt; /sys/bus/pci/drivers/e1000e/unbind +echo -n :00:19.0 gt; /sys/bus/pci/drivers/uio_pci_generic/bind + /programlisting + /para + para +You can verify that the device has been bound to the driver +by looking for it in sysfs, for example like the following: + programlisting +ls -l /sys/bus/pci/devices/:00:19.0/driver + /programlisting +Which if successful should print + programlisting + .../:00:19.0/driver -gt; ../../../bus/pci/drivers/uio_pci_generic + /programlisting +Note that the generic driver will not bind to old PCI 2.2 devices. +If binding the device failed, run the following command: + programlisting + dmesg + /programlisting +and look in the output for
[PATCH 1/2] KVM: Introduce KVM_SET_IDENTITY_MAP_ADDR ioctl
Now KVM allow guest to modify guest's physical address of EPT's identity mapping page. (discard uncessary check when setting address) Signed-off-by: Sheng Yang sh...@linux.intel.com --- arch/x86/include/asm/kvm_host.h |1 + arch/x86/kvm/vmx.c | 13 + arch/x86/kvm/x86.c | 13 + include/linux/kvm.h |2 ++ 4 files changed, 25 insertions(+), 4 deletions(-) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index 08732d7..e210b21 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -411,6 +411,7 @@ struct kvm_arch{ struct page *ept_identity_pagetable; bool ept_identity_pagetable_done; + gpa_t ept_identity_map_addr; unsigned long irq_sources_bitmap; unsigned long irq_states[KVM_IOAPIC_NUM_PINS]; diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 3a75db3..4ffc4c3 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -1719,7 +1719,7 @@ static void vmx_set_cr3(struct kvm_vcpu *vcpu, unsigned long cr3) eptp = construct_eptp(cr3); vmcs_write64(EPT_POINTER, eptp); guest_cr3 = is_paging(vcpu) ? vcpu-arch.cr3 : - VMX_EPT_IDENTITY_PAGETABLE_ADDR; + vcpu-kvm-arch.ept_identity_map_addr; } vmx_flush_tlb(vcpu); @@ -2122,7 +2122,7 @@ static int init_rmode_identity_map(struct kvm *kvm) if (likely(kvm-arch.ept_identity_pagetable_done)) return 1; ret = 0; - identity_map_pfn = VMX_EPT_IDENTITY_PAGETABLE_ADDR PAGE_SHIFT; + identity_map_pfn = kvm-arch.ept_identity_map_addr PAGE_SHIFT; r = kvm_clear_guest_page(kvm, identity_map_pfn, 0, PAGE_SIZE); if (r 0) goto out; @@ -2191,7 +2191,8 @@ static int alloc_identity_pagetable(struct kvm *kvm) goto out; kvm_userspace_mem.slot = IDENTITY_PAGETABLE_PRIVATE_MEMSLOT; kvm_userspace_mem.flags = 0; - kvm_userspace_mem.guest_phys_addr = VMX_EPT_IDENTITY_PAGETABLE_ADDR; + kvm_userspace_mem.guest_phys_addr = + kvm-arch.ept_identity_map_addr; kvm_userspace_mem.memory_size = PAGE_SIZE; r = __kvm_set_memory_region(kvm, kvm_userspace_mem, 0); if (r) @@ -3814,9 +3815,13 @@ static struct kvm_vcpu *vmx_create_vcpu(struct kvm *kvm, unsigned int id) if (alloc_apic_access_page(kvm) != 0) goto free_vmcs; - if (enable_ept) + if (enable_ept) { + if (!kvm-arch.ept_identity_map_addr) + kvm-arch.ept_identity_map_addr = + VMX_EPT_IDENTITY_PAGETABLE_ADDR; if (alloc_identity_pagetable(kvm) != 0) goto free_vmcs; + } return vmx-vcpu; diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 48567fa..22df92e 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -1208,6 +1208,7 @@ int kvm_dev_ioctl_check_extension(long ext) case KVM_CAP_IOEVENTFD: case KVM_CAP_PIT2: case KVM_CAP_PIT_STATE2: + case KVM_CAP_SET_IDENTITY_MAP_ADDR: r = 1; break; case KVM_CAP_COALESCED_MMIO: @@ -1908,6 +1909,13 @@ static int kvm_vm_ioctl_set_tss_addr(struct kvm *kvm, unsigned long addr) return ret; } +static int kvm_vm_ioctl_set_identity_map_addr(struct kvm *kvm, + unsigned long addr) +{ + kvm-arch.ept_identity_map_addr = addr; + return 0; +} + static int kvm_vm_ioctl_set_nr_mmu_pages(struct kvm *kvm, u32 kvm_nr_mmu_pages) { @@ -2171,6 +2179,11 @@ long kvm_arch_vm_ioctl(struct file *filp, if (r 0) goto out; break; + case KVM_SET_IDENTITY_MAP_ADDR: + r = kvm_vm_ioctl_set_identity_map_addr(kvm, arg); + if (r 0) + goto out; + break; case KVM_SET_MEMORY_REGION: { struct kvm_memory_region kvm_mem; struct kvm_userspace_memory_region kvm_userspace_mem; diff --git a/include/linux/kvm.h b/include/linux/kvm.h index 230a91a..4266b0a 100644 --- a/include/linux/kvm.h +++ b/include/linux/kvm.h @@ -435,6 +435,7 @@ struct kvm_ioeventfd { #define KVM_CAP_PIT_STATE2 35 #endif #define KVM_CAP_IOEVENTFD 36 +#define KVM_CAP_SET_IDENTITY_MAP_ADDR 37 #ifdef KVM_CAP_IRQ_ROUTING @@ -512,6 +513,7 @@ struct kvm_irqfd { #define KVM_SET_USER_MEMORY_REGION _IOW(KVMIO, 0x46,\ struct kvm_userspace_memory_region) #define KVM_SET_TSS_ADDR _IO(KVMIO, 0x47) +#define KVM_SET_IDENTITY_MAP_ADDR _IO(KVMIO, 0x48) /* Device model IOC */ #define KVM_CREATE_IRQCHIP _IO(KVMIO, 0x60) #define KVM_IRQ_LINE _IOW(KVMIO,
[PATCH] kvm: Drop obsolete cpu_get/put in make_all_cpus_request
spin_lock disables preemption, so we can simply read the current cpu. Signed-off-by: Jan Kiszka jan.kis...@siemens.com --- virt/kvm/kvm_main.c |3 +-- 1 files changed, 1 insertions(+), 2 deletions(-) diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 7cd1c10..98e4ec8 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -741,8 +741,8 @@ static bool make_all_cpus_request(struct kvm *kvm, unsigned int req) if (alloc_cpumask_var(cpus, GFP_ATOMIC)) cpumask_clear(cpus); - me = get_cpu(); spin_lock(kvm-requests_lock); + me = smp_processor_id(); kvm_for_each_vcpu(i, vcpu, kvm) { if (test_and_set_bit(req, vcpu-requests)) continue; @@ -757,7 +757,6 @@ static bool make_all_cpus_request(struct kvm *kvm, unsigned int req) else called = false; spin_unlock(kvm-requests_lock); - put_cpu(); free_cpumask_var(cpus); return called; } -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
RE: KVM vs Xen/OpenVZ for VPS hosting business
-Original Message- From: kvm-ow...@vger.kernel.org [mailto:kvm-ow...@vger.kernel.org] On Behalf Of howard chen Sent: Sonntag, 19. Juli 2009 11:47 To: kvm@vger.kernel.org Subject: KVM vs Xen/OpenVZ for VPS hosting business Hello, Currently both Xen and OpenVZ are well known and mature product used in hosting companies. How about KVM? What are the advantages if I use KVM as the VPS solution? If I would start a new hosting business I would offer container and full virtualization because of the following (just a few considerations): OpenVZ (or any other container virtualization in general): - you can run more VPS per physical host, but only Linux as guest - much better resource controls, but only for older kernels (last stable is 2.6.18) - very easy management tools for hosting scenarios - stable environment with third party management tools for hosting KVM (or full virtualization in general): - full guest support (windows, linux, bsd, opensolaris) - easier management tools compared to XEN - compete with high quality VMware ESX hosting offerings (include HA, failover, etc.) I would not choose XEN now for new business, as for me it is not clear if XEN is still here in such a prominent manner in a few years as most distribution moving to KVM. Br, Martin E.g. performance? security? maintainity? I am not familar with KVM so want to know your opinion. Thanks. -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@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 majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] enable x2APIC without interrupt remapping under KVM
KVM would like to provide x2APIC interface to a guest without emulating interrupt remapping device. The reason KVM prefers guest to use x2APIC is that x2APIC interface is better virtualizable and provides better performance than mmio xAPIC interface: - msr exits are faster than mmio (no page table walk, emulation) - no need to read back ICR to look at the busy bit - one 64 bit ICR write instead of two 32 bit writes - shared code with the Hyper-V paravirt interface Included patch changes x2APIC enabling logic to enable it even if IR initialization failed, but kernel runs under KVM and no apic id is greater than 255 (if there is one spec requires BIOS to move to x2apic mode before starting an OS). Signed-off-by: Gleb Natapov g...@redhat.com Acked-by: Suresh Siddha suresh.b.sid...@intel.com --- This is based on x86 tree commit ff78d570fae with Ingo comments addressed (comment formatting, print error on alloc failure, shorter error messages). diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c index 0a1c283..a79e8a9 100644 --- a/arch/x86/kernel/apic/apic.c +++ b/arch/x86/kernel/apic/apic.c @@ -49,6 +49,7 @@ #include asm/mtrr.h #include asm/smp.h #include asm/mce.h +#include asm/kvm_para.h unsigned int num_processors; @@ -1361,52 +1362,76 @@ void enable_x2apic(void) } #endif /* CONFIG_X86_X2APIC */ -void __init enable_IR_x2apic(void) +int __init enable_IR(void) { #ifdef CONFIG_INTR_REMAP int ret; - unsigned long flags; - struct IO_APIC_route_entry **ioapic_entries = NULL; ret = dmar_table_init(); if (ret) { pr_debug(dmar_table_init() failed with %d:\n, ret); - goto ir_failed; + return 0; } if (!intr_remapping_supported()) { pr_debug(intr-remapping not supported\n); - goto ir_failed; + return 0; } - if (!x2apic_preenabled skip_ioapic_setup) { pr_info(Skipped enabling intr-remap because of skipping io-apic setup\n); - return; + return 0; } + if (enable_intr_remapping(x2apic_supported())) + return 0; + + pr_info(Enabled Interrupt-remapping\n); + + return 1; + +#endif + return 0; +} + +void __init enable_IR_x2apic(void) +{ + unsigned long flags; + struct IO_APIC_route_entry **ioapic_entries = NULL; + int ret, x2apic_enabled = 0; + ioapic_entries = alloc_ioapic_entries(); if (!ioapic_entries) { - pr_info(Allocate ioapic_entries failed: %d\n, ret); - goto end; + pr_err(Allocate ioapic_entries failed\n); + goto out; } ret = save_IO_APIC_setup(ioapic_entries); if (ret) { pr_info(Saving IO-APIC state failed: %d\n, ret); - goto end; + goto out; } local_irq_save(flags); - mask_IO_APIC_setup(ioapic_entries); mask_8259A(); + mask_IO_APIC_setup(ioapic_entries); - ret = enable_intr_remapping(x2apic_supported()); - if (ret) - goto end_restore; + ret = enable_IR(); + if (!ret) { + /* IR is required if there is APIC ID 255 even when running +* under KVM +*/ + if (max_physical_apicid 255 || !kvm_para_available()) + goto nox2apic; + /* +* without IR all CPUs can be addressed by IOAPIC/MSI +* only in physical mode +*/ + x2apic_phys = 1; + } - pr_info(Enabled Interrupt-remapping\n); + x2apic_enabled = 1; if (x2apic_supported() !x2apic_mode) { x2apic_mode = 1; @@ -1414,41 +1439,25 @@ void __init enable_IR_x2apic(void) pr_info(Enabled x2apic\n); } -end_restore: - if (ret) - /* -* IR enabling failed -*/ +nox2apic: + if (!ret) /* IR enabling failed */ restore_IO_APIC_setup(ioapic_entries); - unmask_8259A(); local_irq_restore(flags); -end: +out: if (ioapic_entries) free_ioapic_entries(ioapic_entries); - if (!ret) + if (x2apic_enabled) return; -ir_failed: if (x2apic_preenabled) - panic(x2apic enabled by bios. But IR enabling failed); + panic(x2apic: enabled by BIOS but kernel init failed.); else if (cpu_has_x2apic) - pr_info(Not enabling x2apic,Intr-remapping\n); -#else - if (!cpu_has_x2apic) - return; - - if (x2apic_preenabled) - panic(x2apic enabled prior OS handover, - enable CONFIG_X86_X2APIC, CONFIG_INTR_REMAP); -#endif - - return; + pr_info(Not enabling x2apic, Intr-remapping
Re: [PATCH] Add UUID option into kvm command line
On Fri, 2009-07-17 at 23:17 +0800, Yolkfull Chow wrote: Signed-off-by: Yolkfull Chow yz...@redhat.com --- client/tests/kvm/kvm_vm.py | 24 1 files changed, 24 insertions(+), 0 deletions(-) Ok, I've followed the discussion around this patch, thanks Yolkfull and Michael. Applied. diff --git a/client/tests/kvm/kvm_vm.py b/client/tests/kvm/kvm_vm.py index 503f636..48f2916 100644 --- a/client/tests/kvm/kvm_vm.py +++ b/client/tests/kvm/kvm_vm.py @@ -107,6 +107,7 @@ class VM: @param iso_dir: The directory where ISOs reside self.pid = None +self.uuid = None self.name = name self.params = params @@ -287,6 +288,11 @@ class VM: elif params.get(display) == nographic: qemu_cmd += -nographic +if params.get(uuid) == random: +qemu_cmd += -uuid %s % self.uuid +elif params.get(uuid): +qemu_cmd += -uuid %s % params.get(uuid) + return qemu_cmd @@ -371,6 +377,12 @@ class VM: if params.get(display) == vnc: self.vnc_port = kvm_utils.find_free_port(5900, 6000) +# Find random UUID if specified 'uuid = random' in config file +if params.get(uuid) == random: +f = open(/proc/sys/kernel/random/uuid) +self.uuid = f.read().strip() +f.close() + # Make qemu command qemu_command = self.make_qemu_command() @@ -732,3 +744,15 @@ class VM: self.send_key(shift-%s % char.lower()) else: self.send_key(char) + + +def get_uuid(self): + +Catch UUID of the VM. + +@return: None,if not specified in config file + +if self.params.get(uuid) == random: +return self.uuid +else: +return self.params.get(uuid, None) -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [KVM_AUTOTEST] add kvm hugepage variant
On Fri, 2009-07-10 at 12:01 +0200, Lukáš Doktor wrote: After discussion I split the patches. Hi Lukáš, sorry for the delay answering your patch. Looks good to me in general, I have some remarks to make: 1) When posting patches to the autotest kvm tests, please cross post the autotest mailing list (autot...@test.kernel.org) and the KVM list. 2) About scripts to prepare the environment to perform tests - we've had some discussion about including shell scripts on autotest. Bottom line, autotest has a policy of not including non python code when possible [1]. So, would you mind re-creating your hugepage setup code in python and re-sending it? Thanks for your contribution, looking forward getting it integrated to our tests. [1] Unless when it is not practical for testing purposes - writing tests in C is just fine, for example. This patch adds kvm_hugepage variant. It prepares the host system and start vm with -mem-path option. It does not clean after itself, because it's impossible to unmount and free hugepages before all guests are destroyed. I need to ask you what to do with change of qemu parameter. Newest versions are using -mempath insted of -mem-path. This is impossible to fix using current config file. I can see 2 solutions: 1) direct change in kvm_vm.py (parse output and try another param) 2) detect qemu capabilities outside and create additional layer (better for future occurrence) Dne 9.7.2009 11:24, Lukáš Doktor napsal(a): This patch adds kvm_hugepage variant. It prepares the host system and start vm with -mem-path option. It does not clean after itself, because it's impossible to unmount and free hugepages before all guests are destroyed. There is also added autotest.libhugetlbfs test. I need to ask you what to do with change of qemu parameter. Newest versions are using -mempath insted of -mem-path. This is impossible to fix using current config file. I can see 2 solutions: 1) direct change in kvm_vm.py (parse output and try another param) 2) detect qemu capabilities outside and create additional layer (better for future occurrence) Tested by:ldok...@redhat.com on RHEL5.4 with kvm-83-72.el5 -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [KVM_AUTOTEST] set English environment
2009/7/9 Lukáš Doktor ldok...@redhat.com: Set English environment before test executions. This is critical because we are parsing outputs of commands, which are localized! Tested by: ldok...@redhat.com on RHEL5.4 with kvm-83-72.el5 Ok, fair enough to have this extra security. Thanks, applied. -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: KVM vs Xen/OpenVZ for VPS hosting business
- howard chen howac...@gmail.com wrote: Hello, Currently both Xen and OpenVZ are well known and mature product used in hosting companies. How about KVM? What are the advantages if I use KVM as the VPS solution? E.g. performance? Due to a difference between virtualization and containers concepts, KVM won't be faster than OpenVZ. KVM may approach similar performance to Xen, if you use VirtIO para-virtual drivers. security? KVM is a kernel module, while Xen and OpenVZ is a whole modified kernel, which means that, _theoretically_, KVM has much lower chance of having security holes. maintainity? Kernel maintainability: Here KVM has an edge again, because it is a kernel module it is much easier to port to newer versions of the Linux kernel. Xen and OpenVZ require much more significant work and code changes to keep up-to-date with newer kernels. For KVM forward-porting is natural, as it is integrated in the kernel. Distro maintainability: KVM can be very easily maintained for new and old distros alike, even those Linux distros that are not virtualization aware. Maintenance of Xen or OpenVZ support on less popular Linux distros is a big problem. -Alexey -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [ANNOUNCE] kvm-88 release (CAN NOT install modules on debian/amd64/2.6.30)
On Sun, Jul 19, 2009 at 11:41:20AM +0800, John Wong wrote: Marcelo Tosatti 提到: On Mon, Jul 13, 2009 at 12:01:25AM +0800, John Wong wrote: [/ramdisk/kvm-88/kvm/kernel/x86/kvm.ko] undefined! WARNING: __tracepoint_kvm_mmu_pagetable_walk [/ramdisk/kvm-88/kvm/kernel/x86/kvm.ko] undefined! WARNING: __tracepoint_kvm_msi_set_irq [/ramdisk/kvm-88/kvm/kernel/x86/kvm.ko] undefined! when i depmod -a after install, i see some warning message like this: /sbin/depmod -a WARNING: Module /lib/modules/2.6.30-1-amd64/extra/kvm-intel.ko ignored, due to loop WARNING: Module /lib/modules/2.6.30-1-amd64/extra/kvm-amd.ko ignored, due to loop WARNING: Loop detected: /lib/modules/2.6.30-1-amd64/extra/kvm.ko which needs kvm.ko again! WARNING: Module /lib/modules/2.6.30-1-amd64/extra/kvm.ko ignored, due to loop when i insmod ./kvm.ko, i see the error message like this: sudo insmod ./kvm.ko insmod: error inserting './kvm.ko': -1 Unknown symbol in module and i can not load the modules on my debian/amd64 kernel-2.6.30 qemu-system-x86_64(kvm-88.tar.gz) is work on my debian with kvm-kmod-2.6.30.1-rc2.tar.gz Please help, thank you. John, The attached patch should fix this. Hi, Marcelo I have new problem to compile kvm-88 on debian/amd64/(Linux redcat 2.6.30-1-amd64 #1 SMP Sat Jul 18 12:55:06 UTC 2009 x86_64 GNU/Linux) I had used ./configure --kerneldir=/usr/src/linux and i do find /usr/src/linux -name 'scsi.h' then the output is: /usr/src/linux/linux-headers-2.6.30-1-amd64.orig/include/config/i2o/scsi.h /usr/src/linux/linux-headers-2.6.30-1-amd64.orig/include/config/scsi.h /usr/src/linux/include/scsi/scsi.h /usr/src/linux/include/config/i2o/scsi.h /usr/src/linux/include/config/scsi.h Please help again, thank you. John, I don't know what is going on, works for me on 2.6.30 host. Maybe try without --kerneldir? The compile error message like this: /ramdisk/kvm-88/hw/scsi-generic.c:45:23: warning: scsi/scsi.h: No such file or directory /ramdisk/kvm-88/hw/scsi-generic.c: In function ‘scsi_command_complete’: /ramdisk/kvm-88/hw/scsi-generic.c:165: error: ‘BUSY’ undeclared (first use in this function) /ramdisk/kvm-88/hw/scsi-generic.c:165: error: (Each undeclared identifier is reported only once /ramdisk/kvm-88/hw/scsi-generic.c:165: error: for each function it appears in.) /ramdisk/kvm-88/hw/scsi-generic.c:173: error: ‘CHECK_CONDITION’ undeclared (first use in this function) /ramdisk/kvm-88/hw/scsi-generic.c:175: error: ‘GOOD’ undeclared (first use in this function) /ramdisk/kvm-88/hw/scsi-generic.c: In function ‘scsi_read_data’: /ramdisk/kvm-88/hw/scsi-generic.c:266: error: ‘REQUEST_SENSE’ undeclared (first use in this function) /ramdisk/kvm-88/hw/scsi-generic.c: In function ‘scsi_write_complete’: /ramdisk/kvm-88/hw/scsi-generic.c:300: error: ‘MODE_SELECT’ undeclared (first use in this function) /ramdisk/kvm-88/hw/scsi-generic.c:301: error: ‘TYPE_TAPE’ undeclared (first use in this function) /ramdisk/kvm-88/hw/scsi-generic.c: In function ‘scsi_length’: /ramdisk/kvm-88/hw/scsi-generic.c:382: error: ‘TEST_UNIT_READY’ undeclared (first use in this function) /ramdisk/kvm-88/hw/scsi-generic.c:383: error: ‘REZERO_UNIT’ undeclared (first use in this function) /ramdisk/kvm-88/hw/scsi-generic.c:384: error: ‘START_STOP’ undeclared (first use in this function) /ramdisk/kvm-88/hw/scsi-generic.c:385: error: ‘SEEK_6’ undeclared (first use in this function) /ramdisk/kvm-88/hw/scsi-generic.c:386: error: ‘WRITE_FILEMARKS’ undeclared (first use in this function) /ramdisk/kvm-88/hw/scsi-generic.c:387: error: ‘SPACE’ undeclared (first use in this function) /ramdisk/kvm-88/hw/scsi-generic.c:388: error: ‘ERASE’ undeclared (first use in this function) /ramdisk/kvm-88/hw/scsi-generic.c:389: error: ‘ALLOW_MEDIUM_REMOVAL’ undeclared (first use in this function) /ramdisk/kvm-88/hw/scsi-generic.c:390: error: ‘VERIFY’ undeclared (first use in this function) /ramdisk/kvm-88/hw/scsi-generic.c:391: error: ‘SEEK_10’ undeclared (first use in this function) /ramdisk/kvm-88/hw/scsi-generic.c:392: error: ‘SYNCHRONIZE_CACHE’ undeclared (first use in this function) /ramdisk/kvm-88/hw/scsi-generic.c:393: error: ‘LOCK_UNLOCK_CACHE’ undeclared (first use in this function) /ramdisk/kvm-88/hw/scsi-generic.c:396: error: ‘SET_LIMITS’ undeclared (first use in this function) /ramdisk/kvm-88/hw/scsi-generic.c:397: error: ‘WRITE_LONG’ undeclared (first use in this function) /ramdisk/kvm-88/hw/scsi-generic.c:398: error: ‘MOVE_MEDIUM’ undeclared (first use in this function) /ramdisk/kvm-88/hw/scsi-generic.c:399: error: ‘UPDATE_BLOCK’ undeclared (first use in this function) /ramdisk/kvm-88/hw/scsi-generic.c:402: error: ‘MODE_SENSE’ undeclared (first use in this function) /ramdisk/kvm-88/hw/scsi-generic.c:404: error: ‘WRITE_SAME’ undeclared (first use in this function) /ramdisk/kvm-88/hw/scsi-generic.c:407: error:
[KVM-AUTOTEST PATCH 0/17] kvm_subprocess, guestwizard improvements, timedrift and other small things
The following patch series includes all the patches I sent that have not been applied yet. They are all rebased against the latest HEAD (including the recent UUID patch). Some new things are included too, such as a simple time drift test for Windows. Sorry for posting so many commits at once. -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[KVM-AUTOTEST PATCH 02/17] Modify kvm_vm and kvm_preprocessing to use the new kvm_subprocess module
Signed-off-by: Michael Goldish mgold...@redhat.com --- client/tests/kvm/kvm_preprocessing.py | 27 ++-- client/tests/kvm/kvm_vm.py| 111 +++- 2 files changed, 59 insertions(+), 79 deletions(-) diff --git a/client/tests/kvm/kvm_preprocessing.py b/client/tests/kvm/kvm_preprocessing.py index 80d7be8..7b97f00 100644 --- a/client/tests/kvm/kvm_preprocessing.py +++ b/client/tests/kvm/kvm_preprocessing.py @@ -1,7 +1,7 @@ import sys, os, time, commands, re, logging, signal from autotest_lib.client.bin import test from autotest_lib.client.common_lib import error -import kvm_vm, kvm_utils +import kvm_vm, kvm_utils, kvm_subprocess def preprocess_image(test, params): @@ -75,7 +75,7 @@ def preprocess_vm(test, params, env, name): qemu_path, image_dir, iso_dir): -logging.debug(VM's qemu command differs from requested one; +logging.debug(VM's qemu command differs from requested one; restarting it...) start_vm = True @@ -158,13 +158,11 @@ def process_command(test, params, env, command, command_timeout, # execute command logging.info(Executing command '%s'... % command) timeout = int(command_timeout) -(status, pid, output) = kvm_utils.run_bg(cd %s; %s % (test.bindir, +(status, output) = kvm_subprocess.run_fg(cd %s; %s % (test.bindir, command), -None, logging.debug, -(command) , -timeout = timeout) + logging.debug, (command) , + timeout=timeout) if status != 0: -kvm_utils.safe_kill(pid, signal.SIGTERM) logging.warn(Custom processing command failed: '%s'... % command) if command_noncritical != yes: raise error.TestError(Custom processing command failed) @@ -204,17 +202,6 @@ def preprocess(test, params, env): @param params: A dict containing all VM and image parameters. @param env: The environment (a dict-like object). -# Verify the identities of all living VMs -for vm in env.values(): -if not kvm_utils.is_vm(vm): -continue -if vm.is_dead(): -continue -if not vm.verify_process_identity(): -logging.debug(VM '%s' seems to have been replaced by another - process % vm.name) -vm.pid = None - # Destroy and remove VMs that are no longer needed in the environment requested_vms = kvm_utils.get_sub_dict_names(params, vms) for key in env.keys(): @@ -282,8 +269,8 @@ def postprocess(test, params, env): # Remove them all logging.debug('keep_ppm_files' not specified; removing all PPM files from results dir...) -kvm_utils.run_bg(rm -vf %s % os.path.join(test.debugdir, *.ppm), - None, logging.debug, (rm) , timeout=5.0) +rm_cmd = rm -vf %s % os.path.join(test.debugdir, *.ppm) +kvm_subprocess.run_fg(rm_cmd, logging.debug, (rm) , timeout=5.0) #execute any post_commands if params.get(post_command): diff --git a/client/tests/kvm/kvm_vm.py b/client/tests/kvm/kvm_vm.py index 48f2916..8bc2403 100644 --- a/client/tests/kvm/kvm_vm.py +++ b/client/tests/kvm/kvm_vm.py @@ -1,6 +1,6 @@ #!/usr/bin/python import time, socket, os, logging, fcntl -import kvm_utils +import kvm_utils, kvm_subprocess Utility classes and functions to handle Virtual Machine creation using qemu. @@ -54,17 +54,22 @@ def create_image(params, qemu_img_path, image_dir): qemu_img_cmd += %s % size logging.debug(Running qemu-img command:\n%s % qemu_img_cmd) -(status, pid, output) = kvm_utils.run_bg(qemu_img_cmd, None, - logging.debug, (qemu-img) , - timeout=30) +(status, output) = kvm_subprocess.run_fg(qemu_img_cmd, logging.debug, + (qemu-img) , timeout=30) -if status: -logging.debug(qemu-img exited with status %d % status) -logging.error(Could not create image %s % image_filename) +if status is None: +logging.error(Timeout elapsed while waiting for qemu-img command + to complete:\n%s % qemu_img_cmd) +return None +elif status != 0: +logging.error(Could not create image; + qemu-img command failed:\n%s % qemu_img_cmd) +logging.error(Status: %s % status) +logging.error(Output: +
[KVM-AUTOTEST PATCH 01/17] Add new module kvm_subprocess
This module is intended to be used for controlling all child processes in KVM tests: both QEMU processes and SSH/SCP/Telnet processes. Processes started with this module keep running and can be interacted with even after the parent process exits. The current run_bg() utility tracks a child process as long as the parent process is running. When the parent process exits, the tracking thread terminates and cannot resume when needed. Currently SSH/SCP/Telnet communication is handled by kvm_utils.kvm_spawn, which does not allow the child process to run after the parent process exits. Thus, open SSH/SCP/Telnet sessions cannot be reused by tests following the one in which they are opened. The new module provides a solution to these two problems, and also saves some code by reusing common code required both for QEMU processes and SSH/SCP/Telnet processes. Signed-off-by: Michael Goldish mgold...@redhat.com --- client/tests/kvm/kvm_subprocess.py | 1146 1 files changed, 1146 insertions(+), 0 deletions(-) create mode 100644 client/tests/kvm/kvm_subprocess.py diff --git a/client/tests/kvm/kvm_subprocess.py b/client/tests/kvm/kvm_subprocess.py new file mode 100644 index 000..413bdaa --- /dev/null +++ b/client/tests/kvm/kvm_subprocess.py @@ -0,0 +1,1146 @@ +#!/usr/bin/python +import sys, subprocess, pty, select, os, time, signal, re, termios, fcntl +import threading, logging, commands +import common, kvm_utils + + +A class and functions used for running and controlling child processes. + +...@copyright: 2008-2009 Red Hat Inc. + + + +def run_bg(command, termination_func=None, output_func=None, output_prefix=, + timeout=1.0): + +Run command as a subprocess. Call output_func with each line of output +from the subprocess (prefixed by output_prefix). Call termination_func +when the subprocess terminates. Return when timeout expires or when the +subprocess exits -- whichever occurs first. + +@brief: Run a subprocess in the background and collect its output and +exit status. + +@param command: The shell command to execute +@param termination_func: A function to call when the process terminates +(should take an integer exit status parameter) +@param output_func: A function to call with each line of output from +the subprocess (should take a string parameter) +@param output_prefix: A string to pre-pend to each line of the output, +before passing it to stdout_func +@param timeout: Time duration (in seconds) to wait for the subprocess to +terminate before returning + +@return: A kvm_tail object. + +process = kvm_tail(command=command, + termination_func=termination_func, + output_func=output_func, + output_prefix=output_prefix) + +end_time = time.time() + timeout +while time.time() end_time and process.is_alive(): +time.sleep(0.1) + +return process + + +def run_fg(command, output_func=None, output_prefix=, timeout=1.0): + +Run command as a subprocess. Call output_func with each line of output +from the subprocess (prefixed by prefix). Return when timeout expires or +when the subprocess exits -- whichever occurs first. If timeout expires +and the subprocess is still running, kill it before returning. + +@brief: Run a subprocess in the foreground and collect its output and +exit status. + +@param command: The shell command to execute +@param output_func: A function to call with each line of output from +the subprocess (should take a string parameter) +@param output_prefix: A string to pre-pend to each line of the output, +before passing it to stdout_func +@param timeout: Time duration (in seconds) to wait for the subprocess to +terminate before killing it and returning + +@return: A 2-tuple containing the exit status of the process and its +STDOUT/STDERR output. If timeout expires before the process +terminates, the returned status is None. + +process = run_bg(command, None, output_func, output_prefix, timeout) +output = process.get_output() +if process.is_alive(): +status = None +else: +status = process.get_status() +process.close() +return (status, output) + + +def _lock(filename): +if not os.path.exists(filename): +open(filename, w).close() +fd = os.open(filename, os.O_RDWR) +fcntl.lockf(fd, fcntl.LOCK_EX) +return fd + + +def _unlock(fd): +fcntl.lockf(fd, fcntl.LOCK_UN) +os.close(fd) + + +def _locked(filename): +try: +fd = os.open(filename, os.O_RDWR) +except: +return False +try: +fcntl.lockf(fd, fcntl.LOCK_EX | fcntl.LOCK_NB) +except: +os.close(fd) +return True +fcntl.lockf(fd, fcntl.LOCK_UN) +os.close(fd) +
[KVM-AUTOTEST PATCH 03/17] Modify remote_login and remote_scp in kvm_utils to use kvm_subprocess
Also remove a reference to kvm_log that was left behind. Signed-off-by: Michael Goldish mgold...@redhat.com --- client/tests/kvm/kvm_utils.py | 13 - 1 files changed, 8 insertions(+), 5 deletions(-) diff --git a/client/tests/kvm/kvm_utils.py b/client/tests/kvm/kvm_utils.py index b2b0d1a..fb587c5 100644 --- a/client/tests/kvm/kvm_utils.py +++ b/client/tests/kvm/kvm_utils.py @@ -2,6 +2,7 @@ import md5, thread, subprocess, time, string, random, socket, os, signal, pty import select, re, logging from autotest_lib.client.bin import utils from autotest_lib.client.common_lib import error +import kvm_subprocess KVM test utility functions. @@ -631,8 +632,9 @@ def remote_login(command, password, prompt, linesep=\n, timeout=10): @return Return the kvm_spawn object on success and None on failure. -sub = kvm_spawn(command, linesep) -sub.set_prompt(prompt) +sub = kvm_subprocess.kvm_shell_session(command, + linesep=linesep, + prompt=prompt) password_prompt_count = 0 @@ -698,7 +700,7 @@ def remote_scp(command, password, timeout=300, login_timeout=10): @return: True if the transfer succeeds and False on failure. -sub = kvm_spawn(command) +sub = kvm_subprocess.kvm_expect(command) password_prompt_count = 0 _timeout = login_timeout @@ -729,9 +731,10 @@ def remote_scp(command, password, timeout=300, login_timeout=10): sub.close() return False else: # match == None -logging.debug(Timeout or process terminated) +logging.debug(Timeout elapsed or process terminated) +status = sub.get_status() sub.close() -return sub.poll() == 0 +return status == 0 def scp_to_remote(host, port, username, password, local_path, remote_path, -- 1.5.4.1 -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[KVM-AUTOTEST PATCH 04/17] Modify run_autotest() in kvm_tests.py to use the new kvm_subprocess module.
Signed-off-by: Michael Goldish mgold...@redhat.com --- client/tests/kvm/kvm_tests.py |9 + 1 files changed, 5 insertions(+), 4 deletions(-) diff --git a/client/tests/kvm/kvm_tests.py b/client/tests/kvm/kvm_tests.py index 2d11fed..5991aed 100644 --- a/client/tests/kvm/kvm_tests.py +++ b/client/tests/kvm/kvm_tests.py @@ -1,6 +1,6 @@ import time, os, logging from autotest_lib.client.common_lib import utils, error -import kvm_utils, ppm_utils, scan_results +import kvm_utils, kvm_subprocess, ppm_utils, scan_results KVM test definitions. @@ -274,15 +274,16 @@ def run_autotest(test, params, env): cmd += --exclude=*.pyc cmd += --exclude=*.svn cmd += --exclude=*.git -kvm_utils.run_bg(cmd % (test.bindir, tarred_autotest_path), timeout=30) +kvm_subprocess.run_fg(cmd % (test.bindir, tarred_autotest_path), timeout=30) # tar the contents of bindir/autotest/tests/test_name cmd = cd %s; tar cvjf %s %s/* cmd += --exclude=*.pyc cmd += --exclude=*.svn cmd += --exclude=*.git -kvm_utils.run_bg(cmd % (os.path.join(test.bindir, autotest, tests), -tarred_test_path, test_name), timeout=30) +kvm_subprocess.run_fg(cmd % + (os.path.join(test.bindir, autotest, tests), + tarred_test_path, test_name), timeout=30) # Check if we need to copy autotest.tar.bz2 copy = False -- 1.5.4.1 -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[KVM-AUTOTEST PATCH 05/17] Remove kvm_spawn and run_bg() from kvm_utils.py.
These are now provided by kvm_subprocess.py. Signed-off-by: Michael Goldish mgold...@redhat.com --- client/tests/kvm/kvm_utils.py | 477 + 1 files changed, 2 insertions(+), 475 deletions(-) diff --git a/client/tests/kvm/kvm_utils.py b/client/tests/kvm/kvm_utils.py index fb587c5..9391874 100644 --- a/client/tests/kvm/kvm_utils.py +++ b/client/tests/kvm/kvm_utils.py @@ -227,390 +227,8 @@ def check_kvm_source_dir(source_dir): raise error.TestError(Unknown source dir layout, cannot proceed.) -# The following are a class and functions used for SSH, SCP and Telnet -# communication with guests. - -class kvm_spawn: - -This class is used for spawning and controlling a child process. - - -def __init__(self, command, linesep=\n): - -Initialize the class and run command as a child process. - -@param command: Command that will be run. -@param linesep: Line separator for the given platform. - -self.exitstatus = None -self.linesep = linesep -(pid, fd) = pty.fork() -if pid == 0: -os.execv(/bin/sh, [/bin/sh, -c, command]) -else: -self.pid = pid -self.fd = fd - - -def set_linesep(self, linesep): - -Sets the line separator string (usually \\n). - -@param linesep: Line separator character. - -self.linesep = linesep - - -def is_responsive(self, timeout=5.0): - -Return True if the session is responsive. - -Send a newline to the child process (e.g. SSH or Telnet) and read some -output using read_nonblocking. -If all is OK, some output should be available (e.g. the shell prompt). -In that case return True. Otherwise return False. - -@param timeout: Timeout that will happen before we consider the -process unresponsive - -self.read_nonblocking(timeout=0.1) -self.sendline() -output = self.read_nonblocking(timeout=timeout) -if output.strip(): -return True -return False - - -def poll(self): - -If the process exited, return its exit status. Otherwise return None. -The exit status is stored for use in subsequent calls. - -if self.exitstatus != None: -return self.exitstatus -pid, status = os.waitpid(self.pid, os.WNOHANG) -if pid: -self.exitstatus = os.WEXITSTATUS(status) -return self.exitstatus -else: -return None - - -def close(self): - -Close the session (close the process filedescriptors and kills the -process ID), and return the exit status. - -try: -os.close(self.fd) -os.kill(self.pid, signal.SIGTERM) -except OSError: -pass -return self.poll() - - -def sendline(self, str=): - -Sends a string followed by a line separator to the child process. - -@param str: String that will be sent to the child process. - -try: -os.write(self.fd, str + self.linesep) -except OSError: -pass - - -def read_nonblocking(self, timeout=1.0): - -Read from child until there is nothing to read for timeout seconds. - -@param timeout: Time (seconds) of wait before we give up reading from -the child process. - -data = -while True: -r, w, x = select.select([self.fd], [], [], timeout) -if self.fd in r: -try: -data += os.read(self.fd, 1024) -except OSError: -return data -else: -return data - - -def match_patterns(self, str, patterns): - -Match str against a list of patterns. - -Return the index of the first pattern that matches a substring of str. -None and empty strings in patterns are ignored. -If no match is found, return None. - -@param patterns: List of strings (regular expression patterns). - -for i in range(len(patterns)): -if not patterns[i]: -continue -exp = re.compile(patterns[i]) -if exp.search(str): -return i - - -def read_until_output_matches(self, patterns, filter=lambda(x):x, - timeout=30.0, internal_timeout=1.0, - print_func=None): - -Read using read_nonblocking until a match is found using match_patterns, -or until timeout expires. Before attempting to search for a match, the -data is filtered using the filter function provided. - -@brief: Read from child using read_nonblocking until a pattern -matches. -@param patterns: List of strings (regular
[KVM-AUTOTEST PATCH 06/17] kvm_guest_wizard: rename output_dir to debug_dir in barrier_2()
The name 'debug_dir' makes it clearer that it corresponds to test.debugdir. Signed-off-by: Michael Goldish mgold...@redhat.com --- client/tests/kvm/kvm_guest_wizard.py | 20 ++-- 1 files changed, 10 insertions(+), 10 deletions(-) diff --git a/client/tests/kvm/kvm_guest_wizard.py b/client/tests/kvm/kvm_guest_wizard.py index 2dd9be5..143e61e 100644 --- a/client/tests/kvm/kvm_guest_wizard.py +++ b/client/tests/kvm/kvm_guest_wizard.py @@ -18,7 +18,7 @@ def handle_var(vm, params, varname): def barrier_2(vm, words, fail_if_stuck_for, stuck_detection_history, - output_dir, data_scrdump_filename, current_step_num): + debug_dir, data_scrdump_filename, current_step_num): if len(words) 7: logging.error(Bad barrier_2 command line) return False @@ -34,12 +34,12 @@ def barrier_2(vm, words, fail_if_stuck_for, stuck_detection_history, if sleep_duration 1.0: sleep_duration = 1.0 if sleep_duration 10.0: sleep_duration = 10.0 -scrdump_filename = os.path.join(output_dir, scrdump.ppm) -cropped_scrdump_filename = os.path.join(output_dir, cropped_scrdump.ppm) -expected_scrdump_filename = os.path.join(output_dir, scrdump_expected.ppm) -expected_cropped_scrdump_filename = os.path.join(output_dir, +scrdump_filename = os.path.join(debug_dir, scrdump.ppm) +cropped_scrdump_filename = os.path.join(debug_dir, cropped_scrdump.ppm) +expected_scrdump_filename = os.path.join(debug_dir, scrdump_expected.ppm) +expected_cropped_scrdump_filename = os.path.join(debug_dir, cropped_scrdump_expected.ppm) -comparison_filename = os.path.join(output_dir, comparison.ppm) +comparison_filename = os.path.join(debug_dir, comparison.ppm) end_time = time.time() + timeout end_time_stuck = time.time() + fail_if_stuck_for @@ -99,7 +99,7 @@ def barrier_2(vm, words, fail_if_stuck_for, stuck_detection_history, prev_whole_image_md5sums.insert(0, whole_image_md5sum) # Limit queue length to stuck_detection_history prev_whole_image_md5sums = \ -prev_whole_image_md5sums[:stuck_detection_history] +prev_whole_image_md5sums[:stuck_detection_history] # Sleep for a while time.sleep(sleep_duration) @@ -113,12 +113,12 @@ def barrier_2(vm, words, fail_if_stuck_for, stuck_detection_history, logging.info(message) return False else: -# Collect information and put it in output_dir +# Collect information and put it in debug_dir if data_scrdump_filename and os.path.exists(data_scrdump_filename): # Read expected screendump image (ew, eh, edata) = \ ppm_utils.image_read_from_ppm_file(data_scrdump_filename) -# Write it in output_dir +# Write it in debug_dir ppm_utils.image_write_to_ppm_file(expected_scrdump_filename, ew, eh, edata) # Write the cropped version as well @@ -131,7 +131,7 @@ def barrier_2(vm, words, fail_if_stuck_for, stuck_detection_history, ppm_utils.image_write_to_ppm_file(comparison_filename, w, h, data) # Print error messages and fail the test -long_message = message + \n(see analysis at %s) % output_dir +long_message = message + \n(see analysis at %s) % debug_dir logging.error(long_message) raise error.TestFail, message -- 1.5.4.1 -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[KVM-AUTOTEST PATCH 07/17] kvm_guest_wizard: pass 'params' directly to barrier_2()
Currently parameters for barrier_2() are extracted from 'params' in the main run_steps() test routine, and then passed to barrier_2(). Instead, let barrier_2() extract parameters from 'params' as it sees fit. This will make adding new parameters slightly easier and cleaner. Signed-off-by: Michael Goldish mgold...@redhat.com --- client/tests/kvm/kvm_guest_wizard.py | 37 - 1 files changed, 18 insertions(+), 19 deletions(-) diff --git a/client/tests/kvm/kvm_guest_wizard.py b/client/tests/kvm/kvm_guest_wizard.py index 143e61e..eb0e2d5 100644 --- a/client/tests/kvm/kvm_guest_wizard.py +++ b/client/tests/kvm/kvm_guest_wizard.py @@ -17,8 +17,8 @@ def handle_var(vm, params, varname): return True -def barrier_2(vm, words, fail_if_stuck_for, stuck_detection_history, - debug_dir, data_scrdump_filename, current_step_num): +def barrier_2(vm, words, params, debug_dir, data_scrdump_filename, + current_step_num): if len(words) 7: logging.error(Bad barrier_2 command line) return False @@ -41,6 +41,18 @@ def barrier_2(vm, words, fail_if_stuck_for, stuck_detection_history, cropped_scrdump_expected.ppm) comparison_filename = os.path.join(debug_dir, comparison.ppm) +fail_if_stuck_for = params.get(fail_if_stuck_for) +if fail_if_stuck_for: +fail_if_stuck_for = float(fail_if_stuck_for) +else: +fail_if_stuck_for = 1e308 + +stuck_detection_history = params.get(stuck_detection_history) +if stuck_detection_history: +stuck_detection_history = int(stuck_detection_history) +else: +stuck_detection_history = 2 + end_time = time.time() + timeout end_time_stuck = time.time() + fail_if_stuck_for start_time = time.time() @@ -151,18 +163,6 @@ def run_steps(test, params, env): if not os.path.exists(steps_filename): raise error.TestError(Steps file not found: %s % steps_filename) -fail_if_stuck_for = params.get(fail_if_stuck_for) -if fail_if_stuck_for: -fail_if_stuck_for = float(fail_if_stuck_for) -else: -fail_if_stuck_for = 1e308 - -stuck_detection_history = params.get(stuck_detection_history) -if stuck_detection_history: -stuck_detection_history = int(stuck_detection_history) -else: -stuck_detection_history = 2 - sf = open(steps_filename, r) lines = sf.readlines() sf.close() @@ -201,13 +201,12 @@ def run_steps(test, params, env): logging.error(Variable not defined: %s % words[1]) elif words[0] == barrier_2: if current_screendump: -scrdump_filename = ( -os.path.join(ppm_utils.get_data_dir(steps_filename), - current_screendump)) +scrdump_filename = os.path.join( +ppm_utils.get_data_dir(steps_filename), +current_screendump) else: scrdump_filename = None -if not barrier_2(vm, words, fail_if_stuck_for, - stuck_detection_history, test.debugdir, +if not barrier_2(vm, words, params, test.debugdir, scrdump_filename, current_step_num): skip_current_step = True else: -- 1.5.4.1 -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[KVM-AUTOTEST PATCH 08/17] kvm_guest_wizard: allow keeping screendump history for debugging purposes
Add two new step file test parameters: - keep_screendump_history: if equals 'yes', screendump history is saved in test.debugdir/barrier_history in JPG format. Each screendump taken by the test is saved if it differs from the previous screendump. By default, when a barrier succeeds all history is removed, so eventually the remaining files are only those of the (last) failed barrier, if any. - keep_all_history: if equals 'yes', screendump history is not removed upon barrier success. The test leaves behind all the collected screendump history. Signed-off-by: Michael Goldish mgold...@redhat.com --- client/tests/kvm/kvm_guest_wizard.py | 38 - 1 files changed, 32 insertions(+), 6 deletions(-) diff --git a/client/tests/kvm/kvm_guest_wizard.py b/client/tests/kvm/kvm_guest_wizard.py index eb0e2d5..73b830e 100644 --- a/client/tests/kvm/kvm_guest_wizard.py +++ b/client/tests/kvm/kvm_guest_wizard.py @@ -1,6 +1,6 @@ import os, time, md5, re, shutil, logging from autotest_lib.client.common_lib import utils, error -import kvm_utils, ppm_utils +import kvm_utils, ppm_utils, kvm_subprocess Utilities to perform automatic guest installation using step files. @@ -53,6 +53,11 @@ def barrier_2(vm, words, params, debug_dir, data_scrdump_filename, else: stuck_detection_history = 2 +keep_screendump_history = params.get(keep_screendump_history) == yes +if keep_screendump_history: +keep_all_history = params.get(keep_all_history) == yes +history_dir = os.path.join(debug_dir, barrier_history) + end_time = time.time() + timeout end_time_stuck = time.time() + fail_if_stuck_for start_time = time.time() @@ -91,21 +96,42 @@ def barrier_2(vm, words, params, debug_dir, data_scrdump_filename, # Read image file (w, h, data) = ppm_utils.image_read_from_ppm_file(scrdump_filename) +# Compute md5sum of whole image +whole_image_md5sum = ppm_utils.image_md5sum(w, h, data) + +# Write screendump to history_dir (as JPG) if requested +# and if the screendump differs from the previous one +if (keep_screendump_history and +whole_image_md5sum not in prev_whole_image_md5sums[:1]): +try: +os.makedirs(history_dir) +except: +pass +history_scrdump_filename = os.path.join(history_dir, +scrdump-step_%s-%s.jpg % (current_step_num, + time.strftime(%Y%m%d-%H%M%S))) +kvm_subprocess.run_fg(convert -quality 30 %s %s % + (scrdump_filename, history_scrdump_filename), + logging.debug, (convert) , timeout=30) + # Compare md5sum of barrier region with the expected md5sum calced_md5sum = ppm_utils.get_region_md5sum(w, h, data, x1, y1, dx, dy, cropped_scrdump_filename) if calced_md5sum == md5sum: +# Success -- remove screendump history unless requested not to +if keep_screendump_history and not keep_all_history: +kvm_subprocess.run_fg(rm -rvf %s % history_dir, + logging.debug, (rm) , timeout=30) +# Report success return True -# Compute md5sum of whole image in order to compare it with -# previous ones -whole_image_md5sum = ppm_utils.image_md5sum(w, h, data) +# Insert image md5sum into queue of last seen images: # If md5sum is already in queue... if whole_image_md5sum in prev_whole_image_md5sums: # Remove md5sum from queue prev_whole_image_md5sums.remove(whole_image_md5sum) else: -# Extend 'stuck' timeout +# Otherwise extend 'stuck' timeout end_time_stuck = time.time() + fail_if_stuck_for # Insert md5sum at beginning of queue prev_whole_image_md5sums.insert(0, whole_image_md5sum) @@ -129,7 +155,7 @@ def barrier_2(vm, words, params, debug_dir, data_scrdump_filename, if data_scrdump_filename and os.path.exists(data_scrdump_filename): # Read expected screendump image (ew, eh, edata) = \ -ppm_utils.image_read_from_ppm_file(data_scrdump_filename) +ppm_utils.image_read_from_ppm_file(data_scrdump_filename) # Write it in debug_dir ppm_utils.image_write_to_ppm_file(expected_scrdump_filename, ew, eh, edata) -- 1.5.4.1 -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[KVM-AUTOTEST PATCH 10/17] KVM test: optionally convert PPM files to PNG format after test
This is intended to save disk space. Requires ImageMagick (uses mogrify). To enable: convert_ppm_files_to_png = yes To enable only for failed tests: convert_ppm_files_to_png_on_error = yes Reminder: by default PPM files are removed after the test (and after the conversion, if requested). To keep them specify: keep_ppm_files = yes To keep them only for failed tests: keep_ppm_files_on_error = yes A reasonable choice would be to keep PNG files for failed tests, and never keep PPM files. To do this specify convert_ppm_files_to_png_on_error = yes without specifying 'keep_ppm_files = yes' or 'keep_ppm_files_on_error = yes' (or explicitly set to 'no', if it was set to 'yes' on a higher level in the config hierarchy). This patch also makes small cosmetic changes to the 'keep_ppm_files' feature. Signed-off-by: Michael Goldish mgold...@redhat.com --- client/tests/kvm/kvm_preprocessing.py | 16 1 files changed, 12 insertions(+), 4 deletions(-) diff --git a/client/tests/kvm/kvm_preprocessing.py b/client/tests/kvm/kvm_preprocessing.py index 7b97f00..71f7a6b 100644 --- a/client/tests/kvm/kvm_preprocessing.py +++ b/client/tests/kvm/kvm_preprocessing.py @@ -264,11 +264,19 @@ def postprocess(test, params, env): process(test, params, env, postprocess_image, postprocess_vm) -# See if we should get rid of all PPM files -if not params.get(keep_ppm_files) == yes: -# Remove them all +# Should we convert PPM files to PNG format? +if params.get(convert_ppm_files_to_png) == yes: +logging.debug('convert_ppm_files_to_png' specified; converting PPM + files to PNG format...) +mogrify_cmd = (mogrify -format png %s % + os.path.join(test.debugdir, *.ppm)) +kvm_subprocess.run_fg(mogrify_cmd, logging.debug, (mogrify) , + timeout=30.0) + +# Should we keep the PPM files? +if params.get(keep_ppm_files) != yes: logging.debug('keep_ppm_files' not specified; removing all PPM files - from results dir...) + from debug dir...) rm_cmd = rm -vf %s % os.path.join(test.debugdir, *.ppm) kvm_subprocess.run_fg(rm_cmd, logging.debug, (rm) , timeout=5.0) -- 1.5.4.1 -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[KVM-AUTOTEST PATCH 11/17] KVM test: kvm_tests.cfg.sample: convert PPM files to PNG by default
By default, always remove PPM files, and keep PNG files only for failed tests. This shouldn't do much harm, because while PPMs can be incorporated directly into step files, PNGs can be converted back to PPMs easily, and take less disk space. (PNG is a lossless compression format.) The 'keep_ppm_files' and 'keep_ppm_files_on_error' settings are commented out so the user can easily enable them if desired. Signed-off-by: Michael Goldish mgold...@redhat.com --- client/tests/kvm/kvm_tests.cfg.sample |5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff --git a/client/tests/kvm/kvm_tests.cfg.sample b/client/tests/kvm/kvm_tests.cfg.sample index 02112b7..1288952 100644 --- a/client/tests/kvm/kvm_tests.cfg.sample +++ b/client/tests/kvm/kvm_tests.cfg.sample @@ -8,8 +8,9 @@ main_vm = vm1 # Some preprocessor/postprocessor params start_vm = yes -keep_ppm_files = no -keep_ppm_files_on_error = yes +convert_ppm_files_to_png_on_error = yes +#keep_ppm_files = yes +#keep_ppm_files_on_error = yes kill_vm = no kill_vm_gracefully = yes -- 1.5.4.1 -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[KVM-AUTOTEST PATCH 12/17] KVM test: add simple timedrift test (mainly for Windows)
1) Log into a guest. 2) Take a time reading from the guest and host. 3) Run load on the guest and host. 4) Take a second time reading. 5) Stop the load and rest for a while. 6) Take a third time reading. 7) If the drift immediately after load is higher than a user- specified value (in %), fail. If the drift after the rest period is higher than a user-specified value, fail. Signed-off-by: Michael Goldish mgold...@redhat.com --- client/tests/kvm/kvm.py |1 + client/tests/kvm/kvm_tests.py | 161 - 2 files changed, 160 insertions(+), 2 deletions(-) diff --git a/client/tests/kvm/kvm.py b/client/tests/kvm/kvm.py index b18b643..070e463 100644 --- a/client/tests/kvm/kvm.py +++ b/client/tests/kvm/kvm.py @@ -55,6 +55,7 @@ class kvm(test.test): kvm_install: test_routine(kvm_install, run_kvm_install), linux_s3: test_routine(kvm_tests, run_linux_s3), stress_boot: test_routine(kvm_tests, run_stress_boot), +timedrift:test_routine(kvm_tests, run_timedrift), } # Make it possible to import modules from the test's bindir diff --git a/client/tests/kvm/kvm_tests.py b/client/tests/kvm/kvm_tests.py index 5991aed..ca0b8c0 100644 --- a/client/tests/kvm/kvm_tests.py +++ b/client/tests/kvm/kvm_tests.py @@ -1,4 +1,4 @@ -import time, os, logging +import time, os, logging, re, commands from autotest_lib.client.common_lib import utils, error import kvm_utils, kvm_subprocess, ppm_utils, scan_results @@ -529,7 +529,6 @@ def run_stress_boot(tests, params, env): # boot the first vm vm = kvm_utils.env_get_vm(env, params.get(main_vm)) - if not vm: raise error.TestError(VM object not found in environment) if not vm.is_alive(): @@ -586,3 +585,161 @@ def run_stress_boot(tests, params, env): for se in sessions: se.close() logging.info(Total number booted: %d % (num -1)) + + +def run_timedrift(test, params, env): + +Time drift test (mainly for Windows guests): + +1) Log into a guest. +2) Take a time reading from the guest and host. +3) Run load on the guest and host. +4) Take a second time reading. +5) Stop the load and rest for a while. +6) Take a third time reading. +7) If the drift immediately after load is higher than a user- +specified value (in %), fail. +If the drift after the rest period is higher than a user-specified value, +fail. + +@param test: KVM test object. +@param params: Dictionary with test parameters. +@param env: Dictionary with the test environment. + +vm = kvm_utils.env_get_vm(env, params.get(main_vm)) +if not vm: +raise error.TestError(VM object not found in environment) +if not vm.is_alive(): +raise error.TestError(VM seems to be dead; Test requires a living VM) + +logging.info(Waiting for guest to be up...) + +session = kvm_utils.wait_for(vm.ssh_login, 240, 0, 2) +if not session: +raise error.TestFail(Could not log into guest) + +logging.info(Logged in) + +# Collect test parameters: +# Command to run to get the current time +time_command = params.get(time_command) +# Filter which should match a string to be passed to time.strptime() +time_filter_re = params.get(time_filter_re) +# Time format for time.strptime() +time_format = params.get(time_format) +guest_load_command = params.get(guest_load_command) +guest_load_stop_command = params.get(guest_load_stop_command) +host_load_command = params.get(host_load_command) +guest_load_instances = int(params.get(guest_load_instances, 1)) +host_load_instances = int(params.get(host_load_instances, 0)) +# CPU affinity mask for taskset +cpu_mask = params.get(cpu_mask, 0xFF) +load_duration = float(params.get(load_duration, 30)) +rest_duration = float(params.get(rest_duration, 10)) +drift_threshold = float(params.get(drift_threshold, 200)) +drift_threshold_after_rest = float(params.get(drift_threshold_after_rest, + 200)) + +guest_load_sessions = [] +host_load_sessions = [] + +# Remember the VM's previous CPU affinity +prev_cpu_mask = commands.getoutput(taskset -p %s % vm.get_pid()) +prev_cpu_mask = prev_cpu_mask.split()[-1] +# Set the VM's CPU affinity +commands.getoutput(taskset -p %s %s % (cpu_mask, vm.get_pid())) + +try: +# Get time before load +host_time_0 = time.time() +session.sendline(time_command) +(match, s) = session.read_up_to_prompt() +s = re.findall(time_filter_re, s)[0] +guest_time_0 = time.mktime(time.strptime(s, time_format)) + +# Run some load on the guest +logging.info(Starting load on guest...) +for i in range(guest_load_instances): +load_session = vm.ssh_login() +if not load_session: +
[KVM-AUTOTEST PATCH 14/17] KVM test: fix string and docstring indentation in kvm_config.py
Signed-off-by: Michael Goldish mgold...@redhat.com --- client/tests/kvm/kvm_config.py | 99 +--- 1 files changed, 52 insertions(+), 47 deletions(-) diff --git a/client/tests/kvm/kvm_config.py b/client/tests/kvm/kvm_config.py index 99ccb2a..7e8b1db 100755 --- a/client/tests/kvm/kvm_config.py +++ b/client/tests/kvm/kvm_config.py @@ -168,8 +168,8 @@ class config: Return the indent level of the next non-empty, non-comment line in file. -@param file: File like object. -@return: If no line is available, return -1. +@param file: File like object. +@return: If no line is available, return -1. pos = file.tell() line = self.get_next_line(file) @@ -188,10 +188,10 @@ class config: Add name to str with a separator dot and return the result. -@param str: String that will be processed -@param name: name that will be appended to the string. -@return: If append is True, append name to str. -Otherwise, pre-pend name to str. +@param str: String that will be processed +@param name: name that will be appended to the string. +@return: If append is True, append name to str. +Otherwise, pre-pend name to str. if str == : return name @@ -208,14 +208,14 @@ class config: Read and parse lines from file like object until a line with an indent level lower than or equal to prev_indent is encountered. -@brief: Parse a 'variants' or 'subvariants' block from a file-like -object. -@param file: File-like object that will be parsed -@param list: List of dicts to operate on -@param subvariants: If True, parse in 'subvariants' mode; -otherwise parse in 'variants' mode -@param prev_indent: The indent level of the parent block -@return: The resulting list of dicts. +@brief: Parse a 'variants' or 'subvariants' block from a file-like +object. +@param file: File-like object that will be parsed +@param list: List of dicts to operate on +@param subvariants: If True, parse in 'subvariants' mode; +otherwise parse in 'variants' mode +@param prev_indent: The indent level of the parent block +@return: The resulting list of dicts. new_list = [] @@ -270,16 +270,16 @@ class config: Read and parse lines from file until a line with an indent level lower than or equal to prev_indent is encountered. -@brief: Parse a file-like object. -@param file: A file-like object -@param list: A list of dicts to operate on (list is modified in -place and should not be used after the call) -@param restricted: if True, operate in restricted mode -(prohibit 'variants') -@param prev_indent: the indent level of the parent block -@return: Return the resulting list of dicts. -@note: List is destroyed and should not be used after the call. -Only the returned list should be used. +@brief: Parse a file-like object. +@param file: A file-like object +@param list: A list of dicts to operate on (list is modified in +place and should not be used after the call) +@param restricted: if True, operate in restricted mode +(prohibit 'variants') +@param prev_indent: the indent level of the parent block +@return: Return the resulting list of dicts. +@note: List is destroyed and should not be used after the call. +Only the returned list should be used. while True: indent = self.get_next_line_indent(file) @@ -305,8 +305,8 @@ class config: if op_found: if self.debug and not restricted: self.__debug_print(indented_line, - Parsing operator (%d dicts in current - context) % len_list) + Parsing operator (%d dicts in current + context) % len_list) (left, value) = self.split_and_strip(line, op_found) filters_and_key = self.split_and_strip(left, :) filters = filters_and_key[:-1] @@ -352,9 +352,9 @@ class config: list = filtered_list if self.debug and not restricted: self.__debug_print(indented_line, - Parsing no/only (%d dicts in current - context, %d remain) % - (len_list, len(list))) + Parsing no/only (%d dicts in current +
[KVM-AUTOTEST PATCH 13/17] KVM test: fix a parsing problem in kvm_config.py
Allow kvm_config to parse weird lines that seem to contain several operators, such as: time_filter_re = (?=TIME: ...) The '?=' is recognized as the operator instead of the '='. To fix this, select the operator closest to the beginning of the line. Signed-off-by: Michael Goldish mgold...@redhat.com --- client/tests/kvm/kvm_config.py |6 -- 1 files changed, 4 insertions(+), 2 deletions(-) diff --git a/client/tests/kvm/kvm_config.py b/client/tests/kvm/kvm_config.py index 95eefcb..99ccb2a 100755 --- a/client/tests/kvm/kvm_config.py +++ b/client/tests/kvm/kvm_config.py @@ -294,10 +294,12 @@ class config: # Look for a known operator in the line operators = [?+=, ?=, ?=, +=, =, =] op_found = None +op_pos = len(line) for op in operators: -if op in line: +pos = line.find(op) +if pos = 0 and pos op_pos: op_found = op -break +op_pos = pos # Found an operator? if op_found: -- 1.5.4.1 -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[KVM-AUTOTEST PATCH 15/17] KVM test: add timedrift test to kvm_tests.cfg.sample
Currently the test will only run on Windows. It should be able to run on Linux just as well, but if I understand correctly, testing time drift on Linux is less interesting. Also make some tiny cosmetic changes (spacing), and move the stress_boot test before the shutdown test (shutdown should be last). Signed-off-by: Michael Goldish mgold...@redhat.com --- client/tests/kvm/kvm_tests.cfg.sample | 46 ++-- 1 files changed, 37 insertions(+), 9 deletions(-) diff --git a/client/tests/kvm/kvm_tests.cfg.sample b/client/tests/kvm/kvm_tests.cfg.sample index 1288952..2d75a66 100644 --- a/client/tests/kvm/kvm_tests.cfg.sample +++ b/client/tests/kvm/kvm_tests.cfg.sample @@ -92,20 +92,33 @@ variants: test_name = disktest test_control_file = disktest.control -- linux_s3: install setup +- linux_s3: install setup type = linux_s3 -- shutdown: install setup +- timedrift:install setup +type = timedrift +extra_params += -rtc-td-hack +# Pin the VM and host load to CPU #0 +cpu_mask = 0x1 +# Set the load and rest durations +load_duration = 20 +rest_duration = 20 +# Fail if the drift after load is higher than 50% +drift_threshold = 50 +# Fail if the drift after the rest period is higher than 10% +drift_threshold_after_rest = 10 + +- stress_boot: install setup +type = stress_boot +max_vms = 5 +alive_test_cmd = ps aux + +- shutdown: install setup type = shutdown kill_vm = yes kill_vm_gracefully = no -- stress_boot: -type = stress_boot -max_vms = 5 -alive_test_cmd = ps aux - # NICs variants: - @rtl8139: @@ -121,6 +134,7 @@ variants: variants: # Linux section - @Linux: +no timedrift cmd_shutdown = shutdown -h now cmd_reboot = shutdown -r now ssh_status_test_command = echo $? @@ -303,8 +317,6 @@ variants: md5sum=bf4635e4a4bd3b43838e72bc8c329d55 md5sum_1m=18ecd37b639109f1b2af05cfb57dfeaf - - # Windows section - @Windows: no autotest @@ -318,6 +330,21 @@ variants: migration_test_command = ver vol stress_boot: alive_test_cmd = systeminfo +timedrift: +# For this to work, the ISO should contain vlc (vlc.exe) and a video (ED_1024.avi) +cdrom = windows/vlc.iso +time_command = echo TIME: %date% %time% +time_filter_re = (?=TIME: \w\w\w ).{19}(?=\.\d\d) +time_format = %m/%d/%Y %H:%M:%S +guest_load_command = 'cmd /c d:\vlc -f --loop --no-qt-privacy-ask --no-qt-system-tray d:\ED_1024.avi' +# Alternative guest load: +#guest_load_command = (dir /s dir /s dir /s dir /s) nul +guest_load_stop_command = taskkill /F /IM vlc.exe +guest_load_instances = 2 +host_load_command = bzip2 -c --best /dev/urandom /dev/null +# Alternative host load: +#host_load_command = dd if=/dev/urandom of=/dev/null +host_load_instances = 8 variants: - Win2000: @@ -582,5 +609,6 @@ variants: only qcow2.*ide.*default.*up.*Ubuntu-8.10-server.*(autotest.sleeptest) only rtl8139 + # Choose your test list only fc8_quick -- 1.5.4.1 -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[KVM-AUTOTEST PATCH 16/17] KVM test: initialize some VM attributes in __init__() to prevent trouble
'redirs' and 'vnc_port' might be used before they're defined, if make_qemu_command() is called before create(). To make sure this doesn't happen, define them in the VM constructor. Signed-off-by: Michael Goldish mgold...@redhat.com --- client/tests/kvm/kvm_vm.py |2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/client/tests/kvm/kvm_vm.py b/client/tests/kvm/kvm_vm.py index 8bc2403..d96b359 100644 --- a/client/tests/kvm/kvm_vm.py +++ b/client/tests/kvm/kvm_vm.py @@ -112,6 +112,8 @@ class VM: @param iso_dir: The directory where ISOs reside self.process = None +self.redirs = {} +self.vnc_port = 5900 self.uuid = None self.name = name -- 1.5.4.1 -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] replace qemu_kvm_cpu_env
On Wed, Jul 15, 2009 at 01:22:12PM -0400, Glauber Costa wrote: We now have an upstream qemu function that does exactly that, but in a kvm-independent way. Use it. Signed-off-by: Glauber Costa glom...@redhat.com --- hw/acpi.c | 24 +--- 1 files changed, 1 insertions(+), 23 deletions(-) diff --git a/hw/acpi.c b/hw/acpi.c index 7de9cb7..d23abd1 100644 --- a/hw/acpi.c +++ b/hw/acpi.c @@ -775,33 +775,11 @@ static void disable_processor(struct gpe_regs *g, int cpu) } #if defined(TARGET_I386) || defined(TARGET_X86_64) -#ifdef CONFIG_KVM -static CPUState *qemu_kvm_cpu_env(int index) -{ -CPUState *penv; - -penv = first_cpu; - -while (penv) { -if (penv-cpu_index == index) -return penv; -penv = (CPUState *)penv-next_cpu; -} - -return NULL; -} -#endif - - void qemu_system_cpu_hot_add(int cpu, int state) { CPUState *env; -if (state -#ifdef CONFIG_KVM - (!qemu_kvm_cpu_env(cpu)) -#endif -) { +if (state !qemu_get_cpu(cpu)) { env = pc_new_cpu(model); if (!env) { fprintf(stderr, cpu %d creation failed\n, cpu); Applied, thanks (did not apply the previous patchset because of the return error handling issue). -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] kvm-390: fix wait_queue handling
On Thu, Jul 16, 2009 at 05:17:37PM +0200, Christian Bornträger wrote: From: Christian Borntraeger borntrae...@de.ibm.com There are two waitqueues in kvm for wait handling: vcpu-wq for virt/kvm/kvm_main.c and vpcu-arch.local_int.wq for the s390 specific wait code. the wait handling in kvm_s390_handle_wait was broken by using different wait_queues for add_wait queue and remove_wait_queue. There are two options to fix the problem: o move all the s390 specific code to vcpu-wq and remove vcpu-arch.local_int.wq o move all the s390 specific code to vcpu-arch.local_int.wq This patch chooses the 2nd variant for two reasons: o s390 does not use kvm_vcpu_block but implements its own enabled wait handling. Having a separate wait_queue make it clear, that our wait mechanism is different o the patch is much smaller Report-by: Julia Lawall ju...@diku.dk Signed-off-by: Christian Borntraeger borntrae...@de.ibm.com --- arch/s390/kvm/interrupt.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) Index: kvm/arch/s390/kvm/interrupt.c === --- kvm.orig/arch/s390/kvm/interrupt.c +++ kvm/arch/s390/kvm/interrupt.c @@ -386,7 +386,7 @@ no_timer: } __unset_cpu_idle(vcpu); __set_current_state(TASK_RUNNING); - remove_wait_queue(vcpu-wq, wait); + remove_wait_queue(vcpu-arch.local_int.wq, wait); spin_unlock_bh(vcpu-arch.local_int.lock); spin_unlock(vcpu-arch.local_int.float_int-lock); hrtimer_try_to_cancel(vcpu-arch.ckc_timer); Applied, thanks. -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[ kvm-Bugs-2823765 ] about KVM-88 ?
Bugs item #2823765, was opened at 2009-07-18 21:59 Message generated for change (Comment added) made by mtosatti You can respond by visiting: https://sourceforge.net/tracker/?func=detailatid=893831aid=2823765group_id=180599 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: amd Group: None Status: Pending Resolution: None Priority: 5 Private: No Submitted By: z axis (sw2wolf) Assigned to: Nobody/Anonymous (nobody) Summary: about KVM-88 ? Initial Comment: $./configure --prefix=/usr/local --audio-drv-list=alsa oss --enable-mixemu $make $sudo make insatll WARNING: Loop detected: /lib/modules/2.6.30-ARCH/extra/kvm.ko which needs kvm.ko again! WARNING: Module /lib/modules/2.6.30-ARCH/extra/kvm.ko ignored, due to loop WARNING: Module /lib/modules/2.6.30-ARCH/extra/kvm-amd.ko ignored, due to loop WARNING: Module /lib/modules/2.6.30-ARCH/extra/kvm-intel.ko ignored, due to loop %sudo modprobe kvm-amd FATAL: Module kvm_amd not found. -- Comment By: Marcelo Tosatti (mtosatti) Date: 2009-07-20 11:41 Message: sw2wolf, Please use the patch found at http://patchwork.kernel.org/patch/36141/ -- You can respond by visiting: https://sourceforge.net/tracker/?func=detailatid=893831aid=2823765group_id=180599 -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: Timeout of network interface with OpenBSD 4.5 VM
Per a posting to openbsd misc mailing list on the 15th by Nick Osborn All good advice, but in the meantime a kernel without acpimadt, ioapic, and mpbios drivers will do the job. It appears they must be completely removed rather than just disabled. And he goes on to post a minimal kernel config that achieves that goal. -- Chris Dukes -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: KVM crashes when using certain USB device
Hi there, try to switch to USB 1.1 - not the best way but this helped my Windows XP running and doing things like printing, formatting USB keys or using a Dongle (Aladin, I think, it's also HASP) USB 2.0 was not really working well with KVM :-( Best regards, Erik G wrote: On Thu, Jul 16, 2009 at 9:15 AM, Jim Parisj...@jtan.com wrote: Hi G, I've continued my attempts to get the HASP dongle working, but with no success: -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [ANNOUNCE] kvm-88 release (CAN NOT install modules on debian/amd64/2.6.30)
Marcelo Tosatti 提到: John, I don't know what is going on, works for me on 2.6.30 host. Maybe try without --kerneldir? Hi Marcelo, yes i did, i can not compile it without --kerneldir, then i try --kerneldir, but still not work. Are you use Debian? Anyone use Debian/amd64/sid here? Debian user, please help. Thank you. -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCHv4] uio: add generic driver for PCI 2.3 devices
On Wed, 15 Jul 2009 23:39:11 +0200 Hans J. Koch h...@linutronix.de wrote: On Wed, Jul 15, 2009 at 11:13:40PM +0300, Michael S. Tsirkin wrote: This adds a generic uio driver that can bind to any PCI device. First user will be virtualization where a qemu userspace process needs to give guest OS access to the device. Interrupts are handled using the Interrupt Disable bit in the PCI command register and Interrupt Status bit in the PCI status register. All devices compliant to PCI 2.3 (circa 2002) and all compliant PCI Express devices should support these bits. Driver detects this support, and won't bind to devices which do not support the Interrupt Disable Bit in the command register. It's expected that more features of interest to virtualization will be added to this driver in the future. Possibilities are: mmap for device resources, MSI/MSI-X, eventfd (to interface with kvm), iommu. Well, I'm not enough of a PCI expert to tell whether your 2.3-test works or not (can it have side effects, e.g. trigger an interrupt when you toggle that bit?). I've added Jesse Barnes to Cc: since you modify a PCI core header file. If there are no objections from the PCI people, I guess we can take this. pci_reg.h portion looks fine to me, and only supporting devices with the interrupt disable bit certainly simplifies things. There were some other questions on the thread though (like Greg's similar driver); not sure if you've answered those yet. -- Jesse Barnes, Intel Open Source Technology Center -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH -v7] QEMU-KVM: MCE: Add MCE simulation support to qemu/kvm
On Mon, Jul 20, 2009 at 10:00:53AM +0800, Huang Ying wrote: KVM ioctls are used to initialize MCE simulation and inject MCE. The real MCE simulation is implemented in Linux kernel. The Kernel part has been merged. ChangeLog: v7: - Re-based on qemu-kvm.git/next branch v6: - Re-based on latest qemu-kvm.git v5: - Re-based on latest qemu-kvm.git v3: - Re-based on qemu/tcg MCE support patch v2: - Use new kernel MCE capability exportion interface. Signed-off-by: Huang Ying ying.hu...@intel.com Applied, thanks. -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCHv4] uio: add generic driver for PCI 2.3 devices
On Mon, Jul 20, 2009 at 10:17:02AM -0700, Jesse Barnes wrote: On Wed, 15 Jul 2009 23:39:11 +0200 Hans J. Koch h...@linutronix.de wrote: On Wed, Jul 15, 2009 at 11:13:40PM +0300, Michael S. Tsirkin wrote: This adds a generic uio driver that can bind to any PCI device. First user will be virtualization where a qemu userspace process needs to give guest OS access to the device. Interrupts are handled using the Interrupt Disable bit in the PCI command register and Interrupt Status bit in the PCI status register. All devices compliant to PCI 2.3 (circa 2002) and all compliant PCI Express devices should support these bits. Driver detects this support, and won't bind to devices which do not support the Interrupt Disable Bit in the command register. It's expected that more features of interest to virtualization will be added to this driver in the future. Possibilities are: mmap for device resources, MSI/MSI-X, eventfd (to interface with kvm), iommu. Well, I'm not enough of a PCI expert to tell whether your 2.3-test works or not (can it have side effects, e.g. trigger an interrupt when you toggle that bit?). I've added Jesse Barnes to Cc: since you modify a PCI core header file. If there are no objections from the PCI people, I guess we can take this. pci_reg.h portion looks fine to me, and only supporting devices with the interrupt disable bit certainly simplifies things. There were some other questions on the thread though (like Greg's similar driver); not sure if you've answered those yet. Yes, and Greg seems satisfied :). See 20090716181919.gb27...@suse.de. Chris Wright (author of pci-stub that was mentioned) also acked the patch. -- Jesse Barnes, Intel Open Source Technology Center -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCHv5] uio: add generic driver for PCI 2.3 devices
On Mon, Jul 20, 2009 at 10:29:34AM +0300, Michael S. Tsirkin wrote: This adds a generic uio driver that can bind to any PCI device. First user will be virtualization where a qemu userspace process needs to give guest OS access to the device. Interrupts are handled using the Interrupt Disable bit in the PCI command register and Interrupt Status bit in the PCI status register. All devices compliant to PCI 2.3 (circa 2002) and all compliant PCI Express devices should support these bits. Driver detects this support, and won't bind to devices which do not support the Interrupt Disable Bit in the command register. It's expected that more features of interest to virtualization will be added to this driver in the future. Possibilities are: mmap for device resources, MSI/MSI-X, eventfd (to interface with kvm), iommu. Thanks for adding the docs! Looks alright to me. Thanks, Hans Signed-off-by: Michael S. Tsirkin m...@redhat.com Acked-by: Chris Wright chr...@redhat.com Signed-off-by: Hans J. Koch h...@linutronix.de --- Greg, here's a combined patch including documentation, for upstream inclusion. This is intended to solve the problem in virtualization that shared interrupts do not work with assigned devices. Earlier versions of this patch have circulated on k...@vger. Changes since v4: - add documentation in Docbook format Changes since v3: - minor driver version fix Changes since v2: - remove irqcontrol: user can enable interrupts by writing command register directly - don't claim resources as we don't support mmap yet, but note the intent to do so in the commit log Changes since v1: - some naming changes - do a single read to get both command and status register Documentation/DocBook/uio-howto.tmpl | 163 ++ MAINTAINERS |8 ++ drivers/uio/Kconfig | 10 ++ drivers/uio/Makefile |1 + drivers/uio/uio_pci_generic.c| 207 ++ include/linux/pci_regs.h |1 + 6 files changed, 390 insertions(+), 0 deletions(-) create mode 100644 drivers/uio/uio_pci_generic.c diff --git a/Documentation/DocBook/uio-howto.tmpl b/Documentation/DocBook/uio-howto.tmpl index 8f6e3b2..4d4ce0e 100644 --- a/Documentation/DocBook/uio-howto.tmpl +++ b/Documentation/DocBook/uio-howto.tmpl @@ -25,6 +25,10 @@ year2006-2008/year holderHans-Jürgen Koch./holder /copyright +copyright + year2009/year + holderRed Hat Inc, Michael S. Tsirkin (m...@redhat.com)/holder +/copyright legalnotice para @@ -42,6 +46,13 @@ GPL version 2. revhistory revision + revnumber0.9/revnumber + date2009-07-16/date + authorinitialsmst/authorinitials + revremarkAdded generic pci driver + /revremark + /revision + revision revnumber0.8/revnumber date2008-12-24/date authorinitialshjk/authorinitials @@ -809,6 +820,158 @@ framework to set up sysfs files for this region. Simply leave it alone. /chapter +chapter id=uio_pci_generic xreflabel=Using Generic driver for PCI cards +?dbhtml filename=uio_pci_generic.html? +titleGeneric PCI UIO driver/title + para + The generic driver is a kernel module named uio_pci_generic. + It can work with any device compliant to PCI 2.3 (circa 2002) and + any compliant PCI Express device. Using this, you only need to +write the userspace driver, removing the need to write +a hardware-specific kernel module. + /para + +sect1 id=uio_pci_generic_binding +titleMaking the driver recognize the device/title + para +Since the driver does not declare any device ids, it will not get loaded +automatically and will not automatically bind to any devices, you must load it +and allocate id to the driver yourself. For example: + programlisting + modprobe uio_pci_generic + echo quot;8086 10f5quot; gt; /sys/bus/pci/drivers/uio_pci_generic/new_id + /programlisting + /para + para +If there already is a hardware specific kernel driver for your device, the +generic driver still won't bind to it, in this case if you want to use the +generic driver (why would you?) you'll have to manually unbind the hardware +specific driver and bind the generic driver, like this: + programlisting +echo -n :00:19.0 gt; /sys/bus/pci/drivers/e1000e/unbind +echo -n :00:19.0 gt; /sys/bus/pci/drivers/uio_pci_generic/bind + /programlisting + /para + para +You can verify that the device has been bound to the driver +by looking for it in sysfs, for example like the following: + programlisting +ls -l /sys/bus/pci/devices/:00:19.0/driver + /programlisting +Which if successful should print + programlisting + .../:00:19.0/driver -gt; ../../../bus/pci/drivers/uio_pci_generic + /programlisting +Note that the
Re: [PATCHv5] uio: add generic driver for PCI 2.3 devices
On Mon, Jul 20, 2009 at 09:09:43PM +0200, Hans J. Koch wrote: On Mon, Jul 20, 2009 at 10:29:34AM +0300, Michael S. Tsirkin wrote: This adds a generic uio driver that can bind to any PCI device. First user will be virtualization where a qemu userspace process needs to give guest OS access to the device. Interrupts are handled using the Interrupt Disable bit in the PCI command register and Interrupt Status bit in the PCI status register. All devices compliant to PCI 2.3 (circa 2002) and all compliant PCI Express devices should support these bits. Driver detects this support, and won't bind to devices which do not support the Interrupt Disable Bit in the command register. It's expected that more features of interest to virtualization will be added to this driver in the future. Possibilities are: mmap for device resources, MSI/MSI-X, eventfd (to interface with kvm), iommu. Thanks for adding the docs! Looks alright to me. Thanks, Hans Signed-off-by: Michael S. Tsirkin m...@redhat.com Acked-by: Chris Wright chr...@redhat.com Signed-off-by: Hans J. Koch h...@linutronix.de Jesse just acked this patch in a private mail, as well. Acked-by: Jesse Barnes jbar...@virtuousgeek.org --- Greg, here's a combined patch including documentation, for upstream inclusion. This is intended to solve the problem in virtualization that shared interrupts do not work with assigned devices. Earlier versions of this patch have circulated on k...@vger. Changes since v4: - add documentation in Docbook format Changes since v3: - minor driver version fix Changes since v2: - remove irqcontrol: user can enable interrupts by writing command register directly - don't claim resources as we don't support mmap yet, but note the intent to do so in the commit log Changes since v1: - some naming changes - do a single read to get both command and status register Documentation/DocBook/uio-howto.tmpl | 163 ++ MAINTAINERS |8 ++ drivers/uio/Kconfig | 10 ++ drivers/uio/Makefile |1 + drivers/uio/uio_pci_generic.c| 207 ++ include/linux/pci_regs.h |1 + 6 files changed, 390 insertions(+), 0 deletions(-) create mode 100644 drivers/uio/uio_pci_generic.c diff --git a/Documentation/DocBook/uio-howto.tmpl b/Documentation/DocBook/uio-howto.tmpl index 8f6e3b2..4d4ce0e 100644 --- a/Documentation/DocBook/uio-howto.tmpl +++ b/Documentation/DocBook/uio-howto.tmpl @@ -25,6 +25,10 @@ year2006-2008/year holderHans-Jürgen Koch./holder /copyright +copyright + year2009/year + holderRed Hat Inc, Michael S. Tsirkin (m...@redhat.com)/holder +/copyright legalnotice para @@ -42,6 +46,13 @@ GPL version 2. revhistory revision + revnumber0.9/revnumber + date2009-07-16/date + authorinitialsmst/authorinitials + revremarkAdded generic pci driver + /revremark + /revision + revision revnumber0.8/revnumber date2008-12-24/date authorinitialshjk/authorinitials @@ -809,6 +820,158 @@ framework to set up sysfs files for this region. Simply leave it alone. /chapter +chapter id=uio_pci_generic xreflabel=Using Generic driver for PCI cards +?dbhtml filename=uio_pci_generic.html? +titleGeneric PCI UIO driver/title + para + The generic driver is a kernel module named uio_pci_generic. + It can work with any device compliant to PCI 2.3 (circa 2002) and + any compliant PCI Express device. Using this, you only need to +write the userspace driver, removing the need to write +a hardware-specific kernel module. + /para + +sect1 id=uio_pci_generic_binding +titleMaking the driver recognize the device/title + para +Since the driver does not declare any device ids, it will not get loaded +automatically and will not automatically bind to any devices, you must load it +and allocate id to the driver yourself. For example: + programlisting + modprobe uio_pci_generic + echo quot;8086 10f5quot; gt; /sys/bus/pci/drivers/uio_pci_generic/new_id + /programlisting + /para + para +If there already is a hardware specific kernel driver for your device, the +generic driver still won't bind to it, in this case if you want to use the +generic driver (why would you?) you'll have to manually unbind the hardware +specific driver and bind the generic driver, like this: + programlisting +echo -n :00:19.0 gt; /sys/bus/pci/drivers/e1000e/unbind +echo -n :00:19.0 gt; /sys/bus/pci/drivers/uio_pci_generic/bind + /programlisting + /para + para +You can verify that the device has been bound to the driver +by looking for it in sysfs, for example like the following: + programlisting +
Re: [PATCHv5] uio: add generic driver for PCI 2.3 devices
On Mon, Jul 20, 2009 at 10:52:27PM +0300, Michael S. Tsirkin wrote: On Mon, Jul 20, 2009 at 09:09:43PM +0200, Hans J. Koch wrote: On Mon, Jul 20, 2009 at 10:29:34AM +0300, Michael S. Tsirkin wrote: This adds a generic uio driver that can bind to any PCI device. First user will be virtualization where a qemu userspace process needs to give guest OS access to the device. Interrupts are handled using the Interrupt Disable bit in the PCI command register and Interrupt Status bit in the PCI status register. All devices compliant to PCI 2.3 (circa 2002) and all compliant PCI Express devices should support these bits. Driver detects this support, and won't bind to devices which do not support the Interrupt Disable Bit in the command register. It's expected that more features of interest to virtualization will be added to this driver in the future. Possibilities are: mmap for device resources, MSI/MSI-X, eventfd (to interface with kvm), iommu. Thanks for adding the docs! Looks alright to me. Thanks, Hans Signed-off-by: Michael S. Tsirkin m...@redhat.com Acked-by: Chris Wright chr...@redhat.com Signed-off-by: Hans J. Koch h...@linutronix.de Jesse just acked this patch in a private mail, as well. Acked-by: Jesse Barnes jbar...@virtuousgeek.org Odd, but ok... I'll queue it up now. thanks, greg k-h -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] fix segfault with -no-kvm
Our PIT implementation calls qemu_kvm_pit_in_kernel without checking for kvm_enabled() as does everybody else. It will make it dereference kvm_context pointer wich will be NULL. Signed-off-by: Glauber Costa glom...@redhat.com --- hw/i8254.c |4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/i8254.c b/hw/i8254.c index fd0bdfe..34a716c 100644 --- a/hw/i8254.c +++ b/hw/i8254.c @@ -478,7 +478,7 @@ void hpet_disable_pit(void) { PITChannelState *s = pit_state.channels[0]; -if (qemu_kvm_pit_in_kernel()) { +if (kvm_enabled() qemu_kvm_pit_in_kernel()) { if (qemu_kvm_has_pit_state2()) { kvm_hpet_disable_kpit(); } else { @@ -502,7 +502,7 @@ void hpet_enable_pit(void) PITState *pit = pit_state; PITChannelState *s = pit-channels[0]; -if (qemu_kvm_pit_in_kernel()) { +if (kvm_enabled() qemu_kvm_pit_in_kernel()) { if (qemu_kvm_has_pit_state2()) { kvm_hpet_enable_kpit(); } else { -- 1.6.2.2 -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 0/9] More integration with qemu.git
Marcelo: Attention: this is _not_ a resent of my last series. I'm deferring resending that until we reach consensus on the ioctl error values. This one is another one I had on trigger. I tested it across reboots, system_resets, shutdown, migration, and normal use. It tries to glue together a lot of code that looked like the same. It has a quite visible side effect, which is that from this point on, we'll need --enabled-kvm for running a kvm guest. Although it is a big change, I argue that it would happen soon or later. -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 3/9] change order of kvm_init call.
The goal is to get rid of the call to kvm_init. But those things are subtle, and often break. So do it in a separate patch, to help finding potential issues in future bisections. Signed-off-by: Glauber Costa glom...@redhat.com --- vl.c | 18 +- 1 files changed, 9 insertions(+), 9 deletions(-) diff --git a/vl.c b/vl.c index f4e4d0f..86a6d70 100644 --- a/vl.c +++ b/vl.c @@ -5748,15 +5748,6 @@ int main(int argc, char **argv, char **envp) signal(SIGTTIN, SIG_IGN); } -#ifdef CONFIG_KVM -if (kvm_enabled()) { - if (kvm_init(smp_cpus) 0) { - fprintf(stderr, Could not initialize KVM, will disable KVM support\n); - exit(1); - } -} -#endif - if (pid_file qemu_create_pidfile(pid_file) != 0) { if (daemonize) { uint8_t status = 1; @@ -5956,6 +5947,15 @@ int main(int argc, char **argv, char **envp) } #endif +#ifdef CONFIG_KVM +if (kvm_enabled()) { + if (kvm_init(smp_cpus) 0) { + fprintf(stderr, Could not initialize KVM, will disable KVM support\n); + exit(1); + } +} +#endif + if (monitor_device) { monitor_hd = qemu_chr_open(monitor, monitor_device, NULL); if (!monitor_hd) { -- 1.6.2.2 -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 5/9] fold second pass of kvm initialization
From: Glauber Costa glom...@t60.(none) There is no reason why kvm_init_ap() and friends are placed outside kvm_init(). After we call kvm_init(), no extra initialization step should be necessary. There are now no references to KVM_UPSTREAM outside of kvm*.c files Signed-off-by: Glauber Costa glom...@t60.(none) --- qemu-kvm.c | 20 vl.c | 22 -- 2 files changed, 20 insertions(+), 22 deletions(-) diff --git a/qemu-kvm.c b/qemu-kvm.c index c3af59c..26cac25 100644 --- a/qemu-kvm.c +++ b/qemu-kvm.c @@ -2251,6 +2251,8 @@ int kvm_arch_init_irq_routing(void) } #endif +extern int no_hpet; + static int kvm_create_context() { int r; @@ -2283,6 +2285,24 @@ static int kvm_create_context() return r; } +kvm_init_ap(); +if (kvm_irqchip) { +if (!qemu_kvm_has_gsi_routing()) { +irq0override = 0; +#ifdef TARGET_I386 +/* if kernel can't do irq routing, interrupt source + * override 0-2 can not be set up as required by hpet, + * so disable hpet. + */ +no_hpet=1; +} else if (!qemu_kvm_has_pit_state2()) { +no_hpet=1; +} +#else +} +#endif +} + return 0; } diff --git a/vl.c b/vl.c index ae9e0b4..92ae881 100644 --- a/vl.c +++ b/vl.c @@ -5997,28 +5997,6 @@ int main(int argc, char **argv, char **envp) module_call_init(MODULE_INIT_DEVICE); -if (kvm_enabled()) { -kvm_init_ap(); -#ifdef CONFIG_KVM -if (kvm_irqchip) { -if (!qemu_kvm_has_gsi_routing()) { -irq0override = 0; -#ifdef TARGET_I386 -/* if kernel can't do irq routing, interrupt source - * override 0-2 can not be set up as required by hpet, - * so disable hpet. - */ -no_hpet=1; -} else if (!qemu_kvm_has_pit_state2()) { -no_hpet=1; -} -#else -} -#endif -} -#endif -} - machine-init(ram_size, boot_devices, kernel_filename, kernel_cmdline, initrd_filename, cpu_model); -- 1.6.2.2 -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 4/9] use qemu version of kvm initialization
Our code now looks like qemu's a lot. Remove ours, and leave just qemu's. Signed-off-by: Glauber Costa glom...@redhat.com --- vl.c | 11 --- 1 files changed, 0 insertions(+), 11 deletions(-) diff --git a/vl.c b/vl.c index 86a6d70..ae9e0b4 100644 --- a/vl.c +++ b/vl.c @@ -5935,7 +5935,6 @@ int main(int argc, char **argv, char **envp) } } -#ifdef KVM_UPSTREAM if (kvm_enabled()) { int ret; @@ -5945,16 +5944,6 @@ int main(int argc, char **argv, char **envp) exit(1); } } -#endif - -#ifdef CONFIG_KVM -if (kvm_enabled()) { - if (kvm_init(smp_cpus) 0) { - fprintf(stderr, Could not initialize KVM, will disable KVM support\n); - exit(1); - } -} -#endif if (monitor_device) { monitor_hd = qemu_chr_open(monitor, monitor_device, NULL); -- 1.6.2.2 -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 7/9] reuse env stop and stopped states
qemu CPUState already provides stop and stopped states. And they mean exactly that. There is no need for us to provide our own. Signed-off-by: Glauber Costa glom...@redhat.com --- cpu-defs.h |2 -- qemu-kvm.c | 30 -- vl.c |2 +- 3 files changed, 13 insertions(+), 21 deletions(-) diff --git a/cpu-defs.h b/cpu-defs.h index 7570096..fce366f 100644 --- a/cpu-defs.h +++ b/cpu-defs.h @@ -142,8 +142,6 @@ struct qemu_work_item; struct KVMCPUState { pthread_t thread; int signalled; -int stop; -int stopped; int created; void *vcpu_ctx; struct qemu_work_item *queued_work_first, *queued_work_last; diff --git a/qemu-kvm.c b/qemu-kvm.c index 58d5de2..6d556b8 100644 --- a/qemu-kvm.c +++ b/qemu-kvm.c @@ -91,7 +91,7 @@ static int kvm_debug(void *opaque, void *data, if (handle) { kvm_debug_cpu_requested = env; - env-kvm_cpu_state.stopped = 1; + env-stopped = 1; } return handle; } @@ -979,7 +979,7 @@ int handle_halt(kvm_vcpu_context_t vcpu) int handle_shutdown(kvm_context_t kvm, CPUState *env) { /* stop the current vcpu from going back to guest mode */ -env-kvm_cpu_state.stopped = 1; +env-stopped = 1; qemu_system_reset_request(); return 1; @@ -1817,7 +1817,7 @@ int kvm_cpu_exec(CPUState *env) static int is_cpu_stopped(CPUState *env) { -return !vm_running || env-kvm_cpu_state.stopped; +return !vm_running || env-stopped; } static void flush_queued_work(CPUState *env) @@ -1863,9 +1863,9 @@ static void kvm_main_loop_wait(CPUState *env, int timeout) cpu_single_env = env; flush_queued_work(env); -if (env-kvm_cpu_state.stop) { - env-kvm_cpu_state.stop = 0; - env-kvm_cpu_state.stopped = 1; +if (env-stop) { + env-stop = 0; + env-stopped = 1; pthread_cond_signal(qemu_pause_cond); } @@ -1877,7 +1877,7 @@ static int all_threads_paused(void) CPUState *penv = first_cpu; while (penv) { -if (penv-kvm_cpu_state.stop) +if (penv-stop) return 0; penv = (CPUState *)penv-next_cpu; } @@ -1891,11 +1891,11 @@ static void pause_all_threads(void) while (penv) { if (penv != cpu_single_env) { -penv-kvm_cpu_state.stop = 1; +penv-stop = 1; pthread_kill(penv-kvm_cpu_state.thread, SIG_IPI); } else { -penv-kvm_cpu_state.stop = 0; -penv-kvm_cpu_state.stopped = 1; +penv-stop = 0; +penv-stopped = 1; cpu_exit(penv); } penv = (CPUState *)penv-next_cpu; @@ -1912,8 +1912,8 @@ static void resume_all_threads(void) assert(!cpu_single_env); while (penv) { -penv-kvm_cpu_state.stop = 0; -penv-kvm_cpu_state.stopped = 0; +penv-stop = 0; +penv-stopped = 0; pthread_kill(penv-kvm_cpu_state.thread, SIG_IPI); penv = (CPUState *)penv-next_cpu; } @@ -2698,12 +2698,6 @@ int kvm_log_stop(target_phys_addr_t phys_addr, target_phys_addr_t len) return 0; } -void qemu_kvm_cpu_stop(CPUState *env) -{ -if (kvm_enabled()) -env-kvm_cpu_state.stopped = 1; -} - int kvm_set_boot_cpu_id(uint32_t id) { return kvm_set_boot_vcpu_id(kvm_context, id); diff --git a/vl.c b/vl.c index 92ae881..32134a2 100644 --- a/vl.c +++ b/vl.c @@ -3553,7 +3553,7 @@ void qemu_system_reset_request(void) reset_requested = 1; } if (cpu_single_env) { -qemu_kvm_cpu_stop(cpu_single_env); +cpu_single_env-stopped = 1; } qemu_notify_event(); } -- 1.6.2.2 -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 8/9] kvm_send_ipi
Provide a wrapper to pthread kill. It is more elegant because we only need to pass a CPUState pointer, meaning signall this cpu Signed-off-by: Glauber Costa glom...@redhat.com --- qemu-kvm.c | 13 + 1 files changed, 9 insertions(+), 4 deletions(-) diff --git a/qemu-kvm.c b/qemu-kvm.c index 6d556b8..c89146d 100644 --- a/qemu-kvm.c +++ b/qemu-kvm.c @@ -66,6 +66,11 @@ static CPUState *kvm_debug_cpu_requested; static uint64_t phys_ram_size; +static inline void kvm_send_ipi(CPUState *env) +{ +pthread_kill(env-kvm_cpu_state.thread, SIG_IPI); +} + /* The list of ioperm_data */ static LIST_HEAD(, ioperm_data) ioperm_head; @@ -1712,7 +1717,7 @@ static void on_vcpu(CPUState *env, void (*func)(void *data), void *data) wi.next = NULL; wi.done = false; -pthread_kill(env-kvm_cpu_state.thread, SIG_IPI); +kvm_send_ipi(env); while (!wi.done) qemu_cond_wait(qemu_work_cond); } @@ -1744,7 +1749,7 @@ void kvm_update_interrupt_request(CPUState *env) if (signal) { env-kvm_cpu_state.signalled = 1; if (env-kvm_cpu_state.thread) -pthread_kill(env-kvm_cpu_state.thread, SIG_IPI); +kvm_send_ipi(env); } } } @@ -1892,7 +1897,7 @@ static void pause_all_threads(void) while (penv) { if (penv != cpu_single_env) { penv-stop = 1; -pthread_kill(penv-kvm_cpu_state.thread, SIG_IPI); +kvm_send_ipi(penv); } else { penv-stop = 0; penv-stopped = 1; @@ -1914,7 +1919,7 @@ static void resume_all_threads(void) while (penv) { penv-stop = 0; penv-stopped = 0; -pthread_kill(penv-kvm_cpu_state.thread, SIG_IPI); +kvm_send_ipi(penv); penv = (CPUState *)penv-next_cpu; } } -- 1.6.2.2 -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 6/9] remove kvm_in* functions
We can use plain qemu's here, and save a couple of lines/complexity. I'm leaving outb for later, because the SMM thing makes it a little bit less trivial. Signed-off-by: Glauber Costa glom...@redhat.com --- qemu-kvm.c | 25 - 1 files changed, 4 insertions(+), 21 deletions(-) diff --git a/qemu-kvm.c b/qemu-kvm.c index 26cac25..58d5de2 100644 --- a/qemu-kvm.c +++ b/qemu-kvm.c @@ -97,24 +97,6 @@ static int kvm_debug(void *opaque, void *data, } #endif -static int kvm_inb(void *opaque, uint16_t addr, uint8_t *data) -{ -*data = cpu_inb(0, addr); -return 0; -} - -static int kvm_inw(void *opaque, uint16_t addr, uint16_t *data) -{ -*data = cpu_inw(0, addr); -return 0; -} - -static int kvm_inl(void *opaque, uint16_t addr, uint32_t *data) -{ -*data = cpu_inl(0, addr); -return 0; -} - #define PM_IO_BASE 0xb000 static int kvm_outb(void *opaque, uint16_t addr, uint8_t data) @@ -855,15 +837,16 @@ static int handle_io(kvm_vcpu_context_t vcpu) for (i = 0; i run-io.count; ++i) { switch (run-io.direction) { case KVM_EXIT_IO_IN: + r = 0; switch (run-io.size) { case 1: - r = kvm_inb(kvm-opaque, addr, p); + *(uint8_t *)p = cpu_inb(kvm-opaque, addr); break; case 2: - r = kvm_inw(kvm-opaque, addr, p); + *(uint16_t *)p = cpu_inw(kvm-opaque, addr); break; case 4: - r = kvm_inl(kvm-opaque, addr, p); + *(uint32_t *)p = cpu_inl(kvm-opaque, addr); break; default: fprintf(stderr, bad I/O size %d\n, run-io.size); -- 1.6.2.2 -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 9/9] remove kvm_abi variable
We're not using this for anything Signed-off-by: Glauber Costa glom...@redhat.com --- qemu-kvm.c |3 --- 1 files changed, 0 insertions(+), 3 deletions(-) diff --git a/qemu-kvm.c b/qemu-kvm.c index c89146d..b9eed8e 100644 --- a/qemu-kvm.c +++ b/qemu-kvm.c @@ -43,7 +43,6 @@ int kvm_pit = 1; int kvm_pit_reinject = 1; int kvm_nested = 0; - static KVMState *kvm_state; kvm_context_t kvm_context; @@ -84,7 +83,6 @@ static LIST_HEAD(, ioperm_data) ioperm_head; #define ALIGN(x, y) (((x)+(y)-1) ~((y)-1)) -int kvm_abi = EXPECTED_KVM_API_VERSION; int kvm_page_size; #ifdef KVM_CAP_SET_GUEST_DEBUG @@ -436,7 +434,6 @@ int kvm_init(int smp_cpus) fprintf(stderr, kvm userspace version too old\n); goto out_close; } - kvm_abi = r; kvm_page_size = getpagesize(); kvm_state = qemu_mallocz(sizeof(*kvm_state)); kvm_context = kvm_state-kvm_context; -- 1.6.2.2 -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCHv5] uio: add generic driver for PCI 2.3 devices
On Mon, 20 Jul 2009 12:55:36 -0700 Greg KH gre...@suse.de wrote: On Mon, Jul 20, 2009 at 10:52:27PM +0300, Michael S. Tsirkin wrote: On Mon, Jul 20, 2009 at 09:09:43PM +0200, Hans J. Koch wrote: On Mon, Jul 20, 2009 at 10:29:34AM +0300, Michael S. Tsirkin wrote: This adds a generic uio driver that can bind to any PCI device. First user will be virtualization where a qemu userspace process needs to give guest OS access to the device. Interrupts are handled using the Interrupt Disable bit in the PCI command register and Interrupt Status bit in the PCI status register. All devices compliant to PCI 2.3 (circa 2002) and all compliant PCI Express devices should support these bits. Driver detects this support, and won't bind to devices which do not support the Interrupt Disable Bit in the command register. It's expected that more features of interest to virtualization will be added to this driver in the future. Possibilities are: mmap for device resources, MSI/MSI-X, eventfd (to interface with kvm), iommu. Thanks for adding the docs! Looks alright to me. Thanks, Hans Signed-off-by: Michael S. Tsirkin m...@redhat.com Acked-by: Chris Wright chr...@redhat.com Signed-off-by: Hans J. Koch h...@linutronix.de Jesse just acked this patch in a private mail, as well. Acked-by: Jesse Barnes jbar...@virtuousgeek.org Odd, but ok... I just replied to Michael's off-list forward of some of the thread that I missed, I'm not trying to hide anything. :) Move along, nothing to see here... -- Jesse Barnes, Intel Open Source Technology Center -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: KVM crashes when using certain USB device
G wrote: I'm not too familiar with valgrind output, I have only used it on smaller programs I've written myself, so I don't know what to think of the messages (and amount of messages; valgrind told me to use --error-limit=no). I do get a bit nervous from all the complaints about uninitialized values and byes, but maybe it's normal for an application of kvm's size and type. I'd be nervous too :) Many of the complaints look harmless, but it's probably worth fixing them to make the real bugs stand out more. Even though you're having problems with -no-kvm, I suspect this is an upstream qemu issue, so you should probably try the qemu list too. qemu-de...@nongnu.org? I'll try to figure out the -no-kvm issue first, so I can run any commands they might want me to run. And thanks for your help and suggestions so far, btw. Here's a patch to try. I'm not familiar with the code, but it looks like this buffer might be too small versus the packet lengths that you're seeing, and similar definitions in hw/usb-uhci.c. -jim diff -urN kvm-87-orig/usb-linux.c kvm-87/usb-linux.c --- kvm-87-orig/usb-linux.c 2009-06-23 09:32:38.0 -0400 +++ kvm-87/usb-linux.c 2009-07-20 19:15:35.0 -0400 @@ -115,7 +115,7 @@ uint16_t offset; uint8_t state; struct usb_ctrlrequest req; -uint8_t buffer[1024]; +uint8_t buffer[2048]; }; typedef struct USBHostDevice { -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/2] kvm: use get_desc_base() and get_desc_limit()
On Sat, Jul 18, 2009 at 11:58:32PM +0900, Akinobu Mita wrote: Use get_desc_base() and get_desc_limit() to get the base address and limit in desc_struct. Cc: Avi Kivity a...@redhat.com Cc: kvm@vger.kernel.org Signed-off-by: Akinobu Mita akinobu.m...@gmail.com --- Applied both, thanks. arch/x86/kvm/x86.c | 18 +- 1 files changed, 5 insertions(+), 13 deletions(-) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index fe5474a..38d9b53 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -132,8 +132,7 @@ unsigned long segment_base(u16 selector) table_base = segment_base(ldt_selector); } d = (struct desc_struct *)(table_base + (selector ~7)); - v = d-base0 | ((unsigned long)d-base1 16) | - ((unsigned long)d-base2 24); + v = get_desc_base(d); #ifdef CONFIG_X86_64 if (d-s == 0 (d-type == 2 || d-type == 9 || d-type == 11)) v |= ((unsigned long)((struct ldttss_desc64 *)d)-base3) 32; @@ -3617,11 +3616,8 @@ static void kvm_set_segment(struct kvm_vcpu *vcpu, static void seg_desct_to_kvm_desct(struct desc_struct *seg_desc, u16 selector, struct kvm_segment *kvm_desct) { - kvm_desct-base = seg_desc-base0; - kvm_desct-base |= seg_desc-base1 16; - kvm_desct-base |= seg_desc-base2 24; - kvm_desct-limit = seg_desc-limit0; - kvm_desct-limit |= seg_desc-limit 16; + kvm_desct-base = get_desc_base(seg_desc); + kvm_desct-limit = get_desc_limit(seg_desc); if (seg_desc-g) { kvm_desct-limit = 12; kvm_desct-limit |= 0xfff; @@ -3700,11 +3696,7 @@ static int save_guest_segment_descriptor(struct kvm_vcpu *vcpu, u16 selector, static u32 get_tss_base_addr(struct kvm_vcpu *vcpu, struct desc_struct *seg_desc) { - u32 base_addr; - - base_addr = seg_desc-base0; - base_addr |= (seg_desc-base1 16); - base_addr |= (seg_desc-base2 24); + u32 base_addr = get_desc_base(seg_desc); return vcpu-arch.mmu.gva_to_gpa(vcpu, base_addr); } @@ -3993,7 +3985,7 @@ int kvm_task_switch(struct kvm_vcpu *vcpu, u16 tss_selector, int reason) } } - if (!nseg_desc.p || (nseg_desc.limit0 | nseg_desc.limit 16) 0x67) { + if (!nseg_desc.p || get_desc_limit(nseg_desc) 0x67) { kvm_queue_exception_e(vcpu, TS_VECTOR, tss_selector 0xfffc); return 1; } -- 1.6.0.6 -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@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 majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] kvm: Drop obsolete cpu_get/put in make_all_cpus_request
Jan, This was suggested but we thought it might be safer to keep the get_cpu/put_cpu pair in case -rt kernels require it (which might be bullshit, but nobody verified). On Mon, Jul 20, 2009 at 11:30:12AM +0200, Jan Kiszka wrote: spin_lock disables preemption, so we can simply read the current cpu. Signed-off-by: Jan Kiszka jan.kis...@siemens.com --- virt/kvm/kvm_main.c |3 +-- 1 files changed, 1 insertions(+), 2 deletions(-) diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 7cd1c10..98e4ec8 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -741,8 +741,8 @@ static bool make_all_cpus_request(struct kvm *kvm, unsigned int req) if (alloc_cpumask_var(cpus, GFP_ATOMIC)) cpumask_clear(cpus); - me = get_cpu(); spin_lock(kvm-requests_lock); + me = smp_processor_id(); kvm_for_each_vcpu(i, vcpu, kvm) { if (test_and_set_bit(req, vcpu-requests)) continue; @@ -757,7 +757,6 @@ static bool make_all_cpus_request(struct kvm *kvm, unsigned int req) else called = false; spin_unlock(kvm-requests_lock); - put_cpu(); free_cpumask_var(cpus); return called; } -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@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 majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [KVM_AUTOTEST] set English environment
On Thursday 09 July 2009, Lukáš Doktor wrote: --- orig/client/tests/kvm/control 2009-07-08 13:18:07.0 +0200 +++ new/client/tests/kvm/control2009-07-09 12:32:32.0 +0200 @@ -45,6 +45,8 @@ Each test is appropriately documented on import sys, os +# set English environment +os.environ['LANG'] = 'en_US.UTF-8' # enable modules import from current directory (tests/kvm) pwd = os.path.join(os.environ['AUTODIR'],'tests/kvm') sys.path.append(pwd) LANG can still be overridden with LC_ALL. For a well-defined environment, best set LC_ALL='C'. This will also set other i18n settings and works on systems that don't come with UTF-8 enabled. Arnd -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 1/2][v2] KVM: Introduce KVM_SET_IDENTITY_MAP_ADDR ioctl
Now KVM allow guest to modify guest's physical address of EPT's identity mapping page. (change from v1, discard unnecessary check, change ioctl to accept parameter address rather than value) Signed-off-by: Sheng Yang sh...@linux.intel.com --- arch/x86/include/asm/kvm_host.h |1 + arch/x86/kvm/vmx.c | 13 + arch/x86/kvm/x86.c | 19 +++ include/linux/kvm.h |2 ++ 4 files changed, 31 insertions(+), 4 deletions(-) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index 08732d7..e210b21 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -411,6 +411,7 @@ struct kvm_arch{ struct page *ept_identity_pagetable; bool ept_identity_pagetable_done; + gpa_t ept_identity_map_addr; unsigned long irq_sources_bitmap; unsigned long irq_states[KVM_IOAPIC_NUM_PINS]; diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 3a75db3..4ffc4c3 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -1719,7 +1719,7 @@ static void vmx_set_cr3(struct kvm_vcpu *vcpu, unsigned long cr3) eptp = construct_eptp(cr3); vmcs_write64(EPT_POINTER, eptp); guest_cr3 = is_paging(vcpu) ? vcpu-arch.cr3 : - VMX_EPT_IDENTITY_PAGETABLE_ADDR; + vcpu-kvm-arch.ept_identity_map_addr; } vmx_flush_tlb(vcpu); @@ -2122,7 +2122,7 @@ static int init_rmode_identity_map(struct kvm *kvm) if (likely(kvm-arch.ept_identity_pagetable_done)) return 1; ret = 0; - identity_map_pfn = VMX_EPT_IDENTITY_PAGETABLE_ADDR PAGE_SHIFT; + identity_map_pfn = kvm-arch.ept_identity_map_addr PAGE_SHIFT; r = kvm_clear_guest_page(kvm, identity_map_pfn, 0, PAGE_SIZE); if (r 0) goto out; @@ -2191,7 +2191,8 @@ static int alloc_identity_pagetable(struct kvm *kvm) goto out; kvm_userspace_mem.slot = IDENTITY_PAGETABLE_PRIVATE_MEMSLOT; kvm_userspace_mem.flags = 0; - kvm_userspace_mem.guest_phys_addr = VMX_EPT_IDENTITY_PAGETABLE_ADDR; + kvm_userspace_mem.guest_phys_addr = + kvm-arch.ept_identity_map_addr; kvm_userspace_mem.memory_size = PAGE_SIZE; r = __kvm_set_memory_region(kvm, kvm_userspace_mem, 0); if (r) @@ -3814,9 +3815,13 @@ static struct kvm_vcpu *vmx_create_vcpu(struct kvm *kvm, unsigned int id) if (alloc_apic_access_page(kvm) != 0) goto free_vmcs; - if (enable_ept) + if (enable_ept) { + if (!kvm-arch.ept_identity_map_addr) + kvm-arch.ept_identity_map_addr = + VMX_EPT_IDENTITY_PAGETABLE_ADDR; if (alloc_identity_pagetable(kvm) != 0) goto free_vmcs; + } return vmx-vcpu; diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 48567fa..6fdfc17 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -1208,6 +1208,7 @@ int kvm_dev_ioctl_check_extension(long ext) case KVM_CAP_IOEVENTFD: case KVM_CAP_PIT2: case KVM_CAP_PIT_STATE2: + case KVM_CAP_SET_IDENTITY_MAP_ADDR: r = 1; break; case KVM_CAP_COALESCED_MMIO: @@ -1908,6 +1909,13 @@ static int kvm_vm_ioctl_set_tss_addr(struct kvm *kvm, unsigned long addr) return ret; } +static int kvm_vm_ioctl_set_identity_map_addr(struct kvm *kvm, + u64 ident_addr) +{ + kvm-arch.ept_identity_map_addr = ident_addr; + return 0; +} + static int kvm_vm_ioctl_set_nr_mmu_pages(struct kvm *kvm, u32 kvm_nr_mmu_pages) { @@ -2171,6 +2179,17 @@ long kvm_arch_vm_ioctl(struct file *filp, if (r 0) goto out; break; + case KVM_SET_IDENTITY_MAP_ADDR: { + u64 ident_addr; + + r = -EFAULT; + if (copy_from_user(ident_addr, argp, sizeof ident_addr)) + goto out; + r = kvm_vm_ioctl_set_identity_map_addr(kvm, ident_addr); + if (r 0) + goto out; + break; + } case KVM_SET_MEMORY_REGION: { struct kvm_memory_region kvm_mem; struct kvm_userspace_memory_region kvm_userspace_mem; diff --git a/include/linux/kvm.h b/include/linux/kvm.h index 230a91a..f8f8900 100644 --- a/include/linux/kvm.h +++ b/include/linux/kvm.h @@ -435,6 +435,7 @@ struct kvm_ioeventfd { #define KVM_CAP_PIT_STATE2 35 #endif #define KVM_CAP_IOEVENTFD 36 +#define KVM_CAP_SET_IDENTITY_MAP_ADDR 37 #ifdef KVM_CAP_IRQ_ROUTING @@ -512,6 +513,7 @@ struct kvm_irqfd { #define KVM_SET_USER_MEMORY_REGION _IOW(KVMIO, 0x46,\ struct
Re: KVM and kernel 2.6.30 file system madness
On Wed, Jul 15, 2009 at 02:33:03PM +0530, Amit Shah wrote: On (Wed) Jul 15 2009 [09:52:36], Robert Wimmer wrote: Hi! Are you using virtio-block? Yes. OK, then there is a known problem. I think the fix is waiting to be applied. Amit, would you kindly state the problem with virtio-block? Thanks, Mark. -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html