qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Luiz Capitulino <lcapitulino@redhat.com>
To: Alon Levy <alevy@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v3 5/5] vga: ppm_save(): Return error on failure
Date: Fri, 23 Mar 2012 11:27:02 -0300	[thread overview]
Message-ID: <20120323112702.7550b87e@doriath.home> (raw)
In-Reply-To: <1332095353-19120-6-git-send-email-alevy@redhat.com>

On Sun, 18 Mar 2012 19:29:13 +0100
Alon Levy <alevy@redhat.com> wrote:

> From: Luiz Capitulino <lcapitulino@redhat.com>
> 
> This makes all devices using ppm_save() return an error appropriately
> when the screendump command fails.
> 
> Based on a code by Anthony Liguori.
> 
> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
> Signed-off-by: Alon Levy <alevy@redhat.com>
> ---
>  hw/blizzard.c   |    2 +-
>  hw/qxl.c        |    2 +-
>  hw/vga.c        |    8 +++++---
>  hw/vga_int.h    |    3 ++-
>  hw/vmware_vga.c |    2 +-
>  5 files changed, 10 insertions(+), 7 deletions(-)
> 
> diff --git a/hw/blizzard.c b/hw/blizzard.c
> index 76df78c..29e5ae6 100644
> --- a/hw/blizzard.c
> +++ b/hw/blizzard.c
> @@ -942,7 +942,7 @@ static void blizzard_screen_dump(void *opaque, const char *filename,
>          blizzard_update_display(opaque);
>      }
>      if (s && ds_get_data(s->state))
> -        ppm_save(filename, s->state->surface);
> +        ppm_save(filename, s->state->surface, errp);
>  }
>  
>  #define DEPTH 8
> diff --git a/hw/qxl.c b/hw/qxl.c
> index 27f27f5..aa68612 100644
> --- a/hw/qxl.c
> +++ b/hw/qxl.c
> @@ -1503,7 +1503,7 @@ static void qxl_hw_screen_dump(void *opaque, const char *filename, bool cswitch,
>      case QXL_MODE_COMPAT:
>      case QXL_MODE_NATIVE:
>          qxl_render_update(qxl);
> -        ppm_save(filename, qxl->ssd.ds->surface);
> +        ppm_save(filename, qxl->ssd.ds->surface, errp);
>          break;
>      case QXL_MODE_VGA:
>          vga->screen_dump(vga, filename, cswitch, errp);
> diff --git a/hw/vga.c b/hw/vga.c
> index 79c5c38..80e6dca 100644
> --- a/hw/vga.c
> +++ b/hw/vga.c
> @@ -2365,7 +2365,7 @@ void vga_init_vbe(VGACommonState *s, MemoryRegion *system_memory)
>  /********************************************************/
>  /* vga screen dump */
>  
> -int ppm_save(const char *filename, struct DisplaySurface *ds)
> +int ppm_save(const char *filename, struct DisplaySurface *ds, Error **errp)
>  {
>      FILE *f;
>      uint8_t *d, *d1;
> @@ -2377,8 +2377,10 @@ int ppm_save(const char *filename, struct DisplaySurface *ds)
>  
>      trace_ppm_save(filename, ds);
>      f = fopen(filename, "wb");

What I suggested to you was calling qemu_fopen_err() instead of fopen().

> -    if (!f)
> +    if (!f) {
> +        error_set_file_open_failed(errp, filename, errno);

Does this even compile?

Also note that there are device models that don't use ppm_save(), they have to
be converted too.

>          return -1;
> +    }
>      fprintf(f, "P6\n%d %d\n%d\n",
>              ds->width, ds->height, 255);
>      linebuf = g_malloc(ds->width * 3);
> @@ -2420,5 +2422,5 @@ static void vga_screen_dump(void *opaque, const char *filename, bool cswitch,
>          vga_invalidate_display(s);
>          vga_hw_update();
>      }
> -    ppm_save(filename, s->ds->surface);
> +    ppm_save(filename, s->ds->surface, errp);
>  }
> diff --git a/hw/vga_int.h b/hw/vga_int.h
> index 7685b2b..63078ba 100644
> --- a/hw/vga_int.h
> +++ b/hw/vga_int.h
> @@ -24,6 +24,7 @@
>  
>  #include <hw/hw.h>
>  #include "memory.h"
> +#include "error.h"
>  
>  #define ST01_V_RETRACE      0x08
>  #define ST01_DISP_ENABLE    0x01
> @@ -200,7 +201,7 @@ void vga_ioport_write(void *opaque, uint32_t addr, uint32_t val);
>  uint32_t vga_mem_readb(VGACommonState *s, target_phys_addr_t addr);
>  void vga_mem_writeb(VGACommonState *s, target_phys_addr_t addr, uint32_t val);
>  void vga_invalidate_scanlines(VGACommonState *s, int y1, int y2);
> -int ppm_save(const char *filename, struct DisplaySurface *ds);
> +int ppm_save(const char *filename, struct DisplaySurface *ds, Error **errp);
>  
>  int vga_ioport_invalid(VGACommonState *s, uint32_t addr);
>  void vga_init_vbe(VGACommonState *s, MemoryRegion *address_space);
> diff --git a/hw/vmware_vga.c b/hw/vmware_vga.c
> index 6868778..0769652 100644
> --- a/hw/vmware_vga.c
> +++ b/hw/vmware_vga.c
> @@ -1016,7 +1016,7 @@ static void vmsvga_screen_dump(void *opaque, const char *filename, bool cswitch,
>      if (s->depth == 32) {
>          DisplaySurface *ds = qemu_create_displaysurface_from(s->width,
>                  s->height, 32, ds_get_linesize(s->vga.ds), s->vga.vram_ptr);
> -        ppm_save(filename, ds);
> +        ppm_save(filename, ds, errp);
>          g_free(ds);
>      }
>  }

  reply	other threads:[~2012-03-23 14:27 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-14 22:55 [Qemu-devel] [PATCH v2 0/5] screendump qapi convertion Alon Levy
2012-03-14 22:55 ` [Qemu-devel] [PATCH v2 1/5] error: add error_set_file_open_failed Alon Levy
2012-03-15 14:52   ` Luiz Capitulino
2012-03-15 15:21     ` Alon Levy
2012-03-15 16:00       ` Luiz Capitulino
2012-03-14 22:55 ` [Qemu-devel] [PATCH v2 2/5] vga_hw_screen_dump: add Error** param Alon Levy
2012-03-15 14:54   ` Luiz Capitulino
2012-03-15 15:22     ` Alon Levy
2012-03-14 22:55 ` [Qemu-devel] [PATCH v2 3/5] qapi: convert screendump Alon Levy
2012-03-15 14:55   ` Luiz Capitulino
2012-03-15 15:23     ` Alon Levy
2012-03-14 22:55 ` [Qemu-devel] [PATCH v2 4/5] vga: ppm_save(): Return error on failure Alon Levy
2012-03-14 22:55 ` [Qemu-devel] [PATCH v2 5/5] blockdev: use error_set_file_open_failed Alon Levy
2012-03-15 14:56   ` Luiz Capitulino
2012-03-15 15:23     ` Alon Levy
2012-03-18 18:29 ` [Qemu-devel] [PATCH v3 0/5] screendump qapi convertion Alon Levy
2012-03-18 18:29   ` [Qemu-devel] [PATCH v3 1/5] qerror: add error codes for fopen failure Alon Levy
2012-03-23 14:21     ` Luiz Capitulino
2012-03-23 19:53       ` Alon Levy
2012-03-23 20:48         ` Luiz Capitulino
2012-03-26 18:44       ` Alon Levy
2012-03-26 18:51       ` Alon Levy
2012-03-18 18:29   ` [Qemu-devel] [PATCH v3 2/5] add qemu_fopen_err Alon Levy
2012-03-23 14:22     ` Luiz Capitulino
2012-03-23 19:55       ` Alon Levy
2012-03-18 18:29   ` [Qemu-devel] [PATCH v3 3/5] vga_hw_screen_dump: add Error** param Alon Levy
2012-03-18 18:29   ` [Qemu-devel] [PATCH v3 4/5] qapi: convert screendump Alon Levy
2012-03-23 14:25     ` Luiz Capitulino
2012-03-18 18:29   ` [Qemu-devel] [PATCH v3 5/5] vga: ppm_save(): Return error on failure Alon Levy
2012-03-23 14:27     ` Luiz Capitulino [this message]
2012-03-23 19:54       ` Alon Levy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120323112702.7550b87e@doriath.home \
    --to=lcapitulino@redhat.com \
    --cc=alevy@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).