Re: [Qemu-devel] Bug #757654: UHCI fails to signal stall response patch

2011-04-16 Thread Jan Vesely
On Sat, Apr 16, 2011 at 8:33 AM, Brad Hards  wrote:
> On Sat, 16 Apr 2011 06:57:00 am Jan Vesely wrote:
>> +        s->status |= UHCI_STS_USBERR;
> This is per UHCI 1.1D Section 4.1.5. Looks good.
>
>> +        *int_mask |= 0x02;
>> +        if (td->ctrl & TD_CTRL_IOC)
>> +            *int_mask |= 0x01;
>> +        uhci_update_irq(s);
> I see "A hardware interrupt is signalled to the system", but can you provide a
> little explanation of why this particular interrupt mask?

I used th code I found around in that same file (hw/usb-uhci.c),
lines 705-724 contain both masks. "if (td->ctrl & TD_CTRL_IOC)
*int_mask |= 0x01;", is in more places so I just copied that lines.
*int_mask |= 0x2, is used when SPD condition is detected.
that is strange, SPD should use the same interrupt as IOC, but return
value indicates that it is treated as error condition (unsuccessful
td) so I figured *int_mask |= 0x2 signals error interrupt (it does not
match bits in interrupt enable register- that was my first guess)
uhci_update_irq(s); to me it looks like a duplicate functionality to
int_mask parameter, I did not investigate further and included it just
to be sure (it's used on line 775, when error countdown reaches zero).

>
>> +        s->status |= UHCI_STS_USBERR;
> This is per UHCI 1.1d Section 4.1.4. Looks good.
>
>> +        *int_mask |= 0x02;
>> +        if (td->ctrl & TD_CTRL_IOC)
>> +           *int_mask |= 0x01;
>> +        uhci_update_irq(s);
> I see "A hardware interrupt is signalled to the system", but can you provide a
> little explanation of why this particular interrupt mask?
>
>



Re: [Qemu-devel] [Qemu-trivial] Bug #757654: UHCI fails to signal stall response patch

2011-04-16 Thread Stefan Hajnoczi
On Fri, Apr 15, 2011 at 9:57 PM, Jan Vesely  wrote:
> I'm sending a patch for bug #757654. The bug does not really break
> anything it just makes USB error detection harder.
> It's a quick fix and might need some polishing but it works (I am
> currently using it).
>
> thx,
> jan
>
> PS: I guess you need this line:
> Signed-off-by: Jan Vesely 

Not trivial.  CCing Gerd for USB review instead.

Stefan



Re: [Qemu-devel] [PATCH] raw-posix: Linearize direct I/O on Linux NFS

2011-04-16 Thread Stefan Hajnoczi
On Sat, Apr 16, 2011 at 12:00 AM, Anthony Liguori  wrote:
> 3) We have no way to detect when we no longer need a work around which makes
> (2) really unappealing.

I agree.

> 4) That leaves us with:
>    a) waiting for NFS to get fixed properly and just living with worse
> performance on older kernels
>
>    b) having a user-tunable switch to enable bouncing
>
> I really dislike the idea of (b) because we're stuck with it forever and
> it's yet another switch for people to mistakenly depend on.

The user-tunable switch is potentially interesting for performance
troubleshooting.  We have seen another file system which has issues
with vectored direct I/O.  It would have been much easier to identify
the problem by telling the user "Try running it with linearize=on and
see if it makes a difference".

But let's try harder on linux-nfs.

Stefan



Re: [Qemu-devel] Para-virtualized ram-based filesystem?

2011-04-16 Thread Stefan Hajnoczi
On Sat, Apr 16, 2011 at 1:27 AM, Brad Hards  wrote:
> On Saturday 16 April 2011 09:58:32 Ritchie, Stuart wrote:
>> How does that sound?
> As a general user: Confusing.
>
> Is there a concrete example (specific applications, specific performance 
> issues,
> specific requirements) that you can share?

I'm also wondering why you want this.

Does it matter if the files get pushed out to swap on the host?

It's tempting to take advantage of running virtualized but then things
like migration get in the way.  Have you actually tried out network
file systems and determined they won't work for some reason?

Stefan



Re: [Qemu-devel] Para-virtualized ram-based filesystem?

2011-04-16 Thread Stefan Hajnoczi
Resent because Stuart dropped from the recipients list.

On Sat, Apr 16, 2011 at 9:52 AM, Stefan Hajnoczi  wrote:
> On Sat, Apr 16, 2011 at 1:27 AM, Brad Hards  wrote:
>> On Saturday 16 April 2011 09:58:32 Ritchie, Stuart wrote:
>>> How does that sound?
>> As a general user: Confusing.
>>
>> Is there a concrete example (specific applications, specific performance 
>> issues,
>> specific requirements) that you can share?
>
> I'm also wondering why you want this.
>
> Does it matter if the files get pushed out to swap on the host?
>
> It's tempting to take advantage of running virtualized but then things
> like migration get in the way.  Have you actually tried out network
> file systems and determined they won't work for some reason?
>
> Stefan
>



Re: [Qemu-devel] [PATCH 1/3] slirp: Implement TFTP Blocksize option

2011-04-16 Thread Stefan Hajnoczi
On Mon, Apr 11, 2011 at 07:10:52PM +, Herve Poussineau wrote:
> From: Herv? Poussineau 
> 
> This option is described in RFC 1783. As this is only an optional field,
> we may ignore it in some situations and handle it in some others.
> Here, if client requests a block size bigger than the block size we emit
> (512 bytes), accept the option with a value of 512
> 
> Signed-off-by: Herv? Poussineau 
> ---
>  slirp/tftp.c |   40 
>  1 files changed, 32 insertions(+), 8 deletions(-)

Have you tested PXELINUX and gPXE?

Stefan



Re: [Qemu-devel] [PATCH] Fix buffer overrun in sched_getaffinity

2011-04-16 Thread Stefan Hajnoczi
On Tue, Apr 12, 2011 at 12:48:20PM +0900, Mike McCormack wrote:
> Zeroing of the cpu array should start from &cpus[kernel_ret]
> not &cpus[num_zeros_to_fill].
> 
> This fixes a crash in EFL's edje_cc running under qemu-arm.
> 
> Signed-off-by: Mike McCormack 
> ---
>  linux-user/syscall.c |2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index bb0999d..1cda10a 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -6389,7 +6389,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long 
> arg1,
>  unsigned long zero = arg2 - ret;
>  p = alloca(zero);
>  memset(p, 0, zero);
> -if (copy_to_user(arg3 + zero, p, zero)) {
> +if (copy_to_user(arg3 + ret, p, zero)) {
>  goto efault;
>  }
>  arg2 = ret;

Reviewed-by: Stefan Hajnoczi 

Note that mainline Linux does not zero unwritten bytes.  I would drop
the entire arg2 > ret case and instead copy only ret bytes to user.

Stefan



Re: [Qemu-devel] [PATCH 1/2] Implement basic part of SA-1110/SA-1100

2011-04-16 Thread Dmitry Eremin-Solenikov
Hello,

What about this version of patches?

On 4/14/11, Dmitry Eremin-Solenikov  wrote:
> Basic implementation of DEC/Intel SA-1100/SA-1110 chips emulation.
> Implemented:
>  - IRQs
>  - GPIO
>  - PPC
>  - RTC
>  - UARTs (no IrDA/etc.)
>  - OST reused from pxa25x
>
> Everything else is TODO (esp. PM/idle/sleep!) - see the todo in the
> hw/strongarm.c
>
> V5:
>   * syntax fixup
>
> V4:
>   * use bitnames to access RTC and UART registers
>   * drop unused casts
>   * disable debug printfs in GPIO code
>
> V3:
>   * fix the name of UART VMSD
>   * fix RTSR reg offset
>   * add SSP support
>
> V2:
>   * removed all strongarm variants except latest
>   * dropped unused casts
>   * fixed PIC vmstate
>   * fixed new devices created with version_id = 1
>
> Signed-off-by: Dmitry Eremin-Solenikov 

-- 
With best wishes
Dmitry



Re: [Qemu-devel] [PATCH 0/7] Rework PCMCIA subsystem

2011-04-16 Thread Dmitry Eremin-Solenikov
Hi,

What about this serie of patches?

On 4/11/11, Dmitry Eremin-Solenikov  wrote:
> Please pull the following changeset that makes PCMCIA subsystem to use
> QBus and Qdev for managing devices. Currently the only implementation
> of PCMCIA host is a PXA2xx host and the only possible PCMCIA device is
> IDE MicroDrive (dscm1).
>
> With this patchset I can create a microdrive device from command line:
> -device dscm1 -device ide-drive,drive=test -drive
> if=none,id=test,file=/dev/null
>
>
> Dmitry Eremin-Solenikov (7):
>   pxa2xx_pcmcia: qdevify
>   PCMCIA: start qdev'ication
>   microdrive: qdevify
>   pcmcia: move all card callbacks to PCMCIACardInfo
>   pcmcia: move attach and detach socket methods to PCMCIASocket
>   pxa: change order of pcmcia devices instantiation, so that the socket
> 0 will be default
>   ide-core: allocate metadata storage for CFATA drives
>
>  Makefile.objs   |3 +
>  hw/ide/core.c   |4 ++
>  hw/ide/internal.h   |2 +
>  hw/ide/microdrive.c |   88 +++---
>  hw/mainstone.c  |   14 +++--
>  hw/pcmcia.c |  145
> +
>  hw/pcmcia.h |   49 -
>  hw/pxa.h|9 +---
>  hw/pxa2xx.c |9 ++--
>  hw/pxa2xx_pcmcia.c  |  148
> ++-
>  hw/spitz.c  |   26 ++
>  hw/tosa.c   |   18 ---
>  vl.c|   43 ---
>  13 files changed, 372 insertions(+), 186 deletions(-)
>  create mode 100644 hw/pcmcia.c
>
>


-- 
With best wishes
Dmitry



Re: [Qemu-devel] [PATCH] multiboot: Support quotable commas in module list

2011-04-16 Thread Adam Lackorzynski

On Fri Apr 15, 2011 at 15:17:28 +0200, Kevin Wolf wrote:
> Am 15.04.2011 09:56, schrieb Adam Lackorzynski:
> > Support quoting of ',' (and '\') to allow commas in the parameter list of
> > modules.
> > 
> > Signed-off-by: Adam Lackorzynski 
> 
> Other options in qemu use double commas for escaping. So maybe reusing
> get_opt_value() would make things more consistent. It also has the
> advantage that double commas don't need additional escape characters for
> the shell.
> 
> On the other hand, using backslashes for escaping is probably more
> familiar for most people, so I don't have a very strong opinion on it.

Same for me. I like the fact with the double-commas and easier shell
quoting. On the other side using backslashes is more common. However, I
construct the overall command via scripts anyway, so I'll only very
seldom actually type this myself.

Here's how it would look like. Diff is smaller.
More opinions very welcome.


diff --git a/hw/multiboot.c b/hw/multiboot.c
index 394ed01..7d5cb22 100644
--- a/hw/multiboot.c
+++ b/hw/multiboot.c
@@ -97,11 +97,11 @@ typedef struct {
 
 static uint32_t mb_add_cmdline(MultibootState *s, const char *cmdline)
 {
-int len = strlen(cmdline) + 1;
 target_phys_addr_t p = s->offset_cmdlines;
+char *b = (char *)s->mb_buf + p;
 
-pstrcpy((char *)s->mb_buf + p, len, cmdline);
-s->offset_cmdlines += len;
+get_opt_value(b, strlen(cmdline) + 1, cmdline);
+s->offset_cmdlines += strlen(b) + 1;
 return s->mb_buf_phys + p;
 }
 
@@ -238,7 +238,7 @@ int load_multiboot(void *fw_cfg,
 const char *r = initrd_filename;
 mbs.mb_buf_size += strlen(r) + 1;
 mbs.mb_mods_avail = 1;
-while ((r = strchr(r, ','))) {
+while (*(r = get_opt_value(NULL, 0, r))) {
mbs.mb_mods_avail++;
r++;
 }
@@ -252,7 +252,7 @@ int load_multiboot(void *fw_cfg,
 mbs.offset_cmdlines = mbs.offset_mbinfo + mbs.mb_mods_avail * MB_MOD_SIZE;
 
 if (initrd_filename) {
-char *next_initrd;
+char *next_initrd, not_last;
 
 mbs.offset_mods = mbs.mb_buf_size;
 
@@ -261,9 +261,9 @@ int load_multiboot(void *fw_cfg,
 int mb_mod_length;
 uint32_t offs = mbs.mb_buf_size;
 
-next_initrd = strchr(initrd_filename, ',');
-if (next_initrd)
-*next_initrd = '\0';
+next_initrd = (char *)get_opt_value(NULL, 0, initrd_filename);
+not_last = *next_initrd;
+*next_initrd = '\0';
 /* if a space comes after the module filename, treat everything
after that as parameters */
 target_phys_addr_t c = mb_add_cmdline(&mbs, initrd_filename);
@@ -287,7 +287,7 @@ int load_multiboot(void *fw_cfg,
  (char *)mbs.mb_buf + offs,
  (char *)mbs.mb_buf + offs + mb_mod_length, c);
 initrd_filename = next_initrd+1;
-} while (next_initrd);
+} while (not_last);
 }
 
 /* Commandline support */



Adam
-- 
Adam a...@os.inf.tu-dresden.de
  Lackorzynski http://os.inf.tu-dresden.de/~adam/



Re: [Qemu-devel] [PATCH] multiboot: Support quotable commas in module list

2011-04-16 Thread Stefan Hajnoczi
On Sat, Apr 16, 2011 at 10:42 AM, Adam Lackorzynski
 wrote:
>
> On Fri Apr 15, 2011 at 15:17:28 +0200, Kevin Wolf wrote:
>> Am 15.04.2011 09:56, schrieb Adam Lackorzynski:
>> > Support quoting of ',' (and '\') to allow commas in the parameter list of
>> > modules.
>> >
>> > Signed-off-by: Adam Lackorzynski 
>>
>> Other options in qemu use double commas for escaping. So maybe reusing
>> get_opt_value() would make things more consistent. It also has the
>> advantage that double commas don't need additional escape characters for
>> the shell.
>>
>> On the other hand, using backslashes for escaping is probably more
>> familiar for most people, so I don't have a very strong opinion on it.
>
> Same for me. I like the fact with the double-commas and easier shell
> quoting. On the other side using backslashes is more common. However, I
> construct the overall command via scripts anyway, so I'll only very
> seldom actually type this myself.
>
> Here's how it would look like. Diff is smaller.
> More opinions very welcome.

I like this more because it is more consistent with QEMU syntax and reuses code.

Stefan



[Qemu-devel] [PULL] Trivial patches for 10-16 April

2011-04-16 Thread Stefan Hajnoczi
The following changes since commit adc56dda0c4eed62149d28939b7d7e329ad95ae8:

  migration: move some declarations to migration.h (2011-04-15 20:14:54 +)

are available in the git repository at:
  git://repo.or.cz/qemu/stefanha.git trivial-patches

Brad Hards (4):
  Makefile: Clean up after "make pdf"
  usb: trivial spelling fixes
  usb: initialise data element in Linux USB_DISCONNECT ioctl
  usb: fix spelling errors in usb-linux.c

Stefan Weil (1):
  Fix some typos in comments and documentation

 .gitignore  |3 +++
 Makefile|5 -
 hw/usb-msd.c|4 ++--
 qemu-options.hx |4 ++--
 savevm.c|2 +-
 target-arm/helper.c |2 +-
 usb-linux.c |5 +++--
 7 files changed, 16 insertions(+), 9 deletions(-)



Re: [Qemu-devel] [PATCH] Fix buffer overrun in sched_getaffinity

2011-04-16 Thread Mike Frysinger
On Sat, Apr 16, 2011 at 05:16, Stefan Hajnoczi wrote:
> On Tue, Apr 12, 2011 at 12:48:20PM +0900, Mike McCormack wrote:
>> Zeroing of the cpu array should start from &cpus[kernel_ret]
>> not &cpus[num_zeros_to_fill].
>>
>> This fixes a crash in EFL's edje_cc running under qemu-arm.
>>
>> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
>> index bb0999d..1cda10a 100644
>> --- a/linux-user/syscall.c
>> +++ b/linux-user/syscall.c
>> @@ -6389,7 +6389,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long 
>> arg1,
>>                      unsigned long zero = arg2 - ret;
>>                      p = alloca(zero);
>>                      memset(p, 0, zero);
>> -                    if (copy_to_user(arg3 + zero, p, zero)) {
>> +                    if (copy_to_user(arg3 + ret, p, zero)) {
>>                          goto efault;
>>                      }
>>                      arg2 = ret;
>
> Reviewed-by: Stefan Hajnoczi 
>
> Note that mainline Linux does not zero unwritten bytes.  I would drop
> the entire arg2 > ret case and instead copy only ret bytes to user.

both changes make sense to me
Acked-by: Mike Frysinger 
-mike



[Qemu-devel] [PATCH] Fix some wording in qemu.1

2011-04-16 Thread Dan Church
It was apparent that some parts of the man page were written by
non-native English speaker(s), so I figured I'd help out somewhat:

--- qemu/qemu.1.orig2011-04-16 14:33:06.0 -0500
+++ qemu/qemu.1 2011-04-16 14:36:38.0 -0500
@@ -271,11 +271,11 @@
 Available types are: ide, scsi, sd, mtd, floppy, pflash, virtio.
 .IP "\fBbus=\fR\fIbus\fR\fB,unit=\fR\fIunit\fR" 4
 .IX Item "bus=bus,unit=unit"
-These options define where is connected the drive by defining the bus
number and
+These options define where the drive by is connected defining the bus
number and
 the unit id.
 .IP "\fBindex=\fR\fIindex\fR" 4
 .IX Item "index=index"
-This option defines where is connected the drive by using an index in the list
+This option defines where the drive is connected by using an index in the list
 of available connectors of a given interface type.
 .IP "\fBmedia=\fR\fImedia\fR" 4
 .IX Item "media=media"
@@ -376,10 +376,10 @@
 incremented:
 .Sp
 .Vb 1
-\&qemu \-drive file=a \-drive file=b"
+\&qemu \-drive file=a \-drive file=b
 .Ve
 .Sp
-is interpreted like:
+is interpreted as:
 .Sp
 .Vb 1
 \&qemu \-hda a \-hdb b


-- 
   Fourth Law of Programming:
   Anything that can go wrong wi
sendmail: segmentation violated - core dumped



[Qemu-devel] iPXE/Etherboot prompts twice for booting?

2011-04-16 Thread Michael Tokarev
I'm playing with iPXE ROM images again, and see
iPXE prompts two times during bootup.  Once like
this: "Press Ctrl-B to configure", at early stage,
even if -boot n is not selected.  And second time
when it actually tries to boot, like "Press Ctrl-B
for the command line".

The same behavor happens with old Etherboot, with
the exception that during init stage it tries to
boot too but fails.

Any idea how to get rid of that?

Thanks!

/mjt



Re: [Qemu-devel] [PATCH] Fix some wording in qemu.1

2011-04-16 Thread Stefan Weil

Am 16.04.2011 21:38, schrieb Dan Church:

It was apparent that some parts of the man page were written by
non-native English speaker(s), so I figured I'd help out somewhat:

--- qemu/qemu.1.orig2011-04-16 14:33:06.0 -0500
+++ qemu/qemu.1 2011-04-16 14:36:38.0 -0500
@@ -271,11 +271,11 @@
  Available types are: ide, scsi, sd, mtd, floppy, pflash, virtio.
  .IP "\fBbus=\fR\fIbus\fR\fB,unit=\fR\fIunit\fR" 4
  .IX Item "bus=bus,unit=unit"
-These options define where is connected the drive by defining the bus
number and
+These options define where the drive by is connected defining the bus
number and
   


... where the drive is connected by defining ...? See also next change.

The other changes look good.


  the unit id.
  .IP "\fBindex=\fR\fIindex\fR" 4
  .IX Item "index=index"
-This option defines where is connected the drive by using an index in the list
+This option defines where the drive is connected by using an index in the list
  of available connectors of a given interface type.
  .IP "\fBmedia=\fR\fImedia\fR" 4
  .IX Item "media=media"
@@ -376,10 +376,10 @@
  incremented:
  .Sp
  .Vb 1
-\& qemu \-drive file=a \-drive file=b"
+\& qemu \-drive file=a \-drive file=b
  .Ve
  .Sp
-is interpreted like:
+is interpreted as:
  .Sp
  .Vb 1
  \& qemu \-hda a \-hdb b


   





Re: [Qemu-devel] is it just me or is ne2k broken in qemu?

2011-04-16 Thread Michael Tokarev
15.04.2011 18:17, Alex Williamson wrote:
> On Thu, 2011-04-14 at 12:31 +0400, Michael Tokarev wrote:

>> The NIC works for a while, but after a few packets,
>> or a few 1000s of packets, it stalls.  In tcpdump
>> on the host I see many ARP requests coming from the
>> guest and each has corresponding ARP reply, but
>> nothing is actually reaching the guest.

> For testing the iPXE ROMs I booted up each NIC, including ne2k_pci, to a
> network loaded kernel (~4M) and installation initrd (~8M).  I stopped
> the test at the point where the installer kernel was able to
> successfully DHCP with the boot NIC.  ne2k_pci was definitely the
> slowest of the cards at loading the images, but I didn't notice any
> functionality issues.  Maybe I didn't let it run long enough, but the
> boot ROM seems ok with it.

I'm doing exactly the same here, -- testing iPXE booting,
so booting linux kernel over network.  I haven't been able
to boot linux on ne2k so far, it fails somewhere down the
road after loading initrd+kernel - either during initrd
run or about after switching to new init (still running
off network ofcourse) after mounting nfs root.

So when I encountered this issue I tried non-network boot
and various versions of (linux) guest and qemu-kvm - and
for me, ne2k always fail (stalls) after some time.

And Mulyadi Santosa mentioned it's apparently a known issue
due to some timer-related problem in the code.

/mjt



[Qemu-devel] [PATCH 6/6] kvm: Install specialized interrupt handler

2011-04-16 Thread Marcelo Tosatti
From: Jan Kiszka 

KVM only requires to set the raised IRQ in CPUState and to kick the
receiving vcpu if it is remote. Installing a specialized handler allows
potential future changes to the TCG code path without risking KVM side
effects.

Signed-off-by: Jan Kiszka 
Signed-off-by: Marcelo Tosatti 
---
 kvm-all.c |   11 +++
 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/kvm-all.c b/kvm-all.c
index 1d7e8ea..fd1fbfe 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -651,6 +651,15 @@ static CPUPhysMemoryClient kvm_cpu_phys_memory_client = {
 .log_stop = kvm_log_stop,
 };
 
+static void kvm_handle_interrupt(CPUState *env, int mask)
+{
+env->interrupt_request |= mask;
+
+if (!qemu_cpu_is_self(env)) {
+qemu_cpu_kick(env);
+}
+}
+
 int kvm_init(void)
 {
 static const char upgrade_note[] =
@@ -759,6 +768,8 @@ int kvm_init(void)
 
 s->many_ioeventfds = kvm_check_many_ioeventfds();
 
+cpu_interrupt_handler = kvm_handle_interrupt;
+
 return 0;
 
 err:
-- 
1.7.4.2




[Qemu-devel] [PATCH 2/6] kvm: add kvmclock to its second bit

2011-04-16 Thread Marcelo Tosatti
From: Glauber Costa 

We have two bits that can represent kvmclock in cpuid.
They signal the guest which msr set to use. When we tweak flags
involving this value - specially when we use "-", we have to act on both.

Besides adding it to the kvm features list, we also have to "break" the
assumption represented by the break in lookup_feature.

Signed-off-by: Glauber Costa 
Signed-off-by: Avi Kivity 
---
 target-i386/cpuid.c |3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/target-i386/cpuid.c b/target-i386/cpuid.c
index 814d13e..5e48d35 100644
--- a/target-i386/cpuid.c
+++ b/target-i386/cpuid.c
@@ -73,7 +73,7 @@ static const char *ext3_feature_name[] = {
 };
 
 static const char *kvm_feature_name[] = {
-"kvmclock", "kvm_nopiodelay", "kvm_mmu", NULL, "kvm_asyncpf", NULL, NULL, 
NULL,
+"kvmclock", "kvm_nopiodelay", "kvm_mmu", "kvmclock", "kvm_asyncpf", NULL, 
NULL, NULL,
 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
@@ -193,7 +193,6 @@ static int lookup_feature(uint32_t *pval, const char *s, 
const char *e,
 for (mask = 1, ppc = featureset; mask; mask <<= 1, ++ppc)
 if (*ppc && !altcmp(s, e, *ppc)) {
 *pval |= mask;
-break;
 }
 return (mask ? 1 : 0);
 }
-- 
1.7.4.2




[Qemu-devel] [PATCH 1/6] kvm: use kernel-provided para_features instead of statically coming up with new capabilities

2011-04-16 Thread Marcelo Tosatti
From: Glauber Costa 

Use the features provided by KVM_GET_SUPPORTED_CPUID directly to
mask out features from guest-visible cpuid.

The old get_para_features() mechanism is kept for older kernels that do not 
implement it.

Signed-off-by: Glauber Costa 
Signed-off-by: Avi Kivity 
---
 target-i386/kvm.c |   78 +---
 1 files changed, 49 insertions(+), 29 deletions(-)

diff --git a/target-i386/kvm.c b/target-i386/kvm.c
index a13599d..485572f 100644
--- a/target-i386/kvm.c
+++ b/target-i386/kvm.c
@@ -92,6 +92,35 @@ static struct kvm_cpuid2 *try_get_cpuid(KVMState *s, int max)
 return cpuid;
 }
 
+#ifdef CONFIG_KVM_PARA
+struct kvm_para_features {
+int cap;
+int feature;
+} para_features[] = {
+{ KVM_CAP_CLOCKSOURCE, KVM_FEATURE_CLOCKSOURCE },
+{ KVM_CAP_NOP_IO_DELAY, KVM_FEATURE_NOP_IO_DELAY },
+{ KVM_CAP_PV_MMU, KVM_FEATURE_MMU_OP },
+#ifdef KVM_CAP_ASYNC_PF
+{ KVM_CAP_ASYNC_PF, KVM_FEATURE_ASYNC_PF },
+#endif
+{ -1, -1 }
+};
+
+static int get_para_features(CPUState *env)
+{
+int i, features = 0;
+
+for (i = 0; i < ARRAY_SIZE(para_features) - 1; i++) {
+if (kvm_check_extension(env->kvm_state, para_features[i].cap)) {
+features |= (1 << para_features[i].feature);
+}
+}
+
+return features;
+}
+#endif
+
+
 uint32_t kvm_arch_get_supported_cpuid(CPUState *env, uint32_t function,
   uint32_t index, int reg)
 {
@@ -99,6 +128,9 @@ uint32_t kvm_arch_get_supported_cpuid(CPUState *env, 
uint32_t function,
 int i, max;
 uint32_t ret = 0;
 uint32_t cpuid_1_edx;
+#ifdef CONFIG_KVM_PARA
+int has_kvm_features = 0;
+#endif
 
 max = 1;
 while ((cpuid = try_get_cpuid(env->kvm_state, max)) == NULL) {
@@ -108,6 +140,11 @@ uint32_t kvm_arch_get_supported_cpuid(CPUState *env, 
uint32_t function,
 for (i = 0; i < cpuid->nent; ++i) {
 if (cpuid->entries[i].function == function &&
 cpuid->entries[i].index == index) {
+#ifdef CONFIG_KVM_PARA
+if (cpuid->entries[i].function == KVM_CPUID_FEATURES) {
+has_kvm_features = 1;
+}
+#endif
 switch (reg) {
 case R_EAX:
 ret = cpuid->entries[i].eax;
@@ -140,38 +177,15 @@ uint32_t kvm_arch_get_supported_cpuid(CPUState *env, 
uint32_t function,
 
 qemu_free(cpuid);
 
-return ret;
-}
-
 #ifdef CONFIG_KVM_PARA
-struct kvm_para_features {
-int cap;
-int feature;
-} para_features[] = {
-{ KVM_CAP_CLOCKSOURCE, KVM_FEATURE_CLOCKSOURCE },
-{ KVM_CAP_NOP_IO_DELAY, KVM_FEATURE_NOP_IO_DELAY },
-{ KVM_CAP_PV_MMU, KVM_FEATURE_MMU_OP },
-#ifdef KVM_CAP_ASYNC_PF
-{ KVM_CAP_ASYNC_PF, KVM_FEATURE_ASYNC_PF },
-#endif
-{ -1, -1 }
-};
-
-static int get_para_features(CPUState *env)
-{
-int i, features = 0;
-
-for (i = 0; i < ARRAY_SIZE(para_features) - 1; i++) {
-if (kvm_check_extension(env->kvm_state, para_features[i].cap)) {
-features |= (1 << para_features[i].feature);
-}
+/* fallback for older kernels */
+if (!has_kvm_features && (function == KVM_CPUID_FEATURES)) {
+ret = get_para_features(env);
 }
-#ifdef KVM_CAP_ASYNC_PF
-has_msr_async_pf_en = features & (1 << KVM_FEATURE_ASYNC_PF);
 #endif
-return features;
+
+return ret;
 }
-#endif /* CONFIG_KVM_PARA */
 
 typedef struct HWPoisonPage {
 ram_addr_t ram_addr;
@@ -397,7 +411,13 @@ int kvm_arch_init_vcpu(CPUState *env)
 c = &cpuid_data.entries[cpuid_i++];
 memset(c, 0, sizeof(*c));
 c->function = KVM_CPUID_FEATURES;
-c->eax = env->cpuid_kvm_features & get_para_features(env);
+c->eax = env->cpuid_kvm_features & kvm_arch_get_supported_cpuid(env,
+KVM_CPUID_FEATURES, 0, R_EAX);
+
+#ifdef KVM_CAP_ASYNC_PF
+has_msr_async_pf_en = c->eax & (1 << KVM_FEATURE_ASYNC_PF);
+#endif
+
 #endif
 
 cpu_x86_cpuid(env, 0, 0, &limit, &unused, &unused, &unused);
-- 
1.7.4.2




[Qemu-devel] [PATCH 5/6] Redirect cpu_interrupt to callback handler

2011-04-16 Thread Marcelo Tosatti
From: Jan Kiszka 

This allows to override the interrupt handling of QEMU in system mode.
KVM will make use of it to set a specialized handler.

Signed-off-by: Jan Kiszka 
Signed-off-by: Marcelo Tosatti 
---
 cpu-all.h |   14 +-
 exec.c|4 +++-
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/cpu-all.h b/cpu-all.h
index dc0f2f0..628206e 100644
--- a/cpu-all.h
+++ b/cpu-all.h
@@ -789,7 +789,19 @@ extern CPUState *cpu_single_env;
 #define CPU_INTERRUPT_SIPI   0x800 /* SIPI pending. */
 #define CPU_INTERRUPT_MCE0x1000 /* (x86 only) MCE pending. */
 
-void cpu_interrupt(CPUState *s, int mask);
+#ifndef CONFIG_USER_ONLY
+typedef void (*CPUInterruptHandler)(CPUState *, int);
+
+extern CPUInterruptHandler cpu_interrupt_handler;
+
+static inline void cpu_interrupt(CPUState *s, int mask)
+{
+cpu_interrupt_handler(s, mask);
+}
+#else /* USER_ONLY */
+void cpu_interrupt(CPUState *env, int mask);
+#endif /* USER_ONLY */
+
 void cpu_reset_interrupt(CPUState *env, int mask);
 
 void cpu_exit(CPUState *s);
diff --git a/exec.c b/exec.c
index cc0806e..72f4784 100644
--- a/exec.c
+++ b/exec.c
@@ -1632,7 +1632,7 @@ static void cpu_unlink_tb(CPUState *env)
 
 #ifndef CONFIG_USER_ONLY
 /* mask must never be zero, except for A20 change call */
-void cpu_interrupt(CPUState *env, int mask)
+static void tcg_handle_interrupt(CPUState *env, int mask)
 {
 int old_mask;
 
@@ -1659,6 +1659,8 @@ void cpu_interrupt(CPUState *env, int mask)
 }
 }
 
+CPUInterruptHandler cpu_interrupt_handler = tcg_handle_interrupt;
+
 #else /* CONFIG_USER_ONLY */
 
 void cpu_interrupt(CPUState *env, int mask)
-- 
1.7.4.2




[Qemu-devel] [PATCH 0/6] [PULL] qemu-kvm.git uq/master queue

2011-04-16 Thread Marcelo Tosatti
The following changes since commit adc56dda0c4eed62149d28939b7d7e329ad95ae8:

  migration: move some declarations to migration.h (2011-04-15 20:14:54 +)

are available in the git repository at:
  git://git.kernel.org/pub/scm/virt/kvm/qemu-kvm.git uq/master

Glauber Costa (3):
  kvm: use kernel-provided para_features instead of statically coming up 
with new capabilities
  kvm: add kvmclock to its second bit
  kvm: create kvmclock when one of the flags are present

Jan Kiszka (3):
  Break up user and system cpu_interrupt implementations
  Redirect cpu_interrupt to callback handler
  kvm: Install specialized interrupt handler

 cpu-all.h   |   14 -
 exec.c  |   18 ---
 hw/kvmclock.c   |6 +++-
 kvm-all.c   |   11 +++
 target-i386/cpuid.c |3 +-
 target-i386/kvm.c   |   78 ---
 6 files changed, 92 insertions(+), 38 deletions(-)



[Qemu-devel] [PATCH 3/6] kvm: create kvmclock when one of the flags are present

2011-04-16 Thread Marcelo Tosatti
From: Glauber Costa 

kvmclock presence can be signalled by two different flags. So for
device creation, we have to test for both.

Signed-off-by: Glauber Costa 
Signed-off-by: Avi Kivity 
---
 hw/kvmclock.c |6 +-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/hw/kvmclock.c b/hw/kvmclock.c
index b6ceddf..004c4ad 100644
--- a/hw/kvmclock.c
+++ b/hw/kvmclock.c
@@ -103,7 +103,11 @@ static SysBusDeviceInfo kvmclock_info = {
 void kvmclock_create(void)
 {
 if (kvm_enabled() &&
-first_cpu->cpuid_kvm_features & (1ULL << KVM_FEATURE_CLOCKSOURCE)) {
+first_cpu->cpuid_kvm_features & ((1ULL << KVM_FEATURE_CLOCKSOURCE)
+#ifdef KVM_FEATURE_CLOCKSOURCE2
+|| (1ULL << KVM_FEATURE_CLOCKSOURCE2)
+#endif
+)) {
 sysbus_create_simple("kvmclock", -1, NULL);
 }
 }
-- 
1.7.4.2




[Qemu-devel] [PATCH 4/6] Break up user and system cpu_interrupt implementations

2011-04-16 Thread Marcelo Tosatti
From: Jan Kiszka 

Both have only two lines in common, and we will convert the system
service into a callback which is of no use for user mode operation.

Signed-off-by: Jan Kiszka 
CC: Riku Voipio 
Signed-off-by: Marcelo Tosatti 
---
 exec.c |   14 ++
 1 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/exec.c b/exec.c
index b1ee52a..cc0806e 100644
--- a/exec.c
+++ b/exec.c
@@ -1630,6 +1630,7 @@ static void cpu_unlink_tb(CPUState *env)
 spin_unlock(&interrupt_lock);
 }
 
+#ifndef CONFIG_USER_ONLY
 /* mask must never be zero, except for A20 change call */
 void cpu_interrupt(CPUState *env, int mask)
 {
@@ -1638,7 +1639,6 @@ void cpu_interrupt(CPUState *env, int mask)
 old_mask = env->interrupt_request;
 env->interrupt_request |= mask;
 
-#ifndef CONFIG_USER_ONLY
 /*
  * If called from iothread context, wake the target cpu in
  * case its halted.
@@ -1647,21 +1647,27 @@ void cpu_interrupt(CPUState *env, int mask)
 qemu_cpu_kick(env);
 return;
 }
-#endif
 
 if (use_icount) {
 env->icount_decr.u16.high = 0x;
-#ifndef CONFIG_USER_ONLY
 if (!can_do_io(env)
 && (mask & ~old_mask) != 0) {
 cpu_abort(env, "Raised interrupt while not in I/O function");
 }
-#endif
 } else {
 cpu_unlink_tb(env);
 }
 }
 
+#else /* CONFIG_USER_ONLY */
+
+void cpu_interrupt(CPUState *env, int mask)
+{
+env->interrupt_request |= mask;
+cpu_unlink_tb(env);
+}
+#endif /* CONFIG_USER_ONLY */
+
 void cpu_reset_interrupt(CPUState *env, int mask)
 {
 env->interrupt_request &= ~mask;
-- 
1.7.4.2




[Qemu-devel] QEMU-KVM and hardened (GRSEC/PaX) kernel

2011-04-16 Thread Антон Кочков
Good day!
I'm trying to make working qemu-kvm with hardened gentoo on hardened kernel.
When i'm using CONFIG_PAX_KERNPAGEXEC and CONFIG_PAX_MEM_UNDEREF qemu just start
and go to infinite loop and take 100% of one of my CPU core. adn it
even can't be killed.
Also it is dont give answer for qemu monitor/remote gdb.
When I'm changed these two values as disabled, qemu-kvm now start, and
stop (i mean qemu monitor show that virtual machine is running, but no
any activity/output). Also it's load about 0%.
See details in bug http://bugs.gentoo.org/show_bug.cgi?id=363713

Hope this info help improve qemu-kvm.

Best regards,
Anton Kochkov.



Re: [Qemu-devel] [PATCH 0/6] [PULL] qemu-kvm.git uq/master queue

2011-04-16 Thread Anthony Liguori

On 04/16/2011 05:10 PM, Marcelo Tosatti wrote:

The following changes since commit adc56dda0c4eed62149d28939b7d7e329ad95ae8:

   migration: move some declarations to migration.h (2011-04-15 20:14:54 +)

are available in the git repository at:
   git://git.kernel.org/pub/scm/virt/kvm/qemu-kvm.git uq/master

Glauber Costa (3):
   kvm: use kernel-provided para_features instead of statically coming up 
with new capabilities


It's hard to follow this logic, but something in this series introduces 
a ton of chatter on stdout.  For instance:



anthony@titi:~/build/qemu$ x86_64-softmmu/qemu-system-x86_64 -hda 
~/images/linux.img -snapshot

error: feature "sse2" not available in set
error: bad option value [feature_edx = sse2 sse fxsr mmx pat cmov pge 
sep apic cx8 mce pae msr tsc pse de fpumtrr clflush mca pse36]

error: feature "sse2" not available in set
error: bad option value [feature_edx = sse2 sse fxsr mmx pat cmov pge 
sep apic cx8 mce pae msr tsc pse de fpumtrr clflush mca pse36]

error: feature "sse2" not available in set
error: bad option value [feature_edx = sse2 sse fxsr mmx pat cmov pge 
sep apic cx8 mce pae msr tsc pse de fpumtrr clflush mca pse36]

error: feature "sse2" not available in set
error: bad option value [feature_edx = sse2 sse fxsr mmx pat cmov pge 
sep apic cx8 mce pae msr tsc pse de fpumtrr clflush mca pse36]

error: feature "sse2" not available in set
error: bad option value [feature_edx = sse2 sse fxsr mmx pat cmov pge 
sep apic cx8 mce pae msr tsc pse de fpumtrr clflush mca pse36]

error: feature "sse2" not available in set
error: bad option value [feature_edx = sse2 sse fxsr mmx pat cmov pge 
sep apic cx8 mce pae msr tsc pse de fpumtrr clflush mca pse36]

CPU feature hypervisor not found

This is with or without KVM enabled.

Regards,

Anthony Liguori


   kvm: add kvmclock to its second bit
   kvm: create kvmclock when one of the flags are present

Jan Kiszka (3):
   Break up user and system cpu_interrupt implementations
   Redirect cpu_interrupt to callback handler
   kvm: Install specialized interrupt handler

  cpu-all.h   |   14 -
  exec.c  |   18 ---
  hw/kvmclock.c   |6 +++-
  kvm-all.c   |   11 +++
  target-i386/cpuid.c |3 +-
  target-i386/kvm.c   |   78 ---
  6 files changed, 92 insertions(+), 38 deletions(-)





Re: [Qemu-devel] [PULL] Trivial patches for 10-16 April

2011-04-16 Thread Anthony Liguori

On 04/16/2011 06:33 AM, Stefan Hajnoczi wrote:

The following changes since commit adc56dda0c4eed62149d28939b7d7e329ad95ae8:

   migration: move some declarations to migration.h (2011-04-15 20:14:54 +)

are available in the git repository at:
   git://repo.or.cz/qemu/stefanha.git trivial-patches

Brad Hards (4):
   Makefile: Clean up after "make pdf"
   usb: trivial spelling fixes
   usb: initialise data element in Linux USB_DISCONNECT ioctl
   usb: fix spelling errors in usb-linux.c

Stefan Weil (1):
   Fix some typos in comments and documentation


Pulled.  Thanks.

Regards,

Anthony Liguori


  .gitignore  |3 +++
  Makefile|5 -
  hw/usb-msd.c|4 ++--
  qemu-options.hx |4 ++--
  savevm.c|2 +-
  target-arm/helper.c |2 +-
  usb-linux.c |5 +++--
  7 files changed, 16 insertions(+), 9 deletions(-)







Re: [Qemu-devel] [PATCH] Fix some wording in qemu.1

2011-04-16 Thread Dan Church
Yeah, sorry about that. I pressed 'p' in Vim in the wrong place.
Here's the final patch:

--- qemu/qemu.1.orig2011-04-16 14:33:06.0 -0500
+++ qemu/qemu.1 2011-04-16 14:56:56.0 -0500
@@ -271,11 +271,11 @@
 Available types are: ide, scsi, sd, mtd, floppy, pflash, virtio.
 .IP "\fBbus=\fR\fIbus\fR\fB,unit=\fR\fIunit\fR" 4
 .IX Item "bus=bus,unit=unit"
-These options define where is connected the drive by defining the bus
number and
+These options define where the drive is connected by defining the bus
number and
 the unit id.
 .IP "\fBindex=\fR\fIindex\fR" 4
 .IX Item "index=index"
-This option defines where is connected the drive by using an index in the list
+This option defines where the drive is connected by using an index in the list
 of available connectors of a given interface type.
 .IP "\fBmedia=\fR\fImedia\fR" 4
 .IX Item "media=media"
@@ -376,10 +376,10 @@
 incremented:
 .Sp
 .Vb 1
-\&qemu \-drive file=a \-drive file=b"
+\&qemu \-drive file=a \-drive file=b
 .Ve
 .Sp
-is interpreted like:
+is interpreted as:
 .Sp
 .Vb 1
 \&qemu \-hda a \-hdb b


On Sat, Apr 16, 2011 at 15:25, Stefan Weil  wrote:
> Am 16.04.2011 21:38, schrieb Dan Church:
>>
>> It was apparent that some parts of the man page were written by
>> non-native English speaker(s), so I figured I'd help out somewhat:
>>
>> --- qemu/qemu.1.orig    2011-04-16 14:33:06.0 -0500
>> +++ qemu/qemu.1 2011-04-16 14:36:38.0 -0500
>> @@ -271,11 +271,11 @@
>>  Available types are: ide, scsi, sd, mtd, floppy, pflash, virtio.
>>  .IP "\fBbus=\fR\fIbus\fR\fB,unit=\fR\fIunit\fR" 4
>>  .IX Item "bus=bus,unit=unit"
>> -These options define where is connected the drive by defining the bus
>> number and
>> +These options define where the drive by is connected defining the bus
>> number and
>>
>
> ... where the drive is connected by defining ...? See also next change.
>
> The other changes look good.
>
>>  the unit id.
>>  .IP "\fBindex=\fR\fIindex\fR" 4
>>  .IX Item "index=index"
>> -This option defines where is connected the drive by using an index in the
>> list
>> +This option defines where the drive is connected by using an index in the
>> list
>>  of available connectors of a given interface type.
>>  .IP "\fBmedia=\fR\fImedia\fR" 4
>>  .IX Item "media=media"
>> @@ -376,10 +376,10 @@
>>  incremented:
>>  .Sp
>>  .Vb 1
>> -\&         qemu \-drive file=a \-drive file=b"
>> +\&         qemu \-drive file=a \-drive file=b
>>  .Ve
>>  .Sp
>> -is interpreted like:
>> +is interpreted as:
>>  .Sp
>>  .Vb 1
>>  \&         qemu \-hda a \-hdb b
>>
>>
>>
>
>



-- 
   Fourth Law of Programming:
   Anything that can go wrong wi
sendmail: segmentation violated - core dumped



Re: [Qemu-devel] [PATCH] Fix some wording in qemu.1

2011-04-16 Thread Stefan Weil

Am 17.04.2011 03:25, schrieb Dan Church:

Yeah, sorry about that. I pressed 'p' in Vim in the wrong place.
Here's the final patch:

--- qemu/qemu.1.orig 2011-04-16 14:33:06.0 -0500
+++ qemu/qemu.1 2011-04-16 14:56:56.0 -0500
@@ -271,11 +271,11 @@
Available types are: ide, scsi, sd, mtd, floppy, pflash, virtio.
.IP "\fBbus=\fR\fIbus\fR\fB,unit=\fR\fIunit\fR" 4
.IX Item "bus=bus,unit=unit"
-These options define where is connected the drive by defining the bus
number and
+These options define where the drive is connected by defining the bus
number and
the unit id.
.IP "\fBindex=\fR\fIindex\fR" 4
.IX Item "index=index"
-This option defines where is connected the drive by using an index in 
the list
+This option defines where the drive is connected by using an index in 
the list

of available connectors of a given interface type.
.IP "\fBmedia=\fR\fImedia\fR" 4
.IX Item "media=media"
@@ -376,10 +376,10 @@
incremented:
.Sp
.Vb 1
-\& qemu \-drive file=a \-drive file=b"
+\& qemu \-drive file=a \-drive file=b
.Ve
.Sp
-is interpreted like:
+is interpreted as:
.Sp
.Vb 1
\& qemu \-hda a \-hdb b


On Sat, Apr 16, 2011 at 15:25, Stefan Weil  wrote:

Am 16.04.2011 21:38, schrieb Dan Church:


It was apparent that some parts of the man page were written by
non-native English speaker(s), so I figured I'd help out somewhat:

--- qemu/qemu.1.orig2011-04-16 14:33:06.0 -0500
+++ qemu/qemu.1 2011-04-16 14:36:38.0 -0500
@@ -271,11 +271,11 @@
 Available types are: ide, scsi, sd, mtd, floppy, pflash, virtio.
 .IP "\fBbus=\fR\fIbus\fR\fB,unit=\fR\fIunit\fR" 4
 .IX Item "bus=bus,unit=unit"
-These options define where is connected the drive by defining the bus
number and
+These options define where the drive by is connected defining the bus
number and



... where the drive is connected by defining ...? See also next change.

The other changes look good.


 the unit id.
 .IP "\fBindex=\fR\fIindex\fR" 4
 .IX Item "index=index"
-This option defines where is connected the drive by using an index 
in the

list
+This option defines where the drive is connected by using an index 
in the

list
 of available connectors of a given interface type.
 .IP "\fBmedia=\fR\fImedia\fR" 4
 .IX Item "media=media"
@@ -376,10 +376,10 @@
 incremented:
 .Sp
 .Vb 1
-\& qemu \-drive file=a \-drive file=b"
+\& qemu \-drive file=a \-drive file=b
 .Ve
 .Sp
-is interpreted like:
+is interpreted as:
 .Sp
 .Vb 1
 \& qemu \-hda a \-hdb b


Could you please add a "Signed-off-by" signature and send the patch with 
"git send-email"?


Thanks,
Stefan W.