提交 87f2bd3c 编写于 作者: D Dawid Zamirski 提交者: Matthias Bolte

hyperv: update hypervObject struct.

Currently named as hypervObjecUnified to keep code
compilable/functional until all bits are in place.

This struct is a result of unserializing WMI request response.
Therefore, it needs to be able to deal with different "versions" of the
same WMI class. To accomplish this, the "data" member was turned in to
a union which:

* has a "common" member that contains only WMI class fields that are
  safe to access and are present in all "versions". This is ensured by
  the code generator that takes care of proper struct memory alignment
  between "common", "v1", "v2" etc members. This memeber is to be used
  by the driver code wherever the API implementation can be shared for
  all supported hyper-v versions.
* the "v1" and "v2" member can be used by the driver code to handle
  version specific cases.

Example:

Msvm_ComputerSystem *vm = NULL;
...
hypervGetVirtualMachineList(priv, wqlQuery, *vm);
...
/* safe for "v1" and "v2" */
char *vmName = vm->data.common->Name;

/* or if one really needs special handling for "v2" */
if (priv->wmiVersion == HYPERV_WMI_VERSION_V2) {
    char *foo = vm->data.v2->SomeV2OnlyField;
}

In other words, driver should not concern itself with existence of "v1"
or "v2" of WMI class unless absolutely necessary.
上级 a5689ad2
......@@ -41,6 +41,24 @@ int hypervVerifyResponse(WsManClient *client, WsXmlDocH response,
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Object
*/
typedef struct _hypervObjectUnified hypervObjectUnified;
struct _hypervObjectUnified {
/* Unserialized data from wsman response. The member called "common" has
* properties that are the same type and name for all "versions" of given
* WMI class. This means that calling code does not have to make any
* conditional checks based on which version was returned as long as it
* only needs to read common values. The alignment of structs is ensured
* by the generator.
*/
union {
XML_TYPE_PTR common;
XML_TYPE_PTR v1;
XML_TYPE_PTR v2;
} data;
/* The info used to make wsman request */
hypervWmiClassInfoPtr info;
hypervObjectUnified *next;
};
struct _hypervObject {
XmlSerializerInfo *serializerInfo;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册