From nobody Sun May 5 21:29:17 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 1492527395167740.9686127345326; Tue, 18 Apr 2017 07:56:35 -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 757D1C04B940; Tue, 18 Apr 2017 14:56:32 +0000 (UTC) Received: from colo-mx.corp.redhat.com (unknown [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 481A97FCC0; Tue, 18 Apr 2017 14:56:31 +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 3F5CAB3184; Tue, 18 Apr 2017 14:56:29 +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 v3IEuRSt008114 for ; Tue, 18 Apr 2017 10:56:27 -0400 Received: by smtp.corp.redhat.com (Postfix) id 27DF971C51; Tue, 18 Apr 2017 14:56:27 +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 14B9971C9F for ; Tue, 18 Apr 2017 14:56:24 +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 97EAA3DBD8 for ; Tue, 18 Apr 2017 14:56:22 +0000 (UTC) Received: by mail-qk0-f178.google.com with SMTP id d131so132314463qkc.3 for ; Tue, 18 Apr 2017 07:56:22 -0700 (PDT) Received: from dawid-fedora.datto.lan ([47.19.105.250]) by smtp.gmail.com with ESMTPSA id n9sm4424560qtc.68.2017.04.18.07.56.21 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 18 Apr 2017 07:56:21 -0700 (PDT) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 757D1C04B940 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 757D1C04B940 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="sxIwNjOZ" DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 97EAA3DBD8 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 97EAA3DBD8 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; bh=SIvHLRHZKfpcmi5kFR8+gaFsuSVluTS+HqTUYrLWvt0=; b=sxIwNjOZEM1LuQg3ZASS4yi+2p+EAxsvMMaaOVZ5gQvIuYIqtL4rt1Te6rTVFcnjpy P2KYDYMu8tKc5wNEJry9qRveBKvS7tL3kZ4XfZawfwZzRVGre3T/NSBzrN7IfhrjSLib /7CjSMzz6Uy6J3gXvfNUo7e+MLrkDn8VpRzRnSWGE0oqANuCp6vUtLRt6odpy+W4ZRjB 14nAdtaSYZMgQXY25JJ/Cv/JROSlrAFBdJFRcPbbhKzdVtsqw2K3iujPHMHKY9kcHaY6 WBP8Qh2THi7ljrnBhTuvOmfDz2Q7BLFu8M76l5BxXAkXLcFV1/RtwafMZRxY8bpgG4r6 kBVA== 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; bh=SIvHLRHZKfpcmi5kFR8+gaFsuSVluTS+HqTUYrLWvt0=; b=iXKcdekvW3ZdX70N/la+SjA3PVMKIEDr2HVWvVf7XWrrRoSTtDXUFhBrMOjv9S12Bi Gbtxk1TUwMtJa34C7ABPzkBrmvERxlj+MjrdBX6bALlT6RDh7YS82pCBs6hQjQKbYlXT +SY9Iap/kJP2QQJhj/hRxRViZq245nqBtDxjcupgyR6rxpTzCila7df47ymYt8qwkRMw WZ2oSahAXvlbyujKmu2Hsp7TXzTippmshpUKcRyxcvfqPJiiPZ1a/bRoZoL5hyAW3TsV ZkbbUeyOu0TIUmqRZXD911XWlw7AB9Lu2KVqAepxVsNjg3D6DpdyPFbxYaJCfSr4Bew5 RO7w== X-Gm-Message-State: AN3rC/5HP+LakffVuZ4TnPq8IH0o0+QXUvrHU9iIQpSpKCc10FOmAhov UTlgrfm0GZ4jF6Yq1kaNog== X-Received: by 10.55.6.83 with SMTP id 80mr14969716qkg.156.1492527381603; Tue, 18 Apr 2017 07:56:21 -0700 (PDT) From: Dawid Zamirski To: libvir-list@redhat.com Date: Tue, 18 Apr 2017 10:56:20 -0400 Message-Id: <20170418145620.4249-1-dzamirski@datto.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Tue, 18 Apr 2017 14:56:22 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Tue, 18 Apr 2017 14:56:22 +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.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.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.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3] hyperv: recognize array property as distinct type. 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.31]); Tue, 18 Apr 2017 14:56:33 +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" When hyperv code generator for WMI classes identifies common properties, it needs to take into account array type as a distinct type, i.e string !=3D string[]. This is the case where v1 of the Msvm_VirtualSystemSettingData has Notes property as string whereas v2 uses Notes[], therefore they have to be treated as different fields and cannot be placed in the "common" struct. --- changes in v3: * add virBufferCheckError before calling virBufferContentAndReset. src/hyperv/hyperv_driver.c | 28 ++++++++++++++++++++++++++-- src/hyperv/hyperv_wmi_generator.py | 2 +- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c index 090ea24..8e5eeda 100644 --- a/src/hyperv/hyperv_driver.c +++ b/src/hyperv/hyperv_driver.c @@ -894,8 +894,32 @@ hypervDomainGetXMLDesc(virDomainPtr domain, unsigned i= nt flags) if (VIR_STRDUP(def->name, computerSystem->data.common->ElementName) < = 0) goto cleanup; =20 - if (VIR_STRDUP(def->description, virtualSystemSettingData->data.common= ->Notes) < 0) - goto cleanup; + if (priv->wmiVersion =3D=3D HYPERV_WMI_VERSION_V1) { + if (VIR_STRDUP(def->description, + virtualSystemSettingData->data.v1->Notes) < 0) + goto cleanup; + } else if (priv->wmiVersion =3D=3D HYPERV_WMI_VERSION_V2 && + virtualSystemSettingData->data.v2->Notes.data !=3D NULL) { + char **notes =3D (char **) virtualSystemSettingData->data.v2->Note= s.data; + virBuffer buf =3D VIR_BUFFER_INITIALIZER; + size_t i =3D 0; + + /* in practice Notes has 1 element */ + for (i =3D 0; i < virtualSystemSettingData->data.v2->Notes.count; = i++) { + /* but if there's more than 1, separate by double new line */ + if (virBufferUse(&buf) > 0) + virBufferAddLit(&buf, "\n\n"); + + virBufferAdd(&buf, *notes, -1); + notes++; + } + + if (virBufferCheckError(&buf)) + cleanup; + + def->description =3D virBufferContentAndReset(&buf); + } + =20 virDomainDefSetMemoryTotal(def, memorySettingData->data.common->Limit = * 1024); /* megabyte to kilobyte */ def->mem.cur_balloon =3D memorySettingData->data.common->VirtualQuanti= ty * 1024; /* megabyte to kilobyte */ diff --git a/src/hyperv/hyperv_wmi_generator.py b/src/hyperv/hyperv_wmi_gen= erator.py index c15d97a..9aee0b9 100755 --- a/src/hyperv/hyperv_wmi_generator.py +++ b/src/hyperv/hyperv_wmi_generator.py @@ -251,7 +251,7 @@ class WmiClass: 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) + key =3D "%s_%s_%s" % (prop.name, prop.type, prop.is_array) =20 if key in property_info: property_info[key][1] +=3D 1 --=20 2.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list