mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 12:35:17 +00:00
esx: Fix dynamic dispatch for CastFromAnyType functions
This was broken by the refactoring in ac1e6586ec75. It resulted in a segfault for 'virsh vol-dumpxml' and related volume functions. Before the refactoring all users of the ESX_VI__TEMPLATE__DISPATCH macro dispatched on the item type, as the item is the input to all those functions. Commit ac1e6586ec75 made the dynamically dispatched CastFromAnyType functions use this macro too, but this functions dispatched on the actual type of the AnyType object. The item is the output of the CastFromAnyType functions. This difference was missed in the refactoring, making CastFromAnyType functions dereferencing the item pointer that is NULL at the time of the dispatch.
This commit is contained in:
parent
3ba5d77f3c
commit
4a9019afbb
@ -529,8 +529,9 @@
|
|||||||
* Macros to implement dynamic dispatched functions
|
* Macros to implement dynamic dispatched functions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define ESX_VI__TEMPLATE__DISPATCH(__type, _dispatch, _error_return) \
|
#define ESX_VI__TEMPLATE__DISPATCH(_actual_type, __type, _dispatch, \
|
||||||
switch (item->_type) { \
|
_error_return) \
|
||||||
|
switch (_actual_type) { \
|
||||||
_dispatch \
|
_dispatch \
|
||||||
\
|
\
|
||||||
case esxVI_Type_##__type: \
|
case esxVI_Type_##__type: \
|
||||||
@ -539,7 +540,7 @@
|
|||||||
default: \
|
default: \
|
||||||
ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, \
|
ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, \
|
||||||
_("Call to %s for unexpected type '%s'"), __FUNCTION__, \
|
_("Call to %s for unexpected type '%s'"), __FUNCTION__, \
|
||||||
esxVI_Type_ToString(item->_type)); \
|
esxVI_Type_ToString(_actual_type)); \
|
||||||
return _error_return; \
|
return _error_return; \
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -581,7 +582,8 @@
|
|||||||
|
|
||||||
#define ESX_VI__TEMPLATE__DYNAMIC_FREE(__type, _dispatch, _body) \
|
#define ESX_VI__TEMPLATE__DYNAMIC_FREE(__type, _dispatch, _body) \
|
||||||
ESX_VI__TEMPLATE__FREE(__type, \
|
ESX_VI__TEMPLATE__FREE(__type, \
|
||||||
ESX_VI__TEMPLATE__DISPATCH(__type, _dispatch, /* nothing */) \
|
ESX_VI__TEMPLATE__DISPATCH(item->_type, __type, _dispatch, \
|
||||||
|
/* nothing */) \
|
||||||
_body)
|
_body)
|
||||||
|
|
||||||
|
|
||||||
@ -614,14 +616,14 @@
|
|||||||
|
|
||||||
#define ESX_VI__TEMPLATE__DYNAMIC_CAST_FROM_ANY_TYPE(__type, _dispatch) \
|
#define ESX_VI__TEMPLATE__DYNAMIC_CAST_FROM_ANY_TYPE(__type, _dispatch) \
|
||||||
ESX_VI__TEMPLATE__CAST_FROM_ANY_TYPE_EXTRA(__type, esxVI_##__type, \
|
ESX_VI__TEMPLATE__CAST_FROM_ANY_TYPE_EXTRA(__type, esxVI_##__type, \
|
||||||
ESX_VI__TEMPLATE__DISPATCH(__type, _dispatch, -1), \
|
ESX_VI__TEMPLATE__DISPATCH(anyType->type, __type, _dispatch, -1), \
|
||||||
/* nothing */)
|
/* nothing */)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define ESX_VI__TEMPLATE__DYNAMIC_SERIALIZE(__type, _dispatch, _serialize) \
|
#define ESX_VI__TEMPLATE__DYNAMIC_SERIALIZE(__type, _dispatch, _serialize) \
|
||||||
ESX_VI__TEMPLATE__SERIALIZE_EXTRA(__type, \
|
ESX_VI__TEMPLATE__SERIALIZE_EXTRA(__type, \
|
||||||
ESX_VI__TEMPLATE__DISPATCH(__type, _dispatch, -1), \
|
ESX_VI__TEMPLATE__DISPATCH(item->_type, __type, _dispatch, -1), \
|
||||||
_serialize)
|
_serialize)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user