From patchwork Fri May 12 13:31:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Perevalov X-Patchwork-Id: 9724193 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 A640560382 for ; Fri, 12 May 2017 13:38:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9D9F0286B6 for ; Fri, 12 May 2017 13:38:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8EC9228776; Fri, 12 May 2017 13:38:14 +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 1AFCA286B6 for ; Fri, 12 May 2017 13:38:12 +0000 (UTC) Received: from localhost ([::1]:53856 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d9Aln-0001bM-O8 for patchwork-qemu-devel@patchwork.kernel.org; Fri, 12 May 2017 09:38:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57673) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d9Afi-0005Nz-OV for qemu-devel@nongnu.org; Fri, 12 May 2017 09:31:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d9Afd-00071r-NT for qemu-devel@nongnu.org; Fri, 12 May 2017 09:31:54 -0400 Received: from mailout4.w1.samsung.com ([210.118.77.14]:56136) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1d9Afd-000716-E3 for qemu-devel@nongnu.org; Fri, 12 May 2017 09:31:49 -0400 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout4.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0OPU00BRGDKX2U00@mailout4.w1.samsung.com> for qemu-devel@nongnu.org; Fri, 12 May 2017 14:31:46 +0100 (BST) Received: from eusmges4.samsung.com (unknown [203.254.199.244]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20170512133145eucas1p2f7b77d7873a758db67d20666087cccca~93w60tkf71102611026eucas1p2z; Fri, 12 May 2017 13:31:45 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges4.samsung.com (EUCPMTA) with SMTP id 43.3D.04729.149B5195; Fri, 12 May 2017 14:31:45 +0100 (BST) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20170512133144eucas1p25b4275feb4126a21415242c5085382fd~93w6Mx7tF1102711027eucas1p2w; Fri, 12 May 2017 13:31:44 +0000 (GMT) X-AuditID: cbfec7f4-f79806d000001279-97-5915b9413258 Received: from eusync1.samsung.com ( [203.254.199.211]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 6E.71.20206.069B5195; Fri, 12 May 2017 14:32:16 +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 <0OPU00791DKM5L30@eusync1.samsung.com>; Fri, 12 May 2017 14:31:44 +0100 (BST) From: Alexey Perevalov To: qemu-devel@nongnu.org Date: Fri, 12 May 2017 16:31:19 +0300 Message-id: <1494595886-30912-3-git-send-email-a.perevalov@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1494595886-30912-1-git-send-email-a.perevalov@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrMIsWRmVeSWpSXmKPExsWy7djP87qOO0UjDc41ilnMvXuexaJ32z12 iyvtP9kttuz/xm5xvHcHiwOrx5Nrm5k83u+7yubRt2UVYwBzFJdNSmpOZllqkb5dAlfGq30P mQq2yFbcfKzSwLhMvIuRk0NCwETi2NZWFghbTOLCvfVsXYxcHEICSxklfu16zwjhfGaUmPHv OytMx/zNN5kgEssYJXY8nAPV0s0ksXjNTPYuRg4ONgEDiX33bEEaRAQkJX53nWYGsZkFYiXe Xr/GBmILC3QySqz/5gFiswioSixbuYcFpJVXwF1iYXsIxC45iZPHJoPt5RTwkHh89xYryCoJ getsElePTmcCqZcQkJXYdIAZot5FYv2h80wQtrDEq+Nb2CFsGYnLk7tZIHrbGSW6d3ZCDZrA KHFm+l+oKnuJUzevMkEcyicxadt0ZogFvBIdbUIQJR4SDbMeQ+11lNj7VA8kLCQwm1Fi8u/g CYwyCxgZVjGKpJYW56anFpvoFSfmFpfmpesl5+duYgRG5el/x7/sYFx8zOoQowAHoxIPb8V6 0Ugh1sSy4srcQ4wSHMxKIryGW4BCvCmJlVWpRfnxRaU5qcWHGKU5WJTEeblOXYsQEkhPLEnN Tk0tSC2CyTJxcEo1MMrp69fF26dnc5kw6FbaZRve0670+rf7fFBDCu9ZizdBmpw/rE63PhZ3 yTFweuLzasXWpa3OKRZi12ftWhKwzupy5ZZNZ/QOvpFqiVSuFj160PG6+f7vqscd+mYmFVhN eL38m4nt+xduV1gOObb6MH2tzhH2OWzEvWfd16e3OQqY2KecWSifq8RSnJFoqMVcVJwIAHJP /7LGAgAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrELMWRmVeSWpSXmKPExsVy+t/xy7oJO0UjDZZMM7GYe/c8i0Xvtnvs Flfaf7JbbNn/jd3ieO8OFgdWjyfXNjN5vN93lc2jb8sqxgDmKDebjNTElNQihdS85PyUzLx0 W6XQEDddCyWFvMTcVFulCF3fkCAlhbLEnFIgz8gADTg4B7gHK+nbJbhlvNr3kKlgi2zFzccq DYzLxLsYOTkkBEwk5m++yQRhi0lcuLeerYuRi0NIYAmjxJ/bk1lAEkICvUwS55aJdjFycLAJ GEjsu2cLEhYRkJT43XWaGcRmFoiVuDThBRuILSzQySix/psHiM0ioCqxbOUeFpBWXgF3iYXt IRCr5CROHpvMCmJzCnhIPL57ixVik7vEtoalbBMYeRcwMqxiFEktLc5Nzy020itOzC0uzUvX S87P3cQIDM9tx35u2cHY9S74EKMAB6MSD2/FetFIIdbEsuLK3EOMEhzMSiK8hluAQrwpiZVV qUX58UWlOanFhxhNgW6ayCwlmpwPjJ28knhDE0NzS0MjYwsLcyMjJXHeqR+uhAsJpCeWpGan phakFsH0MXFwSjUwOiwXWeT7b37Snb23Lr9iM326Qi/GonbTqr9vXRutzweuzT4Ws+znh+1n 7k7Jcvr0yFYx8uwK98nvlf6Ft4g9zdFS4+YVEUgWLDY7zmacuFf07XpDn69TNRIPX/qgZZSY 9XhDm+7K0OVPHy+c8zNCtJGNZfMkuZWt/NJ3Zup47PlTeXWn54z2V0osxRmJhlrMRcWJAGE1 3XFlAgAA X-MTR: 20000000000000000@CPGS X-CMS-MailID: 20170512133144eucas1p25b4275feb4126a21415242c5085382fd 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: 20170512133144eucas1p25b4275feb4126a21415242c5085382fd X-RootMTR: 20170512133144eucas1p25b4275feb4126a21415242c5085382fd References: <1494595886-30912-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 V5 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 --- include/migration/postcopy-ram.h | 2 +- migration/migration.c | 2 +- migration/postcopy-ram.c | 10 +++++----- migration/savevm.c | 2 +- 4 files changed, 8 insertions(+), 8 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 /* 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/migration.c b/migration/migration.c index 353f272..569a7f6 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 85fd8d7..4c859b4 100644 --- a/migration/postcopy-ram.c +++ b/migration/postcopy-ram.c @@ -60,7 +60,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; @@ -113,7 +113,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; @@ -136,7 +136,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; } @@ -513,7 +513,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; } @@ -651,7 +651,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/savevm.c b/migration/savevm.c index a00c1ab..27ab8b2 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -1360,7 +1360,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; }