[PATCH spice-server] char-device: Fix some endianess issues migrating

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Data from network are always little endian, convert to host
convention.

Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx>
---
 server/char-device.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/server/char-device.c b/server/char-device.c
index 03ac9907..e7c6dfa8 100644
--- a/server/char-device.c
+++ b/server/char-device.c
@@ -855,7 +855,7 @@ void red_char_device_migrate_data_marshall_empty(SpiceMarshaller *m)
     mig_data = (SpiceMigrateDataCharDevice *)spice_marshaller_reserve_space(m,
                                                                             sizeof(*mig_data));
     memset(mig_data, 0, sizeof(*mig_data));
-    mig_data->version = SPICE_MIGRATE_DATA_CHAR_DEVICE_VERSION;
+    mig_data->version = GUINT32_TO_LE(SPICE_MIGRATE_DATA_CHAR_DEVICE_VERSION);
     mig_data->connected = FALSE;
 }
 
@@ -926,14 +926,23 @@ void red_char_device_migrate_data_marshall(RedCharDevice *dev,
 }
 
 bool red_char_device_restore(RedCharDevice *dev,
-                             SpiceMigrateDataCharDevice *mig_data)
+                             SpiceMigrateDataCharDevice *mig_data_le)
 {
     RedCharDeviceClient *dev_client;
     uint32_t client_tokens_window;
+    SpiceMigrateDataCharDevice mig_data[1];
 
     spice_assert(g_list_length(dev->priv->clients) == 1 &&
                  dev->priv->wait_for_migrate_data);
 
+    mig_data->version = GUINT32_FROM_LE(mig_data_le->version);
+    mig_data->connected = mig_data_le->connected;
+    mig_data->num_client_tokens = GUINT32_FROM_LE(mig_data_le->num_client_tokens);
+    mig_data->num_send_tokens = GUINT32_FROM_LE(mig_data_le->num_send_tokens);
+    mig_data->write_size = GUINT32_FROM_LE(mig_data_le->write_size);
+    mig_data->write_num_client_tokens = GUINT32_FROM_LE(mig_data_le->write_num_client_tokens);
+    mig_data->write_data_ptr = GUINT32_FROM_LE(mig_data_le->write_data_ptr);
+
     dev_client = g_list_last(dev->priv->clients)->data;
     if (mig_data->version > SPICE_MIGRATE_DATA_CHAR_DEVICE_VERSION) {
         spice_error("dev %p error: migration data version %u is bigger than self %u",
-- 
2.21.0

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux Virtualization]     [Linux Virtualization]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]