From nobody Sat Apr 27 16:50:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zoho.com; dkim=fail spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1491108800791585.9232869094624; Sat, 1 Apr 2017 21:53:20 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 49352C065846; Sun, 2 Apr 2017 04:53:18 +0000 (UTC) Received: from colo-mx.corp.redhat.com (unknown [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0949E18EFF; Sun, 2 Apr 2017 04:53:18 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 85B8B5EC63; Sun, 2 Apr 2017 04:53:17 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v324pVit019149 for ; Sun, 2 Apr 2017 00:51:31 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7C0CB17CCD; Sun, 2 Apr 2017 04:51:30 +0000 (UTC) Received: from mx1.redhat.com (ext-mx03.extmail.prod.ext.phx2.redhat.com [10.5.110.27]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 758325DD6A for ; Sun, 2 Apr 2017 04:51:29 +0000 (UTC) Received: from mail-qk0-f170.google.com (mail-qk0-f170.google.com [209.85.220.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 85DE280F6D for ; Sun, 2 Apr 2017 04:50:58 +0000 (UTC) Received: by mail-qk0-f170.google.com with SMTP id p22so93442275qka.3 for ; Sat, 01 Apr 2017 21:50:56 -0700 (PDT) Received: from dawid-fedora.datto.lan ([47.19.105.250]) by smtp.gmail.com with ESMTPSA id c10sm6934829qka.1.2017.04.01.21.50.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 01 Apr 2017 21:50:51 -0700 (PDT) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 49352C065846 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=datto.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 49352C065846 Authentication-Results: mx1.redhat.com; dkim=fail reason="signature verification failed" (2048-bit key) header.d=datto-com.20150623.gappssmtp.com header.i=@datto-com.20150623.gappssmtp.com header.b="M5wPT/fq" DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 85DE280F6D Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=datto.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=dzamirski@datto.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 85DE280F6D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=datto-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ZnBGKfqBXblb18P0HCOeOCkcTPM840zzG60UQTXjD7k=; b=M5wPT/fq8puk0yP7A8pUifrZ8nJk9gaqfrE8jmvj7PnctPmfTSHnad3I/ouTP+JasV cRIw1h59pQeMeRx2CSL8Pm0Bgx7ON3aFcdpZQGISrdHghrKptx+4yU5/bLuhTJJTsUGZ U7Ti2uzpFnToz0HSEfdwIckXBLZi/aNctHH7FnXlxHrLISKRny2YtG6fZHaosv0UI+jP lh933KeEAihxgye8GILXyG0XXAduDuCZU+KVCxgAfeukMxVq+0tc1UTvmczSwFeO6KZP qnht85a+43xe2YpZ28a34MqJHrZM7GaJcQkehqRSCbvOtX8zCQJZUpu33YNiq0ioNvpx AN2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ZnBGKfqBXblb18P0HCOeOCkcTPM840zzG60UQTXjD7k=; b=h1d3vOCl6RN4dCe07AWOmoXb1+/mI+GqoFcJO68zFty13Fq2PdCoyseRIaVpC/Smmj Ay4CrxuXvv+rRv2Lzfx0d0ofWpqd2JryTL2kRS5YOgv5yOjLoFrrDBDKyb6HgnRa9XCa a6Rl5E0SaTn8wE1uxp/930EQs2QVkVjFOUPztRhcUrhiDXm8spr7Do/pRnsk6VfoaZqI j6UVPQhP/fp8QKPieLi7odKFhvUjTd7l5G8OAADppdoiIiH36aRSARfOgiywjZJ5pAv4 q4k5iyPsI5jyaBuTiUSPH/FScU7J7CQJi33j6G5X6Ib+akEqupyZuW4uxghsHTOP/s16 tZUg== X-Gm-Message-State: AFeK/H0fQAZDIFGICS0j1LUXu5gvZ0EHF62iM7cROIobL0M4O3yhzWScNCVbzQQ5hE3j7+Qj X-Received: by 10.55.49.130 with SMTP id x124mr11085064qkx.63.1491108651548; Sat, 01 Apr 2017 21:50:51 -0700 (PDT) From: Dawid Zamirski To: libvir-list@redhat.com Date: Sun, 2 Apr 2017 00:50:40 -0400 Message-Id: <20170402045049.19631-2-dzamirski@datto.com> In-Reply-To: <20170402045049.19631-1-dzamirski@datto.com> References: <20170402045049.19631-1-dzamirski@datto.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Sun, 02 Apr 2017 04:51:05 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Sun, 02 Apr 2017 04:51:05 +0000 (UTC) for IP:'209.85.220.170' DOMAIN:'mail-qk0-f170.google.com' HELO:'mail-qk0-f170.google.com' FROM:'dzamirski@datto.com' RCPT:'' X-RedHat-Spam-Score: 0.389 (BAYES_50, DCC_REPUT_00_12, DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_NONE, SPF_PASS) 209.85.220.170 mail-qk0-f170.google.com 209.85.220.170 mail-qk0-f170.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.27 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Cc: Sri Ramanujam Subject: [libvirt] [PATCH v2 01/10] hyperv: store WMI version in hypervPrivate. X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Sun, 02 Apr 2017 04:53:19 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Hyper-V 2012+ uses a new "v2" version of Msvm_* WMI classes so we will store that info in hypervPrivate so that it is easily accessbile in the driver API callbacks and handled accordingly. --- src/hyperv/hyperv_private.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/hyperv/hyperv_private.h b/src/hyperv/hyperv_private.h index 574bb5f..4e70699 100644 --- a/src/hyperv/hyperv_private.h +++ b/src/hyperv/hyperv_private.h @@ -28,11 +28,17 @@ # include "hyperv_util.h" # include "openwsman.h" =20 -typedef struct _hypervPrivate hypervPrivate; +typedef enum _hypervWmiVersion hypervWmiVersion; +enum _hypervWmiVersion { + HYPERV_WMI_VERSION_V1, + HYPERV_WMI_VERSION_V2, +}; =20 +typedef struct _hypervPrivate hypervPrivate; struct _hypervPrivate { hypervParsedUri *parsedUri; WsManClient *client; + hypervWmiVersion wmiVersion; }; =20 #endif /* __HYPERV_PRIVATE_H__ */ --=20 2.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat Apr 27 16:50:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zoho.com; dkim=fail spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1491108750386781.9022188226152; Sat, 1 Apr 2017 21:52:30 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DF1B53B708; Sun, 2 Apr 2017 04:52:28 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B193F53C30; Sun, 2 Apr 2017 04:52:28 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 654A118523D2; Sun, 2 Apr 2017 04:52:28 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v324pTin019129 for ; Sun, 2 Apr 2017 00:51:29 -0400 Received: by smtp.corp.redhat.com (Postfix) id 24E3617CCB; Sun, 2 Apr 2017 04:51:29 +0000 (UTC) Received: from mx1.redhat.com (ext-mx01.extmail.prod.ext.phx2.redhat.com [10.5.110.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1D1035DD6A for ; Sun, 2 Apr 2017 04:51:27 +0000 (UTC) Received: from mail-qk0-f180.google.com (mail-qk0-f180.google.com [209.85.220.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 70BB581F01 for ; Sun, 2 Apr 2017 04:50:59 +0000 (UTC) Received: by mail-qk0-f180.google.com with SMTP id d10so93821603qke.1 for ; Sat, 01 Apr 2017 21:50:55 -0700 (PDT) Received: from dawid-fedora.datto.lan ([47.19.105.250]) by smtp.gmail.com with ESMTPSA id c10sm6934829qka.1.2017.04.01.21.50.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 01 Apr 2017 21:50:51 -0700 (PDT) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com DF1B53B708 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=datto.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com DF1B53B708 Authentication-Results: mx1.redhat.com; dkim=fail reason="signature verification failed" (2048-bit key) header.d=datto-com.20150623.gappssmtp.com header.i=@datto-com.20150623.gappssmtp.com header.b="J0WSMSyM" DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 70BB581F01 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=datto.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=dzamirski@datto.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 70BB581F01 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=datto-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=/G7OXwmhc5KgWIX/Xh9swiuxQ+omBwflsQh1/sLGC7c=; b=J0WSMSyMfx/RmBnYGa7PM0SNs/deYMgTB7bd5S1oBdj48wdVB28knW/BPK7zE4AnVu pDP/uYNpofhkzftFlSDS03p6Z0O294UKlb7IZss+UnM3eANqrXT+AnG0g70POB+yJXzp 4eqbJ9rWN26y2tITOZGAE1QtcO7pz5W4JOMH6hW8YOgUVDOiqSTTZMPwVxG6es9f+9Gp 2MfbQ0TmD9gfQ/vE9yCM0sAraclLr1J1uV1GfiHc5/A11RAIaCT0RJtHh9uGoWO6GiRo L3iGo90jHEhZfb2RW4cVvtKU6w21XOWKreBamqp2q/+oHGr05Uvz+BXeKXbH2T4T3Fau blwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=/G7OXwmhc5KgWIX/Xh9swiuxQ+omBwflsQh1/sLGC7c=; b=jabCj9E5CIC39p0ywRTRADoQSg8RG26F4VuJv5vxGlCiA04C7RQoR9qz2vKsUUcfCy CJ3yPJw33dHHIjQJmyw7p46NUn5OkKvOH1pZSoUFQKOoDvBuWLBxjlR0hTjKXnyeS328 X2Vbj4oqCL/n7GwFnCKkVWRDyfawR1abE+LKLMEC+99IquNEqb0yugpRm4+qxbnwPR3c hbQEbx/M6baQg87jqPkDHdmlXWvvonB/YAUIZDnuMXAwCKQvOJ6xPPtZfdBPWyYYckoh slqo71k/KE9PNZtQgRhEHiwTbOV3imwNOXdKTst6oqZ6gXK8p7kpUgc1Q7ZDWWoC7LeX Ygmg== X-Gm-Message-State: AFeK/H016AfXtKr+hDgwQL9/WxKtFT2zb21QUKwhvKoZ3u+JR8S0ZhRgVXtqQM187CF54Eru X-Received: by 10.55.93.131 with SMTP id r125mr10660407qkb.282.1491108652406; Sat, 01 Apr 2017 21:50:52 -0700 (PDT) From: Dawid Zamirski To: libvir-list@redhat.com Date: Sun, 2 Apr 2017 00:50:41 -0400 Message-Id: <20170402045049.19631-3-dzamirski@datto.com> In-Reply-To: <20170402045049.19631-1-dzamirski@datto.com> References: <20170402045049.19631-1-dzamirski@datto.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Sun, 02 Apr 2017 04:51:04 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Sun, 02 Apr 2017 04:51:04 +0000 (UTC) for IP:'209.85.220.180' DOMAIN:'mail-qk0-f180.google.com' HELO:'mail-qk0-f180.google.com' FROM:'dzamirski@datto.com' RCPT:'' X-RedHat-Spam-Score: 0.4 (BAYES_50, DCC_REPUT_00_12, DKIM_SIGNED, DKIM_VALID) 209.85.220.180 mail-qk0-f180.google.com 209.85.220.180 mail-qk0-f180.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.25 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Cc: Sri Ramanujam Subject: [libvirt] [PATCH v2 02/10] hyperv: introduce hypervWmiClassInfo struct. X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Sun, 02 Apr 2017 04:52:29 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This struct is to be used to carry all the information necessary to issue wsman requests for given WMI class. Those will be defined by the generator code (as lists) so that they are handy for the driver code to "extract" needed info depending on which hyper-v we're connected to. For example: hypervWmiClassInfoListPtr Msvm_ComputerSystem_WmiInfo =3D { .count =3D 2 { { .name =3D "Msvm_ComputerSystem", .version =3D "v1", .rootUri =3D "http://asdf.com", ... }, { .name =3D "Msvm_ComputerSystem", .version =3D "v2", .rootUri =3D "http://asdf.com/v2", ... }, } }; Then the driver code will grab either "v1" or "v2" to pass info wsman API, depending on hypervPrivate->wmiVersion value. --- src/hyperv/hyperv_wmi_classes.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/hyperv/hyperv_wmi_classes.h b/src/hyperv/hyperv_wmi_classe= s.h index ac7a3b8..b0f3e3c 100644 --- a/src/hyperv/hyperv_wmi_classes.h +++ b/src/hyperv/hyperv_wmi_classes.h @@ -87,6 +87,28 @@ enum _Msvm_ConcreteJob_JobState { }; =20 =20 +typedef struct _hypervWmiClassInfo hypervWmiClassInfo; +typedef hypervWmiClassInfo *hypervWmiClassInfoPtr; +struct _hypervWmiClassInfo { + /* The WMI class name */ + const char *name; + /* The version of the WMI class as in "v1" or "v2" */ + const char *version; + /* The URI for wsman enumerate request */ + const char *rootUri; + /* The namespace URI for XML serialization */ + const char *resourceUri; + /* The wsman serializer info - one of the *_TypeInfo structs */ + XmlSerializerInfo *serializerInfo; +}; + + +typedef struct _hypervWmiClassInfoList hypervWmiClassInfoList; +typedef hypervWmiClassInfoList *hypervWmiClassInfoListPtr; +struct _hypervWmiClassInfoList { + size_t count; + hypervWmiClassInfoPtr *objs; +}; =20 # include "hyperv_wmi_classes.generated.h" =20 --=20 2.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat Apr 27 16:50:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zoho.com; dkim=fail spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1491108755184251.3229299936885; Sat, 1 Apr 2017 21:52:35 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D25DC7E9CC; Sun, 2 Apr 2017 04:52:33 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7BA4D18EFF; Sun, 2 Apr 2017 04:52:33 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 2A1EE18523D4; Sun, 2 Apr 2017 04:52:33 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v324pUn6019144 for ; Sun, 2 Apr 2017 00:51:30 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8187918A42; Sun, 2 Apr 2017 04:51:30 +0000 (UTC) Received: from mx1.redhat.com (ext-mx02.extmail.prod.ext.phx2.redhat.com [10.5.110.26]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 79C4E6031D for ; Sun, 2 Apr 2017 04:51:28 +0000 (UTC) Received: from mail-qk0-f179.google.com (mail-qk0-f179.google.com [209.85.220.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E80F486647 for ; Sun, 2 Apr 2017 04:50:57 +0000 (UTC) Received: by mail-qk0-f179.google.com with SMTP id d201so63852042qkc.0 for ; Sat, 01 Apr 2017 21:50:56 -0700 (PDT) Received: from dawid-fedora.datto.lan ([47.19.105.250]) by smtp.gmail.com with ESMTPSA id c10sm6934829qka.1.2017.04.01.21.50.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 01 Apr 2017 21:50:52 -0700 (PDT) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D25DC7E9CC Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=datto.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com D25DC7E9CC Authentication-Results: mx1.redhat.com; dkim=fail reason="signature verification failed" (2048-bit key) header.d=datto-com.20150623.gappssmtp.com header.i=@datto-com.20150623.gappssmtp.com header.b="lMina5Tl" DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com E80F486647 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=datto.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=dzamirski@datto.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com E80F486647 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=datto-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=vCXoBshs5+V6rrV2fC/fpAbeYUimvlX3Dv/smLn/T4Y=; b=lMina5TlcppgFoFMYE8KCE4HmgycS3eUjs0E9+LB4kse1u6aqmsvQYmmBBY9SMYlCZ iZuuUnxjii93KS9oL7RfWyvYxE2nuZjseryQYrCzknfk8V+1RBW628LEry2AmAlCS3ek TvYPu8oRmklw5ihIX6FkDKzOaIScmisHUTXfvQa7LSmhhts3TVQL8Y8OMHe4lWbW+YxP 7+X1+xQpy2j1BAIWTv011yTZqFaOxLzhH0/4JsN5WMaWn9bCEU2jTdZQ1Tb+3D9+MPMB aCed9GIO8chSGISdMHduqxKEgFtroF6/vMNlY247TYVVNezLG62MgzmxQgFA2wUOVwgU q/6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=vCXoBshs5+V6rrV2fC/fpAbeYUimvlX3Dv/smLn/T4Y=; b=hLlAzg9b7V5kBP24Z0gyiuJnAkNRojkh1skOZtZquVRqCzt/ipUoY4Ar+7iEnZ7xG/ M39doMbjXctxZx9sci+tLaph/xpOhr8qCdl/i8I+nO6SLV+EsXY8wwLQkG+F9dKb0NGq idGcQytJoFFZJXNdqQYTgpkrmu5dfS9jdF5zBwmY04NDZ3yHcwXwQgOJA1qleVXXKx4x s7YJHX3Y9gTx2sPB38IQGFTDrcpSUuTGFGuBXqAh6Q2bwAmUrJHS5i+G+I7vMiQmHGQP pHLEJc8ekmTTZvTibAstIRCvffADuq2b1XhqwS6L6rik2PHLiTCSpFiEbypFrblCRmg+ QCZA== X-Gm-Message-State: AFeK/H1ZZg7JVfBov6cTmTCTkJFFZy73U5QHSXaq1wp7qWbw2/hMKZqd/u+yEhOzeIKM4xuL X-Received: by 10.55.168.11 with SMTP id r11mr10777823qke.239.1491108652943; Sat, 01 Apr 2017 21:50:52 -0700 (PDT) From: Dawid Zamirski To: libvir-list@redhat.com Date: Sun, 2 Apr 2017 00:50:42 -0400 Message-Id: <20170402045049.19631-4-dzamirski@datto.com> In-Reply-To: <20170402045049.19631-1-dzamirski@datto.com> References: <20170402045049.19631-1-dzamirski@datto.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Sun, 02 Apr 2017 04:51:02 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Sun, 02 Apr 2017 04:51:02 +0000 (UTC) for IP:'209.85.220.179' DOMAIN:'mail-qk0-f179.google.com' HELO:'mail-qk0-f179.google.com' FROM:'dzamirski@datto.com' RCPT:'' X-RedHat-Spam-Score: 0.869 (BAYES_50, DCC_REPUT_00_12, DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, RCVD_IN_SORBS_SPAM, SPF_PASS) 209.85.220.179 mail-qk0-f179.google.com 209.85.220.179 mail-qk0-f179.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.26 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Cc: Sri Ramanujam Subject: [libvirt] [PATCH v2 03/10] hyperv: update hypervObject struct. X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Sun, 02 Apr 2017 04:52:34 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" 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 =3D NULL; ... hypervGetVirtualMachineList(priv, wqlQuery, *vm); ... /* safe for "v1" and "v2" */ char *vmName =3D vm->data.common->Name; /* or if one really needs special handling for "v2" */ if (priv->wmiVersion =3D=3D HYPERV_WMI_VERSION_V2) { char *foo =3D vm->data.v2->SomeV2OnlyField; } In other words, driver should not concern itself with existence of "v1" or "v2" of WMI class unless absolutely necessary. --- src/hyperv/hyperv_wmi.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/hyperv/hyperv_wmi.h b/src/hyperv/hyperv_wmi.h index ce1fe05..5fc36e8 100644 --- a/src/hyperv/hyperv_wmi.h +++ b/src/hyperv/hyperv_wmi.h @@ -41,6 +41,25 @@ int hypervVerifyResponse(WsManClient *client, WsXmlDocH = response, /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *= * * * Object */ +typedef struct _hypervObjectUnified hypervObjectUnified; +struct _hypervObjectUnified { + /* Unserialized data from wsman response. The member called "common" h= as + * properties that are the same type and name for all "versions" of gi= ven + * 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 ensur= ed + * 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; +}; =20 struct _hypervObject { XmlSerializerInfo *serializerInfo; --=20 2.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat Apr 27 16:50:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zoho.com; dkim=fail spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1491109463172189.66741107930284; Sat, 1 Apr 2017 22:04:23 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 57FA931F3E2; Sun, 2 Apr 2017 05:04:21 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 274BA60319; Sun, 2 Apr 2017 05:04:21 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 1742618521C8; Sun, 2 Apr 2017 05:04:19 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v324pO5p019097 for ; Sun, 2 Apr 2017 00:51:24 -0400 Received: by smtp.corp.redhat.com (Postfix) id A87BA17105; Sun, 2 Apr 2017 04:51:24 +0000 (UTC) Received: from mx1.redhat.com (ext-mx07.extmail.prod.ext.phx2.redhat.com [10.5.110.31]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A204762922 for ; Sun, 2 Apr 2017 04:51:23 +0000 (UTC) Received: from mail-qk0-f176.google.com (mail-qk0-f176.google.com [209.85.220.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9B98CC049D5B for ; Sun, 2 Apr 2017 04:50:59 +0000 (UTC) Received: by mail-qk0-f176.google.com with SMTP id g195so21332020qke.2 for ; Sat, 01 Apr 2017 21:50:58 -0700 (PDT) Received: from dawid-fedora.datto.lan ([47.19.105.250]) by smtp.gmail.com with ESMTPSA id c10sm6934829qka.1.2017.04.01.21.50.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 01 Apr 2017 21:50:53 -0700 (PDT) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 57FA931F3E2 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=datto.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 57FA931F3E2 Authentication-Results: mx1.redhat.com; dkim=fail reason="signature verification failed" (2048-bit key) header.d=datto-com.20150623.gappssmtp.com header.i=@datto-com.20150623.gappssmtp.com header.b="vFp+Dep6" DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 9B98CC049D5B Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=datto.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=dzamirski@datto.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 9B98CC049D5B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=datto-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=1iMorNzfKbj3G4NQotAA7Yg4pR2O2tQsFTYgdNDnbAA=; b=vFp+Dep66NSPTJkdlg5Skf4E8gylfhp4HkbmdCy+HTjRvrYioTbFVLbF0FdwI6F17b Uw6ywu+1AnK6QD+I4jdoVYvLSHcNxLrsyPnQQw/jyRR99R7YZW01KUQEb3nDDGGAm/bN E6wnvjqgpeSZBNs+zH6LxBSTrh3wy+a/IlImkwajs19spqVAC8QfSt9XuZ4jWH5mXowX NC2+p7R4dqCaauIp+z40AEw3HiCd1MtzmBckKCkwSnZtoBTWUB7cTeGPsG7jqTOGvxn2 n0bxy0xd5fA7yzwoI3zyPCss4TuMUFkBhOxd+0TLh73IIQgRDABnGJf6OPug91TvnzP6 hdYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=1iMorNzfKbj3G4NQotAA7Yg4pR2O2tQsFTYgdNDnbAA=; b=QnDh9ee+7LuAZDoOSIGtQlfuUx3hRPHGTe5umjr3o7Y+7AAHc+CfWgGurz7GvVDoeU DpCHyr61/uXH4IQInl/ljLjOCm3OrauW1v/IC8VLkhuz13Phbj9txPWt7yUog1vOOdmN 3u+1uu1JnCG3yH5PZq51ZAR1UuZABbDejBtegnvM/JG91apgu383UeTrNm0qy+8dEQKz Aw+Gwjij5q9W7dT4FKYvUyzhfv2oCwwjoUfx1IR9yPhsxh08qSzxxBHviOo+/73kAZzn vk1zYDNVc+sn73QrtyQrvjPCTOGkj7aRezmQ0EtDf3SpNRcK+UcRJF44nu/KYQ7RaMqC Egow== X-Gm-Message-State: AFeK/H1DUCYQM4B44tx8q+WMlpUiwFzqpF4xceDS9teEubRLsA0AV9elnRDIAgaXGlTvlhOH X-Received: by 10.55.169.9 with SMTP id s9mr10445908qke.91.1491108653746; Sat, 01 Apr 2017 21:50:53 -0700 (PDT) From: Dawid Zamirski To: libvir-list@redhat.com Date: Sun, 2 Apr 2017 00:50:43 -0400 Message-Id: <20170402045049.19631-5-dzamirski@datto.com> In-Reply-To: <20170402045049.19631-1-dzamirski@datto.com> References: <20170402045049.19631-1-dzamirski@datto.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Sun, 02 Apr 2017 04:51:02 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Sun, 02 Apr 2017 04:51:02 +0000 (UTC) for IP:'209.85.220.176' DOMAIN:'mail-qk0-f176.google.com' HELO:'mail-qk0-f176.google.com' FROM:'dzamirski@datto.com' RCPT:'' X-RedHat-Spam-Score: -1.901 (BAYES_50, DCC_REPUT_00_12, DKIM_SIGNED, DKIM_VALID, RCVD_IN_MSPIKE_H2, RCVD_IN_SORBS_SPAM, SPF_PASS) 209.85.220.176 mail-qk0-f176.google.com 209.85.220.176 mail-qk0-f176.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.31 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: Sri Ramanujam Subject: [libvirt] [PATCH v2 04/10] hyperv: add hypervWqlQuery struct. X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Sun, 02 Apr 2017 05:04:22 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Since this is the last commit that will compile in the series, the remaining patches should be squashed into this one - they are kept separate only for code review purposes. This struct is to be passed to enumerate-and-pull wsman request (to run "Select" queries) and provides the hypervWmiClassInfoListPtr instance from which we can extract the version specific info using the new hypervGetWmiClassInfo function (currently unused) --- src/hyperv/hyperv_wmi.c | 35 +++++++++++++++++++++++++++++++++++ src/hyperv/hyperv_wmi.h | 8 ++++++++ 2 files changed, 43 insertions(+) diff --git a/src/hyperv/hyperv_wmi.c b/src/hyperv/hyperv_wmi.c index 947101f..bc391e3 100644 --- a/src/hyperv/hyperv_wmi.c +++ b/src/hyperv/hyperv_wmi.c @@ -45,6 +45,41 @@ #define VIR_FROM_THIS VIR_FROM_HYPERV =20 =20 +static int ATTRIBUTE_UNUSED +hypervGetWmiClassInfo(hypervPrivate *priv, hypervWmiClassInfoListPtr list, + hypervWmiClassInfoPtr *info) +{ + const char *version =3D "v2"; + size_t i; + + if (list->count =3D=3D 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("The WMI class info list is empty")); + return -1; + } + + /* if there's just one WMI class and isn't versioned, assume "shared" = */ + if (list->count =3D=3D 1 && list->objs[0]->version =3D=3D NULL) { + *info =3D list->objs[0]; + return 0; + } + + if (priv->wmiVersion =3D=3D HYPERV_WMI_VERSION_V1) + version =3D "v1"; + + for (i =3D 0; i < list->count; i++) { + if (STRCASEEQ(list->objs[i]->version, version)) { + *info =3D list->objs[i]; + return 0; + } + } + + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Could not match WMI class info for version %s"), + version); + + return -1; +} =20 int hypervVerifyResponse(WsManClient *client, WsXmlDocH response, diff --git a/src/hyperv/hyperv_wmi.h b/src/hyperv/hyperv_wmi.h index 5fc36e8..12b94af 100644 --- a/src/hyperv/hyperv_wmi.h +++ b/src/hyperv/hyperv_wmi.h @@ -30,6 +30,7 @@ # include "openwsman.h" =20 =20 +# define HYPERV_WQL_QUERY_INITIALIZER {NULL, NULL} =20 typedef struct _hypervObject hypervObject; =20 @@ -61,6 +62,13 @@ struct _hypervObjectUnified { hypervObjectUnified *next; }; =20 +typedef struct _hypervWqlQuery hypervWqlQuery; +typedef hypervWqlQuery *hypervWqlQueryPtr; +struct _hypervWqlQuery { + const char *query; + hypervWmiClassInfoListPtr info; +}; + struct _hypervObject { XmlSerializerInfo *serializerInfo; XML_TYPE_PTR data; --=20 2.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat Apr 27 16:50:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zoho.com; dkim=fail spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1491108739707255.98928075148683; Sat, 1 Apr 2017 21:52:19 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D53BB83F3E; Sun, 2 Apr 2017 04:52:17 +0000 (UTC) Received: from colo-mx.corp.redhat.com (unknown [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A649C60319; Sun, 2 Apr 2017 04:52:17 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id CA8064ED25; Sun, 2 Apr 2017 04:51:48 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v324pYT3019177 for ; Sun, 2 Apr 2017 00:51:34 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7921517CCB; Sun, 2 Apr 2017 04:51:33 +0000 (UTC) Received: from mx1.redhat.com (ext-mx04.extmail.prod.ext.phx2.redhat.com [10.5.110.28]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 723875DD6A for ; Sun, 2 Apr 2017 04:51:33 +0000 (UTC) Received: from mail-qk0-f180.google.com (mail-qk0-f180.google.com [209.85.220.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4FB7F85545 for ; Sun, 2 Apr 2017 04:50:58 +0000 (UTC) Received: by mail-qk0-f180.google.com with SMTP id g195so21332093qke.2 for ; Sat, 01 Apr 2017 21:50:56 -0700 (PDT) Received: from dawid-fedora.datto.lan ([47.19.105.250]) by smtp.gmail.com with ESMTPSA id c10sm6934829qka.1.2017.04.01.21.50.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 01 Apr 2017 21:50:53 -0700 (PDT) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D53BB83F3E Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=datto.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com D53BB83F3E Authentication-Results: mx1.redhat.com; dkim=fail reason="signature verification failed" (2048-bit key) header.d=datto-com.20150623.gappssmtp.com header.i=@datto-com.20150623.gappssmtp.com header.b="Ibh/5BJB" DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 4FB7F85545 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=datto.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=dzamirski@datto.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 4FB7F85545 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=datto-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=SAtlnZ6IrDc5ldFd/3gLpijlkq0Cd6lEQowVb0tysI0=; b=Ibh/5BJBVxVUFVI0w+qrAoT52PFbLhHRrlcEvfeWf+73OShxrLdcHa9otqfbQuLN9n PvEO2PuLmM1i1GzJ/UrI9CkfKXYFDMam70GR8ZiFX7SgPwy0sVhDqQeUfMAcQLPog6Wf FM6r1jeQ1l7hW+3WW2TimZkCGfKY1FQqd1HeUjkYbff/PsTlvd4scq/Dx7epJNh1SL1Z u/GKoeOKDx6XkNc9P2xE0kX8Gf/9oIEfTHbm3SzYccPB2jpJtqd8UhpnktwJmmo0NpTb tPPUZN7s8Hl1t7/T9ojoDZVv9MawJ3L4K17WDf826r9orjtQokvKmZzsteBHVHB8YtI2 b6LQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=SAtlnZ6IrDc5ldFd/3gLpijlkq0Cd6lEQowVb0tysI0=; b=D289iCkP4DixooxRJ7OgvHOYrl8sIsgCbSnV7Qi0xtl8FMicxY5HmXpbhS9OQ8vUaG 73URwaPF6XfVYNvZFBNFaPkoPEUXMCDoyDRP05Ff5GwzPhTsteTVUFfnMH9ByVu6VfQe Tyfy5jCL40Jq99CVpFRLcidjfCM6a0nnnUh0rykVWd6+Ay0m2hxwMFt0v//6NAlkAoOr ev2ClhotgCBWnfKsRAwOONARt7aa0Pbi7yVTlQjM4aLZarw0yEncov3to00jeXJRrNGB 22JDQyHzvYfWmpaBy9ikLt2eW/NDgDVGG/jqDPBoIELhFrXVY7p9aLtF9eERVZacBRXy Pr3A== X-Gm-Message-State: AFeK/H08qbVy84d5ZTpvzdbctc51C1m8DtB3USTqGzjK2b1nElh1uo82vJ+Oft8rZzd4Wv5N X-Received: by 10.55.2.7 with SMTP id 7mr11234428qkc.228.1491108654313; Sat, 01 Apr 2017 21:50:54 -0700 (PDT) From: Dawid Zamirski To: libvir-list@redhat.com Date: Sun, 2 Apr 2017 00:50:44 -0400 Message-Id: <20170402045049.19631-6-dzamirski@datto.com> In-Reply-To: <20170402045049.19631-1-dzamirski@datto.com> References: <20170402045049.19631-1-dzamirski@datto.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Sun, 02 Apr 2017 04:51:05 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Sun, 02 Apr 2017 04:51:05 +0000 (UTC) for IP:'209.85.220.180' DOMAIN:'mail-qk0-f180.google.com' HELO:'mail-qk0-f180.google.com' FROM:'dzamirski@datto.com' RCPT:'' X-RedHat-Spam-Score: 0.389 (BAYES_50, DCC_REPUT_00_12, DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_NONE, SPF_PASS) 209.85.220.180 mail-qk0-f180.google.com 209.85.220.180 mail-qk0-f180.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.28 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Cc: Sri Ramanujam Subject: [libvirt] [PATCH v2 05/10] hyperv: make hypervEnumAndPull use hypervWqlQuery X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Sun, 02 Apr 2017 04:52:18 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This enables this function to handle "v1" and "v2" WMI requests. Since this commit and the ones that follow should be squashed on previous one: * rename hypervObjectUnified -> hypervObject as we've already broken compilation here so there's no point in keeping those in parallel anymore. * do not mark hypervGetWmiClassInfo as unused --- src/hyperv/hyperv_wmi.c | 40 ++++++++++++++++++---------------------- src/hyperv/hyperv_wmi.h | 17 ++++------------- 2 files changed, 22 insertions(+), 35 deletions(-) diff --git a/src/hyperv/hyperv_wmi.c b/src/hyperv/hyperv_wmi.c index bc391e3..40de8d6 100644 --- a/src/hyperv/hyperv_wmi.c +++ b/src/hyperv/hyperv_wmi.c @@ -45,7 +45,7 @@ #define VIR_FROM_THIS VIR_FROM_HYPERV =20 =20 -static int ATTRIBUTE_UNUSED +static int hypervGetWmiClassInfo(hypervPrivate *priv, hypervWmiClassInfoListPtr list, hypervWmiClassInfoPtr *info) { @@ -143,14 +143,13 @@ hypervVerifyResponse(WsManClient *client, WsXmlDocH r= esponse, =20 /* This function guarantees that query is freed, even on failure */ int -hypervEnumAndPull(hypervPrivate *priv, virBufferPtr query, const char *roo= t, - XmlSerializerInfo *serializerInfo, const char *resourceU= ri, - const char *className, hypervObject **list) +hypervEnumAndPull(hypervPrivate *priv, hypervWqlQueryPtr wqlQuery, + hypervObject **list) { int result =3D -1; WsSerializerContextH serializerContext; client_opt_t *options =3D NULL; - char *query_string =3D NULL; + hypervWmiClassInfoPtr wmiInfo =3D NULL; filter_t *filter =3D NULL; WsXmlDocH response =3D NULL; char *enumContext =3D NULL; @@ -160,18 +159,14 @@ hypervEnumAndPull(hypervPrivate *priv, virBufferPtr q= uery, const char *root, XML_TYPE_PTR data =3D NULL; hypervObject *object; =20 - if (virBufferCheckError(query) < 0) { - virBufferFreeAndReset(query); - return -1; - } - query_string =3D virBufferContentAndReset(query); - if (list =3D=3D NULL || *list !=3D NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument")= ); - VIR_FREE(query_string); return -1; } =20 + if (hypervGetWmiClassInfo(priv, wqlQuery->info, &wmiInfo) < 0) + return -1; + serializerContext =3D wsmc_get_serialization_context(priv->client); =20 options =3D wsmc_options_init(); @@ -182,7 +177,7 @@ hypervEnumAndPull(hypervPrivate *priv, virBufferPtr que= ry, const char *root, goto cleanup; } =20 - filter =3D filter_create_simple(WSM_WQL_FILTER_DIALECT, query_string); + filter =3D filter_create_simple(WSM_WQL_FILTER_DIALECT, wqlQuery->quer= y); =20 if (filter =3D=3D NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", @@ -190,7 +185,8 @@ hypervEnumAndPull(hypervPrivate *priv, virBufferPtr que= ry, const char *root, goto cleanup; } =20 - response =3D wsmc_action_enumerate(priv->client, root, options, filter= ); + response =3D wsmc_action_enumerate(priv->client, wmiInfo->rootUri, opt= ions, + filter); =20 if (hypervVerifyResponse(priv->client, response, "enumeration") < 0) goto cleanup; @@ -201,7 +197,7 @@ hypervEnumAndPull(hypervPrivate *priv, virBufferPtr que= ry, const char *root, response =3D NULL; =20 while (enumContext !=3D NULL && *enumContext !=3D '\0') { - response =3D wsmc_action_pull(priv->client, resourceUri, options, + response =3D wsmc_action_pull(priv->client, wmiInfo->resourceUri, = options, filter, enumContext); =20 if (hypervVerifyResponse(priv->client, response, "pull") < 0) @@ -231,11 +227,12 @@ hypervEnumAndPull(hypervPrivate *priv, virBufferPtr q= uery, const char *root, goto cleanup; } =20 - if (ws_xml_get_child(node, 0, resourceUri, className) =3D=3D NULL) + if (ws_xml_get_child(node, 0, wmiInfo->resourceUri, + wmiInfo->name) =3D=3D NULL) break; =20 - data =3D ws_deserialize(serializerContext, node, serializerInfo, - className, resourceUri, NULL, 0, 0); + data =3D ws_deserialize(serializerContext, node, wmiInfo->serializ= erInfo, + wmiInfo->name, wmiInfo->resourceUri, NULL, 0= , 0); =20 if (data =3D=3D NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", @@ -246,8 +243,8 @@ hypervEnumAndPull(hypervPrivate *priv, virBufferPtr que= ry, const char *root, if (VIR_ALLOC(object) < 0) goto cleanup; =20 - object->serializerInfo =3D serializerInfo; - object->data =3D data; + object->info =3D wmiInfo; + object->data.common =3D data; =20 data =3D NULL; =20 @@ -283,13 +280,12 @@ hypervEnumAndPull(hypervPrivate *priv, virBufferPtr q= uery, const char *root, /* FIXME: ws_serializer_free_mem is broken in openwsman <=3D 2.2.6, * see hypervFreeObject for a detailed explanation. */ if (ws_serializer_free_mem(serializerContext, data, - serializerInfo) < 0) { + wmiInfo->serializerInfo) < 0) { VIR_ERROR(_("Could not free deserialized data")); } #endif } =20 - VIR_FREE(query_string); ws_xml_destroy_doc(response); VIR_FREE(enumContext); hypervFreeObject(priv, head); diff --git a/src/hyperv/hyperv_wmi.h b/src/hyperv/hyperv_wmi.h index 12b94af..8ce32a9 100644 --- a/src/hyperv/hyperv_wmi.h +++ b/src/hyperv/hyperv_wmi.h @@ -32,7 +32,6 @@ =20 # define HYPERV_WQL_QUERY_INITIALIZER {NULL, NULL} =20 -typedef struct _hypervObject hypervObject; =20 int hypervVerifyResponse(WsManClient *client, WsXmlDocH response, const char *detail); @@ -42,8 +41,8 @@ int hypervVerifyResponse(WsManClient *client, WsXmlDocH r= esponse, /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *= * * * Object */ -typedef struct _hypervObjectUnified hypervObjectUnified; -struct _hypervObjectUnified { +typedef struct _hypervObject hypervObject; +struct _hypervObject { /* Unserialized data from wsman response. The member called "common" h= as * properties that are the same type and name for all "versions" of gi= ven * WMI class. This means that calling code does not have to make any @@ -59,7 +58,7 @@ struct _hypervObjectUnified { /* The info used to make wsman request */ hypervWmiClassInfoPtr info; =20 - hypervObjectUnified *next; + hypervObject *next; }; =20 typedef struct _hypervWqlQuery hypervWqlQuery; @@ -69,15 +68,7 @@ struct _hypervWqlQuery { hypervWmiClassInfoListPtr info; }; =20 -struct _hypervObject { - XmlSerializerInfo *serializerInfo; - XML_TYPE_PTR data; - hypervObject *next; -}; - -int hypervEnumAndPull(hypervPrivate *priv, virBufferPtr query, - const char *root, XmlSerializerInfo *serializerInfo, - const char *resourceUri, const char *className, +int hypervEnumAndPull(hypervPrivate *priv, hypervWqlQueryPtr wqlQuery, hypervObject **list); =20 void hypervFreeObject(hypervPrivate *priv, hypervObject *object); --=20 2.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat Apr 27 16:50:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zoho.com; dkim=fail spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1491108746983851.6099679525028; Sat, 1 Apr 2017 21:52:26 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 92F31C049D5B; Sun, 2 Apr 2017 04:52:25 +0000 (UTC) Received: from colo-mx.corp.redhat.com (unknown [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 65C051713B; Sun, 2 Apr 2017 04:52:25 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 1CEB15EC62; Sun, 2 Apr 2017 04:52:25 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v324pSel019114 for ; Sun, 2 Apr 2017 00:51:28 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2195FA0A18; Sun, 2 Apr 2017 04:51:28 +0000 (UTC) Received: from mx1.redhat.com (ext-mx06.extmail.prod.ext.phx2.redhat.com [10.5.110.30]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1977418EFB for ; Sun, 2 Apr 2017 04:51:26 +0000 (UTC) Received: from mail-qk0-f178.google.com (mail-qk0-f178.google.com [209.85.220.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AEDFF3B71F for ; Sun, 2 Apr 2017 04:50:59 +0000 (UTC) Received: by mail-qk0-f178.google.com with SMTP id g195so21332118qke.2 for ; Sat, 01 Apr 2017 21:50:58 -0700 (PDT) Received: from dawid-fedora.datto.lan ([47.19.105.250]) by smtp.gmail.com with ESMTPSA id c10sm6934829qka.1.2017.04.01.21.50.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 01 Apr 2017 21:50:54 -0700 (PDT) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 92F31C049D5B Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=datto.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 92F31C049D5B Authentication-Results: mx1.redhat.com; dkim=fail reason="signature verification failed" (2048-bit key) header.d=datto-com.20150623.gappssmtp.com header.i=@datto-com.20150623.gappssmtp.com header.b="cUFKRTEJ" DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com AEDFF3B71F Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=datto.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=dzamirski@datto.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com AEDFF3B71F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=datto-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Jg5FWIUkufpoIVg9cEdzlRTCwvVEZNCDqii3I69my/U=; b=cUFKRTEJcfCc/g7yos5fBwMI9XSmD6z20VH/1/9H0Z3bCsIZ2MlKbPMp4SKzQ7+2To TjQjsIhcuIU9b9/iHQLzrs0YH+zsWgFIMkThUUyBS/MYYJrZyHe53En3/tjPIO3ue3PS lb5MyQutGBiO8Yyhgk3g7TjRvY7rcdJvWhj3bsRCU8yRV4XsNMrB6Piom3i3y59iUt/N ni7Plgz6m8uYITb/ejzjMripA1Q8GrFrxWBm7D5zhYPMnplo3AklbV8H7SFLDnL6cDKx DsWPMqKFnx4DP2V0sCZkZsU1gJdItbv0IgZ/ZsARRcbrm0ShSbwuPoiU2Z5wntVrKbsZ x9Xw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Jg5FWIUkufpoIVg9cEdzlRTCwvVEZNCDqii3I69my/U=; b=RHxpuzXCL+Ux2EcQ9XQgUhjYcU2MO5LJFiILgZomWEbPWJqBIgxXirakRVagv+mphn Mwxnd50nqC4sUsfOtBq+VGcc19t+NMzzVXetxOKkPxrsGVbCw4UfR8kibFnF9pcooSve ZmjjOW0MIfwdeGU055T2Nx0y3tNqeMXhhddqgIjFrMM64XwjkGlVfQiXdAjnZhREjTHw XJyq1z0QRFNS5BpbqghdUpHIU22Oi2ZXuVVtVNNiG4qo6dy18w65vjLpRo7tLZL1rcUk 9Ag0mDyHXVD4w685+1luWzX2pRk0oBWxVujdYBFHRWErbPgpU2+3Ua6S5pYZl6n+wLnl luxQ== X-Gm-Message-State: AFeK/H2q9pn7YrRUn67dN22EdSDy9Y6mo34L1Zmo1BM+LT4V+D/jpz6tZtsVOnvMX/+5gcND X-Received: by 10.55.53.136 with SMTP id c130mr10486566qka.107.1491108654836; Sat, 01 Apr 2017 21:50:54 -0700 (PDT) From: Dawid Zamirski To: libvir-list@redhat.com Date: Sun, 2 Apr 2017 00:50:45 -0400 Message-Id: <20170402045049.19631-7-dzamirski@datto.com> In-Reply-To: <20170402045049.19631-1-dzamirski@datto.com> References: <20170402045049.19631-1-dzamirski@datto.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Sun, 02 Apr 2017 04:51:03 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Sun, 02 Apr 2017 04:51:03 +0000 (UTC) for IP:'209.85.220.178' DOMAIN:'mail-qk0-f178.google.com' HELO:'mail-qk0-f178.google.com' FROM:'dzamirski@datto.com' RCPT:'' X-RedHat-Spam-Score: 0.369 (BAYES_50, DCC_REPUT_00_12, DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_PASS) 209.85.220.178 mail-qk0-f178.google.com 209.85.220.178 mail-qk0-f178.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.30 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: Sri Ramanujam Subject: [libvirt] [PATCH v2 06/10] hyperv: update generator input file. X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Sun, 02 Apr 2017 04:52:26 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Adds defintiions for "v2" WMI class variants that are needed by the driver to handle both hyperv 2008 and 2012+ --- src/hyperv/hyperv_wmi_generator.input | 239 +++++++++++++++++++++++++++++-= ---- 1 file changed, 206 insertions(+), 33 deletions(-) diff --git a/src/hyperv/hyperv_wmi_generator.input b/src/hyperv/hyperv_wmi_= generator.input index 209a9ff..d7f819e 100644 --- a/src/hyperv/hyperv_wmi_generator.input +++ b/src/hyperv/hyperv_wmi_generator.input @@ -56,6 +56,55 @@ class Msvm_ComputerSystem end =20 =20 +class v2/Msvm_ComputerSystem + string InstanceID + string Caption + string Description + string ElementName + datetime InstallDate + uint16 OperationalStatus[] + string StatusDescriptions[] + string Status + uint16 HealthState + uint16 CommunicationStatus + uint16 DetailedStatus + uint16 OperatingStatus + uint16 PrimaryStatus + uint16 EnabledState + string OtherEnabledState + uint16 RequestedState + uint16 EnabledDefault + datetime TimeOfLastStateChange + uint16 AvailableRequestedStates[] + uint16 TransitioningToState + string CreationClassName + string Name + string PrimaryOwnerName + string PrimaryOwnerContact + string Roles[] + string NameFormat + string OtherIdentifyingInfo[] + string IdentifyingDescriptions[] + uint16 Dedicated[] + string OtherDedicatedDescriptions[] + uint16 ResetCapability + uint16 PowerManagementCapabilities[] + uint64 OnTimeInMilliseconds + uint32 ProcessID + datetime TimeOfLastConfigurationChange + uint16 NumberOfNumaNodes + uint16 ReplicationState + uint16 ReplicationHealth + uint16 ReplicationMode + uint16 FailedOverReplicationType + uint16 LastReplicationType + datetime LastApplicationConsistentReplicationTime + datetime LastReplicationTime + datetime LastSuccessfulBackupTime + uint16 EnhancedSessionModeState +end + + class Msvm_ConcreteJob string Caption string Description @@ -96,6 +145,51 @@ class Msvm_ConcreteJob end =20 =20 +class v2/Msvm_ConcreteJob + string InstanceID + string Caption + string Description + string ElementName + datetime InstallDate + string Name + uint16 OperationalStatus[] + string StatusDescriptions[] + string Status + uint16 HealthState + uint16 CommunicationStatus + uint16 DetailedStatus + uint16 OperatingStatus + uint16 PrimaryStatus + string JobStatus + datetime TimeSubmitted + datetime ScheduledStartTime + datetime StartTime + datetime ElapsedTime + uint32 JobRunTimes + uint8 RunMonth + sint8 RunDay + sint8 RunDayOfWeek + datetime RunStartInterval + uint16 LocalOrUtcTime + datetime UntilTime + string Notify + string Owner + uint32 Priority + uint16 PercentComplete + boolean DeleteOnCompletion + uint16 ErrorCode + string ErrorDescription + string ErrorSummaryDescription + uint16 RecoveryAction + string OtherRecoveryAction + uint16 JobState + datetime TimeOfLastStateChange + datetime TimeBeforeRemoval + boolean Cancellable + uint16 JobType +end + + class Msvm_MemorySettingData string Caption string Description @@ -126,6 +220,38 @@ class Msvm_MemorySettingData end =20 =20 +class v2/Msvm_MemorySettingData + string InstanceID + string Caption + string Description + string ElementName + uint16 ResourceType + string OtherResourceType + string ResourceSubType + string PoolID + uint16 ConsumerVisibility + string HostResource[] + string AllocationUnits + uint64 VirtualQuantity + uint64 Reservation + uint64 Limit + uint32 Weight + boolean AutomaticAllocation + boolean AutomaticDeallocation + string Parent + string Connection[] + string Address + uint16 MappingBehavior + string AddressOnParent + string VirtualQuantityUnits + boolean DynamicMemoryEnabled + uint32 TargetMemoryBuffer + boolean IsVirtualized + boolean SwapFilesInUse + uint64 MaxMemoryBlocksPerNumaNode +end + + class Msvm_ProcessorSettingData string Caption string Description @@ -159,6 +285,37 @@ class Msvm_ProcessorSettingData end =20 =20 +class v2/Msvm_ProcessorSettingData + string InstanceID + string Caption + string Description + string ElementName + uint16 ResourceType + string OtherResourceType + string ResourceSubType + string PoolID + uint16 ConsumerVisibility + string HostResource[] + string AllocationUnits + uint64 VirtualQuantity + uint64 Reservation + uint64 Limit + uint32 Weight + boolean AutomaticAllocation + boolean AutomaticDeallocation + string Parent + string Connection[] + string Address + uint16 MappingBehavior + string AddressOnParent + string VirtualQuantityUnits + boolean LimitCPUID + boolean LimitProcessorFeatures + uint64 MaxProcessorsPerNumaNode + uint64 MaxNumaNodesPerSocket +end + + class Msvm_VirtualSystemSettingData string Caption string Description @@ -184,6 +341,55 @@ class Msvm_VirtualSystemSettingData end =20 =20 +class v2/Msvm_VirtualSystemSettingData + string InstanceID + string Caption + string Description + string ElementName + string VirtualSystemIdentifier + string VirtualSystemType + string Notes[] + datetime CreationTime + string ConfigurationID + string ConfigurationDataRoot + string ConfigurationFile + string SnapshotDataRoot + string SuspendDataRoot + string SwapFileDataRoot + string LogDataRoot + uint16 AutomaticStartupAction + datetime AutomaticStartupActionDelay + uint16 AutomaticStartupActionSequenceNumber + uint16 AutomaticShutdownAction + uint16 AutomaticRecoveryAction + string RecoveryFile + string BIOSGUID + string BIOSSerialNumber + string BaseBoardSerialNumber + string ChassisSerialNumber + string ChassisAssetTag + boolean BIOSNumLock + uint16 BootOrder[] + string Parent + boolean IsSaved + string AdditionalRecoveryInformation + boolean AllowFullSCSICommandSet + uint32 DebugChannelId + uint16 DebugPortEnabled + uint32 DebugPort + string Version + boolean IncrementalBackupEnabled + boolean VirtualNumaEnabled + boolean AllowReducedFcRedundancy + string VirtualSystemSubType + string BootSourceOrder[] + boolean PauseAfterBootFailure + uint16 NetworkBootPreferredProtocol + boolean SecureBootEnabled + uint64 LowMmioGapSize +end + + class Win32_ComputerSystem uint16 AdminPasswordStatus boolean AutomaticManagedPagefile @@ -607,39 +813,6 @@ class Msvm_VirtualSystemGlobalSettingData end =20 =20 -class Msvm_VirtualSwitch - string Caption - string Description - string ElementName - datetime InstallDate - uint16 OperationalStatus[] - string StatusDescriptions[] - string Status - uint16 HealthState - uint16 EnabledState - string OtherEnabledState - uint16 RequestedState - uint16 EnabledDefault - datetime TimeOfLastStateChange - string CreationClassName - string Name - string PrimaryOwnerContact - string PrimaryOwnerName - string Roles[] - string NameFormat - string OtherIdentifyingInfo[] - string IdentifyingDescriptions[] - uint16 Dedicated[] - string OtherDedicatedDescriptions[] - uint16 ResetCapability - uint16 PowerManagementCapabilities[] - string ScopeOfResidence - uint32 NumLearnableAddresses - uint32 MaxVMQOffloads - uint32 MaxChimneyOffloads -end - - class Msvm_ResourceAllocationSettingData string Caption string Description --=20 2.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat Apr 27 16:50:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zoho.com; dkim=fail spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 14911088048051.22522584412809; Sat, 1 Apr 2017 21:53:24 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7EC5481245; Sun, 2 Apr 2017 04:53:23 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 581331713D; Sun, 2 Apr 2017 04:53:23 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 1684818523C6; Sun, 2 Apr 2017 04:53:23 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v324pXcj019171 for ; Sun, 2 Apr 2017 00:51:33 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9F96F18EFB; Sun, 2 Apr 2017 04:51:32 +0000 (UTC) Received: from mx1.redhat.com (ext-mx03.extmail.prod.ext.phx2.redhat.com [10.5.110.27]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9802FA0A18 for ; Sun, 2 Apr 2017 04:51:31 +0000 (UTC) Received: from mail-qk0-f177.google.com (mail-qk0-f177.google.com [209.85.220.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 80C3E80F7C for ; Sun, 2 Apr 2017 04:51:01 +0000 (UTC) Received: by mail-qk0-f177.google.com with SMTP id d10so93821861qke.1 for ; Sat, 01 Apr 2017 21:50:59 -0700 (PDT) Received: from dawid-fedora.datto.lan ([47.19.105.250]) by smtp.gmail.com with ESMTPSA id c10sm6934829qka.1.2017.04.01.21.50.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 01 Apr 2017 21:50:55 -0700 (PDT) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 7EC5481245 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=datto.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 7EC5481245 Authentication-Results: mx1.redhat.com; dkim=fail reason="signature verification failed" (2048-bit key) header.d=datto-com.20150623.gappssmtp.com header.i=@datto-com.20150623.gappssmtp.com header.b="X5tCCQuB" DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 80C3E80F7C Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=datto.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=dzamirski@datto.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 80C3E80F7C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=datto-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=XLau8gjVFNO/F6j0nEtX1ga1//HeF3j5OExKvRZZAbA=; b=X5tCCQuBVfmjO0l0rqMTpULEtLdSHJ6efv/fGd+EjrfIU5wfrfXL8ZE23CU5XTcfve kaX541m+6aulFyOazmuUTd4QxQ7wXBkoFhJhYZ+0ilGbhiDRt8P8teFrt9jGrgw9IFSH iWCKb9ENT3Y0PscLxxnowtqq+UHo3AcIt97q7cOAiPTBUOtJXHuhRgEOPNO8yDNTbaOS XYzJWaQ8VEC6oDmHdx9+R4mpmNIgU1yKpkYB1u9M1B1z0xhLF6XlkyNzhRKLefy506uc MSfr6VaOhTpfHteC44EBpo22gahFZVrEvq11H4aSJ3wiPYt6NyCYbEYgapabTGss8EFp tryg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=XLau8gjVFNO/F6j0nEtX1ga1//HeF3j5OExKvRZZAbA=; b=nmP5FyKGNAAecZqywVx+DN7nfuFQtf+rv60wdukKhqbnF8Omedzxg6OFgl6JjyBDMC zR5jhMYSHppfeDHWc4ye8qg1AuttV4DS4nUxGrYC0GHNax21gLSVwEPk57lJ0drawh5n yreJ20UYALWydEdCjBYmygzyPvndY8wM1CMeCVllCnJ4nPqyQyWxjzlR/2InuCJ/lZo3 KTdmnkFev/YDu5YqV8FS36gyUX4IID8UhpusCwoi3NCGnJVM/hymS1+/TyKgDuaIVH+Q 2Wy8FJS01Pcw44b5U3ka53FaS9SgItcckpTZby9kA9HBeF7ullOIZsyib6aCBSWCUvFn tADw== X-Gm-Message-State: AFeK/H15B58oawLoOZHMlVGIcSwyJpkhmPwl4dD7MdmfIwW7007SYl12vZZkoSR6M+zY0ugt X-Received: by 10.55.198.157 with SMTP id s29mr4669283qkl.74.1491108655421; Sat, 01 Apr 2017 21:50:55 -0700 (PDT) From: Dawid Zamirski To: libvir-list@redhat.com Date: Sun, 2 Apr 2017 00:50:46 -0400 Message-Id: <20170402045049.19631-8-dzamirski@datto.com> In-Reply-To: <20170402045049.19631-1-dzamirski@datto.com> References: <20170402045049.19631-1-dzamirski@datto.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Sun, 02 Apr 2017 04:51:04 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Sun, 02 Apr 2017 04:51:04 +0000 (UTC) for IP:'209.85.220.177' DOMAIN:'mail-qk0-f177.google.com' HELO:'mail-qk0-f177.google.com' FROM:'dzamirski@datto.com' RCPT:'' X-RedHat-Spam-Score: 0.509 (BAYES_50, DCC_REPUT_00_12, DKIM_SIGNED, SPF_PASS, T_DKIM_INVALID) 209.85.220.177 mail-qk0-f177.google.com 209.85.220.177 mail-qk0-f177.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.27 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: Sri Ramanujam Subject: [libvirt] [PATCH v2 07/10] hyperv: update wmi code generator. X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Sun, 02 Apr 2017 04:53:24 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This patch updates the code generator that outputs C headers and code for WMI classes. It has been updated to handle multiple versions (or namespaces) of the same class which were introduced with Hyperv 2012+ --- src/hyperv/hyperv_wmi_generator.py | 385 +++++++++++++++++++++++++++------= ---- 1 file changed, 288 insertions(+), 97 deletions(-) diff --git a/src/hyperv/hyperv_wmi_generator.py b/src/hyperv/hyperv_wmi_gen= erator.py index 8c62882..f2c9cde 100755 --- a/src/hyperv/hyperv_wmi_generator.py +++ b/src/hyperv/hyperv_wmi_generator.py @@ -24,130 +24,310 @@ import sys import os import os.path =20 +separator =3D "/*" + ("*" * 50) + "*\n" +wmi_version_separator =3D "/" +wmi_classes_by_name =3D {} + +class WmiClass: + """Represents WMI class and provides methods to generate C code. + + This class holds one or more instances of WmiClassVersion because with= the + Windows 2012 release, Microsoft introduced "v2" version of Msvm_* fami= ly of + classes that need different URI for making wsman requests and also have + some additional/changed properties (though many of the properies are t= he + same as in "v1". Therefore, this class makes sure that C code is gener= ated + for each of them while avoiding name conflics, identifies common membe= rs, + and defined *_WmiInfo structs holding info about each version so the d= river + code can make the right choices based on which Hyper-v host it's conne= cted + to. + """ + + def __init__(self, name, versions =3D []): + self.name =3D name + self.versions =3D versions + self.common =3D None =20 =20 -separator =3D "/* " + ("* " * 37) + "*\n" + def prepare(self): + """Prepares the class for code generation =20 + Makes sure that "versioned" classes are sorted by version, identfi= es + common properies and ensures that they are aligned by name and + type in each version + """ + # sort vesioned classes by version in case input file did not have= them + # in order + self.versions =3D sorted(self.versions, key=3Dlambda cls: cls.vers= ion) =20 + # if there's more than one verion make sure first one has name suf= fixed + # because we'll generate "common" memeber and will be the "base" n= ame + if len(self.versions) > 1: + first =3D self.versions[0] + if first.version =3D=3D None: + first.version =3D "v1" + first.name =3D "%s_%s" % (first.name, first.version) =20 -class Class: - def __init__(self, name, properties): - self.name =3D name - self.properties =3D properties + # finally, identify common members in all versions and make sure t= hey + # are in the same order - to ensure C struc member alignment + self._align_property_members() =20 =20 - def generate_header(self): + def generate_classes_header(self): + """Generate C header code and return it as string + + Declares: + _Data - used as one of hypervObject->data members + _TypeInfo - used as wsman XmlSerializerInfo + - "inherits" hypervObject struct + """ + name_upper =3D self.name.upper() =20 header =3D separator header +=3D " * %s\n" % self.name header +=3D " */\n" header +=3D "\n" - header +=3D "int hypervGet%sList(hypervPrivate *priv, virBufferPtr= query, %s **list);\n" \ - % (self.name.replace("_", ""), self.name) - header +=3D "\n" + header +=3D "#define %s_CLASSNAME \\\n" % name_upper + header +=3D " \"%s\"\n" % self.name header +=3D "\n" + header +=3D "#define %s_WQL_SELECT \\\n" % name_upper + header +=3D " \"SELECT * FROM %s \"\n" % self.name header +=3D "\n" + header +=3D "extern hypervWmiClassInfoListPtr %s_WmiInfo;\n\n" % s= elf.name + + header +=3D self._declare_data_structs() + header +=3D self._declare_hypervObject_struct() =20 return header =20 =20 + def generate_classes_source(self): + """Returns a C code string defining wsman data structs + + Defines: + _Data structs + _WmiInfo - list holding metadata (e.g. request URIs)= for + each known version of WMI class. + """ + + source =3D separator + source +=3D " * %s\n" % self.name + source +=3D " */\n" + + for cls in self.versions: + source +=3D "SER_START_ITEMS(%s_Data)\n" % cls.name + + for property in cls.properties: + source +=3D property.generate_classes_source(cls.name) + + source +=3D "SER_END_ITEMS(%s_Data);\n\n" % cls.name + + + source +=3D self._define_WmiInfo_struct() + source +=3D "\n\n" + + return source + + def generate_classes_typedef(self): - typedef =3D "typedef struct _%s_Data %s_Data;\n" % (self.name, sel= f.name) - typedef +=3D "typedef struct _%s %s;\n" % (self.name, self.name) + """Returns C string for typdefs""" + + typedef =3D "typedef struct _%s %s;\n" % (self.name, self.name) + + if self.common is not None: + typedef +=3D "typedef struct _%s_Data %s_Data;\n" % (self.name= , self.name) + + for cls in self.versions: + typedef +=3D "typedef struct _%s_Data %s_Data;\n" % (cls.name,= cls.name) =20 return typedef =20 =20 - def generate_classes_header(self): - name_upper =3D self.name.upper() =20 - header =3D separator - header +=3D " * %s\n" % self.name - header +=3D " */\n" - header +=3D "\n" - header +=3D "#define %s_RESOURCE_URI \\\n" % name_upper + def _declare_data_structs(self): + """Returns string C code declaring data structs. =20 - if self.name.startswith("Win32_") or self.name.startswith("CIM_"): - header +=3D " \"http://schemas.microsoft.com/wbem/wsman/1/w= mi/root/cimv2/%s\"\n" % self.name - else: - header +=3D " \"http://schemas.microsoft.com/wbem/wsman/1/w= mi/root/virtualization/%s\"\n" % self.name + The *_Data structs are members of hypervObject data union. Each on= e has + corresponding *_TypeInfo that is used for wsman unserialization of + response XML into the *_Data structs. If there's a "common" member= , it + won't have corresponding *_TypeInfo becuase this is a special case= only + used to provide a common "view" of v1, v2 etc members + """ =20 - header +=3D "\n" - header +=3D "#define %s_CLASSNAME \\\n" % name_upper - header +=3D " \"%s\"\n" % self.name - header +=3D "\n" - header +=3D "#define %s_WQL_SELECT \\\n" % name_upper - header +=3D " \"select * from %s \"\n" % self.name - header +=3D "\n" - header +=3D "struct _%s_Data {\n" % self.name + header =3D "" + if self.common is not None: + header +=3D "struct _%s_Data {\n" % self.name + for property in self.common: + header +=3D property.generate_classes_header() + header +=3D "};\n\n" =20 - for property in self.properties: - header +=3D property.generate_classes_header() + # Declare actual data struct for each versions + for cls in self.versions: + header +=3D "#define %s_RESOURCE_URI \\\n" % cls.name.upper() + header +=3D " \"%s\"\n" % cls.uri_info.resourceUri + header +=3D "\n" + header +=3D "struct _%s_Data {\n" % cls.name + for property in cls.properties: + header +=3D property.generate_classes_header() + header +=3D "};\n\n" + header +=3D "SER_DECLARE_TYPE(%s_Data);\n" % cls.name =20 - header +=3D "};\n" - header +=3D "\n" - header +=3D "SER_DECLARE_TYPE(%s_Data);\n" % self.name - header +=3D "\n" + return header + + + def _declare_hypervObject_struct(self): + """Return string for C code declaring hypervObject instance""" + + header =3D "\n/* must match hypervObject */\n" header +=3D "struct _%s {\n" % self.name - header +=3D " XmlSerializerInfo *serializerInfo;\n" - header +=3D " %s_Data *data;\n" % self.name + header +=3D " union {\n" + + # if there's common use it as "common" else first and only version= is + # the "common" member + if self.common is not None: + header +=3D " %s_Data *common;\n" % self.name + else: + header +=3D " %s_Data *common;\n" % self.versions[0].na= me + + for cls in self.versions: + header +=3D " %s_Data *%s;\n" % (cls.name, cls.version) + + header +=3D " } data;\n" + header +=3D " hypervWmiClassInfoPtr info;\n" header +=3D " %s *next;\n" % self.name header +=3D "};\n" - header +=3D "\n" - header +=3D "\n" - header +=3D "\n" + + header +=3D "\n\n\n" =20 return header =20 =20 - def generate_source(self): - name_upper =3D self.name.upper() + def _define_WmiInfo_struct(self): + """Return string for C code defining *_WmiInfo struct =20 - source =3D separator - source +=3D " * %s\n" % self.name - source +=3D " */\n" - source +=3D "\n" - source +=3D "int\n" - source +=3D "hypervGet%sList(hypervPrivate *priv, virBufferPtr que= ry, %s **list)\n" \ - % (self.name.replace("_", ""), self.name) - source +=3D "{\n" - - if self.name.startswith("Win32_") or self.name.startswith("CIM_"): - source +=3D " return hypervEnumAndPull(priv, query, ROOT_CI= MV2,\n" - else: - source +=3D " return hypervEnumAndPull(priv, query, ROOT_VI= RTUALIZATION,\n" + Those structs hold info with meta-data needed to make wsman reques= ts for + each version of WMI class + """ + + source =3D "hypervWmiClassInfoListPtr %s_WmiInfo =3D &(hypervWmiCl= assInfoList) {\n" % self.name + source +=3D " .count =3D %d,\n" % len(self.versions) + source +=3D " .objs =3D (hypervWmiClassInfoPtr []) {\n" =20 - source +=3D " %s_Data_TypeInfo,\n" % s= elf.name - source +=3D " %s_RESOURCE_URI,\n" % na= me_upper - source +=3D " %s_CLASSNAME,\n" % name_= upper - source +=3D " (hypervObject **)list);\= n" - source +=3D "}\n" - source +=3D "\n" - source +=3D "\n" - source +=3D "\n" + for cls in self.versions: + source +=3D " &(hypervWmiClassInfo) {\n" + source +=3D " .name =3D %s_CLASSNAME,\n" % self.nam= e.upper() + if cls.version is not None: + source +=3D " .version =3D \"%s\",\n" % cls.ver= sion + else: + source +=3D " .version =3D NULL,\n" + source +=3D " .rootUri =3D %s,\n" % cls.uri_info.ro= otUri + source +=3D " .resourceUri =3D %s_RESOURCE_URI,\n" = % cls.name.upper() + source +=3D " .serializerInfo =3D %s_Data_TypeInfo\= n" % cls.name + source +=3D " },\n" + + source +=3D " }\n" + source +=3D "};\n" =20 return source =20 =20 - def generate_classes_source(self): - name_upper =3D self.name.upper() + def _align_property_members(self): + """Identifies common properties in all class versions. =20 - source =3D separator - source +=3D " * %s\n" % self.name - source +=3D " */\n" - source +=3D "\n" - source +=3D "SER_START_ITEMS(%s_Data)\n" % self.name + Makes sure that properties in all versions are ordered with common + members first and that they are in the same order. This makes the + generated C structs memory aligned and safe to access via the "com= mon" + struct that "shares" members with v1, v2 etc. + """ =20 - for property in self.properties: - source +=3D property.generate_classes_source(self.name) + num_classes =3D len(self.versions) + common =3D {} + property_info =3D {} =20 - source +=3D "SER_END_ITEMS(%s_Data);\n" % self.name - source +=3D "\n" - source +=3D "\n" - source +=3D "\n" + if num_classes < 2: + return + + # count property occurences in all class versions + for cls in self.versions: + for prop in cls.properties: + # consdered same if matches by name AND type + key =3D "%s_%s" % (prop.name, prop.type) + + if key in property_info: + property_info[key][1] +=3D 1 + else: + property_info[key] =3D [prop, 1] + + # isolate those that are common for all and keep track of their po= stions + pos =3D 0 + for key in property_info: + info =3D property_info[key] + # exists in all class versions + if info[1] =3D=3D num_classes: + common[info[0].name] =3D [info[0], pos] + pos +=3D 1 + + # alter each versions's property list so that common members are f= irst + # and in the same order as in the common dictionary + total =3D len(common) + for cls in self.versions: + index =3D 0 + count =3D len(cls.properties) + + while index < count: + prop =3D cls.properties[index] + + # it's a "common" proptery + if prop.name in common: + pos =3D common[prop.name][1] + + # move to the same position as in "common" dictionary + if index !=3D pos: + tmp =3D cls.properties[pos] + cls.properties[pos] =3D prop + cls.properties[index] =3D tmp + else: + index +=3D 1 + else: + index +=3D 1 + + # finally, get common properties as list sorted by position in dic= tionary + tmp =3D sorted(common.values(), key=3Dlambda x: x[1]) + self.common =3D [] + for x in tmp: + self.common.append(x[0]) + + + +class ClassUriInfo: + """Prepares URI information needed for wsman requests.""" + + def __init__(self, wmi_name, version): + self.rootUri =3D "ROOT_CIMV2" + self.resourceUri =3D None + baseUri =3D "http://schemas.microsoft.com/wbem/wsman/1/wmi/root/ci= mv2" + + if wmi_name.startswith("Msvm_"): + baseUri =3D "http://schemas.microsoft.com/wbem/wsman/1/wmi/roo= t/virtualization" + self.rootUri =3D "ROOT_VIRTUALIZATION" + + if version =3D=3D "v2": + baseUri +=3D "/v2" + self.rootUri =3D "ROOT_VIRTUALIZATION_V2" + + self.resourceUri =3D "%s/%s" % (baseUri, wmi_name) + + + +class WmiClassVersion: + """Represents specific version of WMI class.""" + + def __init__(self, name, version, properties, uri_info): + self.name =3D name + self.version =3D version + self.properties =3D properties + self.uri_info =3D uri_info =20 - return source =20 =20 class Property: @@ -155,9 +335,13 @@ class Property: "string" : "STR", "datetime" : "STR", "int8" : "INT8", + "sint8" : "INT8", "int16" : "INT16", + "sint16" : "INT16", "int32" : "INT32", + "sint32" : "INT32", "int64" : "INT64", + "sint64" : "INT64", "uint8" : "UINT8", "uint16" : "UINT16", "uint32" : "UINT32", @@ -189,8 +373,6 @@ class Property: return " SER_NS_%s(%s_RESOURCE_URI, \"%s\", 1),\n" \ % (Property.typemap[self.type], class_name.upper(), sel= f.name) =20 - - def open_and_print(filename): if filename.startswith("./"): print " GEN " + filename[2:] @@ -217,8 +399,15 @@ def parse_class(block): assert header_items[0] =3D=3D "class" =20 name =3D header_items[1] - properties =3D [] + version =3D None + wmi_name =3D name + ns_separator =3D name.find(wmi_version_separator) + + if ns_separator !=3D -1: + version =3D name[:ns_separator] + wmi_name =3D name[ns_separator + 1:] + name =3D "%s_%s" % (wmi_name, version) =20 for line in block[1:]: # expected format: @@ -236,7 +425,13 @@ def parse_class(block): properties.append(Property(type=3Ditems[0], name=3Ditems[1], is_array=3Dis_array)) =20 - return Class(name=3Dname, properties=3Dproperties) + cls =3D WmiClassVersion(name=3Dname, version=3Dversion, properties=3Dp= roperties, + uri_info=3DClassUriInfo(wmi_name, version)) + + if wmi_name in wmi_classes_by_name: + wmi_classes_by_name[wmi_name].versions.append(cls) + else: + wmi_classes_by_name[wmi_name] =3D WmiClass(wmi_name, [cls]) =20 =20 =20 @@ -248,15 +443,13 @@ def main(): input_filename =3D os.path.join(os.getcwd(), "hyperv_wmi_generator= .input") output_dirname =3D os.getcwd() =20 - header =3D open_and_print(os.path.join(output_dirname, "hyperv_wmi.gen= erated.h")) - source =3D open_and_print(os.path.join(output_dirname, "hyperv_wmi.gen= erated.c")) + classes_typedef =3D open_and_print(os.path.join(output_dirname, "hyper= v_wmi_classes.generated.typedef")) classes_header =3D open_and_print(os.path.join(output_dirname, "hyperv= _wmi_classes.generated.h")) classes_source =3D open_and_print(os.path.join(output_dirname, "hyperv= _wmi_classes.generated.c")) =20 - # parse input file + number =3D 0 - classes_by_name =3D {} block =3D None =20 for line in file(input_filename, "rb").readlines(): @@ -268,7 +461,7 @@ def main(): line =3D line.lstrip().rstrip() =20 if len(line) < 1: - continue + continue =20 if line.startswith("class"): if block is not None: @@ -279,8 +472,7 @@ def main(): if block is not None: if line =3D=3D "end": if block[0][1].startswith("class"): - cls =3D parse_class(block) - classes_by_name[cls.name] =3D cls + parse_class(block) =20 block =3D None else: @@ -289,21 +481,20 @@ def main(): # write output files notice =3D "/* Generated by hyperv_wmi_generator.py */\n\n\n\n" =20 - header.write(notice) - source.write(notice) classes_typedef.write(notice) classes_header.write(notice) classes_source.write(notice) =20 - names =3D classes_by_name.keys() + names =3D wmi_classes_by_name.keys() names.sort() =20 for name in names: - header.write(classes_by_name[name].generate_header()) - source.write(classes_by_name[name].generate_source()) - classes_typedef.write(classes_by_name[name].generate_classes_typed= ef()) - classes_header.write(classes_by_name[name].generate_classes_header= ()) - classes_source.write(classes_by_name[name].generate_classes_source= ()) + cls =3D wmi_classes_by_name[name] + cls.prepare() + + classes_typedef.write(cls.generate_classes_typedef()) + classes_header.write(cls.generate_classes_header()) + classes_source.write(cls.generate_classes_source()) =20 =20 =20 --=20 2.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat Apr 27 16:50:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zoho.com; dkim=fail spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1491108750441765.119909020738; Sat, 1 Apr 2017 21:52:30 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id ED051C06584F; Sun, 2 Apr 2017 04:52:28 +0000 (UTC) Received: from colo-mx.corp.redhat.com (unknown [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BBF80785D1; Sun, 2 Apr 2017 04:52:28 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 6A8085EC65; Sun, 2 Apr 2017 04:52:28 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v324pZsC019198 for ; Sun, 2 Apr 2017 00:51:35 -0400 Received: by smtp.corp.redhat.com (Postfix) id 725A85DD71; Sun, 2 Apr 2017 04:51:34 +0000 (UTC) Received: from mx1.redhat.com (ext-mx01.extmail.prod.ext.phx2.redhat.com [10.5.110.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6A6655DD6A for ; Sun, 2 Apr 2017 04:51:34 +0000 (UTC) Received: from mail-qk0-f172.google.com (mail-qk0-f172.google.com [209.85.220.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DC32081226 for ; Sun, 2 Apr 2017 04:51:00 +0000 (UTC) Received: by mail-qk0-f172.google.com with SMTP id p22so93442661qka.3 for ; Sat, 01 Apr 2017 21:50:59 -0700 (PDT) Received: from dawid-fedora.datto.lan ([47.19.105.250]) by smtp.gmail.com with ESMTPSA id c10sm6934829qka.1.2017.04.01.21.50.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 01 Apr 2017 21:50:55 -0700 (PDT) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com ED051C06584F Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=datto.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com ED051C06584F Authentication-Results: mx1.redhat.com; dkim=fail reason="signature verification failed" (2048-bit key) header.d=datto-com.20150623.gappssmtp.com header.i=@datto-com.20150623.gappssmtp.com header.b="eBVsDQhX" DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com DC32081226 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=datto.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=dzamirski@datto.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com DC32081226 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=datto-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=igDlfauv3FByqJkSofcFJeNRpdI7FGH20AIqaxzF8wc=; b=eBVsDQhX7B1kIxoaXlm78NscW3LY5ylTSF/VYSQJDSiKmfxrx3FxS7VNR70z2jsgXn 8I9YfwDAqXG3Wl75K8Gxcj4pUMwlqXgKiSniQebKaEnswqmuoKoXTPZs2y52RSMk2TP8 SvQtSdW7MEU6PmdJp4KY+9hH7DvThbzU1LN+H978ZFriPyfQXgjEFezi9Gibcyk/2tDk jjh3mqQ8URWellQrMP4deXdCfg+Rn80i0u8TGyPHRU8P4bJJZbI/qZ67vEWz7SlC0yXN O3m5id1H4tU0ePjcIzSPgVsou6D6/AHQSFwwomfiiu43WkLwg06UoQ9by9PonivlNIHP T7Tg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=igDlfauv3FByqJkSofcFJeNRpdI7FGH20AIqaxzF8wc=; b=GVqRsxfSNVn7SS9V7Kl1LQqy3KbIsAFaFt4YoHUv5p2iI41WObNvbx0a7igMn1mWLL CXLU1vMCRvd40exwwDc1gqFL2x0ZdF4o8YMp/fUOu/JIfPIGvO43TW7u1M926xiEjjW2 /HdjrJy8Ig3LYnXctKdlEQWHKtp9b6kOtsPE1HrQuH4GlCxtpcoef9Ydoslgdzzr1O0z wCVCqHQx0NNHpnarI6e6ChfTCrS/YxhFjHYEKHyIsHgaDfpD6q2RNP9Aov3yllw3f3CM 48vENambyfd30oRj68s+K9sExe9/RNOoWbGcm/w0a1Buqs0r87A3yTsOG7Ewz6bEzO/7 mZQA== X-Gm-Message-State: AFeK/H3kgsdGaNWDVWwzty5O7wMLE+JdT2OiEHEWtK+rJaucXNu50lhr+29pF16apEwmO3XN X-Received: by 10.55.41.206 with SMTP id p75mr4846079qkp.240.1491108655916; Sat, 01 Apr 2017 21:50:55 -0700 (PDT) From: Dawid Zamirski To: libvir-list@redhat.com Date: Sun, 2 Apr 2017 00:50:47 -0400 Message-Id: <20170402045049.19631-9-dzamirski@datto.com> In-Reply-To: <20170402045049.19631-1-dzamirski@datto.com> References: <20170402045049.19631-1-dzamirski@datto.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Sun, 02 Apr 2017 04:51:06 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Sun, 02 Apr 2017 04:51:06 +0000 (UTC) for IP:'209.85.220.172' DOMAIN:'mail-qk0-f172.google.com' HELO:'mail-qk0-f172.google.com' FROM:'dzamirski@datto.com' RCPT:'' X-RedHat-Spam-Score: 0.999 (BAYES_50, DCC_REPUT_00_12, DKIM_SIGNED, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS, T_DKIM_INVALID) 209.85.220.172 mail-qk0-f172.google.com 209.85.220.172 mail-qk0-f172.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.25 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Cc: Sri Ramanujam Subject: [libvirt] [PATCH v2 08/10] hyperv: add helper for getting WMI class lists. X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Sun, 02 Apr 2017 04:52:29 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Those used to be auto-generated and are hand-written now intead. The reason being that those are not very useful and better replacements are in order once the driver itself implements more of the API and common patterns start to emerge. --- src/Makefile.am | 2 - src/hyperv/hyperv_wmi.c | 81 +++++++++++++++++++++++++++++++++++++= ---- src/hyperv/hyperv_wmi.h | 24 +++++++++++- src/hyperv/hyperv_wmi_classes.h | 8 ++++ 4 files changed, 104 insertions(+), 11 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index 75e4344..99f5229 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -910,8 +910,6 @@ HYPERV_DRIVER_SOURCES =3D \ hyperv/openwsman.h =20 HYPERV_DRIVER_GENERATED =3D \ - hyperv/hyperv_wmi.generated.c \ - hyperv/hyperv_wmi.generated.h \ hyperv/hyperv_wmi_classes.generated.c \ hyperv/hyperv_wmi_classes.generated.h \ hyperv/hyperv_wmi_classes.generated.typedef diff --git a/src/hyperv/hyperv_wmi.c b/src/hyperv/hyperv_wmi.c index 40de8d6..9e62f57 100644 --- a/src/hyperv/hyperv_wmi.c +++ b/src/hyperv/hyperv_wmi.c @@ -36,12 +36,6 @@ =20 #define WS_SERIALIZER_FREE_MEM_WORKS 0 =20 -#define ROOT_CIMV2 \ - "http://schemas.microsoft.com/wbem/wsman/1/wmi/root/cimv2/*" - -#define ROOT_VIRTUALIZATION \ - "http://schemas.microsoft.com/wbem/wsman/1/wmi/root/virtualization/*" - #define VIR_FROM_THIS VIR_FROM_HYPERV =20 =20 @@ -81,6 +75,18 @@ hypervGetWmiClassInfo(hypervPrivate *priv, hypervWmiClas= sInfoListPtr list, return -1; } =20 +static int +hypervGetWmiClassList(hypervPrivate *priv, hypervWmiClassInfoListPtr wmiIn= fo, + virBufferPtr query, hypervObject **wmiClass) +{ + hypervWqlQuery wqlQuery =3D HYPERV_WQL_QUERY_INITIALIZER; + + wqlQuery.info =3D wmiInfo; + wqlQuery.query =3D virBufferContentAndReset(query); + + return hypervEnumAndPull(priv, &wqlQuery, wmiClass); +} + int hypervVerifyResponse(WsManClient *client, WsXmlDocH response, const char *detail) @@ -699,5 +705,66 @@ hypervMsvmComputerSystemFromDomain(virDomainPtr domain, } =20 =20 +int +hypervGetMsvmComputerSystemList(hypervPrivate *priv, virBufferPtr query, + Msvm_ComputerSystem **list) +{ + return hypervGetWmiClassList(priv, Msvm_ComputerSystem_WmiInfo, query, + (hypervObject **) list); +} + + +int +hypervGetMsvmConcreteJobList(hypervPrivate *priv, virBufferPtr query, + Msvm_ConcreteJob **list) +{ + return hypervGetWmiClassList(priv, Msvm_ConcreteJob_WmiInfo, query, + (hypervObject **) list); +} + + +int +hypervGetWin32ComputerSystemList(hypervPrivate *priv, virBufferPtr query, + Win32_ComputerSystem **list) +{ + return hypervGetWmiClassList(priv, Win32_ComputerSystem_WmiInfo, query, + (hypervObject **) list); +} + + +int +hypervGetWin32ProcessorList(hypervPrivate *priv, virBufferPtr query, + Win32_Processor **list) +{ + return hypervGetWmiClassList(priv, Win32_Processor_WmiInfo, query, + (hypervObject **) list); +} + + +int +hypervGetMsvmVirtualSystemSettingDataList(hypervPrivate *priv, + virBufferPtr query, + Msvm_VirtualSystemSettingData **= list) +{ + return hypervGetWmiClassList(priv, Msvm_VirtualSystemSettingData_WmiIn= fo, query, + (hypervObject **) list); +} + + +int +hypervGetMsvmProcessorSettingDataList(hypervPrivate *priv, + virBufferPtr query, + Msvm_ProcessorSettingData **list) +{ + return hypervGetWmiClassList(priv, Msvm_ProcessorSettingData_WmiInfo, = query, + (hypervObject **) list); +} + =20 -#include "hyperv_wmi.generated.c" +int +hypervGetMsvmMemorySettingDataList(hypervPrivate *priv, virBufferPtr query, + Msvm_MemorySettingData **list) +{ + return hypervGetWmiClassList(priv, Msvm_MemorySettingData_WmiInfo, que= ry, + (hypervObject **) list); +} diff --git a/src/hyperv/hyperv_wmi.h b/src/hyperv/hyperv_wmi.h index 8ce32a9..2d90a3b 100644 --- a/src/hyperv/hyperv_wmi.h +++ b/src/hyperv/hyperv_wmi.h @@ -109,7 +109,29 @@ enum _Msvm_ReturnCode { =20 const char *hypervReturnCodeToString(int returnCode); =20 +/* Generic "Get WMI class list" */ +int hypervGetMsvmComputerSystemList(hypervPrivate *priv, virBufferPtr quer= y, + Msvm_ComputerSystem **list); =20 +int hypervGetMsvmConcreteJobList(hypervPrivate *priv, virBufferPtr query, + Msvm_ConcreteJob **list); + +int hypervGetWin32ComputerSystemList(hypervPrivate *priv, virBufferPtr que= ry, + Win32_ComputerSystem **list); + +int hypervGetWin32ProcessorList(hypervPrivate *priv, virBufferPtr query, + Win32_Processor **list); + +int hypervGetMsvmVirtualSystemSettingDataList(hypervPrivate *priv, + virBufferPtr query, + Msvm_VirtualSystemSettingDat= a **list); + +int hypervGetMsvmProcessorSettingDataList(hypervPrivate *priv, + virBufferPtr query, + Msvm_ProcessorSettingData **list= ); + +int hypervGetMsvmMemorySettingDataList(hypervPrivate *priv, virBufferPtr q= uery, + Msvm_MemorySettingData **list); =20 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *= * * * Msvm_ComputerSystem @@ -133,6 +155,4 @@ int hypervMsvmComputerSystemFromDomain(virDomainPtr dom= ain, =20 =20 =20 -# include "hyperv_wmi.generated.h" - #endif /* __HYPERV_WMI_H__ */ diff --git a/src/hyperv/hyperv_wmi_classes.h b/src/hyperv/hyperv_wmi_classe= s.h index b0f3e3c..0b8e29c 100644 --- a/src/hyperv/hyperv_wmi_classes.h +++ b/src/hyperv/hyperv_wmi_classes.h @@ -28,6 +28,14 @@ # include "hyperv_wmi_classes.generated.typedef" =20 =20 +# define ROOT_CIMV2 \ + "http://schemas.microsoft.com/wbem/wsman/1/wmi/root/cimv2/*" + +# define ROOT_VIRTUALIZATION \ + "http://schemas.microsoft.com/wbem/wsman/1/wmi/root/virtualization/*" + +# define ROOT_VIRTUALIZATION_V2 \ + "http://schemas.microsoft.com/wbem/wsman/1/wmi/root/virtualization/v2/= *" =20 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *= * * * Msvm_ComputerSystem --=20 2.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat Apr 27 16:50:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zoho.com; dkim=fail spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1491108747240280.39586861857686; Sat, 1 Apr 2017 21:52:27 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9426113A9A; Sun, 2 Apr 2017 04:52:25 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6709D17CFB; Sun, 2 Apr 2017 04:52:25 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 1F69718523CF; Sun, 2 Apr 2017 04:52:25 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v324pZXp019193 for ; Sun, 2 Apr 2017 00:51:35 -0400 Received: by smtp.corp.redhat.com (Postfix) id 62264A2D7C; Sun, 2 Apr 2017 04:51:35 +0000 (UTC) Received: from mx1.redhat.com (ext-mx10.extmail.prod.ext.phx2.redhat.com [10.5.110.39]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5A9C017169 for ; Sun, 2 Apr 2017 04:51:35 +0000 (UTC) Received: from mail-qk0-f172.google.com (mail-qk0-f172.google.com [209.85.220.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6894C61BA6 for ; Sun, 2 Apr 2017 04:51:03 +0000 (UTC) Received: by mail-qk0-f172.google.com with SMTP id p22so93442693qka.3 for ; Sat, 01 Apr 2017 21:51:00 -0700 (PDT) Received: from dawid-fedora.datto.lan ([47.19.105.250]) by smtp.gmail.com with ESMTPSA id c10sm6934829qka.1.2017.04.01.21.50.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 01 Apr 2017 21:50:56 -0700 (PDT) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 9426113A9A Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=datto.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 9426113A9A Authentication-Results: mx1.redhat.com; dkim=fail reason="signature verification failed" (2048-bit key) header.d=datto-com.20150623.gappssmtp.com header.i=@datto-com.20150623.gappssmtp.com header.b="0Aj0pcUU" DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 6894C61BA6 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=datto.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=dzamirski@datto.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 6894C61BA6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=datto-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=07dxAQ6se83QK0Z1AX5V2UUohYAvuGA+BgaigCkDSi8=; b=0Aj0pcUUkWatmjmk2wEr+Mf9IwCpHVqqact7If2f4zfRZZlv21S1lYGM79tVkUMqzL jT2iKIVaezboSBxb91uhgNqjnqrudmXfdwLHYR28ObzPHvvPj2t1GHJfwutG+gdeVpal /526O2mFsATtbC6S7TvRKWPFo7iVSz/VfRxxu0r+vCwZf4gWvYi11LtvaH/ndRMnl5rV CoVc1q/w6UWc2UcwTLifeDQnmKMpQYb3M5BDapJeUJuLiZSk8UEveYkzPk2dw9j4HoHS XF/D3kPy+obE3y7lVfIPQpFFkyieOK1fKr8AsRkppCAaqZsSLRZYQbdEE5QfpwT60/I3 zoUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=07dxAQ6se83QK0Z1AX5V2UUohYAvuGA+BgaigCkDSi8=; b=DrH0AEE9o/1xrtBj6vh/eChdcQZbkXs3POjT2Y/U90yFrHGzdvqOs6cUDQuZFph7Op VdHhzl1rOMKywF3A4JRINAky1Bf2WRXXHdeylxIfcw68lOAPmmRq4CVbc64WHmJDo5D/ YAiGRHLQpRlu9pVGXd0TvzbwzxDSnzLypLLB2Q8yrb89tqdEBvaWLeLap06QW5ZOAU4c +WpX1wWrb5Byu0E2wrzE66g4zJ7iEZedv09WS25w5SW2Pg6cHYSXGYgQDd/WKR7oPWlb I692SML4cv/7iA+1g42/W5N4+GHuFGkerK3KdxWpgFGwX0VJosAhga8qiH0e/AJ3kCex Sovg== X-Gm-Message-State: AFeK/H0QAUqgn9XKAmW5wVLvNfxU+oTnUxiTq/NjNy4tvuZcJZKdB/2p17SYrfNYrPifMk1F X-Received: by 10.55.69.74 with SMTP id s71mr11128142qka.257.1491108656424; Sat, 01 Apr 2017 21:50:56 -0700 (PDT) From: Dawid Zamirski To: libvir-list@redhat.com Date: Sun, 2 Apr 2017 00:50:48 -0400 Message-Id: <20170402045049.19631-10-dzamirski@datto.com> In-Reply-To: <20170402045049.19631-1-dzamirski@datto.com> References: <20170402045049.19631-1-dzamirski@datto.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Sun, 02 Apr 2017 04:51:09 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Sun, 02 Apr 2017 04:51:09 +0000 (UTC) for IP:'209.85.220.172' DOMAIN:'mail-qk0-f172.google.com' HELO:'mail-qk0-f172.google.com' FROM:'dzamirski@datto.com' RCPT:'' X-RedHat-Spam-Score: -1.901 (BAYES_50, DCC_REPUT_00_12, DKIM_SIGNED, DKIM_VALID, RCVD_IN_MSPIKE_H2, RCVD_IN_SORBS_SPAM, SPF_PASS) 209.85.220.172 mail-qk0-f172.google.com 209.85.220.172 mail-qk0-f172.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.39 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Cc: Sri Ramanujam Subject: [libvirt] [PATCH v2 09/10] hyperv: port rest of the driver to new stucts. X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Sun, 02 Apr 2017 04:52:26 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" basically s/data->/data.common->/ Because the data member of hypervObject is a union, get the data via the "common" member everywhere - existing driver does not require special handling for v1 vs v2 separately. --- src/hyperv/hyperv_driver.c | 76 +++++++++++++++++++++++-------------------= ---- src/hyperv/hyperv_wmi.c | 21 ++++++++----- 2 files changed, 51 insertions(+), 46 deletions(-) diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c index b642a02..5d01c1f 100644 --- a/src/hyperv/hyperv_driver.c +++ b/src/hyperv/hyperv_driver.c @@ -240,7 +240,7 @@ hypervConnectGetHostname(virConnectPtr conn) goto cleanup; } =20 - ignore_value(VIR_STRDUP(hostname, computerSystem->data->DNSHostName)); + ignore_value(VIR_STRDUP(hostname, computerSystem->data.common->DNSHost= Name)); =20 cleanup: hypervFreeObject(priv, (hypervObject *)computerSystem); @@ -282,7 +282,7 @@ hypervNodeGetInfo(virConnectPtr conn, virNodeInfoPtr in= fo) "{Win32_ComputerSystem.Name=3D\"%s\"} " "where AssocClass =3D Win32_ComputerSystemProcessor " "ResultClass =3D Win32_Processor", - computerSystem->data->Name); + computerSystem->data.common->Name); =20 if (hypervGetWin32ProcessorList(priv, &query, &processorList) < 0) goto cleanup; @@ -295,7 +295,7 @@ hypervNodeGetInfo(virConnectPtr conn, virNodeInfoPtr in= fo) } =20 /* Strip the string to fit more relevant information in 32 chars */ - tmp =3D processorList->data->Name; + tmp =3D processorList->data.common->Name; =20 while (*tmp !=3D '\0') { if (STRPREFIX(tmp, " ")) { @@ -313,16 +313,16 @@ hypervNodeGetInfo(virConnectPtr conn, virNodeInfoPtr = info) } =20 /* Fill struct */ - if (virStrncpy(info->model, processorList->data->Name, + if (virStrncpy(info->model, processorList->data.common->Name, sizeof(info->model) - 1, sizeof(info->model)) =3D=3D NU= LL) { virReportError(VIR_ERR_INTERNAL_ERROR, _("CPU model %s too long for destination"), - processorList->data->Name); + processorList->data.common->Name); goto cleanup; } =20 - info->memory =3D computerSystem->data->TotalPhysicalMemory / 1024; /* = byte to kilobyte */ - info->mhz =3D processorList->data->MaxClockSpeed; + info->memory =3D computerSystem->data.common->TotalPhysicalMemory / 10= 24; /* byte to kilobyte */ + info->mhz =3D processorList->data.common->MaxClockSpeed; info->nodes =3D 1; info->sockets =3D 0; =20 @@ -331,8 +331,8 @@ hypervNodeGetInfo(virConnectPtr conn, virNodeInfoPtr in= fo) ++info->sockets; } =20 - info->cores =3D processorList->data->NumberOfCores; - info->threads =3D info->cores / processorList->data->NumberOfLogicalPr= ocessors; + info->cores =3D processorList->data.common->NumberOfCores; + info->threads =3D info->cores / processorList->data.common->NumberOfLo= gicalProcessors; info->cpus =3D info->sockets * info->cores; =20 result =3D 0; @@ -372,7 +372,7 @@ hypervConnectListDomains(virConnectPtr conn, int *ids, = int maxids) =20 for (computerSystem =3D computerSystemList; computerSystem !=3D NULL; computerSystem =3D computerSystem->next) { - ids[count++] =3D computerSystem->data->ProcessID; + ids[count++] =3D computerSystem->data.common->ProcessID; =20 if (count >=3D maxids) break; @@ -532,7 +532,7 @@ hypervDomainSuspend(virDomainPtr domain) if (hypervMsvmComputerSystemFromDomain(domain, &computerSystem) < 0) goto cleanup; =20 - if (computerSystem->data->EnabledState !=3D + if (computerSystem->data.common->EnabledState !=3D MSVM_COMPUTERSYSTEM_ENABLEDSTATE_ENABLED) { virReportError(VIR_ERR_OPERATION_INVALID, "%s", _("Domain is not active")); @@ -560,7 +560,7 @@ hypervDomainResume(virDomainPtr domain) if (hypervMsvmComputerSystemFromDomain(domain, &computerSystem) < 0) goto cleanup; =20 - if (computerSystem->data->EnabledState !=3D + if (computerSystem->data.common->EnabledState !=3D MSVM_COMPUTERSYSTEM_ENABLEDSTATE_PAUSED) { virReportError(VIR_ERR_OPERATION_INVALID, "%s", _("Domain is not paused")); @@ -666,7 +666,7 @@ hypervDomainGetInfo(virDomainPtr domain, virDomainInfoP= tr info) virReportError(VIR_ERR_INTERNAL_ERROR, _("Could not lookup %s for domain %s"), "Msvm_VirtualSystemSettingData", - computerSystem->data->ElementName); + computerSystem->data.common->ElementName); goto cleanup; } =20 @@ -676,7 +676,7 @@ hypervDomainGetInfo(virDomainPtr domain, virDomainInfoP= tr info) "{Msvm_VirtualSystemSettingData.InstanceID=3D\"%s\"}= " "where AssocClass =3D Msvm_VirtualSystemSettingDataC= omponent " "ResultClass =3D Msvm_ProcessorSettingData", - virtualSystemSettingData->data->InstanceID); + virtualSystemSettingData->data.common->InstanceID); =20 if (hypervGetMsvmProcessorSettingDataList(priv, &query, &processorSettingData) < 0) { @@ -687,7 +687,7 @@ hypervDomainGetInfo(virDomainPtr domain, virDomainInfoP= tr info) virReportError(VIR_ERR_INTERNAL_ERROR, _("Could not lookup %s for domain %s"), "Msvm_ProcessorSettingData", - computerSystem->data->ElementName); + computerSystem->data.common->ElementName); goto cleanup; } =20 @@ -697,7 +697,7 @@ hypervDomainGetInfo(virDomainPtr domain, virDomainInfoP= tr info) "{Msvm_VirtualSystemSettingData.InstanceID=3D\"%s\"}= " "where AssocClass =3D Msvm_VirtualSystemSettingDataC= omponent " "ResultClass =3D Msvm_MemorySettingData", - virtualSystemSettingData->data->InstanceID); + virtualSystemSettingData->data.common->InstanceID); =20 if (hypervGetMsvmMemorySettingDataList(priv, &query, &memorySettingData) < 0) { @@ -709,15 +709,15 @@ hypervDomainGetInfo(virDomainPtr domain, virDomainInf= oPtr info) virReportError(VIR_ERR_INTERNAL_ERROR, _("Could not lookup %s for domain %s"), "Msvm_MemorySettingData", - computerSystem->data->ElementName); + computerSystem->data.common->ElementName); goto cleanup; } =20 /* Fill struct */ info->state =3D hypervMsvmComputerSystemEnabledStateToDomainState(comp= uterSystem); - info->maxMem =3D memorySettingData->data->Limit * 1024; /* megabyte to= kilobyte */ - info->memory =3D memorySettingData->data->VirtualQuantity * 1024; /* m= egabyte to kilobyte */ - info->nrVirtCpu =3D processorSettingData->data->VirtualQuantity; + info->maxMem =3D memorySettingData->data.common->Limit * 1024; /* mega= byte to kilobyte */ + info->memory =3D memorySettingData->data.common->VirtualQuantity * 102= 4; /* megabyte to kilobyte */ + info->nrVirtCpu =3D processorSettingData->data.common->VirtualQuantity; info->cpuTime =3D 0; =20 result =3D 0; @@ -803,7 +803,7 @@ hypervDomainGetXMLDesc(virDomainPtr domain, unsigned in= t flags) virReportError(VIR_ERR_INTERNAL_ERROR, _("Could not lookup %s for domain %s"), "Msvm_VirtualSystemSettingData", - computerSystem->data->ElementName); + computerSystem->data.common->ElementName); goto cleanup; } =20 @@ -813,7 +813,7 @@ hypervDomainGetXMLDesc(virDomainPtr domain, unsigned in= t flags) "{Msvm_VirtualSystemSettingData.InstanceID=3D\"%s\"}= " "where AssocClass =3D Msvm_VirtualSystemSettingDataC= omponent " "ResultClass =3D Msvm_ProcessorSettingData", - virtualSystemSettingData->data->InstanceID); + virtualSystemSettingData->data.common->InstanceID); =20 if (hypervGetMsvmProcessorSettingDataList(priv, &query, &processorSettingData) < 0) { @@ -824,7 +824,7 @@ hypervDomainGetXMLDesc(virDomainPtr domain, unsigned in= t flags) virReportError(VIR_ERR_INTERNAL_ERROR, _("Could not lookup %s for domain %s"), "Msvm_ProcessorSettingData", - computerSystem->data->ElementName); + computerSystem->data.common->ElementName); goto cleanup; } =20 @@ -834,7 +834,7 @@ hypervDomainGetXMLDesc(virDomainPtr domain, unsigned in= t flags) "{Msvm_VirtualSystemSettingData.InstanceID=3D\"%s\"}= " "where AssocClass =3D Msvm_VirtualSystemSettingDataC= omponent " "ResultClass =3D Msvm_MemorySettingData", - virtualSystemSettingData->data->InstanceID); + virtualSystemSettingData->data.common->InstanceID); =20 if (hypervGetMsvmMemorySettingDataList(priv, &query, &memorySettingData) < 0) { @@ -846,7 +846,7 @@ hypervDomainGetXMLDesc(virDomainPtr domain, unsigned in= t flags) virReportError(VIR_ERR_INTERNAL_ERROR, _("Could not lookup %s for domain %s"), "Msvm_MemorySettingData", - computerSystem->data->ElementName); + computerSystem->data.common->ElementName); goto cleanup; } =20 @@ -854,34 +854,34 @@ hypervDomainGetXMLDesc(virDomainPtr domain, unsigned = int flags) def->virtType =3D VIR_DOMAIN_VIRT_HYPERV; =20 if (hypervIsMsvmComputerSystemActive(computerSystem, NULL)) { - def->id =3D computerSystem->data->ProcessID; + def->id =3D computerSystem->data.common->ProcessID; } else { def->id =3D -1; } =20 - if (virUUIDParse(computerSystem->data->Name, def->uuid) < 0) { + if (virUUIDParse(computerSystem->data.common->Name, def->uuid) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Could not parse UUID from string '%s'"), - computerSystem->data->Name); + computerSystem->data.common->Name); return NULL; } =20 - if (VIR_STRDUP(def->name, computerSystem->data->ElementName) < 0) + if (VIR_STRDUP(def->name, computerSystem->data.common->ElementName) < = 0) goto cleanup; =20 - if (VIR_STRDUP(def->description, virtualSystemSettingData->data->Notes= ) < 0) + if (VIR_STRDUP(def->description, virtualSystemSettingData->data.common= ->Notes) < 0) goto cleanup; =20 - virDomainDefSetMemoryTotal(def, memorySettingData->data->Limit * 1024)= ; /* megabyte to kilobyte */ - def->mem.cur_balloon =3D memorySettingData->data->VirtualQuantity * 10= 24; /* megabyte to kilobyte */ + virDomainDefSetMemoryTotal(def, memorySettingData->data.common->Limit = * 1024); /* megabyte to kilobyte */ + def->mem.cur_balloon =3D memorySettingData->data.common->VirtualQuanti= ty * 1024; /* megabyte to kilobyte */ =20 if (virDomainDefSetVcpusMax(def, - processorSettingData->data->VirtualQuantit= y, + processorSettingData->data.common->Virtual= Quantity, NULL) < 0) goto cleanup; =20 if (virDomainDefSetVcpus(def, - processorSettingData->data->VirtualQuantity) = < 0) + processorSettingData->data.common->VirtualQua= ntity) < 0) goto cleanup; =20 def->os.type =3D VIR_DOMAIN_OSTYPE_HVM; @@ -930,7 +930,7 @@ hypervConnectListDefinedDomains(virConnectPtr conn, cha= r **const names, int maxn =20 for (computerSystem =3D computerSystemList; computerSystem !=3D NULL; computerSystem =3D computerSystem->next) { - if (VIR_STRDUP(names[count], computerSystem->data->ElementName) < = 0) + if (VIR_STRDUP(names[count], computerSystem->data.common->ElementN= ame) < 0) goto cleanup; =20 ++count; @@ -1154,7 +1154,7 @@ hypervDomainHasManagedSaveImage(virDomainPtr domain, = unsigned int flags) if (hypervMsvmComputerSystemFromDomain(domain, &computerSystem) < 0) goto cleanup; =20 - result =3D computerSystem->data->EnabledState =3D=3D + result =3D computerSystem->data.common->EnabledState =3D=3D MSVM_COMPUTERSYSTEM_ENABLEDSTATE_SUSPENDED ? 1 : 0; =20 cleanup: @@ -1177,7 +1177,7 @@ hypervDomainManagedSaveRemove(virDomainPtr domain, un= signed int flags) if (hypervMsvmComputerSystemFromDomain(domain, &computerSystem) < 0) goto cleanup; =20 - if (computerSystem->data->EnabledState !=3D + if (computerSystem->data.common->EnabledState !=3D MSVM_COMPUTERSYSTEM_ENABLEDSTATE_SUSPENDED) { virReportError(VIR_ERR_OPERATION_INVALID, "%s", _("Domain has no managed save image")); @@ -1280,7 +1280,7 @@ hypervConnectListAllDomains(virConnectPtr conn, =20 /* managed save filter */ if (MATCH(VIR_CONNECT_LIST_DOMAINS_FILTERS_MANAGEDSAVE)) { - bool mansave =3D computerSystem->data->EnabledState =3D=3D + bool mansave =3D computerSystem->data.common->EnabledState =3D= =3D MSVM_COMPUTERSYSTEM_ENABLEDSTATE_SUSPENDED; =20 if (!((MATCH(VIR_CONNECT_LIST_DOMAINS_MANAGEDSAVE) && mansave)= || diff --git a/src/hyperv/hyperv_wmi.c b/src/hyperv/hyperv_wmi.c index 9e62f57..7a9aa52 100644 --- a/src/hyperv/hyperv_wmi.c +++ b/src/hyperv/hyperv_wmi.c @@ -439,6 +439,8 @@ hypervInvokeMsvmComputerSystemRequestStateChange(virDom= ainPtr domain, virBuffer query =3D VIR_BUFFER_INITIALIZER; Msvm_ConcreteJob *concreteJob =3D NULL; bool completed =3D false; + const char *resourceUri =3D MSVM_COMPUTERSYSTEM_V2_RESOURCE_URI; + =20 virUUIDFormat(domain->uuid, uuid_string); =20 @@ -447,6 +449,9 @@ hypervInvokeMsvmComputerSystemRequestStateChange(virDom= ainPtr domain, virAsprintf(&properties, "RequestedState=3D%d", requestedState) < = 0) goto cleanup; =20 + if (priv->wmiVersion =3D=3D HYPERV_WMI_VERSION_V1) + resourceUri =3D MSVM_COMPUTERSYSTEM_V2_RESOURCE_URI; + options =3D wsmc_options_init(); =20 if (options =3D=3D NULL) { @@ -459,7 +464,7 @@ hypervInvokeMsvmComputerSystemRequestStateChange(virDom= ainPtr domain, wsmc_add_prop_from_str(options, properties); =20 /* Invoke method */ - response =3D wsmc_action_invoke(priv->client, MSVM_COMPUTERSYSTEM_RESO= URCE_URI, + response =3D wsmc_action_invoke(priv->client, resourceUri, options, "RequestStateChange", NULL); =20 if (hypervVerifyResponse(priv->client, response, "invocation") < 0) @@ -508,7 +513,7 @@ hypervInvokeMsvmComputerSystemRequestStateChange(virDom= ainPtr domain, goto cleanup; } =20 - switch (concreteJob->data->JobState) { + switch (concreteJob->data.common->JobState) { case MSVM_CONCRETEJOB_JOBSTATE_NEW: case MSVM_CONCRETEJOB_JOBSTATE_STARTING: case MSVM_CONCRETEJOB_JOBSTATE_RUNNING: @@ -567,7 +572,7 @@ int hypervMsvmComputerSystemEnabledStateToDomainState (Msvm_ComputerSystem *computerSystem) { - switch (computerSystem->data->EnabledState) { + switch (computerSystem->data.common->EnabledState) { case MSVM_COMPUTERSYSTEM_ENABLEDSTATE_UNKNOWN: return VIR_DOMAIN_NOSTATE; =20 @@ -607,7 +612,7 @@ hypervIsMsvmComputerSystemActive(Msvm_ComputerSystem *c= omputerSystem, if (in_transition !=3D NULL) *in_transition =3D false; =20 - switch (computerSystem->data->EnabledState) { + switch (computerSystem->data.common->EnabledState) { case MSVM_COMPUTERSYSTEM_ENABLEDSTATE_UNKNOWN: return false; =20 @@ -651,20 +656,20 @@ hypervMsvmComputerSystemToDomain(virConnectPtr conn, return -1; } =20 - if (virUUIDParse(computerSystem->data->Name, uuid) < 0) { + if (virUUIDParse(computerSystem->data.common->Name, uuid) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Could not parse UUID from string '%s'"), - computerSystem->data->Name); + computerSystem->data.common->Name); return -1; } =20 - *domain =3D virGetDomain(conn, computerSystem->data->ElementName, uuid= ); + *domain =3D virGetDomain(conn, computerSystem->data.common->ElementNam= e, uuid); =20 if (*domain =3D=3D NULL) return -1; =20 if (hypervIsMsvmComputerSystemActive(computerSystem, NULL)) { - (*domain)->id =3D computerSystem->data->ProcessID; + (*domain)->id =3D computerSystem->data.common->ProcessID; } else { (*domain)->id =3D -1; } --=20 2.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat Apr 27 16:50:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zoho.com; dkim=fail spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1491109517747635.113175785713; Sat, 1 Apr 2017 22:05:17 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4E86C83F3F; Sun, 2 Apr 2017 05:05:16 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1BB7F62922; Sun, 2 Apr 2017 05:05:16 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id B6A9418523CC; Sun, 2 Apr 2017 05:05:15 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v324pSGF019119 for ; Sun, 2 Apr 2017 00:51:28 -0400 Received: by smtp.corp.redhat.com (Postfix) id 36690A2D6A; Sun, 2 Apr 2017 04:51:28 +0000 (UTC) Received: from mx1.redhat.com (ext-mx09.extmail.prod.ext.phx2.redhat.com [10.5.110.38]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3012B5C542 for ; Sun, 2 Apr 2017 04:51:26 +0000 (UTC) Received: from mail-qk0-f182.google.com (mail-qk0-f182.google.com [209.85.220.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C7EED4E4EE for ; Sun, 2 Apr 2017 04:51:02 +0000 (UTC) Received: by mail-qk0-f182.google.com with SMTP id d201so63852368qkc.0 for ; Sat, 01 Apr 2017 21:50:59 -0700 (PDT) Received: from dawid-fedora.datto.lan ([47.19.105.250]) by smtp.gmail.com with ESMTPSA id c10sm6934829qka.1.2017.04.01.21.50.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 01 Apr 2017 21:50:56 -0700 (PDT) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 4E86C83F3F Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=datto.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 4E86C83F3F Authentication-Results: mx1.redhat.com; dkim=fail reason="signature verification failed" (2048-bit key) header.d=datto-com.20150623.gappssmtp.com header.i=@datto-com.20150623.gappssmtp.com header.b="0sfzi/nc" DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com C7EED4E4EE Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=datto.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=dzamirski@datto.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com C7EED4E4EE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=datto-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=D8p9vNNUtmo6lI1CYiZDJuKlQ/a2jvTbY3nojzB7P8g=; b=0sfzi/nckQubZFw6e2zWii0BSVApWS0kYW3NLevT/H8vhqgWdhhuJix8ptV66ziqdl g/Q5imtNQr7wTQt7LlcFkQoXOsiyNMXDgES5IgKkc0PAm+zGh+5AAHepuSvPyM8oKMjU noTCpKUQLCtugZJ6c64IBCfz3VTEC+HwEFMSbRu6Z+fRpGqlIx28fUtG3SAIlIJklSx0 aKNpRdTvcOtvUmM1RhKwXZfRiGUW8vcWy5l7YiTGrqn+MRBnIziVW7v/a3qeRe9f6RN6 A0cXtwXKykd3RNXCPyJeqF3+95voYX3pLMw1xNt7o7cOXg0uZcxXoXeXziVW6run1+g+ ObAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=D8p9vNNUtmo6lI1CYiZDJuKlQ/a2jvTbY3nojzB7P8g=; b=TgLO5LugO41frPrYc5hqG7MpF/AKOn+8HtoDKeYsRQITF1M6JK1ki7010xB4qP5MAK fSz2AdsvOoJtnQZK3XNHdvCA1CONrSotiq1+UFIYXWt2niu6b6JZPMQfxyXnznY1mEap F46Z1kOBS874/s/Q4LE3IGOe4JwYVUoPiuo61LC6c8aSlK/GylZE7Day7iSTZk+n/CQP qf5oJDZFgQqs3tJzqVGbyQuL2LacBicU3aACnMncSfZIwBqDW/MbnzUa9vH4tismQAOU kJsY8IeZYPe5Talwq1qWTVDmBBE81Ww7wGpE2A0s/mhxVFtzF0x8m7TkFJy7UVN4s1R2 2Slg== X-Gm-Message-State: AFeK/H1qzIFmhq0yn6ljDG/0HTz2ZE8rxX4YHGSGp+lOl+QZIj+qBy35hjY3bqSzj/5kiRkr X-Received: by 10.55.167.72 with SMTP id q69mr10680367qke.320.1491108656875; Sat, 01 Apr 2017 21:50:56 -0700 (PDT) From: Dawid Zamirski To: libvir-list@redhat.com Date: Sun, 2 Apr 2017 00:50:49 -0400 Message-Id: <20170402045049.19631-11-dzamirski@datto.com> In-Reply-To: <20170402045049.19631-1-dzamirski@datto.com> References: <20170402045049.19631-1-dzamirski@datto.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Sun, 02 Apr 2017 04:51:05 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Sun, 02 Apr 2017 04:51:05 +0000 (UTC) for IP:'209.85.220.182' DOMAIN:'mail-qk0-f182.google.com' HELO:'mail-qk0-f182.google.com' FROM:'dzamirski@datto.com' RCPT:'' X-RedHat-Spam-Score: 0.979 (BAYES_50, DCC_REPUT_00_12, DKIM_SIGNED, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, RCVD_IN_SORBS_SPAM, SPF_PASS, T_DKIM_INVALID) 209.85.220.182 mail-qk0-f182.google.com 209.85.220.182 mail-qk0-f182.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.38 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Cc: Sri Ramanujam Subject: [libvirt] [PATCH v2 10/10] hyperv: add hypervInitConnection. X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Sun, 02 Apr 2017 05:05:16 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This function detects hyperv version by issuing a simple query using "v2" namespace and falling back to "v1". --- src/hyperv/hyperv_driver.c | 92 ++++++++++++++++++++++++++++--------------= ---- 1 file changed, 56 insertions(+), 36 deletions(-) diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c index 5d01c1f..0913517 100644 --- a/src/hyperv/hyperv_driver.c +++ b/src/hyperv/hyperv_driver.c @@ -55,7 +55,62 @@ hypervFreePrivate(hypervPrivate **priv) VIR_FREE(*priv); } =20 +static int +hypervInitConnection(virConnectPtr conn, hypervPrivate *priv, + char *username, char *password) +{ + virBuffer buf =3D VIR_BUFFER_INITIALIZER; + hypervWqlQuery query =3D HYPERV_WQL_QUERY_INITIALIZER; + hypervObject *computerSystem =3D NULL; + int ret =3D -1; =20 + /* Initialize the openwsman connection */ + priv->client =3D wsmc_create(conn->uri->server, conn->uri->port, "/wsm= an", + priv->parsedUri->transport, username, passw= ord); + + if (priv->client =3D=3D NULL) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Could not create openwsman client")); + goto cleanup; + } + + if (wsmc_transport_init(priv->client, NULL) !=3D 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Could not initialize openwsman transport")); + goto cleanup; + } + + /* FIXME: Currently only basic authentication is supported */ + wsman_transport_set_auth_method(priv->client, "basic"); + + virBufferAddLit(&buf, MSVM_COMPUTERSYSTEM_WQL_SELECT); + virBufferAddLit(&buf, "WHERE "); + virBufferAddLit(&buf, MSVM_COMPUTERSYSTEM_WQL_PHYSICAL); + + query.query =3D virBufferContentAndReset(&buf); + query.info =3D Msvm_ComputerSystem_WmiInfo; + + /* try query using V2 namespace (for Hyperv 2012+) */ + priv->wmiVersion =3D HYPERV_WMI_VERSION_V2; + + if (hypervEnumAndPull(priv, &query, &computerSystem) < 0) { + /* fall back to V1 namespace (for Hyper-v 2008) */ + priv->wmiVersion =3D HYPERV_WMI_VERSION_V1; + + if (hypervEnumAndPull(priv, &query, &computerSystem) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("%s is not a Hyper-V server"), conn->uri->ser= ver); + goto cleanup; + } + } + + ret =3D 0; + + cleanup: + hypervFreeObject(priv, computerSystem); + + return ret; +} =20 static virDrvOpenStatus hypervConnectOpen(virConnectPtr conn, virConnectAuthPtr auth, @@ -67,8 +122,6 @@ hypervConnectOpen(virConnectPtr conn, virConnectAuthPtr = auth, hypervPrivate *priv =3D NULL; char *username =3D NULL; char *password =3D NULL; - virBuffer query =3D VIR_BUFFER_INITIALIZER; - Msvm_ComputerSystem *computerSystem =3D NULL; =20 virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); =20 @@ -147,41 +200,9 @@ hypervConnectOpen(virConnectPtr conn, virConnectAuthPt= r auth, goto cleanup; } =20 - /* Initialize the openwsman connection */ - priv->client =3D wsmc_create(conn->uri->server, conn->uri->port, "/wsm= an", - priv->parsedUri->transport, username, passw= ord); - - if (priv->client =3D=3D NULL) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Could not create openwsman client")); - goto cleanup; - } - - if (wsmc_transport_init(priv->client, NULL) !=3D 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Could not initialize openwsman transport")); - goto cleanup; - } - - /* FIXME: Currently only basic authentication is supported */ - wsman_transport_set_auth_method(priv->client, "basic"); - - /* Check if the connection can be established and if the server has the - * Hyper-V role installed. If the call to hypervGetMsvmComputerSystemL= ist - * succeeds than the connection has been established. If the returned = list - * is empty than the server isn't a Hyper-V server. */ - virBufferAddLit(&query, MSVM_COMPUTERSYSTEM_WQL_SELECT); - virBufferAddLit(&query, "where "); - virBufferAddLit(&query, MSVM_COMPUTERSYSTEM_WQL_PHYSICAL); - - if (hypervGetMsvmComputerSystemList(priv, &query, &computerSystem) < 0) - goto cleanup; =20 - if (computerSystem =3D=3D NULL) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("%s is not a Hyper-V server"), conn->uri->server); + if (hypervInitConnection(conn, priv, username, password) < 0) goto cleanup; - } =20 conn->privateData =3D priv; priv =3D NULL; @@ -191,7 +212,6 @@ hypervConnectOpen(virConnectPtr conn, virConnectAuthPtr= auth, hypervFreePrivate(&priv); VIR_FREE(username); VIR_FREE(password); - hypervFreeObject(priv, (hypervObject *)computerSystem); =20 return result; } --=20 2.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list