[Qemu-devel] Re: [FOR 0.12 PATCH] qdev: Replace device names containing whitespace

2009-12-09 Thread Markus Armbruster
Gerd Hoffmann  writes:

>> diff --git a/hw/usb-msd.c b/hw/usb-msd.c
>> index bb39b62..dec35bc 100644
>> --- a/hw/usb-msd.c
>> +++ b/hw/usb-msd.c
>> @@ -591,7 +591,7 @@ static USBDevice *usb_msd_init(const char *filename)
>>   }
>>
>>   /* create guest device */
>> -dev = usb_create(NULL /* FIXME */, "QEMU USB MSD");
>> +dev = usb_create(NULL /* FIXME */, "usb-storage");
>>   qdev_prop_set_drive(&dev->qdev, "drive", dinfo);
>>   if (qdev_init(&dev->qdev)<  0)
>>   return NULL;
>> @@ -600,8 +600,7 @@ static USBDevice *usb_msd_init(const char *filename)
>>   }
>>
>>   static struct USBDeviceInfo msd_info = {
>> -.qdev.name  = "QEMU USB MSD",
>> -.qdev.alias = "usb-storage",
>> +.qdev.name  = "usb-storage",
>>   .qdev.size  = sizeof(MSDState),
>>   .init   = usb_msd_initfn,
>>   .handle_packet  = usb_generic_handle_packet,
>
> No.  USB needs some more care.  DeviceInfo->name is also used as
> default value for USBDevice->devname.  See usb_qdev_init().   Most usb
> backends don't change it.  So this change is visible in both 'info
> usb' monitor command and within the guest (check
> /proc/bus/usb/devices).
>
> I'd suggest to add a new field to USBDeviceInfo, stick the long name
> there and use that in usb_qdev_init() then.

I missed that needle in the "grep -w name" haystack.

> Otherwise the patch looks fine to me.

Will fix.  Thanks!




Re: [Qemu-devel] [FOR 0.12 PATCH] qdev: Replace device names containing whitespace

2009-12-09 Thread Ian Molton
Markus Armbruster wrote:

> The place for verbose device names is DeviceInfo member desc.  The
> name should be short & sweet.

Agreed, however...

Why do these (maybe others) get caps in their names? they dont look
right to me, compared to the others with nice names like usb-serial,
piix-ide, or cirrus-vga.

> -sysbus_register_dev("Uni-north main", sizeof(UNINState),
> +sysbus_register_dev("Uni-north-main", sizeof(UNINState),
>  pci_unin_main_init_device);
>  pci_qdev_register(&unin_main_pci_host_info);
> -sysbus_register_dev("DEC 21154", sizeof(UNINState),
> +sysbus_register_dev("DEC-21154", sizeof(UNINState),
>  pci_dec_21154_init_device);
>  pci_qdev_register(&dec_21154_pci_host_info);
> -sysbus_register_dev("Uni-north AGP", sizeof(UNINState),
> +sysbus_register_dev("Uni-north-AGP", sizeof(UNINState),
>  pci_unin_agp_init_device);
>  pci_qdev_register(&unin_agp_pci_host_info);
> -sysbus_register_dev("Uni-north internal", sizeof(UNINState),
> +sysbus_register_dev("Uni-north-internal", sizeof(UNINState),
>  pci_unin_internal_init_device);
>  pci_qdev_register(&unin_internal_pci_host_info);
>  }

-Ian




Re: [Qemu-devel] [FOR 0.12 PATCH] qdev: Replace device names containing whitespace

2009-12-09 Thread Markus Armbruster
Ian Molton  writes:

> Markus Armbruster wrote:
>
>> The place for verbose device names is DeviceInfo member desc.  The
>> name should be short & sweet.
>
> Agreed, however...
>
> Why do these (maybe others) get caps in their names? they dont look
> right to me, compared to the others with nice names like usb-serial,
> piix-ide, or cirrus-vga.
>
>> -sysbus_register_dev("Uni-north main", sizeof(UNINState),
>> +sysbus_register_dev("Uni-north-main", sizeof(UNINState),
>>  pci_unin_main_init_device);
>>  pci_qdev_register(&unin_main_pci_host_info);
>> -sysbus_register_dev("DEC 21154", sizeof(UNINState),
>> +sysbus_register_dev("DEC-21154", sizeof(UNINState),
>>  pci_dec_21154_init_device);
>>  pci_qdev_register(&dec_21154_pci_host_info);
>> -sysbus_register_dev("Uni-north AGP", sizeof(UNINState),
>> +sysbus_register_dev("Uni-north-AGP", sizeof(UNINState),
>>  pci_unin_agp_init_device);
>>  pci_qdev_register(&unin_agp_pci_host_info);
>> -sysbus_register_dev("Uni-north internal", sizeof(UNINState),
>> +sysbus_register_dev("Uni-north-internal", sizeof(UNINState),
>>  pci_unin_internal_init_device);
>>  pci_qdev_register(&unin_internal_pci_host_info);
>>  }

I can downcase them.  Blue Swirl, any objections?




Re: [Qemu-devel] [ANNOUNCE][Call-For-Testing] Release 0.12.0-rc1 of QEMU

2009-12-09 Thread Daniel P. Berrange
On Tue, Dec 08, 2009 at 02:07:29PM +0100, Gerd Hoffmann wrote:
> On 12/08/09 13:52, Gerd Hoffmann wrote:
> >>The latter. The guest does not see it, but it at least does not abort.
> >>It is the 'does not abort' behaviour I'm interested in - quite OK with
> >>this returning an error to the monitor client when acpi is disabled.
> >
> >Does the attached patch fix it for you?
> 
> One more fix for the "hw_error() when slots full" case.

Yes, the combination of those two patches fix both problems


(qemu) pci_add pci_addr=auto storage file=/home/berrange/mcdboot.img,if=virtio
PCI bus doesn't support hotplug
failed to add file=/home/berrange/mcdboot.img,if=virtio


(qemu) pci_add pci_addr=auto storage file=/home/berrange/mcdboot.img,if=virtio
PCI: no devfn available for virtio-blk-pci, all in use
failed to add file=/home/berrange/mcdboot.img,if=virtio

Regards,
Daniel
-- 
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|




Re: [Qemu-devel] [ANNOUNCE][Call-For-Testing] Release 0.12.0-rc1 of QEMU

2009-12-09 Thread Ian Molton
Anthony Liguori wrote:
> The QEMU team is pleased to announce the availability of the 0.12.0-rc1
> release.  This is the first release candidate for the 0.12.0 release.
> This release is not intended for production use.

What git tree should I rebase my patches onto (for the next release) ?

Thanks,

-Ian





Re: [Qemu-devel] [PATCH, try 2] qemu/tap: add -net tap,dev= option

2009-12-09 Thread Mark McLoughlin
On Tue, 2009-12-08 at 18:41 +0100, Arnd Bergmann wrote:
> In order to support macvtap, we need a way to select the actual
> tap endpoint. While it would be nice to pass it by network interface
> name, passing the character device is more flexible, and we can
> easily do both in the long run.
> 
> Signed-off-by: Arnd Bergmann 

Looks fine to me

Acked-by: Mark McLoughlin 

Cheers,
Mark.





[Qemu-devel] [PATCH] Let mouse_button monitor command accept coordinates

2009-12-09 Thread Soren Hansen
The mouse_button monitor command currently results in a call like this:

 kbd_mouse_event(0, 0, 0, mouse_button_status);

For a pointer in relative mode, this means a button gets pressed (or
or released) and nothing else. However, if the pointer currently being
controlled is in absolute mode (such as -usbtablet), it means that the
pointer will warp to (0, 0), effectively limiting clicking to the top
left corner of the desktop in the guest.

To work around this, I propose (thanks to Daniel Berrange for the
suggestion) to let the mouse_button monitor command optionally accept
coordinates.

Signed-off-by: Soren Hansen 
---
 monitor.c   |   16 +++-
 qemu-monitor.hx |6 +++---
 2 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/monitor.c b/monitor.c
index e161f7d..8b879cc 100644
--- a/monitor.c
+++ b/monitor.c
@@ -1336,8 +1336,22 @@ static void do_mouse_move(Monitor *mon, const QDict 
*qdict)
 static void do_mouse_button(Monitor *mon, const QDict *qdict)
 {
 int button_state = qdict_get_int(qdict, "button_state");
+int dx, dy, dz;
+const char *dx_str = qdict_get_try_str(qdict, "dx_str");
+const char *dy_str = qdict_get_try_str(qdict, "dy_str");
+const char *dz_str = qdict_get_try_str(qdict, "dz_str");
+
+dx = dy = dz = 0;
+
+if (dx_str && dy_str) {
+dx = strtol(dx_str, NULL, 0);
+dy = strtol(dy_str, NULL, 0);
+if (dz_str)
+dz = strtol(dz_str, NULL, 0);
+}
+
 mouse_button_state = button_state;
-kbd_mouse_event(0, 0, 0, mouse_button_state);
+kbd_mouse_event(dx, dy, dz, mouse_button_state);
 }
 
 static void do_ioport_read(Monitor *mon, const QDict *qdict)
diff --git a/qemu-monitor.hx b/qemu-monitor.hx
index 2b14802..b42b461 100644
--- a/qemu-monitor.hx
+++ b/qemu-monitor.hx
@@ -595,9 +595,9 @@ ETEXI
 
 {
 .name   = "mouse_button",
-.args_type  = "button_state:i",
-.params = "state",
-.help   = "change mouse button state (1=L, 2=M, 4=R)",
+.args_type  = "button_state:i,dx_str:s?,dy_str:s?,dz_str:s?",
+.params = "state [dx dy [dz]]",
+.help   = "change mouse button state (1=L, 2=M, 4=R), optionally 
specifying coordinates as well (useful for pointers in absolute mode)",
 .mhandler.cmd = do_mouse_button,
 },
 
-- 
1.6.5

-- 
Soren Hansen | 
Lead virtualisation engineer | Ubuntu Server Team
Canonical Ltd.   | http://www.ubuntu.com/


signature.asc
Description: Digital signature


[Qemu-devel] Re: [PATCH, try 2] qemu/tap: add -net tap,dev= option

2009-12-09 Thread Michael S. Tsirkin
On Tue, Dec 08, 2009 at 06:41:44PM +0100, Arnd Bergmann wrote:
> In order to support macvtap, we need a way to select the actual
> tap endpoint. While it would be nice to pass it by network interface
> name, passing the character device is more flexible, and we can
> easily do both in the long run.
> 
> Signed-off-by: Arnd Bergmann 
> ---
> diff --git a/net.c b/net.c
> index 13bdbb2..deb12fd 100644
> --- a/net.c
> +++ b/net.c
> @@ -955,6 +955,11 @@ static struct {
>  },
>  #ifndef _WIN32
>  {
> +.name = "dev",
> +.type = QEMU_OPT_STRING,
> +.help = "character device pathname",
> +},
> +{
>  .name = "fd",
>  .type = QEMU_OPT_STRING,
>  .help = "file descriptor of an already opened tap",
> diff --git a/net/tap-aix.c b/net/tap-aix.c
> index 4bc9f2f..b789d06 100644
> --- a/net/tap-aix.c
> +++ b/net/tap-aix.c
> @@ -25,7 +25,8 @@
>  #include "net/tap.h"
>  #include 
>  
> -int tap_open(char *ifname, int ifname_size, int *vnet_hdr, int 
> vnet_hdr_required)
> +int tap_open(char *ifname, int ifname_size, char *dev, int dev_size,
> + int *vnet_hdr, int vnet_hdr_required)
>  {
>  fprintf(stderr, "no tap on AIX\n");
>  return -1;
> diff --git a/net/tap-bsd.c b/net/tap-bsd.c
> index 815997d..09a7780 100644
> --- a/net/tap-bsd.c
> +++ b/net/tap-bsd.c
> @@ -40,7 +40,8 @@
>  #include 
>  #endif
>  
> -int tap_open(char *ifname, int ifname_size, int *vnet_hdr, int 
> vnet_hdr_required)
> +int tap_open(char *ifname, int ifname_size, char *dev, int dev_size,
> + int *vnet_hdr, int vnet_hdr_required)
>  {
>  int fd;
>  char *dev;

Does this compile?

> diff --git a/net/tap-linux.c b/net/tap-linux.c
> index 6af9e82..a6df123 100644
> --- a/net/tap-linux.c
> +++ b/net/tap-linux.c
> @@ -32,14 +32,21 @@
>  #include "sysemu.h"
>  #include "qemu-common.h"
>  
> -int tap_open(char *ifname, int ifname_size, int *vnet_hdr, int 
> vnet_hdr_required)
> +int tap_open(char *ifname, int ifname_size, char *dev, int dev_size,

dev is never modified, so it should be const char *.

> + int *vnet_hdr, int vnet_hdr_required)
>  {
>  struct ifreq ifr;
>  int fd, ret;
> +const char *path;
>  
> -TFR(fd = open("/dev/net/tun", O_RDWR));
> +if (dev[0] == '\0')

== 0 checks are ugly. if (*dev) is shorter, and it's a standard C
idiom to detect non-empty string. Or better pass NULL if no device,
then you can just path = dev ? dev : "/dev/net/tun".

> + path = "/dev/net/tun";
> +else
> + path = dev;

Please do not indent by single space.

> +
> +TFR(fd = open(dev, O_RDWR));
>  if (fd < 0) {
> -fprintf(stderr, "warning: could not open /dev/net/tun: no virtual 
> network emulation\n");
> +fprintf(stderr, "warning: could not open %s: no virtual network 
> emulation\n", path);
>  return -1;
>  }
>  memset(&ifr, 0, sizeof(ifr));
> @@ -70,7 +77,7 @@ int tap_open(char *ifname, int ifname_size, int *vnet_hdr, 
> int vnet_hdr_required
>  pstrcpy(ifr.ifr_name, IFNAMSIZ, "tap%d");
>  ret = ioctl(fd, TUNSETIFF, (void *) &ifr);
>  if (ret != 0) {
> -fprintf(stderr, "warning: could not configure /dev/net/tun: no 
> virtual network emulation\n");
> +fprintf(stderr, "warning: could not configure %s: no virtual network 
> emulation\n", path);
>  close(fd);
>  return -1;
>  }
> diff --git a/net/tap-solaris.c b/net/tap-solaris.c
> index e14fe36..72abb78 100644
> --- a/net/tap-solaris.c
> +++ b/net/tap-solaris.c
> @@ -171,7 +171,8 @@ static int tap_alloc(char *dev, size_t dev_size)
>  return tap_fd;
>  }
>  
> -int tap_open(char *ifname, int ifname_size, int *vnet_hdr, int 
> vnet_hdr_required)
> +int tap_open(char *ifname, int ifname_size, char *dev, int dev_size,
> + int *vnet_hdr, int vnet_hdr_required)
>  {
>  char  dev[10]="";
>  int fd;

Does this compile?

> diff --git a/net/tap.c b/net/tap.c
> index 0d8b424..14ddf65 100644
> --- a/net/tap.c
> +++ b/net/tap.c
> @@ -343,12 +343,17 @@ static int net_tap_init(QemuOpts *opts, int *vnet_hdr)
>  {
>  int fd, vnet_hdr_required;
>  char ifname[128] = {0,};
> +char dev[128] = {0,};
>  const char *setup_script;
>  
>  if (qemu_opt_get(opts, "ifname")) {
>  pstrcpy(ifname, sizeof(ifname), qemu_opt_get(opts, "ifname"));
>  }
>  
> +if (qemu_opt_get(opts, "dev")) {
> +pstrcpy(dev, sizeof(dev), qemu_opt_get(opts, "dev"));
> +}
> +

While in this case this is unlikely to be a problem in practice, we still
should not add arbitrary limitations on file name lengths.  Just teach
tap_open to get NULL instead of and empty string, or better supply
default /dev/net/tun to the option, and you will not need the strcpy.


>  *vnet_hdr = qemu_opt_get_bool(opts, "vnet_hdr", 1);
>  if (qemu_opt_get(opts, "vnet_hdr")) {
> 

[Qemu-devel] Re: irq latency and tcg

2009-12-09 Thread Artyom Tarasenko
2009/12/7 Blue Swirl :
> On Mon, Dec 7, 2009 at 3:30 PM, Artyom Tarasenko
>  wrote:
>> Can it be that qemu (-system-sparc in my case, but I guess it's more
>> or less similar on all platforms) reacts to irqs slower than a real
>> hardware due to tcg optimizations?
>>
>> I see one test pattern which fails on qemu:
>>
>> 
>> nop * N
>> 
>>
>> What I observe is that the proper interrupt does take a place, but
>> after the check, so no-one expects it anymore.
>> Is there a way to reduce the interrupt latency? Or maybe there is a
>> good substitute to a nop*N, so that irq would definitely get through
>> in the mean time?
>
> On Sparc, nops do not generate any code at all.

But "qemu: fatal: Raised interrupt while not in I/O function" is still
a bug, right?




[Qemu-devel] Re: [PATCH, try 2] qemu/tap: add -net tap,dev= option

2009-12-09 Thread Arnd Bergmann
On Wednesday 09 December 2009, Michael S. Tsirkin wrote:
> On Tue, Dec 08, 2009 at 06:41:44PM +0100, Arnd Bergmann wrote:
> > --- a/net/tap-bsd.c
> > +++ b/net/tap-bsd.c
> > @@ -40,7 +40,8 @@
> >  #include 
> >  #endif
> >  
> > -int tap_open(char *ifname, int ifname_size, int *vnet_hdr, int 
> > vnet_hdr_required)
> > +int tap_open(char *ifname, int ifname_size, char *dev, int dev_size,
> > +   int *vnet_hdr, int vnet_hdr_required)
> >  {
> >  int fd;
> >  char *dev;
> 
> Does this compile?

I don't have a BSD or Solaris machine here, or even just a cross-compiler, so
I could not test. However, I only add two arguments and I did the identical
change in the header file and the linux version of this file, so I am reasonably
confident.
 
> > -int tap_open(char *ifname, int ifname_size, int *vnet_hdr, int 
> > vnet_hdr_required)
> > +int tap_open(char *ifname, int ifname_size, char *dev, int dev_size,
> 
> dev is never modified, so it should be const char *.

ok.

> > +   int *vnet_hdr, int vnet_hdr_required)
> >  {
> >  struct ifreq ifr;
> >  int fd, ret;
> > +const char *path;
> >  
> > -TFR(fd = open("/dev/net/tun", O_RDWR));
> > +if (dev[0] == '\0')
> 
> == 0 checks are ugly. if (*dev) is shorter, and it's a standard C
> idiom to detect non-empty string. Or better pass NULL if no device,
> then you can just path = dev ? dev : "/dev/net/tun".

Agreed in principle, but I was following the style that is already used
in the same function, and I think consistency is more important in
this case.
 
> > +   path = "/dev/net/tun";
> > +else
> > +   path = dev;
> 
> Please do not indent by single space.

For some reason, this file uses four character indentation, which
I followed for consistency. In the patch this gets mangled when
some lines use only spaces for indentation and others use only
tabs.

I could change to using only spaces for indentation if that's preferred.

> > diff --git a/net/tap.c b/net/tap.c
> > index 0d8b424..14ddf65 100644
> > --- a/net/tap.c
> > +++ b/net/tap.c
> > @@ -343,12 +343,17 @@ static int net_tap_init(QemuOpts *opts, int *vnet_hdr)
> >  {
> >  int fd, vnet_hdr_required;
> >  char ifname[128] = {0,};
> > +char dev[128] = {0,};
> >  const char *setup_script;
> >  
> >  if (qemu_opt_get(opts, "ifname")) {
> >  pstrcpy(ifname, sizeof(ifname), qemu_opt_get(opts, "ifname"));
> >  }
> >  
> > +if (qemu_opt_get(opts, "dev")) {
> > +pstrcpy(dev, sizeof(dev), qemu_opt_get(opts, "dev"));
> > +}
> > +
> 
> While in this case this is unlikely to be a problem in practice, we still
> should not add arbitrary limitations on file name lengths.  Just teach
> tap_open to get NULL instead of and empty string, or better supply
> default /dev/net/tun to the option, and you will not need the strcpy.

Right, I will do that, or alternatively make dev an input/output argument,
see below.

> >  snprintf(s->nc.info_str, sizeof(s->nc.info_str),
> > - "ifname=%s,script=%s,downscript=%s",
> > - ifname, script, downscript);
> > + "ifname=%s,dev=%s,script=%s,downscript=%s",
> 
> This will look strange if dev is not supplied, will it not?
> Also, I wonder whether there might be any scripts parsing
> info string from monitor, that will get broken by the
> extra parameter. How about we only print dev if it
> is not the default?

Right. I originally planned to return "/dev/net/tun" from tap_open
in that case, but I forgot to put that in. It would also not work well
for Solaris and BSD unless I add untested code there.

I guess it would be consistent to do that, but unless someone insists
on it, I'll just follow your advice here and remove it from being printed.

> > +"-net 
> > tap[,vlan=n][,name=str][,fd=h][,ifname=name][,dev=str][,script=file]\n"
> > +"[,downscript=dfile][,sndbuf=nbytes][,vnet_hdr=on|off]\n"
> >  "connect the host TAP network interface to VLAN 'n' 
> > and use the\n"
> >  "network scripts 'file' (default=%s)\n"
> >  "and 'dfile' (default=%s);\n"
> >  "use '[down]script=no' to disable script execution;\n"
> >  "use 'fd=h' to connect to an already opened TAP 
> > interface\n"
> > +"use 'dev=str' to open a specific tap character 
> > device\n"
> 
> please document default /dev/net/tun

ok.

Thanks for the review!

Arnd




Re: [Qemu-devel] Re: [PATCH, try 2] qemu/tap: add -net tap, dev= option

2009-12-09 Thread Christoph Egger
On Wednesday 09 December 2009 13:33:36 Arnd Bergmann wrote:
> On Wednesday 09 December 2009, Michael S. Tsirkin wrote:
> > On Tue, Dec 08, 2009 at 06:41:44PM +0100, Arnd Bergmann wrote:
> > > --- a/net/tap-bsd.c
> > > +++ b/net/tap-bsd.c
> > > @@ -40,7 +40,8 @@
> > >  #include 
> > >  #endif
> > >
> > > -int tap_open(char *ifname, int ifname_size, int *vnet_hdr, int
> > > vnet_hdr_required) +int tap_open(char *ifname, int ifname_size, char
> > > *dev, int dev_size, + int *vnet_hdr, int 
> > > vnet_hdr_required)
> > >  {
> > >  int fd;
> > >  char *dev;
> >
> > Does this compile?
>
> I don't have a BSD or Solaris machine here, or even just a cross-compiler,
> so I could not test.

This sounds like a bad joke on a virtualization list.

You can say you don't have an AMD or Intel machine to test hw feature XY but
saying you don't have a machine running a certain OS is prude as you can
always use qemu itself to get that up and running.

Christoph


-- 
---to satisfy European Law for business letters:
Advanced Micro Devices GmbH
Karl-Hammerschmidt-Str. 34, 85609 Dornach b. Muenchen
Geschaeftsfuehrer: Andrew Bowd, Thomas M. McCoy, Giuliano Meroni
Sitz: Dornach, Gemeinde Aschheim, Landkreis Muenchen
Registergericht Muenchen, HRB Nr. 43632





[Qemu-devel] Re: [PATCH, try 2] qemu/tap: add -net tap,dev= option

2009-12-09 Thread Michael S. Tsirkin
On Wed, Dec 09, 2009 at 01:33:36PM +0100, Arnd Bergmann wrote:
> On Wednesday 09 December 2009, Michael S. Tsirkin wrote:
> > On Tue, Dec 08, 2009 at 06:41:44PM +0100, Arnd Bergmann wrote:
> > > --- a/net/tap-bsd.c
> > > +++ b/net/tap-bsd.c
> > > @@ -40,7 +40,8 @@
> > >  #include 
> > >  #endif
> > >  
> > > -int tap_open(char *ifname, int ifname_size, int *vnet_hdr, int 
> > > vnet_hdr_required)
> > > +int tap_open(char *ifname, int ifname_size, char *dev, int dev_size,
> > > + int *vnet_hdr, int vnet_hdr_required)
> > >  {
> > >  int fd;
> > >  char *dev;
> > 
> > Does this compile?
> 
> I don't have a BSD or Solaris machine here, or even just a cross-compiler, so
> I could not test.

It should be possible to install in a VM if you really want to,
but that's not my point.

> However, I only add two arguments and I did the identical
> change in the header file and the linux version of this file, so I am 
> reasonably
> confident.

'char *dev' variable has the same name as the new parameter, which
is not legal in C99 and normally triggers compiler warning or error.


> > > -int tap_open(char *ifname, int ifname_size, int *vnet_hdr, int 
> > > vnet_hdr_required)
> > > +int tap_open(char *ifname, int ifname_size, char *dev, int dev_size,
> > 
> > dev is never modified, so it should be const char *.
> 
> ok.
> 
> > > + int *vnet_hdr, int vnet_hdr_required)
> > >  {
> > >  struct ifreq ifr;
> > >  int fd, ret;
> > > +const char *path;
> > >  
> > > -TFR(fd = open("/dev/net/tun", O_RDWR));
> > > +if (dev[0] == '\0')
> > 
> > == 0 checks are ugly. if (*dev) is shorter, and it's a standard C
> > idiom to detect non-empty string. Or better pass NULL if no device,
> > then you can just path = dev ? dev : "/dev/net/tun".
> 
> Agreed in principle, but I was following the style that is already used
> in the same function, and I think consistency is more important in
> this case.

qemu code in general is inconsistent. Let's make new code look sane,
over time most of it will get converted.

> > > + path = "/dev/net/tun";
> > > +else
> > > + path = dev;
> > 
> > Please do not indent by single space.
> 
> For some reason, this file uses four character indentation, which
> I followed for consistency. In the patch this gets mangled when
> some lines use only spaces for indentation and others use only
> tabs.
> 
> I could change to using only spaces for indentation if that's preferred.

Coding style says you should use spaces for indentation.

> > > diff --git a/net/tap.c b/net/tap.c
> > > index 0d8b424..14ddf65 100644
> > > --- a/net/tap.c
> > > +++ b/net/tap.c
> > > @@ -343,12 +343,17 @@ static int net_tap_init(QemuOpts *opts, int 
> > > *vnet_hdr)
> > >  {
> > >  int fd, vnet_hdr_required;
> > >  char ifname[128] = {0,};
> > > +char dev[128] = {0,};
> > >  const char *setup_script;
> > >  
> > >  if (qemu_opt_get(opts, "ifname")) {
> > >  pstrcpy(ifname, sizeof(ifname), qemu_opt_get(opts, "ifname"));
> > >  }
> > >  
> > > +if (qemu_opt_get(opts, "dev")) {
> > > +pstrcpy(dev, sizeof(dev), qemu_opt_get(opts, "dev"));
> > > +}
> > > +
> > 
> > While in this case this is unlikely to be a problem in practice, we still
> > should not add arbitrary limitations on file name lengths.  Just teach
> > tap_open to get NULL instead of and empty string, or better supply
> > default /dev/net/tun to the option, and you will not need the strcpy.
> 
> Right, I will do that, or alternatively make dev an input/output argument,
> see below.

input/output will require allocating storage for it,
so it's more work (assuming length of 128 characters is evil).
Not sure it's a good idea.

> > >  snprintf(s->nc.info_str, sizeof(s->nc.info_str),
> > > - "ifname=%s,script=%s,downscript=%s",
> > > - ifname, script, downscript);
> > > + "ifname=%s,dev=%s,script=%s,downscript=%s",
> > 
> > This will look strange if dev is not supplied, will it not?
> > Also, I wonder whether there might be any scripts parsing
> > info string from monitor, that will get broken by the
> > extra parameter. How about we only print dev if it
> > is not the default?
> 
> Right. I originally planned to return "/dev/net/tun" from tap_open
> in that case, but I forgot to put that in. It would also not work well
> for Solaris and BSD unless I add untested code there.

I think it's better to add untested feature than intentionally
skip it. It's easier for people familiar with the platform to
fix a broken feature than to guess what feature needs to be filled in.

If you don't you, should replace ifndef WINDOWS by ifdef LINUX or
something like that.

> I guess it would be consistent to do that, but unless someone insists
> on it, I'll just follow your advice here and remove it from being printed.
> 
> > > +"-net 
> > > tap[,vlan=n][,name=str][,fd=h][,ifname=name][,dev=str][,script=file]\n"
> > > +"[,do

[Qemu-devel] [PATCH, try 2, version 2] qemu/tap: add -net tap, dev= option

2009-12-09 Thread Arnd Bergmann
In order to support macvtap, we need a way to select the actual
tap endpoint. While it would be nice to pass it by network interface
name, passing the character device is more flexible, and we can
easily do both in the long run.

This version makes it possible to use macvtap without introducing
any macvtap specific code in qemu, only a natural extension to
the existing interface.

Signed-off-by: Arnd Bergmann 
Acked-by: Mark McLoughlin 
Cc: "Michael S. Tsirkin" 
---
Hopefully addressed all comments from Michael. I did compile-test
the non-linux files I touched (the solaris file failed to build for another
reason), and this now prevents passing dev= on non-linux machines.

 net.c |5 +
 net/tap-aix.c |3 ++-
 net/tap-bsd.c |9 -
 net/tap-linux.c   |   12 
 net/tap-solaris.c |7 ++-
 net/tap.c |   17 ++---
 net/tap.h |3 ++-
 qemu-options.hx   |   10 +-
 8 files changed, 54 insertions(+), 12 deletions(-)

diff --git a/net.c b/net.c
index 13bdbb2..deb12fd 100644
--- a/net.c
+++ b/net.c
@@ -955,6 +955,11 @@ static struct {
 },
 #ifndef _WIN32
 {
+.name = "dev",
+.type = QEMU_OPT_STRING,
+.help = "character device pathname",
+},
+{
 .name = "fd",
 .type = QEMU_OPT_STRING,
 .help = "file descriptor of an already opened tap",
diff --git a/net/tap-aix.c b/net/tap-aix.c
index 4bc9f2f..238c190 100644
--- a/net/tap-aix.c
+++ b/net/tap-aix.c
@@ -25,7 +25,8 @@
 #include "net/tap.h"
 #include 
 
-int tap_open(char *ifname, int ifname_size, int *vnet_hdr, int 
vnet_hdr_required)
+int tap_open(char *ifname, int ifname_size, const char *dev,
+   int *vnet_hdr, int vnet_hdr_required)
 {
 fprintf(stderr, "no tap on AIX\n");
 return -1;
diff --git a/net/tap-bsd.c b/net/tap-bsd.c
index 815997d..8a7334c 100644
--- a/net/tap-bsd.c
+++ b/net/tap-bsd.c
@@ -40,7 +40,8 @@
 #include 
 #endif
 
-int tap_open(char *ifname, int ifname_size, int *vnet_hdr, int 
vnet_hdr_required)
+int tap_open(char *ifname, int ifname_size, const char *devarg,
+   int *vnet_hdr, int vnet_hdr_required)
 {
 int fd;
 char *dev;
@@ -80,6 +81,12 @@ int tap_open(char *ifname, int ifname_size, int *vnet_hdr, 
int vnet_hdr_required
 }
 #endif
 
+if (devarg) {
+qemu_error("dev= not supported\n");
+close(fd);
+return -1;
+}
+
 fstat(fd, &s);
 dev = devname(s.st_rdev, S_IFCHR);
 pstrcpy(ifname, ifname_size, dev);
diff --git a/net/tap-linux.c b/net/tap-linux.c
index 6af9e82..d6831c0 100644
--- a/net/tap-linux.c
+++ b/net/tap-linux.c
@@ -32,14 +32,18 @@
 #include "sysemu.h"
 #include "qemu-common.h"
 
-int tap_open(char *ifname, int ifname_size, int *vnet_hdr, int 
vnet_hdr_required)
+int tap_open(char *ifname, int ifname_size, const char *dev,
+int *vnet_hdr, int vnet_hdr_required)
 {
 struct ifreq ifr;
 int fd, ret;
 
-TFR(fd = open("/dev/net/tun", O_RDWR));
+if (!*dev)
+dev = "/dev/net/tun";
+
+TFR(fd = open(dev, O_RDWR));
 if (fd < 0) {
-fprintf(stderr, "warning: could not open /dev/net/tun: no virtual 
network emulation\n");
+fprintf(stderr, "warning: could not open %s: no virtual network 
emulation\n", dev);
 return -1;
 }
 memset(&ifr, 0, sizeof(ifr));
@@ -70,7 +74,7 @@ int tap_open(char *ifname, int ifname_size, int *vnet_hdr, 
int vnet_hdr_required
 pstrcpy(ifr.ifr_name, IFNAMSIZ, "tap%d");
 ret = ioctl(fd, TUNSETIFF, (void *) &ifr);
 if (ret != 0) {
-fprintf(stderr, "warning: could not configure /dev/net/tun: no virtual 
network emulation\n");
+fprintf(stderr, "warning: could not configure %s: no virtual network 
emulation\n", dev);
 close(fd);
 return -1;
 }
diff --git a/net/tap-solaris.c b/net/tap-solaris.c
index e14fe36..3d10984 100644
--- a/net/tap-solaris.c
+++ b/net/tap-solaris.c
@@ -171,10 +171,15 @@ static int tap_alloc(char *dev, size_t dev_size)
 return tap_fd;
 }
 
-int tap_open(char *ifname, int ifname_size, int *vnet_hdr, int 
vnet_hdr_required)
+int tap_open(char *ifname, int ifname_size, const char *devarg,
+   int *vnet_hdr, int vnet_hdr_required)
 {
 char  dev[10]="";
 int fd;
+if (devarg) {
+fprintf(stderr, "dev= not supported\n");
+return -1;
+}
 if( (fd = tap_alloc(dev, sizeof(dev))) < 0 ){
fprintf(stderr, "Cannot allocate TAP device\n");
return -1;
diff --git a/net/tap.c b/net/tap.c
index 0d8b424..8635ae2 100644
--- a/net/tap.c
+++ b/net/tap.c
@@ -343,12 +343,15 @@ static int net_tap_init(QemuOpts *opts, int *vnet_hdr)
 {
 int fd, vnet_hdr_required;
 char ifname[128] = {0,};
+const char *dev;
 const char *setup_script;
 
 if (qemu_opt_get(opts, "ifname")) {
   

[Qemu-devel] Re: [PATCH, try 2, version 2] qemu/tap: add -net tap, dev= option

2009-12-09 Thread Michael S. Tsirkin
On Wed, Dec 09, 2009 at 03:49:04PM +0100, Arnd Bergmann wrote:
> In order to support macvtap, we need a way to select the actual
> tap endpoint. While it would be nice to pass it by network interface
> name, passing the character device is more flexible, and we can
> easily do both in the long run.
> 
> This version makes it possible to use macvtap without introducing
> any macvtap specific code in qemu, only a natural extension to
> the existing interface.
> 
> Signed-off-by: Arnd Bergmann 
> Acked-by: Mark McLoughlin 
> Cc: "Michael S. Tsirkin" 
> ---
> Hopefully addressed all comments from Michael. I did compile-test
> the non-linux files I touched (the solaris file failed to build for another
> reason), and this now prevents passing dev= on non-linux machines.

Found a couple more minor nits in the new versions, otherwise looks good.

>  net.c |5 +
>  net/tap-aix.c |3 ++-
>  net/tap-bsd.c |9 -
>  net/tap-linux.c   |   12 
>  net/tap-solaris.c |7 ++-
>  net/tap.c |   17 ++---
>  net/tap.h |3 ++-
>  qemu-options.hx   |   10 +-
>  8 files changed, 54 insertions(+), 12 deletions(-)
> 
> diff --git a/net.c b/net.c
> index 13bdbb2..deb12fd 100644
> --- a/net.c
> +++ b/net.c
> @@ -955,6 +955,11 @@ static struct {
>  },
>  #ifndef _WIN32
>  {
> +.name = "dev",
> +.type = QEMU_OPT_STRING,
> +.help = "character device pathname",
> +},
> +{
>  .name = "fd",
>  .type = QEMU_OPT_STRING,
>  .help = "file descriptor of an already opened tap",
> diff --git a/net/tap-aix.c b/net/tap-aix.c
> index 4bc9f2f..238c190 100644
> --- a/net/tap-aix.c
> +++ b/net/tap-aix.c
> @@ -25,7 +25,8 @@
>  #include "net/tap.h"
>  #include 
>  
> -int tap_open(char *ifname, int ifname_size, int *vnet_hdr, int 
> vnet_hdr_required)
> +int tap_open(char *ifname, int ifname_size, const char *dev,
> + int *vnet_hdr, int vnet_hdr_required)
>  {
>  fprintf(stderr, "no tap on AIX\n");
>  return -1;
> diff --git a/net/tap-bsd.c b/net/tap-bsd.c
> index 815997d..8a7334c 100644
> --- a/net/tap-bsd.c
> +++ b/net/tap-bsd.c
> @@ -40,7 +40,8 @@
>  #include 
>  #endif
>  
> -int tap_open(char *ifname, int ifname_size, int *vnet_hdr, int 
> vnet_hdr_required)
> +int tap_open(char *ifname, int ifname_size, const char *devarg,
> + int *vnet_hdr, int vnet_hdr_required)
>  {
>  int fd;
>  char *dev;
> @@ -80,6 +81,12 @@ int tap_open(char *ifname, int ifname_size, int *vnet_hdr, 
> int vnet_hdr_required
>  }
>  #endif
>  
> +if (devarg) {
> +qemu_error("dev= not supported\n");
> +close(fd);
> +return -1;
> +}
> +
>  fstat(fd, &s);
>  dev = devname(s.st_rdev, S_IFCHR);
>  pstrcpy(ifname, ifname_size, dev);
> diff --git a/net/tap-linux.c b/net/tap-linux.c
> index 6af9e82..d6831c0 100644
> --- a/net/tap-linux.c
> +++ b/net/tap-linux.c
> @@ -32,14 +32,18 @@
>  #include "sysemu.h"
>  #include "qemu-common.h"
>  
> -int tap_open(char *ifname, int ifname_size, int *vnet_hdr, int 
> vnet_hdr_required)
> +int tap_open(char *ifname, int ifname_size, const char *dev,
> +int *vnet_hdr, int vnet_hdr_required)
>  {
>  struct ifreq ifr;
>  int fd, ret;
>  
> -TFR(fd = open("/dev/net/tun", O_RDWR));
> +if (!*dev)
> +dev = "/dev/net/tun";
> +

Did you test without dev parameter? I think dev will be NULL
so this will deference a nullpointer ...
probably if (!dev) is what you mean?


> +TFR(fd = open(dev, O_RDWR));
>  if (fd < 0) {
> -fprintf(stderr, "warning: could not open /dev/net/tun: no virtual 
> network emulation\n");
> +fprintf(stderr, "warning: could not open %s: no virtual network 
> emulation\n", dev);
>  return -1;
>  }
>  memset(&ifr, 0, sizeof(ifr));
> @@ -70,7 +74,7 @@ int tap_open(char *ifname, int ifname_size, int *vnet_hdr, 
> int vnet_hdr_required
>  pstrcpy(ifr.ifr_name, IFNAMSIZ, "tap%d");
>  ret = ioctl(fd, TUNSETIFF, (void *) &ifr);
>  if (ret != 0) {
> -fprintf(stderr, "warning: could not configure /dev/net/tun: no 
> virtual network emulation\n");
> +fprintf(stderr, "warning: could not configure %s: no virtual network 
> emulation\n", dev);
>  close(fd);
>  return -1;
>  }
> diff --git a/net/tap-solaris.c b/net/tap-solaris.c
> index e14fe36..3d10984 100644
> --- a/net/tap-solaris.c
> +++ b/net/tap-solaris.c
> @@ -171,10 +171,15 @@ static int tap_alloc(char *dev, size_t dev_size)
>  return tap_fd;
>  }
>  
> -int tap_open(char *ifname, int ifname_size, int *vnet_hdr, int 
> vnet_hdr_required)
> +int tap_open(char *ifname, int ifname_size, const char *devarg,
> + int *vnet_hdr, int vnet_hdr_required)
>  {
>  char  dev[10]="";
>  int fd;
> +

Re: [Qemu-devel] Re: [PATCH, try 2, version 2] qemu/tap: add -net tap, dev= option

2009-12-09 Thread Arnd Bergmann
On Wednesday 09 December 2009, Michael S. Tsirkin wrote:
> On Wed, Dec 09, 2009 at 03:49:04PM +0100, Arnd Bergmann wrote:
> >  
> > -TFR(fd = open("/dev/net/tun", O_RDWR));
> > +if (!*dev)
> > +dev = "/dev/net/tun";
> > +
> 
> Did you test without dev parameter? I think dev will be NULL
> so this will deference a nullpointer ...
> probably if (!dev) is what you mean?

D'oh. will fix.
  
> will be neater if you put [,dev=str] after [,script=file]
> Also - it does need a string, but only insofar as all options are strings.
> Maybe dev=devfile or dev=file would be clearer.

Yep. Thanks,

Arnd




[Qemu-devel] [FOR 0.12 PATCH v2 3/3] qdev: Replace device names containing whitespace

2009-12-09 Thread Markus Armbruster
Device names with whitespace require quoting in the shell and in the
monitor.  Some of the offenders are also overly long.  Some have a
more convenient alias, some don't.

The place for verbose device names is DeviceInfo member desc.  The
name should be short & sweet.

Signed-off-by: Markus Armbruster 
---
 hw/bt-hid.c  |2 +-
 hw/cirrus_vga.c  |5 +++--
 hw/grackle_pci.c |4 ++--
 hw/ide/cmd646.c  |4 ++--
 hw/ide/piix.c|8 
 hw/unin_pci.c|   30 +++---
 hw/usb-bt.c  |4 ++--
 hw/usb-bus.c |2 +-
 hw/usb-hid.c |9 +++--
 hw/usb-hub.c |2 +-
 hw/usb-msd.c |5 ++---
 hw/usb-net.c |4 ++--
 hw/usb-ohci.c|5 ++---
 hw/usb-serial.c  |   10 --
 hw/usb-uhci.c|8 
 hw/usb-wacom.c   |4 ++--
 hw/vmware_vga.c  |4 ++--
 usb-bsd.c|4 ++--
 usb-linux.c  |5 ++---
 19 files changed, 56 insertions(+), 63 deletions(-)

diff --git a/hw/bt-hid.c b/hw/bt-hid.c
index 4a04bbd..abdfd35 100644
--- a/hw/bt-hid.c
+++ b/hw/bt-hid.c
@@ -566,6 +566,6 @@ static struct bt_device_s *bt_hid_init(struct 
bt_scatternet_s *net,
 
 struct bt_device_s *bt_keyboard_init(struct bt_scatternet_s *net)
 {
-USBDevice *dev = usb_create_simple(NULL /* FIXME */, "QEMU USB Keyboard");
+USBDevice *dev = usb_create_simple(NULL /* FIXME */, "usb-kbd");
 return bt_hid_init(net, dev, class_keyboard);
 }
diff --git a/hw/cirrus_vga.c b/hw/cirrus_vga.c
index 2d1dd4e..24af81c 100644
--- a/hw/cirrus_vga.c
+++ b/hw/cirrus_vga.c
@@ -3217,11 +3217,12 @@ static int pci_cirrus_vga_initfn(PCIDevice *dev)
 
 void pci_cirrus_vga_init(PCIBus *bus)
 {
-pci_create_simple(bus, -1, "Cirrus VGA");
+pci_create_simple(bus, -1, "cirrus-vga");
 }
 
 static PCIDeviceInfo cirrus_vga_info = {
-.qdev.name= "Cirrus VGA",
+.qdev.name= "cirrus-vga",
+.qdev.desc= "Cirrus CLGD 54xx VGA",
 .qdev.size= sizeof(PCICirrusVGAState),
 .qdev.vmsd= &vmstate_pci_cirrus_vga,
 .init = pci_cirrus_vga_initfn,
diff --git a/hw/grackle_pci.c b/hw/grackle_pci.c
index 089d1fb..ee4fed5 100644
--- a/hw/grackle_pci.c
+++ b/hw/grackle_pci.c
@@ -178,7 +178,7 @@ static PCIDeviceInfo grackle_pci_host_info = {
 };
 
 static PCIDeviceInfo dec_21154_pci_host_info = {
-.qdev.name = "DEC 21154",
+.qdev.name = "dec-21154",
 .qdev.size = sizeof(PCIDevice),
 .init  = dec_21154_pci_host_init,
 };
@@ -188,7 +188,7 @@ static void grackle_register_devices(void)
 sysbus_register_dev("grackle", sizeof(GrackleState),
 pci_grackle_init_device);
 pci_qdev_register(&grackle_pci_host_info);
-sysbus_register_dev("DEC 21154", sizeof(GrackleState),
+sysbus_register_dev("dec-21154", sizeof(GrackleState),
 pci_dec_21154_init_device);
 pci_qdev_register(&dec_21154_pci_host_info);
 }
diff --git a/hw/ide/cmd646.c b/hw/ide/cmd646.c
index 3b7c606..e1e626e 100644
--- a/hw/ide/cmd646.c
+++ b/hw/ide/cmd646.c
@@ -245,7 +245,7 @@ void pci_cmd646_ide_init(PCIBus *bus, DriveInfo **hd_table,
 {
 PCIDevice *dev;
 
-dev = pci_create(bus, -1, "CMD646 IDE");
+dev = pci_create(bus, -1, "cmd646-ide");
 qdev_prop_set_uint32(&dev->qdev, "secondary", secondary_ide_enabled);
 qdev_init_nofail(&dev->qdev);
 
@@ -254,7 +254,7 @@ void pci_cmd646_ide_init(PCIBus *bus, DriveInfo **hd_table,
 
 static PCIDeviceInfo cmd646_ide_info[] = {
 {
-.qdev.name= "CMD646 IDE",
+.qdev.name= "cmd646-ide",
 .qdev.size= sizeof(PCIIDEState),
 .init = pci_cmd646_ide_initfn,
 .qdev.props   = (Property[]) {
diff --git a/hw/ide/piix.c b/hw/ide/piix.c
index ec93f29..de36480 100644
--- a/hw/ide/piix.c
+++ b/hw/ide/piix.c
@@ -161,7 +161,7 @@ void pci_piix3_ide_init(PCIBus *bus, DriveInfo **hd_table, 
int devfn)
 {
 PCIDevice *dev;
 
-dev = pci_create_simple(bus, devfn, "PIIX3 IDE");
+dev = pci_create_simple(bus, devfn, "piix3-ide");
 pci_ide_create_devs(dev, hd_table);
 }
 
@@ -171,18 +171,18 @@ void pci_piix4_ide_init(PCIBus *bus, DriveInfo 
**hd_table, int devfn)
 {
 PCIDevice *dev;
 
-dev = pci_create_simple(bus, devfn, "PIIX4 IDE");
+dev = pci_create_simple(bus, devfn, "piix4-ide");
 pci_ide_create_devs(dev, hd_table);
 }
 
 static PCIDeviceInfo piix_ide_info[] = {
 {
-.qdev.name= "PIIX3 IDE",
+.qdev.name= "piix3-ide",
 .qdev.size= sizeof(PCIIDEState),
 .qdev.no_user = 1,
 .init = pci_piix3_ide_initfn,
 },{
-.qdev.name= "PIIX4 IDE",
+.qdev.name= "piix4-ide",
 .qdev.size= sizeof(PCIIDEState),
 .qdev.no_user = 1,
 .init = pci_piix4_ide_initfn,
diff --git a/hw/unin_pci.c b/hw/unin_pci.c
index 5b3f118..f07c966 100644
--- a/hw/unin_pci.c
+++ b/hw/unin_pci.c
@@ -148,7 +148,7 @@ PCIBus *pci_pmac_init(qemu_irq *pic)
 
 /* Use values fo

[Qemu-devel] [FOR 0.12 PATCH v2 2/3] qdev: Separate USB product description from qdev name

2009-12-09 Thread Markus Armbruster
Using the qdev name for the product description makes for inconvenient
qdev names.

Put the product description in new USBDeviceInfo member product_desc.
Make usb_qdev_init() use it.  No user or guest visible change, since
the value is still the same.

Signed-off-by: Markus Armbruster 
---
 hw/usb-bt.c |1 +
 hw/usb-bus.c|2 +-
 hw/usb-hid.c|3 +++
 hw/usb-hub.c|1 +
 hw/usb-msd.c|1 +
 hw/usb-net.c|1 +
 hw/usb-serial.c |2 ++
 hw/usb-wacom.c  |1 +
 hw/usb.h|2 ++
 usb-bsd.c   |1 +
 usb-linux.c |1 +
 11 files changed, 15 insertions(+), 1 deletions(-)

diff --git a/hw/usb-bt.c b/hw/usb-bt.c
index 18d7a98..07da133 100644
--- a/hw/usb-bt.c
+++ b/hw/usb-bt.c
@@ -645,6 +645,7 @@ USBDevice *usb_bt_init(HCIInfo *hci)
 }
 
 static struct USBDeviceInfo bt_info = {
+.product_desc   = "QEMU BT dongle",
 .qdev.name  = "QEMU BT dongle",
 .qdev.size  = sizeof(struct USBBtState),
 .init   = usb_bt_initfn,
diff --git a/hw/usb-bus.c b/hw/usb-bus.c
index ba1b6e3..8bbc80d 100644
--- a/hw/usb-bus.c
+++ b/hw/usb-bus.c
@@ -43,7 +43,7 @@ static int usb_qdev_init(DeviceState *qdev, DeviceInfo *base)
 USBDeviceInfo *info = DO_UPCAST(USBDeviceInfo, qdev, base);
 int rc;
 
-pstrcpy(dev->product_desc, sizeof(dev->product_desc), qdev->info->name);
+pstrcpy(dev->product_desc, sizeof(dev->product_desc), info->product_desc);
 dev->info = info;
 dev->auto_attach = 1;
 rc = dev->info->init(dev);
diff --git a/hw/usb-hid.c b/hw/usb-hid.c
index 6621f72..33de302 100644
--- a/hw/usb-hid.c
+++ b/hw/usb-hid.c
@@ -880,6 +880,7 @@ void usb_hid_datain_cb(USBDevice *dev, void *opaque, void 
(*datain)(void *))
 
 static struct USBDeviceInfo hid_info[] = {
 {
+.product_desc   = "QEMU USB Tablet",
 .qdev.name  = "QEMU USB Tablet",
 .qdev.alias = "usb-tablet",
 .usbdevice_name = "tablet",
@@ -891,6 +892,7 @@ static struct USBDeviceInfo hid_info[] = {
 .handle_data= usb_hid_handle_data,
 .handle_destroy = usb_hid_handle_destroy,
 },{
+.product_desc   = "QEMU USB Mouse",
 .qdev.name  = "QEMU USB Mouse",
 .qdev.alias = "usb-mouse",
 .usbdevice_name = "mouse",
@@ -902,6 +904,7 @@ static struct USBDeviceInfo hid_info[] = {
 .handle_data= usb_hid_handle_data,
 .handle_destroy = usb_hid_handle_destroy,
 },{
+.product_desc   = "QEMU USB Keyboard",
 .qdev.name  = "QEMU USB Keyboard",
 .qdev.alias = "usb-kbd",
 .usbdevice_name = "keyboard",
diff --git a/hw/usb-hub.c b/hw/usb-hub.c
index e5a0938..32f2ab8 100644
--- a/hw/usb-hub.c
+++ b/hw/usb-hub.c
@@ -544,6 +544,7 @@ static int usb_hub_initfn(USBDevice *dev)
 }
 
 static struct USBDeviceInfo hub_info = {
+.product_desc   = "QEMU USB Hub",
 .qdev.name  = "QEMU USB Hub",
 .qdev.size  = sizeof(USBHubState),
 .init   = usb_hub_initfn,
diff --git a/hw/usb-msd.c b/hw/usb-msd.c
index bb39b62..b9f6588 100644
--- a/hw/usb-msd.c
+++ b/hw/usb-msd.c
@@ -600,6 +600,7 @@ static USBDevice *usb_msd_init(const char *filename)
 }
 
 static struct USBDeviceInfo msd_info = {
+.product_desc   = "QEMU USB MSD",
 .qdev.name  = "QEMU USB MSD",
 .qdev.alias = "usb-storage",
 .qdev.size  = sizeof(MSDState),
diff --git a/hw/usb-net.c b/hw/usb-net.c
index 2556e05..3dd05e3 100644
--- a/hw/usb-net.c
+++ b/hw/usb-net.c
@@ -1487,6 +1487,7 @@ USBDevice *usb_net_init(NICInfo *nd)
 }
 
 static struct USBDeviceInfo net_info = {
+.product_desc   = "QEMU USB Network Interface",
 .qdev.name  = "QEMU USB Network Interface",
 .qdev.size  = sizeof(USBNetState),
 .init   = usb_net_initfn,
diff --git a/hw/usb-serial.c b/hw/usb-serial.c
index 223d4c3..14e410e 100644
--- a/hw/usb-serial.c
+++ b/hw/usb-serial.c
@@ -605,6 +605,7 @@ static USBDevice *usb_braille_init(const char *unused)
 }
 
 static struct USBDeviceInfo serial_info = {
+.product_desc   = "QEMU USB Serial",
 .qdev.name  = "QEMU USB Serial",
 .qdev.alias = "usb-serial",
 .qdev.size  = sizeof(USBSerialState),
@@ -625,6 +626,7 @@ static struct USBDeviceInfo serial_info = {
 };
 
 static struct USBDeviceInfo braille_info = {
+.product_desc   = "QEMU USB Braille",
 .qdev.name  = "QEMU USB Braille",
 .qdev.alias = "usb-braille",
 .qdev.size  = sizeof(USBSerialState),
diff --git a/hw/usb-wacom.c b/hw/usb-wacom.c
index ef61376..b10864f 100644
--- a/hw/usb-wacom.c
+++ b/hw/usb-wacom.c
@@ -409,6 +409,7 @@ static int usb_wacom_initfn(USBDevice *dev)
 }
 
 static struct USBDeviceInfo wacom_info = {
+.product_desc   = "QEMU PenPartner Tablet",
 .qdev.name  = "QEMU PenPartner Tablet",
 .qdev.alias = "wacom-tablet",
 .usbdevice_name = "wacom-tablet",
diff --git a/hw/usb.h b/hw/usb.h
index 39aba99..0684588 100644
--- a/hw/usb.h
+++ b/hw/usb

[Qemu-devel] [FOR 0.12 PATCH v2 1/3] qdev: Rename USBDevice member devname to product_desc

2009-12-09 Thread Markus Armbruster
It's not a device name, it's the USB product description string.

Signed-off-by: Markus Armbruster 
---
 hw/bt-hid.c  |2 +-
 hw/usb-bus.c |   11 ++-
 hw/usb-hid.c |2 +-
 hw/usb.h |2 +-
 usb-bsd.c|4 ++--
 usb-linux.c  |4 ++--
 6 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/hw/bt-hid.c b/hw/bt-hid.c
index 020176e..4a04bbd 100644
--- a/hw/bt-hid.c
+++ b/hw/bt-hid.c
@@ -552,7 +552,7 @@ static struct bt_device_s *bt_hid_init(struct 
bt_scatternet_s *net,
 BT_HID_MTU, bt_hid_new_interrupt_ch);
 
 s->usbdev = dev;
-s->btdev.device.lmp_name = s->usbdev->devname;
+s->btdev.device.lmp_name = s->usbdev->product_desc;
 usb_hid_datain_cb(s->usbdev, s, bt_hid_datain);
 
 s->btdev.device.handle_destroy = bt_hid_destroy;
diff --git a/hw/usb-bus.c b/hw/usb-bus.c
index 99d185e..ba1b6e3 100644
--- a/hw/usb-bus.c
+++ b/hw/usb-bus.c
@@ -43,7 +43,7 @@ static int usb_qdev_init(DeviceState *qdev, DeviceInfo *base)
 USBDeviceInfo *info = DO_UPCAST(USBDeviceInfo, qdev, base);
 int rc;
 
-pstrcpy(dev->devname, sizeof(dev->devname), qdev->info->name);
+pstrcpy(dev->product_desc, sizeof(dev->product_desc), qdev->info->name);
 dev->info = info;
 dev->auto_attach = 1;
 rc = dev->info->init(dev);
@@ -131,7 +131,7 @@ static void do_attach(USBDevice *dev)
 
 if (dev->attached) {
 fprintf(stderr, "Warning: tried to attach usb device %s twice\n",
-dev->devname);
+dev->product_desc);
 return;
 }
 dev->attached++;
@@ -166,7 +166,7 @@ int usb_device_detach(USBDevice *dev)
 
 if (!dev->attached) {
 fprintf(stderr, "Warning: tried to detach unattached usb device %s\n",
-dev->devname);
+dev->product_desc);
 return -1;
 }
 dev->attached--;
@@ -228,7 +228,7 @@ static void usb_bus_dev_print(Monitor *mon, DeviceState 
*qdev, int indent)
 
 monitor_printf(mon, "%*saddr %d.%d, speed %s, name %s%s\n",
indent, "", bus->busnr, dev->addr,
-   usb_speed(dev->speed), dev->devname,
+   usb_speed(dev->speed), dev->product_desc,
dev->attached ? ", attached" : "");
 }
 
@@ -249,7 +249,8 @@ void usb_info(Monitor *mon)
 if (!dev)
 continue;
 monitor_printf(mon, "  Device %d.%d, Speed %s Mb/s, Product %s\n",
-   bus->busnr, dev->addr, usb_speed(dev->speed), 
dev->devname);
+   bus->busnr, dev->addr, usb_speed(dev->speed),
+   dev->product_desc);
 }
 }
 }
diff --git a/hw/usb-hid.c b/hw/usb-hid.c
index f4a2a48..6621f72 100644
--- a/hw/usb-hid.c
+++ b/hw/usb-hid.c
@@ -701,7 +701,7 @@ static int usb_hid_handle_control(USBDevice *dev, int 
request, int value,
 break;
 case 2:
 /* product description */
-ret = set_usb_string(data, s->dev.devname);
+ret = set_usb_string(data, s->dev.product_desc);
 break;
 case 3:
 /* vendor description */
diff --git a/hw/usb.h b/hw/usb.h
index 351c466..39aba99 100644
--- a/hw/usb.h
+++ b/hw/usb.h
@@ -132,7 +132,7 @@ struct USBDevice {
 
 int speed;
 uint8_t addr;
-char devname[32];
+char product_desc[32];
 int auto_attach;
 int attached;
 
diff --git a/usb-bsd.c b/usb-bsd.c
index a66364f..a9987d1 100644
--- a/usb-bsd.c
+++ b/usb-bsd.c
@@ -370,10 +370,10 @@ USBDevice *usb_host_device_open(const char *devname)
 dev->dev.speed = USB_SPEED_FULL - 1;
 
 if (strncmp(dev_info.udi_product, "product", 7) != 0)
-pstrcpy(dev->dev.devname, sizeof(dev->dev.devname),
+pstrcpy(dev->dev.product_desc, sizeof(dev->dev.product_desc),
 dev_info.udi_product);
 else
-snprintf(dev->dev.devname, sizeof(dev->dev.devname),
+snprintf(dev->dev.product_desc, sizeof(dev->dev.product_desc),
  "host:%s", devname);
 
 pstrcpy(dev->devpath, sizeof(dev->devpath), "/dev/");
diff --git a/usb-linux.c b/usb-linux.c
index 285ac22..67735d3 100644
--- a/usb-linux.c
+++ b/usb-linux.c
@@ -933,10 +933,10 @@ static int usb_host_open(USBHostDevice *dev, int bus_num,
 dev->dev.speed = USB_SPEED_HIGH;
 
 if (!prod_name || prod_name[0] == '\0')
-snprintf(dev->dev.devname, sizeof(dev->dev.devname),
+snprintf(dev->dev.product_desc, sizeof(dev->dev.product_desc),
  "host:%d.%d", bus_num, addr);
 else
-pstrcpy(dev->dev.devname, sizeof(dev->dev.devname),
+pstrcpy(dev->dev.product_desc, sizeof(dev->dev.product_desc),
 prod_name);
 
 /* USB devio uses 'write' flag to check for async completions */
-- 
1.6.2.5





[Qemu-devel] [FOR 0.12 PATCH v2 0/3] Replace device names containing whitespace

2009-12-09 Thread Markus Armbruster
Device names with whitespace require quoting in the shell and in the
monitor.  Some of the offenders are also overly long.  Some have a
more convenient alias, some don't.

The place for verbose device names is DeviceInfo member desc.  The
name should be short & sweet.

This patch gets rid of the spaces.  It normalizes names it touches to
lower case with '-' separators.  This seems to be the most common
style.  If you want me to normalize all device names, I can do that.

On naming style: we have 187 device names.  41 of them use upper
case. 40 use '-' as separator, 39 use '_', 19 use ',', and 30 use
space.  10 of them use two different separators simultaneously.

I checked every use of DeviceInfo members name and alias to find places
that use it for purposes other than naming qdevs.  They are:

* Some NIC initialization functions pass the qdev name to
  qemu_new_nic() parameter model.  It ends up in VLANClientState
  member model.  I believe changing that from long description to
  short name is an improvement.  None of the devices using
  qemu_new_nic() that way get their names changed here.

* usb_qdev_init() copies the qdev name to USBDevice devname.  Gets
  overwritten for usb-host devices, but not for the others.  This is
  what Gerd pointed out.  I fixed it just like Gerd recommended.

Markus Armbruster (3):
  qdev: Rename USBDevice member devname to product_desc
  qdev: Separate USB product description from qdev name
  qdev: Replace device names containing whitespace

 hw/bt-hid.c  |4 ++--
 hw/cirrus_vga.c  |5 +++--
 hw/grackle_pci.c |4 ++--
 hw/ide/cmd646.c  |4 ++--
 hw/ide/piix.c|8 
 hw/unin_pci.c|   30 +++---
 hw/usb-bt.c  |5 +++--
 hw/usb-bus.c |   13 +++--
 hw/usb-hid.c |   14 +++---
 hw/usb-hub.c |3 ++-
 hw/usb-msd.c |6 +++---
 hw/usb-net.c |5 +++--
 hw/usb-ohci.c|5 ++---
 hw/usb-serial.c  |   12 ++--
 hw/usb-uhci.c|8 
 hw/usb-wacom.c   |5 +++--
 hw/usb.h |4 +++-
 hw/vmware_vga.c  |4 ++--
 usb-bsd.c|9 +
 usb-linux.c  |   10 +-
 20 files changed, 83 insertions(+), 75 deletions(-)





[Qemu-devel] Re: [FOR 0.12 PATCH v4 03/22] qdev: also match bus name for global properties

2009-12-09 Thread Michael S. Tsirkin
On Tue, Dec 08, 2009 at 01:11:35PM +0100, Gerd Hoffmann wrote:
> i.e. -global PCI.= will set a default property for all
> PCI devices.  Also works for the compat properties used by machine
> types.
> 
> Signed-off-by: Gerd Hoffmann 

Looks like an earlier version of the patches was applied
on staging, and so staging lacks this patch.


> ---
>  hw/qdev-properties.c |3 ++-
>  1 files changed, 2 insertions(+), 1 deletions(-)
> 
> diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c
> index fe106bd..fb07279 100644
> --- a/hw/qdev-properties.c
> +++ b/hw/qdev-properties.c
> @@ -614,7 +614,8 @@ void qdev_prop_set_globals(DeviceState *dev)
>  GlobalProperty *prop;
>  
>  QTAILQ_FOREACH(prop, &global_props, next) {
> -if (strcmp(dev->info->name, prop->driver) != 0) {
> +if (strcmp(dev->info->name, prop->driver) != 0 &&
> +strcmp(dev->info->bus_info->name, prop->driver) != 0) {
>  continue;
>  }
>  if (qdev_prop_parse(dev, prop->property, prop->value) != 0) {
> -- 
> 1.6.5.2
> 
> 




Re: [Qemu-devel] [FOR 0.12 PATCH v2 0/3] Replace device names containing whitespace

2009-12-09 Thread Gerd Hoffmann

  Hi,


* usb_qdev_init() copies the qdev name to USBDevice devname.  Gets
   overwritten for usb-host devices, but not for the others.  This is
   what Gerd pointed out.  I fixed it just like Gerd recommended.


Looks good now.  Ack to the whole series.

cheers,
  Gerd





[Qemu-devel] [FOR 0.12 v3 00/19]: info handlers conversions to QObject

2009-12-09 Thread Luiz Capitulino
 Hi,

 This series covers almost half of the info handlers conversions to the
QObject style.

 The biggest change in this version is that now info handlers always
return a QDict.

changelog
-

v2 -> v3

- Change all info handlers to return a dict
- Fix bad do_info_migrate() rebase
- do_info_cpus(): Use QBool
- do_info_version(): Return QDict

v1 -> v2

- Rebase
- do_info_vnc(): drop keys with 'none' strings
- Fix do_info_balloon() to return bytes

v0 -> v1

- Minor fixes (indentation, casts, etc)
- Improved some documentation and changelogs
- Dropped do_info_network() conversion, it still needs work




[Qemu-devel] [PATCH 01/19] Introduce qemu-objects.h header file

2009-12-09 Thread Luiz Capitulino
An easy way to include all QEMU objects.

Signed-off-by: Luiz Capitulino 
---
 qemu-objects.h |   24 
 1 files changed, 24 insertions(+), 0 deletions(-)
 create mode 100644 qemu-objects.h

diff --git a/qemu-objects.h b/qemu-objects.h
new file mode 100644
index 000..e1d1e0c
--- /dev/null
+++ b/qemu-objects.h
@@ -0,0 +1,24 @@
+/*
+ * Include all QEMU objects.
+ *
+ * Copyright (C) 2009 Red Hat Inc.
+ *
+ * Authors:
+ *  Luiz Capitulino 
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2.  See
+ * the COPYING file in the top-level directory.
+ */
+#ifndef QEMU_OBJECTS_H
+#define QEMU_OBJECTS_H
+
+#include "qobject.h"
+#include "qint.h"
+#include "qfloat.h"
+#include "qbool.h"
+#include "qstring.h"
+#include "qdict.h"
+#include "qlist.h"
+#include "qjson.h"
+
+#endif /* QEMU_OBJECTS_H */
-- 
1.6.6.rc1.39.g9a42





[Qemu-devel] [PATCH 02/19] Makefile: move QObject objs to their own entry

2009-12-09 Thread Luiz Capitulino
Other subsystems will need to link against them.

Signed-off-by: Luiz Capitulino 
---
 Makefile |9 +++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index 85ad688..ea90c23 100644
--- a/Makefile
+++ b/Makefile
@@ -82,6 +82,12 @@ ALL_SUBDIRS=$(TARGET_DIRS) $(patsubst %,pc-bios/%, $(ROMS))
 recurse-all: $(SUBDIR_RULES) $(ROMSUBDIR_RULES)
 
 ###
+# QObject
+qobject-obj-y = qint.o qstring.o qdict.o qlist.o qfloat.o qbool.o
+qobject-obj-y += qjson.o json-lexer.o json-streamer.o json-parser.o
+qobject-obj-y += qerror.o
+
+###
 # block-obj-y is code used by both qemu system emulation and qemu-img
 
 block-obj-y = cutils.o cache-utils.o qemu-malloc.o qemu-option.o module.o
@@ -120,6 +126,7 @@ net-obj-y += $(addprefix net/, $(net-nested-y))
 
 obj-y = $(block-obj-y)
 obj-y += $(net-obj-y)
+obj-y += $(qobject-obj-y)
 obj-y += readline.o console.o
 
 obj-y += tcg-runtime.o host-utils.o
@@ -152,8 +159,6 @@ obj-y += buffered_file.o migration.o migration-tcp.o 
qemu-sockets.o
 obj-y += qemu-char.o aio.o savevm.o
 obj-y += msmouse.o ps2.o
 obj-y += qdev.o qdev-properties.o
-obj-y += qint.o qstring.o qdict.o qlist.o qfloat.o qbool.o json-lexer.o
-obj-y += json-streamer.o json-parser.o qjson.o qerror.o
 obj-y += qemu-config.o block-migration.o
 
 obj-$(CONFIG_BRLAPI) += baum.o
-- 
1.6.6.rc1.39.g9a42





[Qemu-devel] [PATCH 03/19] QDict: Introduce qdict_get_qbool()

2009-12-09 Thread Luiz Capitulino
This is a helper function that does type checking before retrieving
a QBool from the dictionary.

Signed-off-by: Luiz Capitulino 
---
 Makefile |2 +-
 qdict.c  |   15 +++
 qdict.h  |1 +
 3 files changed, 17 insertions(+), 1 deletions(-)

diff --git a/Makefile b/Makefile
index ea90c23..b4356ae 100644
--- a/Makefile
+++ b/Makefile
@@ -246,7 +246,7 @@ qemu-img-cmds.h: $(SRC_PATH)/qemu-img-cmds.hx
 
 check-qint: check-qint.o qint.o qemu-malloc.o
 check-qstring: check-qstring.o qstring.o qemu-malloc.o
-check-qdict: check-qdict.o qdict.o qint.o qstring.o qemu-malloc.o
+check-qdict: check-qdict.o qdict.o qint.o qstring.o qbool.o qemu-malloc.o
 check-qlist: check-qlist.o qlist.o qint.o qemu-malloc.o
 check-qfloat: check-qfloat.o qfloat.o qemu-malloc.o
 check-qjson: check-qjson.o qfloat.o qint.o qdict.o qstring.o qlist.o qbool.o 
qjson.o json-streamer.o json-lexer.o json-parser.o qemu-malloc.o
diff --git a/qdict.c b/qdict.c
index 0e04cb1..45e08be 100644
--- a/qdict.c
+++ b/qdict.c
@@ -12,6 +12,7 @@
 
 #include "qint.h"
 #include "qdict.h"
+#include "qbool.h"
 #include "qstring.h"
 #include "qobject.h"
 #include "qemu-queue.h"
@@ -189,6 +190,20 @@ int64_t qdict_get_int(const QDict *qdict, const char *key)
 }
 
 /**
+ * qdict_get_bool(): Get a bool mapped by 'key'
+ *
+ * This function assumes that 'key' exists and it stores a
+ * QBool object.
+ *
+ * Return bool mapped by 'key'.
+ */
+int qdict_get_bool(const QDict *qdict, const char *key)
+{
+QObject *obj = qdict_get_obj(qdict, key, QTYPE_QBOOL);
+return qbool_get_int(qobject_to_qbool(obj));
+}
+
+/**
  * qdict_get_str(): Get a pointer to the stored string mapped
  * by 'key'
  *
diff --git a/qdict.h b/qdict.h
index 14b2633..1473c04 100644
--- a/qdict.h
+++ b/qdict.h
@@ -37,6 +37,7 @@ void qdict_iter(const QDict *qdict,
 
 /* High level helpers */
 int64_t qdict_get_int(const QDict *qdict, const char *key);
+int qdict_get_bool(const QDict *qdict, const char *key);
 const char *qdict_get_str(const QDict *qdict, const char *key);
 int64_t qdict_get_try_int(const QDict *qdict, const char *key,
   int64_t err_value);
-- 
1.6.6.rc1.39.g9a42





[Qemu-devel] [PATCH 04/19] QDict: Introduce qdict_get_qlist()

2009-12-09 Thread Luiz Capitulino
A helper function to get a QList from a QDict.

Signed-off-by: Luiz Capitulino 
---
 Makefile |2 +-
 qdict.c  |   13 +
 qdict.h  |2 ++
 3 files changed, 16 insertions(+), 1 deletions(-)

diff --git a/Makefile b/Makefile
index b4356ae..f1b0131 100644
--- a/Makefile
+++ b/Makefile
@@ -246,7 +246,7 @@ qemu-img-cmds.h: $(SRC_PATH)/qemu-img-cmds.hx
 
 check-qint: check-qint.o qint.o qemu-malloc.o
 check-qstring: check-qstring.o qstring.o qemu-malloc.o
-check-qdict: check-qdict.o qdict.o qint.o qstring.o qbool.o qemu-malloc.o
+check-qdict: check-qdict.o qdict.o qint.o qstring.o qbool.o qemu-malloc.o 
qlist.o
 check-qlist: check-qlist.o qlist.o qint.o qemu-malloc.o
 check-qfloat: check-qfloat.o qfloat.o qemu-malloc.o
 check-qjson: check-qjson.o qfloat.o qint.o qdict.o qstring.o qlist.o qbool.o 
qjson.o json-streamer.o json-lexer.o json-parser.o qemu-malloc.o
diff --git a/qdict.c b/qdict.c
index 45e08be..ef73265 100644
--- a/qdict.c
+++ b/qdict.c
@@ -204,6 +204,19 @@ int qdict_get_bool(const QDict *qdict, const char *key)
 }
 
 /**
+ * qdict_get_qlist(): Get the QList mapped by 'key'
+ *
+ * This function assumes that 'key' exists and it stores a
+ * QList object.
+ *
+ * Return QList mapped by 'key'.
+ */
+QList *qdict_get_qlist(const QDict *qdict, const char *key)
+{
+return qobject_to_qlist(qdict_get_obj(qdict, key, QTYPE_QLIST));
+}
+
+/**
  * qdict_get_str(): Get a pointer to the stored string mapped
  * by 'key'
  *
diff --git a/qdict.h b/qdict.h
index 1473c04..5fef1ea 100644
--- a/qdict.h
+++ b/qdict.h
@@ -2,6 +2,7 @@
 #define QDICT_H
 
 #include "qobject.h"
+#include "qlist.h"
 #include "qemu-queue.h"
 #include 
 
@@ -38,6 +39,7 @@ void qdict_iter(const QDict *qdict,
 /* High level helpers */
 int64_t qdict_get_int(const QDict *qdict, const char *key);
 int qdict_get_bool(const QDict *qdict, const char *key);
+QList *qdict_get_qlist(const QDict *qdict, const char *key);
 const char *qdict_get_str(const QDict *qdict, const char *key);
 int64_t qdict_get_try_int(const QDict *qdict, const char *key,
   int64_t err_value);
-- 
1.6.6.rc1.39.g9a42





[Qemu-devel] [PATCH 05/19] monitor: Fix do_info_balloon() output

2009-12-09 Thread Luiz Capitulino
Monitor commands should always return values in bytes and info
commands should always return a QDict.

Signed-off-by: Luiz Capitulino 
---
 monitor.c |   19 ---
 1 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/monitor.c b/monitor.c
index a38a103..aa56ec7 100644
--- a/monitor.c
+++ b/monitor.c
@@ -1919,12 +1919,24 @@ static void do_balloon(Monitor *mon, const QDict 
*qdict, QObject **ret_data)
 
 static void monitor_print_balloon(Monitor *mon, const QObject *data)
 {
-monitor_printf(mon, "balloon: actual=%d\n",
- (int)qint_get_int(qobject_to_qint(data)));
+QDict *qdict;
+
+qdict = qobject_to_qdict(data);
+
+monitor_printf(mon, "balloon: actual=%" PRId64 "\n",
+qdict_get_int(qdict, "balloon") >> 20);
 }
 
 /**
  * do_info_balloon(): Balloon information
+ *
+ * Return a QDict with the following information:
+ *
+ * - "balloon": current balloon value in bytes
+ *
+ * Example:
+ *
+ * { "balloon": 1073741824 }
  */
 static void do_info_balloon(Monitor *mon, QObject **ret_data)
 {
@@ -1936,7 +1948,8 @@ static void do_info_balloon(Monitor *mon, QObject 
**ret_data)
 else if (actual == 0)
 qemu_error_new(QERR_DEVICE_NOT_ACTIVE, "balloon");
 else
-*ret_data = QOBJECT(qint_from_int((int)(actual >> 20)));
+*ret_data = qobject_from_jsonf("{ 'balloon': %" PRId64 "}",
+   (int64_t) actual);
 }
 
 static qemu_acl *find_acl(Monitor *mon, const char *name)
-- 
1.6.6.rc1.39.g9a42





[Qemu-devel] [PATCH 06/19] monitor: do_info_cpus(): Use QBool

2009-12-09 Thread Luiz Capitulino
While there update the documentation as well.

Signed-off-by: Luiz Capitulino 
---
 monitor.c |   39 ++-
 1 files changed, 26 insertions(+), 13 deletions(-)

diff --git a/monitor.c b/monitor.c
index aa56ec7..8729535 100644
--- a/monitor.c
+++ b/monitor.c
@@ -611,8 +611,9 @@ static void print_cpu_iter(QObject *obj, void *opaque)
 assert(qobject_type(obj) == QTYPE_QDICT);
 cpu = qobject_to_qdict(obj);
 
-if (strcmp(qdict_get_str(cpu, "current"), "yes") == 0)
+if (qdict_get_bool(cpu, "current")) {
 active = '*';
+}
 
 monitor_printf(mon, "%c CPU #%d: ", active, (int)qdict_get_int(cpu, 
"CPU"));
 
@@ -632,8 +633,9 @@ static void print_cpu_iter(QObject *obj, void *opaque)
(target_long) qdict_get_int(cpu, "PC"));
 #endif
 
-if (strcmp(qdict_get_str(cpu, "halted"), "yes") == 0)
+if (qdict_get_bool(cpu, "halted")) {
 monitor_printf(mon, " (halted)");
+}
 
 monitor_printf(mon, "\n");
 }
@@ -650,12 +652,22 @@ static void monitor_print_cpus(Monitor *mon, const 
QObject *data)
 /**
  * do_info_cpus(): Show CPU information
  *
- * Return a QList with a QDict for each CPU.
+ * Return a QList. Each CPU is represented by a QDict, which contains:
  *
- * For example:
+ * - "cpu": CPU index
+ * - "current": true if this is the current CPU, false otherwise
+ * - "halted": true if the cpu is halted, false otherwise
+ * - Current program counter, in decimal. The key name depends on
+ *   the architecture:
+ *  "pc": i386/x86)64
+ *  "nip": PPC
+ *  "pc" and "npc": sparc
+ *  "PC": mips
  *
- * [ { "CPU": 0, "current": "yes", "pc": 0x..., "halted": "no" },
- *   { "CPU": 1, "current": "no",  "pc": 0x..., "halted": "yes" } ]
+ * Example:
+ *
+ * [ { "CPU": 0, "current": true, "halted": false, "pc": 3227107138 },
+ *   { "CPU": 1, "current": false, "halted": true, "pc": 7108165 } ]
  */
 static void do_info_cpus(Monitor *mon, QObject **ret_data)
 {
@@ -668,14 +680,17 @@ static void do_info_cpus(Monitor *mon, QObject **ret_data)
 mon_get_cpu();
 
 for(env = first_cpu; env != NULL; env = env->next_cpu) {
-const char *answer;
-QDict *cpu = qdict_new();
+QDict *cpu;
+QObject *obj;
 
 cpu_synchronize_state(env);
 
-qdict_put(cpu, "CPU", qint_from_int(env->cpu_index));
-answer = (env == mon->mon_cpu) ? "yes" : "no";
-qdict_put(cpu, "current", qstring_from_str(answer));
+obj = qobject_from_jsonf("{ 'CPU': %d, 'current': %i, 'halted': %i }",
+ env->cpu_index, env == mon->mon_cpu,
+ env->halted);
+assert(obj != NULL);
+
+cpu = qobject_to_qdict(obj);
 
 #if defined(TARGET_I386)
 qdict_put(cpu, "pc", qint_from_int(env->eip + env->segs[R_CS].base));
@@ -687,8 +702,6 @@ static void do_info_cpus(Monitor *mon, QObject **ret_data)
 #elif defined(TARGET_MIPS)
 qdict_put(cpu, "PC", qint_from_int(env->active_tc.PC));
 #endif
-answer = env->halted ? "yes" : "no";
-qdict_put(cpu, "halted", qstring_from_str(answer));
 
 qlist_append(cpu_list, cpu);
 }
-- 
1.6.6.rc1.39.g9a42





[Qemu-devel] [PATCH 07/19] monitor: do_info_version(): Use QDict

2009-12-09 Thread Luiz Capitulino
All 'info' commands should use QDict, this commit also kills
monitor_print_qobject() as do_info_version() doesn't use it
anymore (and no handler will).

Signed-off-by: Luiz Capitulino 
---
 monitor.c |   42 ++
 1 files changed, 22 insertions(+), 20 deletions(-)

diff --git a/monitor.c b/monitor.c
index 8729535..775e687 100644
--- a/monitor.c
+++ b/monitor.c
@@ -257,24 +257,6 @@ static inline int monitor_has_error(const Monitor *mon)
 return mon->error != NULL;
 }
 
-static void monitor_print_qobject(Monitor *mon, const QObject *data)
-{
-switch (qobject_type(data)) {
-case QTYPE_QSTRING:
-monitor_printf(mon, 
"%s",qstring_get_str(qobject_to_qstring(data)));
-break;
-case QTYPE_QINT:
-monitor_printf(mon, "%" 
PRId64,qint_get_int(qobject_to_qint(data)));
-break;
-default:
-monitor_printf(mon, "ERROR: unsupported type: %d",
-qobject_type(data));
-break;
-}
-
-monitor_puts(mon, "\n");
-}
-
 static void monitor_json_emitter(Monitor *mon, const QObject *data)
 {
 QString *json;
@@ -504,12 +486,32 @@ help:
 help_cmd(mon, "info");
 }
 
+static void do_info_version_print(Monitor *mon, const QObject *data)
+{
+QDict *qdict;
+
+qdict = qobject_to_qdict(data);
+
+monitor_printf(mon, "%s%s\n", qdict_get_str(qdict, "qemu"),
+  qdict_get_str(qdict, "package"));
+}
+
 /**
  * do_info_version(): Show QEMU version
+ *
+ * Return a QDict with the following information:
+ *
+ * - "qemu": QEMU's version
+ * - "package": package's version
+ *
+ * Example:
+ *
+ * { "qemu": "0.11.50", "package": "" }
  */
 static void do_info_version(Monitor *mon, QObject **ret_data)
 {
-*ret_data = QOBJECT(qstring_from_str(QEMU_VERSION QEMU_PKGVERSION));
+*ret_data = qobject_from_jsonf("{ 'qemu': %s, 'package': %s }",
+   QEMU_VERSION, QEMU_PKGVERSION);
 }
 
 static void do_info_name(Monitor *mon)
@@ -2200,7 +2202,7 @@ static const mon_cmd_t info_cmds[] = {
 .args_type  = "",
 .params = "",
 .help   = "show the version of QEMU",
-.user_print = monitor_print_qobject,
+.user_print = do_info_version_print,
 .mhandler.info_new = do_info_version,
 },
 {
-- 
1.6.6.rc1.39.g9a42





[Qemu-devel] [PATCH 08/19] monitor: Convert do_info_status() to QObject

2009-12-09 Thread Luiz Capitulino
Signed-off-by: Luiz Capitulino 
---
 monitor.c |   44 +++-
 1 files changed, 35 insertions(+), 9 deletions(-)

diff --git a/monitor.c b/monitor.c
index 775e687..e7a6294 100644
--- a/monitor.c
+++ b/monitor.c
@@ -1910,16 +1910,41 @@ static void do_inject_nmi(Monitor *mon, const QDict 
*qdict)
 }
 #endif
 
-static void do_info_status(Monitor *mon)
+static void do_info_status_print(Monitor *mon, const QObject *data)
 {
-if (vm_running) {
-if (singlestep) {
-monitor_printf(mon, "VM status: running (single step mode)\n");
-} else {
-monitor_printf(mon, "VM status: running\n");
+QDict *qdict;
+
+qdict = qobject_to_qdict(data);
+
+monitor_printf(mon, "VM status: ");
+if (qdict_get_bool(qdict, "running")) {
+monitor_printf(mon, "running");
+if (qdict_get_bool(qdict, "single-step")) {
+monitor_printf(mon, " (single step mode)");
 }
-} else
-   monitor_printf(mon, "VM status: paused\n");
+} else {
+monitor_printf(mon, "paused");
+}
+
+monitor_printf(mon, "\n");
+}
+
+/**
+ * do_info_status(): VM status
+ *
+ * Return a QDict with the following information:
+ *
+ * - "running": true if the VM is running, or false if it is paused
+ * - "single-step": true if the VM is in single step mode, false otherwise
+ *
+ * Example:
+ *
+ * { "running": true, "single-step": false }
+ */
+static void do_info_status(Monitor *mon, QObject **ret_data)
+{
+*ret_data = qobject_from_jsonf("{ 'running': %i, 'single-step': %i }",
+vm_running, singlestep);
 }
 
 /**
@@ -2370,7 +2395,8 @@ static const mon_cmd_t info_cmds[] = {
 .args_type  = "",
 .params = "",
 .help   = "show the current VM status (running|paused)",
-.mhandler.info = do_info_status,
+.user_print = do_info_status_print,
+.mhandler.info_new = do_info_status,
 },
 {
 .name   = "pcmcia",
-- 
1.6.6.rc1.39.g9a42





[Qemu-devel] [PATCH 09/19] monitor: Convert do_info_kvm() to QObject

2009-12-09 Thread Luiz Capitulino
Signed-off-by: Luiz Capitulino 
---
 monitor.c |   41 +
 1 files changed, 33 insertions(+), 8 deletions(-)

diff --git a/monitor.c b/monitor.c
index e7a6294..47f794d 100644
--- a/monitor.c
+++ b/monitor.c
@@ -1783,16 +1783,40 @@ static void tlb_info(Monitor *mon)
 
 #endif
 
-static void do_info_kvm(Monitor *mon)
+static void do_info_kvm_print(Monitor *mon, const QObject *data)
 {
-#ifdef CONFIG_KVM
+QDict *qdict;
+
+qdict = qobject_to_qdict(data);
+
 monitor_printf(mon, "kvm support: ");
-if (kvm_enabled())
-monitor_printf(mon, "enabled\n");
-else
-monitor_printf(mon, "disabled\n");
+if (qdict_get_bool(qdict, "present")) {
+monitor_printf(mon, "%s\n", qdict_get_bool(qdict, "enabled") ?
+"enabled" : "disabled");
+} else {
+monitor_printf(mon, "not compiled\n");
+}
+}
+
+/**
+ * do_info_kvm(): Show KVM information
+ *
+ * Return a QDict with the following information:
+ *
+ * - "enabled": true if KVM support is enabled, false otherwise
+ * - "present": true if QEMU has KVM support, false otherwise
+ *
+ * Example:
+ *
+ * { "enabled": true, "present": true }
+ */
+static void do_info_kvm(Monitor *mon, QObject **ret_data)
+{
+#ifdef CONFIG_KVM
+*ret_data = qobject_from_jsonf("{ 'enabled': %i, 'present': true }",
+   kvm_enabled());
 #else
-monitor_printf(mon, "kvm support: not compiled\n");
+*ret_data = qobject_from_jsonf("{ 'enabled': false, 'present': false }");
 #endif
 }
 
@@ -2346,7 +2370,8 @@ static const mon_cmd_t info_cmds[] = {
 .args_type  = "",
 .params = "",
 .help   = "show KVM information",
-.mhandler.info = do_info_kvm,
+.user_print = do_info_kvm_print,
+.mhandler.info_new = do_info_kvm,
 },
 {
 .name   = "numa",
-- 
1.6.6.rc1.39.g9a42





[Qemu-devel] [PATCH 10/19] monitor: Convert do_info_name() to QObject

2009-12-09 Thread Luiz Capitulino
Signed-off-by: Luiz Capitulino 
---
 monitor.c |   29 +
 1 files changed, 25 insertions(+), 4 deletions(-)

diff --git a/monitor.c b/monitor.c
index 47f794d..3d33bd8 100644
--- a/monitor.c
+++ b/monitor.c
@@ -514,10 +514,30 @@ static void do_info_version(Monitor *mon, QObject 
**ret_data)
QEMU_VERSION, QEMU_PKGVERSION);
 }
 
-static void do_info_name(Monitor *mon)
+static void do_info_name_print(Monitor *mon, const QObject *data)
 {
-if (qemu_name)
-monitor_printf(mon, "%s\n", qemu_name);
+const char *str;
+
+str = qdict_get_str(qobject_to_qdict(data), "name");
+if (strlen(str) > 0) {
+monitor_printf(mon, "%s\n", str);
+}
+}
+
+/**
+ * do_info_name(): Show VM name
+ *
+ * Return a QDict with the following information:
+ *
+ * - "name": VM's name. If the VM has no name, the string will be empty
+ *
+ * Example:
+ *
+ * { "name": "qemu-name" }
+ */
+static void do_info_name(Monitor *mon, QObject **ret_data)
+{
+*ret_data = qobject_from_jsonf("{'name': %s}", qemu_name ? qemu_name : "");
 }
 
 /**
@@ -2449,7 +2469,8 @@ static const mon_cmd_t info_cmds[] = {
 .args_type  = "",
 .params = "",
 .help   = "show the current VM name",
-.mhandler.info = do_info_name,
+.user_print = do_info_name_print,
+.mhandler.info_new = do_info_name,
 },
 {
 .name   = "uuid",
-- 
1.6.6.rc1.39.g9a42





[Qemu-devel] [PATCH 11/19] monitor: Convert do_info_hpet() to QObject

2009-12-09 Thread Luiz Capitulino
Signed-off-by: Luiz Capitulino 
---
 monitor.c |   24 +---
 1 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/monitor.c b/monitor.c
index 3d33bd8..72fd573 100644
--- a/monitor.c
+++ b/monitor.c
@@ -570,10 +570,27 @@ static void do_info_commands(Monitor *mon, QObject 
**ret_data)
 }
 
 #if defined(TARGET_I386)
-static void do_info_hpet(Monitor *mon)
+static void do_info_hpet_print(Monitor *mon, const QObject *data)
 {
 monitor_printf(mon, "HPET is %s by QEMU\n",
-   (no_hpet) ? "disabled" : "enabled");
+   qdict_get_bool(qobject_to_qdict(data), "enabled") ?
+   "enabled" : "disabled");
+}
+
+/**
+ * do_info_hpet(): Show HPET state
+ *
+ * Return a QDict with the following information:
+ *
+ * - "enabled": true if hpet if enabled, false otherwise
+ *
+ * Example:
+ *
+ * { "enabled": true }
+ */
+static void do_info_hpet(Monitor *mon, QObject **ret_data)
+{
+*ret_data = qobject_from_jsonf("{ 'enabled': %i }", !no_hpet);
 }
 #endif
 
@@ -2375,7 +2392,8 @@ static const mon_cmd_t info_cmds[] = {
 .args_type  = "",
 .params = "",
 .help   = "show state of HPET",
-.mhandler.info = do_info_hpet,
+.user_print = do_info_hpet_print,
+.mhandler.info_new = do_info_hpet,
 },
 #endif
 {
-- 
1.6.6.rc1.39.g9a42





[Qemu-devel] [PATCH 12/19] monitor: Convert do_info_uuid() to QObject

2009-12-09 Thread Luiz Capitulino
snprintf() is used because the UUID_FMT is too complex for
qobject_from_jsonf().

Signed-off-by: Luiz Capitulino 
---
 monitor.c |   26 +++---
 1 files changed, 23 insertions(+), 3 deletions(-)

diff --git a/monitor.c b/monitor.c
index 72fd573..f0cb759 100644
--- a/monitor.c
+++ b/monitor.c
@@ -594,13 +594,32 @@ static void do_info_hpet(Monitor *mon, QObject **ret_data)
 }
 #endif
 
-static void do_info_uuid(Monitor *mon)
+static void do_info_uuid_print(Monitor *mon, const QObject *data)
 {
-monitor_printf(mon, UUID_FMT "\n", qemu_uuid[0], qemu_uuid[1],
+monitor_printf(mon, "%s\n", qdict_get_str(qobject_to_qdict(data), "UUID"));
+}
+
+/**
+ * do_info_uuid(): Show VM UUID
+ *
+ * Return a QDict with the following information:
+ *
+ * - "UUID": Universally Unique Identifier
+ *
+ * Example:
+ *
+ * { "UUID": "550e8400-e29b-41d4-a716-44665544" }
+ */
+static void do_info_uuid(Monitor *mon, QObject **ret_data)
+{
+char uuid[64];
+
+snprintf(uuid, sizeof(uuid), UUID_FMT, qemu_uuid[0], qemu_uuid[1],
qemu_uuid[2], qemu_uuid[3], qemu_uuid[4], qemu_uuid[5],
qemu_uuid[6], qemu_uuid[7], qemu_uuid[8], qemu_uuid[9],
qemu_uuid[10], qemu_uuid[11], qemu_uuid[12], qemu_uuid[13],
qemu_uuid[14], qemu_uuid[15]);
+*ret_data = qobject_from_jsonf("{ 'UUID': %s }", uuid);
 }
 
 /* get the current CPU defined by the user */
@@ -2495,7 +2514,8 @@ static const mon_cmd_t info_cmds[] = {
 .args_type  = "",
 .params = "",
 .help   = "show the current VM UUID",
-.mhandler.info = do_info_uuid,
+.user_print = do_info_uuid_print,
+.mhandler.info_new = do_info_uuid,
 },
 #if defined(TARGET_PPC)
 {
-- 
1.6.6.rc1.39.g9a42





[Qemu-devel] [PATCH 13/19] monitor: Convert do_info_mice() to QObject

2009-12-09 Thread Luiz Capitulino
Each mouse is represented by a QDict, the returned QObject is a QList of
all mice.

This commit should not change user output.

Signed-off-by: Luiz Capitulino 
---
 console.h |3 +-
 monitor.c |3 +-
 vl.c  |   62 ++--
 3 files changed, 59 insertions(+), 9 deletions(-)

diff --git a/console.h b/console.h
index 9615f56..c7172f6 100644
--- a/console.h
+++ b/console.h
@@ -44,7 +44,8 @@ struct MouseTransformInfo {
 int a[7];
 };
 
-void do_info_mice(Monitor *mon);
+void do_info_mice_print(Monitor *mon, const QObject *data);
+void do_info_mice(Monitor *mon, QObject **ret_data);
 void do_mouse_set(Monitor *mon, const QDict *qdict);
 
 /* keysym is a unicode code except for special keys (see QEMU_KEY_xxx
diff --git a/monitor.c b/monitor.c
index f0cb759..d5e8dda 100644
--- a/monitor.c
+++ b/monitor.c
@@ -2492,7 +2492,8 @@ static const mon_cmd_t info_cmds[] = {
 .args_type  = "",
 .params = "",
 .help   = "show which guest mouse is receiving events",
-.mhandler.info = do_info_mice,
+.user_print = do_info_mice_print,
+.mhandler.info_new = do_info_mice,
 },
 {
 .name   = "vnc",
diff --git a/vl.c b/vl.c
index 09a0ec5..73737ee 100644
--- a/vl.c
+++ b/vl.c
@@ -156,6 +156,7 @@ int main(int argc, char **argv)
 #include "balloon.h"
 #include "qemu-option.h"
 #include "qemu-config.h"
+#include "qemu-objects.h"
 
 #include "disas.h"
 
@@ -458,25 +459,72 @@ int kbd_mouse_is_absolute(void)
 return qemu_put_mouse_event_current->qemu_put_mouse_event_absolute;
 }
 
-void do_info_mice(Monitor *mon)
+static void info_mice_iter(QObject *data, void *opaque)
+{
+QDict *mouse;
+Monitor *mon = opaque;
+
+mouse = qobject_to_qdict(data);
+monitor_printf(mon, "%c Mouse #%" PRId64 ": %s\n",
+  (qdict_get_bool(mouse, "current") ? '*' : ' '),
+  qdict_get_int(mouse, "index"), qdict_get_str(mouse, "name"));
+}
+
+void do_info_mice_print(Monitor *mon, const QObject *data)
+{
+QList *mice_list;
+
+mice_list = qobject_to_qlist(data);
+if (qlist_empty(mice_list)) {
+monitor_printf(mon, "No mouse devices connected\n");
+return;
+}
+
+qlist_iter(mice_list, info_mice_iter, mon);
+}
+
+/**
+ * do_info_mice(): Show VM mice information
+ *
+ * Each mouse is represented by a QDict, the returned QObject is a QList of
+ * all mice.
+ *
+ * The mouse QDict contains the following:
+ *
+ * - "name": mouse's name
+ * - "index": mouse's index
+ * - "current": true if this mouse is receiving events, false otherwise
+ *
+ * Example:
+ *
+ * [ { "name": "QEMU Microsoft Mouse", "index": 0, "current": false },
+ *   { "name": "QEMU PS/2 Mouse", "index": 1, "current": true } ]
+ */
+void do_info_mice(Monitor *mon, QObject **ret_data)
 {
 QEMUPutMouseEntry *cursor;
+QList *mice_list;
 int index = 0;
 
+mice_list = qlist_new();
+
 if (!qemu_put_mouse_event_head) {
-monitor_printf(mon, "No mouse devices connected\n");
-return;
+goto out;
 }
 
-monitor_printf(mon, "Mouse devices available:\n");
 cursor = qemu_put_mouse_event_head;
 while (cursor != NULL) {
-monitor_printf(mon, "%c Mouse #%d: %s\n",
-   (cursor == qemu_put_mouse_event_current ? '*' : ' '),
-   index, cursor->qemu_put_mouse_event_name);
+QObject *obj;
+obj = qobject_from_jsonf("{ 'name': %s, 'index': %d, 'current': %i }",
+ cursor->qemu_put_mouse_event_name,
+ index, cursor == 
qemu_put_mouse_event_current);
+qlist_append_obj(mice_list, obj);
 index++;
 cursor = cursor->next;
 }
+
+out:
+*ret_data = QOBJECT(mice_list);
 }
 
 void do_mouse_set(Monitor *mon, const QDict *qdict)
-- 
1.6.6.rc1.39.g9a42





[Qemu-devel] [PATCH 14/19] migration: Convert do_info_migrate() to QObject

2009-12-09 Thread Luiz Capitulino
Return a QDict, which may contain more two QDicts, depending on
the type of migration we're performing.

IMPORTANT: as a QInt stores a int64_t integer, RAM values are going
to be stored as int64_t and not as uint64_t as they are today. If
this is a problem QInt will have to be changed.

This commit should not change user output.

Signed-off-by: Luiz Capitulino 
---
 migration.c |  117 +++
 migration.h |4 ++-
 monitor.c   |3 +-
 3 files changed, 107 insertions(+), 17 deletions(-)

diff --git a/migration.c b/migration.c
index d6a3e26..44e37e2 100644
--- a/migration.c
+++ b/migration.c
@@ -19,6 +19,7 @@
 #include "block.h"
 #include "qemu_socket.h"
 #include "block-migration.h"
+#include "qemu-objects.h"
 
 //#define DEBUG_MIGRATION
 
@@ -163,37 +164,123 @@ void do_migrate_set_downtime(Monitor *mon, const QDict 
*qdict)
 max_downtime = (uint64_t)d;
 }
 
-void do_info_migrate(Monitor *mon)
+static void migrate_print_status(Monitor *mon, const char *name,
+ const QDict *status_dict)
 {
+QDict *qdict;
+
+qdict = qobject_to_qdict(qdict_get(status_dict, name));
+
+monitor_printf(mon, "transferred %s: %" PRIu64 " kbytes\n", name,
+qdict_get_int(qdict, "transferred") >> 10);
+monitor_printf(mon, "remaining %s: %" PRIu64 " kbytes\n", name,
+qdict_get_int(qdict, "remaining") >> 10);
+monitor_printf(mon, "total %s: %" PRIu64 " kbytes\n", name,
+qdict_get_int(qdict, "total") >> 10);
+}
+
+void do_info_migrate_print(Monitor *mon, const QObject *data)
+{
+QDict *qdict;
+
+qdict = qobject_to_qdict(data);
+
+monitor_printf(mon, "Migration status: %s\n",
+   qdict_get_str(qdict, "status"));
+
+if (qdict_haskey(qdict, "ram")) {
+migrate_print_status(mon, "ram", qdict);
+}
+
+if (qdict_haskey(qdict, "disk")) {
+migrate_print_status(mon, "disk", qdict);
+}
+}
+
+static void migrate_put_status(QDict *qdict, const char *name,
+   uint64_t trans, uint64_t rem, uint64_t total)
+{
+QObject *obj;
+
+obj = qobject_from_jsonf("{ 'transferred': %" PRId64 ", "
+   "'remaining': %" PRId64 ", "
+   "'total': %" PRId64 " }", trans, rem, total);
+assert(obj != NULL);
+
+qdict_put_obj(qdict, name, obj);
+}
+
+/**
+ * do_info_migrate(): Migration status
+ *
+ * Return a QDict. If migration is active there will be another
+ * QDict with RAM migration status and if block migration is active
+ * another one with block migration status.
+ *
+ * The main QDict contains the following:
+ *
+ * - "status": migration status
+ * - "ram": only present if "status" is "active", it is a QDict with the
+ *   following RAM information (in bytes):
+ *  - "transferred": amount transferred
+ *  - "remaining": amount remaining
+ *  - "total": total
+ * - "disk": only present if it is a block migration, it is a QDict with
+ *   the following disk information (in bytes):
+ *  - "transferred": amount transferred
+ *  - "remaining": amount remaining
+ *  - "total": total
+ *
+ * Examples:
+ *
+ * 1. Migration is "completed":
+ *
+ * { "status": "completed" }
+ *
+ * 2. Migration is "active" and it is not a block migration:
+ *
+ * { "status": "active",
+ *"ram": { "transferred": 123, "remaining": 123, "total": 246 } }
+ *
+ * 3. Migration is "active" and it is a block migration:
+ *
+ * { "status": "active",
+ *   "ram": { "total": 1057024, "remaining": 1053304, "transferred": 3720 },
+ *   "disk": { "total": 20971520, "remaining": 20880384, "transferred": 91136 
}}
+ */
+void do_info_migrate(Monitor *mon, QObject **ret_data)
+{
+QDict *qdict;
 MigrationState *s = current_migration;
 
 if (s) {
-monitor_printf(mon, "Migration status: ");
 switch (s->get_status(s)) {
 case MIG_STATE_ACTIVE:
-monitor_printf(mon, "active\n");
-monitor_printf(mon, "transferred ram: %" PRIu64 " kbytes\n", 
ram_bytes_transferred() >> 10);
-monitor_printf(mon, "remaining ram: %" PRIu64 " kbytes\n", 
ram_bytes_remaining() >> 10);
-monitor_printf(mon, "total ram: %" PRIu64 " kbytes\n", 
ram_bytes_total() >> 10);
+qdict = qdict_new();
+qdict_put(qdict, "status", qstring_from_str("active"));
+
+migrate_put_status(qdict, "ram", ram_bytes_transferred(),
+   ram_bytes_remaining(), ram_bytes_total());
+
 if (blk_mig_active()) {
-monitor_printf(mon, "transferred disk: %" PRIu64 " kbytes\n",
-   blk_mig_bytes_transferred() >> 10);
-monitor_printf(mon, "remaining disk: %" PRIu64 " kbytes\n",
-   blk_mig_bytes_remaining() >> 10);
-monitor_

[Qemu-devel] [PATCH 15/19] block: Convert bdrv_info() to QObject

2009-12-09 Thread Luiz Capitulino
Each block device information is stored in a QDict and the
returned QObject is a QList of all devices.

This commit should not change user output.

Signed-off-by: Luiz Capitulino 
---
 Makefile  |6 +-
 block.c   |  123 +++--
 block.h   |4 +-
 monitor.c |3 +-
 4 files changed, 111 insertions(+), 25 deletions(-)

diff --git a/Makefile b/Makefile
index f1b0131..a662d96 100644
--- a/Makefile
+++ b/Makefile
@@ -235,11 +235,11 @@ libqemu_common.a: $(obj-y)
 
 qemu-img.o: qemu-img-cmds.h
 
-qemu-img$(EXESUF): qemu-img.o qemu-tool.o $(block-obj-y)
+qemu-img$(EXESUF): qemu-img.o qemu-tool.o $(block-obj-y) $(qobject-obj-y)
 
-qemu-nbd$(EXESUF):  qemu-nbd.o qemu-tool.o $(block-obj-y)
+qemu-nbd$(EXESUF):  qemu-nbd.o qemu-tool.o $(block-obj-y) $(qobject-obj-y)
 
-qemu-io$(EXESUF):  qemu-io.o qemu-tool.o cmd.o $(block-obj-y)
+qemu-io$(EXESUF):  qemu-io.o qemu-tool.o cmd.o $(block-obj-y) $(qobject-obj-y)
 
 qemu-img-cmds.h: $(SRC_PATH)/qemu-img-cmds.hx
$(call quiet-command,sh $(SRC_PATH)/hxtool -h < $< > $@,"  GEN   $@")
diff --git a/block.c b/block.c
index 853f025..d7eccb7 100644
--- a/block.c
+++ b/block.c
@@ -26,6 +26,7 @@
 #include "monitor.h"
 #include "block_int.h"
 #include "module.h"
+#include "qemu-objects.h"
 
 #ifdef CONFIG_BSD
 #include 
@@ -1139,43 +1140,125 @@ int bdrv_is_allocated(BlockDriverState *bs, int64_t 
sector_num, int nb_sectors,
 return bs->drv->bdrv_is_allocated(bs, sector_num, nb_sectors, pnum);
 }
 
-void bdrv_info(Monitor *mon)
+static void bdrv_print_dict(QObject *obj, void *opaque)
 {
+QDict *bs_dict;
+Monitor *mon = opaque;
+
+bs_dict = qobject_to_qdict(obj);
+
+monitor_printf(mon, "%s: type=%s removable=%d",
+qdict_get_str(bs_dict, "device"),
+qdict_get_str(bs_dict, "type"),
+qdict_get_bool(bs_dict, "removable"));
+
+if (qdict_get_bool(bs_dict, "removable")) {
+monitor_printf(mon, " locked=%d", qdict_get_bool(bs_dict, "locked"));
+}
+
+if (qdict_haskey(bs_dict, "inserted")) {
+QDict *qdict = qobject_to_qdict(qdict_get(bs_dict, "inserted"));
+
+monitor_printf(mon, " file=");
+monitor_print_filename(mon, qdict_get_str(qdict, "file"));
+if (qdict_haskey(qdict, "backing_file")) {
+monitor_printf(mon, " backing_file=");
+monitor_print_filename(mon, qdict_get_str(qdict, "backing_file"));
+}
+monitor_printf(mon, " ro=%d drv=%s encrypted=%d",
+qdict_get_bool(qdict, "ro"),
+qdict_get_str(qdict, "drv"),
+qdict_get_bool(qdict, "encrypted"));
+} else {
+monitor_printf(mon, " [not inserted]");
+}
+
+monitor_printf(mon, "\n");
+}
+
+void bdrv_info_print(Monitor *mon, const QObject *data)
+{
+qlist_iter(qobject_to_qlist(data), bdrv_print_dict, mon);
+}
+
+/**
+ * bdrv_info(): Block devices information
+ *
+ * Each block device information is stored in a QDict and the
+ * returned QObject is a QList of all devices.
+ *
+ * The QDict contains the following:
+ *
+ * - "device": device name
+ * - "type": device type
+ * - "removable": true if the device is removable, false otherwise
+ * - "locked": true if the device is locked, false otherwise
+ * - "inserted": only present if the device is inserted, it is a QDict
+ *containing the following:
+ *  - "file": device file name
+ *  - "ro": true if read-only, false otherwise
+ *  - "drv": driver format name
+ *  - "backing_file": backing file name if one is used
+ *  - "encrypted": true if encrypted, false otherwise
+ *
+ * Example:
+ *
+ * [ { "device": "ide0-hd0", "type": "hd", "removable": false, "locked": false,
+ * "inserted": { "file": "/tmp/foobar", "ro": false, "drv": "qcow2" } },
+ *   { "device": "floppy0", "type": "floppy", "removable": true,
+ * "locked": false } ]
+ */
+void bdrv_info(Monitor *mon, QObject **ret_data)
+{
+QList *bs_list;
 BlockDriverState *bs;
 
+bs_list = qlist_new();
+
 for (bs = bdrv_first; bs != NULL; bs = bs->next) {
-monitor_printf(mon, "%s:", bs->device_name);
-monitor_printf(mon, " type=");
+QObject *bs_obj;
+const char *type = "unknown";
+
 switch(bs->type) {
 case BDRV_TYPE_HD:
-monitor_printf(mon, "hd");
+type = "hd";
 break;
 case BDRV_TYPE_CDROM:
-monitor_printf(mon, "cdrom");
+type = "cdrom";
 break;
 case BDRV_TYPE_FLOPPY:
-monitor_printf(mon, "floppy");
+type = "floppy";
 break;
 }
-monitor_printf(mon, " removable=%d", bs->removable);
-if (bs->removable) {
-monitor_printf(mon, " locked=%d", bs->locked);
-}
+
+bs_obj = qobject_from_jsonf("{ 'device': %s, 'type': %s, "
+

[Qemu-devel] [PATCH 16/19] block: Convert bdrv_info_stats() to QObject

2009-12-09 Thread Luiz Capitulino
Each device statistic information is stored in a QDict and
the returned QObject is a QList of all devices.

This commit should not change user output.

Signed-off-by: Luiz Capitulino 
---
 block.c   |   82 
 block.h   |3 +-
 monitor.c |3 +-
 3 files changed, 75 insertions(+), 13 deletions(-)

diff --git a/block.c b/block.c
index d7eccb7..3f3496e 100644
--- a/block.c
+++ b/block.c
@@ -1261,22 +1261,82 @@ void bdrv_info(Monitor *mon, QObject **ret_data)
 *ret_data = QOBJECT(bs_list);
 }
 
-/* The "info blockstats" command. */
-void bdrv_info_stats(Monitor *mon)
+static void bdrv_stats_iter(QObject *data, void *opaque)
 {
+QDict *qdict;
+Monitor *mon = opaque;
+
+qdict = qobject_to_qdict(data);
+monitor_printf(mon, "%s:", qdict_get_str(qdict, "device"));
+
+qdict = qobject_to_qdict(qdict_get(qdict, "stats"));
+monitor_printf(mon, " rd_bytes=%" PRId64
+" wr_bytes=%" PRId64
+" rd_operations=%" PRId64
+" wr_operations=%" PRId64
+"\n",
+qdict_get_int(qdict, "rd_bytes"),
+qdict_get_int(qdict, "wr_bytes"),
+qdict_get_int(qdict, "rd_operations"),
+qdict_get_int(qdict, "wr_operations"));
+}
+
+void bdrv_stats_print(Monitor *mon, const QObject *data)
+{
+qlist_iter(qobject_to_qlist(data), bdrv_stats_iter, mon);
+}
+
+/**
+ * bdrv_info_stats(): show block device statistics
+ *
+ * Each device statistic information is stored in a QDict and
+ * the returned QObject is a QList of all devices.
+ *
+ * The QDict contains the following:
+ *
+ * - "device": device name
+ * - "stats": A QDict with the statistics information, it contains:
+ * - "rd_bytes": bytes read
+ * - "wr_bytes": bytes written
+ * - "rd_operations": read operations
+ * - "wr_operations": write operations
+ * 
+ * Example:
+ *
+ * [ { "device": "ide0-hd0",
+ *   "stats": { "rd_bytes": 512,
+ *  "wr_bytes": 0,
+ *  "rd_operations": 1,
+ *  "wr_operations": 0 } },
+ *   { "device": "ide1-cd0",
+ *   "stats": { "rd_bytes": 0,
+ *  "wr_bytes": 0,
+ *  "rd_operations": 0,
+ *  "wr_operations": 0 } } ]
+ */
+void bdrv_info_stats(Monitor *mon, QObject **ret_data)
+{
+QObject *obj;
+QList *devices;
 BlockDriverState *bs;
 
+devices = qlist_new();
+
 for (bs = bdrv_first; bs != NULL; bs = bs->next) {
-monitor_printf(mon, "%s:"
-   " rd_bytes=%" PRIu64
-   " wr_bytes=%" PRIu64
-   " rd_operations=%" PRIu64
-   " wr_operations=%" PRIu64
-   "\n",
-   bs->device_name,
-   bs->rd_bytes, bs->wr_bytes,
-   bs->rd_ops, bs->wr_ops);
-}
+obj = qobject_from_jsonf("{ 'device': %s, 'stats': {"
+ "'rd_bytes': %" PRId64 ","
+ "'wr_bytes': %" PRId64 ","
+ "'rd_operations': %" PRId64 ","
+ "'wr_operations': %" PRId64
+ "} }",
+ bs->device_name,
+ bs->rd_bytes, bs->wr_bytes,
+ bs->rd_ops, bs->wr_ops);
+assert(obj != NULL);
+qlist_append_obj(devices, obj);
+}
+
+*ret_data = QOBJECT(devices);
 }
 
 const char *bdrv_get_encrypted_filename(BlockDriverState *bs)
diff --git a/block.h b/block.h
index 3282dd2..fa51ddf 100644
--- a/block.h
+++ b/block.h
@@ -48,7 +48,8 @@ typedef struct QEMUSnapshotInfo {
 
 void bdrv_info_print(Monitor *mon, const QObject *data);
 void bdrv_info(Monitor *mon, QObject **ret_data);
-void bdrv_info_stats(Monitor *mon);
+void bdrv_stats_print(Monitor *mon, const QObject *data);
+void bdrv_info_stats(Monitor *mon, QObject **ret_data);
 
 void bdrv_init(void);
 void bdrv_init_with_whitelist(void);
diff --git a/monitor.c b/monitor.c
index db596a9..e63a262 100644
--- a/monitor.c
+++ b/monitor.c
@@ -2345,7 +2345,8 @@ static const mon_cmd_t info_cmds[] = {
 .args_type  = "",
 .params = "",
 .help   = "show block device statistics",
-.mhandler.info = bdrv_info_stats,
+.user_print = bdrv_stats_print,
+.mhandler.info_new = bdrv_info_stats,
 },
 {
 .name   = "registers",
-- 
1.6.6.rc1.39.g9a42





[Qemu-devel] [PATCH 17/19] char: Convert qemu_chr_info() to QObject

2009-12-09 Thread Luiz Capitulino
Each device is represented by a QDict. The returned QObject is a QList
of all devices.

This commit should not change user output.

Signed-off-by: Luiz Capitulino 
---
 monitor.c   |3 ++-
 qemu-char.c |   43 +--
 qemu-char.h |4 +++-
 3 files changed, 46 insertions(+), 4 deletions(-)

diff --git a/monitor.c b/monitor.c
index e63a262..b2d0384 100644
--- a/monitor.c
+++ b/monitor.c
@@ -2330,7 +2330,8 @@ static const mon_cmd_t info_cmds[] = {
 .args_type  = "",
 .params = "",
 .help   = "show the character devices",
-.mhandler.info = qemu_chr_info,
+.user_print = qemu_chr_info_print,
+.mhandler.info_new = qemu_chr_info,
 },
 {
 .name   = "block",
diff --git a/qemu-char.c b/qemu-char.c
index da5c15c..c0d1cb0 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -32,6 +32,7 @@
 #include "hw/usb.h"
 #include "hw/baum.h"
 #include "hw/msmouse.h"
+#include "qemu-objects.h"
 
 #include 
 #include 
@@ -2469,13 +2470,51 @@ void qemu_chr_close(CharDriverState *chr)
 qemu_free(chr);
 }
 
-void qemu_chr_info(Monitor *mon)
+static void qemu_chr_qlist_iter(QObject *obj, void *opaque)
 {
+QDict *chr_dict;
+Monitor *mon = opaque;
+
+chr_dict = qobject_to_qdict(obj);
+monitor_printf(mon, "%s: filename=%s\n", qdict_get_str(chr_dict, "label"),
+ qdict_get_str(chr_dict, "filename"));
+}
+
+void qemu_chr_info_print(Monitor *mon, const QObject *ret_data)
+{
+qlist_iter(qobject_to_qlist(ret_data), qemu_chr_qlist_iter, mon);
+}
+
+/**
+ * qemu_chr_info(): Character devices information
+ *
+ * Each device is represented by a QDict. The returned QObject is a QList
+ * of all devices.
+ *
+ * The QDict contains the following:
+ *
+ * - "label": device's label
+ * - "filename": device's file
+ *
+ * Example:
+ *
+ * [ { "label": "monitor", "filename", "stdio" },
+ *   { "label": "serial0", "filename": "vc" } ]
+ */
+void qemu_chr_info(Monitor *mon, QObject **ret_data)
+{
+QList *chr_list;
 CharDriverState *chr;
 
+chr_list = qlist_new();
+
 QTAILQ_FOREACH(chr, &chardevs, next) {
-monitor_printf(mon, "%s: filename=%s\n", chr->label, chr->filename);
+QObject *obj = qobject_from_jsonf("{ 'label': %s, 'filename': %s }",
+  chr->label, chr->filename);
+qlist_append_obj(chr_list, obj);
 }
+
+*ret_data = QOBJECT(chr_list);
 }
 
 CharDriverState *qemu_chr_find(const char *name)
diff --git a/qemu-char.h b/qemu-char.h
index 9957db1..48f54d8 100644
--- a/qemu-char.h
+++ b/qemu-char.h
@@ -5,6 +5,7 @@
 #include "qemu-queue.h"
 #include "qemu-option.h"
 #include "qemu-config.h"
+#include "qobject.h"
 
 /* character device */
 
@@ -87,7 +88,8 @@ int qemu_chr_can_read(CharDriverState *s);
 void qemu_chr_read(CharDriverState *s, uint8_t *buf, int len);
 int qemu_chr_get_msgfd(CharDriverState *s);
 void qemu_chr_accept_input(CharDriverState *s);
-void qemu_chr_info(Monitor *mon);
+void qemu_chr_info_print(Monitor *mon, const QObject *ret_data);
+void qemu_chr_info(Monitor *mon, QObject **ret_data);
 CharDriverState *qemu_chr_find(const char *name);
 
 extern int term_escape_char;
-- 
1.6.6.rc1.39.g9a42





[Qemu-devel] [PATCH 18/19] PCI: Convert pci_device_hot_add() to QObject

2009-12-09 Thread Luiz Capitulino
Return a QDict with information about the just added device.

This commit should not change user output.

Please, note that this patch does not do error handling
conversion. In error conditions the handler still calls
monitor_printf().

Signed-off-by: Luiz Capitulino 
---
 hw/pci-hotplug.c |   40 
 qemu-monitor.hx  |3 ++-
 sysemu.h |3 ++-
 3 files changed, 40 insertions(+), 6 deletions(-)

diff --git a/hw/pci-hotplug.c b/hw/pci-hotplug.c
index 081d6d1..455fedd 100644
--- a/hw/pci-hotplug.c
+++ b/hw/pci-hotplug.c
@@ -33,6 +33,7 @@
 #include "scsi.h"
 #include "virtio-blk.h"
 #include "qemu-config.h"
+#include "qemu-objects.h"
 
 #if defined(TARGET_I386)
 static PCIDevice *qemu_pci_hot_add_nic(Monitor *mon,
@@ -212,7 +213,36 @@ static PCIDevice *qemu_pci_hot_add_storage(Monitor *mon,
 return dev;
 }
 
-void pci_device_hot_add(Monitor *mon, const QDict *qdict)
+void pci_device_hot_add_print(Monitor *mon, const QObject *data)
+{
+QDict *qdict;
+
+assert(qobject_type(data) == QTYPE_QDICT);
+qdict = qobject_to_qdict(data);
+
+monitor_printf(mon, "OK domain %d, bus %d, slot %d, function %d\n",
+   (int) qdict_get_int(qdict, "domain"),
+   (int) qdict_get_int(qdict, "bus"),
+   (int) qdict_get_int(qdict, "slot"),
+   (int) qdict_get_int(qdict, "function"));
+
+}
+
+/**
+ * pci_device_hot_add(): Hot add a PCI device
+ *
+ * Return a QDict with the following device information:
+ *
+ * - "domain": domain number
+ * - "bus": bus number
+ * - "slot": slot number
+ * - "function": function number
+ *
+ * Example:
+ *
+ * { "domain": 0, "bus": 0, "slot": 5, "function": 0 }
+ */
+void pci_device_hot_add(Monitor *mon, const QDict *qdict, QObject **ret_data)
 {
 PCIDevice *dev = NULL;
 const char *pci_addr = qdict_get_str(qdict, "pci_addr");
@@ -239,9 +269,11 @@ void pci_device_hot_add(Monitor *mon, const QDict *qdict)
 monitor_printf(mon, "invalid type: %s\n", type);
 
 if (dev) {
-monitor_printf(mon, "OK domain %d, bus %d, slot %d, function %d\n",
-   0, pci_bus_num(dev->bus), PCI_SLOT(dev->devfn),
-   PCI_FUNC(dev->devfn));
+*ret_data =
+qobject_from_jsonf("{ 'domain': 0, 'bus': %d, 'slot': %d, "
+   "'function': %d }", pci_bus_num(dev->bus),
+   PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn));
+assert(*ret_data != NULL);
 } else
 monitor_printf(mon, "failed to add %s\n", opts);
 }
diff --git a/qemu-monitor.hx b/qemu-monitor.hx
index 0657b2d..c788c73 100644
--- a/qemu-monitor.hx
+++ b/qemu-monitor.hx
@@ -810,7 +810,8 @@ ETEXI
 .args_type  = "pci_addr:s,type:s,opts:s?",
 .params = "auto|[[:]:] nic|storage 
[[vlan=n][,macaddr=addr][,model=type]] [file=file][,if=type][,bus=nr]...",
 .help   = "hot-add PCI device",
-.mhandler.cmd = pci_device_hot_add,
+.user_print = pci_device_hot_add_print,
+.mhandler.cmd_new = pci_device_hot_add,
 },
 #endif
 
diff --git a/sysemu.h b/sysemu.h
index efed771..9d80bb2 100644
--- a/sysemu.h
+++ b/sysemu.h
@@ -212,7 +212,8 @@ extern DriveInfo *drive_init(QemuOpts *arg, void *machine, 
int *fatal_error);
 DriveInfo *add_init_drive(const char *opts);
 
 /* pci-hotplug */
-void pci_device_hot_add(Monitor *mon, const QDict *qdict);
+void pci_device_hot_add_print(Monitor *mon, const QObject *data);
+void pci_device_hot_add(Monitor *mon, const QDict *qdict, QObject **ret_data);
 void drive_hot_add(Monitor *mon, const QDict *qdict);
 void pci_device_hot_remove(Monitor *mon, const char *pci_addr);
 void do_pci_device_hot_remove(Monitor *mon, const QDict *qdict,
-- 
1.6.6.rc1.39.g9a42





[Qemu-devel] [PATCH 19/19] VNC: Convert do_info_vnc() to QObject

2009-12-09 Thread Luiz Capitulino
Return a QDict with server information. Connected clients are returned
as a QList of QDicts.

The new functions (vnc_qdict_remote_addr(), vnc_qdict_local_addr() and
put_addr_qdict()) are used to insert 'host' and 'service' information
in the returned QDict.

This patch is big, but I don't see how to split it.

Signed-off-by: Luiz Capitulino 
---
 console.h |3 +-
 monitor.c |3 +-
 vnc.c |  191 +++--
 3 files changed, 164 insertions(+), 33 deletions(-)

diff --git a/console.h b/console.h
index c7172f6..dfc8ae4 100644
--- a/console.h
+++ b/console.h
@@ -323,7 +323,8 @@ void vnc_display_init(DisplayState *ds);
 void vnc_display_close(DisplayState *ds);
 int vnc_display_open(DisplayState *ds, const char *display);
 int vnc_display_password(DisplayState *ds, const char *password);
-void do_info_vnc(Monitor *mon);
+void do_info_vnc_print(Monitor *mon, const QObject *data);
+void do_info_vnc(Monitor *mon, QObject **ret_data);
 char *vnc_display_local_addr(DisplayState *ds);
 
 /* curses.c */
diff --git a/monitor.c b/monitor.c
index b2d0384..ddf9eac 100644
--- a/monitor.c
+++ b/monitor.c
@@ -2503,7 +2503,8 @@ static const mon_cmd_t info_cmds[] = {
 .args_type  = "",
 .params = "",
 .help   = "show the vnc server status",
-.mhandler.info = do_info_vnc,
+.user_print = do_info_vnc_print,
+.mhandler.info_new = do_info_vnc,
 },
 {
 .name   = "name",
diff --git a/vnc.c b/vnc.c
index 32c4678..f0fea6a 100644
--- a/vnc.c
+++ b/vnc.c
@@ -29,6 +29,7 @@
 #include "qemu_socket.h"
 #include "qemu-timer.h"
 #include "acl.h"
+#include "qemu-objects.h"
 
 #define VNC_REFRESH_INTERVAL_BASE 30
 #define VNC_REFRESH_INTERVAL_INC  50
@@ -99,6 +100,52 @@ char *vnc_socket_remote_addr(const char *format, int fd) {
 return addr_to_string(format, &sa, salen);
 }
 
+static int put_addr_qdict(QDict *qdict, struct sockaddr_storage *sa,
+  socklen_t salen)
+{
+char host[NI_MAXHOST];
+char serv[NI_MAXSERV];
+int err;
+
+if ((err = getnameinfo((struct sockaddr *)sa, salen,
+   host, sizeof(host),
+   serv, sizeof(serv),
+   NI_NUMERICHOST | NI_NUMERICSERV)) != 0) {
+VNC_DEBUG("Cannot resolve address %d: %s\n",
+  err, gai_strerror(err));
+return -1;
+}
+
+qdict_put(qdict, "host", qstring_from_str(host));
+qdict_put(qdict, "service", qstring_from_str(serv));
+
+return 0;
+}
+
+static int vnc_qdict_local_addr(QDict *qdict, int fd)
+{
+struct sockaddr_storage sa;
+socklen_t salen;
+
+salen = sizeof(sa);
+if (getsockname(fd, (struct sockaddr*)&sa, &salen) < 0)
+return -1;
+
+return put_addr_qdict(qdict, &sa, salen);
+}
+
+static int vnc_qdict_remote_addr(QDict *qdict, int fd)
+{
+struct sockaddr_storage sa;
+socklen_t salen;
+
+salen = sizeof(sa);
+if (getpeername(fd, (struct sockaddr*)&sa, &salen) < 0)
+return -1;
+
+return put_addr_qdict(qdict, &sa, salen);
+}
+
 static const char *vnc_auth_name(VncDisplay *vd) {
 switch (vd->auth) {
 case VNC_AUTH_INVALID:
@@ -150,58 +197,140 @@ static const char *vnc_auth_name(VncDisplay *vd) {
 return "unknown";
 }
 
-static void do_info_vnc_client(Monitor *mon, VncState *client)
+static QDict *do_info_vnc_client(Monitor *mon, VncState *client)
 {
-char *clientAddr =
-vnc_socket_remote_addr(" address: %s:%s\n",
-   client->csock);
-if (!clientAddr)
-return;
+QDict *qdict;
 
-monitor_printf(mon, "Client:\n");
-monitor_printf(mon, "%s", clientAddr);
-free(clientAddr);
+qdict = qdict_new();
+if (vnc_qdict_remote_addr(qdict, client->csock) < 0) {
+QDECREF(qdict);
+return NULL;
+}
 
 #ifdef CONFIG_VNC_TLS
 if (client->tls.session &&
-client->tls.dname)
-monitor_printf(mon, "  x509 dname: %s\n", client->tls.dname);
-else
-monitor_printf(mon, "  x509 dname: none\n");
+client->tls.dname) {
+qdict_put(qdict, "x509 dname", qstring_from_str(client->tls.dname));
+}
 #endif
 #ifdef CONFIG_VNC_SASL
 if (client->sasl.conn &&
-client->sasl.username)
-monitor_printf(mon, "username: %s\n", client->sasl.username);
-else
-monitor_printf(mon, "username: none\n");
+client->sasl.username) {
+qdict_put(qdict, "username", qstring_from_str(client->sasl.username));
+}
 #endif
+
+return qdict;
 }
 
-void do_info_vnc(Monitor *mon)
+static void info_vnc_iter(QObject *obj, void *opaque)
 {
-if (vnc_display == NULL || vnc_display->display == NULL) {
+QDict *client;
+Monitor *mon = opaque;
+
+client = qobject_to_qdict(obj);
+monitor_printf(mon, "Client:\n");
+monitor_printf(mon, " address: %s:%s\n",
+   qdict_get_str(clie

Re: [Qemu-devel] [ANNOUNCE][Call-For-Testing] Release 0.12.0-rc1 of QEMU

2009-12-09 Thread Daniel P. Berrange
On Sun, Dec 06, 2009 at 04:43:03PM -0600, Anthony Liguori wrote:
> The QEMU team is pleased to announce the availability of the 0.12.0-rc1
> release.  This is the first release candidate for the 0.12.0 release. 
> This release is not intended for production use.
> 
> Testing release candidates is a great way to contribute to QEMU and 
> improve the quality of the 0.12.0 release.
> 
> The current plan is to release a 0.12.0-rc2 on Friday, Dec. 11th 
> followed by the final 0.12.0 release on Wednesday, Dec 15th.
> 
> For this release candidate, we would appreciate as much testing and 
> feedback as possible, particularly the following features which have 
> seen a lot of activity since the 0.11.0 release:
> 
>  - live migration; especially with non-x86 and complex machine 
> configurations
>  - block device migration
>  - exotic x86 guests that may interact with the BIOS in special ways
>  - PXE booting
>  - SCSI disk support
>  - any tools that depend on parsing monitor output

There's a small bug in SCSI drive hotplug where QEMU is not assigning
unique block device names when you leave the name unspecified

$ /home/berrange/usr/qemu-0.12/bin/qemu -vnc :1 -monitor stdio -device lsi
QEMU 0.11.91 monitor - type 'help' for more information
(qemu) drive_add 0:0:4  file=/home/berrange/mcdboot.img,if=scsi
OK bus 0, unit 0
(qemu) drive_add 0:0:4  file=/home/berrange/mcdboot.img,if=scsi
OK bus 0, unit 1
(qemu) drive_add 0:0:4  file=/home/berrange/mcdboot.img,if=scsi
OK bus 0, unit 2
(qemu) drive_add 0:0:4  file=/home/berrange/mcdboot.img,if=scsi
OK bus 0, unit 3
(qemu) info block
ide1-cd0: type=cdrom removable=1 locked=0 [not inserted]
floppy0: type=floppy removable=1 locked=0 [not inserted]
sd0: type=floppy removable=1 locked=0 [not inserted]
scsi0-hd0: type=hd removable=0 file=/home/berrange/mcdboot.img ro=1 drv=raw 
encrypted=0
scsi0-hd0: type=hd removable=0 file=/home/berrange/mcdboot.img ro=1 drv=raw 
encrypted=0
scsi0-hd0: type=hd removable=0 file=/home/berrange/mcdboot.img ro=1 drv=raw 
encrypted=0
scsi0-hd0: type=hd removable=0 file=/home/berrange/mcdboot.img ro=1 drv=raw 
encrypted=0
(qemu) 


Notice they are all 'scsi0-hd0', instead of scsi0-hd1, scsi0-hd2, etc

(Ignore the fact that i attached the same underlying file many times :-)

Regards,
Daniel
-- 
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|




[Qemu-devel] [PATCH] kvm: x86: Use separate exception_injected CPUState field

2009-12-09 Thread Jan Kiszka
Marcelo correctly remarked that there are usage conflicts between QEMU
core code and KVM /wrt exception_index. So spend a separate field and
also save/restore it properly.

Signed-off-by: Jan Kiszka 
---

NOTE: This obsoletes "kvm: x86: Save/restore exception_index".

 target-i386/cpu.h |1 +
 target-i386/kvm.c |6 +++---
 target-i386/machine.c |1 +
 3 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/target-i386/cpu.h b/target-i386/cpu.h
index 9c3e905..5207b4c 100644
--- a/target-i386/cpu.h
+++ b/target-i386/cpu.h
@@ -692,6 +692,7 @@ typedef struct CPUX86State {
 
 /* For KVM */
 uint32_t mp_state;
+int32_t exception_injected;
 int32_t interrupt_injected;
 uint8_t soft_interrupt;
 uint8_t nmi_injected;
diff --git a/target-i386/kvm.c b/target-i386/kvm.c
index 88b504c..001c6c6 100644
--- a/target-i386/kvm.c
+++ b/target-i386/kvm.c
@@ -705,8 +705,8 @@ static int kvm_put_vcpu_events(CPUState *env)
 return 0;
 }
 
-events.exception.injected = (env->exception_index >= 0);
-events.exception.nr = env->exception_index;
+events.exception.injected = (env->exception_injected >= 0);
+events.exception.nr = env->exception_injected;
 events.exception.has_error_code = env->has_error_code;
 events.exception.error_code = env->error_code;
 
@@ -740,7 +740,7 @@ static int kvm_get_vcpu_events(CPUState *env)
 if (ret < 0) {
return ret;
 }
-env->exception_index =
+env->exception_injected =
events.exception.injected ? events.exception.nr : -1;
 env->has_error_code = events.exception.has_error_code;
 env->error_code = events.exception.error_code;
diff --git a/target-i386/machine.c b/target-i386/machine.c
index cdc8898..84737ef 100644
--- a/target-i386/machine.c
+++ b/target-i386/machine.c
@@ -448,6 +448,7 @@ static const VMStateDescription vmstate_cpu = {
 VMSTATE_INT32_V(interrupt_injected, CPUState, 9),
 VMSTATE_UINT32_V(mp_state, CPUState, 9),
 VMSTATE_UINT64_V(tsc, CPUState, 9),
+VMSTATE_INT32_V(exception_injected, CPUState, 11),
 VMSTATE_UINT8_V(soft_interrupt, CPUState, 11),
 VMSTATE_UINT8_V(nmi_injected, CPUState, 11),
 VMSTATE_UINT8_V(nmi_pending, CPUState, 11),




[Qemu-devel] [PATCH][For stable-0.12] virtio: Add memory statistics reporting to the balloon driver (V5)

2009-12-09 Thread Adam Litke
Reverted the vmstate changes since that has not made it into stable-0.12 yet.

This iteration addresses all of the comments from the last round.  Thanks to
everyone for their careful reviews and helpful comments.  The most significant
change in this version is my use of the QObject API, so a concentrated review
in that area would be most appreciated.  I am hoping to target 0.12.0 with this
patch.  Please let me know if that remains a possibility.  Thanks.

Changes since V4:
 - Virtio spec updated: 
http://ozlabs.org/~rusty/virtio-spec/virtio-spec-0.8.2.pdf
 - Guest-side Linux implementation applied by Rusty
 - Start using the QObject infrastructure
 - All endian conversions done in the host
 - Report stats that reference a quantity of memory in bytes

Changes since V3:
 - Increase stat field size to 64 bits
 - Report all sizes in kb (not pages)
 - Drop anon_pages stat

Changes since V2:
 - Use a virtqueue for communication instead of the device config space

Changes since V1:
 - In the monitor, print all stats on one line with less abbreviated names
 - Coding style changes

When using ballooning to manage overcommitted memory on a host, a system for
guests to communicate their memory usage to the host can provide information
that will minimize the impact of ballooning on the guests.  The current method
employs a daemon running in each guest that communicates memory statistics to a
host daemon at a specified time interval.  The host daemon aggregates this
information and inflates and/or deflates balloons according to the level of
host memory pressure.  This approach is effective but overly complex since a
daemon must be installed inside each guest and coordinated to communicate with
the host.  A simpler approach is to collect memory statistics in the virtio
balloon driver and communicate them directly to the hypervisor.

This patch implements the qemu side of the communication channel.  I will post
the kernel driver modifications in-reply to this message.

Signed-off-by: Adam Litke 
Cc: Anthony Liguori 
Cc: Avi Kivity 
Cc: Rusty Russell 
Cc: qemu-devel@nongnu.org


diff --git a/balloon.h b/balloon.h
index 60b4a5d..23bbffe 100644
--- a/balloon.h
+++ b/balloon.h
@@ -16,12 +16,12 @@
 
 #include "cpu-defs.h"
 
-typedef ram_addr_t (QEMUBalloonEvent)(void *opaque, ram_addr_t target);
+typedef QObject *(QEMUBalloonEvent)(void *opaque, ram_addr_t target);
 
 void qemu_add_balloon_handler(QEMUBalloonEvent *func, void *opaque);
 
 void qemu_balloon(ram_addr_t target);
 
-ram_addr_t qemu_balloon_status(void);
+QObject *qemu_balloon_status(void);
 
 #endif
diff --git a/hw/virtio-balloon.c b/hw/virtio-balloon.c
index cfd3b41..f3bc138 100644
--- a/hw/virtio-balloon.c
+++ b/hw/virtio-balloon.c
@@ -19,6 +19,10 @@
 #include "balloon.h"
 #include "virtio-balloon.h"
 #include "kvm.h"
+#include "monitor.h"
+#include "qlist.h"
+#include "qint.h"
+#include "qstring.h"
 
 #if defined(__linux__)
 #include 
@@ -27,9 +31,13 @@
 typedef struct VirtIOBalloon
 {
 VirtIODevice vdev;
-VirtQueue *ivq, *dvq;
+VirtQueue *ivq, *dvq, *svq;
 uint32_t num_pages;
 uint32_t actual;
+uint64_t stats[VIRTIO_BALLOON_S_NR];
+VirtQueueElement stats_vq_elem;
+size_t stats_vq_offset;
+uint8_t stats_requested;
 } VirtIOBalloon;
 
 static VirtIOBalloon *to_virtio_balloon(VirtIODevice *vdev)
@@ -46,6 +54,35 @@ static void balloon_page(void *addr, int deflate)
 #endif
 }
 
+static inline void reset_stats(VirtIOBalloon *dev)
+{
+int i;
+for (i = 0; i < VIRTIO_BALLOON_S_NR; dev->stats[i++] = -1);
+}
+
+static void stat_put(QList *list, const char *label, uint64_t val)
+{
+if (val != -1) {
+qlist_append(list, qstring_from_str(label));
+qlist_append(list, qint_from_int(val));
+}
+}
+
+static QObject *get_stats_qobject(VirtIOBalloon *dev)
+{
+QList *list = qlist_new();
+uint32_t actual = ram_size - (dev->actual << VIRTIO_BALLOON_PFN_SHIFT);
+
+stat_put(list, "actual", (int)actual >> 20);
+stat_put(list, "mem_swapped_in", dev->stats[VIRTIO_BALLOON_S_SWAP_IN]);
+stat_put(list, "mem_swapped_out", dev->stats[VIRTIO_BALLOON_S_SWAP_OUT]);
+stat_put(list, "major_page_faults", dev->stats[VIRTIO_BALLOON_S_MAJFLT]);
+stat_put(list, "minor_page_faults", dev->stats[VIRTIO_BALLOON_S_MINFLT]);
+stat_put(list, "free_mem", dev->stats[VIRTIO_BALLOON_S_MEMFREE]);
+stat_put(list, "total_mem", dev->stats[VIRTIO_BALLOON_S_MEMTOT]);
+return QOBJECT(list);
+}
+
 /* FIXME: once we do a virtio refactoring, this will get subsumed into common
  * code */
 static size_t memcpy_from_iovector(void *data, size_t offset, size_t size,
@@ -104,6 +141,36 @@ static void virtio_balloon_handle_output(VirtIODevice 
*vdev, VirtQueue *vq)
 }
 }
 
+static void virtio_balloon_receive_stats(VirtIODevice *vdev, VirtQueue *vq)
+{
+VirtIOBalloon *s = DO_UPCAST(VirtIOBalloon, vdev, vdev);
+VirtQueueElement *elem = &s->stats_vq_elem;
+VirtIOBalloonStat stat;
+size_t offset = 0;
+
+

[Qemu-devel] [PATCH] Do not abort on qemu_malloc(0) in production builds

2009-12-09 Thread Anthony Liguori
qemu_malloc() does not allow size=0 to be passed in and aborts on this behavior.

Unfortunately, there is good reason to believe that within qemu, there are a
number of, so far, undetected places that assume size=0 can be safely passed.
Since we do not want to abort unnecessarily in production builds, return
qemu_malloc(1) whenever the version file indicates that this is a production
build.

Also introduce --enable-zero-malloc/--disable-zero-malloc to make this behavior
overridable.

Signed-off-by: Anthony Liguori 
---
 configure |   24 +++-
 qemu-malloc.c |   17 +
 2 files changed, 36 insertions(+), 5 deletions(-)

diff --git a/configure b/configure
index a29839e..ede820e 100755
--- a/configure
+++ b/configure
@@ -256,6 +256,7 @@ blobs="yes"
 pkgversion=""
 check_utests="no"
 user_pie="no"
+zero_malloc=""
 
 # OS specific
 if check_define __linux__ ; then
@@ -600,6 +601,10 @@ for opt do
   ;;
   --enable-docs) docs="yes"
   ;;
+  --enable-zero-malloc) zero_malloc="yes"
+  ;;
+  --disable-zero-malloc) zero_malloc="no"
+  ;;
   *) echo "ERROR: unknown option $opt"; show_help="yes"
   ;;
   esac
@@ -752,6 +757,8 @@ echo "  --enable-linux-aio   enable Linux AIO support"
 echo "  --enable-io-thread   enable IO thread"
 echo "  --disable-blobs  disable installing provided firmware blobs"
 echo "  --kerneldir=PATH look for kernel includes in PATH"
+echo "  --enable-zero-malloc allow allocations of zero size"
+echo "  --disable-zero-mallocabort on allocations of zero size"
 echo ""
 echo "NOTE: The object files are built at the place where configure is 
launched"
 exit 1
@@ -1792,8 +1799,9 @@ fi
 
 # Consult white-list to determine whether to enable werror
 # by default.  Only enable by default for git builds
+z_version=`cut -f3 -d. $source_path/VERSION`
+
 if test -z "$werror" ; then
-z_version=`cut -f3 -d. $source_path/VERSION`
 if test "$z_version" = "50" -a \
 "$linux" = "yes" ; then
 werror="yes"
@@ -1802,6 +1810,16 @@ if test -z "$werror" ; then
 fi
 fi
 
+# Disable zero malloc errors for official releases unless explicitly told to
+# enable/disable
+if test -z "$zero_malloc" ; then
+if test "$z_version" = "50" ; then
+   zero_malloc="no"
+else
+   zero_malloc="yes"
+fi
+fi
+
 if test "$werror" = "yes" ; then
 QEMU_CFLAGS="-Werror $QEMU_CFLAGS"
 fi
@@ -2109,6 +2127,10 @@ fi
 
 echo "CONFIG_UNAME_RELEASE=\"$uname_release\"" >> $config_host_mak
 
+if test "$zero_malloc" = "yes" ; then
+  echo "CONFIG_ZERO_MALLOC=y" >> $config_host_mak
+fi
+
 # USB host support
 case "$usb" in
 linux)
diff --git a/qemu-malloc.c b/qemu-malloc.c
index 295d185..e82af26 100644
--- a/qemu-malloc.c
+++ b/qemu-malloc.c
@@ -42,21 +42,30 @@ void qemu_free(void *ptr)
 free(ptr);
 }
 
+static int allow_zero_malloc(void)
+{
+#if defined(CONFIG_ZERO_MALLOC)
+return 1;
+#else
+return 0;
+#endif
+}
+
 void *qemu_malloc(size_t size)
 {
-if (!size) {
+if (!size && !allow_zero_malloc()) {
 abort();
 }
-return oom_check(malloc(size));
+return oom_check(malloc(size ? size : 1));
 }
 
 void *qemu_realloc(void *ptr, size_t size)
 {
 if (size) {
 return oom_check(realloc(ptr, size));
-} else {
+} else if (allow_zero_malloc()) {
 if (ptr) {
-return realloc(ptr, size);
+return realloc(ptr, size ? size : 1);
 }
 }
 abort();
-- 
1.6.2.5





Re: [Qemu-devel] [PATCH] Do not abort on qemu_malloc(0) in production builds

2009-12-09 Thread Markus Armbruster
Anthony Liguori  writes:

> qemu_malloc() does not allow size=0 to be passed in and aborts on this 
> behavior.
>
> Unfortunately, there is good reason to believe that within qemu, there are a
> number of, so far, undetected places that assume size=0 can be safely passed.
> Since we do not want to abort unnecessarily in production builds, return
> qemu_malloc(1) whenever the version file indicates that this is a production
> build.
>
> Also introduce --enable-zero-malloc/--disable-zero-malloc to make this 
> behavior
> overridable.
>
> Signed-off-by: Anthony Liguori 
> ---
>  configure |   24 +++-
>  qemu-malloc.c |   17 +
>  2 files changed, 36 insertions(+), 5 deletions(-)
>
[...]
> diff --git a/qemu-malloc.c b/qemu-malloc.c
> index 295d185..e82af26 100644
> --- a/qemu-malloc.c
> +++ b/qemu-malloc.c
> @@ -42,21 +42,30 @@ void qemu_free(void *ptr)
>  free(ptr);
>  }
>  
> +static int allow_zero_malloc(void)
> +{
> +#if defined(CONFIG_ZERO_MALLOC)
> +return 1;
> +#else
> +return 0;
> +#endif
> +}
> +
>  void *qemu_malloc(size_t size)
>  {
> -if (!size) {
> +if (!size && !allow_zero_malloc()) {
>  abort();
>  }
> -return oom_check(malloc(size));
> +return oom_check(malloc(size ? size : 1));
>  }
>  
>  void *qemu_realloc(void *ptr, size_t size)
>  {
>  if (size) {
>  return oom_check(realloc(ptr, size));
> -} else {
> +} else if (allow_zero_malloc()) {
>  if (ptr) {
> -return realloc(ptr, size);
> +return realloc(ptr, size ? size : 1);
>  }
>  }
>  abort();

This still aborts on qemu_realloc(NULL, 0), even with
CONFIG_ZERO_MALLOC.  Intentional?




Re: [Qemu-devel] Guest bridge setup variations

2009-12-09 Thread Anthony Liguori

Arnd Bergmann wrote:

As promised, here is my small writeup on which setups I feel
are important in the long run for server-type guests. This
does not cover -net user, which is really for desktop kinds
of applications where you do not want to connect into the
guest from another IP address.

I can see four separate setups that we may or may not want to
support, the main difference being how the forwarding between
guests happens:

1. The current setup, with a bridge and tun/tap devices on ports
of the bridge. This is what Gerhard's work on access controls is
focused on and the only option where the hypervisor actually
is in full control of the traffic between guests. CPU utilization should
be highest this way, and network management can be a burden,
because the controls are done through a Linux, libvirt and/or Director
specific interface.
  


Typical bridging.


2. Using macvlan as a bridging mechanism, replacing the bridge
and tun/tap entirely. This should offer the best performance on
inter-guest communication, both in terms of throughput and
CPU utilization, but offer no access control for this traffic at all.
Performance of guest-external traffic should be slightly better
than bridge/tap.
  


Optimization to typical bridge (no traffic control).


3. Doing the bridging in the NIC using macvlan in passthrough
mode. This lowers the CPU utilization further compared to 2,
at the expense of limiting throughput by the performance of
the PCIe interconnect to the adapter. Whether or not this
is a win is workload dependent. Access controls now happen
in the NIC. Currently, this is not supported yet, due to lack of
device drivers, but it will be an important scenario in the future
according to some people.
  


Optimization to typical bridge (hardware accelerated).


4. Using macvlan for actual VEPA on the outbound interface.
This is mostly interesting because it makes the network access
controls visible in an external switch that is already managed.
CPU utilization and guest-external throughput should be
identical to 3, but inter-guest latency can only be worse because
all frames go through the external switch.
  


VEPA.

While we go over all of these things one thing is becoming clear to me.  
We need to get qemu out of the network configuration business.  There's 
too much going on here.


What I'd like to see is the following interfaces supported:

1) given an fd, make socket calls to send packets.  Could be used with a 
raw socket, a multicast or tcp socket.

2) given an fd, use tap-style read/write calls to send packets*
3) given an fd, treat a vhost-style interface

* need to make all tun ioctls optional based on passed in flags

Every backend we have today could be implemented in terms of one of the 
above three.  They really come down to how the fd is created and setup.


I believe we should continue supporting the mechanisms we support 
today.  However, for people that invoke qemu directly from the command 
line, I believe we should provide a mechanism like the tap helper that 
can be used to call out to a separate program to create these initial 
file descriptors.  We'll have to think about how we can make this 
integrate well so that the syntax isn't clumsy.


Regards,

Anthony Liguori





[Qemu-devel] Re: [PATCH, try 2] qemu/tap: add -net tap,dev= option

2009-12-09 Thread Anthony Liguori

Arnd Bergmann wrote:

In order to support macvtap, we need a way to select the actual
tap endpoint. While it would be nice to pass it by network interface
name, passing the character device is more flexible, and we can
easily do both in the long run.

Signed-off-by: Arnd Bergmann 
  


This isn't really a generic thing and I dislike pretending it is.  This 
is specifically for macvtap.


If we were going to do this, I'd rather introduce a -net macvtap that 
actually allocated the interfaces (similar to how tap works).  The 
problem with this interface is that it's a two stage process.  You have 
to create an interface, then hand the name to qemu.  It would be just as 
easy to hand qemu an fd with a helper.


What's nice about -net tap is that with a little bit of setup 
(/etc/qemu-ifup), it Just Works.  -net tap,dev= does not share this 
property.


I think this is a good place where an exec helper would be a natural fit.

Regards,

Anthony Liguori




[Qemu-devel] [PATCH] e1000: fix init values for command register

2009-12-09 Thread Michael S. Tsirkin
Command register for e1000 was initialized to
values out of spec: all of bus master,
io, memory and interrupt disable bits were set.

This breaks the device now that we actually respect
the interrupt disable bit, unless the guest
happens to clear it. Fix, and make the device
more spec compliant, by not touching
the default.

There are implications for migration
from old qemu as well, will be addressed
separately.

Reported-by: Luiz Capitulino 
Tested-by: Luiz Capitulino 
Signed-off-by: Michael S. Tsirkin 
---
 hw/e1000.c |1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/hw/e1000.c b/hw/e1000.c
index 8566fe3..ad7a267 100644
--- a/hw/e1000.c
+++ b/hw/e1000.c
@@ -1089,7 +1089,6 @@ static int pci_e1000_init(PCIDevice *pci_dev)
 
 pci_config_set_vendor_id(pci_conf, PCI_VENDOR_ID_INTEL);
 pci_config_set_device_id(pci_conf, E1000_DEVID);
-*(uint16_t *)(pci_conf+0x04) = cpu_to_le16(0x0407);
 *(uint16_t *)(pci_conf+0x06) = cpu_to_le16(0x0010);
 pci_conf[0x08] = 0x03;
 pci_config_set_class(pci_conf, PCI_CLASS_NETWORK_ETHERNET);
-- 
1.6.6.rc1.43.gf55cc




Re: [Qemu-devel] [PATCH] Do not abort on qemu_malloc(0) in production builds

2009-12-09 Thread Anthony Liguori

Markus Armbruster wrote:

Anthony Liguori  writes:

  

qemu_malloc() does not allow size=0 to be passed in and aborts on this behavior.

Unfortunately, there is good reason to believe that within qemu, there are a
number of, so far, undetected places that assume size=0 can be safely passed.
Since we do not want to abort unnecessarily in production builds, return
qemu_malloc(1) whenever the version file indicates that this is a production
build.

Also introduce --enable-zero-malloc/--disable-zero-malloc to make this behavior
overridable.

Signed-off-by: Anthony Liguori 
---
 configure |   24 +++-
 qemu-malloc.c |   17 +
 2 files changed, 36 insertions(+), 5 deletions(-)



[...]
  

diff --git a/qemu-malloc.c b/qemu-malloc.c
index 295d185..e82af26 100644
--- a/qemu-malloc.c
+++ b/qemu-malloc.c
@@ -42,21 +42,30 @@ void qemu_free(void *ptr)
 free(ptr);
 }
 
+static int allow_zero_malloc(void)

+{
+#if defined(CONFIG_ZERO_MALLOC)
+return 1;
+#else
+return 0;
+#endif
+}
+
 void *qemu_malloc(size_t size)
 {
-if (!size) {
+if (!size && !allow_zero_malloc()) {
 abort();
 }
-return oom_check(malloc(size));
+return oom_check(malloc(size ? size : 1));
 }
 
 void *qemu_realloc(void *ptr, size_t size)

 {
 if (size) {
 return oom_check(realloc(ptr, size));
-} else {
+} else if (allow_zero_malloc()) {
 if (ptr) {
-return realloc(ptr, size);
+return realloc(ptr, size ? size : 1);
 }
 }
 abort();



This still aborts on qemu_realloc(NULL, 0), even with
CONFIG_ZERO_MALLOC.  Intentional?
  

I guess not.  Should it?  Seems like a very strange case..

Regards,

Anthony Liguori


--
Regards,

Anthony Liguori





[Qemu-devel] RFC: exit on incoming exec migrate failure

2009-12-09 Thread Andrew Farmer
Right now, if an incoming migrate through exec fails, the qemu process will end 
up chewing CPU indefinitely - it looks like it closes the migration FD but 
doesn't remove its IO handler properly. An easy way to reproduce this is to try 
launching with -incoming exec:/bin/false. This is obviously useless, but 
illustrates the issue handily.

One solution might be to retry the command on migrate failure, but that won't 
really help in all circumstances (for instance, if the migration command is 
broken!), so it seems equally appropriate to just die if an incoming exec 
migration fails. The patch is trivial, and follows - does this look sensible? 
(I'm new to qemu development, but trying to pick it up.)

diff --git a/migration-exec.c b/migration-exec.c
index c830669..0292c19 100644
--- a/migration-exec.c
+++ b/migration-exec.c
@@ -114,7 +114,7 @@ static void exec_accept_incoming_migration(void *opaque)
 ret = qemu_loadvm_state(f);
 if (ret < 0) {
 fprintf(stderr, "load of migration failed\n");
-goto err;
+exit(0);
 }
 qemu_announce_self();
 dprintf("successfully loaded vm state\n");
@@ -123,7 +123,6 @@ static void exec_accept_incoming_migration(void *opaque)
 if (autostart)
 vm_start();
 
-err:
 qemu_fclose(f);
 }





Re: [Qemu-devel] [PATCH] Do not abort on qemu_malloc(0) in production builds

2009-12-09 Thread Markus Armbruster
Anthony Liguori  writes:

> Markus Armbruster wrote:
>> This still aborts on qemu_realloc(NULL, 0), even with
>> CONFIG_ZERO_MALLOC.  Intentional?
>>   
> I guess not.  Should it?  Seems like a very strange case..

It is a strange case, but I think the point of this commit is not to
abort on conditions perceived strange ;)

I think it should follow C89 and behave exactly like qemu_malloc(0).




[Qemu-devel] [PATCH 1/7] alpha: Implement IMB; add placeholders for other userspace PALcalls.

2009-12-09 Thread Richard Henderson

Signed-off-by: Richard Henderson 
---
 hw/alpha_palcode.c |   29 +++--
 1 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/hw/alpha_palcode.c b/hw/alpha_palcode.c
index c48a297..44b2ca4 100644
--- a/hw/alpha_palcode.c
+++ b/hw/alpha_palcode.c
@@ -1062,6 +1062,16 @@ void call_pal (CPUState *env, int palcode)
 
 qemu_log("%s: palcode %02x\n", __func__, palcode);
 switch (palcode) {
+case 0x80:
+/* BPT */
+qemu_log("BPT\n");
+/* FIXME: Sends SIGTRAP, si_code=TRAP_BRKPT.  */
+exit(1);
+case 0x81:
+/* BUGCHK */
+qemu_log("BUGCHK\n");
+/* FIXME: Sends SIGTRAP, si_code=SI_FAULT.  */
+exit(1);
 case 0x83:
 /* CALLSYS */
 qemu_log("CALLSYS n " TARGET_FMT_ld "\n", env->ir[0]);
@@ -1076,6 +1086,11 @@ void call_pal (CPUState *env, int palcode)
 env->ir[IR_V0] = -ret;
 }
 break;
+case 0x86:
+/* IMB */
+qemu_log("IMB\n");
+tb_flush(env);
+break;
 case 0x9E:
 /* RDUNIQUE */
 env->ir[IR_V0] = env->unique;
@@ -1086,9 +1101,19 @@ void call_pal (CPUState *env, int palcode)
 env->unique = env->ir[IR_A0];
 qemu_log("WRUNIQUE: " TARGET_FMT_lx "\n", env->unique);
 break;
+case 0xAA:
+/* GENTRAP */
+qemu_log("GENTRAP: " TARGET_FMT_lx "\n", env->ir[IR_A0]);
+/* FIXME: This is supposed to send a signal:
+   SIGFPE:
+ GEN_INTOVF, GEN_INTDIV, GEN_FLTOVF, GEN_FLTDIV,
+ GEN_FLTUND, GEN_FLTINV, GEN_FLTINE, GEN_ROPRAND
+   SIGTRAP:
+ others
+   with various settings of si_code.  */
+exit(1);
 default:
-qemu_log("%s: unhandled palcode %02x\n",
-__func__, palcode);
+qemu_log("%s: unhandled palcode %02x\n", __func__, palcode);
 exit(1);
 }
 }
-- 
1.6.5.2





[Qemu-devel] [PATCH 7/7] alpha: Fixes for alpha-linux syscalls.

2009-12-09 Thread Richard Henderson

1. Add correct definitions of error numbers.
2. Implement SYS_osf_sigprocmask
3. Implement SYS_osf_get/setsysinfo for IEEE_FP_CONTROL.

This last requires exposing the FPCR value to do_syscall.
Since this value is actually split up into the float_status,
expose routines from helper.c to access it.

Finally, also add a float_exception_mask field to float_status.
We don't actually use it to control delivery of exceptions to
the emulator yet, but simply hold the value that we placed there
when loading/storing the FPCR.

Signed-off-by: Richard Henderson 
---
 fpu/softfloat.h|1 +
 linux-user/alpha/syscall.h |  212 
 linux-user/syscall.c   |  137 ++--
 target-alpha/cpu.h |   49 ++
 target-alpha/helper.c  |   77 
 target-alpha/op_helper.c   |   41 +
 6 files changed, 468 insertions(+), 49 deletions(-)

diff --git a/fpu/softfloat.h b/fpu/softfloat.h
index 636591b..9d82694 100644
--- a/fpu/softfloat.h
+++ b/fpu/softfloat.h
@@ -187,6 +187,7 @@ typedef struct float_status {
 signed char float_detect_tininess;
 signed char float_rounding_mode;
 signed char float_exception_flags;
+signed char float_exception_mask;
 #ifdef FLOATX80
 signed char floatx80_rounding_precision;
 #endif
diff --git a/linux-user/alpha/syscall.h b/linux-user/alpha/syscall.h
index 394afec..15a0100 100644
--- a/linux-user/alpha/syscall.h
+++ b/linux-user/alpha/syscall.h
@@ -39,3 +39,215 @@ struct target_pt_regs {
 };
 
 #define UNAME_MACHINE "alpha"
+
+#undef TARGET_EDEADLK
+#define TARGET_EDEADLK 11
+#undef TARGET_EAGAIN
+#define TARGET_EAGAIN  35
+#undef TARGET_EINPROGRESS
+#define TARGET_EINPROGRESS 36
+#undef TARGET_EALREADY
+#define TARGET_EALREADY37
+#undef TARGET_ENOTSOCK
+#define TARGET_ENOTSOCK38
+#undef TARGET_EDESTADDRREQ
+#define TARGET_EDESTADDRREQ39
+#undef TARGET_EMSGSIZE
+#define TARGET_EMSGSIZE40
+#undef TARGET_EPROTOTYPE
+#define TARGET_EPROTOTYPE  41
+#undef TARGET_ENOPROTOOPT
+#define TARGET_ENOPROTOOPT 42
+#undef TARGET_EPROTONOSUPPORT
+#define TARGET_EPROTONOSUPPORT 43
+#undef TARGET_ESOCKTNOSUPPORT
+#define TARGET_ESOCKTNOSUPPORT 44
+#undef TARGET_EOPNOTSUPP
+#define TARGET_EOPNOTSUPP  45
+#undef TARGET_EPFNOSUPPORT
+#define TARGET_EPFNOSUPPORT46
+#undef TARGET_EAFNOSUPPORT
+#define TARGET_EAFNOSUPPORT47
+#undef TARGET_EADDRINUSE
+#define TARGET_EADDRINUSE  48
+#undef TARGET_EADDRNOTAVAIL
+#define TARGET_EADDRNOTAVAIL   49
+#undef TARGET_ENETDOWN
+#define TARGET_ENETDOWN50
+#undef TARGET_ENETUNREACH
+#define TARGET_ENETUNREACH 51
+#undef TARGET_ENETRESET
+#define TARGET_ENETRESET   52
+#undef TARGET_ECONNABORTED
+#define TARGET_ECONNABORTED53
+#undef TARGET_ECONNRESET
+#define TARGET_ECONNRESET  54
+#undef TARGET_ENOBUFS
+#define TARGET_ENOBUFS 55
+#undef TARGET_EISCONN
+#define TARGET_EISCONN 56
+#undef TARGET_ENOTCONN
+#define TARGET_ENOTCONN57
+#undef TARGET_ESHUTDOWN
+#define TARGET_ESHUTDOWN   58
+#undef TARGET_ETOOMANYREFS
+#define TARGET_ETOOMANYREFS59
+#undef TARGET_ETIMEDOUT
+#define TARGET_ETIMEDOUT   60
+#undef TARGET_ECONNREFUSED
+#define TARGET_ECONNREFUSED61
+#undef TARGET_ELOOP
+#define TARGET_ELOOP   62
+#undef TARGET_ENAMETOOLONG
+#define TARGET_ENAMETOOLONG63
+#undef TARGET_EHOSTDOWN
+#define TARGET_EHOSTDOWN   64
+#undef TARGET_EHOSTUNREACH
+#define TARGET_EHOSTUNREACH65
+#undef TARGET_ENOTEMPTY
+#define TARGET_ENOTEMPTY   66
+// Unused  67
+#undef TARGET_EUSERS
+#define TARGET_EUSERS  68
+#undef TARGET_EDQUOT
+#define TARGET_EDQUOT  69
+#undef TARGET_ESTALE
+#define TARGET_ESTALE  70
+#undef TARGET_EREMOTE
+#define TARGET_EREMOTE 71
+// Unused  72-76
+#undef TARGET_ENOLCK
+#define TARGET_ENOLCK  77
+#undef TARGET_ENOSYS
+#define TARGET_ENOSYS  78
+// Unused  79
+#undef TARGET_ENOMSG
+#define TARGET_ENOMSG  80
+#undef TARGET_EIDRM
+#define TARGET_EIDRM   81
+#undef TARGET_ENOSR
+#define TARGET_ENOSR   82
+#undef TARGET_ETIME
+#define TARGET_ETIME   83
+#undef TARGET_EBADMSG
+#define TARGET_EBADMSG 84
+#undef TARGET_EPROTO
+#define TARGET_EPROTO  85
+#undef TARGET_ENODATA
+#define TARGET_ENODATA 86
+#undef TARGET_ENOSTR
+#define TARGET_ENOSTR  87
+#undef TARGET_ECHRNG
+#define TARGET_ECHRNG  88
+#undef TARGET_EL2NSYNC
+#define TARGET_EL2NSYNC89
+#undef TARGET_EL3HLT
+#define TARGET_EL3HLT  90
+#undef TARGET_EL3RST
+#define TARGET_EL3RST  91
+#undef TARGET_ENOPKG
+#define TARGET_ENOPKG  92
+#undef TARGET_ELNRNG
+#define TARGET_ELNRNG  93
+#undef TARGET_EUNATCH
+#define TARGET_EUNATCH 94
+#undef TARGET_ENOCSI
+#define TARGET_ENOCSI

[Qemu-devel] [PATCH 0/7] Improve alpha-linux userspace emulation

2009-12-09 Thread Richard Henderson

The following patch series results in an emulator that's good enough
to run a good bit of the GCC testsuite, dynamic linking and all.
There are more failures than native hardware.  At first glance they
appear to be fpu related, but I havn't investigated properly yet.


r~
--


Richard Henderson (7):
  alpha: Implement IMB; add placeholders for other userspace PALcalls.
  alpha: Drop bogus UNIQ initial value on Linux.
  alpha: Add binfmt entry.
  alpha: Remove bogus DO_TB_FLUSH code from translator.
  alpha: Honor the -cpu command line argument. Also change the default
cpu to ev67.
  alpha: Enable softfloat.
  alpha: Fixes for alpha-linux syscalls.

 configure  |2 +-
 fpu/softfloat-specialize.h |4 +-
 fpu/softfloat.h|1 +
 hw/alpha_palcode.c |   29 ++-
 linux-user/alpha/syscall.h |  212 
 linux-user/elfload.c   |3 -
 linux-user/syscall.c   |  137 ++--
 qemu-binfmt-conf.sh|3 +
 target-alpha/cpu.h |   49 ++
 target-alpha/helper.c  |   77 
 target-alpha/helper.h  |2 -
 target-alpha/op_helper.c   |   46 +-
 target-alpha/translate.c   |   52 +--
 13 files changed, 544 insertions(+), 73 deletions(-)





[Qemu-devel] [PATCH 4/7] alpha: Remove bogus DO_TB_FLUSH code from translator.

2009-12-09 Thread Richard Henderson

Signed-off-by: Richard Henderson 
---
 target-alpha/helper.h|2 --
 target-alpha/op_helper.c |5 -
 target-alpha/translate.c |8 +---
 3 files changed, 1 insertions(+), 14 deletions(-)

diff --git a/target-alpha/helper.h b/target-alpha/helper.h
index a4faca2..9c60be1 100644
--- a/target-alpha/helper.h
+++ b/target-alpha/helper.h
@@ -1,7 +1,5 @@
 #include "def-helper.h"
 
-DEF_HELPER_0(tb_flush, void)
-
 DEF_HELPER_2(excp, void, int, int)
 DEF_HELPER_0(load_pcc, i64)
 DEF_HELPER_0(rc, i64)
diff --git a/target-alpha/op_helper.c b/target-alpha/op_helper.c
index fe222dc..508272c 100644
--- a/target-alpha/op_helper.c
+++ b/target-alpha/op_helper.c
@@ -22,11 +22,6 @@
 #include "softfloat.h"
 #include "helper.h"
 
-void helper_tb_flush (void)
-{
-tb_flush(env);
-}
-
 /*/
 /* Exceptions processing helpers */
 void helper_excp (int excp, int error)
diff --git a/target-alpha/translate.c b/target-alpha/translate.c
index 9e7e9b2..ae1f5a8 100644
--- a/target-alpha/translate.c
+++ b/target-alpha/translate.c
@@ -32,10 +32,7 @@
 #define GEN_HELPER 1
 #include "helper.h"
 
-/* #define DO_SINGLE_STEP */
-#define ALPHA_DEBUG_DISAS
-/* #define DO_TB_FLUSH */
-
+#undef ALPHA_DEBUG_DISAS
 
 #ifdef ALPHA_DEBUG_DISAS
 #  define LOG_DISAS(...) qemu_log(__VA_ARGS__)
@@ -2428,9 +2425,6 @@ static inline void 
gen_intermediate_code_internal(CPUState *env,
 if (ret != 1 && ret != 3) {
 tcg_gen_movi_i64(cpu_pc, ctx.pc);
 }
-#if defined (DO_TB_FLUSH)
-gen_helper_tb_flush();
-#endif
 if (tb->cflags & CF_LAST_IO)
 gen_io_end();
 /* Generate the return instruction */
-- 
1.6.5.2





[Qemu-devel] [PATCH 5/7] alpha: Honor the -cpu command line argument.

2009-12-09 Thread Richard Henderson

Also change the default cpu to ev67.


Signed-off-by: Richard Henderson 
---
 target-alpha/translate.c |   44 ++--
 1 files changed, 42 insertions(+), 2 deletions(-)

diff --git a/target-alpha/translate.c b/target-alpha/translate.c
index ae1f5a8..3f8d1b2 100644
--- a/target-alpha/translate.c
+++ b/target-alpha/translate.c
@@ -2460,17 +2460,57 @@ void gen_intermediate_code_pc (CPUState *env, struct 
TranslationBlock *tb)
 gen_intermediate_code_internal(env, tb, 1);
 }
 
+struct cpu_def_t {
+const char *name;
+int implver, amask;
+};
+
+static const struct cpu_def_t cpu_defs[] = {
+{ "ev4",   IMPLVER_2106x, 0 },
+{ "ev5",   IMPLVER_21164, 0 },
+{ "ev56",  IMPLVER_21164, AMASK_BWX },
+{ "pca56", IMPLVER_21164, AMASK_BWX | AMASK_MVI },
+{ "ev6",   IMPLVER_21264, AMASK_BWX | AMASK_FIX | AMASK_MVI | AMASK_TRAP },
+{ "ev67",  IMPLVER_21264, (AMASK_BWX | AMASK_FIX | AMASK_CIX
+  | AMASK_MVI | AMASK_TRAP | AMASK_PREFETCH), },
+{ "ev68",  IMPLVER_21264, (AMASK_BWX | AMASK_FIX | AMASK_CIX
+  | AMASK_MVI | AMASK_TRAP | AMASK_PREFETCH), },
+{ "21064", IMPLVER_2106x, 0 },
+{ "21164", IMPLVER_21164, 0 },
+{ "21164a", IMPLVER_21164, AMASK_BWX },
+{ "21164pc", IMPLVER_21164, AMASK_BWX | AMASK_MVI },
+{ "21264", IMPLVER_21264, AMASK_BWX | AMASK_FIX | AMASK_MVI | AMASK_TRAP },
+{ "21264a", IMPLVER_21264, (AMASK_BWX | AMASK_FIX | AMASK_CIX
+   | AMASK_MVI | AMASK_TRAP | AMASK_PREFETCH), }
+};
+
 CPUAlphaState * cpu_alpha_init (const char *cpu_model)
 {
 CPUAlphaState *env;
 uint64_t hwpcb;
+int implver, amask, i, max;
 
 env = qemu_mallocz(sizeof(CPUAlphaState));
 cpu_exec_init(env);
 alpha_translate_init();
 tlb_flush(env, 1);
-/* XXX: should not be hardcoded */
-env->implver = IMPLVER_2106x;
+
+/* Default to ev67; no reason not to emulate insns by default.  */
+implver = IMPLVER_21264;
+amask = (AMASK_BWX | AMASK_FIX | AMASK_CIX | AMASK_MVI
+| AMASK_TRAP | AMASK_PREFETCH);
+
+max = ARRAY_SIZE(cpu_defs);
+for (i = 0; i < max; i++) {
+if (strcmp (cpu_model, cpu_defs[i].name) == 0) {
+implver = cpu_defs[i].implver;
+amask = cpu_defs[i].amask;
+break;
+}
+}
+env->implver = implver;
+env->amask = amask;
+
 env->ps = 0x1F00;
 #if defined (CONFIG_USER_ONLY)
 env->ps |= 1 << 3;
-- 
1.6.5.2





[Qemu-devel] [PATCH 3/7] alpha: Add binfmt entry.

2009-12-09 Thread Richard Henderson

Signed-off-by: Richard Henderson 
---
 qemu-binfmt-conf.sh |3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/qemu-binfmt-conf.sh b/qemu-binfmt-conf.sh
index 941f0cf..ba916ac 100644
--- a/qemu-binfmt-conf.sh
+++ b/qemu-binfmt-conf.sh
@@ -34,6 +34,9 @@ if [ $cpu != "i386" ] ; then
 echo 
':i386:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x03\x00:\xff\xff\xff\xff\xff\xfe\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/local/bin/qemu-i386:'
 > /proc/sys/fs/binfmt_misc/register
 echo 
':i486:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x06\x00:\xff\xff\xff\xff\xff\xfe\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/local/bin/qemu-i386:'
 > /proc/sys/fs/binfmt_misc/register
 fi
+if [ $cpu != "alpha" ] ; then
+echo 
':alpha:M::\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x26\x90:\xff\xff\xff\xff\xff\xfe\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/local/bin/qemu-alpha:'
 > /proc/sys/fs/binfmt_misc/register
+fi
 if [ $cpu != "arm" ] ; then
 echo   
':arm:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/local/bin/qemu-arm:'
 > /proc/sys/fs/binfmt_misc/register
 echo   
':armeb:M::\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/local/bin/qemu-armeb:'
 > /proc/sys/fs/binfmt_misc/register
-- 
1.6.5.2





[Qemu-devel] [PATCH 2/7] alpha: Drop bogus UNIQ initial value on Linux.

2009-12-09 Thread Richard Henderson

Signed-off-by: Richard Henderson 
---
 linux-user/elfload.c |3 ---
 1 files changed, 0 insertions(+), 3 deletions(-)

diff --git a/linux-user/elfload.c b/linux-user/elfload.c
index 682a813..f47ec1e 100644
--- a/linux-user/elfload.c
+++ b/linux-user/elfload.c
@@ -677,9 +677,6 @@ static inline void init_thread(struct target_pt_regs *regs, 
struct image_info *i
 regs->pc = infop->entry;
 regs->ps = 8;
 regs->usp = infop->start_stack;
-regs->unique = infop->start_data; /* ? */
-printf("Set unique value to " TARGET_FMT_lx " (" TARGET_FMT_lx ")\n",
-   regs->unique, infop->start_data);
 }
 
 #define ELF_EXEC_PAGESIZE8192
-- 
1.6.5.2





[Qemu-devel] [PATCH 6/7] alpha: Enable softfloat.

2009-12-09 Thread Richard Henderson

Signed-off-by: Richard Henderson 
---
 configure  |2 +-
 fpu/softfloat-specialize.h |4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/configure b/configure
index a29839e..2d46abb 100755
--- a/configure
+++ b/configure
@@ -2432,7 +2432,7 @@ if test ! -z "$gdb_xml_files" ; then
 fi
 
 case "$target_arch2" in
-  
arm|armeb|m68k|microblaze|mips|mipsel|mipsn32|mipsn32el|mips64|mips64el|ppc|ppc64|ppc64abi32|ppcemb|s390x|sparc|sparc64|sparc32plus)
+  
alpha|arm|armeb|m68k|microblaze|mips|mipsel|mipsn32|mipsn32el|mips64|mips64el|ppc|ppc64|ppc64abi32|ppcemb|s390x|sparc|sparc64|sparc32plus)
 echo "CONFIG_SOFTFLOAT=y" >> $config_target_mak
 ;;
   *)
diff --git a/fpu/softfloat-specialize.h b/fpu/softfloat-specialize.h
index f607e19..8e6aceb 100644
--- a/fpu/softfloat-specialize.h
+++ b/fpu/softfloat-specialize.h
@@ -61,7 +61,7 @@ typedef struct {
 **/
 #if defined(TARGET_SPARC)
 #define float32_default_nan make_float32(0x7FFF)
-#elif defined(TARGET_POWERPC) || defined(TARGET_ARM)
+#elif defined(TARGET_POWERPC) || defined(TARGET_ARM) || defined(TARGET_ALPHA)
 #define float32_default_nan make_float32(0x7FC0)
 #elif defined(TARGET_HPPA)
 #define float32_default_nan make_float32(0x7FA0)
@@ -189,7 +189,7 @@ static float32 propagateFloat32NaN( float32 a, float32 b 
STATUS_PARAM)
 **/
 #if defined(TARGET_SPARC)
 #define float64_default_nan make_float64(LIT64( 0x7FFF ))
-#elif defined(TARGET_POWERPC) || defined(TARGET_ARM)
+#elif defined(TARGET_POWERPC) || defined(TARGET_ARM) || defined(TARGET_ALPHA)
 #define float64_default_nan make_float64(LIT64( 0x7FF8 ))
 #elif defined(TARGET_HPPA)
 #define float64_default_nan make_float64(LIT64( 0x7FF4 ))
-- 
1.6.5.2





Re: [Qemu-devel] [PATCH 0/7] Improve alpha-linux userspace emulation

2009-12-09 Thread Laurent Desnogues
On Thu, Dec 10, 2009 at 1:05 AM, Richard Henderson  wrote:
>
> The following patch series results in an emulator that's good enough
> to run a good bit of the GCC testsuite, dynamic linking and all.
> There are more failures than native hardware.  At first glance they
> appear to be fpu related, but I havn't investigated properly yet.

I don't know what FPU instructions gcc emits, but QEMU doesn't
handle the rounding mode encoding.  If you're interested I started
implementing that, though it's not complete (and it didn't fix the
SPEC2k equake failure I had).


Laurent

>
> r~
> --
>
>
> Richard Henderson (7):
>  alpha: Implement IMB; add placeholders for other userspace PALcalls.
>  alpha: Drop bogus UNIQ initial value on Linux.
>  alpha: Add binfmt entry.
>  alpha: Remove bogus DO_TB_FLUSH code from translator.
>  alpha: Honor the -cpu command line argument. Also change the default
>    cpu to ev67.
>  alpha: Enable softfloat.
>  alpha: Fixes for alpha-linux syscalls.
>
>  configure                  |    2 +-
>  fpu/softfloat-specialize.h |    4 +-
>  fpu/softfloat.h            |    1 +
>  hw/alpha_palcode.c         |   29 ++-
>  linux-user/alpha/syscall.h |  212 
> 
>  linux-user/elfload.c       |    3 -
>  linux-user/syscall.c       |  137 ++--
>  qemu-binfmt-conf.sh        |    3 +
>  target-alpha/cpu.h         |   49 ++
>  target-alpha/helper.c      |   77 
>  target-alpha/helper.h      |    2 -
>  target-alpha/op_helper.c   |   46 +-
>  target-alpha/translate.c   |   52 +--
>  13 files changed, 544 insertions(+), 73 deletions(-)
>
>
>
>




Re: [Qemu-devel] [FOR 0.12 PATCH v4 05/22] Revert "monitor: Command-line flag to enable control mode"

2009-12-09 Thread Markus Armbruster
Gerd Hoffmann  writes:

> This reverts commit adcb181afe5a951c521411c7a8e9d9b791aa6742.

Would be nice to state why it's reverted, and that it'll be back in a
few commits.

>
> Conflicts:
>
>   monitor.h
>
> Signed-off-by: Gerd Hoffmann 
[...]