[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

2010/8/21 Eric Blake <eblake@redhat.com>:
* 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. ---
I guess I could fold the default: and UNDEFINED: case labels into one, if that is desirable.
You could make XEN_VM_POWER_STATE_UNDEFINED fall through to default as in case XEN_VM_POWER_STATE_UNDEFINED: default: /* Includes XEN_VM_POWER_STATE_UNKNOWN from libxenserver * 5.5.0, which is gone in 5.6.0. */ virState = VIR_DOMAIN_NOSTATE; break; I think that it's not desirable to remove XEN_VM_POWER_STATE_UNDEFINED completely. ACK. Matthias

On 08/21/2010 09:52 AM, Matthias Bolte wrote:
2010/8/21 Eric Blake<eblake@redhat.com>:
* 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. ---
I guess I could fold the default: and UNDEFINED: case labels into one, if that is desirable.
You could make XEN_VM_POWER_STATE_UNDEFINED fall through to default as in
case XEN_VM_POWER_STATE_UNDEFINED: default: /* Includes XEN_VM_POWER_STATE_UNKNOWN from libxenserver * 5.5.0, which is gone in 5.6.0. */ virState = VIR_DOMAIN_NOSTATE; break;
I think that it's not desirable to remove XEN_VM_POWER_STATE_UNDEFINED completely.
Agreed; your formulation looks best, so that's what I squashed in.
ACK.
Pushed now. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org
participants (2)
-
Eric Blake
-
Matthias Bolte