Re: [Qemu-devel] Significant performance regression in qemu-system-mips.

2010-04-02 Thread Rob Landley
On Thursday 01 April 2010 18:42:27 Alexander Graf wrote:
> On 01.04.2010, at 15:49, Andreas Färber wrote:
> > Am 26.03.2010 um 03:44 schrieb Rob Landley:
> >> According to "qemu-system-ppc -M ?", g3beige is still the default.  The
> >> mac99 machine is the default for ppc64.  (Are there newworlds that run a
> >> 32 bit ppc instead of a 64 bit ppc?)
> >
> > There are. All G3 and G4 PowerMacs, iMacs, iBooks were ppc32 AFAIK.
> > I changed the ppc64 default to mac99 to get a working default
> > configuration there.
>
> I just pushed a fix to OpenBIOS that should make oldworld macs boot again.
> I tested and verified that it makes -M g3beige work and doesn't break
> PPC64, both using KVM.
>
> Alex

Confirmed, ppc32 g3beige working for me.

Thanks,

Rob
-- 
Latency is more important than throughput. It's that simple. - Linus Torvalds




Re: [Qemu-devel] Significant performance regression in qemu-system-mips.

2010-04-02 Thread Rob Landley
On Thursday 01 April 2010 16:33:09 Aurelien Jarno wrote:
> On Wed, Mar 24, 2010 at 03:34:00PM -0500, Rob Landley wrote:
> > Reverting that patch fixed it (git show HEAD | patch -R -p1), by which I
> > mean three consecutive runs with 30 second timeout didn't trigger the
> > hang detection.
>
> I have tried to reproduce the issue by measuring the boot time of a mips
> system, but it stay unchanged between before and after the patch.  Do you
> have some more details about how to reproduce the issue ? Have you tried
> to pay with the -clock option?

It was fixed by commit ca5a2a4b12bd447 from Paolo Bonzini, which is in current 
-git.  (I just confirmed that current -git builds fine.)

If you did want to reproduce the issue get and extract

  http://impactlinux.com/fwl/downloads/firmware-0.9.11.tar.bz2

Create a mips system image:

  ./build.sh mips

And when the noise dies down run the native build with:

  sources/native-builds/static-tools.sh temp.hdc
  sources/more/native-build.sh mips temp.hdc output 30

That creates a build control image (temp.hdc, with the source tarballs for 
dropbear and strace and a control script to build static binaries of both), 
and then runs a native build using the mips system image under qemu (it'll 
grab qemu-system-mips from your $PATH), uploading the results into the 
"output" directory on the host, with a 30 second inactivity timeout.

When the bug was manifesting, it usually wouldn't even complete with a 60 
second timeout, let alone 30.  (Paolo said disabling dynticks would help, but 
his patch seems to have fixed it properly.)

Thanks,

Rob
-- 
Latency is more important than throughput. It's that simple. - Linus Torvalds




[Qemu-devel] [PATCH] target-mips: Fix one more format specifier for cpu_fprintf

2010-04-02 Thread Stefan Weil
env->bcond must be printed using TARGET_FMT_ld.

Signed-off-by: Stefan Weil 
---
 target-mips/translate.c |4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/target-mips/translate.c b/target-mips/translate.c
index 61f8d72..bdd1884 100644
--- a/target-mips/translate.c
+++ b/target-mips/translate.c
@@ -9638,7 +9638,9 @@ void cpu_dump_state (CPUState *env, FILE *f,
 {
 int i;
 
-cpu_fprintf(f, "pc=0x" TARGET_FMT_lx " HI=0x" TARGET_FMT_lx " LO=0x" 
TARGET_FMT_lx " ds %04x " TARGET_FMT_lx " %d\n",
+cpu_fprintf(f, "pc=0x" TARGET_FMT_lx " HI=0x" TARGET_FMT_lx
+" LO=0x" TARGET_FMT_lx " ds %04x "
+TARGET_FMT_lx " " TARGET_FMT_ld "\n",
 env->active_tc.PC, env->active_tc.HI[0], env->active_tc.LO[0],
 env->hflags, env->btarget, env->bcond);
 for (i = 0; i < 32; i++) {
-- 
1.7.0





[Qemu-devel] Re: 452efb didn't show up in the list

2010-04-02 Thread Artyom Tarasenko
2010/4/2 Blue Swirl :
> On 4/1/10, Artyom Tarasenko  wrote:
>> 2010/4/1 Blue Swirl :
>>  > Which list?
>>
>>  This mailing list?
>>
>>
>>  > On 4/1/10, Artyom Tarasenko  wrote:
>>  >> and looks wrong or incomplete to me:
>>  >>
>>  >>  >According to Sun4M System Architecture Manual chapter 5.3.2, a limit
>>  >>  >of 0 will not generate interrupts.
>>  >>
>>  >>  This is indeed correct, but the chapter 5.3.2 also explains why:
>>  >>
>>  >>  "Setting the limit register to  0  allows the counter to free run. 
>> Since the
>>  >>  timer always resets to a value of 500 nS after reaching maximum count,
>>  >>  there is no match and no interrupts are generated."
>>  >>
>>  >>  The part about 500 nS (0x0200 in the counter register) and
>>  >>  no match seems to be not addressed.
>>  >
>>  > The 500ns offset part could be addressed by making the timer period
>>  > shorter by 1 tick. I doubt such a change would have any visible
>>  > difference with QEMU, except that tick count of 0 should never appear
>>  > in the counter but it may now.
>>
>>
>> as well as all the other values between 0 and 0x200. But it's less
>>  important I guess.
>>
>>
>>  > For the no match part, t->reached should not be set if t->limit == 0.
>
> I think this patch would do what is expected.

Looks good and passes my tests, thanks.

Redefining LIMIT_TO_PERIODS is a really nice solution.


-- 
Regards,
Artyom Tarasenko

solaris/sparc32 under qemu blog: http://tyom.blogspot.com/




[Qemu-devel] Re: [PATCH] provide a stub version of kvm-all.c if !CONFIG_KVM

2010-04-02 Thread Blue Swirl
On 4/2/10, Paolo Bonzini  wrote:
> On 04/02/2010 08:17 PM, Blue Swirl wrote:
>
> > I merged your patch and mine. Does it still look reasonable?
> >
>
>  Yes, of course.  I'd rather see them committed separately though.

This version is designed to be applied after your patch. I made my
patch a bit simpler.
From 1ce35cc1adc0eb54420d6647c3dfc46445788906 Mon Sep 17 00:00:00 2001
From: Blue Swirl 
Date: Fri, 2 Apr 2010 19:00:35 +
Subject: [PATCH] Compile vl.c once

Remove dependency of vl.c to KVM, then we can partially revert
b33612d03540fda7fa67485f1c20395beb7a2bf0.

Signed-off-by: Blue Swirl 
---
 Makefile.objs   |2 +-
 Makefile.target |2 +-
 kvm-all.c   |3 +++
 kvm.h   |4 +---
 sysemu.h|1 +
 vl.c|7 +++
 6 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/Makefile.objs b/Makefile.objs
index 11e44a0..cb2ec2c 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -128,7 +128,7 @@ user-obj-y += cutils.o cache-utils.o
 # libhw
 
 hw-obj-y =
-hw-obj-y += loader.o
+hw-obj-y += vl.o loader.o
 hw-obj-y += virtio.o virtio-console.o
 hw-obj-y += fw_cfg.o pci.o pci_host.o pcie_host.o
 hw-obj-y += watchdog.o
diff --git a/Makefile.target b/Makefile.target
index c504617..c1bfc41 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -162,7 +162,7 @@ endif #CONFIG_BSD_USER
 # System emulator target
 ifdef CONFIG_SOFTMMU
 
-obj-y = arch_init.o cpus.o monitor.o machine.o gdbstub.o vl.o
+obj-y = arch_init.o cpus.o monitor.o machine.o gdbstub.o
 # virtio has to be here due to weird dependency between PCI and virtio-net.
 # need to fix this properly
 obj-y += virtio-blk.o virtio-balloon.o virtio-net.o virtio-pci.o virtio-serial-bus.o
diff --git a/kvm-all.c b/kvm-all.c
index 373fd34..f6317ee 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -51,6 +51,8 @@ typedef struct KVMSlot
 
 typedef struct kvm_dirty_log KVMDirtyLog;
 
+int kvm_allowed = 0;
+
 struct KVMState
 {
 KVMSlot slots[32];
@@ -670,6 +672,7 @@ int kvm_init(int smp_cpus)
 
 kvm_state = s;
 cpu_register_phys_memory_client(&kvm_cpu_phys_memory_client);
+kvm_allowed = 1;
 
 return 0;
 
diff --git a/kvm.h b/kvm.h
index ea3c97d..ec66b2f 100644
--- a/kvm.h
+++ b/kvm.h
@@ -23,9 +23,9 @@
 #include 
 #endif
 
+#if defined CONFIG_KVM || !defined NEED_CPU_H
 extern int kvm_allowed;
 
-#if defined CONFIG_KVM || !defined NEED_CPU_H
 #define kvm_enabled() (kvm_allowed)
 #else
 #define kvm_enabled() (0)
@@ -35,8 +35,6 @@ struct kvm_run;
 
 /* external API */
 
-int kvm_init(int smp_cpus);
-
 #ifdef NEED_CPU_H
 int kvm_init_vcpu(CPUState *env);
 
diff --git a/sysemu.h b/sysemu.h
index d0effa0..0b423db 100644
--- a/sysemu.h
+++ b/sysemu.h
@@ -243,4 +243,5 @@ void rtc_change_mon_event(struct tm *tm);
 
 void register_devices(void);
 
+int kvm_init(int smp_cpus);
 #endif
diff --git a/vl.c b/vl.c
index 9fe4682..1005163 100644
--- a/vl.c
+++ b/vl.c
@@ -145,7 +145,6 @@ int main(int argc, char **argv)
 #include "dma.h"
 #include "audio/audio.h"
 #include "migration.h"
-#include "kvm.h"
 #include "balloon.h"
 #include "qemu-option.h"
 #include "qemu-config.h"
@@ -241,7 +240,6 @@ uint8_t qemu_uuid[16];
 static QEMUBootSetHandler *boot_set_handler;
 static void *boot_set_opaque;
 
-int kvm_allowed = 0;
 uint32_t xen_domid;
 enum xen_mode xen_mode = XEN_EMULATE;
 
@@ -2649,6 +2647,7 @@ int main(int argc, char **argv, char **envp)
 #endif
 int show_vnc_port = 0;
 int defconfig = 1;
+int enable_kvm = 0;
 
 error_set_progname(argv[0]);
 
@@ -3235,7 +3234,7 @@ int main(int argc, char **argv, char **envp)
 do_smbios_option(optarg);
 break;
 case QEMU_OPTION_enable_kvm:
-kvm_allowed = 1;
+enable_kvm = 1;
 break;
 case QEMU_OPTION_usb:
 usb_enabled = 1;
@@ -3581,7 +3580,7 @@ int main(int argc, char **argv, char **envp)
 exit(1);
 }
 
-if (kvm_allowed) {
+if (enable_kvm) {
 int ret = kvm_init(smp_cpus);
 if (ret < 0) {
 if (!kvm_available()) {
-- 
1.5.6.5



[Qemu-devel] Re: [PATCH] provide a stub version of kvm-all.c if !CONFIG_KVM

2010-04-02 Thread Paolo Bonzini

On 04/02/2010 08:17 PM, Blue Swirl wrote:

I merged your patch and mine. Does it still look reasonable?


Yes, of course.  I'd rather see them committed separately though.

Paolo




[Qemu-devel] Re: [PATCH] provide a stub version of kvm-all.c if !CONFIG_KVM

2010-04-02 Thread Blue Swirl
On 4/2/10, Paolo Bonzini  wrote:
> On 04/02/2010 07:29 PM, Blue Swirl wrote:
>
> > Could you stub also kvm_init?
> >
>
>  It is stubbed, but it returns ENOSYS:
>
>   +int kvm_init(int smp_cpus)
>   +{
>   +return -ENOSYS;
>   +}
>   +

Sorry, I expected this to be near the end.

>  and in fact I'm relying this to remove this:
>
>   if (!(kvm_available())) {
>  printf("Option %s not supported for this target\n", popt->name);
>  exit(1);
>   }
>
>  and instead looking for an error when I call kvm_init.  I don't see why
> kvm_init should be called if not passing -enable-kvm (which is kvm_allowed).
>
>
> > Then this part would be simpler because
> > you can call unconditionally kvm_init. I guess there would be no need
> > to export kvm_allowed for !CONFIG_KVM case.
> >
>
>  I don't understand what you mean.  If this doesn't clarify enough, feel
> free to pick up the patch and tweak it; I'm not going to spend much time on
> QEMU for a while.

I merged your patch and mine. Does it still look reasonable?
From ecda8242df18748b73a68d3f39a89a2ac483af4d Mon Sep 17 00:00:00 2001
From: Paolo Bonzini 
Date: Fri, 2 Apr 2010 18:07:55 +
Subject: [PATCH] provide a stub version of kvm-all.c if !CONFIG_KVM

This allows limited use of kvm functions (which will return ENOSYS)
even in once-compiled modules.  The patch also improves a bit the error
messages for KVM initialization.

Signed-off-by: Paolo Bonzini 
Signed-off-by: Blue Swirl 
---
 Makefile.objs   |2 +-
 Makefile.target |4 +-
 kvm-all.c   |9 +++-
 kvm-stub.c  |  135 +++
 kvm.h   |   15 +-
 sysemu.h|1 +
 vl.c|   13 ++
 7 files changed, 154 insertions(+), 25 deletions(-)
 create mode 100644 kvm-stub.c

diff --git a/Makefile.objs b/Makefile.objs
index 11e44a0..cb2ec2c 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -128,7 +128,7 @@ user-obj-y += cutils.o cache-utils.o
 # libhw
 
 hw-obj-y =
-hw-obj-y += loader.o
+hw-obj-y += vl.o loader.o
 hw-obj-y += virtio.o virtio-console.o
 hw-obj-y += fw_cfg.o pci.o pci_host.o pcie_host.o
 hw-obj-y += watchdog.o
diff --git a/Makefile.target b/Makefile.target
index 167fc8d..c1bfc41 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -1,6 +1,7 @@
 # -*- Mode: makefile -*-
 
 GENERATED_HEADERS = config-target.h
+CONFIG_NO_KVM = $(if $(subst n,,$(CONFIG_KVM)),n,y)
 
 include ../config-host.mak
 include config-devices.mak
@@ -161,7 +162,7 @@ endif #CONFIG_BSD_USER
 # System emulator target
 ifdef CONFIG_SOFTMMU
 
-obj-y = arch_init.o cpus.o monitor.o machine.o gdbstub.o vl.o
+obj-y = arch_init.o cpus.o monitor.o machine.o gdbstub.o
 # virtio has to be here due to weird dependency between PCI and virtio-net.
 # need to fix this properly
 obj-y += virtio-blk.o virtio-balloon.o virtio-net.o virtio-pci.o virtio-serial-bus.o
@@ -170,6 +171,7 @@ obj-y += vhost_net.o
 obj-$(CONFIG_VHOST_NET) += vhost.o
 obj-y += rwhandler.o
 obj-$(CONFIG_KVM) += kvm.o kvm-all.o
+obj-$(CONFIG_NO_KVM) += kvm-stub.o
 LIBS+=-lz
 
 QEMU_CFLAGS += $(VNC_TLS_CFLAGS)
diff --git a/kvm-all.c b/kvm-all.c
index 7aa5e57..f6317ee 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -51,6 +51,8 @@ typedef struct KVMSlot
 
 typedef struct kvm_dirty_log KVMDirtyLog;
 
+int kvm_allowed = 0;
+
 struct KVMState
 {
 KVMSlot slots[32];
@@ -670,6 +672,7 @@ int kvm_init(int smp_cpus)
 
 kvm_state = s;
 cpu_register_phys_memory_client(&kvm_cpu_phys_memory_client);
+kvm_allowed = 1;
 
 return 0;
 
@@ -1157,9 +1160,9 @@ int kvm_set_signal_mask(CPUState *env, const sigset_t *sigset)
 return r;
 }
 
-#ifdef KVM_IOEVENTFD
 int kvm_set_ioeventfd_pio_word(int fd, uint16_t addr, uint16_t val, bool assign)
 {
+#ifdef KVM_IOEVENTFD
 struct kvm_ioeventfd kick = {
 .datamatch = val,
 .addr = addr,
@@ -1176,5 +1179,7 @@ int kvm_set_ioeventfd_pio_word(int fd, uint16_t addr, uint16_t val, bool assign)
 if (r < 0)
 return r;
 return 0;
-}
+#else
+return -ENOSYS;
 #endif
+}
diff --git a/kvm-stub.c b/kvm-stub.c
new file mode 100644
index 000..80bb908
--- /dev/null
+++ b/kvm-stub.c
@@ -0,0 +1,135 @@
+/*
+ * QEMU KVM stub
+ *
+ * Copyright Red Hat, Inc. 2010
+ *
+ * Author: Paolo Bonzini 
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ *
+ */
+
+#include "qemu-common.h"
+#include "sysemu.h"
+#include "hw/hw.h"
+#include "gdbstub.h"
+#include "kvm.h"
+
+int kvm_irqchip_in_kernel(void)
+{
+return 0;
+}
+
+int kvm_pit_in_kernel(void)
+{
+return 0;
+}
+
+
+int kvm_init_vcpu(CPUState *env)
+{
+return -ENOSYS;
+}
+
+int kvm_log_start(target_phys_addr_t phys_addr, ram_addr_t size)
+{
+return -ENOSYS;
+}
+
+int kvm_log_stop(target_phys_addr_t phys_addr, ram_addr_t size)
+{
+return -ENOSYS;
+}
+
+int kvm_coalesce_mmio_region(target_phys_addr_t start, ram_addr_t size)
+{
+return -ENOSYS;
+}
+
+int kvm_uncoalesce_mmi

Re: [Qemu-devel] [PATCH] provide opaque CPUState to files that are compiled once

2010-04-02 Thread Anthony Liguori

On 04/02/2010 12:46 PM, Paolo Bonzini wrote:

On 04/02/2010 07:36 PM, Anthony Liguori wrote:

On 04/02/2010 11:43 AM, Paolo Bonzini wrote:

On 04/02/2010 06:24 PM, Anthony Liguori wrote:


I'd rather things be compiled per-target than adding a bunch of crud
everywhere.


Well, this patch in particular removes more lines than it adds. :-P

Anyway---me too, given how hairy it's coming out. Maybe (or without
maybe) this work should have been done on a branch.


What files need to be compiled per-target to fix qemu-kvm?


With this patch, pci.o/i8254.o/acpi.o.  Without, also pcspk.o and 
acpi.o then I stopped.


i8254.o has to be a bug.  There should be no reason to include 
qemu-kvm.h there.  Likewise with acpi.o and pcspk.o.


Regards,

Anthony Liguori


Paolo






Re: [Qemu-devel] [PATCH] provide opaque CPUState to files that are compiled once

2010-04-02 Thread Paolo Bonzini

On 04/02/2010 07:36 PM, Anthony Liguori wrote:

On 04/02/2010 11:43 AM, Paolo Bonzini wrote:

On 04/02/2010 06:24 PM, Anthony Liguori wrote:


I'd rather things be compiled per-target than adding a bunch of crud
everywhere.


Well, this patch in particular removes more lines than it adds. :-P

Anyway---me too, given how hairy it's coming out. Maybe (or without
maybe) this work should have been done on a branch.


What files need to be compiled per-target to fix qemu-kvm?


With this patch, pci.o/i8254.o/acpi.o.  Without, also pcspk.o and acpi.o 
then I stopped.


Paolo




Re: [Qemu-devel] [PATCH] provide opaque CPUState to files that are compiled once

2010-04-02 Thread Anthony Liguori

On 04/02/2010 11:43 AM, Paolo Bonzini wrote:

On 04/02/2010 06:24 PM, Anthony Liguori wrote:


I'd rather things be compiled per-target than adding a bunch of crud
everywhere.


Well, this patch in particular removes more lines than it adds. :-P

Anyway---me too, given how hairy it's coming out.  Maybe (or without 
maybe) this work should have been done on a branch.


What files need to be compiled per-target to fix qemu-kvm?

Regards,

Anthony Liguori


Wouldn't it be easier to split up qemu-kvm.h into qemu-kvm-cpu.h and add
the later include where it's needed (which should be very few places)?


I won't have time to do this if you prefer that, I guess I'll have to 
leave it to Marcelo and Avi.


Paolo






[Qemu-devel] Re: [PATCH] provide a stub version of kvm-all.c if !CONFIG_KVM

2010-04-02 Thread Paolo Bonzini

On 04/02/2010 07:29 PM, Blue Swirl wrote:

Could you stub also kvm_init?


It is stubbed, but it returns ENOSYS:

 +int kvm_init(int smp_cpus)
 +{
 +return -ENOSYS;
 +}
 +

and in fact I'm relying this to remove this:

 if (!(kvm_available())) {
 printf("Option %s not supported for this target\n", popt->name);
 exit(1);
 }

and instead looking for an error when I call kvm_init.  I don't see why 
kvm_init should be called if not passing -enable-kvm (which is kvm_allowed).



Then this part would be simpler because
you can call unconditionally kvm_init. I guess there would be no need
to export kvm_allowed for !CONFIG_KVM case.


I don't understand what you mean.  If this doesn't clarify enough, feel 
free to pick up the patch and tweak it; I'm not going to spend much time 
on QEMU for a while.


Paolo




[Qemu-devel] Re: [PATCH] provide a stub version of kvm-all.c if !CONFIG_KVM

2010-04-02 Thread Blue Swirl
On 4/2/10, Paolo Bonzini  wrote:
> This allows limited use of kvm functions (which will return ENOSYS)
>  even in once-compiled modules.  The patch also improves a bit the error
>  messages for KVM initialization.
>
>  Signed-off-by: Paolo Bonzini 
>  ---
> What about this instead?  I don't like that kvm-stub.c is
> compiled per-target too, but it's basically impossible to
> change this without major changes to the build system.

>
>   Makefile.target |2 +
>   kvm-all.c   |6 ++-
>   kvm-stub.c  |  135 
> +++
>   kvm.h   |   13 +
>   vl.c|   16 +++
>   5 files changed, 151 insertions(+), 21 deletions(-)
>   create mode 100644 kvm-stub.c
>
>  diff --git a/Makefile.target b/Makefile.target
>  index 167fc8d..c504617 100644
>  --- a/Makefile.target
>  +++ b/Makefile.target
>  @@ -1,6 +1,7 @@
>   # -*- Mode: makefile -*-
>
>   GENERATED_HEADERS = config-target.h
>  +CONFIG_NO_KVM = $(if $(subst n,,$(CONFIG_KVM)),n,y)
>
>   include ../config-host.mak
>   include config-devices.mak
>  @@ -170,6 +171,7 @@ obj-y += vhost_net.o
>   obj-$(CONFIG_VHOST_NET) += vhost.o
>   obj-y += rwhandler.o
>   obj-$(CONFIG_KVM) += kvm.o kvm-all.o
>  +obj-$(CONFIG_NO_KVM) += kvm-stub.o
>   LIBS+=-lz
>
>   QEMU_CFLAGS += $(VNC_TLS_CFLAGS)
>  diff --git a/kvm-all.c b/kvm-all.c
>  index 7aa5e57..373fd34 100644
>  --- a/kvm-all.c
>  +++ b/kvm-all.c
>  @@ -1157,9 +1157,9 @@ int kvm_set_signal_mask(CPUState *env, const sigset_t 
> *sigset)
>  return r;
>   }
>
>  -#ifdef KVM_IOEVENTFD
>   int kvm_set_ioeventfd_pio_word(int fd, uint16_t addr, uint16_t val, bool 
> assign)
>   {
>  +#ifdef KVM_IOEVENTFD
>  struct kvm_ioeventfd kick = {
>  .datamatch = val,
>  .addr = addr,
>  @@ -1176,5 +1176,7 @@ int kvm_set_ioeventfd_pio_word(int fd, uint16_t addr, 
> uint16_t val, bool assign)
>  if (r < 0)
>  return r;
>  return 0;
>  -}
>  +#else
>  +return -ENOSYS;
>   #endif
>  +}
>  diff --git a/kvm-stub.c b/kvm-stub.c
>  new file mode 100644
>  index 000..80bb908
>  --- /dev/null
>  +++ b/kvm-stub.c
>  @@ -0,0 +1,135 @@
>  +/*
>  + * QEMU KVM stub
>  + *
>  + * Copyright Red Hat, Inc. 2010
>  + *
>  + * Author: Paolo Bonzini 
>  + *
>  + * This work is licensed under the terms of the GNU GPL, version 2 or later.
>  + * See the COPYING file in the top-level directory.
>  + *
>  + */
>  +
>  +#include "qemu-common.h"
>  +#include "sysemu.h"
>  +#include "hw/hw.h"
>  +#include "gdbstub.h"
>  +#include "kvm.h"
>  +
>  +int kvm_irqchip_in_kernel(void)
>  +{
>  +return 0;
>  +}
>  +
>  +int kvm_pit_in_kernel(void)
>  +{
>  +return 0;
>  +}
>  +
>  +
>  +int kvm_init_vcpu(CPUState *env)
>  +{
>  +return -ENOSYS;
>  +}
>  +
>  +int kvm_log_start(target_phys_addr_t phys_addr, ram_addr_t size)
>  +{
>  +return -ENOSYS;
>  +}
>  +
>  +int kvm_log_stop(target_phys_addr_t phys_addr, ram_addr_t size)
>  +{
>  +return -ENOSYS;
>  +}
>  +
>  +int kvm_coalesce_mmio_region(target_phys_addr_t start, ram_addr_t size)
>  +{
>  +return -ENOSYS;
>  +}
>  +
>  +int kvm_uncoalesce_mmio_region(target_phys_addr_t start, ram_addr_t size)
>  +{
>  +return -ENOSYS;
>  +}
>  +
>  +int kvm_check_extension(KVMState *s, unsigned int extension)
>  +{
>  +return 0;
>  +}
>  +
>  +int kvm_init(int smp_cpus)
>  +{
>  +return -ENOSYS;
>  +}
>  +
>  +void kvm_flush_coalesced_mmio_buffer(void)
>  +{
>  +}
>  +
>  +void kvm_cpu_synchronize_state(CPUState *env)
>  +{
>  +}
>  +
>  +void kvm_cpu_synchronize_post_reset(CPUState *env)
>  +{
>  +}
>  +
>  +void kvm_cpu_synchronize_post_init(CPUState *env)
>  +{
>  +}
>  +
>  +int kvm_cpu_exec(CPUState *env)
>  +{
>  +abort ();
>  +}
>  +
>  +int kvm_has_sync_mmu(void)
>  +{
>  +return 0;
>  +}
>  +
>  +int kvm_has_vcpu_events(void)
>  +{
>  +return 0;
>  +}
>  +
>  +int kvm_has_robust_singlestep(void)
>  +{
>  +return 0;
>  +}
>  +
>  +void kvm_setup_guest_memory(void *start, size_t size)
>  +{
>  +}
>  +
>  +int kvm_update_guest_debug(CPUState *env, unsigned long reinject_trap)
>  +{
>  +tb_flush(env);
>  +return 0;
>  +}
>  +
>  +int kvm_insert_breakpoint(CPUState *current_env, target_ulong addr,
>  +  target_ulong len, int type)
>  +{
>  +return -EINVAL;
>  +}
>  +
>  +int kvm_remove_breakpoint(CPUState *current_env, target_ulong addr,
>  +  target_ulong len, int type)
>  +{
>  +return -EINVAL;
>  +}
>  +
>  +void kvm_remove_all_breakpoints(CPUState *current_env)
>  +{
>  +}
>  +
>  +int kvm_set_signal_mask(CPUState *env, const sigset_t *sigset)
>  +{
>  +abort();
>  +}
>  +
>  +int kvm_set_ioeventfd_pio_word(int fd, uint16_t addr, uint16_t val, bool 
> assign)
>  +{
>  +return -ENOSYS;
>  +}
>  diff --git a/kvm.h b/kvm.h
>  index 1e5be27..ea3c97d 100644
>  --- a/kvm.h
>  +++ b/kvm.h
>  @@ -23,8 +23,9 @@
>   #include 
>   #endif
>
>  -#ifdef CONFIG_KVM

[Qemu-devel] wrong behaviour of caps lock

2010-04-02 Thread Benjamin Drung
Hi,

We applied the attached patch in Ubuntu to fix the wrong behavior of
caps lock.

Initial bug report: https://launchpad.net/bugs/427612

Testcase: Select German NEO 2 as keyboard layout and press "caps lock" +
"l". Then a "-" should appear instead of a "t".

-- 
Benjamin Drung
Ubuntu Developer (www.ubuntu.com) | Debian Maintainer (www.debian.org)
From bb212d2b23bee1abe52db53231caccc1a6a27791 Mon Sep 17 00:00:00 2001
From: Shahar Havivi 
Date: Fri, 12 Feb 2010 00:00:44 +0200
Subject: [PATCH] Qemu does not pass pressed capslock to client

---
 sdl.c |8 +---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/sdl.c b/sdl.c
index cf27ad2..9074641 100644
--- a/sdl.c
+++ b/sdl.c
@@ -390,9 +390,11 @@ static void sdl_process_key(SDL_KeyboardEvent *ev)
 break;
 case 0x45: /* num lock */
 case 0x3a: /* caps lock */
-/* SDL does not send the key up event, so we generate it */
-kbd_put_keycode(keycode);
-kbd_put_keycode(keycode | 0x80);
+if (ev->type == SDL_KEYUP) {
+kbd_put_keycode(keycode | 0x80);
+} else {
+kbd_put_keycode(keycode);
+}
 return;
 }
 
-- 
1.6.3.3



signature.asc
Description: Dies ist ein digital signierter Nachrichtenteil


Re: [Qemu-devel] [PATCH] provide opaque CPUState to files that are compiled once

2010-04-02 Thread Paolo Bonzini

On 04/02/2010 06:24 PM, Anthony Liguori wrote:


I'd rather things be compiled per-target than adding a bunch of crud
everywhere.


Well, this patch in particular removes more lines than it adds. :-P

Anyway---me too, given how hairy it's coming out.  Maybe (or without 
maybe) this work should have been done on a branch.



Wouldn't it be easier to split up qemu-kvm.h into qemu-kvm-cpu.h and add
the later include where it's needed (which should be very few places)?


I won't have time to do this if you prefer that, I guess I'll have to 
leave it to Marcelo and Avi.


Paolo




[Qemu-devel] [PATCH] provide a stub version of kvm-all.c if !CONFIG_KVM

2010-04-02 Thread Paolo Bonzini
This allows limited use of kvm functions (which will return ENOSYS)
even in once-compiled modules.  The patch also improves a bit the error
messages for KVM initialization.

Signed-off-by: Paolo Bonzini 
---
What about this instead?  I don't like that kvm-stub.c is
compiled per-target too, but it's basically impossible to
change this without major changes to the build system.

 Makefile.target |2 +
 kvm-all.c   |6 ++-
 kvm-stub.c  |  135 +++
 kvm.h   |   13 +
 vl.c|   16 +++
 5 files changed, 151 insertions(+), 21 deletions(-)
 create mode 100644 kvm-stub.c

diff --git a/Makefile.target b/Makefile.target
index 167fc8d..c504617 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -1,6 +1,7 @@
 # -*- Mode: makefile -*-
 
 GENERATED_HEADERS = config-target.h
+CONFIG_NO_KVM = $(if $(subst n,,$(CONFIG_KVM)),n,y)
 
 include ../config-host.mak
 include config-devices.mak
@@ -170,6 +171,7 @@ obj-y += vhost_net.o
 obj-$(CONFIG_VHOST_NET) += vhost.o
 obj-y += rwhandler.o
 obj-$(CONFIG_KVM) += kvm.o kvm-all.o
+obj-$(CONFIG_NO_KVM) += kvm-stub.o
 LIBS+=-lz
 
 QEMU_CFLAGS += $(VNC_TLS_CFLAGS)
diff --git a/kvm-all.c b/kvm-all.c
index 7aa5e57..373fd34 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -1157,9 +1157,9 @@ int kvm_set_signal_mask(CPUState *env, const sigset_t 
*sigset)
 return r;
 }
 
-#ifdef KVM_IOEVENTFD
 int kvm_set_ioeventfd_pio_word(int fd, uint16_t addr, uint16_t val, bool 
assign)
 {
+#ifdef KVM_IOEVENTFD
 struct kvm_ioeventfd kick = {
 .datamatch = val,
 .addr = addr,
@@ -1176,5 +1176,7 @@ int kvm_set_ioeventfd_pio_word(int fd, uint16_t addr, 
uint16_t val, bool assign)
 if (r < 0)
 return r;
 return 0;
-}
+#else
+return -ENOSYS;
 #endif
+}
diff --git a/kvm-stub.c b/kvm-stub.c
new file mode 100644
index 000..80bb908
--- /dev/null
+++ b/kvm-stub.c
@@ -0,0 +1,135 @@
+/*
+ * QEMU KVM stub
+ *
+ * Copyright Red Hat, Inc. 2010
+ *
+ * Author: Paolo Bonzini 
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ *
+ */
+
+#include "qemu-common.h"
+#include "sysemu.h"
+#include "hw/hw.h"
+#include "gdbstub.h"
+#include "kvm.h"
+
+int kvm_irqchip_in_kernel(void)
+{
+return 0;
+}
+
+int kvm_pit_in_kernel(void)
+{
+return 0;
+}
+
+
+int kvm_init_vcpu(CPUState *env)
+{
+return -ENOSYS;
+}
+
+int kvm_log_start(target_phys_addr_t phys_addr, ram_addr_t size)
+{
+return -ENOSYS;
+}
+
+int kvm_log_stop(target_phys_addr_t phys_addr, ram_addr_t size)
+{
+return -ENOSYS;
+}
+
+int kvm_coalesce_mmio_region(target_phys_addr_t start, ram_addr_t size)
+{
+return -ENOSYS;
+}
+
+int kvm_uncoalesce_mmio_region(target_phys_addr_t start, ram_addr_t size)
+{
+return -ENOSYS;
+}
+
+int kvm_check_extension(KVMState *s, unsigned int extension)
+{
+return 0;
+}
+
+int kvm_init(int smp_cpus)
+{
+return -ENOSYS;
+}
+
+void kvm_flush_coalesced_mmio_buffer(void)
+{
+}
+
+void kvm_cpu_synchronize_state(CPUState *env)
+{
+}
+
+void kvm_cpu_synchronize_post_reset(CPUState *env)
+{
+}
+
+void kvm_cpu_synchronize_post_init(CPUState *env)
+{
+}
+
+int kvm_cpu_exec(CPUState *env)
+{
+abort ();
+}
+
+int kvm_has_sync_mmu(void)
+{
+return 0;
+}
+
+int kvm_has_vcpu_events(void)
+{
+return 0;
+}
+
+int kvm_has_robust_singlestep(void)
+{
+return 0;
+}
+
+void kvm_setup_guest_memory(void *start, size_t size)
+{
+}
+
+int kvm_update_guest_debug(CPUState *env, unsigned long reinject_trap)
+{
+tb_flush(env);
+return 0;
+}
+
+int kvm_insert_breakpoint(CPUState *current_env, target_ulong addr,
+  target_ulong len, int type)
+{
+return -EINVAL;
+}
+
+int kvm_remove_breakpoint(CPUState *current_env, target_ulong addr,
+  target_ulong len, int type)
+{
+return -EINVAL;
+}
+
+void kvm_remove_all_breakpoints(CPUState *current_env)
+{
+}
+
+int kvm_set_signal_mask(CPUState *env, const sigset_t *sigset)
+{
+abort();
+}
+
+int kvm_set_ioeventfd_pio_word(int fd, uint16_t addr, uint16_t val, bool 
assign)
+{
+return -ENOSYS;
+}
diff --git a/kvm.h b/kvm.h
index 1e5be27..ea3c97d 100644
--- a/kvm.h
+++ b/kvm.h
@@ -23,8 +23,9 @@
 #include 
 #endif
 
-#ifdef CONFIG_KVM
 extern int kvm_allowed;
+
+#if defined CONFIG_KVM || !defined NEED_CPU_H
 #define kvm_enabled() (kvm_allowed)
 #else
 #define kvm_enabled() (0)
@@ -167,15 +168,7 @@ static inline void cpu_synchronize_post_init(CPUState *env)
 }
 }
 
-#if defined(KVM_IOEVENTFD) && defined(CONFIG_KVM)
-int kvm_set_ioeventfd_pio_word(int fd, uint16_t adr, uint16_t val, bool 
assign);
-#else
-static inline
-int kvm_set_ioeventfd_pio_word(int fd, uint16_t adr, uint16_t val, bool assign)
-{
-return -ENOSYS;
-}
 #endif
 
-#endif
+int kvm_set_ioeventfd_pio_word(int fd, uint16_t adr, uint16_t val, bool 
assign);
 #endif
diff --git a/vl.c b/vl.c
index 6768cf

[Qemu-devel] Re: [PATCH 2/2] Make kvm_enabled unavailable to non-target devices

2010-04-02 Thread Anthony Liguori

On 04/02/2010 11:47 AM, Paolo Bonzini wrote:



+#pragma GCC poison kvm_allowed
+#pragma GCC poison kvm_enabled


  kvm_enabled() is a macro.  I dont' think this poison pragma is 
actually

meaningful.


I'm not familiar with poison pragmas, but actually poisoning only
kvm_allowed didn't work.


Indeed, macro expansions are explicitly allowed to use poisoned 
identifiers (and on the contrary macro names count towards poisoning 
errors).


IMO kvm_allowed should be left unpoisoned.


Interesting, thanks.

Regards,

Anthony Liguori


Paolo






[Qemu-devel] Re: [PATCH 2/2] Make kvm_enabled unavailable to non-target devices

2010-04-02 Thread Paolo Bonzini



+#pragma GCC poison kvm_allowed
+#pragma GCC poison kvm_enabled


  kvm_enabled() is a macro.  I dont' think this poison pragma is actually
meaningful.


I'm not familiar with poison pragmas, but actually poisoning only
kvm_allowed didn't work.


Indeed, macro expansions are explicitly allowed to use poisoned 
identifiers (and on the contrary macro names count towards poisoning 
errors).


IMO kvm_allowed should be left unpoisoned.

Paolo




Re: [Qemu-devel] [PATCH 2/2] Make kvm_enabled unavailable to non-target devices

2010-04-02 Thread Blue Swirl
On 4/2/10, Anthony Liguori  wrote:
> On 04/02/2010 10:46 AM, Blue Swirl wrote:
>
> > Signed-off-by: Blue Swirl
> > ---
> >  hw/acpi.c   |   10 +-
> >  hw/pc.h |2 +-
> >  hw/poison.h |3 +++
> >  3 files changed, 9 insertions(+), 6 deletions(-)
> >
> > diff --git a/hw/acpi.c b/hw/acpi.c
> > index 5c01c2e..7c2b109 100644
> > --- a/hw/acpi.c
> > +++ b/hw/acpi.c
> > @@ -51,7 +51,7 @@ typedef struct PIIX4PMState {
> >  qemu_irq irq;
> >  qemu_irq cmos_s3;
> >  qemu_irq smi_irq;
> > -int kvm_enabled;
> > +int kvm_is_enabled;
> >  } PIIX4PMState;
> >
> >  #define RSM_STS (1<<  15)
> > @@ -482,7 +482,7 @@ static void piix4_reset(void *opaque)
> >  pci_conf[0x5a] = 0;
> >  pci_conf[0x5b] = 0;
> >
> > -if (s->kvm_enabled) {
> > +if (s->kvm_is_enabled) {
> >  /* Mark SMM as already inited (until KVM supports SMM). */
> >  pci_conf[0x5B] = 0x02;
> >  }
> > @@ -502,7 +502,7 @@ static void piix4_powerdown(void *opaque, int irq,
> > int power_failing)
> >
> >  i2c_bus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,
> > qemu_irq sci_irq, qemu_irq cmos_s3, qemu_irq
> smi_irq,
> > -   int kvm_enabled)
> > +   int kvm_is_enabled)
> >  {
> >  PIIX4PMState *s;
> >  uint8_t *pci_conf;
> > @@ -529,8 +529,8 @@ i2c_bus *piix4_pm_init(PCIBus *bus, int devfn,
> > uint32_t smb_io_base,
> >
> >  register_ioport_write(ACPI_DBG_IO_ADDR, 4, 4,
> acpi_dbg_writel, s);
> >
> > -s->kvm_enabled = kvm_enabled;
> > -if (s->kvm_enabled) {
> > +s->kvm_is_enabled = kvm_is_enabled;
> > +if (s->kvm_is_enabled) {
> >  /* Mark SMM as already inited to prevent SMM from running.
> > KVM does not
> >   * support SMM mode. */
> >  pci_conf[0x5B] = 0x02;
> > diff --git a/hw/pc.h b/hw/pc.h
> > index 5f86b37..08a541d 100644
> > --- a/hw/pc.h
> > +++ b/hw/pc.h
> > @@ -92,7 +92,7 @@ int acpi_table_add(const char *table_desc);
> >
> >  i2c_bus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,
> > qemu_irq sci_irq, qemu_irq cmos_s3, qemu_irq
> smi_irq,
> > -   int kvm_enabled);
> > +   int kvm_is_enabled);
> >  void piix4_smbus_register_device(SMBusDevice *dev,
> uint8_t addr);
> >  void piix4_acpi_system_hot_add_init(PCIBus *bus);
> >
> > diff --git a/hw/poison.h b/hw/poison.h
> > index d7db7f4..18b9657 100644
> > --- a/hw/poison.h
> > +++ b/hw/poison.h
> > @@ -46,5 +46,8 @@
> >  #pragma GCC poison CPU_INTERRUPT_VIRQ
> >  #pragma GCC poison CPU_INTERRUPT_NMI
> >
> > +#pragma GCC poison kvm_allowed
> > +#pragma GCC poison kvm_enabled
> >
> >
> >
>
>  kvm_enabled() is a macro.  I dont' think this poison pragma is actually
> meaningful.

I'm not familiar with poison pragmas, but actually poisoning only
kvm_allowed didn't work.




Re: [Qemu-devel] [PATCH 2/2] Make kvm_enabled unavailable to non-target devices

2010-04-02 Thread Anthony Liguori

On 04/02/2010 10:46 AM, Blue Swirl wrote:

Signed-off-by: Blue Swirl
---
  hw/acpi.c   |   10 +-
  hw/pc.h |2 +-
  hw/poison.h |3 +++
  3 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/hw/acpi.c b/hw/acpi.c
index 5c01c2e..7c2b109 100644
--- a/hw/acpi.c
+++ b/hw/acpi.c
@@ -51,7 +51,7 @@ typedef struct PIIX4PMState {
  qemu_irq irq;
  qemu_irq cmos_s3;
  qemu_irq smi_irq;
-int kvm_enabled;
+int kvm_is_enabled;
  } PIIX4PMState;

  #define RSM_STS (1<<  15)
@@ -482,7 +482,7 @@ static void piix4_reset(void *opaque)
  pci_conf[0x5a] = 0;
  pci_conf[0x5b] = 0;

-if (s->kvm_enabled) {
+if (s->kvm_is_enabled) {
  /* Mark SMM as already inited (until KVM supports SMM). */
  pci_conf[0x5B] = 0x02;
  }
@@ -502,7 +502,7 @@ static void piix4_powerdown(void *opaque, int irq,
int power_failing)

  i2c_bus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,
 qemu_irq sci_irq, qemu_irq cmos_s3, qemu_irq smi_irq,
-   int kvm_enabled)
+   int kvm_is_enabled)
  {
  PIIX4PMState *s;
  uint8_t *pci_conf;
@@ -529,8 +529,8 @@ i2c_bus *piix4_pm_init(PCIBus *bus, int devfn,
uint32_t smb_io_base,

  register_ioport_write(ACPI_DBG_IO_ADDR, 4, 4, acpi_dbg_writel, s);

-s->kvm_enabled = kvm_enabled;
-if (s->kvm_enabled) {
+s->kvm_is_enabled = kvm_is_enabled;
+if (s->kvm_is_enabled) {
  /* Mark SMM as already inited to prevent SMM from running.
KVM does not
   * support SMM mode. */
  pci_conf[0x5B] = 0x02;
diff --git a/hw/pc.h b/hw/pc.h
index 5f86b37..08a541d 100644
--- a/hw/pc.h
+++ b/hw/pc.h
@@ -92,7 +92,7 @@ int acpi_table_add(const char *table_desc);

  i2c_bus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,
 qemu_irq sci_irq, qemu_irq cmos_s3, qemu_irq smi_irq,
-   int kvm_enabled);
+   int kvm_is_enabled);
  void piix4_smbus_register_device(SMBusDevice *dev, uint8_t addr);
  void piix4_acpi_system_hot_add_init(PCIBus *bus);

diff --git a/hw/poison.h b/hw/poison.h
index d7db7f4..18b9657 100644
--- a/hw/poison.h
+++ b/hw/poison.h
@@ -46,5 +46,8 @@
  #pragma GCC poison CPU_INTERRUPT_VIRQ
  #pragma GCC poison CPU_INTERRUPT_NMI

+#pragma GCC poison kvm_allowed
+#pragma GCC poison kvm_enabled

   


kvm_enabled() is a macro.  I dont' think this poison pragma is actually 
meaningful.


Regards,

Anthony Liguori


  #endif
  #endif
   






Re: [Qemu-devel] [PATCH] provide opaque CPUState to files that are compiled once

2010-04-02 Thread Anthony Liguori

On 04/02/2010 10:43 AM, Paolo Bonzini wrote:

On 04/02/2010 05:22 PM, Anthony Liguori wrote:


hw/* should never access CPUState.

Can you give examples of when qemu-kvm needs this?


Indirectly via header files.  The problem is that GCC poisoning 
complains on prototypes too.


qemu-kvm.h references CPUState and includes cpu.h, so with the latest 
changes all files that include qemu-kvm.h break, even if they don't 
require qemu-kvm.h.  With this patch they instead get the opaque 
definition via hw/hw.h (which includes cpu-common.h), and qemu-kvm.h 
can avoid including cpu.h.


Another example is the new apic.h file created by Blue Swirl.  It 
references CPUState.  It includes apic_get_irq_delivered, so I placed 
apic_set_irq_delivered there too.  But apic_set_irq_delivered is used 
by i8259.c which is compiled once.


There are other similar cases.  Without something like this patch as a 
stopgap measure, you have to make everything compile again per-target 
which is a huge mess of conflicts.


I'd rather things be compiled per-target than adding a bunch of crud 
everywhere.


Wouldn't it be easier to split up qemu-kvm.h into qemu-kvm-cpu.h and add 
the later include where it's needed (which should be very few places)?


Regards,

Anthony Liguori


Paolo






[Qemu-devel] Re: 452efb didn't show up in the list

2010-04-02 Thread Blue Swirl
On 4/1/10, Artyom Tarasenko  wrote:
> 2010/4/1 Blue Swirl :
>  > Which list?
>
>  This mailing list?
>
>
>  > On 4/1/10, Artyom Tarasenko  wrote:
>  >> and looks wrong or incomplete to me:
>  >>
>  >>  >According to Sun4M System Architecture Manual chapter 5.3.2, a limit
>  >>  >of 0 will not generate interrupts.
>  >>
>  >>  This is indeed correct, but the chapter 5.3.2 also explains why:
>  >>
>  >>  "Setting the limit register to  0  allows the counter to free run. Since 
> the
>  >>  timer always resets to a value of 500 nS after reaching maximum count,
>  >>  there is no match and no interrupts are generated."
>  >>
>  >>  The part about 500 nS (0x0200 in the counter register) and
>  >>  no match seems to be not addressed.
>  >
>  > The 500ns offset part could be addressed by making the timer period
>  > shorter by 1 tick. I doubt such a change would have any visible
>  > difference with QEMU, except that tick count of 0 should never appear
>  > in the counter but it may now.
>
>
> as well as all the other values between 0 and 0x200. But it's less
>  important I guess.
>
>
>  > For the no match part, t->reached should not be set if t->limit == 0.

I think this patch would do what is expected.
From 7ef9679874d24f3062bf64525d9dd13d45dc2f27 Mon Sep 17 00:00:00 2001
From: Blue Swirl 
Date: Fri, 2 Apr 2010 15:54:26 +
Subject: [PATCH] sparc32: improve timer implementation

Timer with zero period (free-run) will never match.

Timer counting starts with tick value of 0x200, not from 0,
so the period must calculated from one tick less than the limit.

Signed-off-by: Blue Swirl 
---
 hw/slavio_timer.c |9 ++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/hw/slavio_timer.c b/hw/slavio_timer.c
index ef36fe4..d787553 100644
--- a/hw/slavio_timer.c
+++ b/hw/slavio_timer.c
@@ -88,8 +88,8 @@ typedef struct TimerContext {
 #define TIMER_MAX_COUNT32  0x7e00ULL
 #define TIMER_REACHED  0x8000
 #define TIMER_PERIOD   500ULL // 500ns
-#define LIMIT_TO_PERIODS(l) ((l) >> 9)
-#define PERIODS_TO_LIMIT(l) ((l) << 9)
+#define LIMIT_TO_PERIODS(l) (((l) >> 9) - 1)
+#define PERIODS_TO_LIMIT(l) (((l) + 1) << 9)
 
 static int slavio_timer_is_user(TimerContext *tc)
 {
@@ -127,7 +127,10 @@ static void slavio_timer_irq(void *opaque)
 
 slavio_timer_get_out(t);
 DPRINTF("callback: count %x%08x\n", t->counthigh, t->count);
-t->reached = TIMER_REACHED;
+/* if limit is 0 (free-run), there will be no match */
+if (t->limit != 0) {
+t->reached = TIMER_REACHED;
+}
 /* there is no interrupt if user timer or free-run */
 if (!slavio_timer_is_user(tc) && t->limit != 0) {
 qemu_irq_raise(t->irq);
-- 
1.5.6.5



Re: [Qemu-devel] [PATCH] provide opaque CPUState to files that are compiled once

2010-04-02 Thread Blue Swirl
On 4/2/10, Paolo Bonzini  wrote:
>
>
> >
> > >  qemu-kvm.h references CPUState and includes cpu.h, so with the latest
> > > changes all files that include qemu-kvm.h break, even if they don't
> require
> > > qemu-kvm.h.  With this patch they instead get the opaque definition via
> > > hw/hw.h (which includes cpu-common.h), and qemu-kvm.h can avoid
> including
> > > cpu.h.
> > >
> >
> > This is why I added #ifndef NEED_CPU_H to kvm.h.
> >
>
>  Yes, but adding NEED_CPU_H everywhere is just as bad, or worse.

I fully agree that devices should not use NEED_CPU_H.

> >
> > >  Another example is the new apic.h file created by Blue Swirl.  It
> > > references CPUState.  It includes apic_get_irq_delivered, so I placed
> > > apic_set_irq_delivered there too.  But apic_set_irq_delivered is used by
> > > i8259.c which is compiled once.
> > >
> >
> > But i8259.c is compiled per target, grep Makefile.target?
> >
>
>  Hmm, that was something else, but apic.h was it. :-)

As a concrete example, qemu-kvm's apic.c and ours differ w.r.t.
CPUState use only in kvm_save/load_lapic. But these functions could
just as easily take APICState* as their parameter and the need to pass
CPUState is gone.




Re: [Qemu-devel] [PATCH] provide opaque CPUState to files that are compiled once

2010-04-02 Thread Paolo Bonzini



  qemu-kvm.h references CPUState and includes cpu.h, so with the latest
changes all files that include qemu-kvm.h break, even if they don't require
qemu-kvm.h.  With this patch they instead get the opaque definition via
hw/hw.h (which includes cpu-common.h), and qemu-kvm.h can avoid including
cpu.h.


This is why I added #ifndef NEED_CPU_H to kvm.h.


Yes, but adding NEED_CPU_H everywhere is just as bad, or worse.


  Another example is the new apic.h file created by Blue Swirl.  It
references CPUState.  It includes apic_get_irq_delivered, so I placed
apic_set_irq_delivered there too.  But apic_set_irq_delivered is used by
i8259.c which is compiled once.


But i8259.c is compiled per target, grep Makefile.target?


Hmm, that was something else, but apic.h was it. :-)

Paolo




Re: [Qemu-devel] [PATCH] provide opaque CPUState to files that are compiled once

2010-04-02 Thread Blue Swirl
On 4/2/10, Paolo Bonzini  wrote:
> On 04/02/2010 05:22 PM, Anthony Liguori wrote:
>
>
> > hw/* should never access CPUState.
> >
> > Can you give examples of when qemu-kvm needs this?
> >
>
>  Indirectly via header files.  The problem is that GCC poisoning complains
> on prototypes too.
>
>  qemu-kvm.h references CPUState and includes cpu.h, so with the latest
> changes all files that include qemu-kvm.h break, even if they don't require
> qemu-kvm.h.  With this patch they instead get the opaque definition via
> hw/hw.h (which includes cpu-common.h), and qemu-kvm.h can avoid including
> cpu.h.

This is why I added #ifndef NEED_CPU_H to kvm.h.

>  Another example is the new apic.h file created by Blue Swirl.  It
> references CPUState.  It includes apic_get_irq_delivered, so I placed
> apic_set_irq_delivered there too.  But apic_set_irq_delivered is used by
> i8259.c which is compiled once.

But i8259.c is compiled per target, grep Makefile.target?

>  There are other similar cases.  Without something like this patch as a
> stopgap measure, you have to make everything compile again per-target which
> is a huge mess of conflicts.

This is wrong. There are lot of other ways to handle the need without
resorting to per-target build.




[Qemu-devel] Re: [PATCH 1/2] Move KVM init to arch_init.c, compile vl.c once

2010-04-02 Thread Paolo Bonzini

On 04/02/2010 05:20 PM, Anthony Liguori wrote:


I didn't do this to compile vl.c once.  I don't care about that.

I did this as an initial step towards having kvm functions stubbed out
for !CONFIG_KVM, instead of relying on GCC performing
dead-code-elimination on kvm_enabled().


I'd prefer a kvm-stub.c implementation as opposed to mixing in
CONFIG_KVM in kvm-all.c


I tried it, but our build system makes it a mess because 
compile-once-only can only be done using what once were static 
libraries.  All files from there are added blindly:


   obj-y += $(addprefix ../, $(common-obj-y))
   obj-y += $(addprefix ../libdis/, $(libdis-y))
   obj-y += $(libobj-y)
   obj-y += $(addprefix $(HWDIR)/, $(hw-obj-y))

I'll try something.

Paolo




[Qemu-devel] [PATCH 2/2] Make kvm_enabled unavailable to non-target devices

2010-04-02 Thread Blue Swirl
Signed-off-by: Blue Swirl 
---
 hw/acpi.c   |   10 +-
 hw/pc.h |2 +-
 hw/poison.h |3 +++
 3 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/hw/acpi.c b/hw/acpi.c
index 5c01c2e..7c2b109 100644
--- a/hw/acpi.c
+++ b/hw/acpi.c
@@ -51,7 +51,7 @@ typedef struct PIIX4PMState {
 qemu_irq irq;
 qemu_irq cmos_s3;
 qemu_irq smi_irq;
-int kvm_enabled;
+int kvm_is_enabled;
 } PIIX4PMState;

 #define RSM_STS (1 << 15)
@@ -482,7 +482,7 @@ static void piix4_reset(void *opaque)
 pci_conf[0x5a] = 0;
 pci_conf[0x5b] = 0;

-if (s->kvm_enabled) {
+if (s->kvm_is_enabled) {
 /* Mark SMM as already inited (until KVM supports SMM). */
 pci_conf[0x5B] = 0x02;
 }
@@ -502,7 +502,7 @@ static void piix4_powerdown(void *opaque, int irq,
int power_failing)

 i2c_bus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,
qemu_irq sci_irq, qemu_irq cmos_s3, qemu_irq smi_irq,
-   int kvm_enabled)
+   int kvm_is_enabled)
 {
 PIIX4PMState *s;
 uint8_t *pci_conf;
@@ -529,8 +529,8 @@ i2c_bus *piix4_pm_init(PCIBus *bus, int devfn,
uint32_t smb_io_base,

 register_ioport_write(ACPI_DBG_IO_ADDR, 4, 4, acpi_dbg_writel, s);

-s->kvm_enabled = kvm_enabled;
-if (s->kvm_enabled) {
+s->kvm_is_enabled = kvm_is_enabled;
+if (s->kvm_is_enabled) {
 /* Mark SMM as already inited to prevent SMM from running.
KVM does not
  * support SMM mode. */
 pci_conf[0x5B] = 0x02;
diff --git a/hw/pc.h b/hw/pc.h
index 5f86b37..08a541d 100644
--- a/hw/pc.h
+++ b/hw/pc.h
@@ -92,7 +92,7 @@ int acpi_table_add(const char *table_desc);

 i2c_bus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,
qemu_irq sci_irq, qemu_irq cmos_s3, qemu_irq smi_irq,
-   int kvm_enabled);
+   int kvm_is_enabled);
 void piix4_smbus_register_device(SMBusDevice *dev, uint8_t addr);
 void piix4_acpi_system_hot_add_init(PCIBus *bus);

diff --git a/hw/poison.h b/hw/poison.h
index d7db7f4..18b9657 100644
--- a/hw/poison.h
+++ b/hw/poison.h
@@ -46,5 +46,8 @@
 #pragma GCC poison CPU_INTERRUPT_VIRQ
 #pragma GCC poison CPU_INTERRUPT_NMI

+#pragma GCC poison kvm_allowed
+#pragma GCC poison kvm_enabled
+
 #endif
 #endif
-- 
1.6.2.4




[Qemu-devel] [PATCH 1/2] Move KVM init to arch_init.c, compile vl.c once

2010-04-02 Thread Blue Swirl
Remove dependency of vl.c to KVM, then we can partially revert
b33612d03540fda7fa67485f1c20395beb7a2bf0.

Signed-off-by: Blue Swirl 
---
 Makefile.objs   |2 +-
 Makefile.target |2 +-
 arch_init.c |5 +
 arch_init.h |1 +
 kvm-all.c   |3 +++
 kvm.h   |8 
 vl.c|   16 +---
 7 files changed, 24 insertions(+), 13 deletions(-)

diff --git a/Makefile.objs b/Makefile.objs
index 11e44a0..cb2ec2c 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -128,7 +128,7 @@ user-obj-y += cutils.o cache-utils.o
 # libhw

 hw-obj-y =
-hw-obj-y += loader.o
+hw-obj-y += vl.o loader.o
 hw-obj-y += virtio.o virtio-console.o
 hw-obj-y += fw_cfg.o pci.o pci_host.o pcie_host.o
 hw-obj-y += watchdog.o
diff --git a/Makefile.target b/Makefile.target
index 167fc8d..2aa02f5 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -161,7 +161,7 @@ endif #CONFIG_BSD_USER
 # System emulator target
 ifdef CONFIG_SOFTMMU

-obj-y = arch_init.o cpus.o monitor.o machine.o gdbstub.o vl.o
+obj-y = arch_init.o cpus.o monitor.o machine.o gdbstub.o
 # virtio has to be here due to weird dependency between PCI and virtio-net.
 # need to fix this properly
 obj-y += virtio-blk.o virtio-balloon.o virtio-net.o virtio-pci.o
virtio-serial-bus.o
diff --git a/arch_init.c b/arch_init.c
index cfc03ea..055e65d 100644
--- a/arch_init.c
+++ b/arch_init.c
@@ -508,3 +508,8 @@ int xen_available(void)
 return 0;
 #endif
 }
+
+int kvm_maybe_init(int smp_cpus)
+{
+return kvm_init(smp_cpus);
+}
diff --git a/arch_init.h b/arch_init.h
index 682890c..52dd327 100644
--- a/arch_init.h
+++ b/arch_init.h
@@ -29,5 +29,6 @@ void cpudef_init(void);
 int audio_available(void);
 int kvm_available(void);
 int xen_available(void);
+int kvm_maybe_init(int smp_cpus);

 #endif
diff --git a/kvm-all.c b/kvm-all.c
index 7aa5e57..dc99aae 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -51,6 +51,8 @@ typedef struct KVMSlot

 typedef struct kvm_dirty_log KVMDirtyLog;

+int kvm_allowed = 0;
+
 struct KVMState
 {
 KVMSlot slots[32];
@@ -670,6 +672,7 @@ int kvm_init(int smp_cpus)

 kvm_state = s;
 cpu_register_phys_memory_client(&kvm_cpu_phys_memory_client);
+kvm_allowed = 1;

 return 0;

diff --git a/kvm.h b/kvm.h
index 1e5be27..979f640 100644
--- a/kvm.h
+++ b/kvm.h
@@ -34,7 +34,15 @@ struct kvm_run;

 /* external API */

+#ifdef CONFIG_KVM
 int kvm_init(int smp_cpus);
+#else
+static inline
+int kvm_init(int smp_cpus)
+{
+return -ENOSYS;
+}
+#endif

 #ifdef NEED_CPU_H
 int kvm_init_vcpu(CPUState *env);
diff --git a/vl.c b/vl.c
index 6768cf1..6958b2c 100644
--- a/vl.c
+++ b/vl.c
@@ -145,7 +145,6 @@ int main(int argc, char **argv)
 #include "dma.h"
 #include "audio/audio.h"
 #include "migration.h"
-#include "kvm.h"
 #include "balloon.h"
 #include "qemu-option.h"
 #include "qemu-config.h"
@@ -241,7 +240,6 @@ uint8_t qemu_uuid[16];
 static QEMUBootSetHandler *boot_set_handler;
 static void *boot_set_opaque;

-int kvm_allowed = 0;
 uint32_t xen_domid;
 enum xen_mode xen_mode = XEN_EMULATE;

@@ -2649,6 +2647,7 @@ int main(int argc, char **argv, char **envp)
 #endif
 int show_vnc_port = 0;
 int defconfig = 1;
+int enable_kvm = 0;

 error_set_progname(argv[0]);

@@ -3239,7 +3238,7 @@ int main(int argc, char **argv, char **envp)
 printf("Option %s not supported for this
target\n", popt->name);
 exit(1);
 }
-kvm_allowed = 1;
+enable_kvm = 1;
 break;
 case QEMU_OPTION_usb:
 usb_enabled = 1;
@@ -3585,14 +3584,9 @@ int main(int argc, char **argv, char **envp)
 exit(1);
 }

-if (kvm_enabled()) {
-int ret;
-
-ret = kvm_init(smp_cpus);
-if (ret < 0) {
-fprintf(stderr, "failed to initialize KVM\n");
-exit(1);
-}
+if (enable_kvm && kvm_maybe_init(smp_cpus) < 0) {
+fprintf(stderr, "failed to initialize KVM\n");
+exit(1);
 }

 if (qemu_init_main_loop()) {
-- 
1.6.2.4




Re: [Qemu-devel] [PATCH] provide opaque CPUState to files that are compiled once

2010-04-02 Thread Paolo Bonzini

On 04/02/2010 05:22 PM, Anthony Liguori wrote:


hw/* should never access CPUState.

Can you give examples of when qemu-kvm needs this?


Indirectly via header files.  The problem is that GCC poisoning 
complains on prototypes too.


qemu-kvm.h references CPUState and includes cpu.h, so with the latest 
changes all files that include qemu-kvm.h break, even if they don't 
require qemu-kvm.h.  With this patch they instead get the opaque 
definition via hw/hw.h (which includes cpu-common.h), and qemu-kvm.h can 
avoid including cpu.h.


Another example is the new apic.h file created by Blue Swirl.  It 
references CPUState.  It includes apic_get_irq_delivered, so I placed 
apic_set_irq_delivered there too.  But apic_set_irq_delivered is used by 
i8259.c which is compiled once.


There are other similar cases.  Without something like this patch as a 
stopgap measure, you have to make everything compile again per-target 
which is a huge mess of conflicts.


Paolo




[Qemu-devel] Re: [PATCH 1/2] Move KVM init to arch_init.c, compile vl.c once

2010-04-02 Thread Blue Swirl
On 4/2/10, Anthony Liguori  wrote:
> On 04/02/2010 10:01 AM, Paolo Bonzini wrote:
>
> > On 04/01/2010 10:27 PM, Blue Swirl wrote:
> >
> > > It will not be safe to use kvm_enabled() in vl.c, so there needs to be
> > > a target dependent helper. The call to kvm_init could remain in vl.c,
> > > likewise it's not strictly needed to move kvm_allowed to arch_init.c.
> > >
> >
> > Not really, because kvm_allowed _can_ be used from once-compiled files.
> The attached patch makes kvm-all.c be compiled always, even if !CONFIG_KVM;
> functions that require kvm are almost always omitted for now (so checking
> kvm_enabled() is required to call them).  However, kvm_init is stubbed so
> that vl.c can call it.
> >
> > In the future we could add more stubbing and ultimately do this
> unconditionally:
> >
> >   #define kvm_enabled() kvm_allowed
> >
> > With this patch vl.c can already be compiled once, but I did not include
> it because it would conflict with my balloon.c series; I'm doing enough
> rebasing these days.  Also, qemu-kvm is a bit behind qemu and all these
> patches are nightmares for the merges, so it's better IMO if things are left
> to calm down a bit.
> >
>
>  Having kvm-all.c compile with and without CONFIG_KVM is pretty ugly IMHO.
>
>  Is compiling vl.c once really that important of a goal?  Wouldn't it be
> better to split bits out of vl.c and have those compile once?  Ideally, vl.c
> should be so small that compiling per-target shouldn't matter.

But the only thing preventing compiling whole vl.c once is just KVM
init. I'll send a new patch, hopefully it's better.




Re: [Qemu-devel] [BREAKAGE] commit 9bc6304c156dcc01c619672ca33d7152bb18bcb9 breaks build

2010-04-02 Thread Anthony Liguori

On 04/02/2010 10:27 AM, Anthony Liguori wrote:


This tap files are a bit odd.  We don't compile tap.o for mingw32 but 
we do compile tap-win32.o so what we need to do is define 
tap_get_vhost_net in tap-win32.c.  Testing a patch right now.


I pushed a fix that does exactly this.

Regards,

Anthony Liguori


Regards,

Anthony Liguori


Stefan











Re: [Qemu-devel] [BREAKAGE] commit 9bc6304c156dcc01c619672ca33d7152bb18bcb9 breaks build

2010-04-02 Thread Anthony Liguori

On 04/02/2010 09:30 AM, Stefan Weil wrote:

Blue Swirl schrieb:
   

On 4/2/10, Roy Tam  wrote:
 

2010/4/2 Anthony Liguori:

   

Try doing a clean build
 

This is a fresh checkout.
   

I can confirm this with mingw32:
LINK sparc64-softmmu/qemu-system-sparc64.exe
virtio-net.o: In function `virtio_net_exit':
/src/qemu/hw/virtio-net.c:943: undefined reference to `_tap_get_vhost_net'
virtio-net.o: In function `virtio_net_save':
/src/qemu/hw/virtio-net.c:719: undefined reference to `_tap_get_vhost_net'
virtio-net.o: In function `virtio_net_reset':
/src/qemu/hw/virtio-net.c:122: undefined reference to `_tap_get_vhost_net'
virtio-net.o: In function `virtio_net_set_status':
/src/qemu/hw/virtio-net.c:863: undefined reference to `_tap_get_vhost_net'
/src/qemu/hw/virtio-net.c:870: undefined reference to `_tap_get_vhost_net'
virtio-net.o:/src/qemu/hw/virtio-net.c:878: more undefined references
to `_tap_get_vhost_net' follow
collect2: ld returned 1 exit status
 

A cross build (mingw32 on debian) also results in this linker error.
The reason is quite simple: tap.o (which provides tap_get_vhost_net)
is only build for posix systems, but not for windows:

Makefile.objs:net-nested-$(CONFIG_POSIX) += tap.o

Changing this does not help because tap.c does not
compile for win32 without errors. Either these errors
have to be fixed, or don't call tap_get_vhost_net when
compiling for win32.
   


This tap files are a bit odd.  We don't compile tap.o for mingw32 but we 
do compile tap-win32.o so what we need to do is define tap_get_vhost_net 
in tap-win32.c.  Testing a patch right now.


Regards,

Anthony Liguori


Stefan



   






Re: [Qemu-devel] [PATCH] provide opaque CPUState to files that are compiled once

2010-04-02 Thread Anthony Liguori

On 04/02/2010 09:45 AM, Paolo Bonzini wrote:

This patch allows to unpoison CPUState and env in once-compiled files.
To achieve this, it defines an opaque struct CPUState in cpu-common.h.
This also requires tweaking the relationship between CPUState and
CPUXYZState in target files.

Unpoisoning env is needed because it is widely used as the name for
CPUState arguments.  This is anyway safe, because references to the
global register variable will not creep into target-independent files.
To this end, the patch rationalizes inclusions at the head of
target-*/exec.h.  All exec.h files now include cpu.h before defining the
global register variable env, so that inclusions from machine-independent
context will error out in cpu.h even before env is defined.
   



hw/* should never access CPUState.

Can you give examples of when qemu-kvm needs this?

Regards,

Anthony Liguori


Signed-off-by: Paolo Bonzini
---
 This patch is helpful for qemu-kvm, because some of the changes
 there use CPUState in hw/* files that are now compiled only
 once.

 It can also be used to compile more files once-only, but I'm
 not doing that here.

  cpu-common.h |3 +++
  cpu-defs.h   |1 +
  hw/poison.h  |3 ---
  target-alpha/cpu.h   |4 +---
  target-alpha/exec.h  |6 ++
  target-arm/cpu.h |6 +++---
  target-arm/exec.h|5 ++---
  target-cris/cpu.h|6 +++---
  target-cris/exec.h   |6 +++---
  target-i386/cpu.h|6 +++---
  target-i386/exec.h   |7 ++-
  target-m68k/cpu.h|6 +++---
  target-m68k/exec.h   |6 +++---
  target-microblaze/cpu.h  |7 +++
  target-microblaze/exec.h |6 +++---
  target-mips/cpu.h|5 +
  target-mips/exec.h   |6 ++
  target-ppc/cpu.h |3 +--
  target-ppc/exec.h|2 --
  target-s390x/cpu.h   |6 +++---
  target-s390x/exec.h  |7 +++
  target-sh4/cpu.h |6 +++---
  target-sh4/exec.h|5 ++---
  target-sparc/cpu.h   |6 +++---
  target-sparc/exec.h  |6 +++---
  25 files changed, 56 insertions(+), 74 deletions(-)

diff --git a/cpu-common.h b/cpu-common.h
index b730ca0..415feb5 100644
--- a/cpu-common.h
+++ b/cpu-common.h
@@ -18,6 +18,9 @@
  #include "bswap.h"
  #include "qemu-queue.h"

+struct CPUState;
+typedef struct CPUState CPUState;
+
  #if !defined(CONFIG_USER_ONLY)

  /* address in the RAM (different from a physical address) */
diff --git a/cpu-defs.h b/cpu-defs.h
index 2e94585..e8da6af 100644
--- a/cpu-defs.h
+++ b/cpu-defs.h
@@ -30,6 +30,7 @@
  #include "osdep.h"
  #include "qemu-queue.h"
  #include "targphys.h"
+#include "cpu-common.h"

  #ifndef TARGET_LONG_BITS
  #error TARGET_LONG_BITS must be defined before including this header
diff --git a/hw/poison.h b/hw/poison.h
index d7db7f4..e7814cb 100644
--- a/hw/poison.h
+++ b/hw/poison.h
@@ -33,9 +33,6 @@
  #pragma GCC poison TARGET_PAGE_BITS
  #pragma GCC poison TARGET_PAGE_ALIGN

-#pragma GCC poison CPUState
-#pragma GCC poison env
-
  #pragma GCC poison CPU_INTERRUPT_HARD
  #pragma GCC poison CPU_INTERRUPT_EXITTB
  #pragma GCC poison CPU_INTERRUPT_TIMER
diff --git a/target-alpha/cpu.h b/target-alpha/cpu.h
index 8afe16d..92283e2 100644
--- a/target-alpha/cpu.h
+++ b/target-alpha/cpu.h
@@ -24,7 +24,7 @@

  #define TARGET_LONG_BITS 64

-#define CPUState struct CPUAlphaState
+#define CPUAlphaState CPUState

  #include "cpu-defs.h"

@@ -317,8 +317,6 @@ enum {
  IPR_LAST,
  };

-typedef struct CPUAlphaState CPUAlphaState;
-
  typedef struct pal_handler_t pal_handler_t;
  struct pal_handler_t {
  /* Reset */
diff --git a/target-alpha/exec.h b/target-alpha/exec.h
index 66526e2..789305f 100644
--- a/target-alpha/exec.h
+++ b/target-alpha/exec.h
@@ -21,8 +21,9 @@
  #define __ALPHA_EXEC_H__

  #include "config.h"
-
  #include "dyngen-exec.h"
+#include "cpu.h"
+#include "exec-all.h"

  #define TARGET_LONG_BITS 64

@@ -32,9 +33,6 @@ register struct CPUAlphaState *env asm(AREG0);
  #define SPARAM(n) ((int32_t)PARAM##n)
  #define FP_STATUS (env->fp_status)

-#include "cpu.h"
-#include "exec-all.h"
-
  #if !defined(CONFIG_USER_ONLY)
  #include "softmmu_exec.h"
  #endif /* !defined(CONFIG_USER_ONLY) */
diff --git a/target-arm/cpu.h b/target-arm/cpu.h
index 3892db4..d068b6e 100644
--- a/target-arm/cpu.h
+++ b/target-arm/cpu.h
@@ -23,7 +23,7 @@

  #define ELF_MACHINE   EM_ARM

-#define CPUState struct CPUARMState
+#define CPUARMState CPUState

  #include "cpu-defs.h"

@@ -70,7 +70,7 @@ struct arm_boot_info;
 s<2n+1>  maps to the most significant half of d
   */

-typedef struct CPUARMState {
+struct CPUARMState {
  /* Regs for current mode.  */
  uint32_t regs[16];
  /* Frequently accessed CPSR bits are stored separately for efficiently.
@@ -206,7 +206,7 @@ typedef struct CPUARMState {

  /* These fields after the common ones so they are preserved on res

[Qemu-devel] Re: [PATCH 1/2] Move KVM init to arch_init.c, compile vl.c once

2010-04-02 Thread Anthony Liguori

On 04/02/2010 10:11 AM, Paolo Bonzini wrote:

On 04/02/2010 05:08 PM, Anthony Liguori wrote:
Having kvm-all.c compile with and without CONFIG_KVM is pretty ugly 
IMHO.


Is compiling vl.c once really that important of a goal?


I didn't do this to compile vl.c once.  I don't care about that.

I did this as an initial step towards having kvm functions stubbed out 
for !CONFIG_KVM, instead of relying on GCC performing 
dead-code-elimination on kvm_enabled().


I'd prefer a kvm-stub.c implementation as opposed to mixing in 
CONFIG_KVM in kvm-all.c


Regards,

Anthony Liguori


Paolo






[Qemu-devel] Re: [PATCH 1/2] Move KVM init to arch_init.c, compile vl.c once

2010-04-02 Thread Paolo Bonzini

On 04/02/2010 05:08 PM, Anthony Liguori wrote:

Having kvm-all.c compile with and without CONFIG_KVM is pretty ugly IMHO.

Is compiling vl.c once really that important of a goal?


I didn't do this to compile vl.c once.  I don't care about that.

I did this as an initial step towards having kvm functions stubbed out 
for !CONFIG_KVM, instead of relying on GCC performing 
dead-code-elimination on kvm_enabled().


Paolo




[Qemu-devel] Re: [PATCH 1/2] Move KVM init to arch_init.c, compile vl.c once

2010-04-02 Thread Anthony Liguori

On 04/02/2010 10:01 AM, Paolo Bonzini wrote:

On 04/01/2010 10:27 PM, Blue Swirl wrote:

It will not be safe to use kvm_enabled() in vl.c, so there needs to be
a target dependent helper. The call to kvm_init could remain in vl.c,
likewise it's not strictly needed to move kvm_allowed to arch_init.c.


Not really, because kvm_allowed _can_ be used from once-compiled 
files.  The attached patch makes kvm-all.c be compiled always, even if 
!CONFIG_KVM; functions that require kvm are almost always omitted for 
now (so checking kvm_enabled() is required to call them).  However, 
kvm_init is stubbed so that vl.c can call it.


In the future we could add more stubbing and ultimately do this 
unconditionally:


   #define kvm_enabled() kvm_allowed

With this patch vl.c can already be compiled once, but I did not 
include it because it would conflict with my balloon.c series; I'm 
doing enough rebasing these days.  Also, qemu-kvm is a bit behind qemu 
and all these patches are nightmares for the merges, so it's better 
IMO if things are left to calm down a bit.


Having kvm-all.c compile with and without CONFIG_KVM is pretty ugly IMHO.

Is compiling vl.c once really that important of a goal?  Wouldn't it be 
better to split bits out of vl.c and have those compile once?  Ideally, 
vl.c should be so small that compiling per-target shouldn't matter.


Regards,

Anthony Liguori


They just caused problems with the poisoning check in patch 2/2.


Poisoning kvm_enabled is right, but poisoning kvm_allowed is overkill.

Paolo






[Qemu-devel] Re: [PATCH 1/2] Move KVM init to arch_init.c, compile vl.c once

2010-04-02 Thread Paolo Bonzini

On 04/01/2010 10:27 PM, Blue Swirl wrote:

It will not be safe to use kvm_enabled() in vl.c, so there needs to be
a target dependent helper. The call to kvm_init could remain in vl.c,
likewise it's not strictly needed to move kvm_allowed to arch_init.c.


Not really, because kvm_allowed _can_ be used from once-compiled files. 
 The attached patch makes kvm-all.c be compiled always, even if 
!CONFIG_KVM; functions that require kvm are almost always omitted for 
now (so checking kvm_enabled() is required to call them).  However, 
kvm_init is stubbed so that vl.c can call it.


In the future we could add more stubbing and ultimately do this 
unconditionally:


   #define kvm_enabled() kvm_allowed

With this patch vl.c can already be compiled once, but I did not include 
it because it would conflict with my balloon.c series; I'm doing enough 
rebasing these days.  Also, qemu-kvm is a bit behind qemu and all these 
patches are nightmares for the merges, so it's better IMO if things are 
left to calm down a bit.



They just caused problems with the poisoning check in patch 2/2.


Poisoning kvm_enabled is right, but poisoning kvm_allowed is overkill.

Paolo
From e9bd21893633365567b7c0d468a9971ab02e46f0 Mon Sep 17 00:00:00 2001
From: Paolo Bonzini 
Date: Fri, 2 Apr 2010 09:29:54 +0200
Subject: [PATCH] provide a stub version of kvm-all.c if !CONFIG_KVM

This allows limited use of kvm functions (which will return ENOSYS)
even in once-compiled modules.  The patch also improves a bit the error
messages for KVM initialization.

Signed-off-by: Paolo Bonzini 
---
 Makefile.target |4 ++--
 kvm-all.c   |   16 ++--
 kvm.h   |4 +++-
 vl.c|   16 +++-
 4 files changed, 26 insertions(+), 14 deletions(-)

diff --git a/Makefile.target b/Makefile.target
index 167fc8d..3943de1 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -168,8 +168,8 @@ obj-y += virtio-blk.o virtio-balloon.o virtio-net.o 
virtio-pci.o virtio-serial-b
 obj-y += event_notifier.o
 obj-y += vhost_net.o
 obj-$(CONFIG_VHOST_NET) += vhost.o
-obj-y += rwhandler.o
-obj-$(CONFIG_KVM) += kvm.o kvm-all.o
+obj-y += rwhandler.o kvm-all.o
+obj-$(CONFIG_KVM) += kvm.o
 LIBS+=-lz
 
 QEMU_CFLAGS += $(VNC_TLS_CFLAGS)
diff --git a/kvm-all.c b/kvm-all.c
index 7aa5e57..53f58a6 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -13,14 +13,16 @@
  *
  */
 
+#include "qemu-common.h"
 #include 
 #include 
 #include 
 #include 
 
+#ifdef CONFIG_KVM
 #include 
+#endif
 
-#include "qemu-common.h"
 #include "qemu-barrier.h"
 #include "sysemu.h"
 #include "hw/hw.h"
@@ -73,6 +75,7 @@ struct KVMState
 
 static KVMState *kvm_state;
 
+#ifdef CONFIG_KVM
 static KVMSlot *kvm_alloc_slot(KVMState *s)
 {
 int i;
@@ -282,7 +285,7 @@ static int kvm_set_migration_log(int enable)
 return 0;
 }
 
-static int test_le_bit(unsigned long nr, unsigned char *addr)
+static inline int test_le_bit(unsigned long nr, unsigned char *addr)
 {
 return (addr[nr >> 3] >> (nr & 7)) & 1;
 }
@@ -561,9 +564,11 @@ static CPUPhysMemoryClient kvm_cpu_phys_memory_client = {
.sync_dirty_bitmap = kvm_client_sync_dirty_bitmap,
.migration_log = kvm_client_migration_log,
 };
+#endif
 
 int kvm_init(int smp_cpus)
 {
+#ifdef CONFIG_KVM
 static const char upgrade_note[] =
 "Please upgrade to at least kernel 2.6.29 or recent kvm-kmod\n"
 "(see http://sourceforge.net/projects/kvm).\n";
@@ -683,8 +688,12 @@ err:
 qemu_free(s);
 
 return ret;
+#else
+return -ENOSYS;
+#endif
 }
 
+#ifdef CONFIG_KVM
 static int kvm_handle_io(uint16_t port, void *data, int direction, int size,
  uint32_t count)
 {
@@ -866,6 +875,7 @@ int kvm_cpu_exec(CPUState *env)
 
 return ret;
 }
+#endif
 
 int kvm_ioctl(KVMState *s, int type, ...)
 {
@@ -1139,6 +1149,7 @@ void kvm_remove_all_breakpoints(CPUState *current_env)
 }
 #endif /* !KVM_CAP_SET_GUEST_DEBUG */
 
+#ifdef CONFIG_KVM
 int kvm_set_signal_mask(CPUState *env, const sigset_t *sigset)
 {
 struct kvm_signal_mask *sigmask;
@@ -1156,6 +1167,7 @@ int kvm_set_signal_mask(CPUState *env, const sigset_t 
*sigset)
 
 return r;
 }
+#endif
 
 #ifdef KVM_IOEVENTFD
 int kvm_set_ioeventfd_pio_word(int fd, uint16_t addr, uint16_t val, bool 
assign)
diff --git a/kvm.h b/kvm.h
index 1e5be27..2477cfd 100644
--- a/kvm.h
+++ b/kvm.h
@@ -18,13 +18,15 @@
 #include 
 #include "config-host.h"
 #include "qemu-queue.h"
+#include "cpu-common.h"
 
 #ifdef CONFIG_KVM
 #include 
 #endif
 
-#ifdef CONFIG_KVM
 extern int kvm_allowed;
+
+#ifdef CONFIG_KVM
 #define kvm_enabled() (kvm_allowed)
 #else
 #define kvm_enabled() (0)
diff --git a/vl.c b/vl.c
index 6768cf1..9fe4682 100644
--- a/vl.c
+++ b/vl.c
@@ -3235,10 +3235,6 @@ int main(int argc, char **argv, char **envp)
 do_smbios_option(optarg);
 break;
 case QEMU_OPTION_enable_kvm:
-if (!(kvm_available())) {
-printf("Option %s not supported for this target\n", 
po

[Qemu-devel] Re: [PATCHv6 03/11] notifier: event notifier implementation

2010-04-02 Thread Paolo Bonzini

On 03/17/2010 12:07 PM, Michael S. Tsirkin wrote:

+{
+#ifdef CONFIG_EVENTFD
+int fd = eventfd(!!active, EFD_NONBLOCK | EFD_CLOEXEC);



+uint64_t value;
+int r = read(e->fd,&value, sizeof(value));
+if (r == sizeof(value)) {
+/* restore previous value. */
+int s = write(e->fd,&value, sizeof(value));
+/* never blocks because we use EFD_SEMAPHORE.


No, we don't...

Also, it seems like this function as it is written now requires blocking 
operation of the eventfd, otherwise it would not be atomic when another 
thread calls event_notifier_test_and_clear.  Which makes everything more 
complicated.


But after all is unused, maybe it should be zapped?

Paolo




[Qemu-devel] [PATCH] provide opaque CPUState to files that are compiled once

2010-04-02 Thread Paolo Bonzini
This patch allows to unpoison CPUState and env in once-compiled files.
To achieve this, it defines an opaque struct CPUState in cpu-common.h.
This also requires tweaking the relationship between CPUState and
CPUXYZState in target files.

Unpoisoning env is needed because it is widely used as the name for
CPUState arguments.  This is anyway safe, because references to the
global register variable will not creep into target-independent files.
To this end, the patch rationalizes inclusions at the head of
target-*/exec.h.  All exec.h files now include cpu.h before defining the
global register variable env, so that inclusions from machine-independent
context will error out in cpu.h even before env is defined.

Signed-off-by: Paolo Bonzini 
---
This patch is helpful for qemu-kvm, because some of the changes
there use CPUState in hw/* files that are now compiled only
once.

It can also be used to compile more files once-only, but I'm
not doing that here.

 cpu-common.h |3 +++
 cpu-defs.h   |1 +
 hw/poison.h  |3 ---
 target-alpha/cpu.h   |4 +---
 target-alpha/exec.h  |6 ++
 target-arm/cpu.h |6 +++---
 target-arm/exec.h|5 ++---
 target-cris/cpu.h|6 +++---
 target-cris/exec.h   |6 +++---
 target-i386/cpu.h|6 +++---
 target-i386/exec.h   |7 ++-
 target-m68k/cpu.h|6 +++---
 target-m68k/exec.h   |6 +++---
 target-microblaze/cpu.h  |7 +++
 target-microblaze/exec.h |6 +++---
 target-mips/cpu.h|5 +
 target-mips/exec.h   |6 ++
 target-ppc/cpu.h |3 +--
 target-ppc/exec.h|2 --
 target-s390x/cpu.h   |6 +++---
 target-s390x/exec.h  |7 +++
 target-sh4/cpu.h |6 +++---
 target-sh4/exec.h|5 ++---
 target-sparc/cpu.h   |6 +++---
 target-sparc/exec.h  |6 +++---
 25 files changed, 56 insertions(+), 74 deletions(-)

diff --git a/cpu-common.h b/cpu-common.h
index b730ca0..415feb5 100644
--- a/cpu-common.h
+++ b/cpu-common.h
@@ -18,6 +18,9 @@
 #include "bswap.h"
 #include "qemu-queue.h"
 
+struct CPUState;
+typedef struct CPUState CPUState;
+
 #if !defined(CONFIG_USER_ONLY)
 
 /* address in the RAM (different from a physical address) */
diff --git a/cpu-defs.h b/cpu-defs.h
index 2e94585..e8da6af 100644
--- a/cpu-defs.h
+++ b/cpu-defs.h
@@ -30,6 +30,7 @@
 #include "osdep.h"
 #include "qemu-queue.h"
 #include "targphys.h"
+#include "cpu-common.h"
 
 #ifndef TARGET_LONG_BITS
 #error TARGET_LONG_BITS must be defined before including this header
diff --git a/hw/poison.h b/hw/poison.h
index d7db7f4..e7814cb 100644
--- a/hw/poison.h
+++ b/hw/poison.h
@@ -33,9 +33,6 @@
 #pragma GCC poison TARGET_PAGE_BITS
 #pragma GCC poison TARGET_PAGE_ALIGN
 
-#pragma GCC poison CPUState
-#pragma GCC poison env
-
 #pragma GCC poison CPU_INTERRUPT_HARD
 #pragma GCC poison CPU_INTERRUPT_EXITTB
 #pragma GCC poison CPU_INTERRUPT_TIMER
diff --git a/target-alpha/cpu.h b/target-alpha/cpu.h
index 8afe16d..92283e2 100644
--- a/target-alpha/cpu.h
+++ b/target-alpha/cpu.h
@@ -24,7 +24,7 @@
 
 #define TARGET_LONG_BITS 64
 
-#define CPUState struct CPUAlphaState
+#define CPUAlphaState CPUState
 
 #include "cpu-defs.h"
 
@@ -317,8 +317,6 @@ enum {
 IPR_LAST,
 };
 
-typedef struct CPUAlphaState CPUAlphaState;
-
 typedef struct pal_handler_t pal_handler_t;
 struct pal_handler_t {
 /* Reset */
diff --git a/target-alpha/exec.h b/target-alpha/exec.h
index 66526e2..789305f 100644
--- a/target-alpha/exec.h
+++ b/target-alpha/exec.h
@@ -21,8 +21,9 @@
 #define __ALPHA_EXEC_H__
 
 #include "config.h"
-
 #include "dyngen-exec.h"
+#include "cpu.h"
+#include "exec-all.h"
 
 #define TARGET_LONG_BITS 64
 
@@ -32,9 +33,6 @@ register struct CPUAlphaState *env asm(AREG0);
 #define SPARAM(n) ((int32_t)PARAM##n)
 #define FP_STATUS (env->fp_status)
 
-#include "cpu.h"
-#include "exec-all.h"
-
 #if !defined(CONFIG_USER_ONLY)
 #include "softmmu_exec.h"
 #endif /* !defined(CONFIG_USER_ONLY) */
diff --git a/target-arm/cpu.h b/target-arm/cpu.h
index 3892db4..d068b6e 100644
--- a/target-arm/cpu.h
+++ b/target-arm/cpu.h
@@ -23,7 +23,7 @@
 
 #define ELF_MACHINEEM_ARM
 
-#define CPUState struct CPUARMState
+#define CPUARMState CPUState
 
 #include "cpu-defs.h"
 
@@ -70,7 +70,7 @@ struct arm_boot_info;
s<2n+1> maps to the most significant half of d
  */
 
-typedef struct CPUARMState {
+struct CPUARMState {
 /* Regs for current mode.  */
 uint32_t regs[16];
 /* Frequently accessed CPSR bits are stored separately for efficiently.
@@ -206,7 +206,7 @@ typedef struct CPUARMState {
 
 /* These fields after the common ones so they are preserved on reset.  */
 struct arm_boot_info *boot_info;
-} CPUARMState;
+};
 
 CPUARMState *cpu_arm_init(const char *cpu_model);
 void arm_translate_init(void);
diff --git a/target-arm/exec.h b/target-arm/exec.h
index 0225c3f..4

Re: [Qemu-devel] [BREAKAGE] commit 9bc6304c156dcc01c619672ca33d7152bb18bcb9 breaks build

2010-04-02 Thread Stefan Weil
Blue Swirl schrieb:
> On 4/2/10, Roy Tam  wrote:
>> 2010/4/2 Anthony Liguori :
>>
>>> Try doing a clean build
>>
>> This is a fresh checkout.
>
> I can confirm this with mingw32:
> LINK sparc64-softmmu/qemu-system-sparc64.exe
> virtio-net.o: In function `virtio_net_exit':
> /src/qemu/hw/virtio-net.c:943: undefined reference to `_tap_get_vhost_net'
> virtio-net.o: In function `virtio_net_save':
> /src/qemu/hw/virtio-net.c:719: undefined reference to `_tap_get_vhost_net'
> virtio-net.o: In function `virtio_net_reset':
> /src/qemu/hw/virtio-net.c:122: undefined reference to `_tap_get_vhost_net'
> virtio-net.o: In function `virtio_net_set_status':
> /src/qemu/hw/virtio-net.c:863: undefined reference to `_tap_get_vhost_net'
> /src/qemu/hw/virtio-net.c:870: undefined reference to `_tap_get_vhost_net'
> virtio-net.o:/src/qemu/hw/virtio-net.c:878: more undefined references
> to `_tap_get_vhost_net' follow
> collect2: ld returned 1 exit status

A cross build (mingw32 on debian) also results in this linker error.
The reason is quite simple: tap.o (which provides tap_get_vhost_net)
is only build for posix systems, but not for windows:

Makefile.objs:net-nested-$(CONFIG_POSIX) += tap.o

Changing this does not help because tap.c does not
compile for win32 without errors. Either these errors
have to be fixed, or don't call tap_get_vhost_net when
compiling for win32.

Stefan





[Qemu-devel] Re: [PATCH 1/2] Move KVM init to arch_init.c, compile vl.c once

2010-04-02 Thread Blue Swirl
On 4/1/10, Paolo Bonzini  wrote:
> On 04/01/2010 10:07 PM, Blue Swirl wrote:
>
> > Remove dependency of vl.c to KVM, then we can partially revert
> > b33612d03540fda7fa67485f1c20395beb7a2bf0.
> >
>
>  This is ugly...
>
>  Michael Tsirkin said in commit ca821806:
>
>   Comment on kvm usage: rather than require users to do if(kvm_enabled())
>   and/or ifdefs, this patch adds an API that, internally, is defined to
>   stub function on non-kvm build, and checks kvm_enabled for non-kvm
>   run.
>
>   While rest of qemu code still uses if (kvm_enabled()), I think this
>   approach is cleaner, and we should convert rest of code to it
>   long term.
>
>  Maybe we can start doing this for kvm_init?

I see now. Yes, this would be better approach, I think this is also
what Anthony proposed.

> > +void enable_kvm(void)
> > +{
> > +kvm_allowed = 1;
> > +}
> >
>
>  If you're adding this, this conditional from vl.c
>
>   if (!(kvm_available())) {
>  printf("Option %s not supported for this target\n", popt->name);
>  exit(1);
>   }
>
>  belongs in arch_init.c too, like in do_smbios_option and
> do_acpitable_option.
>
>  Alternatively, with the approach I gave above, you can test in
> kvm_maybe_init if kvm_init returns -ENOSYS, and print the error above
> instead of "failed to initialize KVM".

Also kvm_allowed could be set in kvm-all.c.




Re: [Qemu-devel] [BREAKAGE] commit 9bc6304c156dcc01c619672ca33d7152bb18bcb9 breaks build

2010-04-02 Thread Blue Swirl
On 4/2/10, Roy Tam  wrote:
> 2010/4/2 Anthony Liguori :
>
> > Try doing a clean build
>
>
> This is a fresh checkout.

I can confirm this with mingw32:
  LINK  sparc64-softmmu/qemu-system-sparc64.exe
virtio-net.o: In function `virtio_net_exit':
/src/qemu/hw/virtio-net.c:943: undefined reference to `_tap_get_vhost_net'
virtio-net.o: In function `virtio_net_save':
/src/qemu/hw/virtio-net.c:719: undefined reference to `_tap_get_vhost_net'
virtio-net.o: In function `virtio_net_reset':
/src/qemu/hw/virtio-net.c:122: undefined reference to `_tap_get_vhost_net'
virtio-net.o: In function `virtio_net_set_status':
/src/qemu/hw/virtio-net.c:863: undefined reference to `_tap_get_vhost_net'
/src/qemu/hw/virtio-net.c:870: undefined reference to `_tap_get_vhost_net'
virtio-net.o:/src/qemu/hw/virtio-net.c:878: more undefined references
to `_tap_get_vhost_net' follow
collect2: ld returned 1 exit status




Re: [Qemu-devel] [BREAKAGE] commit 9bc6304c156dcc01c619672ca33d7152bb18bcb9 breaks build

2010-04-02 Thread Roy Tam
2010/4/2 Anthony Liguori :
> Try doing a clean build

This is a fresh checkout.

>
> On Apr 2, 2010 4:43 AM, "Roy Tam"  wrote:
>
> Config:
>
> Install prefixc:/Program Files/Qemu
> BIOS directoryc:/Program Files/Qemu
> binary directory  c:/Program Files/Qemu
> Source path   /usr/home/User/qemu
> C compilergcc
> Host C compiler   gcc
> CFLAGS-O2 -g
> QEMU_CFLAGS   -m32 -D__USE_MINGW_ANSI_STDIO=1
> -DWIN32_LEAN_AND_MEAN -DWINVER=0x501 -Wold-style-definition -I.
> -I$(SRC_PATH) -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64
> -D_LARGEFILE_SOURCE -Wstrict-prototypes -Wredundant-decls -Wall
> -Wundef -Wendif-labels -Wwrite-strings -Wmissing-prototypes
> -fno-strict-aliasing
> LDFLAGS   -Wl,--warn-common -m32 -g
> make  make
> install   install
> host CPU  i386
> host big endian   no
> target list   i386-softmmu x86_64-softmmu mips64el-softmmu
> tcg debug enabled no
> Mon debug enabled no
> gprof enabled no
> sparse enabledno
> strip binariesyes
> profiler  no
> static build  no
> -Werror enabled   no
> SDL support   yes
> curses supportno
> curl support  no
> check support no
> mingw32 support   yes
> Audio drivers sdl
> Extra audio cards ac97 sb16 adlib
> Block whitelist
> Mixer emulation   no
> VNC TLS support   no
> VNC SASL support  no
> xen support   no
> brlapi supportno
> bluez  supportno
> Documentation yes
> NPTL support  no
> GUEST_BASEyes
> PIE user targets  no
> vde support   no
> IO thread no
> Linux AIO support no
> Install blobs yes
> KVM support   no
> fdt support   no
> preadv supportno
> fdatasync no
> uuid support  no
> vhost-net support no
>
> Error log:
>  LINK  i386-softmmu/qemu.exe
> virtio-net.o: In function `virtio_net_reset':
> C:/msys/home/User/qemu/hw/virtio-net.c:122: undefined reference to
> `tap_get_vhost_net'
> virtio-net.o: In function `virtio_net_get_features':
> C:/msys/home/User/qemu/hw/virtio-net.c:187: undefined reference to
> `tap_get_vhost_net'
> C:/msys/home/User/qemu/hw/virtio-net.c:190: undefined reference to
> `tap_get_vhost_net'
> virtio-net.o: In function `virtio_net_save':
> C:/msys/home/User/qemu/hw/virtio-net.c:719: undefined reference to
> `tap_get_vhost_net'
> virtio-net.o: In function `virtio_net_set_status':
> C:/msys/home/User/qemu/hw/virtio-net.c:863: undefined reference to
> `tap_get_vhost_net'
> virtio-net.o:C:/msys/home/User/qemu/hw/virtio-net.c:870: more
> undefined references to `tap_get_vhost_net' follow
> collect2: ld returned 1 exit status
> make[1]: *** [qemu.exe] Error 1
> make: *** [subdir-i386-softmmu] Error 2
>
>
>




Re: [Qemu-devel] [BREAKAGE] commit 9bc6304c156dcc01c619672ca33d7152bb18bcb9 breaks build

2010-04-02 Thread Anthony Liguori
Try doing a clean build

On Apr 2, 2010 4:43 AM, "Roy Tam"  wrote:

Config:

Install prefixc:/Program Files/Qemu
BIOS directoryc:/Program Files/Qemu
binary directory  c:/Program Files/Qemu
Source path   /usr/home/User/qemu
C compilergcc
Host C compiler   gcc
CFLAGS-O2 -g
QEMU_CFLAGS   -m32 -D__USE_MINGW_ANSI_STDIO=1
-DWIN32_LEAN_AND_MEAN -DWINVER=0x501 -Wold-style-definition -I.
-I$(SRC_PATH) -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64
-D_LARGEFILE_SOURCE -Wstrict-prototypes -Wredundant-decls -Wall
-Wundef -Wendif-labels -Wwrite-strings -Wmissing-prototypes
-fno-strict-aliasing
LDFLAGS   -Wl,--warn-common -m32 -g
make  make
install   install
host CPU  i386
host big endian   no
target list   i386-softmmu x86_64-softmmu mips64el-softmmu
tcg debug enabled no
Mon debug enabled no
gprof enabled no
sparse enabledno
strip binariesyes
profiler  no
static build  no
-Werror enabled   no
SDL support   yes
curses supportno
curl support  no
check support no
mingw32 support   yes
Audio drivers sdl
Extra audio cards ac97 sb16 adlib
Block whitelist
Mixer emulation   no
VNC TLS support   no
VNC SASL support  no
xen support   no
brlapi supportno
bluez  supportno
Documentation yes
NPTL support  no
GUEST_BASEyes
PIE user targets  no
vde support   no
IO thread no
Linux AIO support no
Install blobs yes
KVM support   no
fdt support   no
preadv supportno
fdatasync no
uuid support  no
vhost-net support no

Error log:
 LINK  i386-softmmu/qemu.exe
virtio-net.o: In function `virtio_net_reset':
C:/msys/home/User/qemu/hw/virtio-net.c:122: undefined reference to
`tap_get_vhost_net'
virtio-net.o: In function `virtio_net_get_features':
C:/msys/home/User/qemu/hw/virtio-net.c:187: undefined reference to
`tap_get_vhost_net'
C:/msys/home/User/qemu/hw/virtio-net.c:190: undefined reference to
`tap_get_vhost_net'
virtio-net.o: In function `virtio_net_save':
C:/msys/home/User/qemu/hw/virtio-net.c:719: undefined reference to
`tap_get_vhost_net'
virtio-net.o: In function `virtio_net_set_status':
C:/msys/home/User/qemu/hw/virtio-net.c:863: undefined reference to
`tap_get_vhost_net'
virtio-net.o:C:/msys/home/User/qemu/hw/virtio-net.c:870: more
undefined references to `tap_get_vhost_net' follow
collect2: ld returned 1 exit status
make[1]: *** [qemu.exe] Error 1
make: *** [subdir-i386-softmmu] Error 2


Re: [Qemu-devel] [PATCHv2] usb-bus: fix no params

2010-04-02 Thread Aurelien Jarno
On Tue, Mar 30, 2010 at 09:33:24AM +0800, TeLeMan wrote:
> After commit 702f3e0fb52c124c07f215426eeadb70a716643f, the params is
> nerver NULL. It should check *params instead of params to determine
> whether the params is empty.
> 
> Signed-off-by: TeLeMan 

Thanks, applied.

> ---
>  hw/usb-bus.c |2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/hw/usb-bus.c b/hw/usb-bus.c
> index ce8a694..ee0e9e3 100644
> --- a/hw/usb-bus.c
> +++ b/hw/usb-bus.c
> @@ -299,7 +299,7 @@ USBDevice *usbdevice_create(const char *cmdline)
>  }
> 
>  if (!usb->usbdevice_init) {
> -if (params) {
> +if (*params) {
>  error_report("usbdevice %s accepts no params", driver);
>  return NULL;
>  }
> -- 
> 1.6.5.1.1367.gcd48
> 
> --
> SUN OF A BEACH
> 
> 
> 

-- 
Aurelien Jarno  GPG: 1024D/F1BCDB73
aurel...@aurel32.net http://www.aurel32.net




Re: [Qemu-devel] [PATCH 2/2] VirtIO RNG

2010-04-02 Thread Ian Molton
Jamie Lokier wrote:

> I would hope that the host can rate limit itself without needing apps
> to govern themselves, though.

That depends on the source of the entropy - some sources can, some are
fed to daemons that can, but not all systems have such daemons.

:)

-Ian




Re: [Qemu-devel] [PATCH 2/2] VirtIO RNG

2010-04-02 Thread Ian Molton
Paul Brook wrote:
This patch adds support for virtio-rng. Data is read from a
 chardev and can be either raw entropy or received via the EGD protocol.
>>> I still don't get why you need this at all. It seems like
>>> virtio-serial would already provides everything you need.
>> I guess when virtio-rng was first written, virtio-serial wasn't
>> flexible enough because it didn't support multiple devices 
> 
> That argument no longer holds.

So now everything that looks like a stream of bytes has to use the
virtio-serial code...

Why? Its not like it'll make the rng device any simpler, smaller,
faster, or reduce its dependencies. Virtio is simple enough to begin with!

>> and maybe virtio-rng is still needed to enforce the EGD protocol when that
>> is being used.
> 
> Maybe, though the benefit of having this knowledge in wemu seems somewhat 
> unclear. If we do want it then shouldn't be be implemented as a char device 
> backend, rather than part of a specific serial port implementation?

Be my guest...

> gettimeofday can and does jump arbitrarily. Comparing returned values is 
> almost always wrong.

True, however the worst case is still a very temporary over-alotment of
entropy, which really isn't a problem.

-Ian




Re: [Qemu-devel] [PATCH 2/2] VirtIO RNG

2010-04-02 Thread Ian Molton
Paul Brook wrote:
>>This patch adds support for virtio-rng. Data is read from a chardev
>> and can be either raw entropy or received via the EGD protocol.
> 
> I still don't get why you need this at all. It seems like virtio-serial would 
> already provides everything you need.

Because we need to support the virtio-rng driver as it presently exists
in the linux kernel ?

>> +qemu_gettimeofday(&now);
> 
> Using qemu_gettimeofday is almost certainly wrong, and you want to be using 
> virtual time.

I dont think so. What makes you say that ?

> Plus I'm not convinced this is the right place to enforce rate 
> limiting.

Given that some entropy sources enforce it and some do not, where else
would you suggest it be enforced?

This is now bikeshedding severely. We already had this discussion. I've
already modified the patch to comply with *every single one* of the
requests made of me. Frankly I'm getting fed up, and liable to stop
bothering submitting it at all.

If the patch wasn't going to be accepted in any form, it would have been
a courtesy to have just said it in the first place, rather than string
me along saying "well, it'll be fine if you just do..."

I think it speaks volumes that the kernel side of this patch (which
actually involved a complete rewrite of a chunk of the hwrandom code)
got reviewed, tweaked, and accepted inside a couple of weeks. I guess at
least some of my time spent on this want wasted after all...

-Ian




[Qemu-devel] [BREAKAGE] commit 9bc6304c156dcc01c619672ca33d7152bb18bcb9 breaks build

2010-04-02 Thread Roy Tam
Config:

Install prefixc:/Program Files/Qemu
BIOS directoryc:/Program Files/Qemu
binary directory  c:/Program Files/Qemu
Source path   /usr/home/User/qemu
C compilergcc
Host C compiler   gcc
CFLAGS-O2 -g
QEMU_CFLAGS   -m32 -D__USE_MINGW_ANSI_STDIO=1
-DWIN32_LEAN_AND_MEAN -DWINVER=0x501 -Wold-style-definition -I.
-I$(SRC_PATH) -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64
-D_LARGEFILE_SOURCE -Wstrict-prototypes -Wredundant-decls -Wall
-Wundef -Wendif-labels -Wwrite-strings -Wmissing-prototypes
-fno-strict-aliasing
LDFLAGS   -Wl,--warn-common -m32 -g
make  make
install   install
host CPU  i386
host big endian   no
target list   i386-softmmu x86_64-softmmu mips64el-softmmu
tcg debug enabled no
Mon debug enabled no
gprof enabled no
sparse enabledno
strip binariesyes
profiler  no
static build  no
-Werror enabled   no
SDL support   yes
curses supportno
curl support  no
check support no
mingw32 support   yes
Audio drivers sdl
Extra audio cards ac97 sb16 adlib
Block whitelist
Mixer emulation   no
VNC TLS support   no
VNC SASL support  no
xen support   no
brlapi supportno
bluez  supportno
Documentation yes
NPTL support  no
GUEST_BASEyes
PIE user targets  no
vde support   no
IO thread no
Linux AIO support no
Install blobs yes
KVM support   no
fdt support   no
preadv supportno
fdatasync no
uuid support  no
vhost-net support no

Error log:
  LINK  i386-softmmu/qemu.exe
virtio-net.o: In function `virtio_net_reset':
C:/msys/home/User/qemu/hw/virtio-net.c:122: undefined reference to
`tap_get_vhost_net'
virtio-net.o: In function `virtio_net_get_features':
C:/msys/home/User/qemu/hw/virtio-net.c:187: undefined reference to
`tap_get_vhost_net'
C:/msys/home/User/qemu/hw/virtio-net.c:190: undefined reference to
`tap_get_vhost_net'
virtio-net.o: In function `virtio_net_save':
C:/msys/home/User/qemu/hw/virtio-net.c:719: undefined reference to
`tap_get_vhost_net'
virtio-net.o: In function `virtio_net_set_status':
C:/msys/home/User/qemu/hw/virtio-net.c:863: undefined reference to
`tap_get_vhost_net'
virtio-net.o:C:/msys/home/User/qemu/hw/virtio-net.c:870: more
undefined references to `tap_get_vhost_net' follow
collect2: ld returned 1 exit status
make[1]: *** [qemu.exe] Error 1
make: *** [subdir-i386-softmmu] Error 2




[Qemu-devel] [PATCH] vnc: don't forget to call check_pointer_type_change in pointer_event() and set_encodings().

2010-04-02 Thread Yoshiaki Tamura
The following commit broke the behavior of vnc mouse.
Forgetting to call check_pointer_type_change in pointer_event() and
set_encodings() seems to be the reason.
This patch fix this issue.

commit 37c34d9d5d87ea9d51760310c8863b82cb8c055a
Author: Anthony Liguori 
Date:   Wed Mar 10 09:38:29 2010 -0600

input: make vnc use mouse mode notifiers

When we switch to absolute mode, we send out a notification (if the client
supports it).  Today, we only send this notification when the client sends u
a mouse event and we're in the wrong mode.

Signed-off-by: Anthony Liguori 

---
 vnc.c |4 
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/vnc.c b/vnc.c
index e678fcc..cb4a453 100644
--- a/vnc.c
+++ b/vnc.c
@@ -1480,6 +1480,8 @@ static void pointer_event(VncState *vs, int button_mask, 
int x, int y)
 vs->last_x = x;
 vs->last_y = y;
 }
+
+check_pointer_type_change(&vs->mouse_mode_notifier);
 }
 
 static void reset_keys(VncState *vs)
@@ -1820,6 +1822,8 @@ static void set_encodings(VncState *vs, int32_t 
*encodings, size_t n_encodings)
 break;
 }
 }
+
+check_pointer_type_change(&vs->mouse_mode_notifier);
 }
 
 static void set_pixel_conversion(VncState *vs)
-- 
1.7.0.31.g1df487





Re: [Qemu-devel] Significant performance regression in qemu-system-mips.

2010-04-02 Thread Aurelien Jarno
On Fri, Apr 02, 2010 at 01:42:27AM +0200, Alexander Graf wrote:
> 
> On 01.04.2010, at 15:49, Andreas Färber wrote:
> 
> > 
> > Am 26.03.2010 um 03:44 schrieb Rob Landley:
> > 
> >> According to "qemu-system-ppc -M ?", g3beige is still the default.  The 
> >> mac99
> >> machine is the default for ppc64.  (Are there newworlds that run a 32 bit 
> >> ppc
> >> instead of a 64 bit ppc?)
> > 
> > There are. All G3 and G4 PowerMacs, iMacs, iBooks were ppc32 AFAIK.
> > I changed the ppc64 default to mac99 to get a working default configuration 
> > there.
> 
> I just pushed a fix to OpenBIOS that should make oldworld macs boot again. I 
> tested and verified that it makes -M g3beige work and doesn't break PPC64, 
> both using KVM.
> 

I confirm it fixes the problem, thanks a lot. I have pushed the new
version of OpenBIOS to git HEAD.

-- 
Aurelien Jarno  GPG: 1024D/F1BCDB73
aurel...@aurel32.net http://www.aurel32.net