[Qemu-devel] [PATCH] Remove code duplication from savevm instance_id creation code.

2010-11-07 Thread Gleb Natapov
Code in register_savevm_live() and vmstate_register_with_alias_id()
looks identical except idstr used. Move into separate function.

Signed-off-by: Gleb Natapov 
diff --git a/savevm.c b/savevm.c
index cf56121..6ca6920 100644
--- a/savevm.c
+++ b/savevm.c
@@ -1080,6 +1080,33 @@ static int calculate_compat_instance_id(const char 
*idstr)
 return instance_id;
 }
 
+static void setup_instance_id(DeviceState *dev, const char *idstr,
+  int instance_id, SaveStateEntry *se)
+{
+if (dev && dev->parent_bus && dev->parent_bus->info->get_dev_path) {
+char *id = dev->parent_bus->info->get_dev_path(dev);
+if (id) {
+pstrcpy(se->idstr, sizeof(se->idstr), id);
+pstrcat(se->idstr, sizeof(se->idstr), "/");
+qemu_free(id);
+
+se->compat = qemu_mallocz(sizeof(CompatEntry));
+pstrcpy(se->compat->idstr, sizeof(se->compat->idstr), idstr);
+se->compat->instance_id = instance_id == -1 ?
+ calculate_compat_instance_id(idstr) : instance_id;
+instance_id = -1;
+}
+}
+pstrcat(se->idstr, sizeof(se->idstr), idstr);
+
+if (instance_id == -1) {
+se->instance_id = calculate_new_instance_id(se->idstr);
+} else {
+se->instance_id = instance_id;
+}
+assert(!se->compat || se->instance_id == 0);
+}
+
 /* TODO: Individual devices generally have very little idea about the rest
of the system, so instance_id should be removed/replaced.
Meanwhile pass -1 as instance_id if you do not already have a clearly
@@ -1107,28 +1134,8 @@ int register_savevm_live(DeviceState *dev,
 se->vmsd = NULL;
 se->no_migrate = 0;
 
-if (dev && dev->parent_bus && dev->parent_bus->info->get_dev_path) {
-char *id = dev->parent_bus->info->get_dev_path(dev);
-if (id) {
-pstrcpy(se->idstr, sizeof(se->idstr), id);
-pstrcat(se->idstr, sizeof(se->idstr), "/");
-qemu_free(id);
-
-se->compat = qemu_mallocz(sizeof(CompatEntry));
-pstrcpy(se->compat->idstr, sizeof(se->compat->idstr), idstr);
-se->compat->instance_id = instance_id == -1 ?
- calculate_compat_instance_id(idstr) : instance_id;
-instance_id = -1;
-}
-}
-pstrcat(se->idstr, sizeof(se->idstr), idstr);
+setup_instance_id(dev, idstr, instance_id, se);
 
-if (instance_id == -1) {
-se->instance_id = calculate_new_instance_id(se->idstr);
-} else {
-se->instance_id = instance_id;
-}
-assert(!se->compat || se->instance_id == 0);
 /* add at the end of list */
 QTAILQ_INSERT_TAIL(&savevm_handlers, se, entry);
 return 0;
@@ -1217,28 +1224,8 @@ int vmstate_register_with_alias_id(DeviceState *dev, int 
instance_id,
 se->vmsd = vmsd;
 se->alias_id = alias_id;
 
-if (dev && dev->parent_bus && dev->parent_bus->info->get_dev_path) {
-char *id = dev->parent_bus->info->get_dev_path(dev);
-if (id) {
-pstrcpy(se->idstr, sizeof(se->idstr), id);
-pstrcat(se->idstr, sizeof(se->idstr), "/");
-qemu_free(id);
-
-se->compat = qemu_mallocz(sizeof(CompatEntry));
-pstrcpy(se->compat->idstr, sizeof(se->compat->idstr), vmsd->name);
-se->compat->instance_id = instance_id == -1 ?
- calculate_compat_instance_id(vmsd->name) : 
instance_id;
-instance_id = -1;
-}
-}
-pstrcat(se->idstr, sizeof(se->idstr), vmsd->name);
+setup_instance_id(dev, vmsd->name, instance_id, se);
 
-if (instance_id == -1) {
-se->instance_id = calculate_new_instance_id(se->idstr);
-} else {
-se->instance_id = instance_id;
-}
-assert(!se->compat || se->instance_id == 0);
 /* add at the end of list */
 QTAILQ_INSERT_TAIL(&savevm_handlers, se, entry);
 return 0;
--
Gleb.



[Qemu-devel] [Bug 668799] Re: qemu-arm segfaults executing msgmerge (gettext)

2010-11-07 Thread Jan-Simon Möller
We always see this in :

exec.c1662:

void cpu_exit(CPUState *env)
{
cpu_unlink_tb(env);
env->exit_request = 1;
}


A quick test with the statement cpu_unlink_tb(env) removed passed the test.

-- 
qemu-arm segfaults executing msgmerge (gettext)
https://bugs.launchpad.net/bugs/668799
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.

Status in QEMU: New

Bug description:
upstream qemu.git revision b45e9c05dbacba8e992f0bffeca04c6379c3ad45

Starting program: /usr/bin/qemu-arm msgmerge-static ar.po anjuta.pot

[Thread debugging using libthread_db enabled]
[New Thread 0x74bc3ff0 (LWP 26108)]
[New Thread 0x74b8aff0 (LWP 26109)]
[New Thread 0x74b51ff0 (LWP 26110)]
[New Thread 0x74b18ff0 (LWP 26111)]
[New Thread 0x74adfff0 (LWP 26112)]
[New Thread 0x74aa6ff0 (LWP 26113)]
[New Thread 0x74a6dff0 (LWP 26114)]
[New Thread 0x74a34ff0 (LWP 26115)]
[New Thread 0x749fbff0 (LWP 26116)]
[New Thread 0x749c2ff0 (LWP 26117)]
[New Thread 0x74989ff0 (LWP 26118)]
[New Thread 0x74950ff0 (LWP 26119)]
[New Thread 0x74917ff0 (LWP 26120)]
[New Thread 0x748deff0 (LWP 26121)]
[New Thread 0x748a5ff0 (LWP 26122)]
[New Thread 0x7486cff0 (LWP 26123)]
[New Thread 0x74833ff0 (LWP 26124)]
[New Thread 0x747faff0 (LWP 26125)]
[New Thread 0x747c1ff0 (LWP 26126)]
[New Thread 0x74788ff0 (LWP 26127)]
[New Thread 0x7474fff0 (LWP 26128)]
[New Thread 0x74716ff0 (LWP 26129)]
[New Thread 0x746ddff0 (LWP 26130)]
.
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x74aa6ff0 (LWP 26113)]
0x600480d4 in tb_reset_jump_recursive2 (tb=0x74c63540, n=0)
at /home/user/git/qemu/exec.c:1333
1333tb1 = tb1->jmp_next[n1];

(gdb) bt
#0  0x600480d4 in tb_reset_jump_recursive2 (tb=0x74c63540, n=0)
at /home/user/git/qemu/exec.c:1333
#1  0x600481c0 in tb_reset_jump_recursive (tb=0x74c63540)
at /home/user/git/qemu/exec.c:1361
#2  0x60048160 in tb_reset_jump_recursive2 (tb=0x74c634d8, n=0)
at /home/user/git/qemu/exec.c:1355
#3  0x600481c0 in tb_reset_jump_recursive (tb=0x74c634d8)
at /home/user/git/qemu/exec.c:1361
#4  0x60048160 in tb_reset_jump_recursive2 (tb=0x74c63470, n=0)
at /home/user/git/qemu/exec.c:1355
#5  0x600481c0 in tb_reset_jump_recursive (tb=0x74c63470)
at /home/user/git/qemu/exec.c:1361
#6  0x60048160 in tb_reset_jump_recursive2 (tb=0x74c63408, n=1)
at /home/user/git/qemu/exec.c:1355
#7  0x600481d1 in tb_reset_jump_recursive (tb=0x74c63408)
at /home/user/git/qemu/exec.c:1362
#8  0x60048160 in tb_reset_jump_recursive2 (tb=0x74c633a0, n=0)
at /home/user/git/qemu/exec.c:1355
#9  0x600481c0 in tb_reset_jump_recursive (tb=0x74c633a0)
at /home/user/git/qemu/exec.c:1361
#10 0x60048160 in tb_reset_jump_recursive2 (tb=0x74c63338, n=0)
at /home/user/git/qemu/exec.c:1355
#11 0x600481c0 in tb_reset_jump_recursive (tb=0x74c63338)
at /home/user/git/qemu/exec.c:1361
#12 0x60048160 in tb_reset_jump_recursive2 (tb=0x74c632d0, n=0)
at /home/user/git/qemu/exec.c:1355
---Type  to continue, or q  to quit---
#13 0x600481c0 in tb_reset_jump_recursive (tb=0x74c632d0)
at /home/user/git/qemu/exec.c:1361
#14 0x60048160 in tb_reset_jump_recursive2 (tb=0x74c63268, n=1)
at /home/user/git/qemu/exec.c:1355
#15 0x600481d1 in tb_reset_jump_recursive (tb=0x74c63268)
at /home/user/git/qemu/exec.c:1362
#16 0x60048160 in tb_reset_jump_recursive2 (tb=0x74c63200, n=0)
at /home/user/git/qemu/exec.c:1355
#17 0x600481c0 in tb_reset_jump_recursive (tb=0x74c63200)
at /home/user/git/qemu/exec.c:1361
#18 0x600487c5 in cpu_unlink_tb (env=0x62385400) at 
/home/user/git/qemu/exec.c:1617
#19 0x600488e8 in cpu_exit (env=0x62385400) at 
/home/user/git/qemu/exec.c:1662
#20 0x6798 in start_exclusive () at 
/home/user/git/qemu/linux-user/main.c:152
#21 0x6a4b in do_kernel_trap (env=0x62359940)
at /home/user/git/qemu/linux-user/main.c:493
#22 0x600023f3 in cpu_loop (env=0x62359940) at 
/home/user/git/qemu/linux-user/main.c:797
#23 0x600123df in clone_func (arg=0x7ffd76e0)
at /home/user/git/qemu/linux-user/syscall.c:3561
#24 0x600b382d in start_thread (arg=) at 
pthread_create.c:297
#25 0x600f1809 in clone () at 
../sysdeps/unix/sysv/linux/x86_64/clone.S:112
#26 0x in ?? ()
(gdb) 



Its interesting to see this :
#0  0x600480d4 in tb_reset_jump_recursive2 (tb=0x74c63540, n=0)
at /home/user/git/qemu/exec.c:1333
tb1 = 0x0   <<
tb_next = 0xf4c63610<<
ptb = 0x60341c91 

[Qemu-devel] [Bug 668799] Re: qemu-arm segfaults executing msgmerge (gettext)

2010-11-07 Thread Jan-Simon Möller
Alternative testcase:
compile and "export OMP_NUM_THREADS=6" before running.


/**
* FILE: omp_mm.c
* DESCRIPTION:  
*   OpenMp Example - Matrix Multiply - C Version
*   Demonstrates a matrix multiply using OpenMP. Threads share row iterations
*   according to a predefined chunk size.
* AUTHOR: Blaise Barney
* LAST REVISED: 06/28/05
**/
#include 
#include 
#include 

#define NRA 620 /* number of rows in matrix A */
#define NCA 150 /* number of columns in matrix A */
#define NCB 70  /* number of columns in matrix B */

int main (int argc, char *argv[]) 
{
int tid, nthreads, i, j, k, chunk;
double  a[NRA][NCA],   /* matrix A to be multiplied */
b[NCA][NCB],   /* matrix B to be multiplied */
c[NRA][NCB];   /* result matrix C */

chunk = 10;/* set loop iteration chunk size */

/*** Spawn a parallel region explicitly scoping all variables ***/
#pragma omp parallel shared(a,b,c,nthreads,chunk) private(tid,i,j,k)
  {
  tid = omp_get_thread_num();
  if (tid == 0)
{
nthreads = omp_get_num_threads();
printf("Starting matrix multiple example with %d threads\n",nthreads);
printf("Initializing matrices...\n");
}
  /*** Initialize matrices ***/
  #pragma omp for schedule (static, chunk) 
  for (i=0; ihttps://bugs.launchpad.net/bugs/668799
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.

Status in QEMU: New

Bug description:
upstream qemu.git revision b45e9c05dbacba8e992f0bffeca04c6379c3ad45

Starting program: /usr/bin/qemu-arm msgmerge-static ar.po anjuta.pot

[Thread debugging using libthread_db enabled]
[New Thread 0x74bc3ff0 (LWP 26108)]
[New Thread 0x74b8aff0 (LWP 26109)]
[New Thread 0x74b51ff0 (LWP 26110)]
[New Thread 0x74b18ff0 (LWP 26111)]
[New Thread 0x74adfff0 (LWP 26112)]
[New Thread 0x74aa6ff0 (LWP 26113)]
[New Thread 0x74a6dff0 (LWP 26114)]
[New Thread 0x74a34ff0 (LWP 26115)]
[New Thread 0x749fbff0 (LWP 26116)]
[New Thread 0x749c2ff0 (LWP 26117)]
[New Thread 0x74989ff0 (LWP 26118)]
[New Thread 0x74950ff0 (LWP 26119)]
[New Thread 0x74917ff0 (LWP 26120)]
[New Thread 0x748deff0 (LWP 26121)]
[New Thread 0x748a5ff0 (LWP 26122)]
[New Thread 0x7486cff0 (LWP 26123)]
[New Thread 0x74833ff0 (LWP 26124)]
[New Thread 0x747faff0 (LWP 26125)]
[New Thread 0x747c1ff0 (LWP 26126)]
[New Thread 0x74788ff0 (LWP 26127)]
[New Thread 0x7474fff0 (LWP 26128)]
[New Thread 0x74716ff0 (LWP 26129)]
[New Thread 0x746ddff0 (LWP 26130)]
.
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x74aa6ff0 (LWP 26113)]
0x600480d4 in tb_reset_jump_recursive2 (tb=0x74c63540, n=0)
at /home/user/git/qemu/exec.c:1333
1333tb1 = tb1->jmp_next[n1];

(gdb) bt
#0  0x600480d4 in tb_reset_jump_recursive2 (tb=0x74c63540, n=0)
at /home/user/git/qemu/exec.c:1333
#1  0x600481c0 in tb_reset_jump_recursive (tb=0x74c63540)
at /home/user/git/qemu/exec.c:1361
#2  0x60048160 in tb_reset_jump_recursive2 (tb=0x74c634d8, n=0)
at /home/user/git/qemu/exec.c:1355
#3  0x600481c0 in tb_reset_jump_recursive (tb=0x74c634d8)
at /home/user/git/qemu/exec.c:1361
#4  0x60048160 in tb_reset_jump_recursive2 (tb=0x74c63470, n=0)
at /home/user/git/qemu/exec.c:1355
#5  0x600481c0 in tb_reset_jump_recursive (tb=0x74c63470)
at /home/user/git/qemu/exec.c:1361
#6  0x60048160 in tb_reset_jump_recursive2 (tb=0x74c63408, n=1)
at /home/user/git/qemu/exec.c:1355
#7  0x600481d1 in tb_reset_jump_recursive (tb=0x74c63408)
at /home/user/git/qemu/exec.c:1362
#8  0x60048160 in tb_reset_jump_recursive2 (tb=0x74c633a0, n=0)
at /home/user/git/qemu/exec.c:1355
#9  0x600481c0 in tb_reset_jump_recursive (tb=0x74c633a0)
at /home/user/git/qemu/exec.c:1361
#10 0x60048160 in tb_reset_jump_recursive2 (tb=0x74c63338, n=0)
at /home/user/git/qemu/exec.c:1355
#11 0x600481c0 in tb_reset_jump_recursive (tb=0x74c63338)
at /home/user/git/qemu/exec.c:1361
#12 0x60048160 in tb_reset_jump_recursive2 (tb=0x74c632d0, n=0)
at /home/user/git/qemu/exec.c:1355
---Type  to continue, or q  to quit---
#13 0x600481c0 in tb_reset_jump_recursive (tb=0x74c632d0)
at /home/user/git/qemu/exec.c:1361
#14 0x60048160 in tb_reset_jump_recursive2 (tb=0x74c63268, n=1)
at /home/user/git/qemu/exec.c:1355
#15 0x600481d1 in tb_reset_jump_recursive (tb=0x74c63268)
at /home/user/git/qemu/exec.c:1362
#16 0x60048160 in tb_reset_jump_recursive2 (tb=0x74c63200, n=0)
at /home/user

Re: [Qemu-devel] [PATCH v2 5/6] backdoor: [i386] provide and implement intruction-based backdoor interface

2010-11-07 Thread Gleb Natapov
On Thu, Nov 04, 2010 at 11:36:15PM +0100, Lluís wrote:
> Take the unused CPUID 0x40001xxx range as the backdoor instruction.
> 
In KVM (and it fits the spec nicely) cpuid is defined in terms of
tables.  There is no callback that is called when particular cpuid is
queried, so such backdoor interface will be impossible to implement
in KVM. Furthermore any interface that changes/looks at vcpu state in
userspace is broken for KVM. Look at vmware backdoor interface for
instance. KVM  has a hack in emulator code to make it work.

> Signed-off-by: Lluís Vilanova 
> ---
>  backdoor/guest.h|   21 +
>  target-i386/cpuid.c |   27 +++
>  target-i386/helper.h|4 
>  target-i386/translate.c |4 
>  4 files changed, 56 insertions(+), 0 deletions(-)
> 
> diff --git a/backdoor/guest.h b/backdoor/guest.h
> index 8373762..3edcbc6 100644
> --- a/backdoor/guest.h
> +++ b/backdoor/guest.h
> @@ -26,8 +26,29 @@
>   * - v32: value of 32 bits
>   */
>  
> +#include 
> +
> +#if __i386__ || __i486__ || __x86_64__
> +
> +#define _BACKDOOR(t, i8, v32)   \
> +({  \
> +uint32_t eax, ebx, ecx, edx;\
> +uint32_t index = (uint32_t)0x40001000 + (t<<8) + (uint8_t)i8;   \
> +uint32_t count = (uint32_t)v32; \
> +asm volatile ("cpuid"   \
> +  : "=a"(eax), "=b"(ebx), "=c"(ecx), "=d"(edx)  \
> +  : "0"(index), "2"(count)  \
> +);  \
> +eax;\
> +})
> +
> +#define BACKDOOR_i8(i)_BACKDOOR(0, i, 0)
> +#define BACKDOOR_i8_v32(i, v) _BACKDOOR(1, i, v)
> +
> +#else
>  
>  #error Undefined instruction-based backdoor interface for guest architecture
>  
> +#endif
>  
>  #endif /* BACKDOOR__GUEST_H */
> diff --git a/target-i386/cpuid.c b/target-i386/cpuid.c
> index 650a719..03fc973 100644
> --- a/target-i386/cpuid.c
> +++ b/target-i386/cpuid.c
> @@ -27,6 +27,9 @@
>  #include "qemu-option.h"
>  #include "qemu-config.h"
>  
> +#include "helper.h"
> +
> +
>  /* feature flags taken from "Intel Processor Identification and the CPUID
>   * Instruction" and AMD's "CPUID Specification".  In cases of disagreement
>   * between feature naming conventions, aliases may be added.
> @@ -1033,6 +1036,30 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, 
> uint32_t count,
> uint32_t *eax, uint32_t *ebx,
> uint32_t *ecx, uint32_t *edx)
>  {
> +#if defined(CONFIG_BACKDOOR)/* synched with "backdoor/guest.h" */
> +if ((index & ~0xfff) == 0x40001000) {
> +int type = (index >> 8) & 0xf;
> +uint8_t i8 = index & 0x0ff;
> +uint32_t v32 = count;
> +switch (type) {
> +case 0:
> +helper_backdoor_i8(i8);
> +break;
> +case 1:
> +helper_backdoor_i8_v32(i8, v32);
> +break;
> +default:
> +printf("invalid backdoor request\n");
> +abort();
> +}
> +*eax = 0;
> +*ebx = 0;
> +*ecx = 0;
> +*edx = 0;
> +return;
> +}
> +#endif
> +
>  /* test if maximum index reached */
>  if (index & 0x8000) {
>  if (index > env->cpuid_xlevel)
> diff --git a/target-i386/helper.h b/target-i386/helper.h
> index 6b518ad..979d94e 100644
> --- a/target-i386/helper.h
> +++ b/target-i386/helper.h
> @@ -217,4 +217,8 @@ DEF_HELPER_2(rclq, tl, tl, tl)
>  DEF_HELPER_2(rcrq, tl, tl, tl)
>  #endif
>  
> +#if defined(CONFIG_BACKDOOR)
> +#include "backdoor/helper.h"
> +#endif
> +
>  #include "def-helper.h"
> diff --git a/target-i386/translate.c b/target-i386/translate.c
> index 7b6e3c2..dfdc2f0 100644
> --- a/target-i386/translate.c
> +++ b/target-i386/translate.c
> @@ -6941,6 +6941,10 @@ static target_ulong disas_insn(DisasContext *s, 
> target_ulong pc_start)
>  gen_op_set_cc_op(s->cc_op);
>  gen_jmp_im(pc_start - s->cs_base);
>  gen_helper_cpuid();
> +#if defined(CONFIG_BACKDOOR)
> +gen_jmp_im(s->pc);
> +gen_eob(s);
> +#endif
>  break;
>  case 0xf4: /* hlt */
>  if (s->cpl != 0) {
> 

--
Gleb.



Re: [Qemu-devel] [RESEND][PATCH] Remove 16-character limit on process title

2010-11-07 Thread Andreas Färber

Hello,

Am 05.11.2010 um 17:35 schrieb John Morrissey:

qemu uses prctl() to set its process title. I bumped up against  
prctl()'s

16-character limit recently, when adding process title support to
libvirt[1][2].

The attached patch overwrites argv instead. Linux seems to maintain  
the

length of the original args, even when the new args are shorter and
NULL-terminated, so the trailing whitespace in ps(1) output is  
probably
unavoidable. I've seen the same result with other daemons that  
overwrite

argv.


Please use git-send-email to send it inline along with a commit  
message, so that it can be better reviewed and applied.

Also lacks a Signed-off-by. Please see CODING_STYLE or list archives.

Andreas



john

[1] https://www.redhat.com/archives/libvir-list/2010-October/msg00565.html
[2] 
http://libvirt.org/git/?p=libvirt.git;a=commit;h=c08c7b0143b8cdc542e5f4137623d412340c5cf2
--
John Morrissey  _o/\   __o
j...@horde.net_-< \_  /  \     <  \,
www.horde.net/__(_)/_(_)/\___(_) /_(_)__






[Qemu-devel] Re: [sparc] Unassigned mem read access on writing?

2010-11-07 Thread Blue Swirl
On Fri, Nov 5, 2010 at 5:48 PM, Artyom Tarasenko  wrote:
> Trying to boot Solaris 2.1 I get the following error message:
>
> Unassigned mem read access of 1 byte to 0768 from f0014768
> qemu: fatal: Trap 0x29 while interrupts disabled, Error state
> pc: f0014768  npc: f001476c
>
> Looks like a read access to a non-mapped memory (the NF-bit is 0). But
> where can it happen?
>
> The code:
>
>   0xf001475c:  mov  0x200, %o4
> => 0xf0014760:  lda  [ %o4 ] #ASI_N, %o3
>   0xf0014764:  sta  %o2, [ %o4 ] #ASI_N
>   0xf0014768:  sta  %g0, [ %o0 ] (3)
>   0xf001476c:  cmp  %o2, %o3
>   0xf0014770:  bne  0xf001477c
> End of assembler dump.
> (gdb) stepi
> 0xf0014764 in ?? ()
> (gdb) info registers o2
> o2             0x28a    650
> (gdb) stepi
> Remote connection closed
> (gdb)
>
> Any ideas how to debug?

All accesses are 32 bits wide. ASI_N is 4 and the other store access
is to ASI 3 (MMU flush). I don't see how this is possible.

Perhaps PC and NPC are not updated as they should. If you insert a
breakpoint at the offending instruction, do you get the same error as
above with the same PC/NPC value?



Re: [Qemu-devel] [PATCH v2 RESEND] pc: e820 qemu_cfg tables need to be packed

2010-11-07 Thread Blue Swirl
On Fri, Nov 5, 2010 at 9:40 PM, Alex Williamson
 wrote:
> We can't let the compiler define the alignment for qemu_cfg data.

Actually, whole e820_table implementation seems to be buggy. The
structure may not be passed directly to fw_cfg interface without
endianness conversions, otherwise the emulation will not work on big
endian host.



[Qemu-devel] [PATCH] HDA: Honor WAKEEN bits when deciding to raise an interrupt on codec status

2010-11-07 Thread François Revol
From 2e6c61248c76d3f0c511658b9f34660d034703a4 Mon Sep 17 00:00:00 2001

HDA: Honor WAKEEN bits when deciding to raise an interrupt on codec status 
change.
This prevents an interrupt storm with the Haiku HDA driver which does not 
handle codec status changes in the irq handler.


Signed-off-by: François Revol 
---
 hw/intel-hda.c |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/hw/intel-hda.c b/hw/intel-hda.c
index ccb059d..f1bd203 100644
--- a/hw/intel-hda.c
+++ b/hw/intel-hda.c
@@ -235,7 +235,7 @@ static void intel_hda_update_int_sts(IntelHDAState *d)
 if (d->rirb_sts & ICH6_RBSTS_OVERRUN) {
 sts |= (1 << 30);
 }
-if (d->state_sts) {
+if (d->state_sts & d->wake_en) {
 sts |= (1 << 30);
 }
 
@@ -617,6 +617,7 @@ static const struct IntelHDAReg regtab[] = {
 [ ICH6_REG_WAKEEN ] = {
 .name = "WAKEEN",
 .size = 2,
+.wmask= 0x3fff,
 .offset   = offsetof(IntelHDAState, wake_en),
 },
 [ ICH6_REG_STATESTS ] = {
-- 
1.7.2.2





[Qemu-devel] [PATCH] Overwrite argv to set process title, eliminating 16-character prctl() limit.

2010-11-07 Thread John Morrissey
Linux seems to maintain the length of the original args, even when the new
args are shorter and NULL-terminated, so the trailing whitespace in ps(1)
output is probably unavoidable. I've seen the same result with other daemons
that overwrite argv.

Signed-off-by: John Morrissey 
---
 os-posix.c  |   32 
 qemu-os-posix.h |2 +-
 qemu-os-win32.h |3 ++-
 vl.c|   11 +--
 4 files changed, 28 insertions(+), 20 deletions(-)

diff --git a/os-posix.c b/os-posix.c
index 38c29d1..3ddf7e8 100644
--- a/os-posix.c
+++ b/os-posix.c
@@ -39,10 +39,6 @@
 #include "net/slirp.h"
 #include "qemu-options.h"
 
-#ifdef CONFIG_LINUX
-#include 
-#endif
-
 #ifdef CONFIG_EVENTFD
 #include 
 #endif
@@ -149,20 +145,24 @@ char *os_find_datadir(const char *argv0)
 #undef SHARE_SUFFIX
 #undef BUILD_SUFFIX
 
-void os_set_proc_name(const char *s)
+void os_set_proc_name(int argc, char **argv, const char *name)
 {
-#if defined(PR_SET_NAME)
-char name[16];
-if (!s)
+#ifdef CONFIG_LINUX
+char *last_argv_byte, *p;
+int len, i;
+
+if (!name)
 return;
-name[sizeof(name) - 1] = 0;
-strncpy(name, s, sizeof(name));
-/* Could rewrite argv[0] too, but that's a bit more complicated.
-   This simple way is enough for `top'. */
-if (prctl(PR_SET_NAME, name)) {
-perror("unable to change process name");
-exit(1);
-}
+
+last_argv_byte = argv[argc - 1] + strlen(argv[argc - 1]);
+
+len = snprintf(argv[0], last_argv_byte - argv[0], "%s", name);
+
+p = &argv[0][len];
+while (p <= last_argv_byte)
+*p++ = '\0';
+for (i = 1; i < argc; ++i)
+argv[i] = (char *) "";
 #else
 fprintf(stderr, "Change of process name not supported by your OS\n");
 exit(1);
diff --git a/qemu-os-posix.h b/qemu-os-posix.h
index 353f878..b0cf993 100644
--- a/qemu-os-posix.h
+++ b/qemu-os-posix.h
@@ -31,7 +31,7 @@ static inline void os_host_main_loop_wait(int *timeout)
 }
 
 void os_set_line_buffering(void);
-void os_set_proc_name(const char *s);
+void os_set_proc_name(int argc, char **argv, const char *name);
 void os_setup_signal_handling(void);
 void os_daemonize(void);
 void os_setup_post(void);
diff --git a/qemu-os-win32.h b/qemu-os-win32.h
index 1a07e5e..c618362 100644
--- a/qemu-os-win32.h
+++ b/qemu-os-win32.h
@@ -46,7 +46,8 @@ static inline void os_setup_signal_handling(void) {}
 static inline void os_daemonize(void) {}
 static inline void os_setup_post(void) {}
 void os_set_line_buffering(void);
-static inline void os_set_proc_name(const char *dummy) {}
+static inline void os_set_proc_name(int argc, char **argv,
+const char *dummy) {}
 
 #if !defined(EPROTONOSUPPORT)
 # define EPROTONOSUPPORT EINVAL
diff --git a/vl.c b/vl.c
index c58583d..4b203cf 100644
--- a/vl.c
+++ b/vl.c
@@ -1772,7 +1772,11 @@ static const QEMUOption *lookup_opt(int argc, char 
**argv,
 optarg = NULL;
 }
 
-*poptarg = optarg;
+if (optarg != NULL) {
+*poptarg = qemu_strdup(optarg);
+} else {
+*poptarg = NULL;
+}
 *poptind = optind;
 
 return popt;
@@ -1800,6 +1804,7 @@ int main(int argc, char **argv, char **envp)
 int tb_size;
 const char *pid_file = NULL;
 const char *incoming = NULL;
+const char *process_name = NULL;
 int show_vnc_port = 0;
 int defconfig = 1;
 
@@ -2493,7 +2498,7 @@ int main(int argc, char **argv, char **envp)
exit(1);
}
p += 8;
-   os_set_proc_name(p);
+   process_name = p;
 }  
 }  
 break;
@@ -2719,6 +2724,8 @@ int main(int argc, char **argv, char **envp)
 exit(1);
 }
 
+os_set_proc_name(argc, argv, process_name);
+
 if (kvm_allowed) {
 int ret = kvm_init(smp_cpus);
 if (ret < 0) {
-- 
1.7.0.4




[Qemu-devel] [PATCH] Initial implementation of a mpeg1 layer2 streaming audio driver.

2010-11-07 Thread François Revol
Initial implementation of a mpeg1 layer2 streaming audio driver.
It is based on the twolame library .
It allows one to listen to the audio produced by a VM from an mp3 http 
streaming client.
I just noticed esdaudio.c which I used as template on was under BSD licence, 
which is fine by me for this one as well.
For now it almost works with a Haiku guest (with HDA at 22050Hz and the WAKEEN 
patch I just sent), except with a 1min delay and missing frames, so it's 
possible buffers get queued up somewhere.


From 759ce26b14b7c9c5a24fba43b01cfb5d335086be Mon Sep 17 00:00:00 2001

Initial implementation of a mpeg1 layer2 streaming audio driver.
It is based on the twolame library .
Added a check for libtwolame to configure.


Signed-off-by: François Revol 
---
 Makefile.objs|1 +
 audio/audio.c|3 +
 audio/audio_int.h|1 +
 audio/twolameaudio.c |  393 ++
 configure|   20 +++
 5 files changed, 418 insertions(+), 0 deletions(-)
 create mode 100644 audio/twolameaudio.c

diff --git a/Makefile.objs b/Makefile.objs
index faf485e..370d59a 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -109,6 +109,7 @@ audio-obj-$(CONFIG_FMOD) += fmodaudio.o
 audio-obj-$(CONFIG_ESD) += esdaudio.o
 audio-obj-$(CONFIG_PA) += paaudio.o
 audio-obj-$(CONFIG_WINWAVE) += winwaveaudio.o
+audio-obj-$(CONFIG_TWOLAME) += twolameaudio.o
 audio-obj-$(CONFIG_AUDIO_PT_INT) += audio_pt_int.o
 audio-obj-$(CONFIG_AUDIO_WIN_INT) += audio_win_int.o
 audio-obj-y += wavcapture.o
diff --git a/audio/audio.c b/audio/audio.c
index ad51077..0c2c304 100644
--- a/audio/audio.c
+++ b/audio/audio.c
@@ -46,6 +46,9 @@
 static struct audio_driver *drvtab[] = {
 CONFIG_AUDIO_DRIVERS
 &no_audio_driver,
+#ifdef CONFIG_TWOLAME
+&twolame_audio_driver,
+#endif
 &wav_audio_driver
 };
 
diff --git a/audio/audio_int.h b/audio/audio_int.h
index d8560b6..337188b 100644
--- a/audio/audio_int.h
+++ b/audio/audio_int.h
@@ -210,6 +210,7 @@ extern struct audio_driver dsound_audio_driver;
 extern struct audio_driver esd_audio_driver;
 extern struct audio_driver pa_audio_driver;
 extern struct audio_driver winwave_audio_driver;
+extern struct audio_driver twolame_audio_driver;
 extern struct mixeng_volume nominal_volume;
 
 void audio_pcm_init_info (struct audio_pcm_info *info, struct audsettings *as);
diff --git a/audio/twolameaudio.c b/audio/twolameaudio.c
new file mode 100644
index 000..e121a91
--- /dev/null
+++ b/audio/twolameaudio.c
@@ -0,0 +1,393 @@
+/*
+ * QEMU twolame streaming audio driver
+ *
+ * Copyright (c) 2010 François Revol 
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to 
deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+#include "config-host.h"
+#include "qemu-common.h"
+#include "qemu-char.h"
+#include "qemu_socket.h"
+#include "audio.h"
+
+#define AUDIO_CAP "twolame"
+#include "audio_int.h"
+#include "audio_pt_int.h"
+
+#include 
+
+typedef struct {
+HWVoiceOut hw;
+int done;
+int live;
+int decr;
+int rpos;
+void *pcm_buf;
+void *mpg_buf;
+int lsock;
+int fd;
+struct audio_pt pt;
+twolame_options *options;
+} LAMEVoiceOut;
+
+static struct {
+int samples;
+int divisor;
+int port;
+int rate;
+} conf = {
+.samples = 1024,
+.divisor = 2,
+.port = 8080,
+.rate = 160
+};
+
+static const char http_header[] = "HTTP/1.1 200 OK\r\nServer: 
QEMU\r\nContent-Type: audio/mpeg\r\n\r\n";
+
+static void GCC_FMT_ATTR (2, 3) qtwolame_logerr (int err, const char *fmt, ...)
+{
+va_list ap;
+
+va_start (ap, fmt);
+AUD_vlog (AUDIO_CAP, fmt, ap);
+va_end (ap);
+
+AUD_log (AUDIO_CAP, "Reason: %s\n", strerror (err));
+}
+
+static void qtwolame_listen_read(void *opaque)
+{
+LAMEVoiceOut *twolame = opaque;
+struct sockaddr_in addr;
+socklen_t addrlen = sizeof(addr);
+
+if (twolame->fd > -1)
+return;
+
+int csock = qemu_accept(twola

[Qemu-devel] Re: [SeaBIOS] [PATCH v3 0/2] pciinit: fix overflow when bar allocation

2010-11-07 Thread Kevin O'Connor
On Thu, Oct 28, 2010 at 03:54:34PM +0900, Isaku Yamahata wrote:
> Changes v2 -> v3:
> - use [first, last] instead of [start, end)
> 
> Changes v1 -> v2:
> - add comment.
> 
> Patch description:
> This patch set fixes PCI bar allocation when bar overflow occured.
> I checked if pmm_alloc facility can be used, but it doesn't suit for
> pci bar allocation. So I resulted in new API, pci_region which
> encapsulates region allocation and overflow checks.
> The first patch introduces pci_region, and the second patch fixes
> the overflow case with pci_region.

Looks okay to me.  If there are no further comments, I'll commit.

BTW, as a minor nit - I'd prefer to put function descriptions in the
.c file next to the code instead of in the .h file - no need to resend
the patch though.

-Kevin



Re: [Qemu-devel] [PATCH] HDA: Honor WAKEEN bits when deciding to raise an interrupt on codec status

2010-11-07 Thread malc
On Sun, 7 Nov 2010, Fran?ois Revol wrote:

> From 2e6c61248c76d3f0c511658b9f34660d034703a4 Mon Sep 17 00:00:00 2001
> 
> HDA: Honor WAKEEN bits when deciding to raise an interrupt on codec 
> status change. This prevents an interrupt storm with the Haiku HDA 
> driver which does not handle codec status changes in the irq handler.
> 

Talk this over with the author of intel hda.

-- 
mailto:av1...@comtv.ru



[Qemu-devel] sparc32 "bneg,a" bug?

2010-11-07 Thread Artyom Tarasenko
Can it be that bneg,a branches unconditionally, or annuls unconditionally?

   0xf0071520:  subcc  %g3, %g2, %g3
=> 0xf0071524:  bneg,a   0xf007152c
   0xf0071528:  clr  %g3
   0xf007152c:  st  %g3, [ %i0 + 0x58 ]
(gdb) info registers g3 psr
g3 0x18 24
psr0x4000ae7[ #0 #1 #2 ET PS S #9 #11 #26 ]
(gdb) nexti
0xf007152c in ?? ()

 0xf0071528 is supposed to be executed. Or it a gdb stub bug?

-- 
Regards,
Artyom Tarasenko

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



[Qemu-devel] Re: [sparc] Unassigned mem read access on writing?

2010-11-07 Thread Artyom Tarasenko
On Sun, Nov 7, 2010 at 3:56 PM, Blue Swirl  wrote:
> On Fri, Nov 5, 2010 at 5:48 PM, Artyom Tarasenko  wrote:
>> Trying to boot Solaris 2.1 I get the following error message:
>>
>> Unassigned mem read access of 1 byte to 0768 from f0014768
>> qemu: fatal: Trap 0x29 while interrupts disabled, Error state
>> pc: f0014768  npc: f001476c
>>
>> Looks like a read access to a non-mapped memory (the NF-bit is 0). But
>> where can it happen?
>>
>> The code:
>>
>>   0xf001475c:  mov  0x200, %o4
>> => 0xf0014760:  lda  [ %o4 ] #ASI_N, %o3
>>   0xf0014764:  sta  %o2, [ %o4 ] #ASI_N
>>   0xf0014768:  sta  %g0, [ %o0 ] (3)
>>   0xf001476c:  cmp  %o2, %o3
>>   0xf0014770:  bne  0xf001477c
>> End of assembler dump.
>> (gdb) stepi
>> 0xf0014764 in ?? ()
>> (gdb) info registers o2
>> o2             0x28a    650
>> (gdb) stepi
>> Remote connection closed
>> (gdb)
>>
>> Any ideas how to debug?
>
> All accesses are 32 bits wide. ASI_N is 4 and the other store access
> is to ASI 3 (MMU flush). I don't see how this is possible.
>
> Perhaps PC and NPC are not updated as they should. If you insert a
> breakpoint at the offending instruction, do you get the same error as
> above with the same PC/NPC value?

The crash is the same but it doesn't break. The option -singlestep
makes no difference either.
The log tail of ran with -d in_asm -singlestep:

IN:
0xf0014760:  lda  [ %o4 ] #ASI_M_MMUREGS, %o3
--
IN:
0xf0014764:  sta  %o2, [ %o4 ] #ASI_M_MMUREGS
qemu: fatal: Trap 0x29 while interrupts disabled, Error state
pc: f0014768  npc: f001476c


-- 
Regards,
Artyom Tarasenko

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



Re: [Qemu-devel] [PATCH] Initial implementation of a mpeg1 layer2 streaming audio driver.

2010-11-07 Thread malc
On Sun, 7 Nov 2010, Fran?ois Revol wrote:

Please CC audio related stuff to audio maintainer.

> Initial implementation of a mpeg1 layer2 streaming audio driver.
> It is based on the twolame library .
> It allows one to listen to the audio produced by a VM from an mp3 http 
> streaming client.
> I just noticed esdaudio.c which I used as template on was under BSD licence, 
> which is fine by me for this one as well.
> For now it almost works with a Haiku guest (with HDA at 22050Hz and the 
> WAKEEN patch I just sent), except with a 1min delay and missing frames, so 
> it's possible buffers get queued up somewhere.
> 
> 
> From 759ce26b14b7c9c5a24fba43b01cfb5d335086be Mon Sep 17 00:00:00 2001
> 
> Initial implementation of a mpeg1 layer2 streaming audio driver.
> It is based on the twolame library .
> Added a check for libtwolame to configure.
> 
> 
> Signed-off-by: Fran?ois Revol 
> ---
>  Makefile.objs|1 +
>  audio/audio.c|3 +
>  audio/audio_int.h|1 +
>  audio/twolameaudio.c |  393 
> ++
>  configure|   20 +++
>  5 files changed, 418 insertions(+), 0 deletions(-)
>  create mode 100644 audio/twolameaudio.c
> 
> diff --git a/Makefile.objs b/Makefile.objs
> index faf485e..370d59a 100644
> --- a/Makefile.objs
> +++ b/Makefile.objs
> @@ -109,6 +109,7 @@ audio-obj-$(CONFIG_FMOD) += fmodaudio.o
>  audio-obj-$(CONFIG_ESD) += esdaudio.o
>  audio-obj-$(CONFIG_PA) += paaudio.o
>  audio-obj-$(CONFIG_WINWAVE) += winwaveaudio.o
> +audio-obj-$(CONFIG_TWOLAME) += twolameaudio.o
>  audio-obj-$(CONFIG_AUDIO_PT_INT) += audio_pt_int.o
>  audio-obj-$(CONFIG_AUDIO_WIN_INT) += audio_win_int.o
>  audio-obj-y += wavcapture.o
> diff --git a/audio/audio.c b/audio/audio.c
> index ad51077..0c2c304 100644
> --- a/audio/audio.c
> +++ b/audio/audio.c
> @@ -46,6 +46,9 @@
>  static struct audio_driver *drvtab[] = {
>  CONFIG_AUDIO_DRIVERS
>  &no_audio_driver,
> +#ifdef CONFIG_TWOLAME
> +&twolame_audio_driver,
> +#endif
>  &wav_audio_driver
>  };
>  
> diff --git a/audio/audio_int.h b/audio/audio_int.h
> index d8560b6..337188b 100644
> --- a/audio/audio_int.h
> +++ b/audio/audio_int.h
> @@ -210,6 +210,7 @@ extern struct audio_driver dsound_audio_driver;
>  extern struct audio_driver esd_audio_driver;
>  extern struct audio_driver pa_audio_driver;
>  extern struct audio_driver winwave_audio_driver;
> +extern struct audio_driver twolame_audio_driver;
>  extern struct mixeng_volume nominal_volume;
>  
>  void audio_pcm_init_info (struct audio_pcm_info *info, struct audsettings 
> *as);
> diff --git a/audio/twolameaudio.c b/audio/twolameaudio.c
> new file mode 100644
> index 000..e121a91
> --- /dev/null
> +++ b/audio/twolameaudio.c
> @@ -0,0 +1,393 @@
> +/*
> + * QEMU twolame streaming audio driver
> + *
> + * Copyright (c) 2010 Fran?ois Revol 
> + *
> + * Permission is hereby granted, free of charge, to any person obtaining a 
> copy
> + * of this software and associated documentation files (the "Software"), to 
> deal
> + * in the Software without restriction, including without limitation the 
> rights
> + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
> + * copies of the Software, and to permit persons to whom the Software is
> + * furnished to do so, subject to the following conditions:
> + *
> + * The above copyright notice and this permission notice shall be included in
> + * all copies or substantial portions of the Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
> + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
> FROM,
> + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
> + * THE SOFTWARE.
> + */
> +#include "config-host.h"
> +#include "qemu-common.h"
> +#include "qemu-char.h"
> +#include "qemu_socket.h"
> +#include "audio.h"
> +
> +#define AUDIO_CAP "twolame"
> +#include "audio_int.h"
> +#include "audio_pt_int.h"
> +
> +#include 
> +
> +typedef struct {
> +HWVoiceOut hw;
> +int done;
> +int live;
> +int decr;
> +int rpos;
> +void *pcm_buf;
> +void *mpg_buf;
> +int lsock;
> +int fd;
> +struct audio_pt pt;
> +twolame_options *options;
> +} LAMEVoiceOut;
> +
> +static struct {
> +int samples;
> +int divisor;
> +int port;
> +int rate;
> +} conf = {
> +.samples = 1024,
> +.divisor = 2,
> +.port = 8080,
> +.rate = 160
> +};
> +
> +static const char http_header[] = "HTTP/1.1 200 OK\r\nServer: 
> QEMU\r\nContent-Type: audio/mpeg\r\n\r\n";

Line is too long.

> +
> +static void GCC_FMT_ATTR (2, 3) qtwolame_logerr (int err, const char *fmt, 
> ..

Re: [Qemu-devel] [PATCH] Initial implementation of a mpeg1 layer2 streaming audio driver.

2010-11-07 Thread François Revol

Le 7 nov. 2010 à 19:09, malc a écrit :

> On Sun, 7 Nov 2010, Fran?ois Revol wrote:
> 
> Please CC audio related stuff to audio maintainer.

And that'd be you according to MAINTAINERS ?

>> +static const char http_header[] = "HTTP/1.1 200 OK\r\nServer: 
>> QEMU\r\nContent-Type: audio/mpeg\r\n\r\n";
> 
> Line is too long.

Ok I'll break at 80col.

>> +if (twolame->fd > -1)
>> +return;
> 
> Style.

That is ?

>> +
>> +int csock = qemu_accept(twolame->lsock, (struct sockaddr *)&addr, 
>> &addrlen);
> 
> C99 intermixed declartion and initialization is not allowed.

This line I copied form ui/vnc.c which does violate C89 too btw...

>> +
>> +again:
>> +if (twolame->fd > -1) {
>> +written = write (twolame->fd, twolame->mpg_buf, converted);
>> +if (written == -1) {
>> +if (errno == EPIPE) {
>> +dolog ("Lost peer\n");
>> +close (twolame->fd);
>> +twolame->fd = -1;
>> +goto again;
> 
> This goto is obfuscated.

Not much more than in esdaudio.c



>> +}
>> +obt_as.endianness = AUDIO_HOST_ENDIANNESS;
>> +
>> +audio_pcm_init_info (&hw->info, &obt_as);
>> +
>> +twolame_set_mode(twolame->options, (as->nchannels == 2) ? 
>> TWOLAME_STEREO : TWOLAME_MONO);
>> +twolame_set_num_channels(twolame->options, as->nchannels);
>> +twolame_set_in_samplerate(twolame->options, as->freq);
>> +twolame_set_out_samplerate(twolame->options, as->freq);
>> +twolame_set_bitrate(twolame->options, 160); //XXX:conf.
>> +
>> +if (twolame_init_params(twolame->options)) {
>> +dolog ("Could not set twolame options\n");
>> +return -1;
>> +}
> 
> Inconsistent space before opening paren.

Sorry, used to the Haiku style without space before but it seemed to be 
different around.


>> +twolame->mpg_buf = audio_calloc (AUDIO_FUNC, hw->samples, 1 << 
>> hw->info.shift);
>> +if (!twolame->mpg_buf) {
> 
> pcm_buf is not freed.
> 
>> +
>> +// fail1:
> 
> Do not use C99 style comments.

Oh that's leftover from copied error handling, which isn't correct anyway.

François.




Re: [Qemu-devel] [PATCH] Overwrite argv to set process title, eliminating 16-character prctl() limit.

2010-11-07 Thread Andreas Färber

Am 07.11.2010 um 16:44 schrieb John Morrissey:

Linux seems to maintain the length of the original args, even when  
the new
args are shorter and NULL-terminated, so the trailing whitespace in  
ps(1)
output is probably unavoidable. I've seen the same result with other  
daemons

that overwrite argv.

Signed-off-by: John Morrissey 
---



diff --git a/os-posix.c b/os-posix.c
index 38c29d1..3ddf7e8 100644
--- a/os-posix.c
+++ b/os-posix.c



@@ -149,20 +145,24 @@ char *os_find_datadir(const char *argv0)
#undef SHARE_SUFFIX
#undef BUILD_SUFFIX

-void os_set_proc_name(const char *s)
+void os_set_proc_name(int argc, char **argv, const char *name)
{
-#if defined(PR_SET_NAME)
-char name[16];
-if (!s)
+#ifdef CONFIG_LINUX


Is PR_SET_NAME defined outside Linux? If so, then your patch removes  
the limited functionality for those platforms completely.


Andreas



Re: [Qemu-devel] [PATCH] Initial implementation of a mpeg1 layer2 streaming audio driver.

2010-11-07 Thread malc
On Sun, 7 Nov 2010, Fran?ois Revol wrote:

> 
> Le 7 nov. 2010 ? 19:09, malc a ?crit :
> 
> > On Sun, 7 Nov 2010, Fran?ois Revol wrote:
> > 
> > Please CC audio related stuff to audio maintainer.
> 
> And that'd be you according to MAINTAINERS ?
> 
> >> +static const char http_header[] = "HTTP/1.1 200 OK\r\nServer: 
> >> QEMU\r\nContent-Type: audio/mpeg\r\n\r\n";
> > 
> > Line is too long.
> 
> Ok I'll break at 80col.
> 
> >> +if (twolame->fd > -1)
> >> +return;
> > 
> > Style.
> 
> That is ?

Braces around statements.

> >> +
> >> +int csock = qemu_accept(twolame->lsock, (struct sockaddr *)&addr, 
> >> &addrlen);
> > 
> > C99 intermixed declartion and initialization is not allowed.
> 
> This line I copied form ui/vnc.c which does violate C89 too btw...

I do not maintain ui/vnc.c.

> 
> >> +
> >> +again:
> >> +if (twolame->fd > -1) {
> >> +written = write (twolame->fd, twolame->mpg_buf, 
> >> converted);
> >> +if (written == -1) {
> >> +if (errno == EPIPE) {
> >> +dolog ("Lost peer\n");
> >> +close (twolame->fd);
> >> +twolame->fd = -1;
> >> +goto again;
> > 
> > This goto is obfuscated.
> 
> Not much more than in esdaudio.c
> 

Yes much more, esdaudio doesn't close the descriptor before jumping.

> 
> >> +}
> >> +obt_as.endianness = AUDIO_HOST_ENDIANNESS;
> >> +
> >> +audio_pcm_init_info (&hw->info, &obt_as);
> >> +
> >> +twolame_set_mode(twolame->options, (as->nchannels == 2) ? 
> >> TWOLAME_STEREO : TWOLAME_MONO);
> >> +twolame_set_num_channels(twolame->options, as->nchannels);
> >> +twolame_set_in_samplerate(twolame->options, as->freq);
> >> +twolame_set_out_samplerate(twolame->options, as->freq);
> >> +twolame_set_bitrate(twolame->options, 160); //XXX:conf.
> >> +
> >> +if (twolame_init_params(twolame->options)) {
> >> +dolog ("Could not set twolame options\n");
> >> +return -1;
> >> +}
> > 
> > Inconsistent space before opening paren.
> 
> Sorry, used to the Haiku style without space before but it seemed to be 
> different around.
> 
> 
> >> +twolame->mpg_buf = audio_calloc (AUDIO_FUNC, hw->samples, 1 << 
> >> hw->info.shift);
> >> +if (!twolame->mpg_buf) {
> > 
> > pcm_buf is not freed.
> > 
> >> +
> >> +// fail1:
> > 
> > Do not use C99 style comments.
> 
> Oh that's leftover from copied error handling, which isn't correct anyway.
> 
> Fran?ois.
> 

-- 
mailto:av1...@comtv.ru



[Qemu-devel] Re: [PATCH] Overwrite argv to set process title, eliminating 16-character prctl() limit.

2010-11-07 Thread John Morrissey
On Sun, Nov 07, 2010 at 07:27:22PM +0100, Andreas Färber wrote:
> Am 07.11.2010 um 16:44 schrieb John Morrissey:
> >@@ -149,20 +145,24 @@ char *os_find_datadir(const char *argv0)
> >#undef SHARE_SUFFIX
> >#undef BUILD_SUFFIX
> >
> >-void os_set_proc_name(const char *s)
> >+void os_set_proc_name(int argc, char **argv, const char *name)
> >{
> >-#if defined(PR_SET_NAME)
> >-char name[16];
> >-if (!s)
> >+#ifdef CONFIG_LINUX
> 
> Is PR_SET_NAME defined outside Linux? If so, then your patch removes
> the limited functionality for those platforms completely.

PR_SET_NAME is defined in sys/prctl.h which, before this patch, was
conditionally included only on Linux platforms (CONFIG_LINUX).

Additionally, prctl(2) says:

  CONFORMING TO
 This  call  is  Linux-specific.

john
-- 
John Morrissey  _o/\   __o
j...@horde.net_-< \_  /  \     <  \,
www.horde.net/__(_)/_(_)/\___(_) /_(_)__



[Qemu-devel] Re: sparc32 "bneg,a" bug?

2010-11-07 Thread Blue Swirl
On Sun, Nov 7, 2010 at 5:22 PM, Artyom Tarasenko  wrote:
> Can it be that bneg,a branches unconditionally, or annuls unconditionally?
>
>   0xf0071520:  subcc  %g3, %g2, %g3
> => 0xf0071524:  bneg,a   0xf007152c
>   0xf0071528:  clr  %g3
>   0xf007152c:  st  %g3, [ %i0 + 0x58 ]
> (gdb) info registers g3 psr
> g3             0x18     24
> psr            0x4000ae7        [ #0 #1 #2 ET PS S #9 #11 #26 ]
> (gdb) nexti
> 0xf007152c in ?? ()
>
>  0xf0071528 is supposed to be executed. Or it a gdb stub bug?

It should not be executed. Since N flag is not set and this is an
ICC-conditional branch, the delay instruction is annulled. See V8
manual B.21, page 120.

The following program produces the same results natively and with QEMU:
$ cat bneg.c
#include 

long f(long val)
{
long ret;

asm("tst %1\n\t"
"clr %0\n\t"
"bneg,a 1f\n\t"
"or %0, 1, %0\n\t"
"or %0, 2, %0\n\t"
"or %0, 4, %0\n\t"
"1: \n\t"
: "=r" (ret) : "r" (val));
return ret;
}

int main(int argc, const char **argv)
{
long x;

x = -1;
printf("f(0x%lx) = 0x%lx\n", x, f(x));
x = 0;
printf("f(0x%lx) = 0x%lx\n", x, f(x));

return 0;
}
$ gcc -o bneg bneg.c
$ ./bneg
f(0x) = 0x1
f(0x0) = 0x6
$ qemu-sparc32plus ./bneg
f(0x) = 0x1
f(0x0) = 0x6



Re: [Qemu-devel] [PATCH] Overwrite argv to set process title, eliminating 16-character prctl() limit.

2010-11-07 Thread Torsten Förtsch
Hi,

On Sunday, November 07, 2010 16:44:12 John Morrissey wrote:
> -if (prctl(PR_SET_NAME, name)) {
> -perror("unable to change process name");
> -exit(1);
> -}
> +
> +last_argv_byte = argv[argc - 1] + strlen(argv[argc - 1]);
> +
> +len = snprintf(argv[0], last_argv_byte - argv[0], "%s", name);
> +
> +p = &argv[0][len];
> +while (p <= last_argv_byte)
> +*p++ = '\0';
> +for (i = 1; i < argc; ++i)
> +argv[i] = (char *) "";

I am quite new to the list but why not do both call prctl(PR_SET_NAME, name) 
and overwrite argv?

The point is some tools read /proc/PID/cmdline but others the name field in 
/proc/PID/status. The former is changed by overwriting argv the latter by 
prctl.

Torsten Förtsch

-- 
Need professional modperl support? Hire me! (http://foertsch.name)

Like fantasy? http://kabatinte.net



[Qemu-devel] Re: sparc32 "bneg,a" bug?

2010-11-07 Thread Artyom Tarasenko
On Sun, Nov 7, 2010 at 9:32 PM, Blue Swirl  wrote:
> On Sun, Nov 7, 2010 at 5:22 PM, Artyom Tarasenko  wrote:
>> Can it be that bneg,a branches unconditionally, or annuls unconditionally?
>>
>>   0xf0071520:  subcc  %g3, %g2, %g3
>> => 0xf0071524:  bneg,a   0xf007152c
>>   0xf0071528:  clr  %g3
>>   0xf007152c:  st  %g3, [ %i0 + 0x58 ]
>> (gdb) info registers g3 psr
>> g3             0x18     24
>> psr            0x4000ae7        [ #0 #1 #2 ET PS S #9 #11 #26 ]
>> (gdb) nexti
>> 0xf007152c in ?? ()
>>
>>  0xf0071528 is supposed to be executed. Or it a gdb stub bug?
>
> It should not be executed. Since N flag is not set and this is an
> ICC-conditional branch, the delay instruction is annulled. See V8
> manual B.21, page 120.

Ops. Sorry for the noise. I missed that  the annul bit has a different
effect on
conditional branches than it does on unconditional ones.
Thanks for the clarification!

> The following program produces the same results natively and with QEMU:
> $ cat bneg.c
> #include 
>
> long f(long val)
> {
>    long ret;
>
>    asm("tst %1\n\t"
>        "clr %0\n\t"
>        "bneg,a 1f\n\t"
>        "or %0, 1, %0\n\t"
>        "or %0, 2, %0\n\t"
>        "or %0, 4, %0\n\t"
>        "1: \n\t"
>        : "=r" (ret) : "r" (val));
>    return ret;
> }
>
> int main(int argc, const char **argv)
> {
>    long x;
>
>    x = -1;
>    printf("f(0x%lx) = 0x%lx\n", x, f(x));
>    x = 0;
>    printf("f(0x%lx) = 0x%lx\n", x, f(x));
>
>    return 0;
> }
> $ gcc -o bneg bneg.c
> $ ./bneg
> f(0x) = 0x1
> f(0x0) = 0x6
> $ qemu-sparc32plus ./bneg
> f(0x) = 0x1
> f(0x0) = 0x6
>



-- 
Regards,
Artyom Tarasenko

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



[Qemu-devel] [PATCH 1/2] rtl8139: add vlan tag insertion

2010-11-07 Thread Benjamin Poirier
Add support to the emulated hardware to add vlan tags in packets going
from the guest to the network.

Signed-off-by: Benjamin Poirier 
Cc: Igor V. Kovalenko 
---
 hw/rtl8139.c |   46 +++---
 1 files changed, 35 insertions(+), 11 deletions(-)

diff --git a/hw/rtl8139.c b/hw/rtl8139.c
index d92981d..ac294da 100644
--- a/hw/rtl8139.c
+++ b/hw/rtl8139.c
@@ -47,6 +47,8 @@
  *  Darwin)
  */
 
+#include 
+
 #include "hw.h"
 #include "pci.h"
 #include "qemu-timer.h"
@@ -58,6 +60,10 @@
 
 #define PCI_FREQUENCY 3300L
 
+/* bytes in VLAN tag */
+#define VLAN_TCI_LEN 2
+#define VLAN_HDR_LEN (ETHER_TYPE_LEN + VLAN_TCI_LEN)
+
 /* debug RTL8139 card C+ mode only */
 //#define DEBUG_RTL8139CP 1
 
@@ -1913,7 +1919,6 @@ static int rtl8139_cplus_transmit_one(RTL8139State *s)
 
 cpu_physical_memory_read(cplus_tx_ring_desc,(uint8_t *)&val, 4);
 txdw0 = le32_to_cpu(val);
-/* TODO: implement VLAN tagging support, VLAN tag data is read to txdw1 */
 cpu_physical_memory_read(cplus_tx_ring_desc+4,  (uint8_t *)&val, 4);
 txdw1 = le32_to_cpu(val);
 cpu_physical_memory_read(cplus_tx_ring_desc+8,  (uint8_t *)&val, 4);
@@ -1925,9 +1930,6 @@ static int rtl8139_cplus_transmit_one(RTL8139State *s)
descriptor,
txdw0, txdw1, txbufLO, txbufHI));
 
-/* TODO: the following discard cast should clean clang analyzer output */
-(void)txdw1;
-
 /* w0 ownership flag */
 #define CP_TX_OWN (1<<31)
 /* w0 end of ring flag */
@@ -1951,8 +1953,8 @@ static int rtl8139_cplus_transmit_one(RTL8139State *s)
 /* w0 bits 0...15 : buffer size */
 #define CP_TX_BUFFER_SIZE (1<<16)
 #define CP_TX_BUFFER_SIZE_MASK (CP_TX_BUFFER_SIZE - 1)
-/* w1 tag available flag */
-#define CP_RX_TAGC (1<<17)
+/* w1 add tag flag */
+#define CP_TX_TAGC (1<<17)
 /* w1 bits 0...15 : VLAN tag */
 #define CP_TX_VLAN_TAG_MASK ((1<<16) - 1)
 /* w2 low  32bit of Rx buffer ptr */
@@ -1978,12 +1980,22 @@ static int rtl8139_cplus_transmit_one(RTL8139State *s)
 
 DEBUG_PRINT(("RTL8139: +++ C+ Tx mode : transmitting from descriptor 
%d\n", descriptor));
 
+int vlan_extra_size = 0;
 if (txdw0 & CP_TX_FS)
 {
 DEBUG_PRINT(("RTL8139: +++ C+ Tx mode : descriptor %d is first segment 
descriptor\n", descriptor));
 
+DEBUG_PRINT(("RTL8139: +++ C+ Tx mode : add vlan tag: %u tci: %u\n",
+!!(txdw1 & CP_TX_TAGC), bswap16(txdw1 &
+CP_TX_VLAN_TAG_MASK)));
+
 /* reset internal buffer offset */
 s->cplus_txbuffer_offset = 0;
+
+if (txdw1 & CP_TX_TAGC)
+{
+vlan_extra_size = VLAN_HDR_LEN;
+}
 }
 
 int txsize = txdw0 & CP_TX_BUFFER_SIZE_MASK;
@@ -1992,14 +2004,15 @@ static int rtl8139_cplus_transmit_one(RTL8139State *s)
 /* make sure we have enough space to assemble the packet */
 if (!s->cplus_txbuffer)
 {
-s->cplus_txbuffer_len = CP_TX_BUFFER_SIZE;
+s->cplus_txbuffer_len = CP_TX_BUFFER_SIZE + VLAN_HDR_LEN;
 s->cplus_txbuffer = qemu_malloc(s->cplus_txbuffer_len);
 s->cplus_txbuffer_offset = 0;
 
 DEBUG_PRINT(("RTL8139: +++ C+ mode transmission buffer allocated space 
%d\n", s->cplus_txbuffer_len));
 }
 
-while (s->cplus_txbuffer && s->cplus_txbuffer_offset + txsize >= 
s->cplus_txbuffer_len)
+while (s->cplus_txbuffer && s->cplus_txbuffer_offset + txsize +
+vlan_extra_size >= s->cplus_txbuffer_len)
 {
 s->cplus_txbuffer_len += CP_TX_BUFFER_SIZE;
 s->cplus_txbuffer = qemu_realloc(s->cplus_txbuffer, 
s->cplus_txbuffer_len);
@@ -2025,6 +2038,20 @@ static int rtl8139_cplus_transmit_one(RTL8139State *s)
 DEBUG_PRINT(("RTL8139: +++ C+ mode transmit reading %d bytes from host 
memory at %016" PRIx64 " to offset %d\n",
  txsize, (uint64_t)tx_addr, s->cplus_txbuffer_offset));
 
+if (vlan_extra_size && txsize >= 2 * ETHER_ADDR_LEN)
+{
+/* copy addresses */
+cpu_physical_memory_read(tx_addr, s->cplus_txbuffer, 2 *
+ETHER_ADDR_LEN);
+tx_addr += 2 * ETHER_ADDR_LEN;
+txsize -= 2 * ETHER_ADDR_LEN;
+/* insert vlan tag */
+*(uint16_t *)(s->cplus_txbuffer + 2 * ETHER_ADDR_LEN) =
+cpu_to_be16(ETHERTYPE_VLAN);
+*(uint16_t *)(s->cplus_txbuffer + 2 * ETHER_ADDR_LEN + ETHER_TYPE_LEN)
+= cpu_to_le16(txdw1 & CP_TX_VLAN_TAG_MASK);
+s->cplus_txbuffer_offset += 2 * ETHER_ADDR_LEN + VLAN_HDR_LEN;
+}
 cpu_physical_memory_read(tx_addr, s->cplus_txbuffer + 
s->cplus_txbuffer_offset, txsize);
 s->cplus_txbuffer_offset += txsize;
 
@@ -2053,9 +2080,6 @@ static int rtl8139_cplus_transmit_one(RTL8139State *s)
 /* update ring data */
 val = cpu_to_le32(txdw0);
 cpu_physical_memory_write(cplus_tx_ring_desc,(uint8_t *)&val, 4);
-/* TODO: implement VLAN tagging support, VLAN tag data is read to txdw1 */
-//val = cpu_to_le32(txdw1);
-//cpu

[Qemu-devel] [PATCH 2/2] rtl8139: add vlan tag extraction

2010-11-07 Thread Benjamin Poirier
Add support to the emulated hardware to remove vlan tags in packets
going from the network to the guest.

Signed-off-by: Benjamin Poirier 
Cc: Igor V. Kovalenko 

--

AFAIK, extraction is optional to get vlans working. The driver
requests rx detagging but should not assume that it was done. Under
Linux, the mac layer will catch the vlan ethertype. I only added this
part for completeness (to emulate the hardware more truthfully..?).
---
 hw/rtl8139.c |   41 ++---
 1 files changed, 38 insertions(+), 3 deletions(-)

diff --git a/hw/rtl8139.c b/hw/rtl8139.c
index ac294da..557a460 100644
--- a/hw/rtl8139.c
+++ b/hw/rtl8139.c
@@ -1024,6 +1024,44 @@ static ssize_t rtl8139_do_receive(VLANClientState *nc, 
const uint8_t *buf, size_
 
 target_phys_addr_t rx_addr = rtl8139_addr64(rxbufLO, rxbufHI);
 
+if (s->CpCmd & CPlusRxVLAN && size >= ETHER_ADDR_LEN * 2 +
+VLAN_HDR_LEN && be16_to_cpup((uint16_t *) &buf[ETHER_ADDR_LEN *
+2]) == ETHERTYPE_VLAN)
+{
+size_t new_size = size - VLAN_HDR_LEN;
+
+rxdw1 &= ~CP_RX_VLAN_TAG_MASK;
+rxdw1 |= CP_RX_TAVA |
+le16_to_cpup((uint16_t *)&buf[ETHER_HDR_LEN]);
+
+if (buf == buf1 || new_size < MIN_BUF_SIZE)
+{
+/* move the end and pad */
+memmove((uint8_t *)buf + ETHER_ADDR_LEN * 2, buf +
+ETHER_ADDR_LEN * 2 + VLAN_HDR_LEN, new_size -
+ETHER_ADDR_LEN * 2);
+memset((uint8_t *)buf + new_size, 0, MIN_BUF_SIZE - new_size);
+size = MIN_BUF_SIZE;
+}
+else
+{
+/* move the beginning */
+memmove((uint8_t *)buf + VLAN_HDR_LEN, buf, ETHER_ADDR_LEN *
+2);
+buf += VLAN_HDR_LEN;
+size = new_size;
+}
+}
+else
+{
+/* reset VLAN tag flag */
+rxdw1 &= ~CP_RX_TAVA;
+}
+
+DEBUG_PRINT(("RTL8139: C+ Rx mode : removed vlan tag: %u tci: %u\n",
+!!(rxdw1 & CP_RX_TAVA), bswap16(rxdw1 &
+CP_RX_VLAN_TAG_MASK)));
+
 /* receive/copy to target memory */
 cpu_physical_memory_write( rx_addr, buf, size );
 
@@ -1082,9 +1120,6 @@ static ssize_t rtl8139_do_receive(VLANClientState *nc, 
const uint8_t *buf, size_
 rxdw0 &= ~CP_RX_BUFFER_SIZE_MASK;
 rxdw0 |= (size+4);
 
-/* reset VLAN tag flag */
-rxdw1 &= ~CP_RX_TAVA;
-
 /* update ring data */
 val = cpu_to_le32(rxdw0);
 cpu_physical_memory_write(cplus_rx_ring_desc,(uint8_t *)&val, 4);
-- 
1.7.2.3




[Qemu-devel] [Try2][PATCH] Initial implementation of a mpeg1 layer2 streaming audio driver.

2010-11-07 Thread François Revol
Initial implementation of a mpeg1 layer2 streaming audio driver.
2nd try: Style & other fixes from malc's comments.
It is based on the twolame library .
Since twolame is very similar to lame (on purpose), one might easily create a 
lame version from it for better quality.
It allows one to listen to the audio produced by a VM from an mp3 http 
streaming client (layer2 is compatible).
I noticed esdaudio.c which I used as template on was under BSD licence, which 
is fine by me for this one as well.
For now it almost works with a Haiku guest (with HDA at 22050Hz and the WAKEEN 
patch I just sent), except with a 20s delay and missing frames, so it's 
possible buffers get queued up somewhere.

From ee55900f8ceb86a96878a60086e8a4da19c645a8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fran=C3=A7ois=20Revol?= 
Date: Mon, 8 Nov 2010 00:01:43 +0100
Subject: [PATCH] Initial implementation of a mpeg1 layer2 streaming audio 
driver.
 It is based on the twolame library .
 - added a check for libtwolame to configure.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit


Signed-off-by: François Revol 
---
 Makefile.objs|1 +
 audio/audio.c|3 +
 audio/audio_int.h|1 +
 audio/twolameaudio.c |  417 ++
 configure|   20 +++
 5 files changed, 442 insertions(+), 0 deletions(-)
 create mode 100644 audio/twolameaudio.c

diff --git a/Makefile.objs b/Makefile.objs
index faf485e..370d59a 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -109,6 +109,7 @@ audio-obj-$(CONFIG_FMOD) += fmodaudio.o
 audio-obj-$(CONFIG_ESD) += esdaudio.o
 audio-obj-$(CONFIG_PA) += paaudio.o
 audio-obj-$(CONFIG_WINWAVE) += winwaveaudio.o
+audio-obj-$(CONFIG_TWOLAME) += twolameaudio.o
 audio-obj-$(CONFIG_AUDIO_PT_INT) += audio_pt_int.o
 audio-obj-$(CONFIG_AUDIO_WIN_INT) += audio_win_int.o
 audio-obj-y += wavcapture.o
diff --git a/audio/audio.c b/audio/audio.c
index ad51077..0c2c304 100644
--- a/audio/audio.c
+++ b/audio/audio.c
@@ -46,6 +46,9 @@
 static struct audio_driver *drvtab[] = {
 CONFIG_AUDIO_DRIVERS
 &no_audio_driver,
+#ifdef CONFIG_TWOLAME
+&twolame_audio_driver,
+#endif
 &wav_audio_driver
 };
 
diff --git a/audio/audio_int.h b/audio/audio_int.h
index d8560b6..337188b 100644
--- a/audio/audio_int.h
+++ b/audio/audio_int.h
@@ -210,6 +210,7 @@ extern struct audio_driver dsound_audio_driver;
 extern struct audio_driver esd_audio_driver;
 extern struct audio_driver pa_audio_driver;
 extern struct audio_driver winwave_audio_driver;
+extern struct audio_driver twolame_audio_driver;
 extern struct mixeng_volume nominal_volume;
 
 void audio_pcm_init_info (struct audio_pcm_info *info, struct audsettings *as);
diff --git a/audio/twolameaudio.c b/audio/twolameaudio.c
new file mode 100644
index 000..4372fc4
--- /dev/null
+++ b/audio/twolameaudio.c
@@ -0,0 +1,417 @@
+/*
+ * QEMU twolame streaming audio driver
+ *
+ * Copyright (c) 2010 François Revol 
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to 
deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+#include "config-host.h"
+#include "qemu-common.h"
+#include "qemu-char.h"
+#include "qemu_socket.h"
+#include "audio.h"
+
+#define AUDIO_CAP "twolame"
+#include "audio_int.h"
+#include "audio_pt_int.h"
+
+#include 
+
+typedef struct {
+HWVoiceOut hw;
+int done;
+int live;
+int decr;
+int rpos;
+void *pcm_buf;
+void *mpg_buf;
+int lsock;
+int sock;
+struct audio_pt pt;
+twolame_options *options;
+} LAMEVoiceOut;
+
+static struct {
+int samples;
+int divisor;
+int port;
+int rate;
+} conf = {
+.samples = 1024,
+.divisor = 2,
+.port = 8080,
+.rate = 160
+};
+
+static const char http_header[] = "HTTP/1.1 200 OK\r\nServer: QEMU\r\n"
+   "Content-Type: audio/mpeg\r\n\r\n";
+
+static void GCC_FMT_ATTR (2, 3) qtwolame_logerr (int err, const char *fmt, ...)
+{
+va_list a

[Qemu-devel] Re: AIX emulated on x86 host

2010-11-07 Thread Andreas Färber

Am 30.10.2010 um 14:49 schrieb Andreas Schwab:


Andreas Färber  writes:

* Any advice on how to get GCC 4.3+ powerpc64-linux cross-compilers  
built
[2] would be appreciated. We could then better rule out compiler   
bugs.


You don't need any of the target libraries, just the compiler, since  
you

are purely in freestanding land.  So all you need is "make all-gcc".


make all-gcc
make all-target-libgcc
make install-gcc
make install-target-libgcc

did the trick, thanks a lot!

You wouldn't happen to know what to do about an "undefined reference  
to `_GLOBAL_OFFSET_TABLE_'"?


Output format is binary and supposed to be relocatable (tried -fpic  
and -fpie; for an RTAS blob relocated by OpenBIOS).
Compiles with above 4.5.1 powerpc64-linux-gnu-gcc but fails with  
powerpc-elf-gcc.
Is this a symbol I must provide in freestanding land? If yes, how? Or  
am I using the wrong compiler flags?


Andreas


[Qemu-devel] Re: AIX emulated on x86 host

2010-11-07 Thread Andreas Schwab
Andreas Färber  writes:

> You wouldn't happen to know what to do about an "undefined reference to
> _GLOBAL_OFFSET_TABLE_'"?

That symbol is generated by the linker, so it depends on how you call
it.

> Output format is binary and supposed to be relocatable (tried -fpic and
> -fpie; for an RTAS blob relocated by OpenBIOS).

Does it understand ELF PIC relocations?

Andreas.

-- 
Andreas Schwab, sch...@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."



[Qemu-devel] Re: [Try2][PATCH] Initial implementation of a mpeg1 layer2 streaming audio driver.

2010-11-07 Thread François Revol

Le 8 nov. 2010 à 01:02, malc a écrit :

>> +
>> +static void qtwolame_listen_read(void *opaque)
> 
> No space here.

?

>> +if (csock != -1) {
>> +twolame->sock = csock;
>> +dolog ("Accepted peer\n");
>> +if (write (twolame->sock, http_header, sizeof(http_header) - 1) < 
>> sizeof(http_header) - 1) {
> 
> Line is too long.

Dang, wrote it after the 80col pass.

> 
>> +qtwolame_logerr (errno, "write failed for http headers\n");
>> +/* sending headers failed, just close the connection */
>> +closesocket (twolame->sock);
>> +twolame->sock = -1;
>> +}
>> +}
> 
> twolame->csock is not set to -1 (the condition which is checked for 
> everywhere)

There is no twolame->csock, just twolame->lsock (the listen socket), and 
twolame->sock (=csock temporary var) which is the accepted socket.

>> +again:
>> +if (twolame->sock > -1) {
>> +written = write (twolame->sock, twolame->mpg_buf, 
>> converted);
>> +if (written == -1) {
>> +if (errno == EPIPE) {
>> +dolog ("Lost peer\n");
>> +closesocket (twolame->sock);
> 
> This is actually no better than jumping before, reading this code requires
> more analysis than needed, and no i'm not saying it's not correct just hard
> to read.

I'll have to sleep on this then.

>> +twolame_set_mode(twolame->options,
>> +(as->nchannels == 2) ? TWOLAME_STEREO : TWOLAME_MONO);
>> +twolame_set_num_channels(twolame->options, as->nchannels);
>> +twolame_set_in_samplerate(twolame->options, as->freq);
>> +twolame_set_out_samplerate(twolame->options, as->freq);
>> +twolame_set_bitrate(twolame->options, conf.rate);
>> +
>> +if (twolame_init_params(twolame->options)) {
>> +dolog ("Could not set twolame options\n");
>> +goto fail1;
>> +}
> 
> Once again, if you don't like the space before paren by all means do not use
> it, but either way do things consistently.

Ah, forgot this one.

>> +qemu_set_fd_handler2(twolame->lsock, NULL, NULL, NULL, NULL);
>> +if (closesocket (twolame->lsock)) {
> 
> Here we go again, closesocket is cheked here but not elsewhere.

Because elsewhere it's done in an error path and it'd won't do much better, but 
oh well.


> And can you, please, elaborate some more on usage scenarios of this thing?


cf.
http://dev.haiku-os.org/browser/haiku/trunk/3rdparty/mmu_man/onlinedemo/haiku.php

and possibly http://oszoo.org/wiki/index.php/Main_Page some day...

The idea is to use it along with the -vnc option and the VNC applet to present 
a VM on the web.

François.


Re: [Qemu-devel] [PATCH 0/3] v4 Decouple block device removal from device removal

2010-11-07 Thread Ryan Harper
* Markus Armbruster  [2010-11-06 04:19]:
> Ryan Harper  writes:
> 
> > * Markus Armbruster  [2010-11-05 11:11]:
> >> Ryan Harper  writes:
> >> 
> >> > * Markus Armbruster  [2010-11-05 08:28]:
> >> >> I'd be fine with any of these:
> >> >> 
> >> >> 1. A new command "device_disconnet ID" (or similar name) to disconnect
> >> >>device ID from any host parts.  Nice touch: you don't have to know
> >> >>about the device's host part(s) to disconnect it.  But it might be
> >> >>more work than the other two.
> >> >
> >> > This is sort of what netdev_del() and drive_unplug() are today; we're
> >> > just saying sever the connection of this device id.   
> >> 
> >> No, I have netdev_del as (3).
> >> 
> >> All three options are "sort of" the same, just different commands with
> >> a common purpose.
> >> 
> >> > I'd like to rename drive_unplug() to blockdev_del() and call it done.  I
> >> > was looking at libvirt and the right call to netdev_del is already
> >> > in-place; I'd just need to re-spin my block patch to call blockdev_del()
> >> > after invoking device_del() to match what is done for net.
> >> 
> >> Unless I'm missing something, you can't just rename: your unplug does
> >> not delete the host part.
> >> 
> >> >> 2. New commands netdev_disconnect, drive_disconnect (or similar names)
> >> >>to disconnect a host part from a guest device.  Like (1), except you
> >> >>have to point to the other end of the connection to cut it.
> >> >
> >> > What's the advantage here? We need an additional piece of info (host
> >> > part) in addition to the device id?
> >> 
> >> That's a disadvantage.
> >> 
> >> Possible advantage: implementation could be slightly easier than (1),
> >> because you don't have to find the host parts.
> >> 
> >> >> 3. A new command "drive_del ID" similar to existing netdev_del.  This is
> >> >>(2) fused with delete.  Conceptual wart: you can't disconnect and
> >> >>keep the host part around.  Moreover, delete is slightly dangerous,
> >> >>because it renders any guest device still using the host part
> >> >>useless.
> >> >
> >> > Hrm, I thought that's what (1) is.
> >> 
> >> No.
> >> 
> >> With (1), the argument is a *device* ID, and we disconnect *all* host
> >> parts connected to this device (typically just one).
> >> 
> >> With (3), the argument is a netdev/drive ID, and disconnect *this* host
> >> part from the peer device.
> >> 
> >> > Well, either (1) or (3); I'd like to
> >> > rename drive_unplug() to blockdev_del() since they're similar function
> >> > w.r.t removing access to the host resource.  And we can invoke them in
> >> > the same way from libvirt (after doing guest notification, remove
> >> > access).
> >> 
> >> I'd call it drive_del for now, to match drive_add.
> >
> > OK, drive_del() and as you mentioned, drive_unplug will take out the
> > block driver, but doesn't remove the dinfo object; that ends up dying
> > when we call the device destructor.  I think for symmetry we'll want
> > drive_del to remove the dinfo object as well.
> 
> Exactly.
> 
> a. bdrv_detach() to zap the pointer from bdrv to qdev
> b. zap the pointer from qdev to bdrv
> c. drive_uninit() to dispose of the host part

a-c need to be done to match netdev_del symmetry?  How hard of a req is
this?

> 
> Step b could be awkward with (3), because you don't know device details.
> I guess you have to search device properties for a drive property
> pointing to bdrv.  I like (1) because it puts that loop in the one place
> where it belongs: qdev core.  (3) duplicates it in every HOSTDEV_del.
> Except for netdev_del, which is special because of VLANs.
> 
> To avoid step b, you could try to keep the bdrv around in a special
> zombie state.  Still have to free the dinfo, but can't use
> drive_uninit() for that then.
> 
> If you think I'm overcomplicating this, feel free to prove me wrong with
> working code :)

drive_unplug() works as-is today; so it does feel very combursome at
this point.  Other than the name change and agreement on how mgmt should
invoke the command, it's been a long ride to get here.

I'll take my best shot at trying to clean up the other
pointers and objects; though on one of my attempts when I took out the
dinfo() object that didn't go so well; going to have to audit who uses
dinfo and where and what they check before calling it to have a proper
cleanup that doesn't remove the whole device altogether.

-- 
Ryan Harper
Software Engineer; Linux Technology Center
IBM Corp., Austin, Tx
ry...@us.ibm.com



[Qemu-devel] Re: [PATCH] [Seabios] Over 4GB address ranges for 64bit PCI BARs

2010-11-07 Thread Alexey Korolev
Hi,
> Hi.
> The current BAR allocation doesn't check overflow and some patches
> are floating around which aren't merged yet.
> There are several issues.
> 
> - overflow check
>   This should be fixed.
>   Some patches are proposed. None hasn't been merged yet.
>   Your patch also addresses this issue.
>   http://www.seabios.org/pipermail/seabios/2010-July/000794.html
>   http://www.seabios.org/pipermail/seabios/2010-October/001089.html

Right. It would be great if the fix get included in seabios/qemu. 

Update: I've seen today's message from Kevin. He is going to merge your
patch. So it will be good news for us. 


> - >4GB 64bit bar allocation
>   Your patche tries to address this issue. But it breaks PCI-to-PCI
>   bridge filtering support.
Hmm, it is quite possible, as we don't know a lot about seabios PCI-to-PCI 
bridge filtering support.
Just out of curiosity: what is the issue?

>   If the BAR size is huge (or there are too many BARs), the bar can't
>   be allocated under 4G. So several persons want seabios to allocate
>   such BARs at >4GB area complaining that OS can't use BARs that seabios
>   didn't assigned.
> 
>   Others think such BAR can be left unallocated.
>   Seabios role is to setup minimal basic environment for bootloader
>   to boot OS, 64bit bar allocation is beyond it's role.
>   bootloader/rombios usually doesn't handle BARs that is allocated
>   beyond 4GB, and Modern OSes can re-arrange PCI bar allocation itself.
>   So 64bit bar allocation support wouldn't be needed.
> 
>   I'm not sure if there is enough demand to support 64bit BAR allocation
>   and if Kevin will accept it or not. Consensus is needed.
>   What OS are you using?
> 
For us >4GB allocation is welcome but not critical, because we mainly
use Linux versions 2.6.18 and newer. We've tested the seabios without
assignment of the regions which do not fit in first 32bit and it appears
to work fine. So for us 64bit bar allocation support wouldn't be needed.

It is possible that people will use an ancient version of Linux, but the
probability of this event is very low.


Thanks,
Alexey




[Qemu-devel] [PATCH] pc: Fix e820 fw_cfg for big endian

2010-11-07 Thread Alex Williamson
Signed-off-by: Alex Williamson 
---

 Compile tested only.  Only current user is kvm, no cross-arch users.

 hw/pc.c |   14 +++---
 1 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/hw/pc.c b/hw/pc.c
index 0264e3d..cc8ec14 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -467,19 +467,19 @@ static void bochs_bios_write(void *opaque, uint32_t addr, 
uint32_t val)
 
 int e820_add_entry(uint64_t address, uint64_t length, uint32_t type)
 {
-int index = e820_table.count;
+int index = le32_to_cpu(e820_table.count);
 struct e820_entry *entry;
 
 if (index >= E820_NR_ENTRIES)
 return -EBUSY;
-entry = &e820_table.entry[index];
+entry = &e820_table.entry[index++];
 
-entry->address = address;
-entry->length = length;
-entry->type = type;
+entry->address = cpu_to_le64(address);
+entry->length = cpu_to_le64(length);
+entry->type = cpu_to_le32(type);
 
-e820_table.count++;
-return e820_table.count;
+e820_table.count = cpu_to_le32(index);
+return index;
 }
 
 static void *bochs_bios_init(void)




[Qemu-devel] Re: [Try2][PATCH] Initial implementation of a mpeg1 layer2 streaming audio driver.

2010-11-07 Thread malc
On Mon, 8 Nov 2010, Fran?ois Revol wrote:

> 
> Le 8 nov. 2010 ? 01:02, malc a ?crit :
> 
[..snip..]

> 
> 
> > And can you, please, elaborate some more on usage scenarios of this thing?
> 
> 
> cf.
> http://dev.haiku-os.org/browser/haiku/trunk/3rdparty/mmu_man/onlinedemo/haiku.php

Sorry my PHP skills have lapsed aeons ago.

> 
> and possibly http://oszoo.org/wiki/index.php/Main_Page some day...
> 
> The idea is to use it along with the -vnc option and the VNC applet
> to present a VM on the web.

While not very sexy, but can't you just use wav output to a fifo and
compress it via separate process.

-- 
mailto:av1...@comtv.ru



[Qemu-devel] Re: [PATCH] [Seabios] Over 4GB address ranges for 64bit PCI BARs

2010-11-07 Thread Isaku Yamahata
On Mon, Nov 08, 2010 at 04:35:38PM +1300, Alexey Korolev wrote:
> > - >4GB 64bit bar allocation
> >   Your patche tries to address this issue. But it breaks PCI-to-PCI
> >   bridge filtering support.
> Hmm, it is quite possible, as we don't know a lot about seabios PCI-to-PCI 
> bridge filtering support.
> Just out of curiosity: what is the issue?

It's pci_bios_init_device_bridge() in pciinit.c.
The function touches pci_bios_io_addr, pci_bios_mem_addr, and
pci_bios_prefmem_addr.
So we need to modify, not only pci_bios_allocate_region(),
but also pci_bios_init_device_bridge().

The function programs the P2P bridge to forward IO/memory access
on primary pci bus to secondary pci bus.
It needs to be aware of 64bit BAR allocation.


> >   If the BAR size is huge (or there are too many BARs), the bar can't
> >   be allocated under 4G. So several persons want seabios to allocate
> >   such BARs at >4GB area complaining that OS can't use BARs that seabios
> >   didn't assigned.
> > 
> >   Others think such BAR can be left unallocated.
> >   Seabios role is to setup minimal basic environment for bootloader
> >   to boot OS, 64bit bar allocation is beyond it's role.
> >   bootloader/rombios usually doesn't handle BARs that is allocated
> >   beyond 4GB, and Modern OSes can re-arrange PCI bar allocation itself.
> >   So 64bit bar allocation support wouldn't be needed.
> > 
> >   I'm not sure if there is enough demand to support 64bit BAR allocation
> >   and if Kevin will accept it or not. Consensus is needed.
> >   What OS are you using?
> > 
> For us >4GB allocation is welcome but not critical, because we mainly
> use Linux versions 2.6.18 and newer. We've tested the seabios without
> assignment of the regions which do not fit in first 32bit and it appears
> to work fine. So for us 64bit bar allocation support wouldn't be needed.
> 
> It is possible that people will use an ancient version of Linux, but the
> probability of this event is very low.

My position is same to yours. Welcome, but not critical.
So the issue is, who will finish it.
-- 
yamahata



[Qemu-devel] Re: [Try2][PATCH] Initial implementation of a mpeg1 layer2 streaming audio driver.

2010-11-07 Thread François Revol

Le 8 nov. 2010 à 04:57, malc a écrit :

>>> And can you, please, elaborate some more on usage scenarios of this thing?
>> 
>> cf.
>> http://dev.haiku-os.org/browser/haiku/trunk/3rdparty/mmu_man/onlinedemo/haiku.php
> 
> Sorry my PHP skills have lapsed aeons ago.

Sorry I don't have it installed on a publically accessible machine atm.

>> 
>> and possibly http://oszoo.org/wiki/index.php/Main_Page some day...
>> 
>> The idea is to use it along with the -vnc option and the VNC applet
>> to present a VM on the web.
> 
> While not very sexy, but can't you just use wav output to a fifo and
> compress it via separate process.

I did try years ago, but at least the current wav driver really didn't like 
fifos back then. I recall trying for hours to get it pipe to ffmpeg or others 
without much luck.

Also, this poses several problems about the control of the external process 
(respawn on listener disconnection, close on exit...).

François.


Re: [Qemu-devel] [PATCH] virtio-9p: fix build on !CONFIG_UTIMENSAT v2

2010-11-07 Thread M. Mohan Kumar
> This patch introduce a fallback mechanism for old systems that do not
> support utimensat.  This will fix build failure with following warnings:
> 
> hw/virtio-9p-local.c: In function 'local_utimensat':
> hw/virtio-9p-local.c:479: warning: implicit declaration of function
> 'utimensat' hw/virtio-9p-local.c:479: warning: nested extern declaration
> of 'utimensat'
> 
> and
> 
> hw/virtio-9p.c: In function 'v9fs_setattr_post_chmod':
> hw/virtio-9p.c:1410: error: 'UTIME_NOW' undeclared (first use in this
> function) hw/virtio-9p.c:1410: error: (Each undeclared identifier is
> reported only once hw/virtio-9p.c:1410: error: for each function it
> appears in.)
> hw/virtio-9p.c:1413: error: 'UTIME_OMIT' undeclared (first use in this
> function) hw/virtio-9p.c: In function 'v9fs_wstat_post_chmod':
> hw/virtio-9p.c:2905: error: 'UTIME_OMIT' undeclared (first use in this
> function)
> 
> Signed-off-by: Hidetoshi Seto 
> ---
>  hw/virtio-9p-local.c |   32 ++--
>  hw/virtio-9p.h   |   10 ++
>  2 files changed, 40 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/virtio-9p-local.c b/hw/virtio-9p-local.c
> index 0d52020..7811d2c 100644
> --- a/hw/virtio-9p-local.c
> +++ b/hw/virtio-9p-local.c
> @@ -479,10 +479,38 @@ static int local_chown(FsContext *fs_ctx, const char
> *path, FsCred *credp) return -1;
>  }
> 
> +/* TODO: relocate this to proper file, and make it more generic */
> +static int qemu_utimensat(int dirfd, const char *path,
> +  const struct timespec *times, int flags)
> +{

IMHO, this code can be moved to cutils.c

> +#ifdef CONFIG_UTIMENSAT
> +return utimensat(dirfd, path, times, flags);
> +#else
> +/*
> + * Fallback: use utimes() instead of utimensat().
> + * See commit 74bc02b2d2272dc88fb98d43e631eb154717f517 for known
> problem. + */
> +struct timeval tv[2];
> +int i;
> +
> +for (i = 0; i < 2; i++) {
> +if (times[i].tv_nsec == UTIME_OMIT || times[i].tv_nsec ==
> UTIME_NOW) { +tv[i].tv_sec = 0;
> +tv[i].tv_usec = 0;
> +} else {
> +tv[i].tv_sec = times[i].tv_sec;
> +tv[i].tv_usec = times[i].tv_nsec / 1000;
> +}
> +}
> +
> +return utimes(path, &tv[0]);
> +#endif

The idea of introducing utimensat was to avoid resetting atime to 1970-01-01 
05:30:00 (utime does not give option to not change atime). But as per utimes 
man page, if any of the time field is 0, it would be set to current time. As 
per stat man page, truncate will not update atime, only mtime will be updated.