[Spice-commits] Branch '0.10' - 7 commits - server/mjpeg_encoder.c server/mjpeg_encoder.h server/red_memslots.c server/red_memslots.h server/reds.c server/red_worker.c

Alon Levy alon at kemper.freedesktop.org
Mon May 14 01:05:53 PDT 2012


 server/mjpeg_encoder.c |   13 ++++---------
 server/mjpeg_encoder.h |    5 +++++
 server/red_memslots.c  |   29 +++++++++--------------------
 server/red_memslots.h  |   13 ++++---------
 server/red_worker.c    |    3 +--
 server/reds.c          |    1 +
 6 files changed, 24 insertions(+), 40 deletions(-)

New commits:
commit ca5ed4619244cca6eeaea571af824a44f771d383
Author: Yonit Halperin <yhalperi at redhat.com>
Date:   Thu May 10 14:01:39 2012 +0300

    server/mjpeg_encoder: fix wrong size assigned to dest_len
    
    It should have been the allocated size and not the occupied one.
    This led to a lot of unnecessary allocations and deallocations.
    (cherry picked from commit c211774422455802299545b19ffdffd9496fdc31)

diff --git a/server/mjpeg_encoder.c b/server/mjpeg_encoder.c
index 74062f5..42fe352 100644
--- a/server/mjpeg_encoder.c
+++ b/server/mjpeg_encoder.c
@@ -144,7 +144,7 @@ static void term_mem_destination(j_compress_ptr cinfo)
   mem_destination_mgr *dest = (mem_destination_mgr *) cinfo->dest;
 
   *dest->outbuffer = dest->buffer;
-  *dest->outsize = dest->bufsize - dest->pub.free_in_buffer;
+  *dest->outsize = dest->bufsize;
 }
 
 /*
commit a3c4dc8f36e65a49a7c5ccf549c83af90a0d2047
Author: Yonit Halperin <yhalperi at redhat.com>
Date:   Thu May 10 12:26:01 2012 +0300

    server/mjpeg_encoder: Fix memory leak for the inital output buffer given for each frame
    (cherry picked from commit fecc1e3d4d3d93ade71a318ad655e85974638162)

diff --git a/server/mjpeg_encoder.c b/server/mjpeg_encoder.c
index 6b68549..74062f5 100644
--- a/server/mjpeg_encoder.c
+++ b/server/mjpeg_encoder.c
@@ -105,7 +105,6 @@ typedef struct {
 
   unsigned char ** outbuffer;	/* target buffer */
   size_t * outsize;
-  unsigned char * newbuffer;	/* newly allocated buffer */
   uint8_t * buffer;		/* start of buffer */
   size_t bufsize;
 } mem_destination_mgr;
@@ -129,9 +128,7 @@ static boolean empty_mem_output_buffer(j_compress_ptr cinfo)
 
   memcpy(nextbuffer, dest->buffer, dest->bufsize);
 
-  free(dest->newbuffer);
-
-  dest->newbuffer = nextbuffer;
+  free(dest->buffer);
 
   dest->pub.next_output_byte = nextbuffer + dest->bufsize;
   dest->pub.free_in_buffer = dest->bufsize;
@@ -184,12 +181,10 @@ spice_jpeg_mem_dest(j_compress_ptr cinfo,
   dest->pub.term_destination = term_mem_destination;
   dest->outbuffer = outbuffer;
   dest->outsize = outsize;
-  dest->newbuffer = NULL;
-
   if (*outbuffer == NULL || *outsize == 0) {
     /* Allocate initial buffer */
-    dest->newbuffer = *outbuffer = malloc(OUTPUT_BUF_SIZE);
-    if (dest->newbuffer == NULL)
+    *outbuffer = malloc(OUTPUT_BUF_SIZE);
+    if (*outbuffer == NULL)
       ERREXIT1(cinfo, JERR_OUT_OF_MEMORY, 10);
     *outsize = OUTPUT_BUF_SIZE;
   }
diff --git a/server/mjpeg_encoder.h b/server/mjpeg_encoder.h
index c43827f..62ef207 100644
--- a/server/mjpeg_encoder.h
+++ b/server/mjpeg_encoder.h
@@ -27,6 +27,11 @@ MJpegEncoder *mjpeg_encoder_new(int width, int height);
 void mjpeg_encoder_destroy(MJpegEncoder *encoder);
 
 uint8_t mjpeg_encoder_get_bytes_per_pixel(MJpegEncoder *encoder);
+
+/*
+ * *dest must be either NULL or allocated by malloc, since it might be freed
+ * during the encoding, if its size is too small.
+ */
 int mjpeg_encoder_start_frame(MJpegEncoder *encoder, SpiceBitmapFmt format,
                               uint8_t **dest, size_t *dest_len);
 int mjpeg_encoder_encode_scanline(MJpegEncoder *encoder, uint8_t *src_pixels,
commit 63e3456e12f85a3c5d23e9d00d9dbd77232ee876
Author: Alon Levy <alevy at redhat.com>
Date:   Mon May 7 14:14:37 2012 +0300

    server/reds: add "usbredir" to recognized channel names
    
    RHBZ: 819484
    
    Signed-off-by: Alon Levy <alevy at redhat.com>
    (cherry picked from commit ce8e865cf1fcd7ee6ef2e6f8b33506df31e3345e)

diff --git a/server/reds.c b/server/reds.c
index 5f39e4f..8cc87c2 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -3898,6 +3898,7 @@ SPICE_GNUC_VISIBLE int spice_server_set_channel_security(SpiceServer *s, const c
 #ifdef USE_SMARTCARD
         [ SPICE_CHANNEL_SMARTCARD] = "smartcard",
 #endif
+        [ SPICE_CHANNEL_USBREDIR ] = "usbredir",
     };
     int i;
 
commit 3d0448314812457e027e513c2d0dc163c421914a
Author: Alon Levy <alevy at redhat.com>
Date:   Tue Mar 20 19:00:49 2012 +0200

    server/red_memslots: don't assume 64 bit environment
    
    assumption that unsigned long == QXLPHYSICAL causes get_virt to compute
    the wrong slot. Fix by replacing addr variables to be of type
    QXLPHYSICAL.

diff --git a/server/red_memslots.c b/server/red_memslots.c
index 8c8f3cc..249b241 100644
--- a/server/red_memslots.c
+++ b/server/red_memslots.c
@@ -19,10 +19,12 @@
 #include <config.h>
 #endif
 
+#include <inttypes.h>
+
 #include "red_common.h"
 #include "red_memslots.h"
 
-static unsigned long __get_clean_virt(RedMemSlotInfo *info, unsigned long addr)
+static unsigned long __get_clean_virt(RedMemSlotInfo *info, QXLPHYSICAL addr)
 {
     return addr & info->memslot_clean_virt_mask;
 }
@@ -46,7 +48,7 @@ static void print_memslots(RedMemSlotInfo *info)
     }
 }
 
-unsigned long get_virt_delta(RedMemSlotInfo *info, unsigned long addr, int group_id)
+unsigned long get_virt_delta(RedMemSlotInfo *info, QXLPHYSICAL addr, int group_id)
 {
     MemSlot *slot;
     int slot_id;
@@ -107,7 +109,7 @@ unsigned long get_virt(RedMemSlotInfo *info, QXLPHYSICAL addr, uint32_t add_size
     slot_id = get_memslot_id(info, addr);
     if (slot_id > info->num_memslots) {
         print_memslots(info);
-        PANIC("slot_id too big, addr=%lx", addr);
+        PANIC("slot_id too big, addr=%" PRIx64, addr);
     }
 
     slot = &info->mem_slots[group_id][slot_id];
@@ -165,10 +167,11 @@ void red_memslot_info_init(RedMemSlotInfo *info,
         info->mem_slots[i] = spice_new0(MemSlot, num_slots);
     }
 
+    /* TODO: use QXLPHYSICAL_BITS */
     info->memslot_id_shift = 64 - info->mem_slot_bits;
     info->memslot_gen_shift = 64 - (info->mem_slot_bits + info->generation_bits);
-    info->memslot_gen_mask = ~((unsigned long)-1 << info->generation_bits);
-    info->memslot_clean_virt_mask = (((unsigned long)(-1)) >>
+    info->memslot_gen_mask = ~((QXLPHYSICAL)-1 << info->generation_bits);
+    info->memslot_clean_virt_mask = (((QXLPHYSICAL)(-1)) >>
                                        (info->mem_slot_bits + info->generation_bits));
 }
 
diff --git a/server/red_memslots.h b/server/red_memslots.h
index 75754d0..d50587f 100644
--- a/server/red_memslots.h
+++ b/server/red_memslots.h
@@ -53,10 +53,10 @@ static inline int get_generation(RedMemSlotInfo *info, uint64_t addr)
     return (addr >> info->memslot_gen_shift) & info->memslot_gen_mask;
 }
 
-unsigned long get_virt_delta(RedMemSlotInfo *info, unsigned long addr, int group_id);
+unsigned long get_virt_delta(RedMemSlotInfo *info, QXLPHYSICAL addr, int group_id);
 void validate_virt(RedMemSlotInfo *info, unsigned long virt, int slot_id,
                    uint32_t add_size, uint32_t group_id);
-unsigned long get_virt(RedMemSlotInfo *info, unsigned long addr, uint32_t add_size,
+unsigned long get_virt(RedMemSlotInfo *info, QXLPHYSICAL addr, uint32_t add_size,
                        int group_id);
 
 void *validate_chunk (RedMemSlotInfo *info, QXLPHYSICAL data, uint32_t group_id, uint32_t *data_size_out, QXLPHYSICAL *next_out);
commit f13ca1277418ed91d009a8db0faf36fbd1c0a7e0
Author: Alon Levy <alevy at redhat.com>
Date:   Tue Mar 20 18:59:21 2012 +0200

    server/red_worker: fix for case where ASSERT is compiled out

diff --git a/server/red_worker.c b/server/red_worker.c
index 80fa825..8a4315d 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -8379,9 +8379,8 @@ static void red_display_marshall_stream_clip(RedChannelClient *rcc,
 {
     DisplayChannelClient *dcc = RCC_TO_DCC(rcc);
     StreamAgent *agent = item->stream_agent;
-    Stream *stream = agent->stream;
 
-    ASSERT(stream);
+    ASSERT(agent->stream);
 
     red_channel_client_init_send_data(rcc, SPICE_MSG_DISPLAY_STREAM_CLIP, &item->base);
     SpiceMsgDisplayStreamClip stream_clip;
commit 9ee43c37ce8dc028695d81728ac6da88bb79b653
Author: Alon Levy <alevy at redhat.com>
Date:   Wed Mar 21 17:57:32 2012 +0200

    server/red_memslots: use QXLPHYSICAL for addresses
    
    Cannot assume unsigned long == QXLPHYSICAL, not true for 32 bit
    architectures.

diff --git a/server/red_memslots.c b/server/red_memslots.c
index 5057218..8c8f3cc 100644
--- a/server/red_memslots.c
+++ b/server/red_memslots.c
@@ -91,7 +91,7 @@ void validate_virt(RedMemSlotInfo *info, unsigned long virt, int slot_id,
     }
 }
 
-unsigned long get_virt(RedMemSlotInfo *info, unsigned long addr, uint32_t add_size,
+unsigned long get_virt(RedMemSlotInfo *info, QXLPHYSICAL addr, uint32_t add_size,
                        int group_id)
 {
     int slot_id;
diff --git a/server/red_memslots.h b/server/red_memslots.h
index 7aea0a3..75754d0 100644
--- a/server/red_memslots.h
+++ b/server/red_memslots.h
@@ -43,12 +43,12 @@ typedef struct RedMemSlotInfo {
     unsigned long memslot_clean_virt_mask;
 } RedMemSlotInfo;
 
-static inline int get_memslot_id(RedMemSlotInfo *info, unsigned long addr)
+static inline int get_memslot_id(RedMemSlotInfo *info, uint64_t addr)
 {
     return addr >> info->memslot_id_shift;
 }
 
-static inline int get_generation(RedMemSlotInfo *info, unsigned long addr)
+static inline int get_generation(RedMemSlotInfo *info, uint64_t addr)
 {
     return (addr >> info->memslot_gen_shift) & info->memslot_gen_mask;
 }
commit c90d42e2acb6655508e37d42925dc6062d75f479
Author: Alon Levy <alevy at redhat.com>
Date:   Wed Mar 21 17:55:23 2012 +0200

    server/red_memslots: drop two unused functions
    
    cb_get_virt and cb_validate_virt have disappeared a long time ago,
    not needed since:
    
    commit 5ac88aa79fa6445f96e5419d8bf4fce81da63b90
    Author: Gerd Hoffmann <kraxel at redhat.com>
    Date:   Thu Jul 1 17:55:33 2010 +0200
    
        Properly parse QXLImage to the new-world SpiceImage
    
        SpiceImage now replaces RedImage and has all image types in it.
        All image data are now chunked (and as such not copied when demarshalling).

diff --git a/server/red_memslots.c b/server/red_memslots.c
index d98f38c..5057218 100644
--- a/server/red_memslots.c
+++ b/server/red_memslots.c
@@ -127,20 +127,6 @@ unsigned long get_virt(RedMemSlotInfo *info, unsigned long addr, uint32_t add_si
     return h_virt;
 }
 
-void *cb_get_virt(void *opaque, unsigned long addr,
-                  uint32_t add_size, uint32_t group_id)
-{
-    return (void *)get_virt((RedMemSlotInfo *)opaque, addr, add_size, group_id);
-}
-
-void cb_validate_virt(void *opaque,
-                      unsigned long virt, unsigned long from_addr,
-                      uint32_t add_size, uint32_t group_id)
-{
-    int slot_id = get_memslot_id((RedMemSlotInfo *)opaque, from_addr);
-    validate_virt((RedMemSlotInfo *)opaque, virt, slot_id, add_size, group_id);
-}
-
 void *validate_chunk (RedMemSlotInfo *info, QXLPHYSICAL data, uint32_t group_id, uint32_t *data_size_out, QXLPHYSICAL *next_out)
 {
     QXLDataChunk *chunk;
diff --git a/server/red_memslots.h b/server/red_memslots.h
index 18d5208..7aea0a3 100644
--- a/server/red_memslots.h
+++ b/server/red_memslots.h
@@ -60,11 +60,6 @@ unsigned long get_virt(RedMemSlotInfo *info, unsigned long addr, uint32_t add_si
                        int group_id);
 
 void *validate_chunk (RedMemSlotInfo *info, QXLPHYSICAL data, uint32_t group_id, uint32_t *data_size_out, QXLPHYSICAL *next_out);
-void *cb_get_virt(void *opaque, unsigned long addr,
-                  uint32_t add_size, uint32_t group_id);
-void cb_validate_virt(void *opaque,
-                      unsigned long virt, unsigned long from_addr,
-                      uint32_t add_size, uint32_t group_id);
 void red_memslot_info_init(RedMemSlotInfo *info,
                            uint32_t num_groups, uint32_t num_slots,
                            uint8_t generation_bits,


More information about the Spice-commits mailing list