From nobody Mon Feb 9 16:19:46 2026 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 149126357085985.0801524782504; Mon, 3 Apr 2017 16:52:50 -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 5D43B80472; Mon, 3 Apr 2017 23:52:49 +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 29B9C18A72; Mon, 3 Apr 2017 23:52:49 +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 C684F18523CD; Mon, 3 Apr 2017 23:52: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 v33NqStF015719 for ; Mon, 3 Apr 2017 19:52:28 -0400 Received: by smtp.corp.redhat.com (Postfix) id F381218A6D; Mon, 3 Apr 2017 23:52:27 +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 EBCAA18A6C for ; Mon, 3 Apr 2017 23:52:25 +0000 (UTC) Received: from mail-qt0-f180.google.com (mail-qt0-f180.google.com [209.85.216.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 BAF3D7E9C9 for ; Mon, 3 Apr 2017 23:52:24 +0000 (UTC) Received: by mail-qt0-f180.google.com with SMTP id r45so126246266qte.3 for ; Mon, 03 Apr 2017 16:52:24 -0700 (PDT) Received: from dawid-fedora.datto.lan ([47.19.105.250]) by smtp.gmail.com with ESMTPSA id f28sm10658242qtf.44.2017.04.03.16.52.23 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 03 Apr 2017 16:52:23 -0700 (PDT) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 5D43B80472 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=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 5D43B80472 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="qq6NJLFK" DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com BAF3D7E9C9 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 BAF3D7E9C9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=datto-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references; bh=H3wD11PTquyz7ZdnKOft6mflAdXv1PcMGXSK521JUuo=; b=qq6NJLFKZFzptbOblKshp9oCWsJR322RgSSOj5a5NXVJP7uGFsKZyblbdtCnNItAGU Y/nz9TwOJW63lXCWMwgnIu6QuU+RM1hC4pqaedwrm0zFNavFo5Ijon+jLo/yMxo6fhVz EDFFdgXdAeJrSj6QYh33Iv3lXYvfHs1K5dTQwr5CKvJJxMPsoOjBDUFvHtHPJoqW+vQM CbEt5Nh6modrCR2NCnjJcBveNzUApzbWCWRcKUmaBxrRTx/zV2mM3C+ScUtQa8kFbzSQ FRab08N/P3XIwZB/P8BSml4y5GJCEBHZl8cLENt9bu0yTKbBS9qkPs4YTa4g1TPI9Ybu yPgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=H3wD11PTquyz7ZdnKOft6mflAdXv1PcMGXSK521JUuo=; b=e5fFbso6mjb4aZ0yY6Sk6UfVpr40WMWg8l1AkS3D26nUAk7s+Uynf/FYk7N6zUacVz XNMHLYPsuRFYHLdHkJbUxNFyFvyXynS9SzY0Ag2XMbq+QgufFvGg5CfOcdbxH37pUyOv LyXMMouBwqXHibNg/9Xj3g7G4OwYMs6ZNYVN2qZi6P3di9ynn8Z3lveyHJqaVf33VQW5 bYDiGbOGRDPUzQE+xPp9fhNgvZvehGdS03W8GUxd+eC3Q2NR9x/+dL10owSiFeymqaL3 3n58ngTElQAgaqj2ozjdbTDBzLK+VxBvUdC69j+uIQCBUSIkuiJyPGdLXWuMyf4LVxkr Rx/A== X-Gm-Message-State: AFeK/H12kkDxKx1ygvUCyEIYmtAATX8GHGS/tra1gU4dnDnDj3q9lbYlh2VTz5UzQh+riUXY X-Received: by 10.237.37.229 with SMTP id y34mr20542572qtc.30.1491263543713; Mon, 03 Apr 2017 16:52:23 -0700 (PDT) From: Dawid Zamirski To: libvir-list@redhat.com Date: Mon, 3 Apr 2017 19:52:12 -0400 Message-Id: <20170403235219.19721-6-dzamirski@datto.com> In-Reply-To: <20170403235219.19721-1-dzamirski@datto.com> References: <20170403235219.19721-1-dzamirski@datto.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 03 Apr 2017 23:52:25 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 03 Apr 2017 23:52:25 +0000 (UTC) for IP:'209.85.216.180' DOMAIN:'mail-qt0-f180.google.com' HELO:'mail-qt0-f180.google.com' FROM:'dzamirski@datto.com' RCPT:'' X-RedHat-Spam-Score: -0.321 (BAYES_50, DCC_REPUT_00_12, DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_PASS) 209.85.216.180 mail-qt0-f180.google.com 209.85.216.180 mail-qt0-f180.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.26 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 05/12] 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Mon, 03 Apr 2017 23:52:50 +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 069bcc9..5cac58d 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