diff mbox

[v2,2/5] vga_hw_screen_dump: add Error** param

Message ID 1331765714-26209-3-git-send-email-alevy@redhat.com
State New
Headers show

Commit Message

Alon Levy March 14, 2012, 10:55 p.m. UTC
Signed-off-by: Alon Levy <alevy@redhat.com>
---
 console.c       |    5 +++--
 console.h       |    6 ++++--
 hw/blizzard.c   |    3 ++-
 hw/g364fb.c     |    4 +++-
 hw/omap_lcdc.c  |    4 +++-
 hw/qxl.c        |    6 ++++--
 hw/tcx.c        |   13 +++++++++----
 hw/vga.c        |    7 +++++--
 hw/vmware_vga.c |    6 ++++--
 monitor.c       |    4 +++-
 10 files changed, 40 insertions(+), 18 deletions(-)

Comments

Luiz Capitulino March 15, 2012, 2:54 p.m. UTC | #1
On Thu, 15 Mar 2012 00:55:11 +0200
Alon Levy <alevy@redhat.com> wrote:

> Signed-off-by: Alon Levy <alevy@redhat.com>

Please, explain why. More comments at the bottom.

> ---
>  console.c       |    5 +++--
>  console.h       |    6 ++++--
>  hw/blizzard.c   |    3 ++-
>  hw/g364fb.c     |    4 +++-
>  hw/omap_lcdc.c  |    4 +++-
>  hw/qxl.c        |    6 ++++--
>  hw/tcx.c        |   13 +++++++++----
>  hw/vga.c        |    7 +++++--
>  hw/vmware_vga.c |    6 ++++--
>  monitor.c       |    4 +++-
>  10 files changed, 40 insertions(+), 18 deletions(-)
> 
> diff --git a/console.c b/console.c
> index 6a463f5..d3fccf3 100644
> --- a/console.c
> +++ b/console.c
> @@ -24,6 +24,7 @@
>  #include "qemu-common.h"
>  #include "console.h"
>  #include "qemu-timer.h"
> +#include "error.h"
>  
>  //#define DEBUG_CONSOLE
>  #define DEFAULT_BACKSCROLL 512
> @@ -173,7 +174,7 @@ void vga_hw_invalidate(void)
>          active_console->hw_invalidate(active_console->hw);
>  }
>  
> -void vga_hw_screen_dump(const char *filename)
> +void vga_hw_screen_dump(const char *filename, Error **errp)
>  {
>      TextConsole *previous_active_console;
>      bool cswitch;
> @@ -187,7 +188,7 @@ void vga_hw_screen_dump(const char *filename)
>          console_select(0);
>      }
>      if (consoles[0] && consoles[0]->hw_screen_dump) {
> -        consoles[0]->hw_screen_dump(consoles[0]->hw, filename, cswitch);
> +        consoles[0]->hw_screen_dump(consoles[0]->hw, filename, cswitch, errp);
>      } else {
>          error_report("screen dump not implemented");
>      }
> diff --git a/console.h b/console.h
> index 4334db5..caf13f5 100644
> --- a/console.h
> +++ b/console.h
> @@ -6,6 +6,7 @@
>  #include "notify.h"
>  #include "monitor.h"
>  #include "trace.h"
> +#include "error.h"
>  
>  /* keyboard/mouse support */
>  
> @@ -343,7 +344,8 @@ static inline void console_write_ch(console_ch_t *dest, uint32_t ch)
>  
>  typedef void (*vga_hw_update_ptr)(void *);
>  typedef void (*vga_hw_invalidate_ptr)(void *);
> -typedef void (*vga_hw_screen_dump_ptr)(void *, const char *, bool cswitch);
> +typedef void (*vga_hw_screen_dump_ptr)(void *, const char *, bool cswitch,
> +                                       Error **errp);
>  typedef void (*vga_hw_text_update_ptr)(void *, console_ch_t *);
>  
>  DisplayState *graphic_console_init(vga_hw_update_ptr update,
> @@ -354,7 +356,7 @@ DisplayState *graphic_console_init(vga_hw_update_ptr update,
>  
>  void vga_hw_update(void);
>  void vga_hw_invalidate(void);
> -void vga_hw_screen_dump(const char *filename);
> +void vga_hw_screen_dump(const char *filename, Error **errp);
>  void vga_hw_text_update(console_ch_t *chardata);
>  
>  int is_graphic_console(void);
> diff --git a/hw/blizzard.c b/hw/blizzard.c
> index c7d844d..76df78c 100644
> --- a/hw/blizzard.c
> +++ b/hw/blizzard.c
> @@ -23,6 +23,7 @@
>  #include "devices.h"
>  #include "vga_int.h"
>  #include "pixel_ops.h"
> +#include "error.h"
>  
>  typedef void (*blizzard_fn_t)(uint8_t *, const uint8_t *, unsigned int);
>  
> @@ -933,7 +934,7 @@ static void blizzard_update_display(void *opaque)
>  }
>  
>  static void blizzard_screen_dump(void *opaque, const char *filename,
> -                                 bool cswitch)
> +                                 bool cswitch, Error **errp)
>  {
>      BlizzardState *s = (BlizzardState *) opaque;
>  
> diff --git a/hw/g364fb.c b/hw/g364fb.c
> index 3a0b68f..7774d05 100644
> --- a/hw/g364fb.c
> +++ b/hw/g364fb.c
> @@ -22,6 +22,7 @@
>  #include "pixel_ops.h"
>  #include "trace.h"
>  #include "sysbus.h"
> +#include "error.h"
>  
>  typedef struct G364State {
>      /* hardware */
> @@ -289,7 +290,8 @@ static void g364fb_reset(G364State *s)
>      g364fb_invalidate_display(s);
>  }
>  
> -static void g364fb_screen_dump(void *opaque, const char *filename, bool cswitch)
> +static void g364fb_screen_dump(void *opaque, const char *filename, bool cswitch,
> +                               Error **errp)
>  {
>      G364State *s = opaque;
>      int y, x;
> diff --git a/hw/omap_lcdc.c b/hw/omap_lcdc.c
> index f172093..aec7210 100644
> --- a/hw/omap_lcdc.c
> +++ b/hw/omap_lcdc.c
> @@ -20,6 +20,7 @@
>  #include "console.h"
>  #include "omap.h"
>  #include "framebuffer.h"
> +#include "error.h"
>  
>  struct omap_lcd_panel_s {
>      MemoryRegion *sysmem;
> @@ -264,7 +265,8 @@ static int ppm_save(const char *filename, uint8_t *data,
>      return 0;
>  }
>  
> -static void omap_screen_dump(void *opaque, const char *filename, bool cswitch)
> +static void omap_screen_dump(void *opaque, const char *filename, bool cswitch,
> +                             Error **errp)
>  {
>      struct omap_lcd_panel_s *omap_lcd = opaque;
>      if (cswitch) {
> diff --git a/hw/qxl.c b/hw/qxl.c
> index e17b0e3..27f27f5 100644
> --- a/hw/qxl.c
> +++ b/hw/qxl.c
> @@ -23,6 +23,7 @@
>  #include "qemu-queue.h"
>  #include "monitor.h"
>  #include "sysemu.h"
> +#include "error.h"
>  
>  #include "qxl.h"
>  
> @@ -1492,7 +1493,8 @@ static void qxl_hw_invalidate(void *opaque)
>      vga->invalidate(vga);
>  }
>  
> -static void qxl_hw_screen_dump(void *opaque, const char *filename, bool cswitch)
> +static void qxl_hw_screen_dump(void *opaque, const char *filename, bool cswitch,
> +                               Error **errp)
>  {
>      PCIQXLDevice *qxl = opaque;
>      VGACommonState *vga = &qxl->vga;
> @@ -1504,7 +1506,7 @@ static void qxl_hw_screen_dump(void *opaque, const char *filename, bool cswitch)
>          ppm_save(filename, qxl->ssd.ds->surface);
>          break;
>      case QXL_MODE_VGA:
> -        vga->screen_dump(vga, filename, cswitch);
> +        vga->screen_dump(vga, filename, cswitch, errp);
>          break;
>      default:
>          break;
> diff --git a/hw/tcx.c b/hw/tcx.c
> index ac7dcb4..f342a5d 100644
> --- a/hw/tcx.c
> +++ b/hw/tcx.c
> @@ -26,6 +26,7 @@
>  #include "pixel_ops.h"
>  #include "sysbus.h"
>  #include "qdev-addr.h"
> +#include "error.h"
>  
>  #define MAXX 1024
>  #define MAXY 768
> @@ -56,8 +57,10 @@ typedef struct TCXState {
>      uint8_t dac_index, dac_state;
>  } TCXState;
>  
> -static void tcx_screen_dump(void *opaque, const char *filename, bool cswitch);
> -static void tcx24_screen_dump(void *opaque, const char *filename, bool cswitch);
> +static void tcx_screen_dump(void *opaque, const char *filename, bool cswitch,
> +                            Error *errp);
> +static void tcx24_screen_dump(void *opaque, const char *filename, bool cswitch,
> +                              Error *errp);
>  
>  static void tcx_set_dirty(TCXState *s)
>  {
> @@ -574,7 +577,8 @@ static int tcx_init1(SysBusDevice *dev)
>      return 0;
>  }
>  
> -static void tcx_screen_dump(void *opaque, const char *filename, bool cswitch)
> +static void tcx_screen_dump(void *opaque, const char *filename, bool cswitch,
> +                            Error *errp)
>  {
>      TCXState *s = opaque;
>      FILE *f;
> @@ -601,7 +605,8 @@ static void tcx_screen_dump(void *opaque, const char *filename, bool cswitch)
>      return;
>  }
>  
> -static void tcx24_screen_dump(void *opaque, const char *filename, bool cswitch)
> +static void tcx24_screen_dump(void *opaque, const char *filename, bool cswitch,
> +                              Error *errp)
>  {
>      TCXState *s = opaque;
>      FILE *f;
> diff --git a/hw/vga.c b/hw/vga.c
> index 6dc98f6..79c5c38 100644
> --- a/hw/vga.c
> +++ b/hw/vga.c
> @@ -31,6 +31,7 @@
>  #include "qemu-timer.h"
>  #include "xen.h"
>  #include "trace.h"
> +#include "error.h"
>  
>  //#define DEBUG_VGA
>  //#define DEBUG_VGA_MEM
> @@ -163,7 +164,8 @@ static uint32_t expand4[256];
>  static uint16_t expand2[256];
>  static uint8_t expand4to8[16];
>  
> -static void vga_screen_dump(void *opaque, const char *filename, bool cswitch);
> +static void vga_screen_dump(void *opaque, const char *filename, bool cswitch,
> +                            Error **errp);
>  
>  static void vga_update_memory_access(VGACommonState *s)
>  {
> @@ -2409,7 +2411,8 @@ int ppm_save(const char *filename, struct DisplaySurface *ds)
>  
>  /* save the vga display in a PPM image even if no display is
>     available */
> -static void vga_screen_dump(void *opaque, const char *filename, bool cswitch)
> +static void vga_screen_dump(void *opaque, const char *filename, bool cswitch,
> +                            Error **errp)
>  {
>      VGACommonState *s = opaque;
>  
> diff --git a/hw/vmware_vga.c b/hw/vmware_vga.c
> index 142d9f4..6868778 100644
> --- a/hw/vmware_vga.c
> +++ b/hw/vmware_vga.c
> @@ -26,6 +26,7 @@
>  #include "console.h"
>  #include "pci.h"
>  #include "vmware_vga.h"
> +#include "error.h"
>  
>  #undef VERBOSE
>  #define HW_RECT_ACCEL
> @@ -1003,11 +1004,12 @@ static void vmsvga_invalidate_display(void *opaque)
>  
>  /* save the vga display in a PPM image even if no display is
>     available */
> -static void vmsvga_screen_dump(void *opaque, const char *filename, bool cswitch)
> +static void vmsvga_screen_dump(void *opaque, const char *filename, bool cswitch,
> +                               Error **errp)
>  {
>      struct vmsvga_state_s *s = opaque;
>      if (!s->enable) {
> -        s->vga.screen_dump(&s->vga, filename, cswitch);
> +        s->vga.screen_dump(&s->vga, filename, cswitch, errp);
>          return;
>      }
>  
> diff --git a/monitor.c b/monitor.c
> index cbdfbad..79399ab 100644
> --- a/monitor.c
> +++ b/monitor.c
> @@ -895,7 +895,9 @@ static int client_migrate_info(Monitor *mon, const QDict *qdict,
>  
>  static int do_screen_dump(Monitor *mon, const QDict *qdict, QObject **ret_data)
>  {
> -    vga_hw_screen_dump(qdict_get_str(qdict, "filename"));
> +    Error *errp = NULL;
> +
> +    vga_hw_screen_dump(qdict_get_str(qdict, "filename"), &errp);

Better to pass NULL, as it communicates this is not used (yet).

>      return 0;
>  }
>
Alon Levy March 15, 2012, 3:22 p.m. UTC | #2
On Thu, Mar 15, 2012 at 11:54:07AM -0300, Luiz Capitulino wrote:
> On Thu, 15 Mar 2012 00:55:11 +0200
> Alon Levy <alevy@redhat.com> wrote:
> 
> > Signed-off-by: Alon Levy <alevy@redhat.com>
> 
> Please, explain why. More comments at the bottom.

Sure.

> 
> > ---
> >  console.c       |    5 +++--
> >  console.h       |    6 ++++--
> >  hw/blizzard.c   |    3 ++-
> >  hw/g364fb.c     |    4 +++-
> >  hw/omap_lcdc.c  |    4 +++-
> >  hw/qxl.c        |    6 ++++--
> >  hw/tcx.c        |   13 +++++++++----
> >  hw/vga.c        |    7 +++++--
> >  hw/vmware_vga.c |    6 ++++--
> >  monitor.c       |    4 +++-
> >  10 files changed, 40 insertions(+), 18 deletions(-)
> > 
> > diff --git a/console.c b/console.c
> > index 6a463f5..d3fccf3 100644
> > --- a/console.c
> > +++ b/console.c
> > @@ -24,6 +24,7 @@
> >  #include "qemu-common.h"
> >  #include "console.h"
> >  #include "qemu-timer.h"
> > +#include "error.h"
> >  
> >  //#define DEBUG_CONSOLE
> >  #define DEFAULT_BACKSCROLL 512
> > @@ -173,7 +174,7 @@ void vga_hw_invalidate(void)
> >          active_console->hw_invalidate(active_console->hw);
> >  }
> >  
> > -void vga_hw_screen_dump(const char *filename)
> > +void vga_hw_screen_dump(const char *filename, Error **errp)
> >  {
> >      TextConsole *previous_active_console;
> >      bool cswitch;
> > @@ -187,7 +188,7 @@ void vga_hw_screen_dump(const char *filename)
> >          console_select(0);
> >      }
> >      if (consoles[0] && consoles[0]->hw_screen_dump) {
> > -        consoles[0]->hw_screen_dump(consoles[0]->hw, filename, cswitch);
> > +        consoles[0]->hw_screen_dump(consoles[0]->hw, filename, cswitch, errp);
> >      } else {
> >          error_report("screen dump not implemented");
> >      }
> > diff --git a/console.h b/console.h
> > index 4334db5..caf13f5 100644
> > --- a/console.h
> > +++ b/console.h
> > @@ -6,6 +6,7 @@
> >  #include "notify.h"
> >  #include "monitor.h"
> >  #include "trace.h"
> > +#include "error.h"
> >  
> >  /* keyboard/mouse support */
> >  
> > @@ -343,7 +344,8 @@ static inline void console_write_ch(console_ch_t *dest, uint32_t ch)
> >  
> >  typedef void (*vga_hw_update_ptr)(void *);
> >  typedef void (*vga_hw_invalidate_ptr)(void *);
> > -typedef void (*vga_hw_screen_dump_ptr)(void *, const char *, bool cswitch);
> > +typedef void (*vga_hw_screen_dump_ptr)(void *, const char *, bool cswitch,
> > +                                       Error **errp);
> >  typedef void (*vga_hw_text_update_ptr)(void *, console_ch_t *);
> >  
> >  DisplayState *graphic_console_init(vga_hw_update_ptr update,
> > @@ -354,7 +356,7 @@ DisplayState *graphic_console_init(vga_hw_update_ptr update,
> >  
> >  void vga_hw_update(void);
> >  void vga_hw_invalidate(void);
> > -void vga_hw_screen_dump(const char *filename);
> > +void vga_hw_screen_dump(const char *filename, Error **errp);
> >  void vga_hw_text_update(console_ch_t *chardata);
> >  
> >  int is_graphic_console(void);
> > diff --git a/hw/blizzard.c b/hw/blizzard.c
> > index c7d844d..76df78c 100644
> > --- a/hw/blizzard.c
> > +++ b/hw/blizzard.c
> > @@ -23,6 +23,7 @@
> >  #include "devices.h"
> >  #include "vga_int.h"
> >  #include "pixel_ops.h"
> > +#include "error.h"
> >  
> >  typedef void (*blizzard_fn_t)(uint8_t *, const uint8_t *, unsigned int);
> >  
> > @@ -933,7 +934,7 @@ static void blizzard_update_display(void *opaque)
> >  }
> >  
> >  static void blizzard_screen_dump(void *opaque, const char *filename,
> > -                                 bool cswitch)
> > +                                 bool cswitch, Error **errp)
> >  {
> >      BlizzardState *s = (BlizzardState *) opaque;
> >  
> > diff --git a/hw/g364fb.c b/hw/g364fb.c
> > index 3a0b68f..7774d05 100644
> > --- a/hw/g364fb.c
> > +++ b/hw/g364fb.c
> > @@ -22,6 +22,7 @@
> >  #include "pixel_ops.h"
> >  #include "trace.h"
> >  #include "sysbus.h"
> > +#include "error.h"
> >  
> >  typedef struct G364State {
> >      /* hardware */
> > @@ -289,7 +290,8 @@ static void g364fb_reset(G364State *s)
> >      g364fb_invalidate_display(s);
> >  }
> >  
> > -static void g364fb_screen_dump(void *opaque, const char *filename, bool cswitch)
> > +static void g364fb_screen_dump(void *opaque, const char *filename, bool cswitch,
> > +                               Error **errp)
> >  {
> >      G364State *s = opaque;
> >      int y, x;
> > diff --git a/hw/omap_lcdc.c b/hw/omap_lcdc.c
> > index f172093..aec7210 100644
> > --- a/hw/omap_lcdc.c
> > +++ b/hw/omap_lcdc.c
> > @@ -20,6 +20,7 @@
> >  #include "console.h"
> >  #include "omap.h"
> >  #include "framebuffer.h"
> > +#include "error.h"
> >  
> >  struct omap_lcd_panel_s {
> >      MemoryRegion *sysmem;
> > @@ -264,7 +265,8 @@ static int ppm_save(const char *filename, uint8_t *data,
> >      return 0;
> >  }
> >  
> > -static void omap_screen_dump(void *opaque, const char *filename, bool cswitch)
> > +static void omap_screen_dump(void *opaque, const char *filename, bool cswitch,
> > +                             Error **errp)
> >  {
> >      struct omap_lcd_panel_s *omap_lcd = opaque;
> >      if (cswitch) {
> > diff --git a/hw/qxl.c b/hw/qxl.c
> > index e17b0e3..27f27f5 100644
> > --- a/hw/qxl.c
> > +++ b/hw/qxl.c
> > @@ -23,6 +23,7 @@
> >  #include "qemu-queue.h"
> >  #include "monitor.h"
> >  #include "sysemu.h"
> > +#include "error.h"
> >  
> >  #include "qxl.h"
> >  
> > @@ -1492,7 +1493,8 @@ static void qxl_hw_invalidate(void *opaque)
> >      vga->invalidate(vga);
> >  }
> >  
> > -static void qxl_hw_screen_dump(void *opaque, const char *filename, bool cswitch)
> > +static void qxl_hw_screen_dump(void *opaque, const char *filename, bool cswitch,
> > +                               Error **errp)
> >  {
> >      PCIQXLDevice *qxl = opaque;
> >      VGACommonState *vga = &qxl->vga;
> > @@ -1504,7 +1506,7 @@ static void qxl_hw_screen_dump(void *opaque, const char *filename, bool cswitch)
> >          ppm_save(filename, qxl->ssd.ds->surface);
> >          break;
> >      case QXL_MODE_VGA:
> > -        vga->screen_dump(vga, filename, cswitch);
> > +        vga->screen_dump(vga, filename, cswitch, errp);
> >          break;
> >      default:
> >          break;
> > diff --git a/hw/tcx.c b/hw/tcx.c
> > index ac7dcb4..f342a5d 100644
> > --- a/hw/tcx.c
> > +++ b/hw/tcx.c
> > @@ -26,6 +26,7 @@
> >  #include "pixel_ops.h"
> >  #include "sysbus.h"
> >  #include "qdev-addr.h"
> > +#include "error.h"
> >  
> >  #define MAXX 1024
> >  #define MAXY 768
> > @@ -56,8 +57,10 @@ typedef struct TCXState {
> >      uint8_t dac_index, dac_state;
> >  } TCXState;
> >  
> > -static void tcx_screen_dump(void *opaque, const char *filename, bool cswitch);
> > -static void tcx24_screen_dump(void *opaque, const char *filename, bool cswitch);
> > +static void tcx_screen_dump(void *opaque, const char *filename, bool cswitch,
> > +                            Error *errp);
> > +static void tcx24_screen_dump(void *opaque, const char *filename, bool cswitch,
> > +                              Error *errp);
> >  
> >  static void tcx_set_dirty(TCXState *s)
> >  {
> > @@ -574,7 +577,8 @@ static int tcx_init1(SysBusDevice *dev)
> >      return 0;
> >  }
> >  
> > -static void tcx_screen_dump(void *opaque, const char *filename, bool cswitch)
> > +static void tcx_screen_dump(void *opaque, const char *filename, bool cswitch,
> > +                            Error *errp)
> >  {
> >      TCXState *s = opaque;
> >      FILE *f;
> > @@ -601,7 +605,8 @@ static void tcx_screen_dump(void *opaque, const char *filename, bool cswitch)
> >      return;
> >  }
> >  
> > -static void tcx24_screen_dump(void *opaque, const char *filename, bool cswitch)
> > +static void tcx24_screen_dump(void *opaque, const char *filename, bool cswitch,
> > +                              Error *errp)
> >  {
> >      TCXState *s = opaque;
> >      FILE *f;
> > diff --git a/hw/vga.c b/hw/vga.c
> > index 6dc98f6..79c5c38 100644
> > --- a/hw/vga.c
> > +++ b/hw/vga.c
> > @@ -31,6 +31,7 @@
> >  #include "qemu-timer.h"
> >  #include "xen.h"
> >  #include "trace.h"
> > +#include "error.h"
> >  
> >  //#define DEBUG_VGA
> >  //#define DEBUG_VGA_MEM
> > @@ -163,7 +164,8 @@ static uint32_t expand4[256];
> >  static uint16_t expand2[256];
> >  static uint8_t expand4to8[16];
> >  
> > -static void vga_screen_dump(void *opaque, const char *filename, bool cswitch);
> > +static void vga_screen_dump(void *opaque, const char *filename, bool cswitch,
> > +                            Error **errp);
> >  
> >  static void vga_update_memory_access(VGACommonState *s)
> >  {
> > @@ -2409,7 +2411,8 @@ int ppm_save(const char *filename, struct DisplaySurface *ds)
> >  
> >  /* save the vga display in a PPM image even if no display is
> >     available */
> > -static void vga_screen_dump(void *opaque, const char *filename, bool cswitch)
> > +static void vga_screen_dump(void *opaque, const char *filename, bool cswitch,
> > +                            Error **errp)
> >  {
> >      VGACommonState *s = opaque;
> >  
> > diff --git a/hw/vmware_vga.c b/hw/vmware_vga.c
> > index 142d9f4..6868778 100644
> > --- a/hw/vmware_vga.c
> > +++ b/hw/vmware_vga.c
> > @@ -26,6 +26,7 @@
> >  #include "console.h"
> >  #include "pci.h"
> >  #include "vmware_vga.h"
> > +#include "error.h"
> >  
> >  #undef VERBOSE
> >  #define HW_RECT_ACCEL
> > @@ -1003,11 +1004,12 @@ static void vmsvga_invalidate_display(void *opaque)
> >  
> >  /* save the vga display in a PPM image even if no display is
> >     available */
> > -static void vmsvga_screen_dump(void *opaque, const char *filename, bool cswitch)
> > +static void vmsvga_screen_dump(void *opaque, const char *filename, bool cswitch,
> > +                               Error **errp)
> >  {
> >      struct vmsvga_state_s *s = opaque;
> >      if (!s->enable) {
> > -        s->vga.screen_dump(&s->vga, filename, cswitch);
> > +        s->vga.screen_dump(&s->vga, filename, cswitch, errp);
> >          return;
> >      }
> >  
> > diff --git a/monitor.c b/monitor.c
> > index cbdfbad..79399ab 100644
> > --- a/monitor.c
> > +++ b/monitor.c
> > @@ -895,7 +895,9 @@ static int client_migrate_info(Monitor *mon, const QDict *qdict,
> >  
> >  static int do_screen_dump(Monitor *mon, const QDict *qdict, QObject **ret_data)
> >  {
> > -    vga_hw_screen_dump(qdict_get_str(qdict, "filename"));
> > +    Error *errp = NULL;
> > +
> > +    vga_hw_screen_dump(qdict_get_str(qdict, "filename"), &errp);
> 
> Better to pass NULL, as it communicates this is not used (yet).

OK, in that case I'll check that it actually handles that case correctly
(the point of passing a valid pointer was to not worry about that right
now).

> 
> >      return 0;
> >  }
> >  
>
diff mbox

Patch

diff --git a/console.c b/console.c
index 6a463f5..d3fccf3 100644
--- a/console.c
+++ b/console.c
@@ -24,6 +24,7 @@ 
 #include "qemu-common.h"
 #include "console.h"
 #include "qemu-timer.h"
+#include "error.h"
 
 //#define DEBUG_CONSOLE
 #define DEFAULT_BACKSCROLL 512
@@ -173,7 +174,7 @@  void vga_hw_invalidate(void)
         active_console->hw_invalidate(active_console->hw);
 }
 
-void vga_hw_screen_dump(const char *filename)
+void vga_hw_screen_dump(const char *filename, Error **errp)
 {
     TextConsole *previous_active_console;
     bool cswitch;
@@ -187,7 +188,7 @@  void vga_hw_screen_dump(const char *filename)
         console_select(0);
     }
     if (consoles[0] && consoles[0]->hw_screen_dump) {
-        consoles[0]->hw_screen_dump(consoles[0]->hw, filename, cswitch);
+        consoles[0]->hw_screen_dump(consoles[0]->hw, filename, cswitch, errp);
     } else {
         error_report("screen dump not implemented");
     }
diff --git a/console.h b/console.h
index 4334db5..caf13f5 100644
--- a/console.h
+++ b/console.h
@@ -6,6 +6,7 @@ 
 #include "notify.h"
 #include "monitor.h"
 #include "trace.h"
+#include "error.h"
 
 /* keyboard/mouse support */
 
@@ -343,7 +344,8 @@  static inline void console_write_ch(console_ch_t *dest, uint32_t ch)
 
 typedef void (*vga_hw_update_ptr)(void *);
 typedef void (*vga_hw_invalidate_ptr)(void *);
-typedef void (*vga_hw_screen_dump_ptr)(void *, const char *, bool cswitch);
+typedef void (*vga_hw_screen_dump_ptr)(void *, const char *, bool cswitch,
+                                       Error **errp);
 typedef void (*vga_hw_text_update_ptr)(void *, console_ch_t *);
 
 DisplayState *graphic_console_init(vga_hw_update_ptr update,
@@ -354,7 +356,7 @@  DisplayState *graphic_console_init(vga_hw_update_ptr update,
 
 void vga_hw_update(void);
 void vga_hw_invalidate(void);
-void vga_hw_screen_dump(const char *filename);
+void vga_hw_screen_dump(const char *filename, Error **errp);
 void vga_hw_text_update(console_ch_t *chardata);
 
 int is_graphic_console(void);
diff --git a/hw/blizzard.c b/hw/blizzard.c
index c7d844d..76df78c 100644
--- a/hw/blizzard.c
+++ b/hw/blizzard.c
@@ -23,6 +23,7 @@ 
 #include "devices.h"
 #include "vga_int.h"
 #include "pixel_ops.h"
+#include "error.h"
 
 typedef void (*blizzard_fn_t)(uint8_t *, const uint8_t *, unsigned int);
 
@@ -933,7 +934,7 @@  static void blizzard_update_display(void *opaque)
 }
 
 static void blizzard_screen_dump(void *opaque, const char *filename,
-                                 bool cswitch)
+                                 bool cswitch, Error **errp)
 {
     BlizzardState *s = (BlizzardState *) opaque;
 
diff --git a/hw/g364fb.c b/hw/g364fb.c
index 3a0b68f..7774d05 100644
--- a/hw/g364fb.c
+++ b/hw/g364fb.c
@@ -22,6 +22,7 @@ 
 #include "pixel_ops.h"
 #include "trace.h"
 #include "sysbus.h"
+#include "error.h"
 
 typedef struct G364State {
     /* hardware */
@@ -289,7 +290,8 @@  static void g364fb_reset(G364State *s)
     g364fb_invalidate_display(s);
 }
 
-static void g364fb_screen_dump(void *opaque, const char *filename, bool cswitch)
+static void g364fb_screen_dump(void *opaque, const char *filename, bool cswitch,
+                               Error **errp)
 {
     G364State *s = opaque;
     int y, x;
diff --git a/hw/omap_lcdc.c b/hw/omap_lcdc.c
index f172093..aec7210 100644
--- a/hw/omap_lcdc.c
+++ b/hw/omap_lcdc.c
@@ -20,6 +20,7 @@ 
 #include "console.h"
 #include "omap.h"
 #include "framebuffer.h"
+#include "error.h"
 
 struct omap_lcd_panel_s {
     MemoryRegion *sysmem;
@@ -264,7 +265,8 @@  static int ppm_save(const char *filename, uint8_t *data,
     return 0;
 }
 
-static void omap_screen_dump(void *opaque, const char *filename, bool cswitch)
+static void omap_screen_dump(void *opaque, const char *filename, bool cswitch,
+                             Error **errp)
 {
     struct omap_lcd_panel_s *omap_lcd = opaque;
     if (cswitch) {
diff --git a/hw/qxl.c b/hw/qxl.c
index e17b0e3..27f27f5 100644
--- a/hw/qxl.c
+++ b/hw/qxl.c
@@ -23,6 +23,7 @@ 
 #include "qemu-queue.h"
 #include "monitor.h"
 #include "sysemu.h"
+#include "error.h"
 
 #include "qxl.h"
 
@@ -1492,7 +1493,8 @@  static void qxl_hw_invalidate(void *opaque)
     vga->invalidate(vga);
 }
 
-static void qxl_hw_screen_dump(void *opaque, const char *filename, bool cswitch)
+static void qxl_hw_screen_dump(void *opaque, const char *filename, bool cswitch,
+                               Error **errp)
 {
     PCIQXLDevice *qxl = opaque;
     VGACommonState *vga = &qxl->vga;
@@ -1504,7 +1506,7 @@  static void qxl_hw_screen_dump(void *opaque, const char *filename, bool cswitch)
         ppm_save(filename, qxl->ssd.ds->surface);
         break;
     case QXL_MODE_VGA:
-        vga->screen_dump(vga, filename, cswitch);
+        vga->screen_dump(vga, filename, cswitch, errp);
         break;
     default:
         break;
diff --git a/hw/tcx.c b/hw/tcx.c
index ac7dcb4..f342a5d 100644
--- a/hw/tcx.c
+++ b/hw/tcx.c
@@ -26,6 +26,7 @@ 
 #include "pixel_ops.h"
 #include "sysbus.h"
 #include "qdev-addr.h"
+#include "error.h"
 
 #define MAXX 1024
 #define MAXY 768
@@ -56,8 +57,10 @@  typedef struct TCXState {
     uint8_t dac_index, dac_state;
 } TCXState;
 
-static void tcx_screen_dump(void *opaque, const char *filename, bool cswitch);
-static void tcx24_screen_dump(void *opaque, const char *filename, bool cswitch);
+static void tcx_screen_dump(void *opaque, const char *filename, bool cswitch,
+                            Error *errp);
+static void tcx24_screen_dump(void *opaque, const char *filename, bool cswitch,
+                              Error *errp);
 
 static void tcx_set_dirty(TCXState *s)
 {
@@ -574,7 +577,8 @@  static int tcx_init1(SysBusDevice *dev)
     return 0;
 }
 
-static void tcx_screen_dump(void *opaque, const char *filename, bool cswitch)
+static void tcx_screen_dump(void *opaque, const char *filename, bool cswitch,
+                            Error *errp)
 {
     TCXState *s = opaque;
     FILE *f;
@@ -601,7 +605,8 @@  static void tcx_screen_dump(void *opaque, const char *filename, bool cswitch)
     return;
 }
 
-static void tcx24_screen_dump(void *opaque, const char *filename, bool cswitch)
+static void tcx24_screen_dump(void *opaque, const char *filename, bool cswitch,
+                              Error *errp)
 {
     TCXState *s = opaque;
     FILE *f;
diff --git a/hw/vga.c b/hw/vga.c
index 6dc98f6..79c5c38 100644
--- a/hw/vga.c
+++ b/hw/vga.c
@@ -31,6 +31,7 @@ 
 #include "qemu-timer.h"
 #include "xen.h"
 #include "trace.h"
+#include "error.h"
 
 //#define DEBUG_VGA
 //#define DEBUG_VGA_MEM
@@ -163,7 +164,8 @@  static uint32_t expand4[256];
 static uint16_t expand2[256];
 static uint8_t expand4to8[16];
 
-static void vga_screen_dump(void *opaque, const char *filename, bool cswitch);
+static void vga_screen_dump(void *opaque, const char *filename, bool cswitch,
+                            Error **errp);
 
 static void vga_update_memory_access(VGACommonState *s)
 {
@@ -2409,7 +2411,8 @@  int ppm_save(const char *filename, struct DisplaySurface *ds)
 
 /* save the vga display in a PPM image even if no display is
    available */
-static void vga_screen_dump(void *opaque, const char *filename, bool cswitch)
+static void vga_screen_dump(void *opaque, const char *filename, bool cswitch,
+                            Error **errp)
 {
     VGACommonState *s = opaque;
 
diff --git a/hw/vmware_vga.c b/hw/vmware_vga.c
index 142d9f4..6868778 100644
--- a/hw/vmware_vga.c
+++ b/hw/vmware_vga.c
@@ -26,6 +26,7 @@ 
 #include "console.h"
 #include "pci.h"
 #include "vmware_vga.h"
+#include "error.h"
 
 #undef VERBOSE
 #define HW_RECT_ACCEL
@@ -1003,11 +1004,12 @@  static void vmsvga_invalidate_display(void *opaque)
 
 /* save the vga display in a PPM image even if no display is
    available */
-static void vmsvga_screen_dump(void *opaque, const char *filename, bool cswitch)
+static void vmsvga_screen_dump(void *opaque, const char *filename, bool cswitch,
+                               Error **errp)
 {
     struct vmsvga_state_s *s = opaque;
     if (!s->enable) {
-        s->vga.screen_dump(&s->vga, filename, cswitch);
+        s->vga.screen_dump(&s->vga, filename, cswitch, errp);
         return;
     }
 
diff --git a/monitor.c b/monitor.c
index cbdfbad..79399ab 100644
--- a/monitor.c
+++ b/monitor.c
@@ -895,7 +895,9 @@  static int client_migrate_info(Monitor *mon, const QDict *qdict,
 
 static int do_screen_dump(Monitor *mon, const QDict *qdict, QObject **ret_data)
 {
-    vga_hw_screen_dump(qdict_get_str(qdict, "filename"));
+    Error *errp = NULL;
+
+    vga_hw_screen_dump(qdict_get_str(qdict, "filename"), &errp);
     return 0;
 }