From nobody Mon May 6 10:15:07 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 1491939762563291.52488021075726; Tue, 11 Apr 2017 12:42:42 -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 A7F1D6AAD3; Tue, 11 Apr 2017 19:42:40 +0000 (UTC) Received: from colo-mx.corp.redhat.com (unknown [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 46ACD92D62; Tue, 11 Apr 2017 19:42:40 +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 D53595EC64; Tue, 11 Apr 2017 19:42:38 +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 v3BJgbEV031544 for ; Tue, 11 Apr 2017 15:42:37 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7AC4C189A7; Tue, 11 Apr 2017 19:42:37 +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 692B718982 for ; Tue, 11 Apr 2017 19:42: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 EF4CB3D941 for ; Tue, 11 Apr 2017 19:42:33 +0000 (UTC) Received: by mail-qk0-f172.google.com with SMTP id h67so6765071qke.0 for ; Tue, 11 Apr 2017 12:42:33 -0700 (PDT) Received: from dawid-fedora.datto.lan ([47.19.105.250]) by smtp.gmail.com with ESMTPSA id a2sm3720879qte.64.2017.04.11.12.42.15 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 11 Apr 2017 12:42:19 -0700 (PDT) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com A7F1D6AAD3 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 A7F1D6AAD3 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="BsKjzOOY" DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com EF4CB3D941 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 EF4CB3D941 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=Z0gXSWYxUziGQs6AzCZhB/AcTsWKs8O/wo+aHW5uHbY=; b=BsKjzOOY+krY+OFk/tXLEi1EQBL7+kKiIWIWHnlRhWjPcA1pACG+uKKvQIAmpU2aEf 1+iOmnf5GF7G58sgt1268VICVYF6i3d/n1Ex5Sz9oexKs5JMIKzFnFrSUWsfuyOPV9sv Lh5/jUPE28IMJg6ZiY5+v/ptNLNoPvr4SuPuwLWqhYtVnRwcqHMWGRSo6OUxOXn+5zJX gVk6QEIRzKKswCbyMnDirTXfiYf1vXZhqgvQr5ytS/CIesC5QH9vIDiqpxiPKPNlPMdp zHTVR/bE6GV7y9dHiXoCFTnZNY+AEoU7uCDPCBWPO3NoJtPdkobS1NKux/LNUwaKqIgz G96g== 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=Z0gXSWYxUziGQs6AzCZhB/AcTsWKs8O/wo+aHW5uHbY=; b=HJK9+aYEho9SbfHxNLyLYXEQ7iYvafBoGXg+y7QU80qX1HvRLJEu61PVybOXpzLhfL jzlbCjH/voRJo1esu7sJ0UqrkwwYQhQtBE1vQ3n0Tk4siOF5ukEhn9w+g8Tu1l66ptuX rLtn4wsUfYGREhP6orrFhHUWtJ7ewBHcWz9gZL1NHJnGZ6fZsiOUZPtZoxQ4j2atrsMP oJUmOgTQhuv8WLXdGT6wtXv4wYSVJvq0qLGbwvyAnwfGnfsyJ168ODVJOIpb1RaGOdcb 2n1NDhsvjrffoNcTsAlNrbNWw/BTRgovxP5+zmQWy4i2KFoGa4lm+eEaZ8Jg+StfdcUk rUDA== X-Gm-Message-State: AFeK/H1RXYbytx9tF2QeLgyy7J4sYtbXTW+rkJcPyq6WQPGakTFEm61v3iDQIyAkN4MxU+HD X-Received: by 10.55.157.3 with SMTP id g3mr47203663qke.30.1491939752946; Tue, 11 Apr 2017 12:42:32 -0700 (PDT) From: Dawid Zamirski To: libvir-list@redhat.com Date: Tue, 11 Apr 2017 15:42:14 -0400 Message-Id: <20170411194214.23671-1-dzamirski@datto.com> In-Reply-To: <20170411150236.2746-1-dzamirski@datto.com> References: <20170411150236.2746-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, 11 Apr 2017 19:42:34 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Tue, 11 Apr 2017 19:42:34 +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.911 (BAYES_50, DCC_REPUT_00_12, DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_NONE, 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.30 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2] 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Tue, 11 Apr 2017 19:42:41 +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 v2: * move notes variable assignment outside of the loop so that it's not reset at each iteration. src/hyperv/hyperv_driver.c | 25 +++++++++++++++++++++++-- src/hyperv/hyperv_wmi_generator.py | 2 +- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c index 090ea24..350f123 100644 --- a/src/hyperv/hyperv_driver.c +++ b/src/hyperv/hyperv_driver.c @@ -894,8 +894,29 @@ 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++; + } + + 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