[Spice-commits] Branch '0.8' - 9 commits - configure.ac NEWS spice/controller_prot.h spice/enums.h spice/foreign_menu_prot.h spice/protocol.h spice/qxl_dev.h

Alon Levy alon at kemper.freedesktop.org
Mon Jul 18 01:42:37 PDT 2011


 NEWS                      |    7 ++
 configure.ac              |    2 
 spice/controller_prot.h   |   20 ++----
 spice/enums.h             |  145 +++++++++++++++++++++++-----------------------
 spice/foreign_menu_prot.h |   24 +++----
 spice/protocol.h          |    2 
 spice/qxl_dev.h           |   19 +++++-
 7 files changed, 121 insertions(+), 98 deletions(-)

New commits:
commit 771f21b6c995de63cc6d7da0b5b696ac37352b64
Author: Alon Levy <alevy at redhat.com>
Date:   Thu Jul 14 13:04:30 2011 +0300

    Release 0.8.1
    
    For qxl_dev.h changes.

diff --git a/NEWS b/NEWS
index 6903e25..f238abc 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,10 @@
+Major changes in 0.8.1
+======================
+* Add support for volume change
+* Add support for async guest io writes and interrupt
+* Add support for suspend related guest io writes
+* Add support for interrupt indicating guest bug
+
 Major changes in 0.8.0
 ======================
 * Add support for different clipboards (selections) to vd_agent copy paste
diff --git a/configure.ac b/configure.ac
index 72278e9..989cb00 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2,7 +2,7 @@ AC_PREREQ([2.57])
 
 m4_define([SPICE_MAJOR], 0)
 m4_define([SPICE_MINOR], 8)
-m4_define([SPICE_MICRO], 0)
+m4_define([SPICE_MICRO], 1)
 
 AC_INIT(spice-protocol, [SPICE_MAJOR.SPICE_MINOR.SPICE_MICRO], [], spice-protocol)
 
commit 156490faa13f1ad95bf7b3af4c22449748505b09
Author: Alon Levy <alevy at redhat.com>
Date:   Fri Jun 24 12:47:23 2011 +0200

    qxl_dev: add third revision V10
    
    The driver will check for this revision or higher to know that the device
    supports async io, the two S3 related ios, and the interrupts IO_CMD and ERROR.

diff --git a/spice/qxl_dev.h b/spice/qxl_dev.h
index 5ac2f46..5e6ce06 100644
--- a/spice/qxl_dev.h
+++ b/spice/qxl_dev.h
@@ -43,8 +43,12 @@
 
 /* 0x100-0x11f reserved for spice, 0x1ff used for unstable work */
 #define QXL_DEVICE_ID_STABLE 0x0100
-#define QXL_REVISION_STABLE_V04 0x01
-#define QXL_REVISION_STABLE_V06 0x02
+
+enum {
+    QXL_REVISION_STABLE_V04=0x01,
+    QXL_REVISION_STABLE_V06=0x02,
+    QXL_REVISION_STABLE_V10=0x03
+};
 
 #define QXL_DEVICE_ID_DEVEL 0x01ff
 #define QXL_REVISION_DEVEL 0x01
commit 54253a6d545e07d9f16d871aa254d0aa4f779a7f
Author: Alon Levy <alevy at redhat.com>
Date:   Thu Jun 30 15:03:31 2011 +0200

    qxl_dev: add QXL_INTERRUPT_ERROR
    
    The interrupt is used to notify the guest driver it did an error in
    the last io operation. It can be left unhandled.

diff --git a/spice/qxl_dev.h b/spice/qxl_dev.h
index 82eb1c8..5ac2f46 100644
--- a/spice/qxl_dev.h
+++ b/spice/qxl_dev.h
@@ -223,6 +223,7 @@ SPICE_RING_DECLARE(QXLReleaseRing, uint64_t, QXL_RELEASE_RING_SIZE);
 #define QXL_INTERRUPT_DISPLAY (1 << 0)
 #define QXL_INTERRUPT_CURSOR (1 << 1)
 #define QXL_INTERRUPT_IO_CMD (1 << 2)
+#define QXL_INTERRUPT_ERROR  (1 << 3)
 
 /* qxl-1 compat: append only */
 typedef struct SPICE_ATTR_PACKED QXLRam {
commit 49808025e7da2f9067d98b6fad730dbd63a4589d
Author: Alon Levy <alevy at redhat.com>
Date:   Sun May 22 14:52:11 2011 +0300

    add QXL_IO_FLUSH_{SURFACES,RELEASE} for sleep (S3) support
    
    related RHBZ: 688883
    
    Guest initiated sleep looks like this:
    
     Guest:
      (0) stop putting new commands into the rings
      (1) QXL_IO_FLUSH_SURFACES
          qxl calls flush_surfaces(), spice-server flushes command rings and
          renders all surfaces, thereby flushing state to device memory.
      (2) QXL_IO_DESTROY_ALL_SURFACES
          zap surfaces
      (3) QXL_IO_FLUSH_RELEASE
          push release queue head into the release ring, so the guest
          will see it and can release everything.
      (4) tell acpi to reset
     Qemu:
      (5) qxl_reset_handler
     Guest:
      (6) sends surface create commands
    
    The QXL_IO_FLUSH_SURFACES is an optimization, to reduce vmexits. It is used to
     flush both command rings and update all surfaces at once (equivalent to
     UPDATE_AREA X NUM_ACTIVE_SURFACES)
    
     destroy all surfaces to release resources but not destroy the guest side surfaces
     get device to flush all server released resources to the release ring (could use multiple
      calls to OOM - but this is not well defined, would need to loop)
     After (1) there will be no memory allocated on the pci bars.

diff --git a/spice/qxl_dev.h b/spice/qxl_dev.h
index 10ecabd..82eb1c8 100644
--- a/spice/qxl_dev.h
+++ b/spice/qxl_dev.h
@@ -87,6 +87,8 @@ enum {
     QXL_IO_DESTROY_PRIMARY_ASYNC,
     QXL_IO_DESTROY_SURFACE_ASYNC,
     QXL_IO_DESTROY_ALL_SURFACES_ASYNC,
+    QXL_IO_FLUSH_SURFACES_ASYNC,
+    QXL_IO_FLUSH_RELEASE,
 
     QXL_IO_RANGE_SIZE
 };
commit 9601a6353b1bd3262a464a12df5e0984c8ae7029
Author: Gerd Hoffmann <kraxel at redhat.com>
Date:   Wed Jun 22 10:46:18 2011 +0200

    Add async I/O commands.
    
    Add async versions of the I/O commands which do not block and instead
    raise the new QXL_INTERRUPT_IO_CMD when done.
    
    Signed-off-by: Gerd Hoffmann <kraxel at redhat.com>

diff --git a/spice/qxl_dev.h b/spice/qxl_dev.h
index e3e0696..10ecabd 100644
--- a/spice/qxl_dev.h
+++ b/spice/qxl_dev.h
@@ -80,6 +80,13 @@ enum {
     QXL_IO_DESTROY_PRIMARY,
     QXL_IO_DESTROY_SURFACE_WAIT,
     QXL_IO_DESTROY_ALL_SURFACES,
+    /* appended for qxl-3 */
+    QXL_IO_UPDATE_AREA_ASYNC,
+    QXL_IO_MEMSLOT_ADD_ASYNC,
+    QXL_IO_CREATE_PRIMARY_ASYNC,
+    QXL_IO_DESTROY_PRIMARY_ASYNC,
+    QXL_IO_DESTROY_SURFACE_ASYNC,
+    QXL_IO_DESTROY_ALL_SURFACES_ASYNC,
 
     QXL_IO_RANGE_SIZE
 };
@@ -213,6 +220,7 @@ SPICE_RING_DECLARE(QXLReleaseRing, uint64_t, QXL_RELEASE_RING_SIZE);
 
 #define QXL_INTERRUPT_DISPLAY (1 << 0)
 #define QXL_INTERRUPT_CURSOR (1 << 1)
+#define QXL_INTERRUPT_IO_CMD (1 << 2)
 
 /* qxl-1 compat: append only */
 typedef struct SPICE_ATTR_PACKED QXLRam {
commit ad3cc860a36d463bf16dbfb5fe0ac5b28a874c2f
Author: Marc-André Lureau <marcandre.lureau at redhat.com>
Date:   Wed Jun 22 11:55:44 2011 +0200

    protocol: add SPICE_{PLAYBACK,RECORD}_CAP_VOLUME caps
    
    These changes the protocol the following way:
    
    When the client announces it has SPICE_PLAYBACK_CAP_VOLUME, the server
    can send PlaybackChannel.{volume,mute} messages to notify of volume
    changes (respectively for RECORD).
    
    If the client doesn't implement SPICE_PLAYBACK_CAP_VOLUME, the server can
    handle the volume changes the way it prefers, for example, ignoring them or
    applying volume effect on the server side etc..

diff --git a/spice/protocol.h b/spice/protocol.h
index 26d964b..40027be 100644
--- a/spice/protocol.h
+++ b/spice/protocol.h
@@ -103,10 +103,12 @@ typedef struct SPICE_ATTR_PACKED SpiceSubMessageList {
 
 enum {
     SPICE_PLAYBACK_CAP_CELT_0_5_1,
+    SPICE_PLAYBACK_CAP_VOLUME,
 };
 
 enum {
     SPICE_RECORD_CAP_CELT_0_5_1,
+    SPICE_RECORD_CAP_VOLUME,
 };
 
 #include <spice/end-packed.h>
commit e2d6494b26958bf36d9e0eda4609da8f14e2dc31
Author: Marc-André Lureau <marcandre.lureau at redhat.com>
Date:   Sat Jun 18 00:10:32 2011 +0200

    spice: enums.h regenerated

diff --git a/spice/enums.h b/spice/enums.h
index 29f5933..756df56 100644
--- a/spice/enums.h
+++ b/spice/enums.h
@@ -1,9 +1,10 @@
+/* this is a file autogenerated by spice_codegen.py */
 #ifndef _H_SPICE_ENUMS
 #define _H_SPICE_ENUMS
 
 /* Generated from spice.proto, don't edit */
 
-enum SpiceLinkErr {
+typedef enum SpiceLinkErr {
     SPICE_LINK_ERR_OK,
     SPICE_LINK_ERR_ERROR,
     SPICE_LINK_ERR_INVALID_MAGIC,
@@ -16,51 +17,51 @@ enum SpiceLinkErr {
     SPICE_LINK_ERR_CHANNEL_NOT_AVAILABLE,
 
     SPICE_LINK_ERR_ENUM_END
-};
+} SpiceLinkErr;
 
-enum SpiceWarnCode {
+typedef enum SpiceWarnCode {
     SPICE_WARN_GENERAL,
 
     SPICE_WARN_CODE_ENUM_END
-};
+} SpiceWarnCode;
 
-enum SpiceInfoCode {
+typedef enum SpiceInfoCode {
     SPICE_INFO_GENERAL,
 
     SPICE_INFO_CODE_ENUM_END
-};
+} SpiceInfoCode;
 
-enum SpiceMigrateFlags {
+typedef enum SpiceMigrateFlags {
     SPICE_MIGRATE_NEED_FLUSH = (1 << 0),
     SPICE_MIGRATE_NEED_DATA_TRANSFER = (1 << 1),
 
     SPICE_MIGRATE_FLAGS_MASK = 0x3
-};
+} SpiceMigrateFlags;
 
-enum SpiceNotifySeverity {
+typedef enum SpiceNotifySeverity {
     SPICE_NOTIFY_SEVERITY_INFO,
     SPICE_NOTIFY_SEVERITY_WARN,
     SPICE_NOTIFY_SEVERITY_ERROR,
 
     SPICE_NOTIFY_SEVERITY_ENUM_END
-};
+} SpiceNotifySeverity;
 
-enum SpiceNotifyVisibility {
+typedef enum SpiceNotifyVisibility {
     SPICE_NOTIFY_VISIBILITY_LOW,
     SPICE_NOTIFY_VISIBILITY_MEDIUM,
     SPICE_NOTIFY_VISIBILITY_HIGH,
 
     SPICE_NOTIFY_VISIBILITY_ENUM_END
-};
+} SpiceNotifyVisibility;
 
-enum SpiceMouseMode {
+typedef enum SpiceMouseMode {
     SPICE_MOUSE_MODE_SERVER = (1 << 0),
     SPICE_MOUSE_MODE_CLIENT = (1 << 1),
 
     SPICE_MOUSE_MODE_MASK = 0x3
-};
+} SpiceMouseMode;
 
-enum SpicePubkeyType {
+typedef enum SpicePubkeyType {
     SPICE_PUBKEY_TYPE_INVALID,
     SPICE_PUBKEY_TYPE_RSA,
     SPICE_PUBKEY_TYPE_RSA2,
@@ -73,51 +74,51 @@ enum SpicePubkeyType {
     SPICE_PUBKEY_TYPE_EC,
 
     SPICE_PUBKEY_TYPE_ENUM_END
-};
+} SpicePubkeyType;
 
-enum SpiceClipType {
+typedef enum SpiceClipType {
     SPICE_CLIP_TYPE_NONE,
     SPICE_CLIP_TYPE_RECTS,
 
     SPICE_CLIP_TYPE_ENUM_END
-};
+} SpiceClipType;
 
-enum SpicePathFlags {
+typedef enum SpicePathFlags {
     SPICE_PATH_BEGIN = (1 << 0),
     SPICE_PATH_END = (1 << 1),
     SPICE_PATH_CLOSE = (1 << 3),
     SPICE_PATH_BEZIER = (1 << 4),
 
     SPICE_PATH_FLAGS_MASK = 0x1b
-};
+} SpicePathFlags;
 
-enum SpiceVideoCodecType {
+typedef enum SpiceVideoCodecType {
     SPICE_VIDEO_CODEC_TYPE_MJPEG = 1,
 
     SPICE_VIDEO_CODEC_TYPE_ENUM_END
-};
+} SpiceVideoCodecType;
 
-enum SpiceStreamFlags {
+typedef enum SpiceStreamFlags {
     SPICE_STREAM_FLAGS_TOP_DOWN = (1 << 0),
 
     SPICE_STREAM_FLAGS_MASK = 0x1
-};
+} SpiceStreamFlags;
 
-enum SpiceBrushType {
+typedef enum SpiceBrushType {
     SPICE_BRUSH_TYPE_NONE,
     SPICE_BRUSH_TYPE_SOLID,
     SPICE_BRUSH_TYPE_PATTERN,
 
     SPICE_BRUSH_TYPE_ENUM_END
-};
+} SpiceBrushType;
 
-enum SpiceMaskFlags {
+typedef enum SpiceMaskFlags {
     SPICE_MASK_FLAGS_INVERS = (1 << 0),
 
     SPICE_MASK_FLAGS_MASK = 0x1
-};
+} SpiceMaskFlags;
 
-enum SpiceImageType {
+typedef enum SpiceImageType {
     SPICE_IMAGE_TYPE_BITMAP,
     SPICE_IMAGE_TYPE_QUIC,
     SPICE_IMAGE_TYPE_RESERVED,
@@ -132,15 +133,15 @@ enum SpiceImageType {
     SPICE_IMAGE_TYPE_JPEG_ALPHA,
 
     SPICE_IMAGE_TYPE_ENUM_END
-};
+} SpiceImageType;
 
-enum SpiceImageFlags {
+typedef enum SpiceImageFlags {
     SPICE_IMAGE_FLAGS_CACHE_ME = (1 << 0),
     SPICE_IMAGE_FLAGS_HIGH_BITS_SET = (1 << 1),
     SPICE_IMAGE_FLAGS_CACHE_REPLACE_ME = (1 << 2),
 
     SPICE_IMAGE_FLAGS_MASK = 0x7
-};
+} SpiceImageFlags;
 
 typedef enum SpiceBitmapFmt {
     SPICE_BITMAP_FMT_INVALID,
@@ -157,28 +158,28 @@ typedef enum SpiceBitmapFmt {
     SPICE_BITMAP_FMT_ENUM_END
 } SpiceBitmapFmt;
 
-enum SpiceBitmapFlags {
+typedef enum SpiceBitmapFlags {
     SPICE_BITMAP_FLAGS_PAL_CACHE_ME = (1 << 0),
     SPICE_BITMAP_FLAGS_PAL_FROM_CACHE = (1 << 1),
     SPICE_BITMAP_FLAGS_TOP_DOWN = (1 << 2),
 
     SPICE_BITMAP_FLAGS_MASK = 0x7
-};
+} SpiceBitmapFlags;
 
-enum SpiceJpegAlphaFlags {
+typedef enum SpiceJpegAlphaFlags {
     SPICE_JPEG_ALPHA_FLAGS_TOP_DOWN = (1 << 0),
 
     SPICE_JPEG_ALPHA_FLAGS_MASK = 0x1
-};
+} SpiceJpegAlphaFlags;
 
-enum SpiceImageScaleMode {
+typedef enum SpiceImageScaleMode {
     SPICE_IMAGE_SCALE_MODE_INTERPOLATE,
     SPICE_IMAGE_SCALE_MODE_NEAREST,
 
     SPICE_IMAGE_SCALE_MODE_ENUM_END
-};
+} SpiceImageScaleMode;
 
-enum SpiceRopd {
+typedef enum SpiceRopd {
     SPICE_ROPD_INVERS_SRC = (1 << 0),
     SPICE_ROPD_INVERS_BRUSH = (1 << 1),
     SPICE_ROPD_INVERS_DEST = (1 << 2),
@@ -192,31 +193,31 @@ enum SpiceRopd {
     SPICE_ROPD_INVERS_RES = (1 << 10),
 
     SPICE_ROPD_MASK = 0x7ff
-};
+} SpiceRopd;
 
-enum SpiceLineFlags {
+typedef enum SpiceLineFlags {
     SPICE_LINE_FLAGS_START_WITH_GAP = (1 << 2),
     SPICE_LINE_FLAGS_STYLED = (1 << 3),
 
     SPICE_LINE_FLAGS_MASK = 0xc
-};
+} SpiceLineFlags;
 
-enum SpiceStringFlags {
+typedef enum SpiceStringFlags {
     SPICE_STRING_FLAGS_RASTER_A1 = (1 << 0),
     SPICE_STRING_FLAGS_RASTER_A4 = (1 << 1),
     SPICE_STRING_FLAGS_RASTER_A8 = (1 << 2),
     SPICE_STRING_FLAGS_RASTER_TOP_DOWN = (1 << 3),
 
     SPICE_STRING_FLAGS_MASK = 0xf
-};
+} SpiceStringFlags;
 
-enum SpiceSurfaceFlags {
+typedef enum SpiceSurfaceFlags {
     SPICE_SURFACE_FLAGS_PRIMARY = (1 << 0),
 
     SPICE_SURFACE_FLAGS_MASK = 0x1
-};
+} SpiceSurfaceFlags;
 
-enum SpiceSurfaceFmt {
+typedef enum SpiceSurfaceFmt {
     SPICE_SURFACE_FMT_INVALID,
     SPICE_SURFACE_FMT_1_A,
     SPICE_SURFACE_FMT_8_A = 8,
@@ -226,31 +227,31 @@ enum SpiceSurfaceFmt {
     SPICE_SURFACE_FMT_32_ARGB = 96,
 
     SPICE_SURFACE_FMT_ENUM_END
-};
+} SpiceSurfaceFmt;
 
-enum SpiceAlphaFlags {
+typedef enum SpiceAlphaFlags {
     SPICE_ALPHA_FLAGS_DEST_HAS_ALPHA = (1 << 0),
     SPICE_ALPHA_FLAGS_SRC_SURFACE_HAS_ALPHA = (1 << 1),
 
     SPICE_ALPHA_FLAGS_MASK = 0x3
-};
+} SpiceAlphaFlags;
 
-enum SpiceResourceType {
+typedef enum SpiceResourceType {
     SPICE_RES_TYPE_INVALID,
     SPICE_RES_TYPE_PIXMAP,
 
     SPICE_RESOURCE_TYPE_ENUM_END
-};
+} SpiceResourceType;
 
-enum SpiceKeyboardModifierFlags {
+typedef enum SpiceKeyboardModifierFlags {
     SPICE_KEYBOARD_MODIFIER_FLAGS_SCROLL_LOCK = (1 << 0),
     SPICE_KEYBOARD_MODIFIER_FLAGS_NUM_LOCK = (1 << 1),
     SPICE_KEYBOARD_MODIFIER_FLAGS_CAPS_LOCK = (1 << 2),
 
     SPICE_KEYBOARD_MODIFIER_FLAGS_MASK = 0x7
-};
+} SpiceKeyboardModifierFlags;
 
-enum SpiceMouseButton {
+typedef enum SpiceMouseButton {
     SPICE_MOUSE_BUTTON_INVALID,
     SPICE_MOUSE_BUTTON_LEFT,
     SPICE_MOUSE_BUTTON_MIDDLE,
@@ -259,17 +260,17 @@ enum SpiceMouseButton {
     SPICE_MOUSE_BUTTON_DOWN,
 
     SPICE_MOUSE_BUTTON_ENUM_END
-};
+} SpiceMouseButton;
 
-enum SpiceMouseButtonMask {
+typedef enum SpiceMouseButtonMask {
     SPICE_MOUSE_BUTTON_MASK_LEFT = (1 << 0),
     SPICE_MOUSE_BUTTON_MASK_MIDDLE = (1 << 1),
     SPICE_MOUSE_BUTTON_MASK_RIGHT = (1 << 2),
 
     SPICE_MOUSE_BUTTON_MASK_MASK = 0x7
-};
+} SpiceMouseButtonMask;
 
-enum SpiceCursorType {
+typedef enum SpiceCursorType {
     SPICE_CURSOR_TYPE_ALPHA,
     SPICE_CURSOR_TYPE_MONO,
     SPICE_CURSOR_TYPE_COLOR4,
@@ -279,45 +280,45 @@ enum SpiceCursorType {
     SPICE_CURSOR_TYPE_COLOR32,
 
     SPICE_CURSOR_TYPE_ENUM_END
-};
+} SpiceCursorType;
 
-enum SpiceCursorFlags {
+typedef enum SpiceCursorFlags {
     SPICE_CURSOR_FLAGS_NONE = (1 << 0),
     SPICE_CURSOR_FLAGS_CACHE_ME = (1 << 1),
     SPICE_CURSOR_FLAGS_FROM_CACHE = (1 << 2),
 
     SPICE_CURSOR_FLAGS_MASK = 0x7
-};
+} SpiceCursorFlags;
 
-enum SpiceAudioDataMode {
+typedef enum SpiceAudioDataMode {
     SPICE_AUDIO_DATA_MODE_INVALID,
     SPICE_AUDIO_DATA_MODE_RAW,
     SPICE_AUDIO_DATA_MODE_CELT_0_5_1,
 
     SPICE_AUDIO_DATA_MODE_ENUM_END
-};
+} SpiceAudioDataMode;
 
-enum SpiceAudioFmt {
+typedef enum SpiceAudioFmt {
     SPICE_AUDIO_FMT_INVALID,
     SPICE_AUDIO_FMT_S16,
 
     SPICE_AUDIO_FMT_ENUM_END
-};
+} SpiceAudioFmt;
 
-enum SpiceTunnelServiceType {
+typedef enum SpiceTunnelServiceType {
     SPICE_TUNNEL_SERVICE_TYPE_INVALID,
     SPICE_TUNNEL_SERVICE_TYPE_GENERIC,
     SPICE_TUNNEL_SERVICE_TYPE_IPP,
 
     SPICE_TUNNEL_SERVICE_TYPE_ENUM_END
-};
+} SpiceTunnelServiceType;
 
-enum SpiceTunnelIpType {
+typedef enum SpiceTunnelIpType {
     SPICE_TUNNEL_IP_TYPE_INVALID,
     SPICE_TUNNEL_IP_TYPE_IPv4,
 
     SPICE_TUNNEL_IP_TYPE_ENUM_END
-};
+} SpiceTunnelIpType;
 
 enum {
     SPICE_CHANNEL_MAIN = 1,
@@ -456,6 +457,8 @@ enum {
     SPICE_MSG_PLAYBACK_MODE,
     SPICE_MSG_PLAYBACK_START,
     SPICE_MSG_PLAYBACK_STOP,
+    SPICE_MSG_PLAYBACK_VOLUME,
+    SPICE_MSG_PLAYBACK_MUTE,
 
     SPICE_MSG_END_PLAYBACK
 };
@@ -463,6 +466,8 @@ enum {
 enum {
     SPICE_MSG_RECORD_START = 101,
     SPICE_MSG_RECORD_STOP,
+    SPICE_MSG_RECORD_VOLUME,
+    SPICE_MSG_RECORD_MUTE,
 
     SPICE_MSG_END_RECORD
 };
commit 2257ca24ef0c91685a8bd4cf41d383b522dd9c42
Author: Christophe Fergeau <cfergeau at redhat.com>
Date:   Mon Apr 11 12:56:26 2011 +0200

    protocol: use packed-start/end to pack structures
    
    spice-protocol comes with 2 headers to handle structure packing,
    but controller_prot.h and foreign_menu_prot were both using their
    own preprocessor definitions to handle packing. It's better to have
    structure packing macros centralized since how it's done varies
    between compilers, so it may need to change over time.

diff --git a/spice/controller_prot.h b/spice/controller_prot.h
index 697baa0..44d78e1 100644
--- a/spice/controller_prot.h
+++ b/spice/controller_prot.h
@@ -19,23 +19,19 @@
 #define _H_CONTROLLER_PROT
 
 #include <spice/types.h>
+#include <spice/start-packed.h>
 
 #define CONTROLLER_MAGIC      (*(uint32_t*)"CTRL")
 #define CONTROLLER_VERSION    1
 
-#ifdef __GNUC__
-#define ATTR_PACKED __attribute__ ((__packed__))
-#else
-#define ATTR_PACKED __declspec(align(1))
-#endif
 
-typedef struct ATTR_PACKED ControllerInitHeader {
+typedef struct SPICE_ATTR_PACKED ControllerInitHeader {
     uint32_t magic;
     uint32_t version;
     uint32_t size;
 } ControllerInitHeader;
 
-typedef struct ATTR_PACKED ControllerInit {
+typedef struct SPICE_ATTR_PACKED ControllerInit {
     ControllerInitHeader base;
     uint64_t credentials;
     uint32_t flags;
@@ -45,7 +41,7 @@ enum {
     CONTROLLER_FLAG_EXCLUSIVE = 1 << 0,
 };
 
-typedef struct ATTR_PACKED ControllerMsg {
+typedef struct SPICE_ATTR_PACKED ControllerMsg {
     uint32_t id;
     uint32_t size;
 } ControllerMsg;
@@ -88,12 +84,12 @@ enum {
     CONTROLLER_AUTO_DISPLAY_RES = 1 << 1,
 };
 
-typedef struct ATTR_PACKED ControllerValue {
+typedef struct SPICE_ATTR_PACKED ControllerValue {
     ControllerMsg base;
     uint32_t value;
 } ControllerValue;
 
-typedef struct ATTR_PACKED ControllerData {
+typedef struct SPICE_ATTR_PACKED ControllerData {
     ControllerMsg base;
     uint8_t data[0];
 } ControllerData;
@@ -112,6 +108,6 @@ enum {
 #define SPICE_MENU_INTERNAL_ID_BASE   0x1300
 #define SPICE_MENU_INTERNAL_ID_SHIFT  8
 
-#undef ATTR_PACKED
+#include <spice/end-packed.h>
 
 #endif
diff --git a/spice/foreign_menu_prot.h b/spice/foreign_menu_prot.h
index 8c22461..570fafb 100644
--- a/spice/foreign_menu_prot.h
+++ b/spice/foreign_menu_prot.h
@@ -18,28 +18,24 @@
 #ifndef _H_FOREIGN_MENU_PROT
 #define _H_FOREIGN_MENU_PROT
 
+#include <spice/start-packed.h>
+
 #define FOREIGN_MENU_MAGIC      (*(uint32_t*)"FRGM")
 #define FOREIGN_MENU_VERSION    1
 
-#ifdef __GNUC__
-#define ATTR_PACKED __attribute__ ((__packed__))
-#else
-#define ATTR_PACKED __declspec(align(1))
-#endif
-
-typedef struct ATTR_PACKED FrgMenuInitHeader {
+typedef struct SPICE_ATTR_PACKED FrgMenuInitHeader {
     uint32_t magic;
     uint32_t version;
     uint32_t size;
 } FrgMenuInitHeader;
 
-typedef struct ATTR_PACKED FrgMenuInit {
+typedef struct SPICE_ATTR_PACKED FrgMenuInit {
     FrgMenuInitHeader base;
     uint64_t credentials;
     uint8_t title[0]; //UTF8
 } FrgMenuInit;
 
-typedef struct ATTR_PACKED FrgMenuMsg {
+typedef struct SPICE_ATTR_PACKED FrgMenuMsg {
     uint32_t id;
     uint32_t size;
 } FrgMenuMsg;
@@ -58,7 +54,7 @@ enum {
     FOREIGN_MENU_APP_DEACTIVATED,
 };
 
-typedef struct ATTR_PACKED FrgMenuSetTitle {
+typedef struct SPICE_ATTR_PACKED FrgMenuSetTitle {
     FrgMenuMsg base;
     uint8_t string[0]; //UTF8
 } FrgMenuSetTitle;
@@ -71,7 +67,7 @@ enum {
 
 #define FOREIGN_MENU_INVALID_ID 0
 
-typedef struct ATTR_PACKED FrgMenuAddItem {
+typedef struct SPICE_ATTR_PACKED FrgMenuAddItem {
     FrgMenuMsg base;
     uint32_t id;
     uint32_t type;
@@ -79,7 +75,7 @@ typedef struct ATTR_PACKED FrgMenuAddItem {
     uint8_t string[0]; //UTF8
 } FrgMenuAddItem, FrgMenuModItem;
 
-typedef struct ATTR_PACKED FrgMenuRmItem {
+typedef struct SPICE_ATTR_PACKED FrgMenuRmItem {
     FrgMenuMsg base;
     uint32_t id;
 } FrgMenuRmItem;
@@ -93,7 +89,7 @@ enum {
     FOREIGN_MENU_EVENT_UNCHECKED
 };
 
-typedef struct ATTR_PACKED FrgMenuEvent {
+typedef struct SPICE_ATTR_PACKED FrgMenuEvent {
     FrgMenuMsg base;
     uint32_t id;
     uint32_t action; //FOREIGN_MENU_EVENT_?
@@ -102,6 +98,6 @@ typedef struct ATTR_PACKED FrgMenuEvent {
 typedef struct FrgMenuMsg FrgMenuActivate;
 typedef struct FrgMenuMsg FrgMenuDeactivate;
 
-#undef ATTR_PACKED
+#include <spice/end-packed.h>
 
 #endif
commit 15452bfcd477a015ba358a42cf6e10206a3efe7a
Author: Marc-André Lureau <marcandre.lureau at redhat.com>
Date:   Mon Apr 11 12:44:10 2011 +0200

    controller: add missing spice/types include

diff --git a/spice/controller_prot.h b/spice/controller_prot.h
index 38329c5..697baa0 100644
--- a/spice/controller_prot.h
+++ b/spice/controller_prot.h
@@ -18,6 +18,8 @@
 #ifndef _H_CONTROLLER_PROT
 #define _H_CONTROLLER_PROT
 
+#include <spice/types.h>
+
 #define CONTROLLER_MAGIC      (*(uint32_t*)"CTRL")
 #define CONTROLLER_VERSION    1
 


More information about the Spice-commits mailing list