From nobody Mon Feb 9 11:38:27 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=openvz.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1648502276801617.6319876416991; Mon, 28 Mar 2022 14:17:56 -0700 (PDT) Received: from localhost ([::1]:45604 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nYwkM-0004Hq-Uo for importer@patchew.org; Mon, 28 Mar 2022 17:17:54 -0400 Received: from eggs.gnu.org ([209.51.188.92]:49076) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nYwiI-0001Vm-Cg for qemu-devel@nongnu.org; Mon, 28 Mar 2022 17:15:46 -0400 Received: from [2a00:1450:4864:20::22f] (port=39615 helo=mail-lj1-x22f.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nYwiG-0003oj-Ro for qemu-devel@nongnu.org; Mon, 28 Mar 2022 17:15:46 -0400 Received: by mail-lj1-x22f.google.com with SMTP id bn33so20959894ljb.6 for ; Mon, 28 Mar 2022 14:15:44 -0700 (PDT) Received: from localhost.localdomain ([93.175.1.181]) by smtp.gmail.com with ESMTPSA id k15-20020a2e92cf000000b002493cc687f3sm1855827ljh.45.2022.03.28.14.15.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Mar 2022 14:15:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz-org.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Ckh2kBLtdsCsb66fc7ENo7NnFXc/l4GnQNLcbYnl71k=; b=79zr+0t2aHHoWB6KVl7C/jM37Q2MpemE0152izS3V4UJKHRLdyAgGOtUlrhncC647E cfnTMwLHm4XEpArdy/mMRTkUvPFnM/0VSrRhJjWFxR4De+V+jyXjXRXmJgEbb1vgx0fw Z2fYVTnosc4EWjXAGpHZ+qdi80MU9nXEATsU+Ok2flz+c8Ra1JGviacvqzdjJ9Xh/y7T Anh0PWJDYU4THbNDeoGjzY3KDFBy8gzMZbzKqDEXiMTb5msWD8Ok7iNopNbtgZgVspZm mmZ2NVhdfXmYQmaQqJWTAAoNRTCkMSu/asFv7KPB7DxzHi0nSmPutMMUMES3U+14jAtb RRRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Ckh2kBLtdsCsb66fc7ENo7NnFXc/l4GnQNLcbYnl71k=; b=QQcvfmAuJLWEtEnC6BchEOdRbd3RdULu21RGTm6ZVqFAbZsW77ne2iUnGNHUvh8TGo WXABnBzd7u9zk8qCWzEokO51yuXI3Eo4HIgAc9nSJ/gV0WV+LH5onjItfz+h/+ceIAtP 4uCaV/Fjtqq/UcmO1b6xevt9QnqZs6OcNxAmL5HtR8+Q/z+AiqZzLKeVFi+WGQx/arnC 7SiGvOInrhATzmv7nXlPnvGEWSeNRMsanfY8CokgKsDuWXi6ES2ix5fDD6XvMLpr85Dr yl57YMWi+/lIz6EVmV3As633n8Q9qghDSLC5845pUjTnlCpg85QVQ5mlngVEab7hfP8h Hnsw== X-Gm-Message-State: AOAM533KGdbBiNpCEuztNBOc0vOA8lOoJeEZSnQASIU3haCkhA7Gysx9 QvtjXWy4PHlgQxRKcPHKRyDNkfGOZpjmOw== X-Google-Smtp-Source: ABdhPJxx40+R4F1lakn34jWH1/g0lHBkhFeFox1nMocrFsRZG6LWZscIJY5FyB4dZdv+lH9vcXeM6g== X-Received: by 2002:a2e:808d:0:b0:245:a501:241 with SMTP id i13-20020a2e808d000000b00245a5010241mr21817735ljg.479.1648502142929; Mon, 28 Mar 2022 14:15:42 -0700 (PDT) From: Maxim Davydov To: qemu-devel@nongnu.org Subject: [PATCH v1 1/9] qmp: Add dump machine type compatible properties Date: Tue, 29 Mar 2022 00:15:31 +0300 Message-Id: <20220328211539.90170-2-maxim.davydov@openvz.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220328211539.90170-1-maxim.davydov@openvz.org> References: <20220328211539.90170-1-maxim.davydov@openvz.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::22f (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::22f; envelope-from=maxim.davydov@openvz.org; helo=mail-lj1-x22f.google.com X-Spam_score_int: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: eduardo@habkost.net, v.sementsov-og@mail.ru, berrange@redhat.com, xiaoguangrong.eric@gmail.com, mst@redhat.com, jsnow@redhat.com, crosa@redhat.com, f4bug@amsat.org, chen.zhang@intel.com, armbru@redhat.com, wangyanan55@huawei.com, marcandre.lureau@redhat.com, imammedo@redhat.com, lizhijian@fujitsu.com, pbonzini@redhat.com, ani@anisinha.ca, den@openvz.org, maxim.davydov@openvz.org, eblake@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1648502281057100007 Content-Type: text/plain; charset="utf-8" This patch adds the ability to get all the compat_props of the corresponding supported machines for their comparison. Example: { "execute" : "query-machines", "arguments" : { "is-full" : true } } Signed-off-by: Maxim Davydov Reviewed-by: Vladimir Sementsov-Ogievskiy --- hw/core/machine-qmp-cmds.c | 25 +++++++++++++++- qapi/machine.json | 58 +++++++++++++++++++++++++++++++++++-- tests/qtest/fuzz/qos_fuzz.c | 2 +- 3 files changed, 81 insertions(+), 4 deletions(-) diff --git a/hw/core/machine-qmp-cmds.c b/hw/core/machine-qmp-cmds.c index 4f4ab30f8c..8f3206ba8d 100644 --- a/hw/core/machine-qmp-cmds.c +++ b/hw/core/machine-qmp-cmds.c @@ -74,7 +74,8 @@ CpuInfoFastList *qmp_query_cpus_fast(Error **errp) return head; } =20 -MachineInfoList *qmp_query_machines(Error **errp) +MachineInfoList *qmp_query_machines(bool has_is_full, bool is_full, + Error **errp) { GSList *el, *machines =3D object_class_get_list(TYPE_MACHINE, false); MachineInfoList *mach_list =3D NULL; @@ -107,6 +108,28 @@ MachineInfoList *qmp_query_machines(Error **errp) info->default_ram_id =3D g_strdup(mc->default_ram_id); info->has_default_ram_id =3D true; } + if (has_is_full && is_full && mc->compat_props) { + int i; + info->compat_props =3D NULL; + info->has_compat_props =3D true; + + for (i =3D 0; i < mc->compat_props->len; i++) { + GlobalProperty *mt_prop =3D g_ptr_array_index(mc->compat_p= rops, + i); + ObjectClass *klass =3D object_class_by_name(mt_prop->drive= r); + CompatProperty *prop; + + prop =3D g_malloc0(sizeof(*prop)); + if (klass && object_class_is_abstract(klass)) { + prop->abstract =3D true; + } + prop->driver =3D g_strdup(mt_prop->driver); + prop->property =3D g_strdup(mt_prop->property); + prop->value =3D g_strdup(mt_prop->value); + + QAPI_LIST_PREPEND(info->compat_props, prop); + } + } =20 QAPI_LIST_PREPEND(mach_list, info); } diff --git a/qapi/machine.json b/qapi/machine.json index 42fc68403d..16e961477c 100644 --- a/qapi/machine.json +++ b/qapi/machine.json @@ -130,6 +130,28 @@ ## { 'command': 'query-cpus-fast', 'returns': [ 'CpuInfoFast' ] } =20 +## +# @CompatProperty: +# +# Machine type compatible property. It's based on GlobalProperty and creat= ed +# for machine type compat properties (see scripts) +# +# @driver: name of the driver that has GlobalProperty +# +# @abstract: Bool value that shows that property is belonged to abstract c= lass +# +# @property: global property name +# +# @value: global property value +# +# Since: 7.0 +## +{ 'struct': 'CompatProperty', + 'data': { 'driver': 'str', + 'abstract': 'bool', + 'property': 'str', + 'value': 'str' } } + ## # @MachineInfo: # @@ -158,6 +180,9 @@ # # @default-ram-id: the default ID of initial RAM memory backend (since 5.2) # +# @compat-props: List of compatible properties that defines machine type +# (since 7.0) +# # Since: 1.2 ## { 'struct': 'MachineInfo', @@ -165,18 +190,47 @@ '*is-default': 'bool', 'cpu-max': 'int', 'hotpluggable-cpus': 'bool', 'numa-mem-supported': 'bool', 'deprecated': 'bool', '*default-cpu-type': 'str', - '*default-ram-id': 'str' } } + '*default-ram-id': 'str', '*compat-props': ['CompatProperty'] = } } =20 ## # @query-machines: # # Return a list of supported machines # +# @is-full: if true return will contain information about machine type=20 +# compatible properties (since 7.0) +# # Returns: a list of MachineInfo # # Since: 1.2 +# +# Example: +# +# -> { "execute" : "query-machines", "arguments" : { "is-full" : true } } +# <- { "return": [ +# { +# "hotpluggable-cpus": true, +# "name": "pc-q35-6.2", +# "compat-props": [ +# { +# "abstract": false, +# "driver": "virtio-mem", +# "property": "unplugged-inaccessible", +# "value": "off" +# } +# ], +# "numa-mem-supported": false, +# "default-cpu-type": "qemu64-x86_64-cpu", +# "cpu-max": 288, +# "deprecated": false, +# "default-ram-id": "pc.ram" +# }, +# ... +# } ## -{ 'command': 'query-machines', 'returns': ['MachineInfo'] } +{ 'command': 'query-machines', + 'data': { '*is-full': 'bool' }, + 'returns': ['MachineInfo'] } =20 ## # @CurrentMachineParams: diff --git a/tests/qtest/fuzz/qos_fuzz.c b/tests/qtest/fuzz/qos_fuzz.c index 7a244c951e..3f9c1ede6e 100644 --- a/tests/qtest/fuzz/qos_fuzz.c +++ b/tests/qtest/fuzz/qos_fuzz.c @@ -47,7 +47,7 @@ static void qos_set_machines_devices_available(void) MachineInfoList *mach_info; ObjectTypeInfoList *type_info; =20 - mach_info =3D qmp_query_machines(&error_abort); + mach_info =3D qmp_query_machines(false, false, &error_abort); machines_apply_to_node(mach_info); qapi_free_MachineInfoList(mach_info); =20 --=20 2.31.1 From nobody Mon Feb 9 11:38:27 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=openvz.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1648502278127169.8562030010513; Mon, 28 Mar 2022 14:17:58 -0700 (PDT) Received: from localhost ([::1]:45876 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nYwkO-0004TU-VK for importer@patchew.org; Mon, 28 Mar 2022 17:17:56 -0400 Received: from eggs.gnu.org ([209.51.188.92]:49106) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nYwiL-0001XU-9m for qemu-devel@nongnu.org; Mon, 28 Mar 2022 17:15:49 -0400 Received: from [2a00:1450:4864:20::134] (port=36588 helo=mail-lf1-x134.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nYwiJ-0003p3-86 for qemu-devel@nongnu.org; Mon, 28 Mar 2022 17:15:48 -0400 Received: by mail-lf1-x134.google.com with SMTP id bt26so26965278lfb.3 for ; Mon, 28 Mar 2022 14:15:46 -0700 (PDT) Received: from localhost.localdomain ([93.175.1.181]) by smtp.gmail.com with ESMTPSA id k15-20020a2e92cf000000b002493cc687f3sm1855827ljh.45.2022.03.28.14.15.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Mar 2022 14:15:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz-org.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=3HqMSA/clTPoDdP4aVujnhVnvcdeuLUE6tAeAz9JVuU=; b=U6KwcpitTnJEmpICCxE8RxZKMC/V+mE9+UelVwsmhskRFAZtZOkY7CEeYjVea8bSY9 lbxZnh/cWDpRyQ7PdRgO39GzYvazNzWUqby3EpCwJcKjxUzYndsN/2IMAvovxdH0uHJs RzgMgx8M43eSCaD9aNAu9blbkWHgMOLyM7UmXIIfaY1pX1R0W1DOaXGQ34YU6K2tNp4s QHueG8Ao7KfgkqQPGVH6Zu/f3xaVJBtXw++ScJw1hCdMNCpverL1l2x7P40egQxMlJtW ikZyb6GxonPdNVpGPD280sUPm6P0GKrsdD0YuAahSaF43fiY6HRrOjdK0IiVTP+bXNwg 7tTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=3HqMSA/clTPoDdP4aVujnhVnvcdeuLUE6tAeAz9JVuU=; b=w3KtFaWzMgbuvbRfs2SYntVNdJWJ7gzTiaTZOTQHRjm000sDRtxyn6/YUpkuDZ7wf8 GH3KZBdNMQAF4p981RHjP2rfNCBbmkVQE+TorFhAKJLVVplje7MIoovQuI/C7iECaQM/ jNWLNY8Nw2QISyrOD4Zr/ZqhMO0Xjwtriv6i4s2SgS579XEfZaZEfwXcZ4qfgCfd+sQ3 UFX50OrZrjjHfVRa2HLunDtrh80HMh1qdihBxTR6r0zYCGTNQSXPoS/dJAbGvU9E/RKa NYejOz9wITzjPKzlx7O/94k6hrmWrGh0ssVdIBPS73Ma15+gm9J3Y/QWAj0NRT3S4FP2 uMMg== X-Gm-Message-State: AOAM5339EaDUnulTqoWhGsXzlNv3zDVAJ9BJKzIxrFIW+dlLK8nstcOr l+NtAbzCnKT794P7dSrpquK+rMEzwmzBoA== X-Google-Smtp-Source: ABdhPJyCpmZB7Ch4bAB17JknwzryvwUxDzNqWd2dptoppnJuRzncbpCAPJUrNYAn2OY2pDUaNn443A== X-Received: by 2002:a05:6512:c29:b0:44a:865e:19c4 with SMTP id z41-20020a0565120c2900b0044a865e19c4mr11389792lfu.306.1648502144416; Mon, 28 Mar 2022 14:15:44 -0700 (PDT) From: Maxim Davydov To: qemu-devel@nongnu.org Subject: [PATCH v1 2/9] pci: add null-pointer check Date: Tue, 29 Mar 2022 00:15:32 +0300 Message-Id: <20220328211539.90170-3-maxim.davydov@openvz.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220328211539.90170-1-maxim.davydov@openvz.org> References: <20220328211539.90170-1-maxim.davydov@openvz.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::134 (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::134; envelope-from=maxim.davydov@openvz.org; helo=mail-lf1-x134.google.com X-Spam_score_int: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: eduardo@habkost.net, v.sementsov-og@mail.ru, berrange@redhat.com, xiaoguangrong.eric@gmail.com, mst@redhat.com, jsnow@redhat.com, crosa@redhat.com, f4bug@amsat.org, chen.zhang@intel.com, armbru@redhat.com, wangyanan55@huawei.com, marcandre.lureau@redhat.com, imammedo@redhat.com, lizhijian@fujitsu.com, pbonzini@redhat.com, ani@anisinha.ca, den@openvz.org, maxim.davydov@openvz.org, eblake@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1648502279696100005 Content-Type: text/plain; charset="utf-8" Call pci_bus_get_w64_range can fail with the segmentation fault. For example, this can happen during attempt to get pci-hole64-end immediately after initialization. Signed-off-by: Maxim Davydov --- hw/pci-host/i440fx.c | 17 +++++++++++------ hw/pci-host/q35.c | 17 +++++++++++------ 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/hw/pci-host/i440fx.c b/hw/pci-host/i440fx.c index e08716142b..71a114e551 100644 --- a/hw/pci-host/i440fx.c +++ b/hw/pci-host/i440fx.c @@ -158,10 +158,12 @@ static uint64_t i440fx_pcihost_get_pci_hole64_start_v= alue(Object *obj) PCIHostState *h =3D PCI_HOST_BRIDGE(obj); I440FXState *s =3D I440FX_PCI_HOST_BRIDGE(obj); Range w64; - uint64_t value; + uint64_t value =3D 0; =20 - pci_bus_get_w64_range(h->bus, &w64); - value =3D range_is_empty(&w64) ? 0 : range_lob(&w64); + if (h->bus) { + pci_bus_get_w64_range(h->bus, &w64); + value =3D range_is_empty(&w64) ? 0 : range_lob(&w64); + } if (!value && s->pci_hole64_fix) { value =3D pc_pci_hole64_start(); } @@ -191,10 +193,13 @@ static void i440fx_pcihost_get_pci_hole64_end(Object = *obj, Visitor *v, I440FXState *s =3D I440FX_PCI_HOST_BRIDGE(obj); uint64_t hole64_start =3D i440fx_pcihost_get_pci_hole64_start_value(ob= j); Range w64; - uint64_t value, hole64_end; + uint64_t value =3D 0; + uint64_t hole64_end; =20 - pci_bus_get_w64_range(h->bus, &w64); - value =3D range_is_empty(&w64) ? 0 : range_upb(&w64) + 1; + if (h->bus) { + pci_bus_get_w64_range(h->bus, &w64); + value =3D range_is_empty(&w64) ? 0 : range_upb(&w64) + 1; + } hole64_end =3D ROUND_UP(hole64_start + s->pci_hole64_size, 1ULL << 30); if (s->pci_hole64_fix && value < hole64_end) { value =3D hole64_end; diff --git a/hw/pci-host/q35.c b/hw/pci-host/q35.c index ab5a47aff5..d679fd85ef 100644 --- a/hw/pci-host/q35.c +++ b/hw/pci-host/q35.c @@ -124,10 +124,12 @@ static uint64_t q35_host_get_pci_hole64_start_value(O= bject *obj) PCIHostState *h =3D PCI_HOST_BRIDGE(obj); Q35PCIHost *s =3D Q35_HOST_DEVICE(obj); Range w64; - uint64_t value; + uint64_t value =3D 0; =20 - pci_bus_get_w64_range(h->bus, &w64); - value =3D range_is_empty(&w64) ? 0 : range_lob(&w64); + if (h->bus) { + pci_bus_get_w64_range(h->bus, &w64); + value =3D range_is_empty(&w64) ? 0 : range_lob(&w64); + } if (!value && s->pci_hole64_fix) { value =3D pc_pci_hole64_start(); } @@ -157,10 +159,13 @@ static void q35_host_get_pci_hole64_end(Object *obj, = Visitor *v, Q35PCIHost *s =3D Q35_HOST_DEVICE(obj); uint64_t hole64_start =3D q35_host_get_pci_hole64_start_value(obj); Range w64; - uint64_t value, hole64_end; + uint64_t value =3D 0; + uint64_t hole64_end; =20 - pci_bus_get_w64_range(h->bus, &w64); - value =3D range_is_empty(&w64) ? 0 : range_upb(&w64) + 1; + if (h->bus) { + pci_bus_get_w64_range(h->bus, &w64); + value =3D range_is_empty(&w64) ? 0 : range_upb(&w64) + 1; + } hole64_end =3D ROUND_UP(hole64_start + s->mch.pci_hole64_size, 1ULL <<= 30); if (s->pci_hole64_fix && value < hole64_end) { value =3D hole64_end; --=20 2.31.1 From nobody Mon Feb 9 11:38:27 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=openvz.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1648502277056749.0672954615281; Mon, 28 Mar 2022 14:17:57 -0700 (PDT) Received: from localhost ([::1]:45746 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nYwkN-0004NT-Oz for importer@patchew.org; Mon, 28 Mar 2022 17:17:55 -0400 Received: from eggs.gnu.org ([209.51.188.92]:49102) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nYwiL-0001XP-3V for qemu-devel@nongnu.org; Mon, 28 Mar 2022 17:15:49 -0400 Received: from [2a00:1450:4864:20::22f] (port=40893 helo=mail-lj1-x22f.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nYwiJ-0003p5-94 for qemu-devel@nongnu.org; Mon, 28 Mar 2022 17:15:48 -0400 Received: by mail-lj1-x22f.google.com with SMTP id g24so20947069lja.7 for ; Mon, 28 Mar 2022 14:15:46 -0700 (PDT) Received: from localhost.localdomain ([93.175.1.181]) by smtp.gmail.com with ESMTPSA id k15-20020a2e92cf000000b002493cc687f3sm1855827ljh.45.2022.03.28.14.15.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Mar 2022 14:15:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz-org.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=F/qWJafsiGLISrirR9TpiO6oI2wNp5jh8NKPrpO9D6Y=; b=RqN4tQztKbFzCIC6ZO3yl9XrwK4leQvHMyNb4Ie1wQp1MrIXdWkEqOKB1fTQTKNZkI DYkohGvtXLOD5pX8wqVJW9ksbP1PpA/aIdVFdLh0maSaoP2p7QWWb5R9f26C7/zNnGt9 eAY6TBuTEOQvVj9S9sJCDiTneHlSyZZwj8ojGQsliPqqeIXEXGCTYN6w2SOZxHlJ8IXr X1H46Pv2yegFhWHEUVoAck0uCuwS2UkJ5tBWCbxOeCeFrrpmtVCrapexFIWiUB+s3evj HMsmVc4UTu95ZAo6LvukO10JFupuqm6o5aX0BO0rIa/P3bbMyTKy1ChnadYJSt7ePUi1 PmQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=F/qWJafsiGLISrirR9TpiO6oI2wNp5jh8NKPrpO9D6Y=; b=mtukv5BsmqNCCnGtAX7cyO/4aNkycum8r/AlHuTYD5uBSEH/bu7Bk5Lw+ICU0aA2Rq b+eOpVFY/HbnLq5VK6d5Ph0NOQ5xGBswYf1bOmed4Qtj26Exjy9KlyIRivxrZmTwgwWf 2J8PvaUXZdC6oxM0HdRTzwUvNHDBlWBczvEwPjJG6IbyD8b27M2ebgLK4HxmdEIAez74 MXOTbnhEdM77BgpQ3MlvF5uTT8U7zcUi82EtIVIMH7ZNIsfQma1VBMVHtV5rnfIL20jK znyQcLKhLExCOOph4nq9nVomCcF05Ua9hAxXGvR80DoGXL74whEzerdCWUK+U4F1VPQq zfgg== X-Gm-Message-State: AOAM531P8jwOD/I3Mwm+j4waGytw+SJ2xdsn2FK7Ubepd2UNaaREr2mw mBF2bPNFJWxEMFWLyOy+g+kZI3Liqn76uA== X-Google-Smtp-Source: ABdhPJzUmT+E149adL/v7Zw6fNhchFirVLbFB51wklkrN3MRtV3N0kWH3U0r35lvAtFfPd92YuKxcQ== X-Received: by 2002:a05:651c:1699:b0:24a:d5a0:bfb2 with SMTP id bd25-20020a05651c169900b0024ad5a0bfb2mr1931657ljb.30.1648502145826; Mon, 28 Mar 2022 14:15:45 -0700 (PDT) From: Maxim Davydov To: qemu-devel@nongnu.org Subject: [PATCH v1 3/9] mem: appropriate handling getting mem region Date: Tue, 29 Mar 2022 00:15:33 +0300 Message-Id: <20220328211539.90170-4-maxim.davydov@openvz.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220328211539.90170-1-maxim.davydov@openvz.org> References: <20220328211539.90170-1-maxim.davydov@openvz.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::22f (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::22f; envelope-from=maxim.davydov@openvz.org; helo=mail-lj1-x22f.google.com X-Spam_score_int: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: eduardo@habkost.net, v.sementsov-og@mail.ru, berrange@redhat.com, xiaoguangrong.eric@gmail.com, mst@redhat.com, jsnow@redhat.com, crosa@redhat.com, f4bug@amsat.org, chen.zhang@intel.com, armbru@redhat.com, wangyanan55@huawei.com, marcandre.lureau@redhat.com, imammedo@redhat.com, lizhijian@fujitsu.com, pbonzini@redhat.com, ani@anisinha.ca, den@openvz.org, maxim.davydov@openvz.org, eblake@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1648502278551100002 Content-Type: text/plain; charset="utf-8" Attempt to get memory region if the device doesn't have hostmem may not be an error. This can be happen immediately after initialization (getting value without default one). Signed-off-by: Maxim Davydov --- hw/i386/sgx-epc.c | 5 ++++- hw/mem/nvdimm.c | 6 ++++++ hw/mem/pc-dimm.c | 5 +++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/hw/i386/sgx-epc.c b/hw/i386/sgx-epc.c index d664829d35..1a4c8acdcc 100644 --- a/hw/i386/sgx-epc.c +++ b/hw/i386/sgx-epc.c @@ -121,9 +121,12 @@ static MemoryRegion *sgx_epc_md_get_memory_region(Memo= ryDeviceState *md, { SGXEPCDevice *epc =3D SGX_EPC(md); HostMemoryBackend *hostmem; + DeviceState *dev =3D DEVICE(epc); =20 if (!epc->hostmem) { - error_setg(errp, "'" SGX_EPC_MEMDEV_PROP "' property must be set"); + if (dev->realized) { + error_setg(errp, "'" SGX_EPC_MEMDEV_PROP "' property must be s= et"); + } return NULL; } =20 diff --git a/hw/mem/nvdimm.c b/hw/mem/nvdimm.c index 7c7d777781..61e77e5476 100644 --- a/hw/mem/nvdimm.c +++ b/hw/mem/nvdimm.c @@ -166,9 +166,15 @@ static MemoryRegion *nvdimm_md_get_memory_region(Memor= yDeviceState *md, Error **errp) { NVDIMMDevice *nvdimm =3D NVDIMM(md); + PCDIMMDevice *dimm =3D PC_DIMM(nvdimm); Error *local_err =3D NULL; =20 if (!nvdimm->nvdimm_mr) { + /* Not error if we try get memory region after init */ + if (!dimm->hostmem) { + return NULL; + } + nvdimm_prepare_memory_region(nvdimm, &local_err); if (local_err) { error_propagate(errp, local_err); diff --git a/hw/mem/pc-dimm.c b/hw/mem/pc-dimm.c index f27e1a11ba..6fd74de97f 100644 --- a/hw/mem/pc-dimm.c +++ b/hw/mem/pc-dimm.c @@ -240,6 +240,11 @@ static void pc_dimm_md_set_addr(MemoryDeviceState *md,= uint64_t addr, static MemoryRegion *pc_dimm_md_get_memory_region(MemoryDeviceState *md, Error **errp) { + PCDIMMDevice *dimm =3D PC_DIMM(md); + /* Not error if we try get memory region after init */ + if (!dimm->hostmem) { + return NULL; + } return pc_dimm_get_memory_region(PC_DIMM(md), errp); } =20 --=20 2.31.1 From nobody Mon Feb 9 11:38:27 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=openvz.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1648502404617828.8497786247094; Mon, 28 Mar 2022 14:20:04 -0700 (PDT) Received: from localhost ([::1]:53856 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nYwmR-0001Sx-BS for importer@patchew.org; Mon, 28 Mar 2022 17:20:03 -0400 Received: from eggs.gnu.org ([209.51.188.92]:49118) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nYwiM-0001am-H3 for qemu-devel@nongnu.org; Mon, 28 Mar 2022 17:15:50 -0400 Received: from [2a00:1450:4864:20::12e] (port=46735 helo=mail-lf1-x12e.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nYwiL-0003pI-05 for qemu-devel@nongnu.org; Mon, 28 Mar 2022 17:15:50 -0400 Received: by mail-lf1-x12e.google.com with SMTP id e16so26930749lfc.13 for ; Mon, 28 Mar 2022 14:15:48 -0700 (PDT) Received: from localhost.localdomain ([93.175.1.181]) by smtp.gmail.com with ESMTPSA id k15-20020a2e92cf000000b002493cc687f3sm1855827ljh.45.2022.03.28.14.15.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Mar 2022 14:15:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz-org.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=fZKapn44JNSnvlOlsZjDBxj/jSMFPLsC8E1aDAQA7GM=; b=MQqdkG+IyOLTOI/nH3x5P0AbDBvI89sLmcA2WfyRqskzLkBfWQ95/ljbIKSRX4u15v ObeojMVEW/zwQpSZgJiIM1g7ICp8GMiqRWHOSIoVVps1CzljL33mpKegcJedXNbHzZhR vXPAIf7weziAhRJIwwuc1OOf1gwLFg2KOZ4yLocaFgQSiNxPs8So2t/CZtXb8otAEtI7 Eb9vPG1IzgUPH/W61YiDqWQgeyJEeC+qHgYLyXsBmMq0L6wT2V8W1Kf2L5fLbvTuUI3R zYY7ygdLp2eB3SLuySncbazdnYoMDmnuXLdXwqSfU3PJINN71n8YnYO5RBISLR+OAFkK wXlQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=fZKapn44JNSnvlOlsZjDBxj/jSMFPLsC8E1aDAQA7GM=; b=a3ypfTdTSRjMC7gweaIGaK86hzJxAD3U4FaLP02CzdaESkjkRbSNvPkR9hARpAoKAQ 1N44E/vTr6Q7hjhxxxjAB5c/7kh+u7oaHuXqS7MOoJpsKU/h/KbDyXNXI9fDNdL+dBrs 3BDLuMnS+P5jmc3Irfk5eCTdXDaHrFVGtG5KA2/nI/b8XdoGUmzz1w8Sn8Qi9v7VB+Er oz3pwIkhkGS+8Q9RUPOsAjAWNzP/ooi7SDjCnRV+tIMWXZWSCQvCqBre8NE+kOAMVFOl 8eTe6mwomnPy4iYlaZr9RWBzYt3sJeqh0grhXCkDH9WjbYcjvg2Us1zj73uK81pYmWrG qQ7Q== X-Gm-Message-State: AOAM531eqHkmfCmFl/FRwkUdkk8cu7mVzoCqO4F/RmPxAsqfdVIV6b1P PKkObpi3f/VsD61f2TrWbtEDHk2oyajjzw== X-Google-Smtp-Source: ABdhPJy6zsAMaM+lyFqDnpqftyaBL9IdNCdfmrljdSbTf4HZaVFEPjnX3bzRrkw3h8S8xkiajDsaVw== X-Received: by 2002:a05:6512:2214:b0:44a:348a:d6d with SMTP id h20-20020a056512221400b0044a348a0d6dmr21544010lfu.506.1648502147198; Mon, 28 Mar 2022 14:15:47 -0700 (PDT) From: Maxim Davydov To: qemu-devel@nongnu.org Subject: [PATCH v1 4/9] msmouse: add appropriate unregister handler Date: Tue, 29 Mar 2022 00:15:34 +0300 Message-Id: <20220328211539.90170-5-maxim.davydov@openvz.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220328211539.90170-1-maxim.davydov@openvz.org> References: <20220328211539.90170-1-maxim.davydov@openvz.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::12e (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::12e; envelope-from=maxim.davydov@openvz.org; helo=mail-lf1-x12e.google.com X-Spam_score_int: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: eduardo@habkost.net, v.sementsov-og@mail.ru, berrange@redhat.com, xiaoguangrong.eric@gmail.com, mst@redhat.com, jsnow@redhat.com, crosa@redhat.com, f4bug@amsat.org, chen.zhang@intel.com, armbru@redhat.com, wangyanan55@huawei.com, marcandre.lureau@redhat.com, imammedo@redhat.com, lizhijian@fujitsu.com, pbonzini@redhat.com, ani@anisinha.ca, den@openvz.org, maxim.davydov@openvz.org, eblake@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1648502405626100005 Content-Type: text/plain; charset="utf-8" Attempt to finalize msmouse after initalization brings to segmentation fault in QTAILQ_REMOVE. Signed-off-by: Maxim Davydov --- chardev/msmouse.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/chardev/msmouse.c b/chardev/msmouse.c index eb9231dcdb..2cc1b16561 100644 --- a/chardev/msmouse.c +++ b/chardev/msmouse.c @@ -146,7 +146,9 @@ static void char_msmouse_finalize(Object *obj) { MouseChardev *mouse =3D MOUSE_CHARDEV(obj); =20 - qemu_input_handler_unregister(mouse->hs); + if (mouse->hs) { + qemu_input_handler_unregister(mouse->hs); + } } =20 static QemuInputHandler msmouse_handler =3D { --=20 2.31.1 From nobody Mon Feb 9 11:38:27 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=openvz.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1648502404879676.064435366442; Mon, 28 Mar 2022 14:20:04 -0700 (PDT) Received: from localhost ([::1]:53954 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nYwmR-0001XE-Kt for importer@patchew.org; Mon, 28 Mar 2022 17:20:03 -0400 Received: from eggs.gnu.org ([209.51.188.92]:49146) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nYwiO-0001gb-GR for qemu-devel@nongnu.org; Mon, 28 Mar 2022 17:15:52 -0400 Received: from [2a00:1450:4864:20::12a] (port=40700 helo=mail-lf1-x12a.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nYwiN-0003rS-38 for qemu-devel@nongnu.org; Mon, 28 Mar 2022 17:15:52 -0400 Received: by mail-lf1-x12a.google.com with SMTP id t25so26963357lfg.7 for ; Mon, 28 Mar 2022 14:15:50 -0700 (PDT) Received: from localhost.localdomain ([93.175.1.181]) by smtp.gmail.com with ESMTPSA id k15-20020a2e92cf000000b002493cc687f3sm1855827ljh.45.2022.03.28.14.15.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Mar 2022 14:15:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz-org.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=xJSmV3NZ+AOVy0EQfz+E+II5VBJktTYUyBL6qJb89d0=; b=ZIJ4NMiTtIVgNAkkh1T3dFB0Al14YBtAUP/exbs6srLToI/1xiDJD2quQpk7TYU5W5 TUlSWHvq+pHsYcHEIB1t1pHlgmzZnmx/Ks81+g7snIB0KopvMqxO5zEi5d3u055JTg+0 C4pe/0ELnuopk3Z9kV3StLX29eA5r/FAaHFIOsSLeh4jMuQYD7XtS2p6xq3oIiojSPd5 4sbe8NIlSeI1wU5e52JmD35vIxJKiN8FhwCyLpQ6pZQ5U98IyfR2fCgy1GTdFV1ZrKt6 yXnHItiVU7uZfL5PUALcOYmXg5id2BVWIp+wCltPTQWI52RUYHFRsVm0uPgJcPzecnx/ Q4Jw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=xJSmV3NZ+AOVy0EQfz+E+II5VBJktTYUyBL6qJb89d0=; b=zkQSnurS8Z8Aksrnv67crLfExCfctSUIggcA5F3WE8Agk/jaovQsY19XvGGcLtiJuy 0vCMr39S6Hv9H/LiifZDKnVDrH0oHIVkomB5f7brconxNXXw+iXkMyeYkKZZh9dOHaim X20E287nRvInbTBvzHA75nrO3cVcTss9xM4unlIaCIHRXcwENSCw9X7R4lNn5oaGRdRq sqaFXI4hVNoXk6biEsziClcntJEPkqAIVOJIkHuTAHzx55Muirpk8957um029tx9eFrj FMo9pR7fZffzOOWGbirXnsvUSwcpj1Ue1Rf8ou+X2WauJMADEWkbp4bL06Ci/QYfjw99 vOIQ== X-Gm-Message-State: AOAM531jJaIEQNPwda2rlz7KiI42j54nQ9P6B2vNXduEvthuSPYs3X9H SRw3SI+Zzi5NlOpB3vc7xCf9T7DMvgJqpg== X-Google-Smtp-Source: ABdhPJxcJt7FOl5RzSBCR+nTKQ8q4kKuJ0dmaGdN/lnOslPl5HjyGhngJS7JCb4l4r0MJ13kqNyP2g== X-Received: by 2002:a05:6512:2341:b0:448:2465:7cf with SMTP id p1-20020a056512234100b00448246507cfmr20604947lfu.474.1648502148584; Mon, 28 Mar 2022 14:15:48 -0700 (PDT) From: Maxim Davydov To: qemu-devel@nongnu.org Subject: [PATCH v1 5/9] wctablet: add appropriate unregister handler Date: Tue, 29 Mar 2022 00:15:35 +0300 Message-Id: <20220328211539.90170-6-maxim.davydov@openvz.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220328211539.90170-1-maxim.davydov@openvz.org> References: <20220328211539.90170-1-maxim.davydov@openvz.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::12a (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::12a; envelope-from=maxim.davydov@openvz.org; helo=mail-lf1-x12a.google.com X-Spam_score_int: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: eduardo@habkost.net, v.sementsov-og@mail.ru, berrange@redhat.com, xiaoguangrong.eric@gmail.com, mst@redhat.com, jsnow@redhat.com, crosa@redhat.com, f4bug@amsat.org, chen.zhang@intel.com, armbru@redhat.com, wangyanan55@huawei.com, marcandre.lureau@redhat.com, imammedo@redhat.com, lizhijian@fujitsu.com, pbonzini@redhat.com, ani@anisinha.ca, den@openvz.org, maxim.davydov@openvz.org, eblake@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1648502405538100003 Content-Type: text/plain; charset="utf-8" Attempt to finalize msmouse after initalization brings to segmentation fault in QTAILQ_REMOVE. Signed-off-by: Maxim Davydov --- chardev/wctablet.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/chardev/wctablet.c b/chardev/wctablet.c index e8b292c43c..43bdf6b608 100644 --- a/chardev/wctablet.c +++ b/chardev/wctablet.c @@ -319,7 +319,9 @@ static void wctablet_chr_finalize(Object *obj) { TabletChardev *tablet =3D WCTABLET_CHARDEV(obj); =20 - qemu_input_handler_unregister(tablet->hs); + if (tablet->hs) { + qemu_input_handler_unregister(tablet->hs); + } } =20 static void wctablet_chr_open(Chardev *chr, --=20 2.31.1 From nobody Mon Feb 9 11:38:27 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=openvz.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1648502401542678.3799324262682; Mon, 28 Mar 2022 14:20:01 -0700 (PDT) Received: from localhost ([::1]:53698 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nYwmO-0001MR-DA for importer@patchew.org; Mon, 28 Mar 2022 17:20:00 -0400 Received: from eggs.gnu.org ([209.51.188.92]:49162) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nYwiP-0001js-Nn for qemu-devel@nongnu.org; Mon, 28 Mar 2022 17:15:53 -0400 Received: from [2a00:1450:4864:20::12f] (port=35608 helo=mail-lf1-x12f.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nYwiN-0003rm-Oz for qemu-devel@nongnu.org; Mon, 28 Mar 2022 17:15:53 -0400 Received: by mail-lf1-x12f.google.com with SMTP id h7so26997498lfl.2 for ; Mon, 28 Mar 2022 14:15:51 -0700 (PDT) Received: from localhost.localdomain ([93.175.1.181]) by smtp.gmail.com with ESMTPSA id k15-20020a2e92cf000000b002493cc687f3sm1855827ljh.45.2022.03.28.14.15.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Mar 2022 14:15:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz-org.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=BYqdBYE6uDLQHGP/gZTw0UYrRiZaRuFE2yevThnIFfA=; b=NPcP2aVPokjrv13wzjDp1DuTXPjj1dCafYjvh/UGXx3cTxPqTSLKXU3eHDCe6MzcRV f2H3Ij6zr6RC6mFHLI8e0lVMImW6qDsJdebIRyY02GV/wMBUAx/LpmL41sYHXRcvwEmQ Jdr8htsCGHdru4eOfZNWdU6CUq2sFkpP/nOIHJL7sKpPD82dPt0HyABRLDNFUr9COuoY 8eGpIkZmKRe0YEP7VK77AOuPj6ldQi4lrwGe5AsjUquOcZDb0tXW8qqI7X8FuziqpX8a y3p9IwPlDkMsKfD2zb/A6StliVgQZi7K7gOH8LdrNiS4LM4GiHf1K17y33Z788DCuK0u oGcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=BYqdBYE6uDLQHGP/gZTw0UYrRiZaRuFE2yevThnIFfA=; b=N0jbYBuNXQrjKpxmOB3QcRl/4TpCBo0rEevX0YRAjpmNH0BH9wws8VeGQinn3C4gSk dwXI/BPq202NN+BfJ9ioMHY0iYPqPEIlnZXvY0l1mN54CXuvO318rE3CyfEu8iRDQ5ww oB+NK1zsyAnud5e+mej2LYH6Zkdp61CMca6gj9HFf9ugar+sP69k5YuzdKxhnhcUcZzU iXgTWUpLp5BKskyT+1kuR24fswwW9y78Rb7SIVkgF+HgJ5CMl8eW60utQ+VYaFEw2r/3 gvlp4k9Hf27bM35/ZSlQ2EtITXFfTHWr+EYb2/dGS33aH7aTYz3D8fqQjKn0H4dTQoGD jReQ== X-Gm-Message-State: AOAM530U+jpW0xmdLKqQLQWnaE3vppSfA6Vbg7tClm6EbImErYqHGjyH otliGfvVnIE/PCVeTDFqnq7N+JyqtmEj4Q== X-Google-Smtp-Source: ABdhPJxGUDoZarq620vEwvEQeZzY6kbaOMlp87tWl4YoozSCCl72Fg6bx28BUdzVVY92//5CCTixjw== X-Received: by 2002:a05:6512:1195:b0:44a:6e0a:115b with SMTP id g21-20020a056512119500b0044a6e0a115bmr17512823lfr.115.1648502150168; Mon, 28 Mar 2022 14:15:50 -0700 (PDT) From: Maxim Davydov To: qemu-devel@nongnu.org Subject: [PATCH v1 6/9] chardev: add appropriate getting address Date: Tue, 29 Mar 2022 00:15:36 +0300 Message-Id: <20220328211539.90170-7-maxim.davydov@openvz.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220328211539.90170-1-maxim.davydov@openvz.org> References: <20220328211539.90170-1-maxim.davydov@openvz.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::12f (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::12f; envelope-from=maxim.davydov@openvz.org; helo=mail-lf1-x12f.google.com X-Spam_score_int: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: eduardo@habkost.net, v.sementsov-og@mail.ru, berrange@redhat.com, xiaoguangrong.eric@gmail.com, mst@redhat.com, jsnow@redhat.com, crosa@redhat.com, f4bug@amsat.org, chen.zhang@intel.com, armbru@redhat.com, wangyanan55@huawei.com, marcandre.lureau@redhat.com, imammedo@redhat.com, lizhijian@fujitsu.com, pbonzini@redhat.com, ani@anisinha.ca, den@openvz.org, maxim.davydov@openvz.org, eblake@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1648502403742100001 Content-Type: text/plain; charset="utf-8" Attempt to get address after initialization shouldn't fail on assert in the qapi automatically generated code. As a possible solution, it can return null type. Signed-off-by: Maxim Davydov --- chardev/char-socket.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/chardev/char-socket.c b/chardev/char-socket.c index fab2d791d4..f851e3346b 100644 --- a/chardev/char-socket.c +++ b/chardev/char-socket.c @@ -33,6 +33,7 @@ #include "qapi/clone-visitor.h" #include "qapi/qapi-visit-sockets.h" #include "qemu/yank.h" +#include "qapi/qmp/qnull.h" =20 #include "chardev/char-io.h" #include "chardev/char-socket.h" @@ -1509,6 +1510,14 @@ char_socket_get_addr(Object *obj, Visitor *v, const = char *name, { SocketChardev *s =3D SOCKET_CHARDEV(obj); =20 + QNull *null =3D NULL; + + /* Return NULL type if getting addr was called after init */ + if (!s->addr) { + visit_type_null(v, NULL, &null, errp); + return; + } + visit_type_SocketAddress(v, name, &s->addr, errp); } =20 --=20 2.31.1 From nobody Mon Feb 9 11:38:27 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=openvz.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1648502409091715.338402514507; Mon, 28 Mar 2022 14:20:09 -0700 (PDT) Received: from localhost ([::1]:54138 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nYwmW-0001gB-1M for importer@patchew.org; Mon, 28 Mar 2022 17:20:08 -0400 Received: from eggs.gnu.org ([209.51.188.92]:49176) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nYwiQ-0001nJ-Nt for qemu-devel@nongnu.org; Mon, 28 Mar 2022 17:15:54 -0400 Received: from [2a00:1450:4864:20::12c] (port=33544 helo=mail-lf1-x12c.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nYwiP-0003sj-6F for qemu-devel@nongnu.org; Mon, 28 Mar 2022 17:15:54 -0400 Received: by mail-lf1-x12c.google.com with SMTP id bu29so27076710lfb.0 for ; Mon, 28 Mar 2022 14:15:52 -0700 (PDT) Received: from localhost.localdomain ([93.175.1.181]) by smtp.gmail.com with ESMTPSA id k15-20020a2e92cf000000b002493cc687f3sm1855827ljh.45.2022.03.28.14.15.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Mar 2022 14:15:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz-org.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0b/vKG8d64ziCwTuIIIwbPbN0lcgQlGSkacaatvrseM=; b=i6lFDa/kJjXR5SWepoAEEBGD+AukymL5qLiUVPUiiYzQsA6CfQK4OG++831otJLNqx M4ilr2jeMHuTJACUZRaZpDVcxKRgYKEGmsvuLerSeRl4fc0uIO3UJ4kNggtLFX8llcGz Yg+xJhove/3M8g+mO/QUj9DOpCm+aW09TH2RkQcev2l+qYmWxDIp1zhnOlHBedbDZeLw jDI249zMd1nrGC+bQx9p1CQ2TMQWGbcln8EZjIPHtZEDgd2rh/rFrQYjNPWe/AX5C9pu nUJH+LNUaQgr/E/IedBGoQK31kdUve0wuN9IgQc8ILonDrkLcki33E5b29Kd4iJhLSQx p1qw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0b/vKG8d64ziCwTuIIIwbPbN0lcgQlGSkacaatvrseM=; b=Mq7fXKGeFf+7TjsUkab8WJz7vAj4EFTbXhUzrt2Qq54O6MedCq3pW0LCbj1sqzlNQo gqiaOW+SJgf3Z5LsI0QZz0Tkwj65ZPe/3P180uvBKZcchV0v/HHzuUQPUCFphSjIGNft 1JzcKz8eSRzqTgTZeexIQ27IjoLenfzU26t4QaKXR+WoywyQ9h6EHTgxR+e7mZWtiMHJ OSkbNGhFSaHCNcvblrS/cm3VaV/knBp98EovdYKklxuajq49lV9pNWoURV2D4bE6BOfp Y2gD4Lt3dRBhTKLcv1cCMaKePAXKwjRJjlBB48jEIYyeNd/N6UqOM29saAmOD8LHz8nE 0Evg== X-Gm-Message-State: AOAM531W/P1DQf5aseczDgMbKS7+FpzxxV3YAnenw5ADTjTUt1pwgiVe +BnsceQDi8W4aVXNcJWK+TX+yuvQSfb2MA== X-Google-Smtp-Source: ABdhPJzCUf+b7BAsUzOB3Db2R9CWSfCnGEMiOepB2S+n5SEZsqvyVDcR93m2La4OFa3Qxnr7Fb49jg== X-Received: by 2002:ac2:4e0c:0:b0:44a:3260:e35d with SMTP id e12-20020ac24e0c000000b0044a3260e35dmr21484152lfr.104.1648502151614; Mon, 28 Mar 2022 14:15:51 -0700 (PDT) From: Maxim Davydov To: qemu-devel@nongnu.org Subject: [PATCH v1 7/9] colo-compare: safe finalization Date: Tue, 29 Mar 2022 00:15:37 +0300 Message-Id: <20220328211539.90170-8-maxim.davydov@openvz.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220328211539.90170-1-maxim.davydov@openvz.org> References: <20220328211539.90170-1-maxim.davydov@openvz.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::12c (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::12c; envelope-from=maxim.davydov@openvz.org; helo=mail-lf1-x12c.google.com X-Spam_score_int: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: eduardo@habkost.net, v.sementsov-og@mail.ru, berrange@redhat.com, xiaoguangrong.eric@gmail.com, mst@redhat.com, jsnow@redhat.com, crosa@redhat.com, f4bug@amsat.org, chen.zhang@intel.com, armbru@redhat.com, wangyanan55@huawei.com, marcandre.lureau@redhat.com, imammedo@redhat.com, lizhijian@fujitsu.com, pbonzini@redhat.com, ani@anisinha.ca, den@openvz.org, maxim.davydov@openvz.org, eblake@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1648502409711100001 Content-Type: text/plain; charset="utf-8" Fixes some possible issues with finalization. For example, finalization immediately after instance_init fails on the assert. Signed-off-by: Maxim Davydov --- net/colo-compare.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/net/colo-compare.c b/net/colo-compare.c index 62554b5b3c..81d8de0aaa 100644 --- a/net/colo-compare.c +++ b/net/colo-compare.c @@ -1426,7 +1426,7 @@ static void colo_compare_finalize(Object *obj) break; } } - if (QTAILQ_EMPTY(&net_compares)) { + if (QTAILQ_EMPTY(&net_compares) && colo_compare_active) { colo_compare_active =3D false; qemu_mutex_destroy(&event_mtx); qemu_cond_destroy(&event_complete_cond); @@ -1442,19 +1442,26 @@ static void colo_compare_finalize(Object *obj) =20 colo_compare_timer_del(s); =20 - qemu_bh_delete(s->event_bh); + if (s->event_bh) { + qemu_bh_delete(s->event_bh); + } =20 - AioContext *ctx =3D iothread_get_aio_context(s->iothread); - aio_context_acquire(ctx); - AIO_WAIT_WHILE(ctx, !s->out_sendco.done); - if (s->notify_dev) { - AIO_WAIT_WHILE(ctx, !s->notify_sendco.done); + if (s->iothread) { + AioContext *ctx =3D iothread_get_aio_context(s->iothread); + aio_context_acquire(ctx); + AIO_WAIT_WHILE(ctx, !s->out_sendco.done); + if (s->notify_dev) { + AIO_WAIT_WHILE(ctx, !s->notify_sendco.done); + } + aio_context_release(ctx); } - aio_context_release(ctx); =20 /* Release all unhandled packets after compare thead exited */ g_queue_foreach(&s->conn_list, colo_flush_packets, s); - AIO_WAIT_WHILE(NULL, !s->out_sendco.done); + /* Without colo_compare_complete done =3D=3D false without packets */ + if (!g_queue_is_empty(&s->out_sendco.send_list)) { + AIO_WAIT_WHILE(NULL, !s->out_sendco.done); + } =20 g_queue_clear(&s->conn_list); g_queue_clear(&s->out_sendco.send_list); --=20 2.31.1 From nobody Mon Feb 9 11:38:27 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=openvz.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1648502614603884.841532924653; Mon, 28 Mar 2022 14:23:34 -0700 (PDT) Received: from localhost ([::1]:32920 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nYwpp-0006aq-7X for importer@patchew.org; Mon, 28 Mar 2022 17:23:33 -0400 Received: from eggs.gnu.org ([209.51.188.92]:49204) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nYwiS-0001t5-R1 for qemu-devel@nongnu.org; Mon, 28 Mar 2022 17:15:56 -0400 Received: from [2a00:1450:4864:20::22a] (port=33533 helo=mail-lj1-x22a.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nYwiQ-0003tN-HJ for qemu-devel@nongnu.org; Mon, 28 Mar 2022 17:15:56 -0400 Received: by mail-lj1-x22a.google.com with SMTP id u3so21002253ljd.0 for ; Mon, 28 Mar 2022 14:15:54 -0700 (PDT) Received: from localhost.localdomain ([93.175.1.181]) by smtp.gmail.com with ESMTPSA id k15-20020a2e92cf000000b002493cc687f3sm1855827ljh.45.2022.03.28.14.15.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Mar 2022 14:15:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz-org.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=uJ24/uglX+XJ03oQfE1/6Xqa97vS7/5YP2QV3HloPNE=; b=zodEdULpAD4gqkEAohBBwdu2vU4PULN4V/PWvr+ljHnQxdGXGeHZHUU6wkQU5VkNk3 biAbiPlGQfjQSL4TVgjAfMGlle01GmBJ5ffaixoO48VhKtaYvlZlqwmG3M0rGDMUazBW AWl8PO4+2nani2lI3etIT8SKhTIjqGEc0l8D72hYbMiQbalB8dTQT9ahjrdQcvvlE9Jx H+jQOS8gLggl6i5GAwA6WOKoioSBrS6r2wTaJZbw1cqXNhpwJFHRAc2C31CUxsED3gSV t3W2ssLlU9cHJoXSROlAr8Jh+92cUeYQkCGpRNSgbBRmLmY9BXcKOamNhY6LAMrgXgIZ vXsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=uJ24/uglX+XJ03oQfE1/6Xqa97vS7/5YP2QV3HloPNE=; b=N5sibDeLSdv+DLkp7GvjVYt9XIz9eRN5ygubIJnB5/tjJ0hd023vyTE8S8Vr45L42Y kYT6TnvB7Vtp6f/nr1Dr7B+ehgH/g9leCIYTOM5gvTtupZacl8uovmAmSgAXI2iD/UVz kuYVne5Ow0ZGnaHz41zFqspq1zY5hwLiylMYnnAe+nfT8pc8XIpYsX5eG7eZMzlb4ZnA iv6wTFIaQA5uFanHHRnaRFmcz591nwnDdcawIXguSEIPWmUQsNa2IPVue2MMeLMvcGIG jSh4N6X7+1M1l0FaFWJF0cFt2ngGvF4NuoJEpDQU/t/jRvyKECGoOIz8WFvECvR95xqO 08KQ== X-Gm-Message-State: AOAM5314lIC4Dg42Y6f6JiyNBfHXrAgmgBv69n8a0cbhoeb+FBGvmoOv DnhbZoyDTdWn/K+To7iGMnwiItrjaXBUKQ== X-Google-Smtp-Source: ABdhPJzk3AvIq8LDJzhyAUEUlaH5/7lEouvnjFCpI5U7T7dSjrx0bYtxt6+fCCaZklCTFWRa/jHDnA== X-Received: by 2002:a05:651c:4c9:b0:249:afef:48a6 with SMTP id e9-20020a05651c04c900b00249afef48a6mr19144604lji.458.1648502152988; Mon, 28 Mar 2022 14:15:52 -0700 (PDT) From: Maxim Davydov To: qemu-devel@nongnu.org Subject: [PATCH v1 8/9] qom: add command to print initial properties Date: Tue, 29 Mar 2022 00:15:38 +0300 Message-Id: <20220328211539.90170-9-maxim.davydov@openvz.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220328211539.90170-1-maxim.davydov@openvz.org> References: <20220328211539.90170-1-maxim.davydov@openvz.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::22a (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::22a; envelope-from=maxim.davydov@openvz.org; helo=mail-lj1-x22a.google.com X-Spam_score_int: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: eduardo@habkost.net, v.sementsov-og@mail.ru, berrange@redhat.com, xiaoguangrong.eric@gmail.com, mst@redhat.com, jsnow@redhat.com, crosa@redhat.com, f4bug@amsat.org, chen.zhang@intel.com, armbru@redhat.com, wangyanan55@huawei.com, marcandre.lureau@redhat.com, imammedo@redhat.com, lizhijian@fujitsu.com, pbonzini@redhat.com, ani@anisinha.ca, den@openvz.org, maxim.davydov@openvz.org, eblake@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1648502615779100002 Content-Type: text/plain; charset="utf-8" The command "query-init-properties" is needed to get values of properties after initialization (not only default value). It makes sense, for example, when working with x86_64-cpu. All machine types (and x-remote-object, because its init uses machime type's infrastructure) should be skipped, because only the one instance can be correctly initialized. Signed-off-by: Maxim Davydov --- qapi/qom.json | 69 ++++++++++++++++++++++++++ qom/qom-qmp-cmds.c | 121 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 190 insertions(+) diff --git a/qapi/qom.json b/qapi/qom.json index eeb5395ff3..1eedc441eb 100644 --- a/qapi/qom.json +++ b/qapi/qom.json @@ -949,3 +949,72 @@ ## { 'command': 'object-del', 'data': {'id': 'str'}, 'allow-preconfig': true } + +## +# @InitValue: +# +# Not all objects have default values but they have "initial" values. +# +# @name: property name +# +# @value: Current value (default or after initialization. It makes sence, +# for example, for x86-cpus) +# +# Since: 7.0 +# +## +{ 'struct': 'InitValue', + 'data': { 'name': 'str', + '*value': 'any' } } + +## +# @ClassProperties: +# +# Initial values of properties that are owned by the class +# +# @classname: name of the class that owns appropriate properties +# +# @classprops: List of class properties +# +# Since: 7.0 +# +## +{ 'struct': 'ClassProperties', + 'data': { 'classname': 'str', + '*classprops': [ 'InitValue' ] } } + +## +# @InitProps: +# +# List of properties and their values that are available after class +# initialization. So it important to know default value of the property +# even if it doesn't have "QObject *defval" +# +# @name: Object name +# +# @props: List of properties +# +# Notes: a value in each property was defval if it's available +# otherwise it's obtained via "(ObjectPropertyAccessor*) get" +# immediately after initialization of device object. +# +# Since: 7.0 +# +## +{ 'struct': 'InitProps', + 'data': { 'name': 'str', + 'props': [ 'ClassProperties' ] } } + +## +# @query-init-properties: +# +# Returns list of all objects (except all types related with machine type) +# with all properties and their "default" values that will be available +# after initialization. The main purpose of this command is to be used to +# build table with all machine-type-specific properties +# +# Since: 7.0 +# +## +{ 'command': 'query-init-properties', + 'returns': [ 'InitProps' ] } diff --git a/qom/qom-qmp-cmds.c b/qom/qom-qmp-cmds.c index 2d6f41ecc7..c1bb3f1f8b 100644 --- a/qom/qom-qmp-cmds.c +++ b/qom/qom-qmp-cmds.c @@ -27,6 +27,7 @@ #include "qemu/cutils.h" #include "qom/object_interfaces.h" #include "qom/qom-qobject.h" +#include "hw/boards.h" =20 ObjectPropertyInfoList *qmp_qom_list(const char *path, Error **errp) { @@ -235,3 +236,123 @@ void qmp_object_del(const char *id, Error **errp) { user_creatable_del(id, errp); } + +static void query_object_prop(InitValueList **props_list, ObjectProperty *= prop, + Object *obj, Error **errp) +{ + InitValue *prop_info =3D NULL; + + /* Skip inconsiderable properties */ + if (strcmp(prop->name, "type") =3D=3D 0 || + strcmp(prop->name, "realized") =3D=3D 0 || + strcmp(prop->name, "hotpluggable") =3D=3D 0 || + strcmp(prop->name, "hotplugged") =3D=3D 0 || + strcmp(prop->name, "parent_bus") =3D=3D 0) { + return; + } + + prop_info =3D g_malloc0(sizeof(*prop_info)); + prop_info->name =3D g_strdup(prop->name); + prop_info->value =3D NULL; + if (prop->defval) { + prop_info->value =3D qobject_ref(prop->defval); + } else if (prop->get) { + /* + * crash-information in x86-cpu uses errp to return current state. + * So, after requesting this property it returns GenericError: + * "No crash occured" + */ + if (strcmp(prop->name, "crash-information") !=3D 0) { + prop_info->value =3D object_property_get_qobject(obj, prop->na= me, + errp); + } + } + prop_info->has_value =3D !!prop_info->value; + + QAPI_LIST_PREPEND(*props_list, prop_info); +} + +typedef struct QIPData { + InitPropsList **dev_list; + Error **errp; +} QIPData; + +static void query_init_properties_tramp(gpointer list_data, gpointer opaqu= e) +{ + ObjectClass *k =3D list_data; + Object *obj; + ObjectClass *parent; + GHashTableIter iter; + + QIPData *data =3D opaque; + ClassPropertiesList *class_props_list =3D NULL; + InitProps *dev_info; + + /* Only one machine can be initialized correctly (it's already happene= d) */ + if (object_class_dynamic_cast(k, TYPE_MACHINE)) { + return; + } + + const char *klass_name =3D object_class_get_name(k); + /* + * Uses machine type infrastructure with notifiers. It causes immediate + * notify and SEGSEGV during remote_object_machine_done + */ + if (strcmp(klass_name, "x-remote-object") =3D=3D 0) { + return; + } + + dev_info =3D g_malloc0(sizeof(*dev_info)); + dev_info->name =3D g_strdup(klass_name); + + obj =3D object_new_with_class(k); + + /* + * Part of ObjectPropertyIterator infrastructure, but we need more pre= cise + * control of current class to dump appropriate features + * This part was taken out from loop because first initialization diff= er + * from other reinitializations + */ + parent =3D object_get_class(obj); + g_hash_table_iter_init(&iter, obj->properties); + const char *prop_owner_name =3D object_get_typename(obj); + do { + InitValueList *prop_list =3D NULL; + ClassProperties *class_data; + + gpointer key, val; + while (g_hash_table_iter_next(&iter, &key, &val)) { + query_object_prop(&prop_list, (ObjectProperty *)val, obj, + data->errp); + } + class_data =3D g_malloc0(sizeof(*class_data)); + class_data->classname =3D g_strdup(prop_owner_name); + class_data->classprops =3D prop_list; + class_data->has_classprops =3D !!prop_list; + + QAPI_LIST_PREPEND(class_props_list, class_data); + + if (!parent) { + break; + } + g_hash_table_iter_init(&iter, parent->properties); + prop_owner_name =3D object_class_get_name(parent); + parent =3D object_class_get_parent(parent); + } while (true); + dev_info->props =3D class_props_list; + object_unref(OBJECT(obj)); + + QAPI_LIST_PREPEND(*(data->dev_list), dev_info); +} + +InitPropsList *qmp_query_init_properties(Error **errp) +{ + GSList *typename_list =3D object_class_get_list(TYPE_OBJECT, false); + + InitPropsList *dev_list =3D NULL; + QIPData data =3D { &dev_list, errp }; + g_slist_foreach(typename_list, query_init_properties_tramp, &data); + g_slist_free(typename_list); + + return dev_list; +} --=20 2.31.1 From nobody Mon Feb 9 11:38:27 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=openvz.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1648502613471226.73102073370035; Mon, 28 Mar 2022 14:23:33 -0700 (PDT) Received: from localhost ([::1]:32830 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nYwpn-0006X7-DS for importer@patchew.org; Mon, 28 Mar 2022 17:23:31 -0400 Received: from eggs.gnu.org ([209.51.188.92]:49228) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nYwiV-0001x2-Vq for qemu-devel@nongnu.org; Mon, 28 Mar 2022 17:16:03 -0400 Received: from [2a00:1450:4864:20::22a] (port=36729 helo=mail-lj1-x22a.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nYwiS-0003u9-8L for qemu-devel@nongnu.org; Mon, 28 Mar 2022 17:15:58 -0400 Received: by mail-lj1-x22a.google.com with SMTP id v12so8240207ljd.3 for ; Mon, 28 Mar 2022 14:15:55 -0700 (PDT) Received: from localhost.localdomain ([93.175.1.181]) by smtp.gmail.com with ESMTPSA id k15-20020a2e92cf000000b002493cc687f3sm1855827ljh.45.2022.03.28.14.15.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Mar 2022 14:15:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz-org.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=TCG2xV4J5L+FOsAT2lTCWPztzU+XMKH5lpvmFE1VfAY=; b=ihmWCE/wVZ1FiBkcU3I9XVikDWKgV90juttvyNO1UUBv4oO22gM674rmImRs4uCcpO A5Wio6+OZcX3FhM+P6dFC8zZeaau0cA/QNlAbUPwZGheAaeMe8GFU1wkJ9CjskSD/BIK EFWs/q4thFAoTggr2heced6LcixZkq+K0Q1tR6q0bXmitIQZ9cVSJrM3F/tjJsHqbNE+ LBd65IcXzLJCO3WyJKML30pwvtNESBfV8E1Q4U1mYgkqHmVaGUAkdZxCl89dN0T/uhur qzUu8ZRzsinwypkN8mzEBVyngTWmjCNgfAUqaL6zEXKKjn0u8xasdqXEId0Dq1X0OehJ rU+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=TCG2xV4J5L+FOsAT2lTCWPztzU+XMKH5lpvmFE1VfAY=; b=TYZixpxqBk3pi3z/Bhl4dyd4L4BF84rYePXW3lKwQzBBdo6cj2J9bmev8OqTo7OJKs wQk0MjzCpX+W2Kagh1ig4Pla1F+ET5uzxPwMnyo+Tr84ysQLzm8mnJczvwHThLj5U6pp YeBZwex8UNaRCd2dhpsUGPuhFwl9GPg5AxTXs3g09dII/l/J3gPKtbz4cQWyUizs+qYb dKxHLtvQf5wRLeG26t6pmEyFdkxUvJyDwPi2pNZfKgs7PS2HDmnxn3fFDOmqCr7uGmnj PCGn4nqjAXhGaKAJKMFkv+IZGuQVqueubFfbfjF7uv+Ik5hXVNblpXGZG8qb82UVarux CvwA== X-Gm-Message-State: AOAM532ZvCgHdeMuXzlwp32KmK6dOr2ChtJhBOrPoM7gWV+K/4ETFYcn NN0vwO6UaNnC7X5MU11PfkQpgNDLF9pW1g== X-Google-Smtp-Source: ABdhPJzHr24Uqmnwnq1FmG0ep8ov7eVuoWxjbQnuFCGv/CCQkp/sBWvVPHfi6NHyW+BlwJfGQh5jLg== X-Received: by 2002:a2e:7c17:0:b0:249:8221:4c2a with SMTP id x23-20020a2e7c17000000b0024982214c2amr22401084ljc.293.1648502154361; Mon, 28 Mar 2022 14:15:54 -0700 (PDT) From: Maxim Davydov To: qemu-devel@nongnu.org Subject: [PATCH v1 9/9] scripts: printing machine type compat properties Date: Tue, 29 Mar 2022 00:15:39 +0300 Message-Id: <20220328211539.90170-10-maxim.davydov@openvz.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220328211539.90170-1-maxim.davydov@openvz.org> References: <20220328211539.90170-1-maxim.davydov@openvz.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::22a (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::22a; envelope-from=maxim.davydov@openvz.org; helo=mail-lj1-x22a.google.com X-Spam_score_int: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: eduardo@habkost.net, v.sementsov-og@mail.ru, berrange@redhat.com, xiaoguangrong.eric@gmail.com, mst@redhat.com, jsnow@redhat.com, crosa@redhat.com, f4bug@amsat.org, chen.zhang@intel.com, armbru@redhat.com, wangyanan55@huawei.com, marcandre.lureau@redhat.com, imammedo@redhat.com, lizhijian@fujitsu.com, pbonzini@redhat.com, ani@anisinha.ca, den@openvz.org, maxim.davydov@openvz.org, eblake@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1648502615766100001 This script makes the information that can be obtained from query-init-properties and query-machines easy to read. Note: some init values from the devices can't be available like properties from virtio-9p when configure has --disable-virtfs. Such values are replaced by "DEFAULT". Another exception is properties of abstract classes. The default value of the abstract class property is common value of all child classes. But if the values of the child classes are different the default value will be "BASED_ON_CHILD" (for example, old x86_64-cpu can have unsupported feature). Example: 1) virsh qemu-monitor-command VM --pretty \ '{"execute" : "query-init-properties"}' > init_props.json 2) virsh qemu-monitor-command VM --pretty \ '{"execute" : "query-machines", "arguments" : {"is-full" : true}}' \ > compat_props.json 3) scripts/print_MT.py --MT_compat_props compat_props.json\ --init_props init_props.json --mt pc-q35-7.0 pc-q35-6.1 Output: =E2=95=92=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2= =95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95= =90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90= =E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2= =95=90=E2=95=90=E2=95=90=E2=95=A4=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95= =90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90= =E2=95=90=E2=95=A4=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2= =95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95= =95 =E2=94=82 property_name =E2=94=82 pc-q35-7.0 =E2=94= =82 pc-q35-6.1 =E2=94=82 =E2=95=9E=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2= =95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95= =90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90= =E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2= =95=90=E2=95=90=E2=95=90=E2=95=AA=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95= =90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90= =E2=95=90=E2=95=AA=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2= =95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95= =A1 =E2=94=82 ICH9-LPC-x-keep-pci-slot-hpc =E2=94=82 True =E2=94= =82 False =E2=94=82 =E2=94=9C=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2= =94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94= =80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80= =E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2= =94=80=E2=94=80=E2=94=80=E2=94=BC=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94= =80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80= =E2=94=80=E2=94=BC=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2= =94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94= =A4 =E2=94=82 nvme-ns-shared =E2=94=82 True =E2=94= =82 off =E2=94=82 =E2=94=9C=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2= =94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94= =80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80= =E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2= =94=80=E2=94=80=E2=94=80=E2=94=BC=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94= =80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80= =E2=94=80=E2=94=BC=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2= =94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94= =A4 =E2=94=82 vhost-user-vsock-device-seqpacket =E2=94=82 auto =E2=94= =82 off =E2=94=82 =E2=94=9C=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2= =94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94= =80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80= =E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2= =94=80=E2=94=80=E2=94=80=E2=94=BC=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94= =80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80= =E2=94=80=E2=94=BC=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2= =94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94= =A4 =E2=94=82 virtio-mem-unplugged-inaccessible =E2=94=82 auto =E2=94= =82 off =E2=94=82 =E2=94=9C=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2= =94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94= =80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80= =E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2= =94=80=E2=94=80=E2=94=80=E2=94=BC=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94= =80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80= =E2=94=80=E2=94=BC=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2= =94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94= =A4 =E2=94=82 x86_64-cpu-hv-version-id-build =E2=94=82 14393 =E2=94= =82 0x1bbc =E2=94=82 =E2=94=9C=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2= =94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94= =80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80= =E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2= =94=80=E2=94=80=E2=94=80=E2=94=BC=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94= =80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80= =E2=94=80=E2=94=BC=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2= =94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94= =A4 =E2=94=82 x86_64-cpu-hv-version-id-major =E2=94=82 10 =E2=94= =82 0x0006 =E2=94=82 =E2=94=9C=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2= =94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94= =80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80= =E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2= =94=80=E2=94=80=E2=94=80=E2=94=BC=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94= =80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80= =E2=94=80=E2=94=BC=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2= =94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94= =A4 =E2=94=82 x86_64-cpu-hv-version-id-minor =E2=94=82 0 =E2=94= =82 0x0001 =E2=94=82 =E2=95=98=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2= =95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95= =90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90= =E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2= =95=90=E2=95=90=E2=95=90=E2=95=A7=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95= =90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90= =E2=95=90=E2=95=A7=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2= =95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95= =9B Signed-off-by: Maxim Davydov --- scripts/print_MT.py | 274 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 274 insertions(+) create mode 100755 scripts/print_MT.py diff --git a/scripts/print_MT.py b/scripts/print_MT.py new file mode 100755 index 0000000000..8be13be8d7 --- /dev/null +++ b/scripts/print_MT.py @@ -0,0 +1,274 @@ +#! /usr/bin/python3 +# +# Script for printing machine type compatible features. It uses two JSON f= iles +# that should be generated by qmp-init-properties and query-machines. +# +# Copyright (c) 2022 Maxim Davydov +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +import pandas as pd +import json +from tabulate import tabulate +from argparse import ArgumentParser + + +# used for aliases and other names that can be changed +aliases =3D { "e1000-82540em": "e1000" } + + +def get_major(mt): + splited =3D mt.split('.') + if (len(splited) >=3D 2): + return int(mt.split('.')[1]) + else: + return 0 + + +def get_prefix(mt): + splited =3D mt.split('.') + if (len(splited) >=3D 1): + return mt.split('.')[0] + else: + return mt + + +def get_mt_sequence(mt_data): + mt_list =3D [mt['name'] for mt in mt_data['return']] + mt_list.remove('none') + + mt_list.sort(key=3Dget_major, reverse=3DTrue) + mt_list.sort(key=3Dget_prefix, reverse=3DTrue) + + return mt_list + + +def get_req_props(defval_data, prop_set, abstr_class_to_features): + req_prop_values =3D dict() + req_abstr_prop_values =3D dict() + + for device in defval_data['return']: + # Skip cpu devices that will break all default values for cpus + if device['name'] =3D=3D 'base-x86_64-cpu': + continue + if device['name'] =3D=3D 'max-x86_64-cpu': + continue + + # some features in mt set as one absract class + # but this features are owned by another class + device_props_owners =3D dict() + for props_class in device['props']: + if not 'classprops' in props_class: # for example, Object class + continue + + for prop in props_class['classprops']: + if not 'value' in prop: + continue + + prop_name =3D device['name'] + '-' + prop['name'] + device_props_owners[prop['name']] =3D prop['value'] + if prop_name in prop_set: + req_prop_values[prop_name] =3D prop['value'] + + for props_class in device['props']: + if not props_class['classname'] in abstr_class_to_features: + continue + + for req_prop in abstr_class_to_features[props_class['classname= ']]: + if not req_prop in device_props_owners: + continue + + prop_value =3D device_props_owners[req_prop] + prop_name =3D props_class['classname'] + '-' + req_prop + if req_abstr_prop_values.setdefault(prop_name, prop_value)= \ + !=3D prop_value: + req_abstr_prop_values[prop_name] =3D 'BASED_ON_CHILD' + + return req_prop_values, req_abstr_prop_values + + +def make_definition_table(mt_to_compat_props, prop_set, + req_props, req_abstr_props, is_full): + mt_table =3D dict() + for prop in sorted(prop_set): + if not is_full: + values =3D set() + for mt in mt_to_compat_props: + if prop in mt_to_compat_props[mt]: + values.add(mt_to_compat_props[mt][prop]) + else: + if prop in req_props: + values.add(req_props[prop]) + else: + values.add('DEFAULT') + # Skip the property if its value is the same for + # all required machines + if len(values) =3D=3D 1: + continue + + mt_table.setdefault('property_name', []).append(prop) + for mt in mt_to_compat_props: + if prop in mt_to_compat_props[mt]: + value =3D mt_to_compat_props[mt][prop] + mt_table.setdefault(mt, []).append(value) + else: + if prop in req_props: + mt_table.setdefault(mt, []).append(req_props[prop]) + else: + value =3D req_abstr_props.get(prop, 'DEFAULT') + mt_table.setdefault(mt, []).append(value) + + return mt_table + + +def get_standard_form(value): + if type(value) is str: + out =3D value.upper() + if out.isnumeric(): + return int(out) + if out =3D=3D 'TRUE': + return True + if out =3D=3D 'FALSE': + return False + + return value + + +def get_features(mt_data, defval_data, mts, is_full): + prop_set =3D set() + abstr_prop_set =3D set() + mt_to_compat_props =3D dict() + # It will be used for searching appropriate feature (sometimes class n= ame + # in machine type definition and real class name are different) + abstr_class_to_features =3D dict() + + for mt in mt_data['return']: + if mt['name'] =3D=3D 'none': + continue + + if not mt['name'] in mts: + continue + + mt_to_compat_props[mt['name']] =3D dict() + for prop in mt['compat-props']: + driver_name =3D aliases.get(prop['driver'], prop['driver']) + prop_name =3D prop['driver'] + '-' + prop['property'] + real_name =3D driver_name + '-' + prop['property'] + # value is always string + prop_val =3D get_standard_form(prop['value']) + if prop['abstract']: + mt_to_compat_props[mt['name']][real_name] =3D prop_val + abstr_prop_set.add(real_name) + abstr_class_to_features.setdefault(driver_name, + set()).add(prop['proper= ty']) + else: + mt_to_compat_props[mt['name']][real_name] =3D prop_val + prop_set.add(real_name) + + req_props, req_abstr_props =3D get_req_props(defval_data, prop_set, + abstr_class_to_features) + + # join sets for global sorting by name + prop_set.update(abstr_prop_set) + mt_table =3D make_definition_table(mt_to_compat_props, prop_set, req_p= rops, + req_abstr_props, is_full) + # to save mt sequence + df =3D pd.DataFrame({'property_name': mt_table['property_name']}) + for mt in mts: + if not mt in mt_table: + print('Error: {0} no found'.format(mt)) + continue + df[mt] =3D mt_table[mt] + + return df + + +def main(): + parser =3D ArgumentParser(description=3D'''Print definition of machine + type (compatible features)''') + parser.add_argument('--MT_compat_props', type=3Dstr, required=3DTrue, + help=3D'''Path to JSON file with current machine t= ype + definition. It must be generated via + query-machines with is-full option.''') + parser.add_argument('--init_props', type=3Dstr, required=3DTrue, + help=3D'''Path to JSON file with initial features.= It + must be generated via + query-init-properties.''') + parser.add_argument('--format', type=3Dstr, + choices=3D['table', 'csv', 'html', 'json'], + default=3D'table', help=3D'Format of the output fi= le') + parser.add_argument('--file', type=3Dstr, + help=3D'''Path to output file. It must be set with= csv + and html formats.''') + parser.add_argument('--all', action=3D'store_true', + help=3D'''Print all available machine types (list = of + machine types will be ignored''') + parser.add_argument('--mt', nargs=3D"*", type=3Dstr, + help=3D'List of machine types that will be compare= d') + parser.add_argument('--full', action=3D'store_true', + help=3D'''Print all defined properties (by default, + only properties with different values are + printed)''') + + args =3D parser.parse_args() + + if args.all =3D=3D 0 and args.mt =3D=3D None: + print('Enter the list of required machine types (list of all '\ + 'machine types : qemu-system-x86_64 --machine help)') + return + + with open(args.MT_compat_props) as mt_json_file: + mt_data =3D json.load(mt_json_file) + + with open(args.init_props) as defval_json_file: + defval_data =3D json.load(defval_json_file) + + if args.all: + df =3D get_features(mt_data, defval_data, get_mt_sequence(mt_data), + args.full) + else: + df =3D get_features(mt_data, defval_data, args.mt, args.full) + + if args.format =3D=3D 'csv': + if args.file =3D=3D None: + print('Error: csv format requires path to output file') + return + df.to_csv(args.file) + elif args.format =3D=3D 'html': + if args.file =3D=3D None: + print('Error: html format requires path to output file') + return + with open(args.file, 'w') as output_html: + output_html.write(df.to_html(justify=3D'center', col_space=3D'= 400px', + index=3DFalse)) + elif args.format =3D=3D 'json': + json_table =3D df.to_json() + if args.file =3D=3D None: + print(json_table) + else: + with open(args.file, 'w') as output_json: + output_json.write(json_table) + elif args.format =3D=3D 'table': + table =3D tabulate(df, showindex=3DFalse, stralign=3D'center', + tablefmt=3D'fancy_grid', headers=3D'keys') + if args.file =3D=3D None: + print(table) + else: + with open(args.file, 'w') as output_table: + output_table.write(table) + + +if __name__ =3D=3D '__main__': + main() --=20 2.31.1