[libvirt] [PATCH v7 3/6] hyperv: add hypervInvokeMethod

Matthias Bolte matthias.bolte at googlemail.com
Tue Jul 18 19:51:29 UTC 2017


2017-07-18 18:54 GMT+02:00 Andrea Bolognani <abologna at redhat.com>:
> On Tue, 2017-06-27 at 15:13 -0400, Sri Ramanujam wrote:
>> This commit adds support for invoking methods on remote objects
>> via hypervInvokeMethod.
>> ---
>>  src/hyperv/hyperv_wmi.c | 590 ++++++++++++++++++++++++++++++++++++++++++++++++
>>  src/hyperv/hyperv_wmi.h |   8 +-
>>  src/hyperv/openwsman.h  |   4 +
>>  3 files changed, 600 insertions(+), 2 deletions(-)
>>
>> diff --git a/src/hyperv/hyperv_wmi.c b/src/hyperv/hyperv_wmi.c
>> index 2732db3..f944b14 100644
>> --- a/src/hyperv/hyperv_wmi.c
>> +++ b/src/hyperv/hyperv_wmi.c
> [...]
>> +static int
>> +hypervSerializeEprParam(hypervParamPtr p, hypervPrivate *priv,
>> +        const char *resourceUri, WsXmlDocH doc, WsXmlNodeH *methodNode)
>> +{
>> +    int result = -1;
>> +    WsXmlNodeH xmlNodeParam = NULL,
>> +               xmlNodeTemp = NULL,
>> +               xmlNodeAddr = NULL,
>> +               xmlNodeRef = NULL;
>> +    xmlNodePtr xmlNodeAddrPtr = NULL,
>> +               xmlNodeRefPtr = NULL;
> [...]
>> +    if (!(xmlNodeAddrPtr = xmlDocCopyNode((xmlNodePtr) xmlNodeAddr, docPtr, 1))) {
>
> Here you're casting a WsXmlNodeH to a xmlNodePtr, and clang
> doesn't like it one bit:
>
>   hyperv/hyperv_wmi.c:576:43: error:
>     cast from 'WsXmlNodeH' (aka 'struct __WsXmlNode *')
>     to 'xmlNodePtr' (aka 'struct _xmlNode *')
>     increases required alignment from 4 to 8
>     [-Werror,-Wcast-align]
>
> Any idea how to unbreak it?

The problem here is that the driver is mixing direct libxml2 calls
with calls to the libxml2 wrapper of openwsman. The openwsman wrapper
type WsXmlNodeH is actually a xmlNodePtr, but that is hidden to the
compiler.

I checked if the openwsman libxml2 wrapper is complete enough to get
rid of this API mixing. I could replace all direct libxml2 calls with
openwsman wrapper call except xmlNewCDataBlock. A hack for this last
offender is to cast to a void pointer first, instead of a direct cast.
See attached patch for a quick fix, compile-tested only.

Another possibility is to do all the XML building using direct libxml2
calls, format the XML document and reparse it with the openwsman
wrapper. But I don't have time to work on that at the moment.

-- 
Matthias Bolte
http://photron.blogspot.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: hyperv_clang.patch
Type: application/octet-stream
Size: 5457 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20170718/f50ac5d9/attachment-0001.obj>


More information about the libvir-list mailing list