From nobody Fri May 17 03:00:48 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1681858732; cv=none; d=zohomail.com; s=zohoarc; b=eKsK+EryDvoD+2ab4OjBcOJejjhnF/SZOB/XAZ+HvfeUfBoHJc27dzwAkvWa1NVO15MvFff6nnsQLjpIWJq8XJzjMvgwS1ckIiBhyMhG1bWNOJFcuH246dwNHQ6FQdK6QThNn8RArmr89u6HRkWSVUzVtSdg4IyrdUzeWL6aXEI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681858732; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=x4L+QjbUgvxpJ4DIJDYUyZ6+HndeQMO+nRb8rfrhMnE=; b=fA9W6OrZO6dLYNvEjwWlq4x7bNOFYgtvek2QR4eTAXqvE3/rqAa+YhWMBjvzhWIIHLrRhI8rspE+gGYY25R6SSGSUv+A9/LBW/3MrBwAuHfqhnw2kekDsmniFuUBxLqEtMWDjAWbYNkP8/AsEMHP9DLz3/SroETlkHDCu6306cc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1681858732320441.4014535510038; Tue, 18 Apr 2023 15:58:52 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pouGw-0001Ju-9b; Tue, 18 Apr 2023 18:58:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pouGu-0001JZ-0W for qemu-devel@nongnu.org; Tue, 18 Apr 2023 18:58:00 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pouGr-0007Cd-HZ for qemu-devel@nongnu.org; Tue, 18 Apr 2023 18:57:59 -0400 Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-262-jUM82trFN225Y8W0EuUxng-1; Tue, 18 Apr 2023 18:57:54 -0400 Received: by mail-qv1-f70.google.com with SMTP id 6a1803df08f44-5ef4d54d84cso4323846d6.0 for ; Tue, 18 Apr 2023 15:57:54 -0700 (PDT) Received: from x1n.redhat.com (bras-base-aurron9127w-grc-40-70-52-229-124.dsl.bell.ca. [70.52.229.124]) by smtp.gmail.com with ESMTPSA id i3-20020ad45383000000b005e3c45c5cbdsm2937330qvv.96.2023.04.18.15.57.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Apr 2023 15:57:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1681858675; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=x4L+QjbUgvxpJ4DIJDYUyZ6+HndeQMO+nRb8rfrhMnE=; b=OWJZZ+/o/L7+W3B7mcpg5RxI3DI1NbQTM1KILJI6rE4sV7kq+RmFshWiMkPToSyvj/Bfn9 12Lt/aMgsu9ykTxSNPeEuqD5cc6Lz4Gy2Mmntz6iWIzMAko9uDz0da8WTQW6TvQsg0pz1L q3PF99cQt2RW8PcU/qO2YXrZi1G98A8= X-MC-Unique: jUM82trFN225Y8W0EuUxng-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681858673; x=1684450673; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=x4L+QjbUgvxpJ4DIJDYUyZ6+HndeQMO+nRb8rfrhMnE=; b=VLgL8R+N95zF+iAGO1k4HY/NvvFrCVVzQglBWL5EiH9Gj2ID8Pr+k1/4tb8+yxfxP1 l9dSYxKp8Tjqb9JoR4W2l6Us26yIA5sWI+G2TKy/uQgPirm6h9whT1ixKzwLG9ZXMzdA iuUSYwrq/M9ahos+cXFYOdwgO30/6zxwDIdv+pQziO9kVt1m+6dz/IP8TuRTD4Ri2s8v LACZHC0kcE2k2qPKEGHaSFtLWSabC5bsNWNf8RfUjl+Jjb+MbM4MuYYwXqfE/y1OgArE WLdpxPg64PK0gjk1NklFJ6aljnEW5LIttrnw1rybWqxXwZyQEe7PhQDGYVkilhDPzPbA en/A== X-Gm-Message-State: AAQBX9cM30xgvcpy9L+lvZzaxe612LM45Mz7dn2SN6Qcrg+MC4U1EqVL SewLLdD4eKC9Q4UCgplvifhwR5mMXdw6/IImgW4UkWkyw443DZzQqtOiyj/xqfFHkAv6LyJWRiX pIrYNay3syACIemuzgz2QaR18wCy+CWVhSmFXI7EpYRHEFKVUEViPNQjBV6sLziZLahEPB+JO X-Received: by 2002:a05:6214:400e:b0:5ef:4436:b92e with SMTP id kd14-20020a056214400e00b005ef4436b92emr23260682qvb.5.1681858673514; Tue, 18 Apr 2023 15:57:53 -0700 (PDT) X-Google-Smtp-Source: AKy350a2hXbPYqmGmzNmfrdkTGXs5BS0yd3kukch2d1tymdkgmaM9kkLJL8J9+X6Zly96XjBoIiMag== X-Received: by 2002:a05:6214:400e:b0:5ef:4436:b92e with SMTP id kd14-20020a056214400e00b005ef4436b92emr23260658qvb.5.1681858673129; Tue, 18 Apr 2023 15:57:53 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: David Hildenbrand , Paolo Bonzini , Juan Quintela , Leonardo Bras Soares Passos , peterx@redhat.com Subject: [PATCH 1/3] hostmem: Detect and cache fs type for file hostmem Date: Tue, 18 Apr 2023 18:57:47 -0400 Message-Id: <20230418225749.1049185-2-peterx@redhat.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230418225749.1049185-1-peterx@redhat.com> References: <20230418225749.1049185-1-peterx@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1681858733834100005 Content-Type: text/plain; charset="utf-8" Detect the file system for a memory-backend-file object and cache it within the object if possible when CONFIG_LINUX (using statfs). Only support the two important types of memory (tmpfs, hugetlbfs) and keep the rest as "unknown" for now. Signed-off-by: Peter Xu --- backends/hostmem-file.c | 37 ++++++++++++++++++++++++++++++++++++- include/sysemu/hostmem.h | 1 + 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/backends/hostmem-file.c b/backends/hostmem-file.c index 25141283c4..2484e45a11 100644 --- a/backends/hostmem-file.c +++ b/backends/hostmem-file.c @@ -18,13 +18,17 @@ #include "sysemu/hostmem.h" #include "qom/object_interfaces.h" #include "qom/object.h" +#ifdef CONFIG_LINUX +#include +#include +#endif =20 OBJECT_DECLARE_SIMPLE_TYPE(HostMemoryBackendFile, MEMORY_BACKEND_FILE) =20 =20 struct HostMemoryBackendFile { HostMemoryBackend parent_obj; - + __fsword_t fs_type; char *mem_path; uint64_t align; bool discard_data; @@ -52,6 +56,15 @@ file_backend_memory_alloc(HostMemoryBackend *backend, Er= ror **errp) return; } =20 +#ifdef CONFIG_LINUX + struct statfs fs; + if (!statfs(fb->mem_path, &fs)) { + fb->fs_type =3D fs.f_type; + } else { + fb->fs_type =3D 0; + } +#endif + name =3D host_memory_backend_get_name(backend); ram_flags =3D backend->share ? RAM_SHARED : 0; ram_flags |=3D backend->reserve ? 0 : RAM_NORESERVE; @@ -181,6 +194,28 @@ static void file_backend_unparent(Object *obj) } } =20 +const char *file_memory_backend_get_fs_type(Object *obj) +{ +#ifdef CONFIG_LINUX + HostMemoryBackendFile *fb =3D (HostMemoryBackendFile *) + object_dynamic_cast(obj, TYPE_MEMORY_BACKEND_FILE); + + if (!fb) { + goto out; + } + + switch (fb->fs_type) { + case TMPFS_MAGIC: + return "tmpfs"; + case HUGETLBFS_MAGIC: + return "hugetlbfs"; + } + +out: +#endif + return "unknown"; +} + static void file_backend_class_init(ObjectClass *oc, void *data) { diff --git a/include/sysemu/hostmem.h b/include/sysemu/hostmem.h index 39326f1d4f..0354cffa6b 100644 --- a/include/sysemu/hostmem.h +++ b/include/sysemu/hostmem.h @@ -81,5 +81,6 @@ void host_memory_backend_set_mapped(HostMemoryBackend *ba= ckend, bool mapped); bool host_memory_backend_is_mapped(HostMemoryBackend *backend); size_t host_memory_backend_pagesize(HostMemoryBackend *memdev); char *host_memory_backend_get_name(HostMemoryBackend *backend); +const char *file_memory_backend_get_fs_type(Object *obj); =20 #endif --=20 2.39.1 From nobody Fri May 17 03:00:48 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1681858732; cv=none; d=zohomail.com; s=zohoarc; b=fNSpVS00iVm+sUs2H3zOFU6oBzHgLDRauE4kn3maoGUDBehX7qiSZBZu49pAABwSHzxVtnnZXaq3EQmNa8XMY+FimDkzBTYFKssm38OH3kkfroW+GYpEHroYz0U9L/c9dHG7GM8LRcpGqXOv/hcNaG5etPgAOJwHvXHR6al4l5g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681858732; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=fgVm4ot3oncYZxZF5RHIGcFRboA9mEQIrrDpxafvVz0=; b=TMLc/G3F1Ktj27pIXW8BOJ+bKw7oC/gSLm6XKxvUhEDeRi4np+Tow99hBH/nuNzw1drbcXN6gkSf/H3uhtGCZo6cKNAb8wFF0U+LTpOvJY3Rd/xHIF0vuo8HCKubpacJqjFzA+ipwfpS80w4p5c5ReYUag29To12lV/ENGHFh4I= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1681858732327929.0414979740825; Tue, 18 Apr 2023 15:58:52 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pouGz-0001L1-53; Tue, 18 Apr 2023 18:58:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pouGx-0001Kn-IA for qemu-devel@nongnu.org; Tue, 18 Apr 2023 18:58:03 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pouGt-0007D4-Oy for qemu-devel@nongnu.org; Tue, 18 Apr 2023 18:58:00 -0400 Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-222-R6gU-5kEOYimXzL2UihADQ-1; Tue, 18 Apr 2023 18:57:57 -0400 Received: by mail-qk1-f200.google.com with SMTP id af79cd13be357-74d96c33de9so67622985a.1 for ; Tue, 18 Apr 2023 15:57:57 -0700 (PDT) Received: from x1n.redhat.com (bras-base-aurron9127w-grc-40-70-52-229-124.dsl.bell.ca. [70.52.229.124]) by smtp.gmail.com with ESMTPSA id i3-20020ad45383000000b005e3c45c5cbdsm2937330qvv.96.2023.04.18.15.57.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Apr 2023 15:57:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1681858678; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fgVm4ot3oncYZxZF5RHIGcFRboA9mEQIrrDpxafvVz0=; b=BVnvwSmtMovaD9Cnuvbsv2aQYPFHcRrefL8w3w3xddVHsfjtkHEjTl0F3IGqq3LrkpoBLG kDTCyjvTYF1aiNX6FAaauKjZmP+/4kdDxXCA2II20fgTjd7dbfLMftULFDYpTi6b1poSzL jMDGXCX8ELE19Ymz+T3uJppOl4MYITQ= X-MC-Unique: R6gU-5kEOYimXzL2UihADQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681858676; x=1684450676; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fgVm4ot3oncYZxZF5RHIGcFRboA9mEQIrrDpxafvVz0=; b=JSnClTabpeJu8lFyrOESTq+xRm10kOVNctzsfXyXgvdgnupDTKBjR8P6laILHXAlqg YMm2+TKNGl3EUvP2JAVITEFEjxXLLgQ4cHgctflKHQzb3MNr/x/Et5UpFDqcWvKgUPkj RyTx79UEoV6FkWrmH7z6X37oopO1xl8+K1yLf9jF2WmJrCp2OIYulGd6ejgNPr0UNBcd E5vV6p4ges+FN8UCwJEw3Ggmz4me/zVAFzhz3IxOOWEqWas56ow8XjKZf85+QyhRiIQN oRNLx3MbYJMQXNuKmM5iTuQmGCVpowfDIZAnVusTfK/vMfY8rO2nHtwZHG5Z74b8Xvp1 cckw== X-Gm-Message-State: AAQBX9f9al/gyZkwP+PDaQI+1OSwFx1Ixd2ecRVhW1uZPDtr2M+ewmLX uOrkoGW5v2sLMs11ZyUWaZlvE7OLzzipF8lOYySkhJPFDmU3/5+Tp0XbJdkDrdzj/hPOrU4E8Dy Bvlh6unls7OxMXOYXLGH/76QAIp8t3XkQu7TaA3+vD6uTAWgXWpNl6APFDtu/+EWVm+XYd7My X-Received: by 2002:ad4:5ba7:0:b0:5f1:31eb:1f0e with SMTP id 7-20020ad45ba7000000b005f131eb1f0emr5582350qvq.4.1681858676399; Tue, 18 Apr 2023 15:57:56 -0700 (PDT) X-Google-Smtp-Source: AKy350auUMFdrAi5+6gfwcvPdZGSD3TlaosH9IapNsxk2moQGdaRYGk5acR/OzdU/3PzZ/Yzyt4ysw== X-Received: by 2002:ad4:5ba7:0:b0:5f1:31eb:1f0e with SMTP id 7-20020ad45ba7000000b005f131eb1f0emr5582324qvq.4.1681858676139; Tue, 18 Apr 2023 15:57:56 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: David Hildenbrand , Paolo Bonzini , Juan Quintela , Leonardo Bras Soares Passos , peterx@redhat.com Subject: [PATCH 2/3] vl.c: Create late backends before migration object Date: Tue, 18 Apr 2023 18:57:48 -0400 Message-Id: <20230418225749.1049185-3-peterx@redhat.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230418225749.1049185-1-peterx@redhat.com> References: <20230418225749.1049185-1-peterx@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1681858734575100010 Content-Type: text/plain; charset="utf-8" The migration object may want to check against different types of memory when initialized. Delay the creation to be after late backends. Signed-off-by: Peter Xu --- softmmu/vl.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/softmmu/vl.c b/softmmu/vl.c index ea20b23e4c..ad394b402f 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -3583,14 +3583,19 @@ void qemu_init(int argc, char **argv) machine_class->name, machine_class->deprecation_reaso= n); } =20 + /* + * Create backends before creating migration objects, so that it can + * check against compatibilities on the backend memories (e.g. postcopy + * over memory-backend-file objects). + */ + qemu_create_late_backends(); + /* * Note: creates a QOM object, must run only after global and * compat properties have been set up. */ migration_object_init(); =20 - qemu_create_late_backends(); - /* parse features once if machine provides default cpu_type */ current_machine->cpu_type =3D machine_class->default_cpu_type; if (cpu_option) { --=20 2.39.1 From nobody Fri May 17 03:00:48 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1681858750; cv=none; d=zohomail.com; s=zohoarc; b=TAZJKelLMoGBdHHiISLyUrRI73IcCk9YVY5zefFEv9exuwDkUMdk9pE+uRBFeJyTYBL/PGhYqM/tI84tnOe1Gut9DxKrniXvCXaZO7Na03Yu4v4XRP4d+pm5e/2nIH0LQVUan+yUMmyCpFiTMklHHqS/QbwQiW+g2PCUSDcDwmk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681858750; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=tfe7wWvJEqhWrw/5dRu9ujTZ7gYvhKG5iAivwThgjSw=; b=RKDPZjllnSNKmpTufy/lQVnoLA6OSYz+oh/WT9r7sMyQODIE+pGb95ILP309CBR5220aKqz9HtRx2Ozf7oKFx+YfyO00Yk8NvcEskKzta0GY+z5gRKSz0BmfmoLN9O3LX1QY9F6DYYveqIEWMoN4qGLbwjyP8xfUObA0nvtSD/A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 168185875056663.16228065265955; Tue, 18 Apr 2023 15:59:10 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pouH0-0001Lk-Lv; Tue, 18 Apr 2023 18:58:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pouGz-0001LP-Qa for qemu-devel@nongnu.org; Tue, 18 Apr 2023 18:58:05 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pouGx-0007Fa-Fm for qemu-devel@nongnu.org; Tue, 18 Apr 2023 18:58:05 -0400 Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-367-UxbQrX1QNw6mxHvCDHLYRw-1; Tue, 18 Apr 2023 18:58:00 -0400 Received: by mail-qt1-f198.google.com with SMTP id d75a77b69052e-3ecc0c4b867so10996321cf.1 for ; Tue, 18 Apr 2023 15:58:00 -0700 (PDT) Received: from x1n.redhat.com (bras-base-aurron9127w-grc-40-70-52-229-124.dsl.bell.ca. [70.52.229.124]) by smtp.gmail.com with ESMTPSA id i3-20020ad45383000000b005e3c45c5cbdsm2937330qvv.96.2023.04.18.15.57.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Apr 2023 15:57:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1681858681; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tfe7wWvJEqhWrw/5dRu9ujTZ7gYvhKG5iAivwThgjSw=; b=XBO//NrxUQBBaXDfBI4i+rNK6J5lit7kccIx4g8LzbjNRLWQBISW57ebXX4ks/Jk0GG6VP 6Ef9hG9CbqAw8mZajb+PkmXIuqq9fIBBzqh+fujQZLFkw1oe64gE8e3WQAKHpk+PyoLc40 T7Fv2FmcnIz1hAJCd5ub33F3Jy7fZ/k= X-MC-Unique: UxbQrX1QNw6mxHvCDHLYRw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681858679; x=1684450679; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tfe7wWvJEqhWrw/5dRu9ujTZ7gYvhKG5iAivwThgjSw=; b=TCQYvCpuuhTe4whqhUeJUKF+jjdGUSdNGaIVcgIbzvzhv+cVGOKBtxgvqaFKm+/Icw ax5w6yYnH4mMLbNkD3XmmsI4dw6Tb7Uue9/y20EfpJUAqNXtlqI58MsMon31NfFYYfkD P0+Te7WICI8riUVykFN0MS7HE/r9SkA78jNIe7BDMe6r+KNJouE+4zvPh5F6oJZPRwWz WWDlRzuUnCgRm/0LMRjsMx4W38nXLQ9izW4bOcH6maOdH+JOZqJalL6DiPVLua0qSi81 yQw/0F4tEPpjrFPo6uFApfafjSV9kqrLuEbmxcbqeXW/S1rzObOEOAFn3mNVuQ6J9Urt V9aQ== X-Gm-Message-State: AAQBX9cBXgAS1fYWQdUSHNX6g6RfQx6eOu35kgb+nvE3zAJYryHW8MH/ MXAd5mloUqi/+PLGQyJpppWKHY+axPfJkOrJGZoBgpygMxaFKU0aJ9ypcW56zChcoWcgbiAn6nO L4pRCs82vmBS/mNNuzTD74WNCyT2qWf/g2KNgnjJo7bkisSPQFwg969yCRInLYMO06oo9sdRp X-Received: by 2002:a05:6214:4109:b0:5ac:325c:a28f with SMTP id kc9-20020a056214410900b005ac325ca28fmr24495318qvb.0.1681858678874; Tue, 18 Apr 2023 15:57:58 -0700 (PDT) X-Google-Smtp-Source: AKy350YbmefXg08bW7IlGKeN6+wqj0iqJYaBModnTRW4SR6IGgYBYK1+7TcLdhQcBOoU3zLzRMaFKQ== X-Received: by 2002:a05:6214:4109:b0:5ac:325c:a28f with SMTP id kc9-20020a056214410900b005ac325ca28fmr24495291qvb.0.1681858678508; Tue, 18 Apr 2023 15:57:58 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: David Hildenbrand , Paolo Bonzini , Juan Quintela , Leonardo Bras Soares Passos , peterx@redhat.com Subject: [PATCH 3/3] migration/postcopy: Detect file system on dest host Date: Tue, 18 Apr 2023 18:57:49 -0400 Message-Id: <20230418225749.1049185-4-peterx@redhat.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230418225749.1049185-1-peterx@redhat.com> References: <20230418225749.1049185-1-peterx@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1681858751249100002 Content-Type: text/plain; charset="utf-8" Postcopy requires the memory support userfaultfd to work. Right now we check it but it's a bit too late (when switching to postcopy migration). Do that early right at enabling of postcopy. Note that this is still only a best effort because ramblocks can be dynamically created. We can add check in hostmem creations and fail if postcopy enabled, but maybe that's too aggressive. Still, we have chance to fail the most obvious where we know there's an existing unsupported ramblock. Signed-off-by: Peter Xu --- migration/postcopy-ram.c | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c index 93f39f8e06..560530b758 100644 --- a/migration/postcopy-ram.c +++ b/migration/postcopy-ram.c @@ -336,11 +336,12 @@ static bool ufd_check_and_apply(int ufd, MigrationInc= omingState *mis) =20 /* Callback from postcopy_ram_supported_by_host block iterator. */ -static int test_ramblock_postcopiable(RAMBlock *rb, void *opaque) +static int test_ramblock_postcopiable(RAMBlock *rb) { const char *block_name =3D qemu_ram_get_idstr(rb); ram_addr_t length =3D qemu_ram_get_used_length(rb); size_t pagesize =3D qemu_ram_pagesize(rb); + const char *fs; =20 if (length % pagesize) { error_report("Postcopy requires RAM blocks to be a page size multi= ple," @@ -348,6 +349,15 @@ static int test_ramblock_postcopiable(RAMBlock *rb, vo= id *opaque) "page size of 0x%zx", block_name, length, pagesize); return 1; } + + if (rb->fd >=3D 0) { + fs =3D file_memory_backend_get_fs_type(rb->mr->owner); + if (strcmp(fs, "tmpfs") && strcmp(fs, "hugetlbfs")) { + error_report("Host backend files need to be TMPFS or HUGETLBFS= only"); + return 1; + } + } + return 0; } =20 @@ -366,6 +376,7 @@ bool postcopy_ram_supported_by_host(MigrationIncomingSt= ate *mis) struct uffdio_range range_struct; uint64_t feature_mask; Error *local_err =3D NULL; + RAMBlock *block; =20 if (qemu_target_page_size() > pagesize) { error_report("Target page size bigger than host page size"); @@ -390,9 +401,18 @@ bool postcopy_ram_supported_by_host(MigrationIncomingS= tate *mis) goto out; } =20 - /* We don't support postcopy with shared RAM yet */ - if (foreach_not_ignored_block(test_ramblock_postcopiable, NULL)) { - goto out; + /* + * We don't support postcopy with some type of ramblocks. + * + * NOTE: we explicitly ignored ramblock_is_ignored() instead we checked + * all possible ramblocks. This is because this function can be called + * when creating the migration object, during the phase RAM_MIGRATABLE + * is not even properly set for all the ramblocks. + */ + RAMBLOCK_FOREACH(block) { + if (test_ramblock_postcopiable(block)) { + goto out; + } } =20 /* --=20 2.39.1