[Spice-devel] [spice PATCH 08/55] seamless-migration: add migration_protocol.h

Yonit Halperin yhalperi at redhat.com
Wed Aug 15 00:55:48 PDT 2012


The file will hold the declarations of the different migration
data messages (depending on the channel), that will be passed
from the src server to the dst server, via the client, using
SPICE_MSG_MIGRATE_DATA.
---
 server/Makefile.am          |    1 +
 server/migration_protocol.h |   49 +++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 50 insertions(+), 0 deletions(-)
 create mode 100644 server/migration_protocol.h

diff --git a/server/Makefile.am b/server/Makefile.am
index e7b4977..16c8b6d 100644
--- a/server/Makefile.am
+++ b/server/Makefile.am
@@ -72,6 +72,7 @@ libspice_server_la_SOURCES =			\
 	red_dispatcher.h			\
 	main_dispatcher.c			\
 	main_dispatcher.h			\
+	migration_protocol.h		\
 	red_memslots.c				\
 	red_memslots.h				\
 	red_parse_qxl.c				\
diff --git a/server/migration_protocol.h b/server/migration_protocol.h
new file mode 100644
index 0000000..2b7f4c2
--- /dev/null
+++ b/server/migration_protocol.h
@@ -0,0 +1,49 @@
+/*
+   Copyright (C) 2012 Red Hat, Inc.
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   This library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with this library; if not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef _H_MIGRATION_PROTOCOL
+#define _H_MIGRATION_PROTOCOL
+
+/* ************************************************
+ * src-server to dst-server migration data messages
+ * ************************************************/
+
+/* increase the version when the version of any
+ * of the migration data messages is increased */
+#define SPICE_MIGRATION_PROTOCOL_VERSION ~0
+
+typedef struct __attribute__ ((__packed__)) SpiceMigrateDataHeader {
+    uint32_t magic;
+    uint32_t version;
+} SpiceMigrateDataHeader;
+
+static inline int migration_protocol_validate_header(SpiceMigrateDataHeader *header,
+                                                     uint32_t magic,
+                                                     uint32_t version)
+{
+    if (header->magic != magic) {
+        spice_error("bad magic %u (!= %u)", header->magic, magic);
+        return FALSE;
+    }
+    if (header->version > version) {
+        spice_error("unsupported version %u (> %u)", header->version, version);
+        return FALSE;
+    }
+    return TRUE;
+}
+
+#endif
-- 
1.7.7.6



More information about the Spice-devel mailing list