Re: [Qemu-devel] [PULL 5/8] rdma: core rdma logic

2013-04-16 Thread Paolo Bonzini
Il 16/04/2013 06:49, Paolo Bonzini ha scritto:
  +remote_ram_blocks.num_blocks = remote_ram_blocks.remote_area;
  +remote_ram_blocks.block = (void *) (remote_ram_blocks.num_blocks + 1);
 You cannot do this, it doesn't guarantee that remote_ram_blocks.block is
 correctly aligned.  Please use an extra dummy struct RDMARemoteBlock.
 

Actually you do not need to transmit num_blocks at all, do you?  You can
just use head-len / sizeof(struct RDMARemoteBlock).  Then num_blocks
can stop being a pointer, and remote_area can disappear too.

Paolo



Re: [Qemu-devel] weird behaviour of numlock key

2013-04-16 Thread Gerd Hoffmann
On 04/15/13 17:43, Nikola Ciprich wrote:
 Hi Gerd,
 
 I'm using tigervnc, but the problem occurs also with xrdp vnc2rdp
 proxy..

Do things improve with a gtk-vnc based client?  vinagre or
remote-viewer (comes bundles with recent virt-viewer versions)?

cheers,
  Gerd





[Qemu-devel] [PATCH] ARM Cortex A9 Global Timer

2013-04-16 Thread François Legal
 

Hello, 

I made up this patch to implement the Cortex A9 global timer in
Qemu. 

My patch is based on the Qemu branch maintained by Xilinx for the Zynq.


diff -urN qemu-master/hw/cpu/a9mpcore.c qemu-master.new/hw/cpu/a9mpcore.c
---
qemu-master/hw/cpu/a9mpcore.c 2013-04-08 20:12:33.0 +0200
+++
qemu-master.new/hw/cpu/a9mpcore.c 2013-04-15 12:54:06.0 +0200
@@ -15,6
+15,7 @@
 uint32_t num_cpu;
 MemoryRegion container;
 DeviceState *mptimer;
+
DeviceState *mpgtimer;
 DeviceState *wdt;
 DeviceState *gic;
 DeviceState
*scu;
@@ -31,6 +32,7 @@
 {
 A9MPPrivState *s = FROM_SYSBUS(A9MPPrivState, dev);

SysBusDevice *timerbusdev, *wdtbusdev, *gicbusdev, *scubusdev;
+ SysBusDevice
*gtimerbusdev;
 int i;

 s-gic = qdev_create(NULL, arm_gic);
@@ -50,6 +52,11
@@
 qdev_init_nofail(s-scu);
 scubusdev = SYS_BUS_DEVICE(s-scu);

+
s-mpgtimer = qdev_create(NULL, arm_mp_globaltimer);
+
qdev_prop_set_uint32(s-mpgtimer, num-cpu, s-num_cpu);
+
qdev_init_nofail(s-mpgtimer);
+ gtimerbusdev = SYS_BUS_DEVICE(s-mpgtimer);
+

s-mptimer = qdev_create(NULL, arm_mptimer);
 qdev_prop_set_uint32(s-mptimer,
num-cpu, s-num_cpu);
 qdev_init_nofail(s-mptimer);
@@ -68,8 +75,6 @@
 *
0x0600-0x06ff -- private timers and watchdogs
 * 0x0700-0x0fff -- nothing
 *
0x1000-0x1fff -- GIC Distributor
- *
- * We should implement the global timer
but don't currently do so.
 */
 memory_region_init(s-container,
a9mp-priv-container, 0x2000);
 memory_region_add_subregion(s-container,
0,
@@ -80,6 +85,8 @@
 /* Note that the A9 exposes only the timer/watchdog for
this core
 * memory region, not the timer/watchdog for core X ones 11MPcore
has.
 */
+ memory_region_add_subregion(s-container, 0x200,
+
sysbus_mmio_get_region(gtimerbusdev, 0));

memory_region_add_subregion(s-container, 0x600,

sysbus_mmio_get_region(timerbusdev, 0));

memory_region_add_subregion(s-container, 0x620,
@@ -90,10 +97,13 @@

sysbus_init_mmio(dev, s-container);

 /* Wire up the interrupt from each
watchdog and timer.
- * For each core the timer is PPI 29 and the watchdog PPI
30.
+ * For each core the global timer is PPI 27, the private
+ * timer is PPI
29 and the watchdog PPI 30.
 */
 for (i = 0; i  s-num_cpu; i++) {
 int ppibase
= (s-num_irq - 32) + i * 32;
+ sysbus_connect_irq(gtimerbusdev, i,
+
qdev_get_gpio_in(s-gic, ppibase + 27));
 sysbus_connect_irq(timerbusdev, i,

qdev_get_gpio_in(s-gic, ppibase + 29));
 sysbus_connect_irq(wdtbusdev, i,
diff
-urN qemu-master/hw/timer/arm_mpgtimer.c
qemu-master.new/hw/timer/arm_mpgtimer.c
--- qemu-master/hw/timer/arm_mpgtimer.c
1970-01-01 01:00:00.0 +0100
+++ qemu-master.new/hw/timer/arm_mpgtimer.c
2013-04-15 13:56:23.0 +0200
@@ -0,0 +1,359 @@
+/*
+ * Global peripheral
timer block for ARM 11MPCore and A9MP
+ *
+ * Written by François LEGAL
+ *
+ *
This program is free software; you can redistribute it and/or
+ * modify it
under the terms of the GNU General Public License
+ * as published by the Free
Software Foundation; either version
+ * 2 of the License, or (at your option)
any later version.
+ *
+ * This program is distributed in the hope that it will
be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General
Public License for more details.
+ *
+ * You should have received a copy of the
GNU General Public License along
+ * with this program; if not, see
http://www.gnu.org/licenses/.
+ */
+
+#include hw/sysbus.h
+#include
qemu/timer.h
+
+/* This device implements the per-cpu private timer and
watchdog block
+ * which is used in both the ARM11MPCore and Cortex-A9MP.
+
*/
+
+#define MAX_CPUS 4
+
+/* State of a single gtimer or block */
+typedef
struct {
+ uint32_t control;
+ uint64_t compare;
+ uint32_t inc;
+ uint32_t
status;
+ int64_t tick;
+
+ int64_t delta;
+ uint64_t *gtimer_counter;
+
uint32_t *gtimer_control;
+
+ QEMUTimer *timer;
+ MemoryRegion iomem;
+ qemu_irq
irq;
+} gTimerBlock;
+
+typedef struct {
+ SysBusDevice busdev;
+ uint32_t
num_cpu;
+ uint64_t gtimer_counter;
+ uint32_t gtimer_control;
+ gTimerBlock
gtimer[MAX_CPUS];
+ MemoryRegion iomem;
+} ARMMPGTimerState;
+
+static inline
int get_current_cpu(ARMMPGTimerState *s)
+{
+ CPUState *cpu_single_cpu;
+
+ if
(cpu_single_env != NULL) {
+ cpu_single_cpu = ENV_GET_CPU(cpu_single_env);
+
+
if (cpu_single_cpu-cpu_index = s-num_cpu) {
+ hw_error(arm_mptimer: num-cpu
%d but this cpu is %d!n,
+ s-num_cpu, cpu_single_cpu-cpu_index);
+ }
+ return
cpu_single_cpu-cpu_index;
+ } else {
+ return 0;
+ }
+}
+
+static inline void
gtimerblock_update_irq(gTimerBlock *gtb)
+{
+ qemu_set_irq(gtb-irq,
gtb-status);
+}
+
+/* Return conversion factor from mpcore timer ticks to qemu
timer ticks. */
+static inline uint32_t gtimerblock_scale(gTimerBlock *gtb)
+{
+
return *gtb-gtimer_control)  8)  0xff) + 1) * 10;
+}
+
+static void
gtimerblock_reload(gTimerBlock *gtb, int restart)
+{
+ if (restart) {
+
gtb-tick = qemu_get_clock_ns(vm_clock);
+ gtb-tick += (int64_t)(((gtb-compare
- 

[Qemu-devel] [Bug 1169049] [NEW] do not stop on first gdb breakpoint with -enable-kvm

2013-04-16 Thread skovalev
Public bug reported:

I run qemu like this:
  qemu-system-x86-64 -enable-kvm -hda path to file -s -S,

and start gdb with commands like this:
  gdbtartget remote localhost:1234
  gdbbreak *0x7c00
  gdbc

but gdb don't stop on it. I then could break execution manually and then
breakpoints work.

QEMU version: 1.4.0 (from Debian repos)
GDB version: 7.5.1 (copiled from sources, but previous was 7.4.1 from Debian 
repo)

PS Same problem occure on Ubuntu 13.04 with same Qemu and Gdb 7.5.0 from
repo.

Thank you

** Affects: qemu
 Importance: Undecided
 Status: New


** Tags: breakpoints gdb kvm

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1169049

Title:
  do not stop on first gdb breakpoint with -enable-kvm

Status in QEMU:
  New

Bug description:
  I run qemu like this:
qemu-system-x86-64 -enable-kvm -hda path to file -s -S,

  and start gdb with commands like this:
gdbtartget remote localhost:1234
gdbbreak *0x7c00
gdbc

  but gdb don't stop on it. I then could break execution manually and
  then breakpoints work.

  QEMU version: 1.4.0 (from Debian repos)
  GDB version: 7.5.1 (copiled from sources, but previous was 7.4.1 from Debian 
repo)

  PS Same problem occure on Ubuntu 13.04 with same Qemu and Gdb 7.5.0
  from repo.

  Thank you

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1169049/+subscriptions



[Qemu-devel] SoC Idea: Xbox target

2013-04-16 Thread Niel van der Westhuizen
Hey,

So I've been lazily hacking away on https://github.com/espes/xqemu for the
last few months. It's a target for the original Xbox in Qemu - it's kind of
a neat fit, since the Xbox was mostly an nForce 420 PC. It'd be awesome to
have helping out on this as a listed Summer of Code project idea. (mainly
so I could apply for it ;)

Thing is, for this to be a Qemu project it'd need to be viable to be merged
into Qemu eventually. Unfortunately so far my implementation has been far
from clean-room, which could possibly be risky legally, I dono:
-The binaries I've been referencing while reverse engineering are from
the Xbox development kit software (since they conveniently include symbols)
that, while mostly widely available, aren't exactly public.
-The current implementation of the GPU (
https://github.com/espes/xqemu/blob/xbox/hw/nv2a.c) and APU (
https://github.com/espes/xqemu/blob/xbox/hw/mcpx_apu.c) use register
names verbatim from a leaked register listing. If it makes a difference,
most of the GPU names could already be figured out from a combination of
registers documented in nouveau, registers listed in Dxbx (another Xbox
emulator, uNV2A.pas), a published register listing found in an old nvidia
sdk (nv10reg.h), and enums in the debug files in the Xbox development kit
software.

Oh, and someone would need to be found as a mentor.

Thoughts?

Many thanks,
Niel


[Qemu-devel] Qemu redirection option behave differently on Linux and Windows

2013-04-16 Thread Taimoor Mirza
Hi Everyone,
I am trying to use QEMU's port forwarding option with my application and have 
observed following difference in behaviour on Windows and Linux:
* If I relaunch QEMU with same host and guest port redirection values on Linux, 
it throws following error:qemu-system-arm: could not set up host forwarding 
rule 'tcp:8080::8080'qemu-system-arm: Device 'user' could not be initialized
This makes sense as first launch of QEMU creates a socket and binds it to host 
port 8080 and starts listening for connection. So any subsequent request to 
bind to same port fails that results in host forwarding rule error.
* But If I relaunch QEMU with same host and guest port redirection values on 
Windows, it does not throw any error and second launch also gets successful. 
But connection requests are only received by first launch's socket and second 
launch does not get any connection requests.
I looked at QEMU source code and found out that it sets SO_REUSEADDR socket 
option before binding to host port. It looks to me that behavior of 
SO_REUSEADDR option is different on Windows and Linux. 
On Windows, As per MSDN, “The SO_REUSEADDR socket option allows a socket to
forcibly bind to a port in use by another socket. The second socket calls 
setsockopt with the optname parameter set to SO_REUSEADDR and the optval 
parameter set to a boolean value of TRUE before calling bind on the same port 
as the original
socket. Once the second socket has successfully bound, the behavior for all
sockets bound to that port is indeterminate. For example, if all of the sockets
on the same port provide TCP service, any incoming TCP connection requests over
the port cannot be guaranteed to be handled by the correct socket — the
behavior is non-deterministic. “
Whereas on Linux, SO_REUSEADDR socket option, which explicitly allows a 
process to bind to a
port which remains in TIME_WAIT (it still only allows a single process to be 
bound to that
port). The bind function fails to operate properly when the server
terminates and we try to restart it immediately. Normally, the implementation
of TCP will prevent us from binding the same address until a timeout expires,
which is usually on the order of several minutes. Luckily, the SO_REUSEADDR 
socket option allows us to bypass this.
Is it expected behaviour?
Thanks,Taimoor

  

Re: [Qemu-devel] USB2.0 disk format failure in windows guest

2013-04-16 Thread Alan Stern
On Sun, 14 Apr 2013, Gonglei (Arei) wrote:

   Hi Alan,
   We pass-throughed USB 2.0 disk to guest using usb-host (qemu option:
  -device usb-ehci,id=ehci -device usb-host,bus=ehci.0,hostbus=2,hostport=1) 
  on
  KVM(on linux-3.8.3 or linux-3.0.13) and qemu 1.4.0 ,
  
  Are you sure this disk was using EHCI?  The attached log shows bulk
  packet sizes that aren't multiples of 512, which isn't possible in the
  middle of a high-speed transfer.
 
 Yes, this disk was using EHCI, since guest QEMU and Linux kernel both
 prints matching EHCI logs, such as transfer types and transfer sizes.
 There are many buck-out URBs whose sizes are 31 or 4064 that are not
 multiples of 512. Since URB size 31 does occur without guest format
 USB 2.0 disk sceneiro, did you mean that buck-out size 4064 should
 not occur? /* EHCI spec version 1.0 Section 4.10.6 */

That's right; it should not occur.

It's okay to have an URB size that isn't a multiple of 512 if that URB
is the last one in a transfer.  For example, the 31-byte URBs were the
only URBs in their transfers, so they were okay.  But the 4064-byte
URBs occurred at the start and in the middle of their transfers, so
they were wrong.

  What kernel version did you use while recording this log?
 
 We tested KVM on Linux 3.8.3 and Linux 3.0.13, and the problem exists
 on both kernels.

But which kernel version did you use while recording the log that you 
posted?

Also, what type of computer is your host?

 This time we attached a usbmon USB disk format failed log and
 USBlyzer' logs for another test. Would you give us some advice,
 thanks a lot!
 
 Something look like:
 
 88180b974600 480512312 S Bo:6:009:2 -115 31 = 55534243 50599784 0100 
 0a2a 0008 de80  00
 88180b974600 480512375 C Bo:6:009:2 0 31 
 88180b974600 480513372 S Bo:6:009:2 -115 4064 = f80f ff0f 
 ff0f     

This is a lot more concise than the other log, but it still shows the 
same problem: the 4064-byte URB.

Can you post the contents of the /sys/kernel/debug/usb/devices file?

Alan Stern




Re: [Qemu-devel] weird behaviour of numlock key

2013-04-16 Thread Nikola Ciprich
Hi Gerd,

 Do things improve with a gtk-vnc based client?  vinagre or
 remote-viewer (comes bundles with recent virt-viewer versions)?

tried vinagre now, same result...

nik


 
 cheers,
   Gerd
 
 

-- 
-
Ing. Nikola CIPRICH
LinuxBox.cz, s.r.o.
28.rijna 168, 709 00 Ostrava

tel.:   +420 591 166 214
fax:+420 596 621 273
mobil:  +420 777 093 799
www.linuxbox.cz

mobil servis: +420 737 238 656
email servis: ser...@linuxbox.cz
-


pgpkOceuHB5AT.pgp
Description: PGP signature


Re: [Qemu-devel] Support for VNC LED state extension proposal

2013-04-16 Thread Gerd Hoffmann
  Hi,

 What is your vnc client?  Does it support VNC_ENCODING_EXT_KEY_EVENT?
 
 It's uses gvnc as a protocol library and renders via fbdev.  It reads
 keyboard events by putting /dev/tty into mediumraw mode and uses ext key
 events exclusively.  It has no knowledge of the guest keymap.

Neat.  URL?

Does the linux kernel keep track of {caps,num}lock state (+leds) with
the keyboard in mediumraw mode?  Or does it expect the userspace app set
the led state then?

No UI client (neither vnc nor spice) knows the guest keymap btw.

 I believe VMware already has a VNC extension for passing LED state
 changes and I think having an open extension for this is a Good Thing.
 It's a pretty obvious missing piece in the VNC protocol.

Anyone tried to bug vmware to open the specs for the existing extension?

cheers,
  Gerd





Re: [Qemu-devel] [qemu-devel] Bug Report: VM crashed for some kinds of vCPU in nested virtualization

2013-04-16 Thread Jan Kiszka
On 2013-04-16 05:49, 李春奇 Arthur Chunqi Li wrote:
 I changed to the latest version of kvm kernel but the bug also occured.
 
 On the startup of L1 VM on the host, the host kern.log will output:
 Apr 16 11:28:22 Blade1-02 kernel: [ 4908.458090] kvm [2808]: vcpu0
 unhandled rdmsr: 0x345
 Apr 16 11:28:22 Blade1-02 kernel: [ 4908.458166] kvm_set_msr_common: 22
 callbacks suppressed
 Apr 16 11:28:22 Blade1-02 kernel: [ 4908.458169] kvm [2808]: vcpu0
 unhandled wrmsr: 0x40 data 0
 Apr 16 11:28:22 Blade1-02 kernel: [ 4908.458176] kvm [2808]: vcpu0
 unhandled wrmsr: 0x60 data 0
 Apr 16 11:28:22 Blade1-02 kernel: [ 4908.458182] kvm [2808]: vcpu0
 unhandled wrmsr: 0x41 data 0
 Apr 16 11:28:22 Blade1-02 kernel: [ 4908.458188] kvm [2808]: vcpu0
 unhandled wrmsr: 0x61 data 0
 Apr 16 11:28:22 Blade1-02 kernel: [ 4908.458194] kvm [2808]: vcpu0
 unhandled wrmsr: 0x42 data 0
 Apr 16 11:28:22 Blade1-02 kernel: [ 4908.458200] kvm [2808]: vcpu0
 unhandled wrmsr: 0x62 data 0
 Apr 16 11:28:22 Blade1-02 kernel: [ 4908.458206] kvm [2808]: vcpu0
 unhandled wrmsr: 0x43 data 0
 Apr 16 11:28:22 Blade1-02 kernel: [ 4908.458211] kvm [2808]: vcpu0
 unhandled wrmsr: 0x63 data 0
 Apr 16 11:28:23 Blade1-02 kernel: [ 4908.471014] kvm [2808]: vcpu1
 unhandled wrmsr: 0x40 data 0
 Apr 16 11:28:23 Blade1-02 kernel: [ 4908.471024] kvm [2808]: vcpu1
 unhandled wrmsr: 0x60 data 0
 
 When L1 VM starts and crashes, its kern.log will output:
 Apr 16 11:28:55 kvm1 kernel: [   33.590101] device tap0 entered promiscuous
 mode
 Apr 16 11:28:55 kvm1 kernel: [   33.590140] br0: port 2(tap0) entered
 forwarding state
 Apr 16 11:28:55 kvm1 kernel: [   33.590146] br0: port 2(tap0) entered
 forwarding state
 Apr 16 11:29:04 kvm1 kernel: [   42.592103] br0: port 2(tap0) entered
 forwarding state
 Apr 16 11:29:19 kvm1 kernel: [   57.752731] kvm [1673]: vcpu0 unhandled
 rdmsr: 0x345
 Apr 16 11:29:19 kvm1 kernel: [   57.797261] kvm [1673]: vcpu0 unhandled
 wrmsr: 0x40 data 0
 Apr 16 11:29:19 kvm1 kernel: [   57.797315] kvm [1673]: vcpu0 unhandled
 wrmsr: 0x60 data 0
 Apr 16 11:29:19 kvm1 kernel: [   57.797366] kvm [1673]: vcpu0 unhandled
 wrmsr: 0x41 data 0
 Apr 16 11:29:19 kvm1 kernel: [   57.797416] kvm [1673]: vcpu0 unhandled
 wrmsr: 0x61 data 0
 Apr 16 11:29:19 kvm1 kernel: [   57.797466] kvm [1673]: vcpu0 unhandled
 wrmsr: 0x42 data 0
 Apr 16 11:29:19 kvm1 kernel: [   57.797516] kvm [1673]: vcpu0 unhandled
 wrmsr: 0x62 data 0
 Apr 16 11:29:19 kvm1 kernel: [   57.797566] kvm [1673]: vcpu0 unhandled
 wrmsr: 0x43 data 0
 Apr 16 11:29:19 kvm1 kernel: [   57.797616] kvm [1673]: vcpu0 unhandled
 wrmsr: 0x63 data 0
 
 The host will output simultaneously:
 Apr 16 11:29:20 Blade1-02 kernel: [ 4966.314742] nested_vmx_run: VMCS
 MSR_{LOAD,STORE} unsupported

That's an important information. KVM is not yet implementing this
feature, but L1 is using it - doomed to fail. This feature gap of nested
VMX needs to be closed at some point.

 
 And the callback trace displayed on the console is the same as the previous
 mail.
 
 Besides, the L1 and L2 guest may sometimes crash and output nothing, while
 sometimes it will output as above.
 
 
 So this indicates that the msr controls may fail for core2duo CPU emulator.
 

Maybe varying the CPU type (try e.g. -cpu kvm64,+vmx) reduces the
likeliness of this scenario with KVM as guest.

 
 For Jan,
 I have traced the code of qemu and KVM and found the relevant code of errno
 KVM: entry failed, hardware error 0x7. The relevant code is in kernel
 arch/x86/kvm/vmx.c, function vmx_handle_exit():
 
 if (exit_reason  VMX_EXIT_REASONS_FAILED_VMENTRY) {
 vcpu-run-exit_reason = KVM_EXIT_FAIL_ENTRY;
 vcpu-run-fail_entry.hardware_entry_failure_reason
 = exit_reason;
 return 0;
 }
 
 if (unlikely(vmx-fail)) {
 vcpu-run-exit_reason = KVM_EXIT_FAIL_ENTRY;
 vcpu-run-fail_entry.hardware_entry_failure_reason
 = vmcs_read32(VM_INSTRUCTION_ERROR);
 return 0;
 }
 
 The entry failed hardware error may be caused from these two points, both
 are caused by VMENTRY failed. Because macro VMX_EXIT_REASONS_FAILED_VMENTRY
 is 0x8000 and the output errno is 0x7, so this error is caused by the
 second branch. I'm not very clear what the result of
 vmcs_read32(VM_INSTRUCTION_ERROR) refers to.

Try to look this up in the Intel manual. It explains what instruction
error 7 means. You will also find it when tracing down the error message
of L0.

Jan




signature.asc
Description: OpenPGP digital signature


Re: [Qemu-devel] [PATCH] monitor: fix the wrong order of releasing keys

2013-04-16 Thread Markus Armbruster
Amos Kong ak...@redhat.com writes:

 (qemu) sendkey ctrl_r-scroll_lock-scroll_lock

 Executing this command could not let Windows guest panic, it caused by

could not?

 the wrong order of releasing keys. This problem was introduced by
 commit e4c8f004c55d9da3eae3e14df740238bf805b5d6.

 The right release order should be starting from last item.

 Signed-off-by: Amos Kong ak...@redhat.com
 ---
  ui/input.c |8 +++-
  1 files changed, 3 insertions(+), 5 deletions(-)

 diff --git a/ui/input.c b/ui/input.c
 index 9abef0c..ecfeb43 100644
 --- a/ui/input.c
 +++ b/ui/input.c
 @@ -234,13 +234,11 @@ static void free_keycodes(void)
  
  static void release_keys(void *opaque)
  {
 -int i;
 -
 -for (i = 0; i  keycodes_size; i++) {
 -if (keycodes[i]  0x80) {
 +while (keycodes_size  0) {
 +if (keycodes[--keycodes_size]  0x80) {
  kbd_put_keycode(0xe0);
  }
 -kbd_put_keycode(keycodes[i]| 0x80);
 +kbd_put_keycode(keycodes[keycodes_size] | 0x80);
  }
  
  free_keycodes();



Re: [Qemu-devel] [BUG latest master] - qemu segfaults when issuing screendump cmd

2013-04-16 Thread Gerd Hoffmann
On 04/15/13 18:49, Lucas Meneghel Rodrigues wrote:
 Latest qemu.git master is failing big time to pass sanity checks:
 
 https://bugs.launchpad.net/qemu/+bug/1169254
 
 We've had some issues with the test jobs, and finally managed to
 stabilize the grid, so we don't have results for the last couple of
 weeks to bisect the problem.

Can you try this?
  git://git.kraxel.org/qemu rebase/pixman

[ I'm about to prepare a pull req, was planning
   to do it last week but got sick ... ]

cheers,
  Gerd




Re: [Qemu-devel] [PATCH 16/18] console: stop using DisplayState in gfx hardware emulation

2013-04-16 Thread Gerd Hoffmann
On 04/10/13 10:31, Jan Kiszka wrote:
 On 2013-04-03 13:50, Gerd Hoffmann wrote:
   Hi,

 No, it is not, and yes, this is where the inconsistency comes 
 from.  We read wred+wgreen+wblue directly from the surface 
 whereas depth is cached in the vmware vga state struct.  Patch 
 attached.  Not fully tested yet.

 Unfortunately, this doesn't change the picture (except for the 
 expected vmsvga_value_read: Bad register 1c). The 0x315 
 workaround does indeed work.

 Hmm, the patch fixes it for me (boot vesafb with 800x600 or 1024x768 @
 16bpp, Xorg starts successfully) ...

 Can I get a full X server log?
 
 Here is the one without the patch (it no longer applies). If you want me
 to rerun with that patch, please provide an update.

Pushed latest pixman bits (including vmware fixes) to
   git://git.kraxel.org/qemu rebase/pixman

Should be working fine again.

cheers,
  Gerd





Re: [Qemu-devel] [PATCH] Added cleanup for Win32 TAP interface

2013-04-16 Thread Pavel Dovgaluk
Hello!

 From: Stefan Weil [mailto:s...@weilnetz.de]
 Am 15.04.2013 17:55, schrieb Paolo Bonzini:
  Il 13/03/2013 13:23, Pavel Dovgaluk ha scritto:
  Added cleanup for Win32 TAP interface. Signed-off-by: Pavel
  Dovgalyukpavel.dovga...@gmail.com
  Stefan, did this slip? Paolo
 
 Yes, I had not noticed this patch before. But there was a comment
 from Stefan H. which is still unanswered. See
 
 https://lists.gnu.org/archive/html/qemu-devel/2013-03/msg02185.html
 
 Pavel, please have a look on that mail and send an update of your patch.
 Please cc me for w32/w64 related patches.

  I've read this comment and I plan to rewrite the patch later, 
but is not the highest priority task (as ROR bug).
  I'll send you an update after finishing it.

Pavel Dovgaluk




Re: [Qemu-devel] [PATCH] Added cleanup for Win32 TAP interface

2013-04-16 Thread Stefan Hajnoczi
On Mon, Apr 15, 2013 at 08:32:06PM +0200, Stefan Weil wrote:
 Am 15.04.2013 17:55, schrieb Paolo Bonzini:
 Il 13/03/2013 13:23, Pavel Dovgaluk ha scritto:
 Added cleanup for Win32 TAP interface. Signed-off-by: Pavel
 Dovgalyukpavel.dovga...@gmail.com
 Stefan, did this slip? Paolo
 
 
 Yes, I had not noticed this patch before. But there was a comment
 from Stefan H. which is still unanswered. See
 
 https://lists.gnu.org/archive/html/qemu-devel/2013-03/msg02185.html
 
 Pavel, please have a look on that mail and send an update of your patch.
 Please cc me for w32/w64 related patches.

I reviewed the patch, replied (see Stefan Weil's link) and didn't see an
updated patch after that.

Stefan



Re: [Qemu-devel] Qemu redirection option behave differently on Linux and Windows

2013-04-16 Thread Markus Armbruster
Taimoor Mirza mooni_mi...@hotmail.com writes:

 Hi Everyone,
 I am trying to use QEMU's port forwarding option with my application
 and have observed following difference in behaviour on Windows and
 Linux:
 * If I relaunch QEMU with same host and guest port redirection values
 on Linux, it throws following error:qemu-system-arm: could not set up
 host forwarding rule 'tcp:8080::8080'qemu-system-arm: Device 'user'
 could not be initialized
 This makes sense as first launch of QEMU creates a socket and binds it
 to host port 8080 and starts listening for connection. So any
 subsequent request to bind to same port fails that results in host
 forwarding rule error.
 * But If I relaunch QEMU with same host and guest port redirection
 values on Windows, it does not throw any error and second launch also
 gets successful. But connection requests are only received by first
 launch's socket and second launch does not get any connection
 requests.
 I looked at QEMU source code and found out that it sets SO_REUSEADDR
 socket option before binding to host port. It looks to me that
 behavior of SO_REUSEADDR option is different on Windows and Linux.
 On Windows, As per MSDN, “The SO_REUSEADDR socket option allows a socket to
 forcibly bind to a port in use by another socket. The second socket
 calls setsockopt with the optname parameter set to SO_REUSEADDR and
 the optval parameter set to a boolean value of TRUE before calling
 bind on the same port as the original
 socket. Once the second socket has successfully bound, the behavior for all
 sockets bound to that port is indeterminate. For example, if all of the 
 sockets
 on the same port provide TCP service, any incoming TCP connection requests 
 over
 the port cannot be guaranteed to be handled by the correct socket — the
 behavior is non-deterministic. “
 Whereas on Linux, SO_REUSEADDR socket option, which explicitly allows
 a process to bind to a
 port which remains in TIME_WAIT (it still only allows a single process
 to be bound to that
 port). The bind function fails to operate properly when the server
 terminates and we try to restart it immediately. Normally, the implementation
 of TCP will prevent us from binding the same address until a timeout expires,
 which is usually on the order of several minutes. Luckily, the
 SO_REUSEADDR socket option allows us to bypass this.
 Is it expected behaviour?

I ran into this in an unrelated project years ago.  If memory serves,
Windows' SO_REUSEADDR is broken by design.  Luckily, its bind() seems to
be broken as well: it seems to succeed while the port is in state
TIME_WAIT by default.  My solution then was not to set SO_REUSEADDR on
Windows.

http://tomayko.com/writings/that-dilbert-cartoon



Re: [Qemu-devel] QTest with TCG?

2013-04-16 Thread Edgar E. Iglesias
On Tue, Apr 16, 2013 at 07:11:43AM +0200, Paolo Bonzini wrote:
 Il 15/04/2013 21:03, Anthony Liguori ha scritto:
  Edgar E. Iglesias edgar.igles...@gmail.com writes:
  
  Hi,
 
  I would like to use qtest for testing hw-models in combination with 
  firmware.
 
  At the moment I'm using the following patch to allow qtest to run without
  accel=qtest. I'm mostly interested in the mem access functions and the
  interrupt interception. I guess time stepping wouldnt work without
  accel=qtest, but maybe that could be an acceptable limitation.
 
 Yes, but using -icount would provide more reproducibility perhaps.

Yes, thanks.

 
  Is there anything in principle with such a setup that would cause
  problems?
  
  Interesting.  No, I can't think of any problems in principle with doing
  this.  It was not a use case I had considered.
 
 Just one thing, how would you synchronize between the firmware and the
 testcase?

I guess there are various ways depending on the hw/fw setup.

An example is an on chip subsystem with a remote CPU, FW and a collection
of local devices that expose an well defined interface to the rest
of the system. Maybe through specific IPC fifos or by shared
memory. Normally, other CPUs on the system would request operations
through this interface, but in my case I decouple it so that
qtest based testsuites can bang on the interface. So the interface
itself dictates the sync mechanism.

I'm still WIP with this, but currently I'm using a python based
test infrastrucutre and communicating with the DUT through
SHM. Something like a stripped down dumb version of virtio.

Best regards,
Edgar



Re: [Qemu-devel] [PATCH 4/5] virtio-blk: release reference to RAM's memoryRegion

2013-04-16 Thread Stefan Hajnoczi
On Fri, Apr 12, 2013 at 05:05:41PM +0800, liu ping fan wrote:
 On Fri, Apr 12, 2013 at 4:45 PM, Stefan Hajnoczi stefa...@gmail.com wrote:
  On Fri, Apr 12, 2013 at 12:48:12PM +0800, liu ping fan wrote:
  On Thu, Apr 11, 2013 at 6:20 PM, Stefan Hajnoczi stefa...@gmail.com 
  wrote:
   On Mon, Apr 01, 2013 at 04:20:33PM +0800, Liu Ping Fan wrote:
   From: Liu Ping Fan pingf...@linux.vnet.ibm.com
  
   virtio-blk will reference to RAM's memoryRegion when the req has been
   done.  So we can avoid to call bdrv_drain_all() when RAM hot unplug.
  
   How does the hot unplug operation work without bdrv_drain_all()?  In
   other words, how do we safely remove a MemoryRegion and wait for it to
   become unreferenced?
  
  bdrv_drain_all() forces the end of usage of memoryRegion. But we can
  let the req done callback ( marks this req finish the end of usage of
  mr) to release the refcnt of memoryRegion.
 
  Yes.  What I'm interested in is the wait mechanism for the QEMU thread
  to wait until the memory region(s) become unreferenced.
 
  This patch series is only one half of the memory unplug puzzle and I'd
  like to understand how the other half - the unplug operation - will be
  implemented.
 
 The unplug patch is still under developed, more detail please refer to
 Vasilis Liaskovitis's patches:
http://lists.gnu.org/archive/html/qemu-devel/2012-12/msg02693.html
 
  Just a summary would be interesting - especially how a QEMU thread will
  wait until memory regions have been released.  The reference counter
  doesn't have any notification that would allow a blocking wait.
 
 Sorry, not understand a blocking wait.  To summary, when
 initializing, RamDevice's refcnt == 1, and unplug will release this
 one. Meanwhile, all the MemoryListeners which are async with unplug,
 will inc refcnt to against the unplug event.

Okay, thanks for the summary.  I don't need to see patches, I just want
to understand how the changes implemented in this series will be used.

  Then you have the RCU concept.  So maybe the unplug operation will not
  block but instead be called several times from the event loop until all
  references have been released?
 
 As mentioned above, unplug will put its own refcnt. And unplug will not block.

So it sounds like unplug will not block and there is no guarantee the
memory is actually unplugged when the monitor command completes.  The
memory region is only released when the last reference count holder lets
go.

This means that pending I/O to a hung NFS mount can delay the actual
unplug for unbounded time (by default the kernel NFS client keeps
retrying and does not fail the I/O request).  The user will be able to
issue additional monitor commands and see that memory is not yet
unplugged?

Stefan



Re: [Qemu-devel] [RFC PATCH] net: introduce monitor command to query mactables

2013-04-16 Thread Stefan Hajnoczi
On Thu, Apr 11, 2013 at 11:11:58PM +0800, Amos Kong wrote:
 +static MacTableInfo *virtio_net_query_mactable(NetClientState *nc)
 +{
 +VirtIONet *n = qemu_get_nic_opaque(nc);
 +MacTableInfo *info;
 +StringList *str_list = NULL;
 +StringList *entry;
 +char str[12];
 +int i;
 +
 +info = g_malloc0(sizeof(*info));
 +info-name = g_strdup(nc-name);
 +
 +info-promisc = n-promisc;
 +info-has_promisc = true;
 +info-allmulti = n-allmulti;
 +info-has_allmulti = true;
 +info-alluni = n-alluni;
 +info-has_alluni = true;
 +info-nomulti = n-nomulti;
 +info-has_nomulti = true;
 +info-nouni = n-nouni;
 +info-has_nouni = true;
 +info-nobcast = n-nobcast;
 +info-has_nobcast = true;
 +info-multi_overflow = n-mac_table.multi_overflow;
 +info-has_multi_overflow = true;
 +info-uni_overflow = n-mac_table.uni_overflow;
 +info-has_uni_overflow = true;
 +
 +for (i = 0; i  n-mac_table.first_multi; i++) {
 +info-has_unicast = true;
 +entry = g_malloc0(sizeof(*entry));
 +sprintf(str,
 +%.2x:%.2x:%.2x:%.2x:%.2x:%.2x,
 +n-mac_table.macs[i * ETH_ALEN],
 +n-mac_table.macs[i * ETH_ALEN + 1],
 +n-mac_table.macs[i * ETH_ALEN + 2],
 +n-mac_table.macs[i * ETH_ALEN + 3],
 +n-mac_table.macs[i * ETH_ALEN + 4],
 +n-mac_table.macs[i * ETH_ALEN + 5]);

Buffer overflow, char str[12], but luckily...

 +entry-value = g_malloc0(sizeof(String *));
 +entry-value-str = g_strdup(str);

...these lines can be replaced with g_strdup_printf():
https://developer.gnome.org/glib/2.28/glib-String-Utility-Functions.html#g-strdup-printf

 diff --git a/net/net.c b/net/net.c
 index 7869161..2103e7f 100644
 --- a/net/net.c
 +++ b/net/net.c
 @@ -964,6 +964,29 @@ void print_net_client(Monitor *mon, NetClientState *nc)
 nc-info_str);
  }
  
 +MacTableInfoList *qmp_query_mac_table(Error **errp)
 +{
 +NetClientState *nc;
 +MacTableInfoList *table_list = NULL;
 +
 +QTAILQ_FOREACH(nc, net_clients, next) {
 +MacTableInfoList *entry;
 +MacTableInfo *info;
 +
 +if (nc-info-type != NET_CLIENT_OPTIONS_KIND_NIC) {
 +continue;
 +}
 +if (nc-info-query_mac_table) {
 +info = nc-info-query_mac_table(nc);
 +entry = g_malloc0(sizeof(*entry));
 +entry-value = info;
 +entry-next = table_list;
 +table_list = entry;
 +}
 +}
 +return table_list;
 +}

Please add an optional net client name argument so the user can query
just a single NIC.  This saves users from having to parse out a specific
NIC when they just want to query one.

Stefan



Re: [Qemu-devel] [PATCH 4/5] virtio-blk: release reference to RAM's memoryRegion

2013-04-16 Thread Paolo Bonzini
Il 16/04/2013 09:57, Stefan Hajnoczi ha scritto:
 So it sounds like unplug will not block and there is no guarantee the
 memory is actually unplugged when the monitor command completes.  The
 memory region is only released when the last reference count holder lets
 go.
 
 This means that pending I/O to a hung NFS mount can delay the actual
 unplug for unbounded time (by default the kernel NFS client keeps
 retrying and does not fail the I/O request).  The user will be able to
 issue additional monitor commands and see that memory is not yet
 unplugged?

I think info mtree would provide information.  We can add an event
too, similar to the recently added DEVICE_DELETED.

Paolo



Re: [Qemu-devel] [PATCH v5] sheepdog: add discard/trim support for sheepdog

2013-04-16 Thread Stefan Hajnoczi
On Tue, Apr 16, 2013 at 12:15:04AM +0800, Liu Yuan wrote:
 @@ -727,6 +730,20 @@ static void coroutine_fn aio_read_response(void *opaque)
  rsp.result = SD_RES_SUCCESS;
  }
  break;
 +case AIOCB_DISCARD_OBJ:
 +switch (rsp.result) {
 +case SD_RES_INVALID_PARMS:
 +error_report(you are running the old sheep that doesn't support 
 
 + discard command.\n);

error_report() does not need '\n'.

The recently added ssh block driver has a similar case when the server
does not support fsync.  It does the following:

1. Print the error message once only per volume, avoid filling up logs
   on the host.
2. Include details of the volume/server in case the users is connected
   to multiple volumes/servers.  This allows them to figure out which
   server is outdated.

This makes the error messages safe from denial-of-service and includes
more useful information.



Re: [Qemu-devel] [RFC PATCH v2 3/6] memory: add memory_region_to_address()

2013-04-16 Thread Peter Maydell
On 16 April 2013 00:19, Scott Wood scottw...@freescale.com wrote:
 This is useful for when a user of the memory region API needs to
 communicate the absolute bus address to something outside QEMU
 (in particular, KVM).

 Signed-off-by: Scott Wood scottw...@freescale.com
 ---
 TODO: Use add/del memory listeners later in the patchset, which would
 eliminate the need for this patch.

Yes, please do.

 +/* memory_region_to_address: Find the full address of the start of the
 + *  given #MemoryRegion, ignoring aliases.  There is no guarantee
 + *  that the #MemoryRegion is actually visible at this address, if
 + *  there are overlapping regions.
 + *
 + * @mr: #MemoryRegion being queried
 + * @asp: if non-NULL, returns the #AddressSpace @mr is mapped in, if any
 + */
 +hwaddr memory_region_to_address(MemoryRegion *mr, AddressSpace **asp);

A MemoryRegion can appear in more than one AddressSpace (or none at all),
so I don't think this is a very clearly defined API to put in the
memory API itself. (It's ok to make that kind of assumption as a user
of the memory APIs for particular cases, eg in how a memory listener
callback function behaves. But we shouldn't be baking those assumptions
into new API functions.)

thanks
-- PMM



Re: [Qemu-devel] SoC Idea: Xbox target

2013-04-16 Thread Stefan Hajnoczi
On Mon, Apr 15, 2013 at 6:38 PM, Niel van der Westhuizen
nielg...@gmail.com wrote:
 So I've been lazily hacking away on https://github.com/espes/xqemu for the
 last few months. It's a target for the original Xbox in Qemu - it's kind of
 a neat fit, since the Xbox was mostly an nForce 420 PC. It'd be awesome to
 have helping out on this as a listed Summer of Code project idea. (mainly so
 I could apply for it ;)

What is the current status of the xbox target and what would a 12-week
GSoC project accomplish?  The scope of the project needs to be clearly
defined so this information is critical.

 Thing is, for this to be a Qemu project it'd need to be viable to be merged
 into Qemu eventually. Unfortunately so far my implementation has been far
 from clean-room, which could possibly be risky legally, I dono:
 -The binaries I've been referencing while reverse engineering are from
 the Xbox development kit software (since they conveniently include symbols)
 that, while mostly widely available, aren't exactly public.
 -The current implementation of the GPU
 (https://github.com/espes/xqemu/blob/xbox/hw/nv2a.c) and APU
 (https://github.com/espes/xqemu/blob/xbox/hw/mcpx_apu.c) use register names
 verbatim from a leaked register listing. If it makes a difference, most of
 the GPU names could already be figured out from a combination of registers
 documented in nouveau, registers listed in Dxbx (another Xbox emulator,
 uNV2A.pas), a published register listing found in an old nvidia sdk
 (nv10reg.h), and enums in the debug files in the Xbox development kit
 software.

Are just those two files questionable?  Could they be replaced with
something that does not draw from leaked material?

Stefan



Re: [Qemu-devel] [PATCH 07/12] configure: fix TPM logic

2013-04-16 Thread Markus Armbruster
Paolo Bonzini pbonz...@redhat.com writes:

 A non-native i386 or x86_64 emulator should not have TPM passthrough
 support, since the TPM is only present for those hosts.

 Reviewed-by: Andreas Färber afaer...@suse.de
 Signed-off-by: Paolo Bonzini pbonz...@redhat.com

Breaks the build for me:

make: Entering directory `/work/armbru/qemu/bld-x86'
make[1]: *** No rule to make target `../tpm/tpm_tis.o', needed by 
`qemu-system-x86_64'.
make[1]: Target `all' not remade because of errors.
make: *** [subdir-x86_64-softmmu] Error 2
make: Target `all' not remade because of errors.
make: Leaving directory `/work/armbru/qemu/bld-x86'

Workaround: drop --enable-tpm.



Re: [Qemu-devel] [PATCH v6 00/16] Stream Patches

2013-04-16 Thread Edgar E. Iglesias
On Tue, Apr 16, 2013 at 10:18:08AM +1000, peter.crosthwa...@xilinx.com wrote:
 From: Peter Crosthwaite peter.crosthwa...@xilinx.com
 
 Hi all. The Xilinx AXIEnet and DMA devices have two AXI stream connections
 (control and data), only one of which is currently modelled (data). AXI stream
 is modelled using the stream QOM interface described in stream.h. 
 Unfortunately,
 interfaces have no nice way of modelling multiple connections of the same 
 type.
 So to overcome this I created a secondary object which acts as a proxy for the
 stream connection. Multiple connections can be implemented using multiple
 proxies and stream masters link to the relevant proxy, rather than the 
 ethernet
 device itself. This Series changes AXI Enet and DMA to be connected as such.
 
 Also changed the stream interface to implement flow control handshaking. This
 is needed for the AXIEnet to be be able to implement the net can_receive() 
 flow
 control.
 
 Patches 1-10 are low-impact cleanup of axienet/dma as per the current QOM
 styling guidelines and can be cherry-picked off the front.

Applied, thanks Peter.

Cheers


 
 changed from v5:
 rebased against hw ro-organisation
 changed from v4:
 resynchronized control flow stream API
 reordered series for better consistency.
 Folded patch 17 in 16 (app array length fix)
 Fixed DMA tx path halted bit
 changed from v3:
 Changed from asynchronous flow control to synchronous (Edgar review)
 changed from v2:
 Reordered patches (from low impact - high impact)
 Added styling refactoring of AXIDMA
 Added asynchronous patches
 Removed dummy second stream connection patch (former patch 8)
 Added (functional) second stream connection
 changed from v1:
 Removed former P12 (already merged)
 Address Andreas review
 Refactor axienet to be more QOM friendly.
 
 
 Peter Crosthwaite (16):
   xilinx_axienet: typedef XilinxAXIEnet struct
   xilinx_axienet: Defined and use type cast macro
   xilinx_axienet: Register reset properly
   xilinx_axienet: converted init-realize
   xilinx_axidma: typedef XilinxAXIDMA struct
   xilinx_axidma: Defined and use type cast macro
   xilinx_axidma: Register reset properly
   xilinx_axidma: converted init-realize
   petalogix_ml605_mmu: Fix machine node attachment
   petalogix_ml605_mmu: Attach ethernet to machine
   xilinx_axienet: Create Proxy object for stream
   xilinx_axidma: Create Proxy object for stream
   xilinx_axidma: Fix rx/tx halted bit.
   stream: Add flow control API
   xilinx_axienet/dma: Implement rx path flow control
   stream: Remove app argument hack
 
  hw/core/stream.c|   15 ++-
  hw/dma/xilinx_axidma.c  |  261 
 +++
  hw/microblaze/petalogix_ml605_mmu.c |   28 +++-
  hw/net/xilinx_axienet.c |  255 +++---
  include/hw/stream.h |   36 -
  include/hw/xilinx.h |   21 ++-
  6 files changed, 483 insertions(+), 133 deletions(-)
 



Re: [Qemu-devel] [PATCH v3 0/4] m25p80: Fix debug printfery

2013-04-16 Thread Edgar E. Iglesias
On Tue, Apr 16, 2013 at 10:32:14AM +1000, peter.crosthwa...@xilinx.com wrote:
 From: Peter Crosthwaite peter.crosthwa...@xilinx.com
 
 Fix up the debug printfery m25p80 in various ways. 0 functional diff.
 
 changed from v2:
 Rebased against hw reorg

Applied, thanks!

Cheers,
Edgar

 
 
 Peter Crosthwaite (4):
   m25p80: Fix debug messages.
   m25p80: Convert guest errors to LOG_GUEST_ERROR
   m25p80.c: Multiple debug verbosity levels
   m25p80: Add debug message for no bdrv
 
  hw/block/m25p80.c |   52 +---
  1 files changed, 29 insertions(+), 23 deletions(-)
 



Re: [Qemu-devel] [PATCH 00/16 v4] target-i386: CPU hot-add with cpu-add QMP command

2013-04-16 Thread Jan Kiszka
On 2013-04-16 00:12, Igor Mammedov wrote:
 Implements alternative way for hot-adding CPU using cpu-add QMP command,
 wich could be useful until it would be possible to add CPUs via device_add.

Didn't track the full story: What prevents currently a device_add
approach? And that so effectively that we have to create a
to-be-deprecated-again QMP API first?

Thanks,
Jan

 
 All patches except the last are also applicable to device_add aprroach.
 
 To hot-add CPU use following command from qmp-shell:
  cpu-add id=[0..max-cpus - 1)
 
 git tree for testing: https://github.com/imammedo/qemu/tree/cpu_add.v4
 
 based on qom-cpu tree
 
 v4-v3:
   * 'id' in cpu-add command will be a thread number instead of APIC ID
   * split off resume_vcpu() into separate patch
   * move notifier from rtc code into pc.c
 
 v2-v3:
   * use local error  propagate_error() instead of operating on
 passed in errp in several places
   * replace CPUClass.get_firmware_id() with CPUClass.get_arch_id()
   * leave IOAPIC creation to board and just set bus to icc-bus
   * include kvm-stub.o in cpu libary if no KVM is configured
   * create resume_vcpu() stub and include it in libqemustub,
 and use it directly instead of CPU method
   * acpi_piix4: s/cpu_add_notifier/cpu_added_notifier/
 
 v1-v2:
   * generalize cpu sync to KVM, resume and hot-plug notification and
 invoke them form CPUClass, to make available to all targets.
   * introduce cpu_exists() and CPUClass.get_firmware_id() and use
 the last one in acpi_piix to make code target independent.
   * move IOAPIC to ICC bus, it was suggested and easy to convert.
   * leave kvmvapic as SysBusDevice, it doesn't affect hot-plug and
 created only once for all APIC instances. I haven't found yet
 good/clean enough way to convert it to ICCDevice. May be follow-up
 though.
   * split one big ICC patch into several, one per converted device
   * add cpu_hot_add hook to machine and implement it for target-i386,
 instead of adding stabs. Could be used by other targets to
 implement cpu-add.
   * pre-allocate linksCPU for all possible CPUs and make them available
 at /machine/icc-bridge/cpu[0..N] QOM path, so users could find out
 possible/free CPU IDs to use in cpu-add command.
 
 CC: pbonz...@redhat.com
 CC: afaer...@suse.de
 CC: ehabk...@redhat.com
 
 Igor Mammedov (16):
   cpu: make kvm-stub.o a part of CPU library
   cpu: call cpu_synchronize_post_init() from CPUClass.realize() if
 hotplugged
   introduce resume_vcpu(), for single CPU
   cpu: resume CPU from CPUClass.cpu_common_realizefn() when it is
 hot-plugged
   introduce CPU hot-plug notifier
   target-i386: pc: update rtc_cmos on CPU hot-plug
   cpu: introduce get_arch_id() method and override it for target-i386
   cpu: add helper cpu_exists(), to check if CPU with specified id exists
   acpi_piix4: add infrastructure to send CPU hot-plug GPE to guest
   target-i386: introduce apic-id property
   introduce ICC bus/device/bridge
   target-i386: cpu: attach ICC bus to CPU on its creation
   target-i386: replace MSI_SPACE_SIZE with APIC_SPACE_SIZE
   target-i386: move APIC to ICC bus
   target-i386: move IOAPIC to ICC bus
   add cpu-add qmp command and implement CPU hot-add for target-i386
 
  Makefile.target|  14 ++---
  cpus.c |  11 +++-
  default-configs/i386-softmmu.mak   |   1 +
  default-configs/x86_64-softmmu.mak |   1 +
  hw/acpi/piix4.c| 114 
 -
  hw/cpu/Makefile.objs   |   1 +
  hw/cpu/icc_bus.c   | 104 +
  hw/i386/kvm/apic.c |   2 +-
  hw/i386/kvm/ioapic.c   |   2 +-
  hw/i386/kvmvapic.c |   1 +
  hw/i386/pc.c   |  91 +++--
  hw/i386/pc_piix.c  |   7 +++
  hw/i386/pc_q35.c   |   7 +++
  hw/intc/apic.c |   2 +-
  hw/intc/apic_common.c  |  17 --
  hw/intc/ioapic_common.c|  15 +++--
  hw/timer/mc146818rtc.c |   7 +++
  hw/xen/xen_apic.c  |   2 +-
  include/exec/memory.h  |  10 
  include/hw/boards.h|   3 +
  include/hw/i386/apic_internal.h|   8 +--
  include/hw/i386/icc_bus.h  |  53 +
  include/hw/i386/ioapic_internal.h  |   6 +-
  include/hw/pci/msi.h   |   2 +
  include/hw/timer/mc146818rtc.h |   1 +
  include/qom/cpu.h  |  21 +++
  include/sysemu/kvm.h   |  22 +++
  include/sysemu/sysemu.h|   3 +
  kvm-all.c  |   1 +
  kvm-stub.c |   3 +
  memory.c   |  11 
  qapi-schema.json   |  11 
  qmp-commands.hx|  23 
  qmp.c  |  10 
  qom/cpu.c   

Re: [Qemu-devel] [PATCH] pixman: remove -Wredundand-decls

2013-04-16 Thread Markus Armbruster
Gcc issue, perhaps Paolo [cc'ed] got an idea.

Alexey Kardashevskiy a...@ozlabs.ru writes:

 On 04/16/2013 08:48 AM, Alexey Kardashevskiy wrote:
 On 04/16/2013 01:55 AM, Markus Armbruster wrote:
 Alexey Kardashevskiy a...@ozlabs.ru writes:

 On 04/15/2013 10:57 PM, Markus Armbruster wrote:
 Alexey Kardashevskiy a...@ozlabs.ru writes:

 On 04/15/2013 08:01 PM, Peter Maydell wrote:
 On 15 April 2013 10:50, Alexey Kardashevskiy a...@ozlabs.ru wrote:
 /home/alexey/pcipassthru/qemu-impreza/../lib4qemu/usr/include/assert.h:67:13:

 error: redundant redeclaration of '__assert_fail'
 [-Werror=redundant-decls]
 /home/alexey/pcipassthru/qemu-impreza/../lib4qemu/usr/include/assert.h:67:13:

 note: previous declaration of '__assert_fail' was here
 /home/alexey/pcipassthru/qemu-impreza/../lib4qemu/usr/include/assert.h:72:13:

 error: redundant redeclaration of '__assert_perror_fail'
 [-Werror=redundant-decls]

 This copy of assert.h seems to be broken. The declarations
 should be guarded (by _ASSERT_H_DECLS in my system's copy).

 Debian? It uses eglibc which is fork (or clone?) of glibc.

 If it's widespread we might have to work around this.

 It is in fedora 18 and glibc's git master branch. Why if?

 It's in Fedora 17, too, but I *don't* get a warning.  Suspecting your
 compiler.  --version?


 powerpc64-linux-gcc 4.6.3, 4.7.2, 4.8.0, all the same. I'll try to
 track it down tomorrow why it all works when host and target are the
 same (pretty sure this is the cse) but I just do not get it... It is
 just me who sees obvious error in assert.h which is caused by
 -Wno-redundant-decls? Even if you do not hit this now, you will get
 there eventually.

 I don't doubt your gcc+libc is in error.  I just don't want to lose a
 useful warning because of that.
  
 Workaround: configure --disable-werror

 This workaround does NOT work if pragmas used. #pragma GCC diagnostic
 error -Wredundant-decls re-enables warnings as errors.


 Kind of offtopic but still...

 I think this is just beautiful. Fedora18, x86_64, NO cross
 compiler. gcc does not apply -Wredundant-decls to /usr/include/* but
 does it for all other headers and in the case of cross compilation I
 hit this case.

 Does anyone know the way to tell gcc that libc headers are not at
 /usr/include but somewhere else?



 [aik@aik ~]$ cp /usr/include/assert.h ./
 [aik@aik ~]$
 [aik@aik ~]$ cat a.c
 #pragma GCC diagnostic error -Wredundant-decls

 #ifdef USEMINE
 #include assert.h
 #include assert.h
 #else
 #include assert.h
 #include assert.h
 #endif

 int main(int argc, char **argv){ return 0; }
 [aik@aik ~]$
 [aik@aik ~]$ gcc a.c -o a
 [aik@aik ~]$ gcc a.c -o a -DUSEMINE
 In file included from a.c:5:0:
 assert.h:68:13: error: redundant redeclaration of ‘__assert_fail’
 [-Werror=redundant-decls]
 In file included from a.c:4:0:
 assert.h:68:13: note: previous declaration of ‘__assert_fail’ was here
 In file included from a.c:5:0:
 assert.h:73:13: error: redundant redeclaration of
 ‘__assert_perror_fail’ [-Werror=redundant-decls]
 In file included from a.c:4:0:
 assert.h:73:13: note: previous declaration of ‘__assert_perror_fail’ was here
 In file included from a.c:5:0:
 assert.h:80:13: error: redundant redeclaration of ‘__assert’
 [-Werror=redundant-decls]
 In file included from a.c:4:0:
 assert.h:80:13: note: previous declaration of ‘__assert’ was here
 cc1: some warnings being treated as errors
 [aik@aik ~]$



Re: [Qemu-devel] Fedora core 2 filesystem

2013-04-16 Thread Stefan Hajnoczi
On Mon, Apr 15, 2013 at 02:29:03PM +0100, Benito wrote:
 I have a question regarding qemu. Is it possible to take a working
 root filesystem ( old machine running Fedora core 2 ) and emulate it
 with qemu
 on a new PC running a modern Linux distribution ? If so , is it
 going to be a nightmare to accomplish , or is there support to do
 this already ?

Yes, that is possible.  It's called physical-to-virtual (p2v) migration.

The process is:
1. Gather old machine hardware configuration info, mainly from lspci(1)
2. Copy disk contents into a raw image file, typically using dd(1)
3. Configure a new guest with hardware that matches old host as closely
   as possible.  Most important are network card, storage controller,
   and display adapter since the OS may fail to boot up to a useful
   level if it lacks drivers.

If your hardware is not emulated by QEMU, try rtl8139 for NIC, IDE for
storage, and cirrus VGA for display.  These are old devices and many
guest OSes ship with drivers for them.

Keep the old machine around during this process so you can go back if
you hit a hurdle.

Good luck! :)

Stefan



Re: [Qemu-devel] [PATCH 4/4] qemu-iotests: add 053 unaligned compressed image size test

2013-04-16 Thread Stefan Hajnoczi
On Mon, Apr 15, 2013 at 09:38:28AM -0600, Eric Blake wrote:
 On 04/15/2013 09:17 AM, Stefan Hajnoczi wrote:
  Test that qemu-img convert -c works when input image length is not a
  multiple of the cluster size.
  
  Previously an error message would be produced:
  
qemu-img: error while compressing sector 0: Input/output error
  
  Now that qcow2 and qcow handle this case the test passes successfully.
  
  Signed-off-by: Stefan Hajnoczi stefa...@redhat.com
  ---
 
  +echo
  +echo == Creating single sector image ==
  +
  +_make_test_img 512
  +$QEMU_IO -c write -P0xa 0 512 $TEST_IMG | _filter_qemu_io
  +mv $TEST_IMG $TEST_IMG.orig
  +
  +echo
  +echo == Converting the image, compressed ==
  +
  +$QEMU_IMG convert -c -O $IMGFMT $TEST_IMG.orig $TEST_IMG
  +_check_test_img
  +
  +# success, all done
 
 Is it worth also testing that qemu-img info on the converted image still
 reports that the guest sees a size of 512, to prove that the virtual
 size was not expanded as a result of compression tail padding?

Good point.  Let's beef up the test case.  We can also read the first
sector to verify to still contains 0xa bytes.

Stefan



Re: [Qemu-devel] [PATCH 07/12] configure: fix TPM logic

2013-04-16 Thread Paolo Bonzini
Il 16/04/2013 10:28, Markus Armbruster ha scritto:
 Breaks the build for me:
 
 make: Entering directory `/work/armbru/qemu/bld-x86'
 make[1]: *** No rule to make target `../tpm/tpm_tis.o', needed by 
 `qemu-system-x86_64'.
 make[1]: Target `all' not remade because of errors.
 make: *** [subdir-x86_64-softmmu] Error 2
 make: Target `all' not remade because of errors.
 make: Leaving directory `/work/armbru/qemu/bld-x86'
 
 Workaround: drop --enable-tpm.

I had a stale .o in my build directory.  Sending patch, BTW why isn't
TPM enabled by default?

Paolo



Re: [Qemu-devel] [PATCH v5] sheepdog: add discard/trim support for sheepdog

2013-04-16 Thread Kevin Wolf
Am 16.04.2013 um 10:18 hat Stefan Hajnoczi geschrieben:
 On Tue, Apr 16, 2013 at 12:15:04AM +0800, Liu Yuan wrote:
  @@ -727,6 +730,20 @@ static void coroutine_fn aio_read_response(void 
  *opaque)
   rsp.result = SD_RES_SUCCESS;
   }
   break;
  +case AIOCB_DISCARD_OBJ:
  +switch (rsp.result) {
  +case SD_RES_INVALID_PARMS:
  +error_report(you are running the old sheep that doesn't 
  support 
  + discard command.\n);
 
 error_report() does not need '\n'.
 
 The recently added ssh block driver has a similar case when the server
 does not support fsync.  It does the following:
 
 1. Print the error message once only per volume, avoid filling up logs
on the host.
 2. Include details of the volume/server in case the users is connected
to multiple volumes/servers.  This allows them to figure out which
server is outdated.
 
 This makes the error messages safe from denial-of-service and includes
 more useful information.

Or if we can check whether discard works during bdrv_open(), we could
already fail there for discard=on.

Kevin



Re: [Qemu-devel] [qapi] Cannot use list of strings

2013-04-16 Thread Stefan Hajnoczi
On Mon, Apr 15, 2013 at 10:04:24PM +0200, Lluís Vilanova wrote:
 Tried using a list of strings as an argument to a command, but the generated
 code references the 'strList' type, which does not exist.
 
 Is a specialized version for ['str'] missing, or should I define my own type
 with a single field of 'str' type?

akong just hit this too.

I think it's a question for aliguori, luiz, or mdroth.

Stefan



[Qemu-devel] [PATCH build-breakage] build: include config-{, all-}devices.mak after defining CONFIG_SOFTMMU and CONFIG_USER_ONLY

2013-04-16 Thread Paolo Bonzini
Moving the inclusions closer to Makefile, and before rules.mak, makes
Makefile and Makefile.target more consistent with each other.

Signed-off-by: Paolo Bonzini pbonz...@redhat.com
---
 Makefile| 12 ++--
 Makefile.target |  2 +-
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/Makefile b/Makefile
index 67f19f2..516ccbb 100644
--- a/Makefile
+++ b/Makefile
@@ -19,6 +19,12 @@ seems to have been used for an in-tree build. You can fix 
this by running \
 endif
 endif
 
+CONFIG_SOFTMMU := $(if $(filter %-softmmu,$(TARGET_DIRS)),y)
+CONFIG_USER_ONLY := $(if $(filter %-user,$(TARGET_DIRS)),y)
+CONFIG_ALL=y
+-include config-all-devices.mak
+-include config-all-disas.mak
+
 include $(SRC_PATH)/rules.mak
 config-host.mak: $(SRC_PATH)/configure
@echo $@ is out-of-date, running configure
@@ -107,12 +113,6 @@ endif
 defconfig:
rm -f config-all-devices.mak $(SUBDIR_DEVICES_MAK)
 
--include config-all-devices.mak
--include config-all-disas.mak
-CONFIG_SOFTMMU := $(if $(filter %-softmmu,$(TARGET_DIRS)),y)
-CONFIG_USER_ONLY := $(if $(filter %-user,$(TARGET_DIRS)),y)
-CONFIG_ALL=y
-
 ifneq ($(wildcard config-host.mak),)
 include $(SRC_PATH)/Makefile.objs
 include $(SRC_PATH)/tests/Makefile
diff --git a/Makefile.target b/Makefile.target
index 2bd6d14..121bcdc 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -1,8 +1,8 @@
 # -*- Mode: makefile -*-
 
 include ../config-host.mak
-include config-devices.mak
 include config-target.mak
+include config-devices.mak
 include $(SRC_PATH)/rules.mak
 
 $(call set-vpath, $(SRC_PATH))
-- 
1.8.1.4




Re: [Qemu-devel] [PATCH 4/4] qemu-iotests: add 053 unaligned compressed image size test

2013-04-16 Thread Kevin Wolf
Am 16.04.2013 um 10:36 hat Stefan Hajnoczi geschrieben:
 On Mon, Apr 15, 2013 at 09:38:28AM -0600, Eric Blake wrote:
  On 04/15/2013 09:17 AM, Stefan Hajnoczi wrote:
   Test that qemu-img convert -c works when input image length is not a
   multiple of the cluster size.
   
   Previously an error message would be produced:
   
 qemu-img: error while compressing sector 0: Input/output error
   
   Now that qcow2 and qcow handle this case the test passes successfully.
   
   Signed-off-by: Stefan Hajnoczi stefa...@redhat.com
   ---
  
   +echo
   +echo == Creating single sector image ==
   +
   +_make_test_img 512
   +$QEMU_IO -c write -P0xa 0 512 $TEST_IMG | _filter_qemu_io
   +mv $TEST_IMG $TEST_IMG.orig
   +
   +echo
   +echo == Converting the image, compressed ==
   +
   +$QEMU_IMG convert -c -O $IMGFMT $TEST_IMG.orig $TEST_IMG
   +_check_test_img
   +
   +# success, all done
  
  Is it worth also testing that qemu-img info on the converted image still
  reports that the guest sees a size of 512, to prove that the virtual
  size was not expanded as a result of compression tail padding?
 
 Good point.  Let's beef up the test case.  We can also read the first
 sector to verify to still contains 0xa bytes.

Maybe just qemu-img compare -s both images? And you can add the info as
well just in case that compare is broken...

Kevin



Re: [Qemu-devel] [qapi] Cannot use list of strings

2013-04-16 Thread Paolo Bonzini
Il 16/04/2013 10:49, Stefan Hajnoczi ha scritto:
  Tried using a list of strings as an argument to a command, but the 
  generated
  code references the 'strList' type, which does not exist.
  
  Is a specialized version for ['str'] missing, or should I define my own 
  type
  with a single field of 'str' type?
 akong just hit this too.
 
 I think it's a question for aliguori, luiz, or mdroth.

Laszlo defined and used String for this purpose:

##
# @String
#
# A fat type wrapping 'str', to be embedded in lists.
#
# Since 1.2
##
{ 'type': 'String',
  'data': {
'str': 'str' } }


Paolo



Re: [Qemu-devel] [PATCH 0/4] qemu-img: support compression regardless of cluster size

2013-04-16 Thread Kevin Wolf
Am 15.04.2013 um 17:17 hat Stefan Hajnoczi geschrieben:
 It was hard to find a short email subject line.  Anyway, the problem is that
 qemu-img convert -c fails with the following error message if the input image
 length is not a multiple of the output cluster size:
 
   qemu-img: error while compressing sector 0: Input/output error
 
 Ilkka Tengvall ilkka.tengv...@cybercom.com reported the failure.  kwolf and
 eblake suggested a fix which this patch series implements.
 
 qemu-img convert -c succeeds with these patches applied.
 
 The final patch adds qemu-iotests case 053 to protect against regressions.

Thanks, applied all to the block branch. If you're going to send an
updated test case, I'll replace it in my tree.

Kevin



Re: [Qemu-devel] [PATCH] pixman: remove -Wredundand-decls

2013-04-16 Thread Markus Armbruster
Alexey Kardashevskiy a...@ozlabs.ru writes:

 On 04/16/2013 01:55 AM, Markus Armbruster wrote:
 Alexey Kardashevskiy a...@ozlabs.ru writes:

 On 04/15/2013 10:57 PM, Markus Armbruster wrote:
 Alexey Kardashevskiy a...@ozlabs.ru writes:

 On 04/15/2013 08:01 PM, Peter Maydell wrote:
 On 15 April 2013 10:50, Alexey Kardashevskiy a...@ozlabs.ru wrote:
 /home/alexey/pcipassthru/qemu-impreza/../lib4qemu/usr/include/assert.h:67:13:
 error: redundant redeclaration of '__assert_fail'
 [-Werror=redundant-decls]
 /home/alexey/pcipassthru/qemu-impreza/../lib4qemu/usr/include/assert.h:67:13:
 note: previous declaration of '__assert_fail' was here
 /home/alexey/pcipassthru/qemu-impreza/../lib4qemu/usr/include/assert.h:72:13:
 error: redundant redeclaration of '__assert_perror_fail'
 [-Werror=redundant-decls]

 This copy of assert.h seems to be broken. The declarations
 should be guarded (by _ASSERT_H_DECLS in my system's copy).

 Debian? It uses eglibc which is fork (or clone?) of glibc.

 If it's widespread we might have to work around this.

 It is in fedora 18 and glibc's git master branch. Why if?

 It's in Fedora 17, too, but I *don't* get a warning.  Suspecting your
 compiler.  --version?


 powerpc64-linux-gcc 4.6.3, 4.7.2, 4.8.0, all the same. I'll try to
 track it down tomorrow why it all works when host and target are the
 same (pretty sure this is the cse) but I just do not get it... It is
 just me who sees obvious error in assert.h which is caused by
 -Wno-redundant-decls? Even if you do not hit this now, you will get
 there eventually.

 I don't doubt your gcc+libc is in error.  I just don't want to lose a
 useful warning because of that.

 Workaround: configure --disable-werror

 This workaround does NOT work if pragmas used. #pragma GCC diagnostic
 error -Wredundant-decls re-enables warnings as errors.

Bummer.  Could you try the appended patch?

diff --git a/configure b/configure
index 0788e27..41097a2 100755
--- a/configure
+++ b/configure
@@ -3244,8 +3244,10 @@ fi
 
 pragma_disable_unused_but_set=no
 cat  $TMPC  EOF
+#pragma GCC diagnostic push
 #pragma GCC diagnostic ignored -Wunused-but-set-variable
 #pragma GCC diagnostic ignored -Wstrict-prototypes
+#pragma GCC diagnostic pop
 
 int main(void) {
 return 0;
diff --git a/coroutine-ucontext.c b/coroutine-ucontext.c
index 867a662..4bf2cde 100644
--- a/coroutine-ucontext.c
+++ b/coroutine-ucontext.c
@@ -169,6 +169,7 @@ Coroutine *qemu_coroutine_new(void)
 #ifdef CONFIG_VALGRIND_H
 #ifdef CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE
 /* Work around an unused variable in the valgrind.h macro... */
+#pragma GCC diagnostic push
 #pragma GCC diagnostic ignored -Wunused-but-set-variable
 #endif
 static inline void valgrind_stack_deregister(CoroutineUContext *co)
@@ -176,7 +177,7 @@ static inline void 
valgrind_stack_deregister(CoroutineUContext *co)
 VALGRIND_STACK_DEREGISTER(co-valgrind_stack_id);
 }
 #ifdef CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE
-#pragma GCC diagnostic error -Wunused-but-set-variable
+#pragma GCC diagnostic pop
 #endif
 #endif
 
diff --git a/include/ui/qemu-pixman.h b/include/ui/qemu-pixman.h
index b032f52..882e2a3 100644
--- a/include/ui/qemu-pixman.h
+++ b/include/ui/qemu-pixman.h
@@ -8,11 +8,12 @@
 
 /* pixman-0.16.0 headers have a redundant declaration */
 #ifdef CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE
+#pragma GCC diagnostic push
 #pragma GCC diagnostic ignored -Wredundant-decls
 #endif
 #include pixman.h
 #ifdef CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE
-#pragma GCC diagnostic error -Wredundant-decls
+#pragma GCC diagnostic pop
 #endif
 
 #include qemu/typedefs.h
diff --git a/ui/gtk.c b/ui/gtk.c
index 1e105e2..c2c6e38 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -38,11 +38,12 @@
 
 #ifdef CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE
 /* Work around an -Wstrict-prototypes warning in GTK headers */
+#pragma GCC diagnostic push
 #pragma GCC diagnostic ignored -Wstrict-prototypes
 #endif
 #include gtk/gtk.h
 #ifdef CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE
-#pragma GCC diagnostic error -Wstrict-prototypes
+#pragma GCC diagnostic pop
 #endif
 
 



Re: [Qemu-devel] [PATCH v5] sheepdog: add discard/trim support for sheepdog

2013-04-16 Thread Liu Yuan
On 04/16/2013 04:47 PM, Kevin Wolf wrote:
 Am 16.04.2013 um 10:18 hat Stefan Hajnoczi geschrieben:
  On Tue, Apr 16, 2013 at 12:15:04AM +0800, Liu Yuan wrote:
   @@ -727,6 +730,20 @@ static void coroutine_fn aio_read_response(void 
   *opaque)
rsp.result = SD_RES_SUCCESS;
}
break;
   +case AIOCB_DISCARD_OBJ:
   +switch (rsp.result) {
   +case SD_RES_INVALID_PARMS:
   +error_report(you are running the old sheep that doesn't 
   support 
   + discard command.\n);
  
  error_report() does not need '\n'.
  
  The recently added ssh block driver has a similar case when the server
  does not support fsync.  It does the following:
  
  1. Print the error message once only per volume, avoid filling up logs
 on the host.

All the request for the volumes are firstly handled by the sheep daemon
this QEMU connects to, so we can say that if one discard request for any
volume return SD_RES_INVALID_PARMS, then all the volumes attatched to
this VM can't support discard operation.

  2. Include details of the volume/server in case the users is connected
 to multiple volumes/servers.  This allows them to figure out which
 server is outdated.
  

Multi-connections aren't supported yet (though planned), so this doesn't
apply for current SD.

  This makes the error messages safe from denial-of-service and includes
  more useful information.
 Or if we can check whether discard works during bdrv_open(), we could
 already fail there for discard=on.

Hmm, SD doesn't support a feature negotiation request. The most simple
way I can come up is add a s-enable_discard flag that set false when it
is reported discard operation isn't supported by the server connected.
What do you think?

Thanks,
Yuan



[Qemu-devel] [PATCH v2 0/4] qemu-img: support compression regardless of cluster size

2013-04-16 Thread Stefan Hajnoczi
It was hard to find a short email subject line.  Anyway, the problem is that
qemu-img convert -c fails with the following error message if the input image
length is not a multiple of the output cluster size:

  qemu-img: error while compressing sector 0: Input/output error

Ilkka Tengvall ilkka.tengv...@cybercom.com reported the failure.  kwolf and
eblake suggested a fix which this patch series implements.

qemu-img convert -c succeeds with these patches applied.

The final patch adds qemu-iotests case 053 to protect against regressions.

v2:
 * Extend test case to check virtual disk size and contents [eblake]
 * Note: only the last commit changed

Stefan Hajnoczi (4):
  qcow2: allow sub-cluster compressed write to last cluster
  qcow: allow sub-cluster compressed write to last cluster
  qemu-img: do not zero-pad the compressed write buffer
  qemu-iotests: add 053 unaligned compressed image size test

 block/qcow.c   | 17 +--
 block/qcow2.c  | 17 +--
 qemu-img.c |  8 ++---
 tests/qemu-iotests/053 | 73 ++
 tests/qemu-iotests/053.out | 17 +++
 tests/qemu-iotests/group   |  1 +
 6 files changed, 123 insertions(+), 10 deletions(-)
 create mode 100755 tests/qemu-iotests/053
 create mode 100644 tests/qemu-iotests/053.out

-- 
1.8.1.4




[Qemu-devel] [PATCH v2 1/4] qcow2: allow sub-cluster compressed write to last cluster

2013-04-16 Thread Stefan Hajnoczi
Compression in qcow2 requires image length to be a multiple of the
cluster size.  Lift this requirement by zero-padding the final cluster
when necessary.  The virtual disk size is still not cluster-aligned, so
the guest cannot access the zero sectors.

Signed-off-by: Stefan Hajnoczi stefa...@redhat.com
---
 block/qcow2.c | 17 +++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/block/qcow2.c b/block/qcow2.c
index e8934de..2e346d8 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -1537,8 +1537,21 @@ static int qcow2_write_compressed(BlockDriverState *bs, 
int64_t sector_num,
 return 0;
 }
 
-if (nb_sectors != s-cluster_sectors)
-return -EINVAL;
+if (nb_sectors != s-cluster_sectors) {
+ret = -EINVAL;
+
+/* Zero-pad last write if image size is not cluster aligned */
+if (sector_num + nb_sectors == bs-total_sectors 
+nb_sectors  s-cluster_sectors) {
+uint8_t *pad_buf = qemu_blockalign(bs, s-cluster_size);
+memset(pad_buf, 0, s-cluster_size);
+memcpy(pad_buf, buf, nb_sectors * BDRV_SECTOR_SIZE);
+ret = qcow2_write_compressed(bs, sector_num,
+ pad_buf, s-cluster_sectors);
+qemu_vfree(pad_buf);
+}
+return ret;
+}
 
 out_buf = g_malloc(s-cluster_size + (s-cluster_size / 1000) + 128);
 
-- 
1.8.1.4




[Qemu-devel] [PATCH v2 3/4] qemu-img: do not zero-pad the compressed write buffer

2013-04-16 Thread Stefan Hajnoczi
bdrv_write_compressed() does not allow requests that span the end of the
device.  Therefore it is useless to zero-pad the last cluster and
thereby exceed the end of the device.

Let image formats handle zero-padding the final compressed cluster, if
necessary.

Signed-off-by: Stefan Hajnoczi stefa...@redhat.com
---
 qemu-img.c | 8 ++--
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/qemu-img.c b/qemu-img.c
index 31627b0..cd096a1 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -1425,12 +1425,8 @@ static int img_convert(int argc, char **argv)
 }
 assert (remainder == 0);
 
-if (n  cluster_sectors) {
-memset(buf + n * 512, 0, cluster_size - n * 512);
-}
-if (!buffer_is_zero(buf, cluster_size)) {
-ret = bdrv_write_compressed(out_bs, sector_num, buf,
-cluster_sectors);
+if (!buffer_is_zero(buf, n * BDRV_SECTOR_SIZE)) {
+ret = bdrv_write_compressed(out_bs, sector_num, buf, n);
 if (ret != 0) {
 error_report(error while compressing sector % PRId64
  : %s, sector_num, strerror(-ret));
-- 
1.8.1.4




[Qemu-devel] [PATCH v2 4/4] qemu-iotests: add 053 unaligned compressed image size test

2013-04-16 Thread Stefan Hajnoczi
Test that qemu-img convert -c works when input image length is not a
multiple of the cluster size.

Previously an error message would be produced:

  qemu-img: error while compressing sector 0: Input/output error

Now that qcow2 and qcow handle this case the test passes successfully.

Signed-off-by: Stefan Hajnoczi stefa...@redhat.com
---
 tests/qemu-iotests/053 | 73 ++
 tests/qemu-iotests/053.out | 17 +++
 tests/qemu-iotests/group   |  1 +
 3 files changed, 91 insertions(+)
 create mode 100755 tests/qemu-iotests/053
 create mode 100644 tests/qemu-iotests/053.out

diff --git a/tests/qemu-iotests/053 b/tests/qemu-iotests/053
new file mode 100755
index 000..bc56992
--- /dev/null
+++ b/tests/qemu-iotests/053
@@ -0,0 +1,73 @@
+#!/bin/bash
+#
+# Test qemu-img convert when image length is not a multiple of cluster size
+#
+# Copyright (C) 2013 Red Hat, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see http://www.gnu.org/licenses/.
+#
+
+# creator
+owner=stefa...@redhat.com
+
+seq=`basename $0`
+echo QA output created by $seq
+
+here=`pwd`
+tmp=/tmp/$$
+status=1   # failure is the default!
+
+_cleanup()
+{
+   rm -f $TEST_IMG.orig
+   _cleanup_test_img
+}
+trap _cleanup; exit \$status 0 1 2 3 15
+
+# get standard environment, filters and checks
+. ./common.rc
+. ./common.filter
+
+_supported_fmt qcow2 qcow
+_supported_proto file
+_supported_os Linux
+
+echo
+echo == Creating single sector image ==
+
+_make_test_img 512
+$QEMU_IO -c write -P0xa 0 512 $TEST_IMG | _filter_qemu_io
+mv $TEST_IMG $TEST_IMG.orig
+
+echo
+echo == Converting the image, compressed ==
+
+$QEMU_IMG convert -c -O $IMGFMT $TEST_IMG.orig $TEST_IMG
+_check_test_img
+
+echo
+echo == Checking compressed image virtual disk size ==
+
+_img_info | grep '^virtual size:'
+
+echo
+echo == Verifying the compressed image ==
+
+$QEMU_IO -c read -P0xa 0 512 $TEST_IMG | _filter_qemu_io
+
+# success, all done
+echo *** done
+rm -f $seq.full
+status=0
+
diff --git a/tests/qemu-iotests/053.out b/tests/qemu-iotests/053.out
new file mode 100644
index 000..16464e6
--- /dev/null
+++ b/tests/qemu-iotests/053.out
@@ -0,0 +1,17 @@
+QA output created by 053
+
+== Creating single sector image ==
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=512 
+wrote 512/512 bytes at offset 0
+512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+
+== Converting the image, compressed ==
+No errors were found on the image.
+
+== Checking compressed image virtual disk size ==
+virtual size: 512 (512 bytes)
+
+== Verifying the compressed image ==
+read 512/512 bytes at offset 0
+512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+*** done
diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group
index 324bacb..68eabda 100644
--- a/tests/qemu-iotests/group
+++ b/tests/qemu-iotests/group
@@ -59,3 +59,4 @@
 050 rw auto backing quick
 051 rw auto
 052 rw auto backing
+053 rw auto
-- 
1.8.1.4




[Qemu-devel] [PATCH v2 2/4] qcow: allow sub-cluster compressed write to last cluster

2013-04-16 Thread Stefan Hajnoczi
Compression in qcow requires image length to be a multiple of the
cluster size.  Lift this requirement by zero-padding the final cluster
when necessary.  The virtual disk size is still not cluster-aligned, so
the guest cannot access the zero sectors.

Note that this is almost identical to the qcow2 version of this code.
qcow2's compression code is drawn from qcow.

Signed-off-by: Stefan Hajnoczi stefa...@redhat.com
---
 block/qcow.c | 17 +++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/block/qcow.c b/block/qcow.c
index 3278e55..e2a64c7 100644
--- a/block/qcow.c
+++ b/block/qcow.c
@@ -787,8 +787,21 @@ static int qcow_write_compressed(BlockDriverState *bs, 
int64_t sector_num,
 uint8_t *out_buf;
 uint64_t cluster_offset;
 
-if (nb_sectors != s-cluster_sectors)
-return -EINVAL;
+if (nb_sectors != s-cluster_sectors) {
+ret = -EINVAL;
+
+/* Zero-pad last write if image size is not cluster aligned */
+if (sector_num + nb_sectors == bs-total_sectors 
+nb_sectors  s-cluster_sectors) {
+uint8_t *pad_buf = qemu_blockalign(bs, s-cluster_size);
+memset(pad_buf, 0, s-cluster_size);
+memcpy(pad_buf, buf, nb_sectors * BDRV_SECTOR_SIZE);
+ret = qcow_write_compressed(bs, sector_num,
+pad_buf, s-cluster_sectors);
+qemu_vfree(pad_buf);
+}
+return ret;
+}
 
 out_buf = g_malloc(s-cluster_size + (s-cluster_size / 1000) + 128);
 
-- 
1.8.1.4




Re: [Qemu-devel] [PATCH] qemu-char: another io_add_watch_poll fix

2013-04-16 Thread Gerd Hoffmann
On 04/10/13 15:23, Paolo Bonzini wrote:
 After attaching the source, we have to remove the reference we hold
 to it, because we do not hold anymore a pointer to the source.
 
 If we do not do this, removing the source will not finalize it and
 will not drop the real I/O watch source.
 
 This showed up when backporting the new flow control patches to older
 versions of QEMU that still used select.  The whole select then failed
 with EBADF (poll instead will reporting POLLNVAL on a single pollfd)
 and QEMU froze.

I get freezes now in master, bisecting points to this patch.

Reproducer: qemu -serial pty.

qemu is pretty much unusable with libvirt now as libvirt uses pty
chardevs by default for serial  monitor ...

(gdb) bt
#0  __lll_lock_wait () at
../nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:136
#1  0x7f4141ce7388 in _L_lock_854 () from /lib64/libpthread.so.0
#2  0x7f4141ce7257 in __pthread_mutex_lock (mutex=0x7f4145639128) at
pthread_mutex_lock.c:61
#3  0x7f4142f41c37 in ?? () from /lib64/libglib-2.0.so.0
#4  0x7f41439ff1b1 in io_watch_poll_finalize (source=value
optimized out)
at /home/kraxel/projects/qemu/qemu-char.c:647
#5  0x7f4142f4182a in ?? () from /lib64/libglib-2.0.so.0
#6  0x7f4142f41b85 in ?? () from /lib64/libglib-2.0.so.0
#7  0x7f4142f4416e in g_source_remove () from /lib64/libglib-2.0.so.0
#8  0x7f4143a02f38 in pty_chr_state (chr=0x7f4145644b70,
connected=value optimized out)
at /home/kraxel/projects/qemu/qemu-char.c:1151
#9  0x7f4143a0303c in pty_chr_read (chan=value optimized out,
cond=value optimized out,
opaque=0x7f4145644b70) at /home/kraxel/projects/qemu/qemu-char.c:1116
#10 0x7f4142f41f0e in g_main_context_dispatch () from
/lib64/libglib-2.0.so.0
#11 0x7f41439d8259 in glib_pollfds_poll (nonblocking=value
optimized out)
at /home/kraxel/projects/qemu/main-loop.c:187
#12 os_host_main_loop_wait (nonblocking=value optimized out)
at /home/kraxel/projects/qemu/main-loop.c:232
#13 main_loop_wait (nonblocking=value optimized out)
at /home/kraxel/projects/qemu/main-loop.c:468
#14 0x7f4143a4f055 in main_loop (argc=value optimized out,
argv=value optimized out,
envp=value optimized out) at /home/kraxel/projects/qemu/vl.c:2039
#15 main (argc=value optimized out, argv=value optimized out,
envp=value optimized out)
at /home/kraxel/projects/qemu/vl.c:4432

cheers,
  Gerd





Re: [Qemu-devel] [PATCH] pixman: remove -Wredundand-decls

2013-04-16 Thread Paolo Bonzini
Il 16/04/2013 09:57, Markus Armbruster ha scritto:

 I think this is just beautiful. Fedora18, x86_64, NO cross
 compiler. gcc does not apply -Wredundant-decls to /usr/include/* but
 does it for all other headers and in the case of cross compilation I
 hit this case.

'-Wsystem-headers'
 Print warning messages for constructs found in system header files.
 Warnings from system headers are normally suppressed, on the
 assumption that they usually do not indicate real problems and
 would only make the compiler output harder to read.

 Does anyone know the way to tell gcc that libc headers are not at
 /usr/include but somewhere else?

I think this helps:

'--sysroot=DIR'
 Use DIR as the logical root directory for headers and libraries.
 For example, if the compiler normally searches for headers in
 '/usr/include' and libraries in '/usr/lib', it instead searches
 'DIR/usr/include' and 'DIR/usr/lib'.

but you shouldn't need it.  Just configure your GCC with
--with-sysroot=/foo and it should just work.

Also:

 This workaround does NOT work if pragmas used. #pragma GCC diagnostic
 error -Wredundant-decls re-enables warnings as errors.

The solution is to use push/pop like this:

diff --git a/coroutine-ucontext.c b/coroutine-ucontext.c
index 867a662..4bf2cde 100644
--- a/coroutine-ucontext.c
+++ b/coroutine-ucontext.c
@@ -169,6 +169,7 @@ Coroutine *qemu_coroutine_new(void)
 #ifdef CONFIG_VALGRIND_H
 #ifdef CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE
 /* Work around an unused variable in the valgrind.h macro... */
+#pragma GCC diagnostic push
 #pragma GCC diagnostic ignored -Wunused-but-set-variable
 #endif
 static inline void valgrind_stack_deregister(CoroutineUContext *co)
@@ -176,7 +177,7 @@ static inline void
valgrind_stack_deregister(CoroutineUContext *co)
 VALGRIND_STACK_DEREGISTER(co-valgrind_stack_id);
 }
 #ifdef CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE
-#pragma GCC diagnostic error -Wunused-but-set-variable
+#pragma GCC diagnostic pop
 #endif
 #endif

diff --git a/include/ui/qemu-pixman.h b/include/ui/qemu-pixman.h
index b032f52..882e2a3 100644
--- a/include/ui/qemu-pixman.h
+++ b/include/ui/qemu-pixman.h
@@ -8,11 +8,12 @@

 /* pixman-0.16.0 headers have a redundant declaration */
 #ifdef CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE
+#pragma GCC diagnostic push
 #pragma GCC diagnostic ignored -Wredundant-decls
 #endif
 #include pixman.h
 #ifdef CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE
-#pragma GCC diagnostic error -Wredundant-decls
+#pragma GCC diagnostic pop
 #endif

 #include qemu/typedefs.h

Untested, feel free to resubmit with my Signed-off-by.

Paolo



Re: [Qemu-devel] SoC Idea: Xbox target

2013-04-16 Thread Stefan Hajnoczi
On Tue, Apr 16, 2013 at 11:03 AM, Niel van der Westhuizen
nielg...@gmail.com wrote:
 On 16 April 2013 18:27, Stefan Hajnoczi stefa...@gmail.com wrote:

 What is the current status of the xbox target and what would a 12-week
 GSoC project accomplish?  The scope of the project needs to be clearly
 defined so this information is critical.


 Currently it runs the bios to completion (which includes the fancy boot
 animation) and the dashboard runs, but nothing cool is displayed since the
 graphics code has OpenGL bugs that I need to track down.

 The rough todo has some discrete tasks that could be approached in
 isolation, but mostly it's just grinding through getting things working:
   -get shit rendering properly
 -fix /all/ the bugs :/
 -fragment shader generation from register combiners
 -fix vertex shader generation
 -create/destroy graphics context properly
   -get shit making sound properly
   -game controller (xpad) emulation/passthrough
   -fatx/xiso virtual block devices
   -make x86-x86 tcg not retarded slow or get useful kernel support on
 Windows if that's remotely feasible

There is no KVM support on Windows hosts.  On Linux hosts, KVM could
probably be used for fast execution.

If you're interested in improving TCG perhaps this could be a project
idea on its own, which helps your xbox target without touching the
legally questionable graphics and sound emulation.  The improvements
would benefit at least i386 TCG and possibly other targets too.  For
this project we'd need specific tasks and a mentor.  Do you have any
tasks in mind?

 Are just those two files questionable?  Could they be replaced with
 something that does not draw from leaked material?


 Yeah. Replaced? Could rename the registers, but that wouldn't really
 accomplish anything... I guess they'd have to be rewritten from scratch?
 That'd be quite an annoying amount of work :/

Yes.  It seems that the existing graphics and sound code would be hard
to merge into qemu.git.  Although people have emulated other console
hardware without much legal hassle, it gets risky when copyrighted
material is used which was obtained under some sort of contract or
license.

Stefan



Re: [Qemu-devel] [PATCH] qemu-char: another io_add_watch_poll fix

2013-04-16 Thread Paolo Bonzini
Il 16/04/2013 11:15, Gerd Hoffmann ha scritto:
 On 04/10/13 15:23, Paolo Bonzini wrote:
 After attaching the source, we have to remove the reference we hold
 to it, because we do not hold anymore a pointer to the source.

 If we do not do this, removing the source will not finalize it and
 will not drop the real I/O watch source.

 This showed up when backporting the new flow control patches to older
 versions of QEMU that still used select.  The whole select then failed
 with EBADF (poll instead will reporting POLLNVAL on a single pollfd)
 and QEMU froze.
 
 I get freezes now in master, bisecting points to this patch.
 
 Reproducer: qemu -serial pty.
 
 qemu is pretty much unusable with libvirt now as libvirt uses pty
 chardevs by default for serial  monitor ...

I'm not sure why all users of qemu_chr_fe_add_watch believe that the
watch will be one-shot.  This is definitely not what g_io_create_watch
does...

Paolo




[Qemu-devel] [PATCH 04/24] hw/vmware_vga.c: various vmware vga fixes.

2013-04-16 Thread Gerd Hoffmann
Hardcode depth to 32 bpp.  It effectively was that way before because
that is the default surface depth, this just makes it explicit in the
code.

Rename depth to new_depth to make it consistent with the new_width +
new_height names.  In theory we can make new_depth changeable (i.e.
allow the guest to fill in -- say -- 16 there).  In practice the guests
don't try, the X-Server refuses to start if you ask it to use 16bpp
depth (via DefaultDepth in the Screen section).

Always return the correct rmask+gmask+bmask values for the given
new_depth.

Fix mode setting to also verify at new_depth to make sure we have a
correct DisplaySurface, even if the current video mode happes to be
16bpp (set by vgabios via bochs vbe interface).  While being at it
switch over to use qemu_create_displaysurface_from, so the surface is
backed by guest-visible video memory and we save a memcpy.

Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 hw/display/vmware_vga.c |   57 +--
 trace-events|1 +
 2 files changed, 31 insertions(+), 27 deletions(-)

diff --git a/hw/display/vmware_vga.c b/hw/display/vmware_vga.c
index 20e3a28..05befe4 100644
--- a/hw/display/vmware_vga.c
+++ b/hw/display/vmware_vga.c
@@ -39,8 +39,6 @@ struct vmsvga_state_s {
 VGACommonState vga;
 
 int invalidated;
-int depth;
-int bypp;
 int enable;
 int config;
 struct {
@@ -55,6 +53,7 @@ struct vmsvga_state_s {
 uint32_t *scratch;
 int new_width;
 int new_height;
+int new_depth;
 uint32_t guest;
 uint32_t svgaid;
 int syncing;
@@ -721,6 +720,7 @@ static uint32_t vmsvga_value_read(void *opaque, uint32_t 
address)
 uint32_t caps;
 struct vmsvga_state_s *s = opaque;
 DisplaySurface *surface = qemu_console_surface(s-vga.con);
+PixelFormat pf;
 uint32_t ret;
 
 switch (s-index) {
@@ -733,11 +733,11 @@ static uint32_t vmsvga_value_read(void *opaque, uint32_t 
address)
 break;
 
 case SVGA_REG_WIDTH:
-ret = surface_width(surface);
+ret = s-new_width ? s-new_width : surface_width(surface);
 break;
 
 case SVGA_REG_HEIGHT:
-ret = surface_height(surface);
+ret = s-new_height ? s-new_height : surface_height(surface);
 break;
 
 case SVGA_REG_MAX_WIDTH:
@@ -749,11 +749,12 @@ static uint32_t vmsvga_value_read(void *opaque, uint32_t 
address)
 break;
 
 case SVGA_REG_DEPTH:
-ret = s-depth;
+ret = (s-new_depth == 32) ? 24 : s-new_depth;
 break;
 
 case SVGA_REG_BITS_PER_PIXEL:
-ret = (s-depth + 7)  ~7;
+case SVGA_REG_HOST_BITS_PER_PIXEL:
+ret = s-new_depth;
 break;
 
 case SVGA_REG_PSEUDOCOLOR:
@@ -761,19 +762,26 @@ static uint32_t vmsvga_value_read(void *opaque, uint32_t 
address)
 break;
 
 case SVGA_REG_RED_MASK:
-ret = surface-pf.rmask;
+pf = qemu_default_pixelformat(s-new_depth);
+ret = pf.rmask;
 break;
 
 case SVGA_REG_GREEN_MASK:
-ret = surface-pf.gmask;
+pf = qemu_default_pixelformat(s-new_depth);
+ret = pf.gmask;
 break;
 
 case SVGA_REG_BLUE_MASK:
-ret = surface-pf.bmask;
+pf = qemu_default_pixelformat(s-new_depth);
+ret = pf.bmask;
 break;
 
 case SVGA_REG_BYTES_PER_LINE:
-ret = s-bypp * s-new_width;
+if (s-new_width) {
+ret = (s-new_depth * s-new_width) / 8;
+} else {
+ret = surface_stride(surface);
+}
 break;
 
 case SVGA_REG_FB_START: {
@@ -852,10 +860,6 @@ static uint32_t vmsvga_value_read(void *opaque, uint32_t 
address)
 ret = s-cursor.on;
 break;
 
-case SVGA_REG_HOST_BITS_PER_PIXEL:
-ret = (s-depth + 7)  ~7;
-break;
-
 case SVGA_REG_SCRATCH_SIZE:
 ret = s-scratch_size;
 break;
@@ -936,9 +940,10 @@ static void vmsvga_value_write(void *opaque, uint32_t 
address, uint32_t value)
 break;
 
 case SVGA_REG_BITS_PER_PIXEL:
-if (value != s-depth) {
+if (value != 32) {
 printf(%s: Bad bits per pixel: %i bits\n, __func__, value);
 s-config = 0;
+s-invalidated = 1;
 }
 break;
 
@@ -1034,8 +1039,14 @@ static inline void vmsvga_check_size(struct 
vmsvga_state_s *s)
 DisplaySurface *surface = qemu_console_surface(s-vga.con);
 
 if (s-new_width != surface_width(surface) ||
-s-new_height != surface_height(surface)) {
-qemu_console_resize(s-vga.con, s-new_width, s-new_height);
+s-new_height != surface_height(surface) ||
+s-new_depth != surface_bits_per_pixel(surface)) {
+int stride = (s-new_depth * s-new_width) / 8;
+trace_vmware_setmode(s-new_width, s-new_height, s-new_depth);
+surface = qemu_create_displaysurface_from(s-new_width, s-new_height,
+  s-new_depth, stride,

[Qemu-devel] [PATCH 11/24] console: displaystate init revamp

2013-04-16 Thread Gerd Hoffmann
We have only one DisplayState, so there is no need for the next
linking, rip it.  Also consolidate all displaystate initialization
into init_displaystate().  This function is called by vl.c after
creating the devices (and thus all QemuConsoles) and before
initializing DisplayChangeListensers (aka gtk/sdl/vnc/spice ui).

Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 include/ui/console.h |5 +---
 ui/console.c |   73 +++---
 vl.c |6 +
 3 files changed, 36 insertions(+), 48 deletions(-)

diff --git a/include/ui/console.h b/include/ui/console.h
index a234c72..3725dae 100644
--- a/include/ui/console.h
+++ b/include/ui/console.h
@@ -189,12 +189,9 @@ struct DisplayState {
 bool have_text;
 
 QLIST_HEAD(, DisplayChangeListener) listeners;
-
-struct DisplayState *next;
 };
 
-void register_displaystate(DisplayState *ds);
-DisplayState *get_displaystate(void);
+DisplayState *init_displaystate(void);
 DisplaySurface* qemu_create_displaysurface_from(int width, int height, int bpp,
 int linesize, uint8_t *data,
 bool byteswap);
diff --git a/ui/console.c b/ui/console.c
index 3834e39..e100593 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -163,6 +163,8 @@ static QemuConsole *active_console;
 static QemuConsole *consoles[MAX_CONSOLES];
 static int nb_consoles = 0;
 
+static void text_console_do_init(CharDriverState *chr, DisplayState *ds);
+
 void vga_hw_update(void)
 {
 if (active_console  active_console-hw_update)
@@ -1323,39 +1325,37 @@ bool dpy_cursor_define_supported(QemuConsole *con)
 return false;
 }
 
-static void dumb_display_init(void)
-{
-DisplayState *ds = g_malloc0(sizeof(DisplayState));
-int width = 640;
-int height = 480;
-
-if (is_fixedsize_console()) {
-width = active_console-g_width;
-height = active_console-g_height;
-}
-ds-surface = qemu_create_displaysurface(width, height);
-
-register_displaystate(ds);
-}
-
 /***/
 /* register display */
 
-void register_displaystate(DisplayState *ds)
+/* console.c internal use only */
+static DisplayState *get_alloc_displaystate(void)
 {
-DisplayState **s;
-s = display_state;
-while (*s != NULL)
-s = (*s)-next;
-ds-next = NULL;
-*s = ds;
+if (!display_state) {
+display_state = g_new0(DisplayState, 1);
+}
+return display_state;
 }
 
-DisplayState *get_displaystate(void)
+/*
+ * Called by main(), after creating QemuConsoles
+ * and before initializing ui (sdl/vnc/...).
+ */
+DisplayState *init_displaystate(void)
 {
+int i;
+
 if (!display_state) {
-dumb_display_init ();
+display_state = g_new0(DisplayState, 1);
 }
+
+for (i = 0; i  nb_consoles; i++) {
+if (consoles[i]-console_type != GRAPHIC_CONSOLE 
+consoles[i]-ds == NULL) {
+text_console_do_init(consoles[i]-chr, display_state);
+}
+}
+
 return display_state;
 }
 
@@ -1365,10 +1365,12 @@ QemuConsole *graphic_console_init(vga_hw_update_ptr 
update,
   vga_hw_text_update_ptr text_update,
   void *opaque)
 {
+int width = 640;
+int height = 480;
 QemuConsole *s;
 DisplayState *ds;
 
-ds = (DisplayState *) g_malloc0(sizeof(DisplayState));
+ds = get_alloc_displaystate();
 trace_console_gfx_new();
 s = new_console(ds, GRAPHIC_CONSOLE);
 s-hw_update = update;
@@ -1377,9 +1379,9 @@ QemuConsole *graphic_console_init(vga_hw_update_ptr 
update,
 s-hw_text_update = text_update;
 s-hw = opaque;
 
-ds-surface = qemu_create_displaysurface(640, 480);
-
-register_displaystate(ds);
+if (!ds-surface) {
+ds-surface = qemu_create_displaysurface(width, height);
+}
 return s;
 }
 
@@ -1505,6 +1507,10 @@ static CharDriverState *text_console_init(ChardevVC *vc)
 s-g_height = height;
 chr-opaque = s;
 chr-chr_set_echo = text_console_set_echo;
+
+if (display_state) {
+text_console_do_init(chr, display_state);
+}
 return chr;
 }
 
@@ -1520,17 +1526,6 @@ void register_vc_handler(VcHandler *handler)
 vc_handler = handler;
 }
 
-void text_consoles_set_display(DisplayState *ds)
-{
-int i;
-
-for (i = 0; i  nb_consoles; i++) {
-if (consoles[i]-console_type != GRAPHIC_CONSOLE) {
-text_console_do_init(consoles[i]-chr, ds);
-}
-}
-}
-
 void qemu_console_resize(QemuConsole *s, int width, int height)
 {
 s-g_width = width;
diff --git a/vl.c b/vl.c
index 0598998..63fe9a4 100644
--- a/vl.c
+++ b/vl.c
@@ -4331,8 +4331,7 @@ int main(int argc, char **argv, char **envp)
 
 net_check_clients();
 
-/* just use the first displaystate for the moment */
-ds = get_displaystate();
+ds = init_displaystate();
 
 /* 

[Qemu-devel] [PATCH 03/24] hw/vmware_vga.c: add tracepoints for mmio reads+writes

2013-04-16 Thread Gerd Hoffmann
Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 hw/display/vmware_vga.c |  112 +--
 trace-events|6 +++
 2 files changed, 86 insertions(+), 32 deletions(-)

diff --git a/hw/display/vmware_vga.c b/hw/display/vmware_vga.c
index 2233a8b..20e3a28 100644
--- a/hw/display/vmware_vga.c
+++ b/hw/display/vmware_vga.c
@@ -721,61 +721,79 @@ static uint32_t vmsvga_value_read(void *opaque, uint32_t 
address)
 uint32_t caps;
 struct vmsvga_state_s *s = opaque;
 DisplaySurface *surface = qemu_console_surface(s-vga.con);
+uint32_t ret;
 
 switch (s-index) {
 case SVGA_REG_ID:
-return s-svgaid;
+ret = s-svgaid;
+break;
 
 case SVGA_REG_ENABLE:
-return s-enable;
+ret = s-enable;
+break;
 
 case SVGA_REG_WIDTH:
-return surface_width(surface);
+ret = surface_width(surface);
+break;
 
 case SVGA_REG_HEIGHT:
-return surface_height(surface);
+ret = surface_height(surface);
+break;
 
 case SVGA_REG_MAX_WIDTH:
-return SVGA_MAX_WIDTH;
+ret = SVGA_MAX_WIDTH;
+break;
 
 case SVGA_REG_MAX_HEIGHT:
-return SVGA_MAX_HEIGHT;
+ret = SVGA_MAX_HEIGHT;
+break;
 
 case SVGA_REG_DEPTH:
-return s-depth;
+ret = s-depth;
+break;
 
 case SVGA_REG_BITS_PER_PIXEL:
-return (s-depth + 7)  ~7;
+ret = (s-depth + 7)  ~7;
+break;
 
 case SVGA_REG_PSEUDOCOLOR:
-return 0x0;
+ret = 0x0;
+break;
 
 case SVGA_REG_RED_MASK:
-return surface-pf.rmask;
+ret = surface-pf.rmask;
+break;
 
 case SVGA_REG_GREEN_MASK:
-return surface-pf.gmask;
+ret = surface-pf.gmask;
+break;
 
 case SVGA_REG_BLUE_MASK:
-return surface-pf.bmask;
+ret = surface-pf.bmask;
+break;
 
 case SVGA_REG_BYTES_PER_LINE:
-return s-bypp * s-new_width;
+ret = s-bypp * s-new_width;
+break;
 
 case SVGA_REG_FB_START: {
 struct pci_vmsvga_state_s *pci_vmsvga
 = container_of(s, struct pci_vmsvga_state_s, chip);
-return pci_get_bar_addr(pci_vmsvga-card, 1);
+ret = pci_get_bar_addr(pci_vmsvga-card, 1);
+break;
 }
 
 case SVGA_REG_FB_OFFSET:
-return 0x0;
+ret = 0x0;
+break;
 
 case SVGA_REG_VRAM_SIZE:
-return s-vga.vram_size; /* No physical VRAM besides the framebuffer */
+ret = s-vga.vram_size; /* No physical VRAM besides the framebuffer */
+break;
 
 case SVGA_REG_FB_SIZE:
-return s-vga.vram_size;
+ret = s-vga.vram_size;
+break;
 
 case SVGA_REG_CAPABILITIES:
 caps = SVGA_CAP_NONE;
@@ -791,66 +809,96 @@ static uint32_t vmsvga_value_read(void *opaque, uint32_t 
address)
 SVGA_CAP_CURSOR_BYPASS;
 }
 #endif
-return caps;
+ret = caps;
+break;
 
 case SVGA_REG_MEM_START: {
 struct pci_vmsvga_state_s *pci_vmsvga
 = container_of(s, struct pci_vmsvga_state_s, chip);
-return pci_get_bar_addr(pci_vmsvga-card, 2);
+ret = pci_get_bar_addr(pci_vmsvga-card, 2);
+break;
 }
 
 case SVGA_REG_MEM_SIZE:
-return s-fifo_size;
+ret = s-fifo_size;
+break;
 
 case SVGA_REG_CONFIG_DONE:
-return s-config;
+ret = s-config;
+break;
 
 case SVGA_REG_SYNC:
 case SVGA_REG_BUSY:
-return s-syncing;
+ret = s-syncing;
+break;
 
 case SVGA_REG_GUEST_ID:
-return s-guest;
+ret = s-guest;
+break;
 
 case SVGA_REG_CURSOR_ID:
-return s-cursor.id;
+ret = s-cursor.id;
+break;
 
 case SVGA_REG_CURSOR_X:
-return s-cursor.x;
+ret = s-cursor.x;
+break;
 
 case SVGA_REG_CURSOR_Y:
-return s-cursor.x;
+ret = s-cursor.x;
+break;
 
 case SVGA_REG_CURSOR_ON:
-return s-cursor.on;
+ret = s-cursor.on;
+break;
 
 case SVGA_REG_HOST_BITS_PER_PIXEL:
-return (s-depth + 7)  ~7;
+ret = (s-depth + 7)  ~7;
+break;
 
 case SVGA_REG_SCRATCH_SIZE:
-return s-scratch_size;
+ret = s-scratch_size;
+break;
 
 case SVGA_REG_MEM_REGS:
 case SVGA_REG_NUM_DISPLAYS:
 case SVGA_REG_PITCHLOCK:
 case SVGA_PALETTE_BASE ... SVGA_PALETTE_END:
-return 0;
+ret = 0;
+break;
 
 default:
 if (s-index = SVGA_SCRATCH_BASE 
 s-index  SVGA_SCRATCH_BASE + s-scratch_size) {
-return s-scratch[s-index - SVGA_SCRATCH_BASE];
+ret = s-scratch[s-index - SVGA_SCRATCH_BASE];
+break;
 }
 printf(%s: Bad register %02x\n, __func__, s-index);
+ret = 0;
+break;
 }
 
-return 0;
+if (s-index = 

[Qemu-devel] [PATCH 02/24] hw/vmware_vga.c: fix screen resize bug introduced after console revamp

2013-04-16 Thread Gerd Hoffmann
From: Igor Mitsyanko i.mitsya...@gmail.com

In vmsvga display update function, a pointer to DisplaySurface must be acquired
after a call to vmsvga_check_size since this function might replace current
DisplaySurface with a new one.

Signed-off-by: Igor Mitsyanko i.mitsya...@gmail.com
Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 hw/display/vmware_vga.c |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/hw/display/vmware_vga.c b/hw/display/vmware_vga.c
index bcad47a..2233a8b 100644
--- a/hw/display/vmware_vga.c
+++ b/hw/display/vmware_vga.c
@@ -995,7 +995,7 @@ static inline void vmsvga_check_size(struct vmsvga_state_s 
*s)
 static void vmsvga_update_display(void *opaque)
 {
 struct vmsvga_state_s *s = opaque;
-DisplaySurface *surface = qemu_console_surface(s-vga.con);
+DisplaySurface *surface;
 bool dirty = false;
 
 if (!s-enable) {
@@ -1004,6 +1004,7 @@ static void vmsvga_update_display(void *opaque)
 }
 
 vmsvga_check_size(s);
+surface = qemu_console_surface(s-vga.con);
 
 vmsvga_fifo_run(s);
 vmsvga_update_rect_flush(s);
-- 
1.7.9.7




[Qemu-devel] [PATCH 05/24] pixman: add qemu_pixman_color()

2013-04-16 Thread Gerd Hoffmann
Helper function to map qemu colors (32bit integer + matching PixelFormat)
into pixman_color_t.

Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 include/ui/qemu-pixman.h |2 ++
 ui/qemu-pixman.c |   11 +++
 2 files changed, 13 insertions(+)

diff --git a/include/ui/qemu-pixman.h b/include/ui/qemu-pixman.h
index b032f52..b0f09b5 100644
--- a/include/ui/qemu-pixman.h
+++ b/include/ui/qemu-pixman.h
@@ -43,4 +43,6 @@ pixman_image_t 
*qemu_pixman_mirror_create(pixman_format_code_t format,
   pixman_image_t *image);
 void qemu_pixman_image_unref(pixman_image_t *image);
 
+pixman_color_t qemu_pixman_color(PixelFormat *pf, uint32_t color);
+
 #endif /* QEMU_PIXMAN_H */
diff --git a/ui/qemu-pixman.c b/ui/qemu-pixman.c
index 6dcbe90..be551e0 100644
--- a/ui/qemu-pixman.c
+++ b/ui/qemu-pixman.c
@@ -79,3 +79,14 @@ void qemu_pixman_image_unref(pixman_image_t *image)
 }
 pixman_image_unref(image);
 }
+
+pixman_color_t qemu_pixman_color(PixelFormat *pf, uint32_t color)
+{
+pixman_color_t c;
+
+c.red   = ((color  pf-rmask)  pf-rshift)  (16 - pf-rbits);
+c.green = ((color  pf-gmask)  pf-gshift)  (16 - pf-gbits);
+c.blue  = ((color  pf-bmask)  pf-bshift)  (16 - pf-bbits);
+c.alpha = ((color  pf-amask)  pf-ashift)  (16 - pf-abits);
+return c;
+}
-- 
1.7.9.7




[Qemu-devel] [PATCH 07/24] console: use pixman for fill+blit

2013-04-16 Thread Gerd Hoffmann
Zap homegrown pixel shuffeling code, use pixman calls instead.

Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 ui/console.c |   65 +-
 1 file changed, 10 insertions(+), 55 deletions(-)

diff --git a/ui/console.c b/ui/console.c
index 0ed4211..be7f4f1 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -213,36 +213,14 @@ static void vga_fill_rect(QemuConsole *con,
   uint32_t color)
 {
 DisplaySurface *surface = qemu_console_surface(con);
-uint8_t *d, *d1;
-int x, y, bpp;
+pixman_rectangle16_t rect = {
+.x = posx, .y = posy, .width = width, .height = height
+};
+pixman_color_t pcolor;
 
-bpp = surface_bytes_per_pixel(surface);
-d1 = surface_data(surface) +
-surface_stride(surface) * posy + bpp * posx;
-for (y = 0; y  height; y++) {
-d = d1;
-switch(bpp) {
-case 1:
-for (x = 0; x  width; x++) {
-*((uint8_t *)d) = color;
-d++;
-}
-break;
-case 2:
-for (x = 0; x  width; x++) {
-*((uint16_t *)d) = color;
-d += 2;
-}
-break;
-case 4:
-for (x = 0; x  width; x++) {
-*((uint32_t *)d) = color;
-d += 4;
-}
-break;
-}
-d1 += surface_stride(surface);
-}
+pcolor = qemu_pixman_color(surface-pf, color);
+pixman_image_fill_rectangles(PIXMAN_OP_SRC, surface-image,
+ pcolor, 1, rect);
 }
 
 /* copy from (xs, ys) to (xd, yd) a rectangle of size (w, h) */
@@ -250,33 +228,10 @@ static void vga_bitblt(QemuConsole *con,
int xs, int ys, int xd, int yd, int w, int h)
 {
 DisplaySurface *surface = qemu_console_surface(con);
-const uint8_t *s;
-uint8_t *d;
-int wb, y, bpp;
 
-bpp = surface_bytes_per_pixel(surface);
-wb = w * bpp;
-if (yd = ys) {
-s = surface_data(surface) +
-surface_stride(surface) * ys + bpp * xs;
-d = surface_data(surface) +
-surface_stride(surface) * yd + bpp * xd;
-for (y = 0; y  h; y++) {
-memmove(d, s, wb);
-d += surface_stride(surface);
-s += surface_stride(surface);
-}
-} else {
-s = surface_data(surface) +
-surface_stride(surface) * (ys + h - 1) + bpp * xs;
-d = surface_data(surface) +
-surface_stride(surface) * (yd + h - 1) + bpp * xd;
-   for (y = 0; y  h; y++) {
-memmove(d, s, wb);
-d -= surface_stride(surface);
-s -= surface_stride(surface);
-}
-}
+pixman_image_composite(PIXMAN_OP_SRC,
+   surface-image, NULL, surface-image,
+   xs, ys, 0, 0, xd, yd, w, h);
 }
 
 /***/
-- 
1.7.9.7




[Qemu-devel] [PATCH 08/24] console: use pixman for font rendering

2013-04-16 Thread Gerd Hoffmann
Zap homegrown font rendering code, use pixman calls instead.

Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 ui/console.c |  110 ++
 1 file changed, 11 insertions(+), 99 deletions(-)

diff --git a/ui/console.c b/ui/console.c
index be7f4f1..584f069 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -242,45 +242,6 @@ static void vga_bitblt(QemuConsole *con,
 
 #include vgafont.h
 
-#define cbswap_32(__x) \
-((uint32_t)( \
-   (((uint32_t)(__x)  (uint32_t)0x00ffUL)  24) | \
-   (((uint32_t)(__x)  (uint32_t)0xff00UL)   8) | \
-   (((uint32_t)(__x)  (uint32_t)0x00ffUL)   8) | \
-   (((uint32_t)(__x)  (uint32_t)0xff00UL)  24) ))
-
-#ifdef HOST_WORDS_BIGENDIAN
-#define PAT(x) x
-#else
-#define PAT(x) cbswap_32(x)
-#endif
-
-static const uint32_t dmask16[16] = {
-PAT(0x),
-PAT(0x00ff),
-PAT(0xff00),
-PAT(0x),
-PAT(0x00ff),
-PAT(0x00ff00ff),
-PAT(0x0000),
-PAT(0x00ff),
-PAT(0xff00),
-PAT(0xffff),
-PAT(0xff00ff00),
-PAT(0xff00),
-PAT(0x),
-PAT(0x00ff),
-PAT(0xff00),
-PAT(0x),
-};
-
-static const uint32_t dmask4[4] = {
-PAT(0x),
-PAT(0x),
-PAT(0x),
-PAT(0x),
-};
-
 #ifndef CONFIG_CURSES
 enum color_names {
 COLOR_BLACK   = 0,
@@ -353,17 +314,11 @@ static void console_print_text_attributes(TextAttributes 
*t_attrib, char ch)
 static void vga_putcharxy(QemuConsole *s, int x, int y, int ch,
   TextAttributes *t_attrib)
 {
+static pixman_image_t *glyphs[256];
 DisplaySurface *surface = qemu_console_surface(s);
-uint8_t *d;
-const uint8_t *font_ptr;
-unsigned int font_data, linesize, xorcol, bpp;
-int i;
 unsigned int fgcol, bgcol;
-
-#ifdef DEBUG_CONSOLE
-printf(x: %2i y: %2i, x, y);
-console_print_text_attributes(t_attrib, ch);
-#endif
+pixman_image_t *ifg, *ibg;
+pixman_color_t cfg, cbg;
 
 if (t_attrib-invers) {
 bgcol = color_table_rgb[t_attrib-bold][t_attrib-fgcol];
@@ -372,59 +327,16 @@ static void vga_putcharxy(QemuConsole *s, int x, int y, 
int ch,
 fgcol = color_table_rgb[t_attrib-bold][t_attrib-fgcol];
 bgcol = color_table_rgb[t_attrib-bold][t_attrib-bgcol];
 }
+cfg = qemu_pixman_color(surface-pf, fgcol);
+cbg = qemu_pixman_color(surface-pf, bgcol);
+ifg = pixman_image_create_solid_fill(cfg);
+ibg = pixman_image_create_solid_fill(cbg);
 
-bpp = surface_bytes_per_pixel(surface);
-d = surface_data(surface) +
-surface_stride(surface) * y * FONT_HEIGHT + bpp * x * FONT_WIDTH;
-linesize = surface_stride(surface);
-font_ptr = vgafont16 + FONT_HEIGHT * ch;
-xorcol = bgcol ^ fgcol;
-switch (surface_bits_per_pixel(surface)) {
-case 8:
-for(i = 0; i  FONT_HEIGHT; i++) {
-font_data = *font_ptr++;
-if (t_attrib-uline
- ((i == FONT_HEIGHT - 2) || (i == FONT_HEIGHT - 3))) {
-font_data = 0xFF;
-}
-((uint32_t *)d)[0] = (dmask16[(font_data  4)]  xorcol) ^ bgcol;
-((uint32_t *)d)[1] = (dmask16[(font_data  0)  0xf]  xorcol) ^ 
bgcol;
-d += linesize;
-}
-break;
-case 16:
-case 15:
-for(i = 0; i  FONT_HEIGHT; i++) {
-font_data = *font_ptr++;
-if (t_attrib-uline
- ((i == FONT_HEIGHT - 2) || (i == FONT_HEIGHT - 3))) {
-font_data = 0xFF;
-}
-((uint32_t *)d)[0] = (dmask4[(font_data  6)]  xorcol) ^ bgcol;
-((uint32_t *)d)[1] = (dmask4[(font_data  4)  3]  xorcol) ^ 
bgcol;
-((uint32_t *)d)[2] = (dmask4[(font_data  2)  3]  xorcol) ^ 
bgcol;
-((uint32_t *)d)[3] = (dmask4[(font_data  0)  3]  xorcol) ^ 
bgcol;
-d += linesize;
-}
-break;
-case 32:
-for(i = 0; i  FONT_HEIGHT; i++) {
-font_data = *font_ptr++;
-if (t_attrib-uline  ((i == FONT_HEIGHT - 2) || (i == 
FONT_HEIGHT - 3))) {
-font_data = 0xFF;
-}
-((uint32_t *)d)[0] = (-((font_data  7))  xorcol) ^ bgcol;
-((uint32_t *)d)[1] = (-((font_data  6)  1)  xorcol) ^ bgcol;
-((uint32_t *)d)[2] = (-((font_data  5)  1)  xorcol) ^ bgcol;
-((uint32_t *)d)[3] = (-((font_data  4)  1)  xorcol) ^ bgcol;
-((uint32_t *)d)[4] = (-((font_data  3)  1)  xorcol) ^ bgcol;
-((uint32_t *)d)[5] = (-((font_data  2)  1)  xorcol) ^ bgcol;
-((uint32_t *)d)[6] = (-((font_data  1)  1)  xorcol) ^ bgcol;
-((uint32_t *)d)[7] = (-((font_data  0)  1)  xorcol) ^ bgcol;
-d += linesize;
-}
-break;
+if (!glyphs[ch]) {
+glyphs[ch] = qemu_pixman_glyph_from_vgafont(FONT_HEIGHT, vgafont16, 
ch);

[Qemu-devel] [PATCH 13/24] console: give each QemuConsole its own DisplaySurface

2013-04-16 Thread Gerd Hoffmann
Go away from the global DisplaySurface, give one to each QemuConsole
instead.  With this patch applied it is possible to call
graphics_hw_* functions with qemu consoles which are not the current
foreground console.

Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 include/ui/console.h |1 -
 ui/console.c |   96 --
 2 files changed, 69 insertions(+), 28 deletions(-)

diff --git a/include/ui/console.h b/include/ui/console.h
index 9c585c0..0dd66fd 100644
--- a/include/ui/console.h
+++ b/include/ui/console.h
@@ -183,7 +183,6 @@ struct DisplayChangeListener {
 };
 
 struct DisplayState {
-struct DisplaySurface *surface;
 struct QEMUTimer *gui_timer;
 bool have_gfx;
 bool have_text;
diff --git a/ui/console.c b/ui/console.c
index dccc618..e8e548e 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -116,6 +116,7 @@ struct QemuConsole {
 int index;
 console_type_t console_type;
 DisplayState *ds;
+DisplaySurface *surface;
 
 /* Graphic console state.  */
 graphic_hw_update_ptr hw_update;
@@ -164,6 +165,8 @@ static QemuConsole *consoles[MAX_CONSOLES];
 static int nb_consoles = 0;
 
 static void text_console_do_init(CharDriverState *chr, DisplayState *ds);
+static void dpy_gfx_switch_surface(DisplayState *ds,
+   DisplaySurface *surface);
 
 void graphic_hw_update(QemuConsole *con)
 {
@@ -933,8 +936,9 @@ void console_select(unsigned int index)
 }
 active_console = s;
 if (ds-have_gfx) {
-surface = qemu_create_displaysurface(s-g_width, s-g_height);
-dpy_gfx_replace_surface(s, surface);
+dpy_gfx_switch_surface(ds, s-surface);
+dpy_gfx_update(s, 0, 0, surface_width(s-surface),
+   surface_height(s-surface));
 }
 if (ds-have_text) {
 dpy_text_resize(s, s-width, s-height);
@@ -943,7 +947,6 @@ void console_select(unsigned int index)
 qemu_mod_timer(s-cursor_timer,
qemu_get_clock_ms(rt_clock) + CONSOLE_CURSOR_PERIOD / 2);
 }
-graphic_hw_invalidate(s);
 }
 }
 
@@ -1195,8 +1198,8 @@ void register_displaychangelistener(DisplayState *ds,
 dcl-ds = ds;
 QLIST_INSERT_HEAD(ds-listeners, dcl, next);
 gui_setup_refresh(ds);
-if (dcl-ops-dpy_gfx_switch) {
-dcl-ops-dpy_gfx_switch(dcl, ds-surface);
+if (dcl-ops-dpy_gfx_switch  active_console) {
+dcl-ops-dpy_gfx_switch(dcl, active_console-surface);
 }
 }
 
@@ -1212,8 +1215,8 @@ void dpy_gfx_update(QemuConsole *con, int x, int y, int 
w, int h)
 {
 DisplayState *s = con-ds;
 struct DisplayChangeListener *dcl;
-int width = pixman_image_get_width(s-surface-image);
-int height = pixman_image_get_height(s-surface-image);
+int width = surface_width(con-surface);
+int height = surface_height(con-surface);
 
 x = MAX(x, 0);
 y = MAX(y, 0);
@@ -1222,6 +1225,9 @@ void dpy_gfx_update(QemuConsole *con, int x, int y, int 
w, int h)
 w = MIN(w, width - x);
 h = MIN(h, height - y);
 
+if (con != active_console) {
+return;
+}
 QLIST_FOREACH(dcl, s-listeners, next) {
 if (dcl-ops-dpy_gfx_update) {
 dcl-ops-dpy_gfx_update(dcl, x, y, w, h);
@@ -1229,19 +1235,28 @@ void dpy_gfx_update(QemuConsole *con, int x, int y, int 
w, int h)
 }
 }
 
-void dpy_gfx_replace_surface(QemuConsole *con,
- DisplaySurface *surface)
+static void dpy_gfx_switch_surface(DisplayState *ds,
+   DisplaySurface *surface)
 {
-DisplayState *s = con-ds;
-DisplaySurface *old_surface = s-surface;
 struct DisplayChangeListener *dcl;
 
-s-surface = surface;
-QLIST_FOREACH(dcl, s-listeners, next) {
+QLIST_FOREACH(dcl, ds-listeners, next) {
 if (dcl-ops-dpy_gfx_switch) {
 dcl-ops-dpy_gfx_switch(dcl, surface);
 }
 }
+}
+
+void dpy_gfx_replace_surface(QemuConsole *con,
+ DisplaySurface *surface)
+{
+DisplayState *s = con-ds;
+DisplaySurface *old_surface = con-surface;
+
+con-surface = surface;
+if (con == active_console) {
+dpy_gfx_switch_surface(s, surface);
+}
 qemu_free_displaysurface(old_surface);
 }
 
@@ -1260,6 +1275,10 @@ void dpy_gfx_copy(QemuConsole *con, int src_x, int src_y,
 {
 DisplayState *s = con-ds;
 struct DisplayChangeListener *dcl;
+
+if (con != active_console) {
+return;
+}
 QLIST_FOREACH(dcl, s-listeners, next) {
 if (dcl-ops-dpy_gfx_copy) {
 dcl-ops-dpy_gfx_copy(dcl, src_x, src_y, dst_x, dst_y, w, h);
@@ -1273,6 +1292,10 @@ void dpy_text_cursor(QemuConsole *con, int x, int y)
 {
 DisplayState *s = con-ds;
 struct DisplayChangeListener *dcl;
+
+if (con != active_console) {
+return;
+}
 QLIST_FOREACH(dcl, s-listeners, next) {
 if 

[Qemu-devel] [PATCH 01/24] exynos4210_fimd.c: fix display resize bug introduced after console revamp

2013-04-16 Thread Gerd Hoffmann
From: Igor Mitsyanko i.mitsya...@gmail.com

In exynos4210 display update function, we were acquiring DisplaySurface
pointer before calling screen resize function, not paying attention that resize
procedure can replace current DisplaySurface with newly allocated one.
Right thing to do is to initialize DisplaySurface AFTER a call to resize 
function.

Signed-off-by: Igor Mitsyanko i.mitsya...@gmail.com
Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 hw/display/exynos4210_fimd.c |7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/hw/display/exynos4210_fimd.c b/hw/display/exynos4210_fimd.c
index 49cca4b..7e1cbb6 100644
--- a/hw/display/exynos4210_fimd.c
+++ b/hw/display/exynos4210_fimd.c
@@ -1242,7 +1242,7 @@ static void 
exynos4210_update_resolution(Exynos4210fimdState *s)
 static void exynos4210_fimd_update(void *opaque)
 {
 Exynos4210fimdState *s = (Exynos4210fimdState *)opaque;
-DisplaySurface *surface = qemu_console_surface(s-console);
+DisplaySurface *surface;
 Exynos4210fimdWindow *w;
 int i, line;
 hwaddr fb_line_addr, inc_size;
@@ -1255,11 +1255,12 @@ static void exynos4210_fimd_update(void *opaque)
 const int global_height = ((s-vidtcon[2]  FIMD_VIDTCON2_VER_SHIFT) 
 FIMD_VIDTCON2_SIZE_MASK) + 1;
 
-if (!s || !s-console || !surface_bits_per_pixel(surface) ||
-!s-enabled) {
+if (!s || !s-console || !s-enabled ||
+surface_bits_per_pixel(qemu_console_surface(s-console)) == 0) {
 return;
 }
 exynos4210_update_resolution(s);
+surface = qemu_console_surface(s-console);
 
 for (i = 0; i  NUM_OF_WINDOWS; i++) {
 w = s-window[i];
-- 
1.7.9.7




[Qemu-devel] [PATCH 20/24] xen: re-enable refresh interval reporting for xenfb

2013-04-16 Thread Gerd Hoffmann
xenfb informs the guest about the gui refresh interval so it can avoid
pointless work.  That logic was temporarely disabled for the
DisplayState reorganization.  Restore it now, with a proper interface
for it.

Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 hw/display/xenfb.c   |   56 +++---
 include/ui/console.h |1 +
 ui/console.c |6 ++
 3 files changed, 24 insertions(+), 39 deletions(-)

diff --git a/hw/display/xenfb.c b/hw/display/xenfb.c
index 8d327f1..f2eb89f 100644
--- a/hw/display/xenfb.c
+++ b/hw/display/xenfb.c
@@ -78,7 +78,6 @@ struct XenFB {
 void  *pixels;
 int   fbpages;
 int   feature_update;
-int   refresh_period;
 int   bug_trigger;
 int   have_console;
 int   do_resize;
@@ -646,7 +645,7 @@ static void xenfb_guest_copy(struct XenFB *xenfb, int x, 
int y, int w, int h)
 dpy_gfx_update(xenfb-c.con, x, y, w, h);
 }
 
-#if 0 /* def XENFB_TYPE_REFRESH_PERIOD */
+#ifdef XENFB_TYPE_REFRESH_PERIOD
 static int xenfb_queue_full(struct XenFB *xenfb)
 {
 struct xenfb_page *page = xenfb-c.page;
@@ -704,39 +703,7 @@ static void xenfb_update(void *opaque)
 if (xenfb-c.xendev.be_state != XenbusStateConnected)
 return;
 
-if (xenfb-feature_update) {
-#if 0 /* XENFB_TYPE_REFRESH_PERIOD */
-struct DisplayChangeListener *l;
-int period = ;
-int idle = 1;
-
-   if (xenfb_queue_full(xenfb))
-   return;
-
-QLIST_FOREACH(l, xenfb-c.ds-listeners, next) {
-if (l-idle)
-continue;
-idle = 0;
-if (!l-gui_timer_interval) {
-if (period  GUI_REFRESH_INTERVAL)
-period = GUI_REFRESH_INTERVAL;
-} else {
-if (period  l-gui_timer_interval)
-period = l-gui_timer_interval;
-}
-}
-if (idle)
-   period = XENFB_NO_REFRESH;
-
-   if (xenfb-refresh_period != period) {
-   xenfb_send_refresh_period(xenfb, period);
-   xenfb-refresh_period = period;
-xen_be_printf(xenfb-c.xendev, 1, refresh period: %d\n, period);
-   }
-#else
-   ; /* nothing */
-#endif
-} else {
+if (!xenfb-feature_update) {
/* we don't get update notifications, thus use the
 * sledge hammer approach ... */
xenfb-up_fullscreen = 1;
@@ -785,6 +752,20 @@ static void xenfb_update(void *opaque)
 xenfb-up_fullscreen = 0;
 }
 
+static void xenfb_update_interval(void *opaque, uint64_t interval)
+{
+struct XenFB *xenfb = opaque;
+
+if (xenfb-feature_update) {
+#ifdef XENFB_TYPE_REFRESH_PERIOD
+if (xenfb_queue_full(xenfb)) {
+return;
+}
+xenfb_send_refresh_period(xenfb, interval);
+#endif
+}
+}
+
 /* QEMU display state changed, so refresh the framebuffer copy */
 static void xenfb_invalidate(void *opaque)
 {
@@ -858,10 +839,6 @@ static void xenfb_handle_events(struct XenFB *xenfb)
 
 static int fb_init(struct XenDevice *xendev)
 {
-struct XenFB *fb = container_of(xendev, struct XenFB, c.xendev);
-
-fb-refresh_period = -1;
-
 #ifdef XENFB_TYPE_RESIZE
 xenstore_write_be_int(xendev, feature-resize, 1);
 #endif
@@ -980,6 +957,7 @@ struct XenDevOps xen_framebuffer_ops = {
 static const GraphicHwOps xenfb_ops = {
 .invalidate  = xenfb_invalidate,
 .gfx_update  = xenfb_update,
+.update_interval = xenfb_update_interval,
 };
 
 /*
diff --git a/include/ui/console.h b/include/ui/console.h
index 3cb0018..800f458 100644
--- a/include/ui/console.h
+++ b/include/ui/console.h
@@ -272,6 +272,7 @@ typedef struct GraphicHwOps {
 void (*invalidate)(void *opaque);
 void (*gfx_update)(void *opaque);
 void (*text_update)(void *opaque, console_ch_t *text);
+void (*update_interval)(void *opaque, uint64_t interval);
 } GraphicHwOps;
 
 QemuConsole *graphic_console_init(const GraphicHwOps *ops,
diff --git a/ui/console.c b/ui/console.c
index 5bbc891..43ff80b 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -182,6 +182,7 @@ static void gui_update(void *opaque)
 uint64_t dcl_interval;
 DisplayState *ds = opaque;
 DisplayChangeListener *dcl;
+int i;
 
 ds-refreshing = true;
 dpy_refresh(ds);
@@ -196,6 +197,11 @@ static void gui_update(void *opaque)
 }
 if (ds-update_interval != interval) {
 ds-update_interval = interval;
+for (i = 0; i  nb_consoles; i++) {
+if (consoles[i]-hw_ops-update_interval) {
+consoles[i]-hw_ops-update_interval(consoles[i]-hw, 
interval);
+}
+}
 trace_console_refresh(interval);
 }
 ds-last_update = qemu_get_clock_ms(rt_clock);
-- 
1.7.9.7




[Qemu-devel] [PATCH 17/24] console: make DisplayState private to console.c

2013-04-16 Thread Gerd Hoffmann
With gui_* being moved to console.c nobody outside console.c needs
access to DisplayState fields any more.  Make the struct private.

Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 include/ui/console.h |8 
 ui/console.c |8 
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/include/ui/console.h b/include/ui/console.h
index d92626b..50cd7b0 100644
--- a/include/ui/console.h
+++ b/include/ui/console.h
@@ -182,14 +182,6 @@ struct DisplayChangeListener {
 QLIST_ENTRY(DisplayChangeListener) next;
 };
 
-struct DisplayState {
-struct QEMUTimer *gui_timer;
-bool have_gfx;
-bool have_text;
-
-QLIST_HEAD(, DisplayChangeListener) listeners;
-};
-
 DisplayState *init_displaystate(void);
 DisplaySurface* qemu_create_displaysurface_from(int width, int height, int bpp,
 int linesize, uint8_t *data,
diff --git a/ui/console.c b/ui/console.c
index b618221..07fba67 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -157,6 +157,14 @@ struct QemuConsole {
 QEMUTimer *kbd_timer;
 };
 
+struct DisplayState {
+struct QEMUTimer *gui_timer;
+bool have_gfx;
+bool have_text;
+
+QLIST_HEAD(, DisplayChangeListener) listeners;
+};
+
 static DisplayState *display_state;
 static QemuConsole *active_console;
 static QemuConsole *consoles[MAX_CONSOLES];
-- 
1.7.9.7




[Qemu-devel] [PATCH 12/24] console: rename vga_hw_*, add QemuConsole param

2013-04-16 Thread Gerd Hoffmann
Add QemuConsole parameter to vga_hw_*, so the interface allows to update
non-active consoles (the actual code can't handle this yet, see next
patch).  Passing NULL is allowed and updates the active console, like
the functions do today.

While touching all vga_hw_* calls anyway rename that to the functions to
hardware-neutral graphics_hw_*

Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 hw/display/cirrus_vga.c |2 +-
 hw/display/qxl.c|2 +-
 hw/display/vga.c|2 +-
 hw/display/vga_int.h|8 
 include/ui/console.h|   22 ++---
 ui/console.c|   49 +--
 ui/curses.c |4 ++--
 ui/gtk.c|2 +-
 ui/sdl.c|   18 -
 ui/spice-display.c  |2 +-
 ui/vnc.c|   12 ++--
 11 files changed, 67 insertions(+), 56 deletions(-)

diff --git a/hw/display/cirrus_vga.c b/hw/display/cirrus_vga.c
index bf2181a..514bc33 100644
--- a/hw/display/cirrus_vga.c
+++ b/hw/display/cirrus_vga.c
@@ -720,7 +720,7 @@ static void cirrus_do_copy(CirrusVGAState *s, int dst, int 
src, int w, int h)
 /* we have to flush all pending changes so that the copy
is generated at the appropriate moment in time */
 if (notify)
-   vga_hw_update();
+graphic_hw_update(s-vga.con);
 
 (*s-cirrus_rop) (s, s-vga.vram_ptr +
  (s-cirrus_blt_dstaddr  s-cirrus_addr_mask),
diff --git a/hw/display/qxl.c b/hw/display/qxl.c
index 930b7cf..247209d 100644
--- a/hw/display/qxl.c
+++ b/hw/display/qxl.c
@@ -1074,7 +1074,7 @@ static void qxl_enter_vga_mode(PCIQXLDevice *d)
 qemu_spice_create_host_primary(d-ssd);
 d-mode = QXL_MODE_VGA;
 vga_dirty_log_start(d-vga);
-vga_hw_update();
+graphic_hw_update(d-vga.con);
 }
 
 static void qxl_exit_vga_mode(PCIQXLDevice *d)
diff --git a/hw/display/vga.c b/hw/display/vga.c
index c1b67bb..e37e898 100644
--- a/hw/display/vga.c
+++ b/hw/display/vga.c
@@ -2452,6 +2452,6 @@ static void vga_screen_dump(void *opaque, const char 
*filename, bool cswitch,
 if (cswitch) {
 vga_invalidate_display(s);
 }
-vga_hw_update();
+graphic_hw_update(s-con);
 ppm_save(filename, surface, errp);
 }
diff --git a/hw/display/vga_int.h b/hw/display/vga_int.h
index 260f7d6..1b8f670 100644
--- a/hw/display/vga_int.h
+++ b/hw/display/vga_int.h
@@ -152,10 +152,10 @@ typedef struct VGACommonState {
 uint32_t cursor_offset;
 unsigned int (*rgb_to_pixel)(unsigned int r,
  unsigned int g, unsigned b);
-vga_hw_update_ptr update;
-vga_hw_invalidate_ptr invalidate;
-vga_hw_screen_dump_ptr screen_dump;
-vga_hw_text_update_ptr text_update;
+graphic_hw_update_ptr update;
+graphic_hw_invalidate_ptr invalidate;
+graphic_hw_screen_dump_ptr screen_dump;
+graphic_hw_text_update_ptr text_update;
 bool full_update_text;
 bool full_update_gfx;
 /* hardware mouse cursor support */
diff --git a/include/ui/console.h b/include/ui/console.h
index 3725dae..9c585c0 100644
--- a/include/ui/console.h
+++ b/include/ui/console.h
@@ -278,21 +278,21 @@ static inline void console_write_ch(console_ch_t *dest, 
uint32_t ch)
 *dest = ch;
 }
 
-typedef void (*vga_hw_update_ptr)(void *);
-typedef void (*vga_hw_invalidate_ptr)(void *);
-typedef void (*vga_hw_screen_dump_ptr)(void *, const char *, bool cswitch,
+typedef void (*graphic_hw_update_ptr)(void *);
+typedef void (*graphic_hw_invalidate_ptr)(void *);
+typedef void (*graphic_hw_screen_dump_ptr)(void *, const char *, bool cswitch,
Error **errp);
-typedef void (*vga_hw_text_update_ptr)(void *, console_ch_t *);
+typedef void (*graphic_hw_text_update_ptr)(void *, console_ch_t *);
 
-QemuConsole *graphic_console_init(vga_hw_update_ptr update,
-  vga_hw_invalidate_ptr invalidate,
-  vga_hw_screen_dump_ptr screen_dump,
-  vga_hw_text_update_ptr text_update,
+QemuConsole *graphic_console_init(graphic_hw_update_ptr update,
+  graphic_hw_invalidate_ptr invalidate,
+  graphic_hw_screen_dump_ptr screen_dump,
+  graphic_hw_text_update_ptr text_update,
   void *opaque);
 
-void vga_hw_update(void);
-void vga_hw_invalidate(void);
-void vga_hw_text_update(console_ch_t *chardata);
+void graphic_hw_update(QemuConsole *con);
+void graphic_hw_invalidate(QemuConsole *con);
+void graphic_hw_text_update(QemuConsole *con, console_ch_t *chardata);
 
 int is_graphic_console(void);
 int is_fixedsize_console(void);
diff --git a/ui/console.c b/ui/console.c
index e100593..dccc618 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -118,10 +118,10 @@ struct QemuConsole {
 DisplayState *ds;
 
 /* Graphic console state.  */
-

[Qemu-devel] [PATCH 18/24] console: add GraphicHwOps

2013-04-16 Thread Gerd Hoffmann
Pass a single GraphicHwOps struct pointer to graphic_console_init,
instead of a bunch of function pointers.

Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 hw/arm/musicpal.c|8 ++--
 hw/display/blizzard.c|9 ++---
 hw/display/cirrus_vga.c  |8 ++--
 hw/display/exynos4210_fimd.c |8 ++--
 hw/display/g364fb.c  |9 ++---
 hw/display/jazz_led.c|   10 +++---
 hw/display/milkymist-vgafb.c |9 ++---
 hw/display/omap_lcdc.c   |9 ++---
 hw/display/pl110.c   |9 ++---
 hw/display/pxa2xx_lcd.c  |9 ++---
 hw/display/qxl.c |   16 ++--
 hw/display/sm501.c   |7 +--
 hw/display/ssd0303.c |9 ++---
 hw/display/ssd0323.c |9 ++---
 hw/display/tc6393xb.c|9 +
 hw/display/tcx.c |   18 --
 hw/display/vga-isa-mm.c  |4 +---
 hw/display/vga-isa.c |3 +--
 hw/display/vga-pci.c |3 +--
 hw/display/vga.c |   10 +++---
 hw/display/vga_int.h |4 +---
 hw/display/vmware_vga.c  |   20 
 hw/display/xenfb.c   |   10 ++
 hw/unicore32/puv3.c  |4 +++-
 include/ui/console.h |   12 ++--
 ui/console.c |   33 -
 26 files changed, 155 insertions(+), 104 deletions(-)

diff --git a/hw/arm/musicpal.c b/hw/arm/musicpal.c
index 6e77447..31586c6 100644
--- a/hw/arm/musicpal.c
+++ b/hw/arm/musicpal.c
@@ -601,6 +601,11 @@ static const MemoryRegionOps musicpal_lcd_ops = {
 .endianness = DEVICE_NATIVE_ENDIAN,
 };
 
+static const GraphicHwOps musicpal_gfx_ops = {
+.invalidate  = lcd_invalidate,
+.gfx_update  = lcd_refresh,
+};
+
 static int musicpal_lcd_init(SysBusDevice *dev)
 {
 musicpal_lcd_state *s = FROM_SYSBUS(musicpal_lcd_state, dev);
@@ -611,8 +616,7 @@ static int musicpal_lcd_init(SysBusDevice *dev)
   musicpal-lcd, MP_LCD_SIZE);
 sysbus_init_mmio(dev, s-iomem);
 
-s-con = graphic_console_init(lcd_refresh, lcd_invalidate,
-  NULL, s);
+s-con = graphic_console_init(musicpal_gfx_ops, s);
 qemu_console_resize(s-con, 128*3, 64*3);
 
 qdev_init_gpio_in(dev-qdev, musicpal_lcd_gpio_brigthness_in, 3);
diff --git a/hw/display/blizzard.c b/hw/display/blizzard.c
index 70b6822..1ca3355 100644
--- a/hw/display/blizzard.c
+++ b/hw/display/blizzard.c
@@ -944,6 +944,11 @@ static void blizzard_update_display(void *opaque)
 #define DEPTH 32
 #include blizzard_template.h
 
+static const GraphicHwOps blizzard_ops = {
+.invalidate  = blizzard_invalidate_display,
+.gfx_update  = blizzard_update_display,
+};
+
 void *s1d13745_init(qemu_irq gpio_int)
 {
 BlizzardState *s = (BlizzardState *) g_malloc0(sizeof(*s));
@@ -951,9 +956,7 @@ void *s1d13745_init(qemu_irq gpio_int)
 
 s-fb = g_malloc(0x18);
 
-s-con = graphic_console_init(blizzard_update_display,
-  blizzard_invalidate_display,
-  NULL, s);
+s-con = graphic_console_init(blizzard_ops, s);
 surface = qemu_console_surface(s-con);
 
 switch (surface_bits_per_pixel(surface)) {
diff --git a/hw/display/cirrus_vga.c b/hw/display/cirrus_vga.c
index c31b021..db232af 100644
--- a/hw/display/cirrus_vga.c
+++ b/hw/display/cirrus_vga.c
@@ -2910,9 +2910,7 @@ static int vga_initfn(ISADevice *dev)
 vga_common_init(s);
 cirrus_init_common(d-cirrus_vga, CIRRUS_ID_CLGD5430, 0,
isa_address_space(dev), isa_address_space_io(dev));
-s-con = graphic_console_init(s-update, s-invalidate,
-  s-text_update,
-  s);
+s-con = graphic_console_init(s-hw_ops, s);
 rom_add_vga(VGABIOS_CIRRUS_FILENAME);
 /* XXX ISA-LFB support */
 /* FIXME not qdev yet */
@@ -2959,9 +2957,7 @@ static int pci_cirrus_vga_initfn(PCIDevice *dev)
  vga_common_init(s-vga);
  cirrus_init_common(s, device_id, 1, pci_address_space(dev),
 pci_address_space_io(dev));
- s-vga.con = graphic_console_init(s-vga.update, s-vga.invalidate,
-   s-vga.text_update,
-   s-vga);
+ s-vga.con = graphic_console_init(s-vga.hw_ops, s-vga);
 
  /* setup PCI */
 
diff --git a/hw/display/exynos4210_fimd.c b/hw/display/exynos4210_fimd.c
index d651ddb..e6e7b27 100644
--- a/hw/display/exynos4210_fimd.c
+++ b/hw/display/exynos4210_fimd.c
@@ -1887,6 +1887,11 @@ static const VMStateDescription exynos4210_fimd_vmstate 
= {
 }
 };
 
+static const GraphicHwOps exynos4210_fimd_ops = {
+.invalidate  = exynos4210_fimd_invalidate,
+.gfx_update  = exynos4210_fimd_update,
+};
+
 static int exynos4210_fimd_init(SysBusDevice *dev)
 {
 Exynos4210fimdState *s = 

[Qemu-devel] [PATCH 15/24] console: zap g_width + g_height

2013-04-16 Thread Gerd Hoffmann
We have a surface per QemuConsole now, so there is no need to keep
track of the QemuConsole size any more as we can query the surface
size directly at any time.

Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 ui/console.c |   32 +---
 1 file changed, 9 insertions(+), 23 deletions(-)

diff --git a/ui/console.c b/ui/console.c
index 537b2fc..dd1a0fc 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -123,7 +123,6 @@ struct QemuConsole {
 graphic_hw_invalidate_ptr hw_invalidate;
 graphic_hw_text_update_ptr hw_text_update;
 void *hw;
-int g_width, g_height;
 
 /* Text console state */
 int width;
@@ -389,8 +388,8 @@ static void text_console_resize(QemuConsole *s)
 int w1, x, y, last_width;
 
 last_width = s-width;
-s-width = s-g_width / FONT_WIDTH;
-s-height = s-g_height / FONT_HEIGHT;
+s-width = surface_width(s-surface) / FONT_WIDTH;
+s-height = surface_height(s-surface) / FONT_HEIGHT;
 
 w1 = last_width;
 if (s-width  w1)
@@ -951,18 +950,12 @@ static void console_putchar(QemuConsole *s, int ch)
 
 void console_select(unsigned int index)
 {
-DisplaySurface *surface;
 QemuConsole *s;
 
 if (index = MAX_CONSOLES)
 return;
 
 trace_console_select(index);
-if (active_console) {
-surface = qemu_console_surface(active_console);
-active_console-g_width = surface_width(surface);
-active_console-g_height = surface_height(surface);
-}
 s = consoles[index];
 if (s) {
 DisplayState *ds = s-ds;
@@ -1089,11 +1082,8 @@ void kbd_put_keysym(int keysym)
 static void text_console_invalidate(void *opaque)
 {
 QemuConsole *s = (QemuConsole *) opaque;
-DisplaySurface *surface = qemu_console_surface(s);
 
 if (s-ds-have_text  s-console_type == TEXT_CONSOLE) {
-s-g_width = surface_width(surface);
-s-g_height = surface_height(surface);
 text_console_resize(s);
 }
 console_refresh(s);
@@ -1497,6 +1487,8 @@ static void text_console_update_cursor(void *opaque)
 static void text_console_do_init(CharDriverState *chr, DisplayState *ds)
 {
 QemuConsole *s;
+int g_width = 80 * FONT_WIDTH;
+int g_height = 24 * FONT_HEIGHT;
 
 s = chr-opaque;
 
@@ -1512,16 +1504,13 @@ static void text_console_do_init(CharDriverState *chr, 
DisplayState *ds)
 s-total_height = DEFAULT_BACKSCROLL;
 s-x = 0;
 s-y = 0;
-if (s-console_type == TEXT_CONSOLE) {
+if (!s-surface) {
 if (active_console  active_console-surface) {
-s-g_width = surface_width(active_console-surface);
-s-g_height = surface_height(active_console-surface);
-} else {
-s-g_width = 80 * FONT_WIDTH;
-s-g_height = 24 * FONT_HEIGHT;
+g_width = surface_width(active_console-surface);
+g_height = surface_height(active_console-surface);
 }
+s-surface = qemu_create_displaysurface(g_width, g_height);
 }
-s-surface = qemu_create_displaysurface(s-g_width, s-g_height);
 
 s-cursor_timer =
 qemu_new_timer_ms(rt_clock, text_console_update_cursor, s);
@@ -1583,6 +1572,7 @@ static CharDriverState *text_console_init(ChardevVC *vc)
 s = new_console(NULL, TEXT_CONSOLE);
 } else {
 s = new_console(NULL, TEXT_CONSOLE_FIXED_SIZE);
+s-surface = qemu_create_displaysurface(width, height);
 }
 
 if (!s) {
@@ -1591,8 +1581,6 @@ static CharDriverState *text_console_init(ChardevVC *vc)
 }
 
 s-chr = chr;
-s-g_width = width;
-s-g_height = height;
 chr-opaque = s;
 chr-chr_set_echo = text_console_set_echo;
 
@@ -1619,8 +1607,6 @@ void qemu_console_resize(QemuConsole *s, int width, int 
height)
 DisplaySurface *surface;
 
 assert(s-console_type == GRAPHIC_CONSOLE);
-s-g_width = width;
-s-g_height = height;
 surface = qemu_create_displaysurface(width, height);
 dpy_gfx_replace_surface(s, surface);
 }
-- 
1.7.9.7




[Qemu-devel] [PATCH 19/24] console: gui timer fixes

2013-04-16 Thread Gerd Hoffmann
Make gui update rate adaption code in gui_update() actually work.
Sprinkle in a tracepoint so you can see the code at work.  Remove
the update rate adaption code in vnc and make vnc simply use the
generic bits instead.

Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 include/ui/console.h |9 ---
 trace-events |1 +
 ui/console.c |   34 
 ui/sdl.c |   10 +++
 ui/vnc.c |   71 ++
 ui/vnc.h |2 --
 6 files changed, 60 insertions(+), 67 deletions(-)

diff --git a/include/ui/console.h b/include/ui/console.h
index f3e7791..3cb0018 100644
--- a/include/ui/console.h
+++ b/include/ui/console.h
@@ -21,7 +21,8 @@
 #define QEMU_CAPS_LOCK_LED   (1  2)
 
 /* in ms */
-#define GUI_REFRESH_INTERVAL 30
+#define GUI_REFRESH_INTERVAL_DEFAULT30
+#define GUI_REFRESH_INTERVAL_IDLE 3000
 
 typedef void QEMUPutKBDEvent(void *opaque, int keycode);
 typedef void QEMUPutLEDEvent(void *opaque, int ledstate);
@@ -174,8 +175,7 @@ typedef struct DisplayChangeListenerOps {
 } DisplayChangeListenerOps;
 
 struct DisplayChangeListener {
-int idle;
-uint64_t gui_timer_interval;
+uint64_t update_interval;
 const DisplayChangeListenerOps *ops;
 DisplayState *ds;
 
@@ -207,12 +207,13 @@ static inline int is_buffer_shared(DisplaySurface 
*surface)
 
 void register_displaychangelistener(DisplayState *ds,
 DisplayChangeListener *dcl);
+void update_displaychangelistener(DisplayChangeListener *dcl,
+  uint64_t interval);
 void unregister_displaychangelistener(DisplayChangeListener *dcl);
 
 void dpy_gfx_update(QemuConsole *con, int x, int y, int w, int h);
 void dpy_gfx_replace_surface(QemuConsole *con,
  DisplaySurface *surface);
-void dpy_refresh(DisplayState *s);
 void dpy_gfx_copy(QemuConsole *con, int src_x, int src_y,
   int dst_x, int dst_y, int w, int h);
 void dpy_text_cursor(QemuConsole *con, int x, int y);
diff --git a/trace-events b/trace-events
index b08627b..968edb6 100644
--- a/trace-events
+++ b/trace-events
@@ -965,6 +965,7 @@ dma_map_wait(void *dbs) dbs=%p
 console_gfx_new(void) 
 console_txt_new(int w, int h) %dx%d
 console_select(int nr) %d
+console_refresh(int interval) interval %d ms
 displaysurface_create(void *display_surface, int w, int h) surface=%p, %dx%d
 displaysurface_create_from(void *display_surface, int w, int h, int bpp, int 
swap) surface=%p, %dx%d, bpp %d, bswap %d
 displaysurface_free(void *display_surface) surface=%p
diff --git a/ui/console.c b/ui/console.c
index 79a306b..5bbc891 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -157,6 +157,9 @@ struct QemuConsole {
 
 struct DisplayState {
 struct QEMUTimer *gui_timer;
+uint64_t last_update;
+uint64_t update_interval;
+bool refreshing;
 bool have_gfx;
 bool have_text;
 
@@ -171,22 +174,32 @@ static int nb_consoles = 0;
 static void text_console_do_init(CharDriverState *chr, DisplayState *ds);
 static void dpy_gfx_switch_surface(DisplayState *ds,
DisplaySurface *surface);
+static void dpy_refresh(DisplayState *s);
 
 static void gui_update(void *opaque)
 {
-uint64_t interval = GUI_REFRESH_INTERVAL;
+uint64_t interval = GUI_REFRESH_INTERVAL_IDLE;
+uint64_t dcl_interval;
 DisplayState *ds = opaque;
 DisplayChangeListener *dcl;
 
+ds-refreshing = true;
 dpy_refresh(ds);
+ds-refreshing = false;
 
 QLIST_FOREACH(dcl, ds-listeners, next) {
-if (dcl-gui_timer_interval 
-dcl-gui_timer_interval  interval) {
-interval = dcl-gui_timer_interval;
+dcl_interval = dcl-update_interval ?
+dcl-update_interval : GUI_REFRESH_INTERVAL_DEFAULT;
+if (interval  dcl_interval) {
+interval = dcl_interval;
 }
 }
-qemu_mod_timer(ds-gui_timer, interval + qemu_get_clock_ms(rt_clock));
+if (ds-update_interval != interval) {
+ds-update_interval = interval;
+trace_console_refresh(interval);
+}
+ds-last_update = qemu_get_clock_ms(rt_clock);
+qemu_mod_timer(ds-gui_timer, ds-last_update + interval);
 }
 
 static void gui_setup_refresh(DisplayState *ds)
@@ -1286,6 +1299,17 @@ void register_displaychangelistener(DisplayState *ds,
 }
 }
 
+void update_displaychangelistener(DisplayChangeListener *dcl,
+  uint64_t interval)
+{
+DisplayState *ds = dcl-ds;
+
+dcl-update_interval = interval;
+if (!ds-refreshing  ds-update_interval  interval) {
+qemu_mod_timer(ds-gui_timer, ds-last_update + interval);
+}
+}
+
 void unregister_displaychangelistener(DisplayChangeListener *dcl)
 {
 DisplayState *ds = dcl-ds;
diff --git a/ui/sdl.c b/ui/sdl.c
index ede31dc..97764a6 100644
--- a/ui/sdl.c
+++ b/ui/sdl.c
@@ -751,12 +751,12 @@ static void 

[Qemu-devel] [PATCH 14/24] console: simplify screendump

2013-04-16 Thread Gerd Hoffmann
Screendumps are alot simpler as we can update non-active
QemuConsoles now.  So we only need to update the QemuConsole
we want write out, then dump the DisplaySurface content into
a ppm file.  Done.

No console switching needed.  No special support code in the
gfx card emulation needed.  Zap it all.  Also move ppm_save
out of the vga code and next to the qmp_screendump function.

For now screen dumping is limited to console #0 (like it used
to be), even though it is dead simple to extend it to other
consoles.  I wanna finish the console cleanup before setting
new qapi interfaces into stone.

Signed-off-by: Gerd Hoffmann kra...@redhat.com
Tested-by: Igor Mitsyanko i.mitsya...@gmail.com
---
 hw/arm/musicpal.c|2 +-
 hw/display/blizzard.c|   14 +
 hw/display/cirrus_vga.c  |4 +-
 hw/display/exynos4210_fimd.c |2 +-
 hw/display/g364fb.c  |   73 +---
 hw/display/jazz_led.c|1 -
 hw/display/milkymist-vgafb.c |2 +-
 hw/display/omap_lcdc.c   |   86 +---
 hw/display/pl110.c   |2 +-
 hw/display/pxa2xx_lcd.c  |2 +-
 hw/display/qxl.c |   22 +--
 hw/display/sm501.c   |2 +-
 hw/display/ssd0303.c |2 +-
 hw/display/ssd0323.c |2 +-
 hw/display/tc6393xb.c|1 -
 hw/display/tcx.c |  129 +-
 hw/display/vga-isa-mm.c  |2 +-
 hw/display/vga-isa.c |2 +-
 hw/display/vga-pci.c |2 +-
 hw/display/vga.c |   66 -
 hw/display/vga_int.h |2 -
 hw/display/vmware_vga.c  |   26 -
 hw/display/xenfb.c   |1 -
 hw/unicore32/puv3.c  |2 +-
 include/ui/console.h |3 -
 ui/console.c |   72 ---
 26 files changed, 73 insertions(+), 451 deletions(-)

diff --git a/hw/arm/musicpal.c b/hw/arm/musicpal.c
index d2247fa..6e77447 100644
--- a/hw/arm/musicpal.c
+++ b/hw/arm/musicpal.c
@@ -612,7 +612,7 @@ static int musicpal_lcd_init(SysBusDevice *dev)
 sysbus_init_mmio(dev, s-iomem);
 
 s-con = graphic_console_init(lcd_refresh, lcd_invalidate,
-  NULL, NULL, s);
+  NULL, s);
 qemu_console_resize(s-con, 128*3, 64*3);
 
 qdev_init_gpio_in(dev-qdev, musicpal_lcd_gpio_brigthness_in, 3);
diff --git a/hw/display/blizzard.c b/hw/display/blizzard.c
index de7ccf8..70b6822 100644
--- a/hw/display/blizzard.c
+++ b/hw/display/blizzard.c
@@ -933,18 +933,6 @@ static void blizzard_update_display(void *opaque)
 s-my[1] = 0;
 }
 
-static void blizzard_screen_dump(void *opaque, const char *filename,
- bool cswitch, Error **errp)
-{
-BlizzardState *s = (BlizzardState *) opaque;
-DisplaySurface *surface = qemu_console_surface(s-con);
-
-blizzard_update_display(opaque);
-if (s  surface_data(surface)) {
-ppm_save(filename, surface, errp);
-}
-}
-
 #define DEPTH 8
 #include blizzard_template.h
 #define DEPTH 15
@@ -965,7 +953,7 @@ void *s1d13745_init(qemu_irq gpio_int)
 
 s-con = graphic_console_init(blizzard_update_display,
   blizzard_invalidate_display,
-  blizzard_screen_dump, NULL, s);
+  NULL, s);
 surface = qemu_console_surface(s-con);
 
 switch (surface_bits_per_pixel(surface)) {
diff --git a/hw/display/cirrus_vga.c b/hw/display/cirrus_vga.c
index 514bc33..c31b021 100644
--- a/hw/display/cirrus_vga.c
+++ b/hw/display/cirrus_vga.c
@@ -2911,7 +2911,7 @@ static int vga_initfn(ISADevice *dev)
 cirrus_init_common(d-cirrus_vga, CIRRUS_ID_CLGD5430, 0,
isa_address_space(dev), isa_address_space_io(dev));
 s-con = graphic_console_init(s-update, s-invalidate,
-  s-screen_dump, s-text_update,
+  s-text_update,
   s);
 rom_add_vga(VGABIOS_CIRRUS_FILENAME);
 /* XXX ISA-LFB support */
@@ -2960,7 +2960,7 @@ static int pci_cirrus_vga_initfn(PCIDevice *dev)
  cirrus_init_common(s, device_id, 1, pci_address_space(dev),
 pci_address_space_io(dev));
  s-vga.con = graphic_console_init(s-vga.update, s-vga.invalidate,
-   s-vga.screen_dump, s-vga.text_update,
+   s-vga.text_update,
s-vga);
 
  /* setup PCI */
diff --git a/hw/display/exynos4210_fimd.c b/hw/display/exynos4210_fimd.c
index 7e1cbb6..d651ddb 100644
--- a/hw/display/exynos4210_fimd.c
+++ b/hw/display/exynos4210_fimd.c
@@ -1901,7 +1901,7 @@ static int exynos4210_fimd_init(SysBusDevice *dev)
 exynos4210.fimd, FIMD_REGS_SIZE);
 sysbus_init_mmio(dev, s-iomem);
 s-console = 

[Qemu-devel] [PATCH 22/24] console: allow pinning displaychangelisteners to consoles

2013-04-16 Thread Gerd Hoffmann
DisplayChangeListener gets a new QemuConsole field, which can be set to
non-NULL before registering.  This will pin the QemuConsole, so that
particular DisplayChangeListener will not follow console switches.

spice+gtk (which don't support text console input anyway) are switched
over to be pinned to console 0, which usually is the graphical display.

Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 hw/display/qxl.c   |2 +-
 include/ui/console.h   |2 +
 include/ui/spice-display.h |1 -
 ui/console.c   |  103 +++-
 ui/gtk.c   |3 +-
 ui/spice-display.c |   11 ++---
 6 files changed, 84 insertions(+), 38 deletions(-)

diff --git a/hw/display/qxl.c b/hw/display/qxl.c
index 8721d44..bbc6f56 100644
--- a/hw/display/qxl.c
+++ b/hw/display/qxl.c
@@ -2061,7 +2061,6 @@ static int qxl_init_primary(PCIDevice *dev)
 portio_list_add(qxl_vga_port_list, pci_address_space_io(dev), 0x3b0);
 
 vga-con = graphic_console_init(qxl_ops, qxl);
-qxl-ssd.con = vga-con,
 qemu_spice_display_init_common(qxl-ssd);
 
 rc = qxl_init_common(qxl);
@@ -2070,6 +2069,7 @@ static int qxl_init_primary(PCIDevice *dev)
 }
 
 qxl-ssd.dcl.ops = display_listener_ops;
+qxl-ssd.dcl.con = vga-con;
 ds = qemu_console_displaystate(vga-con);
 register_displaychangelistener(ds, qxl-ssd.dcl);
 return rc;
diff --git a/include/ui/console.h b/include/ui/console.h
index bcd0139..e591d74 100644
--- a/include/ui/console.h
+++ b/include/ui/console.h
@@ -178,6 +178,7 @@ struct DisplayChangeListener {
 uint64_t update_interval;
 const DisplayChangeListenerOps *ops;
 DisplayState *ds;
+QemuConsole *con;
 
 QLIST_ENTRY(DisplayChangeListener) next;
 };
@@ -282,6 +283,7 @@ void graphic_hw_update(QemuConsole *con);
 void graphic_hw_invalidate(QemuConsole *con);
 void graphic_hw_text_update(QemuConsole *con, console_ch_t *chardata);
 
+QemuConsole *qemu_console_lookup_by_index(unsigned int index);
 bool qemu_console_is_visible(QemuConsole *con);
 bool qemu_console_is_graphic(QemuConsole *con);
 bool qemu_console_is_fixedsize(QemuConsole *con);
diff --git a/include/ui/spice-display.h b/include/ui/spice-display.h
index 7a20fc4..a46bc80 100644
--- a/include/ui/spice-display.h
+++ b/include/ui/spice-display.h
@@ -71,7 +71,6 @@ typedef struct SimpleSpiceDisplay SimpleSpiceDisplay;
 typedef struct SimpleSpiceUpdate SimpleSpiceUpdate;
 
 struct SimpleSpiceDisplay {
-QemuConsole *con;
 DisplaySurface *ds;
 DisplayChangeListener dcl;
 void *buf;
diff --git a/ui/console.c b/ui/console.c
index 214cdba..4f9219e 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -117,6 +117,7 @@ struct QemuConsole {
 console_type_t console_type;
 DisplayState *ds;
 DisplaySurface *surface;
+int dcls;
 
 /* Graphic console state.  */
 const GraphicHwOps *hw_ops;
@@ -172,8 +173,6 @@ static QemuConsole *consoles[MAX_CONSOLES];
 static int nb_consoles = 0;
 
 static void text_console_do_init(CharDriverState *chr, DisplayState *ds);
-static void dpy_gfx_switch_surface(DisplayState *ds,
-   DisplaySurface *surface);
 static void dpy_refresh(DisplayState *s);
 
 static void gui_update(void *opaque)
@@ -309,7 +308,7 @@ write_err:
 
 void qmp_screendump(const char *filename, Error **errp)
 {
-QemuConsole *con = consoles[0];
+QemuConsole *con = qemu_console_lookup_by_index(0);
 DisplaySurface *surface;
 
 if (con == NULL) {
@@ -1022,13 +1021,14 @@ static void console_putchar(QemuConsole *s, int ch)
 
 void console_select(unsigned int index)
 {
+DisplayChangeListener *dcl;
 QemuConsole *s;
 
 if (index = MAX_CONSOLES)
 return;
 
 trace_console_select(index);
-s = consoles[index];
+s = qemu_console_lookup_by_index(index);
 if (s) {
 DisplayState *ds = s-ds;
 
@@ -1037,7 +1037,14 @@ void console_select(unsigned int index)
 }
 active_console = s;
 if (ds-have_gfx) {
-dpy_gfx_switch_surface(ds, s-surface);
+QLIST_FOREACH(dcl, ds-listeners, next) {
+if (dcl-con != NULL) {
+continue;
+}
+if (dcl-ops-dpy_gfx_switch) {
+dcl-ops-dpy_gfx_switch(dcl, s-surface);
+}
+}
 dpy_gfx_update(s, 0, 0, surface_width(s-surface),
surface_height(s-surface));
 }
@@ -1292,12 +1299,20 @@ void qemu_free_displaysurface(DisplaySurface *surface)
 void register_displaychangelistener(DisplayState *ds,
 DisplayChangeListener *dcl)
 {
+QemuConsole *con;
+
 trace_displaychangelistener_register(dcl, dcl-ops-dpy_name);
 dcl-ds = ds;
 QLIST_INSERT_HEAD(ds-listeners, dcl, next);
 gui_setup_refresh(ds);
-if (dcl-ops-dpy_gfx_switch  active_console) {
-dcl-ops-dpy_gfx_switch(dcl, 

[Qemu-devel] [PATCH] qemu-iotests: Fix _filter_qemu

2013-04-16 Thread Kevin Wolf
$QEMU_PROG happens to be 'qemu' in my setup, so this sed command
replaces a bit too much. Restrict it to the start of the line and to
when it's followed by a colon, i.e. the form used by error messages.

Signed-off-by: Kevin Wolf kw...@redhat.com
---
 tests/qemu-iotests/common.filter | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/qemu-iotests/common.filter b/tests/qemu-iotests/common.filter
index bc5f250..a7f889a 100644
--- a/tests/qemu-iotests/common.filter
+++ b/tests/qemu-iotests/common.filter
@@ -155,7 +155,7 @@ _filter_qemu_io()
 # replace occurrences of QEMU_PROG with qemu
 _filter_qemu()
 {
-sed -e s#$(basename $QEMU_PROG)#QEMU_PROG#g
+sed -e s#^$(basename $QEMU_PROG):#QEMU_PROG:#g
 }
 
 # make sure this script returns success
-- 
1.8.1.4




Re: [Qemu-devel] [PATCH v2 0/4] qemu-img: support compression regardless of cluster size

2013-04-16 Thread Kevin Wolf
Am 16.04.2013 um 11:14 hat Stefan Hajnoczi geschrieben:
 It was hard to find a short email subject line.  Anyway, the problem is that
 qemu-img convert -c fails with the following error message if the input image
 length is not a multiple of the output cluster size:
 
   qemu-img: error while compressing sector 0: Input/output error
 
 Ilkka Tengvall ilkka.tengv...@cybercom.com reported the failure.  kwolf and
 eblake suggested a fix which this patch series implements.
 
 qemu-img convert -c succeeds with these patches applied.
 
 The final patch adds qemu-iotests case 053 to protect against regressions.
 
 v2:
  * Extend test case to check virtual disk size and contents [eblake]
  * Note: only the last commit changed

Thanks, updated patch 4/4.

Kevin



Re: [Qemu-devel] [PATCH v3 0/8] virtio-rng refactoring.

2013-04-16 Thread Amit Shah
On (Sun) 14 Apr 2013 [15:01:02], fred.kon...@greensocs.com wrote:
 From: KONRAD Frederic fred.kon...@greensocs.com
 
 This is the last backend of the refactoring.
 
 Basically it creates virtio-rng-device which extends virtio-device.
 Then a virtio-rng-device can be connected on a virtio-bus.
 virtio-rng-pci, virtio-rng-s390, virtio-rng-ccw are created too, they extend
 respectively virtio-pci, virtio-s390-device, virtio-ccw-device and have a
 virtio-rng-device.
 
 When rng option is NULL, a default rng backend is created as before. But after
 this refactoring, this default-backend will be the child of virtio-rng-device
 instead of virtio-rng-*.
 
 You can checkout my branch here:
 
 git://project.greensocs.com/qemu-virtio.git virtio-rng-v3
 
 Note that it is nearly the same series as virtio-blk and virtio-scsi
 refactoring, and is rebased on top of virtio-net-v3 I posted before.
 
 I made basic tests (with linux guests) on:
  * qemu-system-i386

Looks OK.

Acked-by: Amit Shah amit.s...@redhat.com

Thanks,

Amit



[Qemu-devel] [PATCH 1/9] qxl: add 4k + 8k resolutions

2013-04-16 Thread Gerd Hoffmann
Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 hw/display/qxl.c |4 
 1 file changed, 4 insertions(+)

diff --git a/hw/display/qxl.c b/hw/display/qxl.c
index 930b7cf..9d8ab58 100644
--- a/hw/display/qxl.c
+++ b/hw/display/qxl.c
@@ -116,6 +116,10 @@ static QXLMode qxl_modes[] = {
 QXL_MODE_EX(2560, 2048),
 QXL_MODE_EX(2800, 2100),
 QXL_MODE_EX(3200, 2400),
+QXL_MODE_EX(3840, 2160), /* 4k mainstream */
+QXL_MODE_EX(4096, 2160), /* 4k*/
+QXL_MODE_EX(7680, 4320), /* 8k mainstream */
+QXL_MODE_EX(8192, 4320), /* 8k*/
 };
 
 static void qxl_send_events(PCIQXLDevice *d, uint32_t events);
-- 
1.7.9.7




[Qemu-devel] [PULL 0/9] spice patch queue

2013-04-16 Thread Gerd Hoffmann
  Hi,

This is the spice patch queue, carrying flow control fixes,
for spice chardevs and (with Amit's ack) virtio-serial.  Also
some new resolutions for qxl.

please pull,
  Gerd

The following changes since commit 24a6e7f4d91e9ed5f8117ecb083431a23f8609a0:

  virtio-balloon: fix dynamic properties. (2013-04-15 17:06:58 -0500)

are available in the git repository at:

  git://anongit.freedesktop.org/spice/qemu spice.v69

for you to fetch changes up to 75c439bc65c07d76f5e74c734ed5432bc6114a3b:

  spice-qemu-char: vmc_write: Don't write more bytes then we're asked too 
(2013-04-16 11:52:09 +0200)


Alon Levy (2):
  spice: (32 bit only) fix surface cmd tracking destruction
  spice-qemu-char: Remove intermediate buffer

Gerd Hoffmann (2):
  qxl: add 4k + 8k resolutions
  qxl: add 2000x2000 and 2048x2048 video modes

Hans de Goede (5):
  virtio-console: Also throttle when less was written then requested
  virtio-console: Remove any pending watches on close
  spice-qemu-char: Remove #ifdef-ed code for old spice-server compat
  spice-qemu-char: Add watch support
  spice-qemu-char: vmc_write: Don't write more bytes then we're asked too

 hw/char/virtio-console.c  |   32 +--
 hw/display/qxl.c  |8 ++-
 include/hw/virtio/virtio-serial.h |2 +-
 spice-qemu-char.c |  109 +++--
 4 files changed, 104 insertions(+), 47 deletions(-)



[Qemu-devel] [PATCH 2/9] qxl: add 2000x2000 and 2048x2048 video modes

2013-04-16 Thread Gerd Hoffmann
Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 hw/display/qxl.c |2 ++
 1 file changed, 2 insertions(+)

diff --git a/hw/display/qxl.c b/hw/display/qxl.c
index 9d8ab58..1f7c8fe 100644
--- a/hw/display/qxl.c
+++ b/hw/display/qxl.c
@@ -109,7 +109,9 @@ static QXLMode qxl_modes[] = {
 /* these modes need more than 8 MB video memory */
 QXL_MODE_EX(1920, 1200),
 QXL_MODE_EX(1920, 1440),
+QXL_MODE_EX(2000, 2000),
 QXL_MODE_EX(2048, 1536),
+QXL_MODE_EX(2048, 2048),
 QXL_MODE_EX(2560, 1440),
 QXL_MODE_EX(2560, 1600),
 /* these modes need more than 16 MB video memory */
-- 
1.7.9.7




[Qemu-devel] [PATCH 3/9] spice: (32 bit only) fix surface cmd tracking destruction

2013-04-16 Thread Gerd Hoffmann
From: Alon Levy al...@redhat.com

No change for 64 bit arches, but for 32 bit previously we zeroed half
the surfaces cmd array, instead of all of it.

Signed-off-by: Alon Levy al...@redhat.com
Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 hw/display/qxl.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/display/qxl.c b/hw/display/qxl.c
index 1f7c8fe..cb47995 100644
--- a/hw/display/qxl.c
+++ b/hw/display/qxl.c
@@ -230,7 +230,7 @@ static void 
qxl_spice_destroy_surfaces_complete(PCIQXLDevice *qxl)
 trace_qxl_spice_destroy_surfaces_complete(qxl-id);
 qemu_mutex_lock(qxl-track_lock);
 memset(qxl-guest_surfaces.cmds, 0,
-   sizeof(qxl-guest_surfaces.cmds) * qxl-ssd.num_surfaces);
+   sizeof(qxl-guest_surfaces.cmds[0]) * qxl-ssd.num_surfaces);
 qxl-guest_surfaces.count = 0;
 qemu_mutex_unlock(qxl-track_lock);
 }
-- 
1.7.9.7




[Qemu-devel] [PATCH 6/9] spice-qemu-char: Remove #ifdef-ed code for old spice-server compat

2013-04-16 Thread Gerd Hoffmann
From: Hans de Goede hdego...@redhat.com

We now require spice-server to be = 0.12.0 so this is no longer needed.

Signed-off-by: Hans de Goede hdego...@redhat.com
Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 spice-qemu-char.c |   27 +--
 1 file changed, 1 insertion(+), 26 deletions(-)

diff --git a/spice-qemu-char.c b/spice-qemu-char.c
index c9403de..be19917 100644
--- a/spice-qemu-char.c
+++ b/spice-qemu-char.c
@@ -85,21 +85,6 @@ static void vmc_state(SpiceCharDeviceInstance *sin, int 
connected)
 {
 SpiceCharDriver *scd = container_of(sin, SpiceCharDriver, sin);
 
-#if SPICE_SERVER_VERSION  0x000901
-/*
- * spice-server calls the state callback for the agent channel when the
- * spice client connects / disconnects. Given that not the client but
- * the server is doing the parsing of the messages this is wrong as the
- * server is still listening. Worse, this causes the parser in the server
- * to go out of sync, so we ignore state calls for subtype vdagent
- * spicevmc chardevs. For the full story see:
- * http://lists.freedesktop.org/archives/spice-devel/2011-July/004837.html
- */
-if (strcmp(sin-subtype, vdagent) == 0) {
-return;
-}
-#endif
-
 if ((scd-chr-be_open  connected) ||
 (!scd-chr-be_open  !connected)) {
 return;
@@ -224,7 +209,6 @@ static CharDriverState *chr_open(const char *subtype)
 
 CharDriverState *qemu_chr_open_spice_vmc(const char *type)
 {
-CharDriverState *chr;
 const char **psubtype = spice_server_char_device_recognized_subtypes();
 
 if (type == NULL) {
@@ -243,16 +227,7 @@ CharDriverState *qemu_chr_open_spice_vmc(const char *type)
 return NULL;
 }
 
-chr = chr_open(type);
-
-#if SPICE_SERVER_VERSION  0x000901
-/* See comment in vmc_state() */
-if (strcmp(type, vdagent) == 0) {
-qemu_chr_generic_open(chr);
-}
-#endif
-
-return chr;
+return chr_open(type);
 }
 
 #if SPICE_SERVER_VERSION = 0x000c02
-- 
1.7.9.7




[Qemu-devel] [PATCH 5/9] virtio-console: Remove any pending watches on close

2013-04-16 Thread Gerd Hoffmann
From: Hans de Goede hdego...@redhat.com

Signed-off-by: Hans de Goede hdego...@redhat.com
Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 hw/char/virtio-console.c |   24 ++--
 1 file changed, 22 insertions(+), 2 deletions(-)

diff --git a/hw/char/virtio-console.c b/hw/char/virtio-console.c
index 061f4bd..6759e51 100644
--- a/hw/char/virtio-console.c
+++ b/hw/char/virtio-console.c
@@ -18,6 +18,7 @@
 typedef struct VirtConsole {
 VirtIOSerialPort port;
 CharDriverState *chr;
+guint watch;
 } VirtConsole;
 
 /*
@@ -29,6 +30,7 @@ static gboolean chr_write_unblocked(GIOChannel *chan, 
GIOCondition cond,
 {
 VirtConsole *vcon = opaque;
 
+vcon-watch = 0;
 virtio_serial_throttle_port(vcon-port, false);
 return FALSE;
 }
@@ -61,8 +63,10 @@ static ssize_t flush_buf(VirtIOSerialPort *port,
 ret = 0;
 if (!k-is_console) {
 virtio_serial_throttle_port(port, true);
-qemu_chr_fe_add_watch(vcon-chr, G_IO_OUT, chr_write_unblocked,
-  vcon);
+if (!vcon-watch) {
+vcon-watch = qemu_chr_fe_add_watch(vcon-chr, G_IO_OUT,
+chr_write_unblocked, vcon);
+}
 }
 }
 return ret;
@@ -106,6 +110,10 @@ static void chr_event(void *opaque, int event)
 virtio_serial_open(vcon-port);
 break;
 case CHR_EVENT_CLOSED:
+if (vcon-watch) {
+g_source_remove(vcon-watch);
+vcon-watch = 0;
+}
 virtio_serial_close(vcon-port);
 break;
 }
@@ -130,6 +138,17 @@ static int virtconsole_initfn(VirtIOSerialPort *port)
 return 0;
 }
 
+static int virtconsole_exitfn(VirtIOSerialPort *port)
+{
+VirtConsole *vcon = DO_UPCAST(VirtConsole, port, port);
+
+if (vcon-watch) {
+g_source_remove(vcon-watch);
+}
+
+return 0;
+}
+
 static Property virtconsole_properties[] = {
 DEFINE_PROP_CHR(chardev, VirtConsole, chr),
 DEFINE_PROP_END_OF_LIST(),
@@ -142,6 +161,7 @@ static void virtconsole_class_init(ObjectClass *klass, void 
*data)
 
 k-is_console = true;
 k-init = virtconsole_initfn;
+k-exit = virtconsole_exitfn;
 k-have_data = flush_buf;
 k-set_guest_connected = set_guest_connected;
 dc-props = virtconsole_properties;
-- 
1.7.9.7




[Qemu-devel] [PATCH 24/24] qxl: register QemuConsole for secondary cards

2013-04-16 Thread Gerd Hoffmann
Hook secondary qxl cards properly into the qemu console subsystem.

Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 hw/display/qxl.c |6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/hw/display/qxl.c b/hw/display/qxl.c
index bbc6f56..437f8d0 100644
--- a/hw/display/qxl.c
+++ b/hw/display/qxl.c
@@ -1769,7 +1769,10 @@ static void qxl_hw_invalidate(void *opaque)
 PCIQXLDevice *qxl = opaque;
 VGACommonState *vga = qxl-vga;
 
-vga-hw_ops-invalidate(vga);
+if (qxl-mode == QXL_MODE_VGA) {
+vga-hw_ops-invalidate(vga);
+return;
+}
 }
 
 static void qxl_hw_text_update(void *opaque, console_ch_t *chardata)
@@ -2085,6 +2088,7 @@ static int qxl_init_secondary(PCIDevice *dev)
 memory_region_init_ram(qxl-vga.vram, qxl.vgavram, qxl-vga.vram_size);
 vmstate_register_ram(qxl-vga.vram, qxl-pci.qdev);
 qxl-vga.vram_ptr = memory_region_get_ram_ptr(qxl-vga.vram);
+qxl-vga.con = graphic_console_init(qxl_ops, qxl);
 
 return qxl_init_common(qxl);
 }
-- 
1.7.9.7




[Qemu-devel] [PATCH 9/9] spice-qemu-char: vmc_write: Don't write more bytes then we're asked too

2013-04-16 Thread Gerd Hoffmann
From: Hans de Goede hdego...@redhat.com

This one took me eons to debug, but I've finally found it now, oh well.

The usage of the MIN macro in this line:
last_out = MIN(len, qemu_chr_be_can_write(scd-chr));

Causes qemu_chr_be_can_write to be called *twice*, since the MIN macro
evaluates its arguments twice (bad MIN macro, bad!). And the result of
the call can change between the 2 calls since the guest may have consumed
some data from the virtio ringbuffer between the calls!

When this happens it is possible for qemu_chr_be_can_write to return less
then len in the call made for the comparision, and then to return more then
len in the actual call for the return-value of MIN, after which we will end
up writing len data + some extra garbage, not good.

This patch fixes this by only calling qemu_chr_be_can_write once.

Signed-off-by: Hans de Goede hdego...@redhat.com
Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 spice-qemu-char.c |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/spice-qemu-char.c b/spice-qemu-char.c
index ff95fcb..f10970c 100644
--- a/spice-qemu-char.c
+++ b/spice-qemu-char.c
@@ -35,7 +35,8 @@ static int vmc_write(SpiceCharDeviceInstance *sin, const 
uint8_t *buf, int len)
 uint8_t* p = (uint8_t*)buf;
 
 while (len  0) {
-last_out = MIN(len, qemu_chr_be_can_write(scd-chr));
+int can_write = qemu_chr_be_can_write(scd-chr);
+last_out = MIN(len, can_write);
 if (last_out = 0) {
 break;
 }
-- 
1.7.9.7




Re: [Qemu-devel] [PATCH 00/16 v4] target-i386: CPU hot-add with cpu-add QMP command

2013-04-16 Thread Igor Mammedov
On Tue, 16 Apr 2013 10:30:55 +0200
Jan Kiszka jan.kis...@siemens.com wrote:

 On 2013-04-16 00:12, Igor Mammedov wrote:
  Implements alternative way for hot-adding CPU using cpu-add QMP command,
  wich could be useful until it would be possible to add CPUs via device_add.
 
 Didn't track the full story: What prevents currently a device_add
 approach? And that so effectively that we have to create a
 to-be-deprecated-again QMP API first?
I guess mostly it's review bandwidth and time concerns, it moves but quite slow
and won't be able to make into 1.5 and possibly miss 1.6 with current speed.

In this series all patches except the last one applicable to device_add as
well so any feedback is appreciated.

To make device_add usable for CPU, I have on my TODO list following
series/topics:

1. convert cpuid features to static properties.
http://lists.gnu.org/archive/html/qemu-devel/2013-02/msg04426.html

2. x86 CPU subclasses
http://lists.gnu.org/archive/html/qemu-devel/2013-02/msg00673.html

Summarized issues/ways to go with CPU subclasses could be found here:
http://wiki.qemu.org/Features/CPUHotplug section CPU models as CPU subclasses

[optional]
3. nice to have, unify cpu_model handling and convert it to utilizing global
properties. With it hotplug could look as simple as:
 device_add apic_id=xxx
without specifying all flags that were on -cpu command line.


BTW:
 You were advocating using APIC ID on device_add to identify CPU but Eduardo
 would like avoid its usage on external interfaces.
 It would be nice to have your opinion on subject.
  relevant discussion threads are here:
1. http://lists.gnu.org/archive/html/qemu-devel/2013-04/msg02205.html
2. http://lists.gnu.org/archive/html/qemu-devel/2013-04/msg02274.html

 Thanks,
 Jan
 
  
  All patches except the last are also applicable to device_add aprroach.
  
  To hot-add CPU use following command from qmp-shell:
   cpu-add id=[0..max-cpus - 1)
  
  git tree for testing: https://github.com/imammedo/qemu/tree/cpu_add.v4
  
  based on qom-cpu tree
  
  v4-v3:
* 'id' in cpu-add command will be a thread number instead of APIC ID
* split off resume_vcpu() into separate patch
* move notifier from rtc code into pc.c
  
  v2-v3:
* use local error  propagate_error() instead of operating on
  passed in errp in several places
* replace CPUClass.get_firmware_id() with CPUClass.get_arch_id()
* leave IOAPIC creation to board and just set bus to icc-bus
* include kvm-stub.o in cpu libary if no KVM is configured
* create resume_vcpu() stub and include it in libqemustub,
  and use it directly instead of CPU method
* acpi_piix4: s/cpu_add_notifier/cpu_added_notifier/
  
  v1-v2:
* generalize cpu sync to KVM, resume and hot-plug notification and
  invoke them form CPUClass, to make available to all targets.
* introduce cpu_exists() and CPUClass.get_firmware_id() and use
  the last one in acpi_piix to make code target independent.
* move IOAPIC to ICC bus, it was suggested and easy to convert.
* leave kvmvapic as SysBusDevice, it doesn't affect hot-plug and
  created only once for all APIC instances. I haven't found yet
  good/clean enough way to convert it to ICCDevice. May be follow-up
  though.
* split one big ICC patch into several, one per converted device
* add cpu_hot_add hook to machine and implement it for target-i386,
  instead of adding stabs. Could be used by other targets to
  implement cpu-add.
* pre-allocate linksCPU for all possible CPUs and make them available
  at /machine/icc-bridge/cpu[0..N] QOM path, so users could find out
  possible/free CPU IDs to use in cpu-add command.
  
  CC: pbonz...@redhat.com
  CC: afaer...@suse.de
  CC: ehabk...@redhat.com
  
  Igor Mammedov (16):
cpu: make kvm-stub.o a part of CPU library
cpu: call cpu_synchronize_post_init() from CPUClass.realize() if
  hotplugged
introduce resume_vcpu(), for single CPU
cpu: resume CPU from CPUClass.cpu_common_realizefn() when it is
  hot-plugged
introduce CPU hot-plug notifier
target-i386: pc: update rtc_cmos on CPU hot-plug
cpu: introduce get_arch_id() method and override it for target-i386
cpu: add helper cpu_exists(), to check if CPU with specified id exists
acpi_piix4: add infrastructure to send CPU hot-plug GPE to guest
target-i386: introduce apic-id property
introduce ICC bus/device/bridge
target-i386: cpu: attach ICC bus to CPU on its creation
target-i386: replace MSI_SPACE_SIZE with APIC_SPACE_SIZE
target-i386: move APIC to ICC bus
target-i386: move IOAPIC to ICC bus
add cpu-add qmp command and implement CPU hot-add for target-i386
  
   Makefile.target|  14 ++---
   cpus.c |  11 +++-
   default-configs/i386-softmmu.mak   |   1 +
   default-configs/x86_64-softmmu.mak |   1 +
   hw/acpi/piix4.c| 114 
  

[Qemu-devel] [PATCH 10/24] console: add trace events

2013-04-16 Thread Gerd Hoffmann
Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 trace-events |3 +++
 ui/console.c |4 
 2 files changed, 7 insertions(+)

diff --git a/trace-events b/trace-events
index b4d69d6..b08627b 100644
--- a/trace-events
+++ b/trace-events
@@ -962,6 +962,9 @@ dma_bdrv_cb(void *dbs, int ret) dbs=%p ret=%d
 dma_map_wait(void *dbs) dbs=%p
 
 # console.h
+console_gfx_new(void) 
+console_txt_new(int w, int h) %dx%d
+console_select(int nr) %d
 displaysurface_create(void *display_surface, int w, int h) surface=%p, %dx%d
 displaysurface_create_from(void *display_surface, int w, int h, int bpp, int 
swap) surface=%p, %dx%d, bpp %d, bswap %d
 displaysurface_free(void *display_surface) surface=%p
diff --git a/ui/console.c b/ui/console.c
index 1935996..3834e39 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -904,6 +904,8 @@ void console_select(unsigned int index)
 
 if (index = MAX_CONSOLES)
 return;
+
+trace_console_select(index);
 if (active_console) {
 surface = qemu_console_surface(active_console);
 active_console-g_width = surface_width(surface);
@@ -1367,6 +1369,7 @@ QemuConsole *graphic_console_init(vga_hw_update_ptr 
update,
 DisplayState *ds;
 
 ds = (DisplayState *) g_malloc0(sizeof(DisplayState));
+trace_console_gfx_new();
 s = new_console(ds, GRAPHIC_CONSOLE);
 s-hw_update = update;
 s-hw_invalidate = invalidate;
@@ -1485,6 +1488,7 @@ static CharDriverState *text_console_init(ChardevVC *vc)
 height = vc-rows * FONT_HEIGHT;
 }
 
+trace_console_txt_new(width, height);
 if (width == 0 || height == 0) {
 s = new_console(NULL, TEXT_CONSOLE);
 } else {
-- 
1.7.9.7




[Qemu-devel] [PATCH 3/7] xhci: add xhci_cap_write

2013-04-16 Thread Gerd Hoffmann
Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 hw/usb/hcd-xhci.c |7 +++
 1 file changed, 7 insertions(+)

diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c
index c0dbc54..7f740d9 100644
--- a/hw/usb/hcd-xhci.c
+++ b/hw/usb/hcd-xhci.c
@@ -3079,8 +3079,15 @@ static void xhci_doorbell_write(void *ptr, hwaddr reg,
 }
 }
 
+static void xhci_cap_write(void *opaque, hwaddr addr, uint64_t val,
+   unsigned width)
+{
+/* nothing */
+}
+
 static const MemoryRegionOps xhci_cap_ops = {
 .read = xhci_cap_read,
+.write = xhci_cap_write,
 .valid.min_access_size = 1,
 .valid.max_access_size = 4,
 .impl.min_access_size = 4,
-- 
1.7.9.7




[Qemu-devel] [PULL 0/7] usb patch queue

2013-04-16 Thread Gerd Hoffmann
  Hi,

Here comes the usb patch queue.  Big new feature is the libusb-based
usb-host driver.  There also is a usb-serial fix and a small collection
of xhci bugfixes.

please pull,
  Gerd

The following changes since commit 24a6e7f4d91e9ed5f8117ecb083431a23f8609a0:

  virtio-balloon: fix dynamic properties. (2013-04-15 17:06:58 -0500)

are available in the git repository at:

  git://git.kraxel.org/qemu usb.80

for you to fetch changes up to 2b2325ff6491224a42e1fec99b1c39fbc521c95c:

  use libusb for usb-host (2013-04-16 12:04:09 +0200)


Gerd Hoffmann (6):
  xhci: remove leftover debug printf
  xhci: add xhci_cap_write
  xhci: fix portsc writes
  xhci: use slotid as device address
  xhci: fix address device
  use libusb for usb-host

Hans de Goede (1):
  usb-serial: Remove double call to qemu_chr_add_handlers( NULL )

 configure|   36 ++
 hw/usb/dev-serial.c  |9 -
 hw/usb/hcd-xhci.c|   79 +--
 hw/usb/host-libusb.c | 1449 ++
 hw/usb/host-linux.c  |   14 +-
 trace-events |5 +
 6 files changed, 1551 insertions(+), 41 deletions(-)
 create mode 100644 hw/usb/host-libusb.c



[Qemu-devel] [PATCH 5/7] xhci: use slotid as device address

2013-04-16 Thread Gerd Hoffmann
Is good enougth for unique device addresses and avoids the need for any
state for device addressing.  Makes live migration support easier.  Also
makes device-slot lookups trivial.

Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 hw/usb/hcd-xhci.c |   25 +++--
 1 file changed, 3 insertions(+), 22 deletions(-)

diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c
index bb0cf1e..e489059 100644
--- a/hw/usb/hcd-xhci.c
+++ b/hw/usb/hcd-xhci.c
@@ -408,7 +408,6 @@ typedef struct XHCISlot {
 bool enabled;
 dma_addr_t ctx;
 USBPort *uport;
-unsigned int devaddr;
 XHCIEPContext * eps[31];
 } XHCISlot;
 
@@ -452,7 +451,6 @@ struct XHCIState {
 MemoryRegion mem_oper;
 MemoryRegion mem_runtime;
 MemoryRegion mem_doorbell;
-unsigned int devaddr;
 
 /* properties */
 uint32_t numports_2;
@@ -2141,16 +2139,14 @@ static TRBCCode xhci_address_slot(XHCIState *xhci, 
unsigned int slotid,
 slot_ctx[3] = SLOT_DEFAULT  SLOT_STATE_SHIFT;
 } else {
 USBPacket p;
-slot-devaddr = xhci-devaddr++;
-slot_ctx[3] = (SLOT_ADDRESSED  SLOT_STATE_SHIFT) | slot-devaddr;
-DPRINTF(xhci: device address is %d\n, slot-devaddr);
+slot_ctx[3] = (SLOT_ADDRESSED  SLOT_STATE_SHIFT) | slotid;
 usb_device_reset(dev);
 usb_packet_setup(p, USB_TOKEN_OUT,
  usb_ep_get(dev, USB_TOKEN_OUT, 0), 0,
  0, false, false);
 usb_device_handle_control(dev, p,
   DeviceOutRequest | USB_REQ_SET_ADDRESS,
-  slot-devaddr, 0, 0, NULL);
+  slotid, 0, 0, NULL);
 assert(p.status != USB_RET_ASYNC);
 }
 
@@ -2674,7 +2670,6 @@ static void xhci_reset(DeviceState *dev)
 xhci-dcbaap_low = 0;
 xhci-dcbaap_high = 0;
 xhci-config = 0;
-xhci-devaddr = 2;
 
 for (i = 0; i  xhci-numslots; i++) {
 xhci_disable_slot(xhci, i+1);
@@ -3212,20 +3207,6 @@ static USBPortOps xhci_uport_ops = {
 .child_detach = xhci_child_detach,
 };
 
-static int xhci_find_slotid(XHCIState *xhci, USBDevice *dev)
-{
-XHCISlot *slot;
-int slotid;
-
-for (slotid = 1; slotid = xhci-numslots; slotid++) {
-slot = xhci-slots[slotid-1];
-if (slot-devaddr == dev-addr) {
-return slotid;
-}
-}
-return 0;
-}
-
 static int xhci_find_epid(USBEndpoint *ep)
 {
 if (ep-nr == 0) {
@@ -3245,7 +3226,7 @@ static void xhci_wakeup_endpoint(USBBus *bus, USBEndpoint 
*ep,
 int slotid;
 
 DPRINTF(%s\n, __func__);
-slotid = xhci_find_slotid(xhci, ep-dev);
+slotid = ep-dev-addr;
 if (slotid == 0 || !xhci-slots[slotid-1].enabled) {
 DPRINTF(%s: oops, no slot for dev %d\n, __func__, ep-dev-addr);
 return;
-- 
1.7.9.7




[Qemu-devel] [PATCH 4/7] xhci: fix portsc writes

2013-04-16 Thread Gerd Hoffmann
Check for port reset first and skip everything else then.
Add sanity checks for PLS updates.
Add PLC notification when entering PLS_U0 state.

This gets host-initiated port resume going on win8.

Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 hw/usb/hcd-xhci.c |   42 +++---
 trace-events  |1 +
 2 files changed, 36 insertions(+), 7 deletions(-)

diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c
index 7f740d9..bb0cf1e 100644
--- a/hw/usb/hcd-xhci.c
+++ b/hw/usb/hcd-xhci.c
@@ -2592,6 +2592,7 @@ static void xhci_port_notify(XHCIPort *port, uint32_t 
bits)
 if ((port-portsc  bits) == bits) {
 return;
 }
+trace_usb_xhci_port_notify(port-portnr, bits);
 port-portsc |= bits;
 if (!xhci_running(port-xhci)) {
 return;
@@ -2798,29 +2799,56 @@ static void xhci_port_write(void *ptr, hwaddr reg,
 uint64_t val, unsigned size)
 {
 XHCIPort *port = ptr;
-uint32_t portsc;
+uint32_t portsc, notify;
 
 trace_usb_xhci_port_write(port-portnr, reg, val);
 
 switch (reg) {
 case 0x00: /* PORTSC */
+/* write-1-to-start bits */
+if (val  PORTSC_PR) {
+xhci_port_reset(port);
+break;
+}
+
 portsc = port-portsc;
+notify = 0;
 /* write-1-to-clear bits*/
 portsc = ~(val  (PORTSC_CSC|PORTSC_PEC|PORTSC_WRC|PORTSC_OCC|
PORTSC_PRC|PORTSC_PLC|PORTSC_CEC));
 if (val  PORTSC_LWS) {
 /* overwrite PLS only when LWS=1 */
-uint32_t pls = get_field(val, PORTSC_PLS);
-set_field(portsc, pls, PORTSC_PLS);
-trace_usb_xhci_port_link(port-portnr, pls);
+uint32_t old_pls = get_field(port-portsc, PORTSC_PLS);
+uint32_t new_pls = get_field(val, PORTSC_PLS);
+switch (new_pls) {
+case PLS_U0:
+if (old_pls != PLS_U0) {
+set_field(portsc, new_pls, PORTSC_PLS);
+trace_usb_xhci_port_link(port-portnr, new_pls);
+notify = PORTSC_PLC;
+}
+break;
+case PLS_U3:
+if (old_pls  PLS_U3) {
+set_field(portsc, new_pls, PORTSC_PLS);
+trace_usb_xhci_port_link(port-portnr, new_pls);
+}
+break;
+case PLS_RESUME:
+/* windows does this for some reason, don't spam stderr */
+break;
+default:
+fprintf(stderr, %s: ignore pls write (old %d, new %d)\n,
+__func__, old_pls, new_pls);
+break;
+}
 }
 /* read/write bits */
 portsc = ~(PORTSC_PP|PORTSC_WCE|PORTSC_WDE|PORTSC_WOE);
 portsc |= (val  (PORTSC_PP|PORTSC_WCE|PORTSC_WDE|PORTSC_WOE));
 port-portsc = portsc;
-/* write-1-to-start bits */
-if (val  PORTSC_PR) {
-xhci_port_reset(port);
+if (notify) {
+xhci_port_notify(port, notify);
 }
 break;
 case 0x04: /* PORTPMSC */
diff --git a/trace-events b/trace-events
index 412f7e4..54b7d90 100644
--- a/trace-events
+++ b/trace-events
@@ -362,6 +362,7 @@ usb_xhci_queue_event(uint32_t vector, uint32_t idx, const 
char *trb, const char
 usb_xhci_fetch_trb(uint64_t addr, const char *name, uint64_t param, uint32_t 
status, uint32_t control) addr %016 PRIx64 , %s, p %016 PRIx64 , s %08x, c 
0x%08x
 usb_xhci_port_reset(uint32_t port) port %d
 usb_xhci_port_link(uint32_t port, uint32_t pls) port %d, pls %d
+usb_xhci_port_notify(uint32_t port, uint32_t pls) port %d, bits %x
 usb_xhci_slot_enable(uint32_t slotid) slotid %d
 usb_xhci_slot_disable(uint32_t slotid) slotid %d
 usb_xhci_slot_address(uint32_t slotid) slotid %d
-- 
1.7.9.7




[Qemu-devel] [PATCH 1/7] usb-serial: Remove double call to qemu_chr_add_handlers( NULL )

2013-04-16 Thread Gerd Hoffmann
From: Hans de Goede hdego...@redhat.com

usb-serial has a qdev chardev property, and hw/qdev-properties-system.c
already contains:

static void release_chr(Object *obj, const char *name, void *opaque)
{
DeviceState *dev = DEVICE(obj);
Property *prop = opaque;
CharDriverState **ptr = qdev_get_prop_ptr(dev, prop);
CharDriverState *chr = *ptr;

if (chr) {
qemu_chr_add_handlers(chr, NULL, NULL, NULL, NULL);
qemu_chr_fe_release(chr);
}
}

So doing the qemu_chr_add_handlers(s-cs, NULL, NULL, NULL, NULL); from
the usb handle_destroy function too will lead to it being done twice.

Signed-off-by: Hans de Goede hdego...@redhat.com
Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 hw/usb/dev-serial.c |9 -
 1 file changed, 9 deletions(-)

diff --git a/hw/usb/dev-serial.c b/hw/usb/dev-serial.c
index dd0a608..2fc8a3b 100644
--- a/hw/usb/dev-serial.c
+++ b/hw/usb/dev-serial.c
@@ -410,13 +410,6 @@ static void usb_serial_handle_data(USBDevice *dev, 
USBPacket *p)
 }
 }
 
-static void usb_serial_handle_destroy(USBDevice *dev)
-{
-USBSerialState *s = (USBSerialState *)dev;
-
-qemu_chr_add_handlers(s-cs, NULL, NULL, NULL, NULL);
-}
-
 static int usb_serial_can_read(void *opaque)
 {
 USBSerialState *s = opaque;
@@ -595,7 +588,6 @@ static void usb_serial_class_initfn(ObjectClass *klass, 
void *data)
 uc-handle_reset   = usb_serial_handle_reset;
 uc-handle_control = usb_serial_handle_control;
 uc-handle_data= usb_serial_handle_data;
-uc-handle_destroy = usb_serial_handle_destroy;
 dc-vmsd = vmstate_usb_serial;
 dc-props = serial_properties;
 }
@@ -623,7 +615,6 @@ static void usb_braille_class_initfn(ObjectClass *klass, 
void *data)
 uc-handle_reset   = usb_serial_handle_reset;
 uc-handle_control = usb_serial_handle_control;
 uc-handle_data= usb_serial_handle_data;
-uc-handle_destroy = usb_serial_handle_destroy;
 dc-vmsd = vmstate_usb_serial;
 dc-props = braille_properties;
 }
-- 
1.7.9.7




[Qemu-devel] [PATCH 7/7] use libusb for usb-host

2013-04-16 Thread Gerd Hoffmann
Reimplement usb-host on top of libusb.
Reasons to do this:

 (1) Largely rewritten from scratch, nice opportunity to kill historical
 cruft.
 (2) Offload usbfs handling to libusb.
 (3) Have a single portable code base instead of bsd + linux variants.
 (4) Bring usb-host support to any platform supported by libusbx.

For now this goes side-by-side to the existing code.  That is only to
simplify regression testing though, at the end of the day I want remove
the old code and support libusb exclusively.  Merge early in 1.5 cycle,
remove the old code after 1.5 release or something like this.

Thanks to qdev the old and new code can coexist nicely on linux.  Just
use -device usb-host-linux to use the old linux driver instead of the
libusb one (which takes over the usb-host name).

The bsd driver isn't qdev'ified so it isn't that easy for bsd.
I didn't bother making it runtime switchable, so you have to rebuild
qemu with --disable-libusb to get back the old code.

Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 configure|   36 ++
 hw/usb/host-libusb.c | 1449 ++
 hw/usb/host-linux.c  |   14 +-
 trace-events |4 +
 4 files changed, 1501 insertions(+), 2 deletions(-)
 create mode 100644 hw/usb/host-libusb.c

diff --git a/configure b/configure
index 0788e27..4c4f6f6 100755
--- a/configure
+++ b/configure
@@ -226,6 +226,7 @@ trace_file=trace
 spice=
 rbd=
 smartcard_nss=
+libusb=
 usb_redir=
 glx=
 zlib=yes
@@ -890,6 +891,10 @@ for opt do
   ;;
   --enable-smartcard-nss) smartcard_nss=yes
   ;;
+  --disable-libusb) libusb=no
+  ;;
+  --enable-libusb) libusb=yes
+  ;;
   --disable-usb-redir) usb_redir=no
   ;;
   --enable-usb-redir) usb_redir=yes
@@ -1175,6 +1180,8 @@ echo   --disable-libiscsi   disable iscsi support
 echo   --enable-libiscsienable iscsi support
 echo   --disable-smartcard-nss  disable smartcard nss support
 echo   --enable-smartcard-nss   enable smartcard nss support
+echo   --disable-libusb disable libusb (for usb passthrough)
+echo   --enable-libusb  enable libusb (for usb passthrough)
 echo   --disable-usb-redir  disable usb network redirection support
 echo   --enable-usb-redir   enable usb network redirection support
 echo   --disable-guest-agentdisable building of the QEMU Guest Agent
@@ -3005,6 +3012,23 @@ EOF
 fi
 fi
 
+# check for libusb
+if test $libusb != no ; then
+if $pkg_config libusb-1.0 /dev/null 21 ; then
+libusb=yes
+   usb=libusb
+libusb_cflags=$($pkg_config --cflags libusb-1.0 2/dev/null)
+libusb_libs=$($pkg_config --libs libusb-1.0 2/dev/null)
+QEMU_CFLAGS=$QEMU_CFLAGS $libusb_cflags
+libs_softmmu=$libs_softmmu $libusb_libs
+else
+if test $libusb = yes; then
+feature_not_found libusb
+fi
+libusb=no
+fi
+fi
+
 # check for usbredirparser for usb network redirection support
 if test $usb_redir != no ; then
 if $pkg_config --atleast-version=0.6 libusbredirparser-0.5 /dev/null 21 
; then
@@ -3516,6 +3540,7 @@ echo spice support $spice 
($spice_protocol_version/$spice_server_version)
 echo rbd support   $rbd
 echo xfsctl support$xfs
 echo nss used  $smartcard_nss
+echo libusb$libusb
 echo usb net redir $usb_redir
 echo GLX support   $glx
 echo libiscsi support  $libiscsi
@@ -3823,6 +3848,10 @@ if test $smartcard_nss = yes ; then
   echo libcacard_cflags=$libcacard_cflags  $config_host_mak
 fi
 
+if test $libusb = yes ; then
+  echo CONFIG_USB_LIBUSB=y  $config_host_mak
+fi
+
 if test $usb_redir = yes ; then
   echo CONFIG_USB_REDIR=y  $config_host_mak
 fi
@@ -3907,6 +3936,13 @@ linux)
 bsd)
   echo HOST_USB=bsd  $config_host_mak
 ;;
+libusb)
+  if test $linux = yes; then
+echo HOST_USB=libusb linux legacy  $config_host_mak
+  else
+echo HOST_USB=libusb legacy  $config_host_mak
+  fi
+;;
 *)
   echo HOST_USB=stub  $config_host_mak
 ;;
diff --git a/hw/usb/host-libusb.c b/hw/usb/host-libusb.c
new file mode 100644
index 000..29f35b3
--- /dev/null
+++ b/hw/usb/host-libusb.c
@@ -0,0 +1,1449 @@
+/*
+ * Linux host USB redirector
+ *
+ * Copyright (c) 2005 Fabrice Bellard
+ *
+ * Copyright (c) 2008 Max Krasnyansky
+ *  Support for host device auto connect  disconnect
+ *  Major rewrite to support fully async operation
+ *
+ * Copyright 2008 TJ li...@tjworld.net
+ *  Added flexible support for /dev/bus/usb /sys/bus/usb/devices in 
addition
+ *  to the legacy /proc/bus/usb USB device discovery and handling
+ *
+ * (c) 2012 Gerd Hoffmann kra...@redhat.com
+ *  Completely rewritten to use libusb instead of usbfs ioctls.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the Software), to 
deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, 

[Qemu-devel] [PATCH 6/7] xhci: fix address device

2013-04-16 Thread Gerd Hoffmann
Zero-initialize the set-address dummy USBPacket,
also add buffer to avoid sanity checks triggering.

https://bugzilla.redhat.com/show_bug.cgi?id=929019

Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 hw/usb/hcd-xhci.c |4 
 1 file changed, 4 insertions(+)

diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c
index e489059..a26b78e 100644
--- a/hw/usb/hcd-xhci.c
+++ b/hw/usb/hcd-xhci.c
@@ -2139,8 +2139,12 @@ static TRBCCode xhci_address_slot(XHCIState *xhci, 
unsigned int slotid,
 slot_ctx[3] = SLOT_DEFAULT  SLOT_STATE_SHIFT;
 } else {
 USBPacket p;
+uint8_t buf[1];
+
 slot_ctx[3] = (SLOT_ADDRESSED  SLOT_STATE_SHIFT) | slotid;
 usb_device_reset(dev);
+memset(p, 0, sizeof(p));
+usb_packet_addbuf(p, buf, sizeof(buf));
 usb_packet_setup(p, USB_TOKEN_OUT,
  usb_ep_get(dev, USB_TOKEN_OUT, 0), 0,
  0, false, false);
-- 
1.7.9.7




Re: [Qemu-devel] [qapi] Cannot use list of strings

2013-04-16 Thread Amos Kong
On Tue, Apr 16, 2013 at 10:54:56AM +0200, Paolo Bonzini wrote:
 Il 16/04/2013 10:49, Stefan Hajnoczi ha scritto:
   Tried using a list of strings as an argument to a command, but the 
   generated
   code references the 'strList' type, which does not exist.
   
   Is a specialized version for ['str'] missing, or should I define my 
   own type
   with a single field of 'str' type?
  akong just hit this too.

That thread: http://marc.info/?l=qemu-develm=136572276530702w=3

  I think it's a question for aliguori, luiz, or mdroth.
 
 Laszlo defined and used String for this purpose:

Eric said String list contains additional JSON structure.
At least, it works.

= using StringList
'*unicast':['String'],
'*multicast':  ['String']

{
return: [
{
name: virtio-net-pci.0, 
multicast: [
{
str: 01:80:c2:00:00:21
}, 
{
str: 00:00:00:00:00:00
}
]
}, 

]
}
 using strList
'*unicast':['str'],
'*multicast':  ['str']

Eric, is it expected format?

{
return: [
{
name: virtio-net-pci.0, 
multicast: [
str: 01:80:c2:00:00:21,
str: 00:00:00:00:00:00
]
},

]
}


I changed qapi scripts to define struct, struct list,
visit/free functions for 'str'. But it conflicts with
existed str functions. I hadn't find a solution.

Do we need to defind strList  visit functions in qapi-core files?
not generated by scripts.


diff --git a/scripts/qapi-types.py b/scripts/qapi-types.py
index 9e19920..5167d85 100644
--- a/scripts/qapi-types.py
+++ b/scripts/qapi-types.py
@@ -282,6 +282,10 @@ fdecl.write(mcgen('''
 exprs = parse_schema(sys.stdin)
 exprs = filter(lambda expr: not expr.has_key('gen'), exprs)

+ret = \n
+ret += generate_fwd_struct('str', {'str': 'str'})
+fdecl.write(ret)
+
 for expr in exprs:
 ret = \n
 if expr.has_key('type'):
@@ -319,6 +323,15 @@ for expr in exprs:
 continue
 fdecl.write(ret)

+ret = \n
+ret += generate_struct('str', , {'str': 'str'}) + \n
+ret += generate_type_cleanup_decl('str' + List)
+fdef.write(generate_type_cleanup('str' + List) + \n)
+ret += generate_type_cleanup_decl('str')
+fdef.write(generate_type_cleanup('str') + \n)
+
+fdecl.write(ret)
+
 fdecl.write('''
 #endif
 ''')
diff --git a/scripts/qapi-visit.py b/scripts/qapi-visit.py
index a276540..089dda7 100644
--- a/scripts/qapi-visit.py
+++ b/scripts/qapi-visit.py
@@ -354,6 +354,13 @@ for expr in exprs:
 ret += generate_enum_declaration(expr['enum'], expr['data'])
 fdecl.write(ret)

+ret = generate_visit_struct('str', {'str': 'str'})
+ret += generate_visit_list('str', {'str': 'str'})
+fdef.write(ret)
+
+ret = generate_declaration('str', {'str': 'str'})
+fdecl.write(ret)
+
 fdecl.write('''
 #endif
 ''')

 
 ##
 # @String
 #
 # A fat type wrapping 'str', to be embedded in lists.
 #
 # Since 1.2
 ##
 { 'type': 'String',
   'data': {
 'str': 'str' } }

-- 
Amos.



[Qemu-devel] [PATCH 8/9] spice-qemu-char: Remove intermediate buffer

2013-04-16 Thread Gerd Hoffmann
From: Alon Levy al...@redhat.com

virtio-serial's buffer is valid when it calls us, and we don't
access it otherwise: vmc_read is only called in response to wakeup,
or else we set datalen=0 and throttle. Then vmc_read is called back,
we return 0 (not accessing the buffer) and set the timer to unthrottle.

Also make datalen int and not ssize_t (to fit spice_chr_write signature).

HdG: Update to apply to spice-qemu-char with new gio-channel based
flowcontrol support.

Signed-off-by: Hans de Goede hdego...@redhat.com
Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 spice-qemu-char.c |   12 +++-
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/spice-qemu-char.c b/spice-qemu-char.c
index 7e551bf..ff95fcb 100644
--- a/spice-qemu-char.c
+++ b/spice-qemu-char.c
@@ -14,9 +14,8 @@ typedef struct SpiceCharDriver {
 char  *subtype;
 bool  active;
 bool  blocked;
-uint8_t   *buffer;
-uint8_t   *datapos;
-ssize_t   bufsize, datalen;
+const uint8_t *datapos;
+int   datalen;
 QLIST_ENTRY(SpiceCharDriver) next;
 } SpiceCharDriver;
 
@@ -186,12 +185,7 @@ static int spice_chr_write(CharDriverState *chr, const 
uint8_t *buf, int len)
 int read_bytes;
 
 assert(s-datalen == 0);
-if (s-bufsize  len) {
-s-bufsize = len;
-s-buffer = g_realloc(s-buffer, s-bufsize);
-}
-memcpy(s-buffer, buf, len);
-s-datapos = s-buffer;
+s-datapos = buf;
 s-datalen = len;
 spice_server_char_device_wakeup(s-sin);
 read_bytes = len - s-datalen;
-- 
1.7.9.7




[Qemu-devel] [PATCH 2/7] xhci: remove leftover debug printf

2013-04-16 Thread Gerd Hoffmann
Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 hw/usb/hcd-xhci.c |1 -
 1 file changed, 1 deletion(-)

diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c
index efd4b0d..c0dbc54 100644
--- a/hw/usb/hcd-xhci.c
+++ b/hw/usb/hcd-xhci.c
@@ -2526,7 +2526,6 @@ static void xhci_process_commands(XHCIState *xhci)
 }
 break;
 case CR_SET_TR_DEQUEUE:
-fprintf(stderr, %s: CR_SET_TR_DEQUEUE\n, __func__);
 slotid = xhci_get_slot(xhci, event, trb);
 if (slotid) {
 unsigned int epid = (trb.control  TRB_CR_EPID_SHIFT)
-- 
1.7.9.7




[Qemu-devel] [PATCH 7/9] spice-qemu-char: Add watch support

2013-04-16 Thread Gerd Hoffmann
From: Hans de Goede hdego...@redhat.com

Signed-off-by: Hans de Goede hdego...@redhat.com
Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 spice-qemu-char.c |   67 +
 1 file changed, 63 insertions(+), 4 deletions(-)

diff --git a/spice-qemu-char.c b/spice-qemu-char.c
index be19917..7e551bf 100644
--- a/spice-qemu-char.c
+++ b/spice-qemu-char.c
@@ -13,12 +13,18 @@ typedef struct SpiceCharDriver {
 SpiceCharDeviceInstance sin;
 char  *subtype;
 bool  active;
+bool  blocked;
 uint8_t   *buffer;
 uint8_t   *datapos;
 ssize_t   bufsize, datalen;
 QLIST_ENTRY(SpiceCharDriver) next;
 } SpiceCharDriver;
 
+typedef struct SpiceCharSource {
+GSource   source;
+SpiceCharDriver   *scd;
+} SpiceCharSource;
+
 static QLIST_HEAD(, SpiceCharDriver) spice_chars =
 QLIST_HEAD_INITIALIZER(spice_chars);
 
@@ -54,9 +60,10 @@ static int vmc_read(SpiceCharDeviceInstance *sin, uint8_t 
*buf, int len)
 scd-datapos += bytes;
 scd-datalen -= bytes;
 assert(scd-datalen = 0);
-if (scd-datalen == 0) {
-scd-datapos = 0;
-}
+}
+if (scd-datalen == 0) {
+scd-datapos = 0;
+scd-blocked = false;
 }
 trace_spice_vmc_read(bytes, len);
 return bytes;
@@ -129,10 +136,54 @@ static void vmc_unregister_interface(SpiceCharDriver *scd)
 trace_spice_vmc_unregister_interface(scd);
 }
 
+static gboolean spice_char_source_prepare(GSource *source, gint *timeout)
+{
+SpiceCharSource *src = (SpiceCharSource *)source;
+
+*timeout = -1;
+
+return !src-scd-blocked;
+}
+
+static gboolean spice_char_source_check(GSource *source)
+{
+SpiceCharSource *src = (SpiceCharSource *)source;
+
+return !src-scd-blocked;
+}
+
+static gboolean spice_char_source_dispatch(GSource *source,
+GSourceFunc callback, gpointer user_data)
+{
+GIOFunc func = (GIOFunc)callback;
+
+return func(NULL, G_IO_OUT, user_data);
+}
+
+GSourceFuncs SpiceCharSourceFuncs = {
+.prepare  = spice_char_source_prepare,
+.check= spice_char_source_check,
+.dispatch = spice_char_source_dispatch,
+};
+
+static GSource *spice_chr_add_watch(CharDriverState *chr, GIOCondition cond)
+{
+SpiceCharDriver *scd = chr-opaque;
+SpiceCharSource *src;
+
+assert(cond == G_IO_OUT);
+
+src = (SpiceCharSource *)g_source_new(SpiceCharSourceFuncs,
+  sizeof(SpiceCharSource));
+src-scd = scd;
+
+return (GSource *)src;
+}
 
 static int spice_chr_write(CharDriverState *chr, const uint8_t *buf, int len)
 {
 SpiceCharDriver *s = chr-opaque;
+int read_bytes;
 
 assert(s-datalen == 0);
 if (s-bufsize  len) {
@@ -143,7 +194,14 @@ static int spice_chr_write(CharDriverState *chr, const 
uint8_t *buf, int len)
 s-datapos = s-buffer;
 s-datalen = len;
 spice_server_char_device_wakeup(s-sin);
-return len;
+read_bytes = len - s-datalen;
+if (read_bytes != len) {
+/* We'll get passed in the unconsumed data with the next call */
+s-datalen = 0;
+s-datapos = NULL;
+s-blocked = true;
+}
+return read_bytes;
 }
 
 static void spice_chr_close(struct CharDriverState *chr)
@@ -199,6 +257,7 @@ static CharDriverState *chr_open(const char *subtype)
 s-sin.subtype = g_strdup(subtype);
 chr-opaque = s;
 chr-chr_write = spice_chr_write;
+chr-chr_add_watch = spice_chr_add_watch;
 chr-chr_close = spice_chr_close;
 chr-chr_set_fe_open = spice_chr_set_fe_open;
 
-- 
1.7.9.7




Re: [Qemu-devel] [qemu-devel] Bug Report: VM crashed for some kinds of vCPU in nested virtualization

2013-04-16 Thread 李春奇
I looked up Intel manual for VM instruction error. Error number 7 means VM
entry with invalid control field(s), which means in process of VM
switching some control fields are not properly configured.

I wonder why some emulated CPUs (e.g.Nehalem) can run properly without
nested VMCS MSR support?

Besides, this bug has also been reported at Red Hat community
https://bugzilla.redhat.com/show_bug.cgi?id=892240
And for some specific kernel (e.g. kernel 3.8.4-202.fc18.x86_64 for
fedora18) it works well.


On Tue, Apr 16, 2013 at 3:03 PM, Jan Kiszka jan.kis...@web.de wrote:

 On 2013-04-16 05:49, 李春奇 Arthur Chunqi Li wrote:
  I changed to the latest version of kvm kernel but the bug also occured.
 
  On the startup of L1 VM on the host, the host kern.log will output:
  Apr 16 11:28:22 Blade1-02 kernel: [ 4908.458090] kvm [2808]: vcpu0
  unhandled rdmsr: 0x345
  Apr 16 11:28:22 Blade1-02 kernel: [ 4908.458166] kvm_set_msr_common: 22
  callbacks suppressed
  Apr 16 11:28:22 Blade1-02 kernel: [ 4908.458169] kvm [2808]: vcpu0
  unhandled wrmsr: 0x40 data 0
  Apr 16 11:28:22 Blade1-02 kernel: [ 4908.458176] kvm [2808]: vcpu0
  unhandled wrmsr: 0x60 data 0
  Apr 16 11:28:22 Blade1-02 kernel: [ 4908.458182] kvm [2808]: vcpu0
  unhandled wrmsr: 0x41 data 0
  Apr 16 11:28:22 Blade1-02 kernel: [ 4908.458188] kvm [2808]: vcpu0
  unhandled wrmsr: 0x61 data 0
  Apr 16 11:28:22 Blade1-02 kernel: [ 4908.458194] kvm [2808]: vcpu0
  unhandled wrmsr: 0x42 data 0
  Apr 16 11:28:22 Blade1-02 kernel: [ 4908.458200] kvm [2808]: vcpu0
  unhandled wrmsr: 0x62 data 0
  Apr 16 11:28:22 Blade1-02 kernel: [ 4908.458206] kvm [2808]: vcpu0
  unhandled wrmsr: 0x43 data 0
  Apr 16 11:28:22 Blade1-02 kernel: [ 4908.458211] kvm [2808]: vcpu0
  unhandled wrmsr: 0x63 data 0
  Apr 16 11:28:23 Blade1-02 kernel: [ 4908.471014] kvm [2808]: vcpu1
  unhandled wrmsr: 0x40 data 0
  Apr 16 11:28:23 Blade1-02 kernel: [ 4908.471024] kvm [2808]: vcpu1
  unhandled wrmsr: 0x60 data 0
 
  When L1 VM starts and crashes, its kern.log will output:
  Apr 16 11:28:55 kvm1 kernel: [   33.590101] device tap0 entered
 promiscuous
  mode
  Apr 16 11:28:55 kvm1 kernel: [   33.590140] br0: port 2(tap0) entered
  forwarding state
  Apr 16 11:28:55 kvm1 kernel: [   33.590146] br0: port 2(tap0) entered
  forwarding state
  Apr 16 11:29:04 kvm1 kernel: [   42.592103] br0: port 2(tap0) entered
  forwarding state
  Apr 16 11:29:19 kvm1 kernel: [   57.752731] kvm [1673]: vcpu0 unhandled
  rdmsr: 0x345
  Apr 16 11:29:19 kvm1 kernel: [   57.797261] kvm [1673]: vcpu0 unhandled
  wrmsr: 0x40 data 0
  Apr 16 11:29:19 kvm1 kernel: [   57.797315] kvm [1673]: vcpu0 unhandled
  wrmsr: 0x60 data 0
  Apr 16 11:29:19 kvm1 kernel: [   57.797366] kvm [1673]: vcpu0 unhandled
  wrmsr: 0x41 data 0
  Apr 16 11:29:19 kvm1 kernel: [   57.797416] kvm [1673]: vcpu0 unhandled
  wrmsr: 0x61 data 0
  Apr 16 11:29:19 kvm1 kernel: [   57.797466] kvm [1673]: vcpu0 unhandled
  wrmsr: 0x42 data 0
  Apr 16 11:29:19 kvm1 kernel: [   57.797516] kvm [1673]: vcpu0 unhandled
  wrmsr: 0x62 data 0
  Apr 16 11:29:19 kvm1 kernel: [   57.797566] kvm [1673]: vcpu0 unhandled
  wrmsr: 0x43 data 0
  Apr 16 11:29:19 kvm1 kernel: [   57.797616] kvm [1673]: vcpu0 unhandled
  wrmsr: 0x63 data 0
 
  The host will output simultaneously:
  Apr 16 11:29:20 Blade1-02 kernel: [ 4966.314742] nested_vmx_run: VMCS
  MSR_{LOAD,STORE} unsupported

 That's an important information. KVM is not yet implementing this
 feature, but L1 is using it - doomed to fail. This feature gap of nested
 VMX needs to be closed at some point.

 
  And the callback trace displayed on the console is the same as the
 previous
  mail.
 
  Besides, the L1 and L2 guest may sometimes crash and output nothing,
 while
  sometimes it will output as above.
 
 
  So this indicates that the msr controls may fail for core2duo CPU
 emulator.
 

 Maybe varying the CPU type (try e.g. -cpu kvm64,+vmx) reduces the
 likeliness of this scenario with KVM as guest.

 
  For Jan,
  I have traced the code of qemu and KVM and found the relevant code of
 errno
  KVM: entry failed, hardware error 0x7. The relevant code is in kernel
  arch/x86/kvm/vmx.c, function vmx_handle_exit():
 
  if (exit_reason  VMX_EXIT_REASONS_FAILED_VMENTRY) {
  vcpu-run-exit_reason = KVM_EXIT_FAIL_ENTRY;
  vcpu-run-fail_entry.hardware_entry_failure_reason
  = exit_reason;
  return 0;
  }
 
  if (unlikely(vmx-fail)) {
  vcpu-run-exit_reason = KVM_EXIT_FAIL_ENTRY;
  vcpu-run-fail_entry.hardware_entry_failure_reason
  = vmcs_read32(VM_INSTRUCTION_ERROR);
  return 0;
  }
 
  The entry failed hardware error may be caused from these two points, both
  are caused by VMENTRY failed. Because macro
 VMX_EXIT_REASONS_FAILED_VMENTRY
  is 0x8000 and the output errno is 0x7, so this error is caused by the
  second branch. I'm not very clear what the result of
  vmcs_read32(VM_INSTRUCTION_ERROR) refers to.

 Try to look this up in the Intel manual. It explains what instruction
 error 7 means. You will also find it 

[Qemu-devel] [PULL v4 00/24] console: console overhaul continued

2013-04-16 Thread Gerd Hoffmann
  Hi,

Next batch of console cleanup patches.  What is in there?

  (1) qemu text consoles are rendered using pixman now.
  (2) Each QemuConsole has its own DisplaySurface now, so we can
  switch consoles without re-rendering the QemuConsole and
  update non-active consoles.
  (3) Based on (2) the screendump code is simplified *alot*.
  (4) gui refresh timer adaption is fixes and consolidated.

Also some cleanups and bugfixes.

v4 changes:
  * fix xenfb according to Stefano's review.
  * rebase to latest master.

v3 changes:
  * more bugfixes (especially vmware vga).
  * dropped multi-window gtk patch for now (needs some more
refinement + discussions, but I don't want it block the
other patches).
  * addressed v2 review comments.

v2 adds:
  * bugfixes from Igor.
  * multihead support.

please pull,
  Gerd

The following changes since commit 24a6e7f4d91e9ed5f8117ecb083431a23f8609a0:

  virtio-balloon: fix dynamic properties. (2013-04-15 17:06:58 -0500)

are available in the git repository at:

  git://git.kraxel.org/qemu pixman.v11

for you to fetch changes up to bfe528b9b99d52693a55f2b803039d68a97bcfb2:

  qxl: register QemuConsole for secondary cards (2013-04-16 09:26:21 +0200)


Gerd Hoffmann (22):
  hw/vmware_vga.c: add tracepoints for mmio reads+writes
  hw/vmware_vga.c: various vmware vga fixes.
  pixman: add qemu_pixman_color()
  pixman: render vgafont glyphs into pixman images
  console: use pixman for fill+blit
  console: use pixman for font rendering
  console: switch color_table_rgb to pixman_color_t
  console: add trace events
  console: displaystate init revamp
  console: rename vga_hw_*, add QemuConsole param
  console: give each QemuConsole its own DisplaySurface
  console: simplify screendump
  console: zap g_width + g_height
  console: move gui_update+gui_setup_refresh from vl.c into console.c
  console: make DisplayState private to console.c
  console: add GraphicHwOps
  console: gui timer fixes
  xen: re-enable refresh interval reporting for xenfb
  console: add qemu_console_is_*
  console: allow pinning displaychangelisteners to consoles
  gtk: custom cursor support
  qxl: register QemuConsole for secondary cards

Igor Mitsyanko (2):
  exynos4210_fimd.c: fix display resize bug introduced after console revamp
  hw/vmware_vga.c: fix screen resize bug introduced after console revamp

 hw/arm/musicpal.c|8 +-
 hw/display/blizzard.c|   21 +-
 hw/display/cirrus_vga.c  |   10 +-
 hw/display/exynos4210_fimd.c |   15 +-
 hw/display/g364fb.c  |   80 +
 hw/display/jazz_led.c|   11 +-
 hw/display/milkymist-vgafb.c |9 +-
 hw/display/omap_lcdc.c   |   93 +-
 hw/display/pl110.c   |9 +-
 hw/display/pxa2xx_lcd.c  |9 +-
 hw/display/qxl.c |   42 +--
 hw/display/sm501.c   |7 +-
 hw/display/ssd0303.c |9 +-
 hw/display/ssd0323.c |9 +-
 hw/display/tc6393xb.c|   10 +-
 hw/display/tcx.c |  143 +
 hw/display/vga-isa-mm.c  |4 +-
 hw/display/vga-isa.c |3 +-
 hw/display/vga-pci.c |3 +-
 hw/display/vga.c |   76 +
 hw/display/vga_int.h |6 +-
 hw/display/vmware_vga.c  |  198 +++--
 hw/display/xenfb.c   |   67 ++---
 hw/unicore32/puv3.c  |4 +-
 include/ui/console.h |   55 ++--
 include/ui/qemu-pixman.h |9 +
 include/ui/spice-display.h   |1 -
 trace-events |   11 +
 ui/console.c |  676 +++---
 ui/curses.c  |   11 +-
 ui/gtk.c |   36 ++-
 ui/qemu-pixman.c |   54 
 ui/sdl.c |   52 ++--
 ui/spice-display.c   |   11 +-
 ui/vnc.c |   87 ++
 ui/vnc.h |2 -
 vl.c |   55 +---
 37 files changed, 832 insertions(+), 1074 deletions(-)



[Qemu-devel] [PATCH 1/1] rng random backend: check for -EAGAIN errors on read

2013-04-16 Thread Amit Shah
Not handling EAGAIN triggers the assert

qemu/backends/rng-random.c:44:entropy_available: assertion failed: (len != -1)
Aborted (core dumped)

This happens when starting a guest with '-device virtio-rng-pci',
issuing a 'cat /dev/hwrng' in the guest, while also doing 'cat
/dev/random' on the host.

Reported-by: yunpingzheng yunzh...@redhat.com
Signed-off-by: Amit Shah amit.s...@redhat.com
---
 backends/rng-random.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/backends/rng-random.c b/backends/rng-random.c
index d5761f2..830360c 100644
--- a/backends/rng-random.c
+++ b/backends/rng-random.c
@@ -41,6 +41,9 @@ static void entropy_available(void *opaque)
 ssize_t len;
 
 len = read(s-fd, buffer, s-size);
+if (len  0  errno == EAGAIN) {
+return;
+}
 g_assert(len != -1);
 
 s-receive_func(s-opaque, buffer, len);
-- 
1.8.1.4




Re: [Qemu-devel] [qemu-devel] Bug Report: VM crashed for some kinds of vCPU in nested virtualization

2013-04-16 Thread Jan Kiszka
On 2013-04-16 12:19, 李春奇 Arthur Chunqi Li wrote:
 I looked up Intel manual for VM instruction error. Error number 7 means VM
 entry with invalid control field(s), which means in process of VM
 switching some control fields are not properly configured.
 
 I wonder why some emulated CPUs (e.g.Nehalem) can run properly without
 nested VMCS MSR support?

MSRs are only switched between host (L0) and guest (L1/L2) if their
value differ. That saves some cycles. Therefore, if either the guest is
not using a specific MSR (due to differences in the virtual CPU feature
set) or it is using it in the same way like the host, there is no
switching, thus no risk to hit this unimplemented feature.

Jan




signature.asc
Description: OpenPGP digital signature


Re: [Qemu-devel] [PATCH] pixman: remove -Wredundand-decls

2013-04-16 Thread Markus Armbruster
Paolo Bonzini pbonz...@redhat.com writes:

[...]
 This workaround does NOT work if pragmas used. #pragma GCC diagnostic
 error -Wredundant-decls re-enables warnings as errors.

 The solution is to use push/pop like this:

 diff --git a/coroutine-ucontext.c b/coroutine-ucontext.c
 index 867a662..4bf2cde 100644
 --- a/coroutine-ucontext.c
 +++ b/coroutine-ucontext.c
 @@ -169,6 +169,7 @@ Coroutine *qemu_coroutine_new(void)
  #ifdef CONFIG_VALGRIND_H
  #ifdef CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE
  /* Work around an unused variable in the valgrind.h macro... */
 +#pragma GCC diagnostic push
  #pragma GCC diagnostic ignored -Wunused-but-set-variable
  #endif
  static inline void valgrind_stack_deregister(CoroutineUContext *co)
 @@ -176,7 +177,7 @@ static inline void
 valgrind_stack_deregister(CoroutineUContext *co)
  VALGRIND_STACK_DEREGISTER(co-valgrind_stack_id);
  }
  #ifdef CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE
 -#pragma GCC diagnostic error -Wunused-but-set-variable
 +#pragma GCC diagnostic pop
  #endif
  #endif

 diff --git a/include/ui/qemu-pixman.h b/include/ui/qemu-pixman.h
 index b032f52..882e2a3 100644
 --- a/include/ui/qemu-pixman.h
 +++ b/include/ui/qemu-pixman.h
 @@ -8,11 +8,12 @@

  /* pixman-0.16.0 headers have a redundant declaration */
  #ifdef CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE
 +#pragma GCC diagnostic push
  #pragma GCC diagnostic ignored -Wredundant-decls
  #endif
  #include pixman.h
  #ifdef CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE
 -#pragma GCC diagnostic error -Wredundant-decls
 +#pragma GCC diagnostic pop
  #endif

  #include qemu/typedefs.h

 Untested, feel free to resubmit with my Signed-off-by.

 Paolo

You missed the one in ui/gtk.c.  My patch covers it, and also configure.



Re: [Qemu-devel] [PATCH] ARM Cortex A9 Global Timer

2013-04-16 Thread Peter Maydell
On 15 April 2013 16:41, François Legal francois.le...@thom.fr.eu.org wrote:
 I made up this patch to implement the Cortex A9 global timer in Qemu.

 My patch is based on the Qemu branch maintained by Xilinx for the Zynq.

Hi François; thanks for this patch. Some comments on the code below.

Firstly, if you could send future versions of this patch in the
standard QEMU format that would be helpful:
 * text/plain mail, not multipart with an HTML part
 * commit message at the top describing the patch, with comments
   below a '---' line
 * Signed-off-by: line in the commit message itself
 * please submit patches based on git.qemu.org's master branch,
   not on other trees

http://wiki.qemu.org/Contribute/SubmitAPatch has some other helpful
suggestions.

Onto the code:

 diff -urN qemu-master/hw/cpu/a9mpcore.c qemu-master.new/hw/cpu/a9mpcore.c
 --- qemu-master/hw/cpu/a9mpcore.c2013-04-08 20:12:33.0 +0200
 +++ qemu-master.new/hw/cpu/a9mpcore.c2013-04-15 12:54:06.0 +0200
 @@ -15,6 +15,7 @@
  uint32_t num_cpu;
  MemoryRegion container;
  DeviceState *mptimer;
 +DeviceState *mpgtimer;
  DeviceState *wdt;
  DeviceState *gic;
  DeviceState *scu;
 @@ -31,6 +32,7 @@
  {
  A9MPPrivState *s = FROM_SYSBUS(A9MPPrivState, dev);
  SysBusDevice *timerbusdev, *wdtbusdev, *gicbusdev, *scubusdev;
 +SysBusDevice *gtimerbusdev;
  int i;

  s-gic = qdev_create(NULL, arm_gic);
 @@ -50,6 +52,11 @@
  qdev_init_nofail(s-scu);
  scubusdev = SYS_BUS_DEVICE(s-scu);

 +s-mpgtimer = qdev_create(NULL, arm_mp_globaltimer);

I think a better name for the device would be a9-globaltimer.
This fits our convention of preferring '-' rather than '_'
in new device names, and makes it clear that the global
timer is only used for the A9. (The private timers are used
also by the 11MPCore.)

 +qdev_prop_set_uint32(s-mpgtimer, num-cpu, s-num_cpu);
 +qdev_init_nofail(s-mpgtimer);
 +gtimerbusdev = SYS_BUS_DEVICE(s-mpgtimer);
 +
  s-mptimer = qdev_create(NULL, arm_mptimer);
  qdev_prop_set_uint32(s-mptimer, num-cpu, s-num_cpu);
  qdev_init_nofail(s-mptimer);
 @@ -68,8 +75,6 @@
   *  0x0600-0x06ff -- private timers and watchdogs
   *  0x0700-0x0fff -- nothing
   *  0x1000-0x1fff -- GIC Distributor
 - *
 - * We should implement the global timer but don't currently do so.
   */
  memory_region_init(s-container, a9mp-priv-container, 0x2000);
  memory_region_add_subregion(s-container, 0,
 @@ -80,6 +85,8 @@
  /* Note that the A9 exposes only the timer/watchdog for this core
   * memory region, not the timer/watchdog for core X ones 11MPcore
 has.
   */
 +memory_region_add_subregion(s-container, 0x200,
 +sysbus_mmio_get_region(gtimerbusdev, 0));
  memory_region_add_subregion(s-container, 0x600,
  sysbus_mmio_get_region(timerbusdev, 0));
  memory_region_add_subregion(s-container, 0x620,
 @@ -90,10 +97,13 @@
  sysbus_init_mmio(dev, s-container);

  /* Wire up the interrupt from each watchdog and timer.
 - * For each core the timer is PPI 29 and the watchdog PPI 30.
 + * For each core the global timer is PPI 27, the private
 + * timer is PPI 29 and the watchdog PPI 30.
   */
  for (i = 0; i  s-num_cpu; i++) {
  int ppibase = (s-num_irq - 32) + i * 32;
 +sysbus_connect_irq(gtimerbusdev, i,
 +   qdev_get_gpio_in(s-gic, ppibase + 27));
  sysbus_connect_irq(timerbusdev, i,
 qdev_get_gpio_in(s-gic, ppibase + 29));
  sysbus_connect_irq(wdtbusdev, i,
 diff -urN qemu-master/hw/timer/arm_mpgtimer.c
 qemu-master.new/hw/timer/arm_mpgtimer.c
 --- qemu-master/hw/timer/arm_mpgtimer.c1970-01-01 01:00:00.0
 +0100
 +++ qemu-master.new/hw/timer/arm_mpgtimer.c2013-04-15 13:56:23.0
 +0200

The file should also be renamed: 'hw/timer/a9gtimer.c'

 @@ -0,0 +1,359 @@
 +/*
 + * Global peripheral timer block for ARM 11MPCore and A9MP

This isn't used in 11MPCore.

 + *
 + * Written by François LEGAL
 + *
 + * This program is free software; you can redistribute it and/or
 + * modify it under the terms of the GNU General Public License
 + * as published by the Free Software Foundation; either version
 + * 2 of the License, or (at your option) any later version.
 + *
 + * This program is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 + * GNU General Public License for more details.
 + *
 + * You should have received a copy of the GNU General Public License along
 + * with this program; if not, see http://www.gnu.org/licenses/.
 + */
 +
 +#include hw/sysbus.h
 +#include qemu/timer.h
 +
 +/* This device implements the per-cpu private timer and watchdog block
 + * which is used in both the ARM11MPCore and 

[Qemu-devel] [PATCH 21/24] console: add qemu_console_is_*

2013-04-16 Thread Gerd Hoffmann
Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 include/ui/console.h |6 +++--
 ui/console.c |   59 --
 ui/curses.c  |7 +++---
 ui/sdl.c |   24 ++--
 ui/vnc.c |6 ++---
 5 files changed, 56 insertions(+), 46 deletions(-)

diff --git a/include/ui/console.h b/include/ui/console.h
index 800f458..bcd0139 100644
--- a/include/ui/console.h
+++ b/include/ui/console.h
@@ -282,8 +282,10 @@ void graphic_hw_update(QemuConsole *con);
 void graphic_hw_invalidate(QemuConsole *con);
 void graphic_hw_text_update(QemuConsole *con, console_ch_t *chardata);
 
-int is_graphic_console(void);
-int is_fixedsize_console(void);
+bool qemu_console_is_visible(QemuConsole *con);
+bool qemu_console_is_graphic(QemuConsole *con);
+bool qemu_console_is_fixedsize(QemuConsole *con);
+
 void text_consoles_set_display(DisplayState *ds);
 void console_select(unsigned int index);
 void console_color_init(DisplayState *ds);
diff --git a/ui/console.c b/ui/console.c
index 43ff80b..214cdba 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -515,7 +515,7 @@ static void update_xy(QemuConsole *s, int x, int y)
 TextCell *c;
 int y1, y2;
 
-if (s != active_console) {
+if (!qemu_console_is_visible(s)) {
 return;
 }
 
@@ -543,7 +543,7 @@ static void console_show_cursor(QemuConsole *s, int show)
 int y, y1;
 int x = s-x;
 
-if (s != active_console) {
+if (!qemu_console_is_visible(s)) {
 return;
 }
 
@@ -579,8 +579,9 @@ static void console_refresh(QemuConsole *s)
 TextCell *c;
 int x, y, y1;
 
-if (s != active_console)
+if (!qemu_console_is_visible(s)) {
 return;
+}
 
 if (s-ds-have_text) {
 s-text_x[0] = 0;
@@ -611,15 +612,10 @@ static void console_refresh(QemuConsole *s)
 }
 }
 
-static void console_scroll(int ydelta)
+static void console_scroll(QemuConsole *s, int ydelta)
 {
-QemuConsole *s;
 int i, y1;
 
-s = active_console;
-if (!s || (s-console_type == GRAPHIC_CONSOLE))
-return;
-
 if (ydelta  0) {
 for(i = 0; i  ydelta; i++) {
 if (s-y_displayed == s-y_base)
@@ -669,7 +665,7 @@ static void console_put_lf(QemuConsole *s)
 c-t_attrib = s-t_attrib_default;
 c++;
 }
-if (s == active_console  s-y_displayed == s-y_base) {
+if (qemu_console_is_visible(s)  s-y_displayed == s-y_base) {
 if (s-ds-have_text) {
 s-text_x[0] = 0;
 s-text_y[0] = 0;
@@ -1112,16 +1108,16 @@ void kbd_put_keysym(int keysym)
 
 switch(keysym) {
 case QEMU_KEY_CTRL_UP:
-console_scroll(-1);
+console_scroll(s, -1);
 break;
 case QEMU_KEY_CTRL_DOWN:
-console_scroll(1);
+console_scroll(s, 1);
 break;
 case QEMU_KEY_CTRL_PAGEUP:
-console_scroll(-10);
+console_scroll(s, -10);
 break;
 case QEMU_KEY_CTRL_PAGEDOWN:
-console_scroll(10);
+console_scroll(s, 10);
 break;
 default:
 /* convert the QEMU keysym to VT100 key string */
@@ -1338,7 +1334,7 @@ void dpy_gfx_update(QemuConsole *con, int x, int y, int 
w, int h)
 w = MIN(w, width - x);
 h = MIN(h, height - y);
 
-if (con != active_console) {
+if (!qemu_console_is_visible(con)) {
 return;
 }
 QLIST_FOREACH(dcl, s-listeners, next) {
@@ -1367,7 +1363,7 @@ void dpy_gfx_replace_surface(QemuConsole *con,
 DisplaySurface *old_surface = con-surface;
 
 con-surface = surface;
-if (con == active_console) {
+if (qemu_console_is_visible(con)) {
 dpy_gfx_switch_surface(s, surface);
 }
 qemu_free_displaysurface(old_surface);
@@ -1389,7 +1385,7 @@ void dpy_gfx_copy(QemuConsole *con, int src_x, int src_y,
 DisplayState *s = con-ds;
 struct DisplayChangeListener *dcl;
 
-if (con != active_console) {
+if (!qemu_console_is_visible(con)) {
 return;
 }
 QLIST_FOREACH(dcl, s-listeners, next) {
@@ -1406,7 +1402,7 @@ void dpy_text_cursor(QemuConsole *con, int x, int y)
 DisplayState *s = con-ds;
 struct DisplayChangeListener *dcl;
 
-if (con != active_console) {
+if (!qemu_console_is_visible(con)) {
 return;
 }
 QLIST_FOREACH(dcl, s-listeners, next) {
@@ -1421,7 +1417,7 @@ void dpy_text_update(QemuConsole *con, int x, int y, int 
w, int h)
 DisplayState *s = con-ds;
 struct DisplayChangeListener *dcl;
 
-if (con != active_console) {
+if (!qemu_console_is_visible(con)) {
 return;
 }
 QLIST_FOREACH(dcl, s-listeners, next) {
@@ -1436,7 +1432,7 @@ void dpy_text_resize(QemuConsole *con, int w, int h)
 DisplayState *s = con-ds;
 struct DisplayChangeListener *dcl;
 
-if (con != active_console) {
+if (!qemu_console_is_visible(con)) {
 return;
 }
 QLIST_FOREACH(dcl, s-listeners, next) {
@@ -1451,7 +1447,7 @@ 

Re: [Qemu-devel] [qapi] Cannot use list of strings

2013-04-16 Thread Lluís Vilanova
Paolo Bonzini writes:

 Il 16/04/2013 10:49, Stefan Hajnoczi ha scritto:
  Tried using a list of strings as an argument to a command, but the 
  generated
  code references the 'strList' type, which does not exist.
  
  Is a specialized version for ['str'] missing, or should I define my own 
  type
  with a single field of 'str' type?
 akong just hit this too.
 
 I think it's a question for aliguori, luiz, or mdroth.

 Laszlo defined and used String for this purpose:

Ok, thanks for the info. I suppose I'll go for 'StringList' in the meantime.


Lluis

-- 
 And it's much the same thing with knowledge, for whenever you learn
 something new, the whole world becomes that much richer.
 -- The Princess of Pure Reason, as told by Norton Juster in The Phantom
 Tollbooth



[Qemu-devel] [PATCH 4/9] virtio-console: Also throttle when less was written then requested

2013-04-16 Thread Gerd Hoffmann
From: Hans de Goede hdego...@redhat.com

This is necessary so that we get properly woken up to write the rest.

This patch also changes the len argument to the have_data callback, to
avoid doing an unsigned signed comparison.

Signed-off-by: Hans de Goede hdego...@redhat.com
Acked-by: Amit Shah amit.s...@redhat.com
Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 hw/char/virtio-console.c  |8 +---
 include/hw/virtio/virtio-serial.h |2 +-
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/hw/char/virtio-console.c b/hw/char/virtio-console.c
index 5035030..061f4bd 100644
--- a/hw/char/virtio-console.c
+++ b/hw/char/virtio-console.c
@@ -34,7 +34,8 @@ static gboolean chr_write_unblocked(GIOChannel *chan, 
GIOCondition cond,
 }
 
 /* Callback function that's called when the guest sends us data */
-static ssize_t flush_buf(VirtIOSerialPort *port, const uint8_t *buf, size_t 
len)
+static ssize_t flush_buf(VirtIOSerialPort *port,
+ const uint8_t *buf, ssize_t len)
 {
 VirtConsole *vcon = DO_UPCAST(VirtConsole, port, port);
 ssize_t ret;
@@ -47,7 +48,7 @@ static ssize_t flush_buf(VirtIOSerialPort *port, const 
uint8_t *buf, size_t len)
 ret = qemu_chr_fe_write(vcon-chr, buf, len);
 trace_virtio_console_flush_buf(port-id, len, ret);
 
-if (ret = 0) {
+if (ret  len) {
 VirtIOSerialPortClass *k = VIRTIO_SERIAL_PORT_GET_CLASS(port);
 
 /*
@@ -56,7 +57,8 @@ static ssize_t flush_buf(VirtIOSerialPort *port, const 
uint8_t *buf, size_t len)
  * we had a finer-grained message, like -EPIPE, we could close
  * this connection.
  */
-ret = 0;
+if (ret  0)
+ret = 0;
 if (!k-is_console) {
 virtio_serial_throttle_port(port, true);
 qemu_chr_fe_add_watch(vcon-chr, G_IO_OUT, chr_write_unblocked,
diff --git a/include/hw/virtio/virtio-serial.h 
b/include/hw/virtio/virtio-serial.h
index 7c71304..1d2040b 100644
--- a/include/hw/virtio/virtio-serial.h
+++ b/include/hw/virtio/virtio-serial.h
@@ -104,7 +104,7 @@ typedef struct VirtIOSerialPortClass {
  * 'len'.  In this case, throttling will be enabled for this port.
  */
 ssize_t (*have_data)(VirtIOSerialPort *port, const uint8_t *buf,
- size_t len);
+ ssize_t len);
 } VirtIOSerialPortClass;
 
 /*
-- 
1.7.9.7




[Qemu-devel] [PATCH 09/24] console: switch color_table_rgb to pixman_color_t

2013-04-16 Thread Gerd Hoffmann
Now that all text console rendering uses pixman we can easily
switch the color tables to use pixman_color_t directly.

Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 ui/console.c |   24 
 1 file changed, 8 insertions(+), 16 deletions(-)

diff --git a/ui/console.c b/ui/console.c
index 584f069..1935996 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -32,9 +32,6 @@
 #define MAX_CONSOLES 12
 #define CONSOLE_CURSOR_PERIOD 500
 
-#define QEMU_RGBA(r, g, b, a) (((a)  24) | ((r)  16) | ((g)  8) | (b))
-#define QEMU_RGB(r, g, b) QEMU_RGBA(r, g, b, 0xff)
-
 typedef struct TextAttributes {
 uint8_t fgcol:4;
 uint8_t bgcol:4;
@@ -210,17 +207,15 @@ void vga_hw_text_update(console_ch_t *chardata)
 
 static void vga_fill_rect(QemuConsole *con,
   int posx, int posy, int width, int height,
-  uint32_t color)
+  pixman_color_t color)
 {
 DisplaySurface *surface = qemu_console_surface(con);
 pixman_rectangle16_t rect = {
 .x = posx, .y = posy, .width = width, .height = height
 };
-pixman_color_t pcolor;
 
-pcolor = qemu_pixman_color(surface-pf, color);
 pixman_image_fill_rectangles(PIXMAN_OP_SRC, surface-image,
- pcolor, 1, rect);
+ color, 1, rect);
 }
 
 /* copy from (xs, ys) to (xd, yd) a rectangle of size (w, h) */
@@ -255,7 +250,10 @@ enum color_names {
 };
 #endif
 
-static const uint32_t color_table_rgb[2][8] = {
+#define QEMU_RGB(r, g, b)   \
+{ .red = r  8, .green = g  8, .blue = b  8, .alpha = 0x }
+
+static const pixman_color_t color_table_rgb[2][8] = {
 {   /* dark */
 QEMU_RGB(0x00, 0x00, 0x00),  /* black */
 QEMU_RGB(0xaa, 0x00, 0x00),  /* red */
@@ -316,9 +314,7 @@ static void vga_putcharxy(QemuConsole *s, int x, int y, int 
ch,
 {
 static pixman_image_t *glyphs[256];
 DisplaySurface *surface = qemu_console_surface(s);
-unsigned int fgcol, bgcol;
-pixman_image_t *ifg, *ibg;
-pixman_color_t cfg, cbg;
+pixman_color_t fgcol, bgcol;
 
 if (t_attrib-invers) {
 bgcol = color_table_rgb[t_attrib-bold][t_attrib-fgcol];
@@ -327,16 +323,12 @@ static void vga_putcharxy(QemuConsole *s, int x, int y, 
int ch,
 fgcol = color_table_rgb[t_attrib-bold][t_attrib-fgcol];
 bgcol = color_table_rgb[t_attrib-bold][t_attrib-bgcol];
 }
-cfg = qemu_pixman_color(surface-pf, fgcol);
-cbg = qemu_pixman_color(surface-pf, bgcol);
-ifg = pixman_image_create_solid_fill(cfg);
-ibg = pixman_image_create_solid_fill(cbg);
 
 if (!glyphs[ch]) {
 glyphs[ch] = qemu_pixman_glyph_from_vgafont(FONT_HEIGHT, vgafont16, 
ch);
 }
 qemu_pixman_glyph_render(glyphs[ch], surface-image,
- cfg, cbg, x, y, FONT_WIDTH, FONT_HEIGHT);
+ fgcol, bgcol, x, y, FONT_WIDTH, FONT_HEIGHT);
 }
 
 static void text_console_resize(QemuConsole *s)
-- 
1.7.9.7




[Qemu-devel] [PATCH 23/24] gtk: custom cursor support

2013-04-16 Thread Gerd Hoffmann
Makes gtk ui play nicely with qxl (and vmware_svga)
as you can actually see your pointer now ;)

Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 ui/gtk.c |   33 +
 1 file changed, 33 insertions(+)

diff --git a/ui/gtk.c b/ui/gtk.c
index e9ebbd3..d48529a 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -330,6 +330,37 @@ static void gd_refresh(DisplayChangeListener *dcl)
 graphic_hw_update(dcl-con);
 }
 
+static void gd_mouse_set(DisplayChangeListener *dcl,
+ int x, int y, int visible)
+{
+GtkDisplayState *s = container_of(dcl, GtkDisplayState, dcl);
+gint x_root, y_root;
+
+gdk_window_get_root_coords(s-drawing_area-window,
+   x, y, x_root, y_root);
+gdk_display_warp_pointer(gtk_widget_get_display(s-drawing_area),
+ gtk_widget_get_screen(s-drawing_area),
+ x_root, y_root);
+}
+
+static void gd_cursor_define(DisplayChangeListener *dcl,
+ QEMUCursor *c)
+{
+GtkDisplayState *s = container_of(dcl, GtkDisplayState, dcl);
+GdkPixbuf *pixbuf;
+GdkCursor *cursor;
+
+pixbuf = gdk_pixbuf_new_from_data((guchar *)(c-data),
+  GDK_COLORSPACE_RGB, true, 8,
+  c-width, c-height, c-width * 4,
+  NULL, NULL);
+cursor = 
gdk_cursor_new_from_pixbuf(gtk_widget_get_display(s-drawing_area),
+pixbuf, c-hot_x, c-hot_y);
+gdk_window_set_cursor(s-drawing_area-window, cursor);
+g_object_unref(pixbuf);
+g_object_unref(cursor);
+}
+
 static void gd_switch(DisplayChangeListener *dcl,
   DisplaySurface *surface)
 {
@@ -1358,6 +1389,8 @@ static const DisplayChangeListenerOps dcl_ops = {
 .dpy_gfx_update= gd_update,
 .dpy_gfx_switch= gd_switch,
 .dpy_refresh   = gd_refresh,
+.dpy_mouse_set = gd_mouse_set,
+.dpy_cursor_define = gd_cursor_define,
 };
 
 void gtk_display_init(DisplayState *ds)
-- 
1.7.9.7




  1   2   3   >