From patchwork Wed Jun 7 07:35:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Perevalov X-Patchwork-Id: 9770745 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 4991960234 for ; Wed, 7 Jun 2017 07:39:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 33AFE22376 for ; Wed, 7 Jun 2017 07:39:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 26E3E28521; Wed, 7 Jun 2017 07:39:24 +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 E631A22376 for ; Wed, 7 Jun 2017 07:39:21 +0000 (UTC) Received: from localhost ([::1]:41658 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dIVYm-0005zC-I9 for patchwork-qemu-devel@patchwork.kernel.org; Wed, 07 Jun 2017 03:39:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54585) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dIVVi-00047x-Ct for qemu-devel@nongnu.org; Wed, 07 Jun 2017 03:36:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dIVVf-0000tF-4b for qemu-devel@nongnu.org; Wed, 07 Jun 2017 03:36:10 -0400 Received: from mailout1.w1.samsung.com ([210.118.77.11]:46926) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dIVVe-0000sK-Sa for qemu-devel@nongnu.org; Wed, 07 Jun 2017 03:36:07 -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 <0OR600FJD2G3VS80@mailout1.w1.samsung.com> for qemu-devel@nongnu.org; Wed, 07 Jun 2017 08:36:03 +0100 (BST) Received: from eusmges1.samsung.com (unknown [203.254.199.239]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20170607073602eucas1p178d201559efdfa419c1cc6643485bf12~Fxrw9_Ror2015320153eucas1p1L; Wed, 7 Jun 2017 07:36:02 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1.samsung.com (EUCPMTA) with SMTP id E3.61.14140.5ECA7395; Wed, 7 Jun 2017 08:36:05 +0100 (BST) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20170607073602eucas1p292a25ea3edab8ba8eab3ae95fa2519de~FxrwJjsTR0719407194eucas1p2G; Wed, 7 Jun 2017 07:36:02 +0000 (GMT) X-AuditID: cbfec7ef-f796a6d00000373c-d2-5937ace5a1f8 Received: from eusync4.samsung.com ( [203.254.199.214]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id C7.A5.17452.2ECA7395; Wed, 7 Jun 2017 08:36:02 +0100 (BST) Received: from aperevalov-ubuntu.rnd.samsung.ru ([106.109.129.199]) by eusync4.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0OR600HQN2FH4N90@eusync4.samsung.com>; Wed, 07 Jun 2017 08:36:02 +0100 (BST) From: Alexey Perevalov To: qemu-devel@nongnu.org Date: Wed, 07 Jun 2017 10:35:22 +0300 Message-id: <1496820931-27416-3-git-send-email-a.perevalov@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1496820931-27416-1-git-send-email-a.perevalov@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrOIsWRmVeSWpSXmKPExsWy7djPc7pP15hHGuyZKmAx9+55FovebffY La60/2S32LL/G7vF8d4dLA6sHk+ubWbyeL/vKptH35ZVjAHMUVw2Kak5mWWpRfp2CVwZp8// Yyt4LV+x5uovlgbGOZJdjJwcEgImEkuOTGaEsMUkLtxbz9bFyMUhJLCMUeJg81VWCOczo8Sc yx/YYTqWTrnBDFf1c80pqJZuJomLz98BtXBwsAkYSOy7ZwvSICIgKfG76zQziM0sUCDxsXUl C4gtLJAi8bzrBBOIzSKgKvHk9DqwGl4Bd4nmA6+hlslJnDw2mRXE5hTwkNj3YS0TyC4Jgets EmeWnGUE2SUhICux6QAzRL2LRM/2rVDvCEu8Or4Fao6MRGfHQajedkaJ7p2drBDOBEaJM9P/ QlXZS5y6eZUJ4lI+iUnbpjNDLOCV6GgTgijxkHi8YD3UMkeJj7uvQj0/m1Hi8K6L7BMYZRYw MqxiFEktLc5NTy021CtOzC0uzUvXS87P3cQIjM7T/46/38H4tDnkEKMAB6MSD2/GHrNIIdbE suLK3EOMEhzMSiK8l5aaRwrxpiRWVqUW5ccXleakFh9ilOZgURLn5T11LUJIID2xJDU7NbUg tQgmy8TBKdXAaLqnQNBxVr2izNXDjq4XJqdvsureor+1wWtS3tyzM5O6lNwm/5/XbdnPmrle YGb66x0/1wn84cm+fDfmY3DfgqMqKvvyF6zN3iV+73hUcs39Ro2zs+vPvDp3vuXlxipe0wY2 Fe25h85vn7HrxaVzfxwW+Ej8VTy8JrpK9G3P9x28UxxWfQt2FFViKc5INNRiLipOBAAXsCyE ygIAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrKLMWRmVeSWpSXmKPExsVy+t/xa7qP1phHGtzsZrGYe/c8i0Xvtnvs Flfaf7JbbNn/jd3ieO8OFgdWjyfXNjN5vN93lc2jb8sqxgDmKDebjNTElNQihdS85PyUzLx0 W6XQEDddCyWFvMTcVFulCF3fkCAlhbLEnFIgz8gADTg4B7gHK+nbJbhlnD7/j63gtXzFmqu/ WBoY50h2MXJySAiYSCydcoMZwhaTuHBvPVsXIxeHkMASRompW1+yQDi9TBJTv19n72Lk4GAT MJDYd88WpEFEQFLid9dpsGZmgQKJc5OnsIDYwgIpEs+7TjCB2CwCqhJPTq8Dq+EVcJdoPvCa HWKZnMTJY5NZQWxOAQ+JfR/WgtULAdXsPj2DbQIj7wJGhlWMIqmlxbnpucWGesWJucWleel6 yfm5mxiBQbrt2M/NOxgvbQw+xCjAwajEwyuwyyxSiDWxrLgy9xCjBAezkgjvpaXmkUK8KYmV ValF+fFFpTmpxYcYTYGOmsgsJZqcD4ygvJJ4QxNDc0tDI2MLC3MjIyVx3pIPV8KFBNITS1Kz U1MLUotg+pg4OKUaGJP7w2zTnYO5Ms49N9Hbv7Xvkx/zIinvnFsmj4Mnxzubf/JR3TKJ56zD Q/e/D4O5vLziTfadTzPMeT0xkWNZz6XtBw9/+Va6qfBK89yrnFvFkg/m118vbJKTCHLTif/W lLjvl8qipkOy639bne1hyQ5tPZHQ0R6/fdali9GH61kF9hzp/8A5WYmlOCPRUIu5qDgRAPCR 2BVoAgAA X-MTR: 20000000000000000@CPGS X-CMS-MailID: 20170607073602eucas1p292a25ea3edab8ba8eab3ae95fa2519de 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: 20170607073602eucas1p292a25ea3edab8ba8eab3ae95fa2519de X-RootMTR: 20170607073602eucas1p292a25ea3edab8ba8eab3ae95fa2519de References: <1496820931-27416-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 V7] 02/11] migration: pass MigrationIncomingState* into migration check functions 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, Alexey Perevalov , peterx@redhat.com, dgilbert@redhat.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 | 3 ++- migration/postcopy-ram.c | 10 +++++----- migration/postcopy-ram.h | 2 +- migration/savevm.c | 2 +- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 48c94c9..2a77636 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -726,6 +726,7 @@ void qmp_migrate_set_capabilities(MigrationCapabilityStatusList *params, Error **errp) { MigrationState *s = migrate_get_current(); + MigrationIncomingState *mis = migration_incoming_get_current(); MigrationCapabilityStatusList *cap; bool old_postcopy_cap = migrate_postcopy_ram(); @@ -772,7 +773,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(mis)) { /* 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 9c41887..10d39a0 100644 --- a/migration/postcopy-ram.c +++ b/migration/postcopy-ram.c @@ -63,7 +63,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; @@ -126,7 +126,7 @@ static int test_ramblock_postcopiable(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; @@ -149,7 +149,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; } @@ -525,7 +525,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; } @@ -663,7 +663,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 52d51e8..587a8b8 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 9c320f5..8b7bab8 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -1380,7 +1380,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; }