[Spice-devel] [PATCH spice-server] Attempt to create bitmap debug directory

Frediano Ziglio fziglio at redhat.com
Fri Apr 7 11:11:42 UTC 2017


ping

> > 
> > > 
> > > What if it cannot create - no permissions. I think it can happen, for
> > > instance I am almost always running qemu as a normal user.
> > > 
> > > Probably checking the return value may be enough
> > > 
> > > Pavel
> > > 
> > 
> > Is in /tmp so should be writeable by everybody.
> > If not will crash... like currently does.. so no regressions :-)
> > The test should be done after the open... yes, sounds reasonable
> > 
> 
> There's already
> 
>     if (!f) {
>         spice_error("Error creating bmp");
>         return;
>     }
> 
> so this is making Qemu to exit...
> 
> > Note that this is disabled by defaults as create lot of images in
> > the directory and useful only for debugging.
> > 
> > Frediano
> > 
> > > On Fri, 2017-03-24 at 12:11 +0000, Frediano Ziglio wrote:
> > > > The DUMP_BITMAP compile option enable some debugging code to
> > > > output image bitmaps in a subdirectory of /tmp.
> > > > However if this directory does not exists the server will crash
> > > > as not able to create a file in it.
> > > > Try to create directory before creating the file.
> > > > 
> > > > Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
> > > > ---
> > > >  server/spice-bitmap-utils.c | 4 ++++
> > > >  1 file changed, 4 insertions(+)
> > > > 
> > > > diff --git a/server/spice-bitmap-utils.c b/server/spice-bitmap-
> > > > utils.c
> > > > index 439f05d..09c081d 100644
> > > > --- a/server/spice-bitmap-utils.c
> > > > +++ b/server/spice-bitmap-utils.c
> > > > @@ -18,6 +18,9 @@
> > > >  #ifdef HAVE_CONFIG_H
> > > >  #include <config.h>
> > > >  #endif
> > > > +
> > > > +#include <sys/stat.h>
> > > > +
> > > >  #include "spice-bitmap-utils.h"
> > > >  
> > > >  #define RED_BITMAP_UTILS_RGB16
> > > > @@ -252,6 +255,7 @@ void dump_bitmap(SpiceBitmap *bitmap)
> > > >      file_size = bitmap_data_offset + (bitmap->y * row_size);
> > > >  
> > > >      id = ++file_id;
> > > > +    mkdir(RAM_PATH, 0755);
> > > >      sprintf(file_str, "%s/%u.bmp", RAM_PATH, id);
> > > >  
> > > >      f = fopen(file_str, "wb");
> > > 


More information about the Spice-devel mailing list