From patchwork Fri May 12 11:31:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Perevalov X-Patchwork-Id: 9723973 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 078C160348 for ; Fri, 12 May 2017 11:37:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 02688286D1 for ; Fri, 12 May 2017 11:37:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EAB3D286DC; Fri, 12 May 2017 11:37:12 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4F73D287BB for ; Fri, 12 May 2017 11:37:12 +0000 (UTC) Received: from localhost ([::1]:53007 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d98sh-0006Ik-Cw for patchwork-qemu-devel@patchwork.kernel.org; Fri, 12 May 2017 07:37:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57398) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d98oN-0003Yj-Or for qemu-devel@nongnu.org; Fri, 12 May 2017 07:32:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d98oK-0000uq-Ke for qemu-devel@nongnu.org; Fri, 12 May 2017 07:32:43 -0400 Received: from mailout2.w1.samsung.com ([210.118.77.12]:37410) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1d98oK-0000i2-F7 for qemu-devel@nongnu.org; Fri, 12 May 2017 07:32:40 -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 <0OPU00LMV81W6280@mailout2.w1.samsung.com> for qemu-devel@nongnu.org; Fri, 12 May 2017 12:32:20 +0100 (BST) Received: from eusmges1.samsung.com (unknown [203.254.199.239]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20170512113219eucas1p1b6b07064c3bc9332d7a2e3a57939deca~92IpN3Lcr3189431894eucas1p1k; Fri, 12 May 2017 11:32:19 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges1.samsung.com (EUCPMTA) with SMTP id 40.38.14140.64D95195; Fri, 12 May 2017 12:32:22 +0100 (BST) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20170512113219eucas1p1b48d524f95168b4e21e5fa0e81a107f7~92IonTkq13189931899eucas1p1U; Fri, 12 May 2017 11:32:19 +0000 (GMT) X-AuditID: cbfec7ef-f796a6d00000373c-c0-59159d469c84 Received: from eusync2.samsung.com ( [203.254.199.212]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 56.A1.20206.36D95195; Fri, 12 May 2017 12:32:51 +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 <0OPU0053K81CCS30@eusync2.samsung.com>; Fri, 12 May 2017 12:32:18 +0100 (BST) From: Alexey Perevalov To: qemu-devel@nongnu.org Date: Fri, 12 May 2017 14:31:36 +0300 Message-id: <1494588703-9076-3-git-send-email-a.perevalov@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1494588703-9076-1-git-send-email-a.perevalov@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrKIsWRmVeSWpSXmKPExsWy7djP87puc0UjDZ41ilvMvXuexaJ32z12 iyvtP9kttuz/xm5xvHcHiwOrx5Nrm5k83u+7yubRt2UVYwBzFJdNSmpOZllqkb5dAlfGw3va Bd9kKu6dWcrYwNgg3sXIySEhYCJxeNd+RghbTOLCvfVsXYxcHEICyxglWh4cZQVJCAl8ZpT4 eawApuHevVfMcEWXn91hgXC6mSR2HGsDaufgYBMwkNh3zxakQURAUuJ312lmEJtZIFbi7fVr YBuEBToZJS5uXw+2gUVAVWLTxB6wXl4BN4n+7ykQy+QkTh6bDFbCKeAu8WHNckaQXgmBy2wS 69qWMoHUSwjISmw6wAxR7yKxZuJXFghbWOLV8S3sELaMxOXJ3SwQve2MEt07O1khnAmMEmem /4Wqspc4dfMqE8SlfBKTtk1nhljAK9HRJgRR4iHR9/cSVLmjxNn/rdCQmMUosbx5PdsERpkF jAyrGEVSS4tz01OLDfWKE3OLS/PS9ZLzczcxAiPz9L/j73cwPm0OOcQowMGoxMMrUSUSKcSa WFZcmXuIUYKDWUmEd0W8aKQQb0piZVVqUX58UWlOavEhRmkOFiVxXt5T1yKEBNITS1KzU1ML UotgskwcnFINjKwv4m4tb7px/rrx472q33hMt9+en2VlNqPqSlR205l/Od3yE4J/F6emH2+Q +p9dc+ZDraPQlompEpaRUk2upSpTE94teWteGm9sbOvw3GzSkpeGR+VktgRzcm3pWnpVhI1z 7laHX2mK//sSrO3XpO5rDeTWOTslSP+X1zLtO9wmfYpCXZ0lSizFGYmGWsxFxYkAKtQEsMgC AAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrMLMWRmVeSWpSXmKPExsVy+t/xK7rJc0UjDX7MYbeYe/c8i0Xvtnvs Flfaf7JbbNn/jd3ieO8OFgdWjyfXNjN5vN93lc2jb8sqxgDmKDebjNTElNQihdS85PyUzLx0 W6XQEDddCyWFvMTcVFulCF3fkCAlhbLEnFIgz8gADTg4B7gHK+nbJbhlPLynXfBNpuLemaWM DYwN4l2MnBwSAiYS9+69YoawxSQu3FvP1sXIxSEksIRR4ufmK0wQTi+TxJ7LZ4AcDg42AQOJ ffdsQRpEBCQlfnedBmtmFoiVuDThBVizsEAno8TF7etZQRIsAqoSmyb2sIH08gq4SfR/T4FY Jidx8thksBJOAXeJD2uWM4KUCAGVzP0XO4GRdwEjwypGkdTS4tz03GIjveLE3OLSvHS95Pzc TYzAAN127OeWHYxd74IPMQpwMCrx8EpUiUQKsSaWFVfmHmKU4GBWEuFdES8aKcSbklhZlVqU H19UmpNafIjRFOikicxSosn5wOjJK4k3NDE0tzQ0MrawMDcyUhLnnfrhSriQQHpiSWp2ampB ahFMHxMHp1QDI8+GvyYXNjoxLNf88WIt19prvu3qF2187Pf6mJxbeGRuU4og2+Hjb7X/eFhW a+gLCzJ2CRy6WPlv8dTopesLXp5uvD55xgNfs5qFP5U/RtVsf+dzgiVupdvrLxtT/iXqKWXv vOdfrHpvVYVucc8J8f7JUx2q5KQfyT278ztqraZtk83nR7McipVYijMSDbWYi4oTAYZ1Cwtm AgAA X-MTR: 20000000000000000@CPGS X-CMS-MailID: 20170512113219eucas1p1b48d524f95168b4e21e5fa0e81a107f7 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: 20170512113219eucas1p1b48d524f95168b4e21e5fa0e81a107f7 X-RootMTR: 20170512113219eucas1p1b48d524f95168b4e21e5fa0e81a107f7 References: <1494588703-9076-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 V4 2/9] migration: pass ptr to MigrationIncomingState into migration ufd_version_check & postcopy_ram_supported_by_host 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, dgilbert@redhat.com, peterx@redhat.com, a.perevalov@samsung.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP That tiny refactoring is necessary to be able to set UFFD_FEATURE_THREAD_ID while requesting features, and then to create downtime context in case when kernel supports it. Signed-off-by: Alexey Perevalov --- migration/migration.c | 2 +- migration/postcopy-ram.c | 10 +++++----- migration/postcopy-ram.h | 2 +- migration/savevm.c | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 799952c..1cce2a1 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -804,7 +804,7 @@ void qmp_migrate_set_capabilities(MigrationCapabilityStatusList *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 cdadaf6..fbccc53 100644 --- a/migration/postcopy-ram.c +++ b/migration/postcopy-ram.c @@ -59,7 +59,7 @@ struct PostcopyDiscardState { #include #include -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; @@ -112,7 +112,7 @@ static int test_range_shared(const char *block_name, void *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 = getpagesize(); int ufd = -1; @@ -135,7 +135,7 @@ bool postcopy_ram_supported_by_host(void) } /* Version and features check */ - if (!ufd_version_check(ufd)) { + if (!ufd_version_check(ufd, mis)) { goto out; } @@ -512,7 +512,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; } @@ -650,7 +650,7 @@ void *postcopy_get_tmp_page(MigrationIncomingState *mis) #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/postcopy-ram.h b/migration/postcopy-ram.h index 4c25f03..848595f 100644 --- a/migration/postcopy-ram.h +++ b/migration/postcopy-ram.h @@ -14,7 +14,7 @@ #define QEMU_POSTCOPY_RAM_H /* 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); /* * Make all of RAM sensitive to accesses to areas that haven't yet been written diff --git a/migration/savevm.c b/migration/savevm.c index 352a8f2..28b3499 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -1356,7 +1356,7 @@ static int loadvm_postcopy_handle_advise(MigrationIncomingState *mis) return -1; } - if (!postcopy_ram_supported_by_host()) { + if (!postcopy_ram_supported_by_host(mis)) { postcopy_state_set(POSTCOPY_INCOMING_NONE); return -1; }