[Qemu-devel] [PATCH] Porting TCG to alpha platform

2010-01-19 Thread identifier scorpio
Hello.

I ported TCG to alpha platform, the patch is currently based on stable-0.10 
branch, and now it can run linux-0.2.img testing image on my alpha XP1000 
workstation. but it still can't run MS-windows, and I hope someone, especially 
those guys that are working on target-alpha, may help me to find the bugs.

From 0ee33ea1e43298e6045e16dfcf07cb7a530dfd56 Mon Sep 17 00:00:00 2001
From: Dong Weiyu 
Date: Tue, 19 Jan 2010 16:22:54 +0800
Subject: [PATCH] porting TCG to alpha platform.

---
 cpu-all.h  |2 +-
 tcg/alpha/tcg-target.c | 1335 
 tcg/alpha/tcg-target.h |   70 +++
 3 files changed, 1406 insertions(+), 1 deletions(-)
 create mode 100644 tcg/alpha/tcg-target.c
 create mode 100644 tcg/alpha/tcg-target.h

diff --git a/cpu-all.h b/cpu-all.h
index e0c3efd..bdf6fb2 100644
--- a/cpu-all.h
+++ b/cpu-all.h
@@ -22,7 +22,7 @@
 
 #include "qemu-common.h"
 
-#if defined(__arm__) || defined(__sparc__) || defined(__mips__) || 
defined(__hppa__)
+#if defined(__arm__) || defined(__sparc__) || defined(__mips__) || 
defined(__hppa__) || defined(__alpha__)
 #define WORDS_ALIGNED
 #endif
 
diff --git a/tcg/alpha/tcg-target.c b/tcg/alpha/tcg-target.c
new file mode 100644
index 000..6bbd69f
--- /dev/null
+++ b/tcg/alpha/tcg-target.c
@@ -0,0 +1,1335 @@
+/*

+ * Tiny Code Generator for QEMU on ALPHA platform
+*/

+

+#ifndef NDEBUG

+static const char * const tcg_target_reg_names[TCG_TARGET_NB_REGS] = {

+"$0", "$1", "$2", "$3", "$4", "$5", "$6", "$7",

+"$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15",

+"$16", "$17", "$18", "$19", "$20", "$21", "$22", "$23",

+"$24", "$25", "$26", "$27", "$28", "$29", "$30", "$31",

+};

+#endif

+

+/* 

+ * $26 ~ $31 are special, reserved, 

+ * and $25 is deliberately reserved for jcc operation

+ * and $0 is usually used for return function result, better allocate it later

+ * and $15 is used for cpu_env pointer, allocate it at last

+*/

+static const int tcg_target_reg_alloc_order[] = {

+TCG_REG_1, TCG_REG_2, TCG_REG_3, TCG_REG_4, TCG_REG_5, TCG_REG_6,

+TCG_REG_7, TCG_REG_8, TCG_REG_22, 
+TCG_REG_9, TCG_REG_10, TCG_REG_11, TCG_REG_12, TCG_REG_13, TCG_REG_14,

+TCG_REG_16, TCG_REG_17, TCG_REG_18, TCG_REG_19, TCG_REG_20, TCG_REG_21
+};

+

+/*

+ * according to alpha calling convention, these 6 registers are used for 

+ * function parameter passing. if function has more than 6 parameters, remained

+ * ones are stored on stack.

+*/

+static const int tcg_target_call_iarg_regs[6] = { 

+TCG_REG_16, TCG_REG_17, TCG_REG_18, TCG_REG_19, TCG_REG_20, TCG_REG_21

+};

+

+/*

+ * according to alpha calling convention, $0 is used for returning function 
result.

+*/

+static const int tcg_target_call_oarg_regs[1] = { TCG_REG_0 };

+

+/*

+ * save the address of TB's epilogue.

+*/

+static uint8_t *tb_ret_addr;

+

+/* 

+ * op-code and func-code for jump insn 

+*/

+#define OP_CALL0x01A

+#define OP_RET 0x01A

+#define OP_JMP 0x01A

+

+#define FUNC_JMP   0x00

+#define FUNC_CALL  0x01

+#define FUNC_RET   0x02

+

+#define OP_BR  0x30

+#define OP_BEQ0x39

+#define OP_BNE0x3D

+#define OP_BLBC0x38

+#define OP_BLBS0x3C

+

+#define OP_ADDSUBCMP   0x10

+

+#define FUNC_ADDL  0x00

+#define FUNC_SUBL  0x09

+#define FUNC_ADDQ  0x20

+#define FUNC_SUBQ  0x29

+#define FUNC_CMPEQ 0x2D

+#define FUNC_CMPLT 0x4D

+#define FUNC_CMPLE 0x6D

+#define FUNC_CMPULT0x1D

+#define FUNC_CMPULE0x3D

+

+#define OP_MUL 0x13

+

+#define FUNC_MULL  0x00

+#define FUNC_MULQ  0x20

+

+#define OP_LOGIC   0x11

+

+#define FUNC_AND   0x00

+#define FUNC_BIS   0x20

+#define FUNC_XOR   0x40

+

+#define OP_SHIFT   0x12

+

+#define FUNC_SLL   0x39

+#define FUNC_SRL   0x34

+#define FUNC_SRA   0x3C

+

+#define OP_SEXT0x1C

+

+#define FUNC_SEXTB 0x00

+#define FUNC_SEXTW 0x01

+

+#define OP_LDA 0x08

+#define OP_LDAH0x09

+#define OP_LDBU0x0A

+#define OP_LDWU0x0C

+#define OP_LDL 0x28

+#define OP_LDQ 0x29

+#define OP_STB 0x0E

+#define OP_STW 0x0D

+#define OP_STL 0x2C

+#define OP_STQ 0x2D
+

+/*

+ * return the # of regs used for parameter passing on procedure calling.

+ * note that alpha use $16~$21 to transfer the first 6 paramenters of a 
procedure.

+*/

+static inline int tcg_target_get_call_iarg_regs_count(int flags)

+{

+return 6;

+}

+

+/*

+ * given constraint, return available register set. this function is called 
once

+ * for each op at qemu's initialization stage.

+*/

+static int target_parse_constraint(TCGArgConstraint *ct, const char **pct_str)

+{

+const char *ct_str = *pct_str;

+

+switch(ct_str[0]) 

+{

+case 'r':

+/* constaint 'r' means any register is okay */

+ct->ct |= T

Re: [Qemu-devel] [PATCH] Documentation: Add missing documentation for qdev related command line options

2010-01-19 Thread Markus Armbruster
Stefan Weil  writes:

> Markus Armbruster schrieb:
>> Stefan Weil  writes:
>>
>>> The command line options -device, -nodefaults, -readconfig,
>>> -writeconfig had entries for command line help, but
>>> documentation for texi and derived formats (man, html, info)
>>> was missing.
>>>
>>> This also required moving "@end table" to the end of
>>> qemu-options.hx again.
>>>
>>> Signed-off-by: Stefan Weil 
>>> ---
>>> qemu-options.hx | 25 +
>>> 1 files changed, 21 insertions(+), 4 deletions(-)
>>>
>>> diff --git a/qemu-options.hx b/qemu-options.hx
>>> index e2edd71..b2d04e2 100644
>>> --- a/qemu-options.hx
>>> +++ b/qemu-options.hx
>>> @@ -404,6 +404,12 @@ ETEXI
>>>
>>> DEF("device", HAS_ARG, QEMU_OPTION_device,
>>> "-device driver[,options] add device\n")
>>> +STEXI
>>> +...@item -device @var{driver}[,@var{option}[,...]]
>>> +Add device @var{driver}. Depending on the device type,
>>> +...@var{option} (typically @var{ke...@var{value}) may be useful.
>>> +ETEXI
>>> +
>>
>> While there, would you mind improving --help for -device a bit? It's
>> too terse, and it doesn't start the help text in column 16 like the
>> other options do.
>
> Hi Markus,
>
> this needs a little more work. I just had a look on the code,
> and there is no online help for the possible options (key, value).

What I had in mind was just to bring it up to par with your patch to the
texi, but...

> If you (and especially those who have commit rights) agree,
> I could provide these three additional patches:
>
> * Add online help for properties (qemu -device driver,?)
> * Add online help for property value (qemu -device driver,property=?)
> * Update documentation for command line option -device

... a patch to provide that is very desirable!

I figure the best way to document available properties and there values
is a self-documenting struct PropertyInfo: add a doc member, extend
DEFINE_PROP() & friends to set it, fix up users to pass NULL, and so
forth.  We can then replace the NULL by something useful at our leisure.

> There is already an online help for the driver (qemu -device ?).




[Qemu-devel] Stop using "which" in ./configure

2010-01-19 Thread Loïc Minier
Hi

 Following the thread on the sdl-config patch, please find attached a
 patch to add a couple of portable shell functions which allow testing
 whehter a command/builtin is available and to find the full pathname of
 an executable in the PATH.  This also replaces all uses of "which" in
 ./configure.  (This should be applied on top of the sdl-config patch.)

   Thanks,
-- 
Loïc Minier
>From 815ca36e9b3e2c56040d7fc7709c95d600ed6496 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Lo=C3=AFc=20Minier?= 
Date: Tue, 19 Jan 2010 11:05:00 +0100
Subject: [PATCH] Add and use has() and path_of() funcs

Add has() and path_of() funcs and use them across configure; has()
will test whether a command or builtin is available; path_of() will
search the PATH for executables and return the full pathname if found.
---
 configure |   57 -
 1 files changed, 48 insertions(+), 9 deletions(-)

diff --git a/configure b/configure
index baa2800..8d67b9c 100755
--- a/configure
+++ b/configure
@@ -27,6 +27,47 @@ compile_prog() {
   $cc $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags > /dev/null 2> /dev/null
 }
 
+# check whether a command is available to this shell (may be either an
+# executable or a builtin)
+has() {
+local_command="$1"
+type "$local_command" >/dev/null
+}
+
+# search for an executable in PATH
+path_of() {
+local_command="$1"
+local_path="$PATH"
+local_dir=""
+# absolute path?
+if [ "${local_command#*/}" != "$local_command" ]; then
+if [ -x "$local_command" ] && [ ! -d "$local_command" ]; then
+echo "$local_command"
+return 0
+fi
+fi
+if [ -z "$local_path" ] || [ -z "$local_command" ]; then
+return 1
+fi
+while :; do
+local_dir="${local_path%%:*}"
+if [ "${local_path#*:}" = "$local_path" ]; then
+# last loop
+local_path=""
+else
+local_path="${local_path#*:}"
+fi
+if [ -x "$local_dir/$local_command" ] && [ ! -d "$local_dir/$local_command" ]; then
+echo "$local_dir/$local_command"
+return 0
+fi
+if [ -z "$local_path" ]; then
+# not found
+return 1
+fi
+done
+}
+
 # default parameters
 cpu=""
 prefix=""
@@ -763,7 +804,7 @@ fi
 # Solaris specific configure tool chain decisions
 #
 if test "$solaris" = "yes" ; then
-  solinst=`which $install 2> /dev/null | /usr/bin/grep -v "no $install in"`
+  solinst=`path_of $install`
   if test -z "$solinst" ; then
 echo "Solaris install program not found. Use --install=/usr/ucb/install or"
 echo "install fileutils from www.blastwave.org using pkg-get -i fileutils"
@@ -776,7 +817,7 @@ if test "$solaris" = "yes" ; then
 echo "using pkg-get -i fileutils, or use --install=/usr/ucb/install"
 exit 1
   fi
-  sol_ar=`which ar 2> /dev/null | /usr/bin/grep -v "no ar in"`
+  sol_ar=`path_of ar`
   if test -z "$sol_ar" ; then
 echo "Error: No path includes ar"
 if test -f /usr/ccs/bin/ar ; then
@@ -969,7 +1010,7 @@ fi
 # pkgconfig probe
 
 pkgconfig="${cross_prefix}pkg-config"
-if ! test -x "$(which $pkgconfig 2>/dev/null)"; then
+if ! has $pkgconfig; then
   # likely not cross compiling, or hope for the best
   pkgconfig=pkg-config
 fi
@@ -977,7 +1018,7 @@ fi
 ##
 # Sparse probe
 if test "$sparse" != "no" ; then
-  if test -x "$(which cgcc 2>/dev/null)"; then
+  if has cgcc; then
 sparse=yes
   else
 if test "$sparse" = "yes" ; then
@@ -993,7 +1034,7 @@ fi
 if $pkgconfig sdl --modversion >/dev/null 2>&1; then
   sdlconfig="$pkgconfig sdl"
   _sdlversion=`$sdlconfig --modversion 2>/dev/null | sed 's/[^0-9]//g'`
-elif which sdl-config >/dev/null 2>&1; then
+elif has sdl-config; then
   sdlconfig='sdl-config'
   _sdlversion=`$sdlconfig --version | sed 's/[^0-9]//g'`
 else
@@ -1424,8 +1465,7 @@ EOF
 fi
   else
 if test "$kvm" = "yes" ; then
-  if [ -x "`which awk 2>/dev/null`" ] && \
- [ -x "`which grep 2>/dev/null`" ]; then
+  if has awk && has grep; then
 kvmerr=`LANG=C $cc $QEMU_CFLAGS -o $TMPE $kvm_cflags $TMPC 2>&1 \
 	| grep "error: " \
 	| awk -F "error: " '{if (NR>1) printf(", "); printf("%s",$2);}'`
@@ -1694,8 +1734,7 @@ fi
 
 # Check if tools are available to build documentation.
 if test "$docs" != "no" ; then
-  if test -x "`which texi2html 2>/dev/null`" -a \
-  -x "`which pod2man 2>/dev/null`" ; then
+  if has texi2html && has pod2man; then
 docs=yes
   else
 if test "$docs" = "yes" ; then
-- 
1.6.5



RE: [Qemu-devel] Stop using "which" in ./configure

2010-01-19 Thread Laurent Vivier
>Hi
>
> Following the thread on the sdl-config patch, please find attached a
> patch to add a couple of portable shell functions which allow testing
> whehter a command/builtin is available and to find the full pathname of
> an executable in the PATH.  This also replaces all uses of "which" in
> ./configure.  (This should be applied on top of the sdl-config patch.)
>
>   Thanks,

Why don't you use "type -P" for "path_of" ?"

Regards,
Laurent
-- 
- laur...@vivier.eu  -
"Tout ce qui est impossible reste à accomplir"Jules Verne
"Things are only impossible until they're not" Jean-Luc Picard




Re: [Qemu-devel] [PATCH 05/10] block: Return original error codes in bdrv_pread/write

2010-01-19 Thread Christoph Hellwig
On Mon, Jan 18, 2010 at 01:11:31PM +0100, Kevin Wolf wrote:
> Don't assume -EIO but return the real error.

While I'm not very found of assignment inside of if statements the patch
looks correct,


Reviewed-by: Christoph Hellwig 





Re: [Qemu-devel] [PATCH 01/10] qcow2: Fix error handling in qcow2_grow_l1_table

2010-01-19 Thread Christoph Hellwig
On Mon, Jan 18, 2010 at 01:11:27PM +0100, Kevin Wolf wrote:
> Return the appropriate error value instead of always using EIO. Don't free the
> L1 table on errors, we still need it.
> 
> Signed-off-by: Kevin Wolf 

Looks good correct, but shouldn't we free the clusters for the new l1
table if writing to it fails?  At least dependend on whether it's EIO
in which case we could assume the sectos on disk to be worn out.






Re: [Qemu-devel] [PATCH 02/10] qcow2: Fix error handling in qcow_save_vmstate

2010-01-19 Thread Christoph Hellwig
On Mon, Jan 18, 2010 at 01:11:28PM +0100, Kevin Wolf wrote:
> Don't assume success but pass the bdrv_pwrite return value on.

Looks good,


Reviewed-by: Christoph Hellwig 





Re: [Qemu-devel] [PATCH 03/10] qcow2: Return 0/-errno in get_cluster_table

2010-01-19 Thread Christoph Hellwig
On Mon, Jan 18, 2010 at 01:11:29PM +0100, Kevin Wolf wrote:
> Switching to 0/-errno allows it to distinguish different error cases.

Looks good,


Reviewed-by: Christoph Hellwig 





Re: [Qemu-devel] [PATCH 01/10] qcow2: Fix error handling in qcow2_grow_l1_table

2010-01-19 Thread Kevin Wolf
Am 19.01.2010 11:58, schrieb Christoph Hellwig:
> On Mon, Jan 18, 2010 at 01:11:27PM +0100, Kevin Wolf wrote:
>> Return the appropriate error value instead of always using EIO. Don't free 
>> the
>> L1 table on errors, we still need it.
>>
>> Signed-off-by: Kevin Wolf 
> 
> Looks good correct, but shouldn't we free the clusters for the new l1
> table if writing to it fails?  At least dependend on whether it's EIO
> in which case we could assume the sectos on disk to be worn out.

Agreed, we should try to free them. At least in RHEV, the most likely
case for failure will be ENOSPC and we're going to succeed with the free
in that case.

This will become the first patch of the second series then. ;-)

Kevin




Re: [Qemu-devel] [PATCH 06/10] qcow2: Fix error handling in grow_refcount_table

2010-01-19 Thread Christoph Hellwig
On Mon, Jan 18, 2010 at 01:11:32PM +0100, Kevin Wolf wrote:
> Return the appropriate error code instead of -EIO.
> 
> Signed-off-by: Kevin Wolf 

Looks good,


Reviewed-by: Christoph Hellwig 





Re: [Qemu-devel] Stop using "which" in ./configure

2010-01-19 Thread Loïc Minier
On Tue, Jan 19, 2010, Laurent Vivier wrote:
> Why don't you use "type -P" for "path_of" ?"

 I don't think that's portable enough:
$ sh -c 'type -P ls'
-P: not found
ls is /bin/ls

-- 
Loïc Minier




Re: [Qemu-devel] Stop using "which" in ./configure

2010-01-19 Thread Loïc Minier
On Tue, Jan 19, 2010, Loïc Minier wrote:
>  Following the thread on the sdl-config patch, please find attached a
>  patch to add a couple of portable shell functions which allow testing
>  whehter a command/builtin is available and to find the full pathname of
>  an executable in the PATH.  This also replaces all uses of "which" in
>  ./configure.  (This should be applied on top of the sdl-config patch.)

 Please find attached a new version of the patch with a simpler version
 of path_of() which uses IFS instead of the ${foo#bar} and ${foo%%bar}
 constructs.  It also removes the special casing of an empty PATH.

-- 
Loïc Minier
>From 5fc05ec61d87049ea0f29b2dd51c16e260698ef8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Lo=C3=AFc=20Minier?= 
Date: Tue, 19 Jan 2010 11:05:00 +0100
Subject: [PATCH] Add and use has() and path_of() funcs

Add has() and path_of() funcs and use them across configure; has()
will test whether a command or builtin is available; path_of() will
search the PATH for executables and return the full pathname if found.
---
 configure |   53 -
 1 files changed, 44 insertions(+), 9 deletions(-)

diff --git a/configure b/configure
index baa2800..711e335 100755
--- a/configure
+++ b/configure
@@ -27,6 +27,43 @@ compile_prog() {
   $cc $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags > /dev/null 2> /dev/null
 }
 
+# check whether a command is available to this shell (may be either an
+# executable or a builtin)
+has() {
+local_command="$1"
+type "$local_command" >/dev/null
+}
+
+# search for an executable in PATH
+path_of() {
+local_command="$1"
+local_ifs="$IFS"
+local_dir=""
+
+# pathname has a dir component?
+if [ "${local_command#*/}" != "$local_command" ]; then
+if [ -x "$local_command" ] && [ ! -d "$local_command" ]; then
+echo "$local_command"
+return 0
+fi
+fi
+if [ -z "$local_command" ]; then
+return 1
+fi
+
+IFS=:
+for local_dir in $PATH; do
+if [ -x "$local_dir/$local_command" ] && [ ! -d "$local_dir/$local_command" ]; then
+echo "$local_dir/$local_command"
+IFS="$local_ifs"
+return 0
+fi
+done
+# not found
+IFS="$local_ifs"
+return 1
+}
+
 # default parameters
 cpu=""
 prefix=""
@@ -763,7 +800,7 @@ fi
 # Solaris specific configure tool chain decisions
 #
 if test "$solaris" = "yes" ; then
-  solinst=`which $install 2> /dev/null | /usr/bin/grep -v "no $install in"`
+  solinst=`path_of $install`
   if test -z "$solinst" ; then
 echo "Solaris install program not found. Use --install=/usr/ucb/install or"
 echo "install fileutils from www.blastwave.org using pkg-get -i fileutils"
@@ -776,7 +813,7 @@ if test "$solaris" = "yes" ; then
 echo "using pkg-get -i fileutils, or use --install=/usr/ucb/install"
 exit 1
   fi
-  sol_ar=`which ar 2> /dev/null | /usr/bin/grep -v "no ar in"`
+  sol_ar=`path_of ar`
   if test -z "$sol_ar" ; then
 echo "Error: No path includes ar"
 if test -f /usr/ccs/bin/ar ; then
@@ -969,7 +1006,7 @@ fi
 # pkgconfig probe
 
 pkgconfig="${cross_prefix}pkg-config"
-if ! test -x "$(which $pkgconfig 2>/dev/null)"; then
+if ! has $pkgconfig; then
   # likely not cross compiling, or hope for the best
   pkgconfig=pkg-config
 fi
@@ -977,7 +1014,7 @@ fi
 ##
 # Sparse probe
 if test "$sparse" != "no" ; then
-  if test -x "$(which cgcc 2>/dev/null)"; then
+  if has cgcc; then
 sparse=yes
   else
 if test "$sparse" = "yes" ; then
@@ -993,7 +1030,7 @@ fi
 if $pkgconfig sdl --modversion >/dev/null 2>&1; then
   sdlconfig="$pkgconfig sdl"
   _sdlversion=`$sdlconfig --modversion 2>/dev/null | sed 's/[^0-9]//g'`
-elif which sdl-config >/dev/null 2>&1; then
+elif has sdl-config; then
   sdlconfig='sdl-config'
   _sdlversion=`$sdlconfig --version | sed 's/[^0-9]//g'`
 else
@@ -1424,8 +1461,7 @@ EOF
 fi
   else
 if test "$kvm" = "yes" ; then
-  if [ -x "`which awk 2>/dev/null`" ] && \
- [ -x "`which grep 2>/dev/null`" ]; then
+  if has awk && has grep; then
 kvmerr=`LANG=C $cc $QEMU_CFLAGS -o $TMPE $kvm_cflags $TMPC 2>&1 \
 	| grep "error: " \
 	| awk -F "error: " '{if (NR>1) printf(", "); printf("%s",$2);}'`
@@ -1694,8 +1730,7 @@ fi
 
 # Check if tools are available to build documentation.
 if test "$docs" != "no" ; then
-  if test -x "`which texi2html 2>/dev/null`" -a \
-  -x "`which pod2man 2>/dev/null`" ; then
+  if has texi2html && has pod2man; then
 docs=yes
   else
 if test "$docs" = "yes" ; then
-- 
1.6.5



Re: [Qemu-devel] [PATCH 04/10] qcow2: Return 0/-errno in qcow2_alloc_cluster_offset

2010-01-19 Thread Kevin Wolf
Am 19.01.2010 12:35, schrieb Christoph Hellwig:
>> @@ -715,6 +721,7 @@ uint64_t qcow2_alloc_cluster_offset(BlockDriverState *bs,
>>  
>>  cluster_offset &= ~QCOW_OFLAG_COPIED;
>>  m->nb_clusters = 0;
>> +m->depends_on = NULL;
> 
> What does this have to do with the rest?

It's needed to be able to distinguish between the case where the
clusters are already allocated (0/NULL) and the case where the request
depends on another one (0/non-NULL). This check previously used the
return value (cluster_offset for success, 0 for failure) and I didn't
want to overload m->cluster_offset with such a meaning. This is the
change in the caller:

   /* Need to wait for another request? If so, we are done for now. */
-  if (!acb->cluster_offset && acb->l2meta.depends_on != NULL) {
+  if (acb->l2meta.nb_clusters == 0 && acb->l2meta.depends_on != NULL) {

The alternative would have been to keep using the return value and
hijack some errno value. This would possibly conflict with real
read/write errors though, so I decided to leave the return value alone.

Kevin




Re: [Qemu-devel] [PATCH 04/10] qcow2: Return 0/-errno in qcow2_alloc_cluster_offset

2010-01-19 Thread Christoph Hellwig
On Tue, Jan 19, 2010 at 12:57:35PM +0100, Kevin Wolf wrote:
> It's needed to be able to distinguish between the case where the
> clusters are already allocated (0/NULL) and the case where the request
> depends on another one (0/non-NULL). This check previously used the
> return value (cluster_offset for success, 0 for failure) and I didn't
> want to overload m->cluster_offset with such a meaning. This is the
> change in the caller:
> 
>/* Need to wait for another request? If so, we are done for now. */
> -  if (!acb->cluster_offset && acb->l2meta.depends_on != NULL) {
> +  if (acb->l2meta.nb_clusters == 0 && acb->l2meta.depends_on != NULL) {
> 
> The alternative would have been to keep using the return value and
> hijack some errno value. This would possibly conflict with real
> read/write errors though, so I decided to leave the return value alone.

Ok, makes sense.





[Qemu-devel] Re: [PATCH 01/14] Introduce qemu_write_full()

2010-01-19 Thread Juan Quintela
"Kirill A. Shutemov"  wrote:
> A variant of write(2) which handles partial write.
>
> Signed-off-by: Kirill A. Shutemov 

Hi

Have you updated this series?  Is there any reason that you know when
they haven't been picked?

I am also interested in getting _FORTIFY_SOURCE=2 wo compile cleanly.

Thanks in advance, Juan.




[Qemu-devel] Re: [PATCH 01/14] Introduce qemu_write_full()

2010-01-19 Thread Kirill A. Shutemov
On Tue, Jan 19, 2010 at 2:11 PM, Juan Quintela  wrote:
> "Kirill A. Shutemov"  wrote:
>> A variant of write(2) which handles partial write.
>>
>> Signed-off-by: Kirill A. Shutemov 
>
> Hi
>
> Have you updated this series?  Is there any reason that you know when
> they haven't been picked?

I don't  know any reason, but I'm going to review it once again.

I also have plan to get rid of -fno-strict-aliasing where it's possible.




Re: [Qemu-devel] [PATCH 04/10] qcow2: Return 0/-errno in qcow2_alloc_cluster_offset

2010-01-19 Thread Christoph Hellwig
> @@ -715,6 +721,7 @@ uint64_t qcow2_alloc_cluster_offset(BlockDriverState *bs,
>  
>  cluster_offset &= ~QCOW_OFLAG_COPIED;
>  m->nb_clusters = 0;
> +m->depends_on = NULL;

What does this have to do with the rest?

Otherwise looks good,


Reviewed-by: Christoph Hellwig 




[Qemu-devel] Re: [PATCH] Documentation: Add missing documentation for qdev related command line options

2010-01-19 Thread Michael S. Tsirkin
On Mon, Jan 18, 2010 at 08:32:25PM +0100, Stefan Weil wrote:
> Markus Armbruster schrieb:
> > Stefan Weil  writes:
> >
> >> The command line options -device, -nodefaults, -readconfig,
> >> -writeconfig had entries for command line help, but
> >> documentation for texi and derived formats (man, html, info)
> >> was missing.
> >>
> >> This also required moving "@end table" to the end of
> >> qemu-options.hx again.
> >>
> >> Signed-off-by: Stefan Weil 
> >> ---
> >> qemu-options.hx | 25 +
> >> 1 files changed, 21 insertions(+), 4 deletions(-)
> >>
> >> diff --git a/qemu-options.hx b/qemu-options.hx
> >> index e2edd71..b2d04e2 100644
> >> --- a/qemu-options.hx
> >> +++ b/qemu-options.hx
> >> @@ -404,6 +404,12 @@ ETEXI
> >>
> >> DEF("device", HAS_ARG, QEMU_OPTION_device,
> >> "-device driver[,options] add device\n")
> >> +STEXI
> >> +...@item -device @var{driver}[,@var{option}[,...]]
> >> +Add device @var{driver}. Depending on the device type,
> >> +...@var{option} (typically @var{ke...@var{value}) may be useful.
> >> +ETEXI
> >> +
> >
> > While there, would you mind improving --help for -device a bit? It's
> > too terse, and it doesn't start the help text in column 16 like the
> > other options do.
> 
> Hi Markus,
> 
> this needs a little more work. I just had a look on the code,
> and there is no online help for the possible options (key, value).
> 
> If you (and especially those who have commit rights) agree,
> I could provide these three additional patches:
> 
> * Add online help for properties (qemu -device driver,?)
> * Add online help for property value (qemu -device driver,property=?)
> * Update documentation for command line option -device
> 
> There is already an online help for the driver (qemu -device ?).
> 
> Regards,
> 
> Stefan
> 

Yes, this was on list of things to be fixed for a long time now.

Some more things that need looking into:

. -device ? itself is undocumented
. - device ? currently prints system devices as well
let's only print these that have a description
and add ?? to list all devices
. -netdev has undocumented options as well
. we should have a flag to dump all options in one go,
  for ease of searching

-- 
MST




Re: [Qemu-devel] [PATCH] Fix missing symbols in .rela.plt sections

2010-01-19 Thread Loïc Minier
On Sun, Jan 17, 2010, Loïc Minier wrote:
>  Static builds of qemu on x86-64 (and probably i386) fail

 After actually checking in an i386 Ubuntu lucid chroot, I found out
 that ld uses .rel.plt and .rel.iplt instead of .rela.plt and
 .rela.iplt.  I've applied the same fixes to the two .ld scripts and
 could build static flavors of qemu-linux-user on both with the updated
 patch in attachment.

 Thanks,
-- 
Loïc Minier
>From a3582e37351596119e947b0606021aedb19b6f61 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Lo=C3=AFc=20Minier?= 
Date: Sun, 17 Jan 2010 12:09:38 +0100
Subject: [PATCH] Fix missing symbols in .rel/.rela.plt sections
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Fix .rel.plt sections in the output to not only include .rel.plt
sections from the input but also the .rel.iplt sections and to define
the hidden symbols __rel_iplt_start and __rel_iplt_end around
.rel.iplt as otherwise we get undefined references to these when
linking statically to a multilib libc.a.  This fixes the static build
under i386.

Apply similar logic to rela.plt/.iplt and __rela_iplt/_plt_start/_end to
fix the static build under amd64.

Signed-off-by: Loïc Minier 
---
 i386.ld   |   16 ++--
 x86_64.ld |   16 ++--
 2 files changed, 28 insertions(+), 4 deletions(-)

diff --git a/i386.ld b/i386.ld
index f2dafec..f8df7bf 100644
--- a/i386.ld
+++ b/i386.ld
@@ -39,8 +39,20 @@ SECTIONS
   .rela.fini : { *(.rela.fini)	}
   .rel.bss   : { *(.rel.bss)		}
   .rela.bss  : { *(.rela.bss)		}
-  .rel.plt   : { *(.rel.plt)		}
-  .rela.plt  : { *(.rela.plt)		}
+  .rel.plt  :
+  {
+*(.rel.plt)
+PROVIDE_HIDDEN (__rel_iplt_start = .);
+*(.rel.iplt)
+PROVIDE_HIDDEN (__rel_iplt_end = .);
+  }
+  .rela.plt   :
+  {
+*(.rela.plt)
+PROVIDE_HIDDEN (__rela_iplt_start = .);
+*(.rela.iplt)
+PROVIDE_HIDDEN (__rela_iplt_end = .);
+  }
   .init  : { *(.init)	} =0x47ff041f
   .text  :
   {
diff --git a/x86_64.ld b/x86_64.ld
index 24ea77d..46d8d4d 100644
--- a/x86_64.ld
+++ b/x86_64.ld
@@ -35,8 +35,20 @@ SECTIONS
   .rela.got   : { *(.rela.got) }
   .rel.bss: { *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*) }
   .rela.bss   : { *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*) }
-  .rel.plt: { *(.rel.plt) }
-  .rela.plt   : { *(.rela.plt) }
+  .rel.plt  :
+  {
+*(.rel.plt)
+PROVIDE_HIDDEN (__rel_iplt_start = .);
+*(.rel.iplt)
+PROVIDE_HIDDEN (__rel_iplt_end = .);
+  }
+  .rela.plt   :
+  {
+*(.rela.plt)
+PROVIDE_HIDDEN (__rela_iplt_start = .);
+*(.rela.iplt)
+PROVIDE_HIDDEN (__rela_iplt_end = .);
+  }
   .init   :
   {
 KEEP (*(.init))
-- 
1.6.5



RE: [Qemu-devel] Stop using "which" in ./configure

2010-01-19 Thread Krumme, Chris
Hello Laurent,

Good or bad "type -P" skips the aliases.

Thanks

Chris 

> -Original Message-
> From: 
> qemu-devel-bounces+chris.krumme=windriver@nongnu.org 
> [mailto:qemu-devel-bounces+chris.krumme=windriver@nongnu.o
> rg] On Behalf Of Laurent Vivier
> Sent: Tuesday, January 19, 2010 4:36 AM
> To: l...@dooz.org
> Cc: qemu-devel@nongnu.org
> Subject: RE: [Qemu-devel] Stop using "which" in ./configure
> 
> >Hi
> >
> > Following the thread on the sdl-config patch, please find attached a
> > patch to add a couple of portable shell functions which 
> allow testing
> > whehter a command/builtin is available and to find the full 
> pathname of
> > an executable in the PATH.  This also replaces all uses of 
> "which" in
> > ./configure.  (This should be applied on top of the 
> sdl-config patch.)
> >
> >   Thanks,
> 
> Why don't you use "type -P" for "path_of" ?"
> 
> Regards,
> Laurent
> -- 
> - laur...@vivier.eu  -
> "Tout ce qui est impossible reste à accomplir"Jules Verne
> "Things are only impossible until they're not" Jean-Luc Picard
> 
> 
> 




Re: [Qemu-devel] [PATCH 0/8] virtio-console: Move to qdev, multiple devices, generic ports

2010-01-19 Thread Anthony Liguori

On 01/14/2010 09:34 AM, Amit Shah wrote:

On (Thu) Jan 14 2010 [08:34:42], Anthony Liguori wrote:
   

On 01/14/2010 07:17 AM, Amit Shah wrote:
 

Hello people,

This iteration of the series removes the START and END flags (and
hence the header associated with each buffer). That's the major change
since the last submission.

   

I think the biggest issue remaining is the buffering.

I think this is a pretty fundamental issue to work out since it
determines the very nature of the transport (stream vs. datagram).
 

The buffering is done so that the guest copy of the buffer is acked so
that the guest can go about doing other things. (Currently the guest
spins till a buffer is acked by the host and waiting for individual
ports to flush their data to whichever receiver will consume some time.)
   


The guest already gets an ack when data is consumed.  The host adds the 
consumed buffer to the used ring.



This also puts buffer management in one place: not all ports will
consume all the data given to them. There's a need to maintain the
buffer contents till the ports consume all the data. This buffer
management can either be done by the individual ports, or it could be
done by the bus code. I prefer doing it in the bus code since the code
will be the same and be in one place instead of each port doing it
separately all around the place.
   


The rings themselves are buffers.  Since each port has a ring, each port 
has independent buffering right now.


Regards,

Anthony Liguori





[Qemu-devel] Fwd: Some encountered issues when compiling openbios on a ppc64 host

2010-01-19 Thread Zhiyong Wu
HI, Blue Swirl

Can you give me a help about the issues below?

Thanks ahead.


Cheers,

Zhiyong Wu

-- Forwarded message --
From: Zhiyong Wu 
Date: Tue, Jan 19, 2010 at 6:27 PM
Subject: Some encountered issues when compiling openbios on a ppc64 host
To: openb...@openbios.org
Cc: Alexander Graf , Zhiyong Wu 


HI, openbios guys,

Today i compiled openbios on my ppc64 box, encoutered some questions:

[r...@945n03 openbios]# uname -a
Linux 945n03 2.6.31.5-127.fc12.ppc64 #1 SMP Sat Nov 7 20:58:24 EST
2009 ppc64 ppc64 ppc64 GNU/Linux

[r...@945n03 openbios]# rpm -qa | grep glibc
glibc-2.11-2.ppc
glibc-2.11-2.ppc64
glibc-devel-2.11-2.ppc
glibc-common-2.11-2.ppc
glibc-headers-2.11-2.ppc

[r...@945n03 openbios]# rpm -qa | grep gcc
libgcc-4.4.2-7.fc12.ppc64
gcc-4.4.2-7.fc12.ppc
libgcc-4.4.2-7.fc12.ppc
gcc-c++-4.4.2-7.fc12.ppc
gcc-gfortran-4.4.2-7.fc12.ppc

[r...@945n03 openbios]# gcc -v
Using built-in specs.
Target: ppc64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info
--with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap
--enable-shared --enable-threads=posix --enable-checking=release
--with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-gnu-unique-object
--enable-languages=c,c++,objc,obj-c++,java,fortran,ada
--enable-java-awt=gtk --disable-dssi --enable-plugin
--with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre
--enable-libgcj-multifile --enable-java-maintainer-mode
--with-ecj-jar=/usr/share/java/eclipse-ecj.jar
--disable-libjava-multilib --with-ppl --with-cloog --enable-secureplt
--with-long-double-128 --build=ppc64-redhat-linux
--target=ppc64-redhat-linux --with-cpu=default32
Thread model: posix
gcc version 4.4.2 20091027 (Red Hat 4.4.2-7) (GCC)

[r...@945n03 openbios]# ./config/scripts/switch-arch ppc
Configuring OpenBIOS on ppc64 for ppc
ERROR: no powerpc cross-compiler found !

When i run "setarch 32 bash", "switch-arch" can work well, but it
fails to run "make"

[r...@945n03 openbios]# uname -a
Linux 945n03 2.6.31.5-127.fc12.ppc64 #1 SMP Sat Nov 7 20:58:24 EST
2009 ppc ppc ppc GNU/Linux

[r...@945n03 openbios]# ./config/scripts/switch-arch ppc
Configuring OpenBIOS on ppc for ppc
Initializing build tree obj-ppc...ok.
Creating target Makefile...ok.
Creating config files...ok.

Building OpenBIOS for ppc
Building...error:
/kvm/openbios/obj-ppc/../libc/string.c:499: undefined reference to
`_restgpr_31_x'
liblibc.a(vsprintf.o): In function `number':
/kvm/openbios/obj-ppc/../libc/vsprintf.c:55: undefined reference to
`_savegpr_19'
/kvm/openbios/obj-ppc/../libc/vsprintf.c:145: undefined reference to
`_restgpr_19_x'
liblibc.a(vsprintf.o): In function `vsnprintf':
/kvm/openbios/obj-ppc/../libc/vsprintf.c:158: undefined reference to
`_savegpr_22'
/kvm/openbios/obj-ppc/../libc/vsprintf.c:388: undefined reference to
`_restgpr_22_x'
libgcc.a(__divdi3.o): In function `__divdi3':
/kvm/openbios/obj-ppc/../libgcc/__divdi3.c:8: undefined reference to
`_savegpr_31'
/kvm/openbios/obj-ppc/../libgcc/__divdi3.c:26: undefined reference to
`_restgpr_31_x'
libgcc.a(__udivmoddi4.o): In function `__udivmoddi4':
/kvm/openbios/obj-ppc/../libgcc/__udivmoddi4.c:4: undefined reference
to `_savegpr_26'
/kvm/openbios/obj-ppc/../libgcc/__udivmoddi4.c:31: undefined reference
to `_restgpr_26_x'
make[1]: *** [openbios-qemu.elf] Error 1
make[1]: Leaving directory `/kvm/openbios/obj-ppc'
make: *** [build] Error 1

Who can give me some advices?


Cheers,

Zhiyong Wu




[Qemu-devel] Re: sparc32 do_unassigned_access overhaul

2010-01-19 Thread Artyom Tarasenko
2010/1/15 Artyom Tarasenko :
> 2010/1/15 Blue Swirl :
>> On Fri, Jan 15, 2010 at 9:11 PM, Artyom Tarasenko
>>  wrote:
>>> 2010/1/15 Blue Swirl :
 On Fri, Jan 15, 2010 at 6:46 PM, Artyom Tarasenko
  wrote:
> According to pages 9-31 - 9-34 of "SuperSPARC & MultiCache Controller
> User's Manual":
>
> 1. "A lower priority fault may not overwrite the
>    MFSR status of a higher priority fault."
> 2. The MFAR is overwritten according to the policy defined for the MFSR
> 3. The overwrite bit is asserted if the fault status register (MFSR)
>   has been written more than once by faults of the same class
> 4. SuperSPARC will never place instruction fault addresses in the MFAR.
>
> Implementation of points 1-3 allows booting Solaris 2.6 and 2.5.1.

 Nice work! This also passes my tests.
>>>
>>> I'm afraid we still are not there yet though: Solaris 7 fails potentially 
>>> due to
>>> another bug in the MMU emulation, and the initial [missing-] RAM
>>> detection in OBP fails
>>> very probably due to a bug in in the MMU emulation.
>>
>> Some guesses:
>>  - Access to unassigned RAM area may be handled by the memory
>> controller differently (no faults, different faults etc.) than
>> unassigned access to SBus or other area.

You are right! It seems to be true for the area larger than max RAM though.
On a real SS-5 with 32M in the first bank, no fault is produced at
least for the areas
0-0x2fff, 0x7000-0xafff (ha, this would solve problems
with SS-20 OBP
too) and 0xf000-0xf6ff.

Would you like to implement it?

That's how I tested it:

ok 800 map?
Virtual  : 0800.
Context  : @ 0.01ff.f000  001f.eec1 # 0
Region   : @ 0.01fe.ec20  . Invalid
ok 800 obmem 800 map-page
ok 800 map?
Virtual  : 0800.
Context  : @ 0.01ff.f000  001f.eec1 # 0
Region   : @ 0.01fe.ec20  001f.b231
Segment  : @ 0.01fb.2300  001f.b221
Page : @ 0.01fb.2200  0080.001e Access : rwx---
Physical : 0.0800.
ok 800 20 dump
  \/  1  2  3  4  5  6  7   8  9  a  b  c  d  e  f  v123456789abcdef
 800  00 d1 e1 44 ff d1 e2 18  08 d1 e1 4e ff d1 e2 18  .QaV.Qb..QaV.Qb.
 810  00 d1 e1 44 ff d1 e2 18  08 d1 e1 4e ff d1 e2 18  .QaV.Qb..QaV.Qb.
ok
ok 1000 map?
Virtual  : 1000.
Context  : @ 0.01ff.f000  001f.eec1 # 0
Region   : @ 0.01fe.ec40  . Invalid
ok 1000 obmem 1000 map-page
ok 1000 20 dump
  \/  1  2  3  4  5  6  7   8  9  a  b  c  d  e  f  v123456789abcdef
1000  04 00 00 05 00 1f e0 00  04 00 00 05 00 1f e0 00  ..`...`.
1010  04 00 00 05 04 00 00 05  04 00 00 05 04 00 00 05  

ok 3000 map?
Virtual  : 3000.
Context  : @ 0.01ff.f000  001f.eec1 # 0
Region   : @ 0.01fe.ecc0  . Invalid
ok 3000 obmem 3000 map-page
ok 3000 20 dump
  \/  1  2  3  4  5  6  7   8  9  a  b  c  d  e  f  v123456789abcdef
3000  Data Access Error
ok 2fff obmem 2fff map-page
ok 2fff 20 dump
  \/  1  2  3  4  5  6  7   8  9  a  b  c  d  e  f  v123456789abcdef
2fff  02 ff e1 44 ff d1 e2 18  2f d1 e1 4e ff d1 e2 18  .QaV.Qb..QaV.Qb.
2fff0010  00 d1 e1 44 ff d1 e2 18  2f d1 e1 4e ff d1 e2 18  .QaV.Qb..QaV.Qb.
ok
ok f000 map?
Virtual  : f000.
Context  : @ 0.01ff.f000  001f.eec1 # 0
Region   : @ 0.01fe.efc0  . Invalid
ok f000 obmem f000 map-page
ok f000 20 dump
  \/  1  2  3  4  5  6  7   8  9  a  b  c  d  e  f  v123456789abcdef
f000  10 80 2f 66 a1 48 00 00  01 00 00 00 01 00 00 00  ../f!H..
f010  29 1c 00 04 a8 15 20 d0  81 c5 00 00 a1 48 00 00  )...(. P.E..!H..
ok f7ff map?
Virtual  : f7ff.
Context  : @ 0.01ff.f000  001f.eec1 # 0
Region   : @ 0.01fe.efdc  . Invalid
ok f7ff obmem f7ff map-page
ok f7ff 20 dump
  \/  1  2  3  4  5  6  7   8  9  a  b  c  d  e  f  v123456789abcdef
f7ff  Data Access Error
ok f6ff map?
Virtual  : f6ff.
Context  : @ 0.01ff.f000  001f.eec1 # 0
Region   : @ 0.01fe.efd8  . Invalid
ok f6ff obmem f6ff map-page
ok f6ff 20 dump
  \/  1  2  3  4  5  6  7   8  9  a  b  c  d  e  f  v123456789abcdef
f6ff  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  
f6ff0010  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  

-- 
Regards,
Artyom Tarasenko

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




[Qemu-devel] KVM developer call minutes (Jan 19)

2010-01-19 Thread Chris Wright

Minutes (please reply w/ corrections or follow-ups):

how is stable branch working (both qemu and kvm)?
- qemu 0.12 cherry picking pretty aggressively
  - could use more community involvement
  - any distro patches for qemu/kvm packages?
- doesn't sound like it

vhost-net command line syntax
- Anthony not a huge fan of current syntax, but will take it
- long term, 0.13, like to revisit all network syntax
  - feature driven UI instead of interface driven UI (user shouldn't
have to know about tun/tap).
- hard to properly express proper raw socket interface
  - users confused by subtle differences between raw and tun/

SR-IOV network device status
- require new enough host kernel to allocate VFs
- once allocated, can be used as PCI networking device in the host
  - shared device w/ bridge and taps
  - assigned device, assigned to guest
- need vhost-net above to get VF dedicated to guest via something like
  raw socket
- not capable to manage the embedded bridge, host OS needs these interfaces

todo collection/status updates
- can use this call for some quick status updates on feature development
- could also use this to highlight areas where feature is stuck or the
  todo list could use some community help.
- may prove useful as a running todo list...

mmio bug fix
- Avi is adding SSE support (kills 8 byte assumption, can be 16 bytes)

vmchannel integration
- qemu merge status
  - buffering should be done by guest not qemu (to avoid using host memory)
- can't inform guest about the size of buffer (can't be infinite)
- makes transport unreliable
  - guest driver should not succeed on write until consumed by host
- guest app writes buffer
- put data into ring queue
- move entries to used queue, now complete write (notify guest)
- guest kernel can force guest app to block
- VNC clipboard copy/paste
  - working w/ Amit's scripts, but needs proper GNOME integration (d-bus
pointers appreciated)
- virtio console just doing one-byte at a time
- qemu char device will either block when full or drop bytes
  - desparately needs to be re-written

SPICE code overview tomorrow (Wed, Jan 20, 15:00 UTC)
- Send email to Dor Laor  if interested

QMP status update
- working on feature negotiation, RFC coming tomorrow
- still working on switching libvirt to using QMP handlers
  - few series outstanding on libvirt list
- Markus working on self-description for protocol




[Qemu-devel] [ANNOUNCE] Release 0.12.2 of QEMU

2010-01-19 Thread Anthony Liguori

The QEMU team is pleased to announce the availability of the 0.12.2
release.  This is a stable release of the 0.12 series and only contains 
bug fixes since 0.12.1.


It can be downloaded from Savannah at:

http://download.savannah.gnu.org/releases/qemu/qemu-0.12.2.tar.gz

On behalf of the QEMU team, I'd like to thank everyone who contributed
to make this release happen!

  - Qemu's internal TFTP server breaks lock-step-iness of TFTP (Milan 
Plzik)

  - osdep.c: Fix accept4 fallback (Kevin Wolf)
  - pc: add rombar to compat properties for pc-0.10 and pc-0.11 (Gerd 
Hoffmann)

  - pci: allow loading roms via fw_cfg. (Gerd Hoffmann)
  - roms: rework rom loading via fw (Gerd Hoffmann)
  - fw_cfg: rom loader tweaks. (Gerd Hoffmann)
  - roms: minor fixes and cleanups. (Gerd Hoffmann)
  - pc: add machine type for 0.12 (Gerd Hoffmann)
  - loader: more ignores for rom intended to be loaded by the bios 
(Aurelien Jarno)

  - vnc_refresh: return if vd->timer is NULL (Stefano Stabellini)
  - QMP: Don't free async event's 'data' (Luiz Capitulino)
  - Handle TFTP ERROR from client (Thomas Horsten)
  - dmg: fix ->open failure (Christoph Hellwig)
  - virtio-pci: thinko fix (Michael S. Tsirkin)
  - pc-bios: Update README (SeaBIOS) (Stefan Weil)
  - vmware_vga: Check cursor dimensions passed from guest to avoid 
buffer overflow (Roland Dreier)

  - remove pending exception on vcpu reset. (Gleb Natapov)
  - Fix CPU topology initialization (Jiri Denemark)
  - MCE: Fix bug of IA32_MCG_STATUS after system reset (Huang Ying)
  - linuxboot: fix gdt address calculation (Avi Kivity)
  - QMP: Drop wrong assert() (Luiz Capitulino)
  - vnc: Fix artifacts in hextile decoding (Anthony Liguori)
  - target-i386: Fix "call im" on x86_64 when executing 32-bit code 
(Aurelien Jarno)

  - Add missing newline at the end of options list (Michael Tokarev)
  - Don't load options roms intended to be loaded by the bios in qemu 
(Avi Kivity)

  - USB: Improve usbdevice error messages (Scott Tsai)
  - cpu-all.h: fix cpu_get_real_ticks() #ifdef (Aurelien Jarno)
  - alpha: fix compile (Blue Swirl)
  - user_only: compile everything with -fpie (Kirill A. Shutemov)
  - fdc/sparc32: don't hang on detection under OBP (Artyom Tarasenko)
  - scsi-disk: Inquiry with allocation length of CDB < 36 (v4) (Artyom 
Tarasenko)

  - e1000: fix init values for command register (Michael S. Tsirkin)

--
Regards,

Anthony Liguori













Re: [Qemu-devel] Stop using "which" in ./configure

2010-01-19 Thread Stefan Weil
Loïc Minier schrieb:
> On Tue, Jan 19, 2010, Loïc Minier wrote:
>   
>>  Following the thread on the sdl-config patch, please find attached a
>>  patch to add a couple of portable shell functions which allow testing
>>  whehter a command/builtin is available and to find the full pathname of
>>  an executable in the PATH.  This also replaces all uses of "which" in
>>  ./configure.  (This should be applied on top of the sdl-config patch.)
>> 
>
>  Please find attached a new version of the patch with a simpler version
>  of path_of() which uses IFS instead of the ${foo#bar} and ${foo%%bar}
>  constructs.  It also removes the special casing of an empty PATH.

I did not test the whole patch, but I think this would be better:

+type "$local_command" >/dev/null 2>&1

(type sends error messages to stderr, we don't want to see them)





[Qemu-devel] [PULL] eepro100 patches

2010-01-19 Thread Michael S. Tsirkin
The following changes since commit 1c39457adf220f9011cc6e08c05b272073ec3126:
  Blue Swirl (1):
Sparc32: Update OpenBIOS image to r666

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/mst/qemu.git for_anthony

Stefan Weil (2):
  eepro100: Restructure code (new function tx_command)
  eepro100: Fix multicast support

 hw/eepro100.c |  243 -
 1 files changed, 137 insertions(+), 106 deletions(-)




Re: [Qemu-devel] [PATCH 0/8] virtio-console: Move to qdev, multiple devices, generic ports

2010-01-19 Thread Jamie Lokier
Anthony Liguori wrote:
> I think this is a pretty fundamental issue to work out since it 
> determines the very nature of the transport (stream vs. datagram).

For the record, I don't think there's anything _wrong_ with a datagram
transport.  It would be quite useful sometimes.  But if there is
datagram support, it should be optional, just like you can choose
between SOCK_STREAM and SOCK_DGRAM for AF_UNIX sockets.

Something else occurred to me with the cut buffer application:

What happens if the guest crashes, kexecs or whatever when it's half
way through sending a cut buffer?  A stream protocol will not have a
nice way to recover from that unless there is an additional "out of
band" way to say "I'm starting again".  Does virtio-serial have an
"I'm starting again" which is passed to the host side application?

> Because you have to put a max buffer size on the transport, I think 
> buffering is a really flawed approach provably equivalent to just 
> increasing the message size within the transport.  In general, the later 
> is a better approach because then the guest is using it's memory vs. 
> using host memory.

I agree, using guest memory for the buffer also means there doesn't
have to be an arbitrary limit on the buffer size, or a time limit.  It
can just wait there until it's consumed or the guest decides to restart.

-- Jamie




[Qemu-devel] Re: Stop using "which" in ./configure

2010-01-19 Thread Måns Rullgård
Laurent Vivier  writes:

>>Hi
>>
>> Following the thread on the sdl-config patch, please find attached a
>> patch to add a couple of portable shell functions which allow testing
>> whehter a command/builtin is available and to find the full pathname of
>> an executable in the PATH.  This also replaces all uses of "which" in
>> ./configure.  (This should be applied on top of the sdl-config patch.)
>>
>>   Thanks,
>
> Why don't you use "type -P" for "path_of" ?"

The standard "type" has no options.

-- 
Måns Rullgård
m...@mansr.com





[Qemu-devel] Re: Stop using "which" in ./configure

2010-01-19 Thread Måns Rullgård
Loïc Minier  writes:

> On Tue, Jan 19, 2010, Loïc Minier wrote:
>>  Following the thread on the sdl-config patch, please find attached a
>>  patch to add a couple of portable shell functions which allow testing
>>  whehter a command/builtin is available and to find the full pathname of
>>  an executable in the PATH.  This also replaces all uses of "which" in
>>  ./configure.  (This should be applied on top of the sdl-config patch.)
>
>  Please find attached a new version of the patch with a simpler version
>  of path_of() which uses IFS instead of the ${foo#bar} and ${foo%%bar}
>  constructs.  It also removes the special casing of an empty PATH.
>
> -- 
> Loïc Minier
>
> From 5fc05ec61d87049ea0f29b2dd51c16e260698ef8 Mon Sep 17 00:00:00 2001
> From: =?UTF-8?q?Lo=C3=AFc=20Minier?= 
> Date: Tue, 19 Jan 2010 11:05:00 +0100
> Subject: [PATCH] Add and use has() and path_of() funcs
>
> Add has() and path_of() funcs and use them across configure; has()
> will test whether a command or builtin is available; path_of() will
> search the PATH for executables and return the full pathname if found.
> ---
>  configure |   53 -
>  1 files changed, 44 insertions(+), 9 deletions(-)
>
> diff --git a/configure b/configure
> index baa2800..711e335 100755
> --- a/configure
> +++ b/configure
> @@ -27,6 +27,43 @@ compile_prog() {
>$cc $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags > 
> /dev/null 2> /dev/null
>  }
>  
> +# check whether a command is available to this shell (may be either an
> +# executable or a builtin)
> +has() {
> +local_command="$1"
> +type "$local_command" >/dev/null
> +}

Why the extra variable?  Using $1 directly seems just as obvious to me.

> +# search for an executable in PATH
> +path_of() {
> +local_command="$1"
> +local_ifs="$IFS"
> +local_dir=""
> +
> +# pathname has a dir component?
> +if [ "${local_command#*/}" != "$local_command" ]; then
> +if [ -x "$local_command" ] && [ ! -d "$local_command" ]; then
> +echo "$local_command"
> +return 0
> +fi
> +fi
> +if [ -z "$local_command" ]; then
> +return 1
> +fi
> +
> +IFS=:
> +for local_dir in $PATH; do
> +if [ -x "$local_dir/$local_command" ] && [ ! -d 
> "$local_dir/$local_command" ]; then
> +echo "$local_dir/$local_command"
> +IFS="$local_ifs"
> +return 0
> +fi
> +done
> +# not found
> +IFS="$local_ifs"
> +return 1
> +}
> +
>  # default parameters
>  cpu=""
>  prefix=""
> @@ -763,7 +800,7 @@ fi
>  # Solaris specific configure tool chain decisions
>  #
>  if test "$solaris" = "yes" ; then
> -  solinst=`which $install 2> /dev/null | /usr/bin/grep -v "no $install in"`
> +  solinst=`path_of $install`
>if test -z "$solinst" ; then
>  echo "Solaris install program not found. Use --install=/usr/ucb/install 
> or"
>  echo "install fileutils from www.blastwave.org using pkg-get -i 
> fileutils"
> @@ -776,7 +813,7 @@ if test "$solaris" = "yes" ; then
>  echo "using pkg-get -i fileutils, or use --install=/usr/ucb/install"
>  exit 1
>fi
> -  sol_ar=`which ar 2> /dev/null | /usr/bin/grep -v "no ar in"`
> +  sol_ar=`path_of ar`
>if test -z "$sol_ar" ; then
>  echo "Error: No path includes ar"
>  if test -f /usr/ccs/bin/ar ; then

Is the full path of these tools really important?  Doesn't look like
it to me.

-- 
Måns Rullgård
m...@mansr.com





Re: [Qemu-devel] [PATCH] sparc64: reimplement tick timers v2

2010-01-19 Thread Blue Swirl
On Mon, Jan 18, 2010 at 10:28 PM, Igor V. Kovalenko
 wrote:
> From: Igor V. Kovalenko 
>
> sparc64 timer has tick counter which can be set and read,
> and tick compare value used as deadline to fire timer interrupt.
> The timer is not used as periodic timer, instead deadline
> is set each time new timer interrupt is needed.

Does not compile:

  CCsparc64-softmmu/sun4u.o
cc1: warnings being treated as errors
/src/qemu/hw/sun4u.c: In function 'cpu_tick_set_count':
/src/qemu/hw/sun4u.c:467: error: implicit declaration of function
'TIMER_DPRINTF'
make[1]: *** [sun4u.o] Error 1

If I add the missing TIMER_DPRINTF, Linux still crashes:

Memory: 117376k available (2136k kernel code, 664k data, 184k init)
[f800,07e8]
SLUB: Genslabs=14, HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
Hierarchical RCU implementation.
NR_IRQS:255
clocksource: mult[a] shift[16]
clockevent: mult[1999] shift[32]
Console: colour dummy device 80x25
Unable to handle kernel NULL pointer dereference
tsk->{mm,active_mm}->context = 
tsk->{mm,active_mm}->pgd = f86fdaa4
  \|/  \|/
  "@'/ .. \`@"
  /_| \__/ |_\
 \__U_/
swapper(0): Oops [#1]
TSTATE: 004480001607 TPC: 006e32f4 TNPC: 006e32f8
Y: Not tainted
TPC: 
g0: 006a6100 g1: 21bd5b03 g2: 00698f10 g3:
0001
g4: 0069d300 g5: f890e000 g6: 00688000 g7:

o0:  o1: 0220 o2:  o3:
0004
o4:  o5: 006a4ec0 sp: 0068b581 ret_pc:
006e32ec
RPC: 
l0:  l1: 006f3dc8 l2:  l3:
0068be50
l4: 0068be40 l5:  l6:  l7:

i0:  i1: f80001002028 i2: 00710470 i3:
0010
i4: 0068be38 i5: fed4 i6: f80007e6b501 i7:
0048b434
I7: <__rcu_process_callbacks+0x74/0x360>
Disabling lock debugging due to kernel taint
Caller[0048b434]: __rcu_process_callbacks+0x74/0x360
Instruction DUMP: 90100013  7ffca49d  c277a7e7  80a04010
086b  c25fa7df  9010001d  7ffca496
Kernel panic - not syncing: Attempted to kill the idle task!
Call Trace:
Impossible unaligned trap. insn=81cfe008
  \|/  \|/
  "@'/ .. \`@"
  /_| \__/ |_\
 \__U_/
swapper(0): Byte sized unaligned access?!?! [#2]
TSTATE:  TPC:  TNPC: 
Y: Tainted: G  D
TPC: <(null)>

etc.

>
> v1 -> v2:
> - new conversion helpers cpu_to_timer_ticks and timer_to_cpu_ticks
> - save offset from clock source to implement cpu_tick_set_count
> - renamed struct sun4u_timer to CPUTimer
> - load and save cpu timers

The registered savevm version needs to be increased and we can't
handle the old savevm version 5 format any more.

>
> v0 -> v1:
> - coding style
>
> Signed-off-by: Igor V. Kovalenko 
> ---
>  hw/sun4u.c             |  214 
> +---
>  target-sparc/cpu.h     |    9 ++
>  target-sparc/machine.c |   12 +--
>  3 files changed, 197 insertions(+), 38 deletions(-)
>
> diff --git a/hw/sun4u.c b/hw/sun4u.c
> index a39b28e..f9db758 100644
> --- a/hw/sun4u.c
> +++ b/hw/sun4u.c
> @@ -280,6 +280,12 @@ void cpu_check_irqs(CPUState *env)
>     }
>  }
>
> +static void cpu_kick_irq(CPUState *env)
> +{
> +    env->halted = 0;
> +    cpu_check_irqs(env);
> +}
> +
>  static void cpu_set_irq(void *opaque, int irq, int level)
>  {
>     CPUState *env = opaque;
> @@ -301,6 +307,68 @@ typedef struct ResetData {
>     uint64_t prom_addr;
>  } ResetData;
>
> +struct CPUTimer
> +{
> +    const char *name;
> +    uint32_t    frequency;
> +    uint32_t    disabled;
> +    uint64_t    disabled_mask;
> +    int64_t     clock_offset;
> +    QEMUTimer  *qtimer;
> +};
> +
> +typedef struct CPUTimer CPUTimer;
> +
> +void cpu_put_timer(QEMUFile *f, CPUTimer *s)
> +{
> +    qemu_put_be32s(f, &s->frequency);
> +    qemu_put_be32s(f, &s->disabled);
> +    qemu_put_be64s(f, &s->disabled_mask);
> +    qemu_put_sbe64s(f, &s->clock_offset);
> +    if (s->qtimer) {
> +        qemu_put_timer(f, s->qtimer);
> +    }
> +}
> +
> +void cpu_get_timer(QEMUFile *f, CPUTimer *s)
> +{
> +    qemu_get_be32s(f, &s->frequency);
> +    qemu_get_be32s(f, &s->disabled);
> +    qemu_get_be64s(f, &s->disabled_mask);
> +    qemu_get_sbe64s(f, &s->clock_offset);
> +    if (s->qtimer) {
> +        qemu_get_timer(f, s->qtimer);
> +    }

Whether the old state had qtimer non-NULL or not shouldn't affect
loading. Likewise, we always want to save. Dynamical state may not
affect savevm format.

This kind of conditional save/load would be OK, if for example some
class of timers didn't ever have the missing piece (because of some
hardware difference).

> +}
> +
> +static CPUTimer* cpu_timer_create(const char*

Re: [Qemu-devel] Re: [PATCH 01/14] Introduce qemu_write_full()

2010-01-19 Thread Blue Swirl
On Tue, Jan 19, 2010 at 12:17 PM, Kirill A. Shutemov
 wrote:
> On Tue, Jan 19, 2010 at 2:11 PM, Juan Quintela  wrote:
>> "Kirill A. Shutemov"  wrote:
>>> A variant of write(2) which handles partial write.
>>>
>>> Signed-off-by: Kirill A. Shutemov 
>>
>> Hi
>>
>> Have you updated this series?  Is there any reason that you know when
>> they haven't been picked?
>
> I don't  know any reason, but I'm going to review it once again.

I don't know about others, but I didn't feel competent enough about
all possible corner cases of write().

> I also have plan to get rid of -fno-strict-aliasing where it's possible.

That should be interesting too, if it does not make code more unreadable.




Re: [Qemu-devel] [PATCH 07/10] qcow2: Improve error handling in update_refcount

2010-01-19 Thread Christoph Hellwig
On Mon, Jan 18, 2010 at 01:11:33PM +0100, Kevin Wolf wrote:
> If update_refcount fails, try to undo any changes made so far to avoid
> inconsistencies in the image file.
> 
> Signed-off-by: Kevin Wolf 
> ---
>  block/qcow2-refcount.c |   32 +---
>  1 files changed, 25 insertions(+), 7 deletions(-)
> 

> +/*
> + * Try do undo any updates if an error is returned (This may succeed in
> + * some cases like ENOSPC for allocating a new refcount block)
> + */
> +if (ret < 0) {
> +int dummy;
> +dummy = update_refcount(bs, offset, cluster_offset - offset, 
> -addend);

So we recursively call into update_refcount here.  What happens an error
causes all updates to fail?





Re: [Qemu-devel] [PATCH 08/10] qcow2: Allow updating no refcounts

2010-01-19 Thread Christoph Hellwig
>  #endif
> -if (length <= 0)
> +if (length < 0) {
>  return -EINVAL;
> +}
> +
>  start = offset & ~(s->cluster_size - 1);
>  last = (offset + length - 1) & ~(s->cluster_size - 1);
>  for(cluster_offset = start; cluster_offset <= last;

So for legnth = 0, last will equal start and we'll never go through
the loop.  But should we really bother with all the other work in the
function or just return 0 early on?





Re: [Qemu-devel] [PATCH 09/10] qcow2: Don't ignore update_refcount return value

2010-01-19 Thread Christoph Hellwig
Looks good,


Reviewed-by: Christoph Hellwig 




Re: [Qemu-devel] [PATCH 10/10] qcow2: Don't ignore qcow2_alloc_clusters return value

2010-01-19 Thread Christoph Hellwig
On Mon, Jan 18, 2010 at 01:11:36PM +0100, Kevin Wolf wrote:
> @@ -55,6 +55,9 @@ int qcow2_grow_l1_table(BlockDriverState *bs, int min_size)
>  
>  /* write new table (align to cluster) */
>  new_l1_table_offset = qcow2_alloc_clusters(bs, new_l1_size2);
> +if (new_l1_table_offset < 0) {
> +return new_l1_table_offset;
> +}

I think the error return needs to free new_l1_table first.





Re: [Qemu-devel] [PATCH 0/8] virtio-console: Move to qdev, multiple devices, generic ports

2010-01-19 Thread Amit Shah
On (Tue) Jan 19 2010 [17:59:33], Jamie Lokier wrote:
> 
> What happens if the guest crashes, kexecs or whatever when it's half
> way through sending a cut buffer?  A stream protocol will not have a
> nice way to recover from that unless there is an additional "out of
> band" way to say "I'm starting again".  Does virtio-serial have an
> "I'm starting again" which is passed to the host side application?

That's what I meant when I was talking about the START and END
delimiters. I've removed those for now though. Something like what you
suggest can be added later on.

Amit




[Qemu-devel] [PATCH 0/8] virtio-console: Move to qdev, multiple devices, generic ports

2010-01-19 Thread Amit Shah
Hello all,

In this series I've removed the buffering that happened in the host
and ack the amount of data that ports actually consume. This basically
removes the older patch 5/8 that introduced buffering and throttling.

Other changes include addition of patch 8: MSI support and ensuring we
don't crash in the event we don't have chardevs opened and guest
writes out to virtio-consoles.

Obligatory disclaimer:
This series splits up the patches by functionality. Note, however,
that patches 2-5 introduce some functionality that's advertised to the
guest as having to work all at once or not at all. Also, the savevm
version is bumped only once but save/restore state is added in each of
the patches. They are split only for easier reviewability.

The older virtio-console.c file is completely removed and a new
virtio-serial.c is introduced so that reviewing is easier. I can send a
later patch to rename virtio-serial.c back to virtio-console.c.


Amit Shah (8):
  virtio: Remove duplicate macro definition for max. virtqueues, bump
up the max
  virtio-console: qdev conversion, new virtio-serial-bus
  virtio-serial-bus: Maintain guest and host port open/close state
  virtio-serial-bus: Add a port 'name' property for port discovery in
guests
  virtio-serial-bus: Add ability to hot-unplug ports
  virtio-serial: Add a 'virtserialport' device for generic serial port
support
  Move virtio-serial to Makefile.objs
  virtio-serial: Use MSI vectors for port virtqueues

 Makefile.objs  |2 +-
 Makefile.target|2 +-
 hw/pc.c|   11 +-
 hw/ppc440_bamboo.c |7 -
 hw/qdev.c  |   10 +-
 hw/s390-virtio-bus.c   |   17 +-
 hw/s390-virtio-bus.h   |2 +
 hw/s390-virtio.c   |8 -
 hw/virtio-console.c|  143 ---
 hw/virtio-console.h|   19 --
 hw/virtio-pci.c|   17 +-
 hw/virtio-serial-bus.c |  620 
 hw/virtio-serial.c |  146 
 hw/virtio-serial.h |  173 ++
 hw/virtio.c|2 -
 hw/virtio.h|4 +-
 qemu-options.hx|4 +
 sysemu.h   |6 -
 vl.c   |2 +
 19 files changed, 978 insertions(+), 217 deletions(-)
 delete mode 100644 hw/virtio-console.c
 delete mode 100644 hw/virtio-console.h
 create mode 100644 hw/virtio-serial-bus.c
 create mode 100644 hw/virtio-serial.c
 create mode 100644 hw/virtio-serial.h





[Qemu-devel] [PATCH 1/8] virtio: Remove duplicate macro definition for max. virtqueues, bump up the max

2010-01-19 Thread Amit Shah
VIRTIO_PCI_QUEUE_MAX is redefined in hw/virtio.c. Let's just keep it in
hw/virtio.h.

Also, bump up the value of the maximum allowed virtqueues to 64. This is
in preparation to allow multiple ports per virtio-console device.

Signed-off-by: Amit Shah 
---
 hw/virtio.c |2 --
 hw/virtio.h |2 +-
 2 files changed, 1 insertions(+), 3 deletions(-)

diff --git a/hw/virtio.c b/hw/virtio.c
index fa7184a..7c020a3 100644
--- a/hw/virtio.c
+++ b/hw/virtio.c
@@ -75,8 +75,6 @@ struct VirtQueue
 void (*handle_output)(VirtIODevice *vdev, VirtQueue *vq);
 };
 
-#define VIRTIO_PCI_QUEUE_MAX16
-
 /* virt queue functions */
 static void virtqueue_init(VirtQueue *vq)
 {
diff --git a/hw/virtio.h b/hw/virtio.h
index 3994cc9..7b2b327 100644
--- a/hw/virtio.h
+++ b/hw/virtio.h
@@ -90,7 +90,7 @@ typedef struct {
 unsigned (*get_features)(void * opaque);
 } VirtIOBindings;
 
-#define VIRTIO_PCI_QUEUE_MAX 16
+#define VIRTIO_PCI_QUEUE_MAX 64
 
 #define VIRTIO_NO_VECTOR 0x
 
-- 
1.6.2.5





[Qemu-devel] [PATCH 2/8] virtio-console: qdev conversion, new virtio-serial-bus

2010-01-19 Thread Amit Shah
This commit converts the virtio-console device to create a new
virtio-serial bus that can host console and generic serial ports. The
file hosting this code is now called virtio-serial-bus.c.

The virtio console is now a very simple qdev device that sits on the
virtio-serial-bus and communicates between the bus and qemu's chardevs.

This commit also includes a few changes to the virtio backing code for
pci and s390 to spawn the virtio-serial bus.

As a result of the qdev conversion, we get rid of a lot of legacy code.
The old-style way of instantiating a virtio console using

-virtioconsole ...

is maintained, but the new, preferred way is to use

-device virtio-serial -device virtconsole,chardev=...

With this commit, multiple devices as well as multiple ports with a
single device can be supported.

For multiple ports support, each port gets an IO vq pair. Since the
guest needs to know in advance how many vqs a particular device will
need, we have to set this number as a property of the virtio-serial
device and also as a config option.

In addition, we also spawn a pair of control IO vqs. This is an internal
channel meant for guest-host communication for things like port
open/close, sending port properties over to the guest, etc.

This commit is a part of a series of other commits to get the full
implementation of multiport support. Future commits will add other
support as well as ride on the savevm version that we bump up here.

Signed-off-by: Amit Shah 
---
 Makefile.target|2 +-
 hw/pc.c|   11 +-
 hw/ppc440_bamboo.c |7 -
 hw/qdev.c  |   10 +-
 hw/s390-virtio-bus.c   |   17 +-
 hw/s390-virtio-bus.h   |2 +
 hw/s390-virtio.c   |8 -
 hw/virtio-console.c|  143 --
 hw/virtio-console.h|   19 --
 hw/virtio-pci.c|   13 +-
 hw/virtio-serial-bus.c |  507 
 hw/virtio-serial.c |  111 +++
 hw/virtio-serial.h |  158 +++
 hw/virtio.h|2 +-
 qemu-options.hx|4 +
 sysemu.h   |6 -
 vl.c   |2 +
 17 files changed, 809 insertions(+), 213 deletions(-)
 delete mode 100644 hw/virtio-console.c
 delete mode 100644 hw/virtio-console.h
 create mode 100644 hw/virtio-serial-bus.c
 create mode 100644 hw/virtio-serial.c
 create mode 100644 hw/virtio-serial.h

diff --git a/Makefile.target b/Makefile.target
index e661478..60df16d 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -172,7 +172,7 @@ ifdef CONFIG_SOFTMMU
 obj-y = vl.o async.o monitor.o pci.o pci_host.o pcie_host.o machine.o gdbstub.o
 # virtio has to be here due to weird dependency between PCI and virtio-net.
 # need to fix this properly
-obj-y += virtio-blk.o virtio-balloon.o virtio-net.o virtio-console.o 
virtio-pci.o
+obj-y += virtio-blk.o virtio-balloon.o virtio-net.o virtio-serial.o 
virtio-serial-bus.o virtio-pci.o
 obj-$(CONFIG_KVM) += kvm.o kvm-all.o
 obj-$(CONFIG_ISA_MMIO) += isa_mmio.o
 LIBS+=-lz
diff --git a/hw/pc.c b/hw/pc.c
index a93c5f2..3aadfa9 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -1018,15 +1018,6 @@ static void pc_init1(ram_addr_t ram_size,
 pci_create_simple(pci_bus, -1, "lsi53c895a");
 }
 }
-
-/* Add virtio console devices */
-if (pci_enabled) {
-for(i = 0; i < MAX_VIRTIO_CONSOLES; i++) {
-if (virtcon_hds[i]) {
-pci_create_simple(pci_bus, -1, "virtio-console-pci");
-}
-}
-}
 }
 
 static void pc_init_pci(ram_addr_t ram_size,
@@ -1102,7 +1093,7 @@ static QEMUMachine pc_machine_v0_10 = {
 .property = "class",
 .value= stringify(PCI_CLASS_STORAGE_OTHER),
 },{
-.driver   = "virtio-console-pci",
+.driver   = "virtio-serial-pci",
 .property = "class",
 .value= stringify(PCI_CLASS_DISPLAY_OTHER),
 },{
diff --git a/hw/ppc440_bamboo.c b/hw/ppc440_bamboo.c
index a488240..1ab9872 100644
--- a/hw/ppc440_bamboo.c
+++ b/hw/ppc440_bamboo.c
@@ -108,13 +108,6 @@ static void bamboo_init(ram_addr_t ram_size,
 env = ppc440ep_init(&ram_size, &pcibus, pci_irq_nrs, 1, cpu_model);
 
 if (pcibus) {
-/* Add virtio console devices */
-for(i = 0; i < MAX_VIRTIO_CONSOLES; i++) {
-if (virtcon_hds[i]) {
-pci_create_simple(pcibus, -1, "virtio-console-pci");
-}
-}
-
 /* Register network interfaces. */
 for (i = 0; i < nb_nics; i++) {
 /* There are no PCI NICs on the Bamboo board, but there are
diff --git a/hw/qdev.c b/hw/qdev.c
index b6bd4ae..c643576 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -321,13 +321,9 @@ void qdev_machine_creation_done(void)
 CharDriverState *qdev_init_chardev(DeviceState *dev)
 {
 static int next_serial;
-static int next_virtconsole;
-/* FIXME: This is a nasty hack that needs to go away.  */
-if (strncmp(dev->info->name, "virtio", 6) == 

[Qemu-devel] [PATCH 3/8] virtio-serial-bus: Maintain guest and host port open/close state

2010-01-19 Thread Amit Shah
Via control channel messages, the guest can tell us whether a port got
opened or closed. Similarly, we can also indicate to the guest of host
port open/close events.

Signed-off-by: Amit Shah 
---
 hw/virtio-serial-bus.c |   94 
 hw/virtio-serial.h |6 +++
 2 files changed, 100 insertions(+), 0 deletions(-)

diff --git a/hw/virtio-serial-bus.c b/hw/virtio-serial-bus.c
index e8bbd7d..5bf2990 100644
--- a/hw/virtio-serial-bus.c
+++ b/hw/virtio-serial-bus.c
@@ -66,6 +66,11 @@ static VirtIOSerialPort *find_port_by_vq(VirtIOSerial *vser, 
VirtQueue *vq)
 return NULL;
 }
 
+static bool use_multiport(VirtIOSerial *vser)
+{
+return vser->vdev.guest_features & (1 << VIRTIO_CONSOLE_F_MULTIPORT);
+}
+
 static size_t write_to_port(VirtIOSerialPort *port,
 const uint8_t *buf, size_t size)
 {
@@ -139,11 +144,22 @@ static size_t send_control_event(VirtIOSerialPort *port, 
uint16_t event,
 /* Functions for use inside qemu to open and read from/write to ports */
 int virtio_serial_open(VirtIOSerialPort *port)
 {
+/* Don't allow opening an already-open port */
+if (port->host_connected) {
+return 0;
+}
+/* Send port open notification to the guest */
+port->host_connected = true;
+send_control_event(port, VIRTIO_CONSOLE_PORT_OPEN, 1);
+
 return 0;
 }
 
 int virtio_serial_close(VirtIOSerialPort *port)
 {
+port->host_connected = false;
+send_control_event(port, VIRTIO_CONSOLE_PORT_OPEN, 0);
+
 return 0;
 }
 
@@ -151,6 +167,9 @@ int virtio_serial_close(VirtIOSerialPort *port)
 ssize_t virtio_serial_write(VirtIOSerialPort *port, const uint8_t *buf,
 size_t size)
 {
+if (!port || !port->host_connected || !port->guest_connected) {
+return 0;
+}
 return write_to_port(port, buf, size);
 }
 
@@ -167,6 +186,9 @@ size_t virtio_serial_guest_ready(VirtIOSerialPort *port)
 virtio_queue_empty(vq)) {
 return 0;
 }
+if (use_multiport(port->vser) && !port->guest_connected) {
+return 0;
+}
 
 if (virtqueue_avail_bytes(vq, 4096, 0)) {
 return 4096;
@@ -203,6 +225,11 @@ static void handle_control_message(VirtIOSerial *vser, 
void *buf)
 if (port->is_console) {
 send_control_event(port, VIRTIO_CONSOLE_CONSOLE_PORT, 1);
 }
+
+if (port->host_connected) {
+send_control_event(port, VIRTIO_CONSOLE_PORT_OPEN, 1);
+}
+
 /*
  * When the guest has asked us for this information it means
  * the guest is all setup and has its virtqueues
@@ -213,6 +240,19 @@ static void handle_control_message(VirtIOSerial *vser, 
void *buf)
 port->info->guest_ready(port);
 }
 break;
+
+case VIRTIO_CONSOLE_PORT_OPEN:
+port->guest_connected = cpkt.value;
+if (cpkt.value && port->info->guest_open) {
+/* Send the guest opened notification if an app is interested */
+port->info->guest_open(port);
+}
+
+if (!cpkt.value && port->info->guest_close) {
+/* Send the guest closed notification if an app is interested */
+port->info->guest_close(port);
+}
+break;
 }
 }
 
@@ -302,6 +342,8 @@ static void set_config(VirtIODevice *vdev, const uint8_t 
*config_data)
 static void virtio_serial_save(QEMUFile *f, void *opaque)
 {
 VirtIOSerial *s = opaque;
+VirtIOSerialPort *port;
+uint32_t nr_active_ports;
 
 /* The virtio device */
 virtio_save(&s->vdev, f);
@@ -310,15 +352,41 @@ static void virtio_serial_save(QEMUFile *f, void *opaque)
 qemu_put_be16s(f, &s->config.cols);
 qemu_put_be16s(f, &s->config.rows);
 qemu_put_be32s(f, &s->config.nr_ports);
+
+/* Items in struct VirtIOSerial */
+
+/* Do this because we might have hot-unplugged some ports */
+nr_active_ports = 0;
+QTAILQ_FOREACH(port, &s->ports, next)
+nr_active_ports++;
+
+qemu_put_be32s(f, &nr_active_ports);
+
+/*
+ * Items in struct VirtIOSerialPort.
+ */
+QTAILQ_FOREACH(port, &s->ports, next) {
+/*
+ * We put the port number because we may not have an active
+ * port at id 0 that's reserved for a console port, or in case
+ * of ports that might have gotten unplugged
+ */
+qemu_put_be32s(f, &port->id);
+qemu_put_byte(f, port->guest_connected);
+}
 }
 
 static int virtio_serial_load(QEMUFile *f, void *opaque, int version_id)
 {
 VirtIOSerial *s = opaque;
+VirtIOSerialPort *port;
+uint32_t nr_active_ports;
+unsigned int i;
 
 if (version_id > 2) {
 return -EINVAL;
 }
+
 /* The virtio device */
 virtio_load(&s->vdev, f);
 
@@ -331,6 +399,20 @@ static int virtio_serial_load(QEMUFile *f, void *opaque, 
int version_id)
 qemu_get_be16s(f, &s->config.rows);
 s->config.nr_ports = qemu_get_be32(f);
 
+/* Items in struct 

[Qemu-devel] [PATCH 4/8] virtio-serial-bus: Add a port 'name' property for port discovery in guests

2010-01-19 Thread Amit Shah
The port 'id' or number is internal state between the guest kernel and
our bus implementation. This is invocation-dependent and isn't part of
the guest-host ABI.

To correcly enumerate and map ports between the host and the guest, the
'name' property is used.

Example:

-device virtserialport,name=org.qemu.port.0

This invocation will get us a char device in the guest at:

/dev/virtio-ports/org.qemu.port.0

which can be a symlink to

/dev/vport0p3

This 'name' property is exposed by the guest kernel in a sysfs
attribute:

/sys/kernel/virtio-ports/vport0p3/name

A simple udev script can pick up this name and create the symlink
mentioned above.

Signed-off-by: Amit Shah 
---
 hw/virtio-serial-bus.c |   17 +
 hw/virtio-serial.c |1 +
 hw/virtio-serial.h |8 
 3 files changed, 26 insertions(+), 0 deletions(-)

diff --git a/hw/virtio-serial-bus.c b/hw/virtio-serial-bus.c
index 5bf2990..7e100d0 100644
--- a/hw/virtio-serial-bus.c
+++ b/hw/virtio-serial-bus.c
@@ -204,6 +204,8 @@ static void handle_control_message(VirtIOSerial *vser, void 
*buf)
 {
 struct VirtIOSerialPort *port;
 struct virtio_console_control cpkt, *gcpkt;
+uint8_t *buffer;
+size_t buffer_len;
 
 gcpkt = buf;
 port = find_port_by_id(vser, ldl_p(&gcpkt->id));
@@ -226,6 +228,21 @@ static void handle_control_message(VirtIOSerial *vser, 
void *buf)
 send_control_event(port, VIRTIO_CONSOLE_CONSOLE_PORT, 1);
 }
 
+if (port->name) {
+stw_p(&cpkt.event, VIRTIO_CONSOLE_PORT_NAME);
+stw_p(&cpkt.value, 1);
+
+buffer_len = sizeof(cpkt) + strlen(port->name) + 1;
+buffer = qemu_malloc(buffer_len);
+
+memcpy(buffer, &cpkt, sizeof(cpkt));
+memcpy(buffer + sizeof(cpkt), port->name, strlen(port->name));
+buffer[buffer_len - 1] = 0;
+
+send_control_msg(port, buffer, buffer_len);
+qemu_free(buffer);
+}
+
 if (port->host_connected) {
 send_control_event(port, VIRTIO_CONSOLE_PORT_OPEN, 1);
 }
diff --git a/hw/virtio-serial.c b/hw/virtio-serial.c
index 1dc031e..9c2c93c 100644
--- a/hw/virtio-serial.c
+++ b/hw/virtio-serial.c
@@ -100,6 +100,7 @@ static VirtIOSerialPortInfo virtconsole_info = {
 .qdev.props = (Property[]) {
 DEFINE_PROP_UINT8("is_console", VirtConsole, port.is_console, 1),
 DEFINE_PROP_CHR("chardev", VirtConsole, chr),
+DEFINE_PROP_STRING("name", VirtConsole, port.name),
 DEFINE_PROP_END_OF_LIST(),
 },
 };
diff --git a/hw/virtio-serial.h b/hw/virtio-serial.h
index d9c7acb..28ea7da 100644
--- a/hw/virtio-serial.h
+++ b/hw/virtio-serial.h
@@ -50,6 +50,7 @@ struct virtio_console_control {
 #define VIRTIO_CONSOLE_CONSOLE_PORT1
 #define VIRTIO_CONSOLE_RESIZE  2
 #define VIRTIO_CONSOLE_PORT_OPEN   3
+#define VIRTIO_CONSOLE_PORT_NAME   4
 
 /* == In-qemu interface == */
 
@@ -84,6 +85,13 @@ struct VirtIOSerialPort {
 VirtQueue *ivq, *ovq;
 
 /*
+ * This name is sent to the guest and exported via sysfs.
+ * The guest could create symlinks based on this information.
+ * The name is in the reverse fqdn format, like org.qemu.console.0
+ */
+char *name;
+
+/*
  * This id helps identify ports between the guest and the host.
  * The guest sends a "header" with this id with each data packet
  * that it sends and the host can then find out which associated
-- 
1.6.2.5





[Qemu-devel] [PATCH 5/8] virtio-serial-bus: Add ability to hot-unplug ports

2010-01-19 Thread Amit Shah
Signed-off-by: Amit Shah 
---
 hw/virtio-serial-bus.c |2 ++
 hw/virtio-serial.h |1 +
 2 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/hw/virtio-serial-bus.c b/hw/virtio-serial-bus.c
index 7e100d0..403268f 100644
--- a/hw/virtio-serial-bus.c
+++ b/hw/virtio-serial-bus.c
@@ -520,6 +520,8 @@ static int virtser_port_qdev_exit(DeviceState *qdev)
 VirtIOSerialPort *port = DO_UPCAST(VirtIOSerialPort, dev, &dev->qdev);
 VirtIOSerial *vser = port->vser;
 
+send_control_event(port, VIRTIO_CONSOLE_PORT_REMOVE, 1);
+
 /*
  * Don't decrement nr_ports here; thus we keep a linearly
  * increasing port id. Not utilising an id again saves us a couple
diff --git a/hw/virtio-serial.h b/hw/virtio-serial.h
index 28ea7da..f297b00 100644
--- a/hw/virtio-serial.h
+++ b/hw/virtio-serial.h
@@ -51,6 +51,7 @@ struct virtio_console_control {
 #define VIRTIO_CONSOLE_RESIZE  2
 #define VIRTIO_CONSOLE_PORT_OPEN   3
 #define VIRTIO_CONSOLE_PORT_NAME   4
+#define VIRTIO_CONSOLE_PORT_REMOVE 5
 
 /* == In-qemu interface == */
 
-- 
1.6.2.5





[Qemu-devel] [PATCH 6/8] virtio-serial: Add a 'virtserialport' device for generic serial port support

2010-01-19 Thread Amit Shah
This commit adds a simple chardev-based serial port. Any data the guest
sends is forwarded to the chardev and vice-versa.

Sample uses for such a device can be obtaining info from the guest like
the file systems used, apps installed, etc. for offline usage and
logged-in users, clipboard copy-paste, etc. for online usage.

Signed-off-by: Amit Shah 
---
 hw/virtio-serial.c |   34 ++
 1 files changed, 34 insertions(+), 0 deletions(-)

diff --git a/hw/virtio-serial.c b/hw/virtio-serial.c
index 9c2c93c..bd44ec6 100644
--- a/hw/virtio-serial.c
+++ b/hw/virtio-serial.c
@@ -110,3 +110,37 @@ static void virtconsole_register(void)
 virtio_serial_port_qdev_register(&virtconsole_info);
 }
 device_init(virtconsole_register)
+
+/* Generic Virtio Serial Ports */
+static int virtserialport_initfn(VirtIOSerialDevice *dev)
+{
+VirtIOSerialPort *port = DO_UPCAST(VirtIOSerialPort, dev, &dev->qdev);
+VirtConsole *vcon = DO_UPCAST(VirtConsole, port, port);
+
+port->info = dev->info;
+
+if (vcon->chr) {
+qemu_chr_add_handlers(vcon->chr, chr_can_read, chr_read, chr_event,
+  vcon);
+port->info->have_data = flush_buf;
+}
+return 0;
+}
+
+static VirtIOSerialPortInfo virtserialport_info = {
+.qdev.name = "virtserialport",
+.qdev.size = sizeof(VirtConsole),
+.init  = virtserialport_initfn,
+.exit  = virtconsole_exitfn,
+.qdev.props = (Property[]) {
+DEFINE_PROP_CHR("chardev", VirtConsole, chr),
+DEFINE_PROP_STRING("name", VirtConsole, port.name),
+DEFINE_PROP_END_OF_LIST(),
+},
+};
+
+static void virtserialport_register(void)
+{
+virtio_serial_port_qdev_register(&virtserialport_info);
+}
+device_init(virtserialport_register)
-- 
1.6.2.5





[Qemu-devel] [PATCH 7/8] Move virtio-serial to Makefile.objs

2010-01-19 Thread Amit Shah
There's nothing target-dependent in the virtio-serial code so allow it
to be compiled just once for all the targets.

Signed-off-by: Amit Shah 
---
 Makefile.objs   |2 +-
 Makefile.target |2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/Makefile.objs b/Makefile.objs
index 5802d39..77ff7f6 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -127,7 +127,7 @@ user-obj-y += cutils.o cache-utils.o
 
 hw-obj-y =
 hw-obj-y += loader.o
-hw-obj-y += virtio.o
+hw-obj-y += virtio.o virtio-serial.o
 hw-obj-y += fw_cfg.o
 hw-obj-y += watchdog.o
 hw-obj-$(CONFIG_ECC) += ecc.o
diff --git a/Makefile.target b/Makefile.target
index 60df16d..0bf2253 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -172,7 +172,7 @@ ifdef CONFIG_SOFTMMU
 obj-y = vl.o async.o monitor.o pci.o pci_host.o pcie_host.o machine.o gdbstub.o
 # virtio has to be here due to weird dependency between PCI and virtio-net.
 # need to fix this properly
-obj-y += virtio-blk.o virtio-balloon.o virtio-net.o virtio-serial.o 
virtio-serial-bus.o virtio-pci.o
+obj-y += virtio-blk.o virtio-balloon.o virtio-net.o virtio-pci.o 
virtio-serial-bus.o
 obj-$(CONFIG_KVM) += kvm.o kvm-all.o
 obj-$(CONFIG_ISA_MMIO) += isa_mmio.o
 LIBS+=-lz
-- 
1.6.2.5





[Qemu-devel] [PATCH 8/8] virtio-serial: Use MSI vectors for port virtqueues

2010-01-19 Thread Amit Shah
This commit enables the use of MSI interrupts for virtqueue
notifications for ports. We use nr_ports + 1 (for control channel) msi
entries for the ports, as only the in_vq operations need an interrupt on
the guest.

Signed-off-by: Amit Shah 
---
 hw/virtio-pci.c |4 
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c
index e7fabfb..709d13e 100644
--- a/hw/virtio-pci.c
+++ b/hw/virtio-pci.c
@@ -499,10 +499,13 @@ static int virtio_serial_init_pci(PCIDevice *pci_dev)
 if (!vdev) {
 return -1;
 }
+vdev->nvectors = proxy->nvectors ? proxy->nvectors
+ : proxy->max_virtserial_ports + 1;
 virtio_init_pci(proxy, vdev,
 PCI_VENDOR_ID_REDHAT_QUMRANET,
 PCI_DEVICE_ID_VIRTIO_CONSOLE,
 proxy->class_code, 0x00);
+proxy->nvectors = vdev->nvectors;
 return 0;
 }
 
@@ -581,6 +584,7 @@ static PCIDeviceInfo virtio_info[] = {
 .init  = virtio_serial_init_pci,
 .exit  = virtio_exit_pci,
 .qdev.props = (Property[]) {
+DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy, nvectors, 0),
 DEFINE_PROP_HEX32("class", VirtIOPCIProxy, class_code, 0),
 DEFINE_VIRTIO_COMMON_FEATURES(VirtIOPCIProxy, host_features),
 DEFINE_PROP_UINT32("max_ports", VirtIOPCIProxy, 
max_virtserial_ports,
-- 
1.6.2.5





[Qemu-devel] Re: sparc32 do_unassigned_access overhaul

2010-01-19 Thread Blue Swirl
On Tue, Jan 19, 2010 at 5:30 PM, Artyom Tarasenko
 wrote:
> 2010/1/15 Artyom Tarasenko :
>> 2010/1/15 Blue Swirl :
>>> On Fri, Jan 15, 2010 at 9:11 PM, Artyom Tarasenko
>>>  wrote:
 2010/1/15 Blue Swirl :
> On Fri, Jan 15, 2010 at 6:46 PM, Artyom Tarasenko
>  wrote:
>> According to pages 9-31 - 9-34 of "SuperSPARC & MultiCache Controller
>> User's Manual":
>>
>> 1. "A lower priority fault may not overwrite the
>>    MFSR status of a higher priority fault."
>> 2. The MFAR is overwritten according to the policy defined for the MFSR
>> 3. The overwrite bit is asserted if the fault status register (MFSR)
>>   has been written more than once by faults of the same class
>> 4. SuperSPARC will never place instruction fault addresses in the MFAR.
>>
>> Implementation of points 1-3 allows booting Solaris 2.6 and 2.5.1.
>
> Nice work! This also passes my tests.

 I'm afraid we still are not there yet though: Solaris 7 fails potentially 
 due to
 another bug in the MMU emulation, and the initial [missing-] RAM
 detection in OBP fails
 very probably due to a bug in in the MMU emulation.
>>>
>>> Some guesses:
>>>  - Access to unassigned RAM area may be handled by the memory
>>> controller differently (no faults, different faults etc.) than
>>> unassigned access to SBus or other area.
>
> You are right! It seems to be true for the area larger than max RAM though.
> On a real SS-5 with 32M in the first bank, no fault is produced at
> least for the areas
> 0-0x2fff, 0x7000-0xafff (ha, this would solve problems
> with SS-20 OBP
> too) and 0xf000-0xf6ff.

The fault may still be recorded somewhere else (MXCC, RAM/ECC
controller or IOMMU). OBP may have disabled the fault, or it has not
enabled fault generation.

On SS-5, the physical address space should be only 31 bits, so you
should see RAM aliased at 0x8000.

> Would you like to implement it?

For RAM, there could be a new device which implements generic address
space wrapping (base, length, AND mask, OR mask), it should be useful
for embedded boards. Shouldn't be too difficult, want to try? :-)

Dummy MMIO could be registered for the other areas in sun4m.c. I'm not
sure this is the correct approach, if the fault is still handled
somewhere else.

> That's how I tested it:
>
> ok 800 map?
> Virtual  : 0800.
> Context  : @ 0.01ff.f000  001f.eec1 # 0
> Region   : @ 0.01fe.ec20  . Invalid
> ok 800 obmem 800 map-page
> ok 800 map?
> Virtual  : 0800.
> Context  : @ 0.01ff.f000  001f.eec1 # 0
> Region   : @ 0.01fe.ec20  001f.b231
> Segment  : @ 0.01fb.2300  001f.b221
> Page     : @ 0.01fb.2200  0080.001e Access : rwx---
> Physical : 0.0800.
> ok 800 20 dump
>          \/  1  2  3  4  5  6  7   8  9  a  b  c  d  e  f  v123456789abcdef
>  800  00 d1 e1 44 ff d1 e2 18  08 d1 e1 4e ff d1 e2 18  .QaV.Qb..QaV.Qb.
>  810  00 d1 e1 44 ff d1 e2 18  08 d1 e1 4e ff d1 e2 18  .QaV.Qb..QaV.Qb.

RAM?

> ok
> ok 1000 map?
> Virtual  : 1000.
> Context  : @ 0.01ff.f000  001f.eec1 # 0
> Region   : @ 0.01fe.ec40  . Invalid
> ok 1000 obmem 1000 map-page
> ok 1000 20 dump
>          \/  1  2  3  4  5  6  7   8  9  a  b  c  d  e  f  v123456789abcdef
> 1000  04 00 00 05 00 1f e0 00  04 00 00 05 00 1f e0 00  ..`...`.
> 1010  04 00 00 05 04 00 00 05  04 00 00 05 04 00 00 05  

IOMMU registers here...

> ok 3000 map?
> Virtual  : 3000.
> Context  : @ 0.01ff.f000  001f.eec1 # 0
> Region   : @ 0.01fe.ecc0  . Invalid
> ok 3000 obmem 3000 map-page
> ok 3000 20 dump
>          \/  1  2  3  4  5  6  7   8  9  a  b  c  d  e  f  v123456789abcdef
> 3000  Data Access Error
> ok 2fff obmem 2fff map-page
> ok 2fff 20 dump
>          \/  1  2  3  4  5  6  7   8  9  a  b  c  d  e  f  v123456789abcdef
> 2fff  02 ff e1 44 ff d1 e2 18  2f d1 e1 4e ff d1 e2 18  .QaV.Qb..QaV.Qb.
> 2fff0010  00 d1 e1 44 ff d1 e2 18  2f d1 e1 4e ff d1 e2 18  .QaV.Qb..QaV.Qb.

RAM again?

> ok
> ok f000 map?
> Virtual  : f000.
> Context  : @ 0.01ff.f000  001f.eec1 # 0
> Region   : @ 0.01fe.efc0  . Invalid
> ok f000 obmem f000 map-page
> ok f000 20 dump
>          \/  1  2  3  4  5  6  7   8  9  a  b  c  d  e  f  v123456789abcdef
> f000  10 80 2f 66 a1 48 00 00  01 00 00 00 01 00 00 00  ../f!H..
> f010  29 1c 00 04 a8 15 20 d0  81 c5 00 00 a1 48 00 00  )...(. P.E..!H..

This could be boot ROM aliased all over 0xf000 to 0x.

> ok f7ff map?
> Virtual  : f7ff.
> Context  : @ 0.01ff.f000  001f.eec1 # 0
> Region   : @ 0.01fe.efdc  . Invalid
> ok f7ff obmem f7ff map-page
> ok f7ff 20 dump
>          \/  1  2  3  4  5  6  7   8  9  a  b  c  d  e  f  v123456789abcdef
> f7ff  Data Access Error
> ok f6ff map?
> Virtual  : f6ff.
> Context  : @ 0.01ff.f000  001f.eec1 # 0
> Region   : @ 0.01fe.efd8  0

Re: [Qemu-devel] [PATCH] [For stable-0.12] Sync OSS_GETVERSION handling with head

2010-01-19 Thread Anthony Liguori

On 01/17/2010 11:23 AM, Juergen Lock wrote:

As suggested by Andreas Färber, here is a cumulative patch that syncs
OSS_GETVERSION handling with head by merging the following commits:

1. oss: issue OSS_GETVERSION ioctl only when needed
6d246526ce3c145b2831285def6983f5de6190d3

2. oss: fix fragment setting
3d709fe73a77c40e263b3af6e650fd4b519c3562

3. Workaround for broken OSS_GETVERSION on FreeBSD, part two
72ff25e4e98d6dba9286d032b9ff5432553bbad5

Signed-off-by: Juergen Lock
   


malc, please Ack.

Regards,

Anthony Liguori


--- a/audio/ossaudio.c
+++ b/audio/ossaudio.c
@@ -38,6 +38,10 @@
  #define AUDIO_CAP "oss"
  #include "audio_int.h"

+#if defined OSS_GETVERSION&&  defined SNDCTL_DSP_POLICY
+#define USE_DSP_POLICY
+#endif
+
  typedef struct OSSVoiceOut {
  HWVoiceOut hw;
  void *pcm_buf;
@@ -236,14 +240,39 @@ static void oss_dump_info (struct oss_pa
  }
  #endif

+#ifdef USE_DSP_POLICY
+static int oss_get_version (int fd, int *version, const char *typ)
+{
+if (ioctl (fd, OSS_GETVERSION,&version)) {
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+/*
+ * Looks like atm (20100109) FreeBSD knows OSS_GETVERSION
+ * since 7.x, but currently only on the mixer device (or in
+ * the Linuxolator), and in the native version that part of
+ * the code is in fact never reached so the ioctl fails anyway.
+ * Until this is fixed, just check the errno and if its what
+ * FreeBSD's sound drivers return atm assume they are new enough.
+ */
+if (errno == EINVAL) {
+*version = 0x04;
+return 0;
+}
+#endif
+oss_logerr2 (errno, typ, "Failed to get OSS version\n");
+return -1;
+}
+return 0;
+}
+#endif
+
  static int oss_open (int in, struct oss_params *req,
   struct oss_params *obt, int *pfd)
  {
  int fd;
-int version;
  int oflags = conf.exclusive ? O_EXCL : 0;
  audio_buf_info abinfo;
  int fmt, freq, nchannels;
+int setfragment = 1;
  const char *dspname = in ? conf.devpath_in : conf.devpath_out;
  const char *typ = in ? "ADC" : "DAC";

@@ -281,27 +310,30 @@ static int oss_open (int in, struct oss_
  goto err;
  }

-if (ioctl (fd, OSS_GETVERSION,&version)) {
-oss_logerr2 (errno, typ, "Failed to get OSS version\n");
-version = 0;
-}
+#ifdef USE_DSP_POLICY
+if (conf.policy>= 0) {
+int version;

-if (conf.debug) {
-dolog ("OSS version = %#x\n", version);
-}
+if (!oss_get_version (fd,&version, typ)) {
+if (conf.debug) {
+dolog ("OSS version = %#x\n", version);
+}

-#ifdef SNDCTL_DSP_POLICY
-if (conf.policy>= 0&&  version>= 0x04) {
-int policy = conf.policy;
-if (ioctl (fd, SNDCTL_DSP_POLICY,&policy)) {
-oss_logerr2 (errno, typ, "Failed to set timing policy to %d\n",
- conf.policy);
-goto err;
+if (version>= 0x04) {
+int policy = conf.policy;
+if (ioctl (fd, SNDCTL_DSP_POLICY,&policy)) {
+oss_logerr2 (errno, typ,
+ "Failed to set timing policy to %d\n",
+ conf.policy);
+goto err;
+}
+setfragment = 0;
+}
  }
  }
-else
  #endif
-{
+
+if (setfragment) {
  int  = (req->nfrags<<  16) | ctz32 (req->fragsize);
  if (ioctl (fd, SNDCTL_DSP_SETFRAGMENT,&)) {
  oss_logerr2 (errno, typ, "Failed to set buffer length (%d, %d)\n",
@@ -857,7 +889,7 @@ static struct audio_option oss_options[]
  .valp  =&conf.exclusive,
  .descr = "Open device in exclusive mode (vmix wont work)"
  },
-#ifdef SNDCTL_DSP_POLICY
+#ifdef USE_DSP_POLICY
  {
  .name  = "POLICY",
  .tag   = AUD_OPT_INT,



   






Re: [Qemu-devel] [PATCH] Add definitions for current cpu models..

2010-01-19 Thread Anthony Liguori

On 01/18/2010 10:45 AM, john cooper wrote:

This is a rework of the prior version which adds definitions
for contemporary processors selected via -cpu, as an
alternative to the existing use of "-cpu qemu64" augmented
with a series of feature flags.

The primary motivation was determination of a least common
denominator within a given processor class to simplify guest
migration.  It is still possible to modify an arbitrary model
via additional feature flags however the goal here was to
make doing so unnecessary in typical usage.  The other
consideration was providing models names reflective of
current processors.  Both AMD and Intel have reviewed the
models in terms of balancing generality of migration vs.
excessive feature downgrade relative to released silicon.

Concerning the prior version of the patch, the proposed name
used for a given model drew a fair amount of debate, the
main concern being use of names as mnemonic as possible to
the wisest group of users.  Another suggestion was to use
the vendor name of released silicon corresponding to a least
common denominator CPU within the class, rational being doing
so is more definitive of the intended functionality.  However
something like:

  -cpu "Intel Core 2 Duo P9xxx"
   


Stick with Xeon naming, it's far less annoying.


probably isn't all that easy to remember nor type when
selecting a Penryn class cpu.  So I struck what I believe to
be a reasonable compromise where the original x86_def_t.name
was for the most part retained with the x86_def_t.model_id
capturing the marketing name of the cpu being used as the
least common denominator for the class.  To make it easier for
a user to associate a *.name with *.model_id, "-cpu ?" invoked
rather as "-cpu ??" will append *.model_id to the generated
table:

 :
 x86   Conroe  Intel Celeron_4x0 (Conroe/Merom Class Core 2)
 x86   Penryn  Intel Core 2 Duo P9xxx (Penryn Class Core 2)
 x86  Nehalem  Intel Core i7 9xx (Nehalem Class Core i7)
 x86   Opteron_G1  AMD Opteron 240 (Gen 1 Class Opteron)
 x86   Opteron_G2  AMD Opteron 22xx (Gen 2 Class Opteron)
 x86   Opteron_G3  AMD Opteron 23xx (Gen 3 Class Opteron)
 :
   


I'm very much against having -cpu Nehalem.  The whole point of this is 
to make things easier for a user and for most of the users I've 
encountered, -cpu Nehalem is just as obscure as -cpu qemu64,-sse3,+vmx,...


Regards,

Anthony Liguori




Re: [Qemu-devel] Re: [PATCH 01/14] Introduce qemu_write_full()

2010-01-19 Thread Anthony Liguori

On 01/19/2010 06:17 AM, Kirill A. Shutemov wrote:

On Tue, Jan 19, 2010 at 2:11 PM, Juan Quintela  wrote:
   

"Kirill A. Shutemov"  wrote:
 

A variant of write(2) which handles partial write.

Signed-off-by: Kirill A. Shutemov
   

Hi

Have you updated this series?  Is there any reason that you know when
they haven't been picked?
 

I don't  know any reason, but I'm going to review it once again.

I also have plan to get rid of -fno-strict-aliasing where it's possible.
   


I haven't reviewed the series in detail, but generally speaking I don't 
feel that good about these sort of series.


You're essentially adding dummy error handling to quiet the compiler.  
That's worse than just disabling -Werror because at least you aren't 
losing the information in the code.


If you're going to update error handling, it should be part of an effort 
to make code paths resilient to error.  IOW, actually audit the full 
error path of the function and make it deal with errors gracefully.


Regards,

Anthony Liguori



   






Re: [Qemu-devel] [PATCH] Add definitions for current cpu models..

2010-01-19 Thread Chris Wright
* Anthony Liguori (anth...@codemonkey.ws) wrote:
> I'm very much against having -cpu Nehalem.  The whole point of this is  
> to make things easier for a user and for most of the users I've  
> encountered, -cpu Nehalem is just as obscure as -cpu 
> qemu64,-sse3,+vmx,...

What name will these users know?  FWIW, it makes sense to me as it is.

thanks,
-chris




Re: [Qemu-devel] [PATCH 4/5] PCI: do_pci_info(): PCI bridge support

2010-01-19 Thread Luiz Capitulino
On Mon, 18 Jan 2010 18:14:32 +0100
Markus Armbruster  wrote:

> Luiz Capitulino  writes:
> 
> > This commit adds the "pci_bridge" key to the PCI device QDict,
> > it also adds support for printing it in the user protocol.
> >
> > IMPORTANT: This code is being added separately because I could
> > NOT test it properly. According to Michael Tsirkin, it depends
> > on ultrasparc and it would take time to do the proper setup.
> >
> > Signed-off-by: Luiz Capitulino 
> > ---
> >  hw/pci.c |   76 
> > +++--
> >  1 files changed, 73 insertions(+), 3 deletions(-)
> >
> > diff --git a/hw/pci.c b/hw/pci.c
> > index 8275ceb..d5e4866 100644
> > --- a/hw/pci.c
> > +++ b/hw/pci.c
> > @@ -1102,6 +1102,7 @@ void pci_for_each_device(PCIBus *bus, int bus_num,
> >  
> >  static void pci_device_print(Monitor *mon, QDict *device)
> >  {
> > +int class;
> >  QDict *qdict;
> >  QListEntry *entry;
> >  uint64_t addr, size;
> > @@ -1113,10 +1114,11 @@ static void pci_device_print(Monitor *mon, QDict 
> > *device)
> >  monitor_printf(mon, "");
> >  
> >  qdict = qdict_get_qdict(device, "class_info");
> > +class = qdict_get_int(qdict, "class");
> >  if (qdict_haskey(qdict, "desc")) {
> >  monitor_printf(mon, "%s", qdict_get_str(qdict, "desc"));
> >  } else {
> > -monitor_printf(mon, "Class %04" PRId64, qdict_get_int(qdict, 
> > "class"));
> > +monitor_printf(mon, "Class %d", class);
> >  }
> >  
> >  qdict = qdict_get_qdict(device, "id");
> 
> This change seems unrelated.  Is it intentional?

 I guess it's not, I'll revert and re-submit.




Re: [Qemu-devel] [PATCH] Porting TCG to alpha platform

2010-01-19 Thread Richard Henderson

On 01/19/2010 12:47 AM, identifier scorpio wrote:

I ported TCG to alpha platform, the patch is currently based on stable-0.10 
branch,
and now it can run linux-0.2.img testing image on my alpha XP1000 workstation.
but it still can't run MS-windows, and I hope someone, especially those guys 
that
are working on target-alpha, may help me to find the bugs.


Your patch is mangled.  If you can't use sendmail directly, then attach 
the patch.



+/*
+ * $26 ~ $31 are special, reserved,
+ * and $25 is deliberately reserved for jcc operation
+ * and $0 is usually used for return function result, better allocate it later
+ * and $15 is used for cpu_env pointer, allocate it at last
+*/


I don't see any reason why $28 should be reserved, particularly. 
Although I'd use it as a temporary before anything else.  I expect that 
you could get away with not reserving $26 and $27 as well, and simply 
know that it's free since only $16-$21 have values at the point of a 
call and all others have no live values.



+static const int tcg_target_reg_alloc_order[] = {
+TCG_REG_1, TCG_REG_2, TCG_REG_3, TCG_REG_4, TCG_REG_5, TCG_REG_6,
+TCG_REG_7, TCG_REG_8, TCG_REG_22,
+TCG_REG_9, TCG_REG_10, TCG_REG_11, TCG_REG_12, TCG_REG_13, TCG_REG_14,
+TCG_REG_16, TCG_REG_17, TCG_REG_18, TCG_REG_19, TCG_REG_20, TCG_REG_21
+};


Existing targets put call-saved registers at the front of the allocation 
order.  From looking at tcg.c, I think the only way values actually get 
saved across calls is to already happen to be allocated to a call-saved 
register.



+#define OP_ADDSUBCMP   0x10
+#define FUNC_ADDL  0x00
+#define FUNC_SUBL  0x09
+#define FUNC_ADDQ  0x20


Things might be a bit cleaner if you pre-assembled these values and 
passed only one value to the tcg_out_* routines.  E.g.


#define INSN_ADDQ ((0x10 << 26) | (0x20 << 5))

Compare the sparc port, for example.


+static int target_parse_constraint(TCGArgConstraint *ct, const char **pct_str)
+{
+const char *ct_str = *pct_str;
+
+switch(ct_str[0])
+{
+case 'r':

...

+case 'L':


Do you really need extra temporaries for L?  You already have 3.

You'd also do well to define I,J,K constraints for constants (mirroring 
gcc's letters for clarity).



+static inline void tcg_out_inst2(TCGContext *s, int Opcode, int Ra, int Disp)
+static inline void tcg_out_inst3_disp(TCGContext *s, int Opcode, int Ra, int 
Rb, int Disp)
+static inline void tcg_out_inst3_func(TCGContext *s, int Opcode, int Ra, int 
Rb, int Func, int Disp)
+static inline void tcg_out_inst4(TCGContext *s, int Opcode, int Ra, int Rb, 
int Func, int Rc)
+static inline void tcg_out_inst4i(TCGContext *s, int Opcode, int Ra, int Lit, 
int Func, int Rc)


inst2, inst3, inst4 isn't very descriptive.  How about nice names like

  tcg_out_fmt_mem  // memory format w/ displacement
  tcg_out_fmt_opr  // operate format w/ register
  tcg_out_fmt_opi  // operate format w/ immediate
  tcg_out_fmt_jmp  // jump instruction format


+/*
+ * mov a 64-bit immediate 'arg' to regsiter 'Ra', this function will
+ * generate fixed length (8 insns, 32 bytes) of target insn sequence.
+*/
+static void tcg_out_movi_fixl( \
+TCGContext *s, TCGType type, int Ra, tcg_target_long arg)


Err.. "8 insns"?  You'd only ever need to output 5.  Also, why would you 
ever want to explicitly never elide one of these insns if you could? 
Say, if only L0 and L3 were non-zero?



+/*
+ * mov 64-bit immediate 'arg' to regsiter 'Ra'. this function will
+ * generate variable length of target insn sequence.
+*/
+static inline void tcg_out_movi( \
+TCGContext *s, TCGType type, int Ra, tcg_target_long arg)
+{
+if (type == TCG_TYPE_I32) {
+if ( arg != (int32_t)arg)
+tcg_abort();


Well that's most likely a bug.  If I32 then I'd consider the high bits 
garbage.  I don't recall any promise that TCG sign-extends 32-bit inputs.



+if (arg == 0) {
+tcg_out_inst4(s, OP_LOGIC, Ra, Ra, FUNC_XOR, Ra);


Err, don't xor and create a false dependency on the previous contents. 
Either do a move from the zero register, or better don't special case 
this at all and generate the zero from ...



+else if( arg == (int16_t)arg ) {
+tcg_out_inst3_disp(s, OP_LDA, Ra, TCG_REG_31, arg );
+}


... here.  Watch your formatting as well.


+else if( arg == (int32_t)arg ) {
+tcg_out_inst3_disp(s, OP_LDAH, Ra, TCG_REG_31, (arg>>16));
+if( arg&  ((tcg_target_ulong)0x8000) ) {
+tcg_out_inst3_disp(s, OP_LDAH, Ra, Ra, 1);
+}


You are emitting an unnecessary instruction most of the time here.  You 
should increment the LDAH constant except for the case that it overflows.


However, I'd say that the best way to rearrange all of this is:

void tcg_out_op_long(TCGContext *s, int opc,
 int Ra, int Rb, tcg_target_long val)
{
int l0, l1a, l1b = 0, l2 = 0, l3 = 0;
long val = orig;
int Rs;

switch (opc) {
case INSN_STB:
 

Re: [Qemu-devel] [PATCH 3/5] PCI: Convert pci_info() to QObject

2010-01-19 Thread Luiz Capitulino
On Mon, 18 Jan 2010 18:16:21 +0100
Markus Armbruster  wrote:

> > +static QObject *pci_get_dev_class(const PCIDevice *dev)
> > +{
> > +int class;
> > +const char *str = "";
> > +const pci_class_desc *desc;
> > +
> > +class = pci_get_word(dev->config + PCI_CLASS_DEVICE);
> >  desc = pci_class_descriptions;
> >  while (desc->desc && class != desc->class)
> >  desc++;
> > +
> >  if (desc->desc) {
> [...]
> > +str = desc->desc;
> > +}
> > +
> > +return qobject_from_jsonf("{ 'desc': %s, 'class': %d }", str, class);
> > +}
> 
> This yields 'desc': '' for unknown class.  I find that a bit unnatural.

 Right, good catch.

> If we don't have a desc, put none into the dictionary.

 The right thing would be to have null there, but the standard
so far is just to drop the key (which is what I'm going to do here).

> > +static QObject *pci_get_dev_id(const PCIDevice *dev)
> > +{
> > +return qobject_from_jsonf("{ 'device': %d, 'vendor': %d }",
> > +  pci_get_word(dev->config + PCI_VENDOR_ID),
> > +  pci_get_word(dev->config + PCI_DEVICE_ID));
> > +}
> > +
> > +static QObject *pci_get_regions_list(const PCIDevice *dev)
> > +{
> > +int i;
> > +QList *regions_list;
> > +
> > +regions_list = qlist_new();
> > +
> > +for (i = 0; i < PCI_NUM_REGIONS; i++) {
> > +const PCIIORegion *r = &dev->io_regions[i];
> >  if (r->size != 0) {
> 
> You're struggling with long lines in this function.  "if (!r->size)
> continue" avoids nesting.  Matter of taste, of course.

 I agree.

> > -monitor_printf(mon, "  BAR%d: ", i);
> > +QObject *obj;
> >  if (r->type & PCI_BASE_ADDRESS_SPACE_IO) {
> > -monitor_printf(mon, "I/O at 0x%04"FMT_PCIBUS
> > -   " [0x%04"FMT_PCIBUS"].\n",
> > -   r->addr, r->addr + r->size - 1);
> > +obj = qobject_from_jsonf("{ 'bar': %d, 'type': 'io', "
> > + "'address': %" PRId64 ", "
> > + "'size': %" PRId64 " }",
> > + i, r->addr, r->size);
> >  } else {
> > -const char *type = r->type & PCI_BASE_ADDRESS_MEM_TYPE_64 ?
> > -"64 bit" : "32 bit";
> > -const char *prefetch =
> > -r->type & PCI_BASE_ADDRESS_MEM_PREFETCH ?
> > -" prefetchable" : "";
> > -
> > -monitor_printf(mon, "%s%s memory at 0x%08"FMT_PCIBUS
> > -   " [0x%08"FMT_PCIBUS"].\n",
> > -   type, prefetch,
> > -   r->addr, r->addr + r->size - 1);
> > +int mem_type_64 = r->type & PCI_BASE_ADDRESS_MEM_TYPE_64;
> > +
> > +obj = qobject_from_jsonf("{ 'bar': %d, 'type': 'memory', "
> > + "'mem_type_64': %i, 'prefetch': 
> > %i, "
> > + "'address': %" PRId64 ", "
> > + "'size': %" PRId64 " }",
> > + i, mem_type_64,
> > + r->type 
> > &PCI_BASE_ADDRESS_MEM_PREFETCH,
> > + r->addr, r->size);
> >  }
> > +qlist_append_obj(regions_list, obj);
> >  }
> >  }
> > -monitor_printf(mon, "  id \"%s\"\n", d->qdev.id ? d->qdev.id : "");
> > -if (class == 0x0604 && d->config[0x19] != 0) {
> > -pci_for_each_device(bus, d->config[0x19], pci_info_device);
> > +
> > +return QOBJECT(regions_list);
> > +}
> > +
> > +static QObject *pci_get_dev_dict(const PCIDevice *dev, int bus_num)
> > +{
> > +QObject *obj;
> > +
> > +obj = qobject_from_jsonf("{ 'bus': %d, 'slot': %d, 'function': %d,"
> >"'class_info': %p, 'id': %p, 'regions': 
> > %p,"
> > +  " 'qdev_id': %s }",
> > +  bus_num,
> > +  PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn),
> > +  pci_get_dev_class(dev), pci_get_dev_id(dev),
> > +  pci_get_regions_list(dev),
> > +  dev->qdev.id ? dev->qdev.id : "");
> 
> Why repeat the bus number?  See below.
> 
> > +
> > +if (dev->config[PCI_INTERRUPT_PIN] != 0) {
> > +QDict *qdict = qobject_to_qdict(obj);
> > +qdict_put(qdict, "irq", 
> > qint_from_int(dev->config[PCI_INTERRUPT_LINE]));
> >  }
> > +
> > +return obj;
> >  }
> >  
> > -static void pci_for_each_device_under_bus(PCIBus *bus,
> > -  void (*fn)(PCIBus *b, PCIDevice 
> > *d))
> > +static QObject *pci_get_devices_list(PCIBus *bus, int bus_num)
> >  {

[Qemu-devel] PATCH 3/2] block: kill BDRV_O_CREAT

2010-01-19 Thread Christoph Hellwig
The BDRV_O_CREAT option is unused inside qemu and partially duplicates
the bdrv_create method.  Remove it, and the -C option to qemu-io which
isn't used in qemu-iotests anyway.


Signed-off-by: Christoph Hellwig 

Index: qemu/block.c
===
--- qemu.orig/block.c   2010-01-19 21:45:08.901004272 +0100
+++ qemu/block.c2010-01-19 21:45:44.105254367 +0100
@@ -469,13 +469,6 @@ int bdrv_open2(BlockDriverState *bs, con
 open_flags |= BDRV_O_RDWR;
 }
 
-/*
- * Currently BDRV_O_CREAT is not supported by any image format,
- * but I'm not sure that's reason enough to always clear it for
- * the !BDRV_O_FILE case..
- */
-open_flags &= ~(BDRV_O_CREAT);
-
 ret = drv->bdrv_open(bs, filename, open_flags);
 if (ret == -EACCES || ret == -EPERM) {
 ret = drv->bdrv_open(bs, filename, open_flags & ~BDRV_O_RDWR);
Index: qemu/block.h
===
--- qemu.orig/block.h   2010-01-19 21:47:10.720003392 +0100
+++ qemu/block.h2010-01-19 21:47:29.261004392 +0100
@@ -30,7 +30,7 @@ typedef struct QEMUSnapshotInfo {
 #define BDRV_O_RDONLY  0x
 #define BDRV_O_RDWR0x0002
 #define BDRV_O_ACCESS  0x0003
-#define BDRV_O_CREAT   0x0004 /* create an empty file */
+/* 0x0004 was BDRV_O_CREAT */
 #define BDRV_O_SNAPSHOT0x0008 /* open the file read only and save writes 
in a snapshot */
 #define BDRV_O_FILE0x0010 /* open as a raw file (do not try to
  use a disk image format on top of
Index: qemu/block/nbd.c
===
--- qemu.orig/block/nbd.c   2010-01-19 21:45:52.925004048 +0100
+++ qemu/block/nbd.c2010-01-19 21:45:59.117254240 +0100
@@ -49,9 +49,6 @@ static int nbd_open(BlockDriverState *bs
 size_t blocksize;
 int ret;
 
-if ((flags & BDRV_O_CREAT))
-return -EINVAL;
-
 if (!strstart(filename, "nbd:", &host))
 return -EINVAL;
 
Index: qemu/block/raw-posix.c
===
--- qemu.orig/block/raw-posix.c 2010-01-19 21:46:40.265260294 +0100
+++ qemu/block/raw-posix.c  2010-01-19 21:47:06.080254365 +0100
@@ -205,13 +205,9 @@ out_close:
 static int raw_open(BlockDriverState *bs, const char *filename, int flags)
 {
 BDRVRawState *s = bs->opaque;
-int open_flags = 0;
 
 s->type = FTYPE_FILE;
-if (flags & BDRV_O_CREAT)
-open_flags = O_CREAT | O_TRUNC;
-
-return raw_open_common(bs, filename, flags, open_flags);
+return raw_open_common(bs, filename, flags, 0);
 }
 
 /* XXX: use host sector size if necessary with:
Index: qemu/block/raw-win32.c
===
--- qemu.orig/block/raw-win32.c 2010-01-19 21:46:05.928253941 +0100
+++ qemu/block/raw-win32.c  2010-01-19 21:46:36.202254338 +0100
@@ -76,7 +76,7 @@ static int set_sparse(int fd)
 static int raw_open(BlockDriverState *bs, const char *filename, int flags)
 {
 BDRVRawState *s = bs->opaque;
-int access_flags, create_flags;
+int access_flags;
 DWORD overlapped;
 
 s->type = FTYPE_FILE;
@@ -86,11 +86,7 @@ static int raw_open(BlockDriverState *bs
 } else {
 access_flags = GENERIC_READ;
 }
-if (flags & BDRV_O_CREAT) {
-create_flags = CREATE_ALWAYS;
-} else {
-create_flags = OPEN_EXISTING;
-}
+
 overlapped = FILE_ATTRIBUTE_NORMAL;
 if ((flags & BDRV_O_NOCACHE))
 overlapped |= FILE_FLAG_NO_BUFFERING | FILE_FLAG_WRITE_THROUGH;
@@ -98,7 +94,7 @@ static int raw_open(BlockDriverState *bs
 overlapped |= FILE_FLAG_WRITE_THROUGH;
 s->hfile = CreateFile(filename, access_flags,
   FILE_SHARE_READ, NULL,
-  create_flags, overlapped, NULL);
+  OPEN_EXISTING, overlapped, NULL);
 if (s->hfile == INVALID_HANDLE_VALUE) {
 int err = GetLastError();
 
Index: qemu/qemu-io.c
===
--- qemu.orig/qemu-io.c 2010-01-19 21:47:37.065011538 +0100
+++ qemu/qemu-io.c  2010-01-19 21:48:59.664317026 +0100
@@ -1307,7 +1307,6 @@ open_help(void)
 " 'open -Cn /tmp/data' - creates/opens data file read-write and uncached\n"
 "\n"
 " Opens a file for subsequent use by all of the other qemu-io commands.\n"
-" -C, -- create new file if it doesn't exist\n"
 " -r, -- open file read-only\n"
 " -s, -- use snapshot file\n"
 " -n, -- disable host cache\n"
@@ -1337,7 +1336,7 @@ open_f(int argc, char **argv)
int growable = 0;
int c;
 
-   while ((c = getopt(argc, argv, "snCrg")) != EOF) {
+   while ((c = getopt(argc, argv, "snrg")) != EOF) {
switch (c) {
case 's':
flags |= BDRV_O_SNAPSHOT;
@@ -1345,9 +1344,

[Qemu-devel] Re: KVM developer call minutes (Jan 19)

2010-01-19 Thread Dustin Kirkland
On Wed, Jan 20, 2010 at 6:31 AM, Chris Wright  wrote:
> how is stable branch working (both qemu and kvm)?
> - qemu 0.12 cherry picking pretty aggressively
>  - could use more community involvement
>  - any distro patches for qemu/kvm packages?
>    - doesn't sound like it

I'm currently testing a merge of qemu-kvm-0.12.1.2 for Ubuntu.

We're carrying the 3 patches attached here.  All of these have been
submitted upstream.  One of them is critical to fix our static arm
build.  The other two are relatively minor fixes requested by our
users.

Cheers,
:-Dustin
From a3582e37351596119e947b0606021aedb19b6f61 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Lo=C3=AFc=20Minier?= 
Date: Sun, 17 Jan 2010 12:09:38 +0100
Subject: [PATCH] Fix missing symbols in .rel/.rela.plt sections
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Fix .rel.plt sections in the output to not only include .rel.plt
sections from the input but also the .rel.iplt sections and to define
the hidden symbols __rel_iplt_start and __rel_iplt_end around
.rel.iplt as otherwise we get undefined references to these when
linking statically to a multilib libc.a.  This fixes the static build
under i386.

Apply similar logic to rela.plt/.iplt and __rela_iplt/_plt_start/_end to
fix the static build under amd64.

Signed-off-by: Loďc Minier 
---
 i386.ld   |   16 ++--
 x86_64.ld |   16 ++--
 2 files changed, 28 insertions(+), 4 deletions(-)

diff --git a/i386.ld b/i386.ld
index f2dafec..f8df7bf 100644
--- a/i386.ld
+++ b/i386.ld
@@ -39,8 +39,20 @@ SECTIONS
   .rela.fini : { *(.rela.fini)	}
   .rel.bss   : { *(.rel.bss)		}
   .rela.bss  : { *(.rela.bss)		}
-  .rel.plt   : { *(.rel.plt)		}
-  .rela.plt  : { *(.rela.plt)		}
+  .rel.plt  :
+  {
+*(.rel.plt)
+PROVIDE_HIDDEN (__rel_iplt_start = .);
+*(.rel.iplt)
+PROVIDE_HIDDEN (__rel_iplt_end = .);
+  }
+  .rela.plt   :
+  {
+*(.rela.plt)
+PROVIDE_HIDDEN (__rela_iplt_start = .);
+*(.rela.iplt)
+PROVIDE_HIDDEN (__rela_iplt_end = .);
+  }
   .init  : { *(.init)	} =0x47ff041f
   .text  :
   {
diff --git a/x86_64.ld b/x86_64.ld
index 24ea77d..46d8d4d 100644
--- a/x86_64.ld
+++ b/x86_64.ld
@@ -35,8 +35,20 @@ SECTIONS
   .rela.got   : { *(.rela.got) }
   .rel.bss: { *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*) }
   .rela.bss   : { *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*) }
-  .rel.plt: { *(.rel.plt) }
-  .rela.plt   : { *(.rela.plt) }
+  .rel.plt  :
+  {
+*(.rel.plt)
+PROVIDE_HIDDEN (__rel_iplt_start = .);
+*(.rel.iplt)
+PROVIDE_HIDDEN (__rel_iplt_end = .);
+  }
+  .rela.plt   :
+  {
+*(.rela.plt)
+PROVIDE_HIDDEN (__rela_iplt_start = .);
+*(.rela.iplt)
+PROVIDE_HIDDEN (__rela_iplt_end = .);
+  }
   .init   :
   {
 KEEP (*(.init))
-- 
1.6.5

http://lists.gnu.org/archive/html/qemu-devel/2010-01/msg01114.html

From: Loic Minier
Date: Tue, 29 Dec 2009 22:06:13 +0100
Subject: [PATCH] linux-user: adapt uname machine to emulated CPU

---
 Makefile.target|2 +-
 linux-user/cpu-uname.c |   72 
 linux-user/cpu-uname.h |1 +
 linux-user/syscall.c   |3 +-
 4 files changed, 76 insertions(+), 2 deletions(-)
 create mode 100644 linux-user/cpu-uname.c
 create mode 100644 linux-user/cpu-uname.h

diff --git a/Makefile.target b/Makefile.target
index e661478..9f5bd17 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -95,7 +95,7 @@ $(call set-vpath, $(SRC_PATH)/linux-user:$(SRC_PATH)/linux-user/$(TARGET_ABI_DIR
 
 QEMU_CFLAGS+=-I$(SRC_PATH)/linux-user -I$(SRC_PATH)/linux-user/$(TARGET_ABI_DIR)
 obj-y = main.o syscall.o strace.o mmap.o signal.o thunk.o \
-  elfload.o linuxload.o uaccess.o gdbstub.o
+  elfload.o linuxload.o uaccess.o gdbstub.o cpu-uname.o
 
 obj-$(TARGET_HAS_BFLT) += flatload.o
 obj-$(TARGET_HAS_ELFLOAD32) += elfload32.o
diff --git a/linux-user/cpu-uname.c b/linux-user/cpu-uname.c
new file mode 100644
index 000..ddc37be
--- /dev/null
+++ b/linux-user/cpu-uname.c
@@ -0,0 +1,72 @@
+/*
+ *  cpu to uname machine name map
+ *
+ *  Copyright (c) 2009 Loďc Minier
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, see .
+ */
+
+#include 
+
+#include "qemu.h"
+//#include "qemu-common.h"
+#include "cpu-uname.h"
+
+/* return highest utsna

[Qemu-devel] [PATCH] block: prevent multiwrite_merge from creating too large iovecs

2010-01-19 Thread Christoph Hellwig
If we go over the maximum number of iovecs support by syscall we get
back EINVAL from the kernel which translate to I/O errors for the guest.

Signed-off-by: Christoph Hellwig 

Index: qemu/block.c
===
--- qemu.orig/block.c   2010-01-19 22:10:19.797003226 +0100
+++ qemu/block.c2010-01-19 22:11:08.226005767 +0100
@@ -1711,6 +1711,10 @@ static int multiwrite_merge(BlockDriverS
 merge = bs->drv->bdrv_merge_requests(bs, &reqs[outidx], &reqs[i]);
 }
 
+if (reqs[outidx].qiov->niov + reqs[i].qiov->niov + 1 > IOV_MAX) {
+merge = 0;
+}
+
 if (merge) {
 size_t size;
 QEMUIOVector *qiov = qemu_mallocz(sizeof(*qiov));




Re: [Qemu-devel] [PATCH] [For stable-0.12] Sync OSS_GETVERSION handling with head

2010-01-19 Thread malc
On Tue, 19 Jan 2010, Anthony Liguori wrote:

> On 01/17/2010 11:23 AM, Juergen Lock wrote:
> > As suggested by Andreas F?rber, here is a cumulative patch that syncs
> > OSS_GETVERSION handling with head by merging the following commits:
> > 
> > 1. oss: issue OSS_GETVERSION ioctl only when needed
> > 6d246526ce3c145b2831285def6983f5de6190d3
> > 
> > 2. oss: fix fragment setting
> > 3d709fe73a77c40e263b3af6e650fd4b519c3562
> > 
> > 3. Workaround for broken OSS_GETVERSION on FreeBSD, part two
> > 72ff25e4e98d6dba9286d032b9ff5432553bbad5
> > 
> > Signed-off-by: Juergen Lock
> >
> 
> malc, please Ack.

quack

[..snip..]

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




Re: [Qemu-devel] [PATCH] Porting TCG to alpha platform

2010-01-19 Thread malc
On Tue, 19 Jan 2010, Richard Henderson wrote:

> On 01/19/2010 12:47 AM, identifier scorpio wrote:
> > I ported TCG to alpha platform, the patch is currently based on stable-0.10
> > branch,
> > and now it can run linux-0.2.img testing image on my alpha XP1000
> > workstation.
> > but it still can't run MS-windows, and I hope someone, especially those guys
> > that
> > are working on target-alpha, may help me to find the bugs.
> 
> Your patch is mangled.  If you can't use sendmail directly, then attach the
> patch.

[..snip..]

> > +/*
> > + * mov 64-bit immediate 'arg' to regsiter 'Ra'. this function will
> > + * generate variable length of target insn sequence.
> > +*/
> > +static inline void tcg_out_movi( \
> > +TCGContext *s, TCGType type, int Ra, tcg_target_long arg)
> > +{
> > +if (type == TCG_TYPE_I32) {
> > +if ( arg != (int32_t)arg)
> > +tcg_abort();
> 
> Well that's most likely a bug.  If I32 then I'd consider the high bits
> garbage.  I don't recall any promise that TCG sign-extends 32-bit inputs.

They are garbage, see f.e. 591d6f1dfdb60ab0a4cc487cd5781fa799dcac4b

[..snip..]

> 
> 
> r~
> 

Thanks for reviewing it!

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




Re: [Qemu-devel] [PATCH] Porting TCG to alpha platform

2010-01-19 Thread Stefan Weil
identifier scorpio schrieb:
> Hello.
>
> I ported TCG to alpha platform, the patch is currently based on stable-0.10 
> branch, and now it can run linux-0.2.img testing image on my alpha XP1000 
> workstation. but it still can't run MS-windows, and I hope someone, 
> especially those guys that are working on target-alpha, may help me to find 
> the bugs.
>
> From 0ee33ea1e43298e6045e16dfcf07cb7a530dfd56 Mon Sep 17 00:00:00 2001
> From: Dong Weiyu 
> Date: Tue, 19 Jan 2010 16:22:54 +0800
> Subject: [PATCH] porting TCG to alpha platform.
>
> ---
>  cpu-all.h  |2 +-
>  tcg/alpha/tcg-target.c | 1335 
> 
>  tcg/alpha/tcg-target.h |   70 +++
>  3 files changed, 1406 insertions(+), 1 deletions(-)
>  create mode 100644 tcg/alpha/tcg-target.c
>  create mode 100644 tcg/alpha/tcg-target.h
>   

Maybe you can also try the TCG interpreter (TCI) from
http://repo.or.cz/w/qemu/ar7.git.
In theory, it supports any host architecture with or without native TCG
support.

It was tested successful with some basic tests on x86, mips, ppc and arm,
so I hope it will run on alpha, too.

Kind regards,
Stefan Weil





[Qemu-devel] Re: sparc32 do_unassigned_access overhaul

2010-01-19 Thread Artyom Tarasenko
2010/1/19 Blue Swirl :
> On Tue, Jan 19, 2010 at 5:30 PM, Artyom Tarasenko
>  wrote:
>> 2010/1/15 Artyom Tarasenko :
>>> 2010/1/15 Blue Swirl :
 On Fri, Jan 15, 2010 at 9:11 PM, Artyom Tarasenko
  wrote:
> 2010/1/15 Blue Swirl :
>> On Fri, Jan 15, 2010 at 6:46 PM, Artyom Tarasenko
>>  wrote:
>>> According to pages 9-31 - 9-34 of "SuperSPARC & MultiCache Controller
>>> User's Manual":
>>>
>>> 1. "A lower priority fault may not overwrite the
>>>    MFSR status of a higher priority fault."
>>> 2. The MFAR is overwritten according to the policy defined for the MFSR
>>> 3. The overwrite bit is asserted if the fault status register (MFSR)
>>>   has been written more than once by faults of the same class
>>> 4. SuperSPARC will never place instruction fault addresses in the MFAR.
>>>
>>> Implementation of points 1-3 allows booting Solaris 2.6 and 2.5.1.
>>
>> Nice work! This also passes my tests.
>
> I'm afraid we still are not there yet though: Solaris 7 fails potentially 
> due to
> another bug in the MMU emulation, and the initial [missing-] RAM
> detection in OBP fails
> very probably due to a bug in in the MMU emulation.

 Some guesses:
  - Access to unassigned RAM area may be handled by the memory
 controller differently (no faults, different faults etc.) than
 unassigned access to SBus or other area.
>>
>> You are right! It seems to be true for the area larger than max RAM though.
>> On a real SS-5 with 32M in the first bank, no fault is produced at
>> least for the areas
>> 0-0x2fff, 0x7000-0xafff (ha, this would solve problems
>> with SS-20 OBP
>> too) and 0xf000-0xf6ff.
>
> The fault may still be recorded somewhere else (MXCC, RAM/ECC
> controller or IOMMU).

sfar and sfsr were empty, so it's definitely not MXCC. Don't know
where to look for the other two.

But how the fault would be generated? Don't know about Sun simms, but
PC ones don't have any handshake. IMHO the ECC can be the only
possibility.

> OBP may have disabled the fault, or it has not
> enabled fault generation.

NF bit is not set. Also, you can see the other faults.

> On SS-5, the physical address space should be only 31 bits, so you
> should see RAM aliased at 0x8000.

No. The RAM can be aliased only within one bank or completely outside
the RAM area. Otherwise different banks would have interfered.

>> Would you like to implement it?
>
> For RAM, there could be a new device which implements generic address
> space wrapping (base, length, AND mask, OR mask), it should be useful
> for embedded boards. Shouldn't be too difficult, want to try? :-)

Minutes for you, days for me. :)

> Dummy MMIO could be registered for the other areas in sun4m.c. I'm not
> sure this is the correct approach, if the fault is still handled
> somewhere else.
>
>> That's how I tested it:
>>
>> ok 800 map?
>> Virtual  : 0800.
>> Context  : @ 0.01ff.f000  001f.eec1 # 0
>> Region   : @ 0.01fe.ec20  . Invalid
>> ok 800 obmem 800 map-page
>> ok 800 map?
>> Virtual  : 0800.
>> Context  : @ 0.01ff.f000  001f.eec1 # 0
>> Region   : @ 0.01fe.ec20  001f.b231
>> Segment  : @ 0.01fb.2300  001f.b221
>> Page     : @ 0.01fb.2200  0080.001e Access : rwx---
>> Physical : 0.0800.
>> ok 800 20 dump
>>          \/  1  2  3  4  5  6  7   8  9  a  b  c  d  e  f  v123456789abcdef
>>  800  00 d1 e1 44 ff d1 e2 18  08 d1 e1 4e ff d1 e2 18  .QaV.Qb..QaV.Qb.
>>  810  00 d1 e1 44 ff d1 e2 18  08 d1 e1 4e ff d1 e2 18  .QaV.Qb..QaV.Qb.
>
> RAM?

Looks like a white noise to me. The first byte is frequently
different. Also the mapped RAM is filled with 0's. The pattern can not
be found anywhere in the mapped RAM (0x1000-0x9f):

ok create pattern  hex  00 c, d1 c, e1 c, 44 c, ff c, d1 c, e2 c, 18 c,
ok pattern 8 1000 9e sindex .

ok

Hold on... I tested only the reading. Should have tested writing too:

ok aa55aa55 800 l!
ok sfar@ . sfsr@ .
0 0

no fault, no interrupt, but

ok 800 10 dump
  \/  1  2  3  4  5  6  7   8  9  a  b  c  d  e  f  v123456789abcdef
 800  00 d1 e1 44 ff d1 e2 18  08 d1 e1 4e ff d1 e2 18  .QaV.Qb..QaV.Qb.
ok

no change either. And if I read it differently I get other contents:
ok 800 l@ .
f811bdd

So it's either a noise or a random cache contents.

>> ok
>> ok 1000 map?
>> Virtual  : 1000.
>> Context  : @ 0.01ff.f000  001f.eec1 # 0
>> Region   : @ 0.01fe.ec40  . Invalid
>> ok 1000 obmem 1000 map-page
>> ok 1000 20 dump
>>          \/  1  2  3  4  5  6  7   8  9  a  b  c  d  e  f  v123456789abcdef
>> 1000  04 00 00 05 00 1f e0 00  04 00 00 05 00 1f e0 00  ..`...`.
>> 1010  04 00 00 05 04 00 00 05  04 00 00 05 04 00 00 05  
>
> IOMMU registers here...
>
>> ok 3000 map?
>> Virtual  : 3000.
>> Context  : @ 0.01ff.f000  001f.eec1 # 0
>> Region   : @ 0.01fe.ecc0  . Invalid
>> ok 

Re: [Qemu-devel] [PATCH] Add definitions for current cpu models..

2010-01-19 Thread Jamie Lokier
Anthony Liguori wrote:
> On 01/18/2010 10:45 AM, john cooper wrote:
> > x86   Conroe  Intel Celeron_4x0 (Conroe/Merom Class Core 2)
> > x86   Penryn  Intel Core 2 Duo P9xxx (Penryn Class Core 2)
> > x86  Nehalem  Intel Core i7 9xx (Nehalem Class Core i7)
> > x86   Opteron_G1  AMD Opteron 240 (Gen 1 Class Opteron)
> > x86   Opteron_G2  AMD Opteron 22xx (Gen 2 Class Opteron)
> > x86   Opteron_G3  AMD Opteron 23xx (Gen 3 Class Opteron)
> 
> I'm very much against having -cpu Nehalem.  The whole point of this is 
> to make things easier for a user and for most of the users I've 
> encountered, -cpu Nehalem is just as obscure as -cpu qemu64,-sse3,+vmx,...

When I saw that table just now, I had no idea whether Nehalem is newer
and more advanced than Penryn, or the other way around.  I also have
no idea if "Core i7" is newer than "Core 2 Duo" or not.

I'm not a typical user: I know quite a lot about x86 architecture;
I just haven't kept up to date enough to know the code/model names.
Typical users will know less about them.

It's only from seeing the G1/G2/G3 order that I guess they are listed
in ascending order of functionality.

Naturally, if I were choosing one, I'd want to choose the one with the
most capabilities that works on whatever my host hardware provides.

-- Jamie




Re: [Qemu-devel] [PATCH] Add definitions for current cpu models..

2010-01-19 Thread Jamie Lokier
Chris Wright wrote:
> * Anthony Liguori (anth...@codemonkey.ws) wrote:
> > I'm very much against having -cpu Nehalem.  The whole point of this is  
> > to make things easier for a user and for most of the users I've  
> > encountered, -cpu Nehalem is just as obscure as -cpu 
> > qemu64,-sse3,+vmx,...
> 
> What name will these users know?  FWIW, it makes sense to me as it is.

2001, 2005, 2008, 2010 :-)

-- Jamie




Re: [Qemu-devel] [PATCH] Add definitions for current cpu models..

2010-01-19 Thread Jamie Lokier
john cooper wrote:
> As before a cpu feature 'check' option is added which warns when
> feature flags (either implicit in a cpu model or explicit on the
> command line) would have otherwise been quietly unavailable to a
> guest:
> 
> # qemu-system-x86_64 ... -cpu Nehalem,check
> warning: host cpuid _0001 lacks requested flag 'sse4.2' [0x0010]
> warning: host cpuid _0001 lacks requested flag 'popcnt' [0x0080]

That's a nice feature.  Can we have a 'checkfail' option which refuses
to run if a requested capability isn't available?  Thanks.

I foresee wanting to iterate over the models and pick the latest one
which a host supports - on the grounds that you have done the hard
work of ensuring it is a reasonably good performer, while "probably"
working on another host of similar capability when a new host is made
available.

-- Jamie




Re: [Qemu-devel] [PATCH] Add definitions for current cpu models..

2010-01-19 Thread Chris Wright
* Jamie Lokier (ja...@shareable.org) wrote:
> Chris Wright wrote:
> > * Anthony Liguori (anth...@codemonkey.ws) wrote:
> > > I'm very much against having -cpu Nehalem.  The whole point of this is  
> > > to make things easier for a user and for most of the users I've  
> > > encountered, -cpu Nehalem is just as obscure as -cpu 
> > > qemu64,-sse3,+vmx,...
> > 
> > What name will these users know?  FWIW, it makes sense to me as it is.
> 
> 2001, 2005, 2008, 2010 :-)

Heh, sadly not far from the truth I bet ;-)  Flip side, if you deploy
the sekrit decoder ring at ark.intel.com, the Xeon® + number seems
equally obscure.  Seems we'll never make 'em all happy.

thanks,
-chris




Re: [Qemu-devel] [PATCH] sparc64: reimplement tick timers v2

2010-01-19 Thread Igor Kovalenko
On Tue, Jan 19, 2010 at 9:44 PM, Blue Swirl  wrote:
> On Mon, Jan 18, 2010 at 10:28 PM, Igor V. Kovalenko
>  wrote:
>> From: Igor V. Kovalenko 
>>
>> sparc64 timer has tick counter which can be set and read,
>> and tick compare value used as deadline to fire timer interrupt.
>> The timer is not used as periodic timer, instead deadline
>> is set each time new timer interrupt is needed.
>
> Does not compile:
>
>  CC    sparc64-softmmu/sun4u.o
> cc1: warnings being treated as errors
> /src/qemu/hw/sun4u.c: In function 'cpu_tick_set_count':
> /src/qemu/hw/sun4u.c:467: error: implicit declaration of function
> 'TIMER_DPRINTF'
> make[1]: *** [sun4u.o] Error 1

Sorry forgot the split out debugging piece. New v3 has all these
comments addressed.

> If I add the missing TIMER_DPRINTF, Linux still crashes:
>
> Memory: 117376k available (2136k kernel code, 664k data, 184k init)
> [f800,07e8]
> SLUB: Genslabs=14, HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
> Hierarchical RCU implementation.
> NR_IRQS:255
> clocksource: mult[a] shift[16]
> clockevent: mult[1999] shift[32]
> Console: colour dummy device 80x25
> Unable to handle kernel NULL pointer dereference
> tsk->{mm,active_mm}->context = 
> tsk->{mm,active_mm}->pgd = f86fdaa4
>              \|/  \|/
>              "@'/ .. \`@"
>              /_| \__/ |_\
>                 \__U_/
> swapper(0): Oops [#1]
> TSTATE: 004480001607 TPC: 006e32f4 TNPC: 006e32f8
> Y:     Not tainted
> TPC: 

Easy to reproduce here, and I still fail to find the reason for this crash.
It looks like linux kernel loads zero values from memory while returning
from timer softirq handler. Note this does not always happen at first timer
interrupt inside calibrate_delay loop.

I really want to see debug trace of all processed instructions, but
qemu command line switch -singlestep does not really work for sparc64-softmmu
and stepping through calibrate_delay does not seem to help at the moment.
Any ideas on how to force all instructions after approx. 500 cpu
cycles to be
single stepped, so I get the trace in qemu.log ?

-- 
Kind regards,
Igor V. Kovalenko




Re: [Qemu-devel] [PATCH] Add definitions for current cpu models..

2010-01-19 Thread Anthony Liguori

On 01/19/2010 02:03 PM, Chris Wright wrote:

* Anthony Liguori (anth...@codemonkey.ws) wrote:
   

I'm very much against having -cpu Nehalem.  The whole point of this is
to make things easier for a user and for most of the users I've
encountered, -cpu Nehalem is just as obscure as -cpu
qemu64,-sse3,+vmx,...
 

What name will these users know?  FWIW, it makes sense to me as it is.
   


Whatever is in /proc/cpuinfo.

There is no mention of "Nehalem" in /proc/cpuinfo.

Regards,

Anthony Liguori

thanks,
-chris
   






[Qemu-devel] [PATCH] sparc64: reimplement tick timers v3

2010-01-19 Thread Igor V. Kovalenko
From: Igor V. Kovalenko 

sparc64 timer has tick counter which can be set and read,
and tick compare value used as deadline to fire timer interrupt.
The timer is not used as periodic timer, instead deadline
is set each time new timer interrupt is needed.

v2 -> v3:
- added missing timer debug output macro
- CPUTimer struct and typedef moved to cpu.h
- change CPU_SAVE_VERSION to 6, older save formats not supported

v1 -> v2:
- new conversion helpers cpu_to_timer_ticks and timer_to_cpu_ticks
- save offset from clock source to implement cpu_tick_set_count
- renamed struct sun4u_timer to CPUTimer
- load and save cpu timers

v0 -> v1:
- coding style

Signed-off-by: Igor V. Kovalenko 
---
 hw/sun4u.c |  206 
 target-sparc/cpu.h |   28 +--
 target-sparc/machine.c |   14 ++-
 3 files changed, 202 insertions(+), 46 deletions(-)

diff --git a/hw/sun4u.c b/hw/sun4u.c
index a39b28e..830ad7f 100644
--- a/hw/sun4u.c
+++ b/hw/sun4u.c
@@ -40,6 +40,7 @@
 
 //#define DEBUG_IRQ
 //#define DEBUG_EBUS
+//#define DEBUG_TIMER
 
 #ifdef DEBUG_IRQ
 #define CPUIRQ_DPRINTF(fmt, ...)\
@@ -55,6 +56,13 @@
 #define EBUS_DPRINTF(fmt, ...)
 #endif
 
+#ifdef DEBUG_TIMER
+#define TIMER_DPRINTF(fmt, ...)  \
+do { printf("TIMER: " fmt , ## __VA_ARGS__); } while (0)
+#else
+#define TIMER_DPRINTF(fmt, ...)
+#endif
+
 #define KERNEL_LOAD_ADDR 0x00404000
 #define CMDLINE_ADDR 0x003ff000
 #define INITRD_LOAD_ADDR 0x0030
@@ -280,6 +288,12 @@ void cpu_check_irqs(CPUState *env)
 }
 }
 
+static void cpu_kick_irq(CPUState *env)
+{
+env->halted = 0;
+cpu_check_irqs(env);
+}
+
 static void cpu_set_irq(void *opaque, int irq, int level)
 {
 CPUState *env = opaque;
@@ -301,6 +315,52 @@ typedef struct ResetData {
 uint64_t prom_addr;
 } ResetData;
 
+void cpu_put_timer(QEMUFile *f, CPUTimer *s)
+{
+qemu_put_be32s(f, &s->frequency);
+qemu_put_be32s(f, &s->disabled);
+qemu_put_be64s(f, &s->disabled_mask);
+qemu_put_sbe64s(f, &s->clock_offset);
+
+qemu_put_timer(f, s->qtimer);
+}
+
+void cpu_get_timer(QEMUFile *f, CPUTimer *s)
+{
+qemu_get_be32s(f, &s->frequency);
+qemu_get_be32s(f, &s->disabled);
+qemu_get_be64s(f, &s->disabled_mask);
+qemu_get_sbe64s(f, &s->clock_offset);
+
+qemu_get_timer(f, s->qtimer);
+}
+
+static CPUTimer* cpu_timer_create(const char* name, CPUState *env,
+  QEMUBHFunc *cb, uint32_t frequency,
+  uint64_t disabled_mask)
+{
+CPUTimer *timer = qemu_mallocz(sizeof (CPUTimer));
+
+timer->name = name;
+timer->frequency = frequency;
+timer->disabled_mask = disabled_mask;
+
+timer->disabled = 1;
+timer->clock_offset = qemu_get_clock(vm_clock);
+
+timer->qtimer = qemu_new_timer(vm_clock, cb, env);
+
+return timer;
+}
+
+static void cpu_timer_reset(CPUTimer *timer)
+{
+timer->disabled = 1;
+timer->clock_offset = qemu_get_clock(vm_clock);
+
+qemu_del_timer(timer->qtimer);
+}
+
 static void main_cpu_reset(void *opaque)
 {
 ResetData *s = (ResetData *)opaque;
@@ -308,15 +368,11 @@ static void main_cpu_reset(void *opaque)
 static unsigned int nr_resets;
 
 cpu_reset(env);
-env->tick_cmpr = TICK_INT_DIS | 0;
-ptimer_set_limit(env->tick, TICK_MAX, 1);
-ptimer_run(env->tick, 1);
-env->stick_cmpr = TICK_INT_DIS | 0;
-ptimer_set_limit(env->stick, TICK_MAX, 1);
-ptimer_run(env->stick, 1);
-env->hstick_cmpr = TICK_INT_DIS | 0;
-ptimer_set_limit(env->hstick, TICK_MAX, 1);
-ptimer_run(env->hstick, 1);
+
+cpu_timer_reset(env->tick);
+cpu_timer_reset(env->stick);
+cpu_timer_reset(env->hstick);
+
 env->gregs[1] = 0; // Memory start
 env->gregs[2] = ram_size; // Memory size
 env->gregs[3] = 0; // Machine description XXX
@@ -333,44 +389,127 @@ static void tick_irq(void *opaque)
 {
 CPUState *env = opaque;
 
-if (!(env->tick_cmpr & TICK_INT_DIS)) {
-env->softint |= SOFTINT_TIMER;
-cpu_interrupt(env, CPU_INTERRUPT_TIMER);
+CPUTimer* timer = env->tick;
+
+if (timer->disabled) {
+CPUIRQ_DPRINTF("tick_irq: softint disabled\n");
+return;
+} else {
+CPUIRQ_DPRINTF("tick: fire\n");
 }
+
+env->softint |= SOFTINT_TIMER;
+cpu_kick_irq(env);
 }
 
 static void stick_irq(void *opaque)
 {
 CPUState *env = opaque;
 
-if (!(env->stick_cmpr & TICK_INT_DIS)) {
-env->softint |= SOFTINT_STIMER;
-cpu_interrupt(env, CPU_INTERRUPT_TIMER);
+CPUTimer* timer = env->stick;
+
+if (timer->disabled) {
+CPUIRQ_DPRINTF("stick_irq: softint disabled\n");
+return;
+} else {
+CPUIRQ_DPRINTF("stick: fire\n");
 }
+
+env->softint |= SOFTINT_STIMER;
+cpu_kick_irq(env);
 }
 
 static void hstick_irq(void *opaque)
 {
 CPUState *env = opaque;
 
-if (!(env->hstick_cmpr & T

[Qemu-devel] Re: [PULL] eepro100 patches

2010-01-19 Thread Anthony Liguori

On 01/19/2010 11:42 AM, Michael S. Tsirkin wrote:

The following changes since commit 1c39457adf220f9011cc6e08c05b272073ec3126:
   Blue Swirl (1):
 Sparc32: Update OpenBIOS image to r666

are available in the git repository at:

   git://git.kernel.org/pub/scm/linux/kernel/git/mst/qemu.git for_anthony

Stefan Weil (2):
   eepro100: Restructure code (new function tx_command)
   eepro100: Fix multicast support

  hw/eepro100.c |  243 -
  1 files changed, 137 insertions(+), 106 deletions(-)
   


Pulled.  Thanks.

Regards,

Anthony Liguori




Re: [Qemu-devel] [PATCH] rtl8139: fix clang reporting unused assignment of VLAN tagging data

2010-01-19 Thread Anthony Liguori

On 01/13/2010 04:53 PM, Igor V. Kovalenko wrote:

From: Igor V. Kovalenko

Currently we do not implement VLAN tagging for rtl8139(C+),
still data is read from ring buffer headers.

- augment unused assignment with TODO item
- cast txdw1 to void for now

Signed-off-by: Igor V. Kovalenko
   


Applied.  Thanks.

Regards,

Anthony Liguori

---
  hw/rtl8139.c |5 +
  1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/hw/rtl8139.c b/hw/rtl8139.c
index 1f4f585..f04dd54 100644
--- a/hw/rtl8139.c
+++ b/hw/rtl8139.c
@@ -1909,6 +1909,7 @@ 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);
@@ -1920,6 +1921,9 @@ 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 */
@@ -2045,6 +2049,7 @@ 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_physical_memory_write(cplus_tx_ring_desc+4,&val, 4);





   






Re: [Qemu-devel] [PATCH] char: Remove redundant qemu_chr_generic_open() call.

2010-01-19 Thread Anthony Liguori

On 01/14/2010 09:46 AM, Kusanagi Kouichi wrote:

qemu_chr_open_fd() calls qemu_chr_generic_open(),
so qemu_chr_open_tty() doesn't need to call it.

Signed-off-by: Kusanagi Kouichi
   


Applied.  Thanks.

Regards,

Anthony Liguori

---
  qemu-char.c |1 -
  1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/qemu-char.c b/qemu-char.c
index b13f8d4..800ee6c 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -1187,7 +1187,6 @@ static CharDriverState *qemu_chr_open_tty(QemuOpts *opts)
  return NULL;
  }
  chr->chr_ioctl = tty_serial_ioctl;
-qemu_chr_generic_open(chr);
  return chr;
  }
  #else  /* ! __linux__&&  ! __sun__ */
   






Re: [Qemu-devel] [PATCH v4] raw-posix: Detect CDROM via ioctl on linux

2010-01-19 Thread Anthony Liguori

On 01/14/2010 10:19 AM, Cole Robinson wrote:

Current CDROM detection is hardcoded based on source file name.
Make this smarter on linux by attempting a CDROM specific ioctl.

This makes '-cdrom /dev/sr0' succeed with no media present.

v2:
 Give ioctl check higher priority than filename check.

v3:
 Actually initialize 'prio' variable.
 Check for ioctl success rather than absence of specific failure.

v4:
 Explicitly mention that change is linux specific.

Signed-off-by: Cole Robinson
   


Applied.  Thanks.

Regards,

Anthony Liguori

---
  block/raw-posix.c |   20 ++--
  1 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/block/raw-posix.c b/block/raw-posix.c
index 5a6a22b..a2c7508 100644
--- a/block/raw-posix.c
+++ b/block/raw-posix.c
@@ -1140,9 +1140,25 @@ static int cdrom_open(BlockDriverState *bs, const char 
*filename, int flags)

  static int cdrom_probe_device(const char *filename)
  {
+int fd, ret;
+int prio = 0;
+
  if (strstart(filename, "/dev/cd", NULL))
-return 100;
-return 0;
+prio = 50;
+
+fd = open(filename, O_RDONLY | O_NONBLOCK);
+if (fd<  0) {
+goto out;
+}
+
+/* Attempt to detect via a CDROM specific ioctl */
+ret = ioctl(fd, CDROM_DRIVE_STATUS, CDSL_CURRENT);
+if (ret>= 0)
+prio = 100;
+
+close(fd);
+out:
+return prio;
  }

  static int cdrom_is_inserted(BlockDriverState *bs)
   






Re: [Qemu-devel] [PATCH v4] raw-posix: Detect legacy floppy via ioctl on linux

2010-01-19 Thread Anthony Liguori

On 01/14/2010 10:19 AM, Cole Robinson wrote:

Current legacy floppy detection is hardcoded based on source file
name. Make this smarter on linux by attempting a floppy specific
ioctl.

v2:
 Give ioctl check higher priority than filename check
 s/IDE/legacy/

v3:
 Actually initialize 'prio' variable
 Check for ioctl success rather than absence of specific failure

v4:
 Explicitly mention that change is linux specific.

Signed-off-by: Cole Robinson
   


Applied.  Thanks.

Regards,

Anthony Liguori

---
  block/raw-posix.c |   21 +++--
  1 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/block/raw-posix.c b/block/raw-posix.c
index a2c7508..eea7e56 100644
--- a/block/raw-posix.c
+++ b/block/raw-posix.c
@@ -1055,9 +1055,26 @@ static int floppy_open(BlockDriverState *bs, const char 
*filename, int flags)

  static int floppy_probe_device(const char *filename)
  {
+int fd, ret;
+int prio = 0;
+struct floppy_struct fdparam;
+
  if (strstart(filename, "/dev/fd", NULL))
-return 100;
-return 0;
+prio = 50;
+
+fd = open(filename, O_RDONLY | O_NONBLOCK);
+if (fd<  0) {
+goto out;
+}
+
+/* Attempt to detect via a floppy specific ioctl */
+ret = ioctl(fd, FDGETPRM,&fdparam);
+if (ret>= 0)
+prio = 100;
+
+close(fd);
+out:
+return prio;
  }


   






Re: [Qemu-devel] [PATCH 1/8] VNC: Use 'enabled' key instead of 'status'

2010-01-19 Thread Anthony Liguori

On 01/14/2010 10:50 AM, Luiz Capitulino wrote:

Currently the 'status' key is a string whose value can be
"disabled" or "enabled", change it to the QMP's standard
'enabled' key, which is a bool.

Note that 'status' in being dropped and this wouldn't be
allowed if QMP were stable.

Signed-off-by: Luiz Capitulino
   


Applied all.  Thanks.

Regards,

Anthony Liguori

---
  vnc.c |   10 +-
  1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/vnc.c b/vnc.c
index 58eac73..ef86ef7 100644
--- a/vnc.c
+++ b/vnc.c
@@ -254,7 +254,7 @@ void do_info_vnc_print(Monitor *mon, const QObject *data)
  QList *clients;

  server = qobject_to_qdict(data);
-if (strcmp(qdict_get_str(server, "status"), "disabled") == 0) {
+if (qdict_get_bool(server, "enabled") == 0) {
  monitor_printf(mon, "Server: disabled\n");
  return;
  }
@@ -282,7 +282,7 @@ void do_info_vnc_print(Monitor *mon, const QObject *data)
   *
   * The main QDict contains the following:
   *
- * - "status": "disabled" or "enabled"
+ * - "enabled": true or false
   * - "host": server's IP address
   * - "service": server's port number
   * - "auth": authentication method (optional)
@@ -297,13 +297,13 @@ void do_info_vnc_print(Monitor *mon, const QObject *data)
   *
   * Example:
   *
- * { "status": "enabled", "host": "0.0.0.0", "service": "50402", "auth": "vnc",
+ * { "enabled": true, "host": "0.0.0.0", "service": "50402", "auth": "vnc",
   *   "clients": [ { "host": "127.0.0.1", "service": "50401" } ] }
   */
  void do_info_vnc(Monitor *mon, QObject **ret_data)
  {
  if (vnc_display == NULL || vnc_display->display == NULL) {
-*ret_data = qobject_from_jsonf("{ 'status': 'disabled' }");
+*ret_data = qobject_from_jsonf("{ 'enabled': false }");
  } else {
  QDict *qdict;
  QList *clist;
@@ -319,7 +319,7 @@ void do_info_vnc(Monitor *mon, QObject **ret_data)
  }
  }

-*ret_data = qobject_from_jsonf("{ 'status': 'enabled', 'clients': %p 
}",
+*ret_data = qobject_from_jsonf("{ 'enabled': true, 'clients': %p }",
 QOBJECT(clist));
  assert(*ret_data != NULL);

   






Re: [Qemu-devel] [PATCH 1/3] remove dead code from target-i386/exec.h

2010-01-19 Thread Anthony Liguori

On 01/15/2010 01:56 AM, Paolo Bonzini wrote:

These are unused since edea5f0 (no need to define global registers in
cpu-exec.c, 2008-05-10).

Signed-off-by: Paolo Bonzini
   


Applied.  Thanks.

Regards,

Anthony Liguori

---
  target-i386/exec.h |   48 
  1 files changed, 0 insertions(+), 48 deletions(-)

diff --git a/target-i386/exec.h b/target-i386/exec.h
index 864d030..e8365b1 100644
--- a/target-i386/exec.h
+++ b/target-i386/exec.h
@@ -292,58 +292,10 @@ static inline void load_eflags(int eflags, int 
update_mask)

  static inline void env_to_regs(void)
  {
-#ifdef reg_EAX
-EAX = env->regs[R_EAX];
-#endif
-#ifdef reg_ECX
-ECX = env->regs[R_ECX];
-#endif
-#ifdef reg_EDX
-EDX = env->regs[R_EDX];
-#endif
-#ifdef reg_EBX
-EBX = env->regs[R_EBX];
-#endif
-#ifdef reg_ESP
-ESP = env->regs[R_ESP];
-#endif
-#ifdef reg_EBP
-EBP = env->regs[R_EBP];
-#endif
-#ifdef reg_ESI
-ESI = env->regs[R_ESI];
-#endif
-#ifdef reg_EDI
-EDI = env->regs[R_EDI];
-#endif
  }

  static inline void regs_to_env(void)
  {
-#ifdef reg_EAX
-env->regs[R_EAX] = EAX;
-#endif
-#ifdef reg_ECX
-env->regs[R_ECX] = ECX;
-#endif
-#ifdef reg_EDX
-env->regs[R_EDX] = EDX;
-#endif
-#ifdef reg_EBX
-env->regs[R_EBX] = EBX;
-#endif
-#ifdef reg_ESP
-env->regs[R_ESP] = ESP;
-#endif
-#ifdef reg_EBP
-env->regs[R_EBP] = EBP;
-#endif
-#ifdef reg_ESI
-env->regs[R_ESI] = ESI;
-#endif
-#ifdef reg_EDI
-env->regs[R_EDI] = EDI;
-#endif
  }

  static inline int cpu_has_work(CPUState *env)
   






Re: [Qemu-devel] [PATCH] avoid unreachable statement after break

2010-01-19 Thread Anthony Liguori

On 01/15/2010 02:41 AM, Paolo Bonzini wrote:

Signed-off-by: Paolo Bonzini
   


Applied.  Thanks.

Regards,

Anthony Liguori

---
  cpu-exec.c |2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/cpu-exec.c b/cpu-exec.c
index 44d45fc..d974141 100644
--- a/cpu-exec.c
+++ b/cpu-exec.c
@@ -316,9 +316,9 @@ int cpu_exec(CPUState *env1)
  #elif defined(TARGET_M68K)
  do_interrupt(0);
  #endif
+env->exception_index = -1;
  #endif
  }
-env->exception_index = -1;
  }

  if (kvm_enabled()) {
   






Re: [Qemu-devel] [PATCH 1/4] clean up env->current_tb

2010-01-19 Thread Anthony Liguori

On 01/15/2010 02:42 AM, Paolo Bonzini wrote:

There are three paths from the innermost while loop of cpu_exec
to the top of the outermost for loop.  Two do not reset
env->current_tb.  Fix this.

Signed-off-by: Paolo Bonzini
   


Applied.  Thanks.

Regards,

Anthony Liguori

---
  cpu-exec.c |2 ++
  1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/cpu-exec.c b/cpu-exec.c
index 6f6ed14..9128df9 100644
--- a/cpu-exec.c
+++ b/cpu-exec.c
@@ -56,6 +56,7 @@ int qemu_cpu_has_work(CPUState *env)

  void cpu_loop_exit(void)
  {
+env->current_tb = NULL;
  longjmp(env->jmp_env, 1);
  }

@@ -107,6 +108,7 @@ static void cpu_exec_nocache(int max_cycles, 
TranslationBlock *orig_tb)
  env->current_tb = tb;
  /* execute the generated code */
  next_tb = tcg_qemu_tb_exec(tb->tc_ptr);
+env->current_tb = NULL;

  if ((next_tb&  3) == 2) {
  /* Restore PC.  This may happen if async event occurs before
   






Re: [Qemu-devel] [PATCH] Fix QEMU_WARN_UNUSED_RESULT

2010-01-19 Thread Anthony Liguori

On 01/15/2010 05:56 AM, Kevin Wolf wrote:

Since commit 747bbdf7 QEMU_WARN_UNUSED_RESULT is never defined as it is
conditional on a define from config-host.h which is included only later.
Include that file earlier to get the warnings back.

Reactivating it unfortunately leads to some warnings about unused qdev_init
results. These calls are changed to qdev_init_nofail to avoid build failures.

Signed-off-by: Kevin Wolf
   


Applied.  Thanks.

Regards,

Anthony Liguori

---

Gerd, can you please check if using nofail is appropriate or should be replaced
by some real error checks (and if so, which)?

  hw/usb-net.c|2 +-
  hw/usb-serial.c |4 ++--
  qemu-common.h   |3 ++-
  usb-linux.c |2 +-
  4 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/hw/usb-net.c b/hw/usb-net.c
index 9744dfa..cfd2f62 100644
--- a/hw/usb-net.c
+++ b/hw/usb-net.c
@@ -1492,7 +1492,7 @@ static USBDevice *usb_net_init(const char *cmdline)

  dev = usb_create(NULL /* FIXME */, "usb-net");
  qdev_set_nic_properties(&dev->qdev,&nd_table[idx]);
-qdev_init(&dev->qdev);
+qdev_init_nofail(&dev->qdev);
  return dev;
  }

diff --git a/hw/usb-serial.c b/hw/usb-serial.c
index 2775cf0..37293ea 100644
--- a/hw/usb-serial.c
+++ b/hw/usb-serial.c
@@ -583,7 +583,7 @@ static USBDevice *usb_serial_init(const char *filename)
  qdev_prop_set_uint16(&dev->qdev, "vendorid", vendorid);
  if (productid)
  qdev_prop_set_uint16(&dev->qdev, "productid", productid);
-qdev_init(&dev->qdev);
+qdev_init_nofail(&dev->qdev);

  return dev;
  }
@@ -599,7 +599,7 @@ static USBDevice *usb_braille_init(const char *unused)

  dev = usb_create(NULL /* FIXME */, "usb-braille");
  qdev_prop_set_chr(&dev->qdev, "chardev", cdrv);
-qdev_init(&dev->qdev);
+qdev_init_nofail(&dev->qdev);

  return dev;
  }
diff --git a/qemu-common.h b/qemu-common.h
index 8630f8c..d96060a 100644
--- a/qemu-common.h
+++ b/qemu-common.h
@@ -2,6 +2,8 @@
  #ifndef QEMU_COMMON_H
  #define QEMU_COMMON_H

+#include "config-host.h"
+
  #define QEMU_NORETURN __attribute__ ((__noreturn__))
  #ifdef CONFIG_GCC_ATTRIBUTE_WARN_UNUSED_RESULT
  #define QEMU_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
@@ -29,7 +31,6 @@
  #include
  #include
  #include
-#include "config-host.h"

  #ifndef O_LARGEFILE
  #define O_LARGEFILE 0
diff --git a/usb-linux.c b/usb-linux.c
index 88728e9..5619b30 100644
--- a/usb-linux.c
+++ b/usb-linux.c
@@ -1036,7 +1036,7 @@ USBDevice *usb_host_device_open(const char *devname)
  qdev_prop_set_uint32(&dev->qdev, "hostaddr",  filter.addr);
  qdev_prop_set_uint32(&dev->qdev, "vendorid",  filter.vendor_id);
  qdev_prop_set_uint32(&dev->qdev, "productid", filter.product_id);
-qdev_init(&dev->qdev);
+qdev_init_nofail(&dev->qdev);
  return dev;

  fail:
   






Re: [Qemu-devel] [PATCH] QMP: Emit asynchronous events on all QMP monitors

2010-01-19 Thread Anthony Liguori

On 01/15/2010 08:34 AM, Adam Litke wrote:

When using a control/QMP monitor in tandem with a regular monitor, asynchronous
messages can get lost depending on the order of the QEMU program arguments.
QEMU events issued by monitor_protocol_event() always go to cur_mon.  If the
user monitor was specified on the command line first (or it has ,default), the
message will be directed to the user monitor (not the QMP monitor).
Additionally, only one QMP session is currently able to receive async messages.

To avoid this confusion, scan through the list of monitors and emit the message
on each QMP monitor.

Signed-off-by: Adam Litke
   


Applied.  Thanks.

Regards,

Anthony Liguori

diff --git a/monitor.c b/monitor.c
index 134ed15..06c8bf0 100644
--- a/monitor.c
+++ b/monitor.c
@@ -334,13 +334,10 @@ void monitor_protocol_event(MonitorEvent event, QObject 
*data)
  {
  QDict *qmp;
  const char *event_name;
-Monitor *mon = cur_mon;
+Monitor *mon;

  assert(event<  QEVENT_MAX);

-if (!monitor_ctrl_mode(mon))
-return;
-
  switch (event) {
  case QEVENT_DEBUG:
  event_name = "DEBUG";
@@ -373,7 +370,12 @@ void monitor_protocol_event(MonitorEvent event, QObject 
*data)
  qdict_put_obj(qmp, "data", data);
  }

-monitor_json_emitter(mon, QOBJECT(qmp));
+QLIST_FOREACH(mon,&mon_list, entry) {
+if (!monitor_ctrl_mode(mon))
+return;
+
+monitor_json_emitter(mon, QOBJECT(qmp));
+}
  QDECREF(qmp);
  }



   






[Qemu-devel] [PATCH 00/17] Fix compilation with _FORTIFY_SOURCE

2010-01-19 Thread Juan Quintela
Hi

This series is a work on top of Kirill previous patches.
Changes are:
- I addressed all reviewers comments
- Improved some error messages
- Check that it is valid to return -errno (switched lots of places to just
  return -1).
- check correctly system() result for errors.
- -fstack-protector-all is only used if compiler accept it

And new additions:
- add WARN_UNUSED_RESULT
- check pipe() use in xen code.
- fix mmap_frag() returned -EINVAL when users only deal with -1 for errors.

Kirill, could you coment on the series?

Still not completely happy:
- qemu_write_full() just loops if write() returns 0.  it is only
  used for pipes and files, but pipes and files shouldn't give you
  short writes in the 1st place.  Not sure what to do here.

- check write() errors against -EINVAL/-EINTR/-EAGAIN
  series where not consistent on this regard.  I didn't changed
  any.

You can pull this series from:

git://repo.or.cz/qemu/quintela.git fortify

With this changes, I am able to compile qemu for all architectures in
a linux host without a single warning.

This is important for us (Fedora) because F12 compile all packages with
-Wp,-D_FORTIFY_SOURCE=2, and we had -Werror disabled due to this.

Comments?

Juan Quintela (4):
  force to test result for qemu_write_full()
  check pipe() return value
  Check availavility of -fstack-protector-all
  mmap_frag() users only check for -1 error

Kirill A. Shutemov (13):
  Introduce qemu_write_full()
  posix-aio-compat.c: fix warning with _FORTIFY_SOURCE
  block/cow.c: fix warnings with _FORTIFY_SOURCE
  block/qcow.c: fix warnings with _FORTIFY_SOURCE
  block/vmdk.o: fix warnings with _FORTIFY_SOURCE
  block/vvfat.c: fix warnings with _FORTIFY_SOURCE
  block/qcow2.c: fix warnings with _FORTIFY_SOURCE
  net/slirp.c: fix warning with _FORTIFY_SOURCE
  usb-linux.c: fix warning with _FORTIFY_SOURCE
  vl.c: fix warning with _FORTIFY_SOURCE
  monitor.c: fix warnings with _FORTIFY_SOURCE
  linux-user/mmap.c: fix warnings with _FORTIFY_SOURCE
  Enable _FORTIFY_SOURCE=2

 block/cow.c  |   19 ++--
 block/qcow.c |   26 ---
 block/qcow2.c|   55 -
 block/vmdk.c |   50 -
 block/vvfat.c|9 ++-
 configure|4 +-
 hw/xen_domainbuild.c |   13 ---
 linux-user/mmap.c|8 --
 monitor.c|   12 +-
 net/slirp.c  |9 +++-
 osdep.c  |   27 
 posix-aio-compat.c   |5 +++-
 qemu-common.h|2 +
 usb-linux.c  |3 +-
 vl.c |   22 ---
 15 files changed, 216 insertions(+), 48 deletions(-)





[Qemu-devel] [PATCH 01/17] Introduce qemu_write_full()

2010-01-19 Thread Juan Quintela
From: Kirill A. Shutemov 

A variant of write(2) which handles partial write.

Signed-off-by: Kirill A. Shutemov 
Signed-off-by: Juan Quintela 
---
 osdep.c   |   27 +++
 qemu-common.h |1 +
 2 files changed, 28 insertions(+), 0 deletions(-)

diff --git a/osdep.c b/osdep.c
index 1310684..09fbc99 100644
--- a/osdep.c
+++ b/osdep.c
@@ -243,6 +243,33 @@ int qemu_open(const char *name, int flags, ...)
 return ret;
 }

+/*
+ * A variant of write(2) which handles partial write.
+ *
+ * Return the number of bytes transferred.
+ * Set errno if fewer than `count' bytes are written.
+ */
+ssize_t qemu_write_full(int fd, const void *buf, size_t count)
+{
+ssize_t ret = 0;
+ssize_t total = 0;
+
+while (count) {
+ret = write(fd, buf, count);
+if (ret < 0) {
+if (errno == EINTR)
+continue;
+break;
+}
+
+count -= ret;
+buf += ret;
+total += ret;
+}
+
+return total;
+}
+
 #ifndef _WIN32
 /*
  * Creates a pipe with FD_CLOEXEC set on both file descriptors
diff --git a/qemu-common.h b/qemu-common.h
index 8630f8c..a8144cb 100644
--- a/qemu-common.h
+++ b/qemu-common.h
@@ -160,6 +160,7 @@ void qemu_mutex_lock_iothread(void);
 void qemu_mutex_unlock_iothread(void);

 int qemu_open(const char *name, int flags, ...);
+ssize_t qemu_write_full(int fd, const void *buf, size_t count);
 void qemu_set_cloexec(int fd);

 #ifndef _WIN32
-- 
1.6.5.2





[Qemu-devel] [PATCH 02/17] force to test result for qemu_write_full()

2010-01-19 Thread Juan Quintela

Signed-off-by: Juan Quintela 
---
 qemu-common.h |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/qemu-common.h b/qemu-common.h
index a8144cb..f009796 100644
--- a/qemu-common.h
+++ b/qemu-common.h
@@ -160,7 +160,8 @@ void qemu_mutex_lock_iothread(void);
 void qemu_mutex_unlock_iothread(void);

 int qemu_open(const char *name, int flags, ...);
-ssize_t qemu_write_full(int fd, const void *buf, size_t count);
+ssize_t qemu_write_full(int fd, const void *buf, size_t count)
+QEMU_WARN_UNUSED_RESULT;
 void qemu_set_cloexec(int fd);

 #ifndef _WIN32
-- 
1.6.5.2





[Qemu-devel] [PATCH 03/17] posix-aio-compat.c: fix warning with _FORTIFY_SOURCE

2010-01-19 Thread Juan Quintela
From: Kirill A. Shutemov 

CCposix-aio-compat.o
cc1: warnings being treated as errors
posix-aio-compat.c: In function 'aio_signal_handler':
posix-aio-compat.c:505: error: ignoring return value of 'write', declared with 
attribute warn_unused_result
make: *** [posix-aio-compat.o] Error 1

Signed-off-by: Kirill A. Shutemov 
Signed-off-by: Juan Quintela 
---
 posix-aio-compat.c |5 -
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/posix-aio-compat.c b/posix-aio-compat.c
index dc14f53..b43c531 100644
--- a/posix-aio-compat.c
+++ b/posix-aio-compat.c
@@ -501,8 +501,11 @@ static void aio_signal_handler(int signum)
 {
 if (posix_aio_state) {
 char byte = 0;
+ssize_t ret;

-write(posix_aio_state->wfd, &byte, sizeof(byte));
+ret = write(posix_aio_state->wfd, &byte, sizeof(byte));
+if (ret < 0 && errno != EAGAIN)
+die("write()");
 }

 qemu_service_io();
-- 
1.6.5.2





[Qemu-devel] [PATCH 04/17] block/cow.c: fix warnings with _FORTIFY_SOURCE

2010-01-19 Thread Juan Quintela
From: Kirill A. Shutemov 

CCblock/cow.o
cc1: warnings being treated as errors
block/cow.c: In function 'cow_create':
block/cow.c:251: error: ignoring return value of 'write', declared with 
attribute warn_unused_result
block/cow.c:253: error: ignoring return value of 'ftruncate', declared with 
attribute warn_unused_result
make: *** [block/cow.o] Error 1

Signed-off-by: Kirill A. Shutemov 
Signed-off-by: Juan Quintela 
---
 block/cow.c |   19 ---
 1 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/block/cow.c b/block/cow.c
index a70854e..3733385 100644
--- a/block/cow.c
+++ b/block/cow.c
@@ -209,6 +209,7 @@ static int cow_create(const char *filename, 
QEMUOptionParameter *options)
 struct stat st;
 int64_t image_sectors = 0;
 const char *image_filename = NULL;
+int ret;

 /* Read out options */
 while (options && options->name) {
@@ -248,11 +249,23 @@ static int cow_create(const char *filename, 
QEMUOptionParameter *options)
 }
 cow_header.sectorsize = cpu_to_be32(512);
 cow_header.size = cpu_to_be64(image_sectors * 512);
-write(cow_fd, &cow_header, sizeof(cow_header));
+ret = qemu_write_full(cow_fd, &cow_header, sizeof(cow_header));
+if (ret != sizeof(cow_header)) {
+ret = -1;
+goto exit;
+}
+
 /* resize to include at least all the bitmap */
-ftruncate(cow_fd, sizeof(cow_header) + ((image_sectors + 7) >> 3));
+ret = ftruncate(cow_fd, sizeof(cow_header) + ((image_sectors + 7) >> 3));
+if (ret) {
+ret = -errno;
+goto exit;
+}
+
+ret = 0;
+exit:
 close(cow_fd);
-return 0;
+return ret;
 }

 static void cow_flush(BlockDriverState *bs)
-- 
1.6.5.2





[Qemu-devel] [PATCH 05/17] block/qcow.c: fix warnings with _FORTIFY_SOURCE

2010-01-19 Thread Juan Quintela
From: Kirill A. Shutemov 

CCblock/qcow.o
cc1: warnings being treated as errors
block/qcow.c: In function 'qcow_create':
block/qcow.c:804: error: ignoring return value of 'write', declared with 
attribute warn_unused_result
block/qcow.c:806: error: ignoring return value of 'write', declared with 
attribute warn_unused_result
block/qcow.c:811: error: ignoring return value of 'write', declared with 
attribute warn_unused_result
make: *** [block/qcow.o] Error 1

Signed-off-by: Kirill A. Shutemov 
Signed-off-by: Juan Quintela 
---
 block/qcow.c |   26 ++
 1 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/block/qcow.c b/block/qcow.c
index 1e3e59b..003db1e 100644
--- a/block/qcow.c
+++ b/block/qcow.c
@@ -750,6 +750,7 @@ static int qcow_create(const char *filename, 
QEMUOptionParameter *options)
 int64_t total_size = 0;
 const char *backing_file = NULL;
 int flags = 0;
+int ret;

 /* Read out options */
 while (options && options->name) {
@@ -801,17 +802,34 @@ static int qcow_create(const char *filename, 
QEMUOptionParameter *options)
 }

 /* write all the data */
-write(fd, &header, sizeof(header));
+ret = qemu_write_full(fd, &header, sizeof(header));
+if (ret != sizeof(header)) {
+ret = -1;
+goto exit;
+}
+
 if (backing_file) {
-write(fd, backing_file, backing_filename_len);
+ret = qemu_write_full(fd, backing_file, backing_filename_len);
+if (ret != backing_filename_len) {
+ret = -1;
+goto exit;
+}
+
 }
 lseek(fd, header_size, SEEK_SET);
 tmp = 0;
 for(i = 0;i < l1_size; i++) {
-write(fd, &tmp, sizeof(tmp));
+ret = qemu_write_full(fd, &tmp, sizeof(tmp));
+if (ret != sizeof(tmp)) {
+ret = -1;
+goto exit;
+}
 }
+
+ret = 0;
+exit:
 close(fd);
-return 0;
+return ret;
 }

 static int qcow_make_empty(BlockDriverState *bs)
-- 
1.6.5.2





[Qemu-devel] [PATCH 06/17] block/vmdk.o: fix warnings with _FORTIFY_SOURCE

2010-01-19 Thread Juan Quintela
From: Kirill A. Shutemov 

CCblock/vmdk.o
cc1: warnings being treated as errors
block/vmdk.c: In function 'vmdk_snapshot_create':
block/vmdk.c:236: error: ignoring return value of 'ftruncate', declared with 
attribute warn_unused_result
block/vmdk.c: In function 'vmdk_create':
block/vmdk.c:775: error: ignoring return value of 'write', declared with 
attribute warn_unused_result
block/vmdk.c:776: error: ignoring return value of 'write', declared with 
attribute warn_unused_result
block/vmdk.c:778: error: ignoring return value of 'ftruncate', declared with 
attribute warn_unused_result
block/vmdk.c:784: error: ignoring return value of 'write', declared with 
attribute warn_unused_result
block/vmdk.c:790: error: ignoring return value of 'write', declared with 
attribute warn_unused_result
block/vmdk.c:807: error: ignoring return value of 'write', declared with 
attribute warn_unused_result
make: *** [block/vmdk.o] Error 1

Signed-off-by: Kirill A. Shutemov 
Signed-off-by: Juan Quintela 
---
 block/vmdk.c |   50 --
 1 files changed, 40 insertions(+), 10 deletions(-)

diff --git a/block/vmdk.c b/block/vmdk.c
index 4e48622..18c691a 100644
--- a/block/vmdk.c
+++ b/block/vmdk.c
@@ -233,7 +233,8 @@ static int vmdk_snapshot_create(const char *filename, const 
char *backing_file)
 memset(&header, 0, sizeof(header));
 memcpy(&header,&hdr[4], sizeof(header)); // skip the VMDK4_MAGIC

-ftruncate(snp_fd, header.grain_offset << 9);
+if (ftruncate(snp_fd, header.grain_offset << 9))
+goto fail;
 /* the descriptor offset = 0x200 */
 if (lseek(p_fd, 0x200, SEEK_SET) == -1)
 goto fail;
@@ -716,6 +717,7 @@ static int vmdk_create(const char *filename, 
QEMUOptionParameter *options)
 int64_t total_size = 0;
 const char *backing_file = NULL;
 int flags = 0;
+int ret;

 // Read out options
 while (options && options->name) {
@@ -772,22 +774,44 @@ static int vmdk_create(const char *filename, 
QEMUOptionParameter *options)
 header.check_bytes[3] = 0xa;

 /* write all the data */
-write(fd, &magic, sizeof(magic));
-write(fd, &header, sizeof(header));
+ret = qemu_write_full(fd, &magic, sizeof(magic));
+if (ret != sizeof(magic)) {
+ret = -1;
+goto exit;
+}
+ret = qemu_write_full(fd, &header, sizeof(header));
+if (ret != sizeof(header)) {
+ret = -1;
+goto exit;
+}

-ftruncate(fd, header.grain_offset << 9);
+ret = ftruncate(fd, header.grain_offset << 9);
+if (ret < 0) {
+ret = -1;
+goto exit;
+}

 /* write grain directory */
 lseek(fd, le64_to_cpu(header.rgd_offset) << 9, SEEK_SET);
 for (i = 0, tmp = header.rgd_offset + gd_size;
- i < gt_count; i++, tmp += gt_size)
-write(fd, &tmp, sizeof(tmp));
+ i < gt_count; i++, tmp += gt_size) {
+ret = qemu_write_full(fd, &tmp, sizeof(tmp));
+if (ret != sizeof(tmp)) {
+ret = -1;
+goto exit;
+}
+}

 /* write backup grain directory */
 lseek(fd, le64_to_cpu(header.gd_offset) << 9, SEEK_SET);
 for (i = 0, tmp = header.gd_offset + gd_size;
- i < gt_count; i++, tmp += gt_size)
-write(fd, &tmp, sizeof(tmp));
+ i < gt_count; i++, tmp += gt_size) {
+ret = qemu_write_full(fd, &tmp, sizeof(tmp));
+if (ret != sizeof(tmp)) {
+ret = -1;
+goto exit;
+}
+}

 /* compose the descriptor */
 real_filename = filename;
@@ -804,10 +828,16 @@ static int vmdk_create(const char *filename, 
QEMUOptionParameter *options)

 /* write the descriptor */
 lseek(fd, le64_to_cpu(header.desc_offset) << 9, SEEK_SET);
-write(fd, desc, strlen(desc));
+ret = qemu_write_full(fd, desc, strlen(desc));
+if (ret != strlen(desc)) {
+ret = -1;
+goto exit;
+}

+ret = 0;
+exit:
 close(fd);
-return 0;
+return ret;
 }

 static void vmdk_close(BlockDriverState *bs)
-- 
1.6.5.2





[Qemu-devel] [PATCH 07/17] block/vvfat.c: fix warnings with _FORTIFY_SOURCE

2010-01-19 Thread Juan Quintela
From: Kirill A. Shutemov 

CCblock/vvfat.o
cc1: warnings being treated as errors
block/vvfat.c: In function 'commit_one_file':
block/vvfat.c:2259: error: ignoring return value of 'ftruncate', declared with 
attribute warn_unused_result
make: *** [block/vvfat.o] Error 1
  CCblock/vvfat.o
In file included from /usr/include/stdio.h:912,
 from ./qemu-common.h:19,
 from block/vvfat.c:27:
In function 'snprintf',
inlined from 'init_directories' at block/vvfat.c:871,
inlined from 'vvfat_open' at block/vvfat.c:1068:
/usr/include/bits/stdio2.h:65: error: call to __builtin___snprintf_chk will 
always overflow destination buffer
make: *** [block/vvfat.o] Error 1

Signed-off-by: Kirill A. Shutemov 
Signed-off-by: Juan Quintela 
---
 block/vvfat.c |9 +++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/block/vvfat.c b/block/vvfat.c
index 063f731..df957e5 100644
--- a/block/vvfat.c
+++ b/block/vvfat.c
@@ -868,7 +868,8 @@ static int init_directories(BDRVVVFATState* s,
 {
direntry_t* entry=array_get_next(&(s->directory));
entry->attributes=0x28; /* archive | volume label */
-   snprintf((char*)entry->name,11,"QEMU VVFAT");
+   memcpy(entry->name,"QEMU VVF",8);
+   memcpy(entry->extension,"AT ",3);
 }

 /* Now build FAT, and write back information into directory */
@@ -2256,7 +2257,11 @@ static int commit_one_file(BDRVVVFATState* s,
c = c1;
 }

-ftruncate(fd, size);
+if (ftruncate(fd, size)) {
+perror("ftruncate()");
+close(fd);
+return -4;
+}
 close(fd);

 return commit_mappings(s, first_cluster, dir_index);
-- 
1.6.5.2





[Qemu-devel] [PATCH 09/17] net/slirp.c: fix warning with _FORTIFY_SOURCE

2010-01-19 Thread Juan Quintela
From: Kirill A. Shutemov 

CCnet/slirp.o
cc1: warnings being treated as errors
net/slirp.c: In function 'slirp_smb_cleanup':
net/slirp.c:470: error: ignoring return value of 'system', declared with 
attribute warn_unused_result
make: *** [net/slirp.o] Error 1

Signed-off-by: Kirill A. Shutemov 
Signed-off-by: Juan Quintela 
---
 net/slirp.c |9 -
 1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/net/slirp.c b/net/slirp.c
index 3f91c4b..b75ad16 100644
--- a/net/slirp.c
+++ b/net/slirp.c
@@ -464,10 +464,17 @@ int net_slirp_redir(const char *redir_str)
 static void slirp_smb_cleanup(SlirpState *s)
 {
 char cmd[128];
+int ret;

 if (s->smb_dir[0] != '\0') {
 snprintf(cmd, sizeof(cmd), "rm -rf %s", s->smb_dir);
-system(cmd);
+ret = system(cmd);
+if (!WIFEXITED(ret)) {
+qemu_error("'%s' failed.\n", cmd);
+} else if (WEXITSTATUS(ret)) {
+qemu_error("'%s' failed. Error code: %d\n",
+cmd, WEXITSTATUS(ret));
+}
 s->smb_dir[0] = '\0';
 }
 }
-- 
1.6.5.2





[Qemu-devel] [PATCH 08/17] block/qcow2.c: fix warnings with _FORTIFY_SOURCE

2010-01-19 Thread Juan Quintela
From: Kirill A. Shutemov 

CCblock/qcow2.o
cc1: warnings being treated as errors
block/qcow2.c: In function 'qcow_create2':
block/qcow2.c:829: error: ignoring return value of 'write', declared with 
attribute warn_unused_result
block/qcow2.c:838: error: ignoring return value of 'write', declared with 
attribute warn_unused_result
block/qcow2.c:839: error: ignoring return value of 'write', declared with 
attribute warn_unused_result
block/qcow2.c:841: error: ignoring return value of 'write', declared with 
attribute warn_unused_result
block/qcow2.c:844: error: ignoring return value of 'write', declared with 
attribute warn_unused_result
block/qcow2.c:849: error: ignoring return value of 'write', declared with 
attribute warn_unused_result
block/qcow2.c:852: error: ignoring return value of 'write', declared with 
attribute warn_unused_result
block/qcow2.c:855: error: ignoring return value of 'write', declared with 
attribute warn_unused_result
make: *** [block/qcow2.o] Error 1

Signed-off-by: Kirill A. Shutemov 
Signed-off-by: Juan Quintela 
---
 block/qcow2.c |   55 +--
 1 files changed, 45 insertions(+), 10 deletions(-)

diff --git a/block/qcow2.c b/block/qcow2.c
index 6622eba..1bf94c5 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -842,7 +842,7 @@ static int qcow_create2(const char *filename, int64_t 
total_size,
 uint64_t tmp, offset;
 QCowCreateState s1, *s = &s1;
 QCowExtension ext_bf = {0, 0};
-
+int ret;

 memset(s, 0, sizeof(*s));

@@ -925,7 +925,11 @@ static int qcow_create2(const char *filename, int64_t 
total_size,
 ref_clusters * s->cluster_size);

 /* write all the data */
-write(fd, &header, sizeof(header));
+ret = qemu_write_full(fd, &header, sizeof(header));
+if (ret != sizeof(header)) {
+ret = -1;
+goto exit;
+}
 if (backing_file) {
 if (backing_format_len) {
 char zero[16];
@@ -934,25 +938,56 @@ static int qcow_create2(const char *filename, int64_t 
total_size,
 memset(zero, 0, sizeof(zero));
 cpu_to_be32s(&ext_bf.magic);
 cpu_to_be32s(&ext_bf.len);
-write(fd, &ext_bf, sizeof(ext_bf));
-write(fd, backing_format, backing_format_len);
+ret = qemu_write_full(fd, &ext_bf, sizeof(ext_bf));
+if (ret != sizeof(ext_bf)) {
+ret = -1;
+goto exit;
+}
+ret = qemu_write_full(fd, backing_format, backing_format_len);
+if (ret != backing_format_len) {
+ret = -1;
+goto exit;
+}
 if (padding > 0) {
-write(fd, zero, padding);
+ret = qemu_write_full(fd, zero, padding);
+if (ret != padding) {
+ret = -1;
+goto exit;
+}
 }
 }
-write(fd, backing_file, backing_filename_len);
+ret = qemu_write_full(fd, backing_file, backing_filename_len);
+if (ret != backing_filename_len) {
+ret = -1;
+goto exit;
+}
 }
 lseek(fd, s->l1_table_offset, SEEK_SET);
 tmp = 0;
 for(i = 0;i < l1_size; i++) {
-write(fd, &tmp, sizeof(tmp));
+ret = qemu_write_full(fd, &tmp, sizeof(tmp));
+if (ret != sizeof(tmp)) {
+ret = -1;
+goto exit;
+}
 }
 lseek(fd, s->refcount_table_offset, SEEK_SET);
-write(fd, s->refcount_table, s->cluster_size);
+ret = qemu_write_full(fd, s->refcount_table, s->cluster_size);
+if (ret != s->cluster_size) {
+ret = -1;
+goto exit;
+}

 lseek(fd, s->refcount_block_offset, SEEK_SET);
-write(fd, s->refcount_block, ref_clusters * s->cluster_size);
+ret = qemu_write_full(fd, s->refcount_block,
+   ref_clusters * s->cluster_size);
+if (ret != s->cluster_size) {
+ret = -1;
+goto exit;
+}

+ret = 0;
+exit:
 qemu_free(s->refcount_table);
 qemu_free(s->refcount_block);
 close(fd);
@@ -966,7 +1001,7 @@ static int qcow_create2(const char *filename, int64_t 
total_size,
 bdrv_close(bs);
 }

-return 0;
+return ret;
 }

 static int qcow_create(const char *filename, QEMUOptionParameter *options)
-- 
1.6.5.2





[Qemu-devel] [PATCH 11/17] vl.c: fix warning with _FORTIFY_SOURCE

2010-01-19 Thread Juan Quintela
From: Kirill A. Shutemov 

CCi386-softmmu/vl.o
cc1: warnings being treated as errors
/usr/src/RPM/BUILD/qemu-0.11.92/vl.c: In function 'qemu_event_increment':
/usr/src/RPM/BUILD/qemu-0.11.92/vl.c:3404: error: ignoring return value of 
'write', declared with attribute warn_unused_result
/usr/src/RPM/BUILD/qemu-0.11.92/vl.c: In function 'main':
/usr/src/RPM/BUILD/qemu-0.11.92/vl.c:5774: error: ignoring return value of 
'write', declared with attribute warn_unused_result
/usr/src/RPM/BUILD/qemu-0.11.92/vl.c:6064: error: ignoring return value of 
'chdir', declared with attribute warn_unused_result
/usr/src/RPM/BUILD/qemu-0.11.92/vl.c:6083: error: ignoring return value of 
'chdir', declared with attribute warn_unused_result
make[1]: *** [vl.o] Error 1

Signed-off-by: Kirill A. Shutemov 
Signed-off-by: Juan Quintela 
---
 vl.c |   22 ++
 1 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/vl.c b/vl.c
index 06cb40d..7c29179 100644
--- a/vl.c
+++ b/vl.c
@@ -3176,11 +3176,17 @@ static int io_thread_fd = -1;
 static void qemu_event_increment(void)
 {
 static const char byte = 0;
+ssize_t ret;

 if (io_thread_fd == -1)
 return;

-write(io_thread_fd, &byte, sizeof(byte));
+ret = write(io_thread_fd, &byte, sizeof(byte));
+if (ret < 0 && (errno != EINTR && errno != EAGAIN)) {
+fprintf(stderr, "qemu_event_increment: write() filed: %s\n",
+strerror(errno));
+exit (1);
+}
 }

 static void qemu_event_read(void *opaque)
@@ -5585,7 +5591,9 @@ int main(int argc, char **argv, char **envp)
 #ifndef _WIN32
 if (daemonize) {
 uint8_t status = 1;
-write(fds[1], &status, 1);
+if (write(fds[1], &status, 1) != 1) {
+perror("daemonize. Writing to pipe\n");
+}
 } else
 #endif
 fprintf(stderr, "Could not acquire pid file: %s\n", 
strerror(errno));
@@ -5884,7 +5892,10 @@ int main(int argc, char **argv, char **envp)
if (len != 1)
exit(1);

-   chdir("/");
+if (chdir("/")) {
+perror("not able to chdir to /");
+exit(1);
+}
TFR(fd = qemu_open("/dev/null", O_RDWR));
if (fd == -1)
exit(1);
@@ -5903,7 +5914,10 @@ int main(int argc, char **argv, char **envp)
 fprintf(stderr, "chroot failed\n");
 exit(1);
 }
-chdir("/");
+if (chdir("/")) {
+perror("not able to chdir to /");
+exit(1);
+}
 }

 if (run_as) {
-- 
1.6.5.2





[Qemu-devel] [PATCH 10/17] usb-linux.c: fix warning with _FORTIFY_SOURCE

2010-01-19 Thread Juan Quintela
From: Kirill A. Shutemov 

CCusb-linux.o
cc1: warnings being treated as errors
usb-linux.c: In function 'usb_host_read_file':
usb-linux.c:1204: error: ignoring return value of 'fgets', declared with 
attribute warn_unused_result
make: *** [usb-linux.o] Error 1

Signed-off-by: Kirill A. Shutemov 
Signed-off-by: Juan Quintela 
---
 usb-linux.c |3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/usb-linux.c b/usb-linux.c
index 88728e9..be1d979 100644
--- a/usb-linux.c
+++ b/usb-linux.c
@@ -1201,9 +1201,8 @@ static int usb_host_read_file(char *line, size_t 
line_size, const char *device_f
  device_file);
 f = fopen(filename, "r");
 if (f) {
-fgets(line, line_size, f);
+ret = fgets(line, line_size, f) != NULL;
 fclose(f);
-ret = 1;
 #if 0
 } else {
 if (mon)
-- 
1.6.5.2





[Qemu-devel] [PATCH 12/17] monitor.c: fix warnings with _FORTIFY_SOURCE

2010-01-19 Thread Juan Quintela
From: Kirill A. Shutemov 

CCi386-softmmu/monitor.o
cc1: warnings being treated as errors
/usr/src/RPM/BUILD/qemu-0.11.92/monitor.c: In function 'do_memory_save':
/usr/src/RPM/BUILD/qemu-0.11.92/monitor.c:1318: error: ignoring return value of 
'fwrite', declared with attribute warn_unused_result
/usr/src/RPM/BUILD/qemu-0.11.92/monitor.c: In function 
'do_physical_memory_save':
/usr/src/RPM/BUILD/qemu-0.11.92/monitor.c:1345: error: ignoring return value of 
'fwrite', declared with attribute warn_unused_result
make[1]: *** [monitor.o] Error 1

Signed-off-by: Kirill A. Shutemov 
Signed-off-by: Juan Quintela 
---
 monitor.c |   12 ++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/monitor.c b/monitor.c
index b824e7c..2a20ad7 100644
--- a/monitor.c
+++ b/monitor.c
@@ -1320,10 +1320,14 @@ static void do_memory_save(Monitor *mon, const QDict 
*qdict, QObject **ret_data)
 if (l > size)
 l = size;
 cpu_memory_rw_debug(env, addr, buf, l, 0);
-fwrite(buf, 1, l, f);
+if (fwrite(buf, 1, l, f) != l) {
+monitor_printf(mon, "fwrite() error in do_memory_save\n");
+goto exit;
+}
 addr += l;
 size -= l;
 }
+exit:
 fclose(f);
 }

@@ -1347,11 +1351,15 @@ static void do_physical_memory_save(Monitor *mon, const 
QDict *qdict,
 if (l > size)
 l = size;
 cpu_physical_memory_rw(addr, buf, l, 0);
-fwrite(buf, 1, l, f);
+if (fwrite(buf, 1, l, f) != l) {
+monitor_printf(mon, "fwrite() error in do_physical_memory_save\n");
+goto exit;
+}
 fflush(f);
 addr += l;
 size -= l;
 }
+exit:
 fclose(f);
 }

-- 
1.6.5.2





[Qemu-devel] [PATCH 13/17] linux-user/mmap.c: fix warnings with _FORTIFY_SOURCE

2010-01-19 Thread Juan Quintela
From: Kirill A. Shutemov 

CCi386-linux-user/mmap.o
cc1: warnings being treated as errors
/usr/src/RPM/BUILD/qemu-0.11.92/linux-user/mmap.c: In function 'mmap_frag':
/usr/src/RPM/BUILD/qemu-0.11.92/linux-user/mmap.c:253: error: ignoring return 
value of 'pread', declared with attribute warn_unused_result
/usr/src/RPM/BUILD/qemu-0.11.92/linux-user/mmap.c: In function 'target_mmap':
/usr/src/RPM/BUILD/qemu-0.11.92/linux-user/mmap.c:477: error: ignoring return 
value of 'pread', declared with attribute warn_unused_result
make[1]: *** [mmap.o] Error 1

Signed-off-by: Kirill A. Shutemov 
Signed-off-by: Juan Quintela 
---
 linux-user/mmap.c |6 --
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/linux-user/mmap.c b/linux-user/mmap.c
index 144fb7c..c1c7e48 100644
--- a/linux-user/mmap.c
+++ b/linux-user/mmap.c
@@ -250,7 +250,8 @@ static int mmap_frag(abi_ulong real_start,
 mprotect(host_start, qemu_host_page_size, prot1 | PROT_WRITE);

 /* read the corresponding file data */
-pread(fd, g2h(start), end - start, offset);
+if (pread(fd, g2h(start), end - start, offset) == -1)
+return -1;

 /* put final protection */
 if (prot_new != (prot1 | PROT_WRITE))
@@ -474,7 +475,8 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int 
prot,
   -1, 0);
 if (retaddr == -1)
 goto fail;
-pread(fd, g2h(start), len, offset);
+if (pread(fd, g2h(start), len, offset) == -1)
+goto fail;
 if (!(prot & PROT_WRITE)) {
 ret = target_mprotect(start, len, prot);
 if (ret != 0) {
-- 
1.6.5.2





[Qemu-devel] [PATCH 14/17] check pipe() return value

2010-01-19 Thread Juan Quintela

Signed-off-by: Juan Quintela 
---
 hw/xen_domainbuild.c |   13 +
 1 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/hw/xen_domainbuild.c b/hw/xen_domainbuild.c
index 20d731d..2f59856 100644
--- a/hw/xen_domainbuild.c
+++ b/hw/xen_domainbuild.c
@@ -156,15 +156,18 @@ quit:
 return;
 }

-static void xen_domain_watcher(void)
+static int xen_domain_watcher(void)
 {
 int qemu_running = 1;
 int fd[2], i, n, rc;
 char byte;

-pipe(fd);
+if (pipe(fd) != 0) {
+qemu_log("%s: Huh? pipe error: %s\n", __FUNCTION__, strerror(errno));
+return -1;
+}
 if (fork() != 0)
-return; /* not child */
+return 0; /* not child */

 /* close all file handles, except stdio/out/err,
  * our watch pipe and the xen interface handle */
@@ -238,7 +241,9 @@ int xen_domain_build_pv(const char *kernel, const char 
*ramdisk,
 }
 qemu_log("xen: created domain %d\n", xen_domid);
 atexit(xen_domain_cleanup);
-xen_domain_watcher();
+if (xen_domain_watcher() == -1) {
+goto err;
+}

 xenstore_domain_init1(kernel, ramdisk, cmdline);

-- 
1.6.5.2





[Qemu-devel] [PATCH 15/17] Enable _FORTIFY_SOURCE=2

2010-01-19 Thread Juan Quintela
From: Kirill A. Shutemov 

_FORTIFY_SOURCE is a Glibc feature which adds memory and string function
protection.

Signed-off-by: Kirill A. Shutemov 
Signed-off-by: Juan Quintela 
---
 configure |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/configure b/configure
index 5631bbb..5556b9d 100755
--- a/configure
+++ b/configure
@@ -97,7 +97,7 @@ CFLAGS="-g $CFLAGS"
 QEMU_CFLAGS="-Wall -Wundef -Wendif-labels -Wwrite-strings -Wmissing-prototypes 
$QEMU_CFLAGS"
 QEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
 QEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE 
$QEMU_CFLAGS"
-QEMU_CFLAGS="-U_FORTIFY_SOURCE $QEMU_CFLAGS"
+QEMU_CFLAGS="-D_FORTIFY_SOURCE=2 $QEMU_CFLAGS"
 QEMU_CFLAGS="-I. -I\$(SRC_PATH) $QEMU_CFLAGS"
 LDFLAGS="-g $LDFLAGS"

-- 
1.6.5.2





[Qemu-devel] [PATCH 16/17] Check availavility of -fstack-protector-all

2010-01-19 Thread Juan Quintela
Signed-off-by: Juan Quintela 
---
 configure |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/configure b/configure
index 5556b9d..d8af978 100755
--- a/configure
+++ b/configure
@@ -101,7 +101,7 @@ QEMU_CFLAGS="-D_FORTIFY_SOURCE=2 $QEMU_CFLAGS"
 QEMU_CFLAGS="-I. -I\$(SRC_PATH) $QEMU_CFLAGS"
 LDFLAGS="-g $LDFLAGS"

-gcc_flags="-Wold-style-declaration -Wold-style-definition"
+gcc_flags="-Wold-style-declaration -Wold-style-definition 
-fstack-protector-all"
 cat > $TMPC << EOF
 int main(void) { }
 EOF
-- 
1.6.5.2





[Qemu-devel] [PATCH 17/17] mmap_frag() users only check for -1 error

2010-01-19 Thread Juan Quintela
Signed-off-by: Juan Quintela 
---
 linux-user/mmap.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/linux-user/mmap.c b/linux-user/mmap.c
index c1c7e48..25fc0b2 100644
--- a/linux-user/mmap.c
+++ b/linux-user/mmap.c
@@ -243,7 +243,7 @@ static int mmap_frag(abi_ulong real_start,
possible while it is a shared mapping */
 if ((flags & MAP_TYPE) == MAP_SHARED &&
 (prot & PROT_WRITE))
-return -EINVAL;
+return -1;

 /* adjust protection to be able to read */
 if (!(prot1 & PROT_WRITE))
-- 
1.6.5.2





[Qemu-devel] Re: [PATCH 01/14] Introduce qemu_write_full()

2010-01-19 Thread Juan Quintela
Anthony Liguori  wrote:
> On 01/19/2010 06:17 AM, Kirill A. Shutemov wrote:
>> On Tue, Jan 19, 2010 at 2:11 PM, Juan Quintela  wrote:
>>
>>> "Kirill A. Shutemov"  wrote:
>>>  
 A variant of write(2) which handles partial write.

 Signed-off-by: Kirill A. Shutemov

>>> Hi
>>>
>>> Have you updated this series?  Is there any reason that you know when
>>> they haven't been picked?
>>>  
>> I don't  know any reason, but I'm going to review it once again.
>>
>> I also have plan to get rid of -fno-strict-aliasing where it's possible.
>>
>
> I haven't reviewed the series in detail, but generally speaking I
> don't feel that good about these sort of series.
>
> You're essentially adding dummy error handling to quiet the compiler.
> That's worse than just disabling -Werror because at least you aren't
> losing the information in the code.
>
> If you're going to update error handling, it should be part of an
> effort to make code paths resilient to error.  IOW, actually audit the
> full error path of the function and make it deal with errors
> gracefully.

I reviewed his series, and I reviewed callers.  Please take a look at my
improved series.  Appart for the comments added there, I don't know what
to do here:

@@ -501,8 +501,11 @@ static void aio_signal_handler(int signum)
 {
 if (posix_aio_state) {
 char byte = 0;
+ssize_t ret;

-write(posix_aio_state->wfd, &byte, sizeof(byte));
+ret = write(posix_aio_state->wfd, &byte, sizeof(byte));
+if (ret < 0 && errno != EAGAIN)
+die("write()");
 }

if write() fails in a pipe in the signal handler, I am at a lost about
what to do here.

For the rest, I think that I did the proper error path handling.

Thanks, Juan.




Re: [Qemu-devel] [PATCH] Add definitions for current cpu models..

2010-01-19 Thread Chris Wright
* Anthony Liguori (anth...@codemonkey.ws) wrote:
> On 01/19/2010 02:03 PM, Chris Wright wrote:
>> * Anthony Liguori (anth...@codemonkey.ws) wrote:
>>
>>> I'm very much against having -cpu Nehalem.  The whole point of this is
>>> to make things easier for a user and for most of the users I've
>>> encountered, -cpu Nehalem is just as obscure as -cpu
>>> qemu64,-sse3,+vmx,...
>>>  
>> What name will these users know?  FWIW, it makes sense to me as it is.
>
> Whatever is in /proc/cpuinfo.

That doesn't exactly generalize to families w/ similar cpuid features.

Intel(R) Xeon(R) {E,L,X}{74,55}**
Intel(R) Core(TM)2 {Duo,Quad,Extreme} ...

thanks,
-chris




Re: [Qemu-devel] [PATCH 01/17] Introduce qemu_write_full()

2010-01-19 Thread malc
On Wed, 20 Jan 2010, Juan Quintela wrote:

> From: Kirill A. Shutemov 
> 
> A variant of write(2) which handles partial write.
> 
> Signed-off-by: Kirill A. Shutemov 
> Signed-off-by: Juan Quintela 
> ---
>  osdep.c   |   27 +++
>  qemu-common.h |1 +
>  2 files changed, 28 insertions(+), 0 deletions(-)
> 
> diff --git a/osdep.c b/osdep.c
> index 1310684..09fbc99 100644
> --- a/osdep.c
> +++ b/osdep.c
> @@ -243,6 +243,33 @@ int qemu_open(const char *name, int flags, ...)
>  return ret;
>  }
> 
> +/*
> + * A variant of write(2) which handles partial write.
> + *
> + * Return the number of bytes transferred.
> + * Set errno if fewer than `count' bytes are written.
> + */
> +ssize_t qemu_write_full(int fd, const void *buf, size_t count)
> +{
> +ssize_t ret = 0;
> +ssize_t total = 0;
> +
> +while (count) {
> +ret = write(fd, buf, count);
> +if (ret < 0) {
> +if (errno == EINTR)
> +continue;
> +break;
> +}
> +
> +count -= ret;
> +buf += ret;

Constraint violation (6.5.6)

> +total += ret;
> +}
> +
> +return total;
> +}
> +
>  #ifndef _WIN32
>  /*
>   * Creates a pipe with FD_CLOEXEC set on both file descriptors
> diff --git a/qemu-common.h b/qemu-common.h
> index 8630f8c..a8144cb 100644
> --- a/qemu-common.h
> +++ b/qemu-common.h
> @@ -160,6 +160,7 @@ void qemu_mutex_lock_iothread(void);
>  void qemu_mutex_unlock_iothread(void);
> 
>  int qemu_open(const char *name, int flags, ...);
> +ssize_t qemu_write_full(int fd, const void *buf, size_t count);
>  void qemu_set_cloexec(int fd);
> 
>  #ifndef _WIN32
> 

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




  1   2   >