console: switch ppm_save to qemu_open

... so it works with fdset.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
This commit is contained in:
Gerd Hoffmann 2013-04-23 13:26:59 +02:00 committed by Anthony Liguori
parent 14a936490b
commit cdd5b93757

View File

@ -269,18 +269,20 @@ static void ppm_save(const char *filename, struct DisplaySurface *ds,
{ {
int width = pixman_image_get_width(ds->image); int width = pixman_image_get_width(ds->image);
int height = pixman_image_get_height(ds->image); int height = pixman_image_get_height(ds->image);
int fd;
FILE *f; FILE *f;
int y; int y;
int ret; int ret;
pixman_image_t *linebuf; pixman_image_t *linebuf;
trace_ppm_save(filename, ds); trace_ppm_save(filename, ds);
f = fopen(filename, "wb"); fd = qemu_open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0666);
if (!f) { if (fd == -1) {
error_setg(errp, "failed to open file '%s': %s", filename, error_setg(errp, "failed to open file '%s': %s", filename,
strerror(errno)); strerror(errno));
return; return;
} }
f = fdopen(fd, "wb");
ret = fprintf(f, "P6\n%d %d\n%d\n", width, height, 255); ret = fprintf(f, "P6\n%d %d\n%d\n", width, height, 255);
if (ret < 0) { if (ret < 0) {
linebuf = NULL; linebuf = NULL;