From nobody Tue Feb 10 03:44:52 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 1491263577171136.6008979033403; Mon, 3 Apr 2017 16:52:57 -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 D401A51453; Mon, 3 Apr 2017 23:52:55 +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 A868B17D43; Mon, 3 Apr 2017 23:52:55 +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 5ACA618523CF; Mon, 3 Apr 2017 23:52:55 +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 v33NqSgq015717 for ; Mon, 3 Apr 2017 19:52:28 -0400 Received: by smtp.corp.redhat.com (Postfix) id F277118A72; Mon, 3 Apr 2017 23:52:27 +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 EB79618A6B for ; Mon, 3 Apr 2017 23:52:24 +0000 (UTC) Received: from mail-qt0-f170.google.com (mail-qt0-f170.google.com [209.85.216.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 ADE0EC049D59 for ; Mon, 3 Apr 2017 23:52:23 +0000 (UTC) Received: by mail-qt0-f170.google.com with SMTP id n21so126474389qta.1 for ; Mon, 03 Apr 2017 16:52:23 -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.21 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 03 Apr 2017 16:52:21 -0700 (PDT) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D401A51453 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=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com D401A51453 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="Fg4Hmztb" DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com ADE0EC049D59 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 ADE0EC049D59 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=vCXoBshs5+V6rrV2fC/fpAbeYUimvlX3Dv/smLn/T4Y=; b=Fg4HmztbQx2Qf0kOV/J88LnHvgBvfXx8dfmI5PgXm80QxUYuaq4fM5OHf9Xryzn9TP 6kgNP2hMJdpd0/IdvC8K4bYE8/OhNvPVzKtVORh2+33aK74OPPX9Y5Ar7Nc7t9PHTmGk KDsiPXN+XiT82SiSJDbPL4iWTOyxhrNj8lGNF0JIEPq0NyC6/Sq7yYy92S6LiEwcaToN MRa/ey9uswOLUJX51MHvcqKIYtLe6ch4a8+UCn+edvqDd3ZTjaEMCgE1HAuEHOZuQFI8 uimxgsd2yWGUEHdQ61E9NIyrzRghD4rlSyftGCcDkHarxq3qVvZnDFrB06WC4gwNzSdy 7Ezw== 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=vCXoBshs5+V6rrV2fC/fpAbeYUimvlX3Dv/smLn/T4Y=; b=HIS9mitGowtaygvJXY1TfPGwi5zcnSn5rvd379DkOOxRWQfJ2nxQ53+kH52f5SsoJM 5yWTjrZE/uKJs84Tl6X/cM7TsAub1MHNgq9TMmrndZxG4qp2R+HHkHtKyiCcSGUS0oQ+ 2sKA8oXAfMhHCLXNhV2lfz7PqoXkGfvO3B7wp0vbukKCG0zjI8ujo2elQZHS4TRB/SeO zJcQYAUuIsG6fwTDgvhGR4fKYGolCCGuXWr2pBsOykedXYnLBkiSxYQ8v0w1Hx9fFBdq FH5uKlOtSSNMsol3ihPDbXodIiE5ZG+B5U3sIadU/Ib28gwqt+TQyNvg6FX6pCYjeFCc njww== X-Gm-Message-State: AFeK/H20x+LSTOMCgUtSKRpGlR5CYiEV6YaHLfxr4+EvjOCGZL7ROR6xNyHbeDfX6GoegN+o X-Received: by 10.200.0.136 with SMTP id c8mr19242349qtg.223.1491263542687; Mon, 03 Apr 2017 16:52:22 -0700 (PDT) From: Dawid Zamirski To: libvir-list@redhat.com Date: Mon, 3 Apr 2017 19:52:10 -0400 Message-Id: <20170403235219.19721-4-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.31]); Mon, 03 Apr 2017 23:52:23 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Mon, 03 Apr 2017 23:52:23 +0000 (UTC) for IP:'209.85.216.170' DOMAIN:'mail-qt0-f170.google.com' HELO:'mail-qt0-f170.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.216.170 mail-qt0-f170.google.com 209.85.216.170 mail-qt0-f170.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.31 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 03/12] 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Mon, 03 Apr 2017 23:52:56 +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