From nobody Thu May 2 16:31:05 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 149217599071494.78190013168546; Fri, 14 Apr 2017 06:19:50 -0700 (PDT) Received: from localhost ([::1]:53277 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cz18f-0000Jg-Fy for importer@patchew.org; Fri, 14 Apr 2017 09:19:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49138) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cz16h-0007Qe-3f for qemu-devel@nongnu.org; Fri, 14 Apr 2017 09:17:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cz16d-0008DK-Vn for qemu-devel@nongnu.org; Fri, 14 Apr 2017 09:17:47 -0400 Received: from mailout4.w1.samsung.com ([210.118.77.14]:11705) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cz16d-0008C9-PH for qemu-devel@nongnu.org; Fri, 14 Apr 2017 09:17:43 -0400 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout4.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0OOE00EGKI9FA200@mailout4.w1.samsung.com> for qemu-devel@nongnu.org; Fri, 14 Apr 2017 14:17:39 +0100 (BST) Received: from eusmges2.samsung.com (unknown [203.254.199.241]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20170414131739eucas1p241d0dd4100142d678b029f5d83585967~1RgnKpdFF2461024610eucas1p2V; Fri, 14 Apr 2017 13:17:39 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2.samsung.com (EUCPMTA) with SMTP id F4.07.04459.3FBC0F85; Fri, 14 Apr 2017 14:17:39 +0100 (BST) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20170414131738eucas1p28fe4896d7f42d8c5b23cb95312c41eca~1RgmgSko11945119451eucas1p28; Fri, 14 Apr 2017 13:17:38 +0000 (GMT) Received: from eusync2.samsung.com ( [203.254.199.212]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 46.FF.20206.90CC0F85; Fri, 14 Apr 2017 14:18:01 +0100 (BST) Received: from aperevalov-ubuntu.rnd.samsung.ru ([106.109.129.199]) by eusync2.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0OOE00KVHI9AY150@eusync2.samsung.com>; Fri, 14 Apr 2017 14:17:38 +0100 (BST) X-AuditID: cbfec7f1-f796e6d00000116b-92-58f0cbf36216 From: Alexey Perevalov To: dgilbert@redhat.com, qemu-devel@nongnu.org Date: Fri, 14 Apr 2017 16:17:15 +0300 Message-id: <1492175840-5021-2-git-send-email-a.perevalov@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1492175840-5021-1-git-send-email-a.perevalov@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrPIsWRmVeSWpSXmKPExsWy7djPc7qfT3+IMLi+mcti7t3zLBa92+6x W1xp/8lucbx3B4sDi8eTa5uZPN7vu8rm0bdlFWMAcxSXTUpqTmZZapG+XQJXxp01RxgL1rBX rH1n38D4nbWLkZNDQsBE4tXRt1C2mMSFe+vZuhi5OIQEljJKvPuzgwXC+cwoMbe5mwWmY8bi m1CJZYwSS77MYwNJCAl0M0mcuB3YxcjBwSZgILHvni1IWERAT+LKt05GEJtZwFii5edzdhBb WMBf4szcNiYQm0VAVeLL9ftgNbwCbhJL2k6wQeySkzh5bDLYdZwC7hKvfqwE2yshcIJNYs35 ZhaQXRICshKbDjBD1LtIHO+9DNUrLPHq+BZ2CFtG4vLkbqjedkaJ7p2drBDOBEaJM9P/QlXZ S5y6eZUJ4lI+iUnbpjNDLOCV6GgTgijxkJix5AM0uBwlLnXvZYT4fRajxOM5sRMYZRYwMqxi FEktLc5NTy020itOzC0uzUvXS87P3cQIjMbT/45/3MH4/oTVIUYBDkYlHt4Lxz9ECLEmlhVX 5h5ilOBgVhLhjT4FFOJNSaysSi3Kjy8qzUktPsQozcGiJM7LdepahJBAemJJanZqakFqEUyW iYNTqoHRxVHV2dmYnX3DkvW9r730OFLlr0Selwmysf0T9JP/WuGu+7uvNPjuEjj0hu1p7zmn gGlyF1Iu1MjMz2n5/+Nroc/t7xYzGw0eFWRptF2+JrVnHu+7m39mrFMP4XgUdUcxxeOw/8NP r49p2Mr3xTD+fyPW2vU1UFY996X7P8G9K1QKF2hN/7ZSiaU4I9FQi7moOBEABXluWMICAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrHLMWRmVeSWpSXmKPExsVy+t/xK7qcZz5EGEw9J2Qx9+55FovebffY La60/2S3ON67g8WBxePJtc1MHu/3XWXz6NuyijGAOcrNJiM1MSW1SCE1Lzk/JTMv3VYpNMRN 10JJIS8xN9VWKULXNyRISaEsMacUyDMyQAMOzgHuwUr6dgluGXfWHGEsWMNesfadfQPjd9Yu Rk4OCQETiRmLb7JA2GISF+6tZwOxhQSWMEqcXl7XxcgFZPcyScxYt5a5i5GDg03AQGLfPVuQ GhEBPYkr3zoZQWxmAWOJlp/P2UFsYQFficNXTjCB2CwCqhJfrt8Hq+EVcJNY0naCDWKXnMTJ Y5PBbuAUcJd49WMlC8ReN4mVp98zTWDkXcDIsIpRJLW0ODc9t9hIrzgxt7g0L10vOT93EyMw LLcd+7llB2PXu+BDjAIcjEo8vBVHP0QIsSaWFVfmHmKU4GBWEuGNPgUU4k1JrKxKLcqPLyrN SS0+xGgKdNREZinR5HxgzOSVxBuaGJpbGhoZW1iYGxkpifNO/XAlXEggPbEkNTs1tSC1CKaP iYNTqoFRR/enqufs248d+B9f/JDFxL7xjW94/dTjyn9XGTA3xMpsWiG2WVBP2yBg4o3gsqQn f8x3NKo0yD+K7NHsYlzXlLF76nqTBnOmPmnG0yeniV4uOsTlZLlyl/2h5UyObFzhKz+p1V9R KpQNWJNQJBEuZN6nUGDD3vmpek3f1vURpoki1nyR+5RYijMSDbWYi4oTAXuMxbxhAgAA X-MTR: 20000000000000000@CPGS X-CMS-MailID: 20170414131738eucas1p28fe4896d7f42d8c5b23cb95312c41eca X-Msg-Generator: CA X-Sender-IP: 182.198.249.180 X-Local-Sender: =?UTF-8?B?QWxleGV5IFBlcmV2YWxvdhtTUlItVmlydHVhbGl6YXRpb24g?= =?UTF-8?B?TGFiG+yCvOyEseyghOyekBtTZW5pb3IgRW5naW5lZXI=?= X-Global-Sender: =?UTF-8?B?QWxleGV5IFBlcmV2YWxvdhtTUlItVmlydHVhbGl6YXRpb24g?= =?UTF-8?B?TGFiG1NhbXN1bmcgRWxlY3Ryb25pY3MbU2VuaW9yIEVuZ2luZWVy?= X-Sender-Code: =?UTF-8?B?QzEwG0NJU0hRG0MxMEdEMDFHRDAxMDE1NA==?= CMS-TYPE: 201P X-HopCount: 7 X-CMS-RootMailID: 20170414131738eucas1p28fe4896d7f42d8c5b23cb95312c41eca X-RootMTR: 20170414131738eucas1p28fe4896d7f42d8c5b23cb95312c41eca References: <1492175840-5021-1-git-send-email-a.perevalov@samsung.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 210.118.77.14 Subject: [Qemu-devel] [PATCH 1/6] userfault: add pid into uffd_msg & update UFFD_FEATURE_* X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: i.maximets@samsung.com, a.perevalov@samsung.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This commit duplicates header of "userfaultfd: provide pid in userfault msg" into linux kernel. Signed-off-by: Alexey Perevalov --- linux-headers/linux/userfaultfd.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/linux-headers/linux/userfaultfd.h b/linux-headers/linux/userfa= ultfd.h index 2ed5dc3..760f02f 100644 --- a/linux-headers/linux/userfaultfd.h +++ b/linux-headers/linux/userfaultfd.h @@ -77,6 +77,9 @@ struct uffd_msg { struct { __u64 flags; __u64 address; + union { + __u32 ptid; + } feat; } pagefault; =20 struct { @@ -158,6 +161,8 @@ struct uffdio_api { #define UFFD_FEATURE_EVENT_MADVDONTNEED (1<<3) #define UFFD_FEATURE_MISSING_HUGETLBFS (1<<4) #define UFFD_FEATURE_MISSING_SHMEM (1<<5) +#define UFFD_FEATURE_EVENT_UNMAP (1<<6) +#define UFFD_FEATURE_THREAD_ID (1<<7) __u64 features; =20 __u64 ioctls; --=20 1.8.3.1 From nobody Thu May 2 16:31:05 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1492176078803428.96798405559593; Fri, 14 Apr 2017 06:21:18 -0700 (PDT) Received: from localhost ([::1]:53292 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cz1A5-0001V6-ER for importer@patchew.org; Fri, 14 Apr 2017 09:21:17 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49162) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cz16h-0007R1-LT for qemu-devel@nongnu.org; Fri, 14 Apr 2017 09:17:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cz16e-0008DZ-8V for qemu-devel@nongnu.org; Fri, 14 Apr 2017 09:17:47 -0400 Received: from mailout4.w1.samsung.com ([210.118.77.14]:11705) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cz16d-0008C9-Vk for qemu-devel@nongnu.org; Fri, 14 Apr 2017 09:17:44 -0400 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout4.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0OOE00BOTI9GRT00@mailout4.w1.samsung.com> for qemu-devel@nongnu.org; Fri, 14 Apr 2017 14:17:40 +0100 (BST) Received: from eusmges5.samsung.com (unknown [203.254.199.245]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20170414131740eucas1p1d4c8ccb2ee782d452cf590d74dd986f8~1Rgnw_7yc1011710117eucas1p1Q; Fri, 14 Apr 2017 13:17:40 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges5.samsung.com (EUCPMTA) with SMTP id 0A.D9.25577.3FBC0F85; Fri, 14 Apr 2017 14:17:39 +0100 (BST) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20170414131739eucas1p1ea9a6adcdbe8cfe45ac1ff582d28d873~1RgnExbIW1972019720eucas1p10; Fri, 14 Apr 2017 13:17:39 +0000 (GMT) Received: from eusync2.samsung.com ( [203.254.199.212]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 96.FF.20206.90CC0F85; Fri, 14 Apr 2017 14:18:01 +0100 (BST) Received: from aperevalov-ubuntu.rnd.samsung.ru ([106.109.129.199]) by eusync2.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0OOE00KVHI9AY150@eusync2.samsung.com>; Fri, 14 Apr 2017 14:17:39 +0100 (BST) X-AuditID: cbfec7f5-f792f6d0000063e9-22-58f0cbf3a03c From: Alexey Perevalov To: dgilbert@redhat.com, qemu-devel@nongnu.org Date: Fri, 14 Apr 2017 16:17:16 +0300 Message-id: <1492175840-5021-3-git-send-email-a.perevalov@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1492175840-5021-1-git-send-email-a.perevalov@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrEIsWRmVeSWpSXmKPExsWy7djPc7qfT3+IMPj91MBi7t3zLBa92+6x W1xp/8lucbx3B4sDi8eTa5uZPN7vu8rm0bdlFWMAcxSXTUpqTmZZapG+XQJXxp3fJ1kKPr9n rOh+dZK9gXHTQsYuRk4OCQETia8fnkLZYhIX7q1n62Lk4hASWMoo8ebBKmYI5zOjxJ7mKaww HQe6L0BVLWOUmP5kBjuE080kcezXJpYuRg4ONgEDiX33bEEaRAT0JK586wRbwSxgLNHy8zk7 iC0sYCTxae8zMJtFQFXi3qNWZhCbV8BN4teqdhaIZXISJ49NBlvMKeAu8erHShaQXRICZ9gk PnXsYAbZJSEgK7HpAJTpInH9fiJEq7DEq+Nb2CFsGYnLk7uhWtsZJbp3drJCOBMYJc5M/wtV ZS9x6uZVJohD+SQmbZsONZRXoqNNCKLEQ2LxgteMEGFHia13MiFen8Uo0XqqiWUCo8wCRoZV jCKppcW56anFpnrFibnFpXnpesn5uZsYgTF5+t/xrzsYlx6zOsQowMGoxMN74fiHCCHWxLLi ytxDjBIczEoivNGngEK8KYmVValF+fFFpTmpxYcYpTlYlMR5uU5dixASSE8sSc1OTS1ILYLJ MnFwSjUwrllTtc0/OtiWMckuMpjJ0E9hvTrjNlHb2c8Kbm1cv3Lbv61n/N30HCdKqjh0nJWe dGyFtPKi5QxvZp2Z9aHgtjK72Zlf896UCRYXbK3bPKtCWu74ctvTum8tfr+/vjwtfmbP3EMT Pe0Xv1XjVhc5MjudoXTJXdPI7MV/KzSbH+60aGJcNUmCVYmlOCPRUIu5qDgRABz1GBLFAgAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrELMWRmVeSWpSXmKPExsVy+t/xK7qcZz5EGKxdZ24x9+55FovebffY La60/2S3ON67g8WBxePJtc1MHu/3XWXz6NuyijGAOcrNJiM1MSW1SCE1Lzk/JTMv3VYpNMRN 10JJIS8xN9VWKULXNyRISaEsMacUyDMyQAMOzgHuwUr6dgluGXd+n2Qp+PyesaL71Un2BsZN Cxm7GDk5JARMJA50X2CDsMUkLtxbD2RzcQgJLGGUmL+rBcrpZZJY+f0eexcjBwebgIHEvnu2 IA0iAnoSV751gg1iFjCWaPn5nB3EFhYwkvi09xmYzSKgKnHvUSsziM0r4Cbxa1U7C8QyOYmT xyazgticAu4Sr36sBIsLAdWsPP2eaQIj7wJGhlWMIqmlxbnpucVGesWJucWleel6yfm5mxiB 4bnt2M8tOxi73gUfYhTgYFTi4a04+iFCiDWxrLgy9xCjBAezkghv9CmgEG9KYmVValF+fFFp TmrxIUZToKMmMkuJJucDYyevJN7QxNDc0tDI2MLC3MhISZx36ocr4UIC6YklqdmpqQWpRTB9 TBycUg2MkfYiU8q4D38+6rlBK3H+8uRHN9KTN6ot2H8/05lPInnSi/AphZwrQy+ZcAQZV6sV NittMcmOzLhk7juH9W7g7sldwuca1jKwRV804L51cv3ed+zcFx3PqNgsPD4tV33O+b5IN6GW SuXWdyFz7HXrE7r9ZdXS1604Mj0ssD74qtcuN6+5V0OUWIozEg21mIuKEwHXW1yeZQIAAA== X-MTR: 20000000000000000@CPGS X-CMS-MailID: 20170414131739eucas1p1ea9a6adcdbe8cfe45ac1ff582d28d873 X-Msg-Generator: CA X-Sender-IP: 182.198.249.180 X-Local-Sender: =?UTF-8?B?QWxleGV5IFBlcmV2YWxvdhtTUlItVmlydHVhbGl6YXRpb24g?= =?UTF-8?B?TGFiG+yCvOyEseyghOyekBtTZW5pb3IgRW5naW5lZXI=?= X-Global-Sender: =?UTF-8?B?QWxleGV5IFBlcmV2YWxvdhtTUlItVmlydHVhbGl6YXRpb24g?= =?UTF-8?B?TGFiG1NhbXN1bmcgRWxlY3Ryb25pY3MbU2VuaW9yIEVuZ2luZWVy?= X-Sender-Code: =?UTF-8?B?QzEwG0NJU0hRG0MxMEdEMDFHRDAxMDE1NA==?= CMS-TYPE: 201P X-HopCount: 7 X-CMS-RootMailID: 20170414131739eucas1p1ea9a6adcdbe8cfe45ac1ff582d28d873 X-RootMTR: 20170414131739eucas1p1ea9a6adcdbe8cfe45ac1ff582d28d873 References: <1492175840-5021-1-git-send-email-a.perevalov@samsung.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 210.118.77.14 Subject: [Qemu-devel] [PATCH 2/6] util: introduce glib-helper.c X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: i.maximets@samsung.com, a.perevalov@samsung.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" There is a lack of g_int_cmp which compares pointers value in glib, xen_disk.c introduced its own, so the same function now requires in migration.c. So logically to move it into common place. Futher: maybe extend glib. Also this commit moves existing glib-compat.h into util/glib folder for consolidation purpose. Signed-off-by: Alexey Perevalov --- hw/block/xen_disk.c | 10 +- include/glib-compat.h | 352 -----------------------------------------= ---- include/glib/glib-compat.h | 352 +++++++++++++++++++++++++++++++++++++++++= ++++ include/glib/glib-helper.h | 30 ++++ include/qemu/osdep.h | 2 +- linux-user/main.c | 2 +- scripts/clean-includes | 2 +- util/Makefile.objs | 1 + util/glib-helper.c | 29 ++++ 9 files changed, 417 insertions(+), 363 deletions(-) delete mode 100644 include/glib-compat.h create mode 100644 include/glib/glib-compat.h create mode 100644 include/glib/glib-helper.h create mode 100644 util/glib-helper.c diff --git a/hw/block/xen_disk.c b/hw/block/xen_disk.c index 456a2d5..36f6396 100644 --- a/hw/block/xen_disk.c +++ b/hw/block/xen_disk.c @@ -20,6 +20,7 @@ */ =20 #include "qemu/osdep.h" +#include "glib/glib-helper.h" #include #include =20 @@ -154,13 +155,6 @@ static void ioreq_reset(struct ioreq *ioreq) qemu_iovec_reset(&ioreq->v); } =20 -static gint int_cmp(gconstpointer a, gconstpointer b, gpointer user_data) -{ - uint ua =3D GPOINTER_TO_UINT(a); - uint ub =3D GPOINTER_TO_UINT(b); - return (ua > ub) - (ua < ub); -} - static void destroy_grant(gpointer pgnt) { PersistentGrant *grant =3D pgnt; @@ -1191,7 +1185,7 @@ static int blk_connect(struct XenDevice *xendev) if (blkdev->feature_persistent) { /* Init persistent grants */ blkdev->max_grants =3D max_requests * BLKIF_MAX_SEGMENTS_PER_REQUE= ST; - blkdev->persistent_gnts =3D g_tree_new_full((GCompareDataFunc)int_= cmp, + blkdev->persistent_gnts =3D g_tree_new_full((GCompareDataFunc)g_in= t_cmp, NULL, NULL, batch_maps ? (GDestroyNotify)g_free : diff --git a/include/glib-compat.h b/include/glib-compat.h deleted file mode 100644 index 863c8cf..0000000 --- a/include/glib-compat.h +++ /dev/null @@ -1,352 +0,0 @@ -/* - * GLIB Compatibility Functions - * - * Copyright IBM, Corp. 2013 - * - * Authors: - * Anthony Liguori - * Michael Tokarev - * Paolo Bonzini - * - * This work is licensed under the terms of the GNU GPL, version 2 or late= r. - * See the COPYING file in the top-level directory. - * - */ - -#ifndef QEMU_GLIB_COMPAT_H -#define QEMU_GLIB_COMPAT_H - -#include - -/* GLIB version compatibility flags */ -#if !GLIB_CHECK_VERSION(2, 26, 0) -#define G_TIME_SPAN_SECOND (G_GINT64_CONSTANT(1000000)) -#endif - -#if !GLIB_CHECK_VERSION(2, 28, 0) -static inline gint64 qemu_g_get_monotonic_time(void) -{ - /* g_get_monotonic_time() is best-effort so we can use the wall clock = as a - * fallback. - */ - - GTimeVal time; - g_get_current_time(&time); - - return time.tv_sec * G_TIME_SPAN_SECOND + time.tv_usec; -} -/* work around distro backports of this interface */ -#define g_get_monotonic_time() qemu_g_get_monotonic_time() -#endif - -#if defined(_WIN32) && !GLIB_CHECK_VERSION(2, 50, 0) -/* - * g_poll has a problem on Windows when using - * timeouts < 10ms, so use wrapper. - */ -#define g_poll(fds, nfds, timeout) g_poll_fixed(fds, nfds, timeout) -gint g_poll_fixed(GPollFD *fds, guint nfds, gint timeout); -#endif - -#if !GLIB_CHECK_VERSION(2, 30, 0) -/* Not a 100% compatible implementation, but good enough for most - * cases. Placeholders are only supported at the end of the - * template. */ -static inline gchar *qemu_g_dir_make_tmp(gchar const *tmpl, GError **error) -{ - gchar *path =3D g_build_filename(g_get_tmp_dir(), tmpl ?: ".XXXXXX", N= ULL); - - if (mkdtemp(path) !=3D NULL) { - return path; - } - /* Error occurred, clean up. */ - g_set_error(error, G_FILE_ERROR, g_file_error_from_errno(errno), - "mkdtemp() failed"); - g_free(path); - return NULL; -} -#define g_dir_make_tmp(tmpl, error) qemu_g_dir_make_tmp(tmpl, error) -#endif /* glib 2.30 */ - -#if !GLIB_CHECK_VERSION(2, 31, 0) -/* before glib-2.31, GMutex and GCond was dynamic-only (there was a separa= te - * GStaticMutex, but it didn't work with condition variables). - * - * Our implementation uses GOnce to fake a static implementation that does - * not require separate initialization. - * We need to rename the types to avoid passing our CompatGMutex/CompatGCo= nd - * by mistake to a function that expects GMutex/GCond. However, for ease - * of use we keep the GLib function names. GLib uses macros for the - * implementation, we use inline functions instead and undefine the macros. - */ - -typedef struct CompatGMutex { - GOnce once; -} CompatGMutex; - -typedef struct CompatGCond { - GOnce once; -} CompatGCond; - -static inline gpointer do_g_mutex_new(gpointer unused) -{ - return (gpointer) g_mutex_new(); -} - -static inline void g_mutex_init(CompatGMutex *mutex) -{ - mutex->once =3D (GOnce) G_ONCE_INIT; -} - -static inline void g_mutex_clear(CompatGMutex *mutex) -{ - g_assert(mutex->once.status !=3D G_ONCE_STATUS_PROGRESS); - if (mutex->once.retval) { - g_mutex_free((GMutex *) mutex->once.retval); - } - mutex->once =3D (GOnce) G_ONCE_INIT; -} - -static inline void (g_mutex_lock)(CompatGMutex *mutex) -{ - g_once(&mutex->once, do_g_mutex_new, NULL); - g_mutex_lock((GMutex *) mutex->once.retval); -} -#undef g_mutex_lock - -static inline gboolean (g_mutex_trylock)(CompatGMutex *mutex) -{ - g_once(&mutex->once, do_g_mutex_new, NULL); - return g_mutex_trylock((GMutex *) mutex->once.retval); -} -#undef g_mutex_trylock - - -static inline void (g_mutex_unlock)(CompatGMutex *mutex) -{ - g_mutex_unlock((GMutex *) mutex->once.retval); -} -#undef g_mutex_unlock - -static inline gpointer do_g_cond_new(gpointer unused) -{ - return (gpointer) g_cond_new(); -} - -static inline void g_cond_init(CompatGCond *cond) -{ - cond->once =3D (GOnce) G_ONCE_INIT; -} - -static inline void g_cond_clear(CompatGCond *cond) -{ - g_assert(cond->once.status !=3D G_ONCE_STATUS_PROGRESS); - if (cond->once.retval) { - g_cond_free((GCond *) cond->once.retval); - } - cond->once =3D (GOnce) G_ONCE_INIT; -} - -static inline void (g_cond_wait)(CompatGCond *cond, CompatGMutex *mutex) -{ - g_assert(mutex->once.status !=3D G_ONCE_STATUS_PROGRESS); - g_once(&cond->once, do_g_cond_new, NULL); - g_cond_wait((GCond *) cond->once.retval, (GMutex *) mutex->once.retval= ); -} -#undef g_cond_wait - -static inline void (g_cond_broadcast)(CompatGCond *cond) -{ - g_once(&cond->once, do_g_cond_new, NULL); - g_cond_broadcast((GCond *) cond->once.retval); -} -#undef g_cond_broadcast - -static inline void (g_cond_signal)(CompatGCond *cond) -{ - g_once(&cond->once, do_g_cond_new, NULL); - g_cond_signal((GCond *) cond->once.retval); -} -#undef g_cond_signal - -static inline gboolean (g_cond_timed_wait)(CompatGCond *cond, - CompatGMutex *mutex, - GTimeVal *time) -{ - g_assert(mutex->once.status !=3D G_ONCE_STATUS_PROGRESS); - g_once(&cond->once, do_g_cond_new, NULL); - return g_cond_timed_wait((GCond *) cond->once.retval, - (GMutex *) mutex->once.retval, time); -} -#undef g_cond_timed_wait - -/* This is not a macro, because it didn't exist until 2.32. */ -static inline gboolean g_cond_wait_until(CompatGCond *cond, CompatGMutex *= mutex, - gint64 end_time) -{ - GTimeVal time; - - /* Convert from monotonic to CLOCK_REALTIME. */ - end_time -=3D g_get_monotonic_time(); - g_get_current_time(&time); - end_time +=3D time.tv_sec * G_TIME_SPAN_SECOND + time.tv_usec; - - time.tv_sec =3D end_time / G_TIME_SPAN_SECOND; - time.tv_usec =3D end_time % G_TIME_SPAN_SECOND; - return g_cond_timed_wait(cond, mutex, &time); -} - -/* before 2.31 there was no g_thread_new() */ -static inline GThread *g_thread_new(const char *name, - GThreadFunc func, gpointer data) -{ - GThread *thread =3D g_thread_create(func, data, TRUE, NULL); - if (!thread) { - g_error("creating thread"); - } - return thread; -} -#else -#define CompatGMutex GMutex -#define CompatGCond GCond -#endif /* glib 2.31 */ - -#if !GLIB_CHECK_VERSION(2, 32, 0) -/* Beware, function returns gboolean since 2.39.2, see GLib commit 9101915= */ -static inline void g_hash_table_add(GHashTable *hash_table, gpointer key) -{ - g_hash_table_replace(hash_table, key, key); -} -#endif - -#ifndef g_assert_true -#define g_assert_true(expr) = \ - do { = \ - if (G_LIKELY(expr)) { = \ - } else { = \ - g_assertion_message(G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUN= C, \ - "'" #expr "' should be TRUE"); = \ - } = \ - } while (0) -#endif - -#ifndef g_assert_false -#define g_assert_false(expr) = \ - do { = \ - if (G_LIKELY(!(expr))) { = \ - } else { = \ - g_assertion_message(G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUN= C, \ - "'" #expr "' should be FALSE"); = \ - } = \ - } while (0) -#endif - -#ifndef g_assert_null -#define g_assert_null(expr) = \ - do { = \ - if (G_LIKELY((expr) =3D=3D NULL)) { = \ - } else { = \ - g_assertion_message(G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUN= C, \ - "'" #expr "' should be NULL"); = \ - } = \ - } while (0) -#endif - -#ifndef g_assert_nonnull -#define g_assert_nonnull(expr) = \ - do { = \ - if (G_LIKELY((expr) !=3D NULL)) { = \ - } else { = \ - g_assertion_message(G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUN= C, \ - "'" #expr "' should not be NULL"); = \ - } = \ - } while (0) -#endif - -#ifndef g_assert_cmpmem -#define g_assert_cmpmem(m1, l1, m2, l2) = \ - do { = \ - gconstpointer __m1 =3D m1, __m2 =3D m2; = \ - int __l1 =3D l1, __l2 =3D l2; = \ - if (__l1 !=3D __l2) { = \ - g_assertion_message_cmpnum( = \ - G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, = \ - #l1 " (len(" #m1 ")) =3D=3D " #l2 " (len(" #m2 "))", __l1,= "=3D=3D", \ - __l2, 'i'); = \ - } else if (memcmp(__m1, __m2, __l1) !=3D 0) { = \ - g_assertion_message(G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUN= C, \ - "assertion failed (" #m1 " =3D=3D " #m2 ")= "); \ - } = \ - } while (0) -#endif - -#if !GLIB_CHECK_VERSION(2, 28, 0) -static inline void g_list_free_full(GList *list, GDestroyNotify free_func) -{ - GList *l; - - for (l =3D list; l; l =3D l->next) { - free_func(l->data); - } - - g_list_free(list); -} - -static inline void g_slist_free_full(GSList *list, GDestroyNotify free_fun= c) -{ - GSList *l; - - for (l =3D list; l; l =3D l->next) { - free_func(l->data); - } - - g_slist_free(list); -} -#endif - -#if !GLIB_CHECK_VERSION(2, 26, 0) -static inline void g_source_set_name(GSource *source, const char *name) -{ - /* This is just a debugging aid, so leaving it a no-op */ -} -static inline void g_source_set_name_by_id(guint tag, const char *name) -{ - /* This is just a debugging aid, so leaving it a no-op */ -} -#endif - -#if !GLIB_CHECK_VERSION(2, 36, 0) -/* Always fail. This will not include error_report output in the test log, - * sending it instead to stderr. - */ -#define g_test_initialized() (0) -#endif -#if !GLIB_CHECK_VERSION(2, 38, 0) -#ifdef CONFIG_HAS_GLIB_SUBPROCESS_TESTS -#error schizophrenic detection of glib subprocess testing -#endif -#define g_test_subprocess() (0) -#endif - - -#if !GLIB_CHECK_VERSION(2, 34, 0) -static inline void -g_test_add_data_func_full(const char *path, - gpointer data, - gpointer fn, - gpointer data_free_func) -{ -#if GLIB_CHECK_VERSION(2, 26, 0) - /* back-compat casts, remove this once we can require new-enough glib = */ - g_test_add_vtable(path, 0, data, NULL, - (GTestFixtureFunc)fn, (GTestFixtureFunc) data_free_f= unc); -#else - /* back-compat casts, remove this once we can require new-enough glib = */ - g_test_add_vtable(path, 0, data, NULL, - (void (*)(void)) fn, (void (*)(void)) data_free_func= ); -#endif -} -#endif - - -#endif diff --git a/include/glib/glib-compat.h b/include/glib/glib-compat.h new file mode 100644 index 0000000..863c8cf --- /dev/null +++ b/include/glib/glib-compat.h @@ -0,0 +1,352 @@ +/* + * GLIB Compatibility Functions + * + * Copyright IBM, Corp. 2013 + * + * Authors: + * Anthony Liguori + * Michael Tokarev + * Paolo Bonzini + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + * + */ + +#ifndef QEMU_GLIB_COMPAT_H +#define QEMU_GLIB_COMPAT_H + +#include + +/* GLIB version compatibility flags */ +#if !GLIB_CHECK_VERSION(2, 26, 0) +#define G_TIME_SPAN_SECOND (G_GINT64_CONSTANT(1000000)) +#endif + +#if !GLIB_CHECK_VERSION(2, 28, 0) +static inline gint64 qemu_g_get_monotonic_time(void) +{ + /* g_get_monotonic_time() is best-effort so we can use the wall clock = as a + * fallback. + */ + + GTimeVal time; + g_get_current_time(&time); + + return time.tv_sec * G_TIME_SPAN_SECOND + time.tv_usec; +} +/* work around distro backports of this interface */ +#define g_get_monotonic_time() qemu_g_get_monotonic_time() +#endif + +#if defined(_WIN32) && !GLIB_CHECK_VERSION(2, 50, 0) +/* + * g_poll has a problem on Windows when using + * timeouts < 10ms, so use wrapper. + */ +#define g_poll(fds, nfds, timeout) g_poll_fixed(fds, nfds, timeout) +gint g_poll_fixed(GPollFD *fds, guint nfds, gint timeout); +#endif + +#if !GLIB_CHECK_VERSION(2, 30, 0) +/* Not a 100% compatible implementation, but good enough for most + * cases. Placeholders are only supported at the end of the + * template. */ +static inline gchar *qemu_g_dir_make_tmp(gchar const *tmpl, GError **error) +{ + gchar *path =3D g_build_filename(g_get_tmp_dir(), tmpl ?: ".XXXXXX", N= ULL); + + if (mkdtemp(path) !=3D NULL) { + return path; + } + /* Error occurred, clean up. */ + g_set_error(error, G_FILE_ERROR, g_file_error_from_errno(errno), + "mkdtemp() failed"); + g_free(path); + return NULL; +} +#define g_dir_make_tmp(tmpl, error) qemu_g_dir_make_tmp(tmpl, error) +#endif /* glib 2.30 */ + +#if !GLIB_CHECK_VERSION(2, 31, 0) +/* before glib-2.31, GMutex and GCond was dynamic-only (there was a separa= te + * GStaticMutex, but it didn't work with condition variables). + * + * Our implementation uses GOnce to fake a static implementation that does + * not require separate initialization. + * We need to rename the types to avoid passing our CompatGMutex/CompatGCo= nd + * by mistake to a function that expects GMutex/GCond. However, for ease + * of use we keep the GLib function names. GLib uses macros for the + * implementation, we use inline functions instead and undefine the macros. + */ + +typedef struct CompatGMutex { + GOnce once; +} CompatGMutex; + +typedef struct CompatGCond { + GOnce once; +} CompatGCond; + +static inline gpointer do_g_mutex_new(gpointer unused) +{ + return (gpointer) g_mutex_new(); +} + +static inline void g_mutex_init(CompatGMutex *mutex) +{ + mutex->once =3D (GOnce) G_ONCE_INIT; +} + +static inline void g_mutex_clear(CompatGMutex *mutex) +{ + g_assert(mutex->once.status !=3D G_ONCE_STATUS_PROGRESS); + if (mutex->once.retval) { + g_mutex_free((GMutex *) mutex->once.retval); + } + mutex->once =3D (GOnce) G_ONCE_INIT; +} + +static inline void (g_mutex_lock)(CompatGMutex *mutex) +{ + g_once(&mutex->once, do_g_mutex_new, NULL); + g_mutex_lock((GMutex *) mutex->once.retval); +} +#undef g_mutex_lock + +static inline gboolean (g_mutex_trylock)(CompatGMutex *mutex) +{ + g_once(&mutex->once, do_g_mutex_new, NULL); + return g_mutex_trylock((GMutex *) mutex->once.retval); +} +#undef g_mutex_trylock + + +static inline void (g_mutex_unlock)(CompatGMutex *mutex) +{ + g_mutex_unlock((GMutex *) mutex->once.retval); +} +#undef g_mutex_unlock + +static inline gpointer do_g_cond_new(gpointer unused) +{ + return (gpointer) g_cond_new(); +} + +static inline void g_cond_init(CompatGCond *cond) +{ + cond->once =3D (GOnce) G_ONCE_INIT; +} + +static inline void g_cond_clear(CompatGCond *cond) +{ + g_assert(cond->once.status !=3D G_ONCE_STATUS_PROGRESS); + if (cond->once.retval) { + g_cond_free((GCond *) cond->once.retval); + } + cond->once =3D (GOnce) G_ONCE_INIT; +} + +static inline void (g_cond_wait)(CompatGCond *cond, CompatGMutex *mutex) +{ + g_assert(mutex->once.status !=3D G_ONCE_STATUS_PROGRESS); + g_once(&cond->once, do_g_cond_new, NULL); + g_cond_wait((GCond *) cond->once.retval, (GMutex *) mutex->once.retval= ); +} +#undef g_cond_wait + +static inline void (g_cond_broadcast)(CompatGCond *cond) +{ + g_once(&cond->once, do_g_cond_new, NULL); + g_cond_broadcast((GCond *) cond->once.retval); +} +#undef g_cond_broadcast + +static inline void (g_cond_signal)(CompatGCond *cond) +{ + g_once(&cond->once, do_g_cond_new, NULL); + g_cond_signal((GCond *) cond->once.retval); +} +#undef g_cond_signal + +static inline gboolean (g_cond_timed_wait)(CompatGCond *cond, + CompatGMutex *mutex, + GTimeVal *time) +{ + g_assert(mutex->once.status !=3D G_ONCE_STATUS_PROGRESS); + g_once(&cond->once, do_g_cond_new, NULL); + return g_cond_timed_wait((GCond *) cond->once.retval, + (GMutex *) mutex->once.retval, time); +} +#undef g_cond_timed_wait + +/* This is not a macro, because it didn't exist until 2.32. */ +static inline gboolean g_cond_wait_until(CompatGCond *cond, CompatGMutex *= mutex, + gint64 end_time) +{ + GTimeVal time; + + /* Convert from monotonic to CLOCK_REALTIME. */ + end_time -=3D g_get_monotonic_time(); + g_get_current_time(&time); + end_time +=3D time.tv_sec * G_TIME_SPAN_SECOND + time.tv_usec; + + time.tv_sec =3D end_time / G_TIME_SPAN_SECOND; + time.tv_usec =3D end_time % G_TIME_SPAN_SECOND; + return g_cond_timed_wait(cond, mutex, &time); +} + +/* before 2.31 there was no g_thread_new() */ +static inline GThread *g_thread_new(const char *name, + GThreadFunc func, gpointer data) +{ + GThread *thread =3D g_thread_create(func, data, TRUE, NULL); + if (!thread) { + g_error("creating thread"); + } + return thread; +} +#else +#define CompatGMutex GMutex +#define CompatGCond GCond +#endif /* glib 2.31 */ + +#if !GLIB_CHECK_VERSION(2, 32, 0) +/* Beware, function returns gboolean since 2.39.2, see GLib commit 9101915= */ +static inline void g_hash_table_add(GHashTable *hash_table, gpointer key) +{ + g_hash_table_replace(hash_table, key, key); +} +#endif + +#ifndef g_assert_true +#define g_assert_true(expr) = \ + do { = \ + if (G_LIKELY(expr)) { = \ + } else { = \ + g_assertion_message(G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUN= C, \ + "'" #expr "' should be TRUE"); = \ + } = \ + } while (0) +#endif + +#ifndef g_assert_false +#define g_assert_false(expr) = \ + do { = \ + if (G_LIKELY(!(expr))) { = \ + } else { = \ + g_assertion_message(G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUN= C, \ + "'" #expr "' should be FALSE"); = \ + } = \ + } while (0) +#endif + +#ifndef g_assert_null +#define g_assert_null(expr) = \ + do { = \ + if (G_LIKELY((expr) =3D=3D NULL)) { = \ + } else { = \ + g_assertion_message(G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUN= C, \ + "'" #expr "' should be NULL"); = \ + } = \ + } while (0) +#endif + +#ifndef g_assert_nonnull +#define g_assert_nonnull(expr) = \ + do { = \ + if (G_LIKELY((expr) !=3D NULL)) { = \ + } else { = \ + g_assertion_message(G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUN= C, \ + "'" #expr "' should not be NULL"); = \ + } = \ + } while (0) +#endif + +#ifndef g_assert_cmpmem +#define g_assert_cmpmem(m1, l1, m2, l2) = \ + do { = \ + gconstpointer __m1 =3D m1, __m2 =3D m2; = \ + int __l1 =3D l1, __l2 =3D l2; = \ + if (__l1 !=3D __l2) { = \ + g_assertion_message_cmpnum( = \ + G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, = \ + #l1 " (len(" #m1 ")) =3D=3D " #l2 " (len(" #m2 "))", __l1,= "=3D=3D", \ + __l2, 'i'); = \ + } else if (memcmp(__m1, __m2, __l1) !=3D 0) { = \ + g_assertion_message(G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUN= C, \ + "assertion failed (" #m1 " =3D=3D " #m2 ")= "); \ + } = \ + } while (0) +#endif + +#if !GLIB_CHECK_VERSION(2, 28, 0) +static inline void g_list_free_full(GList *list, GDestroyNotify free_func) +{ + GList *l; + + for (l =3D list; l; l =3D l->next) { + free_func(l->data); + } + + g_list_free(list); +} + +static inline void g_slist_free_full(GSList *list, GDestroyNotify free_fun= c) +{ + GSList *l; + + for (l =3D list; l; l =3D l->next) { + free_func(l->data); + } + + g_slist_free(list); +} +#endif + +#if !GLIB_CHECK_VERSION(2, 26, 0) +static inline void g_source_set_name(GSource *source, const char *name) +{ + /* This is just a debugging aid, so leaving it a no-op */ +} +static inline void g_source_set_name_by_id(guint tag, const char *name) +{ + /* This is just a debugging aid, so leaving it a no-op */ +} +#endif + +#if !GLIB_CHECK_VERSION(2, 36, 0) +/* Always fail. This will not include error_report output in the test log, + * sending it instead to stderr. + */ +#define g_test_initialized() (0) +#endif +#if !GLIB_CHECK_VERSION(2, 38, 0) +#ifdef CONFIG_HAS_GLIB_SUBPROCESS_TESTS +#error schizophrenic detection of glib subprocess testing +#endif +#define g_test_subprocess() (0) +#endif + + +#if !GLIB_CHECK_VERSION(2, 34, 0) +static inline void +g_test_add_data_func_full(const char *path, + gpointer data, + gpointer fn, + gpointer data_free_func) +{ +#if GLIB_CHECK_VERSION(2, 26, 0) + /* back-compat casts, remove this once we can require new-enough glib = */ + g_test_add_vtable(path, 0, data, NULL, + (GTestFixtureFunc)fn, (GTestFixtureFunc) data_free_f= unc); +#else + /* back-compat casts, remove this once we can require new-enough glib = */ + g_test_add_vtable(path, 0, data, NULL, + (void (*)(void)) fn, (void (*)(void)) data_free_func= ); +#endif +} +#endif + + +#endif diff --git a/include/glib/glib-helper.h b/include/glib/glib-helper.h new file mode 100644 index 0000000..db740fb --- /dev/null +++ b/include/glib/glib-helper.h @@ -0,0 +1,30 @@ +/* + * Helpers for GLIB + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + * + */ + +#ifndef QEMU_GLIB_HELPER_H +#define QEMU_GLIB_HELPER_H + + +#include "glib/glib-compat.h" + +#define GPOINTER_TO_UINT64(a) ((guint64) (a)) + +/* + * return 1 in case of a > b, -1 otherwise and 0 if equeal + */ +gint g_int_cmp64(gconstpointer a, gconstpointer b, + gpointer __attribute__((unused)) user_data); + +/* + * return 1 in case of a > b, -1 otherwise and 0 if equeal + */ +int g_int_cmp(gconstpointer a, gconstpointer b, + gpointer __attribute__((unused)) user_data); + +#endif /* QEMU_GLIB_HELPER_H */ + diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h index 122ff06..36f8a89 100644 --- a/include/qemu/osdep.h +++ b/include/qemu/osdep.h @@ -104,7 +104,7 @@ extern int daemon(int, int); #include "sysemu/os-posix.h" #endif =20 -#include "glib-compat.h" +#include "glib/glib-compat.h" #include "qemu/typedefs.h" =20 #ifndef O_LARGEFILE diff --git a/linux-user/main.c b/linux-user/main.c index 10a3bb3..7cea6bc 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -35,7 +35,7 @@ #include "elf.h" #include "exec/log.h" #include "trace/control.h" -#include "glib-compat.h" +#include "glib/glib-compat.h" =20 char *exec_path; =20 diff --git a/scripts/clean-includes b/scripts/clean-includes index dd938da..b32b928 100755 --- a/scripts/clean-includes +++ b/scripts/clean-includes @@ -123,7 +123,7 @@ for f in "$@"; do ;; *include/qemu/osdep.h | \ *include/qemu/compiler.h | \ - *include/glib-compat.h | \ + *include/glib/glib-compat.h | \ *include/sysemu/os-posix.h | \ *include/sysemu/os-win32.h | \ *include/standard-headers/ ) diff --git a/util/Makefile.objs b/util/Makefile.objs index c6205eb..0080712 100644 --- a/util/Makefile.objs +++ b/util/Makefile.objs @@ -43,3 +43,4 @@ util-obj-y +=3D qdist.o util-obj-y +=3D qht.o util-obj-y +=3D range.o util-obj-y +=3D systemd.o +util-obj-y +=3D glib-helper.o diff --git a/util/glib-helper.c b/util/glib-helper.c new file mode 100644 index 0000000..2557009 --- /dev/null +++ b/util/glib-helper.c @@ -0,0 +1,29 @@ +/* + * Implementation for GLIB helpers + * this file is intented to commulate and later reuse + * additional glib functions + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + + */ + +#include "glib/glib-helper.h" + +gint g_int_cmp64(gconstpointer a, gconstpointer b, + gpointer __attribute__((unused)) user_data) +{ + guint64 ua =3D GPOINTER_TO_UINT64(a); + guint64 ub =3D GPOINTER_TO_UINT64(b); + return (ua > ub) - (ua < ub); +} + +/* + * return 1 in case of a > b, -1 otherwise and 0 if equeal + */ +gint g_int_cmp(gconstpointer a, gconstpointer b, + gpointer __attribute__((unused)) user_data) +{ + return g_int_cmp64(a, b, user_data); +} + --=20 1.8.3.1 From nobody Thu May 2 16:31:05 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1492175972393951.0751099816094; Fri, 14 Apr 2017 06:19:32 -0700 (PDT) Received: from localhost ([::1]:53276 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cz18N-00005F-09 for importer@patchew.org; Fri, 14 Apr 2017 09:19:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49178) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cz16i-0007Rl-Kq for qemu-devel@nongnu.org; Fri, 14 Apr 2017 09:17:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cz16f-0008E5-FP for qemu-devel@nongnu.org; Fri, 14 Apr 2017 09:17:48 -0400 Received: from mailout2.w1.samsung.com ([210.118.77.12]:61604) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cz16f-0008DI-6i for qemu-devel@nongnu.org; Fri, 14 Apr 2017 09:17:45 -0400 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0OOE00IN2I9GX100@mailout2.w1.samsung.com> for qemu-devel@nongnu.org; Fri, 14 Apr 2017 14:17:40 +0100 (BST) Received: from eusmges2.samsung.com (unknown [203.254.199.241]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20170414131740eucas1p2c9af5901dc94d65cf80a9d02271f4762~1Rgn_WrlF1643616436eucas1p2l; Fri, 14 Apr 2017 13:17:40 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges2.samsung.com (EUCPMTA) with SMTP id 45.07.04459.3FBC0F85; Fri, 14 Apr 2017 14:17:40 +0100 (BST) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20170414131739eucas1p27a3eed795ae545efff380d7c5f8358c3~1RgnVkGNd2461824618eucas1p2H; Fri, 14 Apr 2017 13:17:39 +0000 (GMT) Received: from eusync2.samsung.com ( [203.254.199.212]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id D9.2D.17452.17CC0F85; Fri, 14 Apr 2017 14:19:45 +0100 (BST) Received: from aperevalov-ubuntu.rnd.samsung.ru ([106.109.129.199]) by eusync2.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0OOE00KVHI9AY150@eusync2.samsung.com>; Fri, 14 Apr 2017 14:17:39 +0100 (BST) X-AuditID: cbfec7f1-f796e6d00000116b-94-58f0cbf3e1b9 From: Alexey Perevalov To: dgilbert@redhat.com, qemu-devel@nongnu.org Date: Fri, 14 Apr 2017 16:17:17 +0300 Message-id: <1492175840-5021-4-git-send-email-a.perevalov@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1492175840-5021-1-git-send-email-a.perevalov@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrHIsWRmVeSWpSXmKPExsWy7djP87pfTn+IMDg4m8li7t3zLBa92+6x W1xp/8lucbx3B4sDi8eTa5uZPN7vu8rm0bdlFWMAcxSXTUpqTmZZapG+XQJXxqO/sQXz5Cu+ LnvA2MB4RqKLkZNDQsBE4tThd6wQtpjEhXvr2boYuTiEBJYySrQtOw3lfGaU2NjziRGm48qx p+wQiWWMEh+2TmGCcLqZJI792sTSxcjBwSZgILHvni1Ig4iAnsSVb51gzcwCxhItP5+zg9jC Al4S0/+eYAMpZxFQlbjwORXE5BVwk/i9IBBilZzEyWOTwY7jFHCXePVjJQvIJgmBE2wSz1ZB tEoIyEpsOsAMYbpILGgOhmgVlnh1fAs7hC0j0dlxkAmitZ1RontnJyuEM4FR4sz0v1BV9hKn bl5lgjiTT2LStulQQ3klOtqEIEo8JF6cPA5V7iix++wyFojPZzFKbFn6mHkCo8wCRoZVjCKp pcW56anFRnrFibnFpXnpesn5uZsYgbF4+t/xjzsY35+wOsQowMGoxMN74fiHCCHWxLLiytxD jBIczEoivNGngEK8KYmVValF+fFFpTmpxYcYpTlYlMR5uU5dixASSE8sSc1OTS1ILYLJMnFw SjUwcnmq2+89eePiQR3LbYKc5bEXn89cee9eMtNlqb/v1sw5+YHniGzu3uLutl1Wk1MD5ttN t6/X+8fleZBHWLbhXby1yrf3U7yOSpbmr+uc9VbsRVtzi0pgqHvkU7YpDw2PqRn7Kizv/blT Wv/z+6c8OWfTFF2C3RUlL8e8nhnEKln9h/3fH6dCJZbijERDLeai4kQATP5ZW8ECAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrLLMWRmVeSWpSXmKPExsVy+t/xK7qFZz5EGNxfxG4x9+55FovebffY La60/2S3ON67g8WBxePJtc1MHu/3XWXz6NuyijGAOcrNJiM1MSW1SCE1Lzk/JTMv3VYpNMRN 10JJIS8xN9VWKULXNyRISaEsMacUyDMyQAMOzgHuwUr6dgluGY/+xhbMk6/4uuwBYwPjGYku Rk4OCQETiSvHnrJD2GISF+6tZ+ti5OIQEljCKDHzykYop5dJYuX3e0BVHBxsAgYS++7ZgjSI COhJXPnWyQhiMwsYS7T8fA42SFjAS2L63xNsIOUsAqoSFz6ngpi8Am4SvxcEQqySkzh5bDIr iM0p4C7x6sdKFhBbCKhk5en3TBMYeRcwMqxiFEktLc5Nzy021CtOzC0uzUvXS87P3cQIDMpt x35u3sF4aWPwIUYBDkYlHt6Kox8ihFgTy4orcw8xSnAwK4nwRp8CCvGmJFZWpRblxxeV5qQW H2I0BTppIrOUaHI+MGLySuINTQzNLQ2NjC0szI2MlMR5Sz5cCRcSSE8sSc1OTS1ILYLpY+Lg lGpgnCfyhSN1tt81OY9crxfJ8zxe31giNU/4iYzYxWopQbYrGSqLL9b89OFfahpc2aGwrlxW 9VX2/fkF3gtfBYUEf4486XG7iGFG+6z7r51fWMdobnrw6crtJU+OHnrVKqBzzbtIrKv8Y5BE 4uKbnLNED/Mt0UksfhQUOCH2nvzuKzYn1n+5vfKJuxJLcUaioRZzUXEiAJ+Jh9JgAgAA X-MTR: 20000000000000000@CPGS X-CMS-MailID: 20170414131739eucas1p27a3eed795ae545efff380d7c5f8358c3 X-Msg-Generator: CA X-Sender-IP: 182.198.249.179 X-Local-Sender: =?UTF-8?B?QWxleGV5IFBlcmV2YWxvdhtTUlItVmlydHVhbGl6YXRpb24g?= =?UTF-8?B?TGFiG+yCvOyEseyghOyekBtTZW5pb3IgRW5naW5lZXI=?= X-Global-Sender: =?UTF-8?B?QWxleGV5IFBlcmV2YWxvdhtTUlItVmlydHVhbGl6YXRpb24g?= =?UTF-8?B?TGFiG1NhbXN1bmcgRWxlY3Ryb25pY3MbU2VuaW9yIEVuZ2luZWVy?= X-Sender-Code: =?UTF-8?B?QzEwG0NJU0hRG0MxMEdEMDFHRDAxMDE1NA==?= CMS-TYPE: 201P X-HopCount: 7 X-CMS-RootMailID: 20170414131739eucas1p27a3eed795ae545efff380d7c5f8358c3 X-RootMTR: 20170414131739eucas1p27a3eed795ae545efff380d7c5f8358c3 References: <1492175840-5021-1-git-send-email-a.perevalov@samsung.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 210.118.77.12 Subject: [Qemu-devel] [PATCH 3/6] migration: add UFFD_FEATURE_THREAD_ID feature support X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: i.maximets@samsung.com, a.perevalov@samsung.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Userfaultfd mechanism is able to provide process thread id, in case when client request it with UFDD_API ioctl. Signed-off-by: Alexey Perevalov --- include/migration/postcopy-ram.h | 2 +- migration/migration.c | 2 +- migration/postcopy-ram.c | 12 ++++++------ migration/savevm.c | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/include/migration/postcopy-ram.h b/include/migration/postcopy-= ram.h index 8e036b9..809f6db 100644 --- a/include/migration/postcopy-ram.h +++ b/include/migration/postcopy-ram.h @@ -14,7 +14,7 @@ #define QEMU_POSTCOPY_RAM_H =20 /* Return true if the host supports everything we need to do postcopy-ram = */ -bool postcopy_ram_supported_by_host(void); +bool postcopy_ram_supported_by_host(MigrationIncomingState *mis); =20 /* * Make all of RAM sensitive to accesses to areas that haven't yet been wr= itten diff --git a/migration/migration.c b/migration/migration.c index ad4036f..79f6425 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -802,7 +802,7 @@ void qmp_migrate_set_capabilities(MigrationCapabilitySt= atusList *params, * special support. */ if (!old_postcopy_cap && runstate_check(RUN_STATE_INMIGRATE) && - !postcopy_ram_supported_by_host()) { + !postcopy_ram_supported_by_host(NULL)) { /* postcopy_ram_supported_by_host will have emitted a more * detailed message */ diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c index dc80dbb..70f0480 100644 --- a/migration/postcopy-ram.c +++ b/migration/postcopy-ram.c @@ -60,13 +60,13 @@ struct PostcopyDiscardState { #include #include =20 -static bool ufd_version_check(int ufd) +static bool ufd_version_check(int ufd, MigrationIncomingState *mis) { struct uffdio_api api_struct; uint64_t ioctl_mask; =20 api_struct.api =3D UFFD_API; - api_struct.features =3D 0; + api_struct.features =3D UFFD_FEATURE_THREAD_ID; if (ioctl(ufd, UFFDIO_API, &api_struct)) { error_report("postcopy_ram_supported_by_host: UFFDIO_API failed: %= s", strerror(errno)); @@ -113,7 +113,7 @@ static int test_range_shared(const char *block_name, vo= id *host_addr, * normally fine since if the postcopy succeeds it gets turned back on at = the * end. */ -bool postcopy_ram_supported_by_host(void) +bool postcopy_ram_supported_by_host(MigrationIncomingState *mis) { long pagesize =3D getpagesize(); int ufd =3D -1; @@ -136,7 +136,7 @@ bool postcopy_ram_supported_by_host(void) } =20 /* Version and features check */ - if (!ufd_version_check(ufd)) { + if (!ufd_version_check(ufd, mis)) { goto out; } =20 @@ -515,7 +515,7 @@ int postcopy_ram_enable_notify(MigrationIncomingState *= mis) * Although the host check already tested the API, we need to * do the check again as an ABI handshake on the new fd. */ - if (!ufd_version_check(mis->userfault_fd)) { + if (!ufd_version_check(mis->userfault_fd, mis)) { return -1; } =20 @@ -653,7 +653,7 @@ void *postcopy_get_tmp_page(MigrationIncomingState *mis) =20 #else /* No target OS support, stubs just fail */ -bool postcopy_ram_supported_by_host(void) +bool postcopy_ram_supported_by_host(MigrationIncomingState *mis) { error_report("%s: No OS support", __func__); return false; diff --git a/migration/savevm.c b/migration/savevm.c index 3b19a4a..f01e418 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -1360,7 +1360,7 @@ static int loadvm_postcopy_handle_advise(MigrationInc= omingState *mis) return -1; } =20 - if (!postcopy_ram_supported_by_host()) { + if (!postcopy_ram_supported_by_host(mis)) { postcopy_state_set(POSTCOPY_INCOMING_NONE); return -1; } --=20 1.8.3.1 From nobody Thu May 2 16:31:05 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1492176080719591.3312420937717; Fri, 14 Apr 2017 06:21:20 -0700 (PDT) Received: from localhost ([::1]:53293 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cz1A7-0001WZ-EX for importer@patchew.org; Fri, 14 Apr 2017 09:21:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49182) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cz16i-0007Rz-UV for qemu-devel@nongnu.org; Fri, 14 Apr 2017 09:17:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cz16f-0008EM-LM for qemu-devel@nongnu.org; Fri, 14 Apr 2017 09:17:48 -0400 Received: from mailout1.w1.samsung.com ([210.118.77.11]:24106) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cz16f-0008DO-AH for qemu-devel@nongnu.org; Fri, 14 Apr 2017 09:17:45 -0400 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0OOE00FYQI9HA800@mailout1.w1.samsung.com> for qemu-devel@nongnu.org; Fri, 14 Apr 2017 14:17:41 +0100 (BST) Received: from eusmges1.samsung.com (unknown [203.254.199.239]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20170414131741eucas1p2135df2d85b1c87ad0d35e426f64916ce~1Rgo1KGx92464124641eucas1p2D; Fri, 14 Apr 2017 13:17:41 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1.samsung.com (EUCPMTA) with SMTP id EC.E6.14140.7FBC0F85; Fri, 14 Apr 2017 14:17:43 +0100 (BST) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20170414131740eucas1p27eba648b990a93a627265c740e7ff118~1Rgn0o4xi1945719457eucas1p2t; Fri, 14 Apr 2017 13:17:40 +0000 (GMT) Received: from eusync2.samsung.com ( [203.254.199.212]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 2A.2D.17452.17CC0F85; Fri, 14 Apr 2017 14:19:45 +0100 (BST) Received: from aperevalov-ubuntu.rnd.samsung.ru ([106.109.129.199]) by eusync2.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0OOE00KVHI9AY150@eusync2.samsung.com>; Fri, 14 Apr 2017 14:17:40 +0100 (BST) X-AuditID: cbfec7ef-f796a6d00000373c-9e-58f0cbf72bd0 From: Alexey Perevalov To: dgilbert@redhat.com, qemu-devel@nongnu.org Date: Fri, 14 Apr 2017 16:17:18 +0300 Message-id: <1492175840-5021-5-git-send-email-a.perevalov@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1492175840-5021-1-git-send-email-a.perevalov@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrHIsWRmVeSWpSXmKPExsWy7djPc7rfT3+IMFjQqWMx9+55FovebffY La60/2S3ON67g8WBxePJtc1MHu/3XWXz6NuyijGAOYrLJiU1J7MstUjfLoEr4/8G6YKjExgr ji08yNjA2JjbxcjBISFgInF3j2YXIyeQKSZx4d56ti5GLg4hgWWMEl9mrYJyPjNKPN63gRmi ykRiVscGFhAbrKrncwZEUTeTxNTLL9hBprIJGEjsu2cLUiMioCdx5VsnI4jNLGAs0fLzOTuI LSxgJ9G5ZTUjSDmLgKrE7osZIGFeATeJrasnMUGskpM4eWwyK4jNKeAu8erHShaQVRICZ9gk Vt4/ygbxgKzEpgPMEKaLxJrJohCtwhKvjm9hh7BlJDo7DjJBtLYzSnTv7GSFcCYwSpyZ/heq yl7i1M2rTBB38klM2jYdaiivREebEESJh8SnnTtZIWxHidPfN7BCvD6LUaLv6mWWCYwyCxgZ VjGKpJYW56anFhvqFSfmFpfmpesl5+duYgTG4ul/x9/vYHzaHHKIUYCDUYmH98LxDxFCrIll xZW5hxglOJiVRHijTwGFeFMSK6tSi/Lji0pzUosPMUpzsCiJ8/KeuhYhJJCeWJKanZpakFoE k2Xi4JRqYDTs+V+dONN9wWvRHWJzBUNbuR0jp5dyue57MHnv5WpHyUnmn2VWC1oc76pN9LGz WFtZzSAUfuGYxcfm/RwWOskHsnRtnk4v/nNgxXP307eUDX8WfPNNbG6PPsA+PefNtTmPTwg8 1IzItWo2vjo38qvQj6O/Xm/atNCUO3avvOv94vdif2ZUJimxFGckGmoxFxUnAgAUHq5lwQIA AA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrPLMWRmVeSWpSXmKPExsVy+t/xK7qFZz5EGKxqVbeYe/c8i0Xvtnvs Flfaf7JbHO/dweLA4vHk2mYmj/f7rrJ59G1ZxRjAHOVmk5GamJJapJCal5yfkpmXbqsUGuKm a6GkkJeYm2qrFKHrGxKkpFCWmFMK5BkZoAEH5wD3YCV9uwS3jP8bpAuOTmCsOLbwIGMDY2Nu FyMnh4SAicSsjg0sELaYxIV769m6GLk4hASWMEq0TbwO5fQySRzYtJapi5GDg03AQGLfPVuQ BhEBPYkr3zoZQWxmAWOJlp/P2UFsYQE7ic4tqxlBylkEVCV2X8wACfMKuElsXT2JCWKXnMTJ Y5NZQWxOAXeJVz9Wgt0gBFSz8vR7pgmMvAsYGVYxiqSWFuem5xYb6hUn5haX5qXrJefnbmIE Bua2Yz8372C8tDH4EKMAB6MSD2/F0Q8RQqyJZcWVuYcYJTiYlUR4o08BhXhTEiurUovy44tK c1KLDzGaAt00kVlKNDkfGDV5JfGGJobmloZGxhYW5kZGSuK8JR+uhAsJpCeWpGanphakFsH0 MXFwSjUw6jfW5zavsfrRd03hhvbs2aJzr2keztvqo9VpdESlIrhm3pTb2r/F2mNbpum3eH2p 0O1QX177qM7lokvcdUGBvct2SF7hvLPKMXzTJ7mcd3PXTmbtV/mydn6ome/M8B2GGyZe9dl+ 7Lm10ZTQaHOj9S0VBvrvq2ZveRO9zih0i/6X9PWxy8IilViKMxINtZiLihMBpnPyr2ICAAA= X-MTR: 20000000000000000@CPGS X-CMS-MailID: 20170414131740eucas1p27eba648b990a93a627265c740e7ff118 X-Msg-Generator: CA X-Sender-IP: 182.198.249.179 X-Local-Sender: =?UTF-8?B?QWxleGV5IFBlcmV2YWxvdhtTUlItVmlydHVhbGl6YXRpb24g?= =?UTF-8?B?TGFiG+yCvOyEseyghOyekBtTZW5pb3IgRW5naW5lZXI=?= X-Global-Sender: =?UTF-8?B?QWxleGV5IFBlcmV2YWxvdhtTUlItVmlydHVhbGl6YXRpb24g?= =?UTF-8?B?TGFiG1NhbXN1bmcgRWxlY3Ryb25pY3MbU2VuaW9yIEVuZ2luZWVy?= X-Sender-Code: =?UTF-8?B?QzEwG0NJU0hRG0MxMEdEMDFHRDAxMDE1NA==?= CMS-TYPE: 201P X-HopCount: 7 X-CMS-RootMailID: 20170414131740eucas1p27eba648b990a93a627265c740e7ff118 X-RootMTR: 20170414131740eucas1p27eba648b990a93a627265c740e7ff118 References: <1492175840-5021-1-git-send-email-a.perevalov@samsung.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 210.118.77.11 Subject: [Qemu-devel] [PATCH 4/6] migration: calculate downtime on dst side X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: i.maximets@samsung.com, a.perevalov@samsung.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This patch provides downtime calculation per vCPU, as a summary and as a overlapped value for all vCPUs. This approach just keeps tree with page fault addr as a key, and t1-t2 interval of pagefault time and page copy time, with affected vCPU bit mask. For more implementation details please see comment to get_postcopy_total_downtime function. Signed-off-by: Alexey Perevalov --- include/migration/migration.h | 14 +++ migration/migration.c | 280 ++++++++++++++++++++++++++++++++++++++= +++- migration/postcopy-ram.c | 24 +++- migration/qemu-file.c | 1 - migration/trace-events | 9 +- 5 files changed, 323 insertions(+), 5 deletions(-) diff --git a/include/migration/migration.h b/include/migration/migration.h index 5720c88..5d2c628 100644 --- a/include/migration/migration.h +++ b/include/migration/migration.h @@ -123,10 +123,24 @@ struct MigrationIncomingState { =20 /* See savevm.c */ LoadStateEntry_Head loadvm_handlers; + + /* + * Tree for keeping postcopy downtime, + * necessary to calculate correct downtime, during multiple + * vm suspends, it keeps host page address as a key and + * DowntimeDuration as a data + * NULL means kernel couldn't provide process thread id, + * and QEMU couldn't identify which vCPU raise page fault + */ + GTree *postcopy_downtime; }; =20 MigrationIncomingState *migration_incoming_get_current(void); void migration_incoming_state_destroy(void); +void mark_postcopy_downtime_begin(uint64_t addr, int cpu); +void mark_postcopy_downtime_end(uint64_t addr); +uint64_t get_postcopy_total_downtime(void); +void destroy_downtime_duration(gpointer data); =20 /* * An outstanding page request, on the source, having been received diff --git a/migration/migration.c b/migration/migration.c index 79f6425..5bac434 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -38,6 +38,8 @@ #include "io/channel-tls.h" #include "migration/colo.h" =20 +#define DEBUG_VCPU_DOWNTIME 1 + #define MAX_THROTTLE (32 << 20) /* Migration transfer speed throttli= ng */ =20 /* Amount of time to allocate to each "chunk" of bandwidth-throttled @@ -77,6 +79,19 @@ static NotifierList migration_state_notifiers =3D =20 static bool deferred_incoming; =20 +typedef struct { + int64_t begin; + int64_t end; + uint64_t *cpus; /* cpus bit mask array, QEMU bit functions support + bit operation on memory regions, but doesn't check out of range */ +} DowntimeDuration; + +typedef struct { + int64_t tp; /* point in time */ + bool is_end; + uint64_t *cpus; +} OverlapDowntime; + /* * Current state of incoming postcopy; note this is not part of * MigrationIncomingState since it's state is used during cleanup @@ -117,6 +132,13 @@ MigrationState *migrate_get_current(void) return ¤t_migration; } =20 +void destroy_downtime_duration(gpointer data) +{ + DowntimeDuration *dd =3D (DowntimeDuration *)data; + g_free(dd->cpus); + g_free(data); +} + MigrationIncomingState *migration_incoming_get_current(void) { static bool once; @@ -138,10 +160,13 @@ void migration_incoming_state_destroy(void) struct MigrationIncomingState *mis =3D migration_incoming_get_current(= ); =20 qemu_event_destroy(&mis->main_thread_load_event); + if (mis->postcopy_downtime) { + g_tree_destroy(mis->postcopy_downtime); + mis->postcopy_downtime =3D NULL; + } loadvm_free_handlers(mis); } =20 - typedef struct { bool optional; uint32_t size; @@ -1754,7 +1779,6 @@ static int postcopy_start(MigrationState *ms, bool *o= ld_vm_running) */ ms->postcopy_after_devices =3D true; notifier_list_notify(&migration_state_notifiers, ms); - ms->downtime =3D qemu_clock_get_ms(QEMU_CLOCK_REALTIME) - time_at_sto= p; =20 qemu_mutex_unlock_iothread(); @@ -2117,3 +2141,255 @@ PostcopyState postcopy_state_set(PostcopyState new_= state) return atomic_xchg(&incoming_postcopy_state, new_state); } =20 +#define SIZE_TO_KEEP_CPUBITS (1 + smp_cpus/sizeof(guint64)) + +void mark_postcopy_downtime_begin(uint64_t addr, int cpu) +{ + MigrationIncomingState *mis =3D migration_incoming_get_current(); + DowntimeDuration *dd; + if (!mis->postcopy_downtime) { + return; + } + + dd =3D g_tree_lookup(mis->postcopy_downtime, (gpointer)addr); /* !!! c= ast */ + if (!dd) { + dd =3D (DowntimeDuration *)g_new0(DowntimeDuration, 1); + dd->cpus =3D g_new0(guint64, SIZE_TO_KEEP_CPUBITS); + g_tree_insert(mis->postcopy_downtime, (gpointer)addr, (gpointer)dd= ); + } + + if (cpu < 0) { + /* assume in this situation all vCPUs are sleeping */ + int i; + for (i =3D 0; i < SIZE_TO_KEEP_CPUBITS; i++) { + dd->cpus[i] =3D ~(uint64_t)0u; + } + } else + set_bit(cpu, dd->cpus); + + /* + * overwrite previously set dd->begin, if that page already was + * faulted on another cpu + */ + dd->begin =3D qemu_clock_get_ms(QEMU_CLOCK_REALTIME); + trace_mark_postcopy_downtime_begin(addr, dd, dd->begin, cpu); +} + +void mark_postcopy_downtime_end(uint64_t addr) +{ + MigrationIncomingState *mis =3D migration_incoming_get_current(); + DowntimeDuration *dd; + if (!mis->postcopy_downtime) { + return; + } + + dd =3D g_tree_lookup(mis->postcopy_downtime, (gpointer)addr); + if (!dd) { + /* error_report("Could not populate downtime duration completion t= ime \n\ + There is no downtime duration for 0x%"PRIx64, addr= ); */ + return; + } + + dd->end =3D qemu_clock_get_ms(QEMU_CLOCK_REALTIME); + trace_mark_postcopy_downtime_end(addr, dd, dd->end); +} + +struct downtime_overlay_cxt { + GPtrArray *downtime_points; + size_t number_of_points; +}; +/* + * This function split each DowntimeDuration, which represents as start/end + * pointand makes a points of it, then fill array with points, + * to sort it in future. + */ +static gboolean split_duration_and_fill_points(gpointer key, gpointer valu= e, + gpointer data) +{ + struct downtime_overlay_cxt *ctx =3D (struct downtime_overlay_cxt *)da= ta; + DowntimeDuration *dd =3D (DowntimeDuration *)value; + GPtrArray *interval =3D ctx->downtime_points; + if (dd->begin) { + OverlapDowntime *od_begin =3D g_new0(OverlapDowntime, 1); + od_begin->cpus =3D g_memdup(dd->cpus, sizeof(uint64_t) * SIZE_TO_K= EEP_CPUBITS); + od_begin->tp =3D dd->begin; + od_begin->is_end =3D false; + g_ptr_array_add(interval, od_begin); + ctx->number_of_points +=3D 1; + } + + if (dd->end) { + OverlapDowntime *od_end =3D g_new0(OverlapDowntime, 1); + od_end->cpus =3D g_memdup(dd->cpus, sizeof(uint64_t) * SIZE_TO_KEE= P_CPUBITS); + od_end->tp =3D dd->end; + od_end->is_end =3D true; + g_ptr_array_add(interval, od_end); + ctx->number_of_points +=3D 1; + } + + if (dd->end && dd->begin) + trace_split_duration_and_fill_points(dd->end - dd->begin, (uint64_= t)key); + return FALSE; +} + +#ifdef DEBUG_VCPU_DOWNTIME +static gboolean calculate_per_cpu(gpointer key, gpointer value, + gpointer data) +{ + int *downtime_cpu =3D (int *)data; + DowntimeDuration *dd =3D (DowntimeDuration *)value; + int cpu_iter; + for (cpu_iter =3D 0; cpu_iter < smp_cpus; cpu_iter++) { + if (test_bit(cpu_iter, dd->cpus) && dd->end && dd->begin) + downtime_cpu[cpu_iter] +=3D dd->end - dd->begin; + } + return FALSE; +} +#endif /* DEBUG_VCPU_DOWNTIME */ + +static gint compare_downtime(gconstpointer a, gconstpointer b) +{ + DowntimeDuration *dda =3D (DowntimeDuration *)a; + DowntimeDuration *ddb =3D (DowntimeDuration *)b; + return dda->begin - ddb->begin; +} + +static void destroy_overlap_downtime(gpointer data) +{ + OverlapDowntime *od =3D (OverlapDowntime *)data; + g_free(od->cpus); + g_free(data); +} + +static int check_overlap(uint64_t *b) +{ + unsigned long zero_bit =3D find_first_zero_bit(b, BITS_PER_LONG * SIZE= _TO_KEEP_CPUBITS); + return zero_bit >=3D smp_cpus; +} + +/* + * This function calculates downtime per cpu and trace it + * + * Also it calculates total downtime as an interval's overlap, + * for many vCPU. + * + * The approach is following: + * Initially intervals are represented in tree where key is + * pagefault address, and values: + * begin - page fault time + * end - page load time + * cpus - bit mask shows affected cpus + * + * To calculate overlap on all cpus, intervals converted into + * array of points in time (downtime_points), the size of + * array is 2 * number of nodes in tree of intervals (2 array + * elements per one in element of interval). + * Each element is marked as end (E) or as start (S) of interval. + * The overlap downtime will be calculated for SE, only in case + * there is sequence S(0..N)E(M) for every vCPU. + * + * As example we have 3 CPU + * + * S1 E1 S1 E1 + * -----***********------------xxx***************------------------------>= CPU1 + * + * S2 E2 + * ------------****************xxx--------------------------------------->= CPU2 + * + * S3 E3 + * ------------------------****xxx********------------------------------->= CPU3 + * + * We have sequence S1,S2,E1,S3,S1,E2,E3,E1 + * S2,E1 - doesn't match condition due to sequence S1,S2,E1 doesn't includ= e CPU3 + * S3,S1,E2 - sequenece includes all CPUs, in this case overlap will be S1= ,E2 + * Legend of picture is following: * - means downtime per vCPU + * x - means overlapped downtime + */ +uint64_t get_postcopy_total_downtime(void) +{ + MigrationIncomingState *mis =3D migration_incoming_get_current(); + uint64_t total_downtime =3D 0; /* for total overlapped downtime */ + const int intervals =3D g_tree_nnodes(mis->postcopy_downtime); + int point_iter, start_point_iter, i; + struct downtime_overlay_cxt dp_ctx =3D { 0 }; + /* + * array will contain 2 * interval points or less, if + * it was not page fault finalization for page, + * real count will be in ctx.number_of_points + */ + dp_ctx.downtime_points =3D g_ptr_array_new_full(2 * intervals, + destroy_overlap_downt= ime); + if (!mis->postcopy_downtime) { + goto out; + } + +#ifdef DEBUG_VCPU_DOWNTIME + { + gint *downtime_cpu =3D g_new0(int, smp_cpus); + g_tree_foreach(mis->postcopy_downtime, calculate_per_cpu, downtime= _cpu); + for (point_iter =3D 0; point_iter < smp_cpus; point_iter++) + { + trace_downtime_per_cpu(point_iter, downtime_cpu[point_iter]); + } + g_free(downtime_cpu); + } +#endif /* DEBUG_VCPU_DOWNTIME */ + + /* make downtime points S/E from interval */ + g_tree_foreach(mis->postcopy_downtime, split_duration_and_fill_points, + &dp_ctx); + g_ptr_array_sort(dp_ctx.downtime_points, compare_downtime); + + for (point_iter =3D 1; point_iter < dp_ctx.number_of_points; + point_iter++) { + OverlapDowntime *od =3D g_ptr_array_index(dp_ctx.downtime_points, + point_iter); + uint64_t *cur_cpus; + int smp_cpus_i =3D smp_cpus; + OverlapDowntime *prev_od =3D g_ptr_array_index(dp_ctx.downtime_poi= nts, + point_iter - 1); + if (!od || !prev_od) + continue; + /* we need sequence SE */ + if (!od->is_end || prev_od->is_end) + continue; + + cur_cpus =3D g_memdup(od->cpus, sizeof(uint64_t) * SIZE_TO_KEEP_CP= UBITS); + for (start_point_iter =3D point_iter - 1; + start_point_iter >=3D 0 && smp_cpus_i; + start_point_iter--, smp_cpus_i--) { + OverlapDowntime *t_od =3D g_ptr_array_index(dp_ctx.downtime_po= ints, + start_point_iter); + if (!t_od) + break; + /* should be S */ + if (t_od->is_end) + break; + + /* points were sorted, it's possible when + * end is not occured, but this points were ommited + * in split_duration_and_fill_points */ + if (od->tp <=3D prev_od->tp) { + break; + } + + for (i =3D 0; i < SIZE_TO_KEEP_CPUBITS; i++) { + cur_cpus[i] |=3D t_od->cpus[i]; + } + + /* check_overlap - just count number of bits in cur_cpus, + * and compare it with smp_cpus */ + if (check_overlap(cur_cpus)) { + total_downtime +=3D od->tp - prev_od->tp; + /* situation when one S point represents all vCPU is possi= ble */ + break; + } + } + g_free(cur_cpus); + } + trace_get_postcopy_total_downtime(g_tree_nnodes(mis->postcopy_downtime= ), + total_downtime); +out: + g_ptr_array_free(dp_ctx.downtime_points, TRUE); + return total_downtime; +} diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c index 70f0480..ea89f4e 100644 --- a/migration/postcopy-ram.c +++ b/migration/postcopy-ram.c @@ -23,8 +23,10 @@ #include "migration/postcopy-ram.h" #include "sysemu/sysemu.h" #include "sysemu/balloon.h" +#include #include "qemu/error-report.h" #include "trace.h" +#include "glib/glib-helper.h" =20 /* Arbitrary limit on size of each discard command, * keeps them around ~200 bytes @@ -81,6 +83,11 @@ static bool ufd_version_check(int ufd, MigrationIncoming= State *mis) return false; } =20 + if (mis && UFFD_FEATURE_THREAD_ID & api_struct.features) { + mis->postcopy_downtime =3D g_tree_new_full(g_int_cmp64, + NULL, NULL, destroy_downtime_dura= tion); + } + if (getpagesize() !=3D ram_pagesize_summary()) { bool have_hp =3D false; /* We've got a huge page */ @@ -404,6 +411,18 @@ static int ram_block_enable_notify(const char *block_n= ame, void *host_addr, return 0; } =20 +static int get_mem_fault_cpu_index(uint32_t pid) +{ + CPUState *cpu_iter; + + CPU_FOREACH(cpu_iter) { + if (cpu_iter->thread_id =3D=3D pid) + return cpu_iter->cpu_index; + } + trace_get_mem_fault_cpu_index(pid); + return -1; +} + /* * Handle faults detected by the USERFAULT markings */ @@ -481,8 +500,10 @@ static void *postcopy_ram_fault_thread(void *opaque) rb_offset &=3D ~(qemu_ram_pagesize(rb) - 1); trace_postcopy_ram_fault_thread_request(msg.arg.pagefault.address, qemu_ram_get_idstr(rb), - rb_offset); + rb_offset, msg.arg.pagefau= lt.feat.ptid); =20 + mark_postcopy_downtime_begin(msg.arg.pagefault.address, + get_mem_fault_cpu_index(msg.arg.pagefault.feat= .ptid)); /* * Send the request to the source - we want to request one * of our host page sizes (which is >=3D TPS) @@ -577,6 +598,7 @@ int postcopy_place_page(MigrationIncomingState *mis, vo= id *host, void *from, =20 return -e; } + mark_postcopy_downtime_end((uint64_t)host); =20 trace_postcopy_place_page(host); return 0; diff --git a/migration/qemu-file.c b/migration/qemu-file.c index 195fa94..c9f3e47 100644 --- a/migration/qemu-file.c +++ b/migration/qemu-file.c @@ -547,7 +547,6 @@ size_t qemu_get_buffer_in_place(QEMUFile *f, uint8_t **= buf, size_t size) int qemu_peek_byte(QEMUFile *f, int offset) { int index =3D f->buf_index + offset; - assert(!qemu_file_is_writable(f)); assert(offset < IO_BUF_SIZE); =20 diff --git a/migration/trace-events b/migration/trace-events index 7372ce2..ab2e1e4 100644 --- a/migration/trace-events +++ b/migration/trace-events @@ -110,6 +110,12 @@ process_incoming_migration_co_end(int ret, int ps) "re= t=3D%d postcopy-state=3D%d" process_incoming_migration_co_postcopy_end_main(void) "" migration_set_incoming_channel(void *ioc, const char *ioctype) "ioc=3D%p i= octype=3D%s" migration_set_outgoing_channel(void *ioc, const char *ioctype, const char = *hostname) "ioc=3D%p ioctype=3D%s hostname=3D%s" +mark_postcopy_downtime_begin(uint64_t addr, void *dd, int64_t time, int cp= u) "addr 0x%" PRIx64 " dd %p time %" PRId64 " cpu %d" +mark_postcopy_downtime_end(uint64_t addr, void *dd, int64_t time) "addr 0x= %" PRIx64 " dd %p time %" PRId64 +get_postcopy_total_downtime(int num, uint64_t total) "faults %d, total dow= ntime %" PRIu64 +split_duration_and_fill_points(int64_t downtime, uint64_t addr) "downtime = %" PRId64 " addr 0x%" PRIx64 +downtime_per_cpu(int cpu_index, int downtime) "downtime cpu[%d]=3D%d" +source_return_path_thread_downtime(uint64_t downtime) "downtime %" PRIu64 =20 # migration/rdma.c qemu_rdma_accept_incoming_migration(void) "" @@ -186,7 +192,7 @@ postcopy_ram_enable_notify(void) "" postcopy_ram_fault_thread_entry(void) "" postcopy_ram_fault_thread_exit(void) "" postcopy_ram_fault_thread_quit(void) "" -postcopy_ram_fault_thread_request(uint64_t hostaddr, const char *ramblock,= size_t offset) "Request for HVA=3D%" PRIx64 " rb=3D%s offset=3D%zx" +postcopy_ram_fault_thread_request(uint64_t hostaddr, const char *ramblock,= size_t offset, int pid) "Request for HVA=3D%" PRIx64 " rb=3D%s offset=3D%z= x %d" postcopy_ram_incoming_cleanup_closeuf(void) "" postcopy_ram_incoming_cleanup_entry(void) "" postcopy_ram_incoming_cleanup_exit(void) "" @@ -195,6 +201,7 @@ save_xbzrle_page_skipping(void) "" save_xbzrle_page_overflow(void) "" ram_save_iterate_big_wait(uint64_t milliconds, int iterations) "big wait: = %" PRIu64 " milliseconds, %d iterations" ram_load_complete(int ret, uint64_t seq_iter) "exit_code %d seq iteration = %" PRIu64 +get_mem_fault_cpu_index(uint32_t pid) "pid %u is not vCPU" =20 # migration/exec.c migration_exec_outgoing(const char *cmd) "cmd=3D%s" --=20 1.8.3.1 From nobody Thu May 2 16:31:05 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 149217617713932.983802982726615; Fri, 14 Apr 2017 06:22:57 -0700 (PDT) Received: from localhost ([::1]:53298 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cz1Bf-0002eP-Sd for importer@patchew.org; Fri, 14 Apr 2017 09:22:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49199) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cz16k-0007SC-Ki for qemu-devel@nongnu.org; Fri, 14 Apr 2017 09:17:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cz16h-0008Fp-GM for qemu-devel@nongnu.org; Fri, 14 Apr 2017 09:17:50 -0400 Received: from mailout3.w1.samsung.com ([210.118.77.13]:25638) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cz16h-0008EY-7s for qemu-devel@nongnu.org; Fri, 14 Apr 2017 09:17:47 -0400 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout3.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0OOE00LEYI9I0X00@mailout3.w1.samsung.com> for qemu-devel@nongnu.org; Fri, 14 Apr 2017 14:17:42 +0100 (BST) Received: from eusmges3.samsung.com (unknown [203.254.199.242]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20170414131741eucas1p17f6f461beaab8a2bdb0c08b4785ef2ce~1RgpPSgX-1793717937eucas1p12; Fri, 14 Apr 2017 13:17:41 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges3.samsung.com (EUCPMTA) with SMTP id 1D.E7.17464.5FBC0F85; Fri, 14 Apr 2017 14:17:41 +0100 (BST) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20170414131740eucas1p28f240a4e6c78fb56be52f2641c3e5af6~1Rgoe7Uxq2464124641eucas1p2C; Fri, 14 Apr 2017 13:17:40 +0000 (GMT) Received: from eusync2.samsung.com ( [203.254.199.212]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 37.FF.20206.B0CC0F85; Fri, 14 Apr 2017 14:18:03 +0100 (BST) Received: from aperevalov-ubuntu.rnd.samsung.ru ([106.109.129.199]) by eusync2.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0OOE00KVHI9AY150@eusync2.samsung.com>; Fri, 14 Apr 2017 14:17:40 +0100 (BST) X-AuditID: cbfec7f2-f797e6d000004438-94-58f0cbf55702 From: Alexey Perevalov To: dgilbert@redhat.com, qemu-devel@nongnu.org Date: Fri, 14 Apr 2017 16:17:19 +0300 Message-id: <1492175840-5021-6-git-send-email-a.perevalov@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1492175840-5021-1-git-send-email-a.perevalov@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrPIsWRmVeSWpSXmKPExsWy7djPc7pfT3+IMDj4XNxi7t3zLBa92+6x W1xp/8lucbx3B4sDi8eTa5uZPN7vu8rm0bdlFWMAcxSXTUpqTmZZapG+XQJXxr9PH1kKfipW 3D2zjLmBcZtUFyMnh4SAicSF6T8YIWwxiQv31rOB2EICSxklvu4R6GLkArI/M0o0THvECNOw qusUM0RiGaPElqVnGSGcbiaJqZdfsHcxcnCwCRhI7LtnC9IgIqAnceVbJ1gzs4CxRMvP5+wg trCAq0TXlJdsIOUsAqoSJz6CHcQr4Cax6NwGNohdchInj01mBbE5BdwlXv1YyQKySkLgMpvE xzmbWUF6JQRkJTYdYIaod5E40baaFcIWlnh1fAs7hC0jcXlyN1RvO6NE985OVghnAqPEmel/ oarsJU7dvMoEcSifxKRt05khFvBKdLQJQZR4SHzZcgxqr6NE7383iNdnMUrcPD+JeQKjzAJG hlWMIqmlxbnpqcXGesWJucWleel6yfm5mxiB0Xj63/FPOxi/nrA6xCjAwajEw3vh+IcIIdbE suLK3EOMEhzMSiK80aeAQrwpiZVVqUX58UWlOanFhxilOViUxHm5Tl2LEBJITyxJzU5NLUgt gskycXBKNTDO0Ps69USsxOcZnyc9+VWma/fw1lmF2T1u+tPnRN748G7xO4YsV++vSwtuv/n5 d9HmjBC1OfL+BelsXuW3vhm3tbnz9vNwXRP24Mz6uO2rQ8yJdZZz/xq9/qDgX2uw6squ4iSz i3f09X2SA3Uctv/m3Llec8/+2NO/z8jdCjDxvfe9prm06fxeJZbijERDLeai4kQA1qIIJcIC AAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrPLMWRmVeSWpSXmKPExsVy+t/xK7rcZz5EGEz9LWkx9+55FovebffY La60/2S3ON67g8WBxePJtc1MHu/3XWXz6NuyijGAOcrNJiM1MSW1SCE1Lzk/JTMv3VYpNMRN 10JJIS8xN9VWKULXNyRISaEsMacUyDMyQAMOzgHuwUr6dgluGf8+fWQp+KlYcffMMuYGxm1S XYycHBICJhKruk4xQ9hiEhfurWfrYuTiEBJYwijx/u8/Fginl0niwKa1TF2MHBxsAgYS++7Z gjSICOhJXPnWyQhiMwsYS7T8fM4OYgsLuEp0TXnJBlLOIqAqceIj2C5eATeJRec2sEHskpM4 eWwyK4jNKeAu8erHShYQWwioZuXp90wTGHkXMDKsYhRJLS3OTc8tNtIrTswtLs1L10vOz93E CAzMbcd+btnB2PUu+BCjAAejEg9vxdEPEUKsiWXFlbmHGCU4mJVEeKNPAYV4UxIrq1KL8uOL SnNSiw8xmgLdNJFZSjQ5Hxg1eSXxhiaG5paGRsYWFuZGRkrivFM/XAkXEkhPLEnNTk0tSC2C 6WPi4JRqYGRydFVeJ2JkHbrh7Sr1R/+1zhdbn4syOHcj1y3Vcfqjiu45rQnKmw8L3pbOLVt3 VifLgi9G8pnWAf7jV/01JHq/CyQdPm7B/iDsJsuJpp1b9Dx2dYu9aNh6eunJR8xsAbxtu7c3 zbxZctvBLGrJc6l/Emd6X50RdJ+15odM0JXvcxa0Lfvz5qISS3FGoqEWc1FxIgBAeCDAYgIA AA== X-MTR: 20000000000000000@CPGS X-CMS-MailID: 20170414131740eucas1p28f240a4e6c78fb56be52f2641c3e5af6 X-Msg-Generator: CA X-Sender-IP: 182.198.249.180 X-Local-Sender: =?UTF-8?B?QWxleGV5IFBlcmV2YWxvdhtTUlItVmlydHVhbGl6YXRpb24g?= =?UTF-8?B?TGFiG+yCvOyEseyghOyekBtTZW5pb3IgRW5naW5lZXI=?= X-Global-Sender: =?UTF-8?B?QWxleGV5IFBlcmV2YWxvdhtTUlItVmlydHVhbGl6YXRpb24g?= =?UTF-8?B?TGFiG1NhbXN1bmcgRWxlY3Ryb25pY3MbU2VuaW9yIEVuZ2luZWVy?= X-Sender-Code: =?UTF-8?B?QzEwG0NJU0hRG0MxMEdEMDFHRDAxMDE1NA==?= CMS-TYPE: 201P X-HopCount: 7 X-CMS-RootMailID: 20170414131740eucas1p28f240a4e6c78fb56be52f2641c3e5af6 X-RootMTR: 20170414131740eucas1p28f240a4e6c78fb56be52f2641c3e5af6 References: <1492175840-5021-1-git-send-email-a.perevalov@samsung.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 210.118.77.13 Subject: [Qemu-devel] [PATCH 5/6] migration: send postcopy downtime back to source X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: i.maximets@samsung.com, a.perevalov@samsung.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Right now to initiate postcopy live migration need to send request to source machine and specify destination. User could request migration status by query-migrate qmp command on source machine, but postcopy downtime is being evaluated on destination, so it should be transmitted back to source. For this purpose return path socket was shosen. Signed-off-by: Alexey Perevalov --- include/migration/migration.h | 4 +++- migration/migration.c | 20 ++++++++++++++++++-- migration/postcopy-ram.c | 1 + 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/include/migration/migration.h b/include/migration/migration.h index 5d2c628..5535aa6 100644 --- a/include/migration/migration.h +++ b/include/migration/migration.h @@ -55,7 +55,8 @@ enum mig_rp_message_type { =20 MIG_RP_MSG_REQ_PAGES_ID, /* data (start: be64, len: be32, id: string) = */ MIG_RP_MSG_REQ_PAGES, /* data (start: be64, len: be32) */ - + MIG_RP_MSG_DOWNTIME, /* downtime value from destination, + calculated and sent in case of post copy */ MIG_RP_MSG_MAX }; =20 @@ -364,6 +365,7 @@ void migrate_send_rp_pong(MigrationIncomingState *mis, uint32_t value); void migrate_send_rp_req_pages(MigrationIncomingState *mis, const char* rb= name, ram_addr_t start, size_t len); +void migrate_send_rp_downtime(MigrationIncomingState *mis, uint64_t downti= me); =20 void ram_control_before_iterate(QEMUFile *f, uint64_t flags); void ram_control_after_iterate(QEMUFile *f, uint64_t flags); diff --git a/migration/migration.c b/migration/migration.c index 5bac434..3134e24 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -553,6 +553,19 @@ void migrate_send_rp_message(MigrationIncomingState *m= is, } =20 /* + * Send postcopy migration downtime, + * at the moment of calling this function migration should + * be completed. + */ +void migrate_send_rp_downtime(MigrationIncomingState *mis, uint64_t downti= me) +{ + uint64_t buf; + + buf =3D cpu_to_be64(downtime); + migrate_send_rp_message(mis, MIG_RP_MSG_DOWNTIME, sizeof(downtime), &b= uf); +} + +/* * Send a 'SHUT' message on the return channel with the given value * to indicate that we've finished with the RP. Non-0 value indicates * error. @@ -1483,6 +1496,7 @@ static struct rp_cmd_args { [MIG_RP_MSG_PONG] =3D { .len =3D 4, .name =3D "PONG" }, [MIG_RP_MSG_REQ_PAGES] =3D { .len =3D 12, .name =3D "REQ_PAGES" }, [MIG_RP_MSG_REQ_PAGES_ID] =3D { .len =3D -1, .name =3D "REQ_PAGES_ID= " }, + [MIG_RP_MSG_DOWNTIME] =3D { .len =3D 8, .name =3D "DOWNTIME" }, [MIG_RP_MSG_MAX] =3D { .len =3D -1, .name =3D "MAX" }, }; =20 @@ -1613,6 +1627,10 @@ static void *source_return_path_thread(void *opaque) migrate_handle_rp_req_pages(ms, (char *)&buf[13], start, len); break; =20 + case MIG_RP_MSG_DOWNTIME: + ms->downtime =3D ldq_be_p(buf); + break; + default: break; } @@ -1677,7 +1695,6 @@ static int postcopy_start(MigrationState *ms, bool *o= ld_vm_running) int ret; QIOChannelBuffer *bioc; QEMUFile *fb; - int64_t time_at_stop =3D qemu_clock_get_ms(QEMU_CLOCK_REALTIME); bool restart_block =3D false; migrate_set_state(&ms->state, MIGRATION_STATUS_ACTIVE, MIGRATION_STATUS_POSTCOPY_ACTIVE); @@ -1779,7 +1796,6 @@ static int postcopy_start(MigrationState *ms, bool *o= ld_vm_running) */ ms->postcopy_after_devices =3D true; notifier_list_notify(&migration_state_notifiers, ms); - ms->downtime =3D qemu_clock_get_ms(QEMU_CLOCK_REALTIME) - time_at_sto= p; =20 qemu_mutex_unlock_iothread(); =20 diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c index ea89f4e..42330fd 100644 --- a/migration/postcopy-ram.c +++ b/migration/postcopy-ram.c @@ -330,6 +330,7 @@ int postcopy_ram_incoming_cleanup(MigrationIncomingStat= e *mis) } =20 postcopy_state_set(POSTCOPY_INCOMING_END); + migrate_send_rp_downtime(mis, get_postcopy_total_downtime()); migrate_send_rp_shut(mis, qemu_file_get_error(mis->from_src_file) !=3D= 0); =20 if (mis->postcopy_tmp_page) { --=20 1.8.3.1 From nobody Thu May 2 16:31:05 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1492176174471565.7095489371434; Fri, 14 Apr 2017 06:22:54 -0700 (PDT) Received: from localhost ([::1]:53297 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cz1Bc-0002cK-Jf for importer@patchew.org; Fri, 14 Apr 2017 09:22:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49180) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cz16i-0007Rx-Sm for qemu-devel@nongnu.org; Fri, 14 Apr 2017 09:17:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cz16f-0008ET-S7 for qemu-devel@nongnu.org; Fri, 14 Apr 2017 09:17:48 -0400 Received: from mailout1.w1.samsung.com ([210.118.77.11]:24106) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cz16f-0008DO-MK for qemu-devel@nongnu.org; Fri, 14 Apr 2017 09:17:45 -0400 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0OOE00IO7I9IUO00@mailout1.w1.samsung.com> for qemu-devel@nongnu.org; Fri, 14 Apr 2017 14:17:42 +0100 (BST) Received: from eusmges5.samsung.com (unknown [203.254.199.245]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20170414131742eucas1p12412b6bdeba4aee3ebe1fe706f95b39a~1Rgpt6dUM1794117941eucas1p1t; Fri, 14 Apr 2017 13:17:42 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges5.samsung.com (EUCPMTA) with SMTP id 8A.D9.25577.5FBC0F85; Fri, 14 Apr 2017 14:17:41 +0100 (BST) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20170414131741eucas1p2f34e11e4292fef1c50ef63bd3522ad04~1Rgo9_Ijt1944319443eucas1p2l; Fri, 14 Apr 2017 13:17:41 +0000 (GMT) Received: from eusync2.samsung.com ( [203.254.199.212]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id C7.FF.20206.B0CC0F85; Fri, 14 Apr 2017 14:18:03 +0100 (BST) Received: from aperevalov-ubuntu.rnd.samsung.ru ([106.109.129.199]) by eusync2.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0OOE00KVHI9AY150@eusync2.samsung.com>; Fri, 14 Apr 2017 14:17:41 +0100 (BST) X-AuditID: cbfec7f5-f792f6d0000063e9-26-58f0cbf5f5ac From: Alexey Perevalov To: dgilbert@redhat.com, qemu-devel@nongnu.org Date: Fri, 14 Apr 2017 16:17:20 +0300 Message-id: <1492175840-5021-7-git-send-email-a.perevalov@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1492175840-5021-1-git-send-email-a.perevalov@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrAIsWRmVeSWpSXmKPExsWy7djP87pfT3+IMGjeYW4x9+55FovebffY La60/2S3ON67g8WBxePJtc1MHu/3XWXz6NuyijGAOYrLJiU1J7MstUjfLoEro/XsVJaCWyoV ex8vY2lgfCrTxcjJISFgIvFh3RQmCFtM4sK99WxdjFwcQgJLGSWedM9ghXA+M0ocW/GYBaZj b8t1qKpljBJT320CSwgJdDNJzJ9q2sXIwcEmYCCx754tSFhEQE/iyrdORhCbWcBYouXnc3YQ W1jARuLurhlgm1kEVCU6NlxgA7F5Bdwkni3ayw6xS07i5LHJrCA2p4C7xKsfK1lA9koInGGT mDfxECvILgkBWYlNB5ghTBeJ3e2MEK3CEq+Ob4EaIyNxeXI3VGs7o0T3zk5WCGcCo8SZ6X+h quwlTt28ygRxKJ/EpG3ToYbySnS0CUGUeEg03dgLDQdHiScff7FAwmEWo8SCS6vZJzDKLGBk WMUoklpanJueWmyqV5yYW1yal66XnJ+7iREYj6f/Hf+6g3HpMatDjAIcjEo8vBeOf4gQYk0s K67MPcQowcGsJMIbfQooxJuSWFmVWpQfX1Sak1p8iFGag0VJnJfr1LUIIYH0xJLU7NTUgtQi mCwTB6dUA2PQTMWTzf1VNxK6i+vSi8rMl/z44mD7XXZG19Gw2e9FDPy+zfv/bElzmGTjDglz 78jPsq6M0QWmS0PXmfB5tAZlPcgKl5NMu7n3cmLMM/ki3U1aBybdex4TWRb5gEv5S+3Zh9nd BczCwR3fjLgerzv59H+B+5MdW/M/HVW88dB9/2yhF4Z+TUosxRmJhlrMRcWJADMt0iDDAgAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrALMWRmVeSWpSXmKPExsVy+t/xK7rcZz5EGHzotrSYe/c8i0Xvtnvs Flfaf7JbHO/dweLA4vHk2mYmj/f7rrJ59G1ZxRjAHOVmk5GamJJapJCal5yfkpmXbqsUGuKm a6GkkJeYm2qrFKHrGxKkpFCWmFMK5BkZoAEH5wD3YCV9uwS3jNazU1kKbqlU7H28jKWB8alM FyMnh4SAicTelutsELaYxIV764FsLg4hgSWMEnM7trJCOL1MEkt+3WfvYuTgYBMwkNh3zxak QURAT+LKt05GEJtZwFii5edzdhBbWMBG4u6uGUwgNouAqkTHhgtgC3gF3CSeLdrLDrFMTuLk scmsIDangLvEqx8rWUBsIaCalaffM01g5F3AyLCKUSS1tDg3PbfYSK84Mbe4NC9dLzk/dxMj MDS3Hfu5ZQdj17vgQ4wCHIxKPLwVRz9ECLEmlhVX5h5ilOBgVhLhjT4FFOJNSaysSi3Kjy8q zUktPsRoCnTURGYp0eR8YNzklcQbmhiaWxoaGVtYmBsZKYnzTv1wJVxIID2xJDU7NbUgtQim j4mDU6qBcdK/ebN/yp6Um7tk17HOvw0nXrXH3Q4uVfkqOv/5Le1J/pdsWdkjPd57Tz908SFb zbqGbS3LxbzP+Rz7bbuz9vrmmEjhzpI5Kj/2Tax23aFpInQ04Zqa4h2dfd/lTcXV61nO7hRu 5tF5ljz99qfmcyUTVRt4hWvsb8vlsPCwrWo+pf/f0+eBvRJLcUaioRZzUXEiAMhgMcVjAgAA X-MTR: 20000000000000000@CPGS X-CMS-MailID: 20170414131741eucas1p2f34e11e4292fef1c50ef63bd3522ad04 X-Msg-Generator: CA X-Sender-IP: 182.198.249.180 X-Local-Sender: =?UTF-8?B?QWxleGV5IFBlcmV2YWxvdhtTUlItVmlydHVhbGl6YXRpb24g?= =?UTF-8?B?TGFiG+yCvOyEseyghOyekBtTZW5pb3IgRW5naW5lZXI=?= X-Global-Sender: =?UTF-8?B?QWxleGV5IFBlcmV2YWxvdhtTUlItVmlydHVhbGl6YXRpb24g?= =?UTF-8?B?TGFiG1NhbXN1bmcgRWxlY3Ryb25pY3MbU2VuaW9yIEVuZ2luZWVy?= X-Sender-Code: =?UTF-8?B?QzEwG0NJU0hRG0MxMEdEMDFHRDAxMDE1NA==?= CMS-TYPE: 201P X-HopCount: 7 X-CMS-RootMailID: 20170414131741eucas1p2f34e11e4292fef1c50ef63bd3522ad04 X-RootMTR: 20170414131741eucas1p2f34e11e4292fef1c50ef63bd3522ad04 References: <1492175840-5021-1-git-send-email-a.perevalov@samsung.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 210.118.77.11 Subject: [Qemu-devel] [PATCH 6/6] migration: detailed traces for postcopy X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: i.maximets@samsung.com, a.perevalov@samsung.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" It could help to track down vCPU state during page fault and page fault sources. This patch showes proc's status/stack/syscall file at the moment of pagefau= lt, it's very interesting to know who was page fault initiator. Signed-off-by: Alexey Perevalov --- migration/postcopy-ram.c | 98 ++++++++++++++++++++++++++++++++++++++++++++= +++- migration/trace-events | 6 +++ 2 files changed, 103 insertions(+), 1 deletion(-) diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c index 42330fd..513633c 100644 --- a/migration/postcopy-ram.c +++ b/migration/postcopy-ram.c @@ -412,7 +412,91 @@ static int ram_block_enable_notify(const char *block_n= ame, void *host_addr, return 0; } =20 -static int get_mem_fault_cpu_index(uint32_t pid) +#define PROC_LEN 1024 +#define DEBUG_FAULT_PROCESS_STATUS 1 + +#ifdef DEBUG_FAULT_PROCESS_STATUS + +static FILE *get_proc_file(const gchar *frmt, pid_t thread_id) +{ + FILE *f =3D NULL; + gchar *file_path =3D g_strdup_printf(frmt, thread_id); + if (file_path =3D=3D NULL) { + error_report("Couldn't allocate path for %u", thread_id); + return NULL; + } + f =3D fopen(file_path, "r"); + if (!f) { + error_report("can't open %s", file_path); + } + + trace_get_proc_file(file_path); + g_free(file_path); + return f; +} + +typedef void(*proc_line_handler)(const char *line); + +static void proc_line_cb(const char *line) +{ + /* trace_ functions are inline */ + trace_proc_line_cb(line); +} + +static void foreach_line_in_file(FILE *f, proc_line_handler cb) +{ + char *line =3D NULL; + ssize_t read; + size_t len; + + while ((read =3D getline(&line, &len, f)) !=3D -1) { + /* workaround, trace_ infrastructure already insert \n + * and getline includes it */ + ssize_t str_len =3D strlen(line) - 1; + if (str_len <=3D 0) + continue; + line[str_len] =3D '\0'; + cb(line); + } + free(line); +} + +static void observe_thread_proc(const gchar *path_frmt, pid_t thread_id) +{ + FILE *f =3D get_proc_file(path_frmt, thread_id); + if (!f) { + error_report("can't read thread's proc"); + return; + } + + foreach_line_in_file(f, proc_line_cb); + fclose(f); +} + +/* + * for convinience tracing need to trace + * observe_thread_begin + * get_proc_file + * proc_line_cb + * observe_thread_end + */ +static void observe_thread(const char *msg, pid_t thread_id) +{ + trace_observe_thread_begin(msg); + observe_thread_proc("/proc/%d/status", thread_id); + observe_thread_proc("/proc/%d/syscall", thread_id); + observe_thread_proc("/proc/%d/stack", thread_id); + trace_observe_thread_end(msg); +} + +#else +static void observe_thread(const char *msg, pid_t thread_id) +{ +} + +#endif /* DEBUG_FAULT_PROCESS_STATUS */ + +static int get_mem_fault_cpu_index(pid_t pid) { CPUState *cpu_iter; =20 @@ -421,9 +505,20 @@ static int get_mem_fault_cpu_index(uint32_t pid) return cpu_iter->cpu_index; } trace_get_mem_fault_cpu_index(pid); + observe_thread("not a vCPU", pid); + return -1; } =20 +static void observe_vcpu_state(void) +{ + CPUState *cpu_iter; + CPU_FOREACH(cpu_iter) { + observe_thread("vCPU", cpu_iter->thread_id); + trace_vcpu_state(cpu_iter->running, cpu_iter->cpu_index); + } +} + /* * Handle faults detected by the USERFAULT markings */ @@ -465,6 +560,7 @@ static void *postcopy_ram_fault_thread(void *opaque) } =20 ret =3D read(mis->userfault_fd, &msg, sizeof(msg)); + observe_vcpu_state(); if (ret !=3D sizeof(msg)) { if (errno =3D=3D EAGAIN) { /* diff --git a/migration/trace-events b/migration/trace-events index ab2e1e4..3a74f91 100644 --- a/migration/trace-events +++ b/migration/trace-events @@ -202,6 +202,12 @@ save_xbzrle_page_overflow(void) "" ram_save_iterate_big_wait(uint64_t milliconds, int iterations) "big wait: = %" PRIu64 " milliseconds, %d iterations" ram_load_complete(int ret, uint64_t seq_iter) "exit_code %d seq iteration = %" PRIu64 get_mem_fault_cpu_index(uint32_t pid) "pid %u is not vCPU" +observe_thread_status(int ptid, char *name, char *status) "host_tid %d %s = %s" +vcpu_state(int cpu_index, int is_running) "cpu %d running %d" +proc_line_cb(const char *str) "%s" +get_proc_file(const char *str) "opened %s" +observe_thread_begin(const char *str) "%s" +observe_thread_end(const char *str) "%s" =20 # migration/exec.c migration_exec_outgoing(const char *cmd) "cmd=3D%s" --=20 1.8.3.1