From 9a4f2a3219fd8bc9d96353b051fe5853a440e7d5 Mon Sep 17 00:00:00 2001
From: Thilo Boehm <tboehm@linux.vnet.ibm.com>
Date: Fri, 11 Oct 2013 13:47:34 +0200
Subject: [PATCH 35/60] VSSM: Fix endianness issue in domain properties

The properties for the on_xxx actions must be 16-bit values in
order to avoid failures on big endian systems.

Signed-off-by: Thilo Boehm <tboehm@linux.vnet.ibm.com>
Reviewed-by:  Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
Signed-off-by: John Ferlan <jferlan@redhat.com>
---
 libxkutil/device_parsing.c                | 2 +-
 libxkutil/device_parsing.h                | 8 ++++----
 src/Virt_VirtualSystemManagementService.c | 4 ++--
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/libxkutil/device_parsing.c b/libxkutil/device_parsing.c
index 97419d2..8a90653 100644
--- a/libxkutil/device_parsing.c
+++ b/libxkutil/device_parsing.c
@@ -1602,7 +1602,7 @@ static int parse_features(struct domain *dominfo, xmlNode *features)
         return 1;
 }

-static void set_action(int *val, xmlNode *child)
+static void set_action(uint16_t *val, xmlNode *child)
 {
         char *action = (char *)xmlNodeGetContent(child);

diff --git a/libxkutil/device_parsing.h b/libxkutil/device_parsing.h
index 531703d..92427c1 100644
--- a/libxkutil/device_parsing.h
+++ b/libxkutil/device_parsing.h
@@ -213,7 +213,7 @@ struct domain {
         bool acpi;
         bool apic;
         bool pae;
-        int autostrt;
+        uint16_t autostrt;

         union {
                 struct pv_os_info pv;
@@ -221,9 +221,9 @@ struct domain {
                 struct lxc_os_info lxc;
         } os_info;

-        int on_poweroff;
-        int on_reboot;
-        int on_crash;
+        uint16_t on_poweroff;
+        uint16_t on_reboot;
+        uint16_t on_crash;

         struct virt_device *dev_graphics;
         int dev_graphics_ct;
diff --git a/src/Virt_VirtualSystemManagementService.c b/src/Virt_VirtualSystemManagementService.c
index 6548d08..5c7238f 100644
--- a/src/Virt_VirtualSystemManagementService.c
+++ b/src/Virt_VirtualSystemManagementService.c
@@ -719,13 +719,13 @@ static int vssd_to_domain(CMPIInstance *inst,
         if (ret != CMPI_RC_OK)
                 tmp = 0;

-        domain->on_poweroff = (int)tmp;
+        domain->on_poweroff = tmp;

         ret = cu_get_u16_prop(inst, "AutomaticRecoveryAction", &tmp);
         if (ret != CMPI_RC_OK)
                 tmp = CIM_VSSD_RECOVERY_NONE;

-        domain->on_crash = (int)tmp;
+        domain->on_crash = tmp;

         if (cu_get_bool_prop(inst, "IsFullVirt", &fullvirt) != CMPI_RC_OK)
                 fullvirt = false;
--
2.1.0
