Re: [Qemu-devel] [PATCH v4 03/11] dataplane: add host memory mapping code

2012-12-05 Thread Stefan Hajnoczi
On Thu, Nov 29, 2012 at 02:57:05PM +0200, Michael S. Tsirkin wrote:
 On Thu, Nov 29, 2012 at 02:54:26PM +0200, Michael S. Tsirkin wrote:
  On Thu, Nov 29, 2012 at 01:45:19PM +0100, Stefan Hajnoczi wrote:
   On Thu, Nov 29, 2012 at 02:33:11PM +0200, Michael S. Tsirkin wrote:
On Thu, Nov 22, 2012 at 04:16:44PM +0100, Stefan Hajnoczi wrote:
 The data plane thread needs to map guest physical addresses to host
 pointers.  Normally this is done with cpu_physical_memory_map() but 
 the
 function assumes the global mutex is held.  The data plane thread does
 not touch the global mutex and therefore needs a thread-safe memory
 mapping mechanism.
 
 Hostmem registers a MemoryListener similar to how vhost collects and
 pushes memory region information into the kernel.  There is a
 fine-grained lock on the regions list which is held during lookup and
 when installing a new regions list.
 
 When the physical memory map changes the MemoryListener callbacks are
 invoked.  They build up a new list of memory regions which is finally
 installed when the list has been completed.
 
 Note that this approach is not safe across memory hotplug because 
 mapped
 pointers may still be in used across memory unplug.  However, this is
 currently a problem for QEMU in general and needs to be addressed in 
 the
 future.

Sounds like a serious problem.
I'm not sure I understand - do you say this currently a problem for QEMU
virtio? Coul you give an example please?
   
   This is a limitation of the memory API but cannot be triggered by users
   today since we don't support memory hot unplug.  I'm just explaining
   that virtio-blk-data-plane has the same issue as hw/virtio-blk.c or any
   other device emulation code here.
   
   Some more detail:
   
   The issue is that hw/virtio-blk.c submits an asynchronous I/O request on
   the host with the guest buffer.  Then virtio-blk emulation returns back
   to the caller and continues QEMU execution.
   
   It is unsafe to unplug memory while the I/O request is pending since
   there's no mechanism (e.g. refcount) to wait until the guest memory is
   no longer in use.
   
   This is a known issue.  There's no way to trigger a problem today but we
   need to eventually enhance QEMU's memory API to handle this case.
   
   Stefan
  
  For this problem we would simply need to flush outstanding aio
  before freeing memory for unplug, no refcount necessary.
  
  This patch however introduces the issue in the frontend
  and it looks like there won't be any way to solve
  it without changing the API.
 
 To clarify, as you say it is not triggerable
 so I don't think this is strictly required to address
 this at this point though it should not be too hard:
 just register callback that flushes the frontend processing.
 
 But if you can't code it at this point, please add
 a TODO comment in code.

Yes, I'm adding a TODO and your suggestion to flush the frontend sounds
like a simple solution - we already quiesce at other critical points
like live migration.

Stefan



Re: [Qemu-devel] [PATCH v4 03/11] dataplane: add host memory mapping code

2012-12-05 Thread Stefan Hajnoczi
On Thu, Nov 29, 2012 at 04:36:08PM +0200, Michael S. Tsirkin wrote:
 On Thu, Nov 29, 2012 at 03:26:56PM +0100, Stefan Hajnoczi wrote:
  On Thu, Nov 29, 2012 at 03:54:25PM +0200, Michael S. Tsirkin wrote:
   On Thu, Nov 22, 2012 at 04:16:44PM +0100, Stefan Hajnoczi wrote:
The data plane thread needs to map guest physical addresses to host
pointers.  Normally this is done with cpu_physical_memory_map() but the
function assumes the global mutex is held.  The data plane thread does
not touch the global mutex and therefore needs a thread-safe memory
mapping mechanism.

Hostmem registers a MemoryListener similar to how vhost collects and
pushes memory region information into the kernel.  There is a
fine-grained lock on the regions list which is held during lookup and
when installing a new regions list.

When the physical memory map changes the MemoryListener callbacks are
invoked.  They build up a new list of memory regions which is finally
installed when the list has been completed.

Note that this approach is not safe across memory hotplug because mapped
pointers may still be in used across memory unplug.  However, this is
currently a problem for QEMU in general and needs to be addressed in the
future.

Signed-off-by: Stefan Hajnoczi stefa...@redhat.com
   
   Worth bothering with binary search?
   vhost does a linear search over regions because
   the number of ram regions is very small.
  
  memory.c does binary search.  I did the same but in practice there are
  20 regions for a simple VM.  It's probably not worth it but without
  performance results this is speculation.
  
  I think there's no harm in using binary search to start with.
  
+static void hostmem_listener_append_region(MemoryListener *listener,
+   MemoryRegionSection 
*section)
+{
+Hostmem *hostmem = container_of(listener, Hostmem, listener);
+
+if (memory_region_is_ram(section-mr)) {
+hostmem_append_new_region(hostmem, section);
+}
   
   I think you also need to remove VGA region since you
   don't mark these pages as dirty so access there won't work.
  
  I don't understand.  If memory in the VGA region returns true from
  memory_region_is_ram(), why would there be a problem?
 
 If you change this memory but you don't update the display.
 Never happens with non buggy guests but we should catch and fail if it does.

Okay, I took a look at the VGA code and I think it makes sense now.  We
have VRAM as a regular RAM region so that writes to it are cheap.  To
avoid scanning or redrawing VRAM on every update we use dirty logging.

Since virtio-blk-data-plane does not mark pages dirty an I/O buffer in
VRAM would fail to update the display correctly.

I will try to put in a check to omit the VGA region.  It can be dropped
in the future when we use the memory API with dirty logging from the
data plane thread.

Stefan



Re: [Qemu-devel] [PATCH v1 0/3] Xilinx Microblaze IP updates

2012-12-05 Thread Edgar E. Iglesias
On Wed, Dec 05, 2012 at 04:53:41PM +1000, Peter Crosthwaite wrote:
 Minor fixes to xilinx microblaze IP.
 
 Peter Crosthwaite (3):
   xilinx_axienet: Implement R_IS behaviour
   xilinx_uartlite: suppress cannot receive message
   xilinx_uartlite: Accept input after rx FIFO pop
 
  hw/xilinx_axienet.c  |4 
  hw/xilinx_uartlite.c |7 ++-
  2 files changed, 6 insertions(+), 5 deletions(-)
 


Applied all, thanks Peter.



Re: [Qemu-devel] [PATCH] virtfs-proxy-helper: check return code of setfsgid/setfsuid

2012-12-05 Thread Aneesh Kumar K.V

Hi,

I have tested the below patch. Currently i don't have a signed-off-by on
the patch. One change noted by mohan which I incorporated in the patch
is we need to call setresgid before calling setresuid. If you are ok
with this change I can send it upstream.

commit d11bb5bb31a68e3eefb4e592161978dba29137f5
Author: Paolo Bonzini pbon...@redhat.com
Date:   Thu Oct 11 14:20:23 2012 +0200

virtfs-proxy-helper: use setresuid and setresgid

The setfsuid and setfsgid system calls are obscure and they complicate
the error checking (that glibc's warn_unused_result feature forces
us to do).  Switch to the standard setresuid and setresgid functions.

Signed-off-by: Aneesh Kumar K.V aneesh.ku...@linux.vnet.ibm.com

diff --git a/fsdev/virtfs-proxy-helper.c b/fsdev/virtfs-proxy-helper.c
index f9a8270..df2a939 100644
--- a/fsdev/virtfs-proxy-helper.c
+++ b/fsdev/virtfs-proxy-helper.c
@@ -272,31 +272,76 @@ static int send_status(int sockfd, struct iovec *iovec, 
int status)
 /*
  * from man 7 capabilities, section
  * Effect of User ID Changes on Capabilities:
- * 4. If the file system user ID is changed from 0 to nonzero (see setfsuid(2))
- * then the following capabilities are cleared from the effective set:
- * CAP_CHOWN, CAP_DAC_OVERRIDE, CAP_DAC_READ_SEARCH,  CAP_FOWNER, CAP_FSETID,
- * CAP_LINUX_IMMUTABLE  (since  Linux 2.2.30), CAP_MAC_OVERRIDE, and CAP_MKNOD
- * (since Linux 2.2.30). If the file system UID is changed from nonzero to 0,
- * then any of these capabilities that are enabled in the permitted set
- * are enabled in the effective set.
+ * If the effective user ID is changed from nonzero to 0, then the permitted
+ * set is copied to the effective set.  If the effective user ID is changed
+ * from 0 to nonzero, then all capabilities are are cleared from the effective
+ * set.
+ *
+ * The setfsuid/setfsgid man pages warn that changing the effective user ID may
+ * expose the program to unwanted signals, but this is not true anymore: for an
+ * unprivileged (without CAP_KILL) program to send a signal, the real or
+ * effective user ID of the sending process must equal the real or saved user
+ * ID of the target process.  Even when dropping privileges, it is enough to
+ * keep the saved UID to a privileged value and virtfs-proxy-helper won't
+ * be exposed to signals.  So just use setresuid/setresgid.
  */
-static int setfsugid(int uid, int gid)
+static int setugid(int uid, int gid, int *suid, int *sgid)
 {
+int retval;
+
 /*
- * We still need DAC_OVERRIDE because  we don't change
+ * We still need DAC_OVERRIDE because we don't change
  * supplementary group ids, and hence may be subjected DAC rules
  */
 cap_value_t cap_list[] = {
 CAP_DAC_OVERRIDE,
 };
 
-setfsgid(gid);
-setfsuid(uid);
+*suid = geteuid();
+*sgid = getegid();
+
+if (setresgid(-1, gid, *sgid) == -1) {
+retval = -errno;
+goto err_out;
+}
+
+if (setresuid(-1, uid, *suid) == -1) {
+retval = -errno;
+goto err_sgid;
+}
 
 if (uid != 0 || gid != 0) {
-return do_cap_set(cap_list, ARRAY_SIZE(cap_list), 0);
+if (do_cap_set(cap_list, ARRAY_SIZE(cap_list), 0)  0) {
+retval = -errno;
+goto err_suid;
+}
 }
 return 0;
+
+err_suid:
+if (setresuid(-1, *suid, *suid) == -1) {
+abort();
+}
+err_sgid:
+if (setresgid(-1, *sgid, *sgid) == -1) {
+abort();
+}
+err_out:
+return retval;
+}
+
+/*
+ * This is used to reset the ugid back with the saved values
+ * There is nothing much we can do checking error values here.
+ */
+static void resetugid(int suid, int sgid)
+{
+if (setresgid(-1, sgid, sgid) == -1) {
+abort();
+}
+if (setresuid(-1, suid, suid) == -1) {
+abort();
+}
 }
 
 /*
@@ -578,18 +623,15 @@ static int do_create_others(int type, struct iovec *iovec)
 
 v9fs_string_init(path);
 v9fs_string_init(oldpath);
-cur_uid = geteuid();
-cur_gid = getegid();
 
 retval = proxy_unmarshal(iovec, offset, dd, uid, gid);
 if (retval  0) {
 return retval;
 }
 offset += retval;
-retval = setfsugid(uid, gid);
+retval = setugid(uid, gid, cur_uid, cur_gid);
 if (retval  0) {
-retval = -errno;
-goto err_out;
+goto unmarshal_err_out;
 }
 switch (type) {
 case T_MKNOD:
@@ -619,9 +661,10 @@ static int do_create_others(int type, struct iovec *iovec)
 }
 
 err_out:
+resetugid(cur_uid, cur_gid);
+unmarshal_err_out:
 v9fs_string_free(path);
 v9fs_string_free(oldpath);
-setfsugid(cur_uid, cur_gid);
 return retval;
 }
 
@@ -641,24 +684,16 @@ static int do_create(struct iovec *iovec)
 if (ret  0) {
 goto unmarshal_err_out;
 }
-cur_uid = geteuid();
-cur_gid = getegid();
-ret = setfsugid(uid, gid);
+ret = setugid(uid, gid, cur_uid, cur_gid);
 if (ret  0) {
-/*
- * On 

Re: [Qemu-devel] [PATCH][RESEND] iscsi: add support for iSCSI NOPs

2012-12-05 Thread Peter Lieven
All, please ignore this patch. During testing we found a problem in live
usage. We will resubmit once this is fixed.

Peter

Am 04.12.2012 um 06:03 schrieb ronnie sahlberg:

 Acked-By: ronniesahlb...@gmail.com (Ronnie Sahlberg)
 
 
 This verified that the service is actually operational and is much
 more reliable than TCP-KEEPALIVES.
 This is the proper way to monitor that the iscsi target is alive.
 
 We should as a later patch add the ability to configure this via the
 qemu config file instead of using hardcoded values.
 
 
 regards
 ronnie sahlberg
 
 
 On Mon, Dec 3, 2012 at 11:34 AM, Peter Lieven p...@dlhnet.de wrote:
 This patch will send NOP-Out PDUs every 5 seconds to the iSCSI target.
 If a consecutive number of NOP-In replies fail a reconnect is initiated.
 iSCSI NOPs help to ensure that the connection to the target is still 
 operational.
 This should not, but in reality may be the case even if the TCP connection 
 is still
 alive if there are bugs in either the target or the initiator implementation.
 
 Reported-by: Ronnie Sahlberg ronniesahlb...@gmail.com
 Signed-off-by: Peter Lieven p...@kamp.de
 ---
 block/iscsi.c |   43 +++
 1 file changed, 43 insertions(+)
 
 diff --git a/block/iscsi.c b/block/iscsi.c
 index d0b1a10..fab4c8b 100644
 --- a/block/iscsi.c
 +++ b/block/iscsi.c
 @@ -47,6 +47,9 @@ typedef struct IscsiLun {
 int block_size;
 uint64_t num_blocks;
 int events;
 +
 +QEMUTimer *nop_timer;
 +int nops_in_flight;
 } IscsiLun;
 
 typedef struct IscsiAIOCB {
 @@ -72,6 +75,9 @@ struct IscsiTask {
 int complete;
 };
 
 +#define NOP_INTERVAL 5000
 +#define MAX_NOP_FAILURES 3
 +
 static void
 iscsi_bh_cb(void *p)
 {
 @@ -925,6 +931,35 @@ static char *parse_initiator_name(const char *target)
 }
 }
 
 +static void iscsi_nop_cb(struct iscsi_context *iscsi, int status, void 
 *command_data, void *private_data)
 +{
 +IscsiLun *iscsilun = private_data;
 +
 +if (iscsilun) {
 +iscsilun-nops_in_flight = 0;
 +}
 +}
 +
 +static void iscsi_nop_timed_event(void *opaque)
 +{
 +IscsiLun *iscsilun = opaque;
 +
 +if (iscsilun-nops_in_flight  MAX_NOP_FAILURES) {
 +error_report(iSCSI: NOP timeout. Reconnecting...);
 +iscsi_reconnect(iscsilun-iscsi);
 +iscsilun-nops_in_flight = 0;
 +}
 +
 +if (iscsi_nop_out_async(iscsilun-iscsi, iscsi_nop_cb, NULL, 0, 
 iscsilun) != 0) {
 +error_report(iSCSI: failed to sent NOP-Out. Disabling NOP 
 messages.);
 +return;
 +}
 +
 +qemu_mod_timer(iscsilun-nop_timer, qemu_get_clock_ms(rt_clock) + 
 NOP_INTERVAL);
 +iscsi_set_events(iscsilun);
 +iscsilun-nops_in_flight++;
 +}
 +
 /*
  * We support iscsi url's on the form
  * iscsi://[username%password@]host[:port]/targetname/lun
 @@ -1036,6 +1071,10 @@ static int iscsi_open(BlockDriverState *bs, const 
 char *filename, int flags)
 
 ret = 0;
 
 +/* Set up a timer for sending out iSCSI NOPs */
 +iscsilun-nop_timer = qemu_new_timer_ms(rt_clock, 
 iscsi_nop_timed_event, iscsilun);
 +qemu_mod_timer(iscsilun-nop_timer, qemu_get_clock_ms(rt_clock) + 
 NOP_INTERVAL);
 +
 out:
 if (initiator_name != NULL) {
 g_free(initiator_name);
 @@ -1058,6 +1097,10 @@ static void iscsi_close(BlockDriverState *bs)
 IscsiLun *iscsilun = bs-opaque;
 struct iscsi_context *iscsi = iscsilun-iscsi;
 
 +if (iscsilun-nop_timer) {
 +qemu_del_timer(iscsilun-nop_timer);
 +qemu_free_timer(iscsilun-nop_timer);
 +}
 qemu_aio_set_fd_handler(iscsi_get_fd(iscsi), NULL, NULL, NULL, NULL);
 iscsi_destroy_context(iscsi);
 memset(iscsilun, 0, sizeof(IscsiLun));
 --
 1.7.9.5
 
 




Re: [Qemu-devel] [PATCH v3] vnc: added initial websocket protocol support

2012-12-05 Thread Tim Hardeck
Hi Stefan,

On 12/03/2012 05:22 PM, Stefan Hajnoczi wrote:
 Thanks for the patch, Tim.  Some general code review comments below.
Thanks for the code review. I am going to incorporate them in my new patch.

 I hope someone has time to review the VNC and WebSocket specific stuff. 
 I didn't check the details of buffers, whether the WebSocket spec is
 correctly implemented, etc.
I have mainly tested my websockets implementation with the guest OS
openSUSE 12.2 which worked fine during all my tests on several browsers.
I recently found out though that when I run Firefox in openSUSE 12.1,
noVNC complains about an unsupported VNC encoding and QEMU crashes. I
have attached the back trace at the end of this mail.

This issue could be fixed by not encoding Websocket frames directly in
vnc_write but in vnc_client_write_locked. This should also decrease the
overhead through websocket frame headers.
Nevertheless it looks like QEMU did crash because of the sudden
disconnect which shouldn't happen.

I have created a vnc_client_write_ws function which is used instead of
vnc_client_write_plain. I have also moved the decoding part to
vnc_client_read_ws to keep consistency?
Is this Ok or should I add the websocket en/decoding to the existing vnc
plain functions?

Regards
Tim



#0  0x73f92d25 in __GI_raise (sig=sig@entry=6) at
../nptl/sysdeps/unix/sysv/linux/raise.c:64
resultvar = 0
pid = 24308
selftid = 24312
#1  0x73f941a8 in __GI_abort () at abort.c:91
save_stage = 2
act = {__sigaction_handler = {sa_handler = 0x559153c0
__func__.4908, sa_sigaction =
0x559153c0 __func__.4908}, sa_mask = {__val =
{140737287809753, 0, 18374686479671623680,
0, 140737286898450, 131072, 93825010082032, 2064448, 93825010157472,
1989008, 22,
140737218422160, 1, 140737488346032, 0, 140737218426624}}, sa_flags
= -201457138, sa_restorer =
0x6d940}
sigs = {__val = {32, 0 repeats 15 times}}
#2  0x5577b5c2 in error_exit (err=22, msg=0x559153c0
__func__.4908 qemu_mutex_lock)
at qemu-thread-posix.c:28
No locals.
#3  0x5577b6e1 in qemu_mutex_lock (mutex=0x5328) at
qemu-thread-posix.c:59
err = 22
__func__ = qemu_mutex_lock
#4  0x557bb075 in vnc_lock_output (vs=0x5665a100) at
ui/vnc-jobs.h:63
No locals.
#5  0x557bb5eb in vnc_jobs_consume_buffer (vs=0x5665a100) at
ui/vnc-jobs.c:166
flush = false
#6  0x557bb5ae in vnc_jobs_join (vs=0x5665a100) at
ui/vnc-jobs.c:159
No locals.
#7  0x557bf9d9 in vnc_update_client_sync (vs=0x5665a100,
has_dirty=1) at ui/vnc.c:876
ret = 0
---Type return to continue, or q return to quit---
#8  0x557bf308 in vnc_dpy_copy (ds=0x56583240, src_x=99,
src_y=143, dst_x=99, dst_y=
146, w=8, h=1) at ui/vnc.c:752
vd = 0x7fffeea48010
vs = 0x5665a100
vn = 0x0
src_row = 0x18 Address 0x18 out of bounds
dst_row = 0xc000c00 Address 0xc000c00 out of bounds
i = 768
x = -1
y = 24
pitch = 1024
inc = 0
w_lim = 0
s = 8
cmp_bytes = 2359296
#9  0x55623e78 in dpy_gfx_copy (s=0x56583240, src_x=99,
src_y=143, dst_x=99, dst_y=146,
w=8, h=1) at console.h:275
dcl = 0x565f38e0
#10 0x556281f4 in qemu_console_copy (ds=0x56583240,
src_x=99, src_y=143, dst_x=99,
dst_y=146, w=8, h=1) at console.c:1598
No locals.
#11 0x5566a79a in cirrus_do_copy (s=0x565afc08, dst=448832,
src=439616, w=8, h=1)
at hw/cirrus_vga.c:732
sx = 99
sy = 143
dx = 99
---Type return to continue, or q return to quit---
dy = 146
depth = 3
notify = 1
#12 0x5566a8f7 in cirrus_bitblt_videotovideo_copy
(s=0x565afc08) at hw/cirrus_vga.c:750
No locals.
#13 0x5566ae8b in cirrus_bitblt_videotovideo (s=0x565afc08)
at hw/cirrus_vga.c:872
ret = 1
#14 0x5566b61c in cirrus_bitblt_start (s=0x565afc08) at
hw/cirrus_vga.c:1013
blt_rop = 13 '\r'
#15 0x5566b6c8 in cirrus_write_bitblt (s=0x565afc08,
reg_value=2)
at hw/cirrus_vga.c:1034
old_value = 0
#16 0x5566c589 in cirrus_vga_write_gr (s=0x565afc08,
reg_index=49, reg_value=2)
at hw/cirrus_vga.c:1529
No locals.
#17 0x5566cebb in cirrus_mmio_blt_write (s=0x565afc08,
address=64, value=2 '\002')
at hw/cirrus_vga.c:1883
No locals.
#18 0x5566ed4c in cirrus_mmio_write (opaque=0x565afc08,
addr=320, val=2, size=1)
at hw/cirrus_vga.c:2659
s = 0x565afc08
#19 0x5584b7ca in memory_region_write_accessor
(opaque=0x565c0538, addr=320, value=
0x7fffefe92a98, size=1, shift=0, mask=255) at
/suse/thardeck/Development/qemu/memory.c:334
mr = 0x565c0538
tmp = 2
#20 0x5584b8ac in access_with_adjusted_size (addr=320,
value=0x7fffefe92a98, size=4,
---Type return to 

Re: [Qemu-devel] [PATCH v6 2/2] qemu-ga: sample fsfreeze hooks

2012-12-05 Thread Tomoki Sekiyama
On 2012/12/05 1:51, Luiz Capitulino wrote:
 On Fri, 30 Nov 2012 22:33:57 +0900
 Tomoki Sekiyama tomoki.sekiyama...@hitachi.com wrote:
 
 Adds sample hook scripts for --fsfreeze-hook option of qemu-ga.
   - fsfreeze-hook : execute scripts in fsfreeze-hook.d/
   - fsfreeze-hook.d.sample/mysql-flush.sh : quiesce MySQL before snapshot

 Signed-off-by: Tomoki Sekiyama tomoki.sekiyama...@hitachi.com
 ---
  docs/qemu-guest-agent/fsfreeze-hook|   33 
  .../fsfreeze-hook.d.sample/mysql-flush.sh  |   55 
 
  2 files changed, 88 insertions(+)
  create mode 100755 docs/qemu-guest-agent/fsfreeze-hook
  create mode 100755 
 docs/qemu-guest-agent/fsfreeze-hook.d.sample/mysql-flush.sh

 diff --git a/docs/qemu-guest-agent/fsfreeze-hook 
 b/docs/qemu-guest-agent/fsfreeze-hook
 new file mode 100755
 index 000..ed7d86d
 --- /dev/null
 +++ b/docs/qemu-guest-agent/fsfreeze-hook
 @@ -0,0 +1,33 @@
 +#!/bin/sh
 +
 +# This script is executed when a guest agent receives fsfreeze-freeze and
 +# fsfreeze-thaw command, if it is specified in --fsfreeze-hook (-F)
 +# option of qemu-ga or placed in default path (/etc/qemu/fsfreeze-hook).
 +# When the agent receives fsfreeze-freeze request, this script is issued 
 with
 +# freeze argument before the filesystem is freezed. And for fsfreeze-thaw
 +# request, it is issued with thaw argument after filesystem is thawed.
 +
 +LOGFILE=/var/log/qga-fsfreeze-hook.log
 +FSFREEZE_D=$(dirname -- $0)/fsfreeze-hook.d
 
 The script you introduce is called fsfreeze-hook.d.sample. If it's expected
 that people really use these two scripts (vs. doc purposes only) I suggest
 the following:
 
  1. Move these files to scripts/
  2. Drop the .sample suffix

It is good for fsfreeze-hook. But as for mysql-flush.sh, users may
need to configure authentication etc. if their environments are with
non-default setup (by edditing either the script or ~/.my.cnf file).

So, I'd like to (1)move these files to scripts/, but (2)reamin .sample
suffix to indicate that users may need to modify the script.
How do you think?

Thanks,
-- 
Tomoki Sekiyama tomoki.sekiyama...@hitachi.com
Linux Technology Center
Hitachi, Ltd., Yokohama Research Laboratory




Re: [Qemu-devel] [PATCH v2 2/2] ivshmem: use irqfd to interrupt among VMs

2012-12-05 Thread Jan Kiszka
On 2012-12-05 06:34, Cam Macdonell wrote:
  static void ivshmem_write_config(PCIDevice *pci_dev, uint32_t address,
  uint32_t val, int len)
  {
 +bool is_enabled, was_enabled = msi_enabled(pci_dev);
 +
  pci_default_write_config(pci_dev, address, val, len);
 +is_enabled = msi_enabled(pci_dev);
 
 Problem 1)  in my tests is_enabled is always 0, so I don't think the
 irqfds are getting setup

You likely want to call msix_enabled here.

Jan

-- 
Siemens AG, Corporate Technology, CT RTC ITP SDP-DE
Corporate Competence Center Embedded Linux



Re: [Qemu-devel] [PATCH 2/3] target-i386:make hw_breakpoint_enabled return bool type

2012-12-05 Thread Jan Kiszka
On 2012-12-05 01:51, li guang wrote:
 在 2012-12-04二的 11:26 +,Peter Maydell写道:
 On 4 December 2012 11:11, Jan Kiszka jan.kis...@siemens.com wrote:
 On 2012-12-04 11:23, Peter Maydell wrote:
 Doesn't this break the use of this function in target-i386/seg_helper.c:

   if (hw_breakpoint_enabled(env-dr[7], i) == 0x1) {

 which specifically wants to determine whether the breakpoint is
 enabled only locally?
 
  It was changed to 'if (hw_breakpoint_enabled(env-dr[7], i)) {'
  in patch 3/3

Which is broken as it neglects the different types of enabled.

 

 It does. And that also indicates the function is misnamed. Something
 like hw_breakpoint_state might be better.

 
 misnamed? I think hw_breakpoint_enabled is ask whether breakpoint
  
 is enabled or not, so it's almost suitable.

There are two types of enabled breakpoints: task-local and global. The
current hw_breakpoint_enabled returns both as a bitmask, and that is
causing the confusing and regression in your patches.

Jan

-- 
Siemens AG, Corporate Technology, CT RTC ITP SDP-DE
Corporate Competence Center Embedded Linux



Re: [Qemu-devel] [PATCH 3/3] target-i386:slightly refactor dr7 related function

2012-12-05 Thread Jan Kiszka
On 2012-12-05 01:56, li guang wrote:
 @@ -1014,22 +1016,40 @@ void hw_breakpoint_remove(CPUX86State *env, int 
 index)
  int check_hw_breakpoints(CPUX86State *env, int force_dr6_update)
  {
  target_ulong dr6;
 -int reg, type;
 +int index;
  int hit_enabled = 0;
 +bool bp_match = false;
 +bool wp_match = false;

  dr6 = env-dr[6]  ~0xf;
 -for (reg = 0; reg  4; reg++) {
 -type = hw_breakpoint_type(env-dr[7], reg);
 -if ((type == 0  env-dr[reg] == env-eip) ||
 -((type  1)  env-cpu_watchpoint[reg] 
 - (env-cpu_watchpoint[reg]-flags  BP_WATCHPOINT_HIT))) {
 -dr6 |= 1  reg;
 -if (hw_breakpoint_enabled(env-dr[7], reg))
 +   for (index = 0; index  DR7_MAX_BP; index++) {
 +switch (hw_breakpoint_type(env-dr[7], index)) {
 +case DR7_BP_INST:
 +if (env-dr[index] == env-eip) {
 +bp_match = true;
 +}
 +break;
 +case DR7_DATA_WR:
 +case DR7_DATA_RW:
 +if (env-cpu_watchpoint[index] 
 +env-cpu_watchpoint[index]-flags  BP_WATCHPOINT_HIT) {
 +wp_match = true;
 +}

 Also here.

 
 No, just fall through.

I told you how to clearly mark such cases.

Jan

-- 
Siemens AG, Corporate Technology, CT RTC ITP SDP-DE
Corporate Competence Center Embedded Linux



[Qemu-devel] [Bug 955379] Re: cmake hangs with qemu-arm-static

2012-12-05 Thread Janne Karhunen
Just out of interest tried how far the timeout hackery can go working
around the issue. Well, looks like it goes quite far: having previously
reproduced the hang in 4-5 runs and in under a minute, now have had this
running without a hang for an hour. I will also test the patch under OBS
worker(s) and if it solves the issue there as well, I will attach it as
a workaround for time being for those interested. However, Peter is
right and this is not a final solution of any kind: just a workaround.

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

Title:
  cmake hangs with qemu-arm-static

Status in QEMU:
  Confirmed
Status in Linaro QEMU:
  Confirmed
Status in “qemu-linaro” package in Ubuntu:
  Confirmed

Bug description:
  I'm using git commit 3e7ecd976b06f... configured with --target-list
  =arm-linux-user --static in a chroot environment to compile some
  things. I ran into this problem with both pcl and opencv-2.3.1. cmake
  consistently freezes at some point during its execution, though in a
  different spot each time, usually during a step when it's searching
  for some libraries. For instance, pcl most commonly stops after:

  [snip]
  -- Boost version: 1.46.1
  -- Found the following Boost libraries:
  --   system
  --   filesystem
  --   thread
  --   date_time
  -- checking for module 'eigen3'
  --   found eigen3, version 3.0.1

  which is perplexing because it freezes after finding what it wants,
  not during the search. When it does get past that point, it does so
  almost immediately but freezes somewhere else.

  I'm using 64-bit Ubuntu 11.10 with kernel release 3.0.0-16-generic
  with an Intel i5.

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



Re: [Qemu-devel] [PATCH v2 2/2] ivshmem: use irqfd to interrupt among VMs

2012-12-05 Thread Andrew Jones


- Original Message -
 On Tue, Dec 4, 2012 at 4:10 AM, Andrew Jones drjo...@redhat.com
 wrote:
 
 
  - Original Message -
  On Thu, Nov 29, 2012 at 1:34 AM, liu ping fan qemul...@gmail.com
  wrote:
   On Thu, Nov 29, 2012 at 12:42 PM, Cam Macdonell
   c...@cs.ualberta.ca wrote:
   On Tue, Nov 27, 2012 at 7:53 PM, liu ping fan
   qemul...@gmail.com
   wrote:
   On Wed, Nov 28, 2012 at 5:48 AM, Cam Macdonell
   c...@cs.ualberta.ca wrote:
   On Sat, Nov 24, 2012 at 8:51 PM, Liu Ping Fan
   qemul...@gmail.com wrote:
   From: Liu Ping Fan pingf...@linux.vnet.ibm.com
  
   Using irqfd, so we can avoid switch between kernel and user
   when
   VMs interrupts each other.
  
   Nice work.  Due to a hardware failure, there will be a small
   delay in
   me being able to test this.  I'll follow up as soon as I can.
  
   BTW where can I find the latest guest code for test?
   I got the guest code from
   git://gitorious.org/nahanni/guest-code.git.
   But it seems outdated, after fixing the unlocked_ioctl, and
   vm-id
   bits
   position (the codes conflict with ivshmem spec), it works (I
   have
   tested for V1).
  
   Hello,
  
   Which device driver are you using?
  
   guest-code/kernel_module/standard/kvm_ivshmem.c
 
  The uio driver is the recommended one, however if you want to use
  the
  kvm_ivshmem one and have it working, then feel free to continue.
 
  If the uio driver is the recommended one, then can you please post
  it
  to lkml? It should be integrated into drivers/virt with an
  appropriate
  Kconfig update.
 
 
 Sure.  Should it go under drivers/virt or drivers/uio?  It seems the
 uio drivers all get grouped together.

Good point. That is the current practice. As there's still only a
handful of uio drivers, then I guess it doesn't make sense to try and
change that at this point. It seems that it would make more sense to
use drivers/uio just for generic uio drivers though, and then the other
uio drivers would go under drivers/type/uio, e.g. drivers/virt/uio

Drew

 
 Thanks,
 Cam
 
  Thanks,
  Drew
 
 
  I had deleted it form the repo, but some users had based solutions
  off
  it, so I added it back.
 
  btw, my hardware issue has been resolved, so I'll get to testing
  your
  patch soon.
 
  Sincerely,
  Cam
 
  
   Cam
  
  
   Regards,
   Pingfan
  
  
   Signed-off-by: Liu Ping Fan pingf...@linux.vnet.ibm.com
   ---
hw/ivshmem.c |   54
+-
1 files changed, 53 insertions(+), 1 deletions(-)
  
   diff --git a/hw/ivshmem.c b/hw/ivshmem.c
   index 7c8630c..5709e89 100644
   --- a/hw/ivshmem.c
   +++ b/hw/ivshmem.c
   @@ -19,6 +19,7 @@
#include hw.h
#include pc.h
#include pci.h
   +#include msi.h
#include msix.h
#include kvm.h
#include migration.h
   @@ -83,6 +84,7 @@ typedef struct IVShmemState {
uint32_t vectors;
uint32_t features;
EventfdEntry *eventfd_table;
   +int *vector_virqs;
  
Error *migration_blocker;
  
   @@ -625,16 +627,62 @@ static int ivshmem_load(QEMUFile* f,
   void
   *opaque, int version_id)
return 0;
}
  
   +static int ivshmem_vector_use(PCIDevice *dev, unsigned
   vector,
   + MSIMessage msg)
   +{
   +IVShmemState *s = DO_UPCAST(IVShmemState, dev, dev);
   +int virq;
   +EventNotifier *n =
   s-peers[s-vm_id].eventfds[vector];
   +
   +virq = kvm_irqchip_add_msi_route(kvm_state, msg);
   +if (virq = 0 
   kvm_irqchip_add_irqfd_notifier(kvm_state,
   n, virq) = 0) {
   +s-vector_virqs[vector] = virq;
   +qemu_chr_add_handlers(s-eventfd_chr[vector], NULL,
   NULL, NULL, NULL);
   +} else if (virq = 0) {
   +kvm_irqchip_release_virq(kvm_state, virq);
   +error_report(ivshmem, can not setup irqfd\n);
   +return -1;
   +} else {
   +error_report(ivshmem, no enough msi route to setup
   irqfd\n);
   +return -1;
   +}
   +
   +return 0;
   +}
   +
   +static void ivshmem_vector_release(PCIDevice *dev, unsigned
   vector)
   +{
   +IVShmemState *s = DO_UPCAST(IVShmemState, dev, dev);
   +EventNotifier *n =
   s-peers[s-vm_id].eventfds[vector];
   +int virq = s-vector_virqs[vector];
   +
   +if (s-vector_virqs[vector] = 0) {
   +kvm_irqchip_remove_irqfd_notifier(kvm_state, n,
   virq);
   +kvm_irqchip_release_virq(kvm_state, virq);
   +s-vector_virqs[vector] = -1;
   +}
   +}
   +
static void ivshmem_write_config(PCIDevice *pci_dev,
uint32_t
address,
uint32_t val, int len)
{
   +bool is_enabled, was_enabled = msi_enabled(pci_dev);
   +
pci_default_write_config(pci_dev, address, val, len);
   +is_enabled = msi_enabled(pci_dev);
   +if (!was_enabled  is_enabled) {
   +msix_set_vector_notifiers(pci_dev,
   ivshmem_vector_use,
   +ivshmem_vector_release);
   +} else if 

[Qemu-devel] [PATCH 3/6] usb: Don't allow USB_RET_ASYNC for interrupt packets

2012-12-05 Thread Gerd Hoffmann
From: Hans de Goede hdego...@redhat.com

It is tempting to use USB_RET_ASYNC for interrupt packets, rather then the
current NAK + polling approach, but this causes issues for migration, as
an async completed packet will not getting written back to guest memory until
the next poll time, and if a migration happens in between it will get lost!

Make an exception for host devices, because:
1) host-linux actually uses async completion for interrupt endpoints
2) host devices don't migrate anyways

Ideally we would convert host-linux.c to handle (input) interrupt endpoints in
a buffered manner like it does for isoc endpoints, keeping multiple urbs
submitted to ensure the devices timing requirements are met, as well as making
its interrupt ep handling the same as other usb-devices.

Signed-off-by: Hans de Goede hdego...@redhat.com
Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 hw/usb.h|1 +
 hw/usb/core.c   |4 
 hw/usb/host-bsd.c   |1 +
 hw/usb/host-linux.c |1 +
 4 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/hw/usb.h b/hw/usb.h
index 7d6de69..58f812f 100644
--- a/hw/usb.h
+++ b/hw/usb.h
@@ -197,6 +197,7 @@ struct USBEndpoint {
 
 enum USBDeviceFlags {
 USB_DEV_FLAG_FULL_PATH,
+USB_DEV_FLAG_IS_HOST,
 };
 
 /* definition of a USB device */
diff --git a/hw/usb/core.c b/hw/usb/core.c
index 52b5310..8e360d3 100644
--- a/hw/usb/core.c
+++ b/hw/usb/core.c
@@ -406,7 +406,11 @@ void usb_handle_packet(USBDevice *dev, USBPacket *p)
 if (QTAILQ_EMPTY(p-ep-queue) || p-ep-pipeline) {
 usb_process_one(p);
 if (p-status == USB_RET_ASYNC) {
+/* hcd drivers cannot handle async for isoc */
 assert(p-ep-type != USB_ENDPOINT_XFER_ISOC);
+/* using async for interrupt packets breaks migration */
+assert(p-ep-type != USB_ENDPOINT_XFER_INT ||
+   (dev-flags  USB_DEV_FLAG_IS_HOST));
 usb_packet_set_state(p, USB_PACKET_ASYNC);
 QTAILQ_INSERT_TAIL(p-ep-queue, p, queue);
 } else if (p-status == USB_RET_ADD_TO_QUEUE) {
diff --git a/hw/usb/host-bsd.c b/hw/usb/host-bsd.c
index 6473e8b..dae0009 100644
--- a/hw/usb/host-bsd.c
+++ b/hw/usb/host-bsd.c
@@ -292,6 +292,7 @@ static void usb_host_handle_destroy(USBDevice *opaque)
 
 static int usb_host_initfn(USBDevice *dev)
 {
+dev-flags |= (1  USB_DEV_FLAG_IS_HOST);
 return 0;
 }
 
diff --git a/hw/usb/host-linux.c b/hw/usb/host-linux.c
index aa77b77..bdafb6b 100644
--- a/hw/usb/host-linux.c
+++ b/hw/usb/host-linux.c
@@ -1476,6 +1476,7 @@ static int usb_host_initfn(USBDevice *dev)
 {
 USBHostDevice *s = DO_UPCAST(USBHostDevice, dev, dev);
 
+dev-flags |= (1  USB_DEV_FLAG_IS_HOST);
 dev-auto_attach = 0;
 s-fd = -1;
 s-hub_fd = -1;
-- 
1.7.1




[Qemu-devel] [PATCH 5/6] ehci: Lower timer freq when the periodic schedule is idle

2012-12-05 Thread Gerd Hoffmann
From: Hans de Goede hdego...@redhat.com

Lower the timer freq if no iso schedule packets complete for 64 frames in
a row.

We can safely do this, without adding latency, because:
1) If there is isoc traffic this will never trigger
2) For async handled interrupt packets (only usb-host), the completion handler
   will immediately schedule the frame_timer from a bh
3) All devices using NAK to signal no data for interrupt endpoints now use
   wakeup, which will immediately schedule the frame_timer from a bh

The advantage of this is that when we only have interrupt packets in the
periodic schedule, async_stepdown can do its work and significantly lower
the frequency at which the frame_timer runs.

Signed-off-by: Hans de Goede hdego...@redhat.com
Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 hw/usb/hcd-ehci.c |   39 +--
 hw/usb/hcd-ehci.h |1 +
 2 files changed, 34 insertions(+), 6 deletions(-)

diff --git a/hw/usb/hcd-ehci.c b/hw/usb/hcd-ehci.c
index 7df8e21..7536837 100644
--- a/hw/usb/hcd-ehci.c
+++ b/hw/usb/hcd-ehci.c
@@ -114,6 +114,7 @@
 #define BUFF_SIZE5*4096   // Max bytes to transfer per transaction
 #define MAX_QH   100  // Max allowable queue heads in a chain
 #define MIN_FR_PER_TICK  3// Min frames to process when catching up
+#define PERIODIC_ACTIVE  64
 
 /*  Internal periodic / asynchronous schedule state machine states
  */
@@ -738,6 +739,19 @@ static int ehci_register_companion(USBBus *bus, USBPort 
*ports[],
 return 0;
 }
 
+static void ehci_wakeup_endpoint(USBBus *bus, USBEndpoint *ep)
+{
+EHCIState *s = container_of(bus, EHCIState, bus);
+uint32_t portsc = s-portsc[ep-dev-port-index];
+
+if (portsc  PORTSC_POWNER) {
+return;
+}
+
+s-periodic_sched_active = PERIODIC_ACTIVE;
+qemu_bh_schedule(s-async_bh);
+}
+
 static USBDevice *ehci_find_device(EHCIState *ehci, uint8_t addr)
 {
 USBDevice *dev;
@@ -1188,9 +1202,10 @@ static void ehci_async_complete_packet(USBPort *port, 
USBPacket *packet)
 trace_usb_ehci_packet_action(p-queue, p, wakeup);
 p-async = EHCI_ASYNC_FINISHED;
 
-if (p-queue-async) {
-qemu_bh_schedule(p-queue-ehci-async_bh);
+if (!p-queue-async) {
+s-periodic_sched_active = PERIODIC_ACTIVE;
 }
+qemu_bh_schedule(s-async_bh);
 }
 
 static void ehci_execute_complete(EHCIQueue *q)
@@ -1344,6 +1359,8 @@ static int ehci_process_itd(EHCIState *ehci,
 uint32_t i, len, pid, dir, devaddr, endp;
 uint32_t pg, off, ptr1, ptr2, max, mult;
 
+ehci-periodic_sched_active = PERIODIC_ACTIVE;
+
 dir =(itd-bufptr[1]  ITD_BUFPTR_DIRECTION);
 devaddr = get_field(itd-bufptr[0], ITD_BUFPTR_DEVADDR);
 endp = get_field(itd-bufptr[0], ITD_BUFPTR_EP);
@@ -2033,6 +2050,9 @@ static void ehci_advance_state(EHCIState *ehci, int async)
 case EST_WRITEBACK:
 assert(q != NULL);
 again = ehci_state_writeback(q);
+if (!async) {
+ehci-periodic_sched_active = PERIODIC_ACTIVE;
+}
 break;
 
 default:
@@ -2198,7 +2218,6 @@ static void ehci_frame_timer(void *opaque)
 
 if (ehci_periodic_enabled(ehci) || ehci-pstate != EST_INACTIVE) {
 need_timer++;
-ehci-async_stepdown = 0;
 
 if (frames  ehci-maxframes) {
 skipped_frames = frames - ehci-maxframes;
@@ -,18 +2241,25 @@ static void ehci_frame_timer(void *opaque)
 break;
 }
 }
+if (ehci-periodic_sched_active) {
+ehci-periodic_sched_active--;
+}
 ehci_update_frindex(ehci, 1);
 ehci_advance_periodic_state(ehci);
 ehci-last_run_ns += FRAME_TIMER_NS;
 }
 } else {
-if (ehci-async_stepdown  ehci-maxframes / 2) {
-ehci-async_stepdown++;
-}
+ehci-periodic_sched_active = 0;
 ehci_update_frindex(ehci, frames);
 ehci-last_run_ns += FRAME_TIMER_NS * frames;
 }
 
+if (ehci-periodic_sched_active) {
+ehci-async_stepdown = 0;
+} else if (ehci-async_stepdown  ehci-maxframes / 2) {
+ehci-async_stepdown++;
+}
+
 /*  Async is not inside loop since it executes everything it can once
  *  called
  */
@@ -2301,6 +2327,7 @@ static USBPortOps ehci_port_ops = {
 
 static USBBusOps ehci_bus_ops = {
 .register_companion = ehci_register_companion,
+.wakeup_endpoint = ehci_wakeup_endpoint,
 };
 
 static int usb_ehci_post_load(void *opaque, int version_id)
diff --git a/hw/usb/hcd-ehci.h b/hw/usb/hcd-ehci.h
index d8078f4..772870b 100644
--- a/hw/usb/hcd-ehci.h
+++ b/hw/usb/hcd-ehci.h
@@ -311,6 +311,7 @@ struct EHCIState {
 
 uint64_t last_run_ns;
 uint32_t async_stepdown;
+uint32_t periodic_sched_active;
 bool int_req_by_async;
 };
 
-- 
1.7.1




[Qemu-devel] [PATCH 4/6] usb: Allow overriding of usb_desc at the device level

2012-12-05 Thread Gerd Hoffmann
From: Hans de Goede hdego...@redhat.com

This allows devices to present a different set of descriptors based on
device properties.

Signed-off-by: Hans de Goede hdego...@redhat.com
Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 hw/usb.h |1 +
 hw/usb/bus.c |3 +++
 2 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/hw/usb.h b/hw/usb.h
index 58f812f..268e653 100644
--- a/hw/usb.h
+++ b/hw/usb.h
@@ -230,6 +230,7 @@ struct USBDevice {
 USBEndpoint ep_out[USB_MAX_ENDPOINTS];
 
 QLIST_HEAD(, USBDescString) strings;
+const USBDesc *usb_desc; /* Overrides class usb_desc if not NULL */
 const USBDescDevice *device;
 
 int configuration;
diff --git a/hw/usb/bus.c b/hw/usb/bus.c
index 55d0edd..8264c24 100644
--- a/hw/usb/bus.c
+++ b/hw/usb/bus.c
@@ -166,6 +166,9 @@ const char *usb_device_get_product_desc(USBDevice *dev)
 const USBDesc *usb_device_get_usb_desc(USBDevice *dev)
 {
 USBDeviceClass *klass = USB_DEVICE_GET_CLASS(dev);
+if (dev-usb_desc) {
+return dev-usb_desc;
+}
 return klass-usb_desc;
 }
 
-- 
1.7.1




[Qemu-devel] [PATCH 6/6] usb-tablet: Allow connecting to ehci

2012-12-05 Thread Gerd Hoffmann
From: Hans de Goede hdego...@redhat.com

Our ehci code has is capable of significantly lowering the wakeup rate
for the hcd emulation while the device is idle. It is possible to add
similar code ot the uhci emulation, but that simply is not there atm,
and there is no reason why a (virtual) usb-tablet can not be a USB-2 device.

Making usb-hid devices connect to the emulated ehci controller instead
of the emulated uhci controller on vms which have both lowers the cpuload
for a fully idle vm from 20% to 2-3% (on my laptop).

An alternative implementation to using a property to select the tablet
type, would be simply making it a new device type, ie usb-tablet2, but the
downside of that is that this will require libvirt changes to be available
through libvirt at all, and then management tools changes to become the
default for new vms, where as using a property will automatically get
any pc-1.3 type vms the lower cpuload.

[ kraxel: adapt compat property for post-1.3 merge ]

Signed-off-by: Hans de Goede hdego...@redhat.com
Signed-off-by: Gerd Hoffmann kra...@redhat.com

tablet compat fixup

Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 hw/pc_piix.c |9 ++
 hw/usb/dev-hid.c |   85 +-
 2 files changed, 93 insertions(+), 1 deletions(-)

diff --git a/hw/pc_piix.c b/hw/pc_piix.c
index 040cd07..19e342a 100644
--- a/hw/pc_piix.c
+++ b/hw/pc_piix.c
@@ -290,17 +290,26 @@ static QEMUMachine pc_machine_v1_4 = {
 .is_default = 1,
 };
 
+#define PC_COMPAT_1_3 \
+{\
+.driver   = usb-tablet,\
+.property = usb_version,\
+.value= stringify(1),\
+}
+
 static QEMUMachine pc_machine_v1_3 = {
 .name = pc-1.3,
 .desc = Standard PC,
 .init = pc_init_pci_1_3,
 .max_cpus = 255,
 .compat_props = (GlobalProperty[]) {
+PC_COMPAT_1_3,
 { /* end of list */ }
 },
 };
 
 #define PC_COMPAT_1_2 \
+PC_COMPAT_1_3,\
 {\
 .driver   = nec-usb-xhci,\
 .property = msi,\
diff --git a/hw/usb/dev-hid.c b/hw/usb/dev-hid.c
index 55266b1..8749128 100644
--- a/hw/usb/dev-hid.c
+++ b/hw/usb/dev-hid.c
@@ -46,6 +46,7 @@ typedef struct USBHIDState {
 USBDevice dev;
 USBEndpoint *intr;
 HIDState hid;
+uint32_t usb_version;
 } USBHIDState;
 
 enum {
@@ -131,6 +132,36 @@ static const USBDescIface desc_iface_tablet = {
 },
 };
 
+static const USBDescIface desc_iface_tablet2 = {
+.bInterfaceNumber  = 0,
+.bNumEndpoints = 1,
+.bInterfaceClass   = USB_CLASS_HID,
+.bInterfaceProtocol= 0x02,
+.ndesc = 1,
+.descs = (USBDescOther[]) {
+{
+/* HID descriptor */
+.data = (uint8_t[]) {
+0x09,  /*  u8  bLength */
+USB_DT_HID,/*  u8  bDescriptorType */
+0x01, 0x00,/*  u16 HID_class */
+0x00,  /*  u8  country_code */
+0x01,  /*  u8  num_descriptors */
+USB_DT_REPORT, /*  u8  type: Report */
+74, 0, /*  u16 len */
+},
+},
+},
+.eps = (USBDescEndpoint[]) {
+{
+.bEndpointAddress  = USB_DIR_IN | 0x01,
+.bmAttributes  = USB_ENDPOINT_XFER_INT,
+.wMaxPacketSize= 8,
+.bInterval = 4, /* 2 ^ (4-1) * 125 usecs = 1 ms */
+},
+},
+};
+
 static const USBDescIface desc_iface_keyboard = {
 .bInterfaceNumber  = 0,
 .bNumEndpoints = 1,
@@ -196,6 +227,23 @@ static const USBDescDevice desc_device_tablet = {
 },
 };
 
+static const USBDescDevice desc_device_tablet2 = {
+.bcdUSB= 0x0200,
+.bMaxPacketSize0   = 64,
+.bNumConfigurations= 1,
+.confs = (USBDescConfig[]) {
+{
+.bNumInterfaces= 1,
+.bConfigurationValue   = 1,
+.iConfiguration= STR_CONFIG_TABLET,
+.bmAttributes  = 0xa0,
+.bMaxPower = 50,
+.nif = 1,
+.ifs = desc_iface_tablet2,
+},
+},
+};
+
 static const USBDescDevice desc_device_keyboard = {
 .bcdUSB= 0x0100,
 .bMaxPacketSize0   = 8,
@@ -239,6 +287,20 @@ static const USBDesc desc_tablet = {
 .str  = desc_strings,
 };
 
+static const USBDesc desc_tablet2 = {
+.id = {
+.idVendor  = 0x0627,
+.idProduct = 0x0001,
+.bcdDevice = 0,
+.iManufacturer = STR_MANUFACTURER,
+.iProduct  = STR_PRODUCT_TABLET,
+.iSerialNumber = STR_SERIALNUMBER,
+},
+.full = desc_device_tablet,
+.high = desc_device_tablet2,
+.str  = desc_strings,
+};
+
 static const USBDesc desc_keyboard = {
 .id = 

[Qemu-devel] [PATCH 1/6] add pc-1.4

2012-12-05 Thread Gerd Hoffmann
Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 hw/pc_piix.c |   15 +--
 1 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/hw/pc_piix.c b/hw/pc_piix.c
index aa3e7f4..040cd07 100644
--- a/hw/pc_piix.c
+++ b/hw/pc_piix.c
@@ -281,8 +281,8 @@ static void pc_xen_hvm_init(QEMUMachineInitArgs *args)
 }
 #endif
 
-static QEMUMachine pc_machine_v1_3 = {
-.name = pc-1.3,
+static QEMUMachine pc_machine_v1_4 = {
+.name = pc-1.4,
 .alias = pc,
 .desc = Standard PC,
 .init = pc_init_pci_1_3,
@@ -290,6 +290,16 @@ static QEMUMachine pc_machine_v1_3 = {
 .is_default = 1,
 };
 
+static QEMUMachine pc_machine_v1_3 = {
+.name = pc-1.3,
+.desc = Standard PC,
+.init = pc_init_pci_1_3,
+.max_cpus = 255,
+.compat_props = (GlobalProperty[]) {
+{ /* end of list */ }
+},
+};
+
 #define PC_COMPAT_1_2 \
 {\
 .driver   = nec-usb-xhci,\
@@ -626,6 +636,7 @@ static QEMUMachine xenfv_machine = {
 
 static void pc_machine_init(void)
 {
+qemu_register_machine(pc_machine_v1_4);
 qemu_register_machine(pc_machine_v1_3);
 qemu_register_machine(pc_machine_v1_2);
 qemu_register_machine(pc_machine_v1_1);
-- 
1.7.1




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

2012-12-05 Thread Gerd Hoffmann
  Hi,

Flushing the usb patch queue, there are a few bits sent during the
freeze I didn't feel like merging that close to the release, so
merge them now.  Series reduces the ehci emulation cpu overhead and
allows to connect the usb tablet to ehci.

please pull,
  Gerd

The following changes since commit 16c6c80ac3a772b42a87b77dfdf0fdac7c607b0e:

  Open up 1.4 development branch (2012-12-03 14:08:40 -0600)

are available in the git repository at:
  git://git.kraxel.org/qemu usb.74

Gerd Hoffmann (1):
  add pc-1.4

Hans de Goede (5):
  usb: Call wakeup when data becomes available for all devices with int eps
  usb: Don't allow USB_RET_ASYNC for interrupt packets
  usb: Allow overriding of usb_desc at the device level
  ehci: Lower timer freq when the periodic schedule is idle
  usb-tablet: Allow connecting to ehci

 hw/pc_piix.c |   24 +-
 hw/usb.h |2 +
 hw/usb/bus.c |3 ++
 hw/usb/core.c|4 ++
 hw/usb/dev-hid.c |   85 +-
 hw/usb/dev-hub.c |2 +
 hw/usb/dev-network.c |7 
 hw/usb/dev-wacom.c   |4 ++
 hw/usb/hcd-ehci.c|   39 +++---
 hw/usb/hcd-ehci.h|1 +
 hw/usb/host-bsd.c|1 +
 hw/usb/host-linux.c  |1 +
 hw/usb/redirect.c|4 ++
 13 files changed, 168 insertions(+), 9 deletions(-)



[Qemu-devel] [PATCH 2/6] usb: Call wakeup when data becomes available for all devices with int eps

2012-12-05 Thread Gerd Hoffmann
From: Hans de Goede hdego...@redhat.com

This is necessary for proper interaction with the xhci controller, and it
will allow other hcds to lower there frame timer while waiting for interrupt
data.

Signed-off-by: Hans de Goede hdego...@redhat.com
Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 hw/usb/dev-hub.c |2 ++
 hw/usb/dev-network.c |7 +++
 hw/usb/dev-wacom.c   |4 
 hw/usb/redirect.c|4 
 4 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/hw/usb/dev-hub.c b/hw/usb/dev-hub.c
index 9ee60dd..470fbbb 100644
--- a/hw/usb/dev-hub.c
+++ b/hw/usb/dev-hub.c
@@ -184,6 +184,7 @@ static void usb_hub_detach(USBPort *port1)
 port-wPortStatus = ~PORT_STAT_ENABLE;
 port-wPortChange |= PORT_STAT_C_ENABLE;
 }
+usb_wakeup(s-intr);
 }
 
 static void usb_hub_child_detach(USBPort *port1, USBDevice *child)
@@ -363,6 +364,7 @@ static void usb_hub_handle_control(USBDevice *dev, 
USBPacket *p,
 port-wPortChange |= PORT_STAT_C_RESET;
 /* set enable bit */
 port-wPortStatus |= PORT_STAT_ENABLE;
+usb_wakeup(s-intr);
 }
 break;
 case PORT_POWER:
diff --git a/hw/usb/dev-network.c b/hw/usb/dev-network.c
index 14d9e5a..30cb033 100644
--- a/hw/usb/dev-network.c
+++ b/hw/usb/dev-network.c
@@ -639,6 +639,8 @@ typedef struct USBNetState {
 unsigned int in_ptr, in_len;
 uint8_t in_buf[2048];
 
+USBEndpoint *intr;
+
 char usbstring_mac[13];
 NICState *nic;
 NICConf conf;
@@ -851,6 +853,10 @@ static void *rndis_queue_response(USBNetState *s, unsigned 
int length)
 struct rndis_response *r =
 g_malloc0(sizeof(struct rndis_response) + length);
 
+if (QTAILQ_EMPTY(s-rndis_resp)) {
+usb_wakeup(s-intr);
+}
+
 QTAILQ_INSERT_TAIL(s-rndis_resp, r, entries);
 r-length = length;
 
@@ -1349,6 +1355,7 @@ static int usb_net_initfn(USBDevice *dev)
 s-media_state = 0;/* NDIS_MEDIA_STATE_CONNECTED */;
 s-filter = 0;
 s-vendorid = 0x1234;
+s-intr = usb_ep_get(dev, USB_TOKEN_IN, 1);
 
 qemu_macaddr_default_if_unset(s-conf.macaddr);
 s-nic = qemu_new_nic(net_usbnet_info, s-conf,
diff --git a/hw/usb/dev-wacom.c b/hw/usb/dev-wacom.c
index 08b416d..f7342b0 100644
--- a/hw/usb/dev-wacom.c
+++ b/hw/usb/dev-wacom.c
@@ -43,6 +43,7 @@
 
 typedef struct USBWacomState {
 USBDevice dev;
+USBEndpoint *intr;
 QEMUPutMouseEntry *eh_entry;
 int dx, dy, dz, buttons_state;
 int x, y;
@@ -137,6 +138,7 @@ static void usb_mouse_event(void *opaque,
 s-dz += dz1;
 s-buttons_state = buttons_state;
 s-changed = 1;
+usb_wakeup(s-intr);
 }
 
 static void usb_wacom_event(void *opaque,
@@ -150,6 +152,7 @@ static void usb_wacom_event(void *opaque,
 s-dz += dz;
 s-buttons_state = buttons_state;
 s-changed = 1;
+usb_wakeup(s-intr);
 }
 
 static inline int int_clamp(int val, int vmin, int vmax)
@@ -337,6 +340,7 @@ static int usb_wacom_initfn(USBDevice *dev)
 USBWacomState *s = DO_UPCAST(USBWacomState, dev, dev);
 usb_desc_create_serial(dev);
 usb_desc_init(dev);
+s-intr = usb_ep_get(dev, USB_TOKEN_IN, 1);
 s-changed = 1;
 return 0;
 }
diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c
index 490c90f..9e7f645 100644
--- a/hw/usb/redirect.c
+++ b/hw/usb/redirect.c
@@ -1644,6 +1644,10 @@ static void usbredir_interrupt_packet(void *priv, 
uint64_t id,
 return;
 }
 
+if (QTAILQ_EMPTY(dev-endpoint[EP2I(ep)].bufpq)) {
+usb_wakeup(usb_ep_get(dev-dev, USB_TOKEN_IN, ep  0x0f));
+}
+
 /* bufp_alloc also adds the packet to the ep queue */
 bufp_alloc(dev, data, data_len, interrupt_packet-status, ep);
 } else {
-- 
1.7.1




Re: [Qemu-devel] [PULL for-1.3 0/3] seabios update

2012-12-05 Thread Brad Campbell

On 30/11/12 23:29, Gerd Hoffmann wrote:

   Hi,

This pull updates seabios to current master.   The seabios q35 patches
didn't land upstream yet so they miss the boat unfortunaly.  As this
update brings an important regression fix we can't wait for them and
risk to not update seabios for 1.3.  So here we go with the latest and
greatest seabios bits.



This update has broken my existing Windows XP Guests.
The machines bluescreen on boot with a 0x007E in ACPI.SYS.

Manually reverting to the previous bios.bin from commit 
01afdadc92e71e29700e64f3a5f42c1c543e3cf9
dated Aug-7 allows them to boot normally.

The VM's were created many moons ago using qemu-kvm which I upgraded to qemu 
vanilla yesterday.

I used to boot them with qemu -net nic,model=virtio -net tap,ifname=tap0,script= -drive 
file=/tracks/nobackup/xp_office.qcow2,cache=unsafe -m 512 -localtime

And now I just add the -enable-kvm to the existing command line.

Host is a core2duo running a 64 bit vanilla 3.7-rc6 kernel and a 32 bit debian 
userspace.

qemu is latest git  -  Updating 16c6c80..80625b9

Not a huge issue and certainly not urgent, but one I'd like to nail down before I go migrating my 
production boxes from qemu-kvm to qemu vanilla.


Regards,
Brad



[Qemu-devel] [PATCH] virtio: verify that all outstanding buffers are flushed (was Re: vmstate conversion for virtio?)

2012-12-05 Thread Michael S. Tsirkin
Add sanity check to address the following concern:

On Wed, Dec 05, 2012 at 09:47:22AM +1030, Rusty Russell wrote:
 All we need is the index of the request; the rest can be re-read from
 the ring.

I'd like to point out that this is not generally
true if any available requests are outstanding.
Imagine a ring of size 4.
Below A means available U means used.

A 1
A 2
U 2
A 2
U 2
A 2
U 2
A 2
U 2

At this point available ring has wrapped around, the only
way to know head 1 is outstanding is because backend
has stored this info somewhere.

The reason we manage to migrate without tracking this in migration
state is because we flush outstanding requests before
migration.
This flush is device-specific though, let's add
a safeguard in virtio core to ensure it's done properly.

Signed-off-by: Michael S. Tsirkin m...@redhat.com

---

diff --git a/hw/virtio.c b/hw/virtio.c
index f40a8c5..b80a5a9 100644
--- a/hw/virtio.c
+++ b/hw/virtio.c
@@ -788,6 +788,8 @@ void virtio_save(VirtIODevice *vdev, QEMUFile *f)
 if (vdev-vq[i].vring.num == 0)
 break;
 
+assert(!vq-inuse);
+
 qemu_put_be32(f, vdev-vq[i].vring.num);
 qemu_put_be64(f, vdev-vq[i].pa);
 qemu_put_be16s(f, vdev-vq[i].last_avail_idx);

-- 
MST



Re: [Qemu-devel] [PATCH 4/4] exec: refactor cpu_restore_state

2012-12-05 Thread Andreas Färber
Am 04.12.2012 22:20, schrieb Blue Swirl:
 Refactor common code around calls to cpu_restore_state().
 
 tb_find_pc() has now no external users, make it static.
 
 Signed-off-by: Blue Swirl blauwir...@gmail.com

Would've been nice to get CC'ed on the refactoring of a cpu_* function...

I've reviewed mostly the non-target parts and they look okay,
CPUArchState is unfortunately still needed.

Andreas

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg



Re: [Qemu-devel] [PATCH] target-i386: honor CR0_PG_MASK in cpu_get_phys_page_debug

2012-12-05 Thread Andreas Färber
Am 17.11.2012 21:52, schrieb Max Filippov:
 cpu_get_phys_page_debug is not in sync with cpu_x86_handle_mmu_fault:
 the latter first checks CR0_PG_MASK and only after CR4_PAE_MASK.
 
 This fixes odd gdb code display with PAE enabled.
 
 Signed-off-by: Max Filippov jcmvb...@gmail.com

You write, they are not in sync. Would it be possible to share code to
assure this, e.g., by calling a helper function from both?

Regards,
Andreas

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg



Re: [Qemu-devel] [PATCH v4 03/11] dataplane: add host memory mapping code

2012-12-05 Thread Michael S. Tsirkin
On Wed, Dec 05, 2012 at 09:31:56AM +0100, Stefan Hajnoczi wrote:
 On Thu, Nov 29, 2012 at 04:36:08PM +0200, Michael S. Tsirkin wrote:
  On Thu, Nov 29, 2012 at 03:26:56PM +0100, Stefan Hajnoczi wrote:
   On Thu, Nov 29, 2012 at 03:54:25PM +0200, Michael S. Tsirkin wrote:
On Thu, Nov 22, 2012 at 04:16:44PM +0100, Stefan Hajnoczi wrote:
 The data plane thread needs to map guest physical addresses to host
 pointers.  Normally this is done with cpu_physical_memory_map() but 
 the
 function assumes the global mutex is held.  The data plane thread does
 not touch the global mutex and therefore needs a thread-safe memory
 mapping mechanism.
 
 Hostmem registers a MemoryListener similar to how vhost collects and
 pushes memory region information into the kernel.  There is a
 fine-grained lock on the regions list which is held during lookup and
 when installing a new regions list.
 
 When the physical memory map changes the MemoryListener callbacks are
 invoked.  They build up a new list of memory regions which is finally
 installed when the list has been completed.
 
 Note that this approach is not safe across memory hotplug because 
 mapped
 pointers may still be in used across memory unplug.  However, this is
 currently a problem for QEMU in general and needs to be addressed in 
 the
 future.
 
 Signed-off-by: Stefan Hajnoczi stefa...@redhat.com

Worth bothering with binary search?
vhost does a linear search over regions because
the number of ram regions is very small.
   
   memory.c does binary search.  I did the same but in practice there are
   20 regions for a simple VM.  It's probably not worth it but without
   performance results this is speculation.
   
   I think there's no harm in using binary search to start with.
   
 +static void hostmem_listener_append_region(MemoryListener *listener,
 +   MemoryRegionSection 
 *section)
 +{
 +Hostmem *hostmem = container_of(listener, Hostmem, listener);
 +
 +if (memory_region_is_ram(section-mr)) {
 +hostmem_append_new_region(hostmem, section);
 +}

I think you also need to remove VGA region since you
don't mark these pages as dirty so access there won't work.
   
   I don't understand.  If memory in the VGA region returns true from
   memory_region_is_ram(), why would there be a problem?
  
  If you change this memory but you don't update the display.
  Never happens with non buggy guests but we should catch and fail if it does.
 
 Okay, I took a look at the VGA code and I think it makes sense now.  We
 have VRAM as a regular RAM region so that writes to it are cheap.  To
 avoid scanning or redrawing VRAM on every update we use dirty logging.
 
 Since virtio-blk-data-plane does not mark pages dirty an I/O buffer in
 VRAM would fail to update the display correctly.
 
 I will try to put in a check to omit the VGA region.

There are many ways to do this but I guess the simplest
is to detect dirty logging and skip that region.

  It can be dropped
 in the future when we use the memory API with dirty logging from the
 data plane thread.
 
 Stefan

Or not - there's also the issue that e.g. cirrus doing tricks
with memory mapping at data path. So skipping
that region might help performance.

-- 
MST



Re: [Qemu-devel] [PATCH 3/6] target-i386: use define for cpuid vendor string size

2012-12-05 Thread Andreas Färber
Am 04.12.2012 20:38, schrieb Eduardo Habkost:
 On Tue, Dec 04, 2012 at 05:34:40PM -0200, Eduardo Habkost wrote:
 From: Igor Mammedov imamm...@redhat.com

 Signed-off-by: Igor Mammedov imamm...@redhat.com
 
 Reviewed-by: Eduardo Habkost ehabk...@redhat.com

As a reminder, when you submit patches, I need your Sob added.
In these particular cases, I can usually search the list for an earlier
submission by Igor and take that, but it would be more time-efficient if
I could just apply the latest submitted version with Sobs.

If you cherry-pick patches from your colleague's branch, you can use
git-cherry-pick's -s option to facilitate this.

Regards,
Andreas

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg



[Qemu-devel] [Bug 955379] Re: cmake hangs with qemu-arm-static

2012-12-05 Thread Janne Karhunen
Some kind of semi-workaround patch attached. It seems to leave this kind
of race window for me (for select which is worse):

   0x6004bf98 +136:   xor%r8d,%r8d
   0x6004bf9b +139:   test   %eax,%eax
   0x6004bf9d +141:   jne0x6004c2b7 do_select+935
   0x6004bfa3 +147:   mov0x20(%rsp),%r14
   0x6004bfa8 +152:   mov0x246d8(%r14),%esi
   0x6004bfaf +159:   test   %esi,%esi
   0x6004bfb1 +161:   je 0x6004bfb8 do_select+168
   0x6004bfb3 +163:   lea0x40(%rsp),%r8
   0x6004bfb8 +168:   mov0x28(%rsp),%rdx
   0x6004bfbd +173:   mov%r11,%rsi
   0x6004bfc0 +176:   mov%ebx,%edi
   0x6004bfc2 +178:   callq  0x6012df90 select

I think it could still be narrowed some, but this makes it unlikely
enough for me for time being...

** Patch added: racy workaround patch
   
https://bugs.launchpad.net/qemu/+bug/955379/+attachment/3452139/+files/cmake.patch

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

Title:
  cmake hangs with qemu-arm-static

Status in QEMU:
  Confirmed
Status in Linaro QEMU:
  Confirmed
Status in “qemu-linaro” package in Ubuntu:
  Confirmed

Bug description:
  I'm using git commit 3e7ecd976b06f... configured with --target-list
  =arm-linux-user --static in a chroot environment to compile some
  things. I ran into this problem with both pcl and opencv-2.3.1. cmake
  consistently freezes at some point during its execution, though in a
  different spot each time, usually during a step when it's searching
  for some libraries. For instance, pcl most commonly stops after:

  [snip]
  -- Boost version: 1.46.1
  -- Found the following Boost libraries:
  --   system
  --   filesystem
  --   thread
  --   date_time
  -- checking for module 'eigen3'
  --   found eigen3, version 3.0.1

  which is perplexing because it freezes after finding what it wants,
  not during the search. When it does get past that point, it does so
  almost immediately but freezes somewhere else.

  I'm using 64-bit Ubuntu 11.10 with kernel release 3.0.0-16-generic
  with an Intel i5.

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



Re: [Qemu-devel] [PATCH v6 2/2] qemu-ga: sample fsfreeze hooks

2012-12-05 Thread Luiz Capitulino
On Wed, 05 Dec 2012 17:41:08 +0900
Tomoki Sekiyama tomoki.sekiyama...@hitachi.com wrote:

 On 2012/12/05 1:51, Luiz Capitulino wrote:
  On Fri, 30 Nov 2012 22:33:57 +0900
  Tomoki Sekiyama tomoki.sekiyama...@hitachi.com wrote:
  
  Adds sample hook scripts for --fsfreeze-hook option of qemu-ga.
- fsfreeze-hook : execute scripts in fsfreeze-hook.d/
- fsfreeze-hook.d.sample/mysql-flush.sh : quiesce MySQL before snapshot
 
  Signed-off-by: Tomoki Sekiyama tomoki.sekiyama...@hitachi.com
  ---
   docs/qemu-guest-agent/fsfreeze-hook|   33 
   .../fsfreeze-hook.d.sample/mysql-flush.sh  |   55 
  
   2 files changed, 88 insertions(+)
   create mode 100755 docs/qemu-guest-agent/fsfreeze-hook
   create mode 100755 
  docs/qemu-guest-agent/fsfreeze-hook.d.sample/mysql-flush.sh
 
  diff --git a/docs/qemu-guest-agent/fsfreeze-hook 
  b/docs/qemu-guest-agent/fsfreeze-hook
  new file mode 100755
  index 000..ed7d86d
  --- /dev/null
  +++ b/docs/qemu-guest-agent/fsfreeze-hook
  @@ -0,0 +1,33 @@
  +#!/bin/sh
  +
  +# This script is executed when a guest agent receives fsfreeze-freeze and
  +# fsfreeze-thaw command, if it is specified in --fsfreeze-hook (-F)
  +# option of qemu-ga or placed in default path (/etc/qemu/fsfreeze-hook).
  +# When the agent receives fsfreeze-freeze request, this script is issued 
  with
  +# freeze argument before the filesystem is freezed. And for 
  fsfreeze-thaw
  +# request, it is issued with thaw argument after filesystem is thawed.
  +
  +LOGFILE=/var/log/qga-fsfreeze-hook.log
  +FSFREEZE_D=$(dirname -- $0)/fsfreeze-hook.d
  
  The script you introduce is called fsfreeze-hook.d.sample. If it's expected
  that people really use these two scripts (vs. doc purposes only) I suggest
  the following:
  
   1. Move these files to scripts/
   2. Drop the .sample suffix
 
 It is good for fsfreeze-hook. But as for mysql-flush.sh, users may
 need to configure authentication etc. if their environments are with
 non-default setup (by edditing either the script or ~/.my.cnf file).
 
 So, I'd like to (1)move these files to scripts/, but (2)reamin .sample
 suffix to indicate that users may need to modify the script.
 How do you think?

You could add the '.sample' suffix to the mysql script and add that
suffix to is_ignored_file().



Re: [Qemu-devel] [PATCH] target-i386: honor CR0_PG_MASK in cpu_get_phys_page_debug

2012-12-05 Thread Max Filippov
On Wed, Dec 5, 2012 at 3:15 PM, Andreas Färber afaer...@suse.de wrote:
 Am 17.11.2012 21:52, schrieb Max Filippov:
 cpu_get_phys_page_debug is not in sync with cpu_x86_handle_mmu_fault:
 the latter first checks CR0_PG_MASK and only after CR4_PAE_MASK.

 This fixes odd gdb code display with PAE enabled.

 Signed-off-by: Max Filippov jcmvb...@gmail.com

 You write, they are not in sync. Would it be possible to share code to
 assure this, e.g., by calling a helper function from both?

I'd say yes though that'd be a bigger change. I'll try to do it.

-- 
Thanks.
-- Max



Re: [Qemu-devel] [PATCH 3/6] target-i386: use define for cpuid vendor string size

2012-12-05 Thread Eduardo Habkost
On Wed, Dec 05, 2012 at 12:29:06PM +0100, Andreas Färber wrote:
 Am 04.12.2012 20:38, schrieb Eduardo Habkost:
  On Tue, Dec 04, 2012 at 05:34:40PM -0200, Eduardo Habkost wrote:
  From: Igor Mammedov imamm...@redhat.com
 
  Signed-off-by: Igor Mammedov imamm...@redhat.com
  
  Reviewed-by: Eduardo Habkost ehabk...@redhat.com
 
 As a reminder, when you submit patches, I need your Sob added.
 In these particular cases, I can usually search the list for an earlier
 submission by Igor and take that, but it would be more time-efficient if
 I could just apply the latest submitted version with Sobs.
 
 If you cherry-pick patches from your colleague's branch, you can use
 git-cherry-pick's -s option to facilitate this.

Sorry, I'll do that next time.

BTW, I cherry-picked the patches from igor's tree directly (after
discussing with him), so I don't know if all of them have been submitted
to the list before.

For reference, they are:
https://github.com/imammedo/qemu/commit/b515a509d6e175681bbd85d2833400b1d5368877
https://github.com/imammedo/qemu/commit/4c9d836d4e6589493c82c21dd9b48ddc244c0a3d
https://github.com/imammedo/qemu/commit/cf301a2013c99e22cab55f9e840c3885b6130c38
https://github.com/imammedo/qemu/commit/dc70027e0bd190832527b68579704384fd8b950b

 
 Regards,
 Andreas
 
 -- 
 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
 GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg

-- 
Eduardo



Re: [Qemu-devel] [PATCH 3/6] target-i386: use define for cpuid vendor string size

2012-12-05 Thread Igor Mammedov
On Wed, 5 Dec 2012 09:51:25 -0200
Eduardo Habkost ehabk...@redhat.com wrote:

 On Wed, Dec 05, 2012 at 12:29:06PM +0100, Andreas Färber wrote:
  Am 04.12.2012 20:38, schrieb Eduardo Habkost:
   On Tue, Dec 04, 2012 at 05:34:40PM -0200, Eduardo Habkost wrote:
   From: Igor Mammedov imamm...@redhat.com
  
   Signed-off-by: Igor Mammedov imamm...@redhat.com
   
   Reviewed-by: Eduardo Habkost ehabk...@redhat.com
  
  As a reminder, when you submit patches, I need your Sob added.
  In these particular cases, I can usually search the list for an earlier
  submission by Igor and take that, but it would be more time-efficient if
  I could just apply the latest submitted version with Sobs.
  
  If you cherry-pick patches from your colleague's branch, you can use
  git-cherry-pick's -s option to facilitate this.
 
 Sorry, I'll do that next time.
 
 BTW, I cherry-picked the patches from igor's tree directly (after
 discussing with him), so I don't know if all of them have been submitted
 to the list before.
They were submitted in v5 cpu properties series.
Message-Id: 1350918203-25198-7-git-send-email-imamm...@redhat.com
Message-Id: 1350918203-25198-8-git-send-email-imamm...@redhat.com
Message-Id: 1350918203-25198-25-git-send-email-imamm...@redhat.com
Message-Id: 1350918203-25198-15-git-send-email-imamm...@redhat.com

 
 For reference, they are:
 https://github.com/imammedo/qemu/commit/b515a509d6e175681bbd85d2833400b1d5368877
 https://github.com/imammedo/qemu/commit/4c9d836d4e6589493c82c21dd9b48ddc244c0a3d
 https://github.com/imammedo/qemu/commit/cf301a2013c99e22cab55f9e840c3885b6130c38
 https://github.com/imammedo/qemu/commit/dc70027e0bd190832527b68579704384fd8b950b
 
  
  Regards,
  Andreas
  
  -- 
  SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
  GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
 




[Qemu-devel] [Bug 955379] Re: cmake hangs with qemu-arm-static

2012-12-05 Thread Ubuntu Foundations Team Bug Bot
The attachment racy workaround patch of this bug report has been
identified as being a patch.  The ubuntu-reviewers team has been
subscribed to the bug report so that they can review the patch.  In the
event that this is in fact not a patch you can resolve this situation by
removing the tag 'patch' from the bug report and editing the attachment
so that it is not flagged as a patch.  Additionally, if you are member
of the ubuntu-reviewers team please also unsubscribe the team from this
bug report.

[This is an automated message performed by a Launchpad user owned by
Brian Murray.  Please contact him regarding any issues with the action
taken in this bug report.]

** Tags added: patch

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

Title:
  cmake hangs with qemu-arm-static

Status in QEMU:
  Confirmed
Status in Linaro QEMU:
  Confirmed
Status in “qemu-linaro” package in Ubuntu:
  Confirmed

Bug description:
  I'm using git commit 3e7ecd976b06f... configured with --target-list
  =arm-linux-user --static in a chroot environment to compile some
  things. I ran into this problem with both pcl and opencv-2.3.1. cmake
  consistently freezes at some point during its execution, though in a
  different spot each time, usually during a step when it's searching
  for some libraries. For instance, pcl most commonly stops after:

  [snip]
  -- Boost version: 1.46.1
  -- Found the following Boost libraries:
  --   system
  --   filesystem
  --   thread
  --   date_time
  -- checking for module 'eigen3'
  --   found eigen3, version 3.0.1

  which is perplexing because it freezes after finding what it wants,
  not during the search. When it does get past that point, it does so
  almost immediately but freezes somewhere else.

  I'm using 64-bit Ubuntu 11.10 with kernel release 3.0.0-16-generic
  with an Intel i5.

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



[Qemu-devel] [PATCH 1/1] tmp105: Create API for TMP105 temperature sensor.

2012-12-05 Thread Alex Horn
* Define enum for TMP105 registers
* Move tmp105_set() from I2C to TMP105 header
* Document units and range of temperature as preconditions

Signed-off-by: Alex Horn alex.h...@cs.ox.ac.uk
---
 hw/i2c.h|3 --
 hw/tmp105.c |   17 ---
 hw/tmp105.h |   67 +++
 3 files changed, 76 insertions(+), 11 deletions(-)
 create mode 100644 hw/tmp105.h

diff --git a/hw/i2c.h b/hw/i2c.h
index 0f5682b..883b5c5 100644
--- a/hw/i2c.h
+++ b/hw/i2c.h
@@ -73,9 +73,6 @@ void *wm8750_dac_buffer(void *opaque, int samples);
 void wm8750_dac_commit(void *opaque);
 void wm8750_set_bclk_in(void *opaque, int new_hz);
 
-/* tmp105.c */
-void tmp105_set(I2CSlave *i2c, int temp);
-
 /* lm832x.c */
 void lm832x_key_event(DeviceState *dev, int key, int state);
 
diff --git a/hw/tmp105.c b/hw/tmp105.c
index 8e8dbd9..9c67e64 100644
--- a/hw/tmp105.c
+++ b/hw/tmp105.c
@@ -20,6 +20,7 @@
 
 #include hw.h
 #include i2c.h
+#include tmp105.h
 
 typedef struct {
 I2CSlave i2c;
@@ -92,22 +93,22 @@ static void tmp105_read(TMP105State *s)
 }
 
 switch (s-pointer  3) {
-case 0:/* Temperature */
+case TMP105_REG_TEMPERATURE:
 s-buf[s-len ++] = (((uint16_t) s-temperature)  8);
 s-buf[s-len ++] = (((uint16_t) s-temperature)  0) 
 (0xf0  ((~s-config  5)  3)); /* R */
 break;
 
-case 1:/* Configuration */
+case TMP105_REG_CONFIG:
 s-buf[s-len ++] = s-config;
 break;
 
-case 2:/* T_LOW */
+case TMP105_REG_T_LOW:
 s-buf[s-len ++] = ((uint16_t) s-limit[0])  8;
 s-buf[s-len ++] = ((uint16_t) s-limit[0])  0;
 break;
 
-case 3:/* T_HIGH */
+case TMP105_REG_T_HIGH:
 s-buf[s-len ++] = ((uint16_t) s-limit[1])  8;
 s-buf[s-len ++] = ((uint16_t) s-limit[1])  0;
 break;
@@ -117,10 +118,10 @@ static void tmp105_read(TMP105State *s)
 static void tmp105_write(TMP105State *s)
 {
 switch (s-pointer  3) {
-case 0:/* Temperature */
+case TMP105_REG_TEMPERATURE:
 break;
 
-case 1:/* Configuration */
+case TMP105_REG_CONFIG:
 if (s-buf[0]  ~s-config  (1  0)) /* SD */
 printf(%s: TMP105 shutdown\n, __FUNCTION__);
 s-config = s-buf[0];
@@ -128,8 +129,8 @@ static void tmp105_write(TMP105State *s)
 tmp105_alarm_update(s);
 break;
 
-case 2:/* T_LOW */
-case 3:/* T_HIGH */
+case TMP105_REG_T_LOW:
+case TMP105_REG_T_HIGH:
 if (s-len = 3)
 s-limit[s-pointer  1] = (int16_t)
 uint16_t) s-buf[0])  8) | s-buf[1]);
diff --git a/hw/tmp105.h b/hw/tmp105.h
new file mode 100644
index 000..51eff4b
--- /dev/null
+++ b/hw/tmp105.h
@@ -0,0 +1,67 @@
+/*
+ * Texas Instruments TMP105 Temperature Sensor
+ *
+ * Browse the data sheet:
+ *
+ *http://www.ti.com/lit/gpn/tmp105
+ *
+ * Copyright (C) 2012 Alex Horn alex.h...@cs.ox.ac.uk
+ * Copyright (C) 2008-2012 Andrzej Zaborowski balr...@gmail.com
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or
+ * later. See the COPYING file in the top-level directory.
+ */
+#ifndef QEMU_TMP105_H
+#define QEMU_TMP105_H
+
+#include i2c.h
+
+/**
+ * TMP105Reg:
+ * @TMP105_REG_TEMPERATURE: Temperature register
+ * @TMP105_REG_CONFIG: Configuration register
+ * @TMP105_REG_T_LOW: Low temperature register (also known as T_hyst)
+ * @TMP105_REG_T_HIGH: High temperature register (also known as T_OS)
+ *
+ * The following temperature sensors are
+ * compatible with the TMP105 registers:
+ * - adt75
+ * - ds1775
+ * - ds75
+ * - lm75
+ * - lm75a
+ * - max6625
+ * - max6626
+ * - mcp980x
+ * - stds75
+ * - tcn75
+ * - tmp100
+ * - tmp101
+ * - tmp105
+ * - tmp175
+ * - tmp275
+ * - tmp75
+ **/
+typedef enum TMP105Reg {
+TMP105_REG_TEMPERATURE = 0,
+TMP105_REG_CONFIG,
+TMP105_REG_T_LOW,
+TMP105_REG_T_HIGH,
+} TMP105Reg;
+
+/**
+ * tmp105_set:
+ * @i2c: dispatcher to TMP105 hardware model
+ * @temp: temperature with 0.001 centigrades units in the range -40 C to +125 C
+ *
+ * Sets the temperature of the TMP105 hardware model.
+ *
+ * Bits 5 and 6 (value 32 and 64) in the register indexed by TMP105_REG_CONFIG
+ * determine the precision of the temperature. See Table 8 in the data sheet.
+ *
+ * @see_also: I2C_SLAVE macro
+ * @see_also: http://www.ti.com/lit/gpn/tmp105
+ */
+void tmp105_set(I2CSlave *i2c, int temp);
+
+#endif
-- 
1.7.6.5




Re: [Qemu-devel] [PATCH] virtfs-proxy-helper: check return code of setfsgid/setfsuid

2012-12-05 Thread Paolo Bonzini
Il 05/12/2012 09:35, Aneesh Kumar K.V ha scritto:
 I have tested the below patch. Currently i don't have a signed-off-by on
 the patch. One change noted by mohan which I incorporated in the patch
 is we need to call setresgid before calling setresuid. If you are ok
 with this change I can send it upstream.

Yes, please.

Either your version without pointers or mine is okay for me.

Paolo



Re: [Qemu-devel] [PATCH 1/1] tmp105: Create API for TMP105 temperature sensor.

2012-12-05 Thread Andreas Färber
Am 05.12.2012 13:34, schrieb Alex Horn:
 * Define enum for TMP105 registers
 * Move tmp105_set() from I2C to TMP105 header
 * Document units and range of temperature as preconditions
 
 Signed-off-by: Alex Horn alex.h...@cs.ox.ac.uk

Looks great, thanks!

Reviewed-by: Andreas Färber afaer...@suse.de

Cheers,
Andreas

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg



Re: [Qemu-devel] [PULL for-1.3 0/3] seabios update

2012-12-05 Thread Gerd Hoffmann
On 12/05/12 11:49, Brad Campbell wrote:
 On 30/11/12 23:29, Gerd Hoffmann wrote:
Hi,

 This pull updates seabios to current master.   The seabios q35 patches
 didn't land upstream yet so they miss the boat unfortunaly.  As this
 update brings an important regression fix we can't wait for them and
 risk to not update seabios for 1.3.  So here we go with the latest and
 greatest seabios bits.

 
 This update has broken my existing Windows XP Guests.
 The machines bluescreen on boot with a 0x007E in ACPI.SYS.

Try passing -no-hpet and see if this helps.

cheers,
  Gerd




Re: [Qemu-devel] [PATCH v4 04/11] dataplane: add virtqueue vring code

2012-12-05 Thread Stefan Hajnoczi
On Thu, Nov 29, 2012 at 02:50:01PM +0200, Michael S. Tsirkin wrote:
 On Thu, Nov 22, 2012 at 04:16:45PM +0100, Stefan Hajnoczi wrote:
  The virtio-blk-data-plane cannot access memory using the usual QEMU
  functions since it executes outside the global mutex and the memory APIs
  are this time are not thread-safe.
  
  This patch introduces a virtqueue module based on the kernel's vhost
  vring code.  The trick is that we map guest memory ahead of time and
  access it cheaply outside the global mutex.
  
  Once the hardware emulation code can execute outside the global mutex it
  will be possible to drop this code.
  
  Signed-off-by: Stefan Hajnoczi stefa...@redhat.com
 
 Is there no way to factor out ommon code and share it with virtio.c?

I think we have touched on this in other sub-threads but for reference:
this code implements vring access outside the global mutex, which means
no QEMU memory API functions.  Therefore it's hard to share the virtio.c
code which uses QEMU memory API functions.

The current work that Ping Fan Liu is doing will lead to thread-safe
memory accesses from device emulation code.  At that point we can ditch
this and unify with virtio.c.

  +/* This is stolen from linux-2.6/drivers/vhost/vhost.c. */
 
 Probably should document the version you based this on.
 Surely not really 2.6?

linux-2.6.git is still mirrored from linux.git :).  I'll try to dig up
the specific Linux version that this code is based on.

  +static int get_indirect(Vring *vring,
  +struct iovec iov[], struct iovec *iov_end,
  +unsigned int *out_num, unsigned int *in_num,
  +struct vring_desc *indirect)
  +{
  +struct vring_desc desc;
  +unsigned int i = 0, count, found = 0;
  +
  +/* Sanity check */
  +if (unlikely(indirect-len % sizeof desc)) {
  +error_report(Invalid length in indirect descriptor: 
  + len %#x not multiple of %#zx,
  + indirect-len, sizeof desc);
  +vring-broken = true;
  +return -EFAULT;
  +}
  +
  +count = indirect-len / sizeof desc;
  +/* Buffers are chained via a 16 bit next field, so
  + * we can have at most 2^16 of these. */
  +if (unlikely(count  USHRT_MAX + 1)) {
  +error_report(Indirect buffer length too big: %d, indirect-len);
  +vring-broken = true;
  +return -EFAULT;
  +}
  +
  +/* Point to translate indirect desc chain */
  +indirect = hostmem_lookup(vring-hostmem, indirect-addr, 
  indirect-len,
  +  false);
 
 This assumes an indirect buffer is contigious in qemu memory
 which seems wrong since unlike vring itself
 there are no alignment requirements.

Let's break this up into one hostmem_lookup() per descriptor.  In other
words, don't try to lookup the entire indirect buffer but copy-in one
descriptor at a time.

 Overriding indirect here also seems unnecessarily tricky.

You are right, let's use a separate local variable to make the code
clearer.

  +int vring_pop(VirtIODevice *vdev, Vring *vring,
  +  struct iovec iov[], struct iovec *iov_end,
  +  unsigned int *out_num, unsigned int *in_num)
  +{
  +struct vring_desc desc;
  +unsigned int i, head, found = 0, num = vring-vr.num;
  +uint16_t avail_idx, last_avail_idx;
  +
  +/* If there was a fatal error then refuse operation */
  +if (vring-broken) {
  +return -EFAULT;
  +}
  +
  +/* Check it isn't doing very strange things with descriptor numbers. */
  +last_avail_idx = vring-last_avail_idx;
  +avail_idx = vring-vr.avail-idx;
 
 I think something needs to be done here to force
 a read otherwise two accesses to avail_idx
 below can cause two reads from the ring and
 could return inconsistent results.

There is no function call or anything in between that forces the
compiler to load the value of avail_idx and reuse it.

So I think you're right.  I'm not 100% sure a read barrier forces the
compiler to load here since the following code just manipulates
last_avail_idx and avail_idx.

Any ideas?

  +if (vdev-guest_features  (1  VIRTIO_RING_F_EVENT_IDX)) {
  +vring_avail_event(vring-vr) = vring-vr.avail-idx;
 
 No barrier here?
 I also don't see similar code in vhost - why is it a good idea?

This is from hw/virtio.c:virtqueue_pop().  We know there is at least one
request available, we're hinting to the guest to not to bother
notifying any requests up to the latest.

However, setting avail_event to the current vring avail_idx only helps
if we get lucky and process the vring *before* the guest decides to
notify a whole bunch of requests it has just enqueued.

So this doesn't seem incorrect but the performance benefit is
questionable.

Do you remember why you wrote this code?  The commit is:

commit bcbabae8ff7f7ec114da9fe2aa7f25f420f35306
Author: Michael S. Tsirkin m...@redhat.com
Date:   Sun Jun 12 16:21:57 2011 +0300

[Qemu-devel] [PATCH v2 0/2] Add TPCI200 and IP-Octal 232 IndustryPack emulation

2012-12-05 Thread Alberto Garcia

Hello again,

I'm sending the new version of my TPCI200 and IP-Octal 232 patches,
here's the original submission for reference:

https://lists.gnu.org/archive/html/qemu-devel/2012-08/msg04173.html

It's been a while since I posted the previous patches. I was on
holidays for quite some time, plus the trip to the KVM Forum where I
could have the chance to meet some of you in person :)

Then came the v1.3 code freeze, so I was making a few changes to both
devices since then. These are the changes from the previous version:

   * Rebased against the current master.  ipoctal renamed to
   * ipoctal232.  Big-endian mode can now be disabled (tpci200).
   * Implemented the RxFIFO (ipoctal232).  Simplified the Tx code
   * (ipoctal232).  Removed the timer (ipoctal232).  Rewrote the IRQ
   * code (both devices).  A few minor bugfixes.  Coding style fixes.

The Linux driver is available in the latest mainline kernel (tested
with v3.7-rc6).

I also devoted quite some time to testing the code (and fixing a few
bugs in the kernel driver along the way). The device has 8 serial
ports, I tried them with minicom, pppd, etc and everything seems to
work fine.

I also tried attaching 4 instances of ipoctal232 to the tpci200 bridge
-32 serial ports in total- and using all of them at the same time and
there was nothing unexpected.

As a last thing, I also tried to reorganize the memory addressing
using Avi's suggestions but I couldn't come up with a solution to the
problems that I described back then. Here's the original thread for
reference:

https://lists.gnu.org/archive/html/qemu-devel/2012-10/msg01117.html

I think that's all, if there's any questions please let me know.

Thanks,

Alberto Garcia (2):
  Add TEWS TPCI200 IndustryPack emulation
  Add GE IP-Octal 232 IndustryPack emulation

 default-configs/pci.mak |1 +
 hw/Makefile.objs|3 +
 hw/ipack.c  |  106 
 hw/ipack.h  |   75 ++
 hw/ipoctal.c|  613 +++
 hw/pci_ids.h|3 +
 hw/tpci200.c|  667 +++
 7 ficheiros modificados, 1468 adições(+)
 create mode 100644 hw/ipack.c
 create mode 100644 hw/ipack.h
 create mode 100644 hw/ipoctal.c
 create mode 100644 hw/tpci200.c

-- 
1.7.10.4



[Qemu-devel] [PATCH v2 2/2] Add GE IP-Octal 232 IndustryPack emulation

2012-12-05 Thread Alberto Garcia

The GE IP-Octal 232 is an IndustryPack module that implements eight
RS-232 serial ports, each one of which can be redirected to a
character device in the host.

Signed-off-by: Alberto Garcia agar...@igalia.com
---
 hw/Makefile.objs |2 +-
 hw/ipoctal.c |  613 ++
 2 ficheiros modificados, 614 adições(+), 1 eliminado(-)
 create mode 100644 hw/ipoctal.c

diff --git a/hw/Makefile.objs b/hw/Makefile.objs
index 2ce5ec0..b43a67e 100644
--- a/hw/Makefile.objs
+++ b/hw/Makefile.objs
@@ -105,7 +105,7 @@ common-obj-$(CONFIG_PCI) += wdt_i6300esb.o
 common-obj-$(CONFIG_PCI) += pcie.o pcie_aer.o pcie_port.o
 
 # IndustryPack
-common-obj-$(CONFIG_IPACK) += tpci200.o ipack.o
+common-obj-$(CONFIG_IPACK) += tpci200.o ipoctal.o ipack.o
 
 # PCI network cards
 common-obj-$(CONFIG_NE2000_PCI) += ne2000.o
diff --git a/hw/ipoctal.c b/hw/ipoctal.c
new file mode 100644
index 000..8cb34f9
--- /dev/null
+++ b/hw/ipoctal.c
@@ -0,0 +1,613 @@
+/*
+ * QEMU GE IP-Octal 232 IndustryPack emulation
+ *
+ * Copyright (C) 2012 Igalia, S.L.
+ * Author: Alberto Garcia agar...@igalia.com
+ *
+ * This code is licensed under the GNU GPL v2 or (at your option) any
+ * later version.
+ */
+
+#include ipack.h
+#include bitops.h
+
+/* #define DEBUG_IPOCTAL */
+
+#ifdef DEBUG_IPOCTAL
+#define DPRINTF2(fmt, ...) \
+do { fprintf(stderr, fmt, ## __VA_ARGS__); } while (0)
+#else
+#define DPRINTF2(fmt, ...) do { } while (0)
+#endif
+
+#define DPRINTF(fmt, ...) DPRINTF2(IP-Octal:  fmt, ## __VA_ARGS__)
+
+#define RX_FIFO_SIZE 3
+
+/* The IP-Octal has 8 channels (a-h)
+   divided into 4 blocks (A-D) */
+#define N_CHANNELS 8
+#define N_BLOCKS   4
+
+#define REG_MRa  0x01
+#define REG_MRb  0x11
+#define REG_SRa  0x03
+#define REG_SRb  0x13
+#define REG_CSRa 0x03
+#define REG_CSRb 0x13
+#define REG_CRa  0x05
+#define REG_CRb  0x15
+#define REG_RHRa 0x07
+#define REG_RHRb 0x17
+#define REG_THRa 0x07
+#define REG_THRb 0x17
+#define REG_ACR  0x09
+#define REG_ISR  0x0B
+#define REG_IMR  0x0B
+#define REG_OPCR 0x1B
+
+#define CR_ENABLE_RXBIT(0)
+#define CR_DISABLE_RX   BIT(1)
+#define CR_ENABLE_TXBIT(2)
+#define CR_DISABLE_TX   BIT(3)
+#define CR_CMD(cr)  ((cr)  4)
+#define CR_NO_OP0
+#define CR_RESET_MR 1
+#define CR_RESET_RX 2
+#define CR_RESET_TX 3
+#define CR_RESET_ERR4
+#define CR_RESET_BRKINT 5
+#define CR_START_BRK6
+#define CR_STOP_BRK 7
+#define CR_ASSERT_RTSN  8
+#define CR_NEGATE_RTSN  9
+#define CR_TIMEOUT_ON   10
+#define CR_TIMEOUT_OFF  12
+
+#define SR_RXRDY   BIT(0)
+#define SR_FFULL   BIT(1)
+#define SR_TXRDY   BIT(2)
+#define SR_TXEMT   BIT(3)
+#define SR_OVERRUN BIT(4)
+#define SR_PARITY  BIT(5)
+#define SR_FRAMING BIT(6)
+#define SR_BREAK   BIT(7)
+
+#define ISR_TXRDYA BIT(0)
+#define ISR_RXRDYA BIT(1)
+#define ISR_BREAKA BIT(2)
+#define ISR_CNTRDY BIT(3)
+#define ISR_TXRDYB BIT(4)
+#define ISR_RXRDYB BIT(5)
+#define ISR_BREAKB BIT(6)
+#define ISR_MPICHG BIT(7)
+#define ISR_TXRDY(CH) (((CH)  1) ? BIT(4) : BIT(0))
+#define ISR_RXRDY(CH) (((CH)  1) ? BIT(5) : BIT(1))
+#define ISR_BREAK(CH) (((CH)  1) ? BIT(6) : BIT(2))
+
+typedef struct IPOctalState IPOctalState;
+typedef struct SCC2698Channel SCC2698Channel;
+typedef struct SCC2698Block SCC2698Block;
+
+struct SCC2698Channel {
+IPOctalState *ipoctal;
+CharDriverState *dev;
+char *devpath;
+bool rx_enabled;
+uint8_t mr[2];
+uint8_t mr_idx;
+uint8_t sr;
+uint8_t rhr[RX_FIFO_SIZE];
+uint8_t rhr_idx;
+uint8_t rx_pending;
+};
+
+struct SCC2698Block {
+uint8_t imr;
+uint8_t isr;
+};
+
+struct IPOctalState {
+IPackDevice dev;
+SCC2698Channel ch[N_CHANNELS];
+SCC2698Block blk[N_BLOCKS];
+uint8_t irq_vector;
+};
+
+static const VMStateDescription vmstate_scc2698_channel = {
+.name = scc2698_channel,
+.version_id = 1,
+.minimum_version_id = 1,
+.minimum_version_id_old = 1,
+.fields  = (VMStateField[]) {
+VMSTATE_BOOL(rx_enabled, SCC2698Channel),
+VMSTATE_UINT8_ARRAY(mr, SCC2698Channel, 2),
+VMSTATE_UINT8(mr_idx, SCC2698Channel),
+VMSTATE_UINT8(sr, SCC2698Channel),
+VMSTATE_UINT8_ARRAY(rhr, SCC2698Channel, RX_FIFO_SIZE),
+VMSTATE_UINT8(rhr_idx, SCC2698Channel),
+VMSTATE_UINT8(rx_pending, SCC2698Channel),
+VMSTATE_END_OF_LIST()
+}
+};
+
+static const VMStateDescription vmstate_scc2698_block = {
+.name = scc2698_block,
+.version_id = 1,
+.minimum_version_id = 1,
+.minimum_version_id_old = 1,
+.fields  = (VMStateField[]) {
+VMSTATE_UINT8(imr, SCC2698Block),
+VMSTATE_UINT8(isr, SCC2698Block),
+VMSTATE_END_OF_LIST()
+}
+};
+
+static const VMStateDescription vmstate_ipoctal = {
+.name = ipoctal,
+.version_id = 1,
+.minimum_version_id = 1,
+.minimum_version_id_old = 1,
+.fields  = (VMStateField[]) {
+VMSTATE_IPACK_DEVICE(dev, IPOctalState),
+

[Qemu-devel] [PATCH v2 1/2] Add TEWS TPCI200 IndustryPack emulation

2012-12-05 Thread Alberto Garcia

The TPCI200 is a PCI board that supports up to 4 IndustryPack modules.

A new bus type called 'IndustryPack' has been created so any
compatible module can be attached to this board.

Signed-off-by: Alberto Garcia agar...@igalia.com
---
 default-configs/pci.mak |1 +
 hw/Makefile.objs|3 +
 hw/ipack.c  |  106 
 hw/ipack.h  |   75 ++
 hw/pci_ids.h|3 +
 hw/tpci200.c|  667 +++
 6 ficheiros modificados, 855 adições(+)
 create mode 100644 hw/ipack.c
 create mode 100644 hw/ipack.h
 create mode 100644 hw/tpci200.c

diff --git a/default-configs/pci.mak b/default-configs/pci.mak
index ae9d1eb..ee2d18d 100644
--- a/default-configs/pci.mak
+++ b/default-configs/pci.mak
@@ -21,3 +21,4 @@ CONFIG_ESP=y
 CONFIG_ESP_PCI=y
 CONFIG_SERIAL=y
 CONFIG_SERIAL_PCI=y
+CONFIG_IPACK=y
diff --git a/hw/Makefile.objs b/hw/Makefile.objs
index d581d8d..2ce5ec0 100644
--- a/hw/Makefile.objs
+++ b/hw/Makefile.objs
@@ -104,6 +104,9 @@ common-obj-$(CONFIG_PCI) += wdt_i6300esb.o
 
 common-obj-$(CONFIG_PCI) += pcie.o pcie_aer.o pcie_port.o
 
+# IndustryPack
+common-obj-$(CONFIG_IPACK) += tpci200.o ipack.o
+
 # PCI network cards
 common-obj-$(CONFIG_NE2000_PCI) += ne2000.o
 common-obj-$(CONFIG_EEPRO100_PCI) += eepro100.o
diff --git a/hw/ipack.c b/hw/ipack.c
new file mode 100644
index 000..59e272b
--- /dev/null
+++ b/hw/ipack.c
@@ -0,0 +1,106 @@
+/*
+ * QEMU IndustryPack emulation
+ *
+ * Copyright (C) 2012 Igalia, S.L.
+ * Author: Alberto Garcia agar...@igalia.com
+ *
+ * This code is licensed under the GNU GPL v2 or (at your option) any
+ * later version.
+ */
+
+#include ipack.h
+
+IPackDevice *ipack_device_find(IPackBus *bus, int32_t slot)
+{
+BusChild *kid;
+
+QTAILQ_FOREACH(kid, bus-qbus.children, sibling) {
+DeviceState *qdev = kid-child;
+IPackDevice *ip = DO_UPCAST(IPackDevice, qdev, qdev);
+if (ip-slot == slot) {
+return ip;
+}
+}
+return NULL;
+}
+
+static int ipack_device_dev_init(DeviceState *qdev)
+{
+IPackBus *bus = DO_UPCAST(IPackBus, qbus, qdev-parent_bus);
+IPackDevice *dev = DO_UPCAST(IPackDevice, qdev, qdev);
+IPackDeviceClass *k = IPACK_DEVICE_GET_CLASS(dev);
+
+if (dev-slot  0) {
+dev-slot = bus-free_slot;
+}
+if (dev-slot = bus-n_slots) {
+return -1;
+}
+bus-free_slot = dev-slot + 1;
+
+dev-irq = qemu_allocate_irqs(bus-set_irq, dev, 2);
+
+return k-init(dev);
+}
+
+static int ipack_device_dev_exit(DeviceState *qdev)
+{
+IPackDevice *dev = DO_UPCAST(IPackDevice, qdev, qdev);
+IPackDeviceClass *k = IPACK_DEVICE_GET_CLASS(dev);
+
+if (k-exit) {
+k-exit(dev);
+}
+
+qemu_free_irqs(dev-irq);
+
+return 0;
+}
+
+static Property ipack_device_props[] = {
+DEFINE_PROP_INT32(slot, IPackDevice, slot, -1),
+DEFINE_PROP_END_OF_LIST()
+};
+
+static void ipack_device_class_init(ObjectClass *klass, void *data)
+{
+DeviceClass *k = DEVICE_CLASS(klass);
+k-bus_type = TYPE_IPACK_BUS;
+k-init = ipack_device_dev_init;
+k-exit = ipack_device_dev_exit;
+k-props = ipack_device_props;
+}
+
+const VMStateDescription vmstate_ipack_device = {
+.name = ipack_device,
+.version_id = 1,
+.minimum_version_id = 1,
+.minimum_version_id_old = 1,
+.fields  = (VMStateField[]) {
+VMSTATE_INT32(slot, IPackDevice),
+VMSTATE_END_OF_LIST()
+}
+};
+
+static const TypeInfo ipack_device_info = {
+.name  = TYPE_IPACK_DEVICE,
+.parent= TYPE_DEVICE,
+.instance_size = sizeof(IPackDevice),
+.class_size= sizeof(IPackDeviceClass),
+.class_init= ipack_device_class_init,
+.abstract  = true,
+};
+
+static const TypeInfo ipack_bus_info = {
+.name = TYPE_IPACK_BUS,
+.parent = TYPE_BUS,
+.instance_size = sizeof(IPackBus),
+};
+
+static void ipack_register_types(void)
+{
+type_register_static(ipack_device_info);
+type_register_static(ipack_bus_info);
+}
+
+type_init(ipack_register_types)
diff --git a/hw/ipack.h b/hw/ipack.h
new file mode 100644
index 000..61a9019
--- /dev/null
+++ b/hw/ipack.h
@@ -0,0 +1,75 @@
+/*
+ * QEMU IndustryPack emulation
+ *
+ * Copyright (C) 2012 Igalia, S.L.
+ * Author: Alberto Garcia agar...@igalia.com
+ *
+ * This code is licensed under the GNU GPL v2 or (at your option) any
+ * later version.
+ */
+
+#ifndef QEMU_IPACK_H
+#define QEMU_IPACK_H
+
+#include qdev.h
+
+typedef struct IPackBus IPackBus;
+
+#define TYPE_IPACK_BUS IndustryPack
+#define IPACK_BUS(obj) OBJECT_CHECK(IPackBus, (obj), TYPE_IPACK_BUS)
+
+struct IPackBus {
+BusState qbus;
+uint8_t n_slots;
+uint8_t free_slot;
+qemu_irq_handler set_irq;
+};
+
+typedef struct IPackDevice IPackDevice;
+typedef struct IPackDeviceClass IPackDeviceClass;
+
+#define TYPE_IPACK_DEVICE ipack-device
+#define IPACK_DEVICE(obj) \
+ OBJECT_CHECK(IPackDevice, (obj), 

[Qemu-devel] [Bug 1086745] [NEW] serial port data THRE comes too early

2012-12-05 Thread Kees Schoenmakers
Public bug reported:

When using a serial port with a Linux guest (and host) and the
application uses hardware handshake, this fails because the handling of
TEMT and/or THRE is not operating properly in such cases.

As long as it takes _time_ for the 'real' port to output the data TEMT
may not return true. After writing characters to a real port, the driver
should timeout the transmission and after the total time expired, TEMT
can be set.

Some applications i.e. with a simplex modem do: RTS_on, WRITE_data, repeat 
IOCTL(GET_LSR_INFO), RTS_off, READ_data.
At the moment this fails because very early in the transmission, GET_LSR_INFO 
returns true and the modem transmitter is switched off.

I looked in the source (git)  and found that 'char_transmit_time' is present. 
My skills fail to implement it myself.
I build and ran the latest git version and found it to fail as decribed above.  
I hope someone can solve it.

** Affects: qemu
 Importance: Undecided
 Status: New


** Tags: handshake port serial

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

Title:
  serial port data THRE comes too early

Status in QEMU:
  New

Bug description:
  When using a serial port with a Linux guest (and host) and the
  application uses hardware handshake, this fails because the handling
  of TEMT and/or THRE is not operating properly in such cases.

  As long as it takes _time_ for the 'real' port to output the data TEMT
  may not return true. After writing characters to a real port, the
  driver should timeout the transmission and after the total time
  expired, TEMT can be set.

  Some applications i.e. with a simplex modem do: RTS_on, WRITE_data, repeat 
IOCTL(GET_LSR_INFO), RTS_off, READ_data.
  At the moment this fails because very early in the transmission, GET_LSR_INFO 
returns true and the modem transmitter is switched off.

  I looked in the source (git)  and found that 'char_transmit_time' is present. 
My skills fail to implement it myself.
  I build and ran the latest git version and found it to fail as decribed 
above.  I hope someone can solve it.

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



[Qemu-devel] [Bug 1086782] [NEW] HPET time drift windows 7 64bits guest

2012-12-05 Thread Carlos-velasco
Public bug reported:

Using latest qemu-kvm (1.2.0), time drift (clock slow in guest) in Windows 7 64 
bits guest when HPET is enabled (default).
Disabling HPET (-no-hpet) solves the time drift.

UsePlatformClock enable/disable doesn't make a difference in the guest.
bcdedit /set useplatformclock true

Using driftfix slew doesn't make a difference too.


# qemu-system-x86_64 --version
QEMU emulator version 1.2.0 (qemu-kvm-1.2.0), Copyright (c) 2003-2008 Fabrice 
Bellard

Kernel is 3.6.8:
# uname -a
Linux pulsar 3.6.8 #1 SMP Sat Dec 1 16:26:10 CET 2012 x86_64 x86_64 x86_64 
GNU/Linux

TSC is stable in the host:
===
# cat /sys/devices/system/clocksource/clocksource0/current_clocksource
tsc

Dmesg:
[0.00] hpet clockevent registered
[0.00] tsc: Fast TSC calibration using PIT
[0.00] tsc: Detected 2660.096 MHz processor
[0.001002] Calibrating delay loop (skipped), value calculated using timer 
frequency.. 5320.19 BogoMIPS (lpj=2660096)
[0.001138] pid_max: default: 32768 minimum: 301
...
[1.492019] tsc: Refined TSC clocksource calibration: 2659.973 MHz
[1.492093] Switching to clocksource tsc


CPUinfo, constant_tsc:
vendor_id   : GenuineIntel
cpu family  : 6
model   : 23
model name  : Intel(R) Core(TM)2 Quad CPUQ8400  @ 2.66GHz
stepping: 10
microcode   : 0xa0b
cpu MHz : 2667.000
cache size  : 2048 KB
flags   : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov 
pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx lm 
constant_tsc arch_perfmon pebs bts rep_good nopl aperfmperf pni dtes64 monitor 
ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm sse4_1 xsave lahf_lm dtherm tpr_shadow 
vnmi flexpriority
bogomips: 5320.19

# grep -i hpet .config
CONFIG_HPET_TIMER=y
CONFIG_HPET_EMULATE_RTC=y
CONFIG_HPET=y
# CONFIG_HPET_MMAP is not set
===

Qemu command line:
/usr/bin/qemu-system-x86_64 -drive 
file=/dev/vol0/KVMORION01,cache=none,aio=native,if=virtio \
  -drive file=/dev/vol0/KVMORION02,cache=none,aio=native,if=virtio \
  -cpu host \
  -m 2048 \
  -smp 4,maxcpus=4,cores=4,threads=1,sockets=1 \
  -rtc base=localtime,driftfix=slew \
  -vnc 10.124.241.211:0,password -k es \
  -monitor telnet:localhost:37200,server,nowait \
  -netdev 
tap,id=kvmorion,ifname=kvmorion,script=/etc/qemu-ifup-br0,downscript=/etc/qemu-ifdown-br0
 \
  -device virtio-net-pci,netdev=kvmorion,id=virtio-nic0,mac=02:85:64:02:c2:aa \
  -device virtio-balloon-pci,id=balloon0 \
  -boot menu=on \
  -pidfile /var/run/kvmorion.pid \
  -daemonize

Using 1 CPU doesn't make a difference.
Only workaround is disabling hpet (-no-hpet)

Sample time drift in guest:
ntpdate -q 10.124.241.211
 5 Dec 13:36:06 ntpdate[3464]: Raised to realtime priority class
server 10.124.241.211, stratum 2, offset 3.694184, delay 0.02551
 5 Dec 13:36:12 ntpdate[3464]: step time server 10.124.241.211 offset 3.694184 s
ec

ntpdate -q 10.124.241.211
 5 Dec 13:52:02 ntpdate[1964]: Raised to realtime priority class
server 10.124.241.211, stratum 2, offset 4.719968, delay 0.02554
 5 Dec 13:52:08 ntpdate[1964]: step time server 10.124.241.211 offset 4.719968 s
ec

** Affects: qemu
 Importance: Undecided
 Status: New

** Summary changed:

- HPET time drift windows 7 64bits
+ HPET time drift windows 7 64bits guest

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

Title:
  HPET time drift windows 7 64bits guest

Status in QEMU:
  New

Bug description:
  Using latest qemu-kvm (1.2.0), time drift (clock slow in guest) in Windows 7 
64 bits guest when HPET is enabled (default).
  Disabling HPET (-no-hpet) solves the time drift.

  UsePlatformClock enable/disable doesn't make a difference in the guest.
  bcdedit /set useplatformclock true

  Using driftfix slew doesn't make a difference too.

  
  # qemu-system-x86_64 --version
  QEMU emulator version 1.2.0 (qemu-kvm-1.2.0), Copyright (c) 2003-2008 Fabrice 
Bellard

  Kernel is 3.6.8:
  # uname -a
  Linux pulsar 3.6.8 #1 SMP Sat Dec 1 16:26:10 CET 2012 x86_64 x86_64 x86_64 
GNU/Linux

  TSC is stable in the host:
  ===
  # cat /sys/devices/system/clocksource/clocksource0/current_clocksource
  tsc

  Dmesg:
  [0.00] hpet clockevent registered
  [0.00] tsc: Fast TSC calibration using PIT
  [0.00] tsc: Detected 2660.096 MHz processor
  [0.001002] Calibrating delay loop (skipped), value calculated using timer 
frequency.. 5320.19 BogoMIPS (lpj=2660096)
  [0.001138] pid_max: default: 32768 minimum: 301
  ...
  [1.492019] tsc: Refined TSC clocksource calibration: 2659.973 MHz
  [1.492093] Switching to clocksource tsc

  
  CPUinfo, constant_tsc:
  vendor_id   : GenuineIntel
  cpu family  : 6
  model   : 23
  model name  : Intel(R) Core(TM)2 Quad CPUQ8400  @ 2.66GHz
  stepping: 10
  microcode   : 0xa0b
  cpu MHz : 2667.000
  cache size   

[Qemu-devel] [Bug 1086745] Re: serial port data THRE comes too early

2012-12-05 Thread Lei Li
Could you please give more details, like the steps to reproduce this
problems.

Thanks.

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

Title:
  serial port data THRE comes too early

Status in QEMU:
  New

Bug description:
  When using a serial port with a Linux guest (and host) and the
  application uses hardware handshake, this fails because the handling
  of TEMT and/or THRE is not operating properly in such cases.

  As long as it takes _time_ for the 'real' port to output the data TEMT
  may not return true. After writing characters to a real port, the
  driver should timeout the transmission and after the total time
  expired, TEMT can be set.

  Some applications i.e. with a simplex modem do: RTS_on, WRITE_data, repeat 
IOCTL(GET_LSR_INFO), RTS_off, READ_data.
  At the moment this fails because very early in the transmission, GET_LSR_INFO 
returns true and the modem transmitter is switched off.

  I looked in the source (git)  and found that 'char_transmit_time' is present. 
My skills fail to implement it myself.
  I build and ran the latest git version and found it to fail as decribed 
above.  I hope someone can solve it.

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



Re: [Qemu-devel] [PATCH v2 0/2] Add TPCI200 and IP-Octal 232 IndustryPack emulation

2012-12-05 Thread Andreas Färber
Hello Alberto,

Am 05.12.2012 14:16, schrieb Alberto Garcia:
 
 Hello again,
 
 I'm sending the new version of my TPCI200 and IP-Octal 232 patches,
[snip]

You may want to resend v2 as inline patches - Thunderbird for instance
doesn't allow to quote / comment on attachments.

Andreas

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg



[Qemu-devel] qmp query-balloon return only actual value ?

2012-12-05 Thread Alexandre DERUMIER
Hi,
I'm trying to use qmp query-balloon, to get stats,

From Doc, I expect to have


- { execute: query-balloon }
- {
  return:{
 actual:1073741824,
 mem_swapped_in:0,
 mem_swapped_out:0,
 major_page_faults:142,
 minor_page_faults:239245,
 free_mem:1014185984,
 total_mem:1044668416
  }
   }


But I got only

- { execute: query-balloon }
- {
  return:{
 actual:1073741824,
  }
   }


qemu 1.3.

Guest kernels tested : 2.6.32, 3.2 and 3.5.

Does I need a more recent kernel in my guest ?

Regards,

Alexandre



Re: [Qemu-devel] [PATCH 08/13] pseries: Update SLOF for NVRAM support

2012-12-05 Thread Erlon Cruz
Hi Alex,


 Could you please post

   * the exact command line you were using


 ./ppc64-softmmu/qemu-system-ppc64 -machine type=pseries,usb=off -m 512
-net nic,vlan=0 -net tap -nographic -cdrom
/exports/isos/SLES-11-SP2-DVD-ppc64-GM-DVD1.iso -hda
/exports/sles11_sp2.qcow2 -monitor unix:/dev/tty1,nowait,server

  * details about your host: architecture, OS, kernel version


 Intel(R) Core(TM) i5-2520M CPU @ 2.50GH
 Linux tpad 3.2.0-23-generic #36-Ubuntu SMP Tue Apr 10 20:39:51 UTC 2012
x86_64 x86_64 x86_64 GNU/Linux

   * is this using KVM or TCG?


TCG


   * what SLES exactly are you using here?


SLES-11-SP2-DVD-ppc64-GM-DVD1.iso: sha256 -
2247dd6bb495eb50860668e46f7d6ba004eece9909f347c8ce487fd6a5f65ee1

  * the exact QEMU version


Git: 01bbd8b... Update version for 1.3.0-rc2

I also run the media check from the installer and it says its OK. The only
abnormal think i could see is a message about the network interface, but it
doesn't seen to affect the behavior in the rootfs guests:

 Starting udev... ibmveth 1001: (unregistered net_device): unable to change
checksum offload settings. 1 rc=-2 ret_attr=1001

This last time I run, before that first error I mentioned I got this error
in this package:

Installation of package ./suse/ppc64/liborc-0_4-0-0.4.11-7.5.23.ppc64.rpm
failed.
Subprocess failed. Error: RPM failed: Inconsistency detected by ld.so:
dl-lookup

but after retrying it passed. But when it hit the vi-base it stuck in that
error no matter how many times I retry or skip the package.

Erlon


[Qemu-devel] [PATCH v2 1/2] pc_sysfw: Check for qemu_find_file() failure

2012-12-05 Thread Markus Armbruster
pc_fw_add_pflash_drv() ignores qemu_find_file() failure, and happily
creates a drive without a medium.

When pc_system_flash_init() asks for its size, bdrv_getlength() fails
with -ENOMEDIUM, which isn't checked either.  It fails relatively
cleanly only because -ENOMEDIUM isn't a multiple of 4096:

$ qemu-system-x86_64 -S -vnc :0 -bios nonexistant
qemu: PC system firmware (pflash) must be a multiple of 0x1000
[Exit 1 ]

Fix by handling the qemu_find_file() failure.

Signed-off-by: Markus Armbruster arm...@redhat.com
---
v2: Don't report errno, because that can produce misleading error
messages.  For instance, when seabios/out/bios.bin is unreadable, we
fall back to $data_dir/seabios/out/bios.bin, which doesn't exist, and
then report seabios/out/bios.bin: No such file or directory.  No other
caller reports errno.

 hw/pc_sysfw.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/hw/pc_sysfw.c b/hw/pc_sysfw.c
index 9d7c5f4..a161e7b 100644
--- a/hw/pc_sysfw.c
+++ b/hw/pc_sysfw.c
@@ -84,6 +84,10 @@ static void pc_fw_add_pflash_drv(void)
 bios_name = BIOS_FILENAME;
 }
 filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
+if (!filename) {
+error_report(Can't open BIOS image %s, bios_name);
+exit(1);
+}
 
 opts = drive_add(IF_PFLASH, -1, filename, readonly=on);
 
-- 
1.7.11.7




Re: [Qemu-devel] [PATCH 08/13] pseries: Update SLOF for NVRAM support

2012-12-05 Thread Alexander Graf

On 05.12.2012, at 15:09, Erlon Cruz wrote:

 Hi Alex,
  
 Could you please post
 
   * the exact command line you were using
 
  ./ppc64-softmmu/qemu-system-ppc64 -machine type=pseries,usb=off -m 512 -net 
 nic,vlan=0 -net tap -nographic -cdrom 
 /exports/isos/SLES-11-SP2-DVD-ppc64-GM-DVD1.iso -hda 
 /exports/sles11_sp2.qcow2 -monitor unix:/dev/tty1,nowait,server

Ah, so you're using -M mac99, which means any patch that says pseries 
shouldn't affect that VM at all.

 
   * details about your host: architecture, OS, kernel version
 
  Intel(R) Core(TM) i5-2520M CPU @ 2.50GH
  Linux tpad 3.2.0-23-generic #36-Ubuntu SMP Tue Apr 10 20:39:51 UTC 2012 
 x86_64 x86_64 x86_64 GNU/Linux
 
   * is this using KVM or TCG?
 
 TCG
  
   * what SLES exactly are you using here?
 
 SLES-11-SP2-DVD-ppc64-GM-DVD1.iso: sha256 - 
 2247dd6bb495eb50860668e46f7d6ba004eece9909f347c8ce487fd6a5f65ee1
 
   * the exact QEMU version
 
  
 Git: 01bbd8b... Update version for 1.3.0-rc2
 
 I also run the media check from the installer and it says its OK. The only 
 abnormal think i could see is a message about the network interface, but it 
 doesn't seen to affect the behavior in the rootfs guests:
 
  Starting udev... ibmveth 1001: (unregistered net_device): unable to change 
 checksum offload settings. 1 rc=-2 ret_attr=1001
 
 This last time I run, before that first error I mentioned I got this error in 
 this package:
 
 Installation of package ./suse/ppc64/liborc-0_4-0-0.4.11-7.5.23.ppc64.rpm 
 failed.
 Subprocess failed. Error: RPM failed: Inconsistency detected by ld.so: 
 dl-lookup
 
 but after retrying it passed. But when it hit the vi-base it stuck in that 
 error no matter how many times I retry or skip the package.

This smells quite a lot like a TCG emulation bug. Could you please check if 
older versions used to work, so whether this is a regression or something that 
never really worked?

Please also give -M pseries -vga std a try.


Alex



Re: [Qemu-devel] [Qemu-ppc] [PATCH 08/13] pseries: Update SLOF for NVRAM support

2012-12-05 Thread Alexander Graf

On 05.12.2012, at 15:35, Alexander Graf wrote:

 
 On 05.12.2012, at 15:09, Erlon Cruz wrote:
 
 Hi Alex,
  
 Could you please post
 
   * the exact command line you were using
 
  ./ppc64-softmmu/qemu-system-ppc64 -machine type=pseries,usb=off -m 512 -net 
 nic,vlan=0 -net tap -nographic -cdrom 
 /exports/isos/SLES-11-SP2-DVD-ppc64-GM-DVD1.iso -hda 
 /exports/sles11_sp2.qcow2 -monitor unix:/dev/tty1,nowait,server
 
 Ah, so you're using -M mac99, which means any patch that says pseries 
 shouldn't affect that VM at all.

Scratch that. -machine type=pseries obviously makes this a pseries machine.

Please still try to check if 1.2 or 1.1 work for you. Checking if disabling 
graphics makes things work would be interesting too.


Alex



Re: [Qemu-devel] [Qemu-ppc] [PATCH 08/13] pseries: Update SLOF for NVRAM support

2012-12-05 Thread Alexander Graf

On 05.12.2012, at 15:37, Alexander Graf wrote:

 
 On 05.12.2012, at 15:35, Alexander Graf wrote:
 
 
 On 05.12.2012, at 15:09, Erlon Cruz wrote:
 
 Hi Alex,
  
 Could you please post
 
   * the exact command line you were using
 
  ./ppc64-softmmu/qemu-system-ppc64 -machine type=pseries,usb=off -m 512 
 -net nic,vlan=0 -net tap -nographic -cdrom 
 /exports/isos/SLES-11-SP2-DVD-ppc64-GM-DVD1.iso -hda 
 /exports/sles11_sp2.qcow2 -monitor unix:/dev/tty1,nowait,server
 
 Ah, so you're using -M mac99, which means any patch that says pseries 
 shouldn't affect that VM at all.
 
 Scratch that. -machine type=pseries obviously makes this a pseries machine.
 
 Please still try to check if 1.2 or 1.1 work for you. Checking if disabling 
 graphics makes things work would be interesting too.

Also -cpu 970 would be an interesting thing to try.


Alex



Re: [Qemu-devel] [RFC 8/8] qom: make CPU a child of DeviceState

2012-12-05 Thread Andreas Färber
Am 04.12.2012 14:19, schrieb Eduardo Habkost:
 From: Igor Mammedov imamm...@redhat.com
 
 Signed-off-by: Igor Mammedov imamm...@redhat.com
 [ehabkost: change CPU type declaration to hae TYPE_DEVICE as parent]
 Signed-off-by: Eduardo Habkost ehabk...@redhat.com
 ---
 Yes, there is changelog data before the --- mark, but I believe that
 in this case they are important to indicate authorship and the scope of
 the Signed-off-by lines (so they need to get into the git commit
 message).
 ---
  include/qemu/cpu.h | 6 +++---
  qom/cpu.c  | 3 ++-
  2 files changed, 5 insertions(+), 4 deletions(-)
 
 diff --git a/include/qemu/cpu.h b/include/qemu/cpu.h
 index 61b7698..bc004fd 100644
 --- a/include/qemu/cpu.h
 +++ b/include/qemu/cpu.h
 @@ -20,7 +20,7 @@
  #ifndef QEMU_CPU_H
  #define QEMU_CPU_H
  
 -#include qemu/object.h
 +#include hw/qdev-core.h
  #include qemu-thread.h
  
  /**
 @@ -46,7 +46,7 @@ typedef struct CPUState CPUState;
   */
  typedef struct CPUClass {
  /* private */
 -ObjectClass parent_class;
 +DeviceClass parent_class;
  /* public */
  
  void (*reset)(CPUState *cpu);
 @@ -62,7 +62,7 @@ typedef struct CPUClass {
   */
  struct CPUState {
  /* private */
 -Object parent_obj;
 +DeviceState parent_obj;
  /* public */
  
  struct QemuThread *thread;
 diff --git a/qom/cpu.c b/qom/cpu.c
 index 5b36046..f59db7d 100644
 --- a/qom/cpu.c
 +++ b/qom/cpu.c
 @@ -20,6 +20,7 @@
  
  #include qemu/cpu.h
  #include qemu-common.h
 +#include hw/qdev-core.h
  
  void cpu_reset(CPUState *cpu)
  {
 @@ -43,7 +44,7 @@ static void cpu_class_init(ObjectClass *klass, void *data)
  
  static TypeInfo cpu_type_info = {
  .name = TYPE_CPU,
 -.parent = TYPE_OBJECT,
 +.parent = TYPE_DEVICE,
  .instance_size = sizeof(CPUState),
  .abstract = true,
  .class_size = sizeof(CPUClass),

This makes the CPU a device, allowing the user to specify it with
-device. My preference would be to disable that at first[1] by setting
DeviceClass::no_user = 1.

Have you tested what happens if someone tries to hotplug a CPU device?
It may be the first device without bus...

[1] Anthony's and my idea was to handle hotplug at a higher level than
CPUState - X86Socket containing X86Core containing X86Thread or so. This
would require me (or someone) to refactor CPU_COMMON's numa_node (also
used in sPAPR), nr_cores, nr_threads (also used in mips/Malta) - in a
non-trivial way. We may need to go from CPU*State to CPUState (possible
so far) to Core to Socket, for which object_get_parent() would be
helpful. So far Object::parent is declared private.
Are we targetting to do this is two steps, using CPUState at first? Or
has one of you been investigating how involved this redesign would be?

Regards,
Andreas

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg



Re: [Qemu-devel] [PULL for-1.3 0/3] seabios: q35 update

2012-12-05 Thread Gabriel L. Somlo
On Wed, Dec 05, 2012 at 07:50:17AM +0100, Gerd Hoffmann wrote:
 Ok, so no IRQ declared for the RTC.  We have IRQ 8 for both rtc and
 hpet, which most likely is the root cause for the issue.  You can try
 simply dropping the line for testing.  I'll try to come up with
 something more clever as the hpet can be disabled in which case we
 should keep irq8 assigned to rtc.

Yeah, with SnowLeopard, simply leaving out the IRQ on RTC in SeaBIOS
got me all the way to a blue screen with a moving mouse pointer, but
no further :)

However, the acpi-dsdt-isa.dsl RTC patch you just sent to SeaBIOS
has no (negative) impact on my ability to boot SnowLeopard.

Thanks much,
--Gabriel



Re: [Qemu-devel] [RFC 0/8] CPU DeviceState v9

2012-12-05 Thread Andreas Färber
Am 04.12.2012 17:40, schrieb Eduardo Habkost:
 On Tue, Dec 04, 2012 at 04:59:38PM +0100, Andreas Färber wrote:
 Am 04.12.2012 14:19, schrieb Eduardo Habkost:
 Changes on v9:
  - Instead of moving qemu_[un]register_reset() to reset.c and including
it on *-user, create stubs for them on libqemustub.a

 We compile cpu.c twice. Can't we do the same for qdev.c or whatever uses
 those functions? I feel they have no business being used in *-user.
 CC'ing Riku and Peter.
 
 I don't understand what exactly you are suggesting. You suggest adding
 #ifdefs to qdev.c to compile out the qemu_[un]register_reset() calls?

Yes, that was my thought. It would've spared us the include troubles in
stubs/ for now. ;)

Andreas

 I had a version of this series that did exactly that[1], but IIRC
 somebody suggested using stub functions instead. And I agree with
 whoever suggested it, I believe stub functions are cleaner when the the
 stub version still have the semantics expected by the caller[2].
 
 [1] http://article.gmane.org/gmane.comp.emulators.xen.devel/137686
 [2] e.g. a no-op qemu_register_reset() still does the job it's supposed
 to do (making sure a function to be called when qemu_devices_reset()
 is called), if we know qemu_devices_reset() is never called.
 
 

 Andreas

  - This is based on afaerber's qom-cpu branch, that has some header cleanup
changes. You can get the complete series in a git tree at:
https://github.com/ehabkost/qemu-hacks/tree/cpu_qdev.v9
git://github.com/ehabkost/qemu-hacks.git cpu_qdev.v9

 v8:
  - Use a simpler copyright header on qdev-properties-system.c
  - Use the new libqemustub.a mechanism instead of the (now exting)
QEMU_WEAK_ALIAS mechanism
  - Move the reset-handler registration code to a new hw/reset.c file

 v7:
  - Use the new QEMU_WEAK_ALIAS mechanism instead of the (now extinct)
GCC_WEAK attribute (patches 20 and 21)

 v6:
  - Simple rebase against latest qemu.git master
  - Patch 13: some new typedefs were added and others were removed
  - Patch 19: trivial rebase
 v5:
  - Tons of header cleanups just to eliminate qlist.h - cpu-common.h 
 circular
dependency (patches 1-17)
  - Add copyright/license information to qdev-properties.c (patch 17)
  - Add copyright/license information to qdev-properties-system.c (patch 22)
  - use error_report()+abort() instead of hw_error() on qdev.c (patch 18)
  - Move qemu_[un]register_reset() and qemu_devices_reset() to qdev-core.c
(patch 19)
  - Make vmstate_[un]register() weak stubs, instead of a new function (patch 
 20)
  - Make sysbus_get_default() weak stub, instead of new qbus reset 
 (un)register
functions (patch 21)
  - Eliminate qdev-system.c (all code is kept on qdev.c, now) (patch 22)
 v4:
   - Add GCC_WEAK_DECL to functions that have GCC_WEAK versions
   - Updated the qdev_init_gpio_in() code on qdev-system.c to current version
   - Patch description updates (moved changelog below --- and/or move info
 about changes made by different authors between SoB lines)
 v3 (submitted by Igor):
   - rebased on top of 8b4a3df (today's master)
   - slight code reshuffling in (see commit's changelog)
  qdev: separate core from the code used only by qemu-system-*
  move qemu_irq typedef out of cpu-common.h
   - commit messages cleanup
 v2:
   Removes the CONFIG_USER_ONLY ifdefs, and use weak symbols to move
   the vmstate and qemu_register_reset() handling to qdev-system.c

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg



[Qemu-devel] [PATCH 2/6] spice-qemu-char: factor out CharDriverState creation

2012-12-05 Thread Marc-André Lureau
Make the CharDriverState creation code reusable by spicevmc port.
---
 spice-qemu-char.c | 37 +++--
 1 file changed, 23 insertions(+), 14 deletions(-)

diff --git a/spice-qemu-char.c b/spice-qemu-char.c
index 665efd3..b86e83a 100644
--- a/spice-qemu-char.c
+++ b/spice-qemu-char.c
@@ -186,13 +186,32 @@ static void print_allowed_subtypes(void)
 fprintf(stderr, \n);
 }
 
-CharDriverState *qemu_chr_open_spice(QemuOpts *opts)
+static CharDriverState *chr_open(QemuOpts *opts, const char *subtype)
 {
 CharDriverState *chr;
 SpiceCharDriver *s;
-const char* name = qemu_opt_get(opts, name);
 uint32_t debug = qemu_opt_get_number(opts, debug, 0);
-const char** psubtype = spice_server_char_device_recognized_subtypes();
+
+chr = g_malloc0(sizeof(CharDriverState));
+s = g_malloc0(sizeof(SpiceCharDriver));
+s-chr = chr;
+s-debug = debug;
+s-active = false;
+s-sin.subtype = subtype;
+chr-opaque = s;
+chr-chr_write = spice_chr_write;
+chr-chr_close = spice_chr_close;
+chr-chr_guest_open = spice_chr_guest_open;
+chr-chr_guest_close = spice_chr_guest_close;
+
+return chr;
+}
+
+CharDriverState *qemu_chr_open_spice(QemuOpts *opts)
+{
+CharDriverState *chr;
+const char *name = qemu_opt_get(opts, name);
+const char **psubtype = spice_server_char_device_recognized_subtypes();
 const char *subtype = NULL;
 
 if (name == NULL) {
@@ -212,17 +231,7 @@ CharDriverState *qemu_chr_open_spice(QemuOpts *opts)
 return NULL;
 }
 
-chr = g_malloc0(sizeof(CharDriverState));
-s = g_malloc0(sizeof(SpiceCharDriver));
-s-chr = chr;
-s-debug = debug;
-s-active = false;
-s-sin.subtype = subtype;
-chr-opaque = s;
-chr-chr_write = spice_chr_write;
-chr-chr_close = spice_chr_close;
-chr-chr_guest_open = spice_chr_guest_open;
-chr-chr_guest_close = spice_chr_guest_close;
+chr = chr_open(opts, subtype);
 
 #if SPICE_SERVER_VERSION  0x000901
 /* See comment in vmc_state() */
-- 
1.7.11.7




[Qemu-devel] [PATCH 4/6] spice-qemu-char: keep a list of spice chardev

2012-12-05 Thread Marc-André Lureau
---
 spice-qemu-char.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/spice-qemu-char.c b/spice-qemu-char.c
index 4be75ba..4eb85ae 100644
--- a/spice-qemu-char.c
+++ b/spice-qemu-char.c
@@ -24,8 +24,12 @@ typedef struct SpiceCharDriver {
 uint8_t   *datapos;
 ssize_t   bufsize, datalen;
 uint32_t  debug;
+QLIST_ENTRY(SpiceCharDriver) next;
 } SpiceCharDriver;
 
+static QLIST_HEAD(, SpiceCharDriver) spice_chars =
+QLIST_HEAD_INITIALIZER(spice_chars);
+
 static int vmc_write(SpiceCharDeviceInstance *sin, const uint8_t *buf, int len)
 {
 SpiceCharDriver *scd = container_of(sin, SpiceCharDriver, sin);
@@ -179,6 +183,7 @@ static void spice_chr_close(struct CharDriverState *chr)
 
 printf(%s\n, __func__);
 vmc_unregister_interface(s);
+QLIST_REMOVE(s, next);
 g_free(s);
 }
 
@@ -229,6 +234,8 @@ static CharDriverState *chr_open(QemuOpts *opts, const char 
*subtype)
 chr-chr_guest_open = spice_chr_guest_open;
 chr-chr_guest_close = spice_chr_guest_close;
 
+QLIST_INSERT_HEAD(spice_chars, s, next);
+
 return chr;
 }
 
-- 
1.7.11.7




[Qemu-devel] [PATCH 5/6] spice-qemu-char: register spicevmc ports during qemu_spice_init()

2012-12-05 Thread Marc-André Lureau
Do the delayed registration of spicevmc ports after Spice server is
initialized.
---
 spice-qemu-char.c | 12 
 ui/qemu-spice.h   |  1 +
 ui/spice-core.c   |  4 
 3 files changed, 17 insertions(+)

diff --git a/spice-qemu-char.c b/spice-qemu-char.c
index 4eb85ae..b2586c2 100644
--- a/spice-qemu-char.c
+++ b/spice-qemu-char.c
@@ -293,4 +293,16 @@ CharDriverState *qemu_chr_open_spice_port(QemuOpts *opts)
 
 return chr;
 }
+
+void qemu_spice_register_ports(void)
+{
+SpiceCharDriver *s;
+
+QLIST_FOREACH(s, spice_chars, next) {
+if (s-sin.portname == NULL) {
+continue;
+}
+vmc_register_interface(s);
+}
+}
 #endif
diff --git a/ui/qemu-spice.h b/ui/qemu-spice.h
index 5669767..642f012 100644
--- a/ui/qemu-spice.h
+++ b/ui/qemu-spice.h
@@ -48,6 +48,7 @@ void do_info_spice(Monitor *mon, QObject **ret_data);
 CharDriverState *qemu_chr_open_spice(QemuOpts *opts);
 #if SPICE_SERVER_VERSION = 0x000c02
 CharDriverState *qemu_chr_open_spice_port(QemuOpts *opts);
+void qemu_spice_register_ports(void);
 #endif
 
 #else  /* CONFIG_SPICE */
diff --git a/ui/spice-core.c b/ui/spice-core.c
index 261c6f2..ddbcd08 100644
--- a/ui/spice-core.c
+++ b/ui/spice-core.c
@@ -714,6 +714,10 @@ void qemu_spice_init(void)
 g_free(x509_key_file);
 g_free(x509_cert_file);
 g_free(x509_cacert_file);
+
+#if SPICE_SERVER_VERSION = 0x000c02
+qemu_spice_register_ports();
+#endif
 }
 
 int qemu_spice_add_interface(SpiceBaseInstance *sin)
-- 
1.7.11.7




[Qemu-devel] [PATCH 1/6] spice-qemu-char: write to chardev whatever amount it can read

2012-12-05 Thread Marc-André Lureau
The current code waits until the chardev can read MIN(len, VMC_MAX)
But some chardev may never reach than amount, in fact some of them
will only ever accept write of 1. Fix the min computation and remove
the VMC_MAX constant.
---
 spice-qemu-char.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/spice-qemu-char.c b/spice-qemu-char.c
index 09aa22d..665efd3 100644
--- a/spice-qemu-char.c
+++ b/spice-qemu-char.c
@@ -14,8 +14,6 @@
 }   \
 } while (0)
 
-#define VMC_MAX_HOST_WRITE2048
-
 typedef struct SpiceCharDriver {
 CharDriverState*  chr;
 SpiceCharDeviceInstance sin;
@@ -35,8 +33,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, VMC_MAX_HOST_WRITE);
-if (qemu_chr_be_can_write(scd-chr)  last_out) {
+last_out = MIN(len, qemu_chr_be_can_write(scd-chr));
+if (last_out = 0) {
 break;
 }
 qemu_chr_be_write(scd-chr, p, last_out);
-- 
1.7.11.7




Re: [Qemu-devel] [PATCH v2] target-mips: Fix incorrect shift for SHILO and SHILOV

2012-12-05 Thread Richard Henderson
On 2012-12-04 17:29, Petar Jovanovic wrote:
  rs5_0 = (int8_t)(rs5_0  2)  2;

This is more portably written as

  rs5_0 = (rs5_0 ^ 0x20) - 0x20;


r~



[Qemu-devel] [PATCH 3/6] spice-qemu-char: add spiceport chardev

2012-12-05 Thread Marc-André Lureau
Add a new spice chardev to allow arbitrary communication between the
host and the Spice client via the spice server.

Examples:

This allows the Spice client to have a special port for the qemu
monitor:

... -chardev spiceport,name=org.qemu.monitor,id=monitorport
-mon chardev=monitorport

v2:
- remove support for chardev to chardev linking
- conditionnaly compile with SPICE_SERVER_VERSION
---
 qemu-char.c   |  3 +++
 qemu-options.hx   | 13 +
 spice-qemu-char.c | 45 +
 trace-events  |  1 +
 ui/qemu-spice.h   |  3 +++
 5 files changed, 65 insertions(+)

diff --git a/qemu-char.c b/qemu-char.c
index 242b799..9940701 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -2762,6 +2762,9 @@ static const struct {
 #endif
 #ifdef CONFIG_SPICE
 { .name = spicevmc, .open = qemu_chr_open_spice },
+#if SPICE_SERVER_VERSION = 0x000c02
+{ .name = spiceport,.open = qemu_chr_open_spice_port },
+#endif
 #endif
 };
 
diff --git a/qemu-options.hx b/qemu-options.hx
index de43b1b..6b5669d 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -1749,6 +1749,7 @@ DEF(chardev, HAS_ARG, QEMU_OPTION_chardev,
 #endif
 #if defined(CONFIG_SPICE)
 -chardev spicevmc,id=id,name=name[,debug=debug]\n
+-chardev spiceport,id=id,name=name[,debug=debug]\n
 #endif
 , QEMU_ARCH_ALL
 )
@@ -1776,6 +1777,7 @@ Backend is one of:
 @option{tty},
 @option{parport},
 @option{spicevmc}.
+@option{spiceport}.
 The specific backend will determine the applicable options.
 
 All devices must have an id, which can be any string up to 127 characters long.
@@ -1961,6 +1963,17 @@ required.
 
 Connect to a spice virtual machine channel, such as vdiport.
 
+@item -chardev spiceport ,id=@var{id} ,debug=@var{debug}, name=@var{name}
+
+@option{spiceport} is only available when spice support is built in.
+
+@option{debug} debug level for spicevmc
+
+@option{name} name of spice port to connect to
+
+Connect to a spice port, allowing a Spice client to handle the traffic
+identified by a name (preferably a fqdn).
+
 @end table
 ETEXI
 
diff --git a/spice-qemu-char.c b/spice-qemu-char.c
index b86e83a..4be75ba 100644
--- a/spice-qemu-char.c
+++ b/spice-qemu-char.c
@@ -3,6 +3,7 @@
 #include ui/qemu-spice.h
 #include spice.h
 #include spice-experimental.h
+#include spice/protocol.h
 
 #include osdep.h
 
@@ -67,6 +68,27 @@ static int vmc_read(SpiceCharDeviceInstance *sin, uint8_t 
*buf, int len)
 return bytes;
 }
 
+#if SPICE_SERVER_VERSION = 0x000c02
+static void vmc_event(SpiceCharDeviceInstance *sin, uint8_t event)
+{
+SpiceCharDriver *scd = container_of(sin, SpiceCharDriver, sin);
+int chr_event;
+
+switch (event) {
+case SPICE_PORT_EVENT_BREAK:
+chr_event = CHR_EVENT_BREAK;
+break;
+default:
+dprintf(scd, 2, %s: unknown %d\n, __func__, event);
+return;
+}
+
+dprintf(scd, 2, %s: %d\n, __func__, event);
+trace_spice_vmc_event(chr_event);
+qemu_chr_be_event(scd-chr, chr_event);
+}
+#endif
+
 static void vmc_state(SpiceCharDeviceInstance *sin, int connected)
 {
 SpiceCharDriver *scd = container_of(sin, SpiceCharDriver, sin);
@@ -103,6 +125,9 @@ static SpiceCharDeviceInterface vmc_interface = {
 .state  = vmc_state,
 .write  = vmc_write,
 .read   = vmc_read,
+#if SPICE_SERVER_VERSION = 0x000c02
+.event  = vmc_event,
+#endif
 };
 
 
@@ -242,3 +267,23 @@ CharDriverState *qemu_chr_open_spice(QemuOpts *opts)
 
 return chr;
 }
+
+#if SPICE_SERVER_VERSION = 0x000c02
+CharDriverState *qemu_chr_open_spice_port(QemuOpts *opts)
+{
+CharDriverState *chr;
+SpiceCharDriver *s;
+const char *name = qemu_opt_get(opts, name);
+
+if (name == NULL) {
+fprintf(stderr, spice-qemu-char: missing name parameter\n);
+return NULL;
+}
+
+chr = chr_open(opts, port);
+s = chr-opaque;
+s-sin.portname = name;
+
+return chr;
+}
+#endif
diff --git a/trace-events b/trace-events
index 6c6cbf1..77247d9 100644
--- a/trace-events
+++ b/trace-events
@@ -535,6 +535,7 @@ spice_vmc_write(ssize_t out, int len) spice wrottn %zd of 
requested %d
 spice_vmc_read(int bytes, int len) spice read %d of requested %d
 spice_vmc_register_interface(void *scd) spice vmc registered interface %p
 spice_vmc_unregister_interface(void *scd) spice vmc unregistered interface %p
+spice_vmc_event(int event) spice vmc event %d
 
 # hw/lm32_pic.c
 lm32_pic_raise_irq(void) Raise CPU interrupt
diff --git a/ui/qemu-spice.h b/ui/qemu-spice.h
index 3299da8..5669767 100644
--- a/ui/qemu-spice.h
+++ b/ui/qemu-spice.h
@@ -46,6 +46,9 @@ void do_info_spice_print(Monitor *mon, const QObject *data);
 void do_info_spice(Monitor *mon, QObject **ret_data);
 
 CharDriverState *qemu_chr_open_spice(QemuOpts *opts);
+#if SPICE_SERVER_VERSION = 0x000c02
+CharDriverState *qemu_chr_open_spice_port(QemuOpts *opts);
+#endif
 
 #else  /* CONFIG_SPICE */
 #include monitor.h
-- 
1.7.11.7




[Qemu-devel] [PATCH v3 2/2] Add GE IP-Octal 232 IndustryPack emulation

2012-12-05 Thread Alberto Garcia
The GE IP-Octal 232 is an IndustryPack module that implements eight
RS-232 serial ports, each one of which can be redirected to a
character device in the host.

Signed-off-by: Alberto Garcia agar...@igalia.com
---
 hw/Makefile.objs |2 +-
 hw/ipoctal.c |  613 ++
 2 ficheiros modificados, 614 adições(+), 1 eliminado(-)
 create mode 100644 hw/ipoctal.c

diff --git a/hw/Makefile.objs b/hw/Makefile.objs
index 2ce5ec0..b43a67e 100644
--- a/hw/Makefile.objs
+++ b/hw/Makefile.objs
@@ -105,7 +105,7 @@ common-obj-$(CONFIG_PCI) += wdt_i6300esb.o
 common-obj-$(CONFIG_PCI) += pcie.o pcie_aer.o pcie_port.o
 
 # IndustryPack
-common-obj-$(CONFIG_IPACK) += tpci200.o ipack.o
+common-obj-$(CONFIG_IPACK) += tpci200.o ipoctal.o ipack.o
 
 # PCI network cards
 common-obj-$(CONFIG_NE2000_PCI) += ne2000.o
diff --git a/hw/ipoctal.c b/hw/ipoctal.c
new file mode 100644
index 000..31a4d42
--- /dev/null
+++ b/hw/ipoctal.c
@@ -0,0 +1,613 @@
+/*
+ * QEMU GE IP-Octal 232 IndustryPack emulation
+ *
+ * Copyright (C) 2012 Igalia, S.L.
+ * Author: Alberto Garcia agar...@igalia.com
+ *
+ * This code is licensed under the GNU GPL v2 or (at your option) any
+ * later version.
+ */
+
+#include ipack.h
+#include bitops.h
+
+/* #define DEBUG_IPOCTAL */
+
+#ifdef DEBUG_IPOCTAL
+#define DPRINTF2(fmt, ...) \
+do { fprintf(stderr, fmt, ## __VA_ARGS__); } while (0)
+#else
+#define DPRINTF2(fmt, ...) do { } while (0)
+#endif
+
+#define DPRINTF(fmt, ...) DPRINTF2(IP-Octal:  fmt, ## __VA_ARGS__)
+
+#define RX_FIFO_SIZE 3
+
+/* The IP-Octal has 8 channels (a-h)
+   divided into 4 blocks (A-D) */
+#define N_CHANNELS 8
+#define N_BLOCKS   4
+
+#define REG_MRa  0x01
+#define REG_MRb  0x11
+#define REG_SRa  0x03
+#define REG_SRb  0x13
+#define REG_CSRa 0x03
+#define REG_CSRb 0x13
+#define REG_CRa  0x05
+#define REG_CRb  0x15
+#define REG_RHRa 0x07
+#define REG_RHRb 0x17
+#define REG_THRa 0x07
+#define REG_THRb 0x17
+#define REG_ACR  0x09
+#define REG_ISR  0x0B
+#define REG_IMR  0x0B
+#define REG_OPCR 0x1B
+
+#define CR_ENABLE_RXBIT(0)
+#define CR_DISABLE_RX   BIT(1)
+#define CR_ENABLE_TXBIT(2)
+#define CR_DISABLE_TX   BIT(3)
+#define CR_CMD(cr)  ((cr)  4)
+#define CR_NO_OP0
+#define CR_RESET_MR 1
+#define CR_RESET_RX 2
+#define CR_RESET_TX 3
+#define CR_RESET_ERR4
+#define CR_RESET_BRKINT 5
+#define CR_START_BRK6
+#define CR_STOP_BRK 7
+#define CR_ASSERT_RTSN  8
+#define CR_NEGATE_RTSN  9
+#define CR_TIMEOUT_ON   10
+#define CR_TIMEOUT_OFF  12
+
+#define SR_RXRDY   BIT(0)
+#define SR_FFULL   BIT(1)
+#define SR_TXRDY   BIT(2)
+#define SR_TXEMT   BIT(3)
+#define SR_OVERRUN BIT(4)
+#define SR_PARITY  BIT(5)
+#define SR_FRAMING BIT(6)
+#define SR_BREAK   BIT(7)
+
+#define ISR_TXRDYA BIT(0)
+#define ISR_RXRDYA BIT(1)
+#define ISR_BREAKA BIT(2)
+#define ISR_CNTRDY BIT(3)
+#define ISR_TXRDYB BIT(4)
+#define ISR_RXRDYB BIT(5)
+#define ISR_BREAKB BIT(6)
+#define ISR_MPICHG BIT(7)
+#define ISR_TXRDY(CH) (((CH)  1) ? BIT(4) : BIT(0))
+#define ISR_RXRDY(CH) (((CH)  1) ? BIT(5) : BIT(1))
+#define ISR_BREAK(CH) (((CH)  1) ? BIT(6) : BIT(2))
+
+typedef struct IPOctalState IPOctalState;
+typedef struct SCC2698Channel SCC2698Channel;
+typedef struct SCC2698Block SCC2698Block;
+
+struct SCC2698Channel {
+IPOctalState *ipoctal;
+CharDriverState *dev;
+char *devpath;
+bool rx_enabled;
+uint8_t mr[2];
+uint8_t mr_idx;
+uint8_t sr;
+uint8_t rhr[RX_FIFO_SIZE];
+uint8_t rhr_idx;
+uint8_t rx_pending;
+};
+
+struct SCC2698Block {
+uint8_t imr;
+uint8_t isr;
+};
+
+struct IPOctalState {
+IPackDevice dev;
+SCC2698Channel ch[N_CHANNELS];
+SCC2698Block blk[N_BLOCKS];
+uint8_t irq_vector;
+};
+
+static const VMStateDescription vmstate_scc2698_channel = {
+.name = scc2698_channel,
+.version_id = 1,
+.minimum_version_id = 1,
+.minimum_version_id_old = 1,
+.fields  = (VMStateField[]) {
+VMSTATE_BOOL(rx_enabled, SCC2698Channel),
+VMSTATE_UINT8_ARRAY(mr, SCC2698Channel, 2),
+VMSTATE_UINT8(mr_idx, SCC2698Channel),
+VMSTATE_UINT8(sr, SCC2698Channel),
+VMSTATE_UINT8_ARRAY(rhr, SCC2698Channel, RX_FIFO_SIZE),
+VMSTATE_UINT8(rhr_idx, SCC2698Channel),
+VMSTATE_UINT8(rx_pending, SCC2698Channel),
+VMSTATE_END_OF_LIST()
+}
+};
+
+static const VMStateDescription vmstate_scc2698_block = {
+.name = scc2698_block,
+.version_id = 1,
+.minimum_version_id = 1,
+.minimum_version_id_old = 1,
+.fields  = (VMStateField[]) {
+VMSTATE_UINT8(imr, SCC2698Block),
+VMSTATE_UINT8(isr, SCC2698Block),
+VMSTATE_END_OF_LIST()
+}
+};
+
+static const VMStateDescription vmstate_ipoctal = {
+.name = ipoctal232,
+.version_id = 1,
+.minimum_version_id = 1,
+.minimum_version_id_old = 1,
+.fields  = (VMStateField[]) {
+VMSTATE_IPACK_DEVICE(dev, IPOctalState),
+

Re: [Qemu-devel] [PATCH v2] target-mips: Fix incorrect shift for SHILO and SHILOV

2012-12-05 Thread Peter Maydell
On 5 December 2012 15:36, Richard Henderson r...@twiddle.net wrote:
 On 2012-12-04 17:29, Petar Jovanovic wrote:
  rs5_0 = (int8_t)(rs5_0  2)  2;

 This is more portably written as

   rs5_0 = (rs5_0 ^ 0x20) - 0x20;

...but way more obscurely. If we want to play that
kind of game can we have a sign-extension function in
a header somewhere?

-- PMM



Re: [Qemu-devel] [RFC 8/8] qom: make CPU a child of DeviceState

2012-12-05 Thread Eduardo Habkost
On Wed, Dec 05, 2012 at 03:48:10PM +0100, Andreas Färber wrote:
 Am 04.12.2012 14:19, schrieb Eduardo Habkost:
[...]
  @@ -43,7 +44,7 @@ static void cpu_class_init(ObjectClass *klass, void *data)
   
   static TypeInfo cpu_type_info = {
   .name = TYPE_CPU,
  -.parent = TYPE_OBJECT,
  +.parent = TYPE_DEVICE,
   .instance_size = sizeof(CPUState),
   .abstract = true,
   .class_size = sizeof(CPUClass),
 
 This makes the CPU a device, allowing the user to specify it with
 -device. My preference would be to disable that at first[1] by setting
 DeviceClass::no_user = 1.

I didn't know no_user existed. It makes sense to set it by now, yes.

 
 Have you tested what happens if someone tries to hotplug a CPU device?
 It may be the first device without bus...

I don't know, but I won't be surprised if stuff breaks horribly.

 
 [1] Anthony's and my idea was to handle hotplug at a higher level than
 CPUState - X86Socket containing X86Core containing X86Thread or so.

Yes, and I agree with this approach.

 This
 would require me (or someone) to refactor CPU_COMMON's numa_node (also
 used in sPAPR), nr_cores, nr_threads (also used in mips/Malta) - in a
 non-trivial way. We may need to go from CPU*State to CPUState (possible
 so far) to Core to Socket, for which object_get_parent() would be
 helpful. So far Object::parent is declared private.

Why, exactly, the CPUX86State, CPUThread, or CPUCore objects would need
to access their parents directly? We could just make sure that the
parent provide the necessary information to its children, when creating
them.

The other side of that question is: why exactly we don't allow an object
to know its parent, by design? What's the right mechanism to be used
when a device really needs to send some signal to its parent?


 Are we targetting to do this is two steps, using CPUState at first? Or
 has one of you been investigating how involved this redesign would be?

What do you mean by using CPUState at first? I mean, I think we'll
always use CPUState in the code that represents a single VCPU/thread,
and it is not going away soon. The name CPUState may be a bit
confusing, though, as it contains the state of a single VCPU/thread (not
a CPU socket).

If you are asking about qdevifying/subclassing CPUState first, I think
the answer is: yes, making it in two steps sounds better. If we use
no_user, we can more easily change the hierarchy later because there
would be nobody using -device to create CPUs yet. And if we have to
design and redo a whole socket/core/thread CPU class hierarchy first, I
don't expect us to finish doing this before QEMU 1.5[1].


When implementing an socket-based interface, I think we may end up with
something like:

- CPUSocket (or CPUPackage)
  - creates multiple CPUCore children

- CPUCore
  - creates multiple CPUThread children
  - maybe have CPUState children directly, to make things simpler

- CPUThread
  - creates one CPUState child
  - (maybe CPUState can be used directly)

- CPUState
  - the class we already have today
  - could be renamed to VCPUState or ThreadState, to make it clearer
  - CPUID data is handled here
  - CPU feature configuration is handled here
  - Will have one subclass for each CPU model


Some variations/alternatives I see:

* Just having two levels. e.g.:

- CPUSocket (or CPUPackage)
  - creates multiple CPUState children, depending on nr_cores/nr_threads
configuration

- CPUState
  - the class we already have today
  - could be renamed to VCPUState or ThreadState, to make it clearer
  - CPUID data is handled here
  - CPU feature configuration is handled here
  - Will have one subclass for each CPU model


* Having CPU model subclasses at the CPUSocket level instead of
  CPUState level
  - It would make the CPUID code really messy: some CPUID bits would
come from the CPUSocket subclass, other from the CPUState itself.
  - On the other hand, the external interface may make more sense
if we do it that way. I mean: create a 4-core SandyBridge CPU
[package] sounds more logical than create a CPU package with 4
SandyBridge threads inside it.


[1] Just to explain my expectations: what I _really_ want to have on
QEMU 1.4 is:
- A good machine-type compatibility mechanism that allows us to
  update CPU model definitions while keeping compatibility
  - Fortunately, the current global-variable-based approach kind-of
works
  - But CPU subclasses/properties would give us a cleaner solution
for free (as we could simply use machine-type global properties)
- Any interface that libvirt can use to query for CPU model
  information, including:
  - Listing available CPU models
- This exists, but it doesn't provide much detail
  - Checking which features are going to be enabled by each CPU model
  - Checking which features can really be enabled on a host
(considering QEMU + kernel + hardware capabilities)
  - CPU subclasses/properties 

[Qemu-devel] [PATCH v3 0/2] Add TPCI200 and IP-Octal 232 IndustryPack emulation

2012-12-05 Thread Alberto Garcia
As requested by Andreas, I'm sending them again as inline patches.

I also changed the name of the VMStateDescription struct from ipoctal
to ipoctal232. Otherwise they're the same.

Regards,

Alberto Garcia (2):
  Add TEWS TPCI200 IndustryPack emulation
  Add GE IP-Octal 232 IndustryPack emulation

 default-configs/pci.mak |1 +
 hw/Makefile.objs|3 +
 hw/ipack.c  |  106 
 hw/ipack.h  |   75 ++
 hw/ipoctal.c|  613 +++
 hw/pci_ids.h|3 +
 hw/tpci200.c|  667 +++
 7 ficheiros modificados, 1468 adições(+)
 create mode 100644 hw/ipack.c
 create mode 100644 hw/ipack.h
 create mode 100644 hw/ipoctal.c
 create mode 100644 hw/tpci200.c

-- 
1.7.10.4




Re: [Qemu-devel] [PATCH v2] target-mips: Fix incorrect shift for SHILO and SHILOV

2012-12-05 Thread Richard Henderson
On 2012-12-05 09:49, Peter Maydell wrote:
 On 5 December 2012 15:36, Richard Henderson r...@twiddle.net wrote:
 On 2012-12-04 17:29, Petar Jovanovic wrote:
  rs5_0 = (int8_t)(rs5_0  2)  2;

 This is more portably written as

   rs5_0 = (rs5_0 ^ 0x20) - 0x20;
 
 ...but way more obscurely. If we want to play that
 kind of game can we have a sign-extension function in
 a header somewhere?

I dunno about more obscurely.  It took me a minute to figure out
what was wanted in the original.

As for a helper function... sure.


r~




[Qemu-devel] [PATCH v3 1/2] Add TEWS TPCI200 IndustryPack emulation

2012-12-05 Thread Alberto Garcia
The TPCI200 is a PCI board that supports up to 4 IndustryPack modules.

A new bus type called 'IndustryPack' has been created so any
compatible module can be attached to this board.

Signed-off-by: Alberto Garcia agar...@igalia.com
---
 default-configs/pci.mak |1 +
 hw/Makefile.objs|3 +
 hw/ipack.c  |  106 
 hw/ipack.h  |   75 ++
 hw/pci_ids.h|3 +
 hw/tpci200.c|  667 +++
 6 ficheiros modificados, 855 adições(+)
 create mode 100644 hw/ipack.c
 create mode 100644 hw/ipack.h
 create mode 100644 hw/tpci200.c

diff --git a/default-configs/pci.mak b/default-configs/pci.mak
index ae9d1eb..ee2d18d 100644
--- a/default-configs/pci.mak
+++ b/default-configs/pci.mak
@@ -21,3 +21,4 @@ CONFIG_ESP=y
 CONFIG_ESP_PCI=y
 CONFIG_SERIAL=y
 CONFIG_SERIAL_PCI=y
+CONFIG_IPACK=y
diff --git a/hw/Makefile.objs b/hw/Makefile.objs
index d581d8d..2ce5ec0 100644
--- a/hw/Makefile.objs
+++ b/hw/Makefile.objs
@@ -104,6 +104,9 @@ common-obj-$(CONFIG_PCI) += wdt_i6300esb.o
 
 common-obj-$(CONFIG_PCI) += pcie.o pcie_aer.o pcie_port.o
 
+# IndustryPack
+common-obj-$(CONFIG_IPACK) += tpci200.o ipack.o
+
 # PCI network cards
 common-obj-$(CONFIG_NE2000_PCI) += ne2000.o
 common-obj-$(CONFIG_EEPRO100_PCI) += eepro100.o
diff --git a/hw/ipack.c b/hw/ipack.c
new file mode 100644
index 000..59e272b
--- /dev/null
+++ b/hw/ipack.c
@@ -0,0 +1,106 @@
+/*
+ * QEMU IndustryPack emulation
+ *
+ * Copyright (C) 2012 Igalia, S.L.
+ * Author: Alberto Garcia agar...@igalia.com
+ *
+ * This code is licensed under the GNU GPL v2 or (at your option) any
+ * later version.
+ */
+
+#include ipack.h
+
+IPackDevice *ipack_device_find(IPackBus *bus, int32_t slot)
+{
+BusChild *kid;
+
+QTAILQ_FOREACH(kid, bus-qbus.children, sibling) {
+DeviceState *qdev = kid-child;
+IPackDevice *ip = DO_UPCAST(IPackDevice, qdev, qdev);
+if (ip-slot == slot) {
+return ip;
+}
+}
+return NULL;
+}
+
+static int ipack_device_dev_init(DeviceState *qdev)
+{
+IPackBus *bus = DO_UPCAST(IPackBus, qbus, qdev-parent_bus);
+IPackDevice *dev = DO_UPCAST(IPackDevice, qdev, qdev);
+IPackDeviceClass *k = IPACK_DEVICE_GET_CLASS(dev);
+
+if (dev-slot  0) {
+dev-slot = bus-free_slot;
+}
+if (dev-slot = bus-n_slots) {
+return -1;
+}
+bus-free_slot = dev-slot + 1;
+
+dev-irq = qemu_allocate_irqs(bus-set_irq, dev, 2);
+
+return k-init(dev);
+}
+
+static int ipack_device_dev_exit(DeviceState *qdev)
+{
+IPackDevice *dev = DO_UPCAST(IPackDevice, qdev, qdev);
+IPackDeviceClass *k = IPACK_DEVICE_GET_CLASS(dev);
+
+if (k-exit) {
+k-exit(dev);
+}
+
+qemu_free_irqs(dev-irq);
+
+return 0;
+}
+
+static Property ipack_device_props[] = {
+DEFINE_PROP_INT32(slot, IPackDevice, slot, -1),
+DEFINE_PROP_END_OF_LIST()
+};
+
+static void ipack_device_class_init(ObjectClass *klass, void *data)
+{
+DeviceClass *k = DEVICE_CLASS(klass);
+k-bus_type = TYPE_IPACK_BUS;
+k-init = ipack_device_dev_init;
+k-exit = ipack_device_dev_exit;
+k-props = ipack_device_props;
+}
+
+const VMStateDescription vmstate_ipack_device = {
+.name = ipack_device,
+.version_id = 1,
+.minimum_version_id = 1,
+.minimum_version_id_old = 1,
+.fields  = (VMStateField[]) {
+VMSTATE_INT32(slot, IPackDevice),
+VMSTATE_END_OF_LIST()
+}
+};
+
+static const TypeInfo ipack_device_info = {
+.name  = TYPE_IPACK_DEVICE,
+.parent= TYPE_DEVICE,
+.instance_size = sizeof(IPackDevice),
+.class_size= sizeof(IPackDeviceClass),
+.class_init= ipack_device_class_init,
+.abstract  = true,
+};
+
+static const TypeInfo ipack_bus_info = {
+.name = TYPE_IPACK_BUS,
+.parent = TYPE_BUS,
+.instance_size = sizeof(IPackBus),
+};
+
+static void ipack_register_types(void)
+{
+type_register_static(ipack_device_info);
+type_register_static(ipack_bus_info);
+}
+
+type_init(ipack_register_types)
diff --git a/hw/ipack.h b/hw/ipack.h
new file mode 100644
index 000..61a9019
--- /dev/null
+++ b/hw/ipack.h
@@ -0,0 +1,75 @@
+/*
+ * QEMU IndustryPack emulation
+ *
+ * Copyright (C) 2012 Igalia, S.L.
+ * Author: Alberto Garcia agar...@igalia.com
+ *
+ * This code is licensed under the GNU GPL v2 or (at your option) any
+ * later version.
+ */
+
+#ifndef QEMU_IPACK_H
+#define QEMU_IPACK_H
+
+#include qdev.h
+
+typedef struct IPackBus IPackBus;
+
+#define TYPE_IPACK_BUS IndustryPack
+#define IPACK_BUS(obj) OBJECT_CHECK(IPackBus, (obj), TYPE_IPACK_BUS)
+
+struct IPackBus {
+BusState qbus;
+uint8_t n_slots;
+uint8_t free_slot;
+qemu_irq_handler set_irq;
+};
+
+typedef struct IPackDevice IPackDevice;
+typedef struct IPackDeviceClass IPackDeviceClass;
+
+#define TYPE_IPACK_DEVICE ipack-device
+#define IPACK_DEVICE(obj) \
+ OBJECT_CHECK(IPackDevice, (obj), 

[Qemu-devel] [PATCH 6/6] docs: add spice-port-fqdn.txt

2012-12-05 Thread Marc-André Lureau
Start a simple org.qemu.* registry of well known name.
---
 docs/spice-port-fqdn.txt | 19 +++
 1 file changed, 19 insertions(+)
 create mode 100644 docs/spice-port-fqdn.txt

diff --git a/docs/spice-port-fqdn.txt b/docs/spice-port-fqdn.txt
new file mode 100644
index 000..5077895
--- /dev/null
+++ b/docs/spice-port-fqdn.txt
@@ -0,0 +1,19 @@
+A Spice port channel is an arbitrary communication between the Spice
+server host side and the client side.
+
+Thanks to the associated reverse fully qualified domain name (fqdn),
+a Spice client can handle the various ports appropriately.
+
+The following fqdn names are reserved by the QEMU project:
+
+org.qemu.monitor.hmp.0
+  QEMU human monitor
+
+org.qemu.monitor.qmp.0:
+  QEMU control monitor
+
+org.qemu.console.serial.0
+  QEMU virtual serial port
+
+org.qemu.console.debug.0
+  QEMU debug console
-- 
1.7.11.7




Re: [Qemu-devel] [PATCH 2/6] target-i386: cpu: separate feature string parsing from CPU model lookup

2012-12-05 Thread Andreas Färber
Am 04.12.2012 20:34, schrieb Eduardo Habkost:
 Instead of using parsing the whole cpu_model string inside

Dropped using.

 cpu_x86_find_by_name(), first split it into the CPU model name and the
 full feature string, then parse the feature string into pieces.
[...]
 diff --git a/target-i386/cpu.c b/target-i386/cpu.c
 index 7afe839..70ba323 100644
 --- a/target-i386/cpu.c
 +++ b/target-i386/cpu.c
 @@ -1208,25 +1208,10 @@ static void x86_cpuid_set_tsc_freq(Object *obj, 
 Visitor *v, void *opaque,
  cpu-env.tsc_khz = value / 1000;
  }
  
 -static int cpu_x86_find_by_name(x86_def_t *x86_cpu_def, const char 
 *cpu_model)
 +static int cpu_x86_find_by_name(x86_def_t *x86_cpu_def, const char *name)
  {
 -unsigned int i;
  x86_def_t *def;
  
 -char *s = g_strdup(cpu_model);
 -char *featurestr, *name = strtok(s, ,);
 -/* Features to be added*/
[...]
 @@ -1235,16 +1220,37 @@ static int cpu_x86_find_by_name(x86_def_t 
 *x86_cpu_def, const char *cpu_model)
  if (kvm_enabled()  name  strcmp(name, host) == 0) {
  kvm_cpu_fill_host(x86_cpu_def);
  } else if (!def) {
 -goto error;
 +return -1;
  } else {
  memcpy(x86_cpu_def, def, sizeof(*def));
  }
  
 +return 0;
 +}
 +
 +/* Parse +feature,-feature,feature=foo CPU feature string
 + */
 +static int cpu_x86_parse_featurestr(x86_def_t *x86_cpu_def, char *features)
 +{
 +unsigned int i;
 +char *featurestr; /* Single 'key=value string being parsed */
 +/* Features to be added*/

I took the liberty of adding a space above by editing patches 1  2.

Also, in Linux, multi-level topics such as PPC: KVM:  seem to be
common, whereas in QEMU we've been using paths (tcg/ppc: ); Anthony
has once used isa: pic:  when he meant affecting both isa and pic
(8f04ee0882aec9fe91fb70f767edf5dacff59835), so since this does not touch
on the QOM cpu.c that I usually label cpu: , in a previous case I have
edited your patch as target-i386/cpu: , but since this subject
redundantly mentions CPU later on I'm dropping it. Hope this explains
the rationale! Generally I found the GNOME guidelines pretty convincing:
https://live.gnome.org/Git/CommitMessages
(capitalizing after the lowercase topic makes the main message stand out
when reading through shortlogs IMO)

Thanks, applied patches 1-2 to qom-cpu:
https://github.com/afaerber/qemu-cpu/commits/qom-cpu

Andreas

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg



Re: [Qemu-devel] [PATCH 24/37] target-i386: use define for cpuid vendor string size

2012-12-05 Thread Andreas Färber
Am 22.10.2012 17:03, schrieb Igor Mammedov:
 Signed-off-by: Igor Mammedov imamm...@redhat.com

Thanks, applied to qom-cpu:
https://github.com/afaerber/qemu-cpu/commits/qom-cpu

Andreas

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg



Re: [Qemu-devel] [PATCH 14/37] target-i386: postpone cpuid_level update to realize time

2012-12-05 Thread Andreas Färber
Am 22.10.2012 17:03, schrieb Igor Mammedov:
 delay capping cpuid_level to 7 to realize time so property setters
 for cpuid_7_0_ebx_features and level could be used in any order/time
 between x86_cpu_initfn() and x86_cpu_realize().
 
 Signed-off-by: Igor Mammedov imamm...@redhat.com

Thanks, rebased and applied to qom-cpu:
https://github.com/afaerber/qemu-cpu/commits/qom-cpu

Andreas

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg



Re: [Qemu-devel] [PATCH 0/6] short x86 CPU init cleanup (v3)

2012-12-05 Thread Andreas Färber
Am 04.12.2012 20:34, schrieb Eduardo Habkost:
 Igor Mammedov (4):
   target-i386: use define for cpuid vendor string size
   target-i386: postpone cpuid_level update to realize time

Applied Igor's earlier signed off versions of these to qom-cpu, spotting
no semantic difference:
https://github.com/afaerber/qemu-cpu/commits/qom-cpu

Still waiting on an ack for the new freq visitor.

Andreas

   add visitor for parsing hz[KMG] input string
   target-i386: use visit_type_hz to parse tsc_freq property value
 
  qapi/qapi-visit-core.c  |  11 +
  qapi/qapi-visit-core.h  |   2 +
  qapi/string-input-visitor.c |  22 ++
  target-i386/cpu.c   | 105 
 
  target-i386/cpu.h   |   2 +
  5 files changed, 103 insertions(+), 39 deletions(-)

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg



Re: [Qemu-devel] [RFC PATCH v5 6/6] virtio-blk : Refactor virtio-blk.

2012-12-05 Thread Peter Maydell
On 4 December 2012 14:35,  fred.kon...@greensocs.com wrote:
 From: KONRAD Frederic fred.kon...@greensocs.com

 Create virtio-blk which extends virtio-device, so it can be connected on
 virtio-bus.

 Signed-off-by: KONRAD Frederic fred.kon...@greensocs.com
 ---
  hw/virtio-blk.c | 170 
 
  hw/virtio-blk.h |   4 ++
  2 files changed, 150 insertions(+), 24 deletions(-)

 diff --git a/hw/virtio-blk.c b/hw/virtio-blk.c
 index e25cc96..ee1ea8b 100644
 --- a/hw/virtio-blk.c
 +++ b/hw/virtio-blk.c
 @@ -21,24 +21,42 @@
  #ifdef __linux__
  # include scsi/sg.h
  #endif
 +#include virtio-bus.h

 +/* Take this structure as our device structure. */
  typedef struct VirtIOBlock
  {
 +/*
 + * Adding parent_obj breaks to_virtio_blk cast function,
 + * and virtio_blk_init.
 + */
 +DeviceState parent_obj;
 +/*
 + * We don't need that anymore, as we'll use QOM cast to get the
 + * VirtIODevice. Just temporary keep it, for not breaking functionality.
 + */
  VirtIODevice vdev;

This doesn't make sense. After your previous patch, VirtIODevice
is-a DeviceState, and VirtIOBlock already is-a VirtIODevice,
so there's nothing to do here. Adding this parent_obj field
here is just breaking things (it would make the VirtIOBlock
into a direct child of DeviceState, which isn't what we want).

  BlockDriverState *bs;
  VirtQueue *vq;
  void *rq;
  QEMUBH *bh;
  BlockConf *conf;
 -VirtIOBlkConf *blk;
 +/*
 + * We can't use pointer with properties.
 + */
 +VirtIOBlkConf blk;
  unsigned short sector_mask;
  DeviceState *qdev;
  } VirtIOBlock;

 -static VirtIOBlock *to_virtio_blk(VirtIODevice *vdev)
 -{
 -return (VirtIOBlock *)vdev;
 -}
 +/*
 + * Use the QOM cast, so we don't need that anymore.
 + *
 + * static VirtIOBlock *to_virtio_blk(VirtIODevice *vdev)
 + * {
 + * return (VirtIOBlock *)vdev;
 + * }
 + */

If we don't need it, just delete it.

-- PMM



[Qemu-devel] [PULL] VirtFS update

2012-12-05 Thread Aneesh Kumar K.V

The following changes since commit 16c6c80ac3a772b42a87b77dfdf0fdac7c607b0e:

  Open up 1.4 development branch (2012-12-03 14:08:40 -0600)

are available in the git repository at:

  git://github.com/kvaneesh/qemu.git for-upstream

for you to fetch changes up to 9fd2ecdc8cb2dc1a8a7c57b6c9c60bc9947b6a73:

  virtfs-proxy-helper: use setresuid and setresgid (2012-12-05 21:55:54 +0530)


Paolo Bonzini (1):
  virtfs-proxy-helper: use setresuid and setresgid

 fsdev/virtfs-proxy-helper.c |   93 +--
 1 file changed, 64 insertions(+), 29 deletions(-)

diff --git a/fsdev/virtfs-proxy-helper.c b/fsdev/virtfs-proxy-helper.c
index f9a8270..df2a939 100644
--- a/fsdev/virtfs-proxy-helper.c
+++ b/fsdev/virtfs-proxy-helper.c
@@ -272,31 +272,76 @@ static int send_status(int sockfd, struct iovec *iovec, 
int status)
 /*
  * from man 7 capabilities, section
  * Effect of User ID Changes on Capabilities:
- * 4. If the file system user ID is changed from 0 to nonzero (see setfsuid(2))
- * then the following capabilities are cleared from the effective set:
- * CAP_CHOWN, CAP_DAC_OVERRIDE, CAP_DAC_READ_SEARCH,  CAP_FOWNER, CAP_FSETID,
- * CAP_LINUX_IMMUTABLE  (since  Linux 2.2.30), CAP_MAC_OVERRIDE, and CAP_MKNOD
- * (since Linux 2.2.30). If the file system UID is changed from nonzero to 0,
- * then any of these capabilities that are enabled in the permitted set
- * are enabled in the effective set.
+ * If the effective user ID is changed from nonzero to 0, then the permitted
+ * set is copied to the effective set.  If the effective user ID is changed
+ * from 0 to nonzero, then all capabilities are are cleared from the effective
+ * set.
+ *
+ * The setfsuid/setfsgid man pages warn that changing the effective user ID may
+ * expose the program to unwanted signals, but this is not true anymore: for an
+ * unprivileged (without CAP_KILL) program to send a signal, the real or
+ * effective user ID of the sending process must equal the real or saved user
+ * ID of the target process.  Even when dropping privileges, it is enough to
+ * keep the saved UID to a privileged value and virtfs-proxy-helper won't
+ * be exposed to signals.  So just use setresuid/setresgid.
  */
-static int setfsugid(int uid, int gid)
+static int setugid(int uid, int gid, int *suid, int *sgid)
 {
+int retval;
+
 /*
- * We still need DAC_OVERRIDE because  we don't change
+ * We still need DAC_OVERRIDE because we don't change
  * supplementary group ids, and hence may be subjected DAC rules
  */
 cap_value_t cap_list[] = {
 CAP_DAC_OVERRIDE,
 };
 
-setfsgid(gid);
-setfsuid(uid);
+*suid = geteuid();
+*sgid = getegid();
+
+if (setresgid(-1, gid, *sgid) == -1) {
+retval = -errno;
+goto err_out;
+}
+
+if (setresuid(-1, uid, *suid) == -1) {
+retval = -errno;
+goto err_sgid;
+}
 
 if (uid != 0 || gid != 0) {
-return do_cap_set(cap_list, ARRAY_SIZE(cap_list), 0);
+if (do_cap_set(cap_list, ARRAY_SIZE(cap_list), 0)  0) {
+retval = -errno;
+goto err_suid;
+}
 }
 return 0;
+
+err_suid:
+if (setresuid(-1, *suid, *suid) == -1) {
+abort();
+}
+err_sgid:
+if (setresgid(-1, *sgid, *sgid) == -1) {
+abort();
+}
+err_out:
+return retval;
+}
+
+/*
+ * This is used to reset the ugid back with the saved values
+ * There is nothing much we can do checking error values here.
+ */
+static void resetugid(int suid, int sgid)
+{
+if (setresgid(-1, sgid, sgid) == -1) {
+abort();
+}
+if (setresuid(-1, suid, suid) == -1) {
+abort();
+}
 }
 
 /*
@@ -578,18 +623,15 @@ static int do_create_others(int type, struct iovec *iovec)
 
 v9fs_string_init(path);
 v9fs_string_init(oldpath);
-cur_uid = geteuid();
-cur_gid = getegid();
 
 retval = proxy_unmarshal(iovec, offset, dd, uid, gid);
 if (retval  0) {
 return retval;
 }
 offset += retval;
-retval = setfsugid(uid, gid);
+retval = setugid(uid, gid, cur_uid, cur_gid);
 if (retval  0) {
-retval = -errno;
-goto err_out;
+goto unmarshal_err_out;
 }
 switch (type) {
 case T_MKNOD:
@@ -619,9 +661,10 @@ static int do_create_others(int type, struct iovec *iovec)
 }
 
 err_out:
+resetugid(cur_uid, cur_gid);
+unmarshal_err_out:
 v9fs_string_free(path);
 v9fs_string_free(oldpath);
-setfsugid(cur_uid, cur_gid);
 return retval;
 }
 
@@ -641,24 +684,16 @@ static int do_create(struct iovec *iovec)
 if (ret  0) {
 goto unmarshal_err_out;
 }
-cur_uid = geteuid();
-cur_gid = getegid();
-ret = setfsugid(uid, gid);
+ret = setugid(uid, gid, cur_uid, cur_gid);
 if (ret  0) {
-/*
- * On failure reset back to the
- * old uid/gid
- */
-ret = -errno;
-   

Re: [Qemu-devel] [PATCH v2] target-mips: Fix incorrect shift for SHILO and SHILOV

2012-12-05 Thread Peter Maydell
On 5 December 2012 15:51, Richard Henderson r...@twiddle.net wrote:
 On 2012-12-05 09:49, Peter Maydell wrote:
 On 5 December 2012 15:36, Richard Henderson r...@twiddle.net wrote:
 On 2012-12-04 17:29, Petar Jovanovic wrote:
  rs5_0 = (int8_t)(rs5_0  2)  2;

 This is more portably written as

   rs5_0 = (rs5_0 ^ 0x20) - 0x20;

 ...but way more obscurely. If we want to play that
 kind of game can we have a sign-extension function in
 a header somewhere?

 I dunno about more obscurely.  It took me a minute to figure out
 what was wanted in the original.

 As for a helper function... sure.

I don't think we should block this patch on that general
cleanup, though. All the sign extensions in target-mips/translate.c
are done in the double-shift way, so this is consistent with
the existing code.

-- PMM



[Qemu-devel] [PATCH 0/8] CPU DeviceState v10

2012-12-05 Thread Eduardo Habkost
Changes on v10:
 - Set no_user=1 on CPU class
 - Coding style fixes
 - Sending as PATCH instead of RFC, now

v9:
 - Instead of moving qemu_[un]register_reset() to reset.c and including
   it on *-user, create stubs for them on libqemustub.a
 - This is based on afaerber's qom-cpu branch, that has some header cleanup
   changes. You can get the complete series in a git tree at:
   https://github.com/ehabkost/qemu-hacks/tree/cpu_qdev.v9
   git://github.com/ehabkost/qemu-hacks.git cpu_qdev.v9

v8:
 - Use a simpler copyright header on qdev-properties-system.c
 - Use the new libqemustub.a mechanism instead of the (now exting)
   QEMU_WEAK_ALIAS mechanism
 - Move the reset-handler registration code to a new hw/reset.c file

v7:
 - Use the new QEMU_WEAK_ALIAS mechanism instead of the (now extinct)
   GCC_WEAK attribute (patches 20 and 21)

v6:
 - Simple rebase against latest qemu.git master
 - Patch 13: some new typedefs were added and others were removed
 - Patch 19: trivial rebase

v5:
 - Tons of header cleanups just to eliminate qlist.h - cpu-common.h circular
   dependency (patches 1-17)
 - Add copyright/license information to qdev-properties.c (patch 17)
 - Add copyright/license information to qdev-properties-system.c (patch 22)
 - use error_report()+abort() instead of hw_error() on qdev.c (patch 18)
 - Move qemu_[un]register_reset() and qemu_devices_reset() to qdev-core.c
   (patch 19)
 - Make vmstate_[un]register() weak stubs, instead of a new function (patch 20)
 - Make sysbus_get_default() weak stub, instead of new qbus reset (un)register
   functions (patch 21)
 - Eliminate qdev-system.c (all code is kept on qdev.c, now) (patch 22)

v4:
  - Add GCC_WEAK_DECL to functions that have GCC_WEAK versions
  - Updated the qdev_init_gpio_in() code on qdev-system.c to current version
  - Patch description updates (moved changelog below --- and/or move info
about changes made by different authors between SoB lines)

v3 (submitted by Igor):
  - rebased on top of 8b4a3df (today's master)
  - slight code reshuffling in (see commit's changelog)
 qdev: separate core from the code used only by qemu-system-*
 move qemu_irq typedef out of cpu-common.h
  - commit messages cleanup

v2:
  Removes the CONFIG_USER_ONLY ifdefs, and use weak symbols to move
  the vmstate and qemu_register_reset() handling to qdev-system.c


git tree for testing:
  https://github.com/ehabkost/qemu-hacks/tree/cpu_qdev.v10
  git://github.com/ehabkost/qemu-hacks.git cpu_qdev.v10

References to previous versions:
  v9: http://marc.info/?l=qemu-develm=135462995431137
  v8: http://article.gmane.org/gmane.comp.emulators.qemu/182589
  v7: http://article.gmane.org/gmane.comp.emulators.qemu/179969
  v6: http://article.gmane.org/gmane.comp.emulators.qemu/179918
  v5: http://article.gmane.org/gmane.comp.emulators.qemu/177426
  v4: http://article.gmane.org/gmane.comp.emulators.qemu/176127
  v3: http://article.gmane.org/gmane.comp.emulators.qemu/175980
  v2: http://article.gmane.org/gmane.comp.emulators.qemu/173909
  v1: http://article.gmane.org/gmane.comp.emulators.qemu/166630


Eduardo Habkost (8):
  Move -I$(SRC_PATH)/include compiler flag to Makefile.objs
  libqemustub: Add qemu_[un]register_reset() stubs
  libqemustub: vmstate register/unregister stubs
  libqemustub: sysbus_get_default() stub
  qdev: Coding style fixes
  qdev-properties.c: Separate core from the code used only by
qemu-system-*
  include qdev code into *-user, too
  qom: Make CPU a child of DeviceState

 Makefile|   1 -
 Makefile.objs   |  23 ++-
 hw/Makefile.objs|  10 +-
 hw/qdev-properties-system.c | 358 
 hw/qdev-properties.c| 356 +++
 hw/qdev-properties.h|   1 +
 hw/qdev.c   |  13 --
 include/qemu/cpu.h  |   6 +-
 qom/cpu.c   |   5 +-
 stubs/Makefile.objs |   3 +
 stubs/reset.c   |  13 ++
 stubs/sysbus.c  |   6 +
 stubs/vmstate.c |  17 +++
 13 files changed, 454 insertions(+), 358 deletions(-)
 create mode 100644 hw/qdev-properties-system.c
 create mode 100644 stubs/reset.c
 create mode 100644 stubs/sysbus.c
 create mode 100644 stubs/vmstate.c

-- 
1.7.11.7




[Qemu-devel] [PATCH 4/8] libqemustub: sysbus_get_default() stub

2012-12-05 Thread Eduardo Habkost
The stub will be used on cases where sysbus.c is not compiled in (e.g.
*-user).

Note that code that uses NULL as the bus with qdev{_try,}_create()
implicitly uses sysbus_get_default() as the bus, and will still require
sysbus.c to be compiled in.

Signed-off-by: Eduardo Habkost ehabk...@redhat.com
---
Changes v1 - v2:
 - Use the new QEMU_WEAK_ALIAS mechanism, instead of GCC_WEAK

Changes v2 - v3:
 - Use the new libqemustub.a mechanism, instead of QEMU_WEAK_ALIAS
---
 stubs/Makefile.objs | 1 +
 stubs/sysbus.c  | 6 ++
 2 files changed, 7 insertions(+)
 create mode 100644 stubs/sysbus.c

diff --git a/stubs/Makefile.objs b/stubs/Makefile.objs
index ca2197e..7672c69 100644
--- a/stubs/Makefile.objs
+++ b/stubs/Makefile.objs
@@ -7,4 +7,5 @@ stub-obj-y += get-fd.o
 stub-obj-y += set-fd-handler.o
 stub-obj-y += reset.o
 stub-obj-y += vmstate.o
+stub-obj-y += sysbus.o
 stub-obj-$(CONFIG_WIN32) += fd-register.o
diff --git a/stubs/sysbus.c b/stubs/sysbus.c
new file mode 100644
index 000..e134965
--- /dev/null
+++ b/stubs/sysbus.c
@@ -0,0 +1,6 @@
+#include hw/qdev-core.h
+
+BusState *sysbus_get_default(void)
+{
+return NULL;
+}
-- 
1.7.11.7




[Qemu-devel] [PATCH 8/8] qom: Make CPU a child of DeviceState

2012-12-05 Thread Eduardo Habkost
This finally makes the CPU class a child of DeviceState, allowing us to
start using DeviceState properties on CPU subclasses.

It has no_user=1, as creating CPUs using -device doesn't work yet.

(based on a previous patch from Igor Mammedov)

Signed-off-by: Eduardo Habkost ehabk...@redhat.com
---
Changes v1 (imammedo) - v2 (ehabkost):
 - Change CPU type declaration to hae TYPE_DEVICE as parent

Changes v2 - v3 (ehabkost):
 - Set no_user=1 on the CPU class
---
 include/qemu/cpu.h | 6 +++---
 qom/cpu.c  | 5 -
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/include/qemu/cpu.h b/include/qemu/cpu.h
index 61b7698..bc004fd 100644
--- a/include/qemu/cpu.h
+++ b/include/qemu/cpu.h
@@ -20,7 +20,7 @@
 #ifndef QEMU_CPU_H
 #define QEMU_CPU_H
 
-#include qemu/object.h
+#include hw/qdev-core.h
 #include qemu-thread.h
 
 /**
@@ -46,7 +46,7 @@ typedef struct CPUState CPUState;
  */
 typedef struct CPUClass {
 /* private */
-ObjectClass parent_class;
+DeviceClass parent_class;
 /* public */
 
 void (*reset)(CPUState *cpu);
@@ -62,7 +62,7 @@ typedef struct CPUClass {
  */
 struct CPUState {
 /* private */
-Object parent_obj;
+DeviceState parent_obj;
 /* public */
 
 struct QemuThread *thread;
diff --git a/qom/cpu.c b/qom/cpu.c
index 5b36046..d301f72 100644
--- a/qom/cpu.c
+++ b/qom/cpu.c
@@ -20,6 +20,7 @@
 
 #include qemu/cpu.h
 #include qemu-common.h
+#include hw/qdev-core.h
 
 void cpu_reset(CPUState *cpu)
 {
@@ -36,14 +37,16 @@ static void cpu_common_reset(CPUState *cpu)
 
 static void cpu_class_init(ObjectClass *klass, void *data)
 {
+DeviceClass *dc = DEVICE_CLASS(klass);
 CPUClass *k = CPU_CLASS(klass);
 
 k-reset = cpu_common_reset;
+dc-no_user = 1;
 }
 
 static TypeInfo cpu_type_info = {
 .name = TYPE_CPU,
-.parent = TYPE_OBJECT,
+.parent = TYPE_DEVICE,
 .instance_size = sizeof(CPUState),
 .abstract = true,
 .class_size = sizeof(CPUClass),
-- 
1.7.11.7




[Qemu-devel] [PATCH 7/8] include qdev code into *-user, too

2012-12-05 Thread Eduardo Habkost
The code depends on some functions from qemu-option.o, so add
qemu-option.o to universal-obj-y to make sure it's included.

Signed-off-by: Eduardo Habkost ehabk...@redhat.com
---
Changes v1 - v2:
 - Keep files on the hw/ directory
   (it's simply easier to keep them there, as qdev.o depends on irq.o)
 - Add a $(hw-core-obj-y) variable to Makefile.objs for the qdev core code
 - Add irq.o to the list of core qdev files
   (as now the gpio code is being kept inside qdev.c)

Changes v2 - v3:
 - Add reset.o to hw-core-obj-y

Changes v3 - v4:
 - Removed reset.o again (it was replaced by stubs on libqemustub.a)
---
 Makefile.objs| 8 
 hw/Makefile.objs | 9 +++--
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/Makefile.objs b/Makefile.objs
index 0a0a33a..8fe4991 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -31,6 +31,13 @@ qom-obj-y = qom/
 universal-obj-y += $(qom-obj-y)
 
 ###
+# Core hw code (qdev core)
+hw-core-obj-y += hw/
+hw-core-obj-y += qemu-option.o
+
+universal-obj-y += $(hw-core-obj-y)
+
+###
 # oslib-obj-y is code depending on the OS (win32 vs posix)
 oslib-obj-y = osdep.o cutils.o qemu-timer-common.o
 oslib-obj-$(CONFIG_WIN32) += oslib-win32.o qemu-thread-win32.o
@@ -253,5 +260,6 @@ nested-vars += \
block-obj-y \
user-obj-y \
common-obj-y \
+   hw-core-obj-y \
extra-obj-y
 dummy := $(call unnest-vars)
diff --git a/hw/Makefile.objs b/hw/Makefile.objs
index 96a8365..1815536 100644
--- a/hw/Makefile.objs
+++ b/hw/Makefile.objs
@@ -1,3 +1,9 @@
+# core qdev-related obj files, also used by *-user:
+hw-core-obj-y += qdev.o qdev-properties.o
+# irq.o needed for qdev GPIO handling:
+hw-core-obj-y += irq.o
+
+
 common-obj-y = usb/ ide/
 common-obj-y += loader.o
 common-obj-$(CONFIG_VIRTIO) += virtio-console.o
@@ -158,7 +164,6 @@ common-obj-$(CONFIG_SOUND) += $(sound-obj-y)
 common-obj-$(CONFIG_REALLY_VIRTFS) += 9pfs/
 
 common-obj-y += usb/
-common-obj-y += irq.o
 common-obj-$(CONFIG_PTIMER) += ptimer.o
 common-obj-$(CONFIG_MAX7310) += max7310.o
 common-obj-$(CONFIG_WM8750) += wm8750.o
@@ -184,7 +189,7 @@ common-obj-$(CONFIG_SD) += sd.o
 common-obj-y += bt.o bt-l2cap.o bt-sdp.o bt-hci.o bt-hid.o
 common-obj-y += bt-hci-csr.o
 common-obj-y += msmouse.o ps2.o
-common-obj-y += qdev.o qdev-properties.o qdev-monitor.o
+common-obj-y += qdev-monitor.o
 common-obj-y += qdev-properties-system.o
 common-obj-$(CONFIG_BRLAPI) += baum.o
 
-- 
1.7.11.7




[Qemu-devel] [PATCH 1/8] Move -I$(SRC_PATH)/include compiler flag to Makefile.objs

2012-12-05 Thread Eduardo Habkost
The flag is necessary for code that doesn't use the variables from
Makefile (but use Makefile.objs), like libcacard/ and stubs/.

This also moves the existing CFLAGS lines from Makefile.objs at the
beginning of the file, to keep them all in the same place.

Signed-off-by: Eduardo Habkost ehabk...@redhat.com
---
 Makefile  |  1 -
 Makefile.objs | 15 +--
 2 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/Makefile b/Makefile
index 9ecbcbb..739d9cd 100644
--- a/Makefile
+++ b/Makefile
@@ -145,7 +145,6 @@ audio/audio.o audio/fmodaudio.o: QEMU_CFLAGS += 
$(FMOD_CFLAGS)
 
 QEMU_CFLAGS+=$(CURL_CFLAGS)
 
-QEMU_CFLAGS += -I$(SRC_PATH)/include
 
 ui/cocoa.o: ui/cocoa.m
 
diff --git a/Makefile.objs b/Makefile.objs
index 3c7abca..0a0a33a 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -1,4 +1,13 @@
 ###
+# general compiler flags
+
+QEMU_CFLAGS += $(GLIB_CFLAGS)
+QEMU_CFLAGS += -I$(SRC_PATH)/include
+
+vl.o: QEMU_CFLAGS+=$(GPROF_CFLAGS)
+vl.o: QEMU_CFLAGS+=$(SDL_CFLAGS)
+
+###
 # Stub library, linked in tools
 stub-obj-y = stubs/
 
@@ -236,12 +245,6 @@ universal-obj-y += $(qapi-obj-y)
 qga-obj-y = qga/ qemu-ga.o module.o qemu-tool.o
 qga-obj-$(CONFIG_POSIX) += qemu-sockets.o qemu-option.o
 
-vl.o: QEMU_CFLAGS+=$(GPROF_CFLAGS)
-
-vl.o: QEMU_CFLAGS+=$(SDL_CFLAGS)
-
-QEMU_CFLAGS+=$(GLIB_CFLAGS)
-
 nested-vars += \
stub-obj-y \
qga-obj-y \
-- 
1.7.11.7




Re: [Qemu-devel] [PULL 00/18] acpi: switch to memory api

2012-12-05 Thread Andreas Färber
Am 04.12.2012 17:05, schrieb Gerd Hoffmann:
 On 12/04/12 16:57, Andreas Färber wrote:
 Am 04.12.2012 14:04, schrieb Gerd Hoffmann:
 Same patches as posted last week.  No review comments, 1.4 tree
 open, so it should be ready to go in now.

 That's not quite true - you ignored my review comment wrt MemoryRegion
 placement (and I left it to you to look for further instances). Can you
 please fix that up on your branch or as follow-up?
 
 You mean that empty line after parent_object?  I can send a followup for
 that one.
 
 Why it is important btw?  Just style?  Some parser tool?

Mainly style: QOM uses the parent's struct as field to block the memory
but otherwise attempts to hide this field from users:

/* private */
FooState parent_obj;
/* public */

Bar baz;
...

In the past I found places where this was mangled up and the parent
field was not the first field as it needs to be, not caught by the qdev
macros.

I have hopes that when we preprocess for QIDL we can also improve the
vtable situation, possibly inserting the parents' fields individually.
Either way my don't-touch-the-parent cleanups will turn useful. ;)

 Can we make
 checkpatch.pl check this?

Maybe? I wouldn't know where or how since it's not within one line...
And last time I attempted to change checkpatch.pl, my patches were
turned down. :(

 Did you see any overlap with Julien's series or can I post my PULL in
 parallel?
 
 Given that you kicked out the acpi changes due to q35 merge conflicts it
 should work in parallel as my series touches acpi only.  Havn't actually
 tried to merge though.

Just found out that the apm patch trivially conflicts (hw/lpc_ich9.c) -
you added a notifier whereas Julien changed apm_init() signature.
I can update my branch once Anthony has pulled yours.

Cheers,
Andreas

 A small followup is needed once both are in: replace get_system_io()
 with the new isa_address_space() in the acpi code.

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg



[Qemu-devel] [PATCH 3/8] libqemustub: vmstate register/unregister stubs

2012-12-05 Thread Eduardo Habkost
Add vmstate stub functions, so that qdev.o can be used without savevm.o
when vmstate support is not necessary (i.e. by *-user).

Signed-off-by: Eduardo Habkost ehabk...@redhat.com
---
Originally submitted as:
  Subject: qdev-core: isolate vmstate handling into separate functions

Changes v1 - v2:
 - Add GCC_WEAK_DECL to function declarations

Changes v2 - v3:
 - Subject: qdev: add weak aliases for vmstate handling on qdev.c
 - Make vmstate_register_with_alias_id()/vmstate_unregister()
   have GCC_WEAK versions, instead of creating a new function
 - Kept qdev_get_vmsd() inside qdev.c

Changss v3 - v4:
 - Use the new QEMU_WEAK_ALIAS system instead of GCC_WEAK

Changes v4 - v5:
 - Use the new libqemustub.a, instead of QEMU_WEAK_ALIAS

Changes v5 - v6:
 - Cosmetic whitespace changes
---
 stubs/Makefile.objs |  1 +
 stubs/vmstate.c | 17 +
 2 files changed, 18 insertions(+)
 create mode 100644 stubs/vmstate.c

diff --git a/stubs/Makefile.objs b/stubs/Makefile.objs
index 00f0b64..ca2197e 100644
--- a/stubs/Makefile.objs
+++ b/stubs/Makefile.objs
@@ -6,4 +6,5 @@ stub-obj-y += fdset-remove-fd.o
 stub-obj-y += get-fd.o
 stub-obj-y += set-fd-handler.o
 stub-obj-y += reset.o
+stub-obj-y += vmstate.o
 stub-obj-$(CONFIG_WIN32) += fd-register.o
diff --git a/stubs/vmstate.c b/stubs/vmstate.c
new file mode 100644
index 000..badf79e
--- /dev/null
+++ b/stubs/vmstate.c
@@ -0,0 +1,17 @@
+#include qemu-common.h
+#include vmstate.h
+
+int vmstate_register_with_alias_id(DeviceState *dev,
+   int instance_id,
+   const VMStateDescription *vmsd,
+   void *base, int alias_id,
+   int required_for_version)
+{
+return 0;
+}
+
+void vmstate_unregister(DeviceState *dev,
+const VMStateDescription *vmsd,
+void *opaque)
+{
+}
-- 
1.7.11.7




[Qemu-devel] [PATCH 6/8] qdev-properties.c: Separate core from the code used only by qemu-system-*

2012-12-05 Thread Eduardo Habkost
This separates the qdev properties code in two parts:
 - qdev-properties.c, that contains most of the qdev properties code;
 - qdev-properties-system.c for code specific for qemu-system-*,
   containing:
   - Property types: drive, chr, netdev, vlan, that depend on code that
 won't be included on *-user
   - qemu_add_globals(), that depends on qemu-config.o.

This change should help on two things:
 - Allowing DeviceState to be used by *-user without pulling
   dependencies that are specific for qemu-system-*;
 - Writing qdev unit tests without pulling too many dependencies.

The copyright/license of qdev-properties.c isn't explicitly stated at
the file, so add a simple copyright/license header pointing to the
commit ID of the original file.

Signed-off-by: Eduardo Habkost ehabk...@redhat.com
---
Detailed changelog:

Changes v1 (ehabkost) - v2 (imammedo):
 - keep qdev_get_child_bus() in hw/qdev.c
 - put qdev_set_nic_properties() in hw/qdev-properties-system.c

Changes v2 - v3 (ehabkost):
 - updated the qdev_init_gpio_in() code on qdev-system.c to current
   version

Changes v3 - v4:
 - Added copyright/license information to qdev-properties-system.c
   (based on copyright/license of qdev-properties.c)
 - Whitespace change at the end of qdev-properties.c
 - Don't create qdev-system.c, now we can keep the qdev.c code as-is
   as the qdev.c dependencies were reduced
 - Rewrite patch description

Changes v4 - v5:
 - Remove large copyright header and instead just point to the original
   file it was based on

Changes v5 - v6:
 - Removed inter-SoB line changelog from commit message

Changes v6 - v7:
 - Incorporate qdev-properties.c coding style fixes
---
 hw/Makefile.objs|   1 +
 hw/qdev-properties-system.c | 358 
 hw/qdev-properties.c| 327 +---
 hw/qdev-properties.h|   1 +
 hw/qdev.c   |  14 --
 5 files changed, 361 insertions(+), 340 deletions(-)
 create mode 100644 hw/qdev-properties-system.c

diff --git a/hw/Makefile.objs b/hw/Makefile.objs
index d581d8d..96a8365 100644
--- a/hw/Makefile.objs
+++ b/hw/Makefile.objs
@@ -185,6 +185,7 @@ common-obj-y += bt.o bt-l2cap.o bt-sdp.o bt-hci.o bt-hid.o
 common-obj-y += bt-hci-csr.o
 common-obj-y += msmouse.o ps2.o
 common-obj-y += qdev.o qdev-properties.o qdev-monitor.o
+common-obj-y += qdev-properties-system.o
 common-obj-$(CONFIG_BRLAPI) += baum.o
 
 # xen backend driver support
diff --git a/hw/qdev-properties-system.c b/hw/qdev-properties-system.c
new file mode 100644
index 000..b51f861
--- /dev/null
+++ b/hw/qdev-properties-system.c
@@ -0,0 +1,358 @@
+/*
+ * qdev property parsing and global properties
+ * (parts specific for qemu-system-*)
+ *
+ * This file is based on code from hw/qdev-properties.c from
+ * commit 074a86fccd185616469dfcdc0e157f438aebba18,
+ * Copyright (c) Gerd Hoffmann kra...@redhat.com and other contributors.
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#include net.h
+#include qdev.h
+#include qerror.h
+#include blockdev.h
+#include hw/block-common.h
+#include net/hub.h
+#include qapi/qapi-visit-core.h
+
+static void get_pointer(Object *obj, Visitor *v, Property *prop,
+const char *(*print)(void *ptr),
+const char *name, Error **errp)
+{
+DeviceState *dev = DEVICE(obj);
+void **ptr = qdev_get_prop_ptr(dev, prop);
+char *p;
+
+p = (char *) (*ptr ? print(*ptr) : );
+visit_type_str(v, p, name, errp);
+}
+
+static void set_pointer(Object *obj, Visitor *v, Property *prop,
+int (*parse)(DeviceState *dev, const char *str,
+ void **ptr),
+const char *name, Error **errp)
+{
+DeviceState *dev = DEVICE(obj);
+Error *local_err = NULL;
+void **ptr = qdev_get_prop_ptr(dev, prop);
+char *str;
+int ret;
+
+if (dev-state != DEV_STATE_CREATED) {
+error_set(errp, QERR_PERMISSION_DENIED);
+return;
+}
+
+visit_type_str(v, str, name, local_err);
+if (local_err) {
+error_propagate(errp, local_err);
+return;
+}
+if (!*str) {
+g_free(str);
+*ptr = NULL;
+return;
+}
+ret = parse(dev, str, ptr);
+error_set_from_qdev_prop_error(errp, ret, dev, prop, str);
+g_free(str);
+}
+
+/* --- drive --- */
+
+static int parse_drive(DeviceState *dev, const char *str, void **ptr)
+{
+BlockDriverState *bs;
+
+bs = bdrv_find(str);
+if (bs == NULL) {
+return -ENOENT;
+}
+if (bdrv_attach_dev(bs, dev)  0) {
+return -EEXIST;
+}
+*ptr = bs;
+return 0;
+}
+
+static void release_drive(Object *obj, const char *name, void *opaque)
+{
+DeviceState *dev = DEVICE(obj);
+Property *prop = opaque;
+BlockDriverState **ptr = qdev_get_prop_ptr(dev, prop);
+

Re: [Qemu-devel] [Qemu-ppc] [PATCH v2 1/2] Make default boot order machine specific

2012-12-05 Thread Avik Sil
On 10/26/2012 05:15 PM, Alexander Graf wrote:
 
 On 25.10.2012, at 22:57, Alexander Graf ag...@suse.de wrote:
 

 On 25.10.2012, at 22:50, Peter Maydell wrote:

 On 25 October 2012 21:18, Anthony Liguori aligu...@us.ibm.com wrote:
 The other approach to this would be:

 static QEMUMachine pseries_machine = {
   .no_boot_order = 1,
 };

 Which I think is what Peter is suggesting.  I'm not a huge fan of this
 because it's backwards logic but we already do this for a bunch of other
 things so I can't object too strongly to it.

 The other issue is that cad is a load of rubbish for half of these
 boards, which don't have anything resembling the usual PC boot
 devices and probably don't pay attention to -boot anyway. A patch
 which only applied a boot order to boards which actually used it
 would probably also be rather shorter.

 That's what v1 did, and it's ok, if it's mentioned explicitly and thought 
 through properly. Just doing this without proper reasoning is bad, because 
 you potentially change semantics of -boot if you miss anything. On OpenBIOS 
 with PPC we actually make use of the -boot arguments for example.

 Hence having a common set of default options the way Anthony put it seems 
 the most sane solution forward. It guarantees you don't break anything in 
 patch 1. Then it goes in and actually changes the semantics for the one 
 machine you want to change in patch 2.
 
 Anthony, please comment on which path you'd prefer. I'd rather like to have a 
 decision before creating more work.
 
Anthony, Can you please look into this since 1.4 window is open now?

Regards,
Avik

 
 Alex
 
 
 




[Qemu-devel] [PATCH 2/8] libqemustub: Add qemu_[un]register_reset() stubs

2012-12-05 Thread Eduardo Habkost
This will be useful for code that don't call qemu_devices_reset() (e.g.
*-user). If qemu_devices_reset() is never called, it means we don't need
to keep track of the reset handler list.

Signed-off-by: Eduardo Habkost ehabk...@redhat.com
---
 stubs/Makefile.objs |  1 +
 stubs/reset.c   | 13 +
 2 files changed, 14 insertions(+)
 create mode 100644 stubs/reset.c

diff --git a/stubs/Makefile.objs b/stubs/Makefile.objs
index 035b29a..00f0b64 100644
--- a/stubs/Makefile.objs
+++ b/stubs/Makefile.objs
@@ -5,4 +5,5 @@ stub-obj-y += fdset-get-fd.o
 stub-obj-y += fdset-remove-fd.o
 stub-obj-y += get-fd.o
 stub-obj-y += set-fd-handler.o
+stub-obj-y += reset.o
 stub-obj-$(CONFIG_WIN32) += fd-register.o
diff --git a/stubs/reset.c b/stubs/reset.c
new file mode 100644
index 000..ad28725
--- /dev/null
+++ b/stubs/reset.c
@@ -0,0 +1,13 @@
+#include hw/hw.h
+
+/* Stub functions for binaries that never call qemu_devices_reset(),
+ * and don't need to keep track of the reset handler list.
+ */
+
+void qemu_register_reset(QEMUResetHandler *func, void *opaque)
+{
+}
+
+void qemu_unregister_reset(QEMUResetHandler *func, void *opaque)
+{
+}
-- 
1.7.11.7




Re: [Qemu-devel] [RFC PATCH v5 6/6] virtio-blk : Refactor virtio-blk.

2012-12-05 Thread Andreas Färber
Am 05.12.2012 17:25, schrieb Peter Maydell:
 On 4 December 2012 14:35,  fred.kon...@greensocs.com wrote:
 From: KONRAD Frederic fred.kon...@greensocs.com

 Create virtio-blk which extends virtio-device, so it can be connected on
 virtio-bus.

 Signed-off-by: KONRAD Frederic fred.kon...@greensocs.com
 ---
  hw/virtio-blk.c | 170 
 
  hw/virtio-blk.h |   4 ++
  2 files changed, 150 insertions(+), 24 deletions(-)

 diff --git a/hw/virtio-blk.c b/hw/virtio-blk.c
 index e25cc96..ee1ea8b 100644
 --- a/hw/virtio-blk.c
 +++ b/hw/virtio-blk.c
 @@ -21,24 +21,42 @@
  #ifdef __linux__
  # include scsi/sg.h
  #endif
 +#include virtio-bus.h

 +/* Take this structure as our device structure. */
  typedef struct VirtIOBlock
  {
 +/*
 + * Adding parent_obj breaks to_virtio_blk cast function,
 + * and virtio_blk_init.
 + */
 +DeviceState parent_obj;
 +/*
 + * We don't need that anymore, as we'll use QOM cast to get the
 + * VirtIODevice. Just temporary keep it, for not breaking functionality.
 + */
  VirtIODevice vdev;
 
 This doesn't make sense. After your previous patch, VirtIODevice
 is-a DeviceState, and VirtIOBlock already is-a VirtIODevice,
 so there's nothing to do here. Adding this parent_obj field
 here is just breaking things (it would make the VirtIOBlock
 into a direct child of DeviceState, which isn't what we want).
 
  BlockDriverState *bs;
  VirtQueue *vq;
  void *rq;
  QEMUBH *bh;
  BlockConf *conf;
 -VirtIOBlkConf *blk;
 +/*
 + * We can't use pointer with properties.
 + */
 +VirtIOBlkConf blk;
  unsigned short sector_mask;
  DeviceState *qdev;
  } VirtIOBlock;

 -static VirtIOBlock *to_virtio_blk(VirtIODevice *vdev)
 -{
 -return (VirtIOBlock *)vdev;
 -}
 +/*
 + * Use the QOM cast, so we don't need that anymore.
 + *
 + * static VirtIOBlock *to_virtio_blk(VirtIODevice *vdev)
 + * {
 + * return (VirtIOBlock *)vdev;
 + * }
 + */
 
 If we don't need it, just delete it.

Seconded. You need to introduce a VIRTIO_BLOCK() macro, backed by
OBJECT_CHECK(), and replace all callers of to_virtio_blk() with
VIRTIO_BLOCK(). Compare my ISA series that I intentionally cc'ed you on.
You can then rename vdev to parent_obj as a check that you caught all users.

Regards,
Andreas

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg



[Qemu-devel] [PATCH 5/8] qdev: Coding style fixes

2012-12-05 Thread Eduardo Habkost
Add missing braces and break lines larger than 80 chars.

Signed-off-by: Eduardo Habkost ehabk...@redhat.com
---
 hw/qdev-properties.c | 53 ++--
 hw/qdev.c|  3 ++-
 2 files changed, 37 insertions(+), 19 deletions(-)

diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c
index 81d901c..67543fd 100644
--- a/hw/qdev-properties.c
+++ b/hw/qdev-properties.c
@@ -95,10 +95,11 @@ static void bit_prop_set(DeviceState *dev, Property *props, 
bool val)
 {
 uint32_t *p = qdev_get_prop_ptr(dev, props);
 uint32_t mask = qdev_get_prop_mask(props);
-if (val)
+if (val) {
 *p |= mask;
-else
+} else {
 *p = ~mask;
+}
 }
 
 static int print_bit(DeviceState *dev, Property *prop, char *dest, size_t len)
@@ -420,11 +421,13 @@ static void release_string(Object *obj, const char *name, 
void *opaque)
 g_free(*(char **)qdev_get_prop_ptr(DEVICE(obj), prop));
 }
 
-static int print_string(DeviceState *dev, Property *prop, char *dest, size_t 
len)
+static int print_string(DeviceState *dev, Property *prop, char *dest,
+size_t len)
 {
 char **ptr = qdev_get_prop_ptr(dev, prop);
-if (!*ptr)
+if (!*ptr) {
 return snprintf(dest, len, null);
+}
 return snprintf(dest, len, \%s\, *ptr);
 }
 
@@ -483,10 +486,12 @@ static int parse_drive(DeviceState *dev, const char *str, 
void **ptr)
 BlockDriverState *bs;
 
 bs = bdrv_find(str);
-if (bs == NULL)
+if (bs == NULL) {
 return -ENOENT;
-if (bdrv_attach_dev(bs, dev)  0)
+}
+if (bdrv_attach_dev(bs, dev)  0) {
 return -EEXIST;
+}
 *ptr = bs;
 return 0;
 }
@@ -749,16 +754,20 @@ static void set_mac(Object *obj, Visitor *v, void *opaque,
 }
 
 for (i = 0, pos = 0; i  6; i++, pos += 3) {
-if (!qemu_isxdigit(str[pos]))
+if (!qemu_isxdigit(str[pos])) {
 goto inval;
-if (!qemu_isxdigit(str[pos+1]))
+}
+if (!qemu_isxdigit(str[pos+1])) {
 goto inval;
+}
 if (i == 5) {
-if (str[pos+2] != '\0')
+if (str[pos+2] != '\0') {
 goto inval;
+}
 } else {
-if (str[pos+2] != ':'  str[pos+2] != '-')
+if (str[pos+2] != ':'  str[pos+2] != '-') {
 goto inval;
+}
 }
 mac-a[i] = strtol(str+pos, p, 16);
 }
@@ -864,7 +873,8 @@ invalid:
 g_free(str);
 }
 
-static int print_pci_devfn(DeviceState *dev, Property *prop, char *dest, 
size_t len)
+static int print_pci_devfn(DeviceState *dev, Property *prop, char *dest,
+   size_t len)
 {
 int32_t *ptr = qdev_get_prop_ptr(dev, prop);
 
@@ -1038,11 +1048,13 @@ PropertyInfo qdev_prop_pci_host_devaddr = {
 
 static Property *qdev_prop_walk(Property *props, const char *name)
 {
-if (!props)
+if (!props) {
 return NULL;
+}
 while (props-name) {
-if (strcmp(props-name, name) == 0)
+if (strcmp(props-name, name) == 0) {
 return props;
+}
 props++;
 }
 return NULL;
@@ -1158,7 +1170,8 @@ void qdev_prop_set_string(DeviceState *dev, const char 
*name, const char *value)
 assert_no_error(errp);
 }
 
-int qdev_prop_set_drive(DeviceState *dev, const char *name, BlockDriverState 
*value)
+int qdev_prop_set_drive(DeviceState *dev, const char *name,
+BlockDriverState *value)
 {
 Error *errp = NULL;
 const char *bdrv_name = value ? bdrv_get_device_name(value) : ;
@@ -1172,13 +1185,15 @@ int qdev_prop_set_drive(DeviceState *dev, const char 
*name, BlockDriverState *va
 return 0;
 }
 
-void qdev_prop_set_drive_nofail(DeviceState *dev, const char *name, 
BlockDriverState *value)
+void qdev_prop_set_drive_nofail(DeviceState *dev, const char *name,
+BlockDriverState *value)
 {
 if (qdev_prop_set_drive(dev, name, value)  0) {
 exit(1);
 }
 }
-void qdev_prop_set_chr(DeviceState *dev, const char *name, CharDriverState 
*value)
+void qdev_prop_set_chr(DeviceState *dev, const char *name,
+   CharDriverState *value)
 {
 Error *errp = NULL;
 assert(!value || value-label);
@@ -1187,7 +1202,8 @@ void qdev_prop_set_chr(DeviceState *dev, const char 
*name, CharDriverState *valu
 assert_no_error(errp);
 }
 
-void qdev_prop_set_netdev(DeviceState *dev, const char *name, NetClientState 
*value)
+void qdev_prop_set_netdev(DeviceState *dev, const char *name,
+  NetClientState *value)
 {
 Error *errp = NULL;
 assert(!value || value-name);
@@ -1229,7 +1245,8 @@ void qdev_prop_set_ptr(DeviceState *dev, const char 
*name, void *value)
 *ptr = value;
 }
 
-static QTAILQ_HEAD(, GlobalProperty) global_props = 
QTAILQ_HEAD_INITIALIZER(global_props);
+static QTAILQ_HEAD(, GlobalProperty) global_props =
+

Re: [Qemu-devel] [PATCH 5/6] add visitor for parsing hz[KMG] input string

2012-12-05 Thread mdroth
On Tue, Dec 04, 2012 at 05:34:42PM -0200, Eduardo Habkost wrote:
 From: Igor Mammedov imamm...@redhat.com
 
 Signed-off-by: Igor Mammedov imamm...@redhat.com
 Acked-by: Andreas Färber afaer...@suse.de
 ---
  qapi/qapi-visit-core.c  | 11 +++
  qapi/qapi-visit-core.h  |  2 ++
  qapi/string-input-visitor.c | 22 ++
  3 files changed, 35 insertions(+)
 
 diff --git a/qapi/qapi-visit-core.c b/qapi/qapi-visit-core.c
 index 7a82b63..5c8705e 100644
 --- a/qapi/qapi-visit-core.c
 +++ b/qapi/qapi-visit-core.c
 @@ -311,3 +311,14 @@ void input_type_enum(Visitor *v, int *obj, const char 
 *strings[],
  g_free(enum_str);
  *obj = value;
  }
 +
 +void visit_type_freq(Visitor *v, int64_t *obj, const char *name, Error 
 **errp)
 +{
 +if (!error_is_set(errp)) {
 +if (v-type_freq) {
 +v-type_freq(v, obj, name, errp);
 +} else {
 +v-type_int(v, obj, name, errp);
 +}
 +}
 +}
 diff --git a/qapi/qapi-visit-core.h b/qapi/qapi-visit-core.h
 index 60aceda..e5e7dd7 100644
 --- a/qapi/qapi-visit-core.h
 +++ b/qapi/qapi-visit-core.h
 @@ -62,6 +62,7 @@ struct Visitor
  void (*type_int64)(Visitor *v, int64_t *obj, const char *name, Error 
 **errp);
  /* visit_type_size() falls back to (*type_uint64)() if type_size is 
 unset */
  void (*type_size)(Visitor *v, uint64_t *obj, const char *name, Error 
 **errp);
 +void (*type_freq)(Visitor *v, int64_t *obj, const char *name, Error 
 **errp);
  };
  
  void visit_start_handle(Visitor *v, void **obj, const char *kind,
 @@ -91,5 +92,6 @@ void visit_type_size(Visitor *v, uint64_t *obj, const char 
 *name, Error **errp);
  void visit_type_bool(Visitor *v, bool *obj, const char *name, Error **errp);
  void visit_type_str(Visitor *v, char **obj, const char *name, Error **errp);
  void visit_type_number(Visitor *v, double *obj, const char *name, Error 
 **errp);
 +void visit_type_freq(Visitor *v, int64_t *obj, const char *name, Error 
 **errp);
  
  #endif
 diff --git a/qapi/string-input-visitor.c b/qapi/string-input-visitor.c
 index 497eb9a..74fe395 100644
 --- a/qapi/string-input-visitor.c
 +++ b/qapi/string-input-visitor.c
 @@ -110,6 +110,27 @@ static void parse_start_optional(Visitor *v, bool 
 *present,
  *present = true;
  }
  
 +static void parse_type_freq(Visitor *v, int64_t *obj, const char *name,
 +Error **errp)
 +{
 +StringInputVisitor *siv = DO_UPCAST(StringInputVisitor, visitor, v);
 +char *endp = (char *) siv-string;
 +long long val = 0;
 +
 +errno = 0;

If this is for strtosz_suffix_unit(), it looks like this is already
handled internally and can be dropped. Relic from a previous version
that called strtod() directly maybe?

If that's not the case, I think it should be fixed in the called function[s]
rather than for each caller.

 +if (siv-string) {
 +val = strtosz_suffix_unit(siv-string, endp,
 + STRTOSZ_DEFSUFFIX_B, 1000);

Specifying 1000 as the unit size will make 1M == 1000^2 as opposed to
1024^2. Is this intentional?

 +}
 +if (!siv-string || val == -1 || *endp) {
 +error_set(errp, QERR_INVALID_PARAMETER_VALUE, name,
 +  a value representable as a non-negative int64);
 +return;
 +}
 +
 +*obj = val;
 +}
 +
  Visitor *string_input_get_visitor(StringInputVisitor *v)
  {
  return v-visitor;
 @@ -132,6 +153,7 @@ StringInputVisitor *string_input_visitor_new(const char 
 *str)
  v-visitor.type_str = parse_type_str;
  v-visitor.type_number = parse_type_number;
  v-visitor.start_optional = parse_start_optional;
 +v-visitor.type_freq = parse_type_freq;

This seems applicable for stuff like -m 1G and potentionally some other
properties. We can make it generic later, but if we do end up re-spinning
consider something like -type_unit_suffixed_int(). But I'm not against
leaving as is for now since I can't think of a better name for it atm :)

Whatever we call it, based on a recent discussion here:

http://lists.gnu.org/archive/html/qemu-devel/2012-11/msg02872.html

we should have a corresponding implementation in qapi-dealloc-visitor.c.
In this case You can just do:

v-visitor.type_freq = qapi_dealloc_type_int;

There aren't any problems in the current code, we just want to avoid relying on
fallbacks for the dealloc case in general because in some situations the
underlying sizes of the C types don't match and this can cause problems down
the road for the dealloc visitor even though it's okay for other visitor
implementations.

  
  v-string = str;
  return v;
 -- 
 1.7.11.7
 
 



[Qemu-devel] [PATCH] e1000: Discard oversized packets based on SBP|LPE

2012-12-05 Thread Michael Contreras
Discard packets longer than 16384 when !SBP to match the hardware behavior.

Signed-off-by: Michael Contreras mich...@inetric.com
---
 hw/e1000.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/hw/e1000.c b/hw/e1000.c
index 5537ad2..e772c8e 100644
--- a/hw/e1000.c
+++ b/hw/e1000.c
@@ -61,6 +61,8 @@ static int debugflags = DBGBIT(TXERR) | DBGBIT(GENERAL);
 
 /* this is the size past which hardware will drop packets when setting LPE=0 */
 #define MAXIMUM_ETHERNET_VLAN_SIZE 1522
+/* this is the size past which hardware will drop packets when setting LPE=1 */
+#define MAXIMUM_ETHERNET_LPE_SIZE 16384
 
 /*
  * HW models:
@@ -809,8 +811,9 @@ e1000_receive(NetClientState *nc, const uint8_t *buf, 
size_t size)
 }
 
 /* Discard oversized packets if !LPE and !SBP. */
-if (size  MAXIMUM_ETHERNET_VLAN_SIZE
- !(s-mac_reg[RCTL]  E1000_RCTL_LPE)
+if ((size  MAXIMUM_ETHERNET_LPE_SIZE ||
+(size  MAXIMUM_ETHERNET_VLAN_SIZE
+ !(s-mac_reg[RCTL]  E1000_RCTL_LPE)))
  !(s-mac_reg[RCTL]  E1000_RCTL_SBP)) {
 return size;
 }
-- 
1.8.0.1




Re: [Qemu-devel] [Bug 1075252] Re: qemu-img cannot read VMDK4 file

2012-12-05 Thread Robert Hubbard
Hi Stefan,
Good exercise, I just pulled the latest branch. The block/vmdk.c has been
completely revised and includes the correct code for vmdk4 support now for
the  vmdk compressed stream optimized. I also missed for  the git-patch
the fact i needed master in the command, this worked and thanks for
pointers.

Branch is 1.3.50

Regards

Rob.


On Tuesday, December 4, 2012, Stefan Hajnoczi 1075...@bugs.launchpad.net
wrote:
 On Tue, Dec 4, 2012 at 2:56 AM, Robert Hubbard hubbardmeis...@gmail.com
wrote:
 I have uploaded a patch - I am failing miserably to get any output from
git
 patch!! ...  :^( . the code is structured to addres the fact that
 convert will not work today, needs lots of work to do this. This would be
 next effort.

 Hi Rob,
 git-patch(1) is used to apply patches - it's not the command for
 producing patch emails.

 Try git-format-patch(1).  Here is a short post I found on creating a
 commit and using git-format-patch(1):

 http://andrewprice.me.uk/weblog/entry/generating-patch-emails-with-git

 There are several git tutorials that cover much more and will help you
 get familiar.  If you want to learn git I recommend:

 http://git-scm.com/book
 http://www-cs-students.stanford.edu/~blynn/gitmagic/

 But remember you don't need to use git - some people use other tools
 or simply diff(1).  You just need to send patches to the mailing list
 as described at http://wiki.qemu.org/Contribute/SubmitAPatch.

 If you have doubts about how to structure a patch series, try peeking
 at what other people have sent to the mailing list.

 I took a quick look at the patch you uploaded:

 It helps review to split changes up into multiple patches, one patch
 for each logical code change.  For example, renaming a struct field
 also involves changing code that uses the field because the name has
 changed.  This is a good candidate for a patch - just the struct field
 rename and updates to code that uses the old name.  If you think at
 this level of code change your diff can be split into several
 independent changes which are easier to review.

 That said, renaming fields or changing whitespace should only be done
 when necessary.  It introduces noise in the form of extra work to
 review - the compiled object code probably doesn't change and the
 behavior of the program won't either.  So it's best to only make
 changes that are necessary or that provide clear value.  (I'm not an
 expert on block/vmdk.c, for example, so any non-essential changes
 basically mean extra work for me to check whether they are okay or
 not.)

 Going back to the original bug: can you confirm that qemu.git/master
 qemu-img correctly displays the VMDK file you have?  Fam Zheng
 indicated the bug you originally hit has already been fixed.

 Please send patches or questions for new VMDK changes that are
 unrelated to this bug report directly to qemu-devel.  Your patch seems
 to be beyond the scope of this bug report and adds some additional
 qemu-img info output.

 Hope this helps.  If you want real-time discussion, try asking on
 #qemu on irc.oftc.net where a lot of QEMU developers hang out.

 Stefan

 --
 You received this bug notification because you are subscribed to the bug
 report.
 https://bugs.launchpad.net/bugs/1075252

 Title:
   qemu-img cannot  read VMDK4 file

 Status in QEMU:
   New

 Bug description:
   Unable to  read any vmdk4 type files. Goal was to convert to a qcow2,
   this worked after emitting code.

   OS is  Centos linux 2.6.32. I pulled the latest git tree down for qemu
   to see if this was resolved, it is not.

   Starting program: /home/rhubbard/QEMU/qemu/qemu-img info -f vmdk
   /root/Juniper/beta1candidate-07122012-disk1.vmdk


   There seems a mismatch with the l1_backup_tble_offset.  this is now a
uint64 type.  The value is actually -512 because of this and this causes
the code check at line 418 in vmdk.c to erroneously  think there is a
backup table. This causes vmdk open to fail.
   and message
   qemu failed to open 


   from debug;
   gdb) x/4x (s-l1_backup_table_offset)
   0xa61cd0: 0xfe00  0x  0x00a62770  0x

   (gdb) p *s
   $1 = {hd = 0x0, l1_table_offset = 0, l1_backup_table_offset = -512,
l1_table = 0xa62770,
 l1_backup_table = 0x0, l1_size = 64, l1_entry_sectors = 65536,
l2_size = 512, l2_cache = 0x0,
 l2_cache_offsets = {0 repeats 16 times}, l2_cache_counts = {0
repeats 16 times},
 cluster_sectors = 128, parent_cid = 4294967295}

   typedef struct BDRVVmdkState {
   BlockDriverState *hd;
   int64_t l1_table_offset;
  ??? - what should this be , don't know what the actual layout on the
vmdk spec says , is this a 64bit / 8 byte field ?

   int64_t l1_backup_table_offset;
   uint32_t *l1_table;
   uint32_t *l1_backup_table;
   unsigned int l1_size;
   uint32_t l1_entry_sectors;

   unsigned int l2_size;

   from vmdk.c
   /*!!!  if (s-l1_backup_table_offset) {
   s-l1_backup_table = 

Re: [Qemu-devel] [PULL for-1.3 0/3] seabios update

2012-12-05 Thread Brad Campbell

On 05/12/12 20:47, Gerd Hoffmann wrote:

On 12/05/12 11:49, Brad Campbell wrote:

On 30/11/12 23:29, Gerd Hoffmann wrote:

Hi,

This pull updates seabios to current master.   The seabios q35 patches
didn't land upstream yet so they miss the boat unfortunaly.  As this
update brings an important regression fix we can't wait for them and
risk to not update seabios for 1.3.  So here we go with the latest and
greatest seabios bits.


This update has broken my existing Windows XP Guests.
The machines bluescreen on boot with a 0x007E in ACPI.SYS.

Try passing -no-hpet and see if this helps.

Yep, that fixes it.

Many thanks!

Regards,
Brad




Re: [Qemu-devel] [RFC] 1.4 release schedule

2012-12-05 Thread Blue Swirl
On Tue, Dec 4, 2012 at 10:00 PM, Anthony Liguori aligu...@us.ibm.com wrote:
 Peter Maydell peter.mayd...@linaro.org writes:

 On 4 December 2012 18:38, Blue Swirl blauwir...@gmail.com wrote:
 The definition of the hard freeze bothers me. A few patches that went
 in after 1.3-rc0 were not bug fixes but just new features, so the
 difference between soft and hard freezes was not clear.

 My vote for this would be to adhere to our definition
 and only commit bugfixes.

 Let's get specific.  What was committed post hard freeze that's not a
 bug fix?

d3067b0 Documentation: Update image format information
a13e5e0 Documentation: Update block cache mode information
044d003 qemu-tech.texi: update implemented xtensa features list
a0a7068 target-i386: Enable SSSE3 TCG support
80ae416 target-i386/cpu: Add missing flags to Haswell CPU model
42015c9 virtio-rng: fix typos, comments
e1e54f3 target-i386: cpu: add missing flags to Haswell CPU model
339c270 qom: make object_finalize static
64b625f qdev: simplify (de)allocation of buses
fde9bf4 qom: make object_delete usable for statically-allocated objects
667d22d qdev: move bus removal to object_unparent
74c856e tests: add thread pool unit tests
b2ea25d tests: add AioContext unit tests
21022c9 q35: Add kvmclock support
a1c9304 ich9: Add i82801b11 dmi-to-pci bridge
df2d8b3 q35: Introduce q35 pc based chipset emulator
678e7b9 ich9: Add smbus
4d00636 ich9: Add the lpc chip
e516572 ich9: Add acpi support and definitions
410edd9 pc/piix_pci: factor out smram/pam logic
d8ee038 pc_piix: Move kvm irq routing functions out of pc_piix.c
a39e356 pc: Move ioapic_init() from pc_piix.c to pc.c
9011a1a pc, pc_piix: split out pc nic initialization
723aedd usb-redir: Don't handle interrupt output packets async
234e810 usb-redir: Split usb_handle_interrupt_data into separate
in/out functions
33c1a68 usb-bt: Return NAK instead of STALL when interrupt ep has no data
1bc6b70 block: add bdrv_reopen() support for raw hdev, floppy, and cdrom
d132c79 target-mips: Add comments on POOL32Axf encoding


 The only thing I'm aware of is q35.  I asked Michael not to merge that
 (he planned to) prior to the hard freeze because there was a specific
 change I wanted to be made.  Normally, PCI bits would go through
 Michael's tree but I felt the change really needed to be made.

 So I agreed to take the bits post hard freeze so the change could be
 made.  This is really was an exceptional case though and I don't think
 it warrants a change in the description of hard freeze.  This was all
 discussed on the mailing list too FWIW.

The description is OK if a bit terse, for example documentation or
comment fixes could be explicitly mentioned.

I may have missed the discussion where q35 was excepted to bypass the
freeze, but only one third of the commits above were about q35 though.


 Regards,

 Anthony Liguori


 -- PMM




Re: [Qemu-devel] [PATCH 5/6] add visitor for parsing hz[KMG] input string

2012-12-05 Thread Eduardo Habkost
On Wed, Dec 05, 2012 at 11:52:29AM -0600, mdroth wrote:
 On Tue, Dec 04, 2012 at 05:34:42PM -0200, Eduardo Habkost wrote:
[...]
  diff --git a/qapi/string-input-visitor.c b/qapi/string-input-visitor.c
  index 497eb9a..74fe395 100644
  --- a/qapi/string-input-visitor.c
  +++ b/qapi/string-input-visitor.c
  @@ -110,6 +110,27 @@ static void parse_start_optional(Visitor *v, bool 
  *present,
   *present = true;
   }
   
  +static void parse_type_freq(Visitor *v, int64_t *obj, const char *name,
  +Error **errp)
  +{
  +StringInputVisitor *siv = DO_UPCAST(StringInputVisitor, visitor, v);
  +char *endp = (char *) siv-string;
  +long long val = 0;
  +
  +errno = 0;
 
 If this is for strtosz_suffix_unit(), it looks like this is already
 handled internally and can be dropped. Relic from a previous version
 that called strtod() directly maybe?
 
 If that's not the case, I think it should be fixed in the called function[s]
 rather than for each caller.
 
  +if (siv-string) {
  +val = strtosz_suffix_unit(siv-string, endp,
  + STRTOSZ_DEFSUFFIX_B, 1000);
 
 Specifying 1000 as the unit size will make 1M == 1000^2 as opposed to
 1024^2. Is this intentional?

I don't know if this is a good idea for a generalx-use visitor, but this is the
current behavior of -cpu ...,tsc_freq=1M, that we need to keep for
compatibility, somehow.

 
  +}
  +if (!siv-string || val == -1 || *endp) {
  +error_set(errp, QERR_INVALID_PARAMETER_VALUE, name,
  +  a value representable as a non-negative int64);
  +return;
  +}
  +
  +*obj = val;
  +}
  +
   Visitor *string_input_get_visitor(StringInputVisitor *v)
   {
   return v-visitor;
  @@ -132,6 +153,7 @@ StringInputVisitor *string_input_visitor_new(const char 
  *str)
   v-visitor.type_str = parse_type_str;
   v-visitor.type_number = parse_type_number;
   v-visitor.start_optional = parse_start_optional;
  +v-visitor.type_freq = parse_type_freq;
 
 This seems applicable for stuff like -m 1G and potentionally some other
 properties. We can make it generic later, but if we do end up re-spinning
 consider something like -type_unit_suffixed_int(). But I'm not against
 leaving as is for now since I can't think of a better name for it atm :)

I thought the visitor was going to support things like 1GHz, but if it's just
a suffixed int with no unit, the name could be changed, I guess.

But we still have the 1000 vs 1024 problem. On the one hand, it would be
interesting to make make it consistent and use the same base everywhere.
On the other hand, I assume we have different command-line options using
different bases and we'll need to keep compatibility.

Must all visitor functions have the
function(Visitor *v, obj, const char *name, Error **errp) signature,
or can we add additional type-specific arguments? (so we could tell
the visitor if the default base should be 1000 or 1024)

-- 
Eduardo



Re: [Qemu-devel] [RFC] 1.4 release schedule

2012-12-05 Thread Hans de Goede

Hi,

On 12/05/2012 08:28 PM, Blue Swirl wrote:

On Tue, Dec 4, 2012 at 10:00 PM, Anthony Liguori aligu...@us.ibm.com wrote:

Peter Maydell peter.mayd...@linaro.org writes:


On 4 December 2012 18:38, Blue Swirl blauwir...@gmail.com wrote:

The definition of the hard freeze bothers me. A few patches that went
in after 1.3-rc0 were not bug fixes but just new features, so the
difference between soft and hard freezes was not clear.


My vote for this would be to adhere to our definition
and only commit bugfixes.


Let's get specific.  What was committed post hard freeze that's not a
bug fix?


d3067b0 Documentation: Update image format information
a13e5e0 Documentation: Update block cache mode information
044d003 qemu-tech.texi: update implemented xtensa features list


Adding missing / updating docs to be more accurate is a bug fix,
and one with a very low chance of causing regressions at that.


a0a7068 target-i386: Enable SSSE3 TCG support
80ae416 target-i386/cpu: Add missing flags to Haswell CPU model
42015c9 virtio-rng: fix typos, comments
e1e54f3 target-i386: cpu: add missing flags to Haswell CPU model
339c270 qom: make object_finalize static
64b625f qdev: simplify (de)allocation of buses
fde9bf4 qom: make object_delete usable for statically-allocated objects
667d22d qdev: move bus removal to object_unparent
74c856e tests: add thread pool unit tests
b2ea25d tests: add AioContext unit tests
21022c9 q35: Add kvmclock support
a1c9304 ich9: Add i82801b11 dmi-to-pci bridge
df2d8b3 q35: Introduce q35 pc based chipset emulator
678e7b9 ich9: Add smbus
4d00636 ich9: Add the lpc chip
e516572 ich9: Add acpi support and definitions
410edd9 pc/piix_pci: factor out smram/pam logic
d8ee038 pc_piix: Move kvm irq routing functions out of pc_piix.c
a39e356 pc: Move ioapic_init() from pc_piix.c to pc.c
9011a1a pc, pc_piix: split out pc nic initialization




723aedd usb-redir: Don't handle interrupt output packets async

Bug-fix


234e810 usb-redir: Split usb_handle_interrupt_data into separate
in/out functions

Preparation patch for the above bugfix, no functional changes.


33c1a68 usb-bt: Return NAK instead of STALL when interrupt ep has no data

Bug-fix


Regards,

Hans



Re: [Qemu-devel] [PATCH 4/4] exec: refactor cpu_restore_state

2012-12-05 Thread Blue Swirl
On Wed, Dec 5, 2012 at 11:10 AM, Andreas Färber afaer...@suse.de wrote:
 Am 04.12.2012 22:20, schrieb Blue Swirl:
 Refactor common code around calls to cpu_restore_state().

 tb_find_pc() has now no external users, make it static.

 Signed-off-by: Blue Swirl blauwir...@gmail.com

 Would've been nice to get CC'ed on the refactoring of a cpu_* function...

 I've reviewed mostly the non-target parts and they look okay,
 CPUArchState is unfortunately still needed.

Yes, it's inevitable because CPU fields need to be updated.

One idea I had during the refactoring was to create a new structure
for pc, cs_base and flags in TranslationBlock. Only this struct could
be passed to save/restore functions. The struct could be actually a
union with CPU specific fields, like 'npc' for Sparc instead of x86
specific 'cs_base'. But the benefit would be small since other fields
are also used by for example icount, so whole TranslationBlock is
needed in many cases.


 Andreas

 --
 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
 GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg



[Qemu-devel] [Bug 1086745] TEMT comes too early (QEMU/KVM)

2012-12-05 Thread Kees Schoenmakers
Hello,

It is a Linux host and a Linux guest. One serial port (/dev/ttyS0) is
passed from the host to the guest.

The application (on the guest) does Hart (r) communication, This is
done with a 1200 baud simplex modem (one side at a time).

The application raises RTS so that the modem goes in transmit state,
it writes a couple of bytes. Only after _all_ bytes are written in
reality the RTS is to be de-activated which puts the modem in receive
state. Normally a loop like

int parm =0;

while (!parm)
   ioctl(devicefd,TIOCSERGETLSR , parm);

is executed, The loop exits when parm is not zero (TEMT is set);

The current implementation of  TIOCSERGETLSR only checks fifo count
which is nowhere a accurate way of checking if the device in the host
has written all its characters, thus the function
ioctl(devicefd,TIOCSERGETLSR , parm) returns parms set already when
the second character is transmitted and thus the whole communication
cycle is disrupted.

One possible solution is having ioctl( TIOCSERGETLSR ...) in the
guest to check the result of ioctl(. TIOCSERGETLSR) in the
host. Another way is timing of the transmission, that is for each
character written the guest needs to add the charactertime to a timer
and only when the timer timesout TEMT is to be set.

does this help to understand the problem?

best regards

Kees

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

Title:
  serial port data THRE comes too early

Status in QEMU:
  New

Bug description:
  When using a serial port with a Linux guest (and host) and the
  application uses hardware handshake, this fails because the handling
  of TEMT and/or THRE is not operating properly in such cases.

  As long as it takes _time_ for the 'real' port to output the data TEMT
  may not return true. After writing characters to a real port, the
  driver should timeout the transmission and after the total time
  expired, TEMT can be set.

  Some applications i.e. with a simplex modem do: RTS_on, WRITE_data, repeat 
IOCTL(GET_LSR_INFO), RTS_off, READ_data.
  At the moment this fails because very early in the transmission, GET_LSR_INFO 
returns true and the modem transmitter is switched off.

  I looked in the source (git)  and found that 'char_transmit_time' is present. 
My skills fail to implement it myself.
  I build and ran the latest git version and found it to fail as decribed 
above.  I hope someone can solve it.

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



Re: [Qemu-devel] [PATCH] target-mips: Fix incorrect code and test for INSV

2012-12-05 Thread Johnson, Eric
 -Original Message-
 From: qemu-devel-bounces+ericj=mips@nongnu.org [mailto:qemu-devel-
 bounces+ericj=mips@nongnu.org] On Behalf Of Petar Jovanovic
 Sent: Monday, November 26, 2012 7:13 AM
 To: qemu-devel@nongnu.org
 Cc: Jovanovic, Petar; aurel...@aurel32.net
 Subject: [Qemu-devel] [PATCH] target-mips: Fix incorrect code and test for
 INSV
 
 From: Petar Jovanovic pet...@mips.com
 
 Content of register rs should be shifted for pos before applying a mask.
 This change contains both fix for the instruction and to the existing
 test.
 
 Signed-off-by: Petar Jovanovic pet...@mips.com
 ---
  target-mips/dsp_helper.c |2 +-
  tests/tcg/mips/mips32-dsp/insv.c |2 +-
  2 files changed, 2 insertions(+), 2 deletions(-)
 
 diff --git a/target-mips/dsp_helper.c b/target-mips/dsp_helper.c
 index e7949c2..fda5f04 100644
 --- a/target-mips/dsp_helper.c
 +++ b/target-mips/dsp_helper.c
 @@ -3152,7 +3152,7 @@ target_ulong helper_##name(CPUMIPSState *env,
 target_ulong rs,  \
  \
  filter = ((int32_t)0x01  size) - 1;   \
  filter = filter  pos; \
 -temprs = rs  filter;   \
 +temprs = (rs  pos)  filter;  \
  temprt = rt  ~filter;  \
  temp = temprs | temprt; \
  \
 diff --git a/tests/tcg/mips/mips32-dsp/insv.c b/tests/tcg/mips/mips32-
 dsp/insv.c
 index 7e3b047..243b007 100644
 --- a/tests/tcg/mips/mips32-dsp/insv.c
 +++ b/tests/tcg/mips/mips32-dsp/insv.c
 @@ -10,7 +10,7 @@ int main()
  dsp= 0x305;
  rt = 0x12345678;
  rs = 0x87654321;
 -result = 0x12345338;
 +result = 0x12345438;
  __asm
  (wrdsp %2, 0x03\n\t
   insv  %0, %1\n\t
 --
 1.7.5.4
 

Reviewed-by: Eric Johnson er...@mips.com



[Qemu-devel] [PATCH 1/1] tmp105: Fix I2C protocol bug

2012-12-05 Thread Alex Horn
The private buffer length field must only be incremented after the I2C
frame has been transmitted.

To expose this bug, assume the temperature in the TMP105 hardware model
is +0.125 C (e.g. snow slush). Note that eleven bit precision is required
to read this value; otherwise the reading is equal to zero centigrade (ice).

Continue by considering the following I2C protocol steps:

1) Start transfer with I2C_START_SEND
2) Send byte 0x01 (i.e. configuration register)
3) Send byte 0x40 (i.e. eleven bit precision)
4) End transfer with I2C_FINISH

5) Start transfer with I2C_START_SEND
6) Send byte 0x00 (i.e. temperature register)
7) End transfer I2C_FINISH

8) Start transfer with I2C_START_RECV
9) Receive high-order byte of temperature
   ...

In step (1), the function tmp105_tx() is called. By the conditional
check !s-len and the side effect with ++, s-len is equal to 1 when
step (2) begins. Thus, 0x40 is written to s-buf[1] in step (3).
By definition of tmp105_write(), s-config is set to zero in step (3).
Thus, when we read the higher-order byte in step (9), it is zero!

In other words, the TMP105 hardware model allows us to measure 0 C (ice)
even with eleven bit precision when, in fact, it should be 0.125 C (slush)!

Signed-off-by: Alex Horn alex.h...@cs.ox.ac.uk
---
 hw/tmp105.c |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/hw/tmp105.c b/hw/tmp105.c
index 8e8dbd9..5f41a3f 100644
--- a/hw/tmp105.c
+++ b/hw/tmp105.c
@@ -152,7 +152,7 @@ static int tmp105_tx(I2CSlave *i2c, uint8_t data)
 {
 TMP105State *s = (TMP105State *) i2c;
 
-if (!s-len ++)
+if (s-len == 0)
 s-pointer = data;
 else {
 if (s-len = 2)
@@ -160,6 +160,7 @@ static int tmp105_tx(I2CSlave *i2c, uint8_t data)
 tmp105_write(s);
 }
 
+s-len ++;
 return 0;
 }
 
-- 
1.7.6.5




Re: [Qemu-devel] [RFC] 1.4 release schedule

2012-12-05 Thread Blue Swirl
On Wed, Dec 5, 2012 at 7:41 PM, Hans de Goede hdego...@redhat.com wrote:
 Hi,


 On 12/05/2012 08:28 PM, Blue Swirl wrote:

 On Tue, Dec 4, 2012 at 10:00 PM, Anthony Liguori aligu...@us.ibm.com
 wrote:

 Peter Maydell peter.mayd...@linaro.org writes:

 On 4 December 2012 18:38, Blue Swirl blauwir...@gmail.com wrote:

 The definition of the hard freeze bothers me. A few patches that went
 in after 1.3-rc0 were not bug fixes but just new features, so the
 difference between soft and hard freezes was not clear.


 My vote for this would be to adhere to our definition
 and only commit bugfixes.


 Let's get specific.  What was committed post hard freeze that's not a
 bug fix?


 d3067b0 Documentation: Update image format information
 a13e5e0 Documentation: Update block cache mode information
 044d003 qemu-tech.texi: update implemented xtensa features list


 Adding missing / updating docs to be more accurate is a bug fix,
 and one with a very low chance of causing regressions at that.

I don't think they are bug fixes but improvements to documentation
features. But I agree patches only touching documentation, comment and
string contents could be exempted.



 a0a7068 target-i386: Enable SSSE3 TCG support
 80ae416 target-i386/cpu: Add missing flags to Haswell CPU model
 42015c9 virtio-rng: fix typos, comments
 e1e54f3 target-i386: cpu: add missing flags to Haswell CPU model
 339c270 qom: make object_finalize static
 64b625f qdev: simplify (de)allocation of buses
 fde9bf4 qom: make object_delete usable for statically-allocated objects
 667d22d qdev: move bus removal to object_unparent
 74c856e tests: add thread pool unit tests
 b2ea25d tests: add AioContext unit tests
 21022c9 q35: Add kvmclock support
 a1c9304 ich9: Add i82801b11 dmi-to-pci bridge
 df2d8b3 q35: Introduce q35 pc based chipset emulator
 678e7b9 ich9: Add smbus
 4d00636 ich9: Add the lpc chip
 e516572 ich9: Add acpi support and definitions
 410edd9 pc/piix_pci: factor out smram/pam logic
 d8ee038 pc_piix: Move kvm irq routing functions out of pc_piix.c
 a39e356 pc: Move ioapic_init() from pc_piix.c to pc.c
 9011a1a pc, pc_piix: split out pc nic initialization



 723aedd usb-redir: Don't handle interrupt output packets async

 Bug-fix

This was not clear from the description, from that it looked to me
that it's a general change with possibly good and bad effects.



 234e810 usb-redir: Split usb_handle_interrupt_data into separate
 in/out functions

 Preparation patch for the above bugfix, no functional changes.


 33c1a68 usb-bt: Return NAK instead of STALL when interrupt ep has no data

 Bug-fix

Word 'fix' was not mentioned in the description.



 Regards,

 Hans



Re: [Qemu-devel] [BUG] QEMU crashes when 64bit BAR is present

2012-12-05 Thread Alexey Korolev
Hi Gerd,
   Hi,

 And qemu error output is:
 qemu: /home/akorolev/qemu-kvm/exec.c:2255: register_subpage: Assertion 
 `existing-mr-subpage || existing-mr == io_mem_unassigned' failed.

 Guest OS is Centos 5.5 and log is pretty boring, as qemu crashes before 
 Linux can report an issue.
 Where does it crash? seabios? linux kernel?
 Still reproducable with 1.3.0?
It is a qemu core assertion.
Haven't tried 1.3.0 yet, can try it today.
The bug is quite easy to reproduce, if use ivshmem with 64bit tweaks and 
specify size 128M.




Re: [Qemu-devel] [BUG] QEMU crashes when 64bit BAR is present

2012-12-05 Thread Alexey Korolev
On 06/12/12 09:23, Alexey Korolev wrote:
 Hi Gerd,
   Hi,

 And qemu error output is:
 qemu: /home/akorolev/qemu-kvm/exec.c:2255: register_subpage: Assertion 
 `existing-mr-subpage || existing-mr == io_mem_unassigned' failed.

 Guest OS is Centos 5.5 and log is pretty boring, as qemu crashes before 
 Linux can report an issue.
 Where does it crash? seabios? linux kernel?
 Still reproducable with 1.3.0?
 It is a qemu core assertion.
It's a qemu assertion which occurs on early stage of linux bootup process. I 
guess it fails when linux calls HPET init functions. See this
post for details: 
http://lists.gnu.org/archive/html/qemu-devel/2012-01/msg03189.html

 Haven't tried 1.3.0 yet, can try it today.
 The bug is quite easy to reproduce, if use ivshmem with 64bit tweaks and 
 specify size 128M.






Re: [Qemu-devel] [PATCH v2] target-mips: Fix incorrect shift for SHILO and SHILOV

2012-12-05 Thread Johnson, Eric
 -Original Message-
 From: qemu-devel-bounces+ericj=mips@nongnu.org [mailto:qemu-devel-
 bounces+ericj=mips@nongnu.org] On Behalf Of Petar Jovanovic
 Sent: Tuesday, December 04, 2012 3:29 PM
 To: qemu-devel@nongnu.org
 Cc: blauwir...@gmail.com; Jovanovic, Petar; rth7...@gmail.com;
 afaer...@suse.de; aurel...@aurel32.net
 Subject: [Qemu-devel] [PATCH v2] target-mips: Fix incorrect shift for
 SHILO and SHILOV
 
 From: Petar Jovanovic pet...@mips.com
 
 helper_shilo has not been shifting an accumulator value correctly for
 negative
 values in 'shift' field. Minor optimization for shift=0 case.
 This change also adds tests that will trigger issue and check for
 regressions.
 
 Signed-off-by: Petar Jovanovic pet...@mips.com
 ---
  target-mips/dsp_helper.c   |   17 +
  tests/tcg/mips/mips32-dsp/shilo.c  |   18 ++
  tests/tcg/mips/mips32-dsp/shilov.c |   20 
  3 files changed, 47 insertions(+), 8 deletions(-)
 
 diff --git a/target-mips/dsp_helper.c b/target-mips/dsp_helper.c
 index e7949c2..44f6dc7 100644
 --- a/target-mips/dsp_helper.c
 +++ b/target-mips/dsp_helper.c
 @@ -3814,17 +3814,18 @@ void helper_shilo(target_ulong ac, target_ulong
 rs, CPUMIPSState *env)
 
  rs5_0 = rs  0x3F;
  rs5_0 = (int8_t)(rs5_0  2)  2;
 -rs5_0 = MIPSDSP_ABS(rs5_0);
 +
 +if (unlikely(rs5_0 == 0)) {
 +return;
 +}
 +
  acc   = (((uint64_t)env-active_tc.HI[ac]  32)  MIPSDSP_LHI) |
  ((uint64_t)env-active_tc.LO[ac]  MIPSDSP_LLO);
 -if (rs5_0 == 0) {
 -temp = acc;
 +
 +if (rs5_0  0) {
 +temp = acc  rs5_0;
  } else {
 -if (rs5_0  0) {
 -temp = acc  rs5_0;
 -} else {
 -temp = acc  rs5_0;
 -}
 +temp = acc  -rs5_0;
  }
 
  env-active_tc.HI[ac] = (target_ulong)(int32_t)((temp  MIPSDSP_LHI)
  32);
 diff --git a/tests/tcg/mips/mips32-dsp/shilo.c b/tests/tcg/mips/mips32-
 dsp/shilo.c
 index b686616..ce8ebc6 100644
 --- a/tests/tcg/mips/mips32-dsp/shilo.c
 +++ b/tests/tcg/mips/mips32-dsp/shilo.c
 @@ -23,5 +23,23 @@ int main()
  assert(ach == resulth);
  assert(acl == resultl);
 
 +
 +ach = 0x1;
 +acl = 0x8000;
 +
 +resulth = 0x3;
 +resultl = 0x0;
 +
 +__asm
 +(mthi %0, $ac1\n\t
 + mtlo %1, $ac1\n\t
 + shilo $ac1, -1\n\t
 + mfhi %0, $ac1\n\t
 + mflo %1, $ac1\n\t
 + : +r(ach), +r(acl)
 +);
 +assert(ach == resulth);
 +assert(acl == resultl);
 +
  return 0;
  }
 diff --git a/tests/tcg/mips/mips32-dsp/shilov.c b/tests/tcg/mips/mips32-
 dsp/shilov.c
 index f186032..e1d6cea 100644
 --- a/tests/tcg/mips/mips32-dsp/shilov.c
 +++ b/tests/tcg/mips/mips32-dsp/shilov.c
 @@ -25,5 +25,25 @@ int main()
  assert(ach == resulth);
  assert(acl == resultl);
 
 +
 +rs  = 0x;
 +ach = 0x1;
 +acl = 0x8000;
 +
 +resulth = 0x3;
 +resultl = 0x0;
 +
 +__asm
 +(mthi %0, $ac1\n\t
 + mtlo %1, $ac1\n\t
 + shilov $ac1, %2\n\t
 + mfhi %0, $ac1\n\t
 + mflo %1, $ac1\n\t
 + : +r(ach), +r(acl)
 + : r(rs)
 +);
 +assert(ach == resulth);
 +assert(acl == resultl);
 +
  return 0;
  }
 --
 1.7.5.4
 

Reviewed-by: Eric Johnson er...@mips.com



[Qemu-devel] [PATCH 01/11] qdev: export and use qbus_init

2012-12-05 Thread Paolo Bonzini
BusState subclasses need to do their own allocation because
qbus_create_inplace calls object_initialize (which wipes out the
free callback).  This patch separates the initialization of the object
(object_initialize) from its insertion in the qdev tree (qbus_realize); to
do so, it moves the remaining bits of qbus_create_inplace to qbus_realize
and export it as qbus_init.

Signed-off-by: Paolo Bonzini pbonz...@redhat.com
---
 hw/qdev-core.h |  1 +
 hw/qdev.c  | 18 +++---
 2 files changed, 8 insertions(+), 11 deletions(-)

diff --git a/hw/qdev-core.h b/hw/qdev-core.h
index fff7f0f..18f5f73 100644
--- a/hw/qdev-core.h
+++ b/hw/qdev-core.h
@@ -180,6 +180,7 @@ DeviceState *qdev_find_recursive(BusState *bus, const char 
*id);
 typedef int (qbus_walkerfn)(BusState *bus, void *opaque);
 typedef int (qdev_walkerfn)(DeviceState *dev, void *opaque);
 
+void qbus_init(BusState *bus, DeviceState *parent, const char *name);
 void qbus_create_inplace(BusState *bus, const char *typename,
  DeviceState *parent, const char *name);
 BusState *qbus_create(const char *typename, DeviceState *parent, const char 
*name);
diff --git a/hw/qdev.c b/hw/qdev.c
index 788b4da..e758131 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -403,14 +403,16 @@ DeviceState *qdev_find_recursive(BusState *bus, const 
char *id)
 return NULL;
 }
 
-static void qbus_realize(BusState *bus)
+void qbus_init(BusState *bus, DeviceState *parent, const char *name)
 {
 const char *typename = object_get_typename(OBJECT(bus));
 char *buf;
 int i,len;
 
-if (bus-name) {
-/* use supplied name */
+bus-parent = parent;
+
+if (name) {
+bus-name = g_strdup(name);
 } else if (bus-parent  bus-parent-id) {
 /* parent device has id - use it for bus name */
 len = strlen(bus-parent-id) + 16;
@@ -443,10 +445,7 @@ void qbus_create_inplace(BusState *bus, const char 
*typename,
  DeviceState *parent, const char *name)
 {
 object_initialize(bus, typename);
-
-bus-parent = parent;
-bus-name = name ? g_strdup(name) : NULL;
-qbus_realize(bus);
+qbus_init(bus, parent, name);
 }
 
 BusState *qbus_create(const char *typename, DeviceState *parent, const char 
*name)
@@ -454,10 +453,7 @@ BusState *qbus_create(const char *typename, DeviceState 
*parent, const char *nam
 BusState *bus;
 
 bus = BUS(object_new(typename));
-
-bus-parent = parent;
-bus-name = name ? g_strdup(name) : NULL;
-qbus_realize(bus);
+qbus_init(bus, parent, name);
 
 return bus;
 }
-- 
1.8.0.1





  1   2   >