[PATCH 00/11] hyperv: add support for Hyper-V 2012 and newer.

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

 



Hello,

The following patch series reworks the hyper-v driver structs and the
code generator to provide seamless support for both Hyper-V 2008 and
2012 or newer. This does not implement any new libvirt APIs, it just
adapts existing 2008-only driver to also handle 2012 and newer by
sharing as much driver code as possible (currently it's all of it :-))
This is needed to set the foundation before we can move forward with
implementing the rest of the driver APIs.

With 2012 release, Microsoft introduced "v2" version of Msvm_* WMI
classes. Those are largely the same as "v1" (used in 2008) but have some
new properties as well as need different wsman request URIs. To
accomodate those differences, most of work went into the code generator
so that it's "aware" of possibility of multiple versions of the same WMI
class and produce C code accordingly.

To accomplish this the following changes were made:

 * hypervPrivate has now wmiVersion field so the driver can check this
   at runtime and take appropiate action as needed.
 * the abstract hypervObject struct's data member was changed to a union
   that has "common", "v1" and "v2" members. Those are structs that
   represent WMI classes that we get back from wsman response. The
   "common" struct has members that are present in both "v1" and "v2"
   which the driver API callbacks can use to read the data from in
   version-independent manner (if version-specific member needs to be
   accessed the driver can check priv->wmiVersion and read from "v1" or
   "v2" as needed). Those structs are guaranteed to be  memory aligned
   by the code generator (see the _align_propert_members implementation
   that takes care of that)
 * the generator produces *_WmiInfo for each WMI class "family" that
   holds an array of hypervWmiClassInfoPtr each providing information
   as to which request URI to use for each "version" of given WMI class
   as well as XmlSerializerInfo struct needed to unserilize wsman
   responsed into the data structs. The driver uses those to make proper
   wsman request depending on which version it's connected to.
 * the generator no longer produces "helper" functions such as
   hypervGetMsvmComputerSystemList as those were originally just simple
   wrappers around hypervEnumAndPull, instead those were hand-written
   now (to keep driver changes minimal). The reason is that we'll have
   more code coming (once/if this get ACK) implementing missing libvirt
   APIs and surely code patterns will emerge that would warrant more
   useful "utility" functions like that.
 * a hypervInitConnection was added to the driver which "detects"
   hyper-v version by testing simple wsman request using v2 then falling
   back to v1, obviously if both fail, the we're erroring out.

To express how the above translates in code:

int
hypervImplementSomeLibvirtApi(virConnectPtr conn, ...)
{
    hypervPrivate *priv = conn->privateData;
    hypervWqlQuery wqlQuery = HYPERV_WQL_QUERY_INITIALIZER;
    Msvm_ComputerSystem *list = NULL; /* typed hypervObject instance */
    
    /* the WmiInfo struct has the data needed for wsman request and
     * response handling for both v1 and v2 */
    wqlQuery.info = Msvm_ComputerSystem_WmiInfo; 
    wqlQuery.query = "select * from Msvm_ComputerSystem";

    if (hypervEnumAndPull(priv, &query, (hypervObject **) &list) < 0) {
        goto cleanup;
    }

    if (list == NULL) {
        /* none found */
        goto cleanup;
    }

    /* works with v1 and v2 */
    char *vmName = list->data.common->Name;

    /* access property that is in v2 only */
    if (priv->wmiVersion == HYPERV_WMI_VERSION_V2)
        char *foo = list->data.v2->V2Property;
    else
        char *foo = list->data.v1->V1Property;
}


Dawid Zamirski (11):
  hyperv: fixed typo in function name.
  hyperv: store WMI version in hypervPrivate.
  hyperv: introduce hypervWmiClassInfo struct.
  hyperv: update hypervObject struct.
  hyperv: add hypervWqlQuery struct.
  hyperv: make hypervEnumAndPull use hypervWqlQuery
  hyperv: update generator input file.
  hyperv: update wmi code generator.
  hyperv: add helper for getting WMI class lists.
  hyperv: port rest of the driver to new stucts.
  hyperv: add hypervInitConnection.

 src/Makefile.am                       |   2 -
 src/hyperv/hyperv_driver.c            | 168 ++++++++------
 src/hyperv/hyperv_private.h           |   8 +-
 src/hyperv/hyperv_wmi.c               | 179 +++++++++++----
 src/hyperv/hyperv_wmi.h               |  58 ++++-
 src/hyperv/hyperv_wmi_classes.h       |  30 +++
 src/hyperv/hyperv_wmi_generator.input | 239 +++++++++++++++++---
 src/hyperv/hyperv_wmi_generator.py    | 409 +++++++++++++++++++++++-----------
 8 files changed, 809 insertions(+), 284 deletions(-)
 mode change 100755 => 100644 src/hyperv/hyperv_wmi_generator.py

-- 
2.9.3

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]
  Powered by Linux