Re: [Qemu-devel] Boot order problem

2011-07-23 Thread Gleb Natapov
On Fri, Jul 22, 2011 at 09:51:16AM +0900, Minoru Usui wrote:
> Hi, everyone
> 
> I'm in trouble about boot order of VM.
> If anyone know cause of this problem, please let me know.
> 
The cause of the "problem" is the design. booindex and -boot only
modifies the order in which bios will search for bootable device.
It does not exclude devices from a boot device list.
 
> On following environment, I tried to boot from IDE CD-ROM device 
> without inserting any bootable media, which is expected to fail,
> but VM was booting up from virtio HDD which was not specified as bootable 
> device.
> 
>   * host : RHEL6.1(x86_64)
> guest: RHEL6.1(x86_64)
>   * VM has IDE CD-ROM and virtio HDD.
>   * There is no bootable media in IDE CD-ROM.
>   * RHEL6.1 is installed in virtio HDD
>   * Only IDE CD-ROM was spcified as bootable device.
>   * XML configuration of libvirt is below.
> I tested  and  setting,
> but both are booting up from virtio HDD.
> ---
> [ setting version]
>   
> hvm
> 
> 
>   
> 
> [ setting version]
>
>  
>  
>  
>  
>  
>
> ---
> 
> I installed latest qemu-kvm to /usr/local/qemu, and replaced
> /usr/libexec/qemu-kvm to /user/local/qemu/bin/qemu-system-x86_64,
> but it was booting up from virtio HDD.
> 
> On RHEL6.0 host, I tested  setting version, 
> VM didn't boot up from virtio HDD.
> it cannot boot up from CD-ROM. (expected behaviour)
> 
This is not expected behaviour. Expected behaviour is VM boots from HDD.
The only way I can explain behaviour you describe above is that the bios
you are using for RHEL6.0 rpm does not support booting from virtio HDD.
You can test this but making HDD to be ide and retry your test.

> I checked qemu-kvm option by ps command,
> but I think correct -boot or bootindex of -device option is specified.
> 
> [ setting version(RHEL6.1 host)]
> qemu  9871 1 74 16:22 ?00:00:25 /usr/libexec/qemu-kvm -S -M 
> rhel6.1.0 -enable-kvm -m 2048
>  -smp 8,sockets=8,cores=1,threads=1 -name RHEL6.1-GA -uuid 
> 49703959-f0b0-9864-5788-4bc07028bac4 -nodefconfig
>  -nodefaults -chardev 
> socket,id=charmonitor,path=/var/lib/libvirt/qemu/RHEL6.1-GA.monitor,server,nowait
>  
>  -mon chardev=charmonitor,id=monitor,mode=readline -rtc base=utc -boot 
> order=d,menu=off
>  -drive 
> file=/work/libvirt/images/RHEL6.1GA_x86_64_full_file.img,if=none,id=drive-virtio-disk0,format=qcow2,cache=none,aio=threads
>  -device 
> virtio-blk-pci,bus=pci.0,addr=0x5,drive=drive-virtio-disk0,id=virtio-disk0
>  -drive 
> file=/tmp/not_bootable_image.iso,if=none,media=cdrom,id=drive-ide0-1-0,readonly=on,format=raw
>  -device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0
>  -device 
> virtio-net-pci,vlan=0,id=net0,mac=52:54:00:0b:68:82,bus=pci.0,addr=0x3 -net 
> tap,fd=21,vlan=0,name=hostnet0
>  -chardev pty,id=charserial0 -device 
> isa-serial,chardev=charserial0,id=serial0 -usb -device usb-tablet,id=input0
>  -vnc 127.0.0.1:0 -vga cirrus -device intel-hda,id=sound0,bus=pci.0,addr=0x4
>  -device hda-duplex,id=sound0-codec0,bus=sound0.0,cad=0 -device 
> virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x6
> 
>   -> "-boot order=d" is specified
> 
> 
> [ setting version(RHEL6.1 host)]
> qemu  4073 1 23 10:08 ?00:00:37 /usr/libexec/qemu-kvm -S -M 
> rhel6.1.0 -enable-kvm -m 2048
>  -smp 8,sockets=8,cores=1,threads=1 -name RHEL6.1-GA -uuid 
> 49703959-f0b0-9864-5788-4bc07028bac4 -nodefconfig -nodefaults -chardev 
> socket,id=charmonitor,path=/var/lib/libvirt/qemu/RHEL6.1-GA.monitor,server,nowait
>  -mon chardev=charmonitor,id=monitor,mode=readline -rtc base=utc -drive 
> file=/work/libvirt/images/RHEL6.1GA_x86_64_full_file.img,if=none,id=drive-virtio-disk0,format=qcow2,cache=none,aio=threads
>  -device 
> virtio-blk-pci,bus=pci.0,addr=0x5,drive=drive-virtio-disk0,id=virtio-disk0
>  -drive if=none,media=cdrom,id=drive-ide0-1-0,readonly=on,format=raw
>  -device 
> ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0,bootindex=1
>  -device 
> virtio-net-pci,vlan=0,id=net0,mac=52:54:00:0b:68:82,bus=pci.0,addr=0x3 -net 
> tap,fd=21,vlan=0,name=hostnet0
>  -chardev pty,id=charserial0 -device 
> isa-serial,chardev=charserial0,id=serial0 -usb -device usb-tablet,id=input0
>  -vnc 127.0.0.1:0 -vga cirrus -device intel-hda,id=sound0,bus=pci.0,addr=0x4
>  -device hda-duplex,id=sound0-codec0,bus=sound0.0,cad=0 -device 
> virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x6
> 
>   -> "bootindex=1" is specified for IDE CD-ROM device only.
> 
> 
> Next, I suspected seabios, but it was same version of RHEL6.0 and RHEL6.1.
> 
>   # rpm -q seabios
>   seabios-0.6.1.2-3.el6.x86_64
> 
This bios supports booting from virtio and when I do the same test as
you, qemu boots from virtio HDD. Try to reinstall seabios rpm.

> What causes this problem?
> -- 
> Minoru Usui 

--
   

Re: [Qemu-devel] [PATCH 2/3] slirp: fix warning on mingw32

2011-07-23 Thread Stefan Weil

Am 24.07.2011 00:23, schrieb Anthony Liguori:

On 07/23/2011 04:25 PM, Blue Swirl wrote:

Avoid this warning:
   CCslirp/ip_icmp.o
/src/qemu/slirp/ip_icmp.c: In function 'icmp_receive':
/src/qemu/slirp/ip_icmp.c:418:5: error: passing argument 2 of 'recv'
from incompatible pointer type [-Werror]
/usr/local/lib/gcc/i686-mingw32msvc/4.6.0/../../../../i686-mingw32msvc/include/winsock2.h:547:32: 


note: expected 'char *' but argument is of type 'struct icmp *'

Signed-off-by: Blue Swirl
---
  slirp/ip_icmp.c |2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/slirp/ip_icmp.c b/slirp/ip_icmp.c
index 14a5312..a208648 100644
--- a/slirp/ip_icmp.c
+++ b/slirp/ip_icmp.c
@@ -415,7 +415,7 @@ void icmp_receive(struct socket *so)
  icp = mtod(m, struct icmp *);

  id = icp->icmp_id;
-len = recv(so->s, icp, m->m_len, 0);
+len = recv(so->s, (char *)icp, m->m_len, 0);


(char *) is wrong.  recv() takes a void *.

Maybe we need to introduce a qemu_recv?

Regards,

Anthony Liguori


Microsoft's recv() takes a char *.
Both (char *)icp and (void *)icp should work here for any host.

I suggest adding a comment:
/* Type cast needed for MinGW recv. */

Regards,

Stefan Weil




Re: [Qemu-devel] QEMU 0.15.0-rc0, stable-0.15, and QEMU 1.0

2011-07-23 Thread Bruce Rogers
 >>> On 7/23/2011 at 11:15 AM, Anthony Liguori  wrote: 
> Hi,
> 
> I've forked off the stable branch and tagged qemu-0.15.0-rc0 in the 
> master repository.  Please begin explicitly marking patches meant for 
> stable as [STABLE] and CC Justin.
> 
> The stable tree for this release is located at:
> 
> git://git.qemu.org/qemu-stable-0.15.git
> 
> That means the tree is now open for the next release.  In the spirit of 
> the Linux 3.0 release, I think it's only appropriate for our next 
> release to be 1.0.
> 
> I think we would still use an x.y.z versioning convention but would want 
> to do a 2.0 in the next couple years.
> 
> Regards,
> 
> Anthony Liguori

Great! Thanks for making this happen and for all your hard work.

We're excited to put 0.15 to good use.

Bruce




Re: [Qemu-devel] [PATCH v4] hw/pc: Support system flash memory with -pflash parameter

2011-07-23 Thread Anthony Liguori

On 07/23/2011 07:18 PM, Jordan Justen wrote:

In terms of other flash devices, I don't think it's that simple.  Flash is
tied to the mobo layout so I don't think index>  0 really makes sense unless
you allow a specific mapping address.  I doubt that's terribly useful.


I think VM's have a different situation than real hardware.  I'm not
sure an all ROM or all flash decision will work well for qemu.  In
most cases it may work better to make a ROM image available just below
4GB, and add a flash image below this ROM.

This allows the qemu's firmware to be updated as usual in
${prefix}/share/bios.bin, but still allows a flash memory to be
available below this.  (The flash below the ROM could be used only for
storing UEFI variables.)

Otherwise when a new qemu is released along with a new firmware image,
the VM instance using writable flash will continue to use the old
firmware image.


Yes, that's a feature.

We could have a second nvram for other purposes of course.  That could 
be defined as index=1.


Regards,

Anthony Liguori



Re: [Qemu-devel] [PATCH v4] hw/pc: Support system flash memory with -pflash parameter

2011-07-23 Thread Jordan Justen
On Sat, Jul 23, 2011 at 15:26, Anthony Liguori  wrote:
> On 07/23/2011 05:06 PM, Jordan Justen wrote:
>>
>> On Sat, Jul 23, 2011 at 14:25, Anthony Liguori
>>  wrote:
>>>
>>> On 07/23/2011 03:19 PM, Jordan Justen wrote:

 On Sat, Jul 23, 2011 at 08:51, Anthony Liguori
  wrote:
>
> On 07/08/2011 02:37 PM, Jordan Justen wrote:
>>
>> If -pflash is specified and -bios is specified then pflash will
>> be mapped just below the system rom using hw/pflash_cfi01.c.
>>
>> If -pflash is specified on the command line, but -bios is
>> not specified, then 'bios.bin' will NOT be loaded, and
>> instead the -pflash flash image will be mapped just below
>> 4GB in place of the normal rom image.
>
> This is way too tied to the pc platform to be this generic.
>
> I think a better approach would be to default to having unit=0 of
> IF_PFLASH
> default to a read-only BDS that points to bios.bin.  -bios would just
> be
> a
> short cut to use a different file name but you should be able to
> override
> with -drive too.
>
> And to really simplify things, you could add a readonly flag to -bios
> such
> that you could do:
>
> -bios foo.img,readonly=off
>
> Which is what I think you're looking for semantically.

 There seemed to be some feedback on the list interested in preserving
 a read-only firmware, and just adding a flash region.

 So, for example, the firmware could be read from a common system
 location like is generally done with bios.bin today, and VM instance
 specific flash region could still be added.
>>>
>>> You can have multiple flash regions.
>>
>> So, is your recommendation that we support N pflash images in
>> x86/x86-64?  Instance/index 0 is mapped just under 4GB, and the rest
>> follow below this?
>
> No.  There should be a flash device, pflash index 0 is fine, but it should
> be mapped under 4GB and also in the legacy BIOS space.
>
> This is the PC firmware flash.  By default it should be read-only and it
> should be created by using ${prefix}/share/bios.bin.  But it should be
> possible to override both the filename and the read-only flag.
>
> In terms of other flash devices, I don't think it's that simple.  Flash is
> tied to the mobo layout so I don't think index > 0 really makes sense unless
> you allow a specific mapping address.  I doubt that's terribly useful.

I think VM's have a different situation than real hardware.  I'm not
sure an all ROM or all flash decision will work well for qemu.  In
most cases it may work better to make a ROM image available just below
4GB, and add a flash image below this ROM.

This allows the qemu's firmware to be updated as usual in
${prefix}/share/bios.bin, but still allows a flash memory to be
available below this.  (The flash below the ROM could be used only for
storing UEFI variables.)

Otherwise when a new qemu is released along with a new firmware image,
the VM instance using writable flash will continue to use the old
firmware image.

-Jordan

>
> Regards,
>
> Anthony Liguori
>
>>
>> This seems like a good plan, although I can't see a usage for more
>> than 2 instances.
>>
>> -Jordan
>>
>>> You're introducing two modes.  In one mode, we emulate a flash device and
>>> expose it for the BIOS ROM.  In the second mode, we don't emulate a
>>> device
>>> but we expose the BIOS ROM based on a file in a shared read-only
>>> location.
>>>
>>> I'm suggesting always emulating a flash device, but by default make the
>>> device read-only and have it be loaded from a file in a shared read-only
>>> location.
>>>
>>> That means we have a single code path and a consistent view from a
>>> management tooling perspective.  IOW, management tools will always see
>>> that
>>> there is a BIOS block device, and they need to worry about making sure
>>> that
>>> BIOS block device is there.
>>>

 If the entire firmware is moved to a separate VM instance specific
 flash, then firmware update also gets complicated.  It is no longer
 just a matter of updating the qemu firmware package in your distro's
 package management system.
>>>
>>> I think the bit your misunderstanding is that you should default the
>>> firmware to be created from a common file as a read-only device.
>>>
>>> Regards,
>>>
>>> Anthony Liguori
>>>

 What about taking your idea, but adding a second drive that would be
 mapped just below the 1st if it is specified with -drive?

 Thanks,

 -Jordan

>
> Regards,
>
> Anthony Liguori
>
>>
>> Signed-off-by: Jordan Justen
>> Reviewed-by: Aurelien Jarno
>
>
>
>> ---
>>  default-configs/i386-softmmu.mak   |    1 +
>>  default-configs/x86_64-softmmu.mak |    1 +
>>  hw/pc.c                            |  161
>> +++-
>>  3 files changed, 125 insertions(+), 38 deletions(-)
>>
>> diff --

[Qemu-devel] [PATCH] guest agent: add --enable-guest-agent config option

2011-07-23 Thread Michael Roth
QAPI will require glib/python, but for now the guest agent is the only
user. For now, make these dependencies an explicit guest agent one, and
gives users the option to disable it if need be.

Once QAPI is adopted in core QEMU code, we would basically revert this
patch.

Signed-off-by: Michael Roth 
---
 configure |   36 +---
 1 files changed, 25 insertions(+), 11 deletions(-)

diff --git a/configure b/configure
index c0cb979..fa32274 100755
--- a/configure
+++ b/configure
@@ -179,6 +179,7 @@ smartcard=""
 smartcard_nss=""
 usb_redir=""
 opengl=""
+guest_agent="yes"
 
 # parse CC options first
 for opt do
@@ -749,6 +750,10 @@ for opt do
   ;;
   --enable-usb-redir) usb_redir="yes"
   ;;
+  --enable-guest-agent) guest_agent="yes"
+  ;;
+  --disable-guest-agent) guest_agent="no"
+  ;;
   --python-path=*) python_path="$optarg"
   ;;
   *) echo "ERROR: unknown option $opt"; show_help="yes"
@@ -1028,6 +1033,8 @@ echo "  --disable-smartcard-nss  disable smartcard nss 
support"
 echo "  --enable-smartcard-nss   enable smartcard nss support"
 echo "  --disable-usb-redir  disable usb network redirection support"
 echo "  --enable-usb-redir   enable usb network redirection support"
+echo "  --disable-guest-agentdisable building of the QEMU Guest Agent"
+echo "  --enable-guest-agent enable building of the QEMU Guest Agent"
 echo "  --python-path=PATH   path to python executable"
 echo ""
 echo "NOTE: The object files are built at the place where configure is 
launched"
@@ -1815,21 +1822,25 @@ fi
 
 ##
 # python probe
-if ! $python_path -V >/dev/null 2>&1; then
-echo "python executable not found: $python_path. You can specify with 
--python-path"
-exit 1
+if test "$guest_agent" != "no" ; then
+if ! $python_path -V >/dev/null 2>&1; then
+echo "python executable not found: $python_path. You can specify with 
--python-path"
+exit 1
+fi
 fi
 
 ##
 # glib support probe
-if $pkg_config --modversion gthread-2.0 gio-2.0 > /dev/null 2>&1 ; then
-glib_cflags=`$pkg_config --cflags gthread-2.0 gio-2.0 2>/dev/null`
-glib_libs=`$pkg_config --libs gthread-2.0 gio-2.0 2>/dev/null`
-libs_softmmu="$glib_libs $libs_softmmu"
-libs_tools="$glib_libs $libs_tools"
-else
-echo "glib-2.0 required to compile QEMU"
-exit 1
+if test "$guest_agent" != "no" ; then
+if $pkg_config --modversion gthread-2.0 gio-2.0 > /dev/null 2>&1 ; then
+glib_cflags=`$pkg_config --cflags gthread-2.0 gio-2.0 2>/dev/null`
+glib_libs=`$pkg_config --libs gthread-2.0 gio-2.0 2>/dev/null`
+libs_softmmu="$glib_libs $libs_softmmu"
+libs_tools="$glib_libs $libs_tools"
+else
+echo "glib-2.0 required to compile QEMU"
+exit 1
+fi
 fi
 
 ##
@@ -2566,7 +2577,9 @@ if test "$softmmu" = yes ; then
   tools="qemu-img\$(EXESUF) qemu-io\$(EXESUF) $tools"
   if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" ] ; then
   tools="qemu-nbd\$(EXESUF) $tools"
+if [ "$guest_agent" = "yes" ]; then
   tools="qemu-ga\$(EXESUF) $tools"
+fi
 if [ "$check_utests" = "yes" ]; then
   tools="check-qint check-qstring check-qdict check-qlist $tools"
   tools="check-qfloat check-qjson $tools"
@@ -2666,6 +2679,7 @@ echo "xfsctl support$xfs"
 echo "nss used  $smartcard_nss"
 echo "usb net redir $usb_redir"
 echo "OpenGL support$opengl"
+echo "build guest agent $guest_agent"
 echo "python path   $python_path"
 
 if test $sdl_too_old = "yes"; then
-- 
1.7.0.4




[Qemu-devel] [PATCH] qapi: check for python, allow path to be specified

2011-07-23 Thread Michael Roth
QAPI requires python to generate code. Check for python during
configuration and allow python to be specified manually.

Signed-off-by: Michael Roth 
---
 Makefile  |   12 ++--
 configure |   13 +
 2 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/Makefile b/Makefile
index f3a03ad..daa3aa0 100644
--- a/Makefile
+++ b/Makefile
@@ -168,22 +168,22 @@ test-visitor.o test-qmp-commands.o qemu-ga$(EXESUF): 
QEMU_CFLAGS += -I $(qapi-di
 
 $(qapi-dir)/test-qapi-types.c: $(qapi-dir)/test-qapi-types.h
 $(qapi-dir)/test-qapi-types.h: $(SRC_PATH)/qapi-schema-test.json 
$(SRC_PATH)/scripts/qapi-types.py
-   $(call quiet-command,python $(SRC_PATH)/scripts/qapi-types.py -o 
"$(qapi-dir)" -p "test-" < $<, "  GEN   $@")
+   $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-types.py -o 
"$(qapi-dir)" -p "test-" < $<, "  GEN   $@")
 $(qapi-dir)/test-qapi-visit.c: $(qapi-dir)/test-qapi-visit.h
 $(qapi-dir)/test-qapi-visit.h: $(SRC_PATH)/qapi-schema-test.json 
$(SRC_PATH)/scripts/qapi-visit.py
-   $(call quiet-command,python $(SRC_PATH)/scripts/qapi-visit.py -o 
"$(qapi-dir)" -p "test-" < $<, "  GEN   $@")
+   $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-visit.py -o 
"$(qapi-dir)" -p "test-" < $<, "  GEN   $@")
 $(qapi-dir)/test-qmp-commands.h: $(qapi-dir)/test-qmp-marshal.c
 $(qapi-dir)/test-qmp-marshal.c: $(SRC_PATH)/qapi-schema-test.json 
$(SRC_PATH)/scripts/qapi-commands.py
-   $(call quiet-command,python $(SRC_PATH)/scripts/qapi-commands.py -o 
"$(qapi-dir)" -p "test-" < $<, "  GEN   $@")
+   $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-commands.py 
-o "$(qapi-dir)" -p "test-" < $<, "  GEN   $@")
 
 $(qapi-dir)/qga-qapi-types.c: $(qapi-dir)/qga-qapi-types.h
 $(qapi-dir)/qga-qapi-types.h: $(SRC_PATH)/qapi-schema-guest.json 
$(SRC_PATH)/scripts/qapi-types.py
-   $(call quiet-command,python $(SRC_PATH)/scripts/qapi-types.py -o 
"$(qapi-dir)" -p "qga-" < $<, "  GEN   $@")
+   $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-types.py -o 
"$(qapi-dir)" -p "qga-" < $<, "  GEN   $@")
 $(qapi-dir)/qga-qapi-visit.c: $(qapi-dir)/qga-qapi-visit.h
 $(qapi-dir)/qga-qapi-visit.h: $(SRC_PATH)/qapi-schema-guest.json 
$(SRC_PATH)/scripts/qapi-visit.py
-   $(call quiet-command,python $(SRC_PATH)/scripts/qapi-visit.py -o 
"$(qapi-dir)" -p "qga-" < $<, "  GEN   $@")
+   $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-visit.py -o 
"$(qapi-dir)" -p "qga-" < $<, "  GEN   $@")
 $(qapi-dir)/qga-qmp-marshal.c: $(SRC_PATH)/qapi-schema-guest.json 
$(SRC_PATH)/scripts/qapi-commands.py
-   $(call quiet-command,python $(SRC_PATH)/scripts/qapi-commands.py -o 
"$(qapi-dir)" -p "qga-" < $<, "  GEN   $@")
+   $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-commands.py -o 
"$(qapi-dir)" -p "qga-" < $<, "  GEN   $@")
 
 test-visitor.o: $(addprefix $(qapi-dir)/, test-qapi-types.c test-qapi-types.h 
test-qapi-visit.c test-qapi-visit.h) $(qapi-obj-y)
 test-visitor: test-visitor.o qfloat.o qint.o qdict.o qstring.o qlist.o qbool.o 
$(qapi-obj-y) error.o osdep.o qemu-malloc.o $(oslib-obj-y) qjson.o 
json-streamer.o json-lexer.o json-parser.o qerror.o qemu-error.o qemu-tool.o 
$(qapi-dir)/test-qapi-visit.o $(qapi-dir)/test-qapi-types.o
diff --git a/configure b/configure
index 6911c3b..c0cb979 100755
--- a/configure
+++ b/configure
@@ -225,6 +225,7 @@ strip="${cross_prefix}${STRIP-strip}"
 windres="${cross_prefix}${WINDRES-windres}"
 pkg_config="${cross_prefix}${PKG_CONFIG-pkg-config}"
 sdl_config="${cross_prefix}${SDL_CONFIG-sdl-config}"
+python_path="${cross_prefix}${PYTHON_PATH-python}"
 
 # default flags for all hosts
 QEMU_CFLAGS="-fno-strict-aliasing $QEMU_CFLAGS"
@@ -748,6 +749,8 @@ for opt do
   ;;
   --enable-usb-redir) usb_redir="yes"
   ;;
+  --python-path=*) python_path="$optarg"
+  ;;
   *) echo "ERROR: unknown option $opt"; show_help="yes"
   ;;
   esac
@@ -1025,6 +1028,7 @@ echo "  --disable-smartcard-nss  disable smartcard nss 
support"
 echo "  --enable-smartcard-nss   enable smartcard nss support"
 echo "  --disable-usb-redir  disable usb network redirection support"
 echo "  --enable-usb-redir   enable usb network redirection support"
+echo "  --python-path=PATH   path to python executable"
 echo ""
 echo "NOTE: The object files are built at the place where configure is 
launched"
 exit 1
@@ -1810,6 +1814,13 @@ EOF
 fi
 
 ##
+# python probe
+if ! $python_path -V >/dev/null 2>&1; then
+echo "python executable not found: $python_path. You can specify with 
--python-path"
+exit 1
+fi
+
+##
 # glib support probe
 if $pkg_config --modversion gthread-2.0 gio-2.0 > /dev/null 2>&1 ; then
 glib_cflags=`$pkg_config --cflags gthread-2.0 gio-2.0 2>/dev/null`
@@ -2655,6 +2666,7 @@ echo "xfsctl support$xfs"
 echo "nss used  $smartcard_nss"
 echo "usb net redir $usb_redir"
 echo "OpenGL support$opengl"
+

Re: [Qemu-devel] [PATCH 2/2] guest-agent: only enable FSFREEZE when it's supported by the kernel

2011-07-23 Thread Michael Roth

On 07/23/2011 04:26 PM, Anthony Liguori wrote:

Signed-off-by: Anthony Liguori
---
  qga/guest-agent-commands.c |   12 +++-
  1 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/qga/guest-agent-commands.c b/qga/guest-agent-commands.c
index 624972e..30c4068 100644
--- a/qga/guest-agent-commands.c
+++ b/qga/guest-agent-commands.c
@@ -10,15 +10,17 @@
   * See the COPYING file in the top-level directory.
   */

-#if defined(__linux__)
-#define CONFIG_FSFREEZE
-#endif
-
  #include
-#if defined(CONFIG_FSFREEZE)
+
+#if defined(__linux__)
  #include
  #include
+
+#if defined(__linux__)&&  defined(FIFREEZE)
+#define CONFIG_FSFREEZE
  #endif
+#endif
+
  #include
  #include
  #include "qga/guest-agent-core.h"


Much more sensible that the compile test I was doing :)



Re: [Qemu-devel] [PATCH 1/2] qemu-ga: remove dependency on gio and gthread

2011-07-23 Thread Michael Roth

On 07/23/2011 04:26 PM, Anthony Liguori wrote:

As far as I can tell, there isn't a dependency on gthread.  Also, the only use
of gio was to enable GSocket to accept a unix domain socket.

Since GSocket isn't available on OpenSuSE 11.1, let's just remove that
dependency.

Signed-off-by: Anthony Liguori
---
  configure |6 +++---
  qemu-ga.c |   34 +-
  2 files changed, 12 insertions(+), 28 deletions(-)

diff --git a/configure b/configure
index 6911c3b..600da9b 100755
--- a/configure
+++ b/configure
@@ -1811,9 +1811,9 @@ fi

  ##
  # glib support probe
-if $pkg_config --modversion gthread-2.0 gio-2.0>  /dev/null 2>&1 ; then
-glib_cflags=`$pkg_config --cflags gthread-2.0 gio-2.0 2>/dev/null`
-glib_libs=`$pkg_config --libs gthread-2.0 gio-2.0 2>/dev/null`
+if $pkg_config --modversion glib-2.0>  /dev/null 2>&1 ; then
+glib_cflags=`$pkg_config --cflags glib-2.0 2>/dev/null`
+glib_libs=`$pkg_config --libs glib-2.0 2>/dev/null`
  libs_softmmu="$glib_libs $libs_softmmu"
  libs_tools="$glib_libs $libs_tools"
  else
diff --git a/qemu-ga.c b/qemu-ga.c
index 6e2f61f..5d8b7cf 100644
--- a/qemu-ga.c
+++ b/qemu-ga.c
@@ -14,7 +14,6 @@
  #include
  #include
  #include
-#include
  #include
  #include
  #include
@@ -37,9 +36,8 @@
  struct GAState {
  JSONMessageParser parser;
  GMainLoop *main_loop;
-GSocket *conn_sock;
+int conn_fd;
  GIOChannel *conn_channel;
-GSocket *listen_sock;
  GIOChannel *listen_channel;
  const char *path;
  const char *method;
@@ -412,18 +410,19 @@ static gboolean listen_channel_accept(GIOChannel *channel,
GIOCondition condition, gpointer data)
  {
  GAState *s = data;
-GError *err = NULL;
  g_assert(channel != NULL);
  int ret;
  bool accepted = false;
+struct sockaddr_un addr;
+socklen_t addrlen = sizeof(addr);

-s->conn_sock = g_socket_accept(s->listen_sock, NULL,&err);
-if (err != NULL) {
-g_warning("error converting fd to gsocket: %s", err->message);
-g_error_free(err);
+s->conn_fd = qemu_accept(g_io_channel_unix_get_fd(s->listen_channel),
+ (struct sockaddr *)&addr,&addrlen);
+if (s->conn_fd == -1) {
+g_warning("error converting fd to gsocket: %s", strerror(errno));
  goto out;
  }
-ret = conn_channel_add(s, g_socket_get_fd(s->conn_sock));
+ret = conn_channel_add(s, s->conn_fd);
  if (ret) {
  g_warning("error setting up connection");
  goto out;
@@ -440,19 +439,8 @@ out:
   */
  static int listen_channel_add(GAState *s, int listen_fd, bool new)
  {
-GError *err = NULL;
-
  if (new) {
  s->listen_channel = g_io_channel_unix_new(listen_fd);
-if (s->listen_sock) {
-g_object_unref(s->listen_sock);
-}
-s->listen_sock = g_socket_new_from_fd(listen_fd,&err);
-if (err != NULL) {
-g_warning("error converting fd to gsocket: %s", err->message);
-g_error_free(err);
-return -1;
-}
  }
  g_io_add_watch(s->listen_channel, G_IO_IN,
 listen_channel_accept, s);
@@ -466,8 +454,7 @@ static void conn_channel_close(GAState *s)
  {
  if (strcmp(s->method, "unix-listen") == 0) {
  g_io_channel_shutdown(s->conn_channel, true, NULL);
-g_object_unref(s->conn_sock);
-s->conn_sock = NULL;
+s->conn_fd = -1;
  listen_channel_add(s, 0, false);
  } else if (strcmp(s->method, "virtio-serial") == 0) {
  /* we spin on EOF for virtio-serial, so back off a bit. also,
@@ -624,9 +611,6 @@ int main(int argc, char **argv)
  become_daemon(pidfile);
  }

-g_type_init();
-g_thread_init(NULL);
-
  s = qemu_mallocz(sizeof(GAState));
  s->conn_channel = NULL;
  s->path = path;


Was getting hangs when using -m unix-listen. Looks like GSocket must've 
been setting O_NONBLOCK on new connections. Also the conn_sock was only 
part of GAState for cleanup purposes, so we can lose conn_fd. I sent a 
re-spin with these changes as a reply to this patch.




[Qemu-devel] [PATCH] qemu-ga: remove dependency on gio and gthread

2011-07-23 Thread Michael Roth
From: Anthony Liguori 

As far as I can tell, there isn't a dependency on gthread.  Also, the only use
of gio was to enable GSocket to accept a unix domain socket.

Since GSocket isn't available on OpenSuSE 11.1, let's just remove that
dependency.

Signed-off-by: Anthony Liguori 
---
 configure |6 +++---
 qemu-ga.c |   35 +--
 2 files changed, 12 insertions(+), 29 deletions(-)

diff --git a/configure b/configure
index 6911c3b..600da9b 100755
--- a/configure
+++ b/configure
@@ -1811,9 +1811,9 @@ fi
 
 ##
 # glib support probe
-if $pkg_config --modversion gthread-2.0 gio-2.0 > /dev/null 2>&1 ; then
-glib_cflags=`$pkg_config --cflags gthread-2.0 gio-2.0 2>/dev/null`
-glib_libs=`$pkg_config --libs gthread-2.0 gio-2.0 2>/dev/null`
+if $pkg_config --modversion glib-2.0 > /dev/null 2>&1 ; then
+glib_cflags=`$pkg_config --cflags glib-2.0 2>/dev/null`
+glib_libs=`$pkg_config --libs glib-2.0 2>/dev/null`
 libs_softmmu="$glib_libs $libs_softmmu"
 libs_tools="$glib_libs $libs_tools"
 else
diff --git a/qemu-ga.c b/qemu-ga.c
index 6e2f61f..869ee37 100644
--- a/qemu-ga.c
+++ b/qemu-ga.c
@@ -14,7 +14,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -37,9 +36,7 @@
 struct GAState {
 JSONMessageParser parser;
 GMainLoop *main_loop;
-GSocket *conn_sock;
 GIOChannel *conn_channel;
-GSocket *listen_sock;
 GIOChannel *listen_channel;
 const char *path;
 const char *method;
@@ -412,18 +409,20 @@ static gboolean listen_channel_accept(GIOChannel *channel,
   GIOCondition condition, gpointer data)
 {
 GAState *s = data;
-GError *err = NULL;
 g_assert(channel != NULL);
-int ret;
+int ret, conn_fd;
 bool accepted = false;
+struct sockaddr_un addr;
+socklen_t addrlen = sizeof(addr);
 
-s->conn_sock = g_socket_accept(s->listen_sock, NULL, &err);
-if (err != NULL) {
-g_warning("error converting fd to gsocket: %s", err->message);
-g_error_free(err);
+conn_fd = qemu_accept(g_io_channel_unix_get_fd(s->listen_channel),
+ (struct sockaddr *)&addr, &addrlen);
+if (conn_fd == -1) {
+g_warning("error converting fd to gsocket: %s", strerror(errno));
 goto out;
 }
-ret = conn_channel_add(s, g_socket_get_fd(s->conn_sock));
+fcntl(conn_fd, F_SETFL, O_NONBLOCK);
+ret = conn_channel_add(s, conn_fd);
 if (ret) {
 g_warning("error setting up connection");
 goto out;
@@ -440,19 +439,8 @@ out:
  */
 static int listen_channel_add(GAState *s, int listen_fd, bool new)
 {
-GError *err = NULL;
-
 if (new) {
 s->listen_channel = g_io_channel_unix_new(listen_fd);
-if (s->listen_sock) {
-g_object_unref(s->listen_sock);
-}
-s->listen_sock = g_socket_new_from_fd(listen_fd, &err);
-if (err != NULL) {
-g_warning("error converting fd to gsocket: %s", err->message);
-g_error_free(err);
-return -1;
-}
 }
 g_io_add_watch(s->listen_channel, G_IO_IN,
listen_channel_accept, s);
@@ -466,8 +454,6 @@ static void conn_channel_close(GAState *s)
 {
 if (strcmp(s->method, "unix-listen") == 0) {
 g_io_channel_shutdown(s->conn_channel, true, NULL);
-g_object_unref(s->conn_sock);
-s->conn_sock = NULL;
 listen_channel_add(s, 0, false);
 } else if (strcmp(s->method, "virtio-serial") == 0) {
 /* we spin on EOF for virtio-serial, so back off a bit. also,
@@ -624,9 +610,6 @@ int main(int argc, char **argv)
 become_daemon(pidfile);
 }
 
-g_type_init();
-g_thread_init(NULL);
-
 s = qemu_mallocz(sizeof(GAState));
 s->conn_channel = NULL;
 s->path = path;
-- 
1.7.0.4




Re: [Qemu-devel] [PATCH v4] hw/pc: Support system flash memory with -pflash parameter

2011-07-23 Thread Anthony Liguori

On 07/23/2011 05:06 PM, Jordan Justen wrote:

On Sat, Jul 23, 2011 at 14:25, Anthony Liguori  wrote:

On 07/23/2011 03:19 PM, Jordan Justen wrote:


On Sat, Jul 23, 2011 at 08:51, Anthony Liguori
  wrote:


On 07/08/2011 02:37 PM, Jordan Justen wrote:


If -pflash is specified and -bios is specified then pflash will
be mapped just below the system rom using hw/pflash_cfi01.c.

If -pflash is specified on the command line, but -bios is
not specified, then 'bios.bin' will NOT be loaded, and
instead the -pflash flash image will be mapped just below
4GB in place of the normal rom image.


This is way too tied to the pc platform to be this generic.

I think a better approach would be to default to having unit=0 of
IF_PFLASH
default to a read-only BDS that points to bios.bin.  -bios would just be
a
short cut to use a different file name but you should be able to override
with -drive too.

And to really simplify things, you could add a readonly flag to -bios
such
that you could do:

-bios foo.img,readonly=off

Which is what I think you're looking for semantically.


There seemed to be some feedback on the list interested in preserving
a read-only firmware, and just adding a flash region.

So, for example, the firmware could be read from a common system
location like is generally done with bios.bin today, and VM instance
specific flash region could still be added.


You can have multiple flash regions.


So, is your recommendation that we support N pflash images in
x86/x86-64?  Instance/index 0 is mapped just under 4GB, and the rest
follow below this?


No.  There should be a flash device, pflash index 0 is fine, but it 
should be mapped under 4GB and also in the legacy BIOS space.


This is the PC firmware flash.  By default it should be read-only and it 
should be created by using ${prefix}/share/bios.bin.  But it should be 
possible to override both the filename and the read-only flag.


In terms of other flash devices, I don't think it's that simple.  Flash 
is tied to the mobo layout so I don't think index > 0 really makes sense 
unless you allow a specific mapping address.  I doubt that's terribly 
useful.


Regards,

Anthony Liguori



This seems like a good plan, although I can't see a usage for more
than 2 instances.

-Jordan


You're introducing two modes.  In one mode, we emulate a flash device and
expose it for the BIOS ROM.  In the second mode, we don't emulate a device
but we expose the BIOS ROM based on a file in a shared read-only location.

I'm suggesting always emulating a flash device, but by default make the
device read-only and have it be loaded from a file in a shared read-only
location.

That means we have a single code path and a consistent view from a
management tooling perspective.  IOW, management tools will always see that
there is a BIOS block device, and they need to worry about making sure that
BIOS block device is there.



If the entire firmware is moved to a separate VM instance specific
flash, then firmware update also gets complicated.  It is no longer
just a matter of updating the qemu firmware package in your distro's
package management system.


I think the bit your misunderstanding is that you should default the
firmware to be created from a common file as a read-only device.

Regards,

Anthony Liguori



What about taking your idea, but adding a second drive that would be
mapped just below the 1st if it is specified with -drive?

Thanks,

-Jordan



Regards,

Anthony Liguori



Signed-off-by: Jordan Justen
Reviewed-by: Aurelien Jarno





---
  default-configs/i386-softmmu.mak   |1 +
  default-configs/x86_64-softmmu.mak |1 +
  hw/pc.c|  161
+++-
  3 files changed, 125 insertions(+), 38 deletions(-)

diff --git a/default-configs/i386-softmmu.mak
b/default-configs/i386-softmmu.mak
index 55589fa..8697cd4 100644
--- a/default-configs/i386-softmmu.mak
+++ b/default-configs/i386-softmmu.mak
@@ -21,3 +21,4 @@ CONFIG_PIIX_PCI=y
  CONFIG_SOUND=y
  CONFIG_HPET=y
  CONFIG_APPLESMC=y
+CONFIG_PFLASH_CFI01=y
diff --git a/default-configs/x86_64-softmmu.mak
b/default-configs/x86_64-softmmu.mak
index 8895028..eca9284 100644
--- a/default-configs/x86_64-softmmu.mak
+++ b/default-configs/x86_64-softmmu.mak
@@ -21,3 +21,4 @@ CONFIG_PIIX_PCI=y
  CONFIG_SOUND=y
  CONFIG_HPET=y
  CONFIG_APPLESMC=y
+CONFIG_PFLASH_CFI01=y
diff --git a/hw/pc.c b/hw/pc.c
index a3e8539..e25354f 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -41,6 +41,7 @@
  #include "sysemu.h"
  #include "blockdev.h"
  #include "ui/qemu-spice.h"
+#include "flash.h"

  /* output Bochs bios info messages */
  //#define DEBUG_BIOS
@@ -957,70 +958,154 @@ void pc_cpus_init(const char *cpu_model)
  }
  }

-void pc_memory_init(const char *kernel_filename,
-const char *kernel_cmdline,
-const char *initrd_filename,
-ram_addr_t below_4g_mem_size,
-ram_addr_t above_4g_mem_size)
+static void pc_isa_bios_in

Re: [Qemu-devel] [PATCH 2/3] slirp: fix warning on mingw32

2011-07-23 Thread Anthony Liguori

On 07/23/2011 04:25 PM, Blue Swirl wrote:

Avoid this warning:
   CCslirp/ip_icmp.o
/src/qemu/slirp/ip_icmp.c: In function 'icmp_receive':
/src/qemu/slirp/ip_icmp.c:418:5: error: passing argument 2 of 'recv'
from incompatible pointer type [-Werror]
/usr/local/lib/gcc/i686-mingw32msvc/4.6.0/../../../../i686-mingw32msvc/include/winsock2.h:547:32:
note: expected 'char *' but argument is of type 'struct icmp *'

Signed-off-by: Blue Swirl
---
  slirp/ip_icmp.c |2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/slirp/ip_icmp.c b/slirp/ip_icmp.c
index 14a5312..a208648 100644
--- a/slirp/ip_icmp.c
+++ b/slirp/ip_icmp.c
@@ -415,7 +415,7 @@ void icmp_receive(struct socket *so)
  icp = mtod(m, struct icmp *);

  id = icp->icmp_id;
-len = recv(so->s, icp, m->m_len, 0);
+len = recv(so->s, (char *)icp, m->m_len, 0);


(char *) is wrong.  recv() takes a void *.

Maybe we need to introduce a qemu_recv?

Regards,

Anthony Liguori


  icp->icmp_id = id;

  m->m_data -= hlen;





Re: [Qemu-devel] [PATCH v4] hw/pc: Support system flash memory with -pflash parameter

2011-07-23 Thread Jordan Justen
On Sat, Jul 23, 2011 at 14:25, Anthony Liguori  wrote:
> On 07/23/2011 03:19 PM, Jordan Justen wrote:
>>
>> On Sat, Jul 23, 2011 at 08:51, Anthony Liguori
>>  wrote:
>>>
>>> On 07/08/2011 02:37 PM, Jordan Justen wrote:

 If -pflash is specified and -bios is specified then pflash will
 be mapped just below the system rom using hw/pflash_cfi01.c.

 If -pflash is specified on the command line, but -bios is
 not specified, then 'bios.bin' will NOT be loaded, and
 instead the -pflash flash image will be mapped just below
 4GB in place of the normal rom image.
>>>
>>> This is way too tied to the pc platform to be this generic.
>>>
>>> I think a better approach would be to default to having unit=0 of
>>> IF_PFLASH
>>> default to a read-only BDS that points to bios.bin.  -bios would just be
>>> a
>>> short cut to use a different file name but you should be able to override
>>> with -drive too.
>>>
>>> And to really simplify things, you could add a readonly flag to -bios
>>> such
>>> that you could do:
>>>
>>> -bios foo.img,readonly=off
>>>
>>> Which is what I think you're looking for semantically.
>>
>> There seemed to be some feedback on the list interested in preserving
>> a read-only firmware, and just adding a flash region.
>>
>> So, for example, the firmware could be read from a common system
>> location like is generally done with bios.bin today, and VM instance
>> specific flash region could still be added.
>
> You can have multiple flash regions.

So, is your recommendation that we support N pflash images in
x86/x86-64?  Instance/index 0 is mapped just under 4GB, and the rest
follow below this?

This seems like a good plan, although I can't see a usage for more
than 2 instances.

-Jordan

> You're introducing two modes.  In one mode, we emulate a flash device and
> expose it for the BIOS ROM.  In the second mode, we don't emulate a device
> but we expose the BIOS ROM based on a file in a shared read-only location.
>
> I'm suggesting always emulating a flash device, but by default make the
> device read-only and have it be loaded from a file in a shared read-only
> location.
>
> That means we have a single code path and a consistent view from a
> management tooling perspective.  IOW, management tools will always see that
> there is a BIOS block device, and they need to worry about making sure that
> BIOS block device is there.
>
>>
>> If the entire firmware is moved to a separate VM instance specific
>> flash, then firmware update also gets complicated.  It is no longer
>> just a matter of updating the qemu firmware package in your distro's
>> package management system.
>
> I think the bit your misunderstanding is that you should default the
> firmware to be created from a common file as a read-only device.
>
> Regards,
>
> Anthony Liguori
>
>>
>> What about taking your idea, but adding a second drive that would be
>> mapped just below the 1st if it is specified with -drive?
>>
>> Thanks,
>>
>> -Jordan
>>
>>>
>>> Regards,
>>>
>>> Anthony Liguori
>>>

 Signed-off-by: Jordan Justen
 Reviewed-by: Aurelien Jarno
>>>
>>>
>>>
 ---
  default-configs/i386-softmmu.mak   |    1 +
  default-configs/x86_64-softmmu.mak |    1 +
  hw/pc.c                            |  161
 +++-
  3 files changed, 125 insertions(+), 38 deletions(-)

 diff --git a/default-configs/i386-softmmu.mak
 b/default-configs/i386-softmmu.mak
 index 55589fa..8697cd4 100644
 --- a/default-configs/i386-softmmu.mak
 +++ b/default-configs/i386-softmmu.mak
 @@ -21,3 +21,4 @@ CONFIG_PIIX_PCI=y
  CONFIG_SOUND=y
  CONFIG_HPET=y
  CONFIG_APPLESMC=y
 +CONFIG_PFLASH_CFI01=y
 diff --git a/default-configs/x86_64-softmmu.mak
 b/default-configs/x86_64-softmmu.mak
 index 8895028..eca9284 100644
 --- a/default-configs/x86_64-softmmu.mak
 +++ b/default-configs/x86_64-softmmu.mak
 @@ -21,3 +21,4 @@ CONFIG_PIIX_PCI=y
  CONFIG_SOUND=y
  CONFIG_HPET=y
  CONFIG_APPLESMC=y
 +CONFIG_PFLASH_CFI01=y
 diff --git a/hw/pc.c b/hw/pc.c
 index a3e8539..e25354f 100644
 --- a/hw/pc.c
 +++ b/hw/pc.c
 @@ -41,6 +41,7 @@
  #include "sysemu.h"
  #include "blockdev.h"
  #include "ui/qemu-spice.h"
 +#include "flash.h"

  /* output Bochs bios info messages */
  //#define DEBUG_BIOS
 @@ -957,70 +958,154 @@ void pc_cpus_init(const char *cpu_model)
      }
  }

 -void pc_memory_init(const char *kernel_filename,
 -                    const char *kernel_cmdline,
 -                    const char *initrd_filename,
 -                    ram_addr_t below_4g_mem_size,
 -                    ram_addr_t above_4g_mem_size)
 +static void pc_isa_bios_init(ram_addr_t ram_offset, int ram_size)
  {
 -    char *filename;
 -    int ret, linux_boot, i;
 -    ram_addr_t ram_addr, bios_offset, option_rom_offset;
 -    int bios_si

[Qemu-devel] [PATCH 2/2] guest-agent: only enable FSFREEZE when it's supported by the kernel

2011-07-23 Thread Anthony Liguori
Signed-off-by: Anthony Liguori 
---
 qga/guest-agent-commands.c |   12 +++-
 1 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/qga/guest-agent-commands.c b/qga/guest-agent-commands.c
index 624972e..30c4068 100644
--- a/qga/guest-agent-commands.c
+++ b/qga/guest-agent-commands.c
@@ -10,15 +10,17 @@
  * See the COPYING file in the top-level directory.
  */
 
-#if defined(__linux__)
-#define CONFIG_FSFREEZE
-#endif
-
 #include 
-#if defined(CONFIG_FSFREEZE)
+
+#if defined(__linux__)
 #include 
 #include 
+
+#if defined(__linux__) && defined(FIFREEZE)
+#define CONFIG_FSFREEZE
 #endif
+#endif
+
 #include 
 #include 
 #include "qga/guest-agent-core.h"
-- 
1.7.4.1




[Qemu-devel] [PATCH 3/3] simpletrace: suppress a warning from unused variable

2011-07-23 Thread Blue Swirl
Avoid this warning:
  CCsimpletrace.o
/src/qemu/simpletrace.c: In function 'writeout_thread':
/src/qemu/simpletrace.c:122:12: error: variable 'unused' set but not
used [-Werror=unused-but-set-variable]
by adding GCC attribute unused to the variable.

Signed-off-by: Blue Swirl 
---
 simpletrace.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/simpletrace.c b/simpletrace.c
index f1dbb5e..de355e9 100644
--- a/simpletrace.c
+++ b/simpletrace.c
@@ -119,7 +119,7 @@ static void *writeout_thread(void *opaque)
 TraceRecord record;
 unsigned int writeout_idx = 0;
 unsigned int num_available, idx;
-size_t unused;
+size_t unused __attribute__ ((unused));

 for (;;) {
 wait_for_trace_records_available();
-- 
1.6.2.4
From 78719e173f6ffea9154f013221e26724a79d4507 Mon Sep 17 00:00:00 2001
Message-Id: <78719e173f6ffea9154f013221e26724a79d4507.1311456245.git.blauwir...@gmail.com>
In-Reply-To: <8bcd08d1fe7c90869ea6659b6248ace6cf7b1f32.1311456245.git.blauwir...@gmail.com>
References: <8bcd08d1fe7c90869ea6659b6248ace6cf7b1f32.1311456245.git.blauwir...@gmail.com>
From: Blue Swirl 
Date: Sat, 23 Jul 2011 21:21:14 +
Subject: [PATCH 3/3] simpletrace: suppress a warning from unused variable

Avoid this warning:
  CCsimpletrace.o
/src/qemu/simpletrace.c: In function 'writeout_thread':
/src/qemu/simpletrace.c:122:12: error: variable 'unused' set but not used [-Werror=unused-but-set-variable]
by adding GCC attribute unused to the variable.

Signed-off-by: Blue Swirl 
---
 simpletrace.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/simpletrace.c b/simpletrace.c
index f1dbb5e..de355e9 100644
--- a/simpletrace.c
+++ b/simpletrace.c
@@ -119,7 +119,7 @@ static void *writeout_thread(void *opaque)
 TraceRecord record;
 unsigned int writeout_idx = 0;
 unsigned int num_available, idx;
-size_t unused;
+size_t unused __attribute__ ((unused));
 
 for (;;) {
 wait_for_trace_records_available();
-- 
1.7.2.5



[Qemu-devel] [PATCH 1/2] qemu-ga: remove dependency on gio and gthread

2011-07-23 Thread Anthony Liguori
As far as I can tell, there isn't a dependency on gthread.  Also, the only use
of gio was to enable GSocket to accept a unix domain socket.

Since GSocket isn't available on OpenSuSE 11.1, let's just remove that
dependency.

Signed-off-by: Anthony Liguori 
---
 configure |6 +++---
 qemu-ga.c |   34 +-
 2 files changed, 12 insertions(+), 28 deletions(-)

diff --git a/configure b/configure
index 6911c3b..600da9b 100755
--- a/configure
+++ b/configure
@@ -1811,9 +1811,9 @@ fi
 
 ##
 # glib support probe
-if $pkg_config --modversion gthread-2.0 gio-2.0 > /dev/null 2>&1 ; then
-glib_cflags=`$pkg_config --cflags gthread-2.0 gio-2.0 2>/dev/null`
-glib_libs=`$pkg_config --libs gthread-2.0 gio-2.0 2>/dev/null`
+if $pkg_config --modversion glib-2.0 > /dev/null 2>&1 ; then
+glib_cflags=`$pkg_config --cflags glib-2.0 2>/dev/null`
+glib_libs=`$pkg_config --libs glib-2.0 2>/dev/null`
 libs_softmmu="$glib_libs $libs_softmmu"
 libs_tools="$glib_libs $libs_tools"
 else
diff --git a/qemu-ga.c b/qemu-ga.c
index 6e2f61f..5d8b7cf 100644
--- a/qemu-ga.c
+++ b/qemu-ga.c
@@ -14,7 +14,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -37,9 +36,8 @@
 struct GAState {
 JSONMessageParser parser;
 GMainLoop *main_loop;
-GSocket *conn_sock;
+int conn_fd;
 GIOChannel *conn_channel;
-GSocket *listen_sock;
 GIOChannel *listen_channel;
 const char *path;
 const char *method;
@@ -412,18 +410,19 @@ static gboolean listen_channel_accept(GIOChannel *channel,
   GIOCondition condition, gpointer data)
 {
 GAState *s = data;
-GError *err = NULL;
 g_assert(channel != NULL);
 int ret;
 bool accepted = false;
+struct sockaddr_un addr;
+socklen_t addrlen = sizeof(addr);
 
-s->conn_sock = g_socket_accept(s->listen_sock, NULL, &err);
-if (err != NULL) {
-g_warning("error converting fd to gsocket: %s", err->message);
-g_error_free(err);
+s->conn_fd = qemu_accept(g_io_channel_unix_get_fd(s->listen_channel),
+ (struct sockaddr *)&addr, &addrlen);
+if (s->conn_fd == -1) {
+g_warning("error converting fd to gsocket: %s", strerror(errno));
 goto out;
 }
-ret = conn_channel_add(s, g_socket_get_fd(s->conn_sock));
+ret = conn_channel_add(s, s->conn_fd);
 if (ret) {
 g_warning("error setting up connection");
 goto out;
@@ -440,19 +439,8 @@ out:
  */
 static int listen_channel_add(GAState *s, int listen_fd, bool new)
 {
-GError *err = NULL;
-
 if (new) {
 s->listen_channel = g_io_channel_unix_new(listen_fd);
-if (s->listen_sock) {
-g_object_unref(s->listen_sock);
-}
-s->listen_sock = g_socket_new_from_fd(listen_fd, &err);
-if (err != NULL) {
-g_warning("error converting fd to gsocket: %s", err->message);
-g_error_free(err);
-return -1;
-}
 }
 g_io_add_watch(s->listen_channel, G_IO_IN,
listen_channel_accept, s);
@@ -466,8 +454,7 @@ static void conn_channel_close(GAState *s)
 {
 if (strcmp(s->method, "unix-listen") == 0) {
 g_io_channel_shutdown(s->conn_channel, true, NULL);
-g_object_unref(s->conn_sock);
-s->conn_sock = NULL;
+s->conn_fd = -1;
 listen_channel_add(s, 0, false);
 } else if (strcmp(s->method, "virtio-serial") == 0) {
 /* we spin on EOF for virtio-serial, so back off a bit. also,
@@ -624,9 +611,6 @@ int main(int argc, char **argv)
 become_daemon(pidfile);
 }
 
-g_type_init();
-g_thread_init(NULL);
-
 s = qemu_mallocz(sizeof(GAState));
 s->conn_channel = NULL;
 s->path = path;
-- 
1.7.4.1




Re: [Qemu-devel] [PATCH] guest agent: qemu-ga daemon

2011-07-23 Thread Alexander Graf

On 23.07.2011, at 23:12, Anthony Liguori wrote:

> On 07/23/2011 02:22 PM, Alexander Graf wrote:
>> 
>>> We default off'd the I/O thread even after years we still don't have it 
>>> enabled.
>>> 
>>> With respect to 0.15, this bit of code is totally isolated from everything 
>>> else.  Worst case scenario, we just disable it on platforms where it 
>>> doesn't work.  It presents no real risk to the stability of the release.
>> 
>> As you've seen, it can break builds. Why not wait for 0.16? The code came in 
>> more than 2 months after the soft feature freeze, which was specifically for 
>> big features like this, no?
> 
> I just sent out a patch that should fix the build issue.  Let's see what it 
> takes to resolve this before we talk about disabling for 0.16.

Oh, I'd immediately agree on saying it should be enabled for 0.16 :)

> Again, there's zero risk to QEMU for having this enabled so if we can resolve 
> the build issues, and I don't see why we can't, then there should be no real 
> problem here.

I've just tried out the two patches you sent. With them applied, things compile 
just fine.


Alex




[Qemu-devel] [PATCH 2/3] slirp: fix warning on mingw32

2011-07-23 Thread Blue Swirl
Avoid this warning:
  CCslirp/ip_icmp.o
/src/qemu/slirp/ip_icmp.c: In function 'icmp_receive':
/src/qemu/slirp/ip_icmp.c:418:5: error: passing argument 2 of 'recv'
from incompatible pointer type [-Werror]
/usr/local/lib/gcc/i686-mingw32msvc/4.6.0/../../../../i686-mingw32msvc/include/winsock2.h:547:32:
note: expected 'char *' but argument is of type 'struct icmp *'

Signed-off-by: Blue Swirl 
---
 slirp/ip_icmp.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/slirp/ip_icmp.c b/slirp/ip_icmp.c
index 14a5312..a208648 100644
--- a/slirp/ip_icmp.c
+++ b/slirp/ip_icmp.c
@@ -415,7 +415,7 @@ void icmp_receive(struct socket *so)
 icp = mtod(m, struct icmp *);

 id = icp->icmp_id;
-len = recv(so->s, icp, m->m_len, 0);
+len = recv(so->s, (char *)icp, m->m_len, 0);
 icp->icmp_id = id;

 m->m_data -= hlen;
-- 
1.6.2.4
From 37628ecdfc668419a7724687249f2791e9241847 Mon Sep 17 00:00:00 2001
Message-Id: <37628ecdfc668419a7724687249f2791e9241847.1311456245.git.blauwir...@gmail.com>
In-Reply-To: <8bcd08d1fe7c90869ea6659b6248ace6cf7b1f32.1311456245.git.blauwir...@gmail.com>
References: <8bcd08d1fe7c90869ea6659b6248ace6cf7b1f32.1311456245.git.blauwir...@gmail.com>
From: Blue Swirl 
Date: Sat, 23 Jul 2011 20:04:29 +
Subject: [PATCH 2/3] slirp: fix warning on mingw32

Avoid this warning:
  CCslirp/ip_icmp.o
/src/qemu/slirp/ip_icmp.c: In function 'icmp_receive':
/src/qemu/slirp/ip_icmp.c:418:5: error: passing argument 2 of 'recv' from incompatible pointer type [-Werror]
/usr/local/lib/gcc/i686-mingw32msvc/4.6.0/../../../../i686-mingw32msvc/include/winsock2.h:547:32: note: expected 'char *' but argument is of type 'struct icmp *'

Signed-off-by: Blue Swirl 
---
 slirp/ip_icmp.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/slirp/ip_icmp.c b/slirp/ip_icmp.c
index 14a5312..a208648 100644
--- a/slirp/ip_icmp.c
+++ b/slirp/ip_icmp.c
@@ -415,7 +415,7 @@ void icmp_receive(struct socket *so)
 icp = mtod(m, struct icmp *);
 
 id = icp->icmp_id;
-len = recv(so->s, icp, m->m_len, 0);
+len = recv(so->s, (char *)icp, m->m_len, 0);
 icp->icmp_id = id;
 
 m->m_data -= hlen;
-- 
1.7.2.5



Re: [Qemu-devel] [PATCH v4] hw/pc: Support system flash memory with -pflash parameter

2011-07-23 Thread Anthony Liguori

On 07/23/2011 03:19 PM, Jordan Justen wrote:

On Sat, Jul 23, 2011 at 08:51, Anthony Liguori  wrote:

On 07/08/2011 02:37 PM, Jordan Justen wrote:


If -pflash is specified and -bios is specified then pflash will
be mapped just below the system rom using hw/pflash_cfi01.c.

If -pflash is specified on the command line, but -bios is
not specified, then 'bios.bin' will NOT be loaded, and
instead the -pflash flash image will be mapped just below
4GB in place of the normal rom image.


This is way too tied to the pc platform to be this generic.

I think a better approach would be to default to having unit=0 of IF_PFLASH
default to a read-only BDS that points to bios.bin.  -bios would just be a
short cut to use a different file name but you should be able to override
with -drive too.

And to really simplify things, you could add a readonly flag to -bios such
that you could do:

-bios foo.img,readonly=off

Which is what I think you're looking for semantically.


There seemed to be some feedback on the list interested in preserving
a read-only firmware, and just adding a flash region.

So, for example, the firmware could be read from a common system
location like is generally done with bios.bin today, and VM instance
specific flash region could still be added.


You can have multiple flash regions.

You're introducing two modes.  In one mode, we emulate a flash device 
and expose it for the BIOS ROM.  In the second mode, we don't emulate a 
device but we expose the BIOS ROM based on a file in a shared read-only 
location.


I'm suggesting always emulating a flash device, but by default make the 
device read-only and have it be loaded from a file in a shared read-only 
location.


That means we have a single code path and a consistent view from a 
management tooling perspective.  IOW, management tools will always see 
that there is a BIOS block device, and they need to worry about making 
sure that BIOS block device is there.




If the entire firmware is moved to a separate VM instance specific
flash, then firmware update also gets complicated.  It is no longer
just a matter of updating the qemu firmware package in your distro's
package management system.


I think the bit your misunderstanding is that you should default the 
firmware to be created from a common file as a read-only device.


Regards,

Anthony Liguori



What about taking your idea, but adding a second drive that would be
mapped just below the 1st if it is specified with -drive?

Thanks,

-Jordan



Regards,

Anthony Liguori



Signed-off-by: Jordan Justen
Reviewed-by: Aurelien Jarno





---
  default-configs/i386-softmmu.mak   |1 +
  default-configs/x86_64-softmmu.mak |1 +
  hw/pc.c|  161
+++-
  3 files changed, 125 insertions(+), 38 deletions(-)

diff --git a/default-configs/i386-softmmu.mak
b/default-configs/i386-softmmu.mak
index 55589fa..8697cd4 100644
--- a/default-configs/i386-softmmu.mak
+++ b/default-configs/i386-softmmu.mak
@@ -21,3 +21,4 @@ CONFIG_PIIX_PCI=y
  CONFIG_SOUND=y
  CONFIG_HPET=y
  CONFIG_APPLESMC=y
+CONFIG_PFLASH_CFI01=y
diff --git a/default-configs/x86_64-softmmu.mak
b/default-configs/x86_64-softmmu.mak
index 8895028..eca9284 100644
--- a/default-configs/x86_64-softmmu.mak
+++ b/default-configs/x86_64-softmmu.mak
@@ -21,3 +21,4 @@ CONFIG_PIIX_PCI=y
  CONFIG_SOUND=y
  CONFIG_HPET=y
  CONFIG_APPLESMC=y
+CONFIG_PFLASH_CFI01=y
diff --git a/hw/pc.c b/hw/pc.c
index a3e8539..e25354f 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -41,6 +41,7 @@
  #include "sysemu.h"
  #include "blockdev.h"
  #include "ui/qemu-spice.h"
+#include "flash.h"

  /* output Bochs bios info messages */
  //#define DEBUG_BIOS
@@ -957,70 +958,154 @@ void pc_cpus_init(const char *cpu_model)
  }
  }

-void pc_memory_init(const char *kernel_filename,
-const char *kernel_cmdline,
-const char *initrd_filename,
-ram_addr_t below_4g_mem_size,
-ram_addr_t above_4g_mem_size)
+static void pc_isa_bios_init(ram_addr_t ram_offset, int ram_size)
  {
-char *filename;
-int ret, linux_boot, i;
-ram_addr_t ram_addr, bios_offset, option_rom_offset;
-int bios_size, isa_bios_size;
-void *fw_cfg;
-
-linux_boot = (kernel_filename != NULL);
+int isa_bios_size;

-/* allocate RAM */
-ram_addr = qemu_ram_alloc(NULL, "pc.ram",
-  below_4g_mem_size + above_4g_mem_size);
-cpu_register_physical_memory(0, 0xa, ram_addr);
-cpu_register_physical_memory(0x10,
- below_4g_mem_size - 0x10,
- ram_addr + 0x10);
-if (above_4g_mem_size>0) {
-cpu_register_physical_memory(0x1ULL, above_4g_mem_size,
- ram_addr + below_4g_mem_size);
+/* map the last 128KB of the BIOS in ISA space */
+isa_bios_size = ram_size;
+if (isa_bios_size>(128 * 1024)) {
+isa_bios_size = 1

[Qemu-devel] [PATCH 1/3] Fix chrdev return value conversion

2011-07-23 Thread Blue Swirl
6e1db57b2ac9025c2443c665a0d9e78748637b26 didn't
convert brlapi or win32 chrdevs, breaking build for those.

Fix by converting the chrdevs.

Signed-off-by: Blue Swirl 
---
 hw/baum.h   |2 +-
 qemu-char.c |7 ---
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/hw/baum.h b/hw/baum.h
index 8af710f..3f28cc3 100644
--- a/hw/baum.h
+++ b/hw/baum.h
@@ -23,4 +23,4 @@
  */

 /* char device */
-CharDriverState *chr_baum_init(QemuOpts *opts);
+int chr_baum_init(QemuOpts *opts, CharDriverState **_chr);
diff --git a/qemu-char.c b/qemu-char.c
index dcf7065..2982bfd 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -1782,7 +1782,7 @@ static int qemu_chr_open_win_pipe(QemuOpts
*opts, CharDriverState **_chr)
 return 0;
 }

-static CharDriverState *qemu_chr_open_win_file(HANDLE fd_out)
+static int qemu_chr_open_win_file(HANDLE fd_out, CharDriverState **pchr)
 {
 CharDriverState *chr;
 WinCharState *s;
@@ -1793,10 +1793,11 @@ static CharDriverState
*qemu_chr_open_win_file(HANDLE fd_out)
 chr->opaque = s;
 chr->chr_write = win_chr_write;
 qemu_chr_generic_open(chr);
-return chr;
+*pchr = chr;
+return 0;
 }

-static int qemu_chr_open_win_con(QemuOpts *opts, CharDriverState **_chr)
+static int qemu_chr_open_win_con(QemuOpts *opts, CharDriverState **chr)
 {
 return qemu_chr_open_win_file(GetStdHandle(STD_OUTPUT_HANDLE), chr);
 }
-- 
1.6.2.4
From 8bcd08d1fe7c90869ea6659b6248ace6cf7b1f32 Mon Sep 17 00:00:00 2001
Message-Id: <8bcd08d1fe7c90869ea6659b6248ace6cf7b1f32.1311456245.git.blauwir...@gmail.com>
From: Blue Swirl 
Date: Sat, 23 Jul 2011 19:26:08 +
Subject: [PATCH 1/3] Fix chrdev return value conversion

6e1db57b2ac9025c2443c665a0d9e78748637b26 didn't
convert brlapi or win32 chrdevs, breaking build for those.

Fix by converting the chrdevs.

Signed-off-by: Blue Swirl 
---
 hw/baum.h   |2 +-
 qemu-char.c |7 ---
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/hw/baum.h b/hw/baum.h
index 8af710f..3f28cc3 100644
--- a/hw/baum.h
+++ b/hw/baum.h
@@ -23,4 +23,4 @@
  */
 
 /* char device */
-CharDriverState *chr_baum_init(QemuOpts *opts);
+int chr_baum_init(QemuOpts *opts, CharDriverState **_chr);
diff --git a/qemu-char.c b/qemu-char.c
index dcf7065..2982bfd 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -1782,7 +1782,7 @@ static int qemu_chr_open_win_pipe(QemuOpts *opts, CharDriverState **_chr)
 return 0;
 }
 
-static CharDriverState *qemu_chr_open_win_file(HANDLE fd_out)
+static int qemu_chr_open_win_file(HANDLE fd_out, CharDriverState **pchr)
 {
 CharDriverState *chr;
 WinCharState *s;
@@ -1793,10 +1793,11 @@ static CharDriverState *qemu_chr_open_win_file(HANDLE fd_out)
 chr->opaque = s;
 chr->chr_write = win_chr_write;
 qemu_chr_generic_open(chr);
-return chr;
+*pchr = chr;
+return 0;
 }
 
-static int qemu_chr_open_win_con(QemuOpts *opts, CharDriverState **_chr)
+static int qemu_chr_open_win_con(QemuOpts *opts, CharDriverState **chr)
 {
 return qemu_chr_open_win_file(GetStdHandle(STD_OUTPUT_HANDLE), chr);
 }
-- 
1.7.2.5



[Qemu-devel] [PATCH 0/3] build/warning fixes

2011-07-23 Thread Blue Swirl
Blue Swirl (3):
  Fix chrdev return value conversion
  slirp: fix warning on mingw32
  simpletrace: suppress a warning from unused variable

 hw/baum.h   |2 +-
 qemu-char.c |7 ---
 simpletrace.c   |2 +-
 slirp/ip_icmp.c |2 +-
 4 files changed, 7 insertions(+), 6 deletions(-)



[Qemu-devel] [PATCH 2/4] xen: Fix xen_enabled().

2011-07-23 Thread Alexander Graf
From: Anthony PERARD 

Use the "host" CONFIG_ define instead of the "target" one.

Signed-off-by: Anthony PERARD 
Acked-by: Paolo Bonzini 
Signed-off-by: Alexander Graf 
---
 hw/xen.h |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/hw/xen.h b/hw/xen.h
index e432705..43b95d6 100644
--- a/hw/xen.h
+++ b/hw/xen.h
@@ -24,7 +24,7 @@ extern int xen_allowed;
 
 static inline int xen_enabled(void)
 {
-#ifdef CONFIG_XEN
+#ifdef CONFIG_XEN_BACKEND
 return xen_allowed;
 #else
 return 0;
-- 
1.6.0.2




[Qemu-devel] [PATCH 3/4] xen: remove CONFIG_XEN_MAPCACHE

2011-07-23 Thread Alexander Graf
We were still exporting CONFIG_XEN_MAPCACHE, even though it's completely
unused by now. Remove it.

Signed-off-by: Alexander Graf 
---
 configure |3 ---
 1 files changed, 0 insertions(+), 3 deletions(-)

diff --git a/configure b/configure
index 6911c3b..90fe09f 100755
--- a/configure
+++ b/configure
@@ -3277,9 +3277,6 @@ case "$target_arch2" in
 if test "$xen" = "yes" -a "$target_softmmu" = "yes" ; then
   target_phys_bits=64
   echo "CONFIG_XEN=y" >> $config_target_mak
-  if test "$cpu" = "i386" -o "$cpu" = "x86_64"; then
-  echo "CONFIG_XEN_MAPCACHE=y" >> $config_target_mak
-  fi
 fi
 esac
 case "$target_arch2" in
-- 
1.6.0.2




[Qemu-devel] [PATCH 1/4] exec.c: Use ram_addr_t in cpu_physical_memory_rw(...).

2011-07-23 Thread Alexander Graf
From: Anthony PERARD 

As the variable pd and addr1 inside the function cpu_physical_memory_rw
are mean to handle a RAM address, they should be of the ram_addr_t type
instead of unsigned long.

Signed-off-by: Anthony PERARD 
Acked-by: Paolo Bonzini 
Signed-off-by: Alexander Graf 
---
 exec.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/exec.c b/exec.c
index 2160ded..0393d39 100644
--- a/exec.c
+++ b/exec.c
@@ -3858,7 +3858,7 @@ void cpu_physical_memory_rw(target_phys_addr_t addr, 
uint8_t *buf,
 uint8_t *ptr;
 uint32_t val;
 target_phys_addr_t page;
-unsigned long pd;
+ram_addr_t pd;
 PhysPageDesc *p;
 
 while (len > 0) {
@@ -3898,7 +3898,7 @@ void cpu_physical_memory_rw(target_phys_addr_t addr, 
uint8_t *buf,
 l = 1;
 }
 } else {
-unsigned long addr1;
+ram_addr_t addr1;
 addr1 = (pd & TARGET_PAGE_MASK) + (addr & ~TARGET_PAGE_MASK);
 /* RAM case */
 ptr = qemu_get_ram_ptr(addr1);
-- 
1.6.0.2




[Qemu-devel] [PATCH 4/4] xen: make xen_enabled even more clever

2011-07-23 Thread Alexander Graf
When using xen_enabled() we're currently only checking if xen is enabled
at all during the build. But what if you want to build multiple targets
out of which only one can potentially run xen code?

That means that for generic code we'll still have to fall back to the
variable and potentially slow the code down, but it's not as important as
that is mostly xen device emulation which is not touched for non-xen targets.

The target specific code however can with this patch see that it's unable to
ever execute xen code. We can thus always return 0 on xen_enabled(), giving
gcc enough hints to evict the mapcache code from the target memory management
code.

Signed-off-by: Alexander Graf 
Acked-by: Anthony PERARD 
---
 configure |5 +
 hw/xen.h  |2 +-
 2 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/configure b/configure
index 90fe09f..e5ecec9 100755
--- a/configure
+++ b/configure
@@ -3277,7 +3277,12 @@ case "$target_arch2" in
 if test "$xen" = "yes" -a "$target_softmmu" = "yes" ; then
   target_phys_bits=64
   echo "CONFIG_XEN=y" >> $config_target_mak
+else
+  echo "CONFIG_NO_XEN=y" >> $config_target_mak
 fi
+;;
+  *)
+echo "CONFIG_NO_XEN=y" >> $config_target_mak
 esac
 case "$target_arch2" in
   i386|x86_64|ppcemb|ppc|ppc64|s390x)
diff --git a/hw/xen.h b/hw/xen.h
index 43b95d6..2162111 100644
--- a/hw/xen.h
+++ b/hw/xen.h
@@ -24,7 +24,7 @@ extern int xen_allowed;
 
 static inline int xen_enabled(void)
 {
-#ifdef CONFIG_XEN_BACKEND
+#if defined(CONFIG_XEN_BACKEND) && !defined(CONFIG_NO_XEN)
 return xen_allowed;
 #else
 return 0;
-- 
1.6.0.2




[Qemu-devel] [PULL 0.15 0/4] xen-stable patch queue 2011-07-22

2011-07-23 Thread Alexander Graf
Hi Anthony,

This is my current patch queue for xen on 0.15. Please pull.

Alex


The following changes since commit b8095f24f24e50a7d4be33d8a79474aff3324295:
  Anthony Liguori (1):
Bump version to reflect v0.15.0-rc0

are available in the git repository at:

  git://repo.or.cz/qemu/agraf.git xen-stable-0.15

Alexander Graf (2):
  xen: remove CONFIG_XEN_MAPCACHE
  xen: make xen_enabled even more clever

Anthony PERARD (2):
  exec.c: Use ram_addr_t in cpu_physical_memory_rw(...).
  xen: Fix xen_enabled().

 configure |8 +---
 exec.c|4 ++--
 hw/xen.h  |2 +-
 3 files changed, 8 insertions(+), 6 deletions(-)



[Qemu-devel] [PATCH] guest-agent: only enable FSFREEZE when it's supported by the kernel

2011-07-23 Thread Anthony Liguori
Signed-off-by: Anthony Liguori 
---
 qga/guest-agent-commands.c |   12 +++-
 1 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/qga/guest-agent-commands.c b/qga/guest-agent-commands.c
index 624972e..30c4068 100644
--- a/qga/guest-agent-commands.c
+++ b/qga/guest-agent-commands.c
@@ -10,15 +10,17 @@
  * See the COPYING file in the top-level directory.
  */
 
-#if defined(__linux__)
-#define CONFIG_FSFREEZE
-#endif
-
 #include 
-#if defined(CONFIG_FSFREEZE)
+
+#if defined(__linux__)
 #include 
 #include 
+
+#if defined(__linux__) && defined(FIFREEZE)
+#define CONFIG_FSFREEZE
 #endif
+#endif
+
 #include 
 #include 
 #include "qga/guest-agent-core.h"
-- 
1.7.4.1




Re: [Qemu-devel] [PATCH] guest agent: qemu-ga daemon

2011-07-23 Thread Anthony Liguori

On 07/23/2011 02:22 PM, Alexander Graf wrote:



We default off'd the I/O thread even after years we still don't have it enabled.

With respect to 0.15, this bit of code is totally isolated from everything 
else.  Worst case scenario, we just disable it on platforms where it doesn't 
work.  It presents no real risk to the stability of the release.


As you've seen, it can break builds. Why not wait for 0.16? The code came in 
more than 2 months after the soft feature freeze, which was specifically for 
big features like this, no?


I just sent out a patch that should fix the build issue.  Let's see what 
it takes to resolve this before we talk about disabling for 0.16.


Again, there's zero risk to QEMU for having this enabled so if we can 
resolve the build issues, and I don't see why we can't, then there 
should be no real problem here.


Regards,

Anthony Liguori



Alex






[Qemu-devel] [PATCH] qemu-ga: remove dependency on gio and gthread

2011-07-23 Thread Anthony Liguori
As far as I can tell, there isn't a dependency on gthread.  Also, the only use
of gio was to enable GSocket to accept a unix domain socket.

Since GSocket isn't available on OpenSuSE 11.1, let's just remove that
dependency.

Signed-off-by: Anthony Liguori 
---
 configure |6 +++---
 qemu-ga.c |   34 +-
 2 files changed, 12 insertions(+), 28 deletions(-)

diff --git a/configure b/configure
index 6911c3b..600da9b 100755
--- a/configure
+++ b/configure
@@ -1811,9 +1811,9 @@ fi
 
 ##
 # glib support probe
-if $pkg_config --modversion gthread-2.0 gio-2.0 > /dev/null 2>&1 ; then
-glib_cflags=`$pkg_config --cflags gthread-2.0 gio-2.0 2>/dev/null`
-glib_libs=`$pkg_config --libs gthread-2.0 gio-2.0 2>/dev/null`
+if $pkg_config --modversion glib-2.0 > /dev/null 2>&1 ; then
+glib_cflags=`$pkg_config --cflags glib-2.0 2>/dev/null`
+glib_libs=`$pkg_config --libs glib-2.0 2>/dev/null`
 libs_softmmu="$glib_libs $libs_softmmu"
 libs_tools="$glib_libs $libs_tools"
 else
diff --git a/qemu-ga.c b/qemu-ga.c
index 6e2f61f..5d8b7cf 100644
--- a/qemu-ga.c
+++ b/qemu-ga.c
@@ -14,7 +14,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -37,9 +36,8 @@
 struct GAState {
 JSONMessageParser parser;
 GMainLoop *main_loop;
-GSocket *conn_sock;
+int conn_fd;
 GIOChannel *conn_channel;
-GSocket *listen_sock;
 GIOChannel *listen_channel;
 const char *path;
 const char *method;
@@ -412,18 +410,19 @@ static gboolean listen_channel_accept(GIOChannel *channel,
   GIOCondition condition, gpointer data)
 {
 GAState *s = data;
-GError *err = NULL;
 g_assert(channel != NULL);
 int ret;
 bool accepted = false;
+struct sockaddr_un addr;
+socklen_t addrlen = sizeof(addr);
 
-s->conn_sock = g_socket_accept(s->listen_sock, NULL, &err);
-if (err != NULL) {
-g_warning("error converting fd to gsocket: %s", err->message);
-g_error_free(err);
+s->conn_fd = qemu_accept(g_io_channel_unix_get_fd(s->listen_channel),
+ (struct sockaddr *)&addr, &addrlen);
+if (s->conn_fd == -1) {
+g_warning("error converting fd to gsocket: %s", strerror(errno));
 goto out;
 }
-ret = conn_channel_add(s, g_socket_get_fd(s->conn_sock));
+ret = conn_channel_add(s, s->conn_fd);
 if (ret) {
 g_warning("error setting up connection");
 goto out;
@@ -440,19 +439,8 @@ out:
  */
 static int listen_channel_add(GAState *s, int listen_fd, bool new)
 {
-GError *err = NULL;
-
 if (new) {
 s->listen_channel = g_io_channel_unix_new(listen_fd);
-if (s->listen_sock) {
-g_object_unref(s->listen_sock);
-}
-s->listen_sock = g_socket_new_from_fd(listen_fd, &err);
-if (err != NULL) {
-g_warning("error converting fd to gsocket: %s", err->message);
-g_error_free(err);
-return -1;
-}
 }
 g_io_add_watch(s->listen_channel, G_IO_IN,
listen_channel_accept, s);
@@ -466,8 +454,7 @@ static void conn_channel_close(GAState *s)
 {
 if (strcmp(s->method, "unix-listen") == 0) {
 g_io_channel_shutdown(s->conn_channel, true, NULL);
-g_object_unref(s->conn_sock);
-s->conn_sock = NULL;
+s->conn_fd = -1;
 listen_channel_add(s, 0, false);
 } else if (strcmp(s->method, "virtio-serial") == 0) {
 /* we spin on EOF for virtio-serial, so back off a bit. also,
@@ -624,9 +611,6 @@ int main(int argc, char **argv)
 become_daemon(pidfile);
 }
 
-g_type_init();
-g_thread_init(NULL);
-
 s = qemu_mallocz(sizeof(GAState));
 s->conn_channel = NULL;
 s->path = path;
-- 
1.7.4.1




[Qemu-devel] [PATCH 5/5] xen: make xen_enabled even more clever

2011-07-23 Thread Alexander Graf
When using xen_enabled() we're currently only checking if xen is enabled
at all during the build. But what if you want to build multiple targets
out of which only one can potentially run xen code?

That means that for generic code we'll still have to fall back to the
variable and potentially slow the code down, but it's not as important as
that is mostly xen device emulation which is not touched for non-xen targets.

The target specific code however can with this patch see that it's unable to
ever execute xen code. We can thus always return 0 on xen_enabled(), giving
gcc enough hints to evict the mapcache code from the target memory management
code.

Signed-off-by: Alexander Graf 
Acked-by: Anthony PERARD 
---
 configure |5 +
 hw/xen.h  |2 +-
 2 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/configure b/configure
index 90fe09f..e5ecec9 100755
--- a/configure
+++ b/configure
@@ -3277,7 +3277,12 @@ case "$target_arch2" in
 if test "$xen" = "yes" -a "$target_softmmu" = "yes" ; then
   target_phys_bits=64
   echo "CONFIG_XEN=y" >> $config_target_mak
+else
+  echo "CONFIG_NO_XEN=y" >> $config_target_mak
 fi
+;;
+  *)
+echo "CONFIG_NO_XEN=y" >> $config_target_mak
 esac
 case "$target_arch2" in
   i386|x86_64|ppcemb|ppc|ppc64|s390x)
diff --git a/hw/xen.h b/hw/xen.h
index 43b95d6..2162111 100644
--- a/hw/xen.h
+++ b/hw/xen.h
@@ -24,7 +24,7 @@ extern int xen_allowed;
 
 static inline int xen_enabled(void)
 {
-#ifdef CONFIG_XEN_BACKEND
+#if defined(CONFIG_XEN_BACKEND) && !defined(CONFIG_NO_XEN)
 return xen_allowed;
 #else
 return 0;
-- 
1.6.0.2




[Qemu-devel] [PATCH 2/5] xen: Fix xen_enabled().

2011-07-23 Thread Alexander Graf
From: Anthony PERARD 

Use the "host" CONFIG_ define instead of the "target" one.

Signed-off-by: Anthony PERARD 
Acked-by: Paolo Bonzini 
Signed-off-by: Alexander Graf 
---
 hw/xen.h |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/hw/xen.h b/hw/xen.h
index e432705..43b95d6 100644
--- a/hw/xen.h
+++ b/hw/xen.h
@@ -24,7 +24,7 @@ extern int xen_allowed;
 
 static inline int xen_enabled(void)
 {
-#ifdef CONFIG_XEN
+#ifdef CONFIG_XEN_BACKEND
 return xen_allowed;
 #else
 return 0;
-- 
1.6.0.2




[Qemu-devel] [PATCH 1/5] xen: introduce xen_change_state_handler

2011-07-23 Thread Alexander Graf
From: Anthony PERARD 

Remove the call to xenstore_record_dm_state from xen_main_loop_prepare
that is HVM specific.
Add a new vm_change_state_handler shared between xen_pv and xen_hvm
machines to record the VM state to xenstore.

Signed-off-by: Anthony PERARD 
Signed-off-by: Stefano Stabellini 
Signed-off-by: Alexander Graf 
---
 xen-all.c |   25 ++---
 1 files changed, 18 insertions(+), 7 deletions(-)

diff --git a/xen-all.c b/xen-all.c
index 167bed6..83c5476 100644
--- a/xen-all.c
+++ b/xen-all.c
@@ -797,12 +797,17 @@ void xenstore_store_pv_console_info(int i, 
CharDriverState *chr)
 }
 }
 
-static void xenstore_record_dm_state(XenIOState *s, const char *state)
+static void xenstore_record_dm_state(struct xs_handle *xs, const char *state)
 {
 char path[50];
 
+if (xs == NULL) {
+fprintf(stderr, "xenstore connection not initialized\n");
+exit(1);
+}
+
 snprintf(path, sizeof (path), "/local/domain/0/device-model/%u/state", 
xen_domid);
-if (!xs_write(s->xenstore, XBT_NULL, path, state, strlen(state))) {
+if (!xs_write(xs, XBT_NULL, path, state, strlen(state))) {
 fprintf(stderr, "error recording dm state\n");
 exit(1);
 }
@@ -823,15 +828,20 @@ static void xen_main_loop_prepare(XenIOState *state)
 if (evtchn_fd != -1) {
 qemu_set_fd_handler(evtchn_fd, cpu_handle_ioreq, NULL, state);
 }
-
-/* record state running */
-xenstore_record_dm_state(state, "running");
 }
 
 
 /* Initialise Xen */
 
-static void xen_vm_change_state_handler(void *opaque, int running, int reason)
+static void xen_change_state_handler(void *opaque, int running, int reason)
+{
+if (running) {
+/* record state running */
+xenstore_record_dm_state(xenstore, "running");
+}
+}
+
+static void xen_hvm_change_state_handler(void *opaque, int running, int reason)
 {
 XenIOState *state = opaque;
 if (running) {
@@ -854,6 +864,7 @@ int xen_init(void)
 xen_be_printf(NULL, 0, "can't open xen interface\n");
 return -1;
 }
+qemu_add_vm_change_state_handler(xen_change_state_handler, NULL);
 
 return 0;
 }
@@ -915,7 +926,7 @@ int xen_hvm_init(void)
 xen_map_cache_init();
 xen_ram_init(ram_size);
 
-qemu_add_vm_change_state_handler(xen_vm_change_state_handler, state);
+qemu_add_vm_change_state_handler(xen_hvm_change_state_handler, state);
 
 state->client = xen_cpu_phys_memory_client;
 QLIST_INIT(&state->physmap);
-- 
1.6.0.2




[Qemu-devel] [PATCH 4/5] xen: remove CONFIG_XEN_MAPCACHE

2011-07-23 Thread Alexander Graf
We were still exporting CONFIG_XEN_MAPCACHE, even though it's completely
unused by now. Remove it.

Signed-off-by: Alexander Graf 
---
 configure |3 ---
 1 files changed, 0 insertions(+), 3 deletions(-)

diff --git a/configure b/configure
index 6911c3b..90fe09f 100755
--- a/configure
+++ b/configure
@@ -3277,9 +3277,6 @@ case "$target_arch2" in
 if test "$xen" = "yes" -a "$target_softmmu" = "yes" ; then
   target_phys_bits=64
   echo "CONFIG_XEN=y" >> $config_target_mak
-  if test "$cpu" = "i386" -o "$cpu" = "x86_64"; then
-  echo "CONFIG_XEN_MAPCACHE=y" >> $config_target_mak
-  fi
 fi
 esac
 case "$target_arch2" in
-- 
1.6.0.2




[Qemu-devel] [PULL 0/5] Xen patch queue 2011-07-23

2011-07-23 Thread Alexander Graf
Hi Anthony,

This is a rebase of the last xen-next pull request, this time without the
xen-mapcache build breakage fix, as that's been fixed meanwhile.

Please pull.

Alex

The following changes since commit 1167bfd63d983eaa4816ee0edb185f98ff070d6d:
  Anthony Liguori (1):
Open 1.0 development branch.

are available in the git repository at:

  git://repo.or.cz/qemu/agraf.git xen-next

Alexander Graf (2):
  xen: remove CONFIG_XEN_MAPCACHE
  xen: make xen_enabled even more clever

Anthony PERARD (3):
  xen: introduce xen_change_state_handler
  xen: Fix xen_enabled().
  exec.c: Use ram_addr_t in cpu_physical_memory_rw(...).

 configure |8 +---
 exec.c|4 ++--
 hw/xen.h  |2 +-
 xen-all.c |   25 ++---
 4 files changed, 26 insertions(+), 13 deletions(-)




[Qemu-devel] [PATCH 3/5] exec.c: Use ram_addr_t in cpu_physical_memory_rw(...).

2011-07-23 Thread Alexander Graf
From: Anthony PERARD 

As the variable pd and addr1 inside the function cpu_physical_memory_rw
are mean to handle a RAM address, they should be of the ram_addr_t type
instead of unsigned long.

Signed-off-by: Anthony PERARD 
Acked-by: Paolo Bonzini 
Signed-off-by: Alexander Graf 
---
 exec.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/exec.c b/exec.c
index 2160ded..0393d39 100644
--- a/exec.c
+++ b/exec.c
@@ -3858,7 +3858,7 @@ void cpu_physical_memory_rw(target_phys_addr_t addr, 
uint8_t *buf,
 uint8_t *ptr;
 uint32_t val;
 target_phys_addr_t page;
-unsigned long pd;
+ram_addr_t pd;
 PhysPageDesc *p;
 
 while (len > 0) {
@@ -3898,7 +3898,7 @@ void cpu_physical_memory_rw(target_phys_addr_t addr, 
uint8_t *buf,
 l = 1;
 }
 } else {
-unsigned long addr1;
+ram_addr_t addr1;
 addr1 = (pd & TARGET_PAGE_MASK) + (addr & ~TARGET_PAGE_MASK);
 /* RAM case */
 ptr = qemu_get_ram_ptr(addr1);
-- 
1.6.0.2




Re: [Qemu-devel] [PATCH v4] hw/pc: Support system flash memory with -pflash parameter

2011-07-23 Thread Jordan Justen
On Sat, Jul 23, 2011 at 08:51, Anthony Liguori  wrote:
> On 07/08/2011 02:37 PM, Jordan Justen wrote:
>>
>> If -pflash is specified and -bios is specified then pflash will
>> be mapped just below the system rom using hw/pflash_cfi01.c.
>>
>> If -pflash is specified on the command line, but -bios is
>> not specified, then 'bios.bin' will NOT be loaded, and
>> instead the -pflash flash image will be mapped just below
>> 4GB in place of the normal rom image.
>
> This is way too tied to the pc platform to be this generic.
>
> I think a better approach would be to default to having unit=0 of IF_PFLASH
> default to a read-only BDS that points to bios.bin.  -bios would just be a
> short cut to use a different file name but you should be able to override
> with -drive too.
>
> And to really simplify things, you could add a readonly flag to -bios such
> that you could do:
>
> -bios foo.img,readonly=off
>
> Which is what I think you're looking for semantically.

There seemed to be some feedback on the list interested in preserving
a read-only firmware, and just adding a flash region.

So, for example, the firmware could be read from a common system
location like is generally done with bios.bin today, and VM instance
specific flash region could still be added.

If the entire firmware is moved to a separate VM instance specific
flash, then firmware update also gets complicated.  It is no longer
just a matter of updating the qemu firmware package in your distro's
package management system.

What about taking your idea, but adding a second drive that would be
mapped just below the 1st if it is specified with -drive?

Thanks,

-Jordan

>
> Regards,
>
> Anthony Liguori
>
>>
>> Signed-off-by: Jordan Justen
>> Reviewed-by: Aurelien Jarno
>
>
>
>> ---
>>  default-configs/i386-softmmu.mak   |    1 +
>>  default-configs/x86_64-softmmu.mak |    1 +
>>  hw/pc.c                            |  161
>> +++-
>>  3 files changed, 125 insertions(+), 38 deletions(-)
>>
>> diff --git a/default-configs/i386-softmmu.mak
>> b/default-configs/i386-softmmu.mak
>> index 55589fa..8697cd4 100644
>> --- a/default-configs/i386-softmmu.mak
>> +++ b/default-configs/i386-softmmu.mak
>> @@ -21,3 +21,4 @@ CONFIG_PIIX_PCI=y
>>  CONFIG_SOUND=y
>>  CONFIG_HPET=y
>>  CONFIG_APPLESMC=y
>> +CONFIG_PFLASH_CFI01=y
>> diff --git a/default-configs/x86_64-softmmu.mak
>> b/default-configs/x86_64-softmmu.mak
>> index 8895028..eca9284 100644
>> --- a/default-configs/x86_64-softmmu.mak
>> +++ b/default-configs/x86_64-softmmu.mak
>> @@ -21,3 +21,4 @@ CONFIG_PIIX_PCI=y
>>  CONFIG_SOUND=y
>>  CONFIG_HPET=y
>>  CONFIG_APPLESMC=y
>> +CONFIG_PFLASH_CFI01=y
>> diff --git a/hw/pc.c b/hw/pc.c
>> index a3e8539..e25354f 100644
>> --- a/hw/pc.c
>> +++ b/hw/pc.c
>> @@ -41,6 +41,7 @@
>>  #include "sysemu.h"
>>  #include "blockdev.h"
>>  #include "ui/qemu-spice.h"
>> +#include "flash.h"
>>
>>  /* output Bochs bios info messages */
>>  //#define DEBUG_BIOS
>> @@ -957,70 +958,154 @@ void pc_cpus_init(const char *cpu_model)
>>      }
>>  }
>>
>> -void pc_memory_init(const char *kernel_filename,
>> -                    const char *kernel_cmdline,
>> -                    const char *initrd_filename,
>> -                    ram_addr_t below_4g_mem_size,
>> -                    ram_addr_t above_4g_mem_size)
>> +static void pc_isa_bios_init(ram_addr_t ram_offset, int ram_size)
>>  {
>> -    char *filename;
>> -    int ret, linux_boot, i;
>> -    ram_addr_t ram_addr, bios_offset, option_rom_offset;
>> -    int bios_size, isa_bios_size;
>> -    void *fw_cfg;
>> -
>> -    linux_boot = (kernel_filename != NULL);
>> +    int isa_bios_size;
>>
>> -    /* allocate RAM */
>> -    ram_addr = qemu_ram_alloc(NULL, "pc.ram",
>> -                              below_4g_mem_size + above_4g_mem_size);
>> -    cpu_register_physical_memory(0, 0xa, ram_addr);
>> -    cpu_register_physical_memory(0x10,
>> -                 below_4g_mem_size - 0x10,
>> -                 ram_addr + 0x10);
>> -    if (above_4g_mem_size>  0) {
>> -        cpu_register_physical_memory(0x1ULL, above_4g_mem_size,
>> -                                     ram_addr + below_4g_mem_size);
>> +    /* map the last 128KB of the BIOS in ISA space */
>> +    isa_bios_size = ram_size;
>> +    if (isa_bios_size>  (128 * 1024)) {
>> +        isa_bios_size = 128 * 1024;
>>      }
>> +    ram_offset = ram_offset + ram_size - isa_bios_size;
>> +    cpu_register_physical_memory(0x10 - isa_bios_size,
>> +                                 isa_bios_size,
>> +                                 ram_offset | IO_MEM_ROM);
>> +}
>> +
>> +static int pc_system_rom_init(void)
>> +{
>> +    int ret;
>> +    int bios_size;
>> +    ram_addr_t bios_offset;
>> +    char *filename;
>>
>>      /* BIOS load */
>> -    if (bios_name == NULL)
>> +    if (bios_name == NULL) {
>>          bios_name = BIOS_FILENAME;
>> +    }
>>      filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
>>      if (filename) {
>>

[Qemu-devel] [PATCH 5/7] target-alpha: Implement WAIT IPR.

2011-07-23 Thread Richard Henderson
---
 target-alpha/translate.c |   31 +--
 1 files changed, 21 insertions(+), 10 deletions(-)

diff --git a/target-alpha/translate.c b/target-alpha/translate.c
index c61906a..fddaff8 100644
--- a/target-alpha/translate.c
+++ b/target-alpha/translate.c
@@ -1617,9 +1617,10 @@ static void gen_mfpr(int ra, int regno)
 }
 }
 
-static void gen_mtpr(int rb, int regno)
+static ExitStatus gen_mtpr(DisasContext *ctx, int rb, int regno)
 {
 TCGv tmp;
+int data;
 
 if (rb == 31) {
 tmp = tcg_const_i64(0);
@@ -1627,19 +1628,27 @@ static void gen_mtpr(int rb, int regno)
 tmp = cpu_ir[rb];
 }
 
-/* These two register numbers perform a TLB cache flush.  Thankfully we
-   can only do this inside PALmode, which means that the current basic
-   block cannot be affected by the change in mappings.  */
-if (regno == 255) {
+switch (regno) {
+case 255:
 /* TBIA */
 gen_helper_tbia();
-} else if (regno == 254) {
+break;
+
+case 254:
 /* TBIS */
 gen_helper_tbis(tmp);
-} else {
+break;
+
+case 253:
+/* WAIT */
+tmp = tcg_const_i64(1);
+tcg_gen_st32_i64(tmp, cpu_env, offsetof(CPUState, halted));
+return gen_excp(ctx, EXCP_HLT, 0);
+
+default:
 /* The basic registers are data only, and unknown registers
are read-zero, write-ignore.  */
-int data = cpu_pr_data(regno);
+data = cpu_pr_data(regno);
 if (data != 0) {
 if (data & PR_BYTE) {
 tcg_gen_st8_i64(tmp, cpu_env, data & ~PR_BYTE);
@@ -1649,11 +1658,14 @@ static void gen_mtpr(int rb, int regno)
 tcg_gen_st_i64(tmp, cpu_env, data);
 }
 }
+break;
 }
 
 if (rb == 31) {
 tcg_temp_free(tmp);
 }
+
+return NO_EXIT;
 }
 #endif /* !USER_ONLY*/
 
@@ -3053,8 +3065,7 @@ static ExitStatus translate_one(DisasContext *ctx, 
uint32_t insn)
 /* HW_MTPR (PALcode) */
 #ifndef CONFIG_USER_ONLY
 if (ctx->tb->flags & TB_FLAGS_PAL_MODE) {
-gen_mtpr(rb, insn & 0x);
-break;
+return gen_mtpr(ctx, rb, insn & 0x);
 }
 #endif
 goto invalid_opc;
-- 
1.7.4.4




[Qemu-devel] [PULL 0/7] Alpha system emulation, v7

2011-07-23 Thread Richard Henderson
Changes v6->v7

  * Rebase against master, which now includes 2 patches from v6.

The tree is available at

  git://repo.or.cz/qemu/rth.git axp-system-5

Please pull, review, or something.



r~



Richard Henderson (7):
  Export the unassigned_mem read/write functions.
  pci: Export pci_to_cpu_addr.
  target-alpha: Add custom PALcode image for CLIPPER emulation.
  target-alpha: Add CLIPPER emulation.
  target-alpha: Implement WAIT IPR.
  target-alpha: Implement HALT IPR.
  target-alpha: Add high-resolution access to wall clock and an alarm.

 .gitmodules   |3 +
 Makefile  |3 +-
 Makefile.target   |1 +
 configure |8 +-
 cpu-common.h  |7 +
 default-configs/alpha-softmmu.mak |2 +
 exec.c|   12 +-
 hw/alpha_dp264.c  |  188 +
 hw/alpha_pci.c|  358 +
 hw/alpha_sys.h|   44 ++
 hw/alpha_typhoon.c|  799 +
 hw/pci.c  |3 +-
 hw/pci.h  |1 +
 pc-bios/README|3 +
 pc-bios/palcode-clipper   |  Bin 0 -> 185703 bytes
 roms/qemu-palcode |1 +
 target-alpha/cpu.h|4 +
 target-alpha/helper.h |5 +
 target-alpha/op_helper.c  |   25 ++
 target-alpha/translate.c  |   50 ++-
 20 files changed, 1497 insertions(+), 20 deletions(-)
 create mode 100644 hw/alpha_dp264.c
 create mode 100644 hw/alpha_pci.c
 create mode 100644 hw/alpha_sys.h
 create mode 100644 hw/alpha_typhoon.c
 create mode 100755 pc-bios/palcode-clipper
 create mode 16 roms/qemu-palcode

-- 
1.7.4.4




[Qemu-devel] [PATCH 6/7] target-alpha: Implement HALT IPR.

2011-07-23 Thread Richard Henderson
Signed-off-by: Richard Henderson 
---
 target-alpha/helper.h|1 +
 target-alpha/op_helper.c |   10 ++
 target-alpha/translate.c |5 +
 3 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/target-alpha/helper.h b/target-alpha/helper.h
index 2dec57e..c352c24 100644
--- a/target-alpha/helper.h
+++ b/target-alpha/helper.h
@@ -113,6 +113,7 @@ DEF_HELPER_2(stq_c_phys, i64, i64, i64)
 
 DEF_HELPER_FLAGS_0(tbia, TCG_CALL_CONST, void)
 DEF_HELPER_FLAGS_1(tbis, TCG_CALL_CONST, void, i64)
+DEF_HELPER_1(halt, void, i64);
 #endif
 
 #include "def-helper.h"
diff --git a/target-alpha/op_helper.c b/target-alpha/op_helper.c
index 8f39154..ad85e4c 100644
--- a/target-alpha/op_helper.c
+++ b/target-alpha/op_helper.c
@@ -21,6 +21,7 @@
 #include "host-utils.h"
 #include "softfloat.h"
 #include "helper.h"
+#include "sysemu.h"
 #include "qemu-timer.h"
 
 /*/
@@ -1215,6 +1216,15 @@ void helper_tbis(uint64_t p)
 {
 tlb_flush_page(env, p);
 }
+
+void helper_halt(uint64_t restart)
+{
+if (restart) {
+qemu_system_reset_request();
+} else {
+qemu_system_shutdown_request();
+}
+}
 #endif
 
 /*/
diff --git a/target-alpha/translate.c b/target-alpha/translate.c
index fddaff8..b1609e3 100644
--- a/target-alpha/translate.c
+++ b/target-alpha/translate.c
@@ -1645,6 +1645,11 @@ static ExitStatus gen_mtpr(DisasContext *ctx, int rb, 
int regno)
 tcg_gen_st32_i64(tmp, cpu_env, offsetof(CPUState, halted));
 return gen_excp(ctx, EXCP_HLT, 0);
 
+case 252:
+/* HALT */
+gen_helper_halt(tmp);
+return EXIT_PC_STALE;
+
 default:
 /* The basic registers are data only, and unknown registers
are read-zero, write-ignore.  */
-- 
1.7.4.4




Re: [Qemu-devel] [PATCH] guest agent: qemu-ga daemon

2011-07-23 Thread Alexander Graf

On 23.07.2011, at 21:23, Jes Sorensen wrote:

> On 07/23/11 18:10, Anthony Liguori wrote:
>> 
 qga/guest-agent-commands.c: In function ‘qmp_guest_fsfreeze_freeze’:
 qga/guest-agent-commands.c:443: error: ‘FIFREEZE’ undeclared (first
 use in this function)
 qga/guest-agent-commands.c:443: error: (Each undeclared identifier is
 reported only once
 qga/guest-agent-commands.c:443: error: for each function it appears in.)
 qga/guest-agent-commands.c: In function ‘qmp_guest_fsfreeze_thaw’:
 qga/guest-agent-commands.c:481: error: ‘FITHAW’ undeclared (first use
 in this function)
>> 
>> The kernel probably doesn't implement FIFREEZE.  You need to do a
>> configure test and set CONFIG_FSFREEZE appropriately.  I anticipated
>> this and that's why I added CONFIG_FSFREEZE and didn't just do __linux__.
> 
> That would be odd, FIFREEZE has been around since at least January 2009
> according to git blame (fcccf502540e3d752d33b2d8e976034dee81f9f7). Is
> OpenSuSE 11 that old?

http://news.opensuse.org/2008/12/18/opensuse-111-released/

In short: yes, it is :)


Alex



Re: [Qemu-devel] [PATCH] guest agent: qemu-ga daemon

2011-07-23 Thread Jes Sorensen
On 07/23/11 18:10, Anthony Liguori wrote:
> 
>>> qga/guest-agent-commands.c: In function ‘qmp_guest_fsfreeze_freeze’:
>>> qga/guest-agent-commands.c:443: error: ‘FIFREEZE’ undeclared (first
>>> use in this function)
>>> qga/guest-agent-commands.c:443: error: (Each undeclared identifier is
>>> reported only once
>>> qga/guest-agent-commands.c:443: error: for each function it appears in.)
>>> qga/guest-agent-commands.c: In function ‘qmp_guest_fsfreeze_thaw’:
>>> qga/guest-agent-commands.c:481: error: ‘FITHAW’ undeclared (first use
>>> in this function)
> 
> The kernel probably doesn't implement FIFREEZE.  You need to do a
> configure test and set CONFIG_FSFREEZE appropriately.  I anticipated
> this and that's why I added CONFIG_FSFREEZE and didn't just do __linux__.

That would be odd, FIFREEZE has been around since at least January 2009
according to git blame (fcccf502540e3d752d33b2d8e976034dee81f9f7). Is
OpenSuSE 11 that old?

That said, having a test for it being present is a good idea.

Cheers,
Jes




Re: [Qemu-devel] [PATCH] guest agent: qemu-ga daemon

2011-07-23 Thread Alexander Graf

On 23.07.2011, at 21:14, Anthony Liguori wrote:

> On 07/23/2011 01:34 PM, Alexander Graf wrote:
>> 
>> On 23.07.2011, at 18:43, Michael Roth wrote:
>> 
>>> On 07/23/2011 11:10 AM, Anthony Liguori wrote:
 On 07/23/2011 11:06 AM, Michael Roth wrote:
> On 07/23/2011 05:07 AM, Alexander Graf wrote:
>> 
>> On 20.07.2011, at 22:19, Michael Roth wrote:
>> 
>>> This is the actual guest daemon, it listens for requests over a
>>> virtio-serial/isa-serial/unix socket channel and routes them through
>>> to dispatch routines, and writes the results back to the channel in
>>> a manner similar to QMP.
>>> 
>>> A shorthand invocation:
>>> 
>>> qemu-ga -d
>>> 
>>> Is equivalent to:
>>> 
>>> qemu-ga -m virtio-serial -p /dev/virtio-ports/org.qemu.guest_agent.0 \
>>> -f /var/run/qemu-ga.pid -d
>>> 
>>> Signed-off-by: Michael Roth
>> 
>> A rebase on top of current HEAD gave me the following on openSUSE 11.1
>> PPC:
>> 
>> 
>> agraf@lychee:/home/agraf/release/qemu>  make
>> CC qemu-ga.o
>> qemu-ga.c:40: error: expected specifier-qualifier-list before ‘GSocket’
 
 GIO is fairly new. It may not be available on openSUSE.
 
 Mike, you probably need to do a configure test for GIO and if it's not
 present, don't build qemu-ga.
>>> 
>>> It should've failed the glib probe in that case. I think we might need a 
>>> compile test to catch this GSocket issue.
>>> 
>>> Rather than building qemu-ga when possible, should we just go ahead and add 
>>> a configure option and only run the probes when it's set? At least until 
>>> QMP/QEMU start formally using glib? If so, on or off by default?
>> 
>> In general, I like the workflow of adding a feature with default off and 
>> then enabling it after it has been in for a couple of weeks. Since this got 
>> pushed so late for 0.15, I'd personally prefer to see it as preview 
>> (disabled by default) in 0.15 and only enabled by default if the 
>> requirements are there on 0.16.
> 
> The only way something like this gets tested is to default it on.
> 
> We default off'd the I/O thread even after years we still don't have it 
> enabled.
> 
> With respect to 0.15, this bit of code is totally isolated from everything 
> else.  Worst case scenario, we just disable it on platforms where it doesn't 
> work.  It presents no real risk to the stability of the release.

As you've seen, it can break builds. Why not wait for 0.16? The code came in 
more than 2 months after the soft feature freeze, which was specifically for 
big features like this, no?


Alex




Re: [Qemu-devel] [PATCH] guest agent: qemu-ga daemon

2011-07-23 Thread Alexander Graf

On 23.07.2011, at 21:12, Anthony Liguori wrote:

> On 07/23/2011 01:35 PM, Alexander Graf wrote:
>> 
>> On 23.07.2011, at 18:49, Anthony Liguori wrote:
>> 
>>> On 07/23/2011 11:43 AM, Michael Roth wrote:
 On 07/23/2011 11:10 AM, Anthony Liguori wrote:
> On 07/23/2011 11:06 AM, Michael Roth wrote:
>> On 07/23/2011 05:07 AM, Alexander Graf wrote:
>>> 
>>> On 20.07.2011, at 22:19, Michael Roth wrote:
>>> 
 This is the actual guest daemon, it listens for requests over a
 virtio-serial/isa-serial/unix socket channel and routes them through
 to dispatch routines, and writes the results back to the channel in
 a manner similar to QMP.
 
 A shorthand invocation:
 
 qemu-ga -d
 
 Is equivalent to:
 
 qemu-ga -m virtio-serial -p /dev/virtio-ports/org.qemu.guest_agent.0 \
 -f /var/run/qemu-ga.pid -d
 
 Signed-off-by: Michael Roth
>>> 
>>> A rebase on top of current HEAD gave me the following on openSUSE 11.1
>>> PPC:
>>> 
>>> 
>>> agraf@lychee:/home/agraf/release/qemu>  make
>>> CC qemu-ga.o
>>> qemu-ga.c:40: error: expected specifier-qualifier-list before ‘GSocket’
> 
> GIO is fairly new. It may not be available on openSUSE.
> 
> Mike, you probably need to do a configure test for GIO and if it's not
> present, don't build qemu-ga.
 
 It should've failed the glib probe in that case. I think we might need a
 compile test to catch this GSocket issue.
>>> 
>>> Indeed.  Alex, can you help debug this a bit?  We can tr to setup a SUSE 
>>> system.
>> 
>> It's not only about SUSE vs. non-SUSE. This was 11.1 (ancient, but latest 
>> ppc release) on PowerPC.
>> 
>>> Can you confirm that gio is actually present?
>> 
>> Sure, tell me how :). I'm fairly ignorant when it comes to g* stuff.
> 
> pkg-config --modversion gio-2.0


agraf@lychee:~> pkg-config --modversion gio-2.0
2.18.2


Alex




[Qemu-devel] [PATCH 4/7] target-alpha: Add CLIPPER emulation.

2011-07-23 Thread Richard Henderson
This is a DP264 variant, SMP capable, no unusual hardware present.

The emulation does not currently include any PCI IOMMU code.
Hopefully the generic support for that can be merged to HEAD soon.

Signed-off-by: Richard Henderson 
---
 Makefile.target   |1 +
 default-configs/alpha-softmmu.mak |2 +
 hw/alpha_dp264.c  |  188 +
 hw/alpha_pci.c|  358 +
 hw/alpha_sys.h|   44 ++
 hw/alpha_typhoon.c|  781 +
 6 files changed, 1374 insertions(+), 0 deletions(-)
 create mode 100644 hw/alpha_dp264.c
 create mode 100644 hw/alpha_pci.c
 create mode 100644 hw/alpha_sys.h
 create mode 100644 hw/alpha_typhoon.c

diff --git a/Makefile.target b/Makefile.target
index cde509b..08fb2ec 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -371,6 +371,7 @@ obj-s390x-y = s390-virtio-bus.o s390-virtio.o
 
 obj-alpha-y = i8259.o mc146818rtc.o
 obj-alpha-y += vga.o cirrus_vga.o
+obj-alpha-y += alpha_pci.o alpha_dp264.o alpha_typhoon.o
 
 main.o: QEMU_CFLAGS+=$(GPROF_CFLAGS)
 
diff --git a/default-configs/alpha-softmmu.mak 
b/default-configs/alpha-softmmu.mak
index abadcff..be86d0c 100644
--- a/default-configs/alpha-softmmu.mak
+++ b/default-configs/alpha-softmmu.mak
@@ -3,7 +3,9 @@
 include pci.mak
 CONFIG_SERIAL=y
 CONFIG_I8254=y
+CONFIG_PCKBD=y
 CONFIG_VGA_PCI=y
 CONFIG_IDE_CORE=y
 CONFIG_IDE_QDEV=y
 CONFIG_VMWARE_VGA=y
+CONFIG_IDE_CMD646=y
diff --git a/hw/alpha_dp264.c b/hw/alpha_dp264.c
new file mode 100644
index 000..6fdfabe
--- /dev/null
+++ b/hw/alpha_dp264.c
@@ -0,0 +1,188 @@
+/*
+ * QEMU Alpha DP264/CLIPPER hardware system emulator.
+ *
+ * Choose CLIPPER IRQ mappings over, say, DP264, MONET, or WEBBRICK
+ * variants because CLIPPER doesn't have an SMC669 SuperIO controler
+ * that we need to emulate as well.
+ */
+
+#include "hw.h"
+#include "elf.h"
+#include "loader.h"
+#include "boards.h"
+#include "alpha_sys.h"
+#include "sysemu.h"
+#include "mc146818rtc.h"
+#include "ide.h"
+
+#define MAX_IDE_BUS 2
+
+static uint64_t cpu_alpha_superpage_to_phys(void *opaque, uint64_t addr)
+{
+if (((addr >> 41) & 3) == 2) {
+addr &= 0xffull;
+}
+return addr;
+}
+
+/* Note that there are at least 3 viewpoints of IRQ numbers on Alpha systems.
+(0) The dev_irq_n lines into the cpu, which we totally ignore,
+(1) The DRIR lines in the typhoon chipset,
+(2) The "vector" aka mangled interrupt number reported by SRM PALcode,
+(3) The interrupt number assigned by the kernel.
+   The following function is concerned with (1) only.  */
+
+static int clipper_pci_map_irq(PCIDevice *d, int irq_num)
+{
+int slot = d->devfn >> 3;
+
+assert(irq_num >= 0 && irq_num <= 3);
+
+return (slot + 1) * 4 + irq_num;
+}
+
+static void clipper_init(ram_addr_t ram_size,
+ const char *boot_device,
+ const char *kernel_filename,
+ const char *kernel_cmdline,
+ const char *initrd_filename,
+ const char *cpu_model)
+{
+CPUState *cpus[4];
+ram_addr_t ram_offset;
+PCIBus *pci_bus;
+qemu_irq isa_pci_irq, rtc_irq, *isa_irqs;
+long size, i;
+const char *palcode_filename;
+uint64_t palcode_entry, palcode_low, palcode_high;
+uint64_t kernel_entry, kernel_low, kernel_high;
+
+/* Create up to 4 cpus.  */
+memset(cpus, 0, sizeof(cpus));
+for (i = 0; i < smp_cpus; ++i) {
+cpus[i] = cpu_init(cpu_model ? cpu_model : "ev67");
+}
+
+cpus[0]->trap_arg0 = ram_size;
+cpus[0]->trap_arg1 = 0;
+cpus[0]->trap_arg2 = smp_cpus;
+
+ram_offset = qemu_ram_alloc(NULL, "ram", ram_size);
+cpu_register_physical_memory(0, ram_size, ram_offset);
+
+/* Init the chipset.  */
+pci_bus = typhoon_init(&isa_pci_irq, &rtc_irq, cpus, clipper_pci_map_irq);
+
+/* Init the ISA bus.  */
+isa_bus_new(NULL);
+isa_mem_base = pci_to_cpu_addr(pci_bus, 0);
+
+isa_irqs = i8259_init(isa_pci_irq);
+isa_bus_irqs(isa_irqs);
+
+rtc_init(1980, rtc_irq);
+pit_init(0x40, 0);
+isa_create_simple("i8042");
+
+/* VGA setup.  Don't bother loading the bios.  */
+alpha_pci_vga_setup(pci_bus);
+
+/* Serial code setup.  */
+for (i = 0; i < MAX_SERIAL_PORTS; ++i) {
+if (serial_hds[i]) {
+serial_isa_init(i, serial_hds[i]);
+}
+}
+
+/* Network setup.  e1000 is good enough, failing Tulip support.  */
+for (i = 0; i < nb_nics; i++) {
+pci_nic_init_nofail(&nd_table[i], "e1000", NULL);
+}
+
+/* IDE disk setup.  */
+{
+DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
+ide_drive_get(hd, MAX_IDE_BUS);
+
+pci_cmd646_ide_init(pci_bus, hd, 0);
+}
+
+/* Load PALcode.  Given that this is not "real" cpu palcode,
+   but one explicitly written for the emulation, we might as
+   well load it directly fr

[Qemu-devel] [PATCH 7/7] target-alpha: Add high-resolution access to wall clock and an alarm.

2011-07-23 Thread Richard Henderson
The alarm is a fully general one-shot time comparator, which will be
usable under Linux as a hrtimer source.  It's much more flexible than
the RTC source available on real hardware.

The wall clock allows the guest access to the host timekeeping.  Much
like the KVM wall clock source for other guests.

Both are accessed via the PALcode Cserve entry point.

Signed-off-by: Richard Henderson 
---
 hw/alpha_typhoon.c   |   22 --
 target-alpha/cpu.h   |4 
 target-alpha/helper.h|4 
 target-alpha/op_helper.c |   15 +++
 target-alpha/translate.c |   14 ++
 5 files changed, 57 insertions(+), 2 deletions(-)

diff --git a/hw/alpha_typhoon.c b/hw/alpha_typhoon.c
index 7cdf7d3..731b6ea 100644
--- a/hw/alpha_typhoon.c
+++ b/hw/alpha_typhoon.c
@@ -681,6 +681,16 @@ static void typhoon_set_timer_irq(void *opaque, int irq, 
int level)
 }
 }
 
+static void typhoon_alarm_timer(void *opaque)
+{
+TyphoonState *s = (TyphoonState *)((uintptr_t)opaque & ~3);
+int cpu = (uintptr_t)opaque & 3;
+
+/* Set the ITI bit for this cpu.  */
+s->cchip.misc |= 1 << (cpu + 4);
+cpu_interrupt(s->cchip.cpu[cpu], CPU_INTERRUPT_TIMER);
+}
+
 PCIBus *typhoon_init(qemu_irq *p_isa_irq, qemu_irq *p_rtc_irq,
  CPUState *cpus[3], pci_map_irq_fn sys_map_irq)
 {
@@ -689,14 +699,22 @@ PCIBus *typhoon_init(qemu_irq *p_isa_irq, qemu_irq 
*p_rtc_irq,
 PCIHostState *p;
 TyphoonState *s;
 PCIBus *b;
-int region;
+int i, region;
 
 dev = qdev_create(NULL, "typhoon-pcihost");
 p = FROM_SYSBUS(PCIHostState, sysbus_from_qdev(dev));
 s = container_of(p, TyphoonState, host);
 
 /* Remember the CPUs so that we can deliver interrupts to them.  */
-memcpy(s->cchip.cpu, cpus, 4 * sizeof(CPUState *));
+for (i = 0; i < 4; i++) {
+CPUState *env = cpus[i];
+s->cchip.cpu[i] = env;
+if (env) {
+env->alarm_timer = qemu_new_timer_ns(rtc_clock,
+ typhoon_alarm_timer,
+ (void *)((uintptr_t)s + i));
+}
+}
 
 *p_isa_irq = *qemu_allocate_irqs(typhoon_set_isa_irq, s, 1);
 *p_rtc_irq = *qemu_allocate_irqs(typhoon_set_timer_irq, s, 1);
diff --git a/target-alpha/cpu.h b/target-alpha/cpu.h
index 919be12..d0b569b 100644
--- a/target-alpha/cpu.h
+++ b/target-alpha/cpu.h
@@ -265,6 +265,10 @@ struct CPUAlphaState {
 uint64_t scratch[24];
 #endif
 
+/* This alarm doesn't exist in real hardware; we wish it did.  */
+struct QEMUTimer *alarm_timer;
+uint64_t alarm_expire;
+
 #if TARGET_LONG_BITS > HOST_LONG_BITS
 /* temporary fixed-point registers
  * used to emulate 64 bits target on 32 bits hosts
diff --git a/target-alpha/helper.h b/target-alpha/helper.h
index c352c24..b693cee 100644
--- a/target-alpha/helper.h
+++ b/target-alpha/helper.h
@@ -113,7 +113,11 @@ DEF_HELPER_2(stq_c_phys, i64, i64, i64)
 
 DEF_HELPER_FLAGS_0(tbia, TCG_CALL_CONST, void)
 DEF_HELPER_FLAGS_1(tbis, TCG_CALL_CONST, void, i64)
+
 DEF_HELPER_1(halt, void, i64);
+
+DEF_HELPER_FLAGS_0(get_time, TCG_CALL_CONST, i64)
+DEF_HELPER_FLAGS_1(set_alarm, TCG_CALL_CONST, void, i64)
 #endif
 
 #include "def-helper.h"
diff --git a/target-alpha/op_helper.c b/target-alpha/op_helper.c
index ad85e4c..623f1c3 100644
--- a/target-alpha/op_helper.c
+++ b/target-alpha/op_helper.c
@@ -1225,6 +1225,21 @@ void helper_halt(uint64_t restart)
 qemu_system_shutdown_request();
 }
 }
+
+uint64_t helper_get_time(void)
+{
+return qemu_get_clock_ns(rtc_clock);
+}
+
+void helper_set_alarm(uint64_t expire)
+{
+if (expire) {
+env->alarm_expire = expire;
+qemu_mod_timer(env->alarm_timer, expire);
+} else {
+qemu_del_timer(env->alarm_timer);
+}
+}
 #endif
 
 /*/
diff --git a/target-alpha/translate.c b/target-alpha/translate.c
index b1609e3..f386d21 100644
--- a/target-alpha/translate.c
+++ b/target-alpha/translate.c
@@ -1590,6 +1590,9 @@ static int cpu_pr_data(int pr)
 return offsetof(CPUAlphaState, shadow[pr - 32]);
 case 40 ... 63:
 return offsetof(CPUAlphaState, scratch[pr - 40]);
+
+case 251:
+return offsetof(CPUAlphaState, alarm_expire);
 }
 return 0;
 }
@@ -1604,6 +1607,12 @@ static void gen_mfpr(int ra, int regno)
 return;
 }
 
+if (regno == 250) {
+/* WALL_TIME */
+gen_helper_get_time(cpu_ir[ra]);
+return;
+}
+
 /* The basic registers are data only, and unknown registers
are read-zero, write-ignore.  */
 if (data == 0) {
@@ -1650,6 +1659,11 @@ static ExitStatus gen_mtpr(DisasContext *ctx, int rb, 
int regno)
 gen_helper_halt(tmp);
 return EXIT_PC_STALE;
 
+case 251:
+/* ALARM */
+gen_helper_set_alarm(tmp);
+break;
+
 default:
 /* The basic regist

[Qemu-devel] [PATCH 3/7] target-alpha: Add custom PALcode image for CLIPPER emulation.

2011-07-23 Thread Richard Henderson
Signed-off-by: Richard Henderson 
---
 .gitmodules |3 +++
 Makefile|3 ++-
 configure   |8 +++-
 pc-bios/README  |3 +++
 pc-bios/palcode-clipper |  Bin 0 -> 185703 bytes
 roms/qemu-palcode   |1 +
 6 files changed, 16 insertions(+), 2 deletions(-)
 create mode 100755 pc-bios/palcode-clipper
 create mode 16 roms/qemu-palcode

diff --git a/.gitmodules b/.gitmodules
index 7884471..528743d 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -10,3 +10,6 @@
 [submodule "roms/ipxe"]
path = roms/ipxe
url = git://git.qemu.org/ipxe.git
+[submodule "roms/qemu-palcode"]
+   path = roms/qemu-palcode
+   url = git://repo.or.cz/qemu-palcode.git
diff --git a/Makefile b/Makefile
index f3a03ad..310608b 100644
--- a/Makefile
+++ b/Makefile
@@ -243,7 +243,8 @@ bamboo.dtb petalogix-s3adsp1800.dtb petalogix-ml605.dtb \
 mpc8544ds.dtb \
 multiboot.bin linuxboot.bin \
 s390-zipl.rom \
-spapr-rtas.bin slof.bin
+spapr-rtas.bin slof.bin \
+palcode-sx164
 else
 BLOBS=
 endif
diff --git a/configure b/configure
index 6911c3b..6a8a4c8 100755
--- a/configure
+++ b/configure
@@ -3522,7 +3522,13 @@ FILES="$FILES tests/cris/Makefile tests/cris/.gdbinit"
 FILES="$FILES pc-bios/optionrom/Makefile pc-bios/keymaps"
 FILES="$FILES pc-bios/spapr-rtas/Makefile"
 FILES="$FILES roms/seabios/Makefile roms/vgabios/Makefile"
-for bios_file in $source_path/pc-bios/*.bin $source_path/pc-bios/*.rom 
$source_path/pc-bios/*.dtb $source_path/pc-bios/openbios-*; do
+for bios_file in \
+$source_path/pc-bios/*.bin \
+$source_path/pc-bios/*.rom \
+$source_path/pc-bios/*.dtb \
+$source_path/pc-bios/openbios-* \
+$source_path/pc-bios/palcode-*
+do
 FILES="$FILES pc-bios/`basename $bios_file`"
 done
 mkdir -p $DIRS
diff --git a/pc-bios/README b/pc-bios/README
index f74b246..861227a 100644
--- a/pc-bios/README
+++ b/pc-bios/README
@@ -32,3 +32,6 @@
 - The S390 zipl loader is an addition to the official IBM s390-tools
   package. That fork is maintained in its own git repository at:
   git://repo.or.cz/s390-tools.git
+
+- The Alpha palcode image is available from:
+  git://repo.or.cz/qemu-palcode.git
diff --git a/pc-bios/palcode-clipper b/pc-bios/palcode-clipper
new file mode 100755
index 
..a92372c107af72071e265e1ca94b9ae5573bd317
GIT binary patch
literal 185703
zcmeFa3w%`7wLiYk%w%RlUK29~x%YGb
zpa16^NX~w&*Is+=wb$C`%w)~Xvu1fLOPI?ej$W6j^~K{+-Erp+JqAQXMYZtYcabO*
zgbm1^1eOrMlTEm9|Gh%%uQUDXe)eBhEb^YQWWis{vO7t_EBUxEgRZ;A+6tfU5yl1Fi;K4Y(R`HQ;K%
z)qtx3R|BpFTn)Gya5dm+z}0}O0apXA23!re8gMn>YQWWis{vO7t_EBUxEgRZ;A+6t
zfU5yl1Fi;K4Y(R`HQ;K%)qtx3R|BpFTn)Gya5dm+z}0}O0apXA23!re8gMn>YQWWi
zs{vO7t_EBUxEgRZ;A+6tfU5yl1Fi;K4Y(R`HQ;K%)qtx3R|BpFTn)Gya5dm+z}0}O
z0apXA23!re8gMn>YQWWis{vO7t_EBUxEgRZ;A+6tfU5yl1Fi;K4Y(R`HQ;K%)qtx3
zR|BpFTn)Gya5dm+z}0}O0apXA23!re8gMn>YQWWis{vO7t_EBUxEgRZ;A+6tfU5yl
z1Fi;K4Y(R`HQ;K%)qtx3R|BpFTn)Gya5dm+z}0}O0apXA23!re8gMn>YQWWis{vO7
zt_EBUxEgRZ;A+6tfU5yl1Fi;K4Y(R`HQ;K%)qtx3R|BpFTn)Gya5dm+z}0}O0apXA
z23!re8gMn>YQWWis{vO7t_EBUxEgRZ;A+6tfU5yl1Fi;K4Y(R`HQ;K%)qtx3R|BpF
zTn)Gya5dm+z}0}O0apXA23!re8gMn>YQWWis{vO7t_EBUxEgRZ;A+6tfU5yl1Fi->
zzXsa3SmK#uZa(*!u_uVnRs}@F7Gl?`yl7cP_zCYBZK2T8P_vjN?1=4|B4${k;w&L9
zs%-w|410{PBDyd)`m$e$eO^)4=o68~EHSS!9>4aOqPMRZE80H2hUFez{`@lj?_v7I
z8<$|LQqcjCnjLc03*u&puHi#%#95^vzY`;?2QVcFq=J&#L1=NqWv7D|C
zsbep6EJS?O;pllH=0)>P*q&(H^SStE-`Z9C-9ySSeZX8-Wh{dlKlxwvIrtx|`G+_s
zM?7}Uh~od{L-HPI=M&P#o(caGKL`KB*jIesu@7#MZmX*SR|BpFTn)Gya5dm+z}0}O
zf&ag1V1CekIZKq;eaN|%26t{b;&Hack1*d#mIXYNg?+-?C{&BfO%?B(p_isN}%xDgXy$&-iVW7uFlQEXNhIgEPlz6JPMA&OeMDNmx*577$#NSqlP}iDVQMNc35^F{}WX{QO
z{5gz2jxgqP>dzy@KjX+C&A{IWe`{VQFwgs{7MhLzj3{_+`k26|ZW
zE1sV$3Lyp(y`oNhE?s0c{_yAGnbcrzhWMGx9i@OxWiK-+
z;St(mQ1oxa^WO)Qg_dLy1gZ-h)^^R8^4nG;$&^9*0?AGy74$kE=z8u^<;rsw4I
z*I7RM<;3$eDbL|PM^*S!o%k}3J3RcCyczm0q4)Z)Ax7Qik}?Wr+XN4Ds*H5dW48@z-RCzbr%ic^Tph9lvd~9P#HlhyOlTBt!m_
zGQ=;-5WgTp{J6+${eF-k{u>$Mzmy^Va~b0QG(-G*GsM3oL;N)v;xEe(e_n?8b27w_
zWQad0L;SJ~@e4AY?8TX=xlk0`cEB~e5&uLUsC8R
zto>AyuGkN_vc)#eA8pi!pk5W)wsd&73unLkR)x@3{e*R95bfqX@HibCP0;s=`hKjw
zSLyqBeV2NW=RbeNJO2Ih42NeWJX`SMY+>Mg>CX=O{=aDZB<1Wdh`I6O9gE@6br#A2
zl!u}0LD_?Hh&F(8*vaBvoaL;!BquZ<{9^L62EkCz8V~v@k3jibIG@cCKgRiN)3rme
zciN#x@Qm5;>z~x-iP&xad3Kw3jV%KA+F1=^)-Qbb)ot;0)MeqEeB2+}>n-27sMmK%
zG%xy`J?@G76ZMlZH>Y4ethRq%elkAGAwrXvF8(y~_Lcq*mv{c-=oy7Y6*F+g@^(-}
zj^1xgu9!Sx>={B#UOM>>`wS7BTp{J4{_vwdA93*$I3Ihwz}G+976qF_;)5q_F{z_O
zOxhI0m~ih9qP!y{=5$!T+Gq&vYzvBVn=pj6ty-2lHUw&;AH^fP*+zJ@ZyMwK0B3C%
zKL{QV@T`k+TjD>C>8f~U>`wXlj3j@{*E<_@Aj72UaNDW25Ve#;^PN+LdbN|D?V#5T
zdV`Ip3iR%5JGH~(+cg_yNh=<&wOKCD+I5;GYU?;ADX;DaJnEAqjvR~c&Dn)me?vh-
zi2h06DvrL)JAW)6)-l?ha+z_ak1quMT39m}Q)h{o({6!oZIK;?3{lHhjyvS(RCmhr
zb$@Mr+#9heV>%Br_QA$XnalT$tuJ3yQLn~^aTk`uhB;2m=Ml(D__f0;>nolpuaCzg
zcKLbZV2icUbQ(q;&h2jdnX#RTx#j0Elzl}p{(8)Z5T{l)|ES!CoSV?L(Sy(3Y>Ll&
znYzThY~tM14!5JWwmI705Ml2gtUZLW{8rbb&!^mSno^=_>^OFO}bDnOm9z>pM$aAwp9>65zq3tytKpu{z9=O*!aFez;9p}yc
z4>UN|Nqw1f-6iKH9>-_Nruoj`T$~MB*|cjpPgX@^g7!s~rwzAjn}0OJ_V^Y=g{ash
zLS;uwxOdAdz7D

[Qemu-devel] [PATCH 1/7] Export the unassigned_mem read/write functions.

2011-07-23 Thread Richard Henderson
Signed-off-by: Richard Henderson 
---
 cpu-common.h |7 +++
 exec.c   |   12 ++--
 2 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/cpu-common.h b/cpu-common.h
index 44b04b3..78e1bad 100644
--- a/cpu-common.h
+++ b/cpu-common.h
@@ -56,6 +56,13 @@ static inline void 
cpu_register_physical_memory(target_phys_addr_t start_addr,
 cpu_register_physical_memory_offset(start_addr, size, phys_offset, 0);
 }
 
+extern CPUReadMemoryFunc unassigned_mem_readb;
+extern CPUReadMemoryFunc unassigned_mem_readw;
+extern CPUReadMemoryFunc unassigned_mem_readl;
+extern CPUWriteMemoryFunc unassigned_mem_writeb;
+extern CPUWriteMemoryFunc unassigned_mem_writew;
+extern CPUWriteMemoryFunc unassigned_mem_writel;
+
 ram_addr_t cpu_get_physical_page_desc(target_phys_addr_t addr);
 ram_addr_t qemu_ram_alloc_from_ptr(DeviceState *dev, const char *name,
 ram_addr_t size, void *host);
diff --git a/exec.c b/exec.c
index 2160ded..c00badd 100644
--- a/exec.c
+++ b/exec.c
@@ -3232,7 +3232,7 @@ ram_addr_t qemu_ram_addr_from_host_nofail(void *ptr)
 return ram_addr;
 }
 
-static uint32_t unassigned_mem_readb(void *opaque, target_phys_addr_t addr)
+uint32_t unassigned_mem_readb(void *opaque, target_phys_addr_t addr)
 {
 #ifdef DEBUG_UNASSIGNED
 printf("Unassigned mem read " TARGET_FMT_plx "\n", addr);
@@ -3243,7 +3243,7 @@ static uint32_t unassigned_mem_readb(void *opaque, 
target_phys_addr_t addr)
 return 0;
 }
 
-static uint32_t unassigned_mem_readw(void *opaque, target_phys_addr_t addr)
+uint32_t unassigned_mem_readw(void *opaque, target_phys_addr_t addr)
 {
 #ifdef DEBUG_UNASSIGNED
 printf("Unassigned mem read " TARGET_FMT_plx "\n", addr);
@@ -3254,7 +3254,7 @@ static uint32_t unassigned_mem_readw(void *opaque, 
target_phys_addr_t addr)
 return 0;
 }
 
-static uint32_t unassigned_mem_readl(void *opaque, target_phys_addr_t addr)
+uint32_t unassigned_mem_readl(void *opaque, target_phys_addr_t addr)
 {
 #ifdef DEBUG_UNASSIGNED
 printf("Unassigned mem read " TARGET_FMT_plx "\n", addr);
@@ -3265,7 +3265,7 @@ static uint32_t unassigned_mem_readl(void *opaque, 
target_phys_addr_t addr)
 return 0;
 }
 
-static void unassigned_mem_writeb(void *opaque, target_phys_addr_t addr, 
uint32_t val)
+void unassigned_mem_writeb(void *opaque, target_phys_addr_t addr, uint32_t val)
 {
 #ifdef DEBUG_UNASSIGNED
 printf("Unassigned mem write " TARGET_FMT_plx " = 0x%x\n", addr, val);
@@ -3275,7 +3275,7 @@ static void unassigned_mem_writeb(void *opaque, 
target_phys_addr_t addr, uint32_
 #endif
 }
 
-static void unassigned_mem_writew(void *opaque, target_phys_addr_t addr, 
uint32_t val)
+void unassigned_mem_writew(void *opaque, target_phys_addr_t addr, uint32_t val)
 {
 #ifdef DEBUG_UNASSIGNED
 printf("Unassigned mem write " TARGET_FMT_plx " = 0x%x\n", addr, val);
@@ -3285,7 +3285,7 @@ static void unassigned_mem_writew(void *opaque, 
target_phys_addr_t addr, uint32_
 #endif
 }
 
-static void unassigned_mem_writel(void *opaque, target_phys_addr_t addr, 
uint32_t val)
+void unassigned_mem_writel(void *opaque, target_phys_addr_t addr, uint32_t val)
 {
 #ifdef DEBUG_UNASSIGNED
 printf("Unassigned mem write " TARGET_FMT_plx " = 0x%x\n", addr, val);
-- 
1.7.4.4




[Qemu-devel] [PATCH 2/7] pci: Export pci_to_cpu_addr.

2011-07-23 Thread Richard Henderson
This is, more or less, the read accessor to pci_bus_set_mem_base
as a write accessor.  It will be needed for implementing sparse
memory spaces for Alpha.

Signed-off-by: Richard Henderson 
---
 hw/pci.c |3 +--
 hw/pci.h |1 +
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/hw/pci.c b/hw/pci.c
index b904a4e..68e18d3 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -820,8 +820,7 @@ PCIDevice *pci_register_device(PCIBus *bus, const char 
*name,
 return pci_dev;
 }
 
-static target_phys_addr_t pci_to_cpu_addr(PCIBus *bus,
-  target_phys_addr_t addr)
+target_phys_addr_t pci_to_cpu_addr(PCIBus *bus, target_phys_addr_t addr)
 {
 return addr + bus->mem_base;
 }
diff --git a/hw/pci.h b/hw/pci.h
index c220745..458be00 100644
--- a/hw/pci.h
+++ b/hw/pci.h
@@ -246,6 +246,7 @@ void pci_device_reset(PCIDevice *dev);
 void pci_bus_reset(PCIBus *bus);
 
 void pci_bus_set_mem_base(PCIBus *bus, target_phys_addr_t base);
+target_phys_addr_t pci_to_cpu_addr(PCIBus *bus, target_phys_addr_t addr);
 
 PCIDevice *pci_nic_init(NICInfo *nd, const char *default_model,
 const char *default_devaddr);
-- 
1.7.4.4




Re: [Qemu-devel] [PATCH] guest agent: qemu-ga daemon

2011-07-23 Thread Anthony Liguori

On 07/23/2011 01:34 PM, Alexander Graf wrote:


On 23.07.2011, at 18:43, Michael Roth wrote:


On 07/23/2011 11:10 AM, Anthony Liguori wrote:

On 07/23/2011 11:06 AM, Michael Roth wrote:

On 07/23/2011 05:07 AM, Alexander Graf wrote:


On 20.07.2011, at 22:19, Michael Roth wrote:


This is the actual guest daemon, it listens for requests over a
virtio-serial/isa-serial/unix socket channel and routes them through
to dispatch routines, and writes the results back to the channel in
a manner similar to QMP.

A shorthand invocation:

qemu-ga -d

Is equivalent to:

qemu-ga -m virtio-serial -p /dev/virtio-ports/org.qemu.guest_agent.0 \
-f /var/run/qemu-ga.pid -d

Signed-off-by: Michael Roth


A rebase on top of current HEAD gave me the following on openSUSE 11.1
PPC:


agraf@lychee:/home/agraf/release/qemu>  make
CC qemu-ga.o
qemu-ga.c:40: error: expected specifier-qualifier-list before ‘GSocket’


GIO is fairly new. It may not be available on openSUSE.

Mike, you probably need to do a configure test for GIO and if it's not
present, don't build qemu-ga.


It should've failed the glib probe in that case. I think we might need a 
compile test to catch this GSocket issue.

Rather than building qemu-ga when possible, should we just go ahead and add a 
configure option and only run the probes when it's set? At least until QMP/QEMU 
start formally using glib? If so, on or off by default?


In general, I like the workflow of adding a feature with default off and then 
enabling it after it has been in for a couple of weeks. Since this got pushed 
so late for 0.15, I'd personally prefer to see it as preview (disabled by 
default) in 0.15 and only enabled by default if the requirements are there on 
0.16.


The only way something like this gets tested is to default it on.

We default off'd the I/O thread even after years we still don't have it 
enabled.


With respect to 0.15, this bit of code is totally isolated from 
everything else.  Worst case scenario, we just disable it on platforms 
where it doesn't work.  It presents no real risk to the stability of the 
release.


Regards,

Anthony Liguori




Alex







Re: [Qemu-devel] [PATCH] guest agent: qemu-ga daemon

2011-07-23 Thread Anthony Liguori

On 07/23/2011 01:35 PM, Alexander Graf wrote:


On 23.07.2011, at 18:49, Anthony Liguori wrote:


On 07/23/2011 11:43 AM, Michael Roth wrote:

On 07/23/2011 11:10 AM, Anthony Liguori wrote:

On 07/23/2011 11:06 AM, Michael Roth wrote:

On 07/23/2011 05:07 AM, Alexander Graf wrote:


On 20.07.2011, at 22:19, Michael Roth wrote:


This is the actual guest daemon, it listens for requests over a
virtio-serial/isa-serial/unix socket channel and routes them through
to dispatch routines, and writes the results back to the channel in
a manner similar to QMP.

A shorthand invocation:

qemu-ga -d

Is equivalent to:

qemu-ga -m virtio-serial -p /dev/virtio-ports/org.qemu.guest_agent.0 \
-f /var/run/qemu-ga.pid -d

Signed-off-by: Michael Roth


A rebase on top of current HEAD gave me the following on openSUSE 11.1
PPC:


agraf@lychee:/home/agraf/release/qemu>  make
CC qemu-ga.o
qemu-ga.c:40: error: expected specifier-qualifier-list before ‘GSocket’


GIO is fairly new. It may not be available on openSUSE.

Mike, you probably need to do a configure test for GIO and if it's not
present, don't build qemu-ga.


It should've failed the glib probe in that case. I think we might need a
compile test to catch this GSocket issue.


Indeed.  Alex, can you help debug this a bit?  We can tr to setup a SUSE system.


It's not only about SUSE vs. non-SUSE. This was 11.1 (ancient, but latest ppc 
release) on PowerPC.


Can you confirm that gio is actually present?


Sure, tell me how :). I'm fairly ignorant when it comes to g* stuff.


pkg-config --modversion gio-2.0

Regards,

Anthony Liguori



Alex







Re: [Qemu-devel] [PATCH V2] Add "tee" option to qemu char device

2011-07-23 Thread Anthony Liguori

On 07/23/2011 01:31 PM, Alexander Graf wrote:


On 23.07.2011, at 17:23, Anthony Liguori wrote:


On 07/14/2011 03:58 AM, Chunyan Liu wrote:

Add "tee" backend to char device. It could be used as follows:
 -serial tee:filepath,pty
 -chardev tee,tee_fpath=path,tee_backend=pty,,path=path,,[mux=on|off]
With "tee" option, "pty" output would be duplicated to filepath.
Related thread:
http://lists.nongnu.org/archive/html/qemu-devel/2011-07/msg00105.html


I loathe adding even more complexity to the the char layer.  Can't you do this 
just as well with socat?


I disagree. For socat we'd have to open some listening port (unix, tcg, etc) 
and then have socat connect to it.


And what's the problem?  Use a unix domain socket and call it a day.


While socat is not up yet, the VM won't run. It also adds another layer of 
complexity (syncing of socat and qemu process) to the picture that I don't like.


These arguments all apply to any possible option.  Why not a grep 
target?  Why not a cut or less target?



As long as the tee target is reasonably isolated, I don't think it'd clutter 
the char backend.


It'll never be tested and end up becoming dead bloat code.

For uncommon use cases where there's another way to do something with no 
real obvious technical advantages, using existing code (and utilities) 
always wins vs reinventing the wheel IMHO.


Regards,

Anthony Liguori



Re: [Qemu-devel] [PATCH] guest agent: qemu-ga daemon

2011-07-23 Thread Alexander Graf

On 23.07.2011, at 18:49, Anthony Liguori wrote:

> On 07/23/2011 11:43 AM, Michael Roth wrote:
>> On 07/23/2011 11:10 AM, Anthony Liguori wrote:
>>> On 07/23/2011 11:06 AM, Michael Roth wrote:
 On 07/23/2011 05:07 AM, Alexander Graf wrote:
> 
> On 20.07.2011, at 22:19, Michael Roth wrote:
> 
>> This is the actual guest daemon, it listens for requests over a
>> virtio-serial/isa-serial/unix socket channel and routes them through
>> to dispatch routines, and writes the results back to the channel in
>> a manner similar to QMP.
>> 
>> A shorthand invocation:
>> 
>> qemu-ga -d
>> 
>> Is equivalent to:
>> 
>> qemu-ga -m virtio-serial -p /dev/virtio-ports/org.qemu.guest_agent.0 \
>> -f /var/run/qemu-ga.pid -d
>> 
>> Signed-off-by: Michael Roth
> 
> A rebase on top of current HEAD gave me the following on openSUSE 11.1
> PPC:
> 
> 
> agraf@lychee:/home/agraf/release/qemu> make
> CC qemu-ga.o
> qemu-ga.c:40: error: expected specifier-qualifier-list before ‘GSocket’
>>> 
>>> GIO is fairly new. It may not be available on openSUSE.
>>> 
>>> Mike, you probably need to do a configure test for GIO and if it's not
>>> present, don't build qemu-ga.
>> 
>> It should've failed the glib probe in that case. I think we might need a
>> compile test to catch this GSocket issue.
> 
> Indeed.  Alex, can you help debug this a bit?  We can tr to setup a SUSE 
> system.

It's not only about SUSE vs. non-SUSE. This was 11.1 (ancient, but latest ppc 
release) on PowerPC.

> Can you confirm that gio is actually present?

Sure, tell me how :). I'm fairly ignorant when it comes to g* stuff.


Alex




Re: [Qemu-devel] [PATCH] guest agent: qemu-ga daemon

2011-07-23 Thread Alexander Graf

On 23.07.2011, at 18:43, Michael Roth wrote:

> On 07/23/2011 11:10 AM, Anthony Liguori wrote:
>> On 07/23/2011 11:06 AM, Michael Roth wrote:
>>> On 07/23/2011 05:07 AM, Alexander Graf wrote:
 
 On 20.07.2011, at 22:19, Michael Roth wrote:
 
> This is the actual guest daemon, it listens for requests over a
> virtio-serial/isa-serial/unix socket channel and routes them through
> to dispatch routines, and writes the results back to the channel in
> a manner similar to QMP.
> 
> A shorthand invocation:
> 
> qemu-ga -d
> 
> Is equivalent to:
> 
> qemu-ga -m virtio-serial -p /dev/virtio-ports/org.qemu.guest_agent.0 \
> -f /var/run/qemu-ga.pid -d
> 
> Signed-off-by: Michael Roth
 
 A rebase on top of current HEAD gave me the following on openSUSE 11.1
 PPC:
 
 
 agraf@lychee:/home/agraf/release/qemu> make
 CC qemu-ga.o
 qemu-ga.c:40: error: expected specifier-qualifier-list before ‘GSocket’
>> 
>> GIO is fairly new. It may not be available on openSUSE.
>> 
>> Mike, you probably need to do a configure test for GIO and if it's not
>> present, don't build qemu-ga.
> 
> It should've failed the glib probe in that case. I think we might need a 
> compile test to catch this GSocket issue.
> 
> Rather than building qemu-ga when possible, should we just go ahead and add a 
> configure option and only run the probes when it's set? At least until 
> QMP/QEMU start formally using glib? If so, on or off by default?

In general, I like the workflow of adding a feature with default off and then 
enabling it after it has been in for a couple of weeks. Since this got pushed 
so late for 0.15, I'd personally prefer to see it as preview (disabled by 
default) in 0.15 and only enabled by default if the requirements are there on 
0.16.


Alex




Re: [Qemu-devel] [PATCH V2] Add "tee" option to qemu char device

2011-07-23 Thread Alexander Graf

On 23.07.2011, at 17:23, Anthony Liguori wrote:

> On 07/14/2011 03:58 AM, Chunyan Liu wrote:
>> Add "tee" backend to char device. It could be used as follows:
>> -serial tee:filepath,pty
>> -chardev tee,tee_fpath=path,tee_backend=pty,,path=path,,[mux=on|off]
>> With "tee" option, "pty" output would be duplicated to filepath.
>> Related thread:
>> http://lists.nongnu.org/archive/html/qemu-devel/2011-07/msg00105.html
> 
> I loathe adding even more complexity to the the char layer.  Can't you do 
> this just as well with socat?

I disagree. For socat we'd have to open some listening port (unix, tcg, etc) 
and then have socat connect to it. While socat is not up yet, the VM won't run. 
It also adds another layer of complexity (syncing of socat and qemu process) to 
the picture that I don't like.

As long as the tee target is reasonably isolated, I don't think it'd clutter 
the char backend. It'd be just like any other backend and eventually could 
maybe move into something more structured, plugin'ish, like the block layer.

I haven't gotten around to review the patch again though, will try to do soon.

Alex




[Qemu-devel] QEMU 0.15.0-rc0, stable-0.15, and QEMU 1.0

2011-07-23 Thread Anthony Liguori

Hi,

I've forked off the stable branch and tagged qemu-0.15.0-rc0 in the 
master repository.  Please begin explicitly marking patches meant for 
stable as [STABLE] and CC Justin.


The stable tree for this release is located at:

git://git.qemu.org/qemu-stable-0.15.git

That means the tree is now open for the next release.  In the spirit of 
the Linux 3.0 release, I think it's only appropriate for our next 
release to be 1.0.


I think we would still use an x.y.z versioning convention but would want 
to do a 2.0 in the next couple years.


Regards,

Anthony Liguori



[Qemu-devel] Question about debugging binary translator (TCG beckend) in system mode

2011-07-23 Thread Lyu Mitnick
Hello all,

I have written my own TCG code generator (translate TCG to i386). It works
well in user mode (pass every benchmark). However, there

is something error in system mode:

Host - x86-64, Configuration -  --target-list=i386-softmmu --enable-debug
--disable-kvm


|  minix2.04   | small-ffs (NetBSD)

single step|  correct   |  correct

non-single step  |  correct   |  init panic(restart)


(I have comment tb_add_jump of cpu-exec:cpu_exec to disable block chaining)

I dump the exec but there is so much logs to debug. I am wondering to know
how TCG codegen developer debug during development ??

thanks a lot

Mitnick


Re: [Qemu-devel] [PATCH resend] vl.c: Don't limit node count by smp count

2011-07-23 Thread Anthony Liguori

On 06/29/2011 10:29 PM, Sasha Levin wrote:

[I've sent this patch couple of months ago and noticed it
  didn't make it's way in - so I'm sending it again]

It is possible to create CPU-less NUMA nodes, node amount shouldn't be
limited by amount of CPUs.

Tested-by: Michael Roth
Signed-off-by: Sasha Levin


Applied.  Thanks.

Regards,

Anthony Liguori


---
  vl.c |4 ++--
  1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/vl.c b/vl.c
index e0191e1..b95ae8d 100644
--- a/vl.c
+++ b/vl.c
@@ -3147,8 +3147,8 @@ int main(int argc, char **argv, char **envp)
  if (nb_numa_nodes>  0) {
  int i;

-if (nb_numa_nodes>  smp_cpus) {
-nb_numa_nodes = smp_cpus;
+if (nb_numa_nodes>  MAX_NODES) {
+nb_numa_nodes = MAX_NODES;
  }

  /* If no memory size if given for any node, assume the default case





Re: [Qemu-devel] [PATCH 0/4] A few cleanups of qdev users

2011-07-23 Thread Anthony Liguori

On 05/19/2011 06:37 AM, Markus Armbruster wrote:

Markus Armbruster (4):
   usb-ccid: Drop unused CCIDCardInfo callback print()
   virtio-serial: Clean up virtser_bus_dev_print() output
   virtio-serial: Turn props any virtio-serial-bus device must have into
 bus props
   ide: Turn properties any IDE device must have into bus properties


Applied.  Thanks.

Regards,

Anthony Liguori



  hw/ccid.h  |1 -
  hw/ide/qdev.c  |5 -
  hw/usb-ccid.c  |   11 ---
  hw/virtio-console.c|4 
  hw/virtio-serial-bus.c |   18 ++
  5 files changed, 14 insertions(+), 25 deletions(-)






Re: [Qemu-devel] [PATCH 0/2] iothread improvements for Mac OS X

2011-07-23 Thread Anthony Liguori

On 06/09/2011 06:10 AM, Paolo Bonzini wrote:

These are two old patches that I never submitted because I didn't really
think they were useful except as cleanups.  Recently, however, Alex Graf
mentioned some problems that Mac OS X has with iothread, and they sounded
to me like they were related to these patches.  And quite surprisingly,
both of them were fixing bugs!

Mac OS X still has problems with iothread according to Alex's testing
(Linux times out in libata, and reactos likewise hangs early on I/O),
but at least the patches fix deadlocks and keep a responsive UI.

Paolo Bonzini (2):
   iothread: replace fair_mutex with a condition variable
   qemu-timer: change unix timer to dynticks



Applied.  Thanks.

Regards,

Anthony Liguori


  cpus.c   |   24 +---
  qemu-timer.c |   40 
  2 files changed, 37 insertions(+), 27 deletions(-)






Re: [Qemu-devel] [PATCH] Correct spelling of licensed

2011-07-23 Thread Anthony Liguori

On 06/25/2011 09:21 PM, Matthew Fernandez wrote:

Correct typos of "licenced" to "licensed".

Signed-off-by: Matthew Fernandez



Applied.  Thanks.

Regards,

Anthony Liguori


...
On 24 June 2011 00:42, Stefan Weil  wrote:

Am 23.06.2011 10:08, schrieb Matthew Fernandez:

would you mind sending a patch which fixes all other "licenced", too?
There are 65 files which contain this spelling :-)

Cheers,
Stefan W.


No problem. Are there any objections to this being a single patch? Don't
really fancy sending 40+ patches. Obviously it will touch a lot of files,
but won't change any code.

I think a single patch is ok for this special case.
All "licenced" are part of (L)GPL license comments with a very low risk of
merge conflicts,
especially if the patch is accepted and applied soon.

Stefan W.

Patch below, as requested.


diff --git a/hw/a9mpcore.c b/hw/a9mpcore.c
index b5e5328..6f108f4 100644
--- a/hw/a9mpcore.c
+++ b/hw/a9mpcore.c
@@ -4,7 +4,7 @@
   * Copyright (c) 2009 CodeSourcery.
   * Written by Paul Brook
   *
- * This code is licenced under the GPL.
+ * This code is licensed under the GPL.
   */

  /* 64 external IRQ lines.  */
diff --git a/hw/an5206.c b/hw/an5206.c
index 42a0163..04ca420 100644
--- a/hw/an5206.c
+++ b/hw/an5206.c
@@ -3,7 +3,7 @@
   *
   * Copyright (c) 2007 CodeSourcery.
   *
- * This code is licenced under the GPL
+ * This code is licensed under the GPL
   */

  #include "hw.h"
diff --git a/hw/arm-misc.h b/hw/arm-misc.h
index 010acb4..57b8043 100644
--- a/hw/arm-misc.h
+++ b/hw/arm-misc.h
@@ -4,7 +4,7 @@
   * Copyright (c) 2006 CodeSourcery.
   * Written by Paul Brook
   *
- * This code is licenced under the LGPL.
+ * This code is licensed under the LGPL.
   *
   */

diff --git a/hw/arm11mpcore.c b/hw/arm11mpcore.c
index 3bbd885..b47707f 100644
--- a/hw/arm11mpcore.c
+++ b/hw/arm11mpcore.c
@@ -4,7 +4,7 @@
   * Copyright (c) 2006-2007 CodeSourcery.
   * Written by Paul Brook
   *
- * This code is licenced under the GPL.
+ * This code is licensed under the GPL.
   */

  /* ??? The MPCore TRM says the on-chip controller has 224 external IRQ lines
diff --git a/hw/arm_boot.c b/hw/arm_boot.c
index bfac982..94677dd 100644
--- a/hw/arm_boot.c
+++ b/hw/arm_boot.c
@@ -4,7 +4,7 @@
   * Copyright (c) 2006-2007 CodeSourcery.
   * Written by Paul Brook
   *
- * This code is licenced under the GPL.
+ * This code is licensed under the GPL.
   */

  #include "hw.h"
diff --git a/hw/arm_gic.c b/hw/arm_gic.c
index 0e934ec..fb07314 100644
--- a/hw/arm_gic.c
+++ b/hw/arm_gic.c
@@ -4,7 +4,7 @@
   * Copyright (c) 2006-2007 CodeSourcery.
   * Written by Paul Brook
   *
- * This code is licenced under the GPL.
+ * This code is licensed under the GPL.
   */

  /* This file contains implementation code for the RealView EB interrupt
diff --git a/hw/arm_pic.c b/hw/arm_pic.c
index f44568c..985148a 100644
--- a/hw/arm_pic.c
+++ b/hw/arm_pic.c
@@ -4,7 +4,7 @@
   * Copyright (c) 2006 CodeSourcery.
   * Written by Paul Brook
   *
- * This code is licenced under the LGPL
+ * This code is licensed under the LGPL
   */

  #include "hw.h"
diff --git a/hw/arm_sysctl.c b/hw/arm_sysctl.c
index 9225b58..fd0c8bc 100644
--- a/hw/arm_sysctl.c
+++ b/hw/arm_sysctl.c
@@ -4,7 +4,7 @@
   * Copyright (c) 2006-2007 CodeSourcery.
   * Written by Paul Brook
   *
- * This code is licenced under the GPL.
+ * This code is licensed under the GPL.
   */

  #include "hw.h"
diff --git a/hw/arm_timer.c b/hw/arm_timer.c
index dac9e70..fd9448f 100644
--- a/hw/arm_timer.c
+++ b/hw/arm_timer.c
@@ -4,7 +4,7 @@
   * Copyright (c) 2005-2006 CodeSourcery.
   * Written by Paul Brook
   *
- * This code is licenced under the GPL.
+ * This code is licensed under the GPL.
   */

  #include "sysbus.h"
diff --git a/hw/armv7m.c b/hw/armv7m.c
index 72d010a..205d35b 100644
--- a/hw/armv7m.c
+++ b/hw/armv7m.c
@@ -4,7 +4,7 @@
   * Copyright (c) 2006-2007 CodeSourcery.
   * Written by Paul Brook
   *
- * This code is licenced under the GPL.
+ * This code is licensed under the GPL.
   */

  #include "sysbus.h"
diff --git a/hw/armv7m_nvic.c b/hw/armv7m_nvic.c
index d06eec9..1df8d4d 100644
--- a/hw/armv7m_nvic.c
+++ b/hw/armv7m_nvic.c
@@ -4,7 +4,7 @@
   * Copyright (c) 2006-2007 CodeSourcery.
   * Written by Paul Brook
   *
- * This code is licenced under the GPL.
+ * This code is licensed under the GPL.
   *
   * The ARMv7M System controller is fairly tightly tied in with the
   * NVIC.  Much of that is also implemented here.
diff --git a/hw/bitbang_i2c.c b/hw/bitbang_i2c.c
index 2937b5c..53e9c5c 100644
--- a/hw/bitbang_i2c.c
+++ b/hw/bitbang_i2c.c
@@ -4,7 +4,7 @@
   *
   * Copyright (c) 2008 Jan Kiszka
   *
- * This code is licenced under the GNU GPL v2.
+ * This code is licensed under the GNU GPL v2.
   */
  #include "hw.h"
  #include "bitbang_i2c.h"
diff --git a/hw/ccid-card-emulated.c b/hw/ccid-card-emulated.c
index 0b07184..4762e85 100644
--- a/hw/ccid-card-emulated.c
+++ b/hw/ccid-card-emulated.c
@@ -4,7 +4,7 @@
   * Copyright (c) 2011 Red Hat.
   * Written

Re: [Qemu-devel] [PATCH v2 0/3] Let RTC follow backward jumps of host clock immediately

2011-07-23 Thread Anthony Liguori

On 06/20/2011 07:06 AM, Jan Kiszka wrote:

Just noticed that this issue is still unfixed because my series was
somehow forgotten. So I've rebased it over current master, refactored it
to use the generic Notifier infrastructure and renamed it to "clock
reset notifier" to avoid confusion with icount related "warping". Please
review / apply before 0.15-rc0, it fixes a relevant issue.

Original series description:

By default, we base the mc146818 RTC on the host clock (CLOCK_REALTIME).
This works fine if only the frequency of the host clock is tuned (e.g.
by NTP) or if it is set to a future time. However, if the host is tuned
backward, e.g. because NTP obtained the correct time after the guest was
already started or the admin decided to tune the local time, we see an
unpleasant effect in the guest: The RTC will stall for the period the
host clock is set back. We identified that one prominent guest affected
by this is Windows which relies on the periodic RTC interrupt for time
keeping.

This series address the issue by detecting those warps and providing a
callback mechanism to device models. The RTC is enabled to update its
timers and register content immediately. Tested successfully both with
hwclock in a Linux guest and by monitoring the Windows clock while
fiddling with the host time.

Note that if this kind of RTC adjustment is not wanted, the user is
still free to decouple the RTC from the host clock and base it on the
VM clock - just like before.

Jan Kiszka (3):
   notifier: Pass data argument to callback
   qemu-timer: Introduce clock reset notifier
   mc146818rtc: Handle host clock resets


Applied.  Thanks.

Regards,

Anthony Liguori



  hw/fw_cfg.c  |2 +-
  hw/mc146818rtc.c |   20 
  input.c  |2 +-
  migration.c  |   12 ++--
  notify.c |4 ++--
  notify.h |4 ++--
  qemu-timer.c |   29 -
  qemu-timer.h |5 +
  ui/sdl.c |2 +-
  ui/spice-core.c  |2 +-
  ui/spice-input.c |4 ++--
  ui/vnc.c |4 ++--
  usb-linux.c  |2 +-
  vl.c |4 ++--
  xen-all.c|2 +-
  15 files changed, 75 insertions(+), 23 deletions(-)








Re: [Qemu-devel] [PATCH 1/3] Store VNC auth scheme per-client as well as per-server

2011-07-23 Thread Anthony Liguori

On 06/23/2011 07:31 AM, Daniel P. Berrange wrote:

A future patch will introduce a situation where different
clients may have different authentication schemes set.
When a new client arrives, copy the 'auth' and 'subauth'
fields from VncDisplay into the client's VncState, and
use the latter in all authentication functions.

* ui/vnc.h: Add 'auth' and 'subauth' to VncState
* ui/vnc-auth-sasl.c, ui/vnc-auth-vencrypt.c,
   ui/vnc.c: Make auth functions pull auth scheme
   from VncState instead of VncDisplay
---
  ui/vnc-auth-sasl.c |8 
  ui/vnc-auth-vencrypt.c |   18 +-
  ui/vnc.c   |   39 ++-
  ui/vnc.h   |2 ++
  4 files changed, 41 insertions(+), 26 deletions(-)


Applied.  Thanks.

Regards,

Anthony Liguori



diff --git a/ui/vnc-auth-sasl.c b/ui/vnc-auth-sasl.c
index 17a621a..8aac5ec 100644
--- a/ui/vnc-auth-sasl.c
+++ b/ui/vnc-auth-sasl.c
@@ -538,8 +538,8 @@ void start_auth_sasl(VncState *vs)

  #ifdef CONFIG_VNC_TLS
  /* Inform SASL that we've got an external SSF layer from TLS/x509 */
-if (vs->vd->auth == VNC_AUTH_VENCRYPT&&
-vs->vd->subauth == VNC_AUTH_VENCRYPT_X509SASL) {
+if (vs->auth == VNC_AUTH_VENCRYPT&&
+vs->subauth == VNC_AUTH_VENCRYPT_X509SASL) {
  gnutls_cipher_algorithm_t cipher;
  sasl_ssf_t ssf;

@@ -570,8 +570,8 @@ void start_auth_sasl(VncState *vs)
  #ifdef CONFIG_VNC_TLS
  /* Disable SSF, if using TLS+x509+SASL only. TLS without x509
 is not sufficiently strong */
-|| (vs->vd->auth == VNC_AUTH_VENCRYPT&&
-vs->vd->subauth == VNC_AUTH_VENCRYPT_X509SASL)
+|| (vs->auth == VNC_AUTH_VENCRYPT&&
+vs->subauth == VNC_AUTH_VENCRYPT_X509SASL)
  #endif /* CONFIG_VNC_TLS */
  ) {
  /* If we've got TLS or UNIX domain sock, we don't care about SSF */
diff --git a/ui/vnc-auth-vencrypt.c b/ui/vnc-auth-vencrypt.c
index 07c1691..674ba97 100644
--- a/ui/vnc-auth-vencrypt.c
+++ b/ui/vnc-auth-vencrypt.c
@@ -29,7 +29,7 @@

  static void start_auth_vencrypt_subauth(VncState *vs)
  {
-switch (vs->vd->subauth) {
+switch (vs->subauth) {
  case VNC_AUTH_VENCRYPT_TLSNONE:
  case VNC_AUTH_VENCRYPT_X509NONE:
 VNC_DEBUG("Accept TLS auth none\n");
@@ -51,7 +51,7 @@ static void start_auth_vencrypt_subauth(VncState *vs)
  #endif /* CONFIG_VNC_SASL */

  default: /* Should not be possible, but just in case */
-   VNC_DEBUG("Reject subauth %d server bug\n", vs->vd->auth);
+   VNC_DEBUG("Reject subauth %d server bug\n", vs->auth);
 vnc_write_u8(vs, 1);
 if (vs->minor>= 8) {
 static const char err[] = "Unsupported authentication type";
@@ -110,17 +110,17 @@ static void vnc_tls_handshake_io(void *opaque) {


  #define NEED_X509_AUTH(vs)  \
-((vs)->vd->subauth == VNC_AUTH_VENCRYPT_X509NONE ||   \
- (vs)->vd->subauth == VNC_AUTH_VENCRYPT_X509VNC ||\
- (vs)->vd->subauth == VNC_AUTH_VENCRYPT_X509PLAIN ||  \
- (vs)->vd->subauth == VNC_AUTH_VENCRYPT_X509SASL)
+((vs)->subauth == VNC_AUTH_VENCRYPT_X509NONE ||   \
+ (vs)->subauth == VNC_AUTH_VENCRYPT_X509VNC ||\
+ (vs)->subauth == VNC_AUTH_VENCRYPT_X509PLAIN ||  \
+ (vs)->subauth == VNC_AUTH_VENCRYPT_X509SASL)


  static int protocol_client_vencrypt_auth(VncState *vs, uint8_t *data, size_t 
len)
  {
  int auth = read_u32(data, 0);

-if (auth != vs->vd->subauth) {
+if (auth != vs->subauth) {
  VNC_DEBUG("Rejecting auth %d\n", auth);
  vnc_write_u8(vs, 0); /* Reject auth */
  vnc_flush(vs);
@@ -153,10 +153,10 @@ static int protocol_client_vencrypt_init(VncState *vs, 
uint8_t *data, size_t len
  vnc_flush(vs);
  vnc_client_error(vs);
  } else {
-VNC_DEBUG("Sending allowed auth %d\n", vs->vd->subauth);
+VNC_DEBUG("Sending allowed auth %d\n", vs->subauth);
  vnc_write_u8(vs, 0); /* Accept version */
  vnc_write_u8(vs, 1); /* Number of sub-auths */
-vnc_write_u32(vs, vs->vd->subauth); /* The supported auth */
+vnc_write_u32(vs, vs->subauth); /* The supported auth */
  vnc_flush(vs);
  vnc_read_when(vs, protocol_client_vencrypt_auth, 4);
  }
diff --git a/ui/vnc.c b/ui/vnc.c
index 14f2930..39b5b51 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -2124,7 +2124,7 @@ static int protocol_client_auth(VncState *vs, uint8_t 
*data, size_t len)
  {
  /* We only advertise 1 auth scheme at a time, so client
   * must pick the one we sent. Verify this */
-if (data[0] != vs->vd->auth) { /* Reject auth */
+if (data[0] != vs->auth) { /* Reject auth */
 VNC_DEBUG("Reject auth %d because it didn't match advertized\n", 
(int)data[0]);
 vnc_write_u32(vs, 1);
 if (vs->minor>= 8) {
@@ -2135,7 +2135,7 @@ static int protocol_client_auth(VncState *vs, uint8_t 
*data, size_t len)
 vnc_client_error(vs);
  } else 

Re: [Qemu-devel] [PATCH] qemu-char: Print strerror message on failure

2011-07-23 Thread Anthony Liguori

On 06/01/2011 06:29 AM, Kevin Wolf wrote:

The only way for chardev drivers to communicate an error was to return a NULL
pointer, which resulted in an error message that said _that_ something went
wrong, but not _why_.

This patch changes the interface to return 0/-errno and updates
qemu_chr_open_opts to use strerror to display a more helpful error message.

Signed-off-by: Kevin Wolf


Applied.  Thanks.

Regards,

Anthony Liguori


---
  console.c |8 ++-
  console.h |2 +-
  hw/baum.c |7 +-
  hw/msmouse.c  |5 +-
  hw/msmouse.h  |2 +-
  qemu-char.c   |  165 +++--
  spice-qemu-char.c |9 ++-
  ui/qemu-spice.h   |2 +-
  8 files changed, 117 insertions(+), 83 deletions(-)

diff --git a/console.c b/console.c
index 871c1d4..314d625 100644
--- a/console.c
+++ b/console.c
@@ -1507,7 +1507,7 @@ static void text_console_do_init(CharDriverState *chr, 
DisplayState *ds)
  chr->init(chr);
  }

-CharDriverState *text_console_init(QemuOpts *opts)
+int text_console_init(QemuOpts *opts, CharDriverState **_chr)
  {
  CharDriverState *chr;
  TextConsole *s;
@@ -1539,7 +1539,7 @@ CharDriverState *text_console_init(QemuOpts *opts)

  if (!s) {
  free(chr);
-return NULL;
+return -EBUSY;
  }

  s->chr = chr;
@@ -1547,7 +1547,9 @@ CharDriverState *text_console_init(QemuOpts *opts)
  s->g_height = height;
  chr->opaque = s;
  chr->chr_set_echo = text_console_set_echo;
-return chr;
+
+*_chr = chr;
+return 0;
  }

  void text_consoles_set_display(DisplayState *ds)
diff --git a/console.h b/console.h
index 64d1f09..c09537b 100644
--- a/console.h
+++ b/console.h
@@ -354,7 +354,7 @@ void vga_hw_text_update(console_ch_t *chardata);

  int is_graphic_console(void);
  int is_fixedsize_console(void);
-CharDriverState *text_console_init(QemuOpts *opts);
+int text_console_init(QemuOpts *opts, CharDriverState **_chr);
  void text_consoles_set_display(DisplayState *ds);
  void console_select(unsigned int index);
  void console_color_init(DisplayState *ds);
diff --git a/hw/baum.c b/hw/baum.c
index 2aaf5ff..33a22a7 100644
--- a/hw/baum.c
+++ b/hw/baum.c
@@ -576,7 +576,7 @@ static void baum_close(struct CharDriverState *chr)
  qemu_free(baum);
  }

-CharDriverState *chr_baum_init(QemuOpts *opts)
+int chr_baum_init(QemuOpts *opts, CharDriverState **_chr)
  {
  BaumDriverState *baum;
  CharDriverState *chr;
@@ -629,7 +629,8 @@ CharDriverState *chr_baum_init(QemuOpts *opts)

  qemu_chr_generic_open(chr);

-return chr;
+*_chr = chr;
+return 0;

  fail:
  qemu_free_timer(baum->cellCount_timer);
@@ -638,5 +639,5 @@ fail_handle:
  qemu_free(handle);
  qemu_free(chr);
  qemu_free(baum);
-return NULL;
+return -EIO;
  }
diff --git a/hw/msmouse.c b/hw/msmouse.c
index 05f893c..67c6cd4 100644
--- a/hw/msmouse.c
+++ b/hw/msmouse.c
@@ -64,7 +64,7 @@ static void msmouse_chr_close (struct CharDriverState *chr)
  qemu_free (chr);
  }

-CharDriverState *qemu_chr_open_msmouse(QemuOpts *opts)
+int qemu_chr_open_msmouse(QemuOpts *opts, CharDriverState **_chr)
  {
  CharDriverState *chr;

@@ -74,5 +74,6 @@ CharDriverState *qemu_chr_open_msmouse(QemuOpts *opts)

  qemu_add_mouse_event_handler(msmouse_event, chr, 0, "QEMU Microsoft 
Mouse");

-return chr;
+*_chr = chr;
+return 0;
  }
diff --git a/hw/msmouse.h b/hw/msmouse.h
index 456cb21..8b853b3 100644
--- a/hw/msmouse.h
+++ b/hw/msmouse.h
@@ -1,2 +1,2 @@
  /* msmouse.c */
-CharDriverState *qemu_chr_open_msmouse(QemuOpts *opts);
+int qemu_chr_open_msmouse(QemuOpts *opts, CharDriverState **_chr);
diff --git a/qemu-char.c b/qemu-char.c
index 5e04a20..a8e4094 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -220,13 +220,15 @@ static int null_chr_write(CharDriverState *chr, const 
uint8_t *buf, int len)
  return len;
  }

-static CharDriverState *qemu_chr_open_null(QemuOpts *opts)
+static int qemu_chr_open_null(QemuOpts *opts, CharDriverState **_chr)
  {
  CharDriverState *chr;

  chr = qemu_mallocz(sizeof(CharDriverState));
  chr->chr_write = null_chr_write;
-return chr;
+
+*_chr= chr;
+return 0;
  }

  /* MUX driver for serial I/O splitting */
@@ -635,18 +637,21 @@ static CharDriverState *qemu_chr_open_fd(int fd_in, int 
fd_out)
  return chr;
  }

-static CharDriverState *qemu_chr_open_file_out(QemuOpts *opts)
+static int qemu_chr_open_file_out(QemuOpts *opts, CharDriverState **_chr)
  {
  int fd_out;

  TFR(fd_out = qemu_open(qemu_opt_get(opts, "path"),
O_WRONLY | O_TRUNC | O_CREAT | O_BINARY, 0666));
-if (fd_out<  0)
-return NULL;
-return qemu_chr_open_fd(-1, fd_out);
+if (fd_out<  0) {
+return -errno;
+}
+
+*_chr = qemu_chr_open_fd(-1, fd_out);
+return 0;
  }

-static CharDriverState *qemu_chr_open_pipe(QemuOpts *opts)
+static int qemu_chr_open_pipe(QemuOpts *opt

Re: [Qemu-devel] [PATCH v2] Register Linux dyntick timer as per-thread signal

2011-07-23 Thread Anthony Liguori

On 06/17/2011 04:25 AM, Jan Kiszka wrote:

Derived from kvm-tool patch
http://thread.gmane.org/gmane.comp.emulators.kvm.devel/74309

Ingo Molnar pointed out that sending the timer signal to the whole
process, just blocking it everywhere, is suboptimal with an increasing
number of threads. QEMU is also using this pattern so far.

Linux provides a (non-portable) way to restrict the signal to a single
thread: We can use SIGEV_THREAD_ID unless we are forced to emulate
signalfd via an additional thread. That case could theoretically be
optimized as well, but it doesn't look worth bothering.

Signed-off-by: Jan Kiszka


Applied.  Thanks.

Regards,

Anthony Liguori


---

Changes in v2:
  - refactored dynticks_start_timer changes as suggested by Richard
Henderson
  - added reference to original kvm-tool patch

  compatfd.c   |   11 +++
  compatfd.h   |1 +
  qemu-timer.c |8 
  3 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/compatfd.c b/compatfd.c
index 41586ce..31654c6 100644
--- a/compatfd.c
+++ b/compatfd.c
@@ -115,3 +115,14 @@ int qemu_signalfd(const sigset_t *mask)

  return qemu_signalfd_compat(mask);
  }
+
+bool qemu_signalfd_available(void)
+{
+#ifdef CONFIG_SIGNALFD
+errno = 0;
+syscall(SYS_signalfd, -1, NULL, _NSIG / 8);
+return errno != ENOSYS;
+#else
+return false;
+#endif
+}
diff --git a/compatfd.h b/compatfd.h
index fc37915..6b04877 100644
--- a/compatfd.h
+++ b/compatfd.h
@@ -39,5 +39,6 @@ struct qemu_signalfd_siginfo {
  };

  int qemu_signalfd(const sigset_t *mask);
+bool qemu_signalfd_available(void);

  #endif
diff --git a/qemu-timer.c b/qemu-timer.c
index 72066c7..743cf96 100644
--- a/qemu-timer.c
+++ b/qemu-timer.c
@@ -803,6 +803,8 @@ static int64_t qemu_next_alarm_deadline(void)

  #if defined(__linux__)

+#include "compatfd.h"
+
  static int dynticks_start_timer(struct qemu_alarm_timer *t)
  {
  struct sigevent ev;
@@ -822,6 +824,12 @@ static int dynticks_start_timer(struct qemu_alarm_timer *t)
  memset(&ev, 0, sizeof(ev));
  ev.sigev_value.sival_int = 0;
  ev.sigev_notify = SIGEV_SIGNAL;
+#ifdef SIGEV_THREAD_ID
+if (qemu_signalfd_available()) {
+ev.sigev_notify = SIGEV_THREAD_ID;
+ev._sigev_un._tid = qemu_get_thread_id();
+}
+#endif /* SIGEV_THREAD_ID */
  ev.sigev_signo = SIGALRM;

  if (timer_create(CLOCK_REALTIME,&ev,&host_timer)) {





Re: [Qemu-devel] [PATCH] do not reset no_shutdown after we shutdown the vm

2011-07-23 Thread Anthony Liguori

On 06/16/2011 09:25 PM, Wen Congyang wrote:

Daniel P. Berrange sent a libvirt's patch to support
reboots with the QEMU driver. He implements it in
json model like this:
1. add -no-shutdown in the qemu's option:
qemu -no-shutdown 
2. shutdown the vm by monitor command system_powerdown
3. wait for shutdown event
4. reset the vm by monitor command system_reset

no_shutdown will be reset to 0 if the vm is powered down.
We only can reboot the vm once.

If no_shutdown is not reset to 0, we can reboot the vm
many times.

Signed-off-by: Wen Congyang


Applied.  Thanks.

Regards,

Anthony Liguori



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

diff --git a/vl.c b/vl.c
index dbdec71..e2e52ec 100644
--- a/vl.c
+++ b/vl.c
@@ -1396,7 +1396,6 @@ static void main_loop(void)
  monitor_protocol_event(QEVENT_SHUTDOWN, NULL);
  if (no_shutdown) {
  vm_stop(VMSTOP_SHUTDOWN);
-no_shutdown = 0;
  } else
  break;
  }





Re: [Qemu-devel] [PATCH, v2] vga: Fix type of lfb/map_addr/end.

2011-07-23 Thread Anthony Liguori

On 06/14/2011 02:53 PM, Richard Henderson wrote:

These addresses have been passed through pci_to_cpu_addr,
and thus need to be full target_phys_addr_t.

Signed-off-by: Richard Henderson
Cc: Jan Kiszka


Applied.  Thanks.

Regards,

Anthony Liguori


---

  V1->V2:
lfb_addr/end also widened to guest address width.

  hw/vga_int.h |   10 +-
  1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/hw/vga_int.h b/hw/vga_int.h
index d2811bd..eee91a8 100644
--- a/hw/vga_int.h
+++ b/hw/vga_int.h
@@ -106,13 +106,13 @@ typedef void (* vga_update_retrace_info_fn)(struct 
VGACommonState *s);
  typedef struct VGACommonState {
  uint8_t *vram_ptr;
  ram_addr_t vram_offset;
+target_phys_addr_t lfb_addr;
+target_phys_addr_t lfb_end;
+target_phys_addr_t map_addr;
+target_phys_addr_t map_end;
  uint32_t vram_size;
-uint32_t lfb_addr;
-uint32_t lfb_end;
-uint32_t map_addr;
-uint32_t map_end;
-uint32_t lfb_vram_mapped; /* whether 0xa is mapped as ram */
  uint32_t latch;
+uint32_t lfb_vram_mapped; /* whether 0xa is mapped as ram */
  uint8_t sr_index;
  uint8_t sr[256];
  uint8_t gr_index;





Re: [Qemu-devel] [PATCH] guest agent: qemu-ga daemon

2011-07-23 Thread Anthony Liguori

On 07/23/2011 11:43 AM, Michael Roth wrote:

On 07/23/2011 11:10 AM, Anthony Liguori wrote:

On 07/23/2011 11:06 AM, Michael Roth wrote:

On 07/23/2011 05:07 AM, Alexander Graf wrote:


On 20.07.2011, at 22:19, Michael Roth wrote:


This is the actual guest daemon, it listens for requests over a
virtio-serial/isa-serial/unix socket channel and routes them through
to dispatch routines, and writes the results back to the channel in
a manner similar to QMP.

A shorthand invocation:

qemu-ga -d

Is equivalent to:

qemu-ga -m virtio-serial -p /dev/virtio-ports/org.qemu.guest_agent.0 \
-f /var/run/qemu-ga.pid -d

Signed-off-by: Michael Roth


A rebase on top of current HEAD gave me the following on openSUSE 11.1
PPC:


agraf@lychee:/home/agraf/release/qemu> make
CC qemu-ga.o
qemu-ga.c:40: error: expected specifier-qualifier-list before ‘GSocket’


GIO is fairly new. It may not be available on openSUSE.

Mike, you probably need to do a configure test for GIO and if it's not
present, don't build qemu-ga.


It should've failed the glib probe in that case. I think we might need a
compile test to catch this GSocket issue.


Indeed.  Alex, can you help debug this a bit?  We can tr to setup a SUSE 
system.


Can you confirm that gio is actually present?

Regards,

Anthony Liguori



Rather than building qemu-ga when possible, should we just go ahead and
add a configure option and only run the probes when it's set? At least
until QMP/QEMU start formally using glib? If so, on or off by default?



Maybe look at just using GIOChannels which have been around much longer
than GSocket.



The GSocket stuff is being used in addition to GIOChannels to handle the
listen/accept stuff. I believe we can drop it in favor of
qemu-sockets.c/osdep.c though.


qga/guest-agent-commands.c: In function ‘qmp_guest_fsfreeze_freeze’:
qga/guest-agent-commands.c:443: error: ‘FIFREEZE’ undeclared (first
use in this function)
qga/guest-agent-commands.c:443: error: (Each undeclared identifier is
reported only once
qga/guest-agent-commands.c:443: error: for each function it appears
in.)
qga/guest-agent-commands.c: In function ‘qmp_guest_fsfreeze_thaw’:
qga/guest-agent-commands.c:481: error: ‘FITHAW’ undeclared (first use
in this function)


The kernel probably doesn't implement FIFREEZE. You need to do a
configure test and set CONFIG_FSFREEZE appropriately. I anticipated this
and that's why I added CONFIG_FSFREEZE and didn't just do __linux__.



Will do, thanks.


Regards,

Anthony Liguori







Re: [Qemu-devel] [PATCH] guest agent: qemu-ga daemon

2011-07-23 Thread Michael Roth

On 07/23/2011 11:10 AM, Anthony Liguori wrote:

On 07/23/2011 11:06 AM, Michael Roth wrote:

On 07/23/2011 05:07 AM, Alexander Graf wrote:


On 20.07.2011, at 22:19, Michael Roth wrote:


This is the actual guest daemon, it listens for requests over a
virtio-serial/isa-serial/unix socket channel and routes them through
to dispatch routines, and writes the results back to the channel in
a manner similar to QMP.

A shorthand invocation:

qemu-ga -d

Is equivalent to:

qemu-ga -m virtio-serial -p /dev/virtio-ports/org.qemu.guest_agent.0 \
-f /var/run/qemu-ga.pid -d

Signed-off-by: Michael Roth


A rebase on top of current HEAD gave me the following on openSUSE 11.1
PPC:


agraf@lychee:/home/agraf/release/qemu> make
CC qemu-ga.o
qemu-ga.c:40: error: expected specifier-qualifier-list before ‘GSocket’


GIO is fairly new. It may not be available on openSUSE.

Mike, you probably need to do a configure test for GIO and if it's not
present, don't build qemu-ga.


It should've failed the glib probe in that case. I think we might need a 
compile test to catch this GSocket issue.


Rather than building qemu-ga when possible, should we just go ahead and 
add a configure option and only run the probes when it's set? At least 
until QMP/QEMU start formally using glib? If so, on or off by default?




Maybe look at just using GIOChannels which have been around much longer
than GSocket.



The GSocket stuff is being used in addition to GIOChannels to handle the 
listen/accept stuff. I believe we can drop it in favor of 
qemu-sockets.c/osdep.c though.



qga/guest-agent-commands.c: In function ‘qmp_guest_fsfreeze_freeze’:
qga/guest-agent-commands.c:443: error: ‘FIFREEZE’ undeclared (first
use in this function)
qga/guest-agent-commands.c:443: error: (Each undeclared identifier is
reported only once
qga/guest-agent-commands.c:443: error: for each function it appears in.)
qga/guest-agent-commands.c: In function ‘qmp_guest_fsfreeze_thaw’:
qga/guest-agent-commands.c:481: error: ‘FITHAW’ undeclared (first use
in this function)


The kernel probably doesn't implement FIFREEZE. You need to do a
configure test and set CONFIG_FSFREEZE appropriately. I anticipated this
and that's why I added CONFIG_FSFREEZE and didn't just do __linux__.



Will do, thanks.


Regards,

Anthony Liguori





Re: [Qemu-devel] [PATCH] use mmap to allocate execute memory

2011-07-23 Thread Anthony Liguori

On 06/17/2011 05:11 AM, Christoph Egger wrote:


Use mmap to allocate executable memory on NetBSD as well.

From: Tobias Nygren 
Signed-off-by: Christoph Egger 

diff --git a/exec.c b/exec.c
index 09928a3..1954a1c 100644
--- a/exec.c
+++ b/exec.c
@@ -520,7 +520,8 @@ static void code_gen_alloc(unsigned long tb_size)
}
}
#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) \
- || defined(__DragonFly__) || defined(__OpenBSD__)


Your mailer munged this patch.

Regards,

Anthony Liguori


+ || defined(__DragonFly__) || defined(__OpenBSD__) \
+ || defined(__NetBSD__)
{
int flags;
void *addr = NULL;







Re: [Qemu-devel] [PATCH] fix network interface tap backend

2011-07-23 Thread Anthony Liguori

On 06/17/2011 03:56 AM, Christoph Egger wrote:


Fix network interface tap backend work on NetBSD.
It uses an ioctl to get the tap name.

 From Manuel Bouyer 
Signed-off-by: Christoph Egger 

diff --git a/net/tap-bsd.c b/net/tap-bsd.c
index 2f3efde..577aafe 100644
--- a/net/tap-bsd.c
+++ b/net/tap-bsd.c
@@ -28,6 +28,8 @@
#include "qemu-error.h"

#ifdef __NetBSD__
+#include 


Your mailer munged this patch.

Regards,

Anthony Liguori


+#include 
#include 
#endif

@@ -40,8 +42,12 @@
int tap_open(char *ifname, int ifname_size, int *vnet_hdr, int
vnet_hdr_required)
{
int fd;
+#ifdef TAPGIFNAME
+ struct ifreq ifr;
+#else
char *dev;
struct stat s;
+#endif

#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) ||
defined(__OpenBSD__)
/* if no ifname is given, always start the search from tap0/tun0. */
@@ -77,14 +83,30 @@ int tap_open(char *ifname, int ifname_size, int
*vnet_hdr, int vnet_hdr_required
#else
TFR(fd = open("/dev/tap", O_RDWR));
if (fd < 0) {
- fprintf(stderr, "warning: could not open /dev/tap: no virtual network
emulation\n");
+ fprintf(stderr,
+ "warning: could not open /dev/tap: no virtual network emulation: %s\n",
+ strerror(errno));
return -1;
}
#endif

- fstat(fd, &s);
+#ifdef TAPGIFNAME
+ if (ioctl(fd, TAPGIFNAME, (void *)&ifr) < 0) {
+ fprintf(stderr, "warning: could not get tap name: %s\n",
+ strerror(errno));
+ return -1;
+ }
+ pstrcpy(ifname, ifname_size, ifr.ifr_name);
+#else
+ if (fstat(fd, &s) < 0) {
+ fprintf(stderr,
+ "warning: could not stat /dev/tap: no virtual network emulation: %s\n",
+ strerror(errno));
+ return -1;
+ }
dev = devname(s.st_rdev, S_IFCHR);
pstrcpy(ifname, ifname_size, dev);
+#endif

if (*vnet_hdr) {
/* BSD doesn't have IFF_VNET_HDR */







Re: [Qemu-devel] [PATCH] report serial devices created with -device in the PIIX4 config space

2011-07-23 Thread Anthony Liguori

On 07/15/2011 10:10 AM, Paolo Bonzini wrote:

Serial and parallel devices created with -device are not reported in
the PIIX4 configuration space, and are hence not picked up by the DSDT.
This upsets Windows, which hides them altogether from the guest.

To avoid this, check at the end of machine initialization whether the
corresponding I/O ports have been registered.  The new function in
ioport.c does this; this also requires a tweak to isa_unassign_ioport.

I left the comment in piix4_pm_initfn since the registers I moved do
seem to match the 82371AB datasheet.  There are some quirks though.
We are setting this bit:

 "Device 8 EIO Enable (EIO_EN_DEV8)—R/W. 1=Enable PCI access to the
 device 8 enabled I/O ranges to be claimed by PIIX4 and forwarded
 to the ISA/EIO bus. 0=Disable. The LPT_MON_EN must be set to enable
 the decode."

but not LPT_MON_EN (bit 18 at 50h):

 LPT Port Enable (LPT_MON_EN)—R/W. 1=Enable accesses to parallel
 port address range (LPT_DEC_SEL) to generate a device 8 (parallel
 port) decode event. 0=Disable.

We're also setting the LPT_DEC_SEL field (that's the 0x60 written to
63h) to 11, which means reserved, rather than to 01 (378h-37Fh).

Likewise we're not setting SA_MON_EN, SB_MON_EN (respectively bit 14
and bit 16 at address 50h) for the serial ports.  However, we're setting
COMA_DEC_SEL and COMB_DEC_SEL correctly, unlike the corresponding register
for the parallel port.

All these fields are left as they are, since they are probably only
meant to be used in the DSDT.

Signed-off-by: Paolo Bonzini


Applied.  Thanks.

Regards,

Anthony Liguori


---
  hw/acpi_piix4.c |   23 ++-
  ioport.c|   19 +--
  ioport.h|2 +-
  3 files changed, 32 insertions(+), 12 deletions(-)

diff --git a/hw/acpi_piix4.c b/hw/acpi_piix4.c
index 350558b..03de3ad 100644
--- a/hw/acpi_piix4.c
+++ b/hw/acpi_piix4.c
@@ -23,6 +23,7 @@
  #include "acpi.h"
  #include "sysemu.h"
  #include "range.h"
+#include "ioport.h"

  //#define DEBUG

@@ -63,6 +64,7 @@ typedef struct PIIX4PMState {
  qemu_irq irq;
  qemu_irq smi_irq;
  int kvm_enabled;
+Notifier machine_ready;

  /* for pci hotplug */
  ACPIGPE gpe;
@@ -311,6 +313,19 @@ static void piix4_powerdown(void *opaque, int irq, int 
power_failing)
  acpi_pm1_evt_power_down(pm1a, tmr);
  }

+static void piix4_pm_machine_ready(struct Notifier* n)
+{
+PIIX4PMState *s = container_of(n, PIIX4PMState, machine_ready);
+uint8_t *pci_conf;
+
+pci_conf = s->dev.config;
+pci_conf[0x5f] = (isa_is_ioport_assigned(0x378) ? 0x80 : 0) | 0x10;
+pci_conf[0x63] = 0x60;
+pci_conf[0x67] = (isa_is_ioport_assigned(0x3f8) ? 0x08 : 0) |
+   (isa_is_ioport_assigned(0x2f8) ? 0x90 : 0);
+
+}
+
  static int piix4_pm_initfn(PCIDevice *dev)
  {
  PIIX4PMState *s = DO_UPCAST(PIIX4PMState, dev, dev);
@@ -337,11 +352,6 @@ static int piix4_pm_initfn(PCIDevice *dev)

  /* XXX: which specification is used ? The i82731AB has different
 mappings */
-pci_conf[0x5f] = (parallel_hds[0] != NULL ? 0x80 : 0) | 0x10;
-pci_conf[0x63] = 0x60;
-pci_conf[0x67] = (serial_hds[0] != NULL ? 0x08 : 0) |
-   (serial_hds[1] != NULL ? 0x90 : 0);
-
  pci_conf[0x90] = s->smb_io_base | 1;
  pci_conf[0x91] = s->smb_io_base>>  8;
  pci_conf[0xd2] = 0x09;
@@ -354,12 +364,14 @@ static int piix4_pm_initfn(PCIDevice *dev)
  qemu_system_powerdown = *qemu_allocate_irqs(piix4_powerdown, s, 1);

  pm_smbus_init(&s->dev.qdev,&s->smb);
+s->machine_ready.notify = piix4_pm_machine_ready;
+qemu_add_machine_init_done_notifier(&s->machine_ready);
  qemu_register_reset(piix4_reset, s);
  piix4_acpi_system_hot_add_init(dev->bus, s);

  return 0;
  }

  i2c_bus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,
 qemu_irq sci_irq, qemu_irq cmos_s3, qemu_irq smi_irq,
 int kvm_enabled)
diff --git a/ioport.c b/ioport.c
index 2e971fa..0d2611d 100644
--- a/ioport.c
+++ b/ioport.c
@@ -245,18 +245,25 @@ void isa_unassign_ioport(pio_addr_t start, int length)
  int i;

  for(i = start; i<  start + length; i++) {
-ioport_read_table[0][i] = default_ioport_readb;
-ioport_read_table[1][i] = default_ioport_readw;
-ioport_read_table[2][i] = default_ioport_readl;
+ioport_read_table[0][i] = NULL;
+ioport_read_table[1][i] = NULL;
+ioport_read_table[2][i] = NULL;

-ioport_write_table[0][i] = default_ioport_writeb;
-ioport_write_table[1][i] = default_ioport_writew;
-ioport_write_table[2][i] = default_ioport_writel;
+ioport_write_table[0][i] = NULL;
+ioport_write_table[1][i] = NULL;
+ioport_write_table[2][i] = NULL;

  ioport_opaque[i] = NULL;
  }
  }

+bool isa_is_ioport_assigned(pio_addr_t start)
+{
+return (ioport_read_table[0][start] || ioport_write_table[0][start] ||
+   i

Re: [Qemu-devel] [PATCH] multiboot: Support commas in module parameters

2011-07-23 Thread Anthony Liguori

On 07/06/2011 03:03 AM, Adam Lackorzynski wrote:

Support commas in the parameter list of multiboot modules as well as for the
kernel command line, by using double commas (via get_opt_value()).

Signed-off-by: Adam Lackorzynski
Reviewed-by: Kevin Wolf


Applied.  Thanks.

Regards,

Anthony Liguori


---
  hw/multiboot.c |   18 +-
  1 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/hw/multiboot.c b/hw/multiboot.c
index 6e6cfb9..2426e84 100644
--- a/hw/multiboot.c
+++ b/hw/multiboot.c
@@ -97,11 +97,11 @@ typedef struct {

  static uint32_t mb_add_cmdline(MultibootState *s, const char *cmdline)
  {
-int len = strlen(cmdline) + 1;
  target_phys_addr_t p = s->offset_cmdlines;
+char *b = (char *)s->mb_buf + p;

-pstrcpy((char *)s->mb_buf + p, len, cmdline);
-s->offset_cmdlines += len;
+get_opt_value(b, strlen(cmdline) + 1, cmdline);
+s->offset_cmdlines += strlen(b) + 1;
  return s->mb_buf_phys + p;
  }

@@ -238,7 +238,7 @@ int load_multiboot(void *fw_cfg,
  const char *r = initrd_filename;
  mbs.mb_buf_size += strlen(r) + 1;
  mbs.mb_mods_avail = 1;
-while ((r = strchr(r, ','))) {
+while (*(r = get_opt_value(NULL, 0, r))) {
 mbs.mb_mods_avail++;
 r++;
  }
@@ -252,7 +252,7 @@ int load_multiboot(void *fw_cfg,
  mbs.offset_cmdlines = mbs.offset_mbinfo + mbs.mb_mods_avail * MB_MOD_SIZE;

  if (initrd_filename) {
-char *next_initrd;
+char *next_initrd, not_last;

  mbs.offset_mods = mbs.mb_buf_size;

@@ -261,9 +261,9 @@ int load_multiboot(void *fw_cfg,
  int mb_mod_length;
  uint32_t offs = mbs.mb_buf_size;

-next_initrd = strchr(initrd_filename, ',');
-if (next_initrd)
-*next_initrd = '\0';
+next_initrd = (char *)get_opt_value(NULL, 0, initrd_filename);
+not_last = *next_initrd;
+*next_initrd = '\0';
  /* if a space comes after the module filename, treat everything
 after that as parameters */
  target_phys_addr_t c = mb_add_cmdline(&mbs, initrd_filename);
@@ -287,7 +287,7 @@ int load_multiboot(void *fw_cfg,
   (char *)mbs.mb_buf + offs,
   (char *)mbs.mb_buf + offs + mb_mod_length, c);
  initrd_filename = next_initrd+1;
-} while (next_initrd);
+} while (not_last);
  }

  /* Commandline support */





Re: [Qemu-devel] [PATCH] guest agent: qemu-ga daemon

2011-07-23 Thread Anthony Liguori

On 07/23/2011 11:06 AM, Michael Roth wrote:

On 07/23/2011 05:07 AM, Alexander Graf wrote:


On 20.07.2011, at 22:19, Michael Roth wrote:


This is the actual guest daemon, it listens for requests over a
virtio-serial/isa-serial/unix socket channel and routes them through
to dispatch routines, and writes the results back to the channel in
a manner similar to QMP.

A shorthand invocation:

qemu-ga -d

Is equivalent to:

qemu-ga -m virtio-serial -p /dev/virtio-ports/org.qemu.guest_agent.0 \
-f /var/run/qemu-ga.pid -d

Signed-off-by: Michael Roth


A rebase on top of current HEAD gave me the following on openSUSE 11.1
PPC:


agraf@lychee:/home/agraf/release/qemu> make
CC qemu-ga.o
qemu-ga.c:40: error: expected specifier-qualifier-list before ‘GSocket’


GIO is fairly new.  It may not be available on openSUSE.

Mike, you probably need to do a configure test for GIO and if it's not 
present, don't build qemu-ga.


Maybe look at just using GIOChannels which have been around much longer 
than GSocket.



qga/guest-agent-commands.c: In function ‘qmp_guest_fsfreeze_freeze’:
qga/guest-agent-commands.c:443: error: ‘FIFREEZE’ undeclared (first
use in this function)
qga/guest-agent-commands.c:443: error: (Each undeclared identifier is
reported only once
qga/guest-agent-commands.c:443: error: for each function it appears in.)
qga/guest-agent-commands.c: In function ‘qmp_guest_fsfreeze_thaw’:
qga/guest-agent-commands.c:481: error: ‘FITHAW’ undeclared (first use
in this function)


The kernel probably doesn't implement FIFREEZE.  You need to do a 
configure test and set CONFIG_FSFREEZE appropriately.  I anticipated 
this and that's why I added CONFIG_FSFREEZE and didn't just do __linux__.


Regards,

Anthony Liguori



Re: [Qemu-devel] [PATCH] guest agent: qemu-ga daemon

2011-07-23 Thread Anthony Liguori

On 07/23/2011 11:06 AM, Michael Roth wrote:

On 07/23/2011 05:07 AM, Alexander Graf wrote:


On 20.07.2011, at 22:19, Michael Roth wrote:


This is the actual guest daemon, it listens for requests over a
virtio-serial/isa-serial/unix socket channel and routes them through
to dispatch routines, and writes the results back to the channel in
a manner similar to QMP.

A shorthand invocation:

qemu-ga -d

Is equivalent to:

qemu-ga -m virtio-serial -p /dev/virtio-ports/org.qemu.guest_agent.0 \
-f /var/run/qemu-ga.pid -d

Signed-off-by: Michael Roth


A rebase on top of current HEAD gave me the following on openSUSE 11.1
PPC:


agraf@lychee:/home/agraf/release/qemu> make
CC qemu-ga.o
qemu-ga.c:40: error: expected specifier-qualifier-list before ‘GSocket’


GIO is fairly new.  It may not be available on openSUSE.

Mike, you probably need to do a configure test for GIO and if it's not 
present, don't build qemu-ga.


Maybe look at just using GIOChannels which have been around much longer 
than GSocket.



qga/guest-agent-commands.c: In function ‘qmp_guest_fsfreeze_freeze’:
qga/guest-agent-commands.c:443: error: ‘FIFREEZE’ undeclared (first
use in this function)
qga/guest-agent-commands.c:443: error: (Each undeclared identifier is
reported only once
qga/guest-agent-commands.c:443: error: for each function it appears in.)
qga/guest-agent-commands.c: In function ‘qmp_guest_fsfreeze_thaw’:
qga/guest-agent-commands.c:481: error: ‘FITHAW’ undeclared (first use
in this function)


The kernel probably doesn't implement FIFREEZE.  You need to do a 
configure test and set CONFIG_FSFREEZE appropriately.  I anticipated 
this and that's why I added CONFIG_FSFREEZE and didn't just do __linux__.


Regards,

Anthony Liguori



Re: [Qemu-devel] [PATCH] guest agent: qemu-ga daemon

2011-07-23 Thread Michael Roth

On 07/23/2011 05:07 AM, Alexander Graf wrote:


On 20.07.2011, at 22:19, Michael Roth wrote:


This is the actual guest daemon, it listens for requests over a
virtio-serial/isa-serial/unix socket channel and routes them through
to dispatch routines, and writes the results back to the channel in
a manner similar to QMP.

A shorthand invocation:

  qemu-ga -d

Is equivalent to:

  qemu-ga -m virtio-serial -p /dev/virtio-ports/org.qemu.guest_agent.0 \
  -f /var/run/qemu-ga.pid -d

Signed-off-by: Michael Roth


A rebase on top of current HEAD gave me the following on openSUSE 11.1 PPC:


agraf@lychee:/home/agraf/release/qemu>  make
   CCqemu-ga.o
qemu-ga.c:40: error: expected specifier-qualifier-list before ‘GSocket’
qemu-ga.c: In function ‘ga_logging_enabled’:
qemu-ga.c:127: error: ‘GAState’ has no member named ‘logging_enabled’
qemu-ga.c: In function ‘ga_disable_logging’:
qemu-ga.c:132: error: ‘GAState’ has no member named ‘logging_enabled’
qemu-ga.c: In function ‘ga_enable_logging’:
qemu-ga.c:137: error: ‘GAState’ has no member named ‘logging_enabled’
qemu-ga.c: In function ‘ga_log’:
qemu-ga.c:154: error: ‘GAState’ has no member named ‘log_level’
qemu-ga.c:156: error: ‘GAState’ has no member named ‘log_file’
qemu-ga.c:158: error: ‘GAState’ has no member named ‘log_file’
qemu-ga.c: In function ‘process_command’:
qemu-ga.c:284: error: ‘GAState’ has no member named ‘conn_channel’
qemu-ga.c: In function ‘process_event’:
qemu-ga.c:336: error: ‘GAState’ has no member named ‘conn_channel’
qemu-ga.c: In function ‘conn_channel_read’:
qemu-ga.c:372: error: ‘GAState’ has no member named ‘virtio’
qemu-ga.c:379: error: ‘GAState’ has no member named ‘virtio’
qemu-ga.c: In function ‘conn_channel_add’:
qemu-ga.c:396: error: ‘GAState’ has no member named ‘conn_channel’
qemu-ga.c:407: error: ‘GAState’ has no member named ‘conn_channel’
qemu-ga.c: In function ‘listen_channel_accept’:
qemu-ga.c:420: error: ‘GAState’ has no member named ‘conn_sock’
cc1: warnings being treated as errors
qemu-ga.c:420: error: implicit declaration of function ‘g_socket_accept’
qemu-ga.c:420: error: nested extern declaration of ‘g_socket_accept’
qemu-ga.c:420: error: ‘GAState’ has no member named ‘listen_sock’
qemu-ga.c:426: error: implicit declaration of function ‘g_socket_get_fd’
qemu-ga.c:426: error: nested extern declaration of ‘g_socket_get_fd’
qemu-ga.c:426: error: ‘GAState’ has no member named ‘conn_sock’
qemu-ga.c: In function ‘listen_channel_add’:
qemu-ga.c:446: error: ‘GAState’ has no member named ‘listen_channel’
qemu-ga.c:447: error: ‘GAState’ has no member named ‘listen_sock’
qemu-ga.c:448: error: ‘GAState’ has no member named ‘listen_sock’
qemu-ga.c:450: error: ‘GAState’ has no member named ‘listen_sock’
qemu-ga.c:450: error: implicit declaration of function ‘g_socket_new_from_fd’
qemu-ga.c:450: error: nested extern declaration of ‘g_socket_new_from_fd’
qemu-ga.c:457: error: ‘GAState’ has no member named ‘listen_channel’
qemu-ga.c: In function ‘conn_channel_close’:
qemu-ga.c:467: error: ‘GAState’ has no member named ‘method’
qemu-ga.c:467: error: ‘GAState’ has no member named ‘method’
qemu-ga.c:467: error: ‘GAState’ has no member named ‘method’
qemu-ga.c:467: error: ‘GAState’ has no member named ‘method’
qemu-ga.c:467: error: ‘GAState’ has no member named ‘method’
qemu-ga.c:467: error: ‘GAState’ has no member named ‘method’
qemu-ga.c:467: error: ‘GAState’ has no member named ‘method’
qemu-ga.c:467: error: ‘GAState’ has no member named ‘method’
qemu-ga.c:467: error: ‘GAState’ has no member named ‘method’
qemu-ga.c:467: error: ‘GAState’ has no member named ‘method’
qemu-ga.c:467: error: ‘GAState’ has no member named ‘method’
qemu-ga.c:467: error: ‘GAState’ has no member named ‘method’
qemu-ga.c:467: error: ‘GAState’ has no member named ‘method’
qemu-ga.c:467: error: ‘GAState’ has no member named ‘method’
qemu-ga.c:467: error: ‘GAState’ has no member named ‘method’
qemu-ga.c:467: error: ‘GAState’ has no member named ‘method’
qemu-ga.c:467: error: ‘GAState’ has no member named ‘method’
qemu-ga.c:467: error: ‘GAState’ has no member named ‘method’
qemu-ga.c:467: error: ‘GAState’ has no member named ‘method’
qemu-ga.c:467: error: ‘GAState’ has no member named ‘method’
qemu-ga.c:468: error: ‘GAState’ has no member named ‘conn_channel’
qemu-ga.c:469: error: ‘GAState’ has no member named ‘conn_sock’
qemu-ga.c:470: error: ‘GAState’ has no member named ‘conn_sock’
qemu-ga.c:472: error: ‘GAState’ has no member named ‘method’
qemu-ga.c:472: error: ‘GAState’ has no member named ‘method’
qemu-ga.c:472: error: ‘GAState’ has no member named ‘method’
qemu-ga.c:472: error: ‘GAState’ has no member named ‘method’
qemu-ga.c:472: error: ‘GAState’ has no member named ‘method’
qemu-ga.c:472: error: ‘GAState’ has no member named ‘method’
qemu-ga.c:472: error: ‘GAState’ has no member named ‘method’
qemu-ga.c:472: error: ‘GAState’ has no member named ‘method’
qemu-ga.c:472: error: ‘GAState’ has no member named ‘method’
qemu-ga.c:472: error: ‘GAState’

Re: [Qemu-devel] [PATCH v4] hw/pc: Support system flash memory with -pflash parameter

2011-07-23 Thread Anthony Liguori

On 07/08/2011 02:37 PM, Jordan Justen wrote:

If -pflash is specified and -bios is specified then pflash will
be mapped just below the system rom using hw/pflash_cfi01.c.

If -pflash is specified on the command line, but -bios is
not specified, then 'bios.bin' will NOT be loaded, and
instead the -pflash flash image will be mapped just below
4GB in place of the normal rom image.


This is way too tied to the pc platform to be this generic.

I think a better approach would be to default to having unit=0 of 
IF_PFLASH default to a read-only BDS that points to bios.bin.  -bios 
would just be a short cut to use a different file name but you should be 
able to override with -drive too.


And to really simplify things, you could add a readonly flag to -bios 
such that you could do:


-bios foo.img,readonly=off

Which is what I think you're looking for semantically.

Regards,

Anthony Liguori



Signed-off-by: Jordan Justen
Reviewed-by: Aurelien Jarno





---
  default-configs/i386-softmmu.mak   |1 +
  default-configs/x86_64-softmmu.mak |1 +
  hw/pc.c|  161 +++-
  3 files changed, 125 insertions(+), 38 deletions(-)

diff --git a/default-configs/i386-softmmu.mak b/default-configs/i386-softmmu.mak
index 55589fa..8697cd4 100644
--- a/default-configs/i386-softmmu.mak
+++ b/default-configs/i386-softmmu.mak
@@ -21,3 +21,4 @@ CONFIG_PIIX_PCI=y
  CONFIG_SOUND=y
  CONFIG_HPET=y
  CONFIG_APPLESMC=y
+CONFIG_PFLASH_CFI01=y
diff --git a/default-configs/x86_64-softmmu.mak 
b/default-configs/x86_64-softmmu.mak
index 8895028..eca9284 100644
--- a/default-configs/x86_64-softmmu.mak
+++ b/default-configs/x86_64-softmmu.mak
@@ -21,3 +21,4 @@ CONFIG_PIIX_PCI=y
  CONFIG_SOUND=y
  CONFIG_HPET=y
  CONFIG_APPLESMC=y
+CONFIG_PFLASH_CFI01=y
diff --git a/hw/pc.c b/hw/pc.c
index a3e8539..e25354f 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -41,6 +41,7 @@
  #include "sysemu.h"
  #include "blockdev.h"
  #include "ui/qemu-spice.h"
+#include "flash.h"

  /* output Bochs bios info messages */
  //#define DEBUG_BIOS
@@ -957,70 +958,154 @@ void pc_cpus_init(const char *cpu_model)
  }
  }

-void pc_memory_init(const char *kernel_filename,
-const char *kernel_cmdline,
-const char *initrd_filename,
-ram_addr_t below_4g_mem_size,
-ram_addr_t above_4g_mem_size)
+static void pc_isa_bios_init(ram_addr_t ram_offset, int ram_size)
  {
-char *filename;
-int ret, linux_boot, i;
-ram_addr_t ram_addr, bios_offset, option_rom_offset;
-int bios_size, isa_bios_size;
-void *fw_cfg;
-
-linux_boot = (kernel_filename != NULL);
+int isa_bios_size;

-/* allocate RAM */
-ram_addr = qemu_ram_alloc(NULL, "pc.ram",
-  below_4g_mem_size + above_4g_mem_size);
-cpu_register_physical_memory(0, 0xa, ram_addr);
-cpu_register_physical_memory(0x10,
- below_4g_mem_size - 0x10,
- ram_addr + 0x10);
-if (above_4g_mem_size>  0) {
-cpu_register_physical_memory(0x1ULL, above_4g_mem_size,
- ram_addr + below_4g_mem_size);
+/* map the last 128KB of the BIOS in ISA space */
+isa_bios_size = ram_size;
+if (isa_bios_size>  (128 * 1024)) {
+isa_bios_size = 128 * 1024;
  }
+ram_offset = ram_offset + ram_size - isa_bios_size;
+cpu_register_physical_memory(0x10 - isa_bios_size,
+ isa_bios_size,
+ ram_offset | IO_MEM_ROM);
+}
+
+static int pc_system_rom_init(void)
+{
+int ret;
+int bios_size;
+ram_addr_t bios_offset;
+char *filename;

  /* BIOS load */
-if (bios_name == NULL)
+if (bios_name == NULL) {
  bios_name = BIOS_FILENAME;
+}
  filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
  if (filename) {
  bios_size = get_image_size(filename);
  } else {
  bios_size = -1;
  }
-if (bios_size<= 0 ||
-(bios_size % 65536) != 0) {
-goto bios_error;
+
+if (bios_size<= 0 || (bios_size % 65536) != 0) {
+ret = -1;
+} else {
+bios_offset = qemu_ram_alloc(NULL, "pc.bios", bios_size);
+ret = rom_add_file_fixed(bios_name, (uint32_t)(-bios_size), -1);
  }
-bios_offset = qemu_ram_alloc(NULL, "pc.bios", bios_size);
-ret = rom_add_file_fixed(bios_name, (uint32_t)(-bios_size), -1);
+
  if (ret != 0) {
-bios_error:
  fprintf(stderr, "qemu: could not load PC BIOS '%s'\n", bios_name);
  exit(1);
  }
+
  if (filename) {
  qemu_free(filename);
  }
-/* map the last 128KB of the BIOS in ISA space */
-isa_bios_size = bios_size;
-if (isa_bios_size>  (128 * 1024))
-isa_bios_size = 128 * 1024;
-cpu_register_physical_memory(0x10 - isa_bios_size,
- isa_bios_size,
- 

Re: [Qemu-devel] [PATCH] report serial devices created with -device in the PIIX4 config space

2011-07-23 Thread Anthony Liguori

On 07/15/2011 04:00 PM, Andreas Färber wrote:

Am 15.07.2011 um 17:10 schrieb Paolo Bonzini:


Serial and parallel devices created with -device are not reported in
the PIIX4 configuration space, and are hence not picked up by the DSDT.
This upsets Windows, which hides them altogether from the guest.

To avoid this, check at the end of machine initialization whether the
corresponding I/O ports have been registered. The new function in
ioport.c does this; this also requires a tweak to isa_unassign_ioport.

I left the comment in piix4_pm_initfn since the registers I moved do
seem to match the 82371AB datasheet. There are some quirks though.
We are setting this bit:

"Device 8 EIO Enable (EIO_EN_DEV8)—R/W. 1=Enable PCI access to the
device 8 enabled I/O ranges to be claimed by PIIX4 and forwarded
to the ISA/EIO bus. 0=Disable. The LPT_MON_EN must be set to enable
the decode."

but not LPT_MON_EN (bit 18 at 50h):

LPT Port Enable (LPT_MON_EN)—R/W. 1=Enable accesses to parallel
port address range (LPT_DEC_SEL) to generate a device 8 (parallel
port) decode event. 0=Disable.

We're also setting the LPT_DEC_SEL field (that's the 0x60 written to
63h) to 11, which means reserved, rather than to 01 (378h-37Fh).

Likewise we're not setting SA_MON_EN, SB_MON_EN (respectively bit 14
and bit 16 at address 50h) for the serial ports. However, we're setting
COMA_DEC_SEL and COMB_DEC_SEL correctly, unlike the corresponding
register
for the parallel port.

All these fields are left as they are, since they are probably only
meant to be used in the DSDT.

Signed-off-by: Paolo Bonzini 
---
hw/acpi_piix4.c | 23 ++-
ioport.c | 19 +--
ioport.h | 2 +-
3 files changed, 32 insertions(+), 12 deletions(-)

diff --git a/hw/acpi_piix4.c b/hw/acpi_piix4.c
index 350558b..03de3ad 100644
--- a/hw/acpi_piix4.c
+++ b/hw/acpi_piix4.c



@@ -311,6 +313,19 @@ static void piix4_powerdown(void *opaque, int
irq, int power_failing)
acpi_pm1_evt_power_down(pm1a, tmr);
}

+static void piix4_pm_machine_ready(struct Notifier* n)
+{
+ PIIX4PMState *s = container_of(n, PIIX4PMState, machine_ready);


DO_UPCAST()? I assume we have it for a reason.


NIH is the reason we have it.

Regards,

Anthony Liguori



Re: [Qemu-devel] [PATCH v6] showing a splash picture when start

2011-07-23 Thread Anthony Liguori

On 07/10/2011 05:09 AM, Wayne Xia wrote:

 Added options to let qemu transfer two configuration files to bios:
"bootsplash.bmp" and "etc/boot-menu-wait", which could be specified by command
 -boot splash=P,splash-time=T
P is jpg/bmp file name or an absolute path, T have a max value of 0x, unit
is ms. With these two options, if user invoke qemu with menu=on option, then
a splash picture would be showed in a given time. For example:
 qemu -boot menu=on,splash=/root/boot.bmp,splash-time=5000
would make boot.bmp shown as a brand with 5 seconds in the booting up process.
This feature need the new seabios's support, which could be got from git.


Please include documentation in qemu-doc.texi including information on 
what image formats are supported and what restrictions are present (for 
instance 24-bit depth bitmaps with what resolution?).


Regards,

Anthony Liguori



Signed-off-by: Wayne Xia
---
  hw/fw_cfg.c   |  140 -
  qemu-config.c |   27 +++
  sysemu.h  |3 +
  vl.c  |   17 +++-
  4 files changed, 185 insertions(+), 2 deletions(-)

diff --git a/hw/fw_cfg.c b/hw/fw_cfg.c
index 85c8c3c..434fc96 100644
--- a/hw/fw_cfg.c
+++ b/hw/fw_cfg.c
@@ -26,6 +26,7 @@
  #include "isa.h"
  #include "fw_cfg.h"
  #include "sysbus.h"
+#include "qemu-error.h"

  /* debug firmware config */
  //#define DEBUG_FW_CFG
@@ -56,6 +57,143 @@ struct FWCfgState {
  Notifier machine_ready;
  };

+#define JPG_FILE 0
+#define BMP_FILE 1
+
+static FILE *probe_splashfile(char *filename, int *file_sizep, int *file_typep)
+{
+FILE *fp = NULL;
+int fop_ret;
+int file_size;
+int file_type = -1;
+unsigned char buf[2] = {0, 0};
+unsigned int filehead_value = 0;
+int bmp_bpp;
+
+fp = fopen(filename, "rb");
+if (fp == NULL) {
+error_report("failed to open file '%s'.", filename);
+return fp;
+}
+/* check file size */
+fseek(fp, 0L, SEEK_END);
+file_size = ftell(fp);
+if (file_size<  2) {
+error_report("file size is less than 2 bytes '%s'.", filename);
+fclose(fp);
+fp = NULL;
+return fp;
+}
+/* check magic ID */
+fseek(fp, 0L, SEEK_SET);
+fop_ret = fread(buf, 1, 2, fp);
+filehead_value = (buf[0] + (buf[1]<<  8))&  0x;
+if (filehead_value == 0xd8ff) {
+file_type = JPG_FILE;
+} else {
+if (filehead_value == 0x4d42) {
+file_type = BMP_FILE;
+}
+}
+if (file_type<  0) {
+error_report("'%s' not jpg/bmp file,head:0x%x.",
+ filename, filehead_value);
+fclose(fp);
+fp = NULL;
+return fp;
+}
+/* check BMP bpp */
+if (file_type == BMP_FILE) {
+fseek(fp, 28, SEEK_SET);
+fop_ret = fread(buf, 1, 2, fp);
+bmp_bpp = (buf[0] + (buf[1]<<  8))&  0x;
+if (bmp_bpp != 24) {
+error_report("only 24bpp bmp file is supported.");
+fclose(fp);
+fp = NULL;
+return fp;
+}
+}
+/* return values */
+*file_sizep = file_size;
+*file_typep = file_type;
+return fp;
+}
+
+static void fw_cfg_bootsplash(FWCfgState *s)
+{
+int boot_splash_time = -1;
+const char *boot_splash_filename = NULL;
+char *p;
+char *filename;
+FILE *fp;
+int fop_ret;
+int file_size;
+int file_type = -1;
+const char *temp;
+
+/* get user configuration */
+QemuOptsList *plist = qemu_find_opts("boot-opts");
+QemuOpts *opts = QTAILQ_FIRST(&plist->head);
+if (opts != NULL) {
+temp = qemu_opt_get(opts, "splash");
+if (temp != NULL) {
+boot_splash_filename = temp;
+}
+temp = qemu_opt_get(opts, "splash-time");
+if (temp != NULL) {
+p = (char *)temp;
+boot_splash_time = strtol(p, (char **)&p, 10);
+}
+}
+
+/* insert splash time if user configurated */
+if (boot_splash_time>= 0) {
+/* validate the input */
+if (boot_splash_time>  0x) {
+error_report("splash time is big than 65535, force it to 65535.");
+boot_splash_time = 0x;
+}
+/* use little endian format */
+qemu_extra_params_fw[0] = (uint8_t)(boot_splash_time&  0xff);
+qemu_extra_params_fw[1] = (uint8_t)((boot_splash_time>>  8)&  0xff);
+fw_cfg_add_file(s, "etc/boot-menu-wait", qemu_extra_params_fw, 2);
+}
+
+/* insert splash file if user configurated */
+if (boot_splash_filename != NULL) {
+filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, boot_splash_filename);
+if (filename == NULL) {
+error_report("failed to find file '%s'.", boot_splash_filename);
+return;
+}
+/* probing the file */
+fp = probe_splashfile(filename,&file_size,&file_type);
+if (fp == NULL) {
+qemu_free(filename);
+  

Re: [Qemu-devel] [PATCH 00/10] [RESEND] Various net and slirp fixes & enhancements

2011-07-23 Thread Anthony Liguori

On 07/20/2011 05:20 AM, Jan Kiszka wrote:

Almost just a reposting of the previously sent series. No patch
modified, but a nifty (IMO) new one: ping forwarding for slirp using
the unprivileged ICMP sockets of Linux 3.0. See commit log for a simple
how-to.

CC: Gleb Natapov
CC: Markus Armbruster
CC: Peter Maydell


Applied.  Thanks.

The ICMP sockets thing is pretty cool!

Regards,

Anthony Liguori



Jan Kiszka (10):
   slirp: Fix restricted mode
   slirp: Canonicalize restrict syntax
   slirp: Strictly associate DHCP/BOOTP and TFTP with virtual host
   slirp: Replace m_freem with m_free
   slirp: Put forked exec into separate process group
   slirp: Forward ICMP echo requests via unprivileged sockets
   net: Improve layout of 'info network'
   net: Refactor net_client_types
   net: Dump client type 'info network'
   net: Consistently use qemu_macaddr_default_if_unset

  hw/dp8393x.c   |2 +-
  hw/etraxfs_eth.c   |2 +-
  hw/mcf_fec.c   |2 +-
  hw/mipsnet.c   |2 +-
  hw/qdev.c  |2 +-
  hw/stellaris.c |2 +-
  hw/xen_devconfig.c |4 +-
  net.c  |   65 +--
  net.h  |8 +++--
  net/slirp.c|   23 +
  qemu-options.hx|4 +-
  slirp/ip_icmp.c|   95 +--
  slirp/ip_icmp.h|3 ++
  slirp/ip_input.c   |   30 +++--
  slirp/ip_output.c  |4 +-
  slirp/mbuf.h   |3 --
  slirp/misc.c   |   16 -
  slirp/slirp.c  |   37 
  slirp/slirp.h  |5 +++
  slirp/socket.c |2 +
  slirp/tcp_input.c  |   10 +++---
  slirp/tcp_subr.c   |2 +-
  slirp/udp.c|   23 +++-
  23 files changed, 249 insertions(+), 97 deletions(-)






Re: [Qemu-devel] [PATCH] guest agent: use QERR_UNSUPPORTED for disabled RPCs

2011-07-23 Thread Anthony Liguori

On 07/22/2011 04:42 PM, Michael Roth wrote:

Applied.  Thanks.

Regards,

Anthony Liguori


---
  qga/guest-agent-commands.c |6 +++---
  1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/qga/guest-agent-commands.c b/qga/guest-agent-commands.c
index e215bd3..624972e 100644
--- a/qga/guest-agent-commands.c
+++ b/qga/guest-agent-commands.c
@@ -521,7 +521,7 @@ static void guest_fsfreeze_cleanup(void)
   */
  GuestFsfreezeStatus qmp_guest_fsfreeze_status(Error **err)
  {
-error_set(err, QERR_COMMAND_NOT_FOUND, "guest_fsfreeze_status");
+error_set(err, QERR_UNSUPPORTED);

  return 0;
  }
@@ -532,7 +532,7 @@ GuestFsfreezeStatus qmp_guest_fsfreeze_status(Error **err)
   */
  int64_t qmp_guest_fsfreeze_freeze(Error **err)
  {
-error_set(err, QERR_COMMAND_NOT_FOUND, "guest_fsfreeze_freeze");
+error_set(err, QERR_UNSUPPORTED);

  return 0;
  }
@@ -542,7 +542,7 @@ int64_t qmp_guest_fsfreeze_freeze(Error **err)
   */
  int64_t qmp_guest_fsfreeze_thaw(Error **err)
  {
-error_set(err, QERR_COMMAND_NOT_FOUND, "guest_fsfreeze_thaw");
+error_set(err, QERR_UNSUPPORTED);

  return 0;
  }





Re: [Qemu-devel] [PATCH] .gitignore: ignore qemu-ga and qapi-generated

2011-07-23 Thread Anthony Liguori

On 07/23/2011 12:41 AM, Alexandre Raymond wrote:

Add a new binary and generation directory to the gitignore file

Signed-off-by: Alexandre Raymond


Applied.  Thanks.

Regards,

Anthony Liguori


---
  .gitignore |2 ++
  1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/.gitignore b/.gitignore
index 08013fc..54835bc 100644
--- a/.gitignore
+++ b/.gitignore
@@ -15,6 +15,7 @@ libdis*
  libhw32
  libhw64
  libuser
+qapi-generated
  qemu-doc.html
  qemu-tech.html
  qemu-doc.info
@@ -32,6 +33,7 @@ qemu-options.texi
  qemu-img-cmds.texi
  qemu-img-cmds.h
  qemu-io
+qemu-ga
  qemu-monitor.texi
  QMP/qmp-commands.txt
  .gdbinit





Re: [Qemu-devel] [RESEND][PATCH v3] Generalize -machine command line option

2011-07-23 Thread Anthony Liguori

On 07/23/2011 05:38 AM, Jan Kiszka wrote:

From: Jan Kiszka

-machine somehow suggests that it selects the machine, but it doesn't.
Fix that before this command is set in stone.

Actually, -machine should supersede -M and allow to introduce arbitrary
per-machine options to the command line. That will change the internal
realization again, but we will be able to keep the user interface
stable.

Tested-by: Ian Campbell
Signed-off-by: Jan Kiszka


Applied.  Thanks.

Regards,

Anthony Liguori


---

NOTE: This patch is a MUST HAVE for 0.15 as we otherwise set a half
done command line interface into stone!

Changes in v3:
  - fix regression of default machine options handling, -machine xenfv
selects accel=xen again
(I really hope we can clean up the defaults, make them more
generally useful when switching to some QCFG.)

Changes in v2:
  - fix regression of -M my factoring out machine_parse and using it for
both old and new command.

  qemu-config.c   |5 +
  qemu-options.hx |   20 +++-
  vl.c|   43 ++-
  3 files changed, 46 insertions(+), 22 deletions(-)

diff --git a/qemu-config.c b/qemu-config.c
index 93d20c6..b2ec40b 100644
--- a/qemu-config.c
+++ b/qemu-config.c
@@ -464,9 +464,14 @@ QemuOptsList qemu_option_rom_opts = {

  static QemuOptsList qemu_machine_opts = {
  .name = "machine",
+.implied_opt_name = "type",
  .head = QTAILQ_HEAD_INITIALIZER(qemu_machine_opts.head),
  .desc = {
  {
+.name = "type",
+.type = QEMU_OPT_STRING,
+.help = "emulated machine"
+}, {
  .name = "accel",
  .type = QEMU_OPT_STRING,
  .help = "accelerator list",
diff --git a/qemu-options.hx b/qemu-options.hx
index 64114dd..195943b 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -2075,13 +2075,23 @@ if KVM support is enabled when compiling.
  ETEXI

  DEF("machine", HAS_ARG, QEMU_OPTION_machine, \
-"-machine accel=accel1[:accel2]use an accelerator (kvm,xen,tcg), default is 
tcg\n", QEMU_ARCH_ALL)
+"-machine [type=]name[,prop[=value][,...]]\n"
+"selects emulated machine (-machine ? for list)\n"
+"property accel=accel1[:accel2[:...]] selects 
accelerator\n"
+"supported accelerators are kvm, xen, tcg (default: 
tcg)\n",
+QEMU_ARCH_ALL)
  STEXI
-@item -machine accel=@var{accels}
+@item -machine [type=]@var{name}[,prop=@var{value}[,...]]
  @findex -machine
-This is use to enable an accelerator, in kvm,xen,tcg.
-By default, it use only tcg. If there a more than one accelerator
-specified, the next one is used if the first don't work.
+Select the emulated machine by @var{name}. Use @code{-machine ?} to list
+available machines. Supported machine properties are:
+@table @option
+@item accel=@var{accels1}[:@var{accels2}[:...]]
+This is used to enable an accelerator. Depending on the target architecture,
+kvm, xen, or tcg can be available. By default, tcg is used. If there is more
+than one accelerator specified, the next one is used if the previous one fails
+to initialize.
+@end table
  ETEXI

  DEF("xen-domid", HAS_ARG, QEMU_OPTION_xen_domid,
diff --git a/vl.c b/vl.c
index fcd7395..acfff85 100644
--- a/vl.c
+++ b/vl.c
@@ -1899,6 +1899,27 @@ static int debugcon_parse(const char *devname)
  return 0;
  }

+static QEMUMachine *machine_parse(const char *name)
+{
+QEMUMachine *m, *machine = NULL;
+
+if (name) {
+machine = find_machine(name);
+}
+if (machine) {
+return machine;
+}
+printf("Supported machines are:\n");
+for (m = first_machine; m != NULL; m = m->next) {
+if (m->alias) {
+printf("%-10s %s (alias of %s)\n", m->alias, m->desc, m->name);
+}
+printf("%-10s %s%s\n", m->name, m->desc,
+   m->is_default ? " (default)" : "");
+}
+exit(!name || *name != '?');
+}
+
  static int tcg_init(void)
  {
  return 0;
@@ -2155,20 +2176,7 @@ int main(int argc, char **argv, char **envp)
  }
  switch(popt->index) {
  case QEMU_OPTION_M:
-machine = find_machine(optarg);
-if (!machine) {
-QEMUMachine *m;
-printf("Supported machines are:\n");
-for(m = first_machine; m != NULL; m = m->next) {
-if (m->alias)
-printf("%-10s %s (alias of %s)\n",
-   m->alias, m->desc, m->name);
-printf("%-10s %s%s\n",
-   m->name, m->desc,
-   m->is_default ? " (default)" : "");
-}
-exit(*optarg != '?');
-}
+machine = machine_parse(optarg);
  break;
  case QEMU_OPTION_cpu:
  /* hw initialization wil

Re: [Qemu-devel] [PATCH V2] Add "tee" option to qemu char device

2011-07-23 Thread Anthony Liguori

On 07/14/2011 03:58 AM, Chunyan Liu wrote:

Add "tee" backend to char device. It could be used as follows:
 -serial tee:filepath,pty
 -chardev tee,tee_fpath=path,tee_backend=pty,,path=path,,[mux=on|off]
With "tee" option, "pty" output would be duplicated to filepath.
Related thread:
http://lists.nongnu.org/archive/html/qemu-devel/2011-07/msg00105.html


I loathe adding even more complexity to the the char layer.  Can't you 
do this just as well with socat?


Regards,

Anthony Liguori



V2 changes:
 -implement "tee" as a new backend. V1 implemented "tee" as a option.
 -add documentation in qemu-options.hx.

Please review. Thanks.

---
  qemu-char.c |  168 ++-
  qemu-config.c   |6 ++
  qemu-options.hx |   25 -
  3 files changed, 197 insertions(+), 2 deletions(-)

diff --git a/qemu-char.c b/qemu-char.c
index fb13b28..99e49a9 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -228,6 +228,156 @@ static CharDriverState *qemu_chr_open_null(QemuOpts *opts)
  return chr;
  }

+/* Tee driver */
+typedef struct {
+CharDriverState *basechr; /* base io*/
+CharDriverState *filechr; /* duplicate output to file */
+} TeeDriver;
+
+static void tee_init(CharDriverState *chr)
+{
+TeeDriver *s = chr->opaque;
+if (s->basechr->init) {
+s->basechr->init(s->basechr);
+}
+if (s->filechr->init) {
+s->filechr->init(s->filechr);
+}
+}
+
+static void tee_chr_update_read_handler(CharDriverState *chr)
+{
+TeeDriver *s = chr->opaque;
+qemu_chr_add_handlers(s->basechr, chr->chr_can_read, chr->chr_read,
+  chr->chr_event, chr->handler_opaque);
+}
+
+/* tee_chr_write will return the write result of basechr, write result to file
+ * will be ignored. FIX ME. */
+static int tee_chr_write(CharDriverState *chr, const uint8_t *buf, int len)
+{
+TeeDriver *s = chr->opaque;
+if (s->filechr->chr_write) {
+s->filechr->chr_write(s->filechr, buf, len);
+}
+if (s->basechr->chr_write) {
+return s->basechr->chr_write(s->basechr, buf, len);
+}
+return 0;
+}
+
+static void tee_chr_close(CharDriverState *chr)
+{
+TeeDriver *s = chr->opaque;
+if (s->basechr->chr_close) {
+s->basechr->chr_close(s->basechr);
+}
+if (s->filechr->chr_close) {
+s->filechr->chr_close(s->filechr);
+}
+qemu_free(s);
+}
+
+static int tee_chr_ioctl(CharDriverState *chr, int cmd, void *arg)
+{
+TeeDriver *s = chr->opaque;
+if (s->basechr->chr_ioctl) {
+return s->basechr->chr_ioctl(s->basechr, cmd, arg);
+}
+return 0;
+}
+
+static int tee_get_msgfd(CharDriverState *chr)
+{
+TeeDriver *s = chr->opaque;
+if (s->basechr->get_msgfd) {
+return s->basechr->get_msgfd(s->basechr);
+}
+return -1;
+}
+
+static void tee_chr_send_event(CharDriverState *chr, int event)
+{
+TeeDriver *s = chr->opaque;
+if (s->basechr->chr_send_event) {
+s->basechr->chr_send_event(s->basechr, event);
+}
+}
+
+static void tee_chr_accept_input(CharDriverState *chr)
+{
+TeeDriver *s = chr->opaque;
+if (s->basechr->chr_accept_input) {
+s->basechr->chr_accept_input(s->basechr);
+}
+}
+static void tee_chr_set_echo(CharDriverState *chr, bool echo)
+{
+TeeDriver *s = chr->opaque;
+if (s->basechr->chr_set_echo) {
+s->basechr->chr_set_echo(s->basechr, echo);
+}
+}
+static void tee_chr_guest_open(CharDriverState *chr)
+{
+TeeDriver *s = chr->opaque;
+if (s->basechr->chr_guest_open) {
+s->basechr->chr_guest_open(s->basechr);
+}
+}
+static void tee_chr_guest_close(CharDriverState *chr)
+{
+TeeDriver *s = chr->opaque;
+if (s->basechr->chr_guest_close) {
+s->basechr->chr_guest_close(s->basechr);
+}
+}
+
+static CharDriverState *qemu_chr_open_tee(QemuOpts *opts)
+{
+CharDriverState *chr;
+TeeDriver *d;
+CharDriverState *basechr;
+CharDriverState *filechr;
+const char *label = qemu_opts_id(opts);
+const char *tee_fpath = qemu_opt_get(opts, "tee_fpath");
+const char *tee_backend = qemu_opt_get(opts, "tee_backend");
+char *new_label, *new_filename;
+int sz;
+
+chr = qemu_mallocz(sizeof(CharDriverState));
+d = qemu_mallocz(sizeof(TeeDriver));
+
+sz = strlen(label)+3;
+new_label = qemu_malloc(sz);
+snprintf(new_label, sz, "%s-0", label);
+basechr = qemu_chr_open(new_label, tee_backend, NULL);
+
+snprintf(new_label, sz, "%s-1", label);
+sz = strlen(tee_fpath)+6;
+new_filename = qemu_malloc(sz);
+snprintf(new_filename, sz, "file:%s", tee_fpath);
+filechr = qemu_chr_open(new_label, new_filename, NULL);
+qemu_free(new_label);
+qemu_free(new_filename);
+
+d->basechr = basechr;
+d->filechr = filechr;
+chr->opaque = d;
+chr->init = tee_init;
+chr->chr_write = tee_chr_write;
+chr->chr_close = tee_chr_close;
+chr->chr_update_read_handler = tee_chr_u

[Qemu-devel] [PATCH 05/28] PPC: Set MPIC IDE for IPI to 0

2011-07-23 Thread Alexander Graf
We use the IDE register with IPIs as a mask to keep track which processors
have already acknowledged the respective interrupt. So we need to initialize
it to 0 to make sure that it doesn't accidently fire an IPI on CPU0 when the
first IPI is triggered.

Reported-by: Elie Richa 
Signed-off-by: Alexander Graf 
---
 hw/openpic.c |4 
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/hw/openpic.c b/hw/openpic.c
index 9ac3b3d..1f7753d 100644
--- a/hw/openpic.c
+++ b/hw/openpic.c
@@ -1304,6 +1304,10 @@ static void mpic_reset (void *opaque)
 mpp->src[i].ipvp = 0x8080;
 mpp->src[i].ide  = 0x0001;
 }
+/* Set IDE for IPIs to 0 so we don't get spurious interrupts */
+for (i = mpp->irq_ipi0; i < MAX_IPI; i++) {
+mpp->src[i].ide = 0;
+}
 /* Initialise IRQ destinations */
 for (i = 0; i < MAX_CPU; i++) {
 mpp->dst[i].pctp  = 0x000F;
-- 
1.6.0.2




[Qemu-devel] [PATCH 18/28] PPC: KVM: Add stubs for kvm helper functions

2011-07-23 Thread Alexander Graf
We have a bunch of helper functions that don't have any stubs for them in case
we don't have CONFIG_KVM enabled. That didn't bite us so far, because gcc can
optimize them out pretty well, but we should really provide them.

Signed-off-by: Alexander Graf 

---

v1 -> v2:

   - use uint64_t for clockfreq
---
 target-ppc/kvm_ppc.h |   26 ++
 1 files changed, 26 insertions(+), 0 deletions(-)

diff --git a/target-ppc/kvm_ppc.h b/target-ppc/kvm_ppc.h
index 0c659c8..76f98d9 100644
--- a/target-ppc/kvm_ppc.h
+++ b/target-ppc/kvm_ppc.h
@@ -11,11 +11,37 @@
 
 void kvmppc_init(void);
 
+#ifdef CONFIG_KVM
+
 uint32_t kvmppc_get_tbfreq(void);
 uint64_t kvmppc_get_clockfreq(void);
 int kvmppc_get_hypercall(CPUState *env, uint8_t *buf, int buf_len);
 int kvmppc_set_interrupt(CPUState *env, int irq, int level);
 
+#else
+
+static inline uint32_t kvmppc_get_tbfreq(void)
+{
+return 0;
+}
+
+static inline uint64_t kvmppc_get_clockfreq(void)
+{
+return 0;
+}
+
+static inline int kvmppc_get_hypercall(CPUState *env, uint8_t *buf, int 
buf_len)
+{
+return -1;
+}
+
+static inline int kvmppc_set_interrupt(CPUState *env, int irq, int level)
+{
+return -1;
+}
+
+#endif
+
 #ifndef CONFIG_KVM
 #define kvmppc_eieio() do { } while (0)
 #else
-- 
1.6.0.2




[Qemu-devel] [PATCH 15/28] PPC: E500: Remove mpc8544_copy_soc_cell

2011-07-23 Thread Alexander Graf
We don't need mpc8544_copy_soc_cell anymore, since we're explicitly reading
host values and writing guest values respectively.

Signed-off-by: Alexander Graf 
---
 hw/ppce500_mpc8544ds.c |   24 
 1 files changed, 0 insertions(+), 24 deletions(-)

diff --git a/hw/ppce500_mpc8544ds.c b/hw/ppce500_mpc8544ds.c
index eedd149..8a51ac7 100644
--- a/hw/ppce500_mpc8544ds.c
+++ b/hw/ppce500_mpc8544ds.c
@@ -56,30 +56,6 @@ struct boot_info
 uint32_t entry;
 };
 
-#ifdef CONFIG_FDT
-static int mpc8544_copy_soc_cell(void *fdt, const char *node, const char *prop)
-{
-uint32_t cell;
-int ret;
-
-ret = kvmppc_read_host_property(node, prop, &cell, sizeof(cell));
-if (ret < 0) {
-fprintf(stderr, "couldn't read host %s/%s\n", node, prop);
-goto out;
-}
-
-ret = qemu_devtree_setprop_cell(fdt, "/cpus/PowerPC,8544@0",
-prop, cell);
-if (ret < 0) {
-fprintf(stderr, "couldn't set guest /cpus/PowerPC,8544@0/%s\n", prop);
-goto out;
-}
-
-out:
-return ret;
-}
-#endif
-
 static int mpc8544_load_device_tree(CPUState *env,
 target_phys_addr_t addr,
 uint32_t ramsize,
-- 
1.6.0.2




[Qemu-devel] [PATCH 21/28] PPC: E500: Add PV spinning code

2011-07-23 Thread Alexander Graf
CPUs that are not the boot CPU need to run in spinning code to check if they
should run off to execute and if so where to jump to. This usually happens
by leaving secondary CPUs looping and checking if some variable in memory
changed.

In an environment like Qemu however we can be more clever. We can just export
the spin table the primary CPU modifies as MMIO region that would event based
wake up the respective secondary CPUs. That saves us quite some cycles while
the secondary CPUs are not up yet.

So this patch adds a PV device that simply exports the spinning table into the
guest and thus allows the primary CPU to wake up secondary ones.

Signed-off-by: Alexander Graf 

---

v1 -> v2:

  - change into MMIO scheme
  - map the secondary NIP instead of 0 1:1
  - only map 64MB for TLB, same as u-boot
  - prepare code for 64-bit spinnings
---
 Makefile.target|2 +-
 hw/ppce500_mpc8544ds.c |   33 -
 hw/ppce500_spin.c  |  182 
 3 files changed, 212 insertions(+), 5 deletions(-)
 create mode 100644 hw/ppce500_spin.c

diff --git a/Makefile.target b/Makefile.target
index 19f6101..925abd3 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -251,7 +251,7 @@ endif
 obj-ppc-y += ppc4xx_devs.o ppc4xx_pci.o ppc405_uc.o ppc405_boards.o
 obj-ppc-y += ppc440.o ppc440_bamboo.o
 # PowerPC E500 boards
-obj-ppc-y += ppce500_mpc8544ds.o mpc8544_guts.o
+obj-ppc-y += ppce500_mpc8544ds.o mpc8544_guts.o ppce500_spin.o
 # PowerPC 440 Xilinx ML507 reference board.
 obj-ppc-y += virtex_ml507.o
 obj-ppc-$(CONFIG_KVM) += kvm_ppc.o
diff --git a/hw/ppce500_mpc8544ds.c b/hw/ppce500_mpc8544ds.c
index c74119a..96a5362 100644
--- a/hw/ppce500_mpc8544ds.c
+++ b/hw/ppce500_mpc8544ds.c
@@ -49,6 +49,7 @@
 #define MPC8544_PCI_IO 0xE100
 #define MPC8544_PCI_IOLEN  0x1
 #define MPC8544_UTIL_BASE  (MPC8544_CCSRBAR_BASE + 0xe)
+#define MPC8544_SPIN_BASE  0xEF00
 
 struct boot_info
 {
@@ -164,6 +165,18 @@ static void mmubooke_create_initial_mapping(CPUState *env,
 tlb->mas7_3 |= MAS3_UR | MAS3_UW | MAS3_UX | MAS3_SR | MAS3_SW | MAS3_SX;
 }
 
+static void mpc8544ds_cpu_reset_sec(void *opaque)
+{
+CPUState *env = opaque;
+
+cpu_reset(env);
+
+/* Secondary CPU starts in halted state for now. Needs to change when
+   implementing non-kernel boot. */
+env->halted = 1;
+env->exception_index = EXCP_HLT;
+}
+
 static void mpc8544ds_cpu_reset(void *opaque)
 {
 CPUState *env = opaque;
@@ -172,6 +185,7 @@ static void mpc8544ds_cpu_reset(void *opaque)
 cpu_reset(env);
 
 /* Set initial guest state. */
+env->halted = 0;
 env->gpr[1] = (16<<20) - 8;
 env->gpr[3] = bi->dt_base;
 env->nip = bi->entry;
@@ -199,7 +213,6 @@ static void mpc8544ds_init(ram_addr_t ram_size,
 unsigned int pci_irq_nrs[4] = {1, 2, 3, 4};
 qemu_irq **irqs, *mpic;
 DeviceState *dev;
-struct boot_info *boot_info;
 CPUState *firstenv = NULL;
 
 /* Setup CPUs */
@@ -234,9 +247,16 @@ static void mpc8544ds_init(ram_addr_t ram_size,
 env->spr[SPR_40x_TCR] = 1 << 26;
 
 /* Register reset handler */
-boot_info = qemu_mallocz(sizeof(struct boot_info));
-qemu_register_reset(mpc8544ds_cpu_reset, env);
-env->load_info = boot_info;
+if (!i) {
+/* Primary CPU */
+struct boot_info *boot_info;
+boot_info = qemu_mallocz(sizeof(struct boot_info));
+qemu_register_reset(mpc8544ds_cpu_reset, env);
+env->load_info = boot_info;
+} else {
+/* Secondary CPUs */
+qemu_register_reset(mpc8544ds_cpu_reset_sec, env);
+}
 }
 
 env = firstenv;
@@ -289,6 +309,9 @@ static void mpc8544ds_init(ram_addr_t ram_size,
 }
 }
 
+/* Register spinning region */
+sysbus_create_simple("e500-spin", MPC8544_SPIN_BASE, NULL);
+
 /* Load kernel. */
 if (kernel_filename) {
 kernel_size = load_uimage(kernel_filename, &entry, &loadaddr, NULL);
@@ -321,6 +344,8 @@ static void mpc8544ds_init(ram_addr_t ram_size,
 
 /* If we're loading a kernel directly, we must load the device tree too. */
 if (kernel_filename) {
+struct boot_info *boot_info;
+
 #ifndef CONFIG_FDT
 cpu_abort(env, "Compiled without FDT support - can't load kernel\n");
 #endif
diff --git a/hw/ppce500_spin.c b/hw/ppce500_spin.c
new file mode 100644
index 000..299aab6
--- /dev/null
+++ b/hw/ppce500_spin.c
@@ -0,0 +1,182 @@
+#include "hw.h"
+#include "sysemu.h"
+#include "sysbus.h"
+#include "rwhandler.h"
+#include "kvm.h"
+
+#define MAX_CPUS 32
+
+typedef struct spin_info {
+uint64_t addr;
+uint64_t r3;
+uint32_t resv;
+uint32_t pir;
+uint64_t r6;
+} __attribute__ ((packed)) SpinInfo;
+
+typedef struct spin_state {
+SysBusDevice busdev;
+ReadWriteHandler rw;
+SpinInfo spin[MAX_CPUS];
+} SpinState;
+
+typedef struct spin_kick {
+CPUSt

[Qemu-devel] [PATCH 03/28] PPC: Extend MPIC MMIO range

2011-07-23 Thread Alexander Graf
The MPIC exports a page for each CPU that it controls. To support more than
one CPU, we need to also reserve the MMIO space according to the amount of
CPUs we want to support.

Signed-off-by: Alexander Graf 
---
 hw/openpic.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/hw/openpic.c b/hw/openpic.c
index 491bfee..ad45331 100644
--- a/hw/openpic.c
+++ b/hw/openpic.c
@@ -128,7 +128,7 @@ enum {
 #define MPIC_MSI_REG_START0x11C00
 #define MPIC_MSI_REG_SIZE 0x100
 #define MPIC_CPU_REG_START0x2
-#define MPIC_CPU_REG_SIZE 0x100
+#define MPIC_CPU_REG_SIZE 0x100 + ((MAX_CPU - 1) * 0x1000)
 
 enum mpic_ide_bits {
 IDR_EP = 0,
-- 
1.6.0.2




[Qemu-devel] [PATCH 24/28] device tree: dont fail operations

2011-07-23 Thread Alexander Graf
When we screw up and issue an FDT command that doesn't work, we really need to
know immediately and usually can't continue to create the machine. To make sure
we don't need to add error checking in all device tree modification code users,
we can just add the fail checks to the qemu abstract functions.

Signed-off-by: Alexander Graf 
---
 device_tree.c |   76 ++--
 1 files changed, 51 insertions(+), 25 deletions(-)

diff --git a/device_tree.c b/device_tree.c
index e58d522..2af345b 100644
--- a/device_tree.c
+++ b/device_tree.c
@@ -72,56 +72,81 @@ fail:
 return NULL;
 }
 
-int qemu_devtree_setprop(void *fdt, const char *node_path,
- const char *property, void *val_array, int size)
+static int findnode_nofail(void *fdt, const char *node_path)
 {
 int offset;
 
 offset = fdt_path_offset(fdt, node_path);
-if (offset < 0)
-return offset;
+if (offset < 0) {
+fprintf(stderr, "%s Couldn't find node %s: %s\n", __func__, node_path,
+fdt_strerror(offset));
+exit(1);
+}
+
+return offset;
+}
+
+int qemu_devtree_setprop(void *fdt, const char *node_path,
+ const char *property, void *val_array, int size)
+{
+int r;
+
+r = fdt_setprop(fdt, findnode_nofail(fdt, node_path), property, val_array, 
size);
+if (r < 0) {
+fprintf(stderr, "%s: Couldn't set %s/%s: %s\n", __func__, node_path,
+property, fdt_strerror(r));
+exit(1);
+}
 
-return fdt_setprop(fdt, offset, property, val_array, size);
+return r;
 }
 
 int qemu_devtree_setprop_cell(void *fdt, const char *node_path,
   const char *property, uint32_t val)
 {
-int offset;
+int r;
 
-offset = fdt_path_offset(fdt, node_path);
-if (offset < 0)
-return offset;
+r = fdt_setprop_cell(fdt, findnode_nofail(fdt, node_path), property, val);
+if (r < 0) {
+fprintf(stderr, "%s: Couldn't set %s/%s = %#08x: %s\n", __func__,
+node_path, property, val, fdt_strerror(r));
+exit(1);
+}
 
-return fdt_setprop_cell(fdt, offset, property, val);
+return r;
 }
 
 int qemu_devtree_setprop_string(void *fdt, const char *node_path,
 const char *property, const char *string)
 {
-int offset;
+int r;
 
-offset = fdt_path_offset(fdt, node_path);
-if (offset < 0)
-return offset;
+r = fdt_setprop_string(fdt, findnode_nofail(fdt, node_path), property, 
string);
+if (r < 0) {
+fprintf(stderr, "%s: Couldn't set %s/%s = %s: %s\n", __func__,
+node_path, property, string, fdt_strerror(r));
+exit(1);
+}
 
-return fdt_setprop_string(fdt, offset, property, string);
+return r;
 }
 
 int qemu_devtree_nop_node(void *fdt, const char *node_path)
 {
-int offset;
+int r;
 
-offset = fdt_path_offset(fdt, node_path);
-if (offset < 0)
-return offset;
+r = fdt_nop_node(fdt, findnode_nofail(fdt, node_path));
+if (r < 0) {
+fprintf(stderr, "%s: Couldn't nop node %s: %s\n", __func__, node_path,
+fdt_strerror(r));
+exit(1);
+}
 
-return fdt_nop_node(fdt, offset);
+return r;
 }
 
 int qemu_devtree_add_subnode(void *fdt, const char *name)
 {
-int offset;
 char *dupname = qemu_strdup(name);
 char *basename = strrchr(dupname, '/');
 int retval;
@@ -133,12 +158,13 @@ int qemu_devtree_add_subnode(void *fdt, const char *name)
 basename[0] = '\0';
 basename++;
 
-offset = fdt_path_offset(fdt, dupname);
-if (offset < 0) {
-return offset;
+retval = fdt_add_subnode(fdt, findnode_nofail(fdt, dupname), basename);
+if (retval < 0) {
+fprintf(stderr, "FDT: Failed to create subnode %s: %s\n", name,
+fdt_strerror(retval));
+exit(1);
 }
 
-retval = fdt_add_subnode(fdt, offset, basename);
 qemu_free(dupname);
 return retval;
 }
-- 
1.6.0.2




[Qemu-devel] [PATCH 10/28] PPC: E500: Generate IRQ lines for many CPUs

2011-07-23 Thread Alexander Graf
Now that we can generate multiple envs for all our virtual CPUs, we
also need to tell the MPIC that we have multiple CPUs connected and
connect them all to the respective virtual interrupt lines.

Signed-off-by: Alexander Graf 
---
 hw/ppce500_mpc8544ds.c |   17 -
 1 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/hw/ppce500_mpc8544ds.c b/hw/ppce500_mpc8544ds.c
index cefb415..7ce9bc7 100644
--- a/hw/ppce500_mpc8544ds.c
+++ b/hw/ppce500_mpc8544ds.c
@@ -237,7 +237,7 @@ static void mpc8544ds_init(ram_addr_t ram_size,
 target_long initrd_size=0;
 int i=0;
 unsigned int pci_irq_nrs[4] = {1, 2, 3, 4};
-qemu_irq *irqs, *mpic;
+qemu_irq **irqs, *mpic;
 DeviceState *dev;
 struct boot_info *boot_info;
 CPUState *firstenv = NULL;
@@ -247,6 +247,8 @@ static void mpc8544ds_init(ram_addr_t ram_size,
 cpu_model = "e500v2_v30";
 }
 
+irqs = qemu_mallocz(smp_cpus * sizeof(qemu_irq *));
+irqs[0] = qemu_mallocz(smp_cpus * sizeof(qemu_irq) * OPENPIC_OUTPUT_NB);
 for (i = 0; i < smp_cpus; i++) {
 qemu_irq *input;
 env = cpu_ppc_init(cpu_model);
@@ -259,6 +261,10 @@ static void mpc8544ds_init(ram_addr_t ram_size,
 firstenv = env;
 }
 
+irqs[i] = irqs[0] + (i * OPENPIC_OUTPUT_NB);
+input = (qemu_irq *)env->irq_inputs;
+irqs[i][OPENPIC_OUTPUT_INT] = input[PPCE500_INPUT_INT];
+irqs[i][OPENPIC_OUTPUT_CINT] = input[PPCE500_INPUT_CINT];
 env->spr[SPR_BOOKE_PIR] = env->cpu_index = i;
 
 /* XXX register timer? */
@@ -283,10 +289,11 @@ static void mpc8544ds_init(ram_addr_t ram_size,
  "mpc8544ds.ram", ram_size));
 
 /* MPIC */
-irqs = qemu_mallocz(sizeof(qemu_irq) * OPENPIC_OUTPUT_NB);
-irqs[OPENPIC_OUTPUT_INT] = ((qemu_irq 
*)env->irq_inputs)[PPCE500_INPUT_INT];
-irqs[OPENPIC_OUTPUT_CINT] = ((qemu_irq 
*)env->irq_inputs)[PPCE500_INPUT_CINT];
-mpic = mpic_init(MPC8544_MPIC_REGS_BASE, 1, &irqs, NULL);
+mpic = mpic_init(MPC8544_MPIC_REGS_BASE, smp_cpus, irqs, NULL);
+
+if (!mpic) {
+cpu_abort(env, "MPIC failed to initialize\n");
+}
 
 /* Serial */
 if (serial_hds[0]) {
-- 
1.6.0.2




[Qemu-devel] [PATCH 23/28] device tree: add add_subnode command

2011-07-23 Thread Alexander Graf
We want to be able to create subnodes in our device tree, so export it through
the qemu device tree abstraction framework.

Signed-off-by: Alexander Graf 
---
 device_tree.c |   24 
 device_tree.h |1 +
 2 files changed, 25 insertions(+), 0 deletions(-)

diff --git a/device_tree.c b/device_tree.c
index ec79dba..e58d522 100644
--- a/device_tree.c
+++ b/device_tree.c
@@ -118,3 +118,27 @@ int qemu_devtree_nop_node(void *fdt, const char *node_path)
 
 return fdt_nop_node(fdt, offset);
 }
+
+int qemu_devtree_add_subnode(void *fdt, const char *name)
+{
+int offset;
+char *dupname = qemu_strdup(name);
+char *basename = strrchr(dupname, '/');
+int retval;
+
+if (!basename) {
+return -1;
+}
+
+basename[0] = '\0';
+basename++;
+
+offset = fdt_path_offset(fdt, dupname);
+if (offset < 0) {
+return offset;
+}
+
+retval = fdt_add_subnode(fdt, offset, basename);
+qemu_free(dupname);
+return retval;
+}
diff --git a/device_tree.h b/device_tree.h
index 76fce5f..4378685 100644
--- a/device_tree.h
+++ b/device_tree.h
@@ -23,5 +23,6 @@ int qemu_devtree_setprop_cell(void *fdt, const char 
*node_path,
 int qemu_devtree_setprop_string(void *fdt, const char *node_path,
 const char *property, const char *string);
 int qemu_devtree_nop_node(void *fdt, const char *node_path);
+int qemu_devtree_add_subnode(void *fdt, const char *name);
 
 #endif /* __DEVICE_TREE_H__ */
-- 
1.6.0.2




[Qemu-devel] [PATCH 14/28] PPC: E500: Use generic kvm function for freq

2011-07-23 Thread Alexander Graf
Now that we have generic KVM functions to read out the host tb and clock
frequencies, let's use them in the e500 code!

Signed-off-by: Alexander Graf 
---
 hw/ppce500_mpc8544ds.c |   44 +---
 1 files changed, 9 insertions(+), 35 deletions(-)

diff --git a/hw/ppce500_mpc8544ds.c b/hw/ppce500_mpc8544ds.c
index 7ce9bc7..eedd149 100644
--- a/hw/ppce500_mpc8544ds.c
+++ b/hw/ppce500_mpc8544ds.c
@@ -14,8 +14,6 @@
  * (at your option) any later version.
  */
 
-#include 
-
 #include "config.h"
 #include "qemu-common.h"
 #include "net.h"
@@ -96,6 +94,9 @@ static int mpc8544_load_device_tree(CPUState *env,
 int fdt_size;
 void *fdt;
 uint8_t hypercall[16];
+char cpu_name[128] = "/cpus/PowerPC,8544@0";
+uint32_t clock_freq = 4;
+uint32_t tb_freq = 4;
 
 filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, BINARY_DEVICE_TREE_FILE);
 if (!filename) {
@@ -133,32 +134,9 @@ static int mpc8544_load_device_tree(CPUState *env,
 fprintf(stderr, "couldn't set /chosen/bootargs\n");
 
 if (kvm_enabled()) {
-struct dirent *dirp;
-DIR *dp;
-char buf[128];
-
-if ((dp = opendir("/proc/device-tree/cpus/")) == NULL) {
-printf("Can't open directory /proc/device-tree/cpus/\n");
-ret = -1;
-goto out;
-}
-
-buf[0] = '\0';
-while ((dirp = readdir(dp)) != NULL) {
-if (strncmp(dirp->d_name, "PowerPC", 7) == 0) {
-snprintf(buf, 128, "/cpus/%s", dirp->d_name);
-break;
-}
-}
-closedir(dp);
-if (buf[0] == '\0') {
-printf("Unknow host!\n");
-ret = -1;
-goto out;
-}
-
-mpc8544_copy_soc_cell(fdt, buf, "clock-frequency");
-mpc8544_copy_soc_cell(fdt, buf, "timebase-frequency");
+/* Read out host's frequencies */
+clock_freq = kvmppc_get_clockfreq();
+tb_freq = kvmppc_get_tbfreq();
 
 /* indicate KVM hypercall interface */
 qemu_devtree_setprop_string(fdt, "/hypervisor", "compatible",
@@ -166,15 +144,11 @@ static int mpc8544_load_device_tree(CPUState *env,
 kvmppc_get_hypercall(env, hypercall, sizeof(hypercall));
 qemu_devtree_setprop(fdt, "/hypervisor", "hcall-instructions",
  hypercall, sizeof(hypercall));
-} else {
-const uint32_t freq = 4;
-
-qemu_devtree_setprop_cell(fdt, "/cpus/PowerPC,8544@0",
-  "clock-frequency", freq);
-qemu_devtree_setprop_cell(fdt, "/cpus/PowerPC,8544@0",
-  "timebase-frequency", freq);
 }
 
+qemu_devtree_setprop_cell(fdt, cpu_name, "clock-frequency", clock_freq);
+qemu_devtree_setprop_cell(fdt, cpu_name, "timebase-frequency", tb_freq);
+
 ret = rom_add_blob_fixed(BINARY_DEVICE_TREE_FILE, fdt, fdt_size, addr);
 qemu_free(fdt);
 
-- 
1.6.0.2




[Qemu-devel] [PATCH 28/28] PPC: E500: Bump CPU count to 15

2011-07-23 Thread Alexander Graf
Now that we have everything in place, make the machine description
aware of the fact that we can now handle 15 virtual CPUs!

Signed-off-by: Alexander Graf 

---

v1 -> v2:

  - Max cpus is 15 because of MPIC
---
 hw/ppce500_mpc8544ds.c |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/hw/ppce500_mpc8544ds.c b/hw/ppce500_mpc8544ds.c
index 9c82044..f903e53 100644
--- a/hw/ppce500_mpc8544ds.c
+++ b/hw/ppce500_mpc8544ds.c
@@ -396,6 +396,7 @@ static QEMUMachine mpc8544ds_machine = {
 .name = "mpc8544ds",
 .desc = "mpc8544ds",
 .init = mpc8544ds_init,
+.max_cpus = 15,
 };
 
 static void mpc8544ds_machine_init(void)
-- 
1.6.0.2




[Qemu-devel] [PATCH 06/28] PPC: MPIC: Remove read functionality for WO registers

2011-07-23 Thread Alexander Graf
The IPI dispatch registers are write only according to every MPIC
spec I have found. So instead of pretending you could read back something
from them, better not handle them at all.

Reported-by: Elie Richa 
Signed-off-by: Alexander Graf 
---
 hw/openpic.c |7 ---
 1 files changed, 0 insertions(+), 7 deletions(-)

diff --git a/hw/openpic.c b/hw/openpic.c
index 1f7753d..3f50421 100644
--- a/hw/openpic.c
+++ b/hw/openpic.c
@@ -952,13 +952,6 @@ static uint32_t openpic_cpu_read_internal(void *opaque, 
target_phys_addr_t addr,
 case 0xB0: /* PEOI */
 retval = 0;
 break;
-#if MAX_IPI > 0
-case 0x40: /* IDE */
-case 0x50:
-idx = (addr - 0x40) >> 4;
-retval = read_IRQreg(opp, opp->irq_ipi0 + idx, IRQ_IDE);
-break;
-#endif
 default:
 break;
 }
-- 
1.6.0.2




[Qemu-devel] [PATCH 19/28] PPC: E500: Update freqs for all CPUs

2011-07-23 Thread Alexander Graf
Now that we can so nicely find out the host's frequencies, we should also
make sure that we get them into all virtual CPUs' device tree nodes.

Signed-off-by: Alexander Graf 
---
 hw/ppce500_mpc8544ds.c |   10 +++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/hw/ppce500_mpc8544ds.c b/hw/ppce500_mpc8544ds.c
index 8a51ac7..e99065c 100644
--- a/hw/ppce500_mpc8544ds.c
+++ b/hw/ppce500_mpc8544ds.c
@@ -70,9 +70,9 @@ static int mpc8544_load_device_tree(CPUState *env,
 int fdt_size;
 void *fdt;
 uint8_t hypercall[16];
-char cpu_name[128] = "/cpus/PowerPC,8544@0";
 uint32_t clock_freq = 4;
 uint32_t tb_freq = 4;
+int i;
 
 filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, BINARY_DEVICE_TREE_FILE);
 if (!filename) {
@@ -122,8 +122,12 @@ static int mpc8544_load_device_tree(CPUState *env,
  hypercall, sizeof(hypercall));
 }
 
-qemu_devtree_setprop_cell(fdt, cpu_name, "clock-frequency", clock_freq);
-qemu_devtree_setprop_cell(fdt, cpu_name, "timebase-frequency", tb_freq);
+for (i = 0; i < smp_cpus; i++) {
+char cpu_name[128];
+snprintf(cpu_name, sizeof(cpu_name), "/cpus/PowerPC,8544@%x", i);
+qemu_devtree_setprop_cell(fdt, cpu_name, "clock-frequency", 
clock_freq);
+qemu_devtree_setprop_cell(fdt, cpu_name, "timebase-frequency", 
tb_freq);
+}
 
 ret = rom_add_blob_fixed(BINARY_DEVICE_TREE_FILE, fdt, fdt_size, addr);
 qemu_free(fdt);
-- 
1.6.0.2




[Qemu-devel] [PATCH 01/28] PPC: Move openpic to target specific code compilation

2011-07-23 Thread Alexander Graf
The MPIC has some funny feature where it maps different registers to an MMIO
region depending which CPU accesses them.

To be able to reflect that, we need to make OpenPIC be compiled in the target
code, so it can access cpu_single_env.

Signed-off-by: Alexander Graf 
---
 Makefile.objs   |1 -
 Makefile.target |2 ++
 2 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/Makefile.objs b/Makefile.objs
index 6991a9f..36919f8 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -208,7 +208,6 @@ hw-obj-$(CONFIG_SMARTCARD_NSS) += ccid-card-emulated.o
 hw-obj-$(CONFIG_USB_REDIR) += usb-redir.o
 
 # PPC devices
-hw-obj-$(CONFIG_OPENPIC) += openpic.o
 hw-obj-$(CONFIG_PREP_PCI) += prep_pci.o
 # Mac shared devices
 hw-obj-$(CONFIG_MACIO) += macio.o
diff --git a/Makefile.target b/Makefile.target
index cde509b..19f6101 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -256,6 +256,8 @@ obj-ppc-y += ppce500_mpc8544ds.o mpc8544_guts.o
 obj-ppc-y += virtex_ml507.o
 obj-ppc-$(CONFIG_KVM) += kvm_ppc.o
 obj-ppc-$(CONFIG_FDT) += device_tree.o
+# PowerPC OpenPIC
+obj-ppc-y += openpic.o
 
 # Xilinx PPC peripherals
 obj-ppc-y += xilinx_intc.o
-- 
1.6.0.2




[Qemu-devel] [PATCH 26/28] MPC8544DS: Remove CPU nodes

2011-07-23 Thread Alexander Graf
We want to generate the CPU nodes in machine init code, so remove them from
the device tree definition that we precompile.

Signed-off-by: Alexander Graf 
---
 pc-bios/mpc8544ds.dtb |  Bin 2277 -> 2028 bytes
 pc-bios/mpc8544ds.dts |   12 
 2 files changed, 0 insertions(+), 12 deletions(-)

diff --git a/pc-bios/mpc8544ds.dtb b/pc-bios/mpc8544ds.dtb
index 
ae318b1fe83846cc2e133951a3666fcfcdf87f79..c6d302153c7407d5d0127be29b0c35f80e47f8fb
 100644
GIT binary patch
delta 424
zcmaDV_=aEO0`I@K3=HgV7#J8V7#P?t0BH>%76f7eAO-?P8KC%#jT*{~lRq;qVGNu+
zgGpO80wTx2Se#mvnV92XVrpOj5@H5o79dUoaVFO=n@yHu7E~<+@qhp%%K^lVK&%DC
zOh63N(K9)OS(!0yas{(Dk?LOn)z6*G!y?7RuxYXeOPCPDVW4@8NM@d#Jb@*NiQ(ep
zFD&Xnqh(mFTTP3F~Xi9v};53e2?3j(nK5CZ{YE>PTIqlPkLJ!3$Ad1_IB
zvyO$SiHU;&Seh9~vH-DTazQCb0LJ$Paex5E4+OFmkod`He4yqApb%Vr6B@stfk6!<
z4_B}V%tP=uK>19QJs6iW9+>=rQJZnmWEm!T#^aN1n7mbC@*oFs0P!Ut)&gQCAci^e
z?&LL0%0TrOh*s~wtStKu$plcqfdJG*M&`*4%wa-|B0wQVBw?w^FPM{<7?mdbu&4v=
zD`Bx>Vl;
#size-cells = <0>;
-
-   PowerPC,8544@0 {
-   device_type = "cpu";
-   reg = <0x0>;
-   d-cache-line-size = <32>;   // 32 bytes
-   i-cache-line-size = <32>;   // 32 bytes
-   d-cache-size = <0x8000>;// L1, 32K
-   i-cache-size = <0x8000>;// L1, 32K
-   timebase-frequency = <0>;
-   bus-frequency = <0>;
-   clock-frequency = <0>;
-   };
};
 
memory {
-- 
1.6.0.2




[Qemu-devel] [PATCH 08/28] PPC: Bump MPIC up to 32 supported CPUs

2011-07-23 Thread Alexander Graf
The MPIC emulation is now capable of handling up to 32 CPUs. Reflect that in
the code exporting the numbers out and fix an integer overflow while at it.

Signed-off-by: Alexander Graf 

---

v1 -> v2:

  - Max cpus is 15 due to cINT routing
  - Report nb_cpus not MAX_CPUS in MPIC capabilities
---
 hw/openpic.c |   10 +++---
 1 files changed, 3 insertions(+), 7 deletions(-)

diff --git a/hw/openpic.c b/hw/openpic.c
index af07e13..aa8446c 100644
--- a/hw/openpic.c
+++ b/hw/openpic.c
@@ -63,7 +63,7 @@
 
 #elif defined(USE_MPCxxx)
 
-#define MAX_CPU 2
+#define MAX_CPU15
 #define MAX_IRQ   128
 #define MAX_DBL 0
 #define MAX_MBX 0
@@ -507,7 +507,7 @@ static inline void write_IRQreg (openpic_t *opp, int n_IRQ,
 break;
 case IRQ_IDE:
 tmp = val & 0xC000;
-tmp |= val & ((1 << MAX_CPU) - 1);
+tmp |= val & ((1ULL << MAX_CPU) - 1);
 opp->src[n_IRQ].ide = tmp;
 DPRINTF("Set IDE %d to 0x%08x\n", n_IRQ, opp->src[n_IRQ].ide);
 break;
@@ -1288,7 +1288,7 @@ static void mpic_reset (void *opaque)
 
 mpp->glbc = 0x8000;
 /* Initialise controller registers */
-mpp->frep = 0x004f0002;
+mpp->frep = 0x004f0002 | ((mpp->nb_cpus - 1) << 8);
 mpp->veni = VENI;
 mpp->pint = 0x;
 mpp->spve = 0x;
@@ -1689,10 +1689,6 @@ qemu_irq *mpic_init (target_phys_addr_t base, int 
nb_cpus,
 {mpic_cpu_read, mpic_cpu_write, MPIC_CPU_REG_START, MPIC_CPU_REG_SIZE},
 };
 
-/* XXX: for now, only one CPU is supported */
-if (nb_cpus != 1)
-return NULL;
-
 mpp = qemu_mallocz(sizeof(openpic_t));
 
 for (i = 0; i < sizeof(list)/sizeof(list[0]); i++) {
-- 
1.6.0.2




[Qemu-devel] [PATCH 12/28] PPC: bamboo: Move host fdt copy to target

2011-07-23 Thread Alexander Graf
We have some code in generic kvm_ppc.c that is only used by 440. Move to
the 440 specific device code.

Signed-off-by: Alexander Graf 
---
 hw/ppc440_bamboo.c   |   37 +++--
 target-ppc/kvm_ppc.c |   30 --
 target-ppc/kvm_ppc.h |1 -
 3 files changed, 35 insertions(+), 33 deletions(-)

diff --git a/hw/ppc440_bamboo.c b/hw/ppc440_bamboo.c
index 20b8629..a059f6b 100644
--- a/hw/ppc440_bamboo.c
+++ b/hw/ppc440_bamboo.c
@@ -31,6 +31,38 @@
 #define FDT_ADDR 0x180
 #define RAMDISK_ADDR 0x190
 
+#ifdef CONFIG_FDT
+static int bamboo_copy_host_cell(void *fdt, const char *node, const char *prop)
+{
+uint32_t cell;
+int ret;
+
+ret = kvmppc_read_host_property(node, prop, &cell, sizeof(cell));
+if (ret < 0) {
+fprintf(stderr, "couldn't read host %s/%s\n", node, prop);
+goto out;
+}
+
+ret = qemu_devtree_setprop_cell(fdt, node, prop, cell);
+if (ret < 0) {
+fprintf(stderr, "couldn't set guest %s/%s\n", node, prop);
+goto out;
+}
+
+out:
+return ret;
+}
+
+static void bamboo_fdt_update(void *fdt)
+{
+/* Copy data from the host device tree into the guest. Since the guest can
+ * directly access the timebase without host involvement, we must expose
+ * the correct frequencies. */
+bamboo_copy_host_cell(fdt, "/cpus/cpu@0", "clock-frequency");
+bamboo_copy_host_cell(fdt, "/cpus/cpu@0", "timebase-frequency");
+}
+#endif
+
 static int bamboo_load_device_tree(target_phys_addr_t addr,
  uint32_t ramsize,
  target_phys_addr_t initrd_base,
@@ -76,8 +108,9 @@ static int bamboo_load_device_tree(target_phys_addr_t addr,
 if (ret < 0)
 fprintf(stderr, "couldn't set /chosen/bootargs\n");
 
-if (kvm_enabled())
-kvmppc_fdt_update(fdt);
+if (kvm_enabled()) {
+bamboo_fdt_update(fdt);
+}
 
 ret = rom_add_blob_fixed(BINARY_DEVICE_TREE_FILE, fdt, fdt_size, addr);
 qemu_free(fdt);
diff --git a/target-ppc/kvm_ppc.c b/target-ppc/kvm_ppc.c
index 536fcab..7cc522a 100644
--- a/target-ppc/kvm_ppc.c
+++ b/target-ppc/kvm_ppc.c
@@ -54,36 +54,6 @@ free:
 free(path);
 return ret;
 }
-
-static int kvmppc_copy_host_cell(void *fdt, const char *node, const char *prop)
-{
-uint32_t cell;
-int ret;
-
-ret = kvmppc_read_host_property(node, prop, &cell, sizeof(cell));
-if (ret < 0) {
-fprintf(stderr, "couldn't read host %s/%s\n", node, prop);
-goto out;
-}
-
-ret = qemu_devtree_setprop_cell(fdt, node, prop, cell);
-if (ret < 0) {
-fprintf(stderr, "couldn't set guest %s/%s\n", node, prop);
-goto out;
-}
-
-out:
-return ret;
-}
-
-void kvmppc_fdt_update(void *fdt)
-{
-/* Copy data from the host device tree into the guest. Since the guest can
- * directly access the timebase without host involvement, we must expose
- * the correct frequencies. */
-kvmppc_copy_host_cell(fdt, "/cpus/cpu@0", "clock-frequency");
-kvmppc_copy_host_cell(fdt, "/cpus/cpu@0", "timebase-frequency");
-}
 #endif
 
 static void kvmppc_timer_hack(void *opaque)
diff --git a/target-ppc/kvm_ppc.h b/target-ppc/kvm_ppc.h
index 45a1373..2f32249 100644
--- a/target-ppc/kvm_ppc.h
+++ b/target-ppc/kvm_ppc.h
@@ -10,7 +10,6 @@
 #define __KVM_PPC_H__
 
 void kvmppc_init(void);
-void kvmppc_fdt_update(void *fdt);
 #ifndef CONFIG_KVM
 static inline int kvmppc_read_host_property(const char *node_path, const char 
*prop,
 void *val, size_t len)
-- 
1.6.0.2




[Qemu-devel] [PATCH 04/28] PPC: Fix IPI support in MPIC

2011-07-23 Thread Alexander Graf
The current IPI support in the MPIC code is incomplete and doesn't work. This
code adds proper support for IPIs in MPIC by using the IDE register to remember
which CPUs IPIs are still outstanding to. New triggers through the IPI trigger
register only add to the list of CPUs we want to IPI.

Signed-off-by: Alexander Graf 

---

v1 -> v2:

  - Use MAX_IPI instead of hardcoded 4

Signed-off-by: Alexander Graf 
---
 hw/openpic.c |   17 +++--
 1 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/hw/openpic.c b/hw/openpic.c
index ad45331..9ac3b3d 100644
--- a/hw/openpic.c
+++ b/hw/openpic.c
@@ -57,7 +57,7 @@
 #define MAX_MBX 4
 #define MAX_TMR 4
 #define VECTOR_BITS 8
-#define MAX_IPI 0
+#define MAX_IPI 4
 
 #define VID (0x)
 
@@ -840,7 +840,9 @@ static void openpic_cpu_write_internal(void *opaque, 
target_phys_addr_t addr,
 case 0x60:
 case 0x70:
 idx = (addr - 0x40) >> 4;
-write_IRQreg(opp, opp->irq_ipi0 + idx, IRQ_IDE, val);
+/* we use IDE as mask which CPUs to deliver the IPI to still. */
+write_IRQreg(opp, opp->irq_ipi0 + idx, IRQ_IDE,
+ opp->src[opp->irq_ipi0 + idx].ide | val);
 openpic_set_irq(opp, opp->irq_ipi0 + idx, 1);
 openpic_set_irq(opp, opp->irq_ipi0 + idx, 0);
 break;
@@ -934,6 +936,17 @@ static uint32_t openpic_cpu_read_internal(void *opaque, 
target_phys_addr_t addr,
 reset_bit(&src->ipvp, IPVP_ACTIVITY);
 src->pending = 0;
 }
+
+if ((n_IRQ >= opp->irq_ipi0) &&  (n_IRQ < (opp->irq_ipi0 + 
MAX_IPI))) {
+src->ide &= ~(1 << idx);
+if (src->ide && !test_bit(&src->ipvp, IPVP_SENSE)) {
+/* trigger on CPUs that didn't know about it yet */
+openpic_set_irq(opp, n_IRQ, 1);
+openpic_set_irq(opp, n_IRQ, 0);
+/* if all CPUs knew about it, set active bit again */
+set_bit(&src->ipvp, IPVP_ACTIVITY);
+}
+}
 }
 break;
 case 0xB0: /* PEOI */
-- 
1.6.0.2




  1   2   >