From patchwork Fri Jun 16 19:11:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Perevalov X-Patchwork-Id: 9793423 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 ABE1060231 for ; Fri, 16 Jun 2017 19:18:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9A0C42841D for ; Fri, 16 Jun 2017 19:18:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8D7A528558; Fri, 16 Jun 2017 19:18:07 +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 09E882841D for ; Fri, 16 Jun 2017 19:18:07 +0000 (UTC) Received: from localhost ([::1]:60473 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dLwkw-0002wD-7c for patchwork-qemu-devel@patchwork.kernel.org; Fri, 16 Jun 2017 15:18:06 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49650) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dLwfW-0007BH-Su for qemu-devel@nongnu.org; Fri, 16 Jun 2017 15:12:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dLwfS-0007R8-2e for qemu-devel@nongnu.org; Fri, 16 Jun 2017 15:12:30 -0400 Received: from mailout3.w1.samsung.com ([210.118.77.13]:56702) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dLwfR-0007Pu-Ph for qemu-devel@nongnu.org; Fri, 16 Jun 2017 15:12:26 -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 <0ORN00H2IMOMKE50@mailout3.w1.samsung.com> for qemu-devel@nongnu.org; Fri, 16 Jun 2017 20:12:22 +0100 (BST) Received: from eusmges3.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20170616191221eucas1p237be2f7347bd684fc52ab4f288251801~Ir-SoU-yw3191631916eucas1p2U; Fri, 16 Jun 2017 19:12:21 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges3.samsung.com (EUCPMTA) with SMTP id 1D.68.17464.59D24495; Fri, 16 Jun 2017 20:12:21 +0100 (BST) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20170616191220eucas1p2ac6347288c68b20113882eaa38f34d5f~Ir-SDd2Xh3070630706eucas1p2J; Fri, 16 Jun 2017 19:12:20 +0000 (GMT) X-AuditID: cbfec7f2-f797e6d000004438-f8-59442d951151 Received: from eusync1.samsung.com ( [203.254.199.211]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id D7.D5.20206.49D24495; Fri, 16 Jun 2017 20:12:20 +0100 (BST) Received: from aperevalov-ubuntu.rnd.samsung.ru ([106.109.129.199]) by eusync1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0ORN00K65MO9DC10@eusync1.samsung.com>; Fri, 16 Jun 2017 20:12:20 +0100 (BST) From: Alexey Perevalov To: qemu-devel@nongnu.org Date: Fri, 16 Jun 2017 22:11:59 +0300 Message-id: <1497640325-10960-3-git-send-email-a.perevalov@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1497640325-10960-1-git-send-email-a.perevalov@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrJIsWRmVeSWpSXmKPExsWy7djPc7pTdV0iDa72cVvMvXuexaJ32z12 iyvtP9kttuz/xm5xvHcHi8WdLX1MDmweT65tZvJ4v+8qm0ffllWMAcxRXDYpqTmZZalF+nYJ XBlbjzsXvJWvaJ+zibWBcZ5kFyMnh4SAicSnG/tZIGwxiQv31rOB2EICSxkltq2S6GLkArI/ M0o8fb2FCabh5bxDjBBFyxglnh10gijqZpL4+vsHUBEHB5uAgcS+e7YgNSICkhK/u04zg9Qw C7QySrT3PWIGSQgLJEicaH0KNpRFQFXi3oV37CA2r4C7xKUnzewQy+QkTh6bzAoyk1PAQ+L4 Jj+QORIC99kkftydxAgSlxCQldh0gBmi3EXi8YbJjBC2sMSr41ugxshIXJ7czQLR284o0b2z kxXCmcAocWb6X6gqe4lTN6+CHcQswCcxadt0ZogFvBIdbUIQJR4SvefvQJU7SrRM/8wG8fxs RomlMzewT2CUWcDIsIpRJLW0ODc9tdhYrzgxt7g0L10vOT93EyMwQk//O/5pB+PXE1aHGAU4 GJV4eBluO0cKsSaWFVfmHmKU4GBWEuG113GJFOJNSaysSi3Kjy8qzUktPsQozcGiJM7Ldepa hJBAemJJanZqakFqEUyWiYNTqoHRSFn5wc7vWXpT1ltIf7nF72+hmCARZpJ1/tx1c4+Q9et/ xsus2LXvSIFpgn/GUYkL216vl5y7VFpGWu/getmgowd62L3TvQ/J2/+tlzlTuUnR/YDAn3cp 3998mW51bd6S8OCSE5bMEZEbpx2rjA504pzvIKzjzWi899Kb4w+uZt7mmrx0fe8XJZbijERD Leai4kQA8Y+WGswCAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrOLMWRmVeSWpSXmKPExsVy+t/xy7pTdF0iDTY3K1vMvXuexaJ32z12 iyvtP9kttuz/xm5xvHcHi8WdLX1MDmweT65tZvJ4v+8qm0ffllWMAcxRbjYZqYkpqUUKqXnJ +SmZeem2SqEhbroWSgp5ibmptkoRur4hQUoKZYk5pUCekQEacHAOcA9W0rdLcMvYety54K18 RfucTawNjPMkuxg5OSQETCRezjvECGGLSVy4t56ti5GLQ0hgCaPE4QOrWEASQgK9TBKdb527 GDk42AQMJPbdswUJiwhISvzuOs0MUs8s0Moo8aRxFjtIjbBAgsTz7hqQGhYBVYl7F96xg9i8 Au4Sl540s0PskpM4eWwyK0g5p4CHxPFNfhCb3CW2bNnBMoGRdwEjwypGkdTS4tz03GIjveLE 3OLSvHS95PzcTYzAQN127OeWHYxd74IPMQpwMCrx8EbedY4UYk0sK67MPcQowcGsJMJrr+MS KcSbklhZlVqUH19UmpNafIjRFOimicxSosn5wCjKK4k3NDE0tzQ0MrawMDcyUhLnnfrhSriQ QHpiSWp2ampBahFMHxMHp1QDo/PnjyotViHixsc22l9dvvv+Ov7cUyssr1xwm7fXLFP1r3Ku 6f/TdzY8/eJwr0Zz4r7lR/1S9i3lOMgfIHyZ/f4+xSzb0qb40A7TuYWHmO5O0nBUujpV/7qm xRZJo0ib4gDL1RWsX7d1dH1f09yXF/Xg+Ja3GVMiwri7/4twB9Z0Jfec8pbKUWIpzkg01GIu Kk4EAIYECM1qAgAA X-MTR: 20000000000000000@CPGS X-CMS-MailID: 20170616191220eucas1p2ac6347288c68b20113882eaa38f34d5f 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: 20170616191220eucas1p2ac6347288c68b20113882eaa38f34d5f X-RootMTR: 20170616191220eucas1p2ac6347288c68b20113882eaa38f34d5f References: <1497640325-10960-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 v9 2/8] 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, dgilbert@redhat.com, Alexey Perevalov , peterx@redhat.com, quintela@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 53fbd41..56929dc 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -591,6 +591,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(); @@ -637,7 +638,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 5d2b92d..35f3ffd 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; } @@ -678,7 +678,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 78a3591..77ea0fd 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 31158da..4c3b75e 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -1367,7 +1367,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; }