Re: [kvm-devel] initiating linux guest shutdown from host

2008-04-23 Thread Luca Tettamanti
On Wed, Apr 23, 2008 at 10:40 AM,  [EMAIL PROTECTED] wrote:
 Hi,
  I'm trying libvirt-0.4.2, it should support initiating guest shutdown for
  KVM domains. But for some reason it doesn't work for me, I'm using linux
  guests with external kernel, if I run poweroff from within the domain, it
  shutdowns correctly, but trying to shutdown the domain from host using
  libvirt doesn't have any effect.
  Does somebody know where the problem could be? How does sending shutdown
  work in KVM/qemu at all? How can I debug it?

libvirt sends system_powerdown to the monitor; is ACPI is enabled
then the guest sees the event but it's free to ignore it (it's the
same as pressing the power button on a real machine: the OS sees the
event and may start the shutdown, ask the user what to do, ignore it,
etc.); e.g. the default ACPI script of the debian stops the desktop
manager if it's running but doesn't shut down the machine. If the ACPI
daemon is not running in the guest then the event is lost...

Luca

-
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] Some FAQ questions

2008-04-22 Thread Luca Tettamanti
On Tue, Apr 22, 2008 at 1:10 PM, Avi Kivity [EMAIL PROTECTED] wrote:
 Damjan wrote:
   I have some questions for the FAQ, about the configuration of Linux guests:
a) is swap needed in the guest (I'd say no, but..)
b) what filesystem is best for a guest
c) what io scheduler in the guest (noop? or cfq)
d) are there any runtime kernel tweaks for the guest (/proc/sys)?

  For the first four questions, do whatever you'd do for a similarly
  configured host running a similar workload.  It's fine to use cfq as the
  I/O scheduler.

Is cfq still fair in the guest? The VM re-dispatches the requests (at
least when using QEMU IDE) and the host can reschedule them at will.

Luca

-
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [PATCH] Make virtio devices multi-function

2008-04-22 Thread Luca Tettamanti
On Tue, Apr 22, 2008 at 4:15 PM, Anthony Liguori [EMAIL PROTECTED] wrote:
 This patch changes virtio devices to be multi-function devices whenever
  possible.  This increases the number of virtio devices we can support now by
  a factor of 8.
[...]
  diff --git a/qemu/hw/virtio.c b/qemu/hw/virtio.c
  index 9100bb1..9ea14d3 100644
  --- a/qemu/hw/virtio.c
  +++ b/qemu/hw/virtio.c
  @@ -405,9 +405,18 @@ VirtIODevice *virtio_init_pci(PCIBus *bus, const char 
 *name,
  PCIDevice *pci_dev;
  uint8_t *config;
  uint32_t size;
  +static int devfn = 7;
  +
  +if ((devfn % 8) == 7)
  +   devfn = -1;
  +else
  +   devfn++;

This code look strange... devfn should be passed to virtio_init_pci by
virtio-{net,blk} init functions, no?

Luca

-
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [kvm-ppc-devel] Top level kvm-userspace directory getting crowded ... need new dir for qemu dependencies

2008-03-02 Thread Luca Barbato
Hollis Blanchard wrote:
 That's a strange assertion, considering that Debian (and thus Ubuntu)
 doesn't have it.

Others do..

https://admin.fedoraproject.org/pkgdb/packages/name/dtc
http://packages.gentoo.org/package/sys-apps/dtc
http://www.novell.com/products/linuxpackages/opensuse/dtc.html

 Have you actually looked at the code in question, or just saw that it
 has lib in the name?
 
 It's 1600 lines of C. In contrast, zlib, which is used in a large number
 of projects, and despite that is often statically linked, is 8500.

That's why today some people are hunting copies and submitting patches 
to cleanup that mess.

lu

-- 

Luca Barbato
Gentoo Council Member
Gentoo/linux Gentoo/PPC
http://dev.gentoo.org/~lu_zero


-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [PATCH] fix -kernel option

2007-12-07 Thread Luca Tettamanti
On Dec 7, 2007 7:38 PM, Anthony Liguori [EMAIL PROTECTED] wrote:
 Izik Eidus wrote:
  Anthony Liguori wrote:
  Glauber de Oliveira Costa wrote:
 
  Currently, the -kernel option is not working.
 
  Reason is, because we're registering chunks for regions 0-0xa and
  0x10-ram_size, the phys_ram_addr + PA is broken.
 
  I think this patch is a reasonable work-around but the long term
  solution is probably going to have to be making sure that nothing
  makes the phys_ram_addr + PA assumption.  With  4GB of memory, this
  assumption is broken because of the BIOS/PCI holes anyway.
  we can always allocate 300 mbs of junk :)

 Well, it may not be so bad.  We can certainly malloc() those 300mbs.
 They'll never be touched by anyone so it doesn't actually increase the
 resident size.

Iff the host kernel is configured to overcommit memory.

Luca

-
SF.Net email is sponsored by:
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] Spawning threads in KVM/QEMU

2007-11-13 Thread Luca Tettamanti
On Nov 13, 2007 11:42 PM, Dor Laor [EMAIL PROTECTED] wrote:
 Anthony Liguori wrote:
  I've been experimenting with creating IO threads for the PV device
  drivers.  Unfortunately, my experiments haven't gotten very far as QEMU
  tends to hang up a bit into booting the guest whenever I spawn a thread
  that does any sort of read/write on a file descriptor.  My suspicion is
  that it has something to do with signals being delivered to the wrong
  thread but after masking out all the signals for this thread, I still
  had no luck.
 
 Maybe you set the mask too late? try setting it before creating the thread:
  sigfillset(thread_sig_mask);
  sigdelset(thread_sig_mask,SIGILL);
  sigdelset(thread_sig_mask,SIGFPE);
  sigdelset(thread_sig_mask,SIGSEGV);

When using RTC or HPET for timing you also need to mask SIGIO; you may
also need to change F_SETOWN (enable_sigio_timer) with the correct
thread id, i.e.:

fcntl(fd, F_SETOWN, gettid());

Luca

-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now  http://get.splunk.com/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] Vista Networking

2007-11-05 Thread Luca Tettamanti
On 11/5/07, Elmar Haneke [EMAIL PROTECTED] wrote:
 What problems are the cause for recommending to emulate NE2K hardware?

Vista expects that the correct frame checksum is calculated for
inbound packets; the emulated card didn't do that.

 Is this still valid fpr KVM-50?

It was fixed in QEMU CVS a while ago, I believe that Avi pulled that
patch when rebased KVM userspace.

Luca

-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now  http://get.splunk.com/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] no quit on halt for linux 2.6.23 x86 guest

2007-10-29 Thread Luca Tettamanti
On 10/29/07, Denys Duchier [EMAIL PROTECTED] wrote:
 qemu doesn't quit (no poweroff?) on halt for linux 2.6.23 x86 guests 
 (confirmed
 by danieldg on irc), but it works for 64bit guests and it works for linux 
 2.6.22
 x86 guests. I tried kvm-45 and kvm-49. -no-kvm does not help.

Try acpi=force on the kernel command line (guest). QEmu doesn't expose
a DMI block and Linux guests usually don't enable ACPI since they're
unable to check BIOS year (all BIOSes shipped before 2001 are
blacklisted because they tend to be very broken).

Luca

-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now  http://get.splunk.com/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [PATCH v2] Use net-tools as a fallback for iproute2 for bridge configuration

2007-09-25 Thread Luca
On 9/25/07, Carlo Marcelo Arenas Belon [EMAIL PROTECTED] wrote:
 diff --git a/scripts/qemu-ifup b/scripts/qemu-ifup
 index 3bf8801..989fe9a 100755
 --- a/scripts/qemu-ifup
 +++ b/scripts/qemu-ifup
 @@ -1,5 +1,18 @@
  #!/bin/sh

 -switch=$(/sbin/ip route list | awk '/^default / { print $NF }')
 +if [ -x /sbin/brctl ]; then
 +  BRCTL=/sbin/brctl
 +elif [ -x /usr/sbin/brctl ]; then
 +  BRCTL=/usr/sbin/brctl
 +else
 +  echo no bridge utils installed
 +  exit 1
 +fi
 +
 +if [ -x /sbin/ip ]; then
 +  switch=$(/sbin/ip route list | awk '/^default / { print $NF }')

NAK on this piece. This won't work with non-trivial setups (yes, I now
that the original script is broken too, but since you are touching
it...).
See:
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=417151

IMHO it's better to rely on distro-specific scripts to setup the networking.

Luca

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] Bug-Report: kvm-44 crashes with -no-kvm with -rc6 host on AMD64 (Stepping F)

2007-09-24 Thread Luca
On 9/24/07, Carsten Otte [EMAIL PROTECTED] wrote:
 Hi list,

 I've observed that current kvm-44 userspace with Avi's git as of
 yesterday does not boot our debian test image on an AMD64 machine. The
 kernel seems to die various panic's in sequence (too fast to observe),
 the final one is in __delay().

Host kernel? Or the guest?

 Everything seems well without -no-kvm
 option with the very same userspace.
 In case of problems in reproducing this, let me know so that I can
 collect debug data.

If it's the guest you can append -serial file:/tmp/log.txt to KVM
command line and add console=ttyS0 to the guest kernel command line.

Luca

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [ANNOUNCE] kvm-42 release

2007-09-21 Thread Luca
On 9/21/07, Avi Kivity [EMAIL PROTECTED] wrote:
 Luca wrote:
  On 9/20/07, Avi Kivity [EMAIL PROTECTED] wrote:
 
  Not much user visible change besides the OpenBSD regression fix.
 
  As usual, if you have an issue please try with -no-kvm-irqchip and report.
 
 
  32 bit Fedora7 on a 32 bit host (kvm-intel) dies due to screaming
  interrupts during IDE probe. Same problem with KVM-41 (last known
  working is KVM-36, I haven't tested anything in between). In both
  cases -no-kvm-irqchip fixes the problem.
 
 

 I fixed a couple of bugs in edge-triggered interrupts handling which
 resolves this.  May also resolve the Ubuntu keyboard issue.

 kvm-43 will be released shortly with this.

Both VMs are working fine with 43.

thanks,
Luca

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [ANNOUNCE] kvm-42 release

2007-09-20 Thread Luca
On 9/20/07, Avi Kivity [EMAIL PROTECTED] wrote:
 Not much user visible change besides the OpenBSD regression fix.

 As usual, if you have an issue please try with -no-kvm-irqchip and report.

32 bit Fedora7 on a 32 bit host (kvm-intel) dies due to screaming
interrupts during IDE probe. Same problem with KVM-41 (last known
working is KVM-36, I haven't tested anything in between). In both
cases -no-kvm-irqchip fixes the problem.

Log attached.

Luca
Linux version 2.6.22.2-42.fc6 ([EMAIL PROTECTED]) (gcc version 4.1.2 20070626 
(Red Hat 4.1.2-13)) #1 SMP Wed Aug 15 11:32:12 EDT 2007
BIOS-provided physical RAM map:
 BIOS-e820:  - 0009fc00 (usable)
 BIOS-e820: 0009fc00 - 000a (reserved)
 BIOS-e820: 000e8000 - 0010 (reserved)
 BIOS-e820: 0010 - 17ff (usable)
 BIOS-e820: 17ff - 1800 (ACPI data)
 BIOS-e820: fffc - 0001 (reserved)
0MB HIGHMEM available.
383MB LOWMEM available.
Using x86 segment limits to approximate NX protection
Zone PFN ranges:
  DMA 0 - 4096
  Normal   4096 -98288
  HighMem 98288 -98288
early_node_map[1] active PFN ranges
0:0 -98288
DMI not present or invalid.
Using APIC driver default
ACPI: RSDP 000FAAC0, 0014 (r0 QEMU  )
ACPI: RSDT 17FF, 002C (r1 QEMU   QEMURSDT1 QEMU1)
ACPI: FACP 17FF002C, 0074 (r1 QEMU   QEMUFACP1 QEMU1)
ACPI: DSDT 17FF0100, 0909 (r1   BXPC   BXDSDT1 INTL 20061109)
ACPI: FACS 17FF00C0, 0040
ACPI: APIC 17FF0A10, 0040 (r1 QEMU   QEMUAPIC1 QEMU1)
ACPI: no DMI BIOS year, acpi=force is required to enable ACPI
ACPI: acpi=force override
ACPI: PM-Timer IO Port: 0xb008
ACPI: LAPIC (acpi_id[0x00] lapic_id[0x00] enabled)
Processor #0 6:2 APIC version 20
ACPI: IOAPIC (id[0x01] address[0xfec0] gsi_base[0])
IOAPIC[0]: apic_id 1, version 17, address 0xfec0, GSI 0-23
Enabling APIC mode:  Flat.  Using 1 I/O APICs
Using ACPI (MADT) for SMP configuration information
Allocating PCI resources starting at 2000 (gap: 1800:e7fc)
Built 1 zonelists.  Total pages: 97521
Kernel command line: ro root=/dev/VolGroup00/LogVol00 acpi=force console=tty0 
console=ttyS0
Enabling fast FPU save and restore... done.
Enabling unmasked SIMD FPU exception support... done.
Initializing CPU#0
CPU 0 irqstacks, hard=c07bd000 soft=c079d000
PID hash table entries: 2048 (order: 11, 8192 bytes)
Detected 2133.485 MHz processor.
Console: colour VGA+ 80x25
Dentry cache hash table entries: 65536 (order: 6, 262144 bytes)
Inode-cache hash table entries: 32768 (order: 5, 131072 bytes)
Memory: 382348k/393152k available (2219k kernel code, 10324k reserved, 1177k 
data, 260k init, 0k highmem)
virtual kernel memory layout:
fixmap  : 0xffc55000 - 0xf000   (3752 kB)
pkmap   : 0xff80 - 0xffc0   (4096 kB)
vmalloc : 0xd880 - 0xff7fe000   ( 623 MB)
lowmem  : 0xc000 - 0xd7ff   ( 383 MB)
  .init : 0xc0757000 - 0xc0798000   ( 260 kB)
  .data : 0xc062adc6 - 0xc0751584   (1177 kB)
  .text : 0xc040 - 0xc062adc6   (2219 kB)
Checking if this processor honours the WP bit even in supervisor mode... Ok.
SLUB: Genslabs=22, HWalign=64, Order=0-1, MinObjects=4, CPUs=1, Nodes=1
Calibrating delay using timer specific routine.. 4361.58 BogoMIPS (lpj=2180791)
Security Framework v1.0.0 initialized
SELinux:  Initializing.
selinux_register_security:  Registering secondary module capability
Capability LSM initialized as secondary
Mount-cache hash table entries: 512
CPU: L1 I cache: 8K
CPU: L2 cache: 128K
Intel machine check architecture supported.
Intel machine check reporting enabled on CPU#0.
Compat vDSO mapped to e000.
Checking 'hlt' instruction... OK.
SMP alternatives: switching to UP code
Freeing SMP alternatives: 14k freed
ACPI: Core revision 20070126
CPU0: Intel QEMU Virtual CPU version 0.9.0 stepping 03
Total of 1 processors activated (4361.58 BogoMIPS).
ENABLING IO-APIC IRQs
..TIMER: vector=0x31 apic1=0 pin1=0 apic2=-1 pin2=-1
APIC calibration not consistent with PM Timer: 121ms instead of 100ms
APIC delta adjusted to PM-Timer: 6249968 (7618049)
Brought up 1 CPUs
Time: 20:35:48  Date: 08/20/107
NET: Registered protocol family 16
ACPI: bus type pci registered
PCI: PCI BIOS revision 2.10 entry at 0xfa530, last bus=0
PCI: Using configuration type 1
Setting up standard PCI resources
ACPI: Interpreter enabled
ACPI: (supports S5)
ACPI: Using IOAPIC for interrupt routing
ACPI: PCI Root Bridge [PCI0] (:00)
* Found PM-Timer Bug on the chipset. Due to workarounds for a bug,
* this clock source is slow. Consider trying other clock sources
PCI quirk: region b000-b03f claimed by PIIX4 ACPI
PCI quirk: region b100-b10f claimed by PIIX4 SMB
ACPI: PCI Interrupt Link [LNKA] (IRQs 3 4 5 6 7 9 10 *11 12)
ACPI: PCI Interrupt Link [LNKB] (IRQs 3 4 5 6 7 *9 10 11 12)
ACPI: PCI Interrupt Link [LNKC] (IRQs 3 4 5 6 7 9 10 *11 12)
ACPI: PCI Interrupt Link

Re: [kvm-devel] windows 2003 smp guest

2007-09-20 Thread Luca
On 9/20/07, Farkas Levente [EMAIL PROTECTED] wrote:
 Dor Laor wrote:
  Haydn Solomon wrote:
  I have a question on guest smp performance. If I have a host with core
  2 duo, should a kvm guest perform better using -smp 2 as opposed to
  not using -smp 2?
 
  Well, it depends:
  In general Avi measured 40% performance increase for using a second cpu
  in the guest. This was long time ago,
  before the in-kernel-apic implementation. It might improve the gain of
  the additional cpu.
 
  On the other hand, for 32 bit windows, using ACPI HAL has pretty big
  overhead at the moment. Since it is a must
  for smp guest, it might be slower than running non-acpi single cpu VM.

 can you tell me what does the HAL means here? and what's kind of HAL
 exists what are the advantage/disadvantages them. how can i
 change/configure this?

Hardware Abstraction Layer. See:
http://support.microsoft.com/kb/99588
http://en.wikipedia.org/wiki/Architecture_of_Windows_NT

Luca

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [ANNOUNCE] kvm-40 release

2007-09-17 Thread Luca
On 9/17/07, Farkas Levente [EMAIL PROTECTED] wrote:
 Dor Laor wrote:
  i've try kvm-40 it now on centos-5 with kernel-2.6.18-8.1.10.el5 x86_64
 
  host (8gb ram and 4 core) and one centos-5 x86_64, centos-5 i386,
  mandrake i586 guests. i try to give 4 cpu for the first 2 guest and 1
  cpu for the last. after i start these 3 guests the host kernel crash all
  the time after the guest starts to boot. so i now try to switchback to
  kvm-36.
 
  It will be helpful to provide the oops/dmesg output.

 how? write it down with paper from the console? at the same time there's
 just a kernel stack dump and i can't scroll it up (eg with shift-page up).

A photo will do, but it's possible that the most interesting part has
been scrolled off screen. Can you setup a serial console
(Documentation/serial-console.txt) or at least netconsole
(Documentation/networking/netconsole.txt)?

 just to clarify, if i've a 4 core host cpus can i give 4 cpus for both
 of the 2 guests?

Yes, virtual CPUs are mapped to threads.

Luca

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [PATCH] Add support for a basic boot menu to the bios

2007-09-17 Thread Luca
On 9/16/07, Avi Kivity [EMAIL PROTECTED] wrote:
 - coding this stuff in rombios32.c instead of rombios.c (with its
 strange idea of C) is *much* preferable for maintainability.

The strange code style is due to the compiler used (bcc). I see that
today it's possible to make as and gcc to emit 16bit code (e.g. HPA
rewrote i386 boot code in plain C)...

Luca

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [ANNOUNCE] kvm-38 release

2007-09-14 Thread Luca
On 9/14/07, Avi Kivity [EMAIL PROTECTED] wrote:
 Haydn Solomon wrote:
  You guys are quick! Ok, kvm-39 allows me to run my windows xp machine
  now.  I just have one question that I'm not sure of.. should reboot be
  working now? I tried rebooting the windows xp and got the following
  output.
 

 Reboot was improved in kvm-39, but not completely fixed.  I'll nail it
 down in kvm-40 or kvm-41.

You can reboot linux guests passing reboot=b on kernel command line.
Don't know about win...

Luca

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] KDE4 beta2 LIve CD does not boot

2007-09-13 Thread Luca
On 9/13/07, Jörg Rödel [EMAIL PROTECTED] wrote:
 On Thu, Sep 13, 2007 at 05:01:57PM +0200, Magicboiz wrote:
  Hello list,
 
  I was trying the OpenSuse KDE4 beta2 live CD and:
 
  [EMAIL PROTECTED]:~/KVM$ sudo /usr/local/bin/qemu-system-x86_64 -m
  384 /media/disk/disco-generico.img -boot d
  -cdrom /media/disk/KDE-Four-Live.i686-0.4.iso -net nic -net
  tap,ifname=tap0,script=qemu-ifup
  Executing /etc/qemu-ifup
  Bringing up tap0 for bridged mode...
  Adding tap0 to br0...
  exception 6 (0)
  rax 00df rbx 0080 rcx  rdx
  009c
  rsi 00055e1c rdi 00055e1c rsp fffae1d0 rbp
  200c
  r8   r9   r10  r11
  
  r12  r13  r14  r15
  
  rip b020 rflags 00033882
  cs 4004 (00040040/ p 1 dpl 3 db 0 s 1 type 3 l 0 g 0 avl 0)
  ds 4004 (00040040/ p 1 dpl 3 db 0 s 1 type 3 l 0 g 0 avl 0)
  es 4004 (00040040/ p 1 dpl 3 db 0 s 1 type 3 l 0 g 0 avl 0)
  ss  (/ p 1 dpl 3 db 0 s 1 type 3 l 0 g 0 avl 0)
  fs 3002 (00030020/ p 1 dpl 3 db 0 s 1 type 3 l 0 g 0 avl 0)
  gs  (/ p 1 dpl 3 db 0 s 1 type 3 l 0 g 0 avl 0)
  tr  (1885/2088 p 1 dpl 0 db 0 s 0 type b l 0 g 0 avl 0)
  ldt  (/ p 1 dpl 0 db 0 s 0 type 2 l 0 g 0 avl 0)
  gdt 40920/47
  idt 0/
  cr0 6010 cr2 0 cr3 0 cr4 0 cr8 0 efer 0
  code: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -- 00
  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  00 00 00 00 00
  Cancelado (core dumped)

 Can you give us some additional information about your hardware? Does
 this happen on an Intel or an AMD host?

Confirmed here with kvm-intel and KVM 39. Invalid opcode (#UD) is
probably caused by the boot spash code which may be using big real
mode code.

Luca
-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] Build of kvm-37 fails

2007-09-10 Thread Luca
On 9/10/07, Pelle [EMAIL PROTECTED] wrote:
 The patch fixes build problems, however the modules won't load properly,
 I don't know if this is a seperate issue or not.

 kernel is ubuntu feisty 2.6.20-16-generic

 $sudo modprobe kvm-intel
 WARNING: Error inserting kvm
 (/lib/modules/2.6.20-16-generic/extra/kvm.ko): Unknown symbol in module,
 or unknown parameter (see dmesg)
 FATAL: Error inserting kvm_intel
 (/lib/modules/2.6.20-16-generic/extra/kvm-intel.ko): Unknown symbol in
 module, or unknown parameter (see dmesg)

 $dmesg
 [54716.482444] kvm: Unknown symbol __divdi3

kvm.ko fails to load due to a 64 bit division, see:

http://git.kernel.org/?p=linux/kernel/git/avi/kvm.git;a=commitdiff;h=e44af0f4ee99974ce40102e23784bc3cae7f4466

Luca


 [54716.492596] kvm_intel: Unknown symbol kvm_lapic_reset
 [54716.492638] kvm_intel: Unknown symbol kvm_migrate_apic_timer
 [54716.492684] kvm_intel: Unknown symbol set_cr3
 [54716.492750] kvm_intel: Unknown symbol kvm_put_guest_fpu
 [54716.492783] kvm_intel: Unknown symbol kvm_timer_intr_post
 [54716.492816] kvm_intel: Unknown symbol gfn_to_page
 [54716.492855] kvm_intel: Unknown symbol segment_base
 [54716.492888] kvm_intel: Unknown symbol kvm_get_msr_common
 [54716.492925] kvm_intel: Unknown symbol kvm_vcpu_uninit
 [54716.492959] kvm_intel: Unknown symbol kvm_emulate_halt
 [54716.492992] kvm_intel: Unknown symbol kvm_set_apic_base
 [54716.493025] kvm_intel: Unknown symbol kvm_get_apic_base
 [54716.493058] kvm_intel: Unknown symbol kvm_load_guest_fpu
 [54716.493100] kvm_intel: Unknown symbol kvm_lapic_find_highest_irr
 [54716.493133] kvm_intel: Unknown symbol emulator_write_emulated
 [54716.493167] kvm_intel: Unknown symbol kvm_exit_arch
 [54716.493202] kvm_intel: Unknown symbol emulate_instruction
 [54716.493244] kvm_intel: Unknown symbol kvm_inject_pending_timer_irqs
 [54716.493282] kvm_intel: Unknown symbol special_reload_dr7
 [54716.493316] kvm_intel: Unknown symbol fx_init
 [54716.493349] kvm_intel: Unknown symbol kvm_create_lapic
 [54716.493386] kvm_intel: Unknown symbol in_special_section
 [54716.493428] kvm_intel: Unknown symbol set_cr4
 [54716.493462] kvm_intel: Unknown symbol kvm_cpu_has_interrupt
 [54716.493496] kvm_intel: Unknown symbol kvm_lapic_get_cr8
 [54716.493544] kvm_intel: Unknown symbol lmsw
 [54716.493577] kvm_intel: Unknown symbol kvm_hypercall
 [54716.493610] kvm_intel: Unknown symbol kvm_vcpu_cache
 [54716.493644] kvm_intel: Unknown symbol get_cr8
 [54716.493679] kvm_intel: Unknown symbol end_special_insn
 [54716.493731] kvm_intel: Unknown symbol kvm_init_arch
 [54716.493777] kvm_intel: Unknown symbol set_cr0
 [54716.493811] kvm_intel: Unknown symbol kvm_lapic_enabled
 [54716.493843] kvm_intel: Unknown symbol emulator_read_std
 [54716.493883] kvm_intel: Unknown symbol start_special_insn
 [54716.493922] kvm_intel: Unknown symbol set_cr8
 [54716.493955] kvm_intel: Unknown symbol kvm_emulate_cpuid
 [54716.493992] kvm_intel: Unknown symbol kvm_vcpu_init
 [54716.494034] kvm_intel: Unknown symbol kvm_set_msr_common
 [54716.494074] kvm_intel: Unknown symbol kvm_mmu_load
 [54716.494108] kvm_intel: Unknown symbol kvm_cpu_get_interrupt
 [54716.494141] kvm_intel: Unknown symbol kvm_emulate_pio
 [54716.494174] kvm_intel: Unknown symbol kvm_resched


 Avi Kivity wrote:
  Pelle wrote:
  Hi,
 
  I tried to compile the new kvm-37, and got the following errors:
 
  regards, Pelle
 
 
 
 
  Does the attached patch help?
 

 -
 This SF.net email is sponsored by: Microsoft
 Defy all challenges. Microsoft(R) Visual Studio 2005.
 http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
 ___
 kvm-devel mailing list
 kvm-devel@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/kvm-devel


-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [BUG][PATCH?] kvm: unhandled wrmsr: 0xc0000083

2007-09-09 Thread Luca Tettamanti
Il Sun, Sep 09, 2007 at 03:51:20PM +0300, Avi Kivity ha scritto: 
 Luca Tettamanti wrote:
 Actually 0xfff2 is in the middle of an instruction.

 I'm guessing an 'out' instruction triggered the reboot, and 
 skip_emulated_instruction() added 2 to rip.
 

 I think you're right; the reset is triggered by an outb to 0x64.

 Now, with this patch:

 diff --git a/qemu/qemu-kvm.c b/qemu/qemu-kvm.c
 index 491c32c..722d838 100644
 --- a/qemu/qemu-kvm.c
 +++ b/qemu/qemu-kvm.c
 @@ -706,8 +706,12 @@ static void update_regs_for_sipi(CPUState *env)
   static void update_regs_for_init(CPUState *env)
  {
 -cpu_reset(env);
 -load_regs(env);
 +if (env-cpu_index) {
 +cpu_reset(env);
 +load_regs(env);
 +} else {
 + vcpu_info[env-cpu_index].init = 0;
 +}
  }
   

 Can you explain this patch?  Why is the boot cpu treated differently?
 I think the only difference should be the halted flag.

The reset has already been done by qmeu_system_reset(), so it's
superfluous. Furthermore, the extra reset causes the vmentry failure. I
still don't understand which check is failing though...

   static void setup_kernel_sigmask(CPUState *env)

 I can reboot using the BIOS (reboot=b) without the outb. I fail to see
 why an extra reset causes the vm entry failure though.

 Default reboot path (i.e. the outb) still fails:

 exception 13 (0)
 rax  rbx  rcx  rdx 
 0700
 rsi  rdi  rsp  rbp 
 
 r8   r9   r10  r11 
 
 r12  r13  r14  r15 
 
 rip  rflags 00033046
 cs f000 (000f/ p 1 dpl 3 db 0 s 1 type 3 l 0 g 0 avl 0)
 ds  (/ p 1 dpl 3 db 0 s 1 type 3 l 0 g 0 avl 0)
 es  (/ p 1 dpl 3 db 0 s 1 type 3 l 0 g 0 avl 0)
 ss  (/ p 1 dpl 3 db 0 s 1 type 3 l 0 g 0 avl 0)
 fs  (/ p 1 dpl 3 db 0 s 1 type 3 l 0 g 0 avl 0)
 gs  (/ p 1 dpl 3 db 0 s 1 type 3 l 0 g 0 avl 0)
 tr 0080 (1085/2088 p 1 dpl 0 db 0 s 0 type b l 0 g 0 avl 0)
 ldt  (/ p 1 dpl 0 db 0 s 0 type 2 l 0 g 0 avl 0)
 gdt 0/
 idt 0/
 cr0 6010 cr2 0 cr3 0 cr4 0 cr8 0 efer 0
 code: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -- 00 
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
 00 00 00 00

 the #GP makes more sense than the vm entry failure if the the emulator
 is jumping to fff2.

 Right.  Maybe the processor dropped out of vm86 mode and we're getting #gp 
 on ds.

Ok, the culprit really is skip_emulated_instruction: skipping the
increment when EIP is 0xfff0 allows rebooting (yes, it's disgusting...)

So I think that there are two different issues:

1) Extra reset in update_regs_for_init causes vm entry failure due to
   invalid guest state

2) The emulator is doing something wrong since it used to handle the
   reset just fine

Luca
-- 
Una donna sposa un uomo sperando che cambi, e lui non cambiera`. Un
uomo sposa una donna sperando che non cambi, e lei cambiera`.

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [BUG] GPF on hardware breakpoints (preempt_notifier)

2007-09-09 Thread Luca Tettamanti
Hi,
while debugging a program with GDB I got a GPF which seems related to
KVM. Note that I was *not* using the debugger inside the guest nor on
the virtual machine. The target was an unrelated userspace program.

This is the GPF:

general protection fault:  [#1]
PREEMPT SMP
Modules linked in: kvm_intel kvm bridge llc tun radeon drm binfmt_misc
nfs cpufreq_stats cpufreq_userspace cpufreq_powersave
cpufreq_conservative microcode firmware_class cls_u32 cls_route sch_sfq
sch_cbq des cbc blkcipher sha1 md5 hmac crypto_hash cryptomgr
crypto_algapi nfsd exportfs lockd sunrpc fuse cpufreq_ondemand
acpi_cpufreq freq_table ipv6 usblp snd_hda_intel snd_pcm_oss ohci1394
snd_mixer_oss atl1 ieee1394 iTCO_wdt parport_pc parport i2c_i801 rtc
e100 snd_pcm snd_timer button mii ehci_hcd snd uhci_hcd intel_agp
usbcore soundcore snd_page_alloc agpgart dm_snapshot dm_mod thermal
processor fan vfat fat nls_cp850 nls_iso8859_15 ntfs nls_base pata_ali
sata_uli pata_jmicron reiserfs xfs
CPU:1
EIP:0060:[f9cfaac4]Not tainted VLI
EFLAGS: 00010002   (2.6.23-rc5-libata-gb21010ed-dirty #96)
EIP is at preempt_notifier_trigger+0x7/0x7a [kvm]
eax: f9cff460   ebx: b7f29ff4   ecx: bf91aa60   edx: bf91aa80
esi: b7f61ce0   edi:    ebp: bf91aa48   esp: e03e9fb8
ds: 007b   es: 007b   fs:   gs: 0033  ss: 0068
Process p (pid: 13319, ti=e03e9000 task=f5d02530 task.ti=e03e9000)
Stack: b7f29ff4 b7f61ce0 f9cfa8be  b7f61ce0 bf91aa48 e03e9fe4 b7f29ff4
   bf91aa80 bf91aa60 0001 0804835f 0073 0202 bf91aa44 007b
    
Call Trace:
 [f9cfa8be] pn_int1_handler+0x12/0x22 [kvm]
 ===
Code: b8 01 00 00 00 e8 7e 43 42 c6 89 e0 25 00 f0 ff ff 8b 40 08 a8 04
74 08 5b 5e 5f e9 93 51 5f c6 5b 5e 5f c3 56 b8 60 f4 cf f9 53 64 8b
35 08 20 42 c0 e8 48 77 5f c6 8b 1d 84 f4 cf f9 89 c2 eb
EIP: [f9cfaac4] preempt_notifier_trigger+0x7/0x7a [kvm] SS:ESP 0068:e03e9fb8

To reproduce just set a hw breakpoint (e.g. watch inside GDB) while a VM
is running. As soon as the breakpoint is hit you get at GPF...

Host userspace and kernel are 32bit, the CPU is a Core2:

processor   : 0
vendor_id   : GenuineIntel
cpu family  : 6
model   : 15
model name  : Intel(R) Core(TM)2 CPU  6400  @ 2.13GHz
stepping: 6
cpu MHz : 1596.000
cache size  : 2048 KB
physical id : 0
siblings: 2
core id : 0
cpu cores   : 2
fdiv_bug: no
hlt_bug : no
f00f_bug: no
coma_bug: no
fpu : yes
fpu_exception   : yes
cpuid level : 10
wp  : yes
flags   : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov 
pat
  pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe nx lm
  constant_tsc arch_perfmon pebs bts pni monitor ds_cpl vmx est 
tm2
  ssse3 cx16 xtpr lahf_lm
bogomips: 4274.53
clflush size: 64

Luca
-- 
Quando un uomo porta dei fiori a sua moglie senza motivo, 
un motivo c'e`.

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [BUG] GPF on hardware breakpoints (preempt_notifier)

2007-09-09 Thread Luca
On 9/9/07, Avi Kivity [EMAIL PROTECTED] wrote:
 Luca Tettamanti wrote:
  Hi,
  while debugging a program with GDB I got a GPF which seems related to
  KVM. Note that I was *not* using the debugger inside the guest nor on
  the virtual machine. The target was an unrelated userspace program.
 

 Yes, kvm is dirtily misappropriating the debug registers on older
 kernels.

I'm runninng the current Linus' git tree, shall I test kvm.git?

Luca

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [BUG] GPF on hardware breakpoints (preempt_notifier)

2007-09-09 Thread Luca
On 9/9/07, Anthony Liguori [EMAIL PROTECTED] wrote:
 Luca wrote:
  On 9/9/07, Avi Kivity [EMAIL PROTECTED] wrote:
 
  Luca Tettamanti wrote:
 
  Hi,
  while debugging a program with GDB I got a GPF which seems related to
  KVM. Note that I was *not* using the debugger inside the guest nor on
  the virtual machine. The target was an unrelated userspace program.
 
 
  Yes, kvm is dirtily misappropriating the debug registers on older
  kernels.
 
 
  I'm runninng the current Linus' git tree, shall I test kvm.git?
 

 Do you have CONFIG_PREEMPT_NOTIFIERS enabled?

No, it's disabled.

Luca

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] (long) kvm and virt-manager not ready for daily usage

2007-09-08 Thread Luca
On 9/8/07, Farkas Levente [EMAIL PROTECTED] wrote:
 kvm is not ready for production use for many reason:
 it can't reboot which imho a very basic feature, what's more can't even
 shutdown/poweroff. the centos i386 guest are not able to shutdown on the
 x86_64 host (strange the x86_64 centos and the i586 mandrake-9 are able
 to shutdown) or what's seems to be more likely it's a random think.

Reboot failure is a regression; for shutdown you should enable APCI
with acpi=force; bochs BIOS doesn't have SMBIOS/DMI tables and Linux
may refuse to use ACPI without them (it depends on the configuration).

Luca

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] Intel-only or AMD Opteron as well?

2007-09-08 Thread Luca
On 9/8/07, Fernando Cassia [EMAIL PROTECTED] wrote:

 This is my first message to the list, and I've just discovered KVM... so
 please have patience with my (probably stupid and answered in some FAQ
 already ;) questions...

Yep, it's in the FAQ:
http://kvm.qumranet.com/kvmwiki/FAQ#head-089ef3cae348adfe76a2e614b3c551f811d71234
http://kvm.qumranet.com/kvmwiki/FAQ#head-a78f5f083749cb9c2e57d7d4efaf2ecf25b9db60
http://kvm.qumranet.com/kvmwiki/FAQ#head-1c0d0eb479b0cbd8cd4b2d04e3d8fbc9710ba666

 It supposedly includes AMD's virtualization features, aka Pacifica.
 The $1M (or $0.02) question is... does KVM include any optimizations for the
 AMD virtualization extensions?

Yes, load kvm-amd.

Luca

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] (long) kvm and virt-manager not ready for daily usage

2007-09-08 Thread Luca
On 9/8/07, Farkas Levente [EMAIL PROTECTED] wrote:
 Luca wrote:
  On 9/8/07, Farkas Levente [EMAIL PROTECTED] wrote:
  kvm is not ready for production use for many reason:
  it can't reboot which imho a very basic feature, what's more can't even
  shutdown/poweroff. the centos i386 guest are not able to shutdown on the
  x86_64 host (strange the x86_64 centos and the i586 mandrake-9 are able
  to shutdown) or what's seems to be more likely it's a random think.
 
  Reboot failure is a regression; for shutdown you should enable APCI
  with acpi=force; bochs BIOS doesn't have SMBIOS/DMI tables and Linux
  may refuse to use ACPI without them (it depends on the configuration).

 when, where, how? is there any docs about it?

Add acpi=force on guest kernel command line.

Luca

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] Intel-only or AMD Opteron as well?

2007-09-08 Thread Luca
On 9/8/07, Fernando Cassia [EMAIL PROTECTED] wrote:
 Point #3: Xen vs KVM... I'm confused

 The above move by RedHat is a bit confusing... what can Xen do that KVM
 cannot?. In other words, why should anyone even bother with Xen with KVM
 around ??.

Xen is probably more mature, and has more more management tools. Plus
it's already known and deployed in the enterprise world. On the
downside Xen is big, while KVM is simpler.

  I've read Xen is more robust because it has a one year lead
 over KVM. But really, how does this translate, if performance of Xen could
 be worse due to more paravirtualization?.

Paravirtualization is not a bad thing ;-) If you cannot modify the
guest then of course a fully virtualized VM is needed, but if you can
modify it (by e.g. loading a special driver) then PV is likely to give
some speed enhancements.
The first obvious area for PV is device drivers: emulating a network
card (or a disk controller, or...) wastes a lot of cycles, it makes
lots of sense to use a special driver virtualization-aware driver that
speeds up the communication between the guest and the host. VirtIO for
example is all about flipping pages between guest and host.
Another class of operations the can be PVirtualized are privileged
instructions that may affect the global state of the machine. E.g. you
don't want the guest to be able to _really_ turn interrupts off;
instead you trap the 'cli' and stop sending interrupts to it. If the
guest is aware of the virtualization it can politely ask the guest to
stop interrupt delivery (instead of going through trap+emulate). ATM
Linux supports the paravirt_ops infrastructure that covers interrupts
delivery, page table / MMU management, APIC, MSR (and maybe other
stuff). This second class of PV ops requires modification of core
parts of the guest operating system; while it's certainly possible to
create a win32 driver for e.g. a PV network card it's impossible to do
the same for paravirt_ops.

 Or is Xen more optimized to
 provide the greatest possible consolidation on servers (ie less resource
 usage, less impact on cpu usage of a high number of VMs?).

Xen supported paravirt-only guest, but gained support for full
virtualization. KVM started as full virtualization solution but is now
gaining PV support (at least for network and block devices - I think
kvm-lite will go further).

  Finally... after reading about Xen and KVM(this KVM, not Sun's ;), I
 wonder... the FAQ says Xen does more paravirtualization, whereas KVM uses
 the CPU's own virtualization features. Yet I visit some articles like this
 one

 http://aplawrence.com/Linux/kvm_virtualization.html

  which claims that Xen is THE FASTEST approach to virtualization. How can
 it be faster since it uses paravirtualization (software) instead of direct
 hardware virtualization features as KVM?

See above. Doing software _emulation_ of the guest is slow. A PV guest
can coordinate very efficiently with the host.

Luca

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] kvm guests are not able to restart

2007-09-03 Thread Luca
On 9/3/07, Avi Kivity [EMAIL PROTECTED] wrote:
 Farkas Levente wrote:
  Luca wrote:
 
  On 9/3/07, Farkas Levente [EMAIL PROTECTED] wrote:
 
  hi,
  i've got a centos-5 x86_64 kvm-35 host system with one centos-5 i386 and
  one x86_64 guests. but none of the guest are able to restart. ie. i
  login to the guests and restart it. it start's as normal reboot, but
  after the last command (shuting down md device) it's do nothing, but in
  virt-manager i see 50% load on the guest. the biggest problem currently
  i can't find any way to restart any guest's other then shutdown and use
  virt-manager and restart them:-(
  what can be a problem? is it a known bug or it's just not working for me?
 
  It's known, but ATM there's no fix available. For more details see:
  http://thread.gmane.org/gmane.comp.emulators.kvm.devel/5651/focus=6003
  and following mails.
 
 
  is this really true? this means kvm are not usable any real environment
  since imho the feature to be able to reboot a server is essential!
 

 It's true unfortunately.  A fix will be available shortly.

I haven't tested but reboot=b (go back in real mode and pass control
to BIOS) may work.

Luca

-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now   http://get.splunk.com/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [BUG][PATCH?] kvm: unhandled wrmsr: 0xc0000083

2007-09-03 Thread Luca Tettamanti
Il Mon, Aug 20, 2007 at 10:58:57AM +0300, Avi Kivity ha scritto: 
 Luca Tettamanti wrote:
 In order to reactivate the CPU after the reset. When the guest reboots I
 get an unhandled vm exit:

 unhandled vm exit:  0x8021
 rax  rbx  rcx  rdx 
 0600
 rsi  rdi  rsp  rbp 
 
 r8   r9   r10  r11 
 
 r12  r13  r14  r15 
 
 rip fff2 rflags 0002
 cs f000 (000f/ p 1 dpl 3 db 0 s 1 type 3 l 0 g 0 avl 0)
 ds  (/ p 1 dpl 3 db 0 s 1 type 3 l 0 g 0 avl 0)
 es  (/ p 1 dpl 3 db 0 s 1 type 3 l 0 g 0 avl 0)
 ss  (/ p 1 dpl 3 db 0 s 1 type 3 l 0 g 0 avl 0)
 fs  (/ p 1 dpl 3 db 0 s 1 type 3 l 0 g 0 avl 0)
 gs  (/ p 1 dpl 3 db 0 s 1 type 3 l 0 g 0 avl 0)
 tr 0080 (1085/2088 p 1 dpl 0 db 0 s 0 type b l 0 g 0 avl 0)
 ldt  (/ p 1 dpl 0 db 0 s 0 type 2 l 0 g 0 avl 0)
 gdt 0/
 idt 0/
 cr0 6010 cr2 0 cr3 0 cr4 0 cr8 0 efer 0

 which is a vm entry failure due to invalid guest state (RIP looks good
 though :P)
   

 Actually 0xfff2 is in the middle of an instruction.

 I'm guessing an 'out' instruction triggered the reboot, and 
 skip_emulated_instruction() added 2 to rip.

I think you're right; the reset is triggered by an outb to 0x64.

Now, with this patch:

diff --git a/qemu/qemu-kvm.c b/qemu/qemu-kvm.c
index 491c32c..722d838 100644
--- a/qemu/qemu-kvm.c
+++ b/qemu/qemu-kvm.c
@@ -706,8 +706,12 @@ static void update_regs_for_sipi(CPUState *env)
 
 static void update_regs_for_init(CPUState *env)
 {
-cpu_reset(env);
-load_regs(env);
+if (env-cpu_index) {
+cpu_reset(env);
+load_regs(env);
+} else {
+ vcpu_info[env-cpu_index].init = 0;
+}
 }
 
 static void setup_kernel_sigmask(CPUState *env)

I can reboot using the BIOS (reboot=b) without the outb. I fail to see
why an extra reset causes the vm entry failure though.

Default reboot path (i.e. the outb) still fails:

exception 13 (0)
rax  rbx  rcx  rdx 
0700
rsi  rdi  rsp  rbp 

r8   r9   r10  r11 

r12  r13  r14  r15 

rip  rflags 00033046
cs f000 (000f/ p 1 dpl 3 db 0 s 1 type 3 l 0 g 0 avl 0)
ds  (/ p 1 dpl 3 db 0 s 1 type 3 l 0 g 0 avl 0)
es  (/ p 1 dpl 3 db 0 s 1 type 3 l 0 g 0 avl 0)
ss  (/ p 1 dpl 3 db 0 s 1 type 3 l 0 g 0 avl 0)
fs  (/ p 1 dpl 3 db 0 s 1 type 3 l 0 g 0 avl 0)
gs  (/ p 1 dpl 3 db 0 s 1 type 3 l 0 g 0 avl 0)
tr 0080 (1085/2088 p 1 dpl 0 db 0 s 0 type b l 0 g 0 avl 0)
ldt  (/ p 1 dpl 0 db 0 s 0 type 2 l 0 g 0 avl 0)
gdt 0/
idt 0/
cr0 6010 cr2 0 cr3 0 cr4 0 cr8 0 efer 0
code: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -- 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

the #GP makes more sense than the vm entry failure if the the emulator
is jumping to fff2.

Luca
-- 
Il piu` bel momento dell'amore e` quando ci si illude che duri per 
sempre; il piu` brutto, quando ci si accorge che dura da troppo.

-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now   http://get.splunk.com/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [RFC][PATCH 5/6][KVM VIRTIO] Add the network device code

2007-08-29 Thread Luca
On 8/29/07, Cam Macdonell [EMAIL PROTECTED] wrote:
 Dor Laor wrote:
  The code can now be accessed by git:
  git://kvm.qumranet.com/home/dor/src/virtio/kvm (kernel) and
  git://kvm.qumranet.com/home/dor/src/virtio/kvm-userspace.
  branch name virt-final.
  --Dor

 I'm really new to git and don't quite grasp it's subtleties.  Do I have
 to git clone your kvm kernel and user-space repos or is there some way
 to use your branch as a branch off Avi's?  I tried finding an online
 reference, but none seem to cover this kind of setup.

If Dor's repository is based on the Avi's one (I think so) you can
pull virt-final branch as a branch of you existing repository (see
refspec parameter in git-pull). This is error prone though (after a
while I tend to pull the wrong tree into the wrong branch ;-) )
I prefer to clone the whole tree (disk space is cheap...), sharing GIT
object where possible, e.g.

git clone --reference kvm.avi
git://kvm.qumranet.com/home/dor/src/virtio/kvm kvm.dor

where kvm.avi is you existing kvm git repository.

Luca

-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now   http://get.splunk.com/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [RFC][PATCH 5/6][KVM VIRTIO] Add the network device code

2007-08-29 Thread Luca
On 8/29/07, Cam Macdonell [EMAIL PROTECTED] wrote:
 Luca wrote:
  On 8/29/07, Cam Macdonell [EMAIL PROTECTED] wrote:
  Dor Laor wrote:
  The code can now be accessed by git:
  git://kvm.qumranet.com/home/dor/src/virtio/kvm (kernel) and
  git://kvm.qumranet.com/home/dor/src/virtio/kvm-userspace.
  branch name virt-final.
  --Dor
  I'm really new to git and don't quite grasp it's subtleties.  Do I have
  to git clone your kvm kernel and user-space repos or is there some way
  to use your branch as a branch off Avi's?  I tried finding an online
  reference, but none seem to cover this kind of setup.
 
  If Dor's repository is based on the Avi's one (I think so) you can
  pull virt-final branch as a branch of you existing repository (see
  refspec parameter in git-pull). This is error prone though (after a
  while I tend to pull the wrong tree into the wrong branch ;-) )
  I prefer to clone the whole tree (disk space is cheap...), sharing GIT
  object where possible, e.g.
 
  git clone --reference kvm.avi
  git://kvm.qumranet.com/home/dor/src/virtio/kvm kvm.dor
 

 Thanks Luca,

 I get this error:

 [EMAIL PROTECTED] ~/research/KVM]$ git clone --reference kvm
 git://kvm.qumranet.com/home/dor/src/virtio/kvm.git kvm.dor
 Initialized empty Git repository in /home/cam/research/KVM/kvm.dor/.git/
 fatal: The remote end hung up unexpectedly
 fetch-pack from 'git://kvm.qumranet.com/home/dor/src/virtio/kvm.git' failed.

 Is there a problem with the repositor or am I doing something wrong?

The command is correct. It seems that either the repository is not
configured for export or the path is wrong.

Luca

-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now   http://get.splunk.com/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [RFC][PATCH 5/6][KVM VIRTIO] Add the network device code

2007-08-28 Thread Luca
On 8/25/07, Dor Laor [EMAIL PROTECTED] wrote:

I just noticed this:

 --- /dev/null
 +++ b/qemu/hw/paravirt_net.c
 @@ -0,0 +1,213 @@
 +/*
 + * QEMU para virtual network emulation
 + *
 + * Copyright (c) 2007 Qumranet
 + *
 + * Permission is hereby granted, free of charge, to any person
 obtaining a copy
 + * of this software and associated documentation files (the
 Software), to deal
 + * in the Software without restriction, including without limitation
 the rights
 + * to use, copy, modify, merge, publish, distribute, sublicense, and/or
 sell
 + * copies of the Software, and to permit persons to whom the Software
 is
 + * furnished to do so, subject to the following conditions:
 + *
 + * The above copyright notice and this permission notice shall be
 included in
 + * all copies or substantial portions of the Software.
[cut]

Shouldn't you use the standard GPL boilerplate? (IANAL, so maybe the
text above is a superset of the GPL and is fine...)

Luca

-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now   http://get.splunk.com/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [BUG] kvm_lock: inconsistent lock state

2007-08-27 Thread Luca Tettamanti
Hi,
I just got this warning when doing a 'rmmod kvm-intel':

=
[ INFO: inconsistent lock state ]
2.6.23-rc3-libata-g28e8351a-dirty #93
-
inconsistent {hardirq-on-W} - {in-hardirq-W} usage.
udevd/2800 [HC1[1]:SC0[0]:HE0:SE1] takes:
 (kvm_lock){+-..}, at: [f9c8718b] hardware_disable+0x31/0xbc [kvm]
{hardirq-on-W} state was registered at:
  [c013e95d] __lock_acquire+0x487/0xbcc
  [c013e1e1] debug_check_no_locks_freed+0x110/0x11a
  [c01cd920] __next_cpu+0x12/0x21
  [c0146ab6] is_module_address+0x35/0x92
  [c013f490] lock_acquire+0x68/0x80
  [f9c87039] kvm_dev_ioctl+0xb5/0x1c8 [kvm]
  [c02f19ce] _spin_lock+0x36/0x5f
  [f9c87039] kvm_dev_ioctl+0xb5/0x1c8 [kvm]
  [f9c87039] kvm_dev_ioctl+0xb5/0x1c8 [kvm]
  [c0119386] do_page_fault+0x30d/0x734
  [f9c86f84] kvm_dev_ioctl+0x0/0x1c8 [kvm]
  [c01756cf] do_ioctl+0x1f/0x62
  [c0175949] vfs_ioctl+0x237/0x249
  [c013e0ae] trace_hardirqs_on+0x11a/0x13d
  [c017598e] sys_ioctl+0x33/0x4d
  [c0103f3e] syscall_call+0x7/0xb
  [] 0x
irq event stamp: 682504
hardirqs last  enabled at (682503): [c0151ce8] 
get_page_from_freelist+0x18c/0x35c
hardirqs last disabled at (682504): [c01049d5] 
call_function_interrupt+0x29/0x38
softirqs last  enabled at (679024): [c01067ed] do_softirq+0x61/0xd1
softirqs last disabled at (679017): [c01067ed] do_softirq+0x61/0xd1

other info that might help us debug this:
1 lock held by udevd/2800:
 #0:  (inode-i_mutex){--..}, at: [c01660d8] shmem_file_write+0x7e/0x2a6

stack backtrace:
 [c013d370] print_usage_bug+0x138/0x142
 [c013db02] mark_lock+0xae/0x44a
 [c02f1fc9] _spin_unlock+0x25/0x3b
 [c013e8ec] __lock_acquire+0x416/0xbcc
 [c013f490] lock_acquire+0x68/0x80
 [f9c8718b] hardware_disable+0x31/0xbc [kvm]
 [c02f19ce] _spin_lock+0x36/0x5f
 [f9c8718b] hardware_disable+0x31/0xbc [kvm]
 [f9c8715a] hardware_disable+0x0/0xbc [kvm]
 [f9c8718b] hardware_disable+0x31/0xbc [kvm]
 [c013c3c8] lock_release_holdtime+0x3d/0x4a
 [f9c8715a] hardware_disable+0x0/0xbc [kvm]
 [c0113bcf] smp_call_function_interrupt+0x37/0x52
 [c01049df] call_function_interrupt+0x33/0x38
 [c01100d8] p4_rearm+0x4/0xf2c
 [c0151df1] get_page_from_freelist+0x295/0x35c
 [c0151f17] __alloc_pages+0x5f/0x295
 [c013c377] put_lock_stats+0xa/0x1e
 [c0165816] shmem_getpage+0x38c/0x59a
 [c02f06bf] __mutex_lock_slowpath+0x290/0x298
 [c0166185] shmem_file_write+0x12b/0x2a6
 [c016605a] shmem_file_write+0x0/0x2a6
 [c016be5a] vfs_write+0x8a/0x10c
 [c016c3d3] sys_write+0x41/0x67
 [c0103f3e] syscall_call+0x7/0xb
 ===

(this is kvm-36, but the bug was there in previous versions too)

kvm_lock is taken in kvm_create_vm with interrupts enabled. Later - at
rmmod time - it's used in decache_vcpus_on_cpu (hardware_disable) with
interrupts disabled (due to on_each_cpu). In theory it should be
harmless since the refcount on /dev/kvm prevents the deadlock.
Switching to irq-safe spin_lock_* seems fine, do you want a patch?

Luca
-- 
Vorrei morire ucciso dagli agi. Vorrei che di me si dicesse: ``Com'�
morto?'' ``Gli � scoppiato il portafogli'' -- Marcello Marchesi

-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now   http://get.splunk.com/___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] Userspace hypercalls?

2007-08-27 Thread Luca
On 8/27/07, Avi Kivity [EMAIL PROTECTED] wrote:
 Anthony Liguori wrote:
  On Mon, 2007-08-27 at 20:36 +0300, Avi Kivity wrote:
   userspace can
  attach a signal to the eventfd if it wants a synchronous exit (does
  eventfd allow fcntl(F_SETOWN)?)
 
  Which would address the latency issue nicely.  Looking at the fs code,
  it looks like eventfd shouldn't have to do anything special for it.

 I'm not sure now.  Which thread will be selected for accepting the
 signal?

It's not specified.

 if it isn't guaranteed to be the current thread, we're back
 with scheduler involvement, and possibly cacheline bouncing.

It's possible to use pthread_sigmask() to block the signal on all
threads but one. But this would require changing the rest of the
emulator; why not just select() the fd in a dedicated thread?

Luca

-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now   http://get.splunk.com/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] KVM-36 compile error on Fedora 7

2007-08-25 Thread Luca Tettamanti
Mark Bidewell ha scritto: 
 On 8/24/07, Luca [EMAIL PROTECTED] wrote:
 
  On 8/25/07, Mark Bidewell [EMAIL PROTECTED] wrote:
   When building kvm-36 with the latest Fedora kernel I get the error:
  
   kvmctl.c: In function 'kvm_run':
   kvmctl.c:1046: error: 'KVM_EXIT_SET_TPR' undeclared (first use in this
   function)
   kvmctl.c:1046: error: (Each undeclared identifier is reported only once
   kvmctl.c:1046: error: for each function it appears in.)
   make[1]: *** [kvmctl.o] Error 1
   make[1]: Leaving directory `/opt/kvm-36/user'
   make: *** [user] Error 2
[...]
 make -C kernel
 make[1]: Entering directory `/opt/kvm-36/kernel'
 make -C /lib/modules/2.6.22.4-65.fc7/build M=`pwd` $@
 make[2]: Entering directory `/usr/src/kernels/2.6.22.4-65.fc7-x86_64'

Ops sorry, I misread the original message. The problematic part is the
userspace component. I can't see how it manages to include the wrong
kvm.h though.
Are you using the tar.gz package or the git tree?

Please also post the output of:

make -C user kvmctl.o

Oh, and try also:

grep -r KVM_EXIT_SET_TPR *

just in case :)

Luca
-- 
Tentare e` il primo passo verso il fallimento.
Homer J. Simpson

-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now   http://get.splunk.com/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] KVM-36 compile error on Fedora 7

2007-08-25 Thread Luca
On 8/25/07, Mark Bidewell [EMAIL PROTECTED] wrote:
 I am using the tarball from sourceforge.  Here is the output to 'make -C
 user kvmctl.o'

 [EMAIL PROTECTED] kvm-36]# make -C user kvmctl.o
 make: Entering directory `/opt/kvm-36/user'
 cc -I /usr/src/kernels/2.6.22.4- 65.fc7-x86_64/include -MMD -MF ./.kvmctl.d
 -g -fomit-frame-pointer -Wall -m64  -fno-stack-protector -c -o kvmctl.o

The include directory is wrong. Have you used --with-patched-kernel?

Luca

-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now   http://get.splunk.com/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] KVM-36 compile error on Fedora 7

2007-08-25 Thread Luca
On 8/25/07, Mark Bidewell [EMAIL PROTECTED] wrote:
 Yes I did use --with-patched-kernel.

Don't. You don't have a patched kernel ;-)

 Here is my configure command line:

 ./configure --with-patched-kernel --prefix=/opt/kvm

Which means that you are going to use your own kernel modules. Do you
*really* want to do that?

Luca

-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now   http://get.splunk.com/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [Qemu-devel] [PATCH 3/4] Add support for HPET periodic timer.

2007-08-24 Thread Luca
On 8/23/07, Dan Kenigsberg [EMAIL PROTECTED] wrote:
 On Thu, Aug 23, 2007 at 12:09:47AM +0200, Andi Kleen wrote:
   $ dmesg |grep -i hpet
   ACPI: HPET 7D5B6AE0, 0038 (r1 A M I  OEMHPET   5000708 MSFT   97)
   ACPI: HPET id: 0x8086a301 base: 0xfed0
   hpet0: at MMIO 0xfed0, IRQs 2, 8, 0, 0
   hpet0: 4 64-bit timers, 14318180 Hz
   hpet_resources: 0xfed0 is busy
 
  What kernel version was that? There was a bug that caused this pre .22
 

 I have vanilla 2.6.22.3 on that machine.

Try:
cat /sys/devices/system/clocksource/clocksource0/available_clocksource

do you see HPET listed twice?

Luca

-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now   http://get.splunk.com/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] serious-looking warning building kvm-36

2007-08-23 Thread Luca
On 8/23/07, Chris Clayton [EMAIL PROTECTED] wrote:
 Hi,

 I've just built kvm-36 and noticed what looks as if it may be a non-trivial
 warning:

 make[1]: Leaving directory `/home/chris/rpm/BUILD/kvm-36/kernel'
 make -C user
 make[1]: Entering directory `/home/chris/rpm/BUILD/kvm-36/user'
 cc -I /home/chris/rpm/BUILD/kvm-36/kernel/include -MMD -MF ./.kvmctl.d -g 
 -fomit-frame-pointer -Wall -m32  -fno-stack-protector -c -o
 kvmctl.o kvmctl.c
 kvmctl.c: In function 'kvm_create':
 kvmctl.c:256: warning: integer constant is too large for 'long' type

 Please cc me to any reply - I'm not subscribed.

It's harmless. That branch is only taken when using more than 4GB of
memory, which in turn is only possible on a 64bit host. In this case
the 'unsigned long' would be a 64bit integer (and the shift would be
acceptable).
There are a couple more of warning related to this issue, a possible
solution to silence the warning is to use always 64bit integers
instead of the longs.

Luca

-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now   http://get.splunk.com/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] tun/tap kernel module

2007-08-23 Thread Luca
On 8/23/07, Cam Macdonell [EMAIL PROTECTED] wrote:
 I'm trying to setup networking on FC6.  Where can I find the tun/tap
 interface?

CONFIG_TUN

But I'm pretty sure that default FC kernel has the module already built. Try:
modprobe tun

Luca

-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now   http://get.splunk.com/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [PATCH 0/4] Rework alarm timer infrastrucure - take2

2007-08-22 Thread Luca
On 8/22/07, Avi Kivity [EMAIL PROTECTED] wrote:
 Luca wrote:
  This is QEMU, with dynticks and HPET:
 
  % time seconds  usecs/call callserrors syscall
  -- --- --- - - 
   52.100.002966   0 96840   clock_gettime
   19.500.001110   0 37050   timer_gettime
   10.660.000607   0 20086   timer_settime
   10.400.000592   0  8985  2539 sigreturn
4.940.000281   0  8361  2485 select
2.410.000137   0  8362   gettimeofday
  -- --- --- - - 
  100.000.005693179684  5024 total
 
 
  This looks like 250 Hz?
 
 
  Nope:
 
  # CONFIG_NO_HZ is not set
  # CONFIG_HZ_100 is not set
  # CONFIG_HZ_250 is not set
  # CONFIG_HZ_300 is not set
  CONFIG_HZ_1000=y
  CONFIG_HZ=1000
 
  and I'm reading it from /proc/config.gz on the guest.
 

 Yeah, thought so -- so dyntick is broken at present.

I see a lot of sub ms timer_settime(). Many of them are the result of
-expire_time being less than the current qemu_get_clock(). This
results into 250us timer due to MIN_TIMER_REARM_US; this happens only
for the REALTIME timer. Other sub-ms timers are generated by the
VIRTUAL timer.

This first issue is easily fixed; if expire_time  current time then
the timer has expired and hasn't been reprogrammed (and thus can be
ignored).
VIRTUAL just becomes more accurate with dyntics, before multiple
timers were batched together.

 Or maybe your host kernel can't support such a high rate.

I don't know... a simple printf tells me that the signal handler is
called about 1050 times per second, which sounds about right.

Luca

-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now   http://get.splunk.com/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [PATCH 0/4] Rework alarm timer infrastrucure - take2

2007-08-22 Thread Luca
On 8/22/07, Luca [EMAIL PROTECTED] wrote:
 I see a lot of sub ms timer_settime(). Many of them are the result of
 -expire_time being less than the current qemu_get_clock().

False alarm, this was a bug in the debug code :D

Luca

-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now   http://get.splunk.com/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [PATCH 0/4] Rework alarm timer infrastrucure - take2

2007-08-22 Thread Luca
On 8/22/07, Luca [EMAIL PROTECTED] wrote:
 On 8/22/07, Avi Kivity [EMAIL PROTECTED] wrote:
  Luca wrote:
   This is QEMU, with dynticks and HPET:
  
   % time seconds  usecs/call callserrors syscall
   -- --- --- - - 
52.100.002966   0 96840   clock_gettime
19.500.001110   0 37050   timer_gettime
10.660.000607   0 20086   timer_settime
10.400.000592   0  8985  2539 sigreturn
 4.940.000281   0  8361  2485 select
 2.410.000137   0  8362   gettimeofday
   -- --- --- - - 
   100.000.005693179684  5024 total
  
  
   This looks like 250 Hz?
  
  
   Nope:
  
   # CONFIG_NO_HZ is not set
   # CONFIG_HZ_100 is not set
   # CONFIG_HZ_250 is not set
   # CONFIG_HZ_300 is not set
   CONFIG_HZ_1000=y
   CONFIG_HZ=1000
  
   and I'm reading it from /proc/config.gz on the guest.
  
 
  Yeah, thought so -- so dyntick is broken at present.

 I see a lot of sub ms timer_settime(). Many of them are the result of
 -expire_time being less than the current qemu_get_clock(). This
 results into 250us timer due to MIN_TIMER_REARM_US; this happens only
 for the REALTIME timer. Other sub-ms timers are generated by the
 VIRTUAL timer.

 This first issue is easily fixed; if expire_time  current time then
 the timer has expired and hasn't been reprogrammed (and thus can be
 ignored).
 VIRTUAL just becomes more accurate with dyntics, before multiple
 timers were batched together.

  Or maybe your host kernel can't support such a high rate.

 I don't know... a simple printf tells me that the signal handler is
 called about 1050 times per second, which sounds about right.

...unless strace is attached. ptrace()'ing the process really screw up
the timing with dynticks; HPET is also affected but the performance
hit is not as severe.

Luca

-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now   http://get.splunk.com/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [PATCH 0/4] Rework alarm timer infrastrucure - take2

2007-08-22 Thread Luca
On 8/22/07, Dor Laor [EMAIL PROTECTED] wrote:
This is QEMU, with dynticks and HPET:
   
% time seconds  usecs/call callserrors syscall
-- --- --- - -
 -
 ---
 52.100.002966   0 96840
 clock_gettime
 19.500.001110   0 37050
 timer_gettime
 10.660.000607   0 20086
 timer_settime
 10.400.000592   0  8985  2539 sigreturn
  4.940.000281   0  8361  2485 select
  2.410.000137   0  8362   gettimeofday
-- --- --- - -
 -
 ---
100.000.005693179684  5024 total
   
   
This looks like 250 Hz?
   
   
Nope:
   
# CONFIG_NO_HZ is not set
# CONFIG_HZ_100 is not set
# CONFIG_HZ_250 is not set
# CONFIG_HZ_300 is not set
CONFIG_HZ_1000=y
CONFIG_HZ=1000
   
and I'm reading it from /proc/config.gz on the guest.
   
  
   Yeah, thought so -- so dyntick is broken at present.
 
  I see a lot of sub ms timer_settime(). Many of them are the result of
  -expire_time being less than the current qemu_get_clock(). This
  results into 250us timer due to MIN_TIMER_REARM_US; this happens only
  for the REALTIME timer. Other sub-ms timers are generated by the
  VIRTUAL timer.
 
  This first issue is easily fixed; if expire_time  current time then
  the timer has expired and hasn't been reprogrammed (and thus can be
  ignored).
  VIRTUAL just becomes more accurate with dyntics, before multiple
  timers were batched together.
 
   Or maybe your host kernel can't support such a high rate.
 
  I don't know... a simple printf tells me that the signal handler is
  called about 1050 times per second, which sounds about right.
 
 ...unless strace is attached. ptrace()'ing the process really screw up
 the timing with dynticks; HPET is also affected but the performance
 hit is not as severe.
 
 I didn't figure out how you use both hpet and dyn-tick together.

I don't. Only one timer source is active at any time; the selection is
done at startup with -clock option.

 Hpet has periodic timer while dyn-tick is one shot timer each time.
 Is ther a chance that both are working and that's the source of our
 problems?

No, the various sources are exclusive (though it might be possible to
use HPET in one shot mode).

Luca

-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now   http://get.splunk.com/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [PATCH 0/4] Rework alarm timer infrastrucure - take2

2007-08-21 Thread Luca Tettamanti
Avi Kivity ha scritto: 
 Luca Tettamanti wrote:
 At 1000Hz:

 QEMU
 hpet5.5%
 dynticks   11.7%

 KVM
 hpet3.4%
 dynticks7.3%

 No surprises here, you can see the additional 1k syscalls per second. 

 This is very surprising to me.  The 6.2% difference for the qemu case 
 translates to 62ms per second, or 62us per tick at 1000Hz.  That's more 
 than a hundred simple syscalls on modern processors.  We shouldn't have to 
 issue a hundred syscalls per guest clock tick.

APIC or PIT interrupts are delivered using the timer, which will be
re-armed after each tick, so I'd expect 1k timer_settime per second. But
according to strace it's not happening, maybe I'm misreading the code?

 The difference with kvm is smaller (just 3.9%), which is not easily 
 explained as the time for the extra syscalls should be about the same.  My 
 guess is that guest behavior is different; with dynticks the guest does 
 about twice as much work as with hpet.

Actually I'm having troubles with cyclesoak (probably it's calibration),
numbers are not very stable across multiple runs...

I've also tried APC which was suggested by malc[1] and:
- readings are far more stable
- the gap between dynticks and non-dynticks seems not significant

 Can you verify this by running

strace -c -p `pgrep qemu`  sleep 10; pkill strace

 for all 4 cases, and posting the results?

Plain QEMU:

With dynticks:

% time seconds  usecs/call callserrors syscall
-- --- --- - - 
 57.970.000469   0 13795   clock_gettime
 32.880.000266   0  1350   gettimeofday
  7.420.60   0  1423  1072 sigreturn
  1.730.14   0  5049   timer_gettime
  0.000.00   0  1683  1072 select
  0.000.00   0  2978   timer_settime
-- --- --- - - 
100.000.000809 26278  2144 total

HPET:

% time seconds  usecs/call callserrors syscall
-- --- --- - - 
 87.480.010459   1 10381 10050 select
  8.450.001010   0 40736   clock_gettime
  2.730.000326   0 10049   gettimeofday
  1.350.000161   0 10086 10064 sigreturn
-- --- --- - - 
100.000.011956 71252 20114 total

Unix (SIGALRM):

% time seconds  usecs/call callserrors syscall
-- --- --- - - 
 90.360.011663   1 10291  9959 select
  7.380.000953   0 40355   clock_gettime
  2.050.000264   0  9960   gettimeofday
  0.210.27   0  9985  9969 sigreturn
-- --- --- - - 
100.000.012907 70591 19928 total

And KVM:

dynticks:

% time seconds  usecs/call callserrors syscall
-- --- --- - - 
 78.900.004001   1  6681  5088 rt_sigtimedwait
 10.870.000551   0 27901   clock_gettime
  4.930.000250   0  7622   timer_settime
  4.300.000218   0 10078   timer_gettime
  0.390.20   0  3863   gettimeofday
  0.350.18   0  6054   ioctl
  0.260.13   0  4196   select
  0.000.00   0  1593   rt_sigaction
-- --- --- - - 
100.000.005071 67988  5088 total

HPET:

% time seconds  usecs/call callserrors syscall
-- --- --- - - 
 90.200.011029   0 32437 22244 rt_sigtimedwait
  4.460.000545   0 44164   clock_gettime
  2.590.000317   0 12128   gettimeofday
  1.500.000184   0 10193   rt_sigaction
  1.100.000134   0 12461   select
  0.150.18   0  6060   ioctl
-- --- --- - - 
100.000.012227117443 22244 total

Unix:

% time seconds  usecs/call callserrors syscall
-- --- --- - - 
 83.290.012522   0 31652 21709 rt_sigtimedwait
  6.910.001039   0 43125   clock_gettime
  3.500.000526   0  6042   ioctl
  2.740.000412   0  9943   rt_sigaction
  1.980.000298   0 12183   select
  1.580.000238   0 11850

Re: [kvm-devel] [Qemu-devel] [PATCH 3/4] Add support for HPET periodic timer.

2007-08-21 Thread Luca
On 8/21/07, Matthew Kent [EMAIL PROTECTED] wrote:
 On Sat, 2007-18-08 at 01:11 +0200, Luca Tettamanti wrote:
  plain text document attachment (clock-hpet)
  Linux operates the HPET timer in legacy replacement mode, which means that
  the periodic interrupt of the CMOS RTC is not delivered (qemu won't be able
  to use /dev/rtc). Add support for HPET (/dev/hpet) as a replacement for the
  RTC; the periodic interrupt is delivered via SIGIO and is handled in the
  same way as the RTC timer.
 
  Signed-off-by: Luca Tettamanti [EMAIL PROTECTED]

 I must be missing something silly here.. should I be able to open more
 than one instance of qemu with -clock hpet? Because upon invoking a
 second instance of qemu HPET_IE_ON fails.

It depends on your hardware. Theoretically it's possible, but I've yet
to see a motherboard with more than one periodic timer.

dmesg | grep hpet should tell you something like:

hpet0: 3 64-bit timers, 14318180 Hz

Luca

-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now   http://get.splunk.com/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [PATCH 0/4] Rework alarm timer infrastrucure - take2

2007-08-20 Thread Luca Tettamanti
Il Sun, Aug 19, 2007 at 10:31:26PM +0300, Avi Kivity ha scritto: 
 Luca wrote:
  On 8/19/07, Luca Tettamanti [EMAIL PROTECTED] wrote:

  +static uint64_t qemu_next_deadline(void) {
  +uint64_t nearest_delta_us = ULLONG_MAX;
  +uint64_t vmdelta_us;
  
 
  Hum, I introduced a bug here... those vars should be signed.
 
  On the overhead introduced: how do you measure it?
 

 
 Run a 100Hz guest, measure cpu usage using something accurate like
 cyclesoak, with and without dynticks, with and without kvm.

Ok, here I've measured the CPU usage on the host when running an idle
guest.

At 100Hz

QEMU
hpet4.8%
dynticks5.1%

Note: I've taken the mean over a period of 20 secs, but the difference
between hpet and dynticks is well inside the variability of the test.

KVM
hpet2.2%
dynticks1.0%

Hum... here the numbers jumps a bit, but dynticks is always below hpet.

At 1000Hz:

QEMU
hpet5.5%
dynticks   11.7%

KVM
hpet3.4%
dynticks7.3%

No surprises here, you can see the additional 1k syscalls per second. On
the bright side, keep in mind that with a tickless guest and dynticks
I've seen as little as 50-60 timer ticks per second.

Hackbench (hackbench -pipe 50) inside the guest:

QEMU: impossible to measure, the variance of the results is much bigger
than difference between dynticks and hpet.

KVM: 
Around 0.8s slower in case on dynticks; variance of the results is
about 0.3s in both cases.

Luca
-- 
Chi parla in tono cortese, ma continua a prepararsi, potra` andare avanti;
 chi parla in tono bellicoso e avanza rapidamente dovra` ritirarsi 
Sun Tzu -- L'arte della guerra

-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now   http://get.splunk.com/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [Qemu-devel] Re: [PATCH 0/4] Rework alarm timer infrastrucure - take2

2007-08-20 Thread Luca
On 8/20/07, malc [EMAIL PROTECTED] wrote:
 On Mon, 20 Aug 2007, Luca Tettamanti wrote:

  Il Sun, Aug 19, 2007 at 10:31:26PM +0300, Avi Kivity ha scritto:
  Luca wrote:
  On 8/19/07, Luca Tettamanti [EMAIL PROTECTED] wrote:
 
  +static uint64_t qemu_next_deadline(void) {
  +uint64_t nearest_delta_us = ULLONG_MAX;
  +uint64_t vmdelta_us;
 
 
  Hum, I introduced a bug here... those vars should be signed.
 
  On the overhead introduced: how do you measure it?
 
 
 
  Run a 100Hz guest, measure cpu usage using something accurate like
  cyclesoak, with and without dynticks, with and without kvm.
 
  Ok, here I've measured the CPU usage on the host when running an idle
  guest.
 
[...]
 The upshot is this - if you have used any standard utility (iostat,
 top - basically anything /proc/stat based) the accounting has a fair
 chance of being inaccurate. If cyclesoak is what you have used then
 the results should be better, but still i would be worried about
 them.

Yes, I've used cyclesoak.

Luca

-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now   http://get.splunk.com/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] Running KVM without root privileges

2007-08-19 Thread Luca
On 8/19/07, Eugene Coetzee [EMAIL PROTECTED] wrote:
 Hi .

 I'm trying to run KVM on Feisty, 64 bit Intel with the -net nic -net
 tap switches so I can use it in bridged network mode.

 It refuses and I have to run it sudo which for security concerns I don't
 want to do.

 The error message is : warning: could not configure /dev/net/tun: no
 virtual network emulation
 Could not initialize device 'tap''

You need CAP_NET_ADMIN to fiddle with TUN/TAP.

Luca

-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now   http://get.splunk.com/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] Running KVM without root privileges

2007-08-19 Thread Luca
On 8/19/07, Eugene Coetzee [EMAIL PROTECTED] wrote:
 Luca wrote:
 On 8/19/07, Eugene Coetzee [EMAIL PROTECTED] wrote:
 Hi .
 
 I'm trying to run KVM on Feisty, 64 bit Intel with the -net nic -net
 tap switches so I can use it in bridged network mode.
 
 It refuses and I have to run it sudo which for security concerns I don't
 want to do.
 
 
 You need CAP_NET_ADMIN to fiddle with TUN/TAP.
 
 
 Thanks for the reply. I'm a little confused about the interaction
 between KVM and qemu. Which binary requires CAP_NET_ADMIN capability -
 KVM or qemu ?

In the upstream package 'kvm' is just a script wrapper that invokes
the right qemu executable (the userspace component of KVM is a
modified QEMU). The exact naming depends on your distro, e.g. Debian
package puts the executable in /usr/bin/kvm.

Luca

-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now   http://get.splunk.com/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [PATCH 0/4] Rework alarm timer infrastrucure - take2

2007-08-19 Thread Luca
On 8/19/07, Luca Tettamanti [EMAIL PROTECTED] wrote:
 +static uint64_t qemu_next_deadline(void) {
 +uint64_t nearest_delta_us = ULLONG_MAX;
 +uint64_t vmdelta_us;

Hum, I introduced a bug here... those vars should be signed.

On the overhead introduced: how do you measure it?

Luca

-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now   http://get.splunk.com/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [BUG][PATCH?] kvm: unhandled wrmsr: 0xc0000083

2007-08-19 Thread Luca Tettamanti
Il Sun, Aug 19, 2007 at 10:36:06AM +0300, Avi Kivity ha scritto: 
 Luca wrote:
 On 8/13/07, Avi Kivity [EMAIL PROTECTED] wrote:
   
 Luca Tettamanti wrote:
 
 The patch stops the unhandled wrmsr, but reboot is still not working
 (guest is stuck using 100% of the CPU). The last working userspace is
 KVM-28, and I tested it with recent kernel modules. Any idea on this
 one?

   
 That's around the time kvm moved to its own main loop (for smp), so it's
 not surprising there's breakage there.  I tested erboot at the time, but
 not with all guests.
 

 Here I can't reboot anything... the only thing that works is GRUB, but
 I guess that it just goes through the BIOS.

 I debugged a bit the problem, but I'm not sure about the solution.
 This is what's happening:
 - guest requests the reboot, the corresponding branch
 kvm_main_loop_cpu() is executed.
 - qemu_system_reset() is called; among the other stuff the APIC is
 re-initialized.
 - kvm_apic_init (called via reset notifier: qemu_system_reset -
 apic_reset - apic_init_ipi -
 kvm_apic_init) set the -init flag of the vcpu to 1
 - in next loop  if (info-init) is executed. Forever ;-)

 The only thing that clears -init is kvm_update_after_sipi which in
 turn is only called by apic_startup; (I'm following the execution with
 gdb and that function is never called, btw). Anyway, as long as -init
 is set, guest code won't be executed, so qemu/kvm spins forever in the
 main loop, executing update_regs_for_init().
   

 Hmm. INIT processing should be different for the boot processor 
 (-cpu_index == 0), in that it should resume execution after INIT, whereas 
 non-boot processors enter a halt state waiting for a SIPI.  Maybe that's 
 the issue.

Yes, the CPU is halted. I don't see any special treatment for BP vs. APs
in the code...
I tried the most obvious fix:

diff --git a/qemu/qemu-kvm.c b/qemu/qemu-kvm.c
index 709e714..1d83d26 100644
--- a/qemu/qemu-kvm.c
+++ b/qemu/qemu-kvm.c
@@ -702,6 +702,9 @@ static void update_regs_for_init(CPUState *env)
 {
 cpu_reset(env);
 load_regs(env);
+/* BP */
+if (env-cpu_index == 0)
+vcpu_info[env-cpu_index].init = 0;
 }
 
 static void setup_kernel_sigmask(CPUState *env)

In order to reactivate the CPU after the reset. When the guest reboots I
get an unhandled vm exit:

unhandled vm exit:  0x8021
rax  rbx  rcx  rdx 
0600
rsi  rdi  rsp  rbp 

r8   r9   r10  r11 

r12  r13  r14  r15 

rip fff2 rflags 0002
cs f000 (000f/ p 1 dpl 3 db 0 s 1 type 3 l 0 g 0 avl 0)
ds  (/ p 1 dpl 3 db 0 s 1 type 3 l 0 g 0 avl 0)
es  (/ p 1 dpl 3 db 0 s 1 type 3 l 0 g 0 avl 0)
ss  (/ p 1 dpl 3 db 0 s 1 type 3 l 0 g 0 avl 0)
fs  (/ p 1 dpl 3 db 0 s 1 type 3 l 0 g 0 avl 0)
gs  (/ p 1 dpl 3 db 0 s 1 type 3 l 0 g 0 avl 0)
tr 0080 (1085/2088 p 1 dpl 0 db 0 s 0 type b l 0 g 0 avl 0)
ldt  (/ p 1 dpl 0 db 0 s 0 type 2 l 0 g 0 avl 0)
gdt 0/
idt 0/
cr0 6010 cr2 0 cr3 0 cr4 0 cr8 0 efer 0

which is a vm entry failure due to invalid guest state (RIP looks good
though :P)

Luca
-- 
Al termine di un pranzo di nozze mi hanno dato un
amaro alle erbe cosi' schifoso che perfino sull'etichetta
c'era un frate che vomitava.

-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now   http://get.splunk.com/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] installing kvm on debian 4.0 r0

2007-08-18 Thread Luca
On 8/18/07, Koen de Jonge [EMAIL PROTECTED] wrote:
  I then used these to make the system workable:
  apt-get install openssh-server
  apt-get install sudo
 
  Then I used these as prerequisite packages for kvm:
  apt-get install gcc-3.4
  apt-get install libsdl1.2-dev
  apt-get install zlibc
  apt-get install zlib1g-dev
  apt-get install uuid-dev
  apt-get install linux-kernel-headers
  apt-get install libasound2-dev
 Installing on another machine (with no X and no nvidia card I noticed I
 also needed):

 apt-get install kernel-package
 apt-get install linux-headers-2.6-amd64

Since Debian has a KVM package you can do:

apt-get build-dep kvm

which should cover all the dependencies.

Luca

-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now   http://get.splunk.com/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [BUG][PATCH?] kvm: unhandled wrmsr: 0xc0000083

2007-08-17 Thread Luca
On 8/13/07, Avi Kivity [EMAIL PROTECTED] wrote:
 Luca Tettamanti wrote:
  The patch stops the unhandled wrmsr, but reboot is still not working
  (guest is stuck using 100% of the CPU). The last working userspace is
  KVM-28, and I tested it with recent kernel modules. Any idea on this
  one?
 

 That's around the time kvm moved to its own main loop (for smp), so it's
 not surprising there's breakage there.  I tested erboot at the time, but
 not with all guests.

Here I can't reboot anything... the only thing that works is GRUB, but
I guess that it just goes through the BIOS.

I debugged a bit the problem, but I'm not sure about the solution.
This is what's happening:
- guest requests the reboot, the corresponding branch
kvm_main_loop_cpu() is executed.
- qemu_system_reset() is called; among the other stuff the APIC is
re-initialized.
- kvm_apic_init (called via reset notifier: qemu_system_reset -
apic_reset - apic_init_ipi -
kvm_apic_init) set the -init flag of the vcpu to 1
- in next loop  if (info-init) is executed. Forever ;-)

The only thing that clears -init is kvm_update_after_sipi which in
turn is only called by apic_startup; (I'm following the execution with
gdb and that function is never called, btw). Anyway, as long as -init
is set, guest code won't be executed, so qemu/kvm spins forever in the
main loop, executing update_regs_for_init().

Luca

-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now   http://get.splunk.com/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [PATCH 0/4] Rework alarm timer infrastrucure - take 2

2007-08-17 Thread Luca Tettamanti
Hello,
in reply to this mail I will send a serie of 4 patches that cleans up and
expands the alarm timer handling in QEMU. Patches have been rebased on QEMU
CVS.

Patch 1 is mostly a cleanup of the existing code; instead of having multiple
#ifdefs to handle different timers scattered all over the code I've created a
modular infrastructure where each timer type is self-contained and generic code
is more readable. The resulting code is functionally equivalent to the old one.

Patch 2 implements the -clock command line option proposed by Daniel Berrange
and Avi Kivity. By default QEMU tries RTC and then falls back to unix timer;
user can override the order of the timer through this options. Syntax is pretty
simple: -clock timer1,timer2,etc. (QEMU will pick the first one that works).

Patch 3 adds support for HPET under Linux (which is basically my old patch). As
suggested HPET takes precedence over other timers, but of course this can be
overridden.

Patch 4 introduces dynticks timer source; patch is mostly based on the work
Dan Kenigsberg. dynticks is now the default alarm timer.

Luca
-- 

-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now   http://get.splunk.com/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [PATCH 3/4] Add support for HPET periodic timer.

2007-08-17 Thread Luca Tettamanti
Linux operates the HPET timer in legacy replacement mode, which means that
the periodic interrupt of the CMOS RTC is not delivered (qemu won't be able
to use /dev/rtc). Add support for HPET (/dev/hpet) as a replacement for the
RTC; the periodic interrupt is delivered via SIGIO and is handled in the
same way as the RTC timer.

Signed-off-by: Luca Tettamanti [EMAIL PROTECTED]

---
 vl.c |   57 -
 1 file changed, 56 insertions(+), 1 deletion(-)

Index: qemu/vl.c
===
--- qemu.orig/vl.c  2007-08-17 17:39:21.0 +0200
+++ qemu/vl.c   2007-08-18 00:40:16.0 +0200
@@ -56,6 +56,7 @@
 #include pty.h
 #include malloc.h
 #include linux/rtc.h
+#include linux/hpet.h
 #include linux/ppdev.h
 #include linux/parport.h
 #else
@@ -809,6 +810,9 @@
 
 #ifdef __linux__
 
+static int hpet_start_timer(struct qemu_alarm_timer *t);
+static void hpet_stop_timer(struct qemu_alarm_timer *t);
+
 static int rtc_start_timer(struct qemu_alarm_timer *t);
 static void rtc_stop_timer(struct qemu_alarm_timer *t);
 
@@ -818,7 +822,9 @@
 
 static struct qemu_alarm_timer alarm_timers[] = {
 #ifdef __linux__
-/* RTC - if available - is preferred */
+/* HPET - if available - is preferred */
+{hpet, hpet_start_timer, hpet_stop_timer, NULL},
+/* ...otherwise try RTC */
 {rtc, rtc_start_timer, rtc_stop_timer, NULL},
 #endif
 #ifndef _WIN32
@@ -1153,6 +1159,55 @@
 fcntl(fd, F_SETOWN, getpid());
 }
 
+static int hpet_start_timer(struct qemu_alarm_timer *t)
+{
+struct hpet_info info;
+int r, fd;
+
+fd = open(/dev/hpet, O_RDONLY);
+if (fd  0)
+return -1;
+
+/* Set frequency */
+r = ioctl(fd, HPET_IRQFREQ, RTC_FREQ);
+if (r  0) {
+fprintf(stderr, Could not configure '/dev/hpet' to have a 1024Hz 
timer. This is not a fatal\n
+error, but for better emulation accuracy type:\n
+'echo 1024  /proc/sys/dev/hpet/max-user-freq' as root.\n);
+goto fail;
+}
+
+/* Check capabilities */
+r = ioctl(fd, HPET_INFO, info);
+if (r  0)
+goto fail;
+
+/* Enable periodic mode */
+r = ioctl(fd, HPET_EPI, 0);
+if (info.hi_flags  (r  0))
+goto fail;
+
+/* Enable interrupt */
+r = ioctl(fd, HPET_IE_ON, 0);
+if (r  0)
+goto fail;
+
+enable_sigio_timer(fd);
+t-priv = (void *)fd;
+
+return 0;
+fail:
+close(fd);
+return -1;
+}
+
+static void hpet_stop_timer(struct qemu_alarm_timer *t)
+{
+int fd = (int)t-priv;
+
+close(fd);
+}
+
 static int rtc_start_timer(struct qemu_alarm_timer *t)
 {
 int rtc_fd;

-- 

-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now   http://get.splunk.com/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [PATCH 2/4] Add -clock option.

2007-08-17 Thread Luca Tettamanti
Allow user to override the list of available alarm timers and their
priority. The format of the options is -clock clk1,clk2,...

Signed-off-by: Luca Tettamanti [EMAIL PROTECTED]

---
 vl.c |   72 +++
 1 file changed, 72 insertions(+)

Index: qemu/vl.c
===
--- qemu.orig/vl.c  2007-08-17 17:31:09.0 +0200
+++ qemu/vl.c   2007-08-18 00:40:22.0 +0200
@@ -829,6 +829,71 @@
 {NULL, }
 };
 
+static void show_available_alarms()
+{
+int i;
+
+printf(Available alarm timers, in order of precedence:\n);
+for (i = 0; alarm_timers[i].name; i++)
+printf(%s\n, alarm_timers[i].name);
+}
+
+static void configure_alarms(char const *opt)
+{
+int i;
+int cur = 0;
+int count = (sizeof(alarm_timers) / sizeof(*alarm_timers)) - 1;
+char *arg;
+char *name;
+
+if (!strcmp(opt, help)) {
+show_available_alarms();
+exit(0);
+}
+
+arg = strdup(opt);
+
+/* Reorder the array */
+name = strtok(arg, ,);
+while (name) {
+struct qemu_alarm_timer tmp;
+
+for (i = 0; i  count; i++) {
+if (!strcmp(alarm_timers[i].name, name))
+break;
+}
+
+if (i == count) {
+fprintf(stderr, Unknown clock %s\n, name);
+goto next;
+}
+
+if (i  cur)
+/* Ignore */
+goto next;
+
+   /* Swap */
+tmp = alarm_timers[i];
+alarm_timers[i] = alarm_timers[cur];
+alarm_timers[cur] = tmp;
+
+cur++;
+next:
+name = strtok(NULL, ,);
+}
+
+free(arg);
+
+if (cur) {
+   /* Disable remaining timers */
+for (i = cur; i  count; i++)
+alarm_timers[i].name = NULL;
+}
+
+/* debug */
+show_available_alarms();
+}
+
 QEMUClock *rt_clock;
 QEMUClock *vm_clock;
 
@@ -6791,6 +6856,8 @@
 #ifdef TARGET_SPARC
-prom-env variable=value  set OpenBIOS nvram variables\n
 #endif
+   -clock  force the use of the given methods for timer 
alarm.\n
+   To see what timers are available use -clock help\n
\n
During emulation, the following keys are useful:\n
ctrl-alt-f  toggle full screen\n
@@ -6888,6 +6955,7 @@
 QEMU_OPTION_name,
 QEMU_OPTION_prom_env,
 QEMU_OPTION_old_param,
+QEMU_OPTION_clock,
 };
 
 typedef struct QEMUOption {
@@ -6992,6 +7060,7 @@
 #if defined(TARGET_ARM)
 { old-param, 0, QEMU_OPTION_old_param },
 #endif
+{ clock, HAS_ARG, QEMU_OPTION_clock },
 { NULL },
 };
 
@@ -7771,6 +7840,9 @@
 case QEMU_OPTION_old_param:
 old_param = 1;
 #endif
+case QEMU_OPTION_clock:
+configure_alarms(optarg);
+break;
 }
 }
 }

-- 

-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now   http://get.splunk.com/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [PATCH 4/4] Add support for dynamic ticks.

2007-08-17 Thread Luca Tettamanti
If DYNAMIC_TICKS is defined qemu does not attepmt to generate SIGALRM at a
constant rate. Rather, the system timer is set to generate SIGALRM only
when it is needed. DYNAMIC_TICKS reduces the number of SIGALRMs sent to
idle dynamic-ticked guests.
Original patch from Dan Kenigsberg [EMAIL PROTECTED]

Signed-off-by: Luca Tettamanti [EMAIL PROTECTED]

---
 configure |5 ++
 vl.c  |  149 +++---
 2 files changed, 148 insertions(+), 6 deletions(-)

Index: qemu/vl.c
===
--- qemu.orig/vl.c  2007-08-17 17:45:00.0 +0200
+++ qemu/vl.c   2007-08-18 00:38:03.0 +0200
@@ -784,12 +784,42 @@
 
 struct qemu_alarm_timer {
 char const *name;
+unsigned int flags;
 
 int (*start)(struct qemu_alarm_timer *t);
 void (*stop)(struct qemu_alarm_timer *t);
+void (*rearm)(struct qemu_alarm_timer *t);
 void *priv;
 };
 
+#define ALARM_FLAG_DYNTICKS  0x1
+
+#ifdef DYNAMIC_TICKS
+
+static inline int alarm_has_dynticks(struct qemu_alarm_timer *t)
+{
+return t-flags  ALARM_FLAG_DYNTICKS;
+}
+
+static void qemu_rearm_alarm_timer(struct qemu_alarm_timer *t) {
+if (!alarm_has_dynticks(t))
+return;
+
+t-rearm(t);
+}
+
+#else /* DYNAMIC_TICKS */
+
+static inline int alarm_has_dynticks(struct qemu_alarm_timer *t)
+{
+return 0;
+}
+
+static void qemu_rearm_alarm_timer(void) {
+}
+
+#endif /* DYNAMIC_TICKS */
+
 static struct qemu_alarm_timer *alarm_timer;
 
 #ifdef _WIN32
@@ -808,6 +838,14 @@
 static int unix_start_timer(struct qemu_alarm_timer *t);
 static void unix_stop_timer(struct qemu_alarm_timer *t);
 
+#ifdef DYNAMIC_TICKS
+
+static int dynticks_start_timer(struct qemu_alarm_timer *t);
+static void dynticks_stop_timer(struct qemu_alarm_timer *t);
+static void dynticks_rearm_timer(struct qemu_alarm_timer *t);
+
+#endif
+
 #ifdef __linux__
 
 static int hpet_start_timer(struct qemu_alarm_timer *t);
@@ -821,16 +859,19 @@
 #endif /* _WIN32 */
 
 static struct qemu_alarm_timer alarm_timers[] = {
+#ifndef _WIN32
+#ifdef DYNAMIC_TICKS
+{dynticks, ALARM_FLAG_DYNTICKS, dynticks_start_timer, 
dynticks_stop_timer, dynticks_rearm_timer, NULL},
+#endif
 #ifdef __linux__
 /* HPET - if available - is preferred */
-{hpet, hpet_start_timer, hpet_stop_timer, NULL},
+{hpet, 0, hpet_start_timer, hpet_stop_timer, NULL, NULL},
 /* ...otherwise try RTC */
-{rtc, rtc_start_timer, rtc_stop_timer, NULL},
+{rtc, 0, rtc_start_timer, rtc_stop_timer, NULL, NULL},
 #endif
-#ifndef _WIN32
-{unix, unix_start_timer, unix_stop_timer, NULL},
+{unix, 0, unix_start_timer, unix_stop_timer, NULL, NULL},
 #else
-{win32, win32_start_timer, win32_stop_timer, alarm_win32_data},
+{win32, 0, win32_start_timer, win32_stop_timer, NULL, alarm_win32_data},
 #endif
 {NULL, }
 };
@@ -949,6 +990,8 @@
 }
 pt = t-next;
 }
+
+qemu_rearm_alarm_timer(alarm_timer);
 }
 
 /* modify the current timer so that it will be fired when current_time
@@ -1008,6 +1051,7 @@
 /* run the callback (the timer list can be modified) */
 ts-cb(ts-opaque);
 }
+qemu_rearm_alarm_timer(alarm_timer);
 }
 
 int64_t qemu_get_clock(QEMUClock *clock)
@@ -1115,7 +1159,8 @@
 last_clock = ti;
 }
 #endif
-if (qemu_timer_expired(active_timers[QEMU_TIMER_VIRTUAL],
+if (alarm_has_dynticks(alarm_timer) ||
+qemu_timer_expired(active_timers[QEMU_TIMER_VIRTUAL],
qemu_get_clock(vm_clock)) ||
 qemu_timer_expired(active_timers[QEMU_TIMER_REALTIME],
qemu_get_clock(rt_clock))) {
@@ -1243,6 +1288,97 @@
 
 #endif /* !defined(__linux__) */
 
+#ifdef DYNAMIC_TICKS
+static int dynticks_start_timer(struct qemu_alarm_timer *t)
+{
+struct sigevent ev;
+timer_t host_timer;
+struct sigaction act;
+
+sigfillset(act.sa_mask);
+act.sa_flags = 0;
+#if defined(TARGET_I386)  defined(USE_CODE_COPY)
+act.sa_flags |= SA_ONSTACK;
+#endif
+act.sa_handler = host_alarm_handler;
+
+sigaction(SIGALRM, act, NULL);
+
+ev.sigev_value.sival_int = 0;
+ev.sigev_notify = SIGEV_SIGNAL;
+ev.sigev_signo = SIGALRM;
+
+if (timer_create(CLOCK_REALTIME, ev, host_timer)) {
+perror(timer_create);
+
+/* disable dynticks */
+fprintf(stderr, Dynamic Ticks disabled\n);
+
+return -1;
+}
+
+t-priv = (void *)host_timer;
+
+return 0;
+}
+
+static void dynticks_stop_timer(struct qemu_alarm_timer *t)
+{
+timer_t host_timer = (timer_t)t-priv;
+
+timer_delete(host_timer);
+}
+
+static void dynticks_rearm_timer(struct qemu_alarm_timer *t)
+{
+timer_t host_timer = (timer_t)t-priv;
+struct itimerspec timeout;
+int64_t nearest_delta_us = INT64_MAX;
+
+if (active_timers[QEMU_TIMER_REALTIME] ||
+active_timers[QEMU_TIMER_VIRTUAL]) {
+int64_t vmdelta_us, current_us

Re: [kvm-devel] [Qemu-devel] [PATCH 0/4] Rework alarm timer infrastrucure - take 2

2007-08-17 Thread Luca
On 8/18/07, Christian MICHON [EMAIL PROTECTED] wrote:
 there's a typo line 1432 on vl.c after applying all 4 patches
 (missing ';')

Ops...

 beyond this small typo, I managed to include this in a win32 qemu build.
 is there a specific practical test to see the improvement in a linux guest
 when running on a windows host ?

The improvements - beyond the refactoring - are either specific to
Linux (HPET timer) or to UNIX in general (dynticks - POSIX timers are
used).
It may be possible to use one-shot timer on windows too, but I'm not
really familiar with win32 API.

Luca

-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now   http://get.splunk.com/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [PATCH/RFC 3/4] Add support for HPET periodic timer.

2007-08-16 Thread Luca Tettamanti
Linux operates the HPET timer in legacy replacement mode, which means that
the periodic interrupt of the CMOS RTC is not delivered (qemu won't be able
to use /dev/rtc). Add support for HPET (/dev/hpet) as a replacement for the
RTC; the periodic interrupt is delivered via SIGIO and is handled in the
same way as the RTC timer.

Signed-off-by: Luca Tettamanti [EMAIL PROTECTED]
---
 qemu/vl.c |   57 ++-
 1 files changed, 56 insertions(+), 1 deletions(-)

diff --git a/qemu/vl.c b/qemu/vl.c
index f0b4896..0373beb 100644
--- a/qemu/vl.c
+++ b/qemu/vl.c
@@ -54,6 +54,7 @@
 #include pty.h
 #include malloc.h
 #include linux/rtc.h
+#include linux/hpet.h
 #include linux/ppdev.h
 #endif
 #endif
@@ -773,6 +774,9 @@ static void unix_stop_timer(struct qemu_alarm_timer *t);
 
 #ifdef __linux__
 
+static int hpet_start_timer(struct qemu_alarm_timer *t);
+static void hpet_stop_timer(struct qemu_alarm_timer *t);
+
 static int rtc_start_timer(struct qemu_alarm_timer *t);
 static void rtc_stop_timer(struct qemu_alarm_timer *t);
 
@@ -782,7 +786,9 @@ static void rtc_stop_timer(struct qemu_alarm_timer *t);
 
 static struct qemu_alarm_timer alarm_timers[] = {
 #ifdef __linux__
-/* RTC - if available - is preferred */
+/* HPET - if available - is preferred */
+{hpet, hpet_start_timer, hpet_stop_timer, NULL},
+/* ...otherwise try RTC */
 {rtc, rtc_start_timer, rtc_stop_timer, NULL},
 #endif
 #ifndef _WIN32
@@ -1117,6 +1123,55 @@ static void enable_sigio_timer(int fd)
 fcntl(fd, F_SETOWN, getpid());
 }
 
+static int hpet_start_timer(struct qemu_alarm_timer *t)
+{
+struct hpet_info info;
+int r, fd;
+
+fd = open(/dev/hpet, O_RDONLY);
+if (fd  0)
+return -1;
+
+/* Set frequency */
+r = ioctl(fd, HPET_IRQFREQ, RTC_FREQ);
+if (r  0) {
+fprintf(stderr, Could not configure '/dev/hpet' to have a 1024Hz 
timer. This is not a fatal\n
+error, but for better emulation accuracy type:\n
+'echo 1024  /proc/sys/dev/hpet/max-user-freq' as root.\n);
+goto fail;
+}
+
+/* Check capabilities */
+r = ioctl(fd, HPET_INFO, info);
+if (r  0)
+goto fail;
+
+/* Enable periodic mode */
+r = ioctl(fd, HPET_EPI, 0);
+if (info.hi_flags  (r  0))
+goto fail;
+
+/* Enable interrupt */
+r = ioctl(fd, HPET_IE_ON, 0);
+if (r  0)
+goto fail;
+
+enable_sigio_timer(fd);
+t-priv = (void *)fd;
+
+return 0;
+fail:
+close(fd);
+return -1;
+}
+
+static void hpet_stop_timer(struct qemu_alarm_timer *t)
+{
+int fd = (int)t-priv;
+
+close(fd);
+}
+
 static int rtc_start_timer(struct qemu_alarm_timer *t)
 {
 int rtc_fd;
-- 
1.5.2.4


-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now   http://get.splunk.com/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [PATCH/RFC 4/4] Add support for dynamic ticks.

2007-08-16 Thread Luca Tettamanti
If DYNAMIC_TICKS is defined qemu does not attepmt to generate SIGALRM at a
constant rate. Rather, the system timer is set to generate SIGALRM only
when it is needed. DYNAMIC_TICKS reduces the number of SIGALRMs sent to
idle dynamic-ticked guests.
Original patch from Dan Kenigsberg [EMAIL PROTECTED]

Signed-off-by: Luca Tettamanti [EMAIL PROTECTED]
---
 qemu/configure |5 ++
 qemu/vl.c  |  149 --
 2 files changed, 148 insertions(+), 6 deletions(-)

diff --git a/qemu/configure b/qemu/configure
index 365b7fb..38373db 100755
--- a/qemu/configure
+++ b/qemu/configure
@@ -262,6 +262,8 @@ for opt do
   ;;
   --enable-uname-release=*) uname_release=$optarg
   ;;
+  --disable-dynamic-ticks) dynamic_ticks=no
+  ;;
   esac
 done
 
@@ -788,6 +790,9 @@ echo TARGET_DIRS=$target_list  $config_mak
 if [ $build_docs = yes ] ; then
   echo BUILD_DOCS=yes  $config_mak
 fi
+if test $dynamic_ticks != no ; then
+  echo #define DYNAMIC_TICKS 1  $config_h
+fi
 
 # XXX: suppress that
 if [ $bsd = yes ] ; then
diff --git a/qemu/vl.c b/qemu/vl.c
index 0373beb..096729d 100644
--- a/qemu/vl.c
+++ b/qemu/vl.c
@@ -748,12 +748,42 @@ struct QEMUTimer {
 
 struct qemu_alarm_timer {
 char const *name;
+unsigned int flags;
 
 int (*start)(struct qemu_alarm_timer *t);
 void (*stop)(struct qemu_alarm_timer *t);
+void (*rearm)(struct qemu_alarm_timer *t);
 void *priv;
 };
 
+#define ALARM_FLAG_DYNTICKS  0x1
+
+#ifdef DYNAMIC_TICKS
+
+static inline int alarm_has_dynticks(struct qemu_alarm_timer *t)
+{
+return t-flags  ALARM_FLAG_DYNTICKS;
+}
+
+static void qemu_rearm_alarm_timer(struct qemu_alarm_timer *t) {
+if (!alarm_has_dynticks(t))
+return;
+
+t-rearm(t);
+}
+
+#else /* DYNAMIC_TICKS */
+
+static inline int alarm_has_dynticks(struct qemu_alarm_timer *t)
+{
+return 0;
+}
+
+static void qemu_rearm_alarm_timer(void) {
+}
+
+#endif /* DYNAMIC_TICKS */
+
 static struct qemu_alarm_timer *alarm_timer;
 
 #ifdef _WIN32
@@ -772,6 +802,14 @@ static void win32_stop_timer(struct qemu_alarm_timer *t);
 static int unix_start_timer(struct qemu_alarm_timer *t);
 static void unix_stop_timer(struct qemu_alarm_timer *t);
 
+#ifdef DYNAMIC_TICKS
+
+static int dynticks_start_timer(struct qemu_alarm_timer *t);
+static void dynticks_stop_timer(struct qemu_alarm_timer *t);
+static void dynticks_rearm_timer(struct qemu_alarm_timer *t);
+
+#endif
+
 #ifdef __linux__
 
 static int hpet_start_timer(struct qemu_alarm_timer *t);
@@ -785,16 +823,19 @@ static void rtc_stop_timer(struct qemu_alarm_timer *t);
 #endif /* _WIN32 */
 
 static struct qemu_alarm_timer alarm_timers[] = {
+#ifndef _WIN32
+#ifdef DYNAMIC_TICKS
+{dynticks, ALARM_FLAG_DYNTICKS, dynticks_start_timer, 
dynticks_stop_timer, dynticks_rearm_timer, NULL},
+#endif
 #ifdef __linux__
 /* HPET - if available - is preferred */
-{hpet, hpet_start_timer, hpet_stop_timer, NULL},
+{hpet, 0, hpet_start_timer, hpet_stop_timer, NULL, NULL},
 /* ...otherwise try RTC */
-{rtc, rtc_start_timer, rtc_stop_timer, NULL},
+{rtc, 0, rtc_start_timer, rtc_stop_timer, NULL, NULL},
 #endif
-#ifndef _WIN32
-{unix, unix_start_timer, unix_stop_timer, NULL},
+{unix, 0, unix_start_timer, unix_stop_timer, NULL, NULL},
 #else
-{win32, win32_start_timer, win32_stop_timer, alarm_win32_data},
+{win32, 0, win32_start_timer, win32_stop_timer, NULL, alarm_win32_data},
 #endif
 {NULL, }
 };
@@ -913,6 +954,8 @@ void qemu_del_timer(QEMUTimer *ts)
 }
 pt = t-next;
 }
+
+qemu_rearm_alarm_timer(alarm_timer);
 }
 
 /* modify the current timer so that it will be fired when current_time
@@ -972,6 +1015,7 @@ static void qemu_run_timers(QEMUTimer **ptimer_head, 
int64_t current_time)
 /* run the callback (the timer list can be modified) */
 ts-cb(ts-opaque);
 }
+qemu_rearm_alarm_timer(alarm_timer);
 }
 
 int64_t qemu_get_clock(QEMUClock *clock)
@@ -1079,7 +1123,8 @@ static void host_alarm_handler(int host_signum)
 last_clock = ti;
 }
 #endif
-if (qemu_timer_expired(active_timers[QEMU_TIMER_VIRTUAL],
+if (alarm_has_dynticks(alarm_timer) ||
+qemu_timer_expired(active_timers[QEMU_TIMER_VIRTUAL],
qemu_get_clock(vm_clock)) ||
 qemu_timer_expired(active_timers[QEMU_TIMER_REALTIME],
qemu_get_clock(rt_clock))) {
@@ -1207,6 +1252,97 @@ static void rtc_stop_timer(struct qemu_alarm_timer *t)
 
 #endif /* !defined(__linux__) */
 
+#ifdef DYNAMIC_TICKS
+static int dynticks_start_timer(struct qemu_alarm_timer *t)
+{
+struct sigevent ev;
+timer_t host_timer;
+struct sigaction act;
+
+sigfillset(act.sa_mask);
+act.sa_flags = 0;
+#if defined(TARGET_I386)  defined(USE_CODE_COPY)
+act.sa_flags |= SA_ONSTACK;
+#endif
+act.sa_handler = host_alarm_handler;
+
+sigaction(SIGALRM, act, NULL);
+
+ev.sigev_value.sival_int = 0;
+ev.sigev_notify = SIGEV_SIGNAL

[kvm-devel] [PATCH/RFC 1/4] Rework alarm timer infrastrucure.

2007-08-16 Thread Luca Tettamanti
Make the alarm code modular, removing #ifdef from the generic code and
abstract a common interface for all the timer. The result is functionally
equivalent to the old code.

Signed-off-by: Luca Tettamanti [EMAIL PROTECTED]
---
 qemu/vl.c |  292 +--
 1 files changed, 189 insertions(+), 103 deletions(-)

diff --git a/qemu/vl.c b/qemu/vl.c
index 5360ed7..33443ca 100644
--- a/qemu/vl.c
+++ b/qemu/vl.c
@@ -745,18 +745,58 @@ struct QEMUTimer {
 struct QEMUTimer *next;
 };
 
-QEMUClock *rt_clock;
-QEMUClock *vm_clock;
+struct qemu_alarm_timer {
+char const *name;
+
+int (*start)(struct qemu_alarm_timer *t);
+void (*stop)(struct qemu_alarm_timer *t);
+void *priv;
+};
+
+static struct qemu_alarm_timer *alarm_timer;
 
-static QEMUTimer *active_timers[2];
 #ifdef _WIN32
-static MMRESULT timerID;
-static HANDLE host_alarm = NULL;
-static unsigned int period = 1;
+
+struct qemu_alarm_win32 {
+MMRESULT timerId;
+HANDLE host_alarm;
+unsigned int period;
+} alarm_win32_data = {0, NULL, -1};
+
+static int win32_start_timer(struct qemu_alarm_timer *t);
+static void win32_stop_timer(struct qemu_alarm_timer *t);
+
+#else
+
+static int unix_start_timer(struct qemu_alarm_timer *t);
+static void unix_stop_timer(struct qemu_alarm_timer *t);
+
+#ifdef __linux__
+
+static int rtc_start_timer(struct qemu_alarm_timer *t);
+static void rtc_stop_timer(struct qemu_alarm_timer *t);
+
+#endif
+
+#endif /* _WIN32 */
+
+static struct qemu_alarm_timer alarm_timers[] = {
+#ifdef __linux__
+/* RTC - if available - is preferred */
+{rtc, rtc_start_timer, rtc_stop_timer, NULL},
+#endif
+#ifndef _WIN32
+{unix, unix_start_timer, unix_stop_timer, NULL},
 #else
-/* frequency of the times() clock tick */
-static int timer_freq;
+{win32, win32_start_timer, win32_stop_timer, alarm_win32_data},
 #endif
+{NULL, }
+};
+
+QEMUClock *rt_clock;
+QEMUClock *vm_clock;
+
+static QEMUTimer *active_timers[2];
 
 QEMUClock *qemu_new_clock(int type)
 {
@@ -973,7 +1013,8 @@ static void host_alarm_handler(int host_signum)
 qemu_timer_expired(active_timers[QEMU_TIMER_REALTIME],
qemu_get_clock(rt_clock))) {
 #ifdef _WIN32
-SetEvent(host_alarm);
+struct qemu_alarm_win32 *data = ((struct 
qemu_alarm_timer*)dwUser)-priv;
+SetEvent(data-host_alarm);
 #endif
 CPUState *env = cpu_single_env;
 if (env) {
@@ -995,10 +1036,31 @@ static void host_alarm_handler(int host_signum)
 #define RTC_FREQ 1024
 
 static int use_rtc = 1;
-static int rtc_fd;
 
-static int start_rtc_timer(void)
+static void enable_sigio_timer(int fd)
+{
+struct sigaction act;
+
+/* timer signal */
+sigfillset(act.sa_mask);
+act.sa_flags = 0;
+#if defined (TARGET_I386)  defined(USE_CODE_COPY)
+act.sa_flags |= SA_ONSTACK;
+#endif
+act.sa_handler = host_alarm_handler;
+
+sigaction(SIGIO, act, NULL);
+fcntl(fd, F_SETFL, O_ASYNC);
+fcntl(fd, F_SETOWN, getpid());
+}
+
+static int rtc_start_timer(struct qemu_alarm_timer *t)
 {
+int rtc_fd;
+
+if (!use_rtc)
+return -1;
+
 rtc_fd = open(/dev/rtc, O_RDONLY);
 if (rtc_fd  0)
 return -1;
@@ -1009,121 +1071,145 @@ static int start_rtc_timer(void)
 goto fail;
 }
 if (ioctl(rtc_fd, RTC_PIE_ON, 0)  0) {
-fail:
+fail:
 close(rtc_fd);
 return -1;
 }
-pit_min_timer_count = PIT_FREQ / RTC_FREQ;
+
+enable_sigio_timer(rtc_fd);
+
+t-priv = (void *)rtc_fd;
+
 return 0;
 }
 
-#else
-
-static int start_rtc_timer(void)
+static void rtc_stop_timer(struct qemu_alarm_timer *t)
 {
-return -1;
+int rtc_fd = (int)t-priv;
+
+close(rtc_fd);
 }
 
 #endif /* !defined(__linux__) */
 
-#endif /* !defined(_WIN32) */
+static int unix_start_timer(struct qemu_alarm_timer *t)
+{
+struct sigaction act;
+struct itimerval itv;
+int err;
 
-static void init_timer_alarm(void)
+/* timer signal */
+sigfillset(act.sa_mask);
+act.sa_flags = 0;
+#if defined(TARGET_I386)  defined(USE_CODE_COPY)
+act.sa_flags |= SA_ONSTACK;
+#endif
+act.sa_handler = host_alarm_handler;
+
+sigaction(SIGALRM, act, NULL);
+
+itv.it_interval.tv_sec = 0;
+/* for i386 kernel 2.6 to get 1 ms */
+itv.it_interval.tv_usec = 999;
+itv.it_value.tv_sec = 0;
+itv.it_value.tv_usec = 10 * 1000;
+
+err = setitimer(ITIMER_REAL, itv, NULL);
+if (err)
+return -1;
+
+return 0;
+}
+
+static void unix_stop_timer(struct qemu_alarm_timer *t)
 {
+struct itimerval itv;
+
+memset(itv, 0, sizeof(itv));
+setitimer(ITIMER_REAL, itv, NULL);
+}
+
+#endif /* !defined(_WIN32) */
+
 #ifdef _WIN32
-{
-int count=0;
-TIMECAPS tc;
-
-ZeroMemory(tc, sizeof(TIMECAPS));
-timeGetDevCaps(tc, sizeof(TIMECAPS));
-if (period  tc.wPeriodMin)
-period = tc.wPeriodMin;
-timeBeginPeriod(period);
-timerID

[kvm-devel] [PATCH/RFC 0/4] Rework alarm timer infrastrucure.

2007-08-16 Thread Luca Tettamanti
Hello,
in reply to this mail I will send a serie of 4 patches that cleans up and 
expands
the alarm timer handling in QEMU. Patches apply to current kvm-userspace tree,
but I think I can rebase it to QEMU svn if desired.

Patch 1 is mostly a cleanup of the existing code; instead of having multiple
#ifdefs to handle different timers scattered all over the code I've created a
modular infrastructure where each timer type is self-contained and generic code
is more readable. The resulting code is functionally equivalent to the old one.

Patch 2 implements the -clock command line option proposed by Daniel Berrange
and Avi Kivity. By default QEMU tries RTC and then falls back to unix timer;
user can override the order of the timer through this options. Syntax is pretty
simple: -clock timer1,timer2,etc. (QEMU will pick the first one that works).

Patch 3 adds support for HPET under Linux (which is basically my old patch). As
suggested HPET takes precedence over other timers, but of course this can be
overridden.

Patch 4 introduces dynticks timer source; patch is mostly based on the work
Dan Kenigsberg. dynticks is now the default alarm timer.

-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now   http://get.splunk.com/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [PATCH/RFC 2/4] Add -clock option.

2007-08-16 Thread Luca Tettamanti
Allow user to override the list of available alarm timers and their
priority. The format of the options is -clock clk1,clk2,...

Signed-off-by: Luca Tettamanti [EMAIL PROTECTED]
---
 qemu/vl.c |   90 --
 1 files changed, 72 insertions(+), 18 deletions(-)

diff --git a/qemu/vl.c b/qemu/vl.c
index 33443ca..f0b4896 100644
--- a/qemu/vl.c
+++ b/qemu/vl.c
@@ -793,6 +793,71 @@ static struct qemu_alarm_timer alarm_timers[] = {
 {NULL, }
 };
 
+static void show_available_alarms()
+{
+int i;
+
+printf(Available alarm timers, in order of precedence:\n);
+for (i = 0; alarm_timers[i].name; i++)
+printf(%s\n, alarm_timers[i].name);
+}
+
+static void configure_alarms(char const *opt)
+{
+int i;
+int cur = 0;
+int count = (sizeof(alarm_timers) / sizeof(*alarm_timers)) - 1;
+char *arg;
+char *name;
+
+if (!strcmp(opt, help)) {
+show_available_alarms();
+exit(0);
+}
+
+arg = strdup(opt);
+
+/* Reorder the array */
+name = strtok(arg, ,);
+while (name) {
+struct qemu_alarm_timer tmp;
+
+for (i = 0; i  count; i++) {
+if (!strcmp(alarm_timers[i].name, name))
+break;
+}
+
+if (i == count) {
+fprintf(stderr, Unknown clock %s\n, name);
+goto next;
+}
+
+if (i  cur)
+/* Ignore */
+goto next;
+
+   /* Swap */
+tmp = alarm_timers[i];
+alarm_timers[i] = alarm_timers[cur];
+alarm_timers[cur] = tmp;
+
+cur++;
+next:
+name = strtok(NULL, ,);
+}
+
+free(arg);
+
+if (cur) {
+   /* Disable remaining timers */
+for (i = cur; i  count; i++)
+alarm_timers[i].name = NULL;
+}
+
+/* debug */
+show_available_alarms();
+}
+
 QEMUClock *rt_clock;
 QEMUClock *vm_clock;
 
@@ -1035,8 +1100,6 @@ static void host_alarm_handler(int host_signum)
 
 #define RTC_FREQ 1024
 
-static int use_rtc = 1;
-
 static void enable_sigio_timer(int fd)
 {
 struct sigaction act;
@@ -1058,9 +1121,6 @@ static int rtc_start_timer(struct qemu_alarm_timer *t)
 {
 int rtc_fd;
 
-if (!use_rtc)
-return -1;
-
 rtc_fd = open(/dev/rtc, O_RDONLY);
 if (rtc_fd  0)
 return -1;
@@ -6566,9 +6626,8 @@ void help(void)
   -daemonize  daemonize QEMU after initializing\n
 #endif
-tdfinject timer interrupts that got lost\n
-#if defined(__linux__)
-   -no-rtc don't use /dev/rtc for timer alarm (do use 
gettimeofday)\n
-#endif
+   -clock  force the use of the given methods for timer 
alarm.\n
+   To see what timers are available use -clock help\n
   -option-rom rom load a file, rom, into the option ROM space\n
\n
During emulation, the following keys are useful:\n
@@ -6658,9 +6717,7 @@ enum {
 QEMU_OPTION_semihosting,
 QEMU_OPTION_incoming,
 QEMU_OPTION_tdf,
-#if defined(__linux__)
-QEMU_OPTION_no_rtc,
-#endif
+QEMU_OPTION_clock,
 QEMU_OPTION_cpu_vendor,
 };
 
@@ -6755,9 +6812,7 @@ const QEMUOption qemu_options[] = {
 { semihosting, 0, QEMU_OPTION_semihosting },
 #endif
 { tdf, 0, QEMU_OPTION_tdf }, /* enable time drift fix */
-#if defined(__linux__)
-{ no-rtc, 0, QEMU_OPTION_no_rtc },
-#endif
+{ clock, HAS_ARG, QEMU_OPTION_clock },
 { cpu-vendor, HAS_ARG, QEMU_OPTION_cpu_vendor },
 { NULL },
 };
@@ -7477,11 +7532,10 @@ int main(int argc, char **argv)
 break;
 case QEMU_OPTION_tdf:
 time_drift_fix = 1;
-#if defined(__linux__)
-   case QEMU_OPTION_no_rtc:
-   use_rtc = 0;
break;
-#endif
+case QEMU_OPTION_clock:
+configure_alarms(optarg);
+break;
case QEMU_OPTION_cpu_vendor:
cpu_vendor_string = optarg;
break;
-- 
1.5.2.4


-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now   http://get.splunk.com/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] kvm for Ubuntu 7.04 (was Re: a (bad) kvm story from a plain user)

2007-08-15 Thread Luca
On 8/16/07, Cam Macdonell [EMAIL PROTECTED] wrote:
 Koen de Jonge (ProcoliX) wrote:
  Slohm Gadaburi wrote:
  hi ppl,
 
  I am grateful for the help and tips I've been given here on the earlier
  thread.
  I just want to summarize the bits I've collected,
  please confirm :)
 
  On an up-to-date Ubuntu 7.04 machine:
  - install kvm+qemu packages
  - install the gcc-3.4 package (hopefully it will not overwrite my gcc 4.x 
  ?)
  - download kvm-35
  - configure it without the --patched flag (will it automatically find
  the gcc-3 ?)
  - insmod the just-build kvm-(amd|intel) module
  - make sure i run the qemu binaries supplied from the kvm35 package
 
  that should do the trick ?
 

 I'm trying to compile kvm-35 (from the git repository) on Ubuntu Feisty
 (all up to date) and I get the following error:

 [EMAIL PROTECTED]:~/src/KVM/kvm-userspace$ sudo make
 make -C kernel
 make[1]: Entering directory `/home/cam/src/KVM/kvm-userspace/kernel'
 make -C /lib/modules/2.6.20-15-generic/build M=`pwd` $@
 make[2]: Entering directory `/usr/src/linux-headers-2.6.20-15-generic'
 make[3]: *** No rule to make target
 `/home/cam/src/KVM/kvm-userspace/kernel/svm.o', needed by
 `/home/cam/src/KVM/kvm-userspace/kernel/kvm.o'.  Stop.
 make[2]: *** [_module_/home/cam/src/KVM/kvm-userspace/kernel] Error 2
 make[2]: Leaving directory `/usr/src/linux-headers-2.6.20-15-generic'
 make[1]: *** [all] Error 2
 make[1]: Leaving directory `/home/cam/src/KVM/kvm-userspace/kernel'
 make: *** [kernel] Error 2

 I have to admit that I'm a little fuzzy on the modules that are needed
 to build a particular kvm release (and where to get them from).

 Initially, I used Ubuntu's apt install and then moved on to buidling
 kvm-33 from source tar ball which built fine.  But, the kvm-33 tarball
 had the svm source files in the the kernel directory.  I notice those
 files are not in the kvm-35 kernel directory (and are causing the
 failure above).  Is there some other repo svm files are part of?

That is not kvm-35 tarball, it's the git repository for the userspace
component (which -as the name suggests - does not contain the kernel
space part).
Download kvm-35 tarball, you'll find both pieces.

Luca

-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now   http://get.splunk.com/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] a (bad) kvm story from a plain user

2007-08-14 Thread Luca
On 8/14/07, Slohm Gadaburi [EMAIL PROTECTED] wrote:
 I did apt-get installed kvm (which gave me the kvm-amd.ko module),
 and qemu packages.

 I modprobed kvm-adm.ko with no hassle.

 and then I followed the HOWTO page on the kvm wiki -
 created an qemu image and booted off a cd for installing RH9.0
 (yeah, antique).

 But the installation was so slow. about 3 hours !

 How can I know if the qemu I ran took advantage of the kvm module ?

If it cannot use hw virtualization it tells you:

Could not initialize KVM, will disable KVM support

 I ran /usr/bin/qemu as I didn't have /usr/local/kvm/bin/qemu like the HOWTO
 mentioned (as I didn't compiled the kvm bundle myself...).

Under debian the executable is called kvm; I believe that it's the
same under ubuntu. Run dpkg -L kvm and see what has been installed.

Luca

-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now   http://get.splunk.com/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [PATCH] Add support for HPET periodic timer.

2007-08-13 Thread Luca
On 8/13/07, Daniel P. Berrange [EMAIL PROTECTED] wrote:
 On Mon, Aug 13, 2007 at 11:04:46AM +0300, Avi Kivity wrote:
  Luca Tettamanti wrote:
  Something like:
 
  - try to use HPET (unless -no-rtc selected)
  - try to use RTC  (unless -no-rtc selected)
  - fallback to normal unix facilities

 If we're going to add command line args it probably makes sense  to be a
 little more generic than -no-rtc or -use-hpet. Have a list of preferred
 clock sources eg

   -clock hpet,rtc,unix

 If -clock is omitted, then default to trying all in the priority you
 describe.

Makes sense, I'll prepare a patch (maybe after a couple of days of vacation :P).

Luca

-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now   http://get.splunk.com/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [PATCH] Fix compile time warnings in userspace component

2007-08-13 Thread Luca Tettamanti
Fix a few trivial warnings:
- use %zu when printing size_t arguments in printf
- include qemu-kvm.h where appropriate
- change the return type of kvm_eat_signals

Signed-Off-By: Luca Tettamanti [EMAIL PROTECTED]

---

 qemu/hw/apic.c |4 
 qemu/migration.c   |8 
 qemu/qemu-kvm.c|2 +-
 qemu/target-i386/helper2.c |4 
 4 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/qemu/hw/apic.c b/qemu/hw/apic.c
index 2c686a5..523b6a8 100644
--- a/qemu/hw/apic.c
+++ b/qemu/hw/apic.c
@@ -19,6 +19,10 @@
  */
 #include vl.h
 
+#ifdef USE_KVM
+#include ../qemu-kvm.h
+#endif
+
 //#define DEBUG_APIC
 //#define DEBUG_IOAPIC
 
diff --git a/qemu/migration.c b/qemu/migration.c
index ed1fd29..a759400 100644
--- a/qemu/migration.c
+++ b/qemu/migration.c
@@ -686,7 +686,7 @@ wait_for_ack:
goto wait_for_ack;
 if (len != 1 || status != 0) {
 *s-has_error = MIG_STAT_READ_FAILED;
-fprintf(stderr, migration: wait_for_ack: read error l=%ld s=%d(%s)\n,
+fprintf(stderr, migration: wait_for_ack: read error l=%zu s=%d(%s)\n,
 len, status, strerror(errno));
 goto out;
 }
@@ -696,7 +696,7 @@ send_go:
 if (len == -1  errno == EINTR)
goto send_go;
 if (len != 1) {
-fprintf(stderr, migration: send_go: write error l=%ld(%s)\n, 
+fprintf(stderr, migration: send_go: write error l=%zu (%s)\n, 
 len, strerror(errno));
 *s-has_error = MIG_STAT_WRITE_FAILED;
 }
@@ -918,7 +918,7 @@ send_ack:
 if (len == -1  errno == EAGAIN)
goto send_ack;
 if (len != 1) {
-fprintf(stderr, migration: send_ack: write error len=%ld (%s)\n,
+fprintf(stderr, migration: send_ack: write error len=%zu (%s)\n,
 len, strerror(errno));
 rc = MIG_STAT_DST_WRITE_FAILED;
goto error_accept;
@@ -936,7 +936,7 @@ wait_for_go:
goto wait_for_go;
 if (len != 1) {
 rc = MIG_STAT_DST_READ_FAILED;
-fprintf(stderr, migration: wait_for_go: read error len=%ld (%s)\n,
+fprintf(stderr, migration: wait_for_go: read error len=%zu (%s)\n,
 len, strerror(errno));
 }
 
diff --git a/qemu/qemu-kvm.c b/qemu/qemu-kvm.c
index 709e714..e23f477 100644
--- a/qemu/qemu-kvm.c
+++ b/qemu/qemu-kvm.c
@@ -591,7 +591,7 @@ static int kvm_eat_signal(CPUState *env, int timeout)
 }
 
 
-static int kvm_eat_signals(CPUState *env, int timeout)
+static void kvm_eat_signals(CPUState *env, int timeout)
 {
 int r = 0;
 
diff --git a/qemu/target-i386/helper2.c b/qemu/target-i386/helper2.c
index 6217cd5..94833dd 100644
--- a/qemu/target-i386/helper2.c
+++ b/qemu/target-i386/helper2.c
@@ -28,6 +28,10 @@
 #include cpu.h
 #include exec-all.h
 
+#ifdef USE_KVM
+#include ../qemu-kvm.h
+#endif
+
 //#define DEBUG_MMU
 
 #ifdef USE_CODE_COPY


Luca
-- 
Perch� � cos� che ti frega, la vita. Ti piglia quando hai ancora l'anima
 addormentata e ti semina dentro un'immagine, o un odore, o un suono che
 poi non te lo togli pi�. E quella l� era la felicit�.

-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now   http://get.splunk.com/___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [PATCH] Dynamic ticks

2007-08-13 Thread Luca Tettamanti
[QEMU_TIMER_VIRTUAL]) {
+int64_t vmdelta_us, current_us;
+
+if (active_timers[QEMU_TIMER_REALTIME])
+nearest_delta_us = 
(active_timers[QEMU_TIMER_REALTIME]-expire_time - 
qemu_get_clock(rt_clock))*1000;
+
+if (active_timers[QEMU_TIMER_VIRTUAL]) {
+/* round up */
+vmdelta_us = (active_timers[QEMU_TIMER_VIRTUAL]-expire_time - 
qemu_get_clock(vm_clock)+999)/1000;
+if (vmdelta_us  nearest_delta_us)
+nearest_delta_us = vmdelta_us;
+}
+
+/* Avoid arming the timer to negative, zero, or too low values */
+/* MIN_TIMER_REARM_US should be optimized */
+#define MIN_TIMER_REARM_US 250
+if (nearest_delta_us = MIN_TIMER_REARM_US)
+nearest_delta_us = MIN_TIMER_REARM_US;
+
+/* check whether a timer is already running */
+if (timer_gettime(host_timer, timeout))
+perror(gettime);
+current_us = timeout.it_value.tv_sec * 100 + 
timeout.it_value.tv_nsec/1000;
+if (current_us  current_us = nearest_delta_us)
+return;
+
+timeout.it_interval.tv_sec = 0;
+timeout.it_interval.tv_nsec = 0; /* 0 for one-shot timer */
+timeout.it_value.tv_sec =  nearest_delta_us / 100;
+timeout.it_value.tv_nsec = nearest_delta_us % 100 * 1000;
+if (timer_settime(host_timer, 0 /* RELATIVE */, timeout, NULL))
+perror(settime);
+}
+}
+#endif /* DYNAMIC_TICKS */
+
 static int saved_argc;
 static char **saved_argv;
 
@@ -7457,6 +7576,11 @@ int main(int argc, char **argv)
case QEMU_OPTION_cpu_vendor:
cpu_vendor_string = optarg;
break;
+#ifdef DYNAMIC_TICKS
+case QEMU_OPTION_no_dyntick:
+use_dynticks = 0;
+break;
+#endif
 }
 }
 }

Luca
-- 
Se non puoi convincerli, confondili.

-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now   http://get.splunk.com/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] kvm.qumranet.com uncontactable?

2007-08-12 Thread Luca
On 8/12/07, Avi Kivity [EMAIL PROTECTED] wrote:
 Alistair John Strachan wrote:
  Hi there,
 
  The site at kvm.qumranet.com seems to be inaccessible. My DNS comes directly
  from the root servers, so it is not a DNS issue on my end. I seem to be able
  to traceroute the domain, but a web browser will time out.
 
  Supposedly, it's there, as my colleague in the US can access the site, but 
  it
  does not work in the UK (on JANET). Netcraft.com cannot connect to it 
  either.
 
  Could somebody please look into this? Thanks.

 I'm just back from travel in the US, and can confirm this.  From some
 locations, it works well; from others it doesn't work at all; and when
 the quantum state is just right you get half your packets dropped.

 I suspect that we just have a bad ISP that doesn't peer well.  We'll
 work to fix this.

Seems more like a firewall or something like that. IP routing is ok, I
can reach the server (from Italy) just fine, but nothing responds
(nothing at *all*, not event a RST - the same behaviour of iptables
DROP target BTW).

Luca

-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now   http://get.splunk.com/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] adding support for above 2giga to kvm (include patchs)

2007-08-12 Thread Luca Tettamanti
(unsigned long ram_size, int 
 vga_ram_size, int boot_device,
  
  floppy_controller = fdctrl_init(6, 2, 0, 0x3f0, fd_table);
  
 -cmos_init(ram_size, boot_device, bs_table);
 +cmos_init(ram_size , above_bios_mem_size, boot_device, bs_table);

ditto

  
  if (pci_enabled  usb_enabled) {
  usb_uhci_init(pci_bus, piix3_devfn + 2);
 @@ -0,0 +1,178 @@
 +diff --git a/qemu/exec.c b/qemu/exec.c
 +index f5cce06..e54711e 100644
 +--- a/qemu/exec.c
  b/qemu/exec.c
 +@@ -69,7 +69,7 @@
 + #define TARGET_PHYS_ADDR_SPACE_BITS 42
 + #else
 + /* Note: for compatibility with kqemu, we use 32 bits for x86_64 */
 +-#define TARGET_PHYS_ADDR_SPACE_BITS 32
 ++#define TARGET_PHYS_ADDR_SPACE_BITS 42
 + #endif
 + 
 + #ifdef USE_KVM
 +diff --git a/qemu/hw/pc.c b/qemu/hw/pc.c
 +index 7bec234..f938fd0 100644
 +--- a/qemu/hw/pc.c
  b/qemu/hw/pc.c
[cut]

Hum, something went wrong with the patch here...

 diff --git a/qemu/vl.c b/qemu/vl.c
 index 5dd6eec..b7d4c9f 100644
 --- a/qemu/vl.c
 +++ b/qemu/vl.c
 @@ -7546,6 +7546,7 @@ int main(int argc, char **argv)
   exit(1);
   }
  } else {
 + phys_ram_size += KVM_EXTRA_PAGES * 4096;

Tabs instead of spaces

   phys_ram_base = qemu_vmalloc(phys_ram_size);
   if (!phys_ram_base) {
   fprintf(stderr, Could not allocate physical memory\n);
 diff --git a/user/kvmctl.c b/user/kvmctl.c
 index 43b374d..b07f8a8 100644
 --- a/user/kvmctl.c
 +++ b/user/kvmctl.c
 @@ -43,7 +43,7 @@ static int kvm_abi = EXPECTED_KVM_API_VERSION;
  
  /* FIXME: share this number with kvm */
  /* FIXME: or dynamically alloc/realloc regions */
 -#define KVM_MAX_NUM_MEM_REGIONS 4u
 +#define KVM_MAX_NUM_MEM_REGIONS 5u
  #define MAX_VCPUS 4
  
  /**
 @@ -236,6 +236,7 @@ int kvm_create(kvm_context_t kvm, unsigned long memory, 
 void **vm_mem)
  {
   unsigned long dosmem = 0xa;
   unsigned long exmem = 0xc;
 + unsigned long pcimem = 0xf000;
   int fd = kvm-fd;
   int zfd;
   int r;
 @@ -249,6 +250,14 @@ int kvm_create(kvm_context_t kvm, unsigned long memory, 
 void **vm_mem)
   .memory_size = memory  exmem ? 0 : memory - exmem,
   .guest_phys_addr = exmem,
   };
 + struct kvm_memory_region above_bios_memory = {
 + .slot = 4,
 + .memory_size = memory  pcimem ? 0 : memory - pcimem,
 + .guest_phys_addr = 0x1,
 + };
 +
 + if (extended_memory.memory_size  pcimem)
 + extended_memory.memory_size = pcimem - exmem;
  
   kvm-vcpu_fd[0] = -1;
  
 @@ -273,8 +282,17 @@ int kvm_create(kvm_context_t kvm, unsigned long memory, 
 void **vm_mem)
   }
   }
  
 + if (above_bios_memory.memory_size) {
 + r = ioctl(fd, KVM_SET_MEMORY_REGION, above_bios_memory);
 + if (r == -1) {
 + fprintf(stderr, kvm_create_memory_region: %m\n);
 + return -1;
 + }
 + }
 +
   kvm_memory_region_save_params(kvm, low_memory);
   kvm_memory_region_save_params(kvm, extended_memory);
 + kvm_memory_region_save_params(kvm, above_bios_memory);
  
   *vm_mem = mmap(NULL, memory, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
   if (*vm_mem == MAP_FAILED) {

Luca
-- 
La differenza fra l'intelligenza e la stupidita`?
All'intelligenza c'e` un limite.

-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now   http://get.splunk.com/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [BUG][PATCH?] kvm: unhandled wrmsr: 0xc0000083

2007-08-11 Thread Luca Tettamanti
(sorry for the double post - I mistyped the address of the list)

Hi Uri, Avi,
I think I debugged the 

kvm: unhandled wrmsr: 0xc083

on guest reboot with recent KVM userspace.

The root cause is this commit from Uri:

commit 5e1accfc9e7a7d79244c862c04621f7ba23c6d38
Author: Uri Lublin [EMAIL PROTECTED]
Date:   Tue Jun 19 20:28:02 2007 +0300

kvm: configure: for i386 machines make x86_64-softmmu the target

To execute the ifdef X86_64 blocks on both sides

diff --git a/configure b/configure
index e4d1ec6..d9292fe 100755
--- a/configure
+++ b/configure
@@ -74,7 +74,7 @@ fi
 
 target_cpu() {
 if [[ $(uname -m) = i?86 ]]; then
-   echo i386
+   echo x86_64
 else
uname -m
 fi

which enabled the compilation of code depending on TARGET_X86_64.
Problems arise when the host is in 32 bit mode; Avi fixed part of the
issue with d9ff68d1 (masking the LM bit when the host is 32 bit).

The MSR issue is caused by load_regs (qemu/qemu-kvm.c); at line 304 (git
current) you can see:

#ifdef TARGET_X86_64
set_msr_entry(msrs[n++], MSR_CSTAR, env-cstar);
set_msr_entry(msrs[n++], MSR_KERNELGSBASE,  env-kernelgsbase);
set_msr_entry(msrs[n++], MSR_FMASK, env-fmask);
set_msr_entry(msrs[n++], MSR_LSTAR ,env-lstar);
#endif

But the kernel side part (vmx.c) cannot handle those MSRs when using a
32 bit kernel (hence the unhandled wrmsr).

As a side note: MSC_CSTAR (syscall target for compat mode) is supported
*only* on AMD processors (there's no syscall on Intel in 32 bit mode);
is it safe to use it unconditionally? (AFAICS vmx.c would do wrmsrl,
maybe it's not documented but supported?).

In order to fix this bug I hijacked lm_capable_kernel (introduced by
Avi) so that {load,save}_regs don't touch 64bit-only MSRs while the host
is in 32bit mode:

---
 qemu-kvm.c |   22 +-
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/qemu/qemu-kvm.c b/qemu/qemu-kvm.c
index 4ba93d8..b8065db 100644
--- a/qemu/qemu-kvm.c
+++ b/qemu/qemu-kvm.c
@@ -9,6 +9,7 @@
 #endif
 
 int kvm_allowed = KVM_ALLOWED_DEFAULT;
+static int lm_capable_kernel;
 
 #ifdef USE_KVM
 
@@ -302,10 +303,12 @@ static void load_regs(CPUState *env)
set_msr_entry(msrs[n++], MSR_STAR,  env-star);
 set_msr_entry(msrs[n++], MSR_IA32_TSC, env-tsc);
 #ifdef TARGET_X86_64
-set_msr_entry(msrs[n++], MSR_CSTAR, env-cstar);
-set_msr_entry(msrs[n++], MSR_KERNELGSBASE,  env-kernelgsbase);
-set_msr_entry(msrs[n++], MSR_FMASK, env-fmask);
-set_msr_entry(msrs[n++], MSR_LSTAR  ,   env-lstar);
+if (lm_capable_kernel) {
+set_msr_entry(msrs[n++], MSR_CSTAR, env-cstar);
+set_msr_entry(msrs[n++], MSR_KERNELGSBASE,  env-kernelgsbase);
+set_msr_entry(msrs[n++], MSR_FMASK, env-fmask);
+set_msr_entry(msrs[n++], MSR_LSTAR  ,   env-lstar);
+}
 #endif
 
 rc = kvm_set_msrs(kvm_context, env-cpu_index, msrs, n);
@@ -439,10 +442,12 @@ static void save_regs(CPUState *env)
msrs[n++].index = MSR_STAR;
 msrs[n++].index = MSR_IA32_TSC;
 #ifdef TARGET_X86_64
-msrs[n++].index = MSR_CSTAR;
-msrs[n++].index = MSR_KERNELGSBASE;
-msrs[n++].index = MSR_FMASK;
-msrs[n++].index = MSR_LSTAR;
+if (lm_capable_kernel) {
+msrs[n++].index = MSR_CSTAR;
+msrs[n++].index = MSR_KERNELGSBASE;
+msrs[n++].index = MSR_FMASK;
+msrs[n++].index = MSR_LSTAR;
+}
 #endif
 rc = kvm_get_msrs(kvm_context, env-cpu_index, msrs, n);
 if (rc == -1) {
@@ -1001,7 +1006,6 @@ static void do_cpuid_ent(struct kvm_cpuid_entry *e, 
uint32_t function,
 if (function == 0x8001) {
uint32_t h_eax, h_edx;
struct utsname utsname;
-   int lm_capable_kernel;
 
host_cpuid(function, h_eax, NULL, NULL, h_edx);
uname(utsname);

get_msr_entry should be fine, cpu_save/cpu_load (used by savevm -
qemu/vl.c) may need a similar fix.

The patch stops the unhandled wrmsr, but reboot is still not working
(guest is stuck using 100% of the CPU). The last working userspace is
KVM-28, and I tested it with recent kernel modules. Any idea on this
one?

Luca
-- 
Runtime error 6D at f000:a12f : user incompetente

-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now   http://get.splunk.com/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] kvm very slow

2007-08-07 Thread Luca
On 8/7/07, Ulrich Schreiner [EMAIL PROTECTED] wrote:
 Could not configure '/dev/rtc' to have a 1024 Hz timer. This is not a
 fatal
 error, but for better emulation accuracy either use a 2.6 host Linux
 kernel or
 type 'echo 1024  /proc/sys/dev/rtc/max-user-freq' as root.

 well i HAVE a 2.6kernel (2.6.22.1-41.fc7), but i cannot set
 dev.rtc.max-user-freq, i only can set the high precision event timer

 dev.hpet.max-user-freq = 1024

Known issue, it's unrelated to KVM. HPET is using the same IRQ as the
cmos RTC so only on of them can deliver the periodical interrupt. I
think that work to program the HPET in dont-break-other-stuff mode is
underway.

Luca

-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now   http://get.splunk.com/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] kvm very slow

2007-08-07 Thread Luca
On 8/7/07, Dor Laor [EMAIL PROTECTED] wrote:
 Luca claims the HPET intefer the RTC. Can it be disabled? ( I know some
 new chipsets implement rtc using HPET).

Basically HPET can operate in legacy mode - where it uses the same IRQ
as the RTC (and RTC won't deliver any interrupt) - or in standard
mode where the IO-APIC can be configured to deliver the interrupt on
any line. ATM Linux can only use the legacy mode.
You can of course disable HPET, but then it won't be available for
in-kernel timekeeping (in case e.g. the TSC is not stable/synced). I'd
rather add support for HPET as timer in QEMU...
On the original issue: if the host is running at HZ=100 then the
precision of the timer may be a awkward (usually around 20ms), but
it's surprising that it causes such a huge drift.

Luca

-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now   http://get.splunk.com/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] kvm very slow

2007-08-07 Thread Luca Tettamanti
Il Tue, Aug 07, 2007 at 02:08:08PM +0200, Luca ha scritto: 
 On 8/7/07, Dor Laor [EMAIL PROTECTED] wrote:
  Luca claims the HPET intefer the RTC. Can it be disabled? ( I know some
  new chipsets implement rtc using HPET).
 
 Basically HPET can operate in legacy mode - where it uses the same IRQ
 as the RTC (and RTC won't deliver any interrupt) - or in standard
 mode where the IO-APIC can be configured to deliver the interrupt on
 any line. ATM Linux can only use the legacy mode.
 You can of course disable HPET, but then it won't be available for
 in-kernel timekeeping (in case e.g. the TSC is not stable/synced). I'd
 rather add support for HPET as timer in QEMU...

Something like this. Ulrich can you give it a try:

---
Patch against current GIT, but also applies to kvm-33.
Run kvm with -use-hpet.

 qemu/vl.c |   62 ++--
 1 file changed, 60 insertions(+), 2 deletions(-)

diff --git a/qemu/vl.c b/qemu/vl.c
index 4ad39f1..36628af 100644
--- a/qemu/vl.c
+++ b/qemu/vl.c
@@ -54,6 +54,7 @@
 #include pty.h
 #include malloc.h
 #include linux/rtc.h
+#include linux/hpet.h
 #include linux/ppdev.h
 #endif
 #endif
@@ -996,8 +997,9 @@ static void host_alarm_handler(int host_signum)
 
 static int use_rtc = 1;
 static int rtc_fd;
+static int use_hpet;
 
-static int start_rtc_timer(void)
+static int enable_rtc(void)
 {
 rtc_fd = open(/dev/rtc, O_RDONLY);
 if (rtc_fd  0)
@@ -1017,6 +1019,56 @@ static int start_rtc_timer(void)
 return 0;
 }
 
+static char default_hpet[] = /dev/hpet;
+
+static int enable_hpet(void)
+{
+struct hpet_info info;
+int r;
+
+rtc_fd = open(default_hpet, O_RDONLY);
+if (rtc_fd  0)
+return -1;
+
+/* Set frequency */
+r = ioctl(rtc_fd, HPET_IRQFREQ, RTC_FREQ);
+if (r  0) {
+fprintf(stderr, Could not configure '/dev/hpet' to have a 1024 Hz 
timer. This is not a fatal\n
+error, but for better emulation accuracy type:\n
+'echo 1024  /proc/sys/dev/hpet/max-user-freq' as root.\n);
+goto fail;
+}
+
+/* Check capabilities */
+r = ioctl(rtc_fd, HPET_INFO, info);
+if (r  0)
+goto fail;
+
+/* Enable peridic mode */
+r = ioctl(rtc_fd, HPET_EPI, 0);
+if (info.hi_flags  (r  0))
+goto fail;
+
+/* Enable interrupt */
+r = ioctl(rtc_fd, HPET_IE_ON, 0);
+if (r  0)
+goto fail;
+
+pit_min_timer_count = PIT_FREQ / RTC_FREQ;
+
+return 0;
+fail:
+close(rtc_fd);
+return -1;
+}
+
+static int start_rtc_timer(void)
+{
+if (use_hpet)
+return enable_hpet();
+else
+return enable_rtc();
+}
 #else
 
 static int start_rtc_timer(void)
@@ -1090,7 +1142,7 @@ static void init_timer_alarm(void)
2.6 kernels */
 if (itv.it_interval.tv_usec  1000 || 1) {
 /* try to use /dev/rtc to have a faster timer */
-if (!use_rtc || (start_rtc_timer()  0))
+if ((!use_rtc  !use_hpet) || (start_rtc_timer()  0))
 goto use_itimer;
 /* disable itimer */
 itv.it_interval.tv_sec = 0;
@@ -6482,6 +6534,7 @@ void help(void)
-tdfinject timer interrupts that got lost\n
 #if defined(__linux__)
-no-rtc don't use /dev/rtc for timer alarm (do use 
gettimeofday)\n
+   -use-rtcuse /dev/hpet (HPET) for timer alarm (do use 
gettimeofday)\n
 #endif
   -option-rom rom load a file, rom, into the option ROM space\n
\n
@@ -6574,6 +6627,7 @@ enum {
 QEMU_OPTION_tdf,
 #if defined(__linux__)
 QEMU_OPTION_no_rtc,
+QEMU_OPTION_use_hpet,
 #endif
 QEMU_OPTION_cpu_vendor,
 };
@@ -6671,6 +6725,7 @@ const QEMUOption qemu_options[] = {
 { tdf, 0, QEMU_OPTION_tdf }, /* enable time drift fix */
 #if defined(__linux__)
 { no-rtc, 0, QEMU_OPTION_no_rtc },
+{ use-hpet, 0, QEMU_OPTION_use_hpet },
 #endif
 { cpu-vendor, HAS_ARG, QEMU_OPTION_cpu_vendor },
 { NULL },
@@ -7395,6 +7450,9 @@ int main(int argc, char **argv)
case QEMU_OPTION_no_rtc:
use_rtc = 0;
break;
+   case QEMU_OPTION_use_hpet:
+   use_hpet = 1;
+   break;
 #endif
case QEMU_OPTION_cpu_vendor:
cpu_vendor_string = optarg;



Luca
-- 
I went to God just to see
And I was looking at me
Saw heaven and hell were lies
When I'm God everyone dies

-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now   http://get.splunk.com/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] qcow2 image growing without reason ?

2007-07-29 Thread Luca
On 7/26/07, Ben Budts [EMAIL PROTECTED] wrote:
 When I select all my files and take properties (in win xp that is), it says 
 3.7GB, as expected...

 The image is allmost the double though (6.4GB) when i look at the qcow2 image,
 when taking the properties of the HD in win xp it also indictates 6.4GB.

Hum, then the used disk space is 6.4GB. Selecting all files may skip
hidden/system/whatever files according to explorer settings.

Luca

-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now   http://get.splunk.com/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [ANNOUNCE] kvm-30 release

2007-07-19 Thread Luca
On 7/19/07, Avi Kivity [EMAIL PROTECTED] wrote:
 Changes from kvm-29:
[...]
 - revert ide enable changes that caused an I/O regression

Not really. Dave is seeing the regression when IDE ports are enabled
and KVM BIOS does enable them.
Reverting the patch allows running another BIOS (e.g. QEMU BIOS) which
doesn't enable the port though.

Luca
As a side note: I'm currently busy with ICWE and tomorrow I'll be
leaving for Rome so I cannot do further tests.

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] kvm-27 vs 28 I/O speed

2007-07-18 Thread Luca
On 7/17/07, Avi Kivity [EMAIL PROTECTED] wrote:
 Luca wrote:
 
  So, would it be correct to revert the patch enabling the ports, assuming
  people use the kvm-supplied bios?
 
  I think so.

 Please confirm that the original test case (I think it was the FC7
 installer?) works with the kvm bios.

Yes, FC7 libata driver does see the disks.

Luca

-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] capturing debug outputs

2007-07-17 Thread Luca
On 7/17/07, eric magaoay [EMAIL PROTECTED] wrote:
 Hi,
 I'm trying to capture debugs output (kernel panic) using -kernel and
 -serial options but nothing is coming out of /dev/ttyS0 (using
 minicom).

Hi,
you have to tell the kernel to use the serial port as a console (the
same way you do with real  hw). Append console=ttyS0 (or
console=tty0 console=ttyS0 to have both) to kernel command line.

Luca

-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] kvm-27 vs 28 I/O speed

2007-07-15 Thread Luca
On 7/15/07, Luca [EMAIL PROTECTED] wrote:
 On 7/13/07, Dave Hansen [EMAIL PROTECTED] wrote:
  diff -ru kvm-fast-dmesg.txt kvm-slow-dmesg.txt
 
   Linux version 2.6.22 ([EMAIL PROTECTED]) (gcc version 4.1.2 (Ubuntu 
  4.1.2-0ubuntu4)) #13 Wed Jul 11 15:27:01 PDT 2007

 Is this a vanilla 2.6.22? 32 bit?

  @@ -107,20 +90,21 @@
   PIIX3: IDE controller at PCI slot :00:01.1
   PIIX3: chipset revision 0
   PIIX3: not 100% native mode: will probe irqs later
  -PIIX3: neither IDE port enabled (BIOS)
  +ide0: BM-DMA at 0x1400-0x1407, BIOS settings: hda:pio, hdb:pio
  +ide1: BM-DMA at 0x1408-0x140f, BIOS settings: hdc:pio, hdd:pio

 Hum, FC6 PIIX driver always comes up with the same mode, regardless of
 what I'm doing to the controller...

Ok, now I'm confused...

pci_config_write: PIIX3 IDE: addr=40 val=8000 len=2
pci_config_write: PIIX3 IDE: addr=42 val=8000 len=2

I'm using KVM-27 userspace, and the BIOS is enabling both ports. So...
linux shouldn't think that the ports are disabled (yet I saw the same
thing with FC7 and libata).

Luca

-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] kvm-27 vs 28 I/O speed

2007-07-15 Thread Luca
On 7/15/07, Luca [EMAIL PROTECTED] wrote:
 On 7/15/07, Luca [EMAIL PROTECTED] wrote:
  On 7/13/07, Dave Hansen [EMAIL PROTECTED] wrote:
   diff -ru kvm-fast-dmesg.txt kvm-slow-dmesg.txt
  
Linux version 2.6.22 ([EMAIL PROTECTED]) (gcc version 4.1.2 (Ubuntu 
   4.1.2-0ubuntu4)) #13 Wed Jul 11 15:27:01 PDT 2007
 
  Is this a vanilla 2.6.22? 32 bit?
 
   @@ -107,20 +90,21 @@
PIIX3: IDE controller at PCI slot :00:01.1
PIIX3: chipset revision 0
PIIX3: not 100% native mode: will probe irqs later
   -PIIX3: neither IDE port enabled (BIOS)
   +ide0: BM-DMA at 0x1400-0x1407, BIOS settings: hda:pio, hdb:pio
   +ide1: BM-DMA at 0x1408-0x140f, BIOS settings: hdc:pio, hdd:pio
 
  Hum, FC6 PIIX driver always comes up with the same mode, regardless of
  what I'm doing to the controller...

 Ok, now I'm confused...

 pci_config_write: PIIX3 IDE: addr=40 val=8000 len=2
 pci_config_write: PIIX3 IDE: addr=42 val=8000 len=2

 I'm using KVM-27 userspace, and the BIOS is enabling both ports. So...
 linux shouldn't think that the ports are disabled (yet I saw the same
 thing with FC7 and libata).

Oh fuck, it's obvious... If you don't supply -L on the command line
KVM ends up using the BIOS in the default system directory
(/usr/share{,local}/qemu); on my system this the BIOS installed by
QEMU 0.9, which does *not* enable the IDE ports. OTOH the BIOS file
shipped with KVM does enable the ports.
I guess that you're seeing the same thing: you used to run KVM+QEMU
bios (ports disabled - fast); then KVM started to enable IDE ports
(even with QEMU bios) and you saw a regression.
Can you re-test KVM 27 with it's BIOS (i.e. use something like -L
~/src/kvm-27/qemu/pc-bios)?

FYI I'm seeing a better tput with MWDMA2 (ports enabled) rather than
with PIO (ports disabled).

Luca

-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] kvm-27 vs 28 I/O speed

2007-07-13 Thread Luca
On 7/13/07, Avi Kivity [EMAIL PROTECTED] wrote:
 Dave Hansen wrote:
  On Thu, 2007-07-12 at 08:37 +0300, Avi Kivity wrote:
 
  Can you confirm it by backing out that one patch?
 
 
  Do you know the git commit id by chance?
 
  -- Dave
 
 
 commit 55a3212bc2f5ecddcd4c5cdf2bfb37ad71e45ff2
 Author: Luca Tettamanti [EMAIL PROTECTED]
 Date:   Tue Jun 5 14:47:33 2007 +0300

 kvm: qemu: initialize ata ports as enabled

 this allows libata to see the qemu ata ports.

 diff --git a/qemu/hw/ide.c b/qemu/hw/ide.c
 index 190f074..ddfb9bc 100644
 --- a/qemu/hw/ide.c
 +++ b/qemu/hw/ide.c
 @@ -2586,6 +2586,8 @@ static void piix3_reset(PCIIDEState *d)
  pci_conf[0x06] = 0x80; /* FBC */
  pci_conf[0x07] = 0x02; // PCI_status_devsel_medium
  pci_conf[0x20] = 0x01; /* BMIBA: 20-23h */
 +pci_conf[0x41] = 0x80; // enable port 0
 +pci_conf[0x43] = 0x80; // enable port 1
  }

  void pci_piix_ide_init(PCIBus *bus, BlockDriverState **hd_table, int devfn)


 I was unable to reproduce this on a FC6 i386 guest.

Hum... I assume the FC6 is using the old IDE driver, yes? I can't
see why that patch should matter though... if those bits are not set
then the IDE controller is not decoding the commands (on real hw).

Luca

-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] kvm-27 vs 28 I/O speed

2007-07-13 Thread Luca
On 7/13/07, Gregory Haskins [EMAIL PROTECTED] wrote:
 On Fri, 2007-07-13 at 16:41 +0300, Avi Kivity wrote:


  I tested FC6 i386 about found no difference with or without the patch.
 
  Dave, can you diff the guest dmesg with kvm-27 and kvm-28 userspace?
  Maybe that will tell us something.
 

 I can say this:  It would seem that the IDE enable bits float before
 Lucas fix.  I say this because I had written/submitted a similar fix way
 back in kvm-teens because I found that sometimes my SLED installer guest
 would fail to see the IDE controller.  I found it to be that the IDE
 controller wasn't enabled sometimes and setting the 0x80 bits as Luca
 has done fixed the issue.

 Then, I found that later versions of KVM (sans my patch) seemed to work
 fine so I somewhat assumed the issue had been addressed.  When I saw
 Lucas patch come through, I realized that it must not have been fixed,
 but I was getting lucky that it tended to come up enabled pretty much
 100%.

 So heres what I think is happening:  I think that having the IDE
 controller enabled is causing FC7 to go into a different mode of
 operation, which is slower for whatever reason.  I think that Dave has a
 system that relatively deterministically comes up disabled, and Avi has
 one that comes up enabled.  Therefore, the patch has ill-effect for
 Dave, and no-effect for Avi.

 Therefore, to test this theory, Avi should modify Luca patch to
 *disable* the IDE and see what happens.  If the theory is true, Avi will
 see a speed improvement.

 Just a shot in the dark... ;)

Just to clarify: you are suggesting that the old IDE driver used to
see that the controller was disabled and reprogrammed it by itself
(fast mode); now it sees it's enabled and leaves whatever mode is
currently set.
I can't look at the sources right now but it's at least plausible ;-)

Luca

-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] kvm-27 vs 28 I/O speed

2007-07-13 Thread Luca
On 7/13/07, Gregory Haskins [EMAIL PROTECTED] wrote:
 On Fri, 2007-07-13 at 16:46 +0200, Luca wrote:
  On 7/13/07, Gregory Haskins [EMAIL PROTECTED] wrote:

  Just to clarify: you are suggesting that the old IDE driver used to
  see that the controller was disabled and reprogrammed it by itself
  (fast mode); now it sees it's enabled and leaves whatever mode is
  currently set.
  I can't look at the sources right now but it's at least plausible ;-)
 

 Yeah.  As Im sure you are aware, those bits that your patch modifies are
 (IIUC) for enabling/disabling access to the legacy IDE.  On real
 hardware, they can be used by the bios to enable/disable the legacy IDE
 function.  It doesnt actually disable the chip IIUC..

Hum, are you *really* sure? Intel doc says:

IDE Decode Enable (IDE). 1=Enable; 0=Disable. When enabled, I/O
transactions on PCI
targeting the IDE ATA register blocks (command block and control
block) are positively
decoded on PCI and driven on the IDE interface. When disabled, these
accesses are
subtractively decoded to ISA.

Now, subtractively decoded to ISA means that if nobody wants them
then those accesses are left to ISA devices (the PCI-to-ISA bridge
forwards them).
So IIRC setting the decode enable to 0 really means disable the controller.

 its just a flag to let higher layer software detect if the legacy IDE is 
 usable.  In our
 emulated environment, those bits were left undefined prior to your patch
 (neither qemu nor bochs was configuring them).

Bochs *is* enabling the ports; it's just that it does that in the
emulated device (i.e. the equivalent of out hw/ide.c) and not in the
BIOS.

Btw, the original thread is there:
http://thread.gmane.org/gmane.comp.emulators.kvm.devel/3619

 So what I am thinking is that the drivers included with the FC7 kernel
 are defaulting to some kind of slower legacy mode when they see it is
 available and enabled.  Otherwise, they probably load some direct
 non-legacy PCI driver and use that instead.

Nope, FC7 with libata doesn't find anything at all. It doesn't even
try to touch the controller if the ports are not enabled. This makes a
lot of sense since with ports disabled all the access to the command
and control blocks are forwarded to the ISA worlds (since the IDE
controller is not claiming the transactions).
I guess that the old driver has some logic like BIOS is stupid, we
really want to enable this port.
Still, I fail to see why enabling the ports should reduce the speed.
Dave, can you confirm that backing out my patch fixes your speed issue?


Luca

-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] Network definitions in a guest (FC6) under kvm

2007-07-12 Thread Luca
On 7/12/07, David Shwatrz [EMAIL PROTECTED] wrote:
 I have kvm on FC7. I had installed an FC6 guest on it according to the
 kvm howto. I can launch the FC6 guest (using kvm) perfectly ok.
 During installation, I set the IP address of the guest to be
  192.168.0.11/24 and defualt gw to 192.168.0.1.
 These definitions are OK (I simply run ifconfig -a from the
 guest , FC7, and see that these definitions are maintained, and the nic is
 UP
 and running).

 On the other hand, I cannot ping it from the host (192.168.0.10) ,
 and also vice versa: I cannot ping the host from the guest,
 namely, I cannot ping 192.168.0.10 from 192.168.0.11.

 Any ideas ? is something missing here ?

You should tell us more about your setup. It seems that you you are
not using a bridged configuration; if eth0 has address 192.168.0.10
then packets for 192.168.0.0/24 are routed through eth0 (an the
virtual interface sit0 doesn't see them).
You can either:
- use a different subnet for the VMs, configure the kernel to forward
packets between the 2 networks
- create a bridge that spans across eth0 and sit0, so that it becomes
an unique net segment

I have a script for the 2nd solution, I can send as soon as I get home
if you're interested.

Luca

-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] Network definitions in a guest (FC6) under kvm

2007-07-12 Thread Luca Tettamanti
(don't top post)

Il Thu, Jul 12, 2007 at 03:56:07PM +0300, David Shwatrz ha scritto: 
 Hello,
 And I just want to add some info :
 
 running :
 brctl show
 
 gives:
 bridge name bridge id   STP enabled interfaces
 virbr0  8000.   no
 
 which means that there is no interface enslaved to this bridge.

Hum, this depends on what the script (/etc/kvm/kvm-ifup, or
/etc/qemu-ifup) is doing...


 On 7/12/07, David Shwatrz [EMAIL PROTECTED] wrote:
 
 Thanks;
 I am not sure I got you !
 running ifconfig -a   on the host shows the following:
 
 eth0  Link encap:Ethernet  HWaddr 00:1B:24:1D:EC:C0
   inet addr: 192.168.0.31  Bcast:192.168.0.255  Mask:255.255.255.0
   inet6 addr: fe80::21b:24ff:fe1d:ecc0/64 Scope:Link
   UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
   RX packets:10164222 errors:0 dropped:0 overruns:0 frame:0
   TX packets:95594 errors:0 dropped:0 overruns:0 carrier:0
   collisions:0 txqueuelen:1000
   RX bytes:3427235680 (3.1 GiB)  TX bytes:27635785 (26.3 MiB)
   Interrupt:19
 
 
 loLink encap:Local Loopback
   inet addr:127.0.0.1  Mask:255.0.0.0
   inet6 addr: ::1/128 Scope:Host
   UP LOOPBACK RUNNING  MTU:16436  Metric:1
   RX packets:5821 errors:0 dropped:0 overruns:0 frame:0
   TX packets:5821 errors:0 dropped:0 overruns:0 carrier:0
   collisions:0 txqueuelen:0
   RX bytes:804856 (785.9 KiB)  TX bytes:804856 (785.9 KiB)
 
 virbr0Link encap:Ethernet  HWaddr 00:00:00:00:00:00
   inet addr: 192.168.122.1  Bcast:192.168.122.255  Mask:
 255.255.255.0
   inet6 addr: fe80::200:ff:fe00:0/64 Scope:Link
   UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
   RX packets:0 errors:0 dropped:0 overruns:0 frame:0
   TX packets:93 errors:0 dropped:0 overruns:0 carrier:0
   collisions:0 txqueuelen:0
   RX bytes:0 (0.0 b)  TX bytes:21586 ( 21.0 KiB)

This configuration is a bit different from the one described in
the first mail though.

 As you can see, there is not sit interface here. There is a virbr0
 (bridge) but on 192.168.122.1

sit0 is the TUN device used by default, i.e. unless you're passing
-no-tap to the kvm script. If you're calling the qemu binary without
using the 'kvm' python wrapper then you should use something like this:

/path/to/kvm/qemu-whatever -hda disk-image.qcow -cdrom cd.iso -net tap
-net nic (plus optional stuff)

So: how are you creating the virtual machine? What is the content of the
network startup file?

Your kernel must also support the TUN device (CONFIG_TUN).

 Please advice; also if you can please send the script, maybe I can get
 some ideas from it regarding what to do.

$ cat /etc/kvm/kvm-ifup

#!/bin/sh

BRIDGE_DEV=br0
BRIDGE_ADDR=172.20.0.1/16
BRIDGE_BCAST=172.20.255.255
BRIDGE_ADDR6=fec0:2::1/64
#MAINIF=eth1

#set -x

ip link show dev $BRIDGE_DEV  /dev/null 21
if [ $? -ne 0 ]; then
# Set up the bridge
brctl addbr $BRIDGE_DEV

if [ -n $MAINIF ]; then
ip link set $MAINIF up
brctl addif $BRIDGE_DEV $MAINIF
fi
ip addr add $BRIDGE_ADDR broadcast $BRIDGE_BCAST dev $BRIDGE_DEV

if [ -n $BRIDGE_ADDR6 ]; then
ip addr add $BRIDGE_ADDR6 dev $BRIDGE_DEV

if [ -e /etc/init.d/radvd ]; then
/etc/init.d/radvd reload
fi
fi

ip link set $BRIDGE_DEV up
fi

# Add new interface
ip link set $1 up
brctl addif $BRIDGE_DEV $1

The configuration is done with the vars at the beginning. What the
script does is:

- Check whether the bridge $BRIDGE_DEV is alread there, if not:
  - Create the bridge
  - Enslave $MAINIF, if required. This can be used to e.g. create a
bridged ethernet with one of your NICs. Leave MAINIF empty if you
want to use a separate subnet for the VMs.
  - Configure IPv6, is requested
- Enslave the new interface ($1)

Note that if the bridge with the VMs is on a separate network (in your
case the LAN on eth0 is 192.168.0.0/24, while the virtual LAN is
192.168.122.0/24) you must enable the forwarding between the 2
interfaces:

# echo 1  /proc/sys/net/ipv4/ip_forward

This allows the guest to talk with the host. To communicate with an
external host (be it another machine on the LAN or a server on the
Internet) you'll have to set up a NAT (or - simpler - MASQUERADE) with
iptables.

This setup allows you to make a clear separation between the VMs and the
rest of the net. Of course you can also create a bridge with eth0 and
the interface of the VM (e.g. set MAINIF=eth0 in my script) and it
will just work.

Option 3 is: forget about the bridge and do the routing at IP level.

HTH,
Luca
-- 
Dicono che  il cane sia  il miglior  amico dell'uomo. Secondo me  non e`
vero. Quanti dei vostri amici avete fatto castrare, recentemente

Re: [kvm-devel] [PATCH 2/2] KVM: Use the scheduler preemption hooks to make kvm preemptible

2007-07-11 Thread Luca
On 7/11/07, Avi Kivity [EMAIL PROTECTED] wrote:
 Current kvm disables preemption while the new virtualization registers are
 in use.  This of course is not very good for latency sensitive workloads (one
 use of virtualization is to offload user interface and other latency
 insensitive stuff to a container, so that it is easier to analyze the
 remaining workload).  This patch re-enables preemption for kvm; preemption
 is now only disabled when switching the registers in and out, and during
 the switch to guest mode and back.
[...]
 diff --git a/drivers/kvm/Kconfig b/drivers/kvm/Kconfig
 index 33fa28a..92644b5 100644
 --- a/drivers/kvm/Kconfig
 +++ b/drivers/kvm/Kconfig
 @@ -10,7 +10,7 @@ if VIRTUALIZATION

  config KVM
 tristate Kernel-based Virtual Machine (KVM) support
 -   depends on X86  EXPERIMENTAL
 +   depends on X86  EXPERIMENTAL  PREEMPT_HOOKS
 depends on X86_CMPXCHG64 || 64BIT

select PREEMPT_HOOKS maybe?

Luca

-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] opening windows from linux (using kvm) in full screen by default

2007-07-02 Thread Luca
On 7/2/07, Mark Ryden [EMAIL PROTECTED] wrote:
 My question is:
 I am launching windows 2003 from linux by
 /usr/local/kvm/bin/qemu-system-x86_64 . -hda vdisk.img -cdrom
 /dev/hdb -no-acpi -boot d -m 384.

-full-screen and, please, man pages exist for a reason ;)

Luca

-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] kvm-27 host oopses

2007-07-02 Thread Luca
On 7/2/07, Dave Hansen [EMAIL PROTECTED] wrote:
 I had a host running kvm-27 oops on me last week.  The system had been
 up for about 2 weeks, and had probably run and stopped at least a couple
 hundred kvm guests.  I don't think it is very reproducible, but here it
 is anyway.  The host is running 2.6.20.4.

 Here's the actual BUG_ON() that was hit:

 static void *mmu_memory_cache_alloc(struct kvm_mmu_memory_cache *mc,
 size_t size)
 {
 void *p;

 BUG_ON(!mc-nobjs);
 p = mc-objects[--mc-nobjs];
 memset(p, 0, size);
 return p;
 }

MMU working memory was exhausted during a guest context switch. It has
been fixed by:

KVM: Lazy guest cr3 switching
4b82b37a35a085a07d9ed84efee06c69655fd3d1

which is included in KVM-28.

Luca

-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [ kvm-Bugs-1740031 ] Kubuntu 7.04 fails to boot as guest- hangs after kernel boot

2007-06-28 Thread Luca
On 6/22/07, Luca [EMAIL PROTECTED] wrote:
 On 6/22/07, Morten Lund [EMAIL PROTECTED] wrote:
  On Thursday 21 June 2007 01:24, Luca wrote:
   On 6/20/07, SourceForge.net [EMAIL PROTECTED] wrote:
Bugs item #1740031, was opened at 2007-06-20 01:12
Message generated for change (Tracker Item Submitted) made by Item
Submitter You can respond by visiting:
https://sourceforge.net/tracker/?func=detailatid=893831aid=1740031grou
   p_id=180599
  
   [...]
  
The image contains a Kubuntu version, installed with qemu with no
hw-acceleration, and it boots fine in qemu. All graphics during the boot
sequence has been disabled from the menu.lst in Grub.
   
My mileage varies: Mostly I get to the point in the hang screenshot.
Although not hanging 100%, as I can type on the keyboard, and the
characters gets displayed.
   
When it hangs, it takes 97% to 100% of the CPU on the host system.
   
And this is where it gets strange: I can sometimes avoid the hang if i
type on the keyboard while the kernel boots (before the actual hang).
Seems to be very random though.
  
   Try booting with 'nolapic' on kernel command line.
 
  Tried to do that. Same issue. I did it in the guest system. Should I do it 
  on
  the host system?

 No, it's correct. Ubuntu 'generic' kernel is compiled for i586 and may
 hit the emulator bug that I fixed. Your lockup is very similar to the
 bug that I've fixed... can you try this patch, just in case:

http://git.kernel.org/?p=linux/kernel/git/avi/kvm.git;a=commitdiff_plain;h=ba9c20c048726037664d303362b688759fdf6e9d

Ping? Any news on this issue?

Luca

-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [PATCH 1/2] kvm: Fix x86 emulator writeback

2007-06-19 Thread Luca Tettamanti
When the old value and new one are the same the emulator skips the
write; this is undesiderable when the destination is a MMIO area and the
write shall be performed regardless of the previous value. This
optimization breaks e.g. a Linux guest APIC compiled without
X86_GOOD_APIC.

Remove the check and perform the writeback stage in the emulation unless
it's explicitly disabled (currently push and some 2 bytes instructions
may disable the writeback).

Signed-Off-By: Luca Tettamanti [EMAIL PROTECTED]

---

 Tested with Fedora7, Solaris10 and WinXP on a 32 bit host with Intel
 CPU.

 drivers/kvm/x86_emulate.c |7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/kvm/x86_emulate.c b/drivers/kvm/x86_emulate.c
index a4a8481..eb10448 100644
--- a/drivers/kvm/x86_emulate.c
+++ b/drivers/kvm/x86_emulate.c
@@ -482,6 +482,7 @@ x86_emulate_memop(struct x86_emulate_ctxt *ctxt, struct 
x86_emulate_ops *ops)
int mode = ctxt-mode;
unsigned long modrm_ea;
int use_modrm_ea, index_reg = 0, base_reg = 0, scale, rip_relative = 0;
+   int no_wb = 0;
 
/* Shadow copy of register state. Committed on successful emulation. */
unsigned long _regs[NR_VCPU_REGS];
@@ -1048,7 +1049,7 @@ done_prefixes:
  _regs[VCPU_REGS_RSP]),
 dst.val, dst.bytes, ctxt)) != 0)
goto done;
-   dst.val = dst.orig_val; /* skanky: disable writeback */
+   no_wb = 1;  /* skanky: disable writeback */
break;
default:
goto cannot_emulate;
@@ -1057,7 +1058,7 @@ done_prefixes:
}
 
 writeback:
-   if ((d  Mov) || (dst.orig_val != dst.val)) {
+   if (!no_wb) {
switch (dst.type) {
case OP_REG:
/* The 4-byte case *is* correct: in 64-bit mode we 
zero-extend. */
@@ -1306,7 +1307,7 @@ twobyte_insn:
 
 twobyte_special_insn:
/* Disable writeback. */
-   dst.orig_val = dst.val;
+   no_wb = 1;
switch (b) {
case 0x09:  /* wbinvd */
break;


Luca
-- 
Colui che sorride quando le cose vanno male ha pensato a qualcuno a cui
dare la colpa.

-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [PATCH 1/2] kvm: Fix x86 emulator writeback

2007-06-19 Thread Luca Tettamanti
Il Mon, Jun 18, 2007 at 02:32:39PM +0300, Avi Kivity ha scritto: 
 Unfortunately, this kills Windows XP (first run with a guest crash, 
 second with a host oops), so I reverted it.  I'd guess some operation  
 which doesn't need writeback ends up in the modified code.  
 Previously, the check caused it to skip writeback, but now it writes 
 back random memory, causing a crash.
 
 
 There are comments around like
 
 /* Disable writeback. */
 dst.orig_val = dst.val;
 
 Best option is probably to add an explicit disable_writeback flag and 
 set it there.

I've tested this patch with linux, solaris and winxp, on a 32 bit guest.
So far everything is fine ;)
David, this patch should fix the lockup you're seeing.

diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c
index 633c2ed..9b7b0b9 100644
--- a/drivers/kvm/kvm_main.c
+++ b/drivers/kvm/kvm_main.c
@@ -1139,8 +1139,10 @@ static int emulator_write_phys(struct kvm_vcpu *vcpu, 
gpa_t gpa,
return 0;
mark_page_dirty(vcpu-kvm, gpa  PAGE_SHIFT);
virt = kmap_atomic(page, KM_USER0);
-   kvm_mmu_pte_write(vcpu, gpa, virt + offset, val, bytes);
-   memcpy(virt + offset_in_page(gpa), val, bytes);
+   if (memcmp(virt + offset_in_page(gpa), val, bytes)) {
+   kvm_mmu_pte_write(vcpu, gpa, virt + offset, val, bytes);
+   memcpy(virt + offset_in_page(gpa), val, bytes);
+   }
kunmap_atomic(virt, KM_USER0);
return 1;
 }
diff --git a/drivers/kvm/x86_emulate.c b/drivers/kvm/x86_emulate.c
index a4a8481..eb10448 100644
--- a/drivers/kvm/x86_emulate.c
+++ b/drivers/kvm/x86_emulate.c
@@ -482,6 +482,7 @@ x86_emulate_memop(struct x86_emulate_ctxt *ctxt, struct 
x86_emulate_ops *ops)
int mode = ctxt-mode;
unsigned long modrm_ea;
int use_modrm_ea, index_reg = 0, base_reg = 0, scale, rip_relative = 0;
+   int no_wb = 0;
 
/* Shadow copy of register state. Committed on successful emulation. */
unsigned long _regs[NR_VCPU_REGS];
@@ -1048,7 +1049,7 @@ done_prefixes:
  _regs[VCPU_REGS_RSP]),
 dst.val, dst.bytes, ctxt)) != 0)
goto done;
-   dst.val = dst.orig_val; /* skanky: disable writeback */
+   no_wb = 1;  /* skanky: disable writeback */
break;
default:
goto cannot_emulate;
@@ -1057,7 +1058,7 @@ done_prefixes:
}
 
 writeback:
-   if ((d  Mov) || (dst.orig_val != dst.val)) {
+   if (!no_wb) {
switch (dst.type) {
case OP_REG:
/* The 4-byte case *is* correct: in 64-bit mode we 
zero-extend. */
@@ -1306,7 +1307,7 @@ twobyte_insn:
 
 twobyte_special_insn:
/* Disable writeback. */
-   dst.orig_val = dst.val;
+   no_wb = 1;
switch (b) {
case 0x09:  /* wbinvd */
break;


Luca
-- 
Ci sono le balle, le megaballe e le statistiche.
 Mark Twain

-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] Duplicate content in files

2007-06-19 Thread Luca
On 6/19/07, Baruch Even [EMAIL PROTECTED] wrote:
 Hello,

 I've tried to diff kvm-28 qemu directory with qemu 0.9.0 and I see that
 some files in the kvm sources have the content of the file duplicated,
 f.ex. qemu/hw/mips_int.c has it's own content twice in the kvm tree, it
 only has it once in qemu as it should be. Look for the include
 directives and you'll see what I mean.

 There are several other files like that.

Funny :-) Clearly they're unused in KVM (only x86* is compiled)
otherwise the linker would scream :P
According to GIT those files haven't been touched, something went
wrong during the initial import.

Luca

-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [BUG] Oops with KVM-27

2007-06-17 Thread Luca Tettamanti
Il Sat, Jun 16, 2007 at 10:43:23AM +0300, Avi Kivity ha scritto: 
 Luca Tettamanti wrote:
  Il Fri, Jun 15, 2007 at 12:06:50PM +0300, Avi Kivity ha scritto: 

  After a bit of thinking: it's correct but removes an optimization;
  furthermore it may miss other instructions that write to memory mapped
  areas.
  A more proper fix should be force the writeback if dst.ptr is in some
  kind of mmio area.
 

  I think we can just disable the optimization, and (in a separate patch)
  add it back in emulator_write_phys(), where we know we're modifying
  memory and not hitting mmio.
  
 
  Problem is that in emulator_write_phys() we've already lost track of the
  previous (dst.orig_val) value. I moved up the decision in

 
 Actually we haven't; just before the memcpy(), we can put a memcmp() to
 guard the kvm_mmu_pte_write(), which is the really expensive operation,
 especially with guest smp.

Yup, but it seemed wasteful to map (at least when highmem is in use) a
page just to check for something that we already knew. That was a
preemptive optmization though, I haven't actually benchmarked the cost
of setting up the mapping ;-)

[...]
 I think we can simply remove the if ().  For the register case, the
 check is more expensive that the write; for mmio, we don't want it; and
 for memory writes, we can put it in emulator_write_phys().

Ok, this way it's simpler. How does this look:

--- a/kernel/x86_emulate.c  2007-06-15 21:13:51.0 +0200
+++ b/kernel/x86_emulate.c  2007-06-17 16:57:50.0 +0200
@@ -1057,40 +1057,38 @@
}
 
 writeback:
-   if ((d  Mov) || (dst.orig_val != dst.val)) {
-   switch (dst.type) {
-   case OP_REG:
-   /* The 4-byte case *is* correct: in 64-bit mode we 
zero-extend. */
-   switch (dst.bytes) {
-   case 1:
-   *(u8 *)dst.ptr = (u8)dst.val;
-   break;
-   case 2:
-   *(u16 *)dst.ptr = (u16)dst.val;
-   break;
-   case 4:
-   *dst.ptr = (u32)dst.val;
-   break;  /* 64b: zero-ext */
-   case 8:
-   *dst.ptr = dst.val;
-   break;
-   }
+   switch (dst.type) {
+   case OP_REG:
+   /* The 4-byte case *is* correct: in 64-bit mode we zero-extend. 
*/
+   switch (dst.bytes) {
+   case 1:
+   *(u8 *)dst.ptr = (u8)dst.val;
break;
-   case OP_MEM:
-   if (lock_prefix)
-   rc = ops-cmpxchg_emulated((unsigned long)dst.
-  ptr, dst.orig_val,
-  dst.val, dst.bytes,
-  ctxt);
-   else
-   rc = ops-write_emulated((unsigned long)dst.ptr,
-dst.val, dst.bytes,
-ctxt);
-   if (rc != 0)
-   goto done;
-   default:
+   case 2:
+   *(u16 *)dst.ptr = (u16)dst.val;
+   break;
+   case 4:
+   *dst.ptr = (u32)dst.val;
+   break;  /* 64b: zero-ext */
+   case 8:
+   *dst.ptr = dst.val;
break;
}
+   break;
+   case OP_MEM:
+   if (lock_prefix)
+   rc = ops-cmpxchg_emulated((unsigned long)dst.
+  ptr, dst.orig_val,
+  dst.val, dst.bytes,
+  ctxt);
+   else
+   rc = ops-write_emulated((unsigned long)dst.ptr,
+dst.val, dst.bytes,
+ctxt);
+   if (rc != 0)
+   goto done;
+   default:
+   break;
}
 
/* Commit shadow register state. */

--- a/kernel/kvm_main.c 2007-06-15 21:18:08.0 +0200
+++ b/kernel/kvm_main.c 2007-06-17 16:59:33.0 +0200
@@ -1139,8 +1139,10 @@
return 0;
mark_page_dirty(vcpu-kvm, gpa  PAGE_SHIFT);
virt = kmap_atomic(page, KM_USER0);
-   kvm_mmu_pte_write(vcpu, gpa, virt + offset, val, bytes);
-   memcpy(virt + offset_in_page(gpa), val, bytes);
+   if (memcmp(virt + offset_in_page(gpa), val, bytes)) {
+   kvm_mmu_pte_write(vcpu, gpa

[kvm-devel] [PATCH 1/2] kvm: Fix x86 emulator writeback

2007-06-17 Thread Luca Tettamanti
When the old value and new one are the same the emulator skips the
write; this is undesiderable when the destination is a MMIO area and the
write shall be performed regardless of the previous value. This
optimization breaks e.g. a Linux guest APIC compiled without
X86_GOOD_APIC.

Remove the check and always perform the writeback stage in the
emulation.

Signed-Off-By: Luca Tettamanti [EMAIL PROTECTED]

---
 drivers/kvm/x86_emulate.c |   60 +++-
 1 file changed, 29 insertions(+), 31 deletions(-)

diff --git a/drivers/kvm/x86_emulate.c b/drivers/kvm/x86_emulate.c
index a4a8481..cea9f3a 100644
--- a/drivers/kvm/x86_emulate.c
+++ b/drivers/kvm/x86_emulate.c
@@ -1057,40 +1057,38 @@ done_prefixes:
}
 
 writeback:
-   if ((d  Mov) || (dst.orig_val != dst.val)) {
-   switch (dst.type) {
-   case OP_REG:
-   /* The 4-byte case *is* correct: in 64-bit mode we 
zero-extend. */
-   switch (dst.bytes) {
-   case 1:
-   *(u8 *)dst.ptr = (u8)dst.val;
-   break;
-   case 2:
-   *(u16 *)dst.ptr = (u16)dst.val;
-   break;
-   case 4:
-   *dst.ptr = (u32)dst.val;
-   break;  /* 64b: zero-ext */
-   case 8:
-   *dst.ptr = dst.val;
-   break;
-   }
+   switch (dst.type) {
+   case OP_REG:
+   /* The 4-byte case *is* correct: in 64-bit mode we zero-extend. 
*/
+   switch (dst.bytes) {
+   case 1:
+   *(u8 *)dst.ptr = (u8)dst.val;
break;
-   case OP_MEM:
-   if (lock_prefix)
-   rc = ops-cmpxchg_emulated((unsigned long)dst.
-  ptr, dst.orig_val,
-  dst.val, dst.bytes,
-  ctxt);
-   else
-   rc = ops-write_emulated((unsigned long)dst.ptr,
-dst.val, dst.bytes,
-ctxt);
-   if (rc != 0)
-   goto done;
-   default:
+   case 2:
+   *(u16 *)dst.ptr = (u16)dst.val;
+   break;
+   case 4:
+   *dst.ptr = (u32)dst.val;
+   break;  /* 64b: zero-ext */
+   case 8:
+   *dst.ptr = dst.val;
break;
}
+   break;
+   case OP_MEM:
+   if (lock_prefix)
+   rc = ops-cmpxchg_emulated((unsigned long)dst.
+  ptr, dst.orig_val,
+  dst.val, dst.bytes,
+  ctxt);
+   else
+   rc = ops-write_emulated((unsigned long)dst.ptr,
+dst.val, dst.bytes,
+ctxt);
+   if (rc != 0)
+   goto done;
+   default:
+   break;
}
 
/* Commit shadow register state. */

Luca
-- 
Software is like sex; it's better when it's free.
Linus Torvalds

-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [PATCH 2/2] kvm: avoid useless memory write when possible

2007-06-17 Thread Luca Tettamanti
When writing to normal memory and the memory area is unchanged the write
can be safely skipped, avoiding the costly kvm_mmu_pte_write.

Signed-Off-By: Luca Tettamanti [EMAIL PROTECTED]

---

 drivers/kvm/kvm_main.c |6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c
index 633c2ed..9b7b0b9 100644
--- a/drivers/kvm/kvm_main.c
+++ b/drivers/kvm/kvm_main.c
@@ -1139,8 +1139,10 @@ static int emulator_write_phys(struct kvm_vcpu *vcpu, 
gpa_t gpa,
return 0;
mark_page_dirty(vcpu-kvm, gpa  PAGE_SHIFT);
virt = kmap_atomic(page, KM_USER0);
-   kvm_mmu_pte_write(vcpu, gpa, virt + offset, val, bytes);
-   memcpy(virt + offset_in_page(gpa), val, bytes);
+   if (memcmp(virt + offset_in_page(gpa), val, bytes)) {
+   kvm_mmu_pte_write(vcpu, gpa, virt + offset, val, bytes);
+   memcpy(virt + offset_in_page(gpa), val, bytes);
+   }
kunmap_atomic(virt, KM_USER0);
return 1;
 }


Luca
-- 
Se non puoi convincerli, confondili.

-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] Suspending with kvm and kvm_loaded

2007-06-16 Thread Luca
On 6/16/07, Richard Hughes [EMAIL PROTECTED] wrote:
 On Sat, 2007-06-16 at 15:30 +0300, Muli Ben-Yehuda wrote:
 
   Is there any easy way we can detect if virtual machines are running?
 
  The module use counts will be elevanted and they'll refuse to unload
  (or there's a nasty bug somewhere).

 Nahh, that's too brutal. Is there a way to (hypothetically) read:

 # cat /sys/module/kvm/parameters/number_of_running_vms
 2

cat /sys/module/kvm_intel/refcnt (or kvm_amd) will tell you how many
VMs are running.

Luca

-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [BUG] Oops with KVM-27

2007-06-15 Thread Luca Tettamanti
,
   unsigned int bytes,
@@ -1152,20 +1165,18 @@
 {
struct kvm_vcpu *vcpu = ctxt-vcpu;
gpa_t gpa = vcpu-mmu.gva_to_gpa(vcpu, addr);
+   struct page *page;
 
if (gpa == UNMAPPED_GVA) {
kvm_arch_ops-inject_page_fault(vcpu, addr, 2);
return X86EMUL_PROPAGATE_FAULT;
}
 
-   if (emulator_write_phys(vcpu, gpa, val, bytes))
+   page = gfn_to_page(vcpu-kvm, gpa  PAGE_SHIFT);
+   if (page  emulator_write_phys_mem(vcpu, gpa, page, val, bytes))
return X86EMUL_CONTINUE;
 
-   vcpu-mmio_needed = 1;
-   vcpu-mmio_phys_addr = gpa;
-   vcpu-mmio_size = bytes;
-   vcpu-mmio_is_write = 1;
-   memcpy(vcpu-mmio_data, val, bytes);
+   emulator_write_phys_mmio(vcpu, gpa, val, bytes);
 
return X86EMUL_CONTINUE;
 }
@@ -1177,12 +1188,37 @@
 struct x86_emulate_ctxt *ctxt)
 {
static int reported;
+   struct kvm_vcpu *vcpu;
+   gpa_t gpa;
+   struct page *page;
 
if (!reported) {
reported = 1;
printk(KERN_WARNING kvm: emulating exchange as write\n);
}
-   return emulator_write_emulated(addr, new, bytes, ctxt);
+
+   vcpu = ctxt-vcpu;
+   gpa = vcpu-mmu.gva_to_gpa(vcpu, addr);
+
+   if (gpa == UNMAPPED_GVA) {
+   kvm_arch_ops-inject_page_fault(vcpu, addr, 2);
+   return X86EMUL_PROPAGATE_FAULT;
+   }
+
+   page = gfn_to_page(vcpu-kvm, gpa  PAGE_SHIFT);
+   if (page) {
+   /* Regular memory */
+   if (!memcmp(old, new, bytes))
+   return X86EMUL_CONTINUE;
+
+   if (emulator_write_phys_mem(vcpu, gpa, page, new, bytes))
+   return X86EMUL_CONTINUE;
+   }
+
+   /* MMIO */
+   emulator_write_phys_mmio(vcpu, gpa, new, bytes);
+
+   return X86EMUL_CONTINUE;
 }
 
 static unsigned long get_segment_base(struct kvm_vcpu *vcpu, int seg)


Both patches apply to kvm-28 and have been run-time tested with 32bit
guest on 32bit host, with a VMX processor.

If patches look good I'll resubmit with proper changelog and
signed-off.

Luca
-- 
The trouble with computers is that they do what you tell them, 
not what you want.
D. Cohen

-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] kvm-intel kernel panicing 2.6.22 on T7200

2007-06-14 Thread Luca
On 6/14/07, Magicboiz [EMAIL PROTECTED] wrote:
 When I say hags, I mean: my whole computer hangs. Nothing works.
 Crtl-Alt-F doesn't work. Magic-SyS Keys doesn't work. Hit my keyboard
 desperately, doesn't work ;)

Since you have a APIC-capable system you can try with nmi_watchdog.
Append nmi_watchdog=1 to kernel command line then start kvm without
starting X (use -vnc :1) so it doesn't interfere with the console
output.
After 5 seconds after the lockup the kernel should print a stack trace
which hopefully will shed some light on the lockup. If nothing happens
it means that CPU is not even receiving NMIs...

Luca

-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [BUG] Oops with KVM-27

2007-06-14 Thread Luca Tettamanti
Il Thu, Jun 14, 2007 at 11:26:29AM +0300, Avi Kivity ha scritto: 
 Luca Tettamanti wrote:
 With GOOD_APIC apic_read_around is a nop, while apic_write_around is a
 normal write. With !GOOD_APIC apic_write_around writes to the APIC reg
 using xchg. With !GOOD_APIC and this patch:
 
 --- include/asm-i386/apic.h~ 2007-04-26 05:08:32.0 +0200
 +++ include/asm-i386/apic.h  2007-06-13 22:35:00.0 +0200
 @@ -56,7 +56,8 @@
  static __inline fastcall void native_apic_write_atomic(unsigned long reg,
 unsigned long v)
  {
 -xchg((volatile unsigned long *)(APIC_BASE+reg), v);
 +//  xchg((volatile unsigned long *)(APIC_BASE+reg), v);
 +*((volatile unsigned long *)(APIC_BASE+reg)) = v;
  }
  
  static __inline fastcall unsigned long native_apic_read(unsigned long reg)
 
 The kernel boots fine. 
   
 
 Looking at the xchg emulation code, it seems fine, but clearly it 
 isn't.

Btw, I've put a printk in x86_emulate.c, where it prepares the operands
for the xchg operations: all the write_atomic are hitting this point,
so the write is lost somewhere in cmpxchg_emulated-write_emulated.

Luca
-- 
Il dottore mi ha detto di smettere di fare cene intime per quattro.
A meno che non ci siamo altre tre persone.

-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [BUG] Oops with KVM-27

2007-06-14 Thread Luca Tettamanti
Il Fri, Jun 15, 2007 at 12:53:24AM +0200, Luca Tettamanti ha scritto: 
 Il Thu, Jun 14, 2007 at 11:26:29AM +0300, Avi Kivity ha scritto: 
  Luca Tettamanti wrote:
  With GOOD_APIC apic_read_around is a nop, while apic_write_around is a
  normal write. With !GOOD_APIC apic_write_around writes to the APIC reg
  using xchg. With !GOOD_APIC and this patch:
  
  --- include/asm-i386/apic.h~   2007-04-26 05:08:32.0 +0200
  +++ include/asm-i386/apic.h2007-06-13 22:35:00.0 +0200
  @@ -56,7 +56,8 @@
   static __inline fastcall void native_apic_write_atomic(unsigned long reg,
unsigned long v)
   {
  -  xchg((volatile unsigned long *)(APIC_BASE+reg), v);
  +//xchg((volatile unsigned long *)(APIC_BASE+reg), v);
  +  *((volatile unsigned long *)(APIC_BASE+reg)) = v;
   }
   
   static __inline fastcall unsigned long native_apic_read(unsigned long reg)
  
  The kernel boots fine. 

  
  Looking at the xchg emulation code, it seems fine, but clearly it 
  isn't.
 
 Btw, I've put a printk in x86_emulate.c, where it prepares the operands
 for the xchg operations: all the write_atomic are hitting this point,
 so the write is lost somewhere in cmpxchg_emulated-write_emulated.

Got it!
The emulator skips the writeback if the old value is unchanged, so the
apic doesn't see the write.

Forcing the writeback:

-  if ((d  Mov) || (dst.orig_val != dst.val)) {
-  if ((d  Mov) || (dst.orig_val != dst.val) || isxchg) {

seems to fix the issue :D I'm not sure that fix is correct though. This
is the patch I'm using:


--- a/kernel/x86_emulate.c  2007-06-03 10:31:15.0 +0200
+++ b/kernel/x86_emulate.c  2007-06-15 01:12:12.0 +0200
@@ -486,6 +486,7 @@
unsigned long _regs[NR_VCPU_REGS];
unsigned long _eip = ctxt-vcpu-rip, _eflags = ctxt-eflags;
unsigned long modrm_val = 0;
+   int isxchg = 0;
 
memcpy(_regs, ctxt-vcpu-regs, sizeof _regs);
 
@@ -912,6 +913,7 @@
break;
case 0x86 ... 0x87: /* xchg */
/* Write back the register source. */
+   isxchg = 1;
switch (dst.bytes) {
case 1:
*(u8 *) src.ptr = (u8) dst.val;
@@ -1056,7 +1058,7 @@
}
 
 writeback:
-   if ((d  Mov) || (dst.orig_val != dst.val)) {
+   if ((d  Mov) || (dst.orig_val != dst.val) || isxchg) {
switch (dst.type) {
case OP_REG:
/* The 4-byte case *is* correct: in 64-bit mode we 
zero-extend. */

Luca
-- 
Su cio` di cui non si puo` parlare e` bene tacere.
 Ludwig Wittgenstein

-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


  1   2   >