From: yvinter <yves.vinter(a)bull.net>
---
src/hyperv/hyperv_driver.c | 55 +++++++++++++++++++++++++++++++++++
src/hyperv/hyperv_wmi_generator.input | 37 +++++++++++++++++++++++
src/hyperv/hyperv_wmi_generator.py | 4 +--
3 files changed, 94 insertions(+), 2 deletions(-)
diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c
index 372ff39..f2017c3 100644
--- a/src/hyperv/hyperv_driver.c
+++ b/src/hyperv/hyperv_driver.c
@@ -1232,6 +1232,7 @@ hypervDomainManagedSaveRemove(virDomainPtr domain, unsigned int
flags)
}
+
#define MATCH(FLAG) (flags & (FLAG))
static int
hypervConnectListAllDomains(virConnectPtr conn,
@@ -1366,6 +1367,59 @@ hypervConnectListAllDomains(virConnectPtr conn,
+static int
+hypervConnectGetVersion(virConnectPtr conn, unsigned long *version)
+{
+ int result = -1;
+ hypervPrivate *priv = conn->privateData;
+ CIM_DataFile *datafile = NULL;
+ virBuffer query = VIR_BUFFER_INITIALIZER;
+ char *p;
+
+ virBufferAddLit(&query, " Select * from CIM_DataFile where
Name='c:\\\\windows\\\\system32\\\\vmms.exe' ");
+ if (hypervGetCIMDataFileList(priv, &query, &datafile) < 0) {
+ goto cleanup;
+ }
+
+ /* Check the result of convertion */
+ if (datafile == NULL) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Could not lookup %s for domain %s"),
+ "Msvm_VirtualSystemSettingData",
+ datafile->data->Version);
+ goto cleanup;
+ }
+
+ /* Delete release number and last digit of build number 1.1.111x.xxxx */
+ p = strrchr(datafile->data->Version,'.');
+ if (p == NULL) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Could not parse version number from '%s'"),
+ datafile->data->Version);
+ goto cleanup;
+ }
+ p--;
+ *p = '\0';
+
+ /* Parse Version String to Long */
+ if (virParseVersionString(datafile->data->Version,
+ version, true) < 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Could not parse version number from '%s'"),
+ datafile->data->Version);
+ goto cleanup;
+ }
+
+ result = 0;
+
+ cleanup:
+ hypervFreeObject(priv, (hypervObject *)datafile);
+ virBufferFreeAndReset(&query);
+
+ return result;
+}
+
+
static virDriver hypervDriver = {
.no = VIR_DRV_HYPERV,
@@ -1402,6 +1456,7 @@ static virDriver hypervDriver = {
.domainHasManagedSaveImage = hypervDomainHasManagedSaveImage, /* 0.9.5 */
.domainManagedSaveRemove = hypervDomainManagedSaveRemove, /* 0.9.5 */
.connectIsAlive = hypervConnectIsAlive, /* 0.9.8 */
+ .connectGetVersion = hypervConnectGetVersion, /* 1.2.10 */
};
diff --git a/src/hyperv/hyperv_wmi_generator.input
b/src/hyperv/hyperv_wmi_generator.input
index 97f9dff..6b969df 100644
--- a/src/hyperv/hyperv_wmi_generator.input
+++ b/src/hyperv/hyperv_wmi_generator.input
@@ -296,3 +296,40 @@ class Win32_Processor
string Version
uint32 VoltageCaps
end
+
+
+class CIM_DataFile
+ uint32 AccessMask
+ boolean Archive
+ string Caption
+ boolean Compressed
+ string CompressionMethod
+ string CreationClassName
+ datetime CreationDate
+ string CSCreationClassName
+ string CSName
+ string Description
+ string Drive
+ string EightDotThreeFileName
+ boolean Encrypted
+ string EncryptionMethod
+ string Extension
+ string FileName
+ uint64 FileSize
+ string FileType
+ string FSCreationClassName
+ string FSName
+ boolean Hidden
+ datetime InstallDate
+ uint64 InUseCount
+ datetime LastAccessed
+ datetime LastModified
+ string Manufacturer
+ string Name
+ string Path
+ boolean Readable
+ string Status
+ boolean System
+ string Version
+ boolean Writeable
+end
diff --git a/src/hyperv/hyperv_wmi_generator.py b/src/hyperv/hyperv_wmi_generator.py
index f767d54..1011719 100755
--- a/src/hyperv/hyperv_wmi_generator.py
+++ b/src/hyperv/hyperv_wmi_generator.py
@@ -68,7 +68,7 @@ class Class:
header += "\n"
header += "#define %s_RESOURCE_URI \\\n" % name_upper
- if self.name.startswith("Win32_"):
+ if self.name.startswith("Win32_") or
self.name.startswith("CIM_DataFile"):
header += "
\"http://schemas.microsoft.com/wbem/wsman/1/wmi/root/cimv2/%s\"\n" %
self.name
else:
header += "
\"http://schemas.microsoft.com/wbem/wsman/1/wmi/root/virtualization/%s\"\n"
% self.name
@@ -113,7 +113,7 @@ class Class:
% (self.name.replace("_", ""), self.name)
source += "{\n"
- if self.name.startswith("Win32_"):
+ if self.name.startswith("Win32_") or
self.name.startswith("CIM_DataFile"):
source += " return hypervEnumAndPull(priv, query,
ROOT_CIMV2,\n"
else:
source += " return hypervEnumAndPull(priv, query,
ROOT_VIRTUALIZATION,\n"
--
1.9.1