mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-11-01 02:41:14 +00:00
3372f8fb5b
This patch 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 the 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: * 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_property_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 WS-MAN responsed into the data structs. The driver uses those to make proper WS-MAN 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 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: void hypervImplementSomeLibvirtApi(virConnectPtr conn, ...) { hypervPrivate *priv = conn->privateData; virBuffer query = VIR_BUFFER_INITIALIZER; 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 = &query; virBufferAddLit(&query, "select * from Msvm_ComputerSystem"); if (hypervEnumAndPull(priv, &wqlQuery, (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; cleanup: hypervFreeObject(priv, (hypervObject *)list); } |
||
---|---|---|
.. | ||
access | ||
admin | ||
bhyve | ||
conf | ||
cpu | ||
esx | ||
hyperv | ||
interface | ||
libxl | ||
locking | ||
logging | ||
lxc | ||
network | ||
node_device | ||
nwfilter | ||
openvz | ||
phyp | ||
qemu | ||
remote | ||
rpc | ||
secret | ||
security | ||
storage | ||
test | ||
uml | ||
util | ||
vbox | ||
vmware | ||
vmx | ||
vz | ||
xen | ||
xenapi | ||
xenconfig | ||
admin_protocol-structs | ||
check-aclperms.pl | ||
check-aclrules.pl | ||
check-driverimpls.pl | ||
check-drivername.pl | ||
check-symfile.pl | ||
check-symsorting.pl | ||
datatypes.c | ||
datatypes.h | ||
driver-hypervisor.h | ||
driver-interface.h | ||
driver-network.h | ||
driver-nodedev.h | ||
driver-nwfilter.h | ||
driver-secret.h | ||
driver-state.h | ||
driver-storage.h | ||
driver-stream.h | ||
driver.c | ||
driver.h | ||
dtrace2systemtap.pl | ||
internal.h | ||
libvirt_admin_private.syms | ||
libvirt_admin_public.syms | ||
libvirt_atomic.syms | ||
libvirt_driver_modules.syms | ||
libvirt_esx.syms | ||
libvirt_gnutls.syms | ||
libvirt_internal.h | ||
libvirt_libssh2.syms | ||
libvirt_libssh.syms | ||
libvirt_linux.syms | ||
libvirt_lxc.syms | ||
libvirt_openvz.syms | ||
libvirt_private.syms | ||
libvirt_probes.d | ||
libvirt_public.syms | ||
libvirt_qemu_probes.d | ||
libvirt_qemu.syms | ||
libvirt_remote.syms | ||
libvirt_sasl.syms | ||
libvirt_vmware.syms | ||
libvirt_vmx.syms | ||
libvirt_xenconfig.syms | ||
libvirt_xenxlconfig.syms | ||
libvirt-admin.c | ||
libvirt-admin.conf | ||
libvirt-domain-snapshot.c | ||
libvirt-domain.c | ||
libvirt-host.c | ||
libvirt-interface.c | ||
libvirt-lxc.c | ||
libvirt-lxc.pc.in | ||
libvirt-network.c | ||
libvirt-nodedev.c | ||
libvirt-nwfilter.c | ||
libvirt-qemu.c | ||
libvirt-qemu.pc.in | ||
libvirt-secret.c | ||
libvirt-storage.c | ||
libvirt-stream.c | ||
libvirt.c | ||
libvirt.conf | ||
libvirt.pc.in | ||
lock_protocol-structs | ||
lxc_monitor_protocol-structs | ||
lxc_protocol-structs | ||
Makefile.am | ||
qemu_protocol-structs | ||
README | ||
remote_protocol-structs | ||
virkeepaliveprotocol-structs | ||
virnetprotocol-structs |
libvirt library code README =========================== The directory provides the bulk of the libvirt codebase. Everything except for the libvirtd daemon and client tools. The build uses a large number of libtool convenience libraries - one for each child directory, and then links them together for the final libvirt.so, although some bits get linked directly to libvirtd daemon instead. The files directly in this directory are supporting the public API entry points & data structures. There are two core shared modules to be aware of: * util/ - a collection of shared APIs that can be used by any code. This directory is always in the include path for all things built * conf/ - APIs for parsing / manipulating all the official XML files used by the public API. This directory is only in the include path for driver implementation modules * vmx/ - VMware VMX config handling (used by esx/ and vmware/) Then there are the hypervisor implementations: * bhyve - bhyve - The BSD Hypervisor * esx/ - VMware ESX and GSX support using vSphere API over SOAP * hyperv/ - Microsoft Hyper-V support using WinRM * lxc/ - Linux Native Containers * openvz/ - OpenVZ containers using cli tools * phyp/ - IBM Power Hypervisor using CLI tools over SSH * qemu/ - QEMU / KVM using qemu CLI/monitor * remote/ - Generic libvirt native RPC client * test/ - A "mock" driver for testing * uml/ - User Mode Linux * vbox/ - Virtual Box using native API * vmware/ - VMware Workstation and Player using the vmrun tool * xen/ - Xen using hypercalls, XenD SEXPR & XenStore * xenapi/ - Xen using libxenserver Finally some secondary drivers that are shared for several HVs. Currently these are used by LXC, OpenVZ, QEMU, UML and Xen drivers. The ESX, Hyper-V, Power Hypervisor, Remote, Test & VirtualBox drivers all implement the secondary drivers directly * cpu/ - CPU feature management * interface/ - Host network interface management * network/ - Virtual NAT networking * nwfilter/ - Network traffic filtering rules * node_device/ - Host device enumeration * secret/ - Secret management * security/ - Mandatory access control drivers * storage/ - Storage management drivers Since both the hypervisor and secondary drivers can be built as dlopen()able modules, it is *FORBIDDEN* to have build dependencies between these directories. Drivers are only allowed to depend on the public API, and the internal APIs in the util/ and conf/ directories