Re: [Qemu-devel] [PATCH v2] qxl: bump pci rev

2011-07-08 Thread Gerd Hoffmann

  Hi,


-DEFINE_PROP_UINT32(revision, PCIQXLDevice, revision, 2),
+DEFINE_PROP_UINT32(revision, PCIQXLDevice, revision, 3),


Can't be done unconditionally.  With an older libspice we can't support 
the rev3 features.


cheers,
  Gerd



Re: [Qemu-devel] [PATCH v2] qxl: async I/O

2011-07-08 Thread Gerd Hoffmann

+void qxl_spice_update_area_async(PCIQXLDevice *qxl, uint32_t surface_id,
+   struct QXLRect *area, struct QXLRect *dirty_rects,
+   uint32_t num_dirty_rects, uint32_t 
clear_dirty_region,
+   int async)
+{
+if (async) {
+qxl-ssd.worker-update_area_async(qxl-ssd.worker, surface_id, area, 
dirty_rects,
+ num_dirty_rects, clear_dirty_region, 0);


Fails to build with older libspice.


+} else {
+qxl-ssd.worker-update_area(qxl-ssd.worker, surface_id, area, 
dirty_rects,
+ num_dirty_rects, clear_dirty_region);
+}
+}

  void qxl_spice_update_area(PCIQXLDevice *qxl, uint32_t surface_id,
 struct QXLRect *area, struct QXLRect *dirty_rects,
 uint32_t num_dirty_rects, uint32_t 
clear_dirty_region)
  {
-qxl-ssd.worker-update_area(qxl-ssd.worker, surface_id, area, 
dirty_rects,
- num_dirty_rects, clear_dirty_region);
+qxl_spice_update_area_async(qxl, surface_id, area, dirty_rects,
+num_dirty_rects, clear_dirty_region, 0);
  }


Pretty pointless wrapper IMHO.


-void qxl_spice_destroy_surface_wait(PCIQXLDevice *qxl, uint32_t id)
+static void qxl_spice_destroy_surface_wait_complete(PCIQXLDevice *qxl)
  {
  qemu_mutex_lock(qxl-track_lock);
-PANIC_ON(id= NUM_SURFACES);
-qxl-ssd.worker-destroy_surface_wait(qxl-ssd.worker, id);
-qxl-guest_surfaces.cmds[id] = 0;
+qxl-guest_surfaces.cmds[qxl-io_data.surface_id] = 0;


I'd suggest to pass in the surface id as argument instead.


  qxl-guest_surfaces.count--;
  qemu_mutex_unlock(qxl-track_lock);
  }

+static void qxl_spice_destroy_surface_wait_async(PCIQXLDevice *qxl, uint32_t 
id, int async)
+{
+qxl-io_data.surface_id = id;
+if (async) {
+qxl-ssd.worker-destroy_surface_wait_async(qxl-ssd.worker, id, 0);
+} else {
+qxl-ssd.worker-destroy_surface_wait(qxl-ssd.worker, id);
+qxl_spice_destroy_surface_wait_complete(qxl);


qxl_spice_destroy_surface_wait_complete(qxl, id);


+}
+}
+
  void qxl_spice_loadvm_commands(PCIQXLDevice *qxl, struct QXLCommandExt *ext,
 uint32_t count)
  {
@@ -171,15 +193,29 @@ void qxl_spice_reset_memslots(PCIQXLDevice *qxl)
  qxl-ssd.worker-reset_memslots(qxl-ssd.worker);
  }

-void qxl_spice_destroy_surfaces(PCIQXLDevice *qxl)
+static void qxl_spice_destroy_surfaces_complete(PCIQXLDevice *qxl)
  {
  qemu_mutex_lock(qxl-track_lock);
-qxl-ssd.worker-destroy_surfaces(qxl-ssd.worker);
  memset(qxl-guest_surfaces.cmds, 0, sizeof(qxl-guest_surfaces.cmds));
  qxl-guest_surfaces.count = 0;
  qemu_mutex_unlock(qxl-track_lock);
  }

+static void qxl_spice_destroy_surfaces(PCIQXLDevice *qxl)
+{
+qxl-ssd.worker-destroy_surfaces(qxl-ssd.worker);
+qxl_spice_destroy_surfaces_complete(qxl);
+}
+
+static void qxl_spice_destroy_surfaces_async(PCIQXLDevice *qxl, int async)
+{
+if (async) {
+qxl-ssd.worker-destroy_surfaces_async(qxl-ssd.worker, 0);
+} else {
+qxl_spice_destroy_surfaces(qxl);
+}
+}


I'd combine those into one function simliar to 
qxl_spice_destroy_surface_wait_async (and we don't need the _async 
suffix if we have a single version only which gets passed in async as 
argument).



+
  void qxl_spice_reset_image_cache(PCIQXLDevice *qxl)
  {
  qxl-ssd.worker-reset_image_cache(qxl-ssd.worker);
@@ -706,6 +742,38 @@ static int interface_flush_resources(QXLInstance *sin)
  return ret;
  }

+static void qxl_add_memslot_complete(PCIQXLDevice *d);
+static void qxl_create_guest_primary_complete(PCIQXLDevice *d);
+
+/* called from spice server thread context only */
+static void interface_async_complete(QXLInstance *sin, uint64_t cookie)
+{
+PCIQXLDevice *qxl = container_of(sin, PCIQXLDevice, ssd.qxl);
+uint32_t current_async;
+
+qemu_mutex_lock(qxl-async_lock);
+current_async = qxl-current_async;
+qxl-current_async = QXL_UNDEFINED_IO;
+qemu_mutex_unlock(qxl-async_lock);


I'd tend to use the cookie to pass that information (also the stuff in 
io_data).



-static void qxl_add_memslot(PCIQXLDevice *d, uint32_t slot_id, uint64_t delta)
+static void qxl_add_memslot_complete(PCIQXLDevice *d)


I think it isn't needed to move that to the completion callback.  Memory 
slots can be created and destroyed with I/O commands only, so there is 
no need to care about the ordering like we have to with surfaces.



  qemu_mutex_init(qxl-track_lock);
+qemu_mutex_init(qxl-async_lock);


Do we really need two locks?
When passing info via cookie, doesn't the need for the async lock go 
away completely?



index af10ae8..b7bc0de 100644
--- a/ui/spice-display.c
+++ b/ui/spice-display.c
@@ -62,6 +62,20 @@ void qemu_spice_rect_union(QXLRect *dest, const QXLRect *r)
  dest-right = MAX(dest-right, r-right);
  

Re: [Qemu-devel] Upstream Qemu With Xen configuration problem

2011-07-08 Thread Daniel Castro
 Date: Thu, 07 Jul 2011 14:29:43 -0400
 From: John Baboval john.babo...@virtualcomputer.com
 To: qemu-devel@nongnu.org
 Subject: Re: [Qemu-devel] Upstream Qemu With Xen configuration problem
 Message-ID: 4e15fb17.3030...@virtualcomputer.com
 Content-Type: text/plain; charset=ISO-8859-1; format=flowed

 I find I have to point at the src directories, and not the dist
 directory. My extra-cflags looks something like this:

 --extra-cflags=-I /path/to/xen/tools/include -L /path/to/xen/tools/libxc
 -I /path/to/xen/tools/libxc -L /path/to/xen/tools/xenstore -I
 /path/to/xen/tools/xenstore'

Thanks John, that helped, I also found out that somehow I am missing
the file xc_e820.h from /usr/include I had to manually copy it to that
location and all is working now.



 -John


 On 07/07/2011 01:17 PM, Daniel Castro wrote:
  Greetings,
 
  I am trying to configure Xen4.2 unstable with upstream qemu. I am
  running on a small problem when running the configuration of qemu,
  Qemu Config can not find Xen. I have debugged the Configuration script
  and the temp c file that qemu uses to detect xen version are returning
  empty string, hence the config script can tell xen version. Xen with
  staging branch works fine.
  My configure call is as follows:
  ./configure --enable-xen --target-list=i386-softmmu
  --extra-cflags=-I/usr/src/xen-unstable.hg/dist/install/usr/include
  --extra-ldflags=-L/usr/src/xen-unstable.hg/dist/install/usr/lib
  --enable-debug
 
  The contents of /usr/src/xen-unstable.hg/dist/install/usr/include are:
  blktaplib.h   libxl.h temp.c  xenguest.hxs_lib.h
  fsimage_grub.h_libxl_types.h  xen xenstat.h
  fsimage.h libxl_utils.h   xenctrl.h   xentoollog.h
  fsimage_plugin.h  libxl_uuid.hxenctrlosdep.h  xs.h
 
  The contents of /usr/src/xen-unstable.hg/dist/install/usr/lib are:
  python2.7  xen
 
  Qemu is on master branch 744d3644181ddb16ef5944a0f9217e46961c8c84
  pxa2xx_lcd: add proper rotation support
  Xen is on unstable branch 23608:2f63562df1c4 libxl: Do not SEGV when
  no 'removable' disk parameter in xenstore
 
  I can change xen changeset freely, but I can not change qemu changeset
  since I need some features present in qemu.
 
  Any help, or pointers are greatly appreciated.
 
  Thanks for your time,
 
  Daniel
 
 
 
 
 



Re: [Qemu-devel] SeaBIOS error with Juniper FreeBSD kernel

2011-07-08 Thread Bjørn Mork
Kevin O'Connor ke...@koconnor.net writes:
 On Thu, Jul 07, 2011 at 05:45:02PM +0200, Bjørn Mork wrote:
 It's been a while with little work and little progress on my side... But
 I looked at this again today, and found that it may be related to the
 SMBIOS table being allocated with malloc_high().  Does that make sense?
 
 Anyway, the problematic OS boots without problems with current seabios
 from git if I make this change:
 
 diff --git a/src/smbios.c b/src/smbios.c
 index 8df0f2d..c96deb5 100644
 --- a/src/smbios.c
 +++ b/src/smbios.c
 @@ -17,7 +17,7 @@ smbios_entry_point_init(u16 max_structure_size,
  u16 number_of_structures)
  {
  struct smbios_entry_point *ep = malloc_fseg(sizeof(*ep));
 -void *finaltable = malloc_high(structure_table_length);
 +void *finaltable = malloc_fseg(structure_table_length);
  if (!ep || !finaltable) {
  warn_noalloc();
  free(ep);

 Thanks.

 It's possible that the OS has an error in handling the SMBIOS when it
 is in high-memory (located above 1meg).  (For example, older versions
 of Linux crash when the mptable is in high memory.)

I looked at a couple of physical machines with vendor BIOSes, and they
seem to put the table in low memory:

# dmidecode 2.9
SMBIOS 2.4 present.
71 structures occupying 2506 bytes.
Table at 0x000F06F0.


# dmidecode 2.9
SMBIOS 2.4 present.
80 structures occupying 2858 bytes.
Table at 0x000E0010.


Makes me think that this would be the safest approach for SeaBIOS as
well.  With the patch above, I get this location:

# dmidecode 2.9
SMBIOS 2.4 present.
10 structures occupying 263 bytes.
Table at 0x000FDA00.


Without it, I get:

# dmidecode 2.9
SMBIOS 2.4 present.
10 structures occupying 263 bytes.
Table at 0x1EF0.



 However, it would be really odd for the OS to work some times with the
 SMBIOS in high memory and sometimes fail.

Yes.  Just to be perfectly clear: The crash with SMBIOS in high memory
happens every time with recent (anything from 2009 or later) SeaBIOS
versions.

I must admit that I right now am wondering whether I somehow screwed up
the previous testing of older versions.  I am not at all sure under what
circumstances older SeaBIOS would work with SMBIOS enabled.

 I tried malloc_low() too, and that works as well.  But malloc_fseg()
 seems appropriate, unless I've misunderstood something here.  Which very
 well can be.  I am not going to claim any understanding at all.

 malloc_low and malloc_fseg would both put the table in the first
 megabyte of physical ram.  Of the two, malloc_fseg would be
 preferable.

That's what I thought.  Glad I could be right about something :-)

 Does the above make any sense, or is this just another example of 
 tickling the underlying bug?

 I have to wonder if the reorganization of memory just caused the bug
 to not pop up.  If you disable SMBIOS, can you confirm the problem
 reliably goes away on multiple versions of SeaBIOS?

Yes.  Tested with current HEAD and with a number of revisions around the
beginning of 2009, i.e. version 0.4.0.  Just to be sure, I selected an
intermediate version as well: 0.5.1.  And I can confirm that the problem
goes away there too when I disable SMBIOS.


Bjørn



Re: [Qemu-devel] [PATCH 1/3] qemu: Add strtosz_suffix_unit function

2011-07-08 Thread Markus Armbruster
Joerg Roedel joerg.roe...@amd.com writes:

 This function does the same as the strtosz_suffix function
 except that it allows to specify the unit to which the
 k/M/B/T suffixes apply. This function will be used later to
 parse the tsc-frequency from the command-line.

 Signed-off-by: Joerg Roedel joerg.roe...@amd.com
 ---
  cutils.c  |   16 +++-
  qemu-common.h |2 ++
  2 files changed, 13 insertions(+), 5 deletions(-)

 diff --git a/cutils.c b/cutils.c
 index f9a7e36..28049e0 100644
 --- a/cutils.c
 +++ b/cutils.c
 @@ -322,7 +322,8 @@ int fcntl_setfl(int fd, int flag)
   * value must be terminated by whitespace, ',' or '\0'. Return -1 on
   * error.
   */
 -int64_t strtosz_suffix(const char *nptr, char **end, const char 
 default_suffix)
 +int64_t strtosz_suffix_unit(const char *nptr, char **end,
 +const char default_suffix, int64_t unit)
  {
  int64_t retval = -1;
  char *endptr;
 @@ -362,20 +363,20 @@ int64_t strtosz_suffix(const char *nptr, char **end, 
 const char default_suffix)
  }
  break;
  case STRTOSZ_DEFSUFFIX_KB:
 -mul = 1  10;
 +mul = unit;
  break;
  case 0:
  if (mul_required) {
  goto fail;
  }
  case STRTOSZ_DEFSUFFIX_MB:
 -mul = 1ULL  20;
 +mul = unit * unit;
  break;
  case STRTOSZ_DEFSUFFIX_GB:
 -mul = 1ULL  30;
 +mul = unit * unit * unit;
  break;
  case STRTOSZ_DEFSUFFIX_TB:
 -mul = 1ULL  40;
 +mul = unit * unit * unit * unit;
  break;
  default:
  goto fail;
 @@ -405,6 +406,11 @@ fail:
  return retval;
  }

Why would anyone ever call this function with an unit argument other
than 1000 or 1024?

Without such a use case, I'd rather give strtosz_suffix() a flag
parameter to pick SI prefixes (multiples of 1000) vs. binary prefixes
(multiples of 1024).

[...]



Re: [Qemu-devel] [PATCH v2] qxl: async I/O

2011-07-08 Thread Gerd Hoffmann

The above two lines change was a mistake. What about:

qxl_spice_update_area_async(...)
{
#ifdef ..
  if (async) {
 qxl-ssd.worker-update_area_async(...)
  } else {
 qxl_spice_update_area(...)
  }
#else
  qxl_spice_update_area(...)
#endif
}


I would do

if (async) {
#if ...
  worker-foo_async()
#else
  abort() /* should hot happen */
#endif
} else {
  worker-foo
}


yeah, I'll throw that, malloc something, cast to cookie, pass it, cast back, 
free.


cookie should be big enougth to store the info directly.  malloc works 
too though.



Doing a runtime check here is pointless, just use
#if SPICE_INTERFACE_QXL_MINOR= 1
...
#endif

this is a runtime check - what's preventing someone from compiling with 3.1 and 
running with 3.0?
that we will require a newer library version? (which I am yet to send a patch 
for)


Yes, thats why the minor version of the shared library needs to be raised.

cheers,
  Gerd



Re: [Qemu-devel] [PATCH v2] qxl: async I/O

2011-07-08 Thread Gerd Hoffmann

btw, I'm looking at #if.*MINOR code like

  #if SPICE_INTERFACE_CORE_MINOR= 3

(ui/spice-core.c)

Shouldn't that be checking the MAJOR as well?


major changing means a incompatible change.  I doubt we ever will do 
that.  But if you feel better checking that it probably should just be a


#if SPICE_INTERFACE_CORE_MAJOR != 1
#error incompatible spice core interface
#endif

at the top of the file.

cheers,
  Gerd




Re: [Qemu-devel] [PATCH v2] qxl: async I/O

2011-07-08 Thread Alon Levy
On Fri, Jul 08, 2011 at 09:17:50AM +0200, Gerd Hoffmann wrote:
 +void qxl_spice_update_area_async(PCIQXLDevice *qxl, uint32_t surface_id,
 +   struct QXLRect *area, struct QXLRect 
 *dirty_rects,
 +   uint32_t num_dirty_rects, uint32_t 
 clear_dirty_region,
 +   int async)
 +{
 +if (async) {
 +qxl-ssd.worker-update_area_async(qxl-ssd.worker, surface_id, 
 area, dirty_rects,
 + num_dirty_rects, clear_dirty_region, 0);
 
 Fails to build with older libspice.

 
 +} else {
 +qxl-ssd.worker-update_area(qxl-ssd.worker, surface_id, area, 
 dirty_rects,
 + num_dirty_rects, clear_dirty_region);
 +}
 +}
 
   void qxl_spice_update_area(PCIQXLDevice *qxl, uint32_t surface_id,
  struct QXLRect *area, struct QXLRect 
  *dirty_rects,
  uint32_t num_dirty_rects, uint32_t 
  clear_dirty_region)
   {
 -qxl-ssd.worker-update_area(qxl-ssd.worker, surface_id, area, 
 dirty_rects,
 - num_dirty_rects, clear_dirty_region);
 +qxl_spice_update_area_async(qxl, surface_id, area, dirty_rects,
 +num_dirty_rects, clear_dirty_region, 0);
   }
 
 Pretty pointless wrapper IMHO.

The above two lines change was a mistake. What about:

qxl_spice_update_area_async(...)
{
#ifdef ..
 if (async) {
qxl-ssd.worker-update_area_async(...)
 } else {
qxl_spice_update_area(...)
 }
#else
 qxl_spice_update_area(...)
#endif
}

 
 -void qxl_spice_destroy_surface_wait(PCIQXLDevice *qxl, uint32_t id)
 +static void qxl_spice_destroy_surface_wait_complete(PCIQXLDevice *qxl)
   {
   qemu_mutex_lock(qxl-track_lock);
 -PANIC_ON(id= NUM_SURFACES);
 -qxl-ssd.worker-destroy_surface_wait(qxl-ssd.worker, id);
 -qxl-guest_surfaces.cmds[id] = 0;
 +qxl-guest_surfaces.cmds[qxl-io_data.surface_id] = 0;
 
 I'd suggest to pass in the surface id as argument instead.

I can use the cookie if that's what you mean (which I guess means it will make
more sense to define it as a void pointer).
 
   qxl-guest_surfaces.count--;
   qemu_mutex_unlock(qxl-track_lock);
   }
 
 +static void qxl_spice_destroy_surface_wait_async(PCIQXLDevice *qxl, 
 uint32_t id, int async)
 +{
 +qxl-io_data.surface_id = id;
 +if (async) {
 +qxl-ssd.worker-destroy_surface_wait_async(qxl-ssd.worker, id, 0);
 +} else {
 +qxl-ssd.worker-destroy_surface_wait(qxl-ssd.worker, id);
 +qxl_spice_destroy_surface_wait_complete(qxl);
 
 qxl_spice_destroy_surface_wait_complete(qxl, id);
and use the cookie on the async_complete with appropriate casting and free, got 
it.

 
 +}
 +}
 +
   void qxl_spice_loadvm_commands(PCIQXLDevice *qxl, struct QXLCommandExt 
  *ext,
  uint32_t count)
   {
 @@ -171,15 +193,29 @@ void qxl_spice_reset_memslots(PCIQXLDevice *qxl)
   qxl-ssd.worker-reset_memslots(qxl-ssd.worker);
   }
 
 -void qxl_spice_destroy_surfaces(PCIQXLDevice *qxl)
 +static void qxl_spice_destroy_surfaces_complete(PCIQXLDevice *qxl)
   {
   qemu_mutex_lock(qxl-track_lock);
 -qxl-ssd.worker-destroy_surfaces(qxl-ssd.worker);
   memset(qxl-guest_surfaces.cmds, 0, sizeof(qxl-guest_surfaces.cmds));
   qxl-guest_surfaces.count = 0;
   qemu_mutex_unlock(qxl-track_lock);
   }
 
 +static void qxl_spice_destroy_surfaces(PCIQXLDevice *qxl)
 +{
 +qxl-ssd.worker-destroy_surfaces(qxl-ssd.worker);
 +qxl_spice_destroy_surfaces_complete(qxl);
 +}
 +
 +static void qxl_spice_destroy_surfaces_async(PCIQXLDevice *qxl, int async)
 +{
 +if (async) {
 +qxl-ssd.worker-destroy_surfaces_async(qxl-ssd.worker, 0);
 +} else {
 +qxl_spice_destroy_surfaces(qxl);
 +}
 +}
 
 I'd combine those into one function simliar to
 qxl_spice_destroy_surface_wait_async (and we don't need the _async
 suffix if we have a single version only which gets passed in async
 as argument).
ok, I'll ditch the suffix.

 
 +
   void qxl_spice_reset_image_cache(PCIQXLDevice *qxl)
   {
   qxl-ssd.worker-reset_image_cache(qxl-ssd.worker);
 @@ -706,6 +742,38 @@ static int interface_flush_resources(QXLInstance *sin)
   return ret;
   }
 
 +static void qxl_add_memslot_complete(PCIQXLDevice *d);
 +static void qxl_create_guest_primary_complete(PCIQXLDevice *d);
 +
 +/* called from spice server thread context only */
 +static void interface_async_complete(QXLInstance *sin, uint64_t cookie)
 +{
 +PCIQXLDevice *qxl = container_of(sin, PCIQXLDevice, ssd.qxl);
 +uint32_t current_async;
 +
 +qemu_mutex_lock(qxl-async_lock);
 +current_async = qxl-current_async;
 +qxl-current_async = QXL_UNDEFINED_IO;
 +qemu_mutex_unlock(qxl-async_lock);
 
 I'd tend to use the cookie to pass that information (also the stuff
 in io_data).

yeah, I'll throw that, malloc something, cast to cookie, pass it, cast back, 
free.

 
 

Re: [Qemu-devel] [PATCH v2] qxl: async I/O

2011-07-08 Thread Alon Levy
On Fri, Jul 08, 2011 at 09:17:50AM +0200, Gerd Hoffmann wrote:
 +void qxl_spice_update_area_async(PCIQXLDevice *qxl, uint32_t surface_id,
 +   struct QXLRect *area, struct QXLRect 
 *dirty_rects,
 +   uint32_t num_dirty_rects, uint32_t 
 clear_dirty_region,
 +   int async)
 +{
 +if (async) {
 +qxl-ssd.worker-update_area_async(qxl-ssd.worker, surface_id, 
 area, dirty_rects,
 + num_dirty_rects, clear_dirty_region, 0);
 
 Fails to build with older libspice.

btw, I'm looking at #if.*MINOR code like

 #if SPICE_INTERFACE_CORE_MINOR = 3

(ui/spice-core.c)

Shouldn't that be checking the MAJOR as well?

[snip]



Re: [Qemu-devel] [PATCH v2] qxl: bump pci rev

2011-07-08 Thread Alon Levy
On Fri, Jul 08, 2011 at 09:19:10AM +0200, Gerd Hoffmann wrote:
   Hi,
 
 -DEFINE_PROP_UINT32(revision, PCIQXLDevice, revision, 2),
 +DEFINE_PROP_UINT32(revision, PCIQXLDevice, revision, 3),
 
 Can't be done unconditionally.  With an older libspice we can't
 support the rev3 features.

ok. so this needs a runtime check for major_version.minor_version = 3.1, no? a 
compile
time won't work because someone can change the shared object, no? (maybe I 
should just
check this scenario).

 
 cheers,
   Gerd



Re: [Qemu-devel] [PATCH] qemu-options.hx: Document werror and rerror -drive options

2011-07-08 Thread Kevin Wolf
Am 07.07.2011 18:04, schrieb Luiz Capitulino:
 
 Signed-off-by: Luiz Capitulino lcapitul...@redhat.com
 ---
  qemu-options.hx |5 +
  1 files changed, 5 insertions(+), 0 deletions(-)
 
 diff --git a/qemu-options.hx b/qemu-options.hx
 index e6d7adc..5f16a78 100644
 --- a/qemu-options.hx
 +++ b/qemu-options.hx
 @@ -160,6 +160,11 @@ an untrusted format header.
  This option specifies the serial number to assign to the device.
  @item addr=@var{addr}
  Specify the controller's PCI address (if=virtio only).
 +@item werror=@var{action},rerror=@var{action}
 +Specify which @var{action} to take on write and read errors. Valid actions 
 are:
 +ignore (ignore the error and try to continue), stop (pause QEMU),
 +enospc (pause QEMU, but only on no space conditions),

Maybe pause QEMU only if the host disk is full; report the error to the
guest otherwise?

 +report (report the error to the guest).
  @end table
  
  By default, writethrough caching is used for all block device.  This means 
 that

We should mention that werror=enospc and rerror=report is the default.

Kevin



[Qemu-devel] [PATCH 2/3] ahci doesn't support migration

2011-07-08 Thread Gerd Hoffmann
Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 hw/ide/ich.c |6 ++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/hw/ide/ich.c b/hw/ide/ich.c
index 054e073..0f26603 100644
--- a/hw/ide/ich.c
+++ b/hw/ide/ich.c
@@ -72,6 +72,11 @@
 #include hw/ide/pci.h
 #include hw/ide/ahci.h
 
+static const VMStateDescription vmstate_ahci = {
+.name = ahci,
+.no_migrate = 1,
+};
+
 static int pci_ich9_ahci_init(PCIDevice *dev)
 {
 struct AHCIPCIState *d;
@@ -123,6 +128,7 @@ static PCIDeviceInfo ich_ahci_info[] = {
 .qdev.name= ich9-ahci,
 .qdev.alias   = ahci,
 .qdev.size= sizeof(AHCIPCIState),
+.qdev.vmsd= vmstate_ahci,
 .init = pci_ich9_ahci_init,
 .exit = pci_ich9_uninit,
 .config_write = pci_ich9_write_config,
-- 
1.7.1




[Qemu-devel] [PATCH 1/3] vmstate: add no_migrate flag to VMStateDescription

2011-07-08 Thread Gerd Hoffmann
This allows to easily tag devices as non-migratable,
so any attempt to migrate a virtual machine with the
device in question active will make migration fail.

Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 hw/hw.h  |1 +
 savevm.c |1 +
 2 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/hw/hw.h b/hw/hw.h
index 9dd7096..1eb3486 100644
--- a/hw/hw.h
+++ b/hw/hw.h
@@ -324,6 +324,7 @@ typedef struct VMStateSubsection {
 
 struct VMStateDescription {
 const char *name;
+int no_migrate;
 int version_id;
 int minimum_version_id;
 int minimum_version_id_old;
diff --git a/savevm.c b/savevm.c
index 8139bc7..fa2da3e 100644
--- a/savevm.c
+++ b/savevm.c
@@ -1234,6 +1234,7 @@ int vmstate_register_with_alias_id(DeviceState *dev, int 
instance_id,
 se-opaque = opaque;
 se-vmsd = vmsd;
 se-alias_id = alias_id;
+se-no_migrate = vmsd-no_migrate;
 
 if (dev  dev-parent_bus  dev-parent_bus-info-get_dev_path) {
 char *id = dev-parent_bus-info-get_dev_path(dev);
-- 
1.7.1




[Qemu-devel] [PATCH 3/3] ehci doesn't support migration

2011-07-08 Thread Gerd Hoffmann
Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 hw/usb-ehci.c |6 ++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/hw/usb-ehci.c b/hw/usb-ehci.c
index 91fb7de..a0449be 100644
--- a/hw/usb-ehci.c
+++ b/hw/usb-ehci.c
@@ -2136,9 +2136,15 @@ static USBBusOps ehci_bus_ops = {
 .device_destroy = ehci_device_destroy,
 };
 
+static const VMStateDescription vmstate_ehci = {
+.name = ehci,
+.no_migrate = 1,
+};
+
 static PCIDeviceInfo ehci_info = {
 .qdev.name= usb-ehci,
 .qdev.size= sizeof(EHCIState),
+.qdev.vmsd= vmstate_ehci,
 .init = usb_ehci_initfn,
 .vendor_id= PCI_VENDOR_ID_INTEL,
 .device_id= PCI_DEVICE_ID_INTEL_82801D,
-- 
1.7.1




[Qemu-devel] [PATCH 0/3] non-migratable devices

2011-07-08 Thread Gerd Hoffmann
  Hi,

This patch series adds an easy way to tag devices as non-migratable
puts it into use for ahci and ehci.

Gerd Hoffmann (3):
  vmstate: add no_migrate flag to VMStateDescription
  ahci doesn't support migration
  ehci doesn't support migration

 hw/hw.h   |1 +
 hw/ide/ich.c  |6 ++
 hw/usb-ehci.c |6 ++
 savevm.c  |1 +
 4 files changed, 14 insertions(+), 0 deletions(-)




[Qemu-devel] [Discuss] is it good to add codes providing information to libvirt about the qemu's capabilities

2011-07-08 Thread Wayne Xia
   Currently libvirt seems to invoke qemu by qemu -help onetime, and
then analysis the output text to find whether one type of device the
qemu could support. For example, if qemu -help prints a text with
-sdl then libvirt thought the qemu could accept that.
But here comes a problem: the output text seems not to adjust its
output according to the qemu's compile configuration, so it is possible
libvirt invoke qemu with -sdl but get qemu exit response that SDL
support is disabled. By default, the sdl is disabled, and the libvirt
thought it is on.
I wonder if it is a good idea to modify the help function in vl.c,
to let it adjust -help output according to the configuration, but this
would hide some option of -help invocation.



-- 
Best Regards

Wayne Xia
mail:xiaw...@linux.vnet.ibm.com
tel:86-010-82450803




[Qemu-devel] [PATCH 02/23] usb: Add a usb_fill_port helper function

2011-07-08 Thread Gerd Hoffmann
From: Hans de Goede hdego...@redhat.com

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

diff --git a/hw/usb-bus.c b/hw/usb-bus.c
index 2abce12..776974e 100644
--- a/hw/usb-bus.c
+++ b/hw/usb-bus.c
@@ -140,8 +140,8 @@ USBDevice *usb_create_simple(USBBus *bus, const char *name)
 return dev;
 }
 
-void usb_register_port(USBBus *bus, USBPort *port, void *opaque, int index,
-   USBPortOps *ops, int speedmask)
+static void usb_fill_port(USBPort *port, void *opaque, int index,
+  USBPortOps *ops, int speedmask)
 {
 port-opaque = opaque;
 port-index = index;
@@ -149,6 +149,12 @@ void usb_register_port(USBBus *bus, USBPort *port, void 
*opaque, int index,
 port-index = index;
 port-ops = ops;
 port-speedmask = speedmask;
+}
+
+void usb_register_port(USBBus *bus, USBPort *port, void *opaque, int index,
+   USBPortOps *ops, int speedmask)
+{
+usb_fill_port(port, opaque, index, ops, speedmask);
 QTAILQ_INSERT_TAIL(bus-free, port, next);
 bus-nfree++;
 }
-- 
1.7.1




[Qemu-devel] [PULL] usb patch queue

2011-07-08 Thread Gerd Hoffmann
  Hi,

Here is the current usb patch queue.  Most noteworthy is the usb
companion controller support added.  There are also a bunch of bug
fixes, some from Hans which he found while doing the companion
controller work and some have been found in patch review.

please pull,
  Gerd

The following changes since commit 9312805d33e8b106bae356d13a8071fb37d75554:

  pxa2xx_lcd: add proper rotation support (2011-07-04 22:12:21 +0200)

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

Gerd Hoffmann (8):
  pci: add ich9 usb controller ids
  uhci: add ich9 controllers
  ehci: fix port count.
  ehci: add ich9 controller.
  usb: update documentation
  usb: fixup bluetooth descriptors
  usb-hub: remove unused descriptor arrays
  usb-ohci: raise interrupt on attach

Hans de Goede (13):
  usb: Add a usb_fill_port helper function
  usb: Move (initial) call of usb_port_location to usb_fill_port
  usb: Add a register_companion USB bus op.
  usb: Make port wakeup and complete ops take a USBPort instead of a Device
  usb: Replace device_destroy bus op with a child_detach port op
  usb-ehci: drop unused num-ports state member
  usb-ehci: Connect Status bit is read only, don't allow changing it by the 
guest
  usb-ehci: cleanup port reset handling
  usb: assert on calling usb_attach(port, NULL) on a port without a dev
  usb-ehci: Fix handling of PED and PEDC port status bits
  usb-ehci: Add support for registering companion controllers
  usb-uhci: Add support for being a companion controller
  usb-ohci: Add support for being a companion controller

Jes Sorensen (1):
  usb_register_port(): do not set port-opaque and port-index twice

Peter Maydell (1):
  hw/usb-musb.c: Don't misuse usb_packet_complete()

 docs/ich9-ehci-uhci.cfg |   37 +++
 docs/usb2.txt   |   33 +-
 hw/milkymist-softusb.c  |9 ++-
 hw/pci_ids.h|8 ++
 hw/usb-bt.c |   24 ++--
 hw/usb-bus.c|   46 +++-
 hw/usb-ehci.c   |  270 ++-
 hw/usb-hub.c|   90 +++-
 hw/usb-musb.c   |   24 +++--
 hw/usb-ohci.c   |   89 +++-
 hw/usb-uhci.c   |   95 +
 hw/usb.c|   13 +--
 hw/usb.h|   20 +++-
 13 files changed, 523 insertions(+), 235 deletions(-)
 create mode 100644 docs/ich9-ehci-uhci.cfg



[Qemu-devel] [PATCH 03/23] usb: Move (initial) call of usb_port_location to usb_fill_port

2011-07-08 Thread Gerd Hoffmann
From: Hans de Goede hdego...@redhat.com

Cleanup / preparation patch for companion controller support. Note that
as a side-effect this patch also fixes the milkymist-softusb controller
not having a port_location set for its ports.

Signed-off-by: Hans de Goede hdego...@redhat.com
Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 hw/usb-bus.c  |1 +
 hw/usb-ehci.c |1 -
 hw/usb-musb.c |1 -
 hw/usb-ohci.c |1 -
 hw/usb-uhci.c |1 -
 5 files changed, 1 insertions(+), 4 deletions(-)

diff --git a/hw/usb-bus.c b/hw/usb-bus.c
index 776974e..e37e8a2 100644
--- a/hw/usb-bus.c
+++ b/hw/usb-bus.c
@@ -149,6 +149,7 @@ static void usb_fill_port(USBPort *port, void *opaque, int 
index,
 port-index = index;
 port-ops = ops;
 port-speedmask = speedmask;
+usb_port_location(port, NULL, index + 1);
 }
 
 void usb_register_port(USBBus *bus, USBPort *port, void *opaque, int index,
diff --git a/hw/usb-ehci.c b/hw/usb-ehci.c
index 91fb7de..88cb2c2 100644
--- a/hw/usb-ehci.c
+++ b/hw/usb-ehci.c
@@ -2206,7 +2206,6 @@ static int usb_ehci_initfn(PCIDevice *dev)
 for(i = 0; i  NB_PORTS; i++) {
 usb_register_port(s-bus, s-ports[i], s, i, ehci_port_ops,
   USB_SPEED_MASK_HIGH);
-usb_port_location(s-ports[i], NULL, i+1);
 s-ports[i].dev = 0;
 }
 
diff --git a/hw/usb-musb.c b/hw/usb-musb.c
index d15971f..84e6017 100644
--- a/hw/usb-musb.c
+++ b/hw/usb-musb.c
@@ -369,7 +369,6 @@ struct MUSBState *musb_init(qemu_irq *irqs)
 usb_bus_new(s-bus, musb_bus_ops, NULL /* FIXME */);
 usb_register_port(s-bus, s-port, s, 0, musb_port_ops,
   USB_SPEED_MASK_LOW | USB_SPEED_MASK_FULL);
-usb_port_location(s-port, NULL, 1);
 
 return s;
 }
diff --git a/hw/usb-ohci.c b/hw/usb-ohci.c
index 1c29b9f..95e4623 100644
--- a/hw/usb-ohci.c
+++ b/hw/usb-ohci.c
@@ -1742,7 +1742,6 @@ static void usb_ohci_init(OHCIState *ohci, DeviceState 
*dev,
 for (i = 0; i  num_ports; i++) {
 usb_register_port(ohci-bus, ohci-rhport[i].port, ohci, i, 
ohci_port_ops,
   USB_SPEED_MASK_LOW | USB_SPEED_MASK_FULL);
-usb_port_location(ohci-rhport[i].port, NULL, i+1);
 }
 
 ohci-async_td = 0;
diff --git a/hw/usb-uhci.c b/hw/usb-uhci.c
index 405fa7b..fd25d2a 100644
--- a/hw/usb-uhci.c
+++ b/hw/usb-uhci.c
@@ -1129,7 +1129,6 @@ static int usb_uhci_common_initfn(PCIDevice *dev)
 for(i = 0; i  NB_PORTS; i++) {
 usb_register_port(s-bus, s-ports[i].port, s, i, uhci_port_ops,
   USB_SPEED_MASK_LOW | USB_SPEED_MASK_FULL);
-usb_port_location(s-ports[i].port, NULL, i+1);
 }
 s-frame_timer = qemu_new_timer_ns(vm_clock, uhci_frame_timer, s);
 s-num_ports_vmstate = NB_PORTS;
-- 
1.7.1




[Qemu-devel] [PATCH 14/23] usb-ohci: Add support for being a companion controller

2011-07-08 Thread Gerd Hoffmann
From: Hans de Goede hdego...@redhat.com

To use as a companion controller, use pci-ohci as device and set the
masterbus and num-ports properties, ie:

-device usb-ehci,addr=0b.1,multifunction=on,id=ehci0
-device pci-ohci,addr=0b.0,multifunction=on,masterbus=ehci0.0,num-ports=4

Signed-off-by: Hans de Goede hdego...@redhat.com
Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 hw/usb-ohci.c |   52 
 1 files changed, 40 insertions(+), 12 deletions(-)

diff --git a/hw/usb-ohci.c b/hw/usb-ohci.c
index 46f0bcb..c77a20e 100644
--- a/hw/usb-ohci.c
+++ b/hw/usb-ohci.c
@@ -1716,8 +1716,9 @@ static USBPortOps ohci_port_ops = {
 static USBBusOps ohci_bus_ops = {
 };
 
-static void usb_ohci_init(OHCIState *ohci, DeviceState *dev,
-  int num_ports, uint32_t localmem_base)
+static int usb_ohci_init(OHCIState *ohci, DeviceState *dev,
+ int num_ports, uint32_t localmem_base,
+ char *masterbus, uint32_t firstport)
 {
 int i;
 
@@ -1737,38 +1738,58 @@ static void usb_ohci_init(OHCIState *ohci, DeviceState 
*dev,
 usb_frame_time, usb_bit_time);
 }
 
+ohci-num_ports = num_ports;
+if (masterbus) {
+USBPort *ports[OHCI_MAX_PORTS];
+for(i = 0; i  num_ports; i++) {
+ports[i] = ohci-rhport[i].port;
+}
+if (usb_register_companion(masterbus, ports, num_ports,
+firstport, ohci, ohci_port_ops,
+USB_SPEED_MASK_LOW | USB_SPEED_MASK_FULL) != 0) {
+return -1;
+}
+} else {
+usb_bus_new(ohci-bus, ohci_bus_ops, dev);
+for (i = 0; i  num_ports; i++) {
+usb_register_port(ohci-bus, ohci-rhport[i].port,
+  ohci, i, ohci_port_ops,
+  USB_SPEED_MASK_LOW | USB_SPEED_MASK_FULL);
+}
+}
+
 ohci-mem = cpu_register_io_memory(ohci_readfn, ohci_writefn, ohci,
DEVICE_LITTLE_ENDIAN);
 ohci-localmem_base = localmem_base;
 
 ohci-name = dev-info-name;
 
-usb_bus_new(ohci-bus, ohci_bus_ops, dev);
-ohci-num_ports = num_ports;
-for (i = 0; i  num_ports; i++) {
-usb_register_port(ohci-bus, ohci-rhport[i].port, ohci, i, 
ohci_port_ops,
-  USB_SPEED_MASK_LOW | USB_SPEED_MASK_FULL);
-}
-
 ohci-async_td = 0;
 qemu_register_reset(ohci_reset, ohci);
+
+return 0;
 }
 
 typedef struct {
 PCIDevice pci_dev;
 OHCIState state;
+char *masterbus;
+uint32_t num_ports;
+uint32_t firstport;
 } OHCIPCIState;
 
 static int usb_ohci_initfn_pci(struct PCIDevice *dev)
 {
 OHCIPCIState *ohci = DO_UPCAST(OHCIPCIState, pci_dev, dev);
-int num_ports = 3;
 
 ohci-pci_dev.config[PCI_CLASS_PROG] = 0x10; /* OHCI */
 /* TODO: RST# value should be 0. */
 ohci-pci_dev.config[PCI_INTERRUPT_PIN] = 0x01; /* interrupt pin 1 */
 
-usb_ohci_init(ohci-state, dev-qdev, num_ports, 0);
+if (usb_ohci_init(ohci-state, dev-qdev, ohci-num_ports, 0,
+  ohci-masterbus, ohci-firstport) != 0) {
+return -1;
+}
 ohci-state.irq = ohci-pci_dev.irq[0];
 
 /* TODO: avoid cast below by using dev */
@@ -1792,7 +1813,8 @@ static int ohci_init_pxa(SysBusDevice *dev)
 {
 OHCISysBusState *s = FROM_SYSBUS(OHCISysBusState, dev);
 
-usb_ohci_init(s-ohci, dev-qdev, s-num_ports, s-dma_offset);
+/* Cannot fail as we pass NULL for masterbus */
+usb_ohci_init(s-ohci, dev-qdev, s-num_ports, s-dma_offset, NULL, 0);
 sysbus_init_irq(dev, s-ohci.irq);
 sysbus_init_mmio(dev, 0x1000, s-ohci.mem);
 
@@ -1807,6 +1829,12 @@ static PCIDeviceInfo ohci_pci_info = {
 .vendor_id= PCI_VENDOR_ID_APPLE,
 .device_id= PCI_DEVICE_ID_APPLE_IPID_USB,
 .class_id = PCI_CLASS_SERIAL_USB,
+.qdev.props   = (Property[]) {
+DEFINE_PROP_STRING(masterbus, OHCIPCIState, masterbus),
+DEFINE_PROP_UINT32(num-ports, OHCIPCIState, num_ports, 3),
+DEFINE_PROP_UINT32(firstport, OHCIPCIState, firstport, 0),
+DEFINE_PROP_END_OF_LIST(),
+},
 };
 
 static SysBusDeviceInfo ohci_sysbus_info = {
-- 
1.7.1




[Qemu-devel] [PATCH 10/23] usb: assert on calling usb_attach(port, NULL) on a port without a dev

2011-07-08 Thread Gerd Hoffmann
From: Hans de Goede hdego...@redhat.com

with the usb-ehci: cleanup port reset handling patch in place no callers
are calling usb_attach(port, NULL) for a port where port-dev is NULL.

Doing that makes no sense as that causes the port detach op to get called
for a port with nothing attached. Add an assert that port-dev != NULL when
dev == NULL, and remove the check for not having a port-dev in the dev == NULL
case.

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

diff --git a/hw/usb.c b/hw/usb.c
index 735ffd1..27a983c 100644
--- a/hw/usb.c
+++ b/hw/usb.c
@@ -40,12 +40,11 @@ void usb_attach(USBPort *port, USBDevice *dev)
 } else {
 /* detach */
 dev = port-dev;
+assert(dev);
 port-ops-detach(port);
-if (dev) {
-usb_send_msg(dev, USB_MSG_DETACH);
-dev-port = NULL;
-port-dev = NULL;
-}
+usb_send_msg(dev, USB_MSG_DETACH);
+dev-port = NULL;
+port-dev = NULL;
 }
 }
 
-- 
1.7.1




[Qemu-devel] [PATCH 08/23] usb-ehci: Connect Status bit is read only, don't allow changing it by the guest

2011-07-08 Thread Gerd Hoffmann
From: Hans de Goede hdego...@redhat.com

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

diff --git a/hw/usb-ehci.c b/hw/usb-ehci.c
index 87e1de3..ce1a432 100644
--- a/hw/usb-ehci.c
+++ b/hw/usb-ehci.c
@@ -103,10 +103,10 @@
 #define PORTSC_BEGIN PORTSC
 #define PORTSC_END   (PORTSC + 4 * NB_PORTS)
 /*
- * Bits that are reserverd or are read-only are masked out of values
+ * Bits that are reserved or are read-only are masked out of values
  * written to us by software
  */
-#define PORTSC_RO_MASK   0x007021c5
+#define PORTSC_RO_MASK   0x007021c4
 #define PORTSC_RWC_MASK  0x002a
 #define PORTSC_WKOC_E(1  22)// Wake on Over Current Enable
 #define PORTSC_WKDS_E(1  21)// Wake on Disconnect Enable
-- 
1.7.1




[Qemu-devel] [PATCH 04/23] usb: Add a register_companion USB bus op.

2011-07-08 Thread Gerd Hoffmann
From: Hans de Goede hdego...@redhat.com

This is a preparation patch for adding support for USB companion controllers.

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

diff --git a/hw/usb-bus.c b/hw/usb-bus.c
index e37e8a2..b511bac 100644
--- a/hw/usb-bus.c
+++ b/hw/usb-bus.c
@@ -160,6 +160,37 @@ void usb_register_port(USBBus *bus, USBPort *port, void 
*opaque, int index,
 bus-nfree++;
 }
 
+int usb_register_companion(const char *masterbus, USBPort *ports[],
+   uint32_t portcount, uint32_t firstport,
+   void *opaque, USBPortOps *ops, int speedmask)
+{
+USBBus *bus;
+int i;
+
+QTAILQ_FOREACH(bus, busses, next) {
+if (strcmp(bus-qbus.name, masterbus) == 0) {
+break;
+}
+}
+
+if (!bus || !bus-ops-register_companion) {
+qerror_report(QERR_INVALID_PARAMETER_VALUE, masterbus,
+  an USB masterbus);
+if (bus) {
+error_printf_unless_qmp(
+USB bus '%s' does not allow companion controllers\n,
+masterbus);
+}
+return -1;
+}
+
+for (i = 0; i  portcount; i++) {
+usb_fill_port(ports[i], opaque, i, ops, speedmask);
+}
+
+return bus-ops-register_companion(bus, ports, portcount, firstport);
+}
+
 void usb_port_location(USBPort *downstream, USBPort *upstream, int portnr)
 {
 if (upstream) {
diff --git a/hw/usb.h b/hw/usb.h
index 076e2ff..a5f2efa 100644
--- a/hw/usb.h
+++ b/hw/usb.h
@@ -344,6 +344,8 @@ struct USBBus {
 };
 
 struct USBBusOps {
+int (*register_companion)(USBBus *bus, USBPort *ports[],
+  uint32_t portcount, uint32_t firstport);
 void (*device_destroy)(USBBus *bus, USBDevice *dev);
 };
 
@@ -356,6 +358,9 @@ USBDevice *usb_create_simple(USBBus *bus, const char *name);
 USBDevice *usbdevice_create(const char *cmdline);
 void usb_register_port(USBBus *bus, USBPort *port, void *opaque, int index,
USBPortOps *ops, int speedmask);
+int usb_register_companion(const char *masterbus, USBPort *ports[],
+   uint32_t portcount, uint32_t firstport,
+   void *opaque, USBPortOps *ops, int speedmask);
 void usb_port_location(USBPort *downstream, USBPort *upstream, int portnr);
 void usb_unregister_port(USBBus *bus, USBPort *port);
 int usb_device_attach(USBDevice *dev);
-- 
1.7.1




[Qemu-devel] [PATCH 17/23] ehci: fix port count.

2011-07-08 Thread Gerd Hoffmann
The ICH4 EHCI controller which we emulate has six ports not four.

Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 hw/usb-ehci.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/hw/usb-ehci.c b/hw/usb-ehci.c
index ec68c29..0b959ca 100644
--- a/hw/usb-ehci.c
+++ b/hw/usb-ehci.c
@@ -130,7 +130,7 @@
 #define FRAME_TIMER_NS   (10 / FRAME_TIMER_FREQ)
 
 #define NB_MAXINTRATE8// Max rate at which controller issues ints
-#define NB_PORTS 4// Number of downstream ports
+#define NB_PORTS 6// Number of downstream ports
 #define BUFF_SIZE5*4096   // Max bytes to transfer per transaction
 #define MAX_ITERATIONS   20   // Max number of QH before we break the loop
 #define MAX_QH   100  // Max allowable queue heads in a chain
-- 
1.7.1




[Qemu-devel] [PATCH 11/23] usb-ehci: Fix handling of PED and PEDC port status bits

2011-07-08 Thread Gerd Hoffmann
From: Hans de Goede hdego...@redhat.com

The PED bit should only be set for highspeed devices and the PEDC bit
should not be set on normal PED bit changes, only on io errors.

Signed-off-by: Hans de Goede hdego...@redhat.com
Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 hw/usb-ehci.c |   24 +++-
 1 files changed, 11 insertions(+), 13 deletions(-)

diff --git a/hw/usb-ehci.c b/hw/usb-ehci.c
index d85e0a9..973c342 100644
--- a/hw/usb-ehci.c
+++ b/hw/usb-ehci.c
@@ -106,7 +106,7 @@
  * Bits that are reserved or are read-only are masked out of values
  * written to us by software
  */
-#define PORTSC_RO_MASK   0x007021c4
+#define PORTSC_RO_MASK   0x007021c0
 #define PORTSC_RWC_MASK  0x002a
 #define PORTSC_WKOC_E(1  22)// Wake on Over Current Enable
 #define PORTSC_WKDS_E(1  21)// Wake on Disconnect Enable
@@ -752,7 +752,7 @@ static void ehci_detach(USBPort *port)
 
 ehci_queues_rip_device(s, port-dev);
 
-*portsc = ~PORTSC_CONNECT;
+*portsc = ~(PORTSC_CONNECT|PORTSC_PED);
 *portsc |= PORTSC_CSC;
 
 /*
@@ -847,16 +847,14 @@ static void ehci_mem_writew(void *ptr, target_phys_addr_t 
addr, uint32_t val)
 static void handle_port_status_write(EHCIState *s, int port, uint32_t val)
 {
 uint32_t *portsc = s-portsc[port];
-int rwc;
 USBDevice *dev = s-ports[port].dev;
 
-rwc = val  PORTSC_RWC_MASK;
+/* Clear rwc bits */
+*portsc = ~(val  PORTSC_RWC_MASK);
+/* The guest may clear, but not set the PED bit */
+*portsc = val | ~PORTSC_PED;
 val = PORTSC_RO_MASK;
 
-// handle_read_write_clear(val, portsc, PORTSC_PEDC | PORTSC_CSC);
-
-*portsc = ~rwc;
-
 if ((val  PORTSC_PRESET)  !(*portsc  PORTSC_PRESET)) {
 trace_usb_ehci_port_reset(port, 1);
 }
@@ -869,13 +867,13 @@ static void handle_port_status_write(EHCIState *s, int 
port, uint32_t val)
 *portsc = ~PORTSC_CSC;
 }
 
-/*  Table 2.16 Set the enable bit(and enable bit change) to indicate
+/*
+ *  Table 2.16 Set the enable bit(and enable bit change) to indicate
  *  to SW that this port has a high speed device attached
- *
- *  TODO - when to disable?
  */
-val |= PORTSC_PED;
-val |= PORTSC_PEDC;
+if (dev  (dev-speedmask  USB_SPEED_MASK_HIGH)) {
+val |= PORTSC_PED;
+}
 }
 
 *portsc = ~PORTSC_RO_MASK;
-- 
1.7.1




[Qemu-devel] [PATCH 01/23] hw/usb-musb.c: Don't misuse usb_packet_complete()

2011-07-08 Thread Gerd Hoffmann
From: Peter Maydell peter.mayd...@linaro.org

In musb_packet() handle final processing of non-asynchronous
USB packets by directly calling musb_schedule_cb() rather than
going through usb_packet_complete(). The latter will trigger
an assertion because the packet doesn't belong to a device.

Signed-off-by: Peter Maydell peter.mayd...@linaro.org
Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 hw/usb-musb.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/hw/usb-musb.c b/hw/usb-musb.c
index 21f35af..d15971f 100644
--- a/hw/usb-musb.c
+++ b/hw/usb-musb.c
@@ -616,7 +616,7 @@ static void musb_packet(MUSBState *s, MUSBEndPoint *ep,
 }
 
 ep-status[dir] = ret;
-usb_packet_complete(s-port.dev, ep-packey[dir].p);
+musb_schedule_cb(s-port.dev, ep-packey[dir].p);
 }
 
 static void musb_tx_packet_complete(USBPacket *packey, void *opaque)
-- 
1.7.1




[Qemu-devel] [PATCH 09/23] usb-ehci: cleanup port reset handling

2011-07-08 Thread Gerd Hoffmann
From: Hans de Goede hdego...@redhat.com

Doing a usb_attach when dev is NULL will just result in the
port detach op getting called even though nothing was connected in
the first place.

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

diff --git a/hw/usb-ehci.c b/hw/usb-ehci.c
index ce1a432..d85e0a9 100644
--- a/hw/usb-ehci.c
+++ b/hw/usb-ehci.c
@@ -863,14 +863,9 @@ static void handle_port_status_write(EHCIState *s, int 
port, uint32_t val)
 
 if (!(val  PORTSC_PRESET) (*portsc  PORTSC_PRESET)) {
 trace_usb_ehci_port_reset(port, 0);
-usb_attach(s-ports[port], dev);
-
-// TODO how to handle reset of ports with no device
 if (dev) {
+usb_attach(s-ports[port], dev);
 usb_send_msg(dev, USB_MSG_RESET);
-}
-
-if (s-ports[port].dev) {
 *portsc = ~PORTSC_CSC;
 }
 
-- 
1.7.1




[Qemu-devel] [PATCH 15/23] pci: add ich9 usb controller ids

2011-07-08 Thread Gerd Hoffmann
Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 hw/pci_ids.h |8 
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/hw/pci_ids.h b/hw/pci_ids.h
index d94578c..927f2b0 100644
--- a/hw/pci_ids.h
+++ b/hw/pci_ids.h
@@ -109,5 +109,13 @@
 #define PCI_DEVICE_ID_INTEL_82371AB  0x7111
 #define PCI_DEVICE_ID_INTEL_82371AB_20x7112
 #define PCI_DEVICE_ID_INTEL_82371AB_30x7113
+#define PCI_DEVICE_ID_INTEL_82801I_UHCI1 0x2934
+#define PCI_DEVICE_ID_INTEL_82801I_UHCI2 0x2935
+#define PCI_DEVICE_ID_INTEL_82801I_UHCI3 0x2936
+#define PCI_DEVICE_ID_INTEL_82801I_UHCI4 0x2937
+#define PCI_DEVICE_ID_INTEL_82801I_UHCI5 0x2938
+#define PCI_DEVICE_ID_INTEL_82801I_UHCI6 0x2939
+#define PCI_DEVICE_ID_INTEL_82801I_EHCI1 0x293a
+#define PCI_DEVICE_ID_INTEL_82801I_EHCI2 0x293c
 
 #define PCI_VENDOR_ID_XENSOURCE  0x5853
-- 
1.7.1




[Qemu-devel] [PATCH 22/23] usb-hub: remove unused descriptor arrays

2011-07-08 Thread Gerd Hoffmann
Somehow they where left over when converting the hub
to the new usb descriptor infrastructure ...

Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 hw/usb-hub.c |   68 --
 1 files changed, 0 insertions(+), 68 deletions(-)

diff --git a/hw/usb-hub.c b/hw/usb-hub.c
index b7557ce..b49a2fe 100644
--- a/hw/usb-hub.c
+++ b/hw/usb-hub.c
@@ -138,74 +138,6 @@ static const USBDesc desc_hub = {
 .str  = desc_strings,
 };
 
-static const uint8_t qemu_hub_dev_descriptor[] = {
-   0x12,   /*  u8 bLength; */
-   0x01,   /*  u8 bDescriptorType; Device */
-   0x10, 0x01, /*  u16 bcdUSB; v1.1 */
-
-   0x09,   /*  u8  bDeviceClass; HUB_CLASSCODE */
-   0x00,   /*  u8  bDeviceSubClass; */
-   0x00,   /*  u8  bDeviceProtocol; [ low/full speeds only ] */
-   0x08,   /*  u8  bMaxPacketSize0; 8 Bytes */
-
-   0x00, 0x00, /*  u16 idVendor; */
-   0x00, 0x00, /*  u16 idProduct; */
-   0x01, 0x01, /*  u16 bcdDevice */
-
-   0x03,   /*  u8  iManufacturer; */
-   0x02,   /*  u8  iProduct; */
-   0x01,   /*  u8  iSerialNumber; */
-   0x01/*  u8  bNumConfigurations; */
-};
-
-/* XXX: patch interrupt size */
-static const uint8_t qemu_hub_config_descriptor[] = {
-
-   /* one configuration */
-   0x09,   /*  u8  bLength; */
-   0x02,   /*  u8  bDescriptorType; Configuration */
-   0x19, 0x00, /*  u16 wTotalLength; */
-   0x01,   /*  u8  bNumInterfaces; (1) */
-   0x01,   /*  u8  bConfigurationValue; */
-   0x00,   /*  u8  iConfiguration; */
-   0xe0,   /*  u8  bmAttributes;
-Bit 7: must be set,
-6: Self-powered,
-5: Remote wakeup,
-4..0: resvd */
-   0x00,   /*  u8  MaxPower; */
-
-   /* USB 1.1:
-* USB 2.0, single TT organization (mandatory):
-*  one interface, protocol 0
-*
-* USB 2.0, multiple TT organization (optional):
-*  two interfaces, protocols 1 (like single TT)
-*  and 2 (multiple TT mode) ... config is
-*  sometimes settable
-*  NOT IMPLEMENTED
-*/
-
-   /* one interface */
-   0x09,   /*  u8  if_bLength; */
-   0x04,   /*  u8  if_bDescriptorType; Interface */
-   0x00,   /*  u8  if_bInterfaceNumber; */
-   0x00,   /*  u8  if_bAlternateSetting; */
-   0x01,   /*  u8  if_bNumEndpoints; */
-   0x09,   /*  u8  if_bInterfaceClass; HUB_CLASSCODE */
-   0x00,   /*  u8  if_bInterfaceSubClass; */
-   0x00,   /*  u8  if_bInterfaceProtocol; [usb1.1 or single tt] */
-   0x00,   /*  u8  if_iInterface; */
-
-   /* one endpoint (status change endpoint) */
-   0x07,   /*  u8  ep_bLength; */
-   0x05,   /*  u8  ep_bDescriptorType; Endpoint */
-   0x81,   /*  u8  ep_bEndpointAddress; IN Endpoint 1 */
-   0x03,   /*  u8  ep_bmAttributes; Interrupt */
-   0x02, 0x00, /*  u16 ep_wMaxPacketSize; 1 + (MAX_ROOT_PORTS / 8) */
-   0xff/*  u8  ep_bInterval; (255ms -- usb 2.0 spec) */
-};
-
 static const uint8_t qemu_hub_hub_descriptor[] =
 {
0x00,   /*  u8  bLength; patched in later */
-- 
1.7.1




[Qemu-devel] [PATCH 05/23] usb: Make port wakeup and complete ops take a USBPort instead of a Device

2011-07-08 Thread Gerd Hoffmann
From: Hans de Goede hdego...@redhat.com

This makes them consistent with the attach and detach ops, and in general
it makes sense to make portops take a port as argument. This also makes
adding support for a companion controller easier / cleaner.

[ kraxel: fix usb-musb.c build ]

Signed-off-by: Hans de Goede hdego...@redhat.com
Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 hw/usb-ehci.c |2 +-
 hw/usb-hub.c  |   10 +-
 hw/usb-musb.c |6 +++---
 hw/usb-ohci.c |   12 +---
 hw/usb-uhci.c |   11 +--
 hw/usb.c  |4 ++--
 hw/usb.h  |9 +++--
 7 files changed, 28 insertions(+), 26 deletions(-)

diff --git a/hw/usb-ehci.c b/hw/usb-ehci.c
index 88cb2c2..428c90b 100644
--- a/hw/usb-ehci.c
+++ b/hw/usb-ehci.c
@@ -,7 +,7 @@ static int ehci_buffer_rw(EHCIQueue *q, int bytes, int rw)
 return 0;
 }
 
-static void ehci_async_complete_packet(USBDevice *dev, USBPacket *packet)
+static void ehci_async_complete_packet(USBPort *port, USBPacket *packet)
 {
 EHCIQueue *q = container_of(packet, EHCIQueue, packet);
 
diff --git a/hw/usb-hub.c b/hw/usb-hub.c
index 6e2a358..d324bba 100644
--- a/hw/usb-hub.c
+++ b/hw/usb-hub.c
@@ -246,10 +246,10 @@ static void usb_hub_detach(USBPort *port1)
 }
 }
 
-static void usb_hub_wakeup(USBDevice *dev)
+static void usb_hub_wakeup(USBPort *port1)
 {
-USBHubState *s = dev-port-opaque;
-USBHubPort *port = s-ports[dev-port-index];
+USBHubState *s = port1-opaque;
+USBHubPort *port = s-ports[port1-index];
 
 if (port-wPortStatus  PORT_STAT_SUSPEND) {
 port-wPortChange |= PORT_STAT_C_SUSPEND;
@@ -257,9 +257,9 @@ static void usb_hub_wakeup(USBDevice *dev)
 }
 }
 
-static void usb_hub_complete(USBDevice *dev, USBPacket *packet)
+static void usb_hub_complete(USBPort *port, USBPacket *packet)
 {
-USBHubState *s = dev-port-opaque;
+USBHubState *s = port-opaque;
 
 /*
  * Just pass it along upstream for now.
diff --git a/hw/usb-musb.c b/hw/usb-musb.c
index 84e6017..580bdc8 100644
--- a/hw/usb-musb.c
+++ b/hw/usb-musb.c
@@ -261,7 +261,7 @@
 
 static void musb_attach(USBPort *port);
 static void musb_detach(USBPort *port);
-static void musb_schedule_cb(USBDevice *dev, USBPacket *p);
+static void musb_schedule_cb(USBPort *port, USBPacket *p);
 static void musb_device_destroy(USBBus *bus, USBDevice *dev);
 
 static USBPortOps musb_port_ops = {
@@ -517,7 +517,7 @@ static void musb_cb_tick1(void *opaque)
 
 #define musb_cb_tick   (dir ? musb_cb_tick1 : musb_cb_tick0)
 
-static void musb_schedule_cb(USBDevice *dev, USBPacket *packey)
+static void musb_schedule_cb(USBPort *port, USBPacket *packey)
 {
 MUSBPacket *p = container_of(packey, MUSBPacket, p);
 MUSBEndPoint *ep = p-ep;
@@ -615,7 +615,7 @@ static void musb_packet(MUSBState *s, MUSBEndPoint *ep,
 }
 
 ep-status[dir] = ret;
-musb_schedule_cb(s-port.dev, ep-packey[dir].p);
+musb_schedule_cb(s-port, ep-packey[dir].p);
 }
 
 static void musb_tx_packet_complete(USBPacket *packey, void *opaque)
diff --git a/hw/usb-ohci.c b/hw/usb-ohci.c
index 95e4623..bd92c31 100644
--- a/hw/usb-ohci.c
+++ b/hw/usb-ohci.c
@@ -367,15 +367,13 @@ static void ohci_detach(USBPort *port1)
 ohci_set_interrupt(s, OHCI_INTR_RHSC);
 }
 
-static void ohci_wakeup(USBDevice *dev)
+static void ohci_wakeup(USBPort *port1)
 {
-USBBus *bus = usb_bus_from_device(dev);
-OHCIState *s = container_of(bus, OHCIState, bus);
-int portnum = dev-port-index;
-OHCIPort *port = s-rhport[portnum];
+OHCIState *s = port1-opaque;
+OHCIPort *port = s-rhport[port1-index];
 uint32_t intr = 0;
 if (port-ctrl  OHCI_PORT_PSS) {
-DPRINTF(usb-ohci: port %d: wakeup\n, portnum);
+DPRINTF(usb-ohci: port %d: wakeup\n, port1-index);
 port-ctrl |= OHCI_PORT_PSSC;
 port-ctrl = ~OHCI_PORT_PSS;
 intr = OHCI_INTR_RHSC;
@@ -602,7 +600,7 @@ static void ohci_copy_iso_td(OHCIState *ohci,
 
 static void ohci_process_lists(OHCIState *ohci, int completion);
 
-static void ohci_async_complete_packet(USBDevice *dev, USBPacket *packet)
+static void ohci_async_complete_packet(USBPort *port, USBPacket *packet)
 {
 OHCIState *ohci = container_of(packet, OHCIState, usb_packet);
 #ifdef DEBUG_PACKET
diff --git a/hw/usb-uhci.c b/hw/usb-uhci.c
index fd25d2a..ab635f6 100644
--- a/hw/usb-uhci.c
+++ b/hw/usb-uhci.c
@@ -620,11 +620,10 @@ static void uhci_detach(USBPort *port1)
 uhci_resume(s);
 }
 
-static void uhci_wakeup(USBDevice *dev)
+static void uhci_wakeup(USBPort *port1)
 {
-USBBus *bus = usb_bus_from_device(dev);
-UHCIState *s = container_of(bus, UHCIState, bus);
-UHCIPort *port = s-ports + dev-port-index;
+UHCIState *s = port1-opaque;
+UHCIPort *port = s-ports[port1-index];
 
 if (port-ctrl  UHCI_PORT_SUSPEND  !(port-ctrl  UHCI_PORT_RD)) {
 port-ctrl |= UHCI_PORT_RD;
@@ -657,7 +656,7 @@ static int uhci_broadcast_packet(UHCIState *s, USBPacket *p)
 return ret;
 }
 
-static 

[Qemu-devel] [PATCH 07/23] usb-ehci: drop unused num-ports state member

2011-07-08 Thread Gerd Hoffmann
From: Hans de Goede hdego...@redhat.com

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

diff --git a/hw/usb-ehci.c b/hw/usb-ehci.c
index 96451f3..87e1de3 100644
--- a/hw/usb-ehci.c
+++ b/hw/usb-ehci.c
@@ -373,7 +373,6 @@ struct EHCIState {
 qemu_irq irq;
 target_phys_addr_t mem_base;
 int mem;
-int num_ports;
 
 /* properties */
 uint32_t freq;
-- 
1.7.1




[Qemu-devel] [PATCH 19/23] usb: update documentation

2011-07-08 Thread Gerd Hoffmann
Add a paragraph on companion controller mode and a
configuration file which sets it all up for you.

Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 docs/ich9-ehci-uhci.cfg |   37 +
 docs/usb2.txt   |   33 -
 2 files changed, 65 insertions(+), 5 deletions(-)
 create mode 100644 docs/ich9-ehci-uhci.cfg

diff --git a/docs/ich9-ehci-uhci.cfg b/docs/ich9-ehci-uhci.cfg
new file mode 100644
index 000..a0e9b96
--- /dev/null
+++ b/docs/ich9-ehci-uhci.cfg
@@ -0,0 +1,37 @@
+###
+#
+# You can pass this file directly to qemu using the -readconfig
+# command line switch.
+#
+# This config file creates a EHCI adapter with companion UHCI
+# controllers as multifunction device in PCI slot 1d.
+#
+# Specify bus=ehci.0 when creating usb devices to hook them up
+# there.
+#
+
+[device ehci]
+  driver = ich9-usb-ehci1
+  addr = 1d.7
+  multifunction = on
+
+[device uhci-1]
+  driver = ich9-usb-uhci1
+  addr = 1d.0
+  multifunction = on
+  masterbus = ehci.0
+  firstport = 0
+
+[device uhci-2]
+  driver = ich9-usb-uhci2
+  addr = 1d.1
+  multifunction = on
+  masterbus = ehci.0
+  firstport = 2
+
+[device uhci-3]
+  driver = ich9-usb-uhci3
+  addr = 1d.2
+  multifunction = on
+  masterbus = ehci.0
+  firstport = 4
diff --git a/docs/usb2.txt b/docs/usb2.txt
index 5950c71..228aa33 100644
--- a/docs/usb2.txt
+++ b/docs/usb2.txt
@@ -2,11 +2,13 @@
 USB 2.0 Quick Start
 ===
 
-The QEMU EHCI Adapter does *not* support companion controllers.  That
-implies there are two completely separate USB busses: One USB 1.1 bus
-driven by the UHCI controller and one USB 2.0 bus driven by the EHCI
-controller.  Devices must be attached to the correct controller
-manually.
+The QEMU EHCI Adapter can be used with and without companion
+controllers.  See below for the companion controller mode.
+
+When not running in companion controller mode there are two completely
+separate USB busses: One USB 1.1 bus driven by the UHCI controller and
+one USB 2.0 bus driven by the EHCI controller.  Devices must be
+attached to the correct controller manually.
 
 The '-usb' switch will make qemu create the UHCI controller as part of
 the PIIX3 chipset.  The USB 1.1 bus will carry the name usb.0.
@@ -32,6 +34,27 @@ This attaches a usb tablet to the UHCI adapter and a usb 
mass storage
 device to the EHCI adapter.
 
 
+Companion controller support
+
+
+Companion controller support has been added recently.  The operational
+model described above with two completely separate busses still works
+fine.  Additionally the UHCI and OHCI controllers got the ability to
+attach to a usb bus created by EHCI as companion controllers.  This is
+done by specifying the masterbus and firstport properties.  masterbus
+specifies the bus name the controller should attach to.  firstport
+specifies the first port the controller should attach to, which is
+needed as usually one ehci controller with six ports has three uhci
+companion controllers with two ports each.
+
+There is a config file in docs which will do all this for you, just
+try ...
+
+qemu -readconfig docs/ich9-ehci-uhci.cfg
+
+... then use bus=ehci.0 to assign your usb devices to that bus.
+
+
 More USB tips  tricks
 ==
 
-- 
1.7.1




Re: [Qemu-devel] Qemu performance

2011-07-08 Thread Alexander Graf

On 08.07.2011, at 04:55, Lê Đức Tài wrote:

 On 30.06.2011, at 15:24, Alexander Graf ag...@suse.de wrote:
 
   On 30.06.2011, at 04:11, Lê Đức Tài letai_d...@yahoo.com.vn wrote:
 
Thank for your answer.
Beside nbench, I'm also using Dhrystone to measure the guest cpu 
  performance. 
The performance does not much diffetence too.
Is the emulated guest performance not depend on guest processor clock?
 
   Please don't top-post.
 
   Qemu doesn't emulate cycle-accurately. Instead, it converts guest code to 
  host code and executes it as fast as it can. So whatever you tell the   
  guest on the cpu speed doesn't really matter. Except for the timebase of 
  course :).
 
   Mind if I ask what exactly you're trying to do with ppc emulation? I'm 
  interested in use cases people have.
 
   Alex
 
 Thank you, 
 Exactly I want to emulate my ppc custom board (ppc440) with many features 
 supporting as Ethernet, HDD, VGA, .. for my test environment (I have a 
 software that running on ppc440).
 And I wan to get the best performance of Qemu.

I see. Qemu always gives you best performance, as it can't throttle the guest 
:). Btw, I'd be happy to merge your custom board (or at least some components 
of it if they are reasonably mainstream) upstream, if you think it makes sense 
and the code is in good shape.


Alex




[Qemu-devel] [PATCH 06/23] usb: Replace device_destroy bus op with a child_detach port op

2011-07-08 Thread Gerd Hoffmann
From: Hans de Goede hdego...@redhat.com

Note this fixes 2 things in one go, first of all the device_destroy bus
op should be a device_detach bus op, as pending async packets from the
device should be cancelled on detach not on destroy.

Secondly having this as a bus op won't work with companion controllers, since
then there will be 1 bus driven by the ehci controller and thus 1 set of bus
ops, but the device being detached may be downstream of a handed over port.
Making the detach of a downstream device a port op allows the ehci controller
to forward this to the companion controller port for handed over ports.

Signed-off-by: Hans de Goede hdego...@redhat.com
Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 hw/milkymist-softusb.c |9 +++--
 hw/usb-bus.c   |2 --
 hw/usb-ehci.c  |   18 ++
 hw/usb-hub.c   |   12 
 hw/usb-musb.c  |   17 +
 hw/usb-ohci.c  |   16 
 hw/usb-uhci.c  |   18 ++
 hw/usb.h   |6 +-
 8 files changed, 69 insertions(+), 29 deletions(-)

diff --git a/hw/milkymist-softusb.c b/hw/milkymist-softusb.c
index 5ab35c3..ce2bfc6 100644
--- a/hw/milkymist-softusb.c
+++ b/hw/milkymist-softusb.c
@@ -247,16 +247,21 @@ static void softusb_attach(USBPort *port)
 {
 }
 
-static void softusb_device_destroy(USBBus *bus, USBDevice *dev)
+static void softusb_detach(USBPort *port)
+{
+}
+
+static void softusb_child_detach(USBPort *port, USBDevice *child)
 {
 }
 
 static USBPortOps softusb_ops = {
 .attach = softusb_attach,
+.detach = softusb_detach,
+.child_detach = softusb_child_detach,
 };
 
 static USBBusOps softusb_bus_ops = {
-.device_destroy = softusb_device_destroy,
 };
 
 static void milkymist_softusb_reset(DeviceState *d)
diff --git a/hw/usb-bus.c b/hw/usb-bus.c
index b511bac..c8347e9 100644
--- a/hw/usb-bus.c
+++ b/hw/usb-bus.c
@@ -82,12 +82,10 @@ static int usb_qdev_init(DeviceState *qdev, DeviceInfo 
*base)
 static int usb_qdev_exit(DeviceState *qdev)
 {
 USBDevice *dev = DO_UPCAST(USBDevice, qdev, qdev);
-USBBus *bus = usb_bus_from_device(dev);
 
 if (dev-attached) {
 usb_device_detach(dev);
 }
-bus-ops-device_destroy(bus, dev);
 if (dev-info-handle_destroy) {
 dev-info-handle_destroy(dev);
 }
diff --git a/hw/usb-ehci.c b/hw/usb-ehci.c
index 428c90b..96451f3 100644
--- a/hw/usb-ehci.c
+++ b/hw/usb-ehci.c
@@ -751,6 +751,8 @@ static void ehci_detach(USBPort *port)
 
 trace_usb_ehci_port_detach(port-index);
 
+ehci_queues_rip_device(s, port-dev);
+
 *portsc = ~PORTSC_CONNECT;
 *portsc |= PORTSC_CSC;
 
@@ -764,6 +766,13 @@ static void ehci_detach(USBPort *port)
 }
 }
 
+static void ehci_child_detach(USBPort *port, USBDevice *child)
+{
+EHCIState *s = port-opaque;
+
+ehci_queues_rip_device(s, child);
+}
+
 /* 4.1 host controller initialization */
 static void ehci_reset(void *opaque)
 {
@@ -2117,23 +2126,16 @@ static void ehci_map(PCIDevice *pci_dev, int region_num,
 cpu_register_physical_memory(addr, size, s-mem);
 }
 
-static void ehci_device_destroy(USBBus *bus, USBDevice *dev)
-{
-EHCIState *s = container_of(bus, EHCIState, bus);
-
-ehci_queues_rip_device(s, dev);
-}
-
 static int usb_ehci_initfn(PCIDevice *dev);
 
 static USBPortOps ehci_port_ops = {
 .attach = ehci_attach,
 .detach = ehci_detach,
+.child_detach = ehci_child_detach,
 .complete = ehci_async_complete_packet,
 };
 
 static USBBusOps ehci_bus_ops = {
-.device_destroy = ehci_device_destroy,
 };
 
 static PCIDeviceInfo ehci_info = {
diff --git a/hw/usb-hub.c b/hw/usb-hub.c
index d324bba..b7557ce 100644
--- a/hw/usb-hub.c
+++ b/hw/usb-hub.c
@@ -238,6 +238,9 @@ static void usb_hub_detach(USBPort *port1)
 USBHubState *s = port1-opaque;
 USBHubPort *port = s-ports[port1-index];
 
+/* Let upstream know the device on this port is gone */
+s-dev.port-ops-child_detach(s-dev.port, port1-dev);
+
 port-wPortStatus = ~PORT_STAT_CONNECTION;
 port-wPortChange |= PORT_STAT_C_CONNECTION;
 if (port-wPortStatus  PORT_STAT_ENABLE) {
@@ -246,6 +249,14 @@ static void usb_hub_detach(USBPort *port1)
 }
 }
 
+static void usb_hub_child_detach(USBPort *port1, USBDevice *child)
+{
+USBHubState *s = port1-opaque;
+
+/* Pass along upstream */
+s-dev.port-ops-child_detach(s-dev.port, child);
+}
+
 static void usb_hub_wakeup(USBPort *port1)
 {
 USBHubState *s = port1-opaque;
@@ -537,6 +548,7 @@ static void usb_hub_handle_destroy(USBDevice *dev)
 static USBPortOps usb_hub_port_ops = {
 .attach = usb_hub_attach,
 .detach = usb_hub_detach,
+.child_detach = usb_hub_child_detach,
 .wakeup = usb_hub_wakeup,
 .complete = usb_hub_complete,
 };
diff --git a/hw/usb-musb.c b/hw/usb-musb.c
index 580bdc8..035dda8 100644
--- a/hw/usb-musb.c
+++ b/hw/usb-musb.c
@@ -261,17 +261,18 @@
 
 static void musb_attach(USBPort *port);
 static void 

[Qemu-devel] [PATCH 13/23] usb-uhci: Add support for being a companion controller

2011-07-08 Thread Gerd Hoffmann
From: Hans de Goede hdego...@redhat.com

To use as a companion controller set the masterbus property.

Signed-off-by: Hans de Goede hdego...@redhat.com
Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 hw/usb-uhci.c |   41 -
 1 files changed, 36 insertions(+), 5 deletions(-)

diff --git a/hw/usb-uhci.c b/hw/usb-uhci.c
index a46d61a..925c03b 100644
--- a/hw/usb-uhci.c
+++ b/hw/usb-uhci.c
@@ -132,7 +132,7 @@ typedef struct UHCIPort {
 
 struct UHCIState {
 PCIDevice dev;
-USBBus bus;
+USBBus bus; /* Note unused when we're a companion controller */
 uint16_t cmd; /* cmd register */
 uint16_t status;
 uint16_t intr; /* interrupt enable register */
@@ -150,6 +150,10 @@ struct UHCIState {
 /* Active packets */
 QTAILQ_HEAD(,UHCIAsync) async_pending;
 uint8_t num_ports_vmstate;
+
+/* Properties */
+char *masterbus;
+uint32_t firstport;
 };
 
 typedef struct UHCI_TD {
@@ -1126,10 +1130,22 @@ static int usb_uhci_common_initfn(PCIDevice *dev)
 pci_conf[PCI_INTERRUPT_PIN] = 4; // interrupt pin 3
 pci_conf[USB_SBRN] = USB_RELEASE_1; // release number
 
-usb_bus_new(s-bus, uhci_bus_ops, s-dev.qdev);
-for(i = 0; i  NB_PORTS; i++) {
-usb_register_port(s-bus, s-ports[i].port, s, i, uhci_port_ops,
-  USB_SPEED_MASK_LOW | USB_SPEED_MASK_FULL);
+if (s-masterbus) {
+USBPort *ports[NB_PORTS];
+for(i = 0; i  NB_PORTS; i++) {
+ports[i] = s-ports[i].port;
+}
+if (usb_register_companion(s-masterbus, ports, NB_PORTS,
+s-firstport, s, uhci_port_ops,
+USB_SPEED_MASK_LOW | USB_SPEED_MASK_FULL) != 0) {
+return -1;
+}
+} else {
+usb_bus_new(s-bus, uhci_bus_ops, s-dev.qdev);
+for (i = 0; i  NB_PORTS; i++) {
+usb_register_port(s-bus, s-ports[i].port, s, i, uhci_port_ops,
+  USB_SPEED_MASK_LOW | USB_SPEED_MASK_FULL);
+}
 }
 s-frame_timer = qemu_new_timer_ns(vm_clock, uhci_frame_timer, s);
 s-num_ports_vmstate = NB_PORTS;
@@ -1170,6 +1186,11 @@ static PCIDeviceInfo uhci_info[] = {
 .device_id= PCI_DEVICE_ID_INTEL_82371SB_2,
 .revision = 0x01,
 .class_id = PCI_CLASS_SERIAL_USB,
+.qdev.props   = (Property[]) {
+DEFINE_PROP_STRING(masterbus, UHCIState, masterbus),
+DEFINE_PROP_UINT32(firstport, UHCIState, firstport, 0),
+DEFINE_PROP_END_OF_LIST(),
+},
 },{
 .qdev.name= piix4-usb-uhci,
 .qdev.size= sizeof(UHCIState),
@@ -1179,6 +1200,11 @@ static PCIDeviceInfo uhci_info[] = {
 .device_id= PCI_DEVICE_ID_INTEL_82371AB_2,
 .revision = 0x01,
 .class_id = PCI_CLASS_SERIAL_USB,
+.qdev.props   = (Property[]) {
+DEFINE_PROP_STRING(masterbus, UHCIState, masterbus),
+DEFINE_PROP_UINT32(firstport, UHCIState, firstport, 0),
+DEFINE_PROP_END_OF_LIST(),
+},
 },{
 .qdev.name= vt82c686b-usb-uhci,
 .qdev.size= sizeof(UHCIState),
@@ -1188,6 +1214,11 @@ static PCIDeviceInfo uhci_info[] = {
 .device_id= PCI_DEVICE_ID_VIA_UHCI,
 .revision = 0x01,
 .class_id = PCI_CLASS_SERIAL_USB,
+.qdev.props   = (Property[]) {
+DEFINE_PROP_STRING(masterbus, UHCIState, masterbus),
+DEFINE_PROP_UINT32(firstport, UHCIState, firstport, 0),
+DEFINE_PROP_END_OF_LIST(),
+},
 },{
 /* end of list */
 }
-- 
1.7.1




[Qemu-devel] [PATCH 23/23] usb-ohci: raise interrupt on attach

2011-07-08 Thread Gerd Hoffmann
Got lost in commit 618c169b577db64ac6589ad48825d2e11760d1a6,
add it back in.  Also fix codestyle while we are at it.

Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 hw/usb-ohci.c |8 +++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/hw/usb-ohci.c b/hw/usb-ohci.c
index c77a20e..8491d59 100644
--- a/hw/usb-ohci.c
+++ b/hw/usb-ohci.c
@@ -327,6 +327,7 @@ static void ohci_attach(USBPort *port1)
 {
 OHCIState *s = port1-opaque;
 OHCIPort *port = s-rhport[port1-index];
+uint32_t old_state = port-ctrl;
 
 /* set connect status */
 port-ctrl |= OHCI_PORT_CCS | OHCI_PORT_CSC;
@@ -344,6 +345,10 @@ static void ohci_attach(USBPort *port1)
 }
 
 DPRINTF(usb-ohci: Attached port %d\n, port1-index);
+
+if (old_state != port-ctrl) {
+ohci_set_interrupt(s, OHCI_INTR_RHSC);
+}
 }
 
 static void ohci_detach(USBPort *port1)
@@ -366,8 +371,9 @@ static void ohci_detach(USBPort *port1)
 }
 DPRINTF(usb-ohci: Detached port %d\n, port1-index);
 
-if (old_state != port-ctrl)
+if (old_state != port-ctrl) {
 ohci_set_interrupt(s, OHCI_INTR_RHSC);
+}
 }
 
 static void ohci_wakeup(USBPort *port1)
-- 
1.7.1




[Qemu-devel] [PATCH 12/23] usb-ehci: Add support for registering companion controllers

2011-07-08 Thread Gerd Hoffmann
From: Hans de Goede hdego...@redhat.com

Signed-off-by: Hans de Goede hdego...@redhat.com
Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 hw/usb-ehci.c |  174 +++--
 1 files changed, 144 insertions(+), 30 deletions(-)

diff --git a/hw/usb-ehci.c b/hw/usb-ehci.c
index 973c342..ec68c29 100644
--- a/hw/usb-ehci.c
+++ b/hw/usb-ehci.c
@@ -20,9 +20,6 @@
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, see http://www.gnu.org/licenses/.
- *
- * TODO:
- *  o Downstream port handoff
  */
 
 #include hw.h
@@ -106,7 +103,7 @@
  * Bits that are reserved or are read-only are masked out of values
  * written to us by software
  */
-#define PORTSC_RO_MASK   0x007021c0
+#define PORTSC_RO_MASK   0x007001c0
 #define PORTSC_RWC_MASK  0x002a
 #define PORTSC_WKOC_E(1  22)// Wake on Over Current Enable
 #define PORTSC_WKDS_E(1  21)// Wake on Disconnect Enable
@@ -373,6 +370,7 @@ struct EHCIState {
 qemu_irq irq;
 target_phys_addr_t mem_base;
 int mem;
+int companion_count;
 
 /* properties */
 uint32_t freq;
@@ -408,6 +406,7 @@ struct EHCIState {
 int astate;// Current state in asynchronous 
schedule
 int pstate;// Current state in periodic schedule
 USBPort ports[NB_PORTS];
+USBPort *companion_ports[NB_PORTS];
 uint32_t usbsts_pending;
 QTAILQ_HEAD(, EHCIQueue) queues;
 
@@ -730,17 +729,17 @@ static void ehci_attach(USBPort *port)
 
 trace_usb_ehci_port_attach(port-index, port-dev-product_desc);
 
+if (*portsc  PORTSC_POWNER) {
+USBPort *companion = s-companion_ports[port-index];
+companion-dev = port-dev;
+companion-ops-attach(companion);
+return;
+}
+
 *portsc |= PORTSC_CONNECT;
 *portsc |= PORTSC_CSC;
 
-/*
- *  If a high speed device is attached then we own this port(indicated
- *  by zero in the PORTSC_POWNER bit field) so set the status bit
- *  and set an interrupt if enabled.
- */
-if ( !(*portsc  PORTSC_POWNER)) {
-ehci_set_interrupt(s, USBSTS_PCD);
-}
+ehci_set_interrupt(s, USBSTS_PCD);
 }
 
 static void ehci_detach(USBPort *port)
@@ -750,36 +749,110 @@ static void ehci_detach(USBPort *port)
 
 trace_usb_ehci_port_detach(port-index);
 
+if (*portsc  PORTSC_POWNER) {
+USBPort *companion = s-companion_ports[port-index];
+companion-ops-detach(companion);
+companion-dev = NULL;
+return;
+}
+
 ehci_queues_rip_device(s, port-dev);
 
 *portsc = ~(PORTSC_CONNECT|PORTSC_PED);
 *portsc |= PORTSC_CSC;
 
-/*
- *  If a high speed device is attached then we own this port(indicated
- *  by zero in the PORTSC_POWNER bit field) so set the status bit
- *  and set an interrupt if enabled.
- */
-if ( !(*portsc  PORTSC_POWNER)) {
-ehci_set_interrupt(s, USBSTS_PCD);
-}
+ehci_set_interrupt(s, USBSTS_PCD);
 }
 
 static void ehci_child_detach(USBPort *port, USBDevice *child)
 {
 EHCIState *s = port-opaque;
+uint32_t portsc = s-portsc[port-index];
+
+if (portsc  PORTSC_POWNER) {
+USBPort *companion = s-companion_ports[port-index];
+companion-ops-child_detach(companion, child);
+companion-dev = NULL;
+return;
+}
 
 ehci_queues_rip_device(s, child);
 }
 
+static void ehci_wakeup(USBPort *port)
+{
+EHCIState *s = port-opaque;
+uint32_t portsc = s-portsc[port-index];
+
+if (portsc  PORTSC_POWNER) {
+USBPort *companion = s-companion_ports[port-index];
+if (companion-ops-wakeup) {
+companion-ops-wakeup(companion);
+}
+}
+}
+
+static int ehci_register_companion(USBBus *bus, USBPort *ports[],
+   uint32_t portcount, uint32_t firstport)
+{
+EHCIState *s = container_of(bus, EHCIState, bus);
+uint32_t i;
+
+if (firstport + portcount  NB_PORTS) {
+qerror_report(QERR_INVALID_PARAMETER_VALUE, firstport,
+  firstport on masterbus);
+error_printf_unless_qmp(
+firstport value of %u makes companion take ports %u - %u, which 
+is outside of the valid range of 0 - %u\n, firstport, firstport,
+firstport + portcount - 1, NB_PORTS - 1);
+return -1;
+}
+
+for (i = 0; i  portcount; i++) {
+if (s-companion_ports[firstport + i]) {
+qerror_report(QERR_INVALID_PARAMETER_VALUE, masterbus,
+  an USB masterbus);
+error_printf_unless_qmp(
+port %u on masterbus %s already has a companion assigned\n,
+firstport + i, bus-qbus.name);
+return -1;
+}
+}
+
+for (i = 0; i  portcount; i++) {
+s-companion_ports[firstport + i] = ports[i];
+s-ports[firstport + i].speedmask |=
+

[Qemu-devel] [PATCH 16/23] uhci: add ich9 controllers

2011-07-08 Thread Gerd Hoffmann
Add ich9 controllers,  Factor out properties to a separate
struct and reference it to reduce duplication.

Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 hw/usb-uhci.c |   54 +++---
 1 files changed, 39 insertions(+), 15 deletions(-)

diff --git a/hw/usb-uhci.c b/hw/usb-uhci.c
index 925c03b..2ef4c5b 100644
--- a/hw/usb-uhci.c
+++ b/hw/usb-uhci.c
@@ -1176,6 +1176,12 @@ static int usb_uhci_vt82c686b_initfn(PCIDevice *dev)
 return usb_uhci_common_initfn(dev);
 }
 
+static Property uhci_properties[] = {
+DEFINE_PROP_STRING(masterbus, UHCIState, masterbus),
+DEFINE_PROP_UINT32(firstport, UHCIState, firstport, 0),
+DEFINE_PROP_END_OF_LIST(),
+};
+
 static PCIDeviceInfo uhci_info[] = {
 {
 .qdev.name= piix3-usb-uhci,
@@ -1186,11 +1192,7 @@ static PCIDeviceInfo uhci_info[] = {
 .device_id= PCI_DEVICE_ID_INTEL_82371SB_2,
 .revision = 0x01,
 .class_id = PCI_CLASS_SERIAL_USB,
-.qdev.props   = (Property[]) {
-DEFINE_PROP_STRING(masterbus, UHCIState, masterbus),
-DEFINE_PROP_UINT32(firstport, UHCIState, firstport, 0),
-DEFINE_PROP_END_OF_LIST(),
-},
+.qdev.props   = uhci_properties,
 },{
 .qdev.name= piix4-usb-uhci,
 .qdev.size= sizeof(UHCIState),
@@ -1200,11 +1202,7 @@ static PCIDeviceInfo uhci_info[] = {
 .device_id= PCI_DEVICE_ID_INTEL_82371AB_2,
 .revision = 0x01,
 .class_id = PCI_CLASS_SERIAL_USB,
-.qdev.props   = (Property[]) {
-DEFINE_PROP_STRING(masterbus, UHCIState, masterbus),
-DEFINE_PROP_UINT32(firstport, UHCIState, firstport, 0),
-DEFINE_PROP_END_OF_LIST(),
-},
+.qdev.props   = uhci_properties,
 },{
 .qdev.name= vt82c686b-usb-uhci,
 .qdev.size= sizeof(UHCIState),
@@ -1214,11 +1212,37 @@ static PCIDeviceInfo uhci_info[] = {
 .device_id= PCI_DEVICE_ID_VIA_UHCI,
 .revision = 0x01,
 .class_id = PCI_CLASS_SERIAL_USB,
-.qdev.props   = (Property[]) {
-DEFINE_PROP_STRING(masterbus, UHCIState, masterbus),
-DEFINE_PROP_UINT32(firstport, UHCIState, firstport, 0),
-DEFINE_PROP_END_OF_LIST(),
-},
+.qdev.props   = uhci_properties,
+},{
+.qdev.name= ich9-usb-uhci1,
+.qdev.size= sizeof(UHCIState),
+.qdev.vmsd= vmstate_uhci,
+.init = usb_uhci_common_initfn,
+.vendor_id= PCI_VENDOR_ID_INTEL,
+.device_id= PCI_DEVICE_ID_INTEL_82801I_UHCI1,
+.revision = 0x03,
+.class_id = PCI_CLASS_SERIAL_USB,
+.qdev.props   = uhci_properties,
+},{
+.qdev.name= ich9-usb-uhci2,
+.qdev.size= sizeof(UHCIState),
+.qdev.vmsd= vmstate_uhci,
+.init = usb_uhci_common_initfn,
+.vendor_id= PCI_VENDOR_ID_INTEL,
+.device_id= PCI_DEVICE_ID_INTEL_82801I_UHCI2,
+.revision = 0x03,
+.class_id = PCI_CLASS_SERIAL_USB,
+.qdev.props   = uhci_properties,
+},{
+.qdev.name= ich9-usb-uhci3,
+.qdev.size= sizeof(UHCIState),
+.qdev.vmsd= vmstate_uhci,
+.init = usb_uhci_common_initfn,
+.vendor_id= PCI_VENDOR_ID_INTEL,
+.device_id= PCI_DEVICE_ID_INTEL_82801I_UHCI3,
+.revision = 0x03,
+.class_id = PCI_CLASS_SERIAL_USB,
+.qdev.props   = uhci_properties,
 },{
 /* end of list */
 }
-- 
1.7.1




[Qemu-devel] [PATCH 20/23] usb_register_port(): do not set port-opaque and port-index twice

2011-07-08 Thread Gerd Hoffmann
From: Jes Sorensen jes.soren...@redhat.com

Signed-off-by: Jes Sorensen jes.soren...@redhat.com
Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 hw/usb-bus.c |2 --
 1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/hw/usb-bus.c b/hw/usb-bus.c
index c8347e9..f1dd55e 100644
--- a/hw/usb-bus.c
+++ b/hw/usb-bus.c
@@ -143,8 +143,6 @@ static void usb_fill_port(USBPort *port, void *opaque, int 
index,
 {
 port-opaque = opaque;
 port-index = index;
-port-opaque = opaque;
-port-index = index;
 port-ops = ops;
 port-speedmask = speedmask;
 usb_port_location(port, NULL, index + 1);
-- 
1.7.1




[Qemu-devel] [PATCH 18/23] ehci: add ich9 controller.

2011-07-08 Thread Gerd Hoffmann
Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 hw/usb-ehci.c |   43 +--
 1 files changed, 29 insertions(+), 14 deletions(-)

diff --git a/hw/usb-ehci.c b/hw/usb-ehci.c
index 0b959ca..a4758f9 100644
--- a/hw/usb-ehci.c
+++ b/hw/usb-ehci.c
@@ -2244,19 +2244,34 @@ static USBBusOps ehci_bus_ops = {
 .register_companion = ehci_register_companion,
 };
 
-static PCIDeviceInfo ehci_info = {
-.qdev.name= usb-ehci,
-.qdev.size= sizeof(EHCIState),
-.init = usb_ehci_initfn,
-.vendor_id= PCI_VENDOR_ID_INTEL,
-.device_id= PCI_DEVICE_ID_INTEL_82801D,
-.revision = 0x10,
-.class_id = PCI_CLASS_SERIAL_USB,
-.qdev.props   = (Property[]) {
-DEFINE_PROP_UINT32(freq,  EHCIState, freq, FRAME_TIMER_FREQ),
-DEFINE_PROP_UINT32(maxframes, EHCIState, maxframes, 128),
-DEFINE_PROP_END_OF_LIST(),
-},
+static Property ehci_properties[] = {
+DEFINE_PROP_UINT32(freq,  EHCIState, freq, FRAME_TIMER_FREQ),
+DEFINE_PROP_UINT32(maxframes, EHCIState, maxframes, 128),
+DEFINE_PROP_END_OF_LIST(),
+};
+
+static PCIDeviceInfo ehci_info[] = {
+{
+.qdev.name= usb-ehci,
+.qdev.size= sizeof(EHCIState),
+.init = usb_ehci_initfn,
+.vendor_id= PCI_VENDOR_ID_INTEL,
+.device_id= PCI_DEVICE_ID_INTEL_82801D, /* ich4 */
+.revision = 0x10,
+.class_id = PCI_CLASS_SERIAL_USB,
+.qdev.props   = ehci_properties,
+},{
+.qdev.name= ich9-usb-ehci1,
+.qdev.size= sizeof(EHCIState),
+.init = usb_ehci_initfn,
+.vendor_id= PCI_VENDOR_ID_INTEL,
+.device_id= PCI_DEVICE_ID_INTEL_82801I_EHCI1,
+.revision = 0x03,
+.class_id = PCI_CLASS_SERIAL_USB,
+.qdev.props   = ehci_properties,
+},{
+/* end of list */
+}
 };
 
 static int usb_ehci_initfn(PCIDevice *dev)
@@ -2335,7 +2350,7 @@ static int usb_ehci_initfn(PCIDevice *dev)
 
 static void ehci_register(void)
 {
-pci_qdev_register(ehci_info);
+pci_qdev_register_many(ehci_info);
 }
 device_init(ehci_register);
 
-- 
1.7.1




[Qemu-devel] [PATCH 21/23] usb: fixup bluetooth descriptors

2011-07-08 Thread Gerd Hoffmann
Commit 4696425cd05c7baa0a4b469d43ba4b8488bcfc0f changes some
endpoints from isocrounous to interrupt by mistake.  Fix it.

Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 hw/usb-bt.c |   24 
 1 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/hw/usb-bt.c b/hw/usb-bt.c
index baae487..e364513 100644
--- a/hw/usb-bt.c
+++ b/hw/usb-bt.c
@@ -99,13 +99,13 @@ static const USBDescIface desc_iface_bluetooth[] = {
 .eps = (USBDescEndpoint[]) {
 {
 .bEndpointAddress  = USB_DIR_OUT | USB_SCO_EP,
-.bmAttributes  = USB_ENDPOINT_XFER_INT,
+.bmAttributes  = USB_ENDPOINT_XFER_ISOC,
 .wMaxPacketSize= 0,
 .bInterval = 0x01,
 },
 {
 .bEndpointAddress  = USB_DIR_IN | USB_SCO_EP,
-.bmAttributes  = USB_ENDPOINT_XFER_INT,
+.bmAttributes  = USB_ENDPOINT_XFER_ISOC,
 .wMaxPacketSize= 0,
 .bInterval = 0x01,
 },
@@ -120,13 +120,13 @@ static const USBDescIface desc_iface_bluetooth[] = {
 .eps = (USBDescEndpoint[]) {
 {
 .bEndpointAddress  = USB_DIR_OUT | USB_SCO_EP,
-.bmAttributes  = USB_ENDPOINT_XFER_INT,
+.bmAttributes  = USB_ENDPOINT_XFER_ISOC,
 .wMaxPacketSize= 0x09,
 .bInterval = 0x01,
 },
 {
 .bEndpointAddress  = USB_DIR_IN | USB_SCO_EP,
-.bmAttributes  = USB_ENDPOINT_XFER_INT,
+.bmAttributes  = USB_ENDPOINT_XFER_ISOC,
 .wMaxPacketSize= 0x09,
 .bInterval = 0x01,
 },
@@ -141,13 +141,13 @@ static const USBDescIface desc_iface_bluetooth[] = {
 .eps = (USBDescEndpoint[]) {
 {
 .bEndpointAddress  = USB_DIR_OUT | USB_SCO_EP,
-.bmAttributes  = USB_ENDPOINT_XFER_INT,
+.bmAttributes  = USB_ENDPOINT_XFER_ISOC,
 .wMaxPacketSize= 0x11,
 .bInterval = 0x01,
 },
 {
 .bEndpointAddress  = USB_DIR_IN | USB_SCO_EP,
-.bmAttributes  = USB_ENDPOINT_XFER_INT,
+.bmAttributes  = USB_ENDPOINT_XFER_ISOC,
 .wMaxPacketSize= 0x11,
 .bInterval = 0x01,
 },
@@ -162,13 +162,13 @@ static const USBDescIface desc_iface_bluetooth[] = {
 .eps = (USBDescEndpoint[]) {
 {
 .bEndpointAddress  = USB_DIR_OUT | USB_SCO_EP,
-.bmAttributes  = USB_ENDPOINT_XFER_INT,
+.bmAttributes  = USB_ENDPOINT_XFER_ISOC,
 .wMaxPacketSize= 0x19,
 .bInterval = 0x01,
 },
 {
 .bEndpointAddress  = USB_DIR_IN | USB_SCO_EP,
-.bmAttributes  = USB_ENDPOINT_XFER_INT,
+.bmAttributes  = USB_ENDPOINT_XFER_ISOC,
 .wMaxPacketSize= 0x19,
 .bInterval = 0x01,
 },
@@ -183,13 +183,13 @@ static const USBDescIface desc_iface_bluetooth[] = {
 .eps = (USBDescEndpoint[]) {
 {
 .bEndpointAddress  = USB_DIR_OUT | USB_SCO_EP,
-.bmAttributes  = USB_ENDPOINT_XFER_INT,
+.bmAttributes  = USB_ENDPOINT_XFER_ISOC,
 .wMaxPacketSize= 0x21,
 .bInterval = 0x01,
 },
 {
 .bEndpointAddress  = USB_DIR_IN | USB_SCO_EP,
-.bmAttributes  = USB_ENDPOINT_XFER_INT,
+.bmAttributes  = USB_ENDPOINT_XFER_ISOC,
 .wMaxPacketSize= 0x21,
 .bInterval = 0x01,
 },
@@ -204,13 +204,13 @@ static const USBDescIface desc_iface_bluetooth[] = {
 .eps = (USBDescEndpoint[]) {
 {
 .bEndpointAddress  = USB_DIR_OUT | USB_SCO_EP,
-.bmAttributes  = USB_ENDPOINT_XFER_INT,
+.bmAttributes  = USB_ENDPOINT_XFER_ISOC,
 .wMaxPacketSize= 0x31,
 .bInterval = 0x01,
 },
 {
 .bEndpointAddress  = USB_DIR_IN | USB_SCO_EP,
-.bmAttributes  = USB_ENDPOINT_XFER_INT,
+.bmAttributes  = USB_ENDPOINT_XFER_ISOC,
 .wMaxPacketSize= 0x31,
 .bInterval = 0x01,
 },
-- 
1.7.1




Re: [Qemu-devel] [PATCH 0/3] non-migratable devices

2011-07-08 Thread Gerd Hoffmann

  Hi,


For scsi-cd and other empty-but-generally-migratable devices we should
probably add an empty vmstate, so that any further addition can be done
as subsections.


That will break migration to older versions which don't know about the 
new sections, even if they are empty ...


cheers,
  Gerd



Re: [Qemu-devel] [PATCH 0/3] non-migratable devices

2011-07-08 Thread Paolo Bonzini

On 07/08/2011 10:53 AM, Gerd Hoffmann wrote:

   Hi,

This patch series adds an easy way to tag devices as non-migratable
puts it into use for ahci and ehci.

Gerd Hoffmann (3):
   vmstate: add no_migrate flag to VMStateDescription
   ahci doesn't support migration
   ehci doesn't support migration

  hw/hw.h   |1 +
  hw/ide/ich.c  |6 ++
  hw/usb-ehci.c |6 ++
  savevm.c  |1 +
  4 files changed, 14 insertions(+), 0 deletions(-)





ACK series

For scsi-cd and other empty-but-generally-migratable devices we should 
probably add an empty vmstate, so that any further addition can be done 
as subsections.


Paolo



Re: [Qemu-devel] VGA pass through and AHCI emulation status

2011-07-08 Thread Alexander Graf

On 08.07.2011, at 10:25, Piwko, Maciej wrote:

 Hi,
 
 We are currently working on passing primary VGA to GOS and checking AHCI 
 emulation. Therefore we are facing problem with that tasks.
 My questions are:
 1. What is the status of VGA pass-through? Are there any known issues with 
 that? Are there any fixes/patches on the way?

Better don't hold your breath here.

 2. AHCI emulation works fine - but only in Linux GOS. Unfortunately we would 
 like to run it in FreeBSD. The controller is seen but no drive can be 
 detected. Therefore my question is: What is the status of this emulation? Are 
 there any known issues? Are there any patches/fixes on the way?

AHCI emulation works with all guests I've tested so far except for one BSD 
flavor. I guess it was FreeBSD then :). The FreeBSD driver does some very 
awkward things, loading the AHCI driver only if it detects an ICH IDE 
controller. I debugged it for about a day and then just gave up on it, as we do 
have some pretty skilled FreeBSD developers in the community and I was hoping 
they'd just take a look at it :).

If you're interested in getting AHCI to work with FreeBSD, I'd be more than 
happy to review your patches :).


Alex

PS: Device emulation mails should always go to qemu-devel, as that's the 
project developing them. The KVM list is mainly for KVM specific code (like 
device passthrough for now), but AHCI definitely belongs to the qemu category.




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

2011-07-08 Thread Chun Yan Liu
On Thursday, July 07, 2011 09:51:45 PM you wrote:
 On 07/07/2011 10:24 AM, Chunyan Liu wrote:
  In previous thread Support logging xen-guest console, it's considered
  that adding a tee option to char layer is a more generic way and makes
  more sense.
  http://lists.nongnu.org/archive/html/qemu-devel/2011-06/msg03011.html
  
  Following is an implementation of tee option to char device. It could
  be used
  
  as follows:
   -chardev pty,id=id,path=path,[mux=on|off],[tee=filepath]
   -serial tee:filepath,pty
  
  With tee option, pty output would be duplicated to filepath.
  
  I've ported this patch to qemu-xen and tested with xen guests already.
  But I'm not very clear how to test the qemu binary directly. Any info?
  
  Please share your comments. Thanks!
  
  Signed-off-by: Chunyan Liucy...@novell.com
  ---
  
qemu-char.c   |  159
+
qemu-config.c |3 +
 
 This is missing documentation in *.hx
 
2 files changed, 162 insertions(+), 0 deletions(-)
  
  diff --git a/qemu-char.c b/qemu-char.c
  index fb13b28..7281ab4 100644
  --- a/qemu-char.c
  +++ b/qemu-char.c
  @@ -228,6 +228,135 @@ static CharDriverState *qemu_chr_open_null(QemuOpts
  *opts)
  
return chr;

}
  
  +/* Tee driver */
  +typedef struct {
  +CharDriverState *basechr; /* base io*/
  +CharDriverState *filechr; /* duplicate output to file */
  +} TeeDriver;
  +
  +static void tee_init(CharDriverState *chr)
  +{
  +TeeDriver *s = chr-opaque;
  +if (s-basechr-init) {
  +s-basechr-init(s-basechr);
  +}
  +if (s-filechr-init) {
  +s-filechr-init(s-filechr);
  +}
  +}
  +
  +static void tee_chr_update_read_handler(CharDriverState *chr)
  +{
  +TeeDriver *s = chr-opaque;
  +qemu_chr_add_handlers(s-basechr, chr-chr_can_read, chr-chr_read,
  +  chr-chr_event, chr-handler_opaque);
  +}
  +
  +static int tee_chr_write(CharDriverState *chr, const uint8_t *buf, int
  len) +{
  +TeeDriver *s = chr-opaque;
  +if (s-filechr-chr_write) {
  +s-filechr-chr_write(s-filechr, buf, len);
 
 What would we do if the file write didn't finish?
Result of file write is ignored, we cann't do anything except printing some 
error log, and we don't want char device output is affacted by that result. 
So, still write to char device. How do you think? 
 
  +}
  +if (s-basechr-chr_write) {
  +return s-basechr-chr_write(s-basechr, buf, len);
  +}
  +return 0;
  +}
  +
  +static void tee_chr_close(CharDriverState *chr)
  +{
  +TeeDriver *s = chr-opaque;
  +if (s-basechr-chr_close) {
  +s-basechr-chr_close(s-basechr);
  +}
  +if (s-filechr-chr_close) {
  +s-filechr-chr_close(s-filechr);
  +}
  +qemu_free(s);
  +}
  +
  +static int tee_chr_ioctl(CharDriverState *chr, int cmd, void *arg)
  +{
  +TeeDriver *s = chr-opaque;
  +if (s-basechr-chr_ioctl) {
  +return s-basechr-chr_ioctl(s-basechr, cmd, arg);
  +}
  +return 0;
  +}
  +
  +static int tee_get_msgfd(CharDriverState *chr)
  +{
  +TeeDriver *s = chr-opaque;
  +if (s-basechr-get_msgfd) {
  +return s-basechr-get_msgfd(s-basechr);
  +}
  +return -1;
  +}
  +
  +static void tee_chr_send_event(CharDriverState *chr, int event)
  +{
  +TeeDriver *s = chr-opaque;
  +if (s-basechr-chr_send_event) {
  +s-basechr-chr_send_event(s-basechr, event);
  +}
  +}
  +
  +static void tee_chr_accept_input(CharDriverState *chr)
  +{
  +TeeDriver *s = chr-opaque;
  +if (s-basechr-chr_accept_input) {
  +s-basechr-chr_accept_input(s-basechr);
  +}
  +}
  +static void tee_chr_set_echo(CharDriverState *chr, bool echo)
  +{
  +TeeDriver *s = chr-opaque;
  +if (s-basechr-chr_set_echo) {
  +s-basechr-chr_set_echo(s-basechr, echo);
  +}
  +}
  +static void tee_chr_guest_open(CharDriverState *chr)
  +{
  +TeeDriver *s = chr-opaque;
  +if (s-basechr-chr_guest_open) {
  +s-basechr-chr_guest_open(s-basechr);
  +}
  +}
  +static void tee_chr_guest_close(CharDriverState *chr)
  +{
  +TeeDriver *s = chr-opaque;
  +if (s-basechr-chr_guest_close) {
  +s-basechr-chr_guest_close(s-basechr);
  +}
  +}
  +
  +static CharDriverState *qemu_chr_open_tee(CharDriverState *basechr,
  + CharDriverState *filechr)
  +{
  +CharDriverState *chr;
  +TeeDriver *d;
  +
  +chr = qemu_mallocz(sizeof(CharDriverState));
  +d = qemu_mallocz(sizeof(TeeDriver));
 
 Instead of having 2 allocated regions, could you please fold them
 together and access each other through DO_UPCAST?
 
typedef struct {
CharDriverState chr;  /* our own driver state */
CharDriverState *basechr; /* base io*/
CharDriverState *filechr; /* duplicate output to file */
} TeeDriver;
 
 
 [...]
 
 void foo(CharDriverState *chr)
 {

Re: [Qemu-devel] [PATCH 0/3] non-migratable devices

2011-07-08 Thread Paolo Bonzini

On 07/08/2011 11:59 AM, Gerd Hoffmann wrote:




For scsi-cd and other empty-but-generally-migratable devices we should
probably add an empty vmstate, so that any further addition can be done
as subsections.


That will break migration to older versions which don't know about the
new sections, even if they are empty ...


scsi-cd is new in 0.15, older versions have scsi-disk only.  That's why 
we should take the occasion to add the empty vmstate at least to it.


For other devices, it's better to make the breakage in a single version. 
 It also allows to make 0.15 the flag day where each device shall 
have a VMState or the entire VM will not be migratable.  If desired, in 
the future we can revert this behavior for pc-0.14 and earlier machines.


Paolo



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

2011-07-08 Thread Alexander Graf

On 08.07.2011, at 12:17, Chun Yan Liu wrote:

 On Thursday, July 07, 2011 09:51:45 PM you wrote:
 On 07/07/2011 10:24 AM, Chunyan Liu wrote:
 In previous thread Support logging xen-guest console, it's considered
 that adding a tee option to char layer is a more generic way and makes
 more sense.
 http://lists.nongnu.org/archive/html/qemu-devel/2011-06/msg03011.html
 
 Following is an implementation of tee option to char device. It could
 be used
 
 as follows:
 -chardev pty,id=id,path=path,[mux=on|off],[tee=filepath]
 -serial tee:filepath,pty
 
 With tee option, pty output would be duplicated to filepath.
 
 I've ported this patch to qemu-xen and tested with xen guests already.
 But I'm not very clear how to test the qemu binary directly. Any info?
 
 Please share your comments. Thanks!
 
 Signed-off-by: Chunyan Liucy...@novell.com
 ---
 
  qemu-char.c   |  159
  +
  qemu-config.c |3 +
 
 This is missing documentation in *.hx
 
  2 files changed, 162 insertions(+), 0 deletions(-)
 
 diff --git a/qemu-char.c b/qemu-char.c
 index fb13b28..7281ab4 100644
 --- a/qemu-char.c
 +++ b/qemu-char.c
 @@ -228,6 +228,135 @@ static CharDriverState *qemu_chr_open_null(QemuOpts
 *opts)
 
  return chr;
 
  }
 
 +/* Tee driver */
 +typedef struct {
 +CharDriverState *basechr; /* base io*/
 +CharDriverState *filechr; /* duplicate output to file */
 +} TeeDriver;
 +
 +static void tee_init(CharDriverState *chr)
 +{
 +TeeDriver *s = chr-opaque;
 +if (s-basechr-init) {
 +s-basechr-init(s-basechr);
 +}
 +if (s-filechr-init) {
 +s-filechr-init(s-filechr);
 +}
 +}
 +
 +static void tee_chr_update_read_handler(CharDriverState *chr)
 +{
 +TeeDriver *s = chr-opaque;
 +qemu_chr_add_handlers(s-basechr, chr-chr_can_read, chr-chr_read,
 +  chr-chr_event, chr-handler_opaque);
 +}
 +
 +static int tee_chr_write(CharDriverState *chr, const uint8_t *buf, int
 len) +{
 +TeeDriver *s = chr-opaque;
 +if (s-filechr-chr_write) {
 +s-filechr-chr_write(s-filechr, buf, len);
 
 What would we do if the file write didn't finish?
 Result of file write is ignored, we cann't do anything except printing some 
 error log, and we don't want char device output is affacted by that result. 
 So, still write to char device. How do you think? 

Well, we could repeat the write at a later point or escalate up that the write 
failed. We could even go as far as failing the write altogether if the file 
write failed. The return value is number of bytes written btw, so there could 
be a case where we send a write of 10 bytes in, the file backend writes 5 bytes 
and the other backend writes 7.

But I guess we should just ignore these corner cases and put a comment in the 
code saying that we're aware of the potential issues :).

 
 +}
 +if (s-basechr-chr_write) {
 +return s-basechr-chr_write(s-basechr, buf, len);
 +}
 +return 0;
 +}
 +
 +static void tee_chr_close(CharDriverState *chr)
 +{
 +TeeDriver *s = chr-opaque;
 +if (s-basechr-chr_close) {
 +s-basechr-chr_close(s-basechr);
 +}
 +if (s-filechr-chr_close) {
 +s-filechr-chr_close(s-filechr);
 +}
 +qemu_free(s);
 +}
 +
 +static int tee_chr_ioctl(CharDriverState *chr, int cmd, void *arg)
 +{
 +TeeDriver *s = chr-opaque;
 +if (s-basechr-chr_ioctl) {
 +return s-basechr-chr_ioctl(s-basechr, cmd, arg);
 +}
 +return 0;
 +}
 +
 +static int tee_get_msgfd(CharDriverState *chr)
 +{
 +TeeDriver *s = chr-opaque;
 +if (s-basechr-get_msgfd) {
 +return s-basechr-get_msgfd(s-basechr);
 +}
 +return -1;
 +}
 +
 +static void tee_chr_send_event(CharDriverState *chr, int event)
 +{
 +TeeDriver *s = chr-opaque;
 +if (s-basechr-chr_send_event) {
 +s-basechr-chr_send_event(s-basechr, event);
 +}
 +}
 +
 +static void tee_chr_accept_input(CharDriverState *chr)
 +{
 +TeeDriver *s = chr-opaque;
 +if (s-basechr-chr_accept_input) {
 +s-basechr-chr_accept_input(s-basechr);
 +}
 +}
 +static void tee_chr_set_echo(CharDriverState *chr, bool echo)
 +{
 +TeeDriver *s = chr-opaque;
 +if (s-basechr-chr_set_echo) {
 +s-basechr-chr_set_echo(s-basechr, echo);
 +}
 +}
 +static void tee_chr_guest_open(CharDriverState *chr)
 +{
 +TeeDriver *s = chr-opaque;
 +if (s-basechr-chr_guest_open) {
 +s-basechr-chr_guest_open(s-basechr);
 +}
 +}
 +static void tee_chr_guest_close(CharDriverState *chr)
 +{
 +TeeDriver *s = chr-opaque;
 +if (s-basechr-chr_guest_close) {
 +s-basechr-chr_guest_close(s-basechr);
 +}
 +}
 +
 +static CharDriverState *qemu_chr_open_tee(CharDriverState *basechr,
 + CharDriverState *filechr)
 +{
 +CharDriverState *chr;
 +TeeDriver *d;
 +
 +chr = qemu_mallocz(sizeof(CharDriverState));
 +d = qemu_mallocz(sizeof(TeeDriver));
 
 

[Qemu-devel] [PATCH 0/1] QMP command for snapshot_blkdev

2011-07-08 Thread Jes . Sorensen
From: Jes Sorensen jes.soren...@redhat.com

Hi,

I discussed the issue of a QMP command for live snapshot with Anthony,
and we have agreed that it is fine to have a QMP command that matches
the current human monitor command. This doesn't preclude that in the
future someone may want to add support breaking live snapshots into
multiple commands.

Cheers,
Jes

Jes Sorensen (1):
  QMP: add snapshot_blkdev command

 qmp-commands.hx |   38 ++
 1 files changed, 38 insertions(+), 0 deletions(-)

-- 
1.7.4.4




[Qemu-devel] [PATCH 1/1] QMP: add snapshot_blkdev command

2011-07-08 Thread Jes . Sorensen
From: Jes Sorensen jes.soren...@redhat.com

Add QMP bits for snapshot_blkdev command. This is the same as
snapshot_blkdev in the human monitor. The command is synchronous.

In the future async commands and or a break down of the functionality
into multiple commands might be added.

Signed-off-by: Jes Sorensen jes.soren...@redhat.com
---
 qmp-commands.hx |   38 ++
 1 files changed, 38 insertions(+), 0 deletions(-)

diff --git a/qmp-commands.hx b/qmp-commands.hx
index 92c5c3a..eb135c1 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -694,6 +694,44 @@ Example:
 EQMP
 
 {
+.name   = blockdev-snapshot,
+.args_type  = device:B,snapshot_file:s?,format:s?,
+.params = device [new-image-file] [format],
+.help   = initiates a live snapshot\n\t\t\t
+  of device. If a new image file is specified, 
the\n\t\t\t
+  new image file will become the new root image.\n\t\t\t
+  If format is specified, the snapshot file will\n\t\t\t
+  be created in that format. Otherwise the\n\t\t\t
+  snapshot will be internal! (currently unsupported),
+.user_print = monitor_user_noop,
+.mhandler.cmd_new = do_snapshot_blkdev,
+},
+
+SQMP
+blockdev-snapshot-sync
+--
+
+Synchronous snapshot of block device, using snapshot file as target,
+if provided. 
+
+Arguments:
+
+- device: device name to snapshot (json-string)
+- snapshot_file: name of new image file (json-string)
+- format: format of new image (json-string)
+
+Example:
+
+- { execute: blockdev-snapshot, arguments: { device: ide-hd0,
+snapshot_file:
+/some/place/my-image,
+   format: qcow2
+   } }
+- { return: {} }
+
+EQMP
+
+{
 .name   = balloon,
 .args_type  = value:M,
 .params = target,
-- 
1.7.4.4




Re: [Qemu-devel] [PATCH 0/3] non-migratable devices

2011-07-08 Thread Markus Armbruster
Gerd Hoffmann kra...@redhat.com writes:

   Hi,

 For scsi-cd and other empty-but-generally-migratable devices we should
 probably add an empty vmstate, so that any further addition can be done
 as subsections.

 That will break migration to older versions which don't know about the
 new sections, even if they are empty ...

Send them only when running a sufficiently recent -M?



Re: [Qemu-devel] [Sheepdog] [PATCH] sheepdog: add data preallocation support

2011-07-08 Thread MORITA Kazutaka
At Wed, 06 Jul 2011 09:53:32 +0200,
Kevin Wolf wrote:
 
 Am 05.07.2011 20:21, schrieb MORITA Kazutaka:
  +
  +max_idx = (vdi_size + SD_DATA_OBJ_SIZE - 1) / SD_DATA_OBJ_SIZE;
  +
  +for (idx = 0; idx  max_idx; idx++) {
  +uint64_t oid;
  +oid = vid_to_data_oid(vid, idx);
  +
  +if (inode-data_vdi_id[idx]) {
  +ret = read_object(fd, buf, 
  vid_to_vdi_oid(inode-data_vdi_id[idx]),
  +  1, SD_DATA_OBJ_SIZE, 0);
  +if (ret)
  +goto out;
 
  Missing braces.
 
  Also, what is this if branch doing? Is it to ensure that we don't
  overwrite existing data? But then, isn't an image always empty when we
  preallocate it?
  
  This branch is for handling a cloned image, which is created with -b
  option.  This branch reads data from the backing file (read_object
  returns zero when it succeeds) instead of filling buffer with zero.
 
 Oh, I see. You support preallocation even with backing files. And
 suddenly it makes perfect sense. :-)
 
 (Although after completing preallocation, you won't need the backing
 file any more as all of it has been copied into the image. Maybe we
 should drop the reference then?)

Though we can drop it, Sheepdog uses the reference to show the VM
image relationships in a tree format as VMware does.  So as far as a
Sheepdog protocol is concerned, I think we should keep it.


Thanks,

Kazutaka



Re: [Qemu-devel] [PATCH 0/3] non-migratable devices

2011-07-08 Thread Paolo Bonzini

On 07/08/2011 01:47 PM, Gerd Hoffmann wrote:




scsi-cd is new in 0.15, older versions have scsi-disk only. That's why
we should take the occasion to add the empty vmstate at least to it.


Ok, good opportunity in that specific case.


For other devices, it's better to make the breakage in a single version.
It also allows to make 0.15 the flag day where each device shall have
a VMState or the entire VM will not be migratable.


Not that easy given that we didn't fully migrate to vmstate yet,
otherwise we could simply fail migration in case we find any device with
qdev-vmsd == NULL.


You can always add

#define VMSD_NONE  ((const VMStateDescription *) 1)


If desired, in the
future we can revert this behavior for pc-0.14 and earlier machines.


And I'm still looking for a sane way to handle *this*.


One possibility is to add device name remapping to machine types, like 
ide is actually ide-0.14 when using pc-0.14 and put a different 
VMState in ide-0.14.


Paolo



Re: [Qemu-devel] [PATCH 0/3] non-migratable devices

2011-07-08 Thread Gerd Hoffmann

  Hi,


scsi-cd is new in 0.15, older versions have scsi-disk only. That's why
we should take the occasion to add the empty vmstate at least to it.


Ok, good opportunity in that specific case.


For other devices, it's better to make the breakage in a single version.
It also allows to make 0.15 the flag day where each device shall have
a VMState or the entire VM will not be migratable.


Not that easy given that we didn't fully migrate to vmstate yet, 
otherwise we could simply fail migration in case we find any device with 
qdev-vmsd == NULL.



If desired, in the
future we can revert this behavior for pc-0.14 and earlier machines.


And I'm still looking for a sane way to handle *this*.

cheers,
  Gerd



Re: [Qemu-devel] [PATCH] qemu-options.hx: Document werror and rerror -drive options

2011-07-08 Thread Luiz Capitulino
On Fri, 08 Jul 2011 10:18:17 +0200
Kevin Wolf kw...@redhat.com wrote:

 Am 07.07.2011 18:04, schrieb Luiz Capitulino:
  
  Signed-off-by: Luiz Capitulino lcapitul...@redhat.com
  ---
   qemu-options.hx |5 +
   1 files changed, 5 insertions(+), 0 deletions(-)
  
  diff --git a/qemu-options.hx b/qemu-options.hx
  index e6d7adc..5f16a78 100644
  --- a/qemu-options.hx
  +++ b/qemu-options.hx
  @@ -160,6 +160,11 @@ an untrusted format header.
   This option specifies the serial number to assign to the device.
   @item addr=@var{addr}
   Specify the controller's PCI address (if=virtio only).
  +@item werror=@var{action},rerror=@var{action}
  +Specify which @var{action} to take on write and read errors. Valid actions 
  are:
  +ignore (ignore the error and try to continue), stop (pause QEMU),
  +enospc (pause QEMU, but only on no space conditions),
 
 Maybe pause QEMU only if the host disk is full; report the error to the
 guest otherwise?

Works for me.

  +report (report the error to the guest).
   @end table
   
   By default, writethrough caching is used for all block device.  This means 
  that
 
 We should mention that werror=enospc and rerror=report is the default.

I did that in my first private first, but I dropped when I realized that
we don't document defaults for the other options.



Re: [Qemu-devel] [PATCH 0/3] non-migratable devices

2011-07-08 Thread Gerd Hoffmann

  Hi,


If desired, in the
future we can revert this behavior for pc-0.14 and earlier machines.


And I'm still looking for a sane way to handle *this*.


One possibility is to add device name remapping to machine types, like
ide is actually ide-0.14 when using pc-0.14 and put a different
VMState in ide-0.14.


That isn't very different from subsections.

Problem is that the old qemu version doesn't have the section at all, 
not that it looks somehow different.


cheers,
  Gerd



[Qemu-devel] [PATCH 1/6] mips: sigaltstack args

2011-07-08 Thread Wesley W. Terpstra
The syscall sigaltstack takes two parameters, not zero. This patch
should have no impact as only values above 4 influence the runtime
behaviour. Nevertheless, it is wrong.

Signed-off-by: Wesley W. Terpstra terps...@debian.org
---

diff --git a/linux-user/main.c b/linux-user/main.c
index 289054b..26ebc73 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -1875,7 +1875,7 @@ static const uint8_t mips_syscall_args[] = {
 MIPS_SYS(sys_getcwd    , 2)
 MIPS_SYS(sys_capget    , 2)
 MIPS_SYS(sys_capset    , 2)    /* 4205 */
-    MIPS_SYS(sys_sigaltstack    , 0)
+    MIPS_SYS(sys_sigaltstack    , 2)
 MIPS_SYS(sys_sendfile    , 4)
 MIPS_SYS(sys_ni_syscall    , 0)
 MIPS_SYS(sys_ni_syscall    , 0)
diff --git a/linux-user/main.c b/linux-user/main.c
index 289054b..26ebc73 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -1875,7 +1875,7 @@ static const uint8_t mips_syscall_args[] = {
 	MIPS_SYS(sys_getcwd	, 2)
 	MIPS_SYS(sys_capget	, 2)
 	MIPS_SYS(sys_capset	, 2)	/* 4205 */
-	MIPS_SYS(sys_sigaltstack	, 0)
+	MIPS_SYS(sys_sigaltstack	, 2)
 	MIPS_SYS(sys_sendfile	, 4)
 	MIPS_SYS(sys_ni_syscall	, 0)
 	MIPS_SYS(sys_ni_syscall	, 0)


Re: [Qemu-devel] [PATCH 0/3] non-migratable devices

2011-07-08 Thread Paolo Bonzini

On 07/08/2011 02:47 PM, Gerd Hoffmann wrote:


One possibility is to add device name remapping to machine types, like
ide is actually ide-0.14 when using pc-0.14 and put a different
VMState in ide-0.14.


That isn't very different from subsections.

Problem is that the old qemu version doesn't have the section at all,
not that it looks somehow different.


No, I meant a different qdev name, i.e. mapping the same device name to 
a different DeviceInfo.


Paolo



Re: [Qemu-devel] [PATCH v8 09/12] VMDK: open/read/write for monolithicFlat image

2011-07-08 Thread Stefan Hajnoczi
On Tue, Jul 5, 2011 at 12:31 PM, Fam Zheng famc...@gmail.com wrote:
 +        ret = sscanf(p, %10s %lld %10s %512s,
[...]
 +            ret = sscanf(p, %10s %lld %10s %511s %lld,

%512s - %511s

But instead of duplicating the format string and sscanf(3), I suggest
doing sscanf(p, %10s %lld %10s %511s %lld, ...) once only.

After it returns you can check:
if (ret  4) {
...fail...
} else if (!strcmp(access, FLAT)) {
if (ret != 5 || flat_offset  0) {
...fail...
}
} else {
if (ret != 4) {
...fail...
}
}

Stefan



Re: [Qemu-devel] migration: new sections and backward compatibility.

2011-07-08 Thread Jes Sorensen
On 07/07/11 09:30, Avi Kivity wrote:
 On 07/07/2011 10:14 AM, Gerd Hoffmann wrote:
 Can't we just implicitly fail migration whenever there's a device in
 the tree that doesn't have VMSTATE?


 There are cases where the device doesn't need to save state, so that
 alone doesn't cut it.
 
 It should then say so by having an empty VMSTATE descriptor.

It seems reasonable to me to introduce a situation where devices have to
explicitly marked as migration compatible and fail if there are devices
in the system which are not.

Even for the case like USB devices where migration might simply force a
replug of the devices.

Cheers,
Jes





[Qemu-devel] [PATCH 3/6] mips: null pointer deref should segfault

2011-07-08 Thread Wesley W. Terpstra
Dereferencing a null pointer causes an exception 0xC (EXCP_AdEL)
instead of EXCP_TLBL. This should also trigger a segfault.

Signed-off-by: Wesley W. Terpstra terps...@debian.org
---

diff --git a/linux-user/main.c b/linux-user/main.c
index 289054b..26ebc73 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -2093,6 +2107,8 @@ void cpu_loop(CPUMIPSState *env)
 break;
 case EXCP_TLBL:
 case EXCP_TLBS:
+case EXCP_AdEL:
+case EXCP_AdES:
 info.si_signo = TARGET_SIGSEGV;
 info.si_errno = 0;
 /* XXX: check env-error_code */
diff --git a/linux-user/main.c b/linux-user/main.c
index 289054b..26ebc73 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -2093,6 +2107,8 @@ void cpu_loop(CPUMIPSState *env)
 break;
 case EXCP_TLBL:
 case EXCP_TLBS:
+case EXCP_AdEL:
+case EXCP_AdES:
 info.si_signo = TARGET_SIGSEGV;
 info.si_errno = 0;
 /* XXX: check env-error_code */


[Qemu-devel] [PATCH 2/6] mips: missing syscall returns wrong errno

2011-07-08 Thread Wesley W. Terpstra
Return -TARGET_ENOSYS instead of -ENOSYS from linux-user/main.c
   * Caused strange 'Level 2 synchronization messages' instead of
correctly reporting the syscall was missing.
   * Made glibc simply fail instead of using older syscalls

Signed-off-by: Wesley W. Terpstra terps...@debian.org
---

diff --git a/linux-user/main.c b/linux-user/main.c
index 289054b..26ebc73 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -2053,7 +2067,7 @@ void cpu_loop(CPUMIPSState *env)
 syscall_num = env-active_tc.gpr[2] - 4000;
 env-active_tc.PC += 4;
 if (syscall_num = sizeof(mips_syscall_args)) {
-ret = -ENOSYS;
+ret = -TARGET_ENOSYS;
 } else {
 int nb_args;
 abi_ulong sp_reg;
diff --git a/linux-user/main.c b/linux-user/main.c
index 289054b..26ebc73 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -2053,7 +2067,7 @@ void cpu_loop(CPUMIPSState *env)
 syscall_num = env-active_tc.gpr[2] - 4000;
 env-active_tc.PC += 4;
 if (syscall_num = sizeof(mips_syscall_args)) {
-ret = -ENOSYS;
+ret = -TARGET_ENOSYS;
 } else {
 int nb_args;
 abi_ulong sp_reg;


[Qemu-devel] [PATCH 6/6] mips: eabi syscall support for 64-bit args

2011-07-08 Thread Wesley W. Terpstra
mips uses the eabi calling convention. For 64-bit values this means
some registers are skipped. This patch replicates the behaviour of
arm/eabi for mips targets.
This affects ftruncate64, creating insane sized fails (or just failing).

Signed-off-by: Wesley W. Terpstra terps...@debian.org
---

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index fed7a8f..0b0a3d0 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -4367,6 +4367,10 @@
 arg3 = arg4;
   }
 #endif
+#ifdef TARGET_MIPS
+arg2 = arg3;
+arg3 = arg4;
+#endif
 return get_errno(truncate64(arg1, target_offset64(arg2, arg3)));
 }
 #endif
@@ -4384,6 +4388,10 @@
 arg3 = arg4;
   }
 #endif
+#ifdef TARGET_MIPS
+arg2 = arg3;
+arg3 = arg4;
+#endif
 return get_errno(ftruncate64(arg1, target_offset64(arg2, arg3)));
 }
 #endif
@@ -6841,6 +6849,9 @@
 if (((CPUARMState *)cpu_env)-eabi)
 arg4 = arg5;
 #endif
+#ifdef TARGET_MIPS
+arg4 = arg5;
+#endif
 if (!(p = lock_user(VERIFY_WRITE, arg2, arg3, 0)))
 goto efault;
 ret = get_errno(pread(arg1, p, arg3, arg4));
@@ -6851,6 +6862,9 @@
 if (((CPUARMState *)cpu_env)-eabi)
 arg4 = arg5;
 #endif
+#ifdef TARGET_MIPS
+arg4 = arg5;
+#endif
 if (!(p = lock_user(VERIFY_READ, arg2, arg3, 1)))
 goto efault;
 ret = get_errno(pwrite(arg1, p, arg3, arg4));
@@ -7609,6 +7623,11 @@
 arg4 = arg5;
 }
 #endif
+#ifdef TARGET_MIPS
+arg2 = arg3;
+arg3 = arg4;
+arg4 = arg5;
+#endif
 ret = get_errno(readahead(arg1, ((off64_t)arg3  32) | arg2, arg4));
 #else
 ret = get_errno(readahead(arg1, arg2, arg3));
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index fed7a8f..0b0a3d0 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -4367,6 +4367,10 @@
 arg3 = arg4;
   }
 #endif
+#ifdef TARGET_MIPS
+arg2 = arg3;
+arg3 = arg4;
+#endif
 return get_errno(truncate64(arg1, target_offset64(arg2, arg3)));
 }
 #endif
@@ -4384,6 +4388,10 @@
 arg3 = arg4;
   }
 #endif
+#ifdef TARGET_MIPS
+arg2 = arg3;
+arg3 = arg4;
+#endif
 return get_errno(ftruncate64(arg1, target_offset64(arg2, arg3)));
 }
 #endif
@@ -6841,6 +6849,9 @@
 if (((CPUARMState *)cpu_env)-eabi)
 arg4 = arg5;
 #endif
+#ifdef TARGET_MIPS
+arg4 = arg5;
+#endif
 if (!(p = lock_user(VERIFY_WRITE, arg2, arg3, 0)))
 goto efault;
 ret = get_errno(pread(arg1, p, arg3, arg4));
@@ -6851,6 +6862,9 @@
 if (((CPUARMState *)cpu_env)-eabi)
 arg4 = arg5;
 #endif
+#ifdef TARGET_MIPS
+arg4 = arg5;
+#endif
 if (!(p = lock_user(VERIFY_READ, arg2, arg3, 1)))
 goto efault;
 ret = get_errno(pwrite(arg1, p, arg3, arg4));
@@ -7609,6 +7623,11 @@
 arg4 = arg5;
 }
 #endif
+#ifdef TARGET_MIPS
+arg2 = arg3;
+arg3 = arg4;
+arg4 = arg5;
+#endif
 ret = get_errno(readahead(arg1, ((off64_t)arg3  32) | arg2, arg4));
 #else
 ret = get_errno(readahead(arg1, arg2, arg3));


[Qemu-devel] [PATCH 4/6] mips: rlimit incorrectly converts values

2011-07-08 Thread Wesley W. Terpstra
Byte swap was applied in the wrong order with testing for
RLIM_INFINITY. On mips bigendian from an amd64 system this results in
infinity being misinterpretted as 2^31-1.

This is a serious bug because it causes setrlimit stack size to kill
all child processes. This means (for example) that 'make' can run no
children. The mechanism of failure:
1. parent sets stack size rlimit to 'infinity'
2. qemu screws this value up
3. child process fetches stack size as a large (but non-infinite) value
4. qemu tries to allocate stack before execution
5. stack allocation fails (too big) and child process dies

Signed-off-by: Wesley W. Terpstra terps...@debian.org
---

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index fed7a8f..0b0a3d0 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -919,18 +919,30 @@ static inline abi_long
host_to_target_rusage(abi_ulong target_addr,

 static inline rlim_t target_to_host_rlim(target_ulong target_rlim)
 {
-if (target_rlim == TARGET_RLIM_INFINITY)
-return RLIM_INFINITY;
+target_ulong target_rlim_swap;
+rlim_t result;
+
+target_rlim_swap = tswapl(target_rlim);
+if (target_rlim_swap == TARGET_RLIM_INFINITY || target_rlim_swap
!= (rlim_t)target_rlim_swap)
+result = RLIM_INFINITY;
 else
-return tswapl(target_rlim);
+result = target_rlim_swap;
+
+return result;
 }

 static inline target_ulong host_to_target_rlim(rlim_t rlim)
 {
+target_ulong target_rlim_swap;
+target_ulong result;
+
 if (rlim == RLIM_INFINITY || rlim != (target_long)rlim)
-return TARGET_RLIM_INFINITY;
+target_rlim_swap = TARGET_RLIM_INFINITY;
 else
-return tswapl(rlim);
+target_rlim_swap = rlim;
+result = tswapl(target_rlim_swap);
+
+return result;
 }

 static inline abi_long copy_from_user_timeval(struct timeval *tv,
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index fed7a8f..0b0a3d0 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -919,18 +919,30 @@ static inline abi_long host_to_target_rusage(abi_ulong target_addr,
 
 static inline rlim_t target_to_host_rlim(target_ulong target_rlim)
 {
-if (target_rlim == TARGET_RLIM_INFINITY)
-return RLIM_INFINITY;
+target_ulong target_rlim_swap;
+rlim_t result;
+
+target_rlim_swap = tswapl(target_rlim);
+if (target_rlim_swap == TARGET_RLIM_INFINITY || target_rlim_swap != (rlim_t)target_rlim_swap)
+result = RLIM_INFINITY;
 else
-return tswapl(target_rlim);
+result = target_rlim_swap;
+
+return result;
 }
 
 static inline target_ulong host_to_target_rlim(rlim_t rlim)
 {
+target_ulong target_rlim_swap;
+target_ulong result;
+
 if (rlim == RLIM_INFINITY || rlim != (target_long)rlim)
-return TARGET_RLIM_INFINITY;
+target_rlim_swap = TARGET_RLIM_INFINITY;
 else
-return tswapl(rlim);
+target_rlim_swap = rlim;
+result = tswapl(target_rlim_swap);
+
+return result;
 }
 
 static inline abi_long copy_from_user_timeval(struct timeval *tv,


[Qemu-devel] [PATCH 5/6] mips: rlimit codes are not the same

2011-07-08 Thread Wesley W. Terpstra
The codes for get/setrlimit differ between linux target platforms.
This patch adds conversion.
This is important else programs (rsyslog, python, ...) can go into a
near infinite loop trying to close all the file descriptors from 0 to
-1.

Signed-off-by: Wesley W. Terpstra terps...@debian.org
---

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index fed7a8f..2011e66 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -945,6 +945,44 @@
 return result;
 }

+static inline int target_to_host_resource(int code)
+{
+switch (code) {
+case TARGET_RLIMIT_AS:
+return RLIMIT_AS;
+case TARGET_RLIMIT_CORE:
+return RLIMIT_CORE;
+case TARGET_RLIMIT_CPU:
+return RLIMIT_CPU;
+case TARGET_RLIMIT_DATA:
+return RLIMIT_DATA;
+case TARGET_RLIMIT_FSIZE:
+return RLIMIT_FSIZE;
+case TARGET_RLIMIT_LOCKS:
+return RLIMIT_LOCKS;
+case TARGET_RLIMIT_MEMLOCK:
+return RLIMIT_MEMLOCK;
+case TARGET_RLIMIT_MSGQUEUE:
+return RLIMIT_MSGQUEUE;
+case TARGET_RLIMIT_NICE:
+return RLIMIT_NICE;
+case TARGET_RLIMIT_NOFILE:
+return RLIMIT_NOFILE;
+case TARGET_RLIMIT_NPROC:
+return RLIMIT_NPROC;
+case TARGET_RLIMIT_RSS:
+return RLIMIT_RSS;
+case TARGET_RLIMIT_RTPRIO:
+return RLIMIT_RTPRIO;
+case TARGET_RLIMIT_SIGPENDING:
+return RLIMIT_SIGPENDING;
+case TARGET_RLIMIT_STACK:
+return RLIMIT_STACK;
+default:
+return code;
+}
+}
+
 static inline abi_long copy_from_user_timeval(struct timeval *tv,
   abi_ulong target_tv_addr)
 {
@@ -,7 +5593,7 @@
 break;
 case TARGET_NR_setrlimit:
 {
-int resource = arg1;
+int resource = target_to_host_resource(arg1);
 struct target_rlimit *target_rlim;
 struct rlimit rlim;
 if (!lock_user_struct(VERIFY_READ, target_rlim, arg2, 1))
@@ -5568,7 +5606,7 @@
 break;
 case TARGET_NR_getrlimit:
 {
-int resource = arg1;
+int resource = target_to_host_resource(arg1);
 struct target_rlimit *target_rlim;
 struct rlimit rlim;

@@ -6872,7 +6910,8 @@
 case TARGET_NR_ugetrlimit:
 {
struct rlimit rlim;
-   ret = get_errno(getrlimit(arg1, rlim));
+   int resource = target_to_host_resource(arg1);
+   ret = get_errno(getrlimit(resource, rlim));
if (!is_error(ret)) {
struct target_rlimit *target_rlim;
 if (!lock_user_struct(VERIFY_WRITE, target_rlim, arg2, 0))
diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h
index 04c268d..6ec9c31 100644
--- a/linux-user/syscall_defs.h
+++ b/linux-user/syscall_defs.h
@@ -693,6 +693,40 @@ struct target_rlimit {
 #define TARGET_RLIM_INFINITY   ((target_ulong)~0UL)
 #endif

+#if defined(TARGET_MIPS)
+#define TARGET_RLIMIT_CPU  0
+#define TARGET_RLIMIT_FSIZE1
+#define TARGET_RLIMIT_DATA 2
+#define TARGET_RLIMIT_STACK3
+#define TARGET_RLIMIT_CORE 4
+#define TARGET_RLIMIT_RSS  7
+#define TARGET_RLIMIT_NPROC8
+#define TARGET_RLIMIT_NOFILE   5
+#define TARGET_RLIMIT_MEMLOCK  9
+#define TARGET_RLIMIT_AS   6
+#define TARGET_RLIMIT_LOCKS10
+#define TARGET_RLIMIT_SIGPENDING   11
+#define TARGET_RLIMIT_MSGQUEUE 12
+#define TARGET_RLIMIT_NICE 13
+#define TARGET_RLIMIT_RTPRIO   14
+#else
+#define TARGET_RLIMIT_CPU  0
+#define TARGET_RLIMIT_FSIZE1
+#define TARGET_RLIMIT_DATA 2
+#define TARGET_RLIMIT_STACK3
+#define TARGET_RLIMIT_CORE 4
+#define TARGET_RLIMIT_RSS  5
+#define TARGET_RLIMIT_NPROC6
+#define TARGET_RLIMIT_NOFILE   7
+#define TARGET_RLIMIT_MEMLOCK  8
+#define TARGET_RLIMIT_AS   9
+#define TARGET_RLIMIT_LOCKS10
+#define TARGET_RLIMIT_SIGPENDING   11
+#define TARGET_RLIMIT_MSGQUEUE 12
+#define TARGET_RLIMIT_NICE 13
+#define TARGET_RLIMIT_RTPRIO   14
+#endif
+
 struct target_pollfd {
 int fd;   /* file descriptor */
 short events; /* requested events */
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index fed7a8f..2011e66 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -945,6 +945,44 @@
 return result;
 }
 
+static inline int target_to_host_resource(int code)
+{
+switch (code) {
+case TARGET_RLIMIT_AS:
+return RLIMIT_AS;
+case TARGET_RLIMIT_CORE:
+return RLIMIT_CORE;
+case TARGET_RLIMIT_CPU:
+return RLIMIT_CPU;
+case TARGET_RLIMIT_DATA:
+return RLIMIT_DATA;
+case TARGET_RLIMIT_FSIZE:
+return RLIMIT_FSIZE;
+case TARGET_RLIMIT_LOCKS:
+return RLIMIT_LOCKS;
+case TARGET_RLIMIT_MEMLOCK:
+

Re: [Qemu-devel] [PATCH 0/3] non-migratable devices

2011-07-08 Thread Gerd Hoffmann

On 07/08/11 14:59, Paolo Bonzini wrote:

On 07/08/2011 02:47 PM, Gerd Hoffmann wrote:


One possibility is to add device name remapping to machine types, like
ide is actually ide-0.14 when using pc-0.14 and put a different
VMState in ide-0.14.


That isn't very different from subsections.

Problem is that the old qemu version doesn't have the section at all,
not that it looks somehow different.


No, I meant a different qdev name, i.e. mapping the same device name to
a different DeviceInfo.


That is an idea.  This could also replace compat properties (by giving 
ide-0.14 different default values for the properties) and thereby move 
the compat info from hw/pc.c to hw/ide/xxx.c.


cheers,
  Gerd



[Qemu-devel] [PATCH 4/3] vmstate: complain about devices without vmstate

2011-07-08 Thread Gerd Hoffmann
Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 hw/hw.h   |2 ++
 hw/qdev.c |7 ++-
 2 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/hw/hw.h b/hw/hw.h
index 1eb3486..6d6c493 100644
--- a/hw/hw.h
+++ b/hw/hw.h
@@ -336,6 +336,8 @@ struct VMStateDescription {
 const VMStateSubsection *subsections;
 };
 
+#define VMSD_NONE ((const VMStateDescription*)1)
+
 extern const VMStateInfo vmstate_info_bool;
 
 extern const VMStateInfo vmstate_info_int8;
diff --git a/hw/qdev.c b/hw/qdev.c
index 292b52f..fafbbae 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -283,7 +283,12 @@ int qdev_init(DeviceState *dev)
 qdev_free(dev);
 return rc;
 }
-if (dev-info-vmsd) {
+if (dev-info-vmsd == NULL) {
+/* TODO: fixup qemu source code, then make this an assert() */
+error_report(WARNING: device %s has no vmstate\n, dev-info-name);
+} else if (dev-info-vmsd == VMSD_NONE) {
+/* device doesn't need vmstate */;
+} else {
 vmstate_register_with_alias_id(dev, -1, dev-info-vmsd, dev,
dev-instance_id_alias,
dev-alias_required_for_version);
-- 
1.7.1




Re: [Qemu-devel] [PATCH v6 1/4] guest agent: command state class

2011-07-08 Thread Luiz Capitulino
On Tue,  5 Jul 2011 08:21:37 -0500
Michael Roth mdr...@linux.vnet.ibm.com wrote:

 
 Signed-off-by: Michael Roth mdr...@linux.vnet.ibm.com
 ---
  Makefile|4 ++-
  configure   |1 +
  qga/guest-agent-command-state.c |   73 
 +++
  qga/guest-agent-core.h  |   25 +
  4 files changed, 102 insertions(+), 1 deletions(-)
  create mode 100644 qga/guest-agent-command-state.c
  create mode 100644 qga/guest-agent-core.h

I'm not sure there's much value in having this as a separate patch, maybe
it should be folded in the next one.

 
 diff --git a/Makefile b/Makefile
 index cbd2d77..6c3ba71 100644
 --- a/Makefile
 +++ b/Makefile
 @@ -181,6 +181,8 @@ test-visitor: test-visitor.o qfloat.o qint.o qdict.o 
 qstring.o qlist.o qbool.o $
  test-qmp-commands.o: $(addprefix $(qapi-dir)/, test-qapi-types.c 
 test-qapi-types.h test-qapi-visit.c test-qapi-visit.h test-qmp-marshal.c 
 test-qmp-commands.h)
  test-qmp-commands: test-qmp-commands.o qfloat.o qint.o qdict.o qstring.o 
 qlist.o qbool.o $(qapi-obj-y) error.o osdep.o qemu-malloc.o $(oslib-obj-y) 
 qjson.o json-streamer.o json-lexer.o json-parser.o qerror.o qemu-error.o 
 qemu-tool.o $(qapi-dir)/test-qapi-visit.o $(qapi-dir)/test-qapi-types.o 
 $(qapi-dir)/test-qmp-marshal.o module.o
  
 +QGALIB=qga/guest-agent-command-state.o
 +
  QEMULIBS=libhw32 libhw64 libuser libdis libdis-user
  
  clean:
 @@ -189,7 +191,7 @@ clean:
   rm -f qemu-options.def
   rm -f *.o *.d *.a *.lo $(TOOLS) TAGS cscope.* *.pod *~ */*~
   rm -Rf .libs
 - rm -f slirp/*.o slirp/*.d audio/*.o audio/*.d block/*.o block/*.d 
 net/*.o net/*.d fsdev/*.o fsdev/*.d ui/*.o ui/*.d qapi/*.o qapi/*.d
 + rm -f slirp/*.o slirp/*.d audio/*.o audio/*.d block/*.o block/*.d 
 net/*.o net/*.d fsdev/*.o fsdev/*.d ui/*.o ui/*.d qapi/*.o qapi/*.d qga/*.o 
 qga/*.d
   rm -f qemu-img-cmds.h
   rm -f trace.c trace.h trace.c-timestamp trace.h-timestamp
   rm -f trace-dtrace.dtrace trace-dtrace.dtrace-timestamp
 diff --git a/configure b/configure
 index 02c552e..6a03002 100755
 --- a/configure
 +++ b/configure
 @@ -3487,6 +3487,7 @@ DIRS=$DIRS pc-bios/spapr-rtas
  DIRS=$DIRS roms/seabios roms/vgabios
  DIRS=$DIRS fsdev ui
  DIRS=$DIRS qapi
 +DIRS=$DIRS qga
  FILES=Makefile tests/Makefile
  FILES=$FILES tests/cris/Makefile tests/cris/.gdbinit
  FILES=$FILES pc-bios/optionrom/Makefile pc-bios/keymaps
 diff --git a/qga/guest-agent-command-state.c b/qga/guest-agent-command-state.c
 new file mode 100644
 index 000..bc6e0bd
 --- /dev/null
 +++ b/qga/guest-agent-command-state.c
 @@ -0,0 +1,73 @@
 +/*
 + * QEMU Guest Agent command state interfaces
 + *
 + * Copyright IBM Corp. 2011
 + *
 + * Authors:
 + *  Michael Roth  mdr...@linux.vnet.ibm.com
 + *
 + * This work is licensed under the terms of the GNU GPL, version 2 or later.
 + * See the COPYING file in the top-level directory.
 + */
 +#include glib.h
 +#include qga/guest-agent-core.h
 +
 +struct GACommandState {
 +GSList *groups;
 +};
 +
 +typedef struct GACommandGroup {
 +void (*init)(void);
 +void (*cleanup)(void);
 +} GACommandGroup;
 +
 +/* handle init/cleanup for stateful guest commands */
 +
 +void ga_command_state_add(GACommandState *cs,
 +  void (*init)(void),
 +  void (*cleanup)(void))
 +{
 +GACommandGroup *cg = qemu_mallocz(sizeof(GACommandGroup));
 +cg-init = init;
 +cg-cleanup = cleanup;
 +cs-groups = g_slist_append(cs-groups, cg);
 +}
 +
 +static void ga_command_group_init(gpointer opaque, gpointer unused)
 +{
 +GACommandGroup *cg = opaque;
 +
 +g_assert(cg);
 +if (cg-init) {
 +cg-init();
 +}
 +}
 +
 +void ga_command_state_init_all(GACommandState *cs)
 +{
 +g_assert(cs);
 +g_slist_foreach(cs-groups, ga_command_group_init, NULL);
 +}
 +
 +static void ga_command_group_cleanup(gpointer opaque, gpointer unused)
 +{
 +GACommandGroup *cg = opaque;
 +
 +g_assert(cg);
 +if (cg-cleanup) {
 +cg-cleanup();
 +}
 +}
 +
 +void ga_command_state_cleanup_all(GACommandState *cs)
 +{
 +g_assert(cs);
 +g_slist_foreach(cs-groups, ga_command_group_cleanup, NULL);
 +}
 +
 +GACommandState *ga_command_state_new(void)
 +{
 +GACommandState *cs = qemu_mallocz(sizeof(GACommandState));
 +cs-groups = NULL;
 +return cs;
 +}
 diff --git a/qga/guest-agent-core.h b/qga/guest-agent-core.h
 new file mode 100644
 index 000..688f120
 --- /dev/null
 +++ b/qga/guest-agent-core.h
 @@ -0,0 +1,25 @@
 +/*
 + * QEMU Guest Agent core declarations
 + *
 + * Copyright IBM Corp. 2011
 + *
 + * Authors:
 + *  Adam Litkeagli...@linux.vnet.ibm.com
 + *  Michael Roth  mdr...@linux.vnet.ibm.com
 + *
 + * This work is licensed under the terms of the GNU GPL, version 2 or later.
 + * See the COPYING file in the top-level directory.
 + */
 +#include qapi/qmp-core.h
 +#include qemu-common.h
 +
 +#define QGA_VERSION 

Re: [Qemu-devel] [PATCH 1/3] vmstate: add no_migrate flag to VMStateDescription

2011-07-08 Thread Anthony Liguori

On 07/08/2011 03:53 AM, Gerd Hoffmann wrote:

This allows to easily tag devices as non-migratable,
so any attempt to migrate a virtual machine with the
device in question active will make migration fail.

Signed-off-by: Gerd Hoffmannkra...@redhat.com


register_device_unmigratable()?

Regards,

Anthony Liguori


---
  hw/hw.h  |1 +
  savevm.c |1 +
  2 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/hw/hw.h b/hw/hw.h
index 9dd7096..1eb3486 100644
--- a/hw/hw.h
+++ b/hw/hw.h
@@ -324,6 +324,7 @@ typedef struct VMStateSubsection {

  struct VMStateDescription {
  const char *name;
+int no_migrate;
  int version_id;
  int minimum_version_id;
  int minimum_version_id_old;
diff --git a/savevm.c b/savevm.c
index 8139bc7..fa2da3e 100644
--- a/savevm.c
+++ b/savevm.c
@@ -1234,6 +1234,7 @@ int vmstate_register_with_alias_id(DeviceState *dev, int 
instance_id,
  se-opaque = opaque;
  se-vmsd = vmsd;
  se-alias_id = alias_id;
+se-no_migrate = vmsd-no_migrate;

  if (dev  dev-parent_bus  dev-parent_bus-info-get_dev_path) {
  char *id = dev-parent_bus-info-get_dev_path(dev);





Re: [Qemu-devel] [PATCH v6 2/4] guest agent: qemu-ga daemon

2011-07-08 Thread Luiz Capitulino
On Tue,  5 Jul 2011 08:21:38 -0500
Michael Roth mdr...@linux.vnet.ibm.com wrote:

 This is the actual guest daemon, it listens for requests over a
 virtio-serial/isa-serial/unix socket channel and routes them through
 to dispatch routines, and writes the results back to the channel in
 a manner similar to QMP.
 
 A shorthand invocation:
 
   qemu-ga -d
 
 Is equivalent to:
 
   qemu-ga -c virtio-serial -p /dev/virtio-ports/org.qemu.guest_agent \
   -p /var/run/qemu-guest-agent.pid -d

I think you meant -f /var/run/qemu-guest-agent.pid

 
 Signed-off-by: Michael Roth mdr...@linux.vnet.ibm.com
 ---
  Makefile   |   10 +-
  qemu-ga.c  |  651 
 
  qga/guest-agent-core.h |4 +
  3 files changed, 661 insertions(+), 4 deletions(-)
  create mode 100644 qemu-ga.c
 
 diff --git a/Makefile b/Makefile
 index 6c3ba71..b2e8593 100644
 --- a/Makefile
 +++ b/Makefile
 @@ -140,7 +140,7 @@ endif
  ##
  
  qemu-img.o: qemu-img-cmds.h
 -qemu-img.o qemu-tool.o qemu-nbd.o qemu-io.o cmd.o: $(GENERATED_HEADERS)
 +qemu-img.o qemu-tool.o qemu-nbd.o qemu-io.o cmd.o qemu-ga.o: 
 $(GENERATED_HEADERS)
  
  qemu-img$(EXESUF): qemu-img.o qemu-tool.o qemu-error.o $(oslib-obj-y) 
 $(trace-obj-y) $(block-obj-y) $(qobject-obj-y) $(version-obj-y) 
 qemu-timer-common.o
  
 @@ -163,7 +163,7 @@ check-qfloat: check-qfloat.o qfloat.o $(CHECK_PROG_DEPS)
  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 error.o qerror.o 
 qemu-error.o $(CHECK_PROG_DEPS)
  
  qapi-dir := qapi-generated
 -$(qapi-obj-y) test-visitor.o test-qmp-commands.o: QEMU_CFLAGS += -I 
 $(qapi-dir)
 +$(qapi-obj-y) test-visitor.o test-qmp-commands.o qemu-ga$(EXESUF): 
 QEMU_CFLAGS += -I $(qapi-dir)
  
  $(qapi-dir)/test-qapi-types.c: $(qapi-dir)/test-qapi-types.h
  $(qapi-dir)/test-qapi-types.h: $(SRC_PATH)/qapi-schema-test.json 
 $(SRC_PATH)/scripts/qapi-types.py
 @@ -183,13 +183,15 @@ test-qmp-commands: test-qmp-commands.o qfloat.o qint.o 
 qdict.o qstring.o qlist.o
  
  QGALIB=qga/guest-agent-command-state.o
  
 +qemu-ga$(EXESUF): qemu-ga.o $(QGALIB) qemu-tool.o qemu-error.o error.o 
 $(oslib-obj-y) $(trace-obj-y) $(block-obj-y) $(qobject-obj-y) 
 $(version-obj-y) $(qapi-obj-y) qemu-timer-common.o qemu-sockets.o module.o 
 qapi/qmp-dispatch.o qapi/qmp-registry.o
 +
  QEMULIBS=libhw32 libhw64 libuser libdis libdis-user
  
  clean:
  # avoid old build problems by removing potentially incorrect old files
   rm -f config.mak op-i386.h opc-i386.h gen-op-i386.h op-arm.h opc-arm.h 
 gen-op-arm.h
   rm -f qemu-options.def
 - rm -f *.o *.d *.a *.lo $(TOOLS) TAGS cscope.* *.pod *~ */*~
 + rm -f *.o *.d *.a *.lo $(TOOLS) qemu-ga TAGS cscope.* *.pod *~ */*~
   rm -Rf .libs
   rm -f slirp/*.o slirp/*.d audio/*.o audio/*.d block/*.o block/*.d 
 net/*.o net/*.d fsdev/*.o fsdev/*.d ui/*.o ui/*.d qapi/*.o qapi/*.d qga/*.o 
 qga/*.d
   rm -f qemu-img-cmds.h
 @@ -385,4 +387,4 @@ tarbin:
   $(mandir)/man8/qemu-nbd.8
  
  # Include automatically generated dependency files
 --include $(wildcard *.d audio/*.d slirp/*.d block/*.d net/*.d ui/*.d 
 qapi/*.d)
 +-include $(wildcard *.d audio/*.d slirp/*.d block/*.d net/*.d ui/*.d 
 qapi/*.d qga/*.d)
 diff --git a/qemu-ga.c b/qemu-ga.c
 new file mode 100644
 index 000..649c16a
 --- /dev/null
 +++ b/qemu-ga.c
 @@ -0,0 +1,651 @@
 +/*
 + * QEMU Guest Agent
 + *
 + * Copyright IBM Corp. 2011
 + *
 + * Authors:
 + *  Adam Litkeagli...@linux.vnet.ibm.com
 + *  Michael Roth  mdr...@linux.vnet.ibm.com
 + *
 + * This work is licensed under the terms of the GNU GPL, version 2 or later.
 + * See the COPYING file in the top-level directory.
 + */
 +#include stdlib.h
 +#include stdio.h
 +#include stdbool.h
 +#include glib.h
 +#include gio/gio.h
 +#include getopt.h
 +#include termios.h
 +#include syslog.h
 +#include qemu_socket.h
 +#include json-streamer.h
 +#include json-parser.h
 +#include qint.h
 +#include qjson.h
 +#include qga/guest-agent-core.h
 +#include module.h
 +#include signal.h
 +
 +#define QGA_VIRTIO_PATH_DEFAULT /dev/virtio-ports/org.qemu.guest_agent
 +#define QGA_PIDFILE_DEFAULT /var/run/qemu-va.pid
 +#define QGA_BAUDRATE_DEFAULT B38400 /* for isa-serial channels */
 +#define QGA_TIMEOUT_DEFAULT 30*1000 /* ms */
 +
 +struct GAState {
 +JSONMessageParser parser;
 +GMainLoop *main_loop;
 +guint conn_id;
 +GSocket *conn_sock;
 +GIOChannel *conn_channel;
 +guint listen_id;
 +GSocket *listen_sock;
 +GIOChannel *listen_channel;
 +const char *path;
 +const char *method;
 +bool virtio; /* fastpath to check for virtio to deal with poll() quirks 
 */
 +GACommandState *command_state;
 +GLogLevelFlags log_level;
 +FILE *log_file;
 +bool logging_enabled;
 +};
 +
 +static struct GAState *ga_state;
 +
 +static void quit_handler(int 

Re: [Qemu-devel] migration: new sections and backward compatibility.

2011-07-08 Thread Peter Maydell
On 8 July 2011 14:02, Jes Sorensen jes.soren...@redhat.com wrote:
 It seems reasonable to me to introduce a situation where devices have to
 explicitly marked as migration compatible and fail if there are devices
 in the system which are not.

To ask a dumb question: does migration here mean only migration
or also vmsave/vmload ?

-- PMM



Re: [Qemu-devel] [PATCH v6 3/4] guest agent: add guest agent commands schema file

2011-07-08 Thread Luiz Capitulino
On Tue,  5 Jul 2011 08:21:39 -0500
Michael Roth mdr...@linux.vnet.ibm.com wrote:

 
 Signed-off-by: Michael Roth mdr...@linux.vnet.ibm.com
 ---
  qapi-schema-guest.json |  204 
 
  1 files changed, 204 insertions(+), 0 deletions(-)
  create mode 100644 qapi-schema-guest.json

I think this should be folded in the next patch.

More comments below.

 
 diff --git a/qapi-schema-guest.json b/qapi-schema-guest.json
 new file mode 100644
 index 000..367b42d
 --- /dev/null
 +++ b/qapi-schema-guest.json
 @@ -0,0 +1,204 @@
 +# *-*- Mode: Python -*-*
 +
 +##
 +# @guest-sync:
 +#
 +# Echo back a unique integer value
 +#
 +# This is used by clients talking to the guest agent over the
 +# wire to ensure the stream is in sync and doesn't contain stale
 +# data from previous client. All guest agent responses should be
 +# ignored until the provided unique integer value is returned,
 +# and it is up to the client to handle stale whole or
 +# partially-delivered JSON text in such a way that this response
 +# can be obtained.
 +#
 +# Such clients should also preceed this command
 +# with a 0xFF byte to make such the guest agent flushes any
 +# partially read JSON data from a previous session.
 +#
 +# @id: randomly generated 64-bit integer
 +#
 +# Returns: The unique integer id passed in by the client
 +#
 +# Since: 0.15.0
 +##
 +{ 'command': 'guest-sync'
 +  'data':{ 'id': 'int' },
 +  'returns': 'int' }
 +
 +##
 +# @guest-ping:
 +#
 +# Ping the guest agent, a non-error return implies success
 +#
 +# Since: 0.15.0
 +##
 +{ 'command': 'guest-ping' }
 +
 +##
 +# @guest-info:
 +#
 +# Get some information about the guest agent.
 +#
 +# Since: 0.15.0
 +##
 +{ 'type': 'GuestAgentInfo', 'data': {'version': 'str'} }
 +{ 'command': 'guest-info',
 +  'returns': 'GuestAgentInfo' }
 +
 +##
 +# @guest-shutdown:
 +#
 +# Initiate guest-activated shutdown. Note: this is an asynchronous
 +# shutdown request, with no guaruntee of successful shutdown. Errors
 +# will be logged to guest's syslog.
 +#
 +# @mode: halt, powerdown, or reboot
 +#
 +# Returns: Nothing on success
 +#
 +# Since: 0.15.0
 +##
 +{ 'command': 'guest-shutdown', 'data': { 'mode': 'str' } }

Shouldn't 'mode' be optional?

 +
 +##
 +# @guest-file-open:
 +#
 +# Open a file in the guest and retrieve a file handle for it
 +#
 +# @filepath: Full path to the file in the guest to open.
 +#
 +# @mode: #optional open mode, as per fopen(), r is the default.
 +#
 +# Returns: Guest file handle on success.
 +#  If @filepath cannot be opened, OpenFileFailed
 +#
 +# Since: 0.15.0
 +##
 +{ 'command': 'guest-file-open',
 +  'data':{ 'filepath': 'str', '*mode': 'str' },
 +  'returns': 'int' }

You can use 'file-path'. Actually, I'd use just 'path'.

 +
 +##
 +# @guest-file-read:
 +#
 +# Read from an open file in the guest
 +#
 +# @filehandle: filehandle returned by guest-file-open
 +#
 +# @count: maximum number of bytes to read
 +#
 +# Returns: GuestFileRead on success.
 +#  If @filehandle is not open, OpenFileFailed
 +#
 +# Since: 0.15.0
 +##
 +{ 'type': 'GuestFileRead',
 +  'data': { 'count': 'int', 'buf': 'str', 'eof': 'bool' } }
 +
 +{ 'command': 'guest-file-read',
 +  'data':{ 'filehandle': 'int', 'count': 'int' },
 +  'returns': 'GuestFileRead' }

file-handle. Also, we have to say that the returned data is base64-encoded.

 +
 +##
 +# @guest-file-write:
 +#
 +# Write to an open file in the guest
 +#
 +# @filehandle: filehandle returned by guest-file-open
 +#
 +# @data_b64: base64-encoded string representing data to be written
 +#
 +# @count: bytes to write (actual bytes, after b64-decode)
 +#
 +# Returns: GuestFileWrite on success.
 +#  If @filehandle is not opened, OpenFileFailed
 +#
 +# Since: 0.15.0
 +##
 +{ 'type': 'GuestFileWrite',
 +  'data': { 'count': 'int', 'eof': 'bool' } }
 +{ 'command': 'guest-file-write',
 +  'data':{ 'filehandle': 'int', 'data_b64': 'str', 'count': 'int' },
 +  'returns': 'GuestFileWrite' }

data-b64

 +
 +##
 +# @guest-file-seek:
 +#
 +# Seek to a position in the file, as with fseek(), and return the
 +# current file position afterward. Also encapsulates ftell()'s
 +# functionality, just Set offset=0, whence=SEEK_CUR.
 +#
 +# @filehandle: filehandle returned by guest-file-open
 +#
 +# @offset: bytes to skip over in the file stream
 +#
 +# @whence: SEEK_SET, SEEK_CUR, or SEEK_END, as with fseek()
 +#
 +# Returns: GuestFileSeek on success.
 +#  If @filehandle is not opened, OpenFileFailed
 +#
 +# Since: 0.15.0
 +##
 +{ 'type': 'GuestFileSeek',
 +  'data': { 'position': 'int', 'eof': 'bool' } }
 +
 +{ 'command': 'guest-file-seek',
 +  'data':{ 'filehandle': 'int', 'offset': 'int', 'whence': 'int' },
 +  'returns': 'GuestFileSeek' }
 +
 +##
 +# @guest-file-close:
 +#
 +# Close an open file in the guest
 +#
 +# @filehandle: filehandle returned by guest-file-open
 +#
 +# Returns: Nothing on success.
 +#  If @filehandle is not opened, OpenFileFailed
 

Re: [Qemu-devel] [PATCH v6 4/4] guest agent: add guest agent RPCs/commands

2011-07-08 Thread Luiz Capitulino
On Tue,  5 Jul 2011 08:21:40 -0500
Michael Roth mdr...@linux.vnet.ibm.com wrote:

 This adds the initial set of QMP/QAPI commands provided by the guest
 agent:
 
 guest-sync
 guest-ping
 guest-info
 guest-shutdown
 guest-file-open
 guest-file-read
 guest-file-write
 guest-file-seek
 guest-file-close
 guest-fsfreeze-freeze
 guest-fsfreeze-thaw
 guest-fsfreeze-status
 
 The input/output specification for these commands are documented in the
 schema.
 
 Example usage:
 
   host:
 qemu -device virtio-serial \
  -chardev socket,path=/tmp/vs0.sock,server,nowait,id=qga0 \
  -device virtserialport,chardev=qga0,name=qga0
  ...
 
 echo {'execute':'guest-info'} | socat stdio \
  unix-connect:/tmp/qga0.sock
 
   guest:
 qemu-ga -c virtio-serial -p /dev/virtio-ports/qga0 \
 -p /var/run/qemu-guest-agent.pid -d
 
 Signed-off-by: Michael Roth mdr...@linux.vnet.ibm.com
 ---
  Makefile   |   15 ++-
  qemu-ga.c  |4 +
  qerror.h   |3 +
  qga/guest-agent-commands.c |  501 
 
  qga/guest-agent-core.h |2 +
  5 files changed, 523 insertions(+), 2 deletions(-)
  create mode 100644 qga/guest-agent-commands.c
 
 diff --git a/Makefile b/Makefile
 index b2e8593..7e4f722 100644
 --- a/Makefile
 +++ b/Makefile
 @@ -175,15 +175,26 @@ $(qapi-dir)/test-qmp-commands.h: 
 $(qapi-dir)/test-qmp-marshal.c
  $(qapi-dir)/test-qmp-marshal.c: $(SRC_PATH)/qapi-schema-test.json 
 $(SRC_PATH)/scripts/qapi-commands.py
   $(call quiet-command,python $(SRC_PATH)/scripts/qapi-commands.py -o 
 $(qapi-dir) -p test-  $,   GEN   $@)
  
 +$(qapi-dir)/qga-qapi-types.c: $(qapi-dir)/qga-qapi-types.h
 +$(qapi-dir)/qga-qapi-types.h: $(SRC_PATH)/qapi-schema-guest.json 
 $(SRC_PATH)/scripts/qapi-types.py
 + $(call quiet-command,python $(SRC_PATH)/scripts/qapi-types.py -o 
 $(qapi-dir) -p qga-  $,   GEN   $@)
 +$(qapi-dir)/qga-qapi-visit.c: $(qapi-dir)/qga-qapi-visit.h
 +$(qapi-dir)/qga-qapi-visit.h: $(SRC_PATH)/qapi-schema-guest.json 
 $(SRC_PATH)/scripts/qapi-visit.py
 + $(call quiet-command,python $(SRC_PATH)/scripts/qapi-visit.py -o 
 $(qapi-dir) -p qga-  $,   GEN   $@)
 +$(qapi-dir)/qga-qmp-marshal.c: $(SRC_PATH)/qapi-schema-guest.json 
 $(SRC_PATH)/scripts/qapi-commands.py
 + $(call quiet-command,python $(SRC_PATH)/scripts/qapi-commands.py -o 
 $(qapi-dir) -p qga-  $,   GEN   $@)
 +
  test-visitor.o: $(addprefix $(qapi-dir)/, test-qapi-types.c 
 test-qapi-types.h test-qapi-visit.c test-qapi-visit.h)
  test-visitor: test-visitor.o qfloat.o qint.o qdict.o qstring.o qlist.o 
 qbool.o $(qapi-obj-y) error.o osdep.o qemu-malloc.o $(oslib-obj-y) qjson.o 
 json-streamer.o json-lexer.o json-parser.o qerror.o qemu-error.o qemu-tool.o 
 $(qapi-dir)/test-qapi-visit.o $(qapi-dir)/test-qapi-types.o
  
  test-qmp-commands.o: $(addprefix $(qapi-dir)/, test-qapi-types.c 
 test-qapi-types.h test-qapi-visit.c test-qapi-visit.h test-qmp-marshal.c 
 test-qmp-commands.h)
  test-qmp-commands: test-qmp-commands.o qfloat.o qint.o qdict.o qstring.o 
 qlist.o qbool.o $(qapi-obj-y) error.o osdep.o qemu-malloc.o $(oslib-obj-y) 
 qjson.o json-streamer.o json-lexer.o json-parser.o qerror.o qemu-error.o 
 qemu-tool.o $(qapi-dir)/test-qapi-visit.o $(qapi-dir)/test-qapi-types.o 
 $(qapi-dir)/test-qmp-marshal.o module.o
  
 -QGALIB=qga/guest-agent-command-state.o
 +QGALIB=qga/guest-agent-command-state.o qga/guest-agent-commands.o
 +
 +qemu-ga.o: $(qapi-dir)/qga-qapi-types.c $(qapi-dir)/qga-qapi-types.h 
 $(qapi-dir)/qga-qapi-visit.c $(qapi-dir)/qga-qmp-marshal.c
  
 -qemu-ga$(EXESUF): qemu-ga.o $(QGALIB) qemu-tool.o qemu-error.o error.o 
 $(oslib-obj-y) $(trace-obj-y) $(block-obj-y) $(qobject-obj-y) 
 $(version-obj-y) $(qapi-obj-y) qemu-timer-common.o qemu-sockets.o module.o 
 qapi/qmp-dispatch.o qapi/qmp-registry.o
 +qemu-ga$(EXESUF): qemu-ga.o $(QGALIB) qemu-tool.o qemu-error.o error.o 
 $(oslib-obj-y) $(trace-obj-y) $(block-obj-y) $(qobject-obj-y) 
 $(version-obj-y) $(qapi-obj-y) qemu-timer-common.o qemu-sockets.o module.o 
 qapi/qmp-dispatch.o qapi/qmp-registry.o $(qapi-dir)/qga-qapi-visit.o 
 $(qapi-dir)/qga-qmp-marshal.o
  
  QEMULIBS=libhw32 libhw64 libuser libdis libdis-user
  
 diff --git a/qemu-ga.c b/qemu-ga.c
 index 649c16a..04ead22 100644
 --- a/qemu-ga.c
 +++ b/qemu-ga.c
 @@ -637,6 +637,9 @@ int main(int argc, char **argv)
  g_log_set_default_handler(ga_log, s);
  g_log_set_fatal_mask(NULL, G_LOG_LEVEL_ERROR);
  s-logging_enabled = true;
 +s-command_state = ga_command_state_new();
 +ga_command_state_init(s, s-command_state);
 +ga_command_state_init_all(s-command_state);
  ga_state = s;
  
  module_call_init(MODULE_INIT_QAPI);
 @@ -645,6 +648,7 @@ int main(int argc, char **argv)
  
  g_main_loop_run(ga_state-main_loop);
  
 +ga_command_state_cleanup_all(ga_state-command_state);
  unlink(pidfile);
  
  return 0;
 diff --git a/qerror.h b/qerror.h
 index 

Re: [Qemu-devel] migration: new sections and backward compatibility.

2011-07-08 Thread Gerd Hoffmann

On 07/08/11 16:43, Peter Maydell wrote:

On 8 July 2011 14:02, Jes Sorensenjes.soren...@redhat.com  wrote:

It seems reasonable to me to introduce a situation where devices have to
explicitly marked as migration compatible and fail if there are devices
in the system which are not.


To ask a dumb question: does migration here mean only migration
or also vmsave/vmload ?


Both.

cheers,
  Gerd




Re: [Qemu-devel] [PATCH v8 00/12] Adding VMDK monolithic flat support

2011-07-08 Thread Stefan Hajnoczi
On Tue, Jul 5, 2011 at 12:31 PM, Fam Zheng famc...@gmail.com wrote:
 Chnages from v7:
    03/12: remove deadloop in probing descriptor file.

 Fam Zheng (12):
  VMDK: introduce VmdkExtent
  VMDK: bugfix, align offset to cluster in get_whole_cluster
  VMDK: probe for monolithicFlat images
  VMDK: separate vmdk_open by format version
  VMDK: add field BDRVVmdkState.desc_offset
  VMDK: flush multiple extents
  VMDK: move 'static' cid_update flag to bs field
  VMDK: change get_cluster_offset return type
  VMDK: open/read/write for monolithicFlat image
  VMDK: create different subformats
  VMDK: fix coding style
  block: add bdrv_get_allocated_file_size() operation

  block.c           |   19 +
  block.h           |    1 +
  block/raw-posix.c |   21 +
  block/raw-win32.c |   29 ++
  block/vmdk.c      | 1361 
 +
  block_int.h       |    2 +
  qemu-img.c        |   31 +--
  7 files changed, 1024 insertions(+), 440 deletions(-)

Getting closer.  Patch 10/12 is big and I see a lot of repetition in
the image creation process.  I wonder if it helps to factor out
certain aspects such as filename and descriptor generation so that the
creation function doesn't become so large.  The aim is to encapsulate
aspects of image creation cleanly so that the caller doesn't need to
keep state around and can use a simple interface to orchestrate image
creation.

Structuring is going to be important for future vmdk changes.  We need
to introduce clean interfaces to separate subformats while keeping
common code shared as utility functions.  Right now there is a lot of
if (flat) { ... } or if (!strcmp(..., monolithicSparse)) { ... }.
The details of various formats are spread throughout the entire vmdk
codebase instead of encapsulated in one module each.  This will become
even more important as you flesh out the support matrix for various
file formats.  Something to keep in mind for future work after this
series.

Stefan



Re: [Qemu-devel] [PATCH v8 10/12] VMDK: create different subformats

2011-07-08 Thread Stefan Hajnoczi
On Tue, Jul 5, 2011 at 12:31 PM, Fam Zheng famc...@gmail.com wrote:
 Add create option 'format', with enums:

The -drive format=... option exists in QEMU today to specify the image
format of a file.  I think adding a format=... creation option may
lead to confusion.

How about subformat=... or type=...?

 Each creates a subformat image file. The default is monolithiSparse.

s/monolithiSparse/monolithicSparse/

 @@ -243,168 +243,6 @@ static int vmdk_is_cid_valid(BlockDriverState *bs)
     return 1;
  }

 -static int vmdk_snapshot_create(const char *filename, const char 
 *backing_file)

Is this function really not needed anymore?

 @@ -1189,28 +990,317 @@ static int vmdk_create(const char *filename, 
 QEMUOptionParameter *options)
         }
     }

 -    /* compose the descriptor */
 -    real_filename = filename;
 -    if ((temp_str = strrchr(real_filename, '\\')) != NULL)
 -        real_filename = temp_str + 1;
 -    if ((temp_str = strrchr(real_filename, '/')) != NULL)
 -        real_filename = temp_str + 1;
 -    if ((temp_str = strrchr(real_filename, ':')) != NULL)
 -        real_filename = temp_str + 1;
 -    snprintf(desc, sizeof(desc), desc_template, (unsigned int)time(NULL),
 -             total_size, real_filename,
 -             (flags  BLOCK_FLAG_COMPAT6 ? 6 : 4),
 -             total_size / (int64_t)(63 * 16));
 -
 -    /* write the descriptor */
 -    lseek(fd, le64_to_cpu(header.desc_offset)  9, SEEK_SET);
 -    ret = qemu_write_full(fd, desc, strlen(desc));
 -    if (ret != strlen(desc)) {
 +    filesize -= filesize;

What is the point of setting filesize to zero?

 +    ret = 0;
 + exit:
 +    close(fd);
 +    return ret;
 +}
 +
 +static int vmdk_create_flat(const char *filename, int64_t filesize)
 +{
 +    int fd, ret;
 +
 +    fd = open(
 +            filename,
 +            O_WRONLY | O_CREAT | O_TRUNC | O_BINARY | O_LARGEFILE,
 +            0644);
 +    if (fd  0) {
 +        return -errno;
 +    }
 +    ret = ftruncate(fd, filesize);
 +    if (ret) {
         ret = -errno;
 -        goto exit;
 +        close(fd);
 +        return -errno;

errno is a global variable that may be modified by any errno-using
library function.  Its value may be changed by close(2) (even if there
is no error closing the fd).  Therefore please do return ret instead
of return -errno.

     }
 +    close(fd);
 +    return 0;
 +}

 -    ret = 0;
 +static int filename_decompose(const char *filename, char *path, char *prefix,
 +        char *postfix, int buf_len)

Memory sizes (e.g. buffer size) should be size_t (which is unsigned)
instead of int.

 +{
 +    const char *p, *q;
 +
 +    if (filename == NULL || !strlen(filename)) {
 +        fprintf(stderr, Vmdk: wrong filename (%s)\n, filename);

Printing filename doesn't make sense since filename is either NULL or
.  Also note that fprintf(..., %s, NULL) is undefined and may
crash on some platforms (e.g. Solaris).

 +        return -1;
 +    }
 +    p = strrchr(filename, '/');
 +    if (p == NULL) {
 +        p = strrchr(filename, '\\');
 +    }
 +    if (p == NULL) {
 +        p = strrchr(filename, ':');
 +    }
 +    if (p != NULL) {
 +        p++;
 +        if (p - filename = buf_len) {
 +            return -1;
 +        }
 +        strncpy(path, filename, p - filename);
 +        path[p - filename] = 0;
 +    } else {
 +        p = filename;
 +        path[0] = '\0';
 +    }
 +    q = strrchr(p, '.');
 +    if (q == NULL) {
 +        pstrcpy(prefix, buf_len, p);
 +        postfix[0] = '\0';
 +    } else {

No check for prefix buf_len here.  Imagine filename has no '/', '\\',
or ':' but it does have a '.'.  It is possible to overflow prefix.

 +        strncpy(prefix, p, q - p);
 +        prefix[q - p] = '\0';
 +        pstrcpy(postfix, buf_len, q);
 +    }
 +    return 0;
 +}
 +
 +static int relative_path(char *dest, int dest_size,
 +        const char *base, const char *target)
 +{
 +    int i = 0;
 +    int n = 0;
 +    const char *p, *q;
 +#ifdef _WIN32
 +    const char *sep = \\;
 +#else
 +    const char *sep = /;
 +#endif
 +
 +    if (!(dest  base  target)) {
 +        return -1;
 +    }
 +    if (path_is_absolute(target)) {
 +        dest[dest_size - 1] = '\0';
 +        strncpy(dest, target, dest_size - 1);
 +        return 0;
 +    }
 +    while (base[i] == target[i]) {
 +        i++;
 +    }
 +    p = base[i];
 +    q = target[i];
 +    while (*p) {
 +        if (*p == *sep) {
 +            n++;
 +        }
 +        p++;
 +    }
 +    dest[0] = '\0';
 +    for (; n; n--) {
 +        pstrcat(dest, dest_size, ..);
 +        pstrcat(dest, dest_size, sep);
 +    }
 +    pstrcat(dest, dest_size, q);
 +    return 0;
 +}
 +
 +static int vmdk_create(const char *filename, QEMUOptionParameter *options)
 +{
 +    int fd = -1;
 +    char desc[4096];
 +    int64_t total_size = 0;
 +    const char *backing_file = NULL;
 +    const char *fmt = NULL;
 +    int flags = 0;
 +    int ret = 0;
 +    char ext_desc_lines[1024] = ;
 +    char path[1024], prefix[1024], 

Re: [Qemu-devel] [PATCH 1/3] vmstate: add no_migrate flag to VMStateDescription

2011-07-08 Thread Gerd Hoffmann

On 07/08/11 16:26, Anthony Liguori wrote:

On 07/08/2011 03:53 AM, Gerd Hoffmann wrote:

This allows to easily tag devices as non-migratable,
so any attempt to migrate a virtual machine with the
device in question active will make migration fail.

Signed-off-by: Gerd Hoffmannkra...@redhat.com


register_device_unmigratable()?


That is just a more complicated way to do the same ;)
Wanna have a patch to zap it?

cheers,
  Gerd




Re: [Qemu-devel] [PATCH 1/3] vmstate: add no_migrate flag to VMStateDescription

2011-07-08 Thread Gerd Hoffmann

On 07/08/11 17:44, Gerd Hoffmann wrote:

On 07/08/11 16:26, Anthony Liguori wrote:

register_device_unmigratable()?


Wanna have a patch to zap it?


Ah, no, we can't, for ivshmem this isn't fixed but depends on the 
configuration, so a static flag in the VMStateDescription doesn't cut it.


cheers,
  Gerd



[Qemu-devel] [PATCH v2 3/4] hw/omap_clk: Add the clock for the OMAP2430-specific fifth GPIO module

2011-07-08 Thread Peter Maydell
The OMAP2430 has a fifth GPIO module which earlier OMAP2 models lack; add
the clock definition for it.

Signed-off-by: Peter Maydell peter.mayd...@linaro.org
---
 hw/omap_clk.c |6 +-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/hw/omap_clk.c b/hw/omap_clk.c
index 6bcabef..577b326 100644
--- a/hw/omap_clk.c
+++ b/hw/omap_clk.c
@@ -836,7 +836,7 @@ static struct clk i2c2_iclk = {
 .parent= core_l4_iclk,
 };
 
-static struct clk gpio_dbclk[4] = {
+static struct clk gpio_dbclk[5] = {
 {
 .name  = gpio1_dbclk,
 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
@@ -853,6 +853,10 @@ static struct clk gpio_dbclk[4] = {
 .name  = gpio4_dbclk,
 .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
 .parent= wu_32k_clk,
+}, {
+.name   = gpio5_dbclk,
+.flags  = CLOCK_IN_OMAP243X,
+.parent = wu_32k_clk,
 },
 };
 
-- 
1.7.1




[Qemu-devel] [PATCH v2 0/4] omap_gpio: convert to qdev

2011-07-08 Thread Peter Maydell
These patches are changes from the meego omap3 tree which convert
the omap GPIO module device to use qdev.

Changes v1-v2:
 * renamed omap_l4_base() to omap_l4_region_base()
 * provide two qdev devices 'omap-gpio' and 'omap2-gpio' rather than
   trying to shoehorn two significantly different devices into one
   (and use hyphen rather than underscore in the device name)
 * wire up the omap clocks to the gpio modules as qdev properties
   (including adding a missing omap2 clock definition...)

We use qdev pointer properties for the omap clocks. This is not ideal.
My preference would be for qdev to support a generic means of defining
a 'port' with an arbitrary interface for connecting two devices. Then
we could reframe the omap clock API in terms of clock ports, and get
some type safety. For now passing an arbitrary pointer seems like the
best pragmatic interim solution. (It's not possible to pass in the
string which is the clock name, because the device does not have the
necessary information (ie the struct omap_mpu_state_s*) to do the
clockname to pointer translation.)

Juha Riihimäki (2):
  hw/omap_l4.c: Add helper function omap_l4_region_base
  hw/omap_gpio.c: Convert to qdev

Peter Maydell (2):
  hw/omap_gpio.c: Don't complain about some writes to r/o registers
  hw/omap_clk: Add the clock for the OMAP2430-specific fifth GPIO
module

 hw/nseries.c   |   47 +-
 hw/omap.h  |   22 +
 hw/omap1.c |   10 ++-
 hw/omap2.c |   34 ++--
 hw/omap_clk.c  |6 +-
 hw/omap_gpio.c |  263 ---
 hw/omap_l4.c   |6 ++
 hw/palm.c  |   26 +++---
 8 files changed, 235 insertions(+), 179 deletions(-)




[Qemu-devel] [PATCH v2 1/4] hw/omap_l4.c: Add helper function omap_l4_region_base

2011-07-08 Thread Peter Maydell
From: Juha Riihimäki juha.riihim...@nokia.com

Add helper function omap_l4_region_base() to return the base address
of a particular region of an L4 target agent.

Signed-off-by: Juha Riihimäki juha.riihim...@nokia.com
[Riku Voipio: Fixes and restructuring patchset]
Signed-off-by: Riku Voipio riku.voi...@iki.fi
[Peter Maydell: More fixes and cleanups for upstream submission]
Signed-off-by:  Peter Maydell peter.mayd...@linaro.org
---
 hw/omap.h|2 ++
 hw/omap_l4.c |6 ++
 2 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/hw/omap.h b/hw/omap.h
index c227a82..00a0ea9 100644
--- a/hw/omap.h
+++ b/hw/omap.h
@@ -93,6 +93,8 @@ struct omap_target_agent_s *omap_l4ta_get(
 int cs);
 target_phys_addr_t omap_l4_attach(struct omap_target_agent_s *ta, int region,
 int iotype);
+target_phys_addr_t omap_l4_region_base(struct omap_target_agent_s *ta,
+   int region);
 int l4_register_io_memory(CPUReadMemoryFunc * const *mem_read,
 CPUWriteMemoryFunc * const *mem_write, void *opaque);
 
diff --git a/hw/omap_l4.c b/hw/omap_l4.c
index 4af0ca8..59c84b1 100644
--- a/hw/omap_l4.c
+++ b/hw/omap_l4.c
@@ -146,6 +146,12 @@ struct omap_l4_s *omap_l4_init(target_phys_addr_t base, 
int ta_num)
 return bus;
 }
 
+target_phys_addr_t omap_l4_region_base(struct omap_target_agent_s *ta,
+   int region)
+{
+return ta-bus-base + ta-start[region].offset;
+}
+
 static uint32_t omap_l4ta_read(void *opaque, target_phys_addr_t addr)
 {
 struct omap_target_agent_s *s = (struct omap_target_agent_s *) opaque;
-- 
1.7.1




[Qemu-devel] [PATCH v2 4/4] hw/omap_gpio.c: Convert to qdev

2011-07-08 Thread Peter Maydell
From: Juha Riihimäki juha.riihim...@nokia.com

Convert the OMAP GPIO module to qdev.

Signed-off-by: Juha Riihimäki juha.riihim...@nokia.com
[Riku Voipio: Fixes and restructuring patchset]
Signed-off-by: Riku Voipio riku.voi...@iki.fi
[Peter Maydell: More fixes and cleanups for upstream submission]
Signed-off-by:  Peter Maydell peter.mayd...@linaro.org
---
 hw/nseries.c   |   47 +-
 hw/omap.h  |   20 +
 hw/omap1.c |   10 ++-
 hw/omap2.c |   34 ++--
 hw/omap_gpio.c |  259 ---
 hw/palm.c  |   26 +++---
 6 files changed, 220 insertions(+), 176 deletions(-)

diff --git a/hw/nseries.c b/hw/nseries.c
index 2f6f473..4ea2d6b 100644
--- a/hw/nseries.c
+++ b/hw/nseries.c
@@ -134,9 +134,9 @@ static void n800_mmc_cs_cb(void *opaque, int line, int 
level)
 static void n8x0_gpio_setup(struct n800_s *s)
 {
 qemu_irq *mmc_cs = qemu_allocate_irqs(n800_mmc_cs_cb, s-cpu-mmc, 1);
-omap2_gpio_out_set(s-cpu-gpif, N8X0_MMC_CS_GPIO, mmc_cs[0]);
+qdev_connect_gpio_out(s-cpu-gpio, N8X0_MMC_CS_GPIO, mmc_cs[0]);
 
-qemu_irq_lower(omap2_gpio_in_get(s-cpu-gpif, N800_BAT_COVER_GPIO)[0]);
+qemu_irq_lower(qdev_get_gpio_in(s-cpu-gpio, N800_BAT_COVER_GPIO));
 }
 
 #define MAEMO_CAL_HEADER(...)  \
@@ -168,8 +168,8 @@ static void n8x0_nand_setup(struct n800_s *s)
 omap_gpmc_attach(s-cpu-gpmc, N8X0_ONENAND_CS, 0, onenand_base_update,
 onenand_base_unmap,
 (s-nand = onenand_init(0xec4800, 1,
-omap2_gpio_in_get(s-cpu-gpif,
-N8X0_ONENAND_GPIO)[0])));
+qdev_get_gpio_in(s-cpu-gpio,
+N8X0_ONENAND_GPIO;
 otp_region = onenand_raw_otp(s-nand);
 
 memcpy(otp_region + 0x000, n8x0_cal_wlan_mac, sizeof(n8x0_cal_wlan_mac));
@@ -180,7 +180,7 @@ static void n8x0_nand_setup(struct n800_s *s)
 static void n8x0_i2c_setup(struct n800_s *s)
 {
 DeviceState *dev;
-qemu_irq tmp_irq = omap2_gpio_in_get(s-cpu-gpif, N8X0_TMP105_GPIO)[0];
+qemu_irq tmp_irq = qdev_get_gpio_in(s-cpu-gpio, N8X0_TMP105_GPIO);
 
 /* Attach the CPU on one end of our I2C bus.  */
 s-i2c = omap_i2c_bus(s-cpu-i2c[0]);
@@ -249,8 +249,8 @@ static void n800_tsc_kbd_setup(struct n800_s *s)
 /* XXX: are the three pins inverted inside the chip between the
  * tsc and the cpu (N4111)?  */
 qemu_irq penirq = NULL;/* NC */
-qemu_irq kbirq = omap2_gpio_in_get(s-cpu-gpif, N800_TSC_KP_IRQ_GPIO)[0];
-qemu_irq dav = omap2_gpio_in_get(s-cpu-gpif, N800_TSC_TS_GPIO)[0];
+qemu_irq kbirq = qdev_get_gpio_in(s-cpu-gpio, N800_TSC_KP_IRQ_GPIO);
+qemu_irq dav = qdev_get_gpio_in(s-cpu-gpio, N800_TSC_TS_GPIO);
 
 s-ts.chip = tsc2301_init(penirq, kbirq, dav);
 s-ts.opaque = s-ts.chip-opaque;
@@ -269,7 +269,7 @@ static void n800_tsc_kbd_setup(struct n800_s *s)
 
 static void n810_tsc_setup(struct n800_s *s)
 {
-qemu_irq pintdav = omap2_gpio_in_get(s-cpu-gpif, N810_TSC_TS_GPIO)[0];
+qemu_irq pintdav = qdev_get_gpio_in(s-cpu-gpio, N810_TSC_TS_GPIO);
 
 s-ts.opaque = tsc2005_init(pintdav);
 s-ts.txrx = tsc2005_txrx;
@@ -361,7 +361,7 @@ static int n810_keys[0x80] = {
 
 static void n810_kbd_setup(struct n800_s *s)
 {
-qemu_irq kbd_irq = omap2_gpio_in_get(s-cpu-gpif, N810_KEYBOARD_GPIO)[0];
+qemu_irq kbd_irq = qdev_get_gpio_in(s-cpu-gpio, N810_KEYBOARD_GPIO);
 DeviceState *dev;
 int i;
 
@@ -726,15 +726,15 @@ static void n8x0_dss_setup(struct n800_s *s)
 
 static void n8x0_cbus_setup(struct n800_s *s)
 {
-qemu_irq dat_out = omap2_gpio_in_get(s-cpu-gpif, N8X0_CBUS_DAT_GPIO)[0];
-qemu_irq retu_irq = omap2_gpio_in_get(s-cpu-gpif, N8X0_RETU_GPIO)[0];
-qemu_irq tahvo_irq = omap2_gpio_in_get(s-cpu-gpif, N8X0_TAHVO_GPIO)[0];
+qemu_irq dat_out = qdev_get_gpio_in(s-cpu-gpio, N8X0_CBUS_DAT_GPIO);
+qemu_irq retu_irq = qdev_get_gpio_in(s-cpu-gpio, N8X0_RETU_GPIO);
+qemu_irq tahvo_irq = qdev_get_gpio_in(s-cpu-gpio, N8X0_TAHVO_GPIO);
 
 CBus *cbus = cbus_init(dat_out);
 
-omap2_gpio_out_set(s-cpu-gpif, N8X0_CBUS_CLK_GPIO, cbus-clk);
-omap2_gpio_out_set(s-cpu-gpif, N8X0_CBUS_DAT_GPIO, cbus-dat);
-omap2_gpio_out_set(s-cpu-gpif, N8X0_CBUS_SEL_GPIO, cbus-sel);
+qdev_connect_gpio_out(s-cpu-gpio, N8X0_CBUS_CLK_GPIO, cbus-clk);
+qdev_connect_gpio_out(s-cpu-gpio, N8X0_CBUS_DAT_GPIO, cbus-dat);
+qdev_connect_gpio_out(s-cpu-gpio, N8X0_CBUS_SEL_GPIO, cbus-sel);
 
 cbus_attach(cbus, s-retu = retu_init(retu_irq, 1));
 cbus_attach(cbus, s-tahvo = tahvo_init(tahvo_irq, 1));
@@ -743,13 +743,12 @@ static void n8x0_cbus_setup(struct n800_s *s)
 static void n8x0_uart_setup(struct n800_s *s)
 {
 CharDriverState *radio = uart_hci_init(
-omap2_gpio_in_get(s-cpu-gpif,
-

Re: [Qemu-devel] [PATCH 1/3] vmstate: add no_migrate flag to VMStateDescription

2011-07-08 Thread Anthony Liguori

On 07/08/2011 11:04 AM, Gerd Hoffmann wrote:

On 07/08/11 17:44, Gerd Hoffmann wrote:

On 07/08/11 16:26, Anthony Liguori wrote:

register_device_unmigratable()?


Wanna have a patch to zap it?


Ah, no, we can't, for ivshmem this isn't fixed but depends on the
configuration, so a static flag in the VMStateDescription doesn't cut it.


Right, but can we have some continuity at least between the two interfaces?

At least make the vmstate flag 'unmigratable' or rename the function to 
qdev_set_no_migrate().


BTW, should this be a vmstate flag or a qdev flag?

Regards,

Anthony Liguori



cheers,
Gerd






[Qemu-devel] qemu minimum memory requirements

2011-07-08 Thread Darren Hart
I'm trying to boot a fairly minimal x86 kernel image (5M uncompressed) with a
small (11M) busybox rootfs in qemu with a minimum amount of memory. I'm able to
reduce the memory available to qemu down to 21M and boot successfully, but below
that, I get the following:

$
/home/dvhart/source/poky.git/build-qemux86/tmp/sysroots/x86_64-linux/usr/bin/qemu
 -kernel 
/home/dvhart/source/poky.git/build-qemux86/tmp/deploy/images/bzImage-qemux86.bin
 -hda 
/home/dvhart/source/poky.git/build-qemux86/tmp/deploy/images/core-image-minimal-qemux86.ext3
 -m 20 --append root=/dev/hda rw
qemu: fatal: Trying to execute code outside RAM or ROM at 0x014284ec

EAX=014284ec EBX=01221000 ECX= EDX=
ESI= EDI=01220ffc EBP=0010 ESP=01431fc0
EIP=014284ec EFL=0002 [---] CPL=0 II=0 A20=1 SMM=0 HLT=0
ES =0018   00cf9300 DPL=0 DS   [-WA]
CS =0010   00cf9b00 DPL=0 CS32 [-RA]
SS =0018   00cf9300 DPL=0 DS   [-WA]
DS =0018   00cf9300 DPL=0 DS   [-WA]
FS =0018   00cf9300 DPL=0 DS   [-WA]
GS =0018   00cf9300 DPL=0 DS   [-WA]
LDT=   8200 DPL=0 LDT
TR =0020 1000 0067 8900 DPL=0 TSS32-avl
GDT= 00012fd0 0027
IDT=  
CR0=0011 CR2= CR3= CR4=
DR0= DR1= DR2= DR3=
DR6=0ff0 DR7=0400
CCS=00105fe0 CCD=00082ff0 CCO=SARL
EFER=
FCW=037f FSW= [ST=0] FTW=00 MXCSR=1f80
FPR0=  FPR1= 
FPR2=  FPR3= 
FPR4=  FPR5= 
FPR6=  FPR7= 
XMM00=
XMM01=
XMM02=
XMM03=
XMM04=
XMM05=
XMM06=
XMM07=
Aborted

I get similar results using the native qemu or kvm commands from my x86_64
Ubuntu 10.10 installation. The qemu console doesn't display anything past the
SeaBIOS version, so I'm wondering if this is unrelated to the kernel image and
simply a limitation of qemu and/or SeaBIOS.

Does anyone have some experience working with qemu with  20M of memory?  I'm
trying to get to the point where I can boot in 8M of memory.

Thanks!

-- 
Darren Hart
Intel Open Source Technology Center
Yocto Project - Linux Kernel



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

2011-07-08 Thread Jordan Justen
If -pflash is specified and -bios is specified then pflash will
be mapped just below the system rom using hw/pflash_cfi01.c.

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

Signed-off-by: Jordan Justen jordan.l.jus...@intel.com
Reviewed-by: Aurelien Jarno aurel...@aurel32.net
---
 default-configs/i386-softmmu.mak   |1 +
 default-configs/x86_64-softmmu.mak |1 +
 hw/pc.c|  161 +++-
 3 files changed, 125 insertions(+), 38 deletions(-)

diff --git a/default-configs/i386-softmmu.mak b/default-configs/i386-softmmu.mak
index 55589fa..8697cd4 100644
--- a/default-configs/i386-softmmu.mak
+++ b/default-configs/i386-softmmu.mak
@@ -21,3 +21,4 @@ CONFIG_PIIX_PCI=y
 CONFIG_SOUND=y
 CONFIG_HPET=y
 CONFIG_APPLESMC=y
+CONFIG_PFLASH_CFI01=y
diff --git a/default-configs/x86_64-softmmu.mak 
b/default-configs/x86_64-softmmu.mak
index 8895028..eca9284 100644
--- a/default-configs/x86_64-softmmu.mak
+++ b/default-configs/x86_64-softmmu.mak
@@ -21,3 +21,4 @@ CONFIG_PIIX_PCI=y
 CONFIG_SOUND=y
 CONFIG_HPET=y
 CONFIG_APPLESMC=y
+CONFIG_PFLASH_CFI01=y
diff --git a/hw/pc.c b/hw/pc.c
index a3e8539..e25354f 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -41,6 +41,7 @@
 #include sysemu.h
 #include blockdev.h
 #include ui/qemu-spice.h
+#include flash.h
 
 /* output Bochs bios info messages */
 //#define DEBUG_BIOS
@@ -957,70 +958,154 @@ void pc_cpus_init(const char *cpu_model)
 }
 }
 
-void pc_memory_init(const char *kernel_filename,
-const char *kernel_cmdline,
-const char *initrd_filename,
-ram_addr_t below_4g_mem_size,
-ram_addr_t above_4g_mem_size)
+static void pc_isa_bios_init(ram_addr_t ram_offset, int ram_size)
 {
-char *filename;
-int ret, linux_boot, i;
-ram_addr_t ram_addr, bios_offset, option_rom_offset;
-int bios_size, isa_bios_size;
-void *fw_cfg;
-
-linux_boot = (kernel_filename != NULL);
+int isa_bios_size;
 
-/* allocate RAM */
-ram_addr = qemu_ram_alloc(NULL, pc.ram,
-  below_4g_mem_size + above_4g_mem_size);
-cpu_register_physical_memory(0, 0xa, ram_addr);
-cpu_register_physical_memory(0x10,
- below_4g_mem_size - 0x10,
- ram_addr + 0x10);
-if (above_4g_mem_size  0) {
-cpu_register_physical_memory(0x1ULL, above_4g_mem_size,
- ram_addr + below_4g_mem_size);
+/* map the last 128KB of the BIOS in ISA space */
+isa_bios_size = ram_size;
+if (isa_bios_size  (128 * 1024)) {
+isa_bios_size = 128 * 1024;
 }
+ram_offset = ram_offset + ram_size - isa_bios_size;
+cpu_register_physical_memory(0x10 - isa_bios_size,
+ isa_bios_size,
+ ram_offset | IO_MEM_ROM);
+}
+
+static int pc_system_rom_init(void)
+{
+int ret;
+int bios_size;
+ram_addr_t bios_offset;
+char *filename;
 
 /* BIOS load */
-if (bios_name == NULL)
+if (bios_name == NULL) {
 bios_name = BIOS_FILENAME;
+}
 filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
 if (filename) {
 bios_size = get_image_size(filename);
 } else {
 bios_size = -1;
 }
-if (bios_size = 0 ||
-(bios_size % 65536) != 0) {
-goto bios_error;
+
+if (bios_size = 0 || (bios_size % 65536) != 0) {
+ret = -1;
+} else {
+bios_offset = qemu_ram_alloc(NULL, pc.bios, bios_size);
+ret = rom_add_file_fixed(bios_name, (uint32_t)(-bios_size), -1);
 }
-bios_offset = qemu_ram_alloc(NULL, pc.bios, bios_size);
-ret = rom_add_file_fixed(bios_name, (uint32_t)(-bios_size), -1);
+
 if (ret != 0) {
-bios_error:
 fprintf(stderr, qemu: could not load PC BIOS '%s'\n, bios_name);
 exit(1);
 }
+
 if (filename) {
 qemu_free(filename);
 }
-/* map the last 128KB of the BIOS in ISA space */
-isa_bios_size = bios_size;
-if (isa_bios_size  (128 * 1024))
-isa_bios_size = 128 * 1024;
-cpu_register_physical_memory(0x10 - isa_bios_size,
- isa_bios_size,
- (bios_offset + bios_size - isa_bios_size) | 
IO_MEM_ROM);
 
-option_rom_offset = qemu_ram_alloc(NULL, pc.rom, PC_ROM_SIZE);
-cpu_register_physical_memory(PC_ROM_MIN_VGA, PC_ROM_SIZE, 
option_rom_offset);
+pc_isa_bios_init(bios_offset, bios_size);
 
 /* map all the bios at the top of memory */
 cpu_register_physical_memory((uint32_t)(-bios_size),
  bios_size, bios_offset | IO_MEM_ROM);
 
+return bios_size;
+}
+
+static void pc_system_flash_init(DriveInfo *pflash_drv, int rom_size)
+{
+

[Qemu-devel] smp-parse: smp-opt-cores for simple -smp X

2011-07-08 Thread Adam Lackorzynski
Hi,

When just using a simple '-smp X', both the smp_cores and smp_threads
variables are set to 1, which on x86 leads to CPUid-0x8008-ecx
returning 1 for the CPU count despite more CPUs are there. Docs say
'Missing values will be computed.', so my try on this is the following.
Comments?


Signed-off-by: Adam Lackorzynski a...@os.inf.tu-dresden.de
---
 vl.c |2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/vl.c b/vl.c
index fcd7395..1459bde 100644
--- a/vl.c
+++ b/vl.c
@@ -886,6 +886,8 @@ static void smp_parse(const char *optarg)
 max_cpus = strtoull(option, NULL, 10);
 
 /* compute missing values, prefer sockets over cores over threads */
+if (sockets + cores + threads == 0)
+cores = smp;
 if (smp == 0 || sockets == 0) {
 sockets = sockets  0 ? sockets : 1;
 cores = cores  0 ? cores : 1;
-- 
1.7.5.3


Adam
-- 
Adam a...@os.inf.tu-dresden.de
  Lackorzynski http://os.inf.tu-dresden.de/~adam/



Re: [Qemu-devel] [PATCH v6 1/4] guest agent: command state class

2011-07-08 Thread Michael Roth

On 07/08/2011 09:25 AM, Luiz Capitulino wrote:

On Tue,  5 Jul 2011 08:21:37 -0500
Michael Rothmdr...@linux.vnet.ibm.com  wrote:



Signed-off-by: Michael Rothmdr...@linux.vnet.ibm.com
---
  Makefile|4 ++-
  configure   |1 +
  qga/guest-agent-command-state.c |   73 +++
  qga/guest-agent-core.h  |   25 +
  4 files changed, 102 insertions(+), 1 deletions(-)
  create mode 100644 qga/guest-agent-command-state.c
  create mode 100644 qga/guest-agent-core.h


I'm not sure there's much value in having this as a separate patch, maybe
it should be folded in the next one.



I can, just trying to make it more review-friendly really. Same with 
breaking out the schema from the command implementations. If needed I 
can respin a more squashed version when things look ready, but this 
stuff is pretty simple and modularized so it doesn't seem like a bad 
idea to pull it out of the meatier patch.




diff --git a/Makefile b/Makefile
index cbd2d77..6c3ba71 100644
--- a/Makefile
+++ b/Makefile
@@ -181,6 +181,8 @@ test-visitor: test-visitor.o qfloat.o qint.o qdict.o 
qstring.o qlist.o qbool.o $
  test-qmp-commands.o: $(addprefix $(qapi-dir)/, test-qapi-types.c 
test-qapi-types.h test-qapi-visit.c test-qapi-visit.h test-qmp-marshal.c 
test-qmp-commands.h)
  test-qmp-commands: test-qmp-commands.o qfloat.o qint.o qdict.o qstring.o 
qlist.o qbool.o $(qapi-obj-y) error.o osdep.o qemu-malloc.o $(oslib-obj-y) 
qjson.o json-streamer.o json-lexer.o json-parser.o qerror.o qemu-error.o 
qemu-tool.o $(qapi-dir)/test-qapi-visit.o $(qapi-dir)/test-qapi-types.o 
$(qapi-dir)/test-qmp-marshal.o module.o

+QGALIB=qga/guest-agent-command-state.o
+
  QEMULIBS=libhw32 libhw64 libuser libdis libdis-user

  clean:
@@ -189,7 +191,7 @@ clean:
rm -f qemu-options.def
rm -f *.o *.d *.a *.lo $(TOOLS) TAGS cscope.* *.pod *~ */*~
rm -Rf .libs
-   rm -f slirp/*.o slirp/*.d audio/*.o audio/*.d block/*.o block/*.d 
net/*.o net/*.d fsdev/*.o fsdev/*.d ui/*.o ui/*.d qapi/*.o qapi/*.d
+   rm -f slirp/*.o slirp/*.d audio/*.o audio/*.d block/*.o block/*.d 
net/*.o net/*.d fsdev/*.o fsdev/*.d ui/*.o ui/*.d qapi/*.o qapi/*.d qga/*.o 
qga/*.d
rm -f qemu-img-cmds.h
rm -f trace.c trace.h trace.c-timestamp trace.h-timestamp
rm -f trace-dtrace.dtrace trace-dtrace.dtrace-timestamp
diff --git a/configure b/configure
index 02c552e..6a03002 100755
--- a/configure
+++ b/configure
@@ -3487,6 +3487,7 @@ DIRS=$DIRS pc-bios/spapr-rtas
  DIRS=$DIRS roms/seabios roms/vgabios
  DIRS=$DIRS fsdev ui
  DIRS=$DIRS qapi
+DIRS=$DIRS qga
  FILES=Makefile tests/Makefile
  FILES=$FILES tests/cris/Makefile tests/cris/.gdbinit
  FILES=$FILES pc-bios/optionrom/Makefile pc-bios/keymaps
diff --git a/qga/guest-agent-command-state.c b/qga/guest-agent-command-state.c
new file mode 100644
index 000..bc6e0bd
--- /dev/null
+++ b/qga/guest-agent-command-state.c
@@ -0,0 +1,73 @@
+/*
+ * QEMU Guest Agent command state interfaces
+ *
+ * Copyright IBM Corp. 2011
+ *
+ * Authors:
+ *  Michael Rothmdr...@linux.vnet.ibm.com
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+#includeglib.h
+#include qga/guest-agent-core.h
+
+struct GACommandState {
+GSList *groups;
+};
+
+typedef struct GACommandGroup {
+void (*init)(void);
+void (*cleanup)(void);
+} GACommandGroup;
+
+/* handle init/cleanup for stateful guest commands */
+
+void ga_command_state_add(GACommandState *cs,
+  void (*init)(void),
+  void (*cleanup)(void))
+{
+GACommandGroup *cg = qemu_mallocz(sizeof(GACommandGroup));
+cg-init = init;
+cg-cleanup = cleanup;
+cs-groups = g_slist_append(cs-groups, cg);
+}
+
+static void ga_command_group_init(gpointer opaque, gpointer unused)
+{
+GACommandGroup *cg = opaque;
+
+g_assert(cg);
+if (cg-init) {
+cg-init();
+}
+}
+
+void ga_command_state_init_all(GACommandState *cs)
+{
+g_assert(cs);
+g_slist_foreach(cs-groups, ga_command_group_init, NULL);
+}
+
+static void ga_command_group_cleanup(gpointer opaque, gpointer unused)
+{
+GACommandGroup *cg = opaque;
+
+g_assert(cg);
+if (cg-cleanup) {
+cg-cleanup();
+}
+}
+
+void ga_command_state_cleanup_all(GACommandState *cs)
+{
+g_assert(cs);
+g_slist_foreach(cs-groups, ga_command_group_cleanup, NULL);
+}
+
+GACommandState *ga_command_state_new(void)
+{
+GACommandState *cs = qemu_mallocz(sizeof(GACommandState));
+cs-groups = NULL;
+return cs;
+}
diff --git a/qga/guest-agent-core.h b/qga/guest-agent-core.h
new file mode 100644
index 000..688f120
--- /dev/null
+++ b/qga/guest-agent-core.h
@@ -0,0 +1,25 @@
+/*
+ * QEMU Guest Agent core declarations
+ *
+ * Copyright IBM Corp. 2011
+ *
+ * Authors:
+ *  Adam Litkeagli...@linux.vnet.ibm.com
+ *  Michael 

[Qemu-devel] Fixed bug [Bug 38672] - bugzilla.kernel.org

2011-07-08 Thread Stefan BOSAK

Hello.

Bug is in (xen-mapcache.c):

Reported-by: Steve stefan.bo...@gmail.com
Signed-off-by: Steve stefan.bo...@gmail.com

diff --git a/xen-mapcache.c b/xen-mapcache.c
index 57fe24d..1c3b5bf 100644
--- a/xen-mapcache.c
+++ b/xen-mapcache.c
@@ -107,7 +107,7 @@ void qemu_map_cache_init(void)
 size = mapcache-nr_buckets * sizeof (MapCacheEntry);
 size = (size + XC_PAGE_SIZE - 1)  ~(XC_PAGE_SIZE - 1);
 DPRINTF(qemu_map_cache_init, nr_buckets = %lx size %lu\n, 
mapcache-nr_buckets, size);

-mapcache-entry = qemu_mallocz(size);
+mapcache-entry = qemu_mallocz(size*sizeof(MapCacheEntry));
 }

static void qemu_remap_bucket(MapCacheEntry *entry,

Should somebody commit this fix ?

Thank you for your time.



Re: [Qemu-devel] [PATCH v6 2/4] guest agent: qemu-ga daemon

2011-07-08 Thread Michael Roth

On 07/08/2011 09:36 AM, Luiz Capitulino wrote:

On Tue,  5 Jul 2011 08:21:38 -0500
Michael Rothmdr...@linux.vnet.ibm.com  wrote:


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

A shorthand invocation:

   qemu-ga -d

Is equivalent to:

   qemu-ga -c virtio-serial -p /dev/virtio-ports/org.qemu.guest_agent \
   -p /var/run/qemu-guest-agent.pid -d


I think you meant -f /var/run/qemu-guest-agent.pid



Yup, sorry.



Signed-off-by: Michael Rothmdr...@linux.vnet.ibm.com
---
  Makefile   |   10 +-
  qemu-ga.c  |  651 
  qga/guest-agent-core.h |4 +
  3 files changed, 661 insertions(+), 4 deletions(-)
  create mode 100644 qemu-ga.c

diff --git a/Makefile b/Makefile
index 6c3ba71..b2e8593 100644
--- a/Makefile
+++ b/Makefile
@@ -140,7 +140,7 @@ endif
  ##

  qemu-img.o: qemu-img-cmds.h
-qemu-img.o qemu-tool.o qemu-nbd.o qemu-io.o cmd.o: $(GENERATED_HEADERS)
+qemu-img.o qemu-tool.o qemu-nbd.o qemu-io.o cmd.o qemu-ga.o: 
$(GENERATED_HEADERS)

  qemu-img$(EXESUF): qemu-img.o qemu-tool.o qemu-error.o $(oslib-obj-y) 
$(trace-obj-y) $(block-obj-y) $(qobject-obj-y) $(version-obj-y) 
qemu-timer-common.o

@@ -163,7 +163,7 @@ check-qfloat: check-qfloat.o qfloat.o $(CHECK_PROG_DEPS)
  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 error.o qerror.o 
qemu-error.o $(CHECK_PROG_DEPS)

  qapi-dir := qapi-generated
-$(qapi-obj-y) test-visitor.o test-qmp-commands.o: QEMU_CFLAGS += -I $(qapi-dir)
+$(qapi-obj-y) test-visitor.o test-qmp-commands.o qemu-ga$(EXESUF): QEMU_CFLAGS 
+= -I $(qapi-dir)

  $(qapi-dir)/test-qapi-types.c: $(qapi-dir)/test-qapi-types.h
  $(qapi-dir)/test-qapi-types.h: $(SRC_PATH)/qapi-schema-test.json 
$(SRC_PATH)/scripts/qapi-types.py
@@ -183,13 +183,15 @@ test-qmp-commands: test-qmp-commands.o qfloat.o qint.o 
qdict.o qstring.o qlist.o

  QGALIB=qga/guest-agent-command-state.o

+qemu-ga$(EXESUF): qemu-ga.o $(QGALIB) qemu-tool.o qemu-error.o error.o 
$(oslib-obj-y) $(trace-obj-y) $(block-obj-y) $(qobject-obj-y) $(version-obj-y) 
$(qapi-obj-y) qemu-timer-common.o qemu-sockets.o module.o qapi/qmp-dispatch.o 
qapi/qmp-registry.o
+
  QEMULIBS=libhw32 libhw64 libuser libdis libdis-user

  clean:
  # avoid old build problems by removing potentially incorrect old files
rm -f config.mak op-i386.h opc-i386.h gen-op-i386.h op-arm.h opc-arm.h 
gen-op-arm.h
rm -f qemu-options.def
-   rm -f *.o *.d *.a *.lo $(TOOLS) TAGS cscope.* *.pod *~ */*~
+   rm -f *.o *.d *.a *.lo $(TOOLS) qemu-ga TAGS cscope.* *.pod *~ */*~
rm -Rf .libs
rm -f slirp/*.o slirp/*.d audio/*.o audio/*.d block/*.o block/*.d 
net/*.o net/*.d fsdev/*.o fsdev/*.d ui/*.o ui/*.d qapi/*.o qapi/*.d qga/*.o 
qga/*.d
rm -f qemu-img-cmds.h
@@ -385,4 +387,4 @@ tarbin:
$(mandir)/man8/qemu-nbd.8

  # Include automatically generated dependency files
--include $(wildcard *.d audio/*.d slirp/*.d block/*.d net/*.d ui/*.d qapi/*.d)
+-include $(wildcard *.d audio/*.d slirp/*.d block/*.d net/*.d ui/*.d qapi/*.d 
qga/*.d)
diff --git a/qemu-ga.c b/qemu-ga.c
new file mode 100644
index 000..649c16a
--- /dev/null
+++ b/qemu-ga.c
@@ -0,0 +1,651 @@
+/*
+ * QEMU Guest Agent
+ *
+ * Copyright IBM Corp. 2011
+ *
+ * Authors:
+ *  Adam Litkeagli...@linux.vnet.ibm.com
+ *  Michael Rothmdr...@linux.vnet.ibm.com
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+#includestdlib.h
+#includestdio.h
+#includestdbool.h
+#includeglib.h
+#includegio/gio.h
+#includegetopt.h
+#includetermios.h
+#includesyslog.h
+#include qemu_socket.h
+#include json-streamer.h
+#include json-parser.h
+#include qint.h
+#include qjson.h
+#include qga/guest-agent-core.h
+#include module.h
+#include signal.h
+
+#define QGA_VIRTIO_PATH_DEFAULT /dev/virtio-ports/org.qemu.guest_agent
+#define QGA_PIDFILE_DEFAULT /var/run/qemu-va.pid
+#define QGA_BAUDRATE_DEFAULT B38400 /* for isa-serial channels */
+#define QGA_TIMEOUT_DEFAULT 30*1000 /* ms */
+
+struct GAState {
+JSONMessageParser parser;
+GMainLoop *main_loop;
+guint conn_id;
+GSocket *conn_sock;
+GIOChannel *conn_channel;
+guint listen_id;
+GSocket *listen_sock;
+GIOChannel *listen_channel;
+const char *path;
+const char *method;
+bool virtio; /* fastpath to check for virtio to deal with poll() quirks */
+GACommandState *command_state;
+GLogLevelFlags log_level;
+FILE *log_file;
+bool logging_enabled;
+};
+
+static struct GAState *ga_state;
+
+static void quit_handler(int sig)
+{
+g_debug(recieved signal num %d, quitting);
+
+if 

Re: [Qemu-devel] [PATCH v6 3/4] guest agent: add guest agent commands schema file

2011-07-08 Thread Michael Roth

On 07/08/2011 10:08 AM, Luiz Capitulino wrote:

On Tue,  5 Jul 2011 08:21:39 -0500
Michael Rothmdr...@linux.vnet.ibm.com  wrote:



Signed-off-by: Michael Rothmdr...@linux.vnet.ibm.com
---
  qapi-schema-guest.json |  204 
  1 files changed, 204 insertions(+), 0 deletions(-)
  create mode 100644 qapi-schema-guest.json


I think this should be folded in the next patch.

More comments below.



diff --git a/qapi-schema-guest.json b/qapi-schema-guest.json
new file mode 100644
index 000..367b42d
--- /dev/null
+++ b/qapi-schema-guest.json
@@ -0,0 +1,204 @@
+# *-*- Mode: Python -*-*
+
+##
+# @guest-sync:
+#
+# Echo back a unique integer value
+#
+# This is used by clients talking to the guest agent over the
+# wire to ensure the stream is in sync and doesn't contain stale
+# data from previous client. All guest agent responses should be
+# ignored until the provided unique integer value is returned,
+# and it is up to the client to handle stale whole or
+# partially-delivered JSON text in such a way that this response
+# can be obtained.
+#
+# Such clients should also preceed this command
+# with a 0xFF byte to make such the guest agent flushes any
+# partially read JSON data from a previous session.
+#
+# @id: randomly generated 64-bit integer
+#
+# Returns: The unique integer id passed in by the client
+#
+# Since: 0.15.0
+##
+{ 'command': 'guest-sync'
+  'data':{ 'id': 'int' },
+  'returns': 'int' }
+
+##
+# @guest-ping:
+#
+# Ping the guest agent, a non-error return implies success
+#
+# Since: 0.15.0
+##
+{ 'command': 'guest-ping' }
+
+##
+# @guest-info:
+#
+# Get some information about the guest agent.
+#
+# Since: 0.15.0
+##
+{ 'type': 'GuestAgentInfo', 'data': {'version': 'str'} }
+{ 'command': 'guest-info',
+  'returns': 'GuestAgentInfo' }
+
+##
+# @guest-shutdown:
+#
+# Initiate guest-activated shutdown. Note: this is an asynchronous
+# shutdown request, with no guaruntee of successful shutdown. Errors
+# will be logged to guest's syslog.
+#
+# @mode: halt, powerdown, or reboot
+#
+# Returns: Nothing on success
+#
+# Since: 0.15.0
+##
+{ 'command': 'guest-shutdown', 'data': { 'mode': 'str' } }


Shouldn't 'mode' be optional?


+
+##
+# @guest-file-open:
+#
+# Open a file in the guest and retrieve a file handle for it
+#
+# @filepath: Full path to the file in the guest to open.
+#
+# @mode: #optional open mode, as per fopen(), r is the default.
+#
+# Returns: Guest file handle on success.
+#  If @filepath cannot be opened, OpenFileFailed
+#
+# Since: 0.15.0
+##
+{ 'command': 'guest-file-open',
+  'data':{ 'filepath': 'str', '*mode': 'str' },
+  'returns': 'int' }


You can use 'file-path'. Actually, I'd use just 'path'.


+
+##
+# @guest-file-read:
+#
+# Read from an open file in the guest
+#
+# @filehandle: filehandle returned by guest-file-open
+#
+# @count: maximum number of bytes to read
+#
+# Returns: GuestFileRead on success.
+#  If @filehandle is not open, OpenFileFailed
+#
+# Since: 0.15.0
+##
+{ 'type': 'GuestFileRead',
+  'data': { 'count': 'int', 'buf': 'str', 'eof': 'bool' } }
+
+{ 'command': 'guest-file-read',
+  'data':{ 'filehandle': 'int', 'count': 'int' },
+  'returns': 'GuestFileRead' }


file-handle. Also, we have to say that the returned data is base64-encoded.


+
+##
+# @guest-file-write:
+#
+# Write to an open file in the guest
+#
+# @filehandle: filehandle returned by guest-file-open
+#
+# @data_b64: base64-encoded string representing data to be written
+#
+# @count: bytes to write (actual bytes, after b64-decode)
+#
+# Returns: GuestFileWrite on success.
+#  If @filehandle is not opened, OpenFileFailed
+#
+# Since: 0.15.0
+##
+{ 'type': 'GuestFileWrite',
+  'data': { 'count': 'int', 'eof': 'bool' } }
+{ 'command': 'guest-file-write',
+  'data':{ 'filehandle': 'int', 'data_b64': 'str', 'count': 'int' },
+  'returns': 'GuestFileWrite' }


data-b64


+
+##
+# @guest-file-seek:
+#
+# Seek to a position in the file, as with fseek(), and return the
+# current file position afterward. Also encapsulates ftell()'s
+# functionality, just Set offset=0, whence=SEEK_CUR.
+#
+# @filehandle: filehandle returned by guest-file-open
+#
+# @offset: bytes to skip over in the file stream
+#
+# @whence: SEEK_SET, SEEK_CUR, or SEEK_END, as with fseek()
+#
+# Returns: GuestFileSeek on success.
+#  If @filehandle is not opened, OpenFileFailed
+#
+# Since: 0.15.0
+##
+{ 'type': 'GuestFileSeek',
+  'data': { 'position': 'int', 'eof': 'bool' } }
+
+{ 'command': 'guest-file-seek',
+  'data':{ 'filehandle': 'int', 'offset': 'int', 'whence': 'int' },
+  'returns': 'GuestFileSeek' }
+
+##
+# @guest-file-close:
+#
+# Close an open file in the guest
+#
+# @filehandle: filehandle returned by guest-file-open
+#
+# Returns: Nothing on success.
+#  If @filehandle is not opened, OpenFileFailed
+#
+# Since: 0.15.0
+##
+{ 'command': 'guest-file-close',
+  'data': { 'filehandle': 'int' } }
+
+##
+# 

[Qemu-devel] PPC version of Fedora 12 on qemu

2011-07-08 Thread David Ahern
Has anyone successfully installed the PPC version of Fedora-12 in a qemu
VM? So far I have been unsuccessful - with the installs failing on the
bootloader. Running yabootconfig manually is failing. Should this work?

I am using qemu.git, pulled this morning.

Thanks,
David



[Qemu-devel] Taking live snapshots of running VMs

2011-07-08 Thread Ahmed M. Azab
Hi All,

Is there a way to take a live memory snapshot of a running VM without
freezing or stopping this VM?

I explored the Qemu code and documentation and I found two ways to
take a snapshot:

1-Using savevm Qemu monitor command, which freezes the VM for tens of seconds
2-Using migrate and select the destination as a file, which forces
the machine to stop after the snapshot is saved.

In production environments (where delaying the operations of a VM is
very critical), it is always useful to take memory snapshots to do
system analysis or forensics. I think Qemu should provide a way to
take a snapshot based on QOW technque of memory pages (same as the
QCOW disk snapshoting).

If such technique does not exist, I am willing it devlop it myself,
but I wonder if the Qemu community will be interested to add my patch
to future versions.

Ahmed



[Qemu-devel] Votre site Web pour 999 DT seulement !

2011-07-08 Thread Votre agence Web

PROMOTION SITE WEB

Du 21 juin au 8 juillet 2011



Nous proposons aux entreprises/associations une solution Internet clé en
main à 999 Dinars. Grande ou petite, votre entreprise/association ne peut
plus se passer d’un site internet si elle désire grandir et se faire
connaitre du plus grand nombre. Nous réalisons pour vous un site web
moderne et efficace, entièrement et facilement gérable par vous-même au
meilleur rapport qualité prix.

L'offre comprend:



• 10 pages web.

• Back Office sécurisé : gestion du contenu du site.

• Formulaire de contact

• Une conception graphique moderne

• Module de news

• inscription newsletter

• Moteur de recherche interne

• Galerie photo

• liens vers les réseaux sociaux (facebook, twitter...)

• Module de sondage

• Statistiques de fréquentation

• Images et textes fournis par vos soins 








Commander maintenant :
http://ptf.tweensa.com/link.php?M=4129515N=113L=37F=T






Re: [Qemu-devel] [PATCH v2] Fix signal handling when io-thread is disabled

2011-07-08 Thread Alexandre Raymond
ping?

On Tue, Jun 14, 2011 at 12:47 PM, Jan Kiszka jan.kis...@siemens.com wrote:
 On 2011-06-14 16:05, Alexandre Raymond wrote:
 Changes since v1:
 - take pthread_sigmask() out of the ifdef as it is now common
 to both parts.

 This fix effectively blocks, in the main thread, the signals handled
 by signalfd or the compatibility signal thread.

 This way, such signals are received synchronously in the main thread
 through sigfd_handler() instead of triggering the signal handler
 directly, asynchronously.

 Signed-off-by: Alexandre Raymond cerb...@gmail.com
 ---
  cpus.c |    2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)

 diff --git a/cpus.c b/cpus.c
 index 4ab76f0..18a1522 100644
 --- a/cpus.c
 +++ b/cpus.c
 @@ -399,7 +399,6 @@ static int qemu_signal_init(void)
      sigaddset(set, SIGALRM);
      sigaddset(set, SIG_IPI);
      sigaddset(set, SIGBUS);
 -    pthread_sigmask(SIG_BLOCK, set, NULL);
  #else
      sigemptyset(set);
      sigaddset(set, SIGBUS);
 @@ -412,6 +411,7 @@ static int qemu_signal_init(void)
          sigaddset(set, SIGALRM);
      }
  #endif
 +    pthread_sigmask(SIG_BLOCK, set, NULL);

      sigfd = qemu_signalfd(set);
      if (sigfd == -1) {

 Acked-by: Jan Kiszka jan.kis...@siemens.com

 Thanks,
 Jan

 --
 Siemens AG, Corporate Technology, CT T DE IT 1
 Corporate Competence Center Embedded Linux




Re: [Qemu-devel] [PATCH] Fix signal handling of SIG_IPI when io-thread is enabled

2011-07-08 Thread Alexandre Raymond
ping?

On Wed, Jun 15, 2011 at 10:11 AM, Alexandre Raymond cerb...@gmail.com wrote:
 Hi Jan,

 Why? Ahh, because of qemu_cpu_kick_self: raise(SIG_IPI)! That should
 generate a per-process SIG_IPI. And that may not only affect Darwin.
 Looks good.

 Actually, with io-thread enabled, it goes through qemu_cpu_kick_self()
 - qemu_cpu_kick_thread() - pthread_kill(..., SIG_IPI).

 I think the problem is with sigwait(). It doesn't state so in the
 Linux or Darwin man pages, but on Solaris, it says : All signals
 identified by the set argument must be blocked on all threads,
 including the calling thread; otherwise, sigwait() might not work
 correctly, which might correspond to the issue I've been witnessing
 (ie: sigwait() unblocking once in a while on a SIGUSR1 (SIG_IPI) in
 the event thread).

 In any case, I don't think it should attempt to catch this signal at
 all since the cpu thread is already catching it.

 Alexandre




Re: [Qemu-devel] Qemu performance

2011-07-08 Thread Lê Đức Tài
On 08.07.2011, at 16:55, Alexander Graf ag...@suse.de wrote:


 I see. Qemu always gives you best performance, as it can't throttle the 
 guest 
:). Btw, I'd be happy to merge your custom board (or at least some components 
of 
it if they are reasonably mainstream) upstream, if you think it makes sense 
and 
the code is in good shape.

 Alex

I'm a new in Qemu.
I'm beginning to develop my custom board, and the is no components is 
implemented :).
So, I'm looking forward to get help from you.

Thank you for your support from the past till now.

Tai