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

[libvirt] [PATCH] xenapi: support xenapi 5.6.0 headers



* src/xenapi/xenapi_driver.c (xenapiDomainGetInfo): Avoid using
XEN_VM_POWER_STATE_UNKNOWN, which disappeared in newer xenapi.
* src/xenapi/xenapi_utils.c (mapPowerState): Likewise.
---

After letting that last build regression slip through, I decided
to install libxenserver, at the current 5.6.0-1 release.  To
my surprise, the compilation still failed; the culprit is that
upstream deleted an enum value.

I thought about doing a configure check and #defining the old
UNKNOWN name to alias the existing UNDEFINED name, but that
would only fix one of the two cases; the switch statement
would still fail to compile in that case due to a duplicate
label.  So I think this patch is the right approach.

I guess I could fold the default: and UNDEFINED: case labels
into one, if that is desirable.

 src/xenapi/xenapi_driver.c |    2 +-
 src/xenapi/xenapi_utils.c  |    3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/xenapi/xenapi_driver.c b/src/xenapi/xenapi_driver.c
index fb3c91d..730859b 100644
--- a/src/xenapi/xenapi_driver.c
+++ b/src/xenapi/xenapi_driver.c
@@ -966,7 +966,7 @@ xenapiDomainGetInfo (virDomainPtr dom, virDomainInfoPtr info)
         vm = vms->contents[0];
         xen_vm_get_memory_static_max(session, &maxmem, vm);
         info->maxMem = (maxmem / 1024);
-        enum xen_vm_power_state state = XEN_VM_POWER_STATE_UNKNOWN;
+        enum xen_vm_power_state state = XEN_VM_POWER_STATE_UNDEFINED;
         xen_vm_get_power_state(session, &state, vm);
         info->state = mapPowerState(state);
         xen_vm_get_record(session, &record, vm);
diff --git a/src/xenapi/xenapi_utils.c b/src/xenapi/xenapi_utils.c
index 23d3fef..e22f6fd 100644
--- a/src/xenapi/xenapi_utils.c
+++ b/src/xenapi/xenapi_utils.c
@@ -336,11 +336,12 @@ mapPowerState(enum xen_vm_power_state state)
     case XEN_VM_POWER_STATE_RUNNING:
         virState = VIR_DOMAIN_RUNNING;
         break;
-    case XEN_VM_POWER_STATE_UNKNOWN:
     case XEN_VM_POWER_STATE_UNDEFINED:
         virState = VIR_DOMAIN_NOSTATE;
         break;
     default:
+        /* Includes XEN_VM_POWER_STATE_UNKNOWN from libxenserver
+         * 5.5.0, which is gone in 5.6.0.  */
         virState = VIR_DOMAIN_NOSTATE;
         break;
     }
-- 
1.7.2.1


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