From nobody Sun May 19 02:26:47 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1603315948; cv=none; d=zohomail.com; s=zohoarc; b=Z1DGFhW9/G7e7EmshgUkPucB52HWnAox6X6W313HXyAiUUL3s7fLBmGFVU+xPeF3OkI6qu7wpfTRuOSRoAPYji7Nva+ag8CJqLVRO/V+crBD1Kji21dHIJUHTdUeQxAO34nIS6zFnYH5HcSNRzbkPDJ/0wB/V2b0sANz5o2t+fA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603315948; h=Content-Type: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=n4IR530G0jn3KaGrAMU+kHWU9guPG9Q80wHEffp3OJw=; b=jxzaIEFvlsUFFFvGKkbkHmNIrd/r6dUOcHRlRB80bEL15kHxXlyyJfRB8YzQHxvgumuzQYP/nmsQt9cX1deF8Vo1b6m6b7AiSX0Nqfok5VKU/ijAvEhdZlNXskeaYRgEufVEN1vc3uXLwPU5RgcvnWN5mpMRSr5aYDpVyR2kOL0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1603315948642429.9270925503912; Wed, 21 Oct 2020 14:32:28 -0700 (PDT) Received: from localhost ([::1]:57424 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVLic-0007Cy-Jc for importer@patchew.org; Wed, 21 Oct 2020 17:32:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46776) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVLe2-0003F0-An for qemu-devel@nongnu.org; Wed, 21 Oct 2020 17:27:42 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:39040) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kVLdp-00025K-GT for qemu-devel@nongnu.org; Wed, 21 Oct 2020 17:27:41 -0400 Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-402-PSukzV2IPfyFFlk4nl-Yiw-1; Wed, 21 Oct 2020 17:27:26 -0400 Received: by mail-qv1-f69.google.com with SMTP id m11so2097868qvt.11 for ; Wed, 21 Oct 2020 14:27:26 -0700 (PDT) Received: from xz-x1.redhat.com (toroon474qw-lp140-04-174-95-215-133.dsl.bell.ca. [174.95.215.133]) by smtp.gmail.com with ESMTPSA id p187sm2089145qkf.70.2020.10.21.14.27.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Oct 2020 14:27:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603315647; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=n4IR530G0jn3KaGrAMU+kHWU9guPG9Q80wHEffp3OJw=; b=KVGeQq4GMNs7kPib77huokFb590Ar7utEEx3phWtiK6Tq9DOpkkWp97TpFmGGAhXeazsVE LuCblgaWUebNpwRFXSg7tX5l7B9no+5juNPDzOPXJ1B9ef3Yc6bz9Ld2wEjz5OtBGo0bHR 9LNefAIVLuA3NBolCenmf/tZ7DkMwho= X-MC-Unique: PSukzV2IPfyFFlk4nl-Yiw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=n4IR530G0jn3KaGrAMU+kHWU9guPG9Q80wHEffp3OJw=; b=LTKkHcfZmuBPr23rLxLjCP1wcaC6KNcaEYcPy7SfEZLf0mQg3X9qCCpPxxUgvxettV CD2uOgdv+aI/gYaIpCCCqWBUTFnF0RSoWQbhu4sKfTwRdt2gUwf2SerypHUCrcluj/gC 0jmudEXDnKgmIMjG8HxI0MGpkEMdZSSNQ5jGZYboGY7pUQVBflzB0H+7ZEtO2eJLIzG3 zC6USm89xWSw8NHKW8s1HNbwW7Jh9SDdGwJX1c9nRW+HnlzErNtNx5/sqB88S6CK08nf gwd14JwKx4+2bIGV/C8xQD4XFVmSdvcPT9u5AHsKwE2EePgwW/hq8psnMEcKkKxbTdum +CWw== X-Gm-Message-State: AOAM532rveMDEcl96iKsd2iFE9bBaRZma9EbME9/gcgnNh2MPTc3l9YN 0gZrKq+gtaViPgdtkhmqODUK+UMKM06IGZVV1/S7yuvKQDNDhUfLUCqr7N3cyAnHxHEzaJK4h2W kDMYP2SYwv/Jrygg= X-Received: by 2002:ae9:c005:: with SMTP id u5mr5254154qkk.41.1603315645405; Wed, 21 Oct 2020 14:27:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy+g7pHqA+gM/cCHBZfxkOPa8HFEBdHpKkMoChWdYtjvPTZC0UJfk3dIFiL5wOF2bT1ds4GOg== X-Received: by 2002:ae9:c005:: with SMTP id u5mr5254126qkk.41.1603315645117; Wed, 21 Oct 2020 14:27:25 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Subject: [PATCH v6 1/6] migration: Pass incoming state into qemu_ufd_copy_ioctl() Date: Wed, 21 Oct 2020 17:27:16 -0400 Message-Id: <20201021212721.440373-2-peterx@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201021212721.440373-1-peterx@redhat.com> References: <20201021212721.440373-1-peterx@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=peterx@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=63.128.21.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/20 22:12:28 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] 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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Thomas Huth , "Dr . David Alan Gilbert" , peterx@redhat.com, Juan Quintela Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" It'll be used in follow up patches to access more fields out of it. Meanwh= ile fetch the userfaultfd inside the function. Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Peter Xu --- migration/postcopy-ram.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c index 0a2f88a87d..722034dc01 100644 --- a/migration/postcopy-ram.c +++ b/migration/postcopy-ram.c @@ -1128,10 +1128,12 @@ int postcopy_ram_incoming_setup(MigrationIncomingSt= ate *mis) return 0; } =20 -static int qemu_ufd_copy_ioctl(int userfault_fd, void *host_addr, +static int qemu_ufd_copy_ioctl(MigrationIncomingState *mis, void *host_add= r, void *from_addr, uint64_t pagesize, RAMBloc= k *rb) { + int userfault_fd =3D mis->userfault_fd; int ret; + if (from_addr) { struct uffdio_copy copy_struct; copy_struct.dst =3D (uint64_t)(uintptr_t)host_addr; @@ -1185,7 +1187,7 @@ int postcopy_place_page(MigrationIncomingState *mis, = void *host, void *from, * which would be slightly cheaper, but we'd have to be careful * of the order of updating our page state. */ - if (qemu_ufd_copy_ioctl(mis->userfault_fd, host, from, pagesize, rb)) { + if (qemu_ufd_copy_ioctl(mis, host, from, pagesize, rb)) { int e =3D errno; error_report("%s: %s copy host: %p from: %p (size: %zd)", __func__, strerror(e), host, from, pagesize); @@ -1212,7 +1214,7 @@ int postcopy_place_page_zero(MigrationIncomingState *= mis, void *host, * but it's not available for everything (e.g. hugetlbpages) */ if (qemu_ram_is_uf_zeroable(rb)) { - if (qemu_ufd_copy_ioctl(mis->userfault_fd, host, NULL, pagesize, r= b)) { + if (qemu_ufd_copy_ioctl(mis, host, NULL, pagesize, rb)) { int e =3D errno; error_report("%s: %s zero host: %p", __func__, strerror(e), host); --=20 2.26.2 From nobody Sun May 19 02:26:47 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1603316906; cv=none; d=zohomail.com; s=zohoarc; b=ilj1c393IpgyIPgxHPjbH3GZT1hq1G+rt77EbFumtCgTl/bEvVWvhLo/mqCGULM0EypQBaT1nESgs9CMdiG+ZSZK5vYg3unaBbendcQZtuChfJwJ0+qDQeJvbfHgO8aQZzZ5lzmoTFi6zmxTMVNcjvgoIVdk3S5N7b7PecBmduM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603316906; h=Content-Type: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=cMJ0oJkDJS1ct9V7+zYpIxHyvkkNruWU9TQfQ8wCbfY=; b=JvSg63z63/XiUC0sWoL/IvnmDMwYw6ZhZnZHpEYS7H80zToNz706SHjzG5MOmPNvddO//T9VwRSaJiUVYncOvNtuo1xdA1Zs2qR28483UD40QolvPmxspeK+7JLOcTNEYROw0X0Vu2R2q8YDFDcVFcWO8D9dgqXsCMCeEryFEIw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 160331690667514.925539027260697; Wed, 21 Oct 2020 14:48:26 -0700 (PDT) Received: from localhost ([::1]:39554 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVLy5-000728-Kz for importer@patchew.org; Wed, 21 Oct 2020 17:48:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46808) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVLe3-0003GS-HA for qemu-devel@nongnu.org; Wed, 21 Oct 2020 17:27:43 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:34810) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kVLdt-00025b-66 for qemu-devel@nongnu.org; Wed, 21 Oct 2020 17:27:43 -0400 Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-544-p9z_AjDtNYGRL1XZg7DpsA-1; Wed, 21 Oct 2020 17:27:27 -0400 Received: by mail-qv1-f71.google.com with SMTP id m11so2097901qvt.11 for ; Wed, 21 Oct 2020 14:27:27 -0700 (PDT) Received: from xz-x1.redhat.com (toroon474qw-lp140-04-174-95-215-133.dsl.bell.ca. [174.95.215.133]) by smtp.gmail.com with ESMTPSA id p187sm2089145qkf.70.2020.10.21.14.27.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Oct 2020 14:27:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603315651; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cMJ0oJkDJS1ct9V7+zYpIxHyvkkNruWU9TQfQ8wCbfY=; b=GFEj7CFQLWskMVwFNCvRWP1jYf38CuxCR0kH77n3axbq7bpT2DWDxloJDOHqTiuhrK6tel xnO3duXtelBiYuLWM0fxCX8jJgPfCELAevuRlYfLLHTQR/PdeZhQZzzE7QB38tdFUq7OYB zIhLVzNb0gHKJ06/J5yVIv8eJIvaVII= X-MC-Unique: p9z_AjDtNYGRL1XZg7DpsA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=cMJ0oJkDJS1ct9V7+zYpIxHyvkkNruWU9TQfQ8wCbfY=; b=dUTeGOHX50Tb6g6RVc7EK9PZw1qPFtxd896Xsc1aFdCH9zqrO6OPJCdE3JjS9t62mO Ec5TTtE6ApsPJRgb/SXhvFG09Hl9LcRKNVKDDPHfuBxTAVtzJmyHJFbEEZzkzOSTUILt dIDVVF4AtHrdmdGfAu16k9EnLH6QhR6zGULlU4Auwzg8E5D5+qKd8MzyaAATadBQLq8k Wm5thobhbb2TaEKZcs1G9fSyzhcsNRY41O13EBgonNOE0rhZIyMZl9BZe+w+fJvvKFhe wie/ocdRTYxABcsWwVutf52pJHLkyj8meewPS1d7YRZigA0pdjvK3Yicm+2SD8dRJJ42 QdEw== X-Gm-Message-State: AOAM533aVpluxLr1ROIxHyhmt/KSbwwZOOsCGnnb+XoOspNZ0paA9jv1 ZxB24rvk372/nL0tU/y+iZAR2PLQUD+CXLEXgIlqvC2jR9dPmWrFsgpj8vnK/0IY4oWS/J6TaZv Qk4bZhEoInYqm8Bg= X-Received: by 2002:ac8:71cc:: with SMTP id i12mr5094787qtp.262.1603315647147; Wed, 21 Oct 2020 14:27:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxQgAm2lKb9OBuz7MzS6ON+pLS9HWlihYCu99jlO3ZJSFXqyJ2dZ/fmfpsUxw57zd03H8WlCw== X-Received: by 2002:ac8:71cc:: with SMTP id i12mr5094775qtp.262.1603315646940; Wed, 21 Oct 2020 14:27:26 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Subject: [PATCH v6 2/6] migration: Introduce migrate_send_rp_message_req_pages() Date: Wed, 21 Oct 2020 17:27:17 -0400 Message-Id: <20201021212721.440373-3-peterx@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201021212721.440373-1-peterx@redhat.com> References: <20201021212721.440373-1-peterx@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=peterx@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=63.128.21.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/20 22:12:28 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] 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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Thomas Huth , "Dr . David Alan Gilbert" , peterx@redhat.com, Juan Quintela Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" This is another layer wrapper for sending a page request to the source VM. = The new migrate_send_rp_message_req_pages() will be used elsewhere in coming patches. Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Peter Xu --- migration/migration.c | 10 ++++++++-- migration/migration.h | 2 ++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 0575ecb379..255e69c8aa 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -316,8 +316,8 @@ error: * Start: Address offset within the RB * Len: Length in bytes required - must be a multiple of pagesize */ -int migrate_send_rp_req_pages(MigrationIncomingState *mis, RAMBlock *rb, - ram_addr_t start) +int migrate_send_rp_message_req_pages(MigrationIncomingState *mis, + RAMBlock *rb, ram_addr_t start) { uint8_t bufc[12 + 1 + 255]; /* start (8), len (4), rbname up to 256 */ size_t msglen =3D 12; /* start + len */ @@ -353,6 +353,12 @@ int migrate_send_rp_req_pages(MigrationIncomingState *= mis, RAMBlock *rb, return migrate_send_rp_message(mis, msg_type, msglen, bufc); } =20 +int migrate_send_rp_req_pages(MigrationIncomingState *mis, + RAMBlock *rb, ram_addr_t start) +{ + return migrate_send_rp_message_req_pages(mis, rb, start); +} + static bool migration_colo_enabled; bool migration_incoming_colo_enabled(void) { diff --git a/migration/migration.h b/migration/migration.h index deb411aaad..e853ccf8b1 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -333,6 +333,8 @@ void migrate_send_rp_pong(MigrationIncomingState *mis, uint32_t value); int migrate_send_rp_req_pages(MigrationIncomingState *mis, RAMBlock *rb, ram_addr_t start); +int migrate_send_rp_message_req_pages(MigrationIncomingState *mis, + RAMBlock *rb, ram_addr_t start); void migrate_send_rp_recv_bitmap(MigrationIncomingState *mis, char *block_name); void migrate_send_rp_resume_ack(MigrationIncomingState *mis, uint32_t valu= e); --=20 2.26.2 From nobody Sun May 19 02:26:47 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1603316105; cv=none; d=zohomail.com; s=zohoarc; b=efc4zOOMaZ5znN1r/5oWy2o8FUTAhimhk6oUtWM/mribNkZuWr4bub8BWUSvN6ue2u5S0ToDtRNs7VOZDKoB+layETVUQgXr4I8tfKzsfqMGWxG0aVaL6RqOkyDyE7I6xsh0qPCk9RI/1ZQQ1MVsQSkK+HXQj+MIVNJzrpVHMXc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603316105; h=Content-Type: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=DAdZm6UmxfnE0oz6ugy69uo/vH12UNLFp6ipaX2Ic7A=; b=JevNTQCuLa2Yae/KfJtNCKZcRVuGjx9jm5w9VrmHHowwteMSQMCTrmD5IIvWaJO6fA8xRlb/PckVMnOCS0jnCcbTEOK44UDWiecCMN6upi6Z6ebFtyS7cZG1U+HaIcjOGlRWVOMI0fqeZaIccJroV8j2MMpfDsUN5nBtKmbWukU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1603316105581887.3182519161633; Wed, 21 Oct 2020 14:35:05 -0700 (PDT) Received: from localhost ([::1]:35534 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVLlA-0001S6-DT for importer@patchew.org; Wed, 21 Oct 2020 17:35:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46804) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVLe3-0003GQ-Gp for qemu-devel@nongnu.org; Wed, 21 Oct 2020 17:27:43 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:31013) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kVLdt-00025Z-5g for qemu-devel@nongnu.org; Wed, 21 Oct 2020 17:27:42 -0400 Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-182-gEBY0TTGNJSN7Jx6NLkyxw-1; Wed, 21 Oct 2020 17:27:29 -0400 Received: by mail-qv1-f69.google.com with SMTP id ec4so2082212qvb.21 for ; Wed, 21 Oct 2020 14:27:29 -0700 (PDT) Received: from xz-x1.redhat.com (toroon474qw-lp140-04-174-95-215-133.dsl.bell.ca. [174.95.215.133]) by smtp.gmail.com with ESMTPSA id p187sm2089145qkf.70.2020.10.21.14.27.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Oct 2020 14:27:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603315651; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DAdZm6UmxfnE0oz6ugy69uo/vH12UNLFp6ipaX2Ic7A=; b=BnMjl0w9SPFKj9ZkILHIWqvSnm6ddXHUD56GPkpxLYfTAbHP8DM2PyKA7iEXGYM0QzoiX4 z8QifRKM2MB1RviZDmRanx/vm8CnVk5RBoCq25OXYaW/ABAE8OT3TL8jaDqGizJ8UQH8Ir +0XQcs//rGSaIpIAQiLTrL6Hrk3PNNM= X-MC-Unique: gEBY0TTGNJSN7Jx6NLkyxw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=DAdZm6UmxfnE0oz6ugy69uo/vH12UNLFp6ipaX2Ic7A=; b=dO/e6jbXktfi1rcyYmm82jMZRUnc2aBM5udWKilVG7/AayH0/lhJmPI8WtR0iHjchs RhT3pobdg+Rvh+2scyImGOYsTAdLD+HyKibk6xdMhU/o0ogSTg/QzZRO4uB7qiW038jH fq4eiGkW5T7n9ojH9CwSMt7ZBDs6f/l6haFdgeImGABe0ys65LrjRd449eLY/CIvELW4 maZ5P12Lsb1YZrCs+bGzzttqx5TbxA2ax36IiKQJNDN937vVYzqwlmyKztdzg3HjH77f kN5nmRWbKGFiRYJCgvgdYO7Mgpt156uPM4s313xq3LjawbYxdGrp9Um8wsbbqOX+ovqX xQ6g== X-Gm-Message-State: AOAM5337FRf9131cnhBsObY1XDmgO5RW2rLSp/IVp68uyqJSPPECpZrO Wu+CkN63AUfLmIjc2jbGL1dD+QVbGBhMYDJHOGFnJTorqQU4Bc8Qkpgf5CNlMXpA4Gzy15s0wE/ L1pA/d0GfRPJjX4s= X-Received: by 2002:a37:7b85:: with SMTP id w127mr5064522qkc.59.1603315648952; Wed, 21 Oct 2020 14:27:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxw+RqovZ9uZIVExAWpFkD6+Tq7sAFH/eJl/z0bIbYorQmtpeRO8F2AgPbdq/UxvEDMxwq/UQ== X-Received: by 2002:a37:7b85:: with SMTP id w127mr5064502qkc.59.1603315648637; Wed, 21 Oct 2020 14:27:28 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Subject: [PATCH v6 3/6] migration: Maintain postcopy faulted addresses Date: Wed, 21 Oct 2020 17:27:18 -0400 Message-Id: <20201021212721.440373-4-peterx@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201021212721.440373-1-peterx@redhat.com> References: <20201021212721.440373-1-peterx@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=peterx@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=63.128.21.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/20 22:12:28 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] 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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Thomas Huth , "Dr . David Alan Gilbert" , peterx@redhat.com, Juan Quintela Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Maintain a list of faulted addresses on the destination host for which we're waiting on. This is implemented using a GTree rather than a real list to m= ake sure even there're plenty of vCPUs/threads that are faulting, the lookup wi= ll still be fast with O(log(N)) (because we'll do that after placing each page= ). It should bring a slight overhead, but ideally that shouldn't be a big prob= lem simply because in most cases the requested page list will be short. Actually we did similar things for postcopy blocktime measurements. This p= atch didn't use that simply because: (1) blocktime measurement is towards vcpu threads only, but here we need = to record all faulted addresses, including main thread and external thread (like, DPDK via vhost-user). (2) blocktime measurement will require UFFD_FEATURE_THREAD_ID, but here we don't want to add that extra dependency on the kernel version since n= ot necessary. E.g., we don't need to know which thread faulted on which page, we also don't care about multiple threads faulting on the same page. But we only care about what addresses are faulted so waiting f= or a page copying from src. (3) blocktime measurement is not enabled by default. However we need thi= s by default especially for postcopy recover. Another thing to mention is that this patch introduced a new mutex to seria= lize the receivedmap and the page_requested tree, however that serialization does not cover other procedures like UFFDIO_COPY. Signed-off-by: Peter Xu Reviewed-by: Dr. David Alan Gilbert --- migration/migration.c | 41 +++++++++++++++++++++++++++++++++++++++- migration/migration.h | 19 ++++++++++++++++++- migration/postcopy-ram.c | 17 ++++++++++++++--- migration/trace-events | 2 ++ 4 files changed, 74 insertions(+), 5 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 255e69c8aa..e3a958b299 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -143,6 +143,13 @@ static int migration_maybe_pause(MigrationState *s, int new_state); static void migrate_fd_cancel(MigrationState *s); =20 +static gint page_request_addr_cmp(gconstpointer ap, gconstpointer bp) +{ + uintptr_t a =3D (uintptr_t) ap, b =3D (uintptr_t) bp; + + return (a > b) - (a < b); +} + void migration_object_init(void) { MachineState *ms =3D MACHINE(qdev_get_machine()); @@ -165,6 +172,8 @@ void migration_object_init(void) qemu_event_init(¤t_incoming->main_thread_load_event, false); qemu_sem_init(¤t_incoming->postcopy_pause_sem_dst, 0); qemu_sem_init(¤t_incoming->postcopy_pause_sem_fault, 0); + qemu_mutex_init(¤t_incoming->page_request_mutex); + current_incoming->page_requested =3D g_tree_new(page_request_addr_cmp); =20 if (!migration_object_check(current_migration, &err)) { error_report_err(err); @@ -240,6 +249,11 @@ void migration_incoming_state_destroy(void) =20 qemu_event_reset(&mis->main_thread_load_event); =20 + if (mis->page_requested) { + g_tree_destroy(mis->page_requested); + mis->page_requested =3D NULL; + } + if (mis->socket_address_list) { qapi_free_SocketAddressList(mis->socket_address_list); mis->socket_address_list =3D NULL; @@ -354,8 +368,33 @@ int migrate_send_rp_message_req_pages(MigrationIncomin= gState *mis, } =20 int migrate_send_rp_req_pages(MigrationIncomingState *mis, - RAMBlock *rb, ram_addr_t start) + RAMBlock *rb, ram_addr_t start, uint64_t had= dr) { + void *aligned =3D (void *)(uintptr_t)(haddr & (-qemu_ram_pagesize(rb))= ); + bool received; + + WITH_QEMU_LOCK_GUARD(&mis->page_request_mutex) { + received =3D ramblock_recv_bitmap_test_byte_offset(rb, start); + if (!received && !g_tree_lookup(mis->page_requested, aligned)) { + /* + * The page has not been received, and it's not yet in the page + * request list. Queue it. Set the value of element to 1, so= that + * things like g_tree_lookup() will return TRUE (1) when found. + */ + g_tree_insert(mis->page_requested, aligned, (gpointer)1); + mis->page_requested_count++; + trace_postcopy_page_req_add(aligned, mis->page_requested_count= ); + } + } + + /* + * If the page is there, skip sending the message. We don't even need= the + * lock because as long as the page arrived, it'll be there forever. + */ + if (received) { + return 0; + } + return migrate_send_rp_message_req_pages(mis, rb, start); } =20 diff --git a/migration/migration.h b/migration/migration.h index e853ccf8b1..8d2d1ce839 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -104,6 +104,23 @@ struct MigrationIncomingState { =20 /* List of listening socket addresses */ SocketAddressList *socket_address_list; + + /* A tree of pages that we requested to the source VM */ + GTree *page_requested; + /* For debugging purpose only, but would be nice to keep */ + int page_requested_count; + /* + * The mutex helps to maintain the requested pages that we sent to the + * source, IOW, to guarantee coherent between the page_requests tree a= nd + * the per-ramblock receivedmap. Note! This does not guarantee consis= tency + * of the real page copy procedures (using UFFDIO_[ZERO]COPY). E.g., = even + * if one bit in receivedmap is cleared, UFFDIO_COPY could have happen= ed + * for that page already. This is intended so that the mutex won't + * serialize and blocked by slow operations like UFFDIO_* ioctls. How= ever + * this should be enough to make sure the page_requested tree always + * contains valid information. + */ + QemuMutex page_request_mutex; }; =20 MigrationIncomingState *migration_incoming_get_current(void); @@ -332,7 +349,7 @@ void migrate_send_rp_shut(MigrationIncomingState *mis, void migrate_send_rp_pong(MigrationIncomingState *mis, uint32_t value); int migrate_send_rp_req_pages(MigrationIncomingState *mis, RAMBlock *rb, - ram_addr_t start); + ram_addr_t start, uint64_t haddr); int migrate_send_rp_message_req_pages(MigrationIncomingState *mis, RAMBlock *rb, ram_addr_t start); void migrate_send_rp_recv_bitmap(MigrationIncomingState *mis, diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c index 722034dc01..ca1daf0024 100644 --- a/migration/postcopy-ram.c +++ b/migration/postcopy-ram.c @@ -684,7 +684,7 @@ int postcopy_request_shared_page(struct PostCopyFD *pcf= d, RAMBlock *rb, qemu_ram_get_idstr(rb), rb_offset); return postcopy_wake_shared(pcfd, client_addr, rb); } - migrate_send_rp_req_pages(mis, rb, aligned_rbo); + migrate_send_rp_req_pages(mis, rb, aligned_rbo, client_addr); return 0; } =20 @@ -979,7 +979,8 @@ retry: * Send the request to the source - we want to request one * of our host page sizes (which is >=3D TPS) */ - ret =3D migrate_send_rp_req_pages(mis, rb, rb_offset); + ret =3D migrate_send_rp_req_pages(mis, rb, rb_offset, + msg.arg.pagefault.address); if (ret) { /* May be network failure, try to wait for recovery */ if (ret =3D=3D -EIO && postcopy_pause_fault_thread(mis)) { @@ -1149,10 +1150,20 @@ static int qemu_ufd_copy_ioctl(MigrationIncomingSta= te *mis, void *host_addr, ret =3D ioctl(userfault_fd, UFFDIO_ZEROPAGE, &zero_struct); } if (!ret) { + qemu_mutex_lock(&mis->page_request_mutex); ramblock_recv_bitmap_set_range(rb, host_addr, pagesize / qemu_target_page_size()); + /* + * If this page resolves a page fault for a previous recorded faul= ted + * address, take a special note to maintain the requested page lis= t. + */ + if (g_tree_lookup(mis->page_requested, host_addr)) { + g_tree_remove(mis->page_requested, host_addr); + mis->page_requested_count--; + trace_postcopy_page_req_del(host_addr, mis->page_requested_cou= nt); + } + qemu_mutex_unlock(&mis->page_request_mutex); mark_postcopy_blocktime_end((uintptr_t)host_addr); - } return ret; } diff --git a/migration/trace-events b/migration/trace-events index 338f38b3dd..e4d5eb94ca 100644 --- a/migration/trace-events +++ b/migration/trace-events @@ -162,6 +162,7 @@ postcopy_pause_return_path(void) "" postcopy_pause_return_path_continued(void) "" postcopy_pause_continued(void) "" postcopy_start_set_run(void) "" +postcopy_page_req_add(void *addr, int count) "new page req %p total %d" source_return_path_thread_bad_end(void) "" source_return_path_thread_end(void) "" source_return_path_thread_entry(void) "" @@ -272,6 +273,7 @@ postcopy_ram_incoming_cleanup_blocktime(uint64_t total)= "total blocktime %" PRIu postcopy_request_shared_page(const char *sharer, const char *rb, uint64_t = rb_offset) "for %s in %s offset 0x%"PRIx64 postcopy_request_shared_page_present(const char *sharer, const char *rb, u= int64_t rb_offset) "%s already %s offset 0x%"PRIx64 postcopy_wake_shared(uint64_t client_addr, const char *rb) "at 0x%"PRIx64"= in %s" +postcopy_page_req_del(void *addr, int count) "resolved page req %p total %= d" =20 get_mem_fault_cpu_index(int cpu, uint32_t pid) "cpu: %d, pid: %u" =20 --=20 2.26.2 From nobody Sun May 19 02:26:47 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1603316272; cv=none; d=zohomail.com; s=zohoarc; b=kybCHT2nfYvg6To1PYz4RY5xxpnjlktG/phBkJXqSAXdJvYqnYu3c5chLZHH3x+ydlwX5hxNxkSAwYyIf2UocV+RF7fItvJU3HK4grMmRQVjs2JIOuUss9OBo/8p8nwdErsM7oOIel5rcmQnSMDJZzm34//Mx3BqKhXTjs7/c1Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603316272; h=Content-Type: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=UNPjhXFw69k7I1uaRrlnu2Tl3UZw4+OZaB4P9a4opmU=; b=gXZcIinGU7bnZghzHcVegoxoZ8CsSfHMXBFVu5GsXIEPwP4DDwMebkIXdGlV3137th4bvcjikzgP1I3lYM4vbtSMeUmsPE1JPxsmYp6o+ja888rflZLK75ByPTMnlpdRSiorsxYkqkaGzlqJC8NWoFBoPkORNNZSIg1icLgEcNM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1603316272542677.4762171986739; Wed, 21 Oct 2020 14:37:52 -0700 (PDT) Received: from localhost ([::1]:42454 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVLnr-0004gT-CU for importer@patchew.org; Wed, 21 Oct 2020 17:37:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46836) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVLe5-0003HX-7N for qemu-devel@nongnu.org; Wed, 21 Oct 2020 17:27:45 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:39154) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kVLdz-00025l-7x for qemu-devel@nongnu.org; Wed, 21 Oct 2020 17:27:44 -0400 Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-330-TmWsOkTOMPamkTnLXQRIag-1; Wed, 21 Oct 2020 17:27:31 -0400 Received: by mail-qk1-f197.google.com with SMTP id g184so2628738qke.3 for ; Wed, 21 Oct 2020 14:27:31 -0700 (PDT) Received: from xz-x1.redhat.com (toroon474qw-lp140-04-174-95-215-133.dsl.bell.ca. [174.95.215.133]) by smtp.gmail.com with ESMTPSA id p187sm2089145qkf.70.2020.10.21.14.27.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Oct 2020 14:27:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603315652; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UNPjhXFw69k7I1uaRrlnu2Tl3UZw4+OZaB4P9a4opmU=; b=S2xKyXnLYn9sr8eyHN8yVDoBZaNYKYOU+UnUWvLzwLEv5NfUAmO0P0Hzv8j1fWG0daEuuD x5wAVCf/SwYlnyiYklgb+w3vHzpAN/7wYJVMRZ5MjyqXEyAp3zMvlT4hjznvYzPPtpwFw1 ibtI+LT/Tf2NXHUgRTi93DqVDiv9Lcw= X-MC-Unique: TmWsOkTOMPamkTnLXQRIag-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=UNPjhXFw69k7I1uaRrlnu2Tl3UZw4+OZaB4P9a4opmU=; b=rru+ycA7zRfZzgVNT62DQZzJiUrG9e49FaxR/KQYpVgtHgHfUlpGUloZzSWJefdYkt vjpTt4eTXfQc1B57Wo7YnPjuLrCe5Z8RbZhXUspb1B7fwKLmmG/u1TovRhceDlGL12zk lCOVJakLA6pbcr1vLgUgt6PNdHxxEJvZqe5Iv2Yj+eZ5QIf4KBtcSgBTuXlpJdFAlw/6 Rep2H2dtYpAtRhpSuIZXE+TAjRGjD1S4eCZCkwLHtUwA5PkysukhiTwu468wJs/QCjvQ 4W8/54AYX6/a+6hZy40pBVoDFY7gc8sFutOak4g9d4Bl7RvuS6KJWSm54QVmvgT7NTG0 ePfg== X-Gm-Message-State: AOAM531KcuLo6SZarbv7DKiroY1Z91B+Z1r2iALpEwcAbaLCVa4hePvD YEyM0tUPdpQOnv45n4JttDdfHwYlXqpZVM8JKhzJq1VWHMGvMvm4Jogu94Ln5AI1ReSeRWYZyUa pD0ry18D8z5VhROs= X-Received: by 2002:a37:ad1a:: with SMTP id f26mr4978543qkm.1.1603315650500; Wed, 21 Oct 2020 14:27:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzFpK/QNHMvS2X+Ioo61Sim5J5yjJ0yRZn6wyzj50T4fJzS6/ZYdI3GHNkyHkhD4VxM2xP6xA== X-Received: by 2002:a37:ad1a:: with SMTP id f26mr4978529qkm.1.1603315650243; Wed, 21 Oct 2020 14:27:30 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Subject: [PATCH v6 4/6] migration: Sync requested pages after postcopy recovery Date: Wed, 21 Oct 2020 17:27:19 -0400 Message-Id: <20201021212721.440373-5-peterx@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201021212721.440373-1-peterx@redhat.com> References: <20201021212721.440373-1-peterx@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=peterx@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=63.128.21.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/20 22:12:28 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] 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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Thomas Huth , Juan Quintela , Xiaohui Li , "Dr . David Alan Gilbert" , peterx@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" We synchronize the requested pages right after a postcopy recovery happens. This helps to synchronize the prioritized pages on source so that the fault= ed threads can be served faster. Reported-by: Xiaohui Li Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Peter Xu --- migration/savevm.c | 57 ++++++++++++++++++++++++++++++++++++++++++ migration/trace-events | 1 + 2 files changed, 58 insertions(+) diff --git a/migration/savevm.c b/migration/savevm.c index d2e141f7b1..33acbba1a4 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -2011,6 +2011,49 @@ static int loadvm_postcopy_handle_run(MigrationIncom= ingState *mis) return LOADVM_QUIT; } =20 +/* We must be with page_request_mutex held */ +static gboolean postcopy_sync_page_req(gpointer key, gpointer value, + gpointer data) +{ + MigrationIncomingState *mis =3D data; + void *host_addr =3D (void *) key; + ram_addr_t rb_offset; + RAMBlock *rb; + int ret; + + rb =3D qemu_ram_block_from_host(host_addr, true, &rb_offset); + if (!rb) { + /* + * This should _never_ happen. However be nice for a migrating VM= to + * not crash/assert. Post an error (note: intended to not use *_o= nce + * because we do want to see all the illegal addresses; and this c= an + * never be triggered by the guest so we're safe) and move on next. + */ + error_report("%s: illegal host addr %p", __func__, host_addr); + /* Try the next entry */ + return FALSE; + } + + ret =3D migrate_send_rp_message_req_pages(mis, rb, rb_offset); + if (ret) { + /* Please refer to above comment. */ + error_report("%s: send rp message failed for addr %p", + __func__, host_addr); + return FALSE; + } + + trace_postcopy_page_req_sync(host_addr); + + return FALSE; +} + +static void migrate_send_rp_req_pages_pending(MigrationIncomingState *mis) +{ + WITH_QEMU_LOCK_GUARD(&mis->page_request_mutex) { + g_tree_foreach(mis->page_requested, postcopy_sync_page_req, mis); + } +} + static int loadvm_postcopy_handle_resume(MigrationIncomingState *mis) { if (mis->state !=3D MIGRATION_STATUS_POSTCOPY_RECOVER) { @@ -2033,6 +2076,20 @@ static int loadvm_postcopy_handle_resume(MigrationIn= comingState *mis) /* Tell source that "we are ready" */ migrate_send_rp_resume_ack(mis, MIGRATION_RESUME_ACK_VALUE); =20 + /* + * After a postcopy recovery, the source should have lost the postcopy + * queue, or potentially the requested pages could have been lost duri= ng + * the network down phase. Let's re-sync with the source VM by re-sen= ding + * all the pending pages that we eagerly need, so these threads won't = get + * blocked too long due to the recovery. + * + * Without this procedure, the faulted destination VM threads (waiting= for + * page requests right before the postcopy is interrupted) can keep ha= nging + * until the pages are sent by the source during the background copyin= g of + * pages, or another thread faulted on the same address accidentally. + */ + migrate_send_rp_req_pages_pending(mis); + return 0; } =20 diff --git a/migration/trace-events b/migration/trace-events index e4d5eb94ca..0fbfd2da60 100644 --- a/migration/trace-events +++ b/migration/trace-events @@ -49,6 +49,7 @@ vmstate_save(const char *idstr, const char *vmsd_name) "%= s, %s" vmstate_load(const char *idstr, const char *vmsd_name) "%s, %s" postcopy_pause_incoming(void) "" postcopy_pause_incoming_continued(void) "" +postcopy_page_req_sync(void *host_addr) "sync page req %p" =20 # vmstate.c vmstate_load_field_error(const char *field, int ret) "field \"%s\" load fa= iled, ret =3D %d" --=20 2.26.2 From nobody Sun May 19 02:26:47 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1603316130; cv=none; d=zohomail.com; s=zohoarc; b=FgKJA5XJZCd3E22td+PogQiyficT2ooIIQa+xQXCbiEeam16uDaQeh/ve+Q5+htr7tY7nyzkZspYR2BVZl5KefBGUJOak06Kn62yXeugL2Mz9uX+3RcdxoTldwY4K4dleIaMSO2SnQt6KiIMX1KUgjaaAAUoYGHs5acmGHDtGiM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603316130; h=Content-Type: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=cXAIBJAlfQRCJ7NOr2j/4Mg/y+8/XbU5hJsy4VMjNYE=; b=QlfyPGtQ6AhI7egjrjxv4uPng6QX+FeDwwzCKc7CuR89SVk/MYoaOF5txevnzNSWwKteAsK738FyjGFZArPE501UsAuFEFMfgO9eM9Rl9Ka0+6HiiJP6iOQjd458tipLTTI7wWAhI7YTboUSVWp+k/dgQhFVD4WmRJLJt3CWv/o= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1603316130954689.2021524474485; Wed, 21 Oct 2020 14:35:30 -0700 (PDT) Received: from localhost ([::1]:37230 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVLlZ-0002Cf-Sa for importer@patchew.org; Wed, 21 Oct 2020 17:35:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46826) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVLe4-0003H7-Cp for qemu-devel@nongnu.org; Wed, 21 Oct 2020 17:27:44 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:35106) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kVLdz-00025w-Dk for qemu-devel@nongnu.org; Wed, 21 Oct 2020 17:27:44 -0400 Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-122-FSw4oeMwP4m7bSn8XytjLg-1; Wed, 21 Oct 2020 17:27:33 -0400 Received: by mail-qk1-f197.google.com with SMTP id s14so2639859qke.1 for ; Wed, 21 Oct 2020 14:27:33 -0700 (PDT) Received: from xz-x1.redhat.com (toroon474qw-lp140-04-174-95-215-133.dsl.bell.ca. [174.95.215.133]) by smtp.gmail.com with ESMTPSA id p187sm2089145qkf.70.2020.10.21.14.27.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Oct 2020 14:27:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603315654; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cXAIBJAlfQRCJ7NOr2j/4Mg/y+8/XbU5hJsy4VMjNYE=; b=TnSffA8/Yd8fxyy965khc32qh7RVMpy2dnai8v58TodwUdlz1KyZe1DzvOUy3XTIfpgbwj sLKtUB4BpqZ4Xf3+XmHYvO6mm+RzDDFcnkWRmYBcrIEz8hdoe3MG3C1V8hWv11cMs7lqJV aHvtut31aGKFFsOQQcVRZy1a0tokHnk= X-MC-Unique: FSw4oeMwP4m7bSn8XytjLg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=cXAIBJAlfQRCJ7NOr2j/4Mg/y+8/XbU5hJsy4VMjNYE=; b=MBVMMRFUvD7er3OmNCxYQyI0xx8tlR/ndsJRZkTRKlTYBL7xCiV9marLSEOzplos/J yWK7buKLDSsvNvUFmxuu9+lRqQiDuhGkgWoKN4z2tllWyujAn9uVG4kOYd9elUBLAhDo LM842EbYq/Gx9ZQpEHBFDTeMSx7Go5MPw7E+7vabxXKfDr9xDRHoicaWw8Flcr9vhdXA TQ6b5ax2CvnaMDppOOdXejcIECGK0oswUtsv30Rauc0MQjlGUQrrpwL20TbZl8MsR2XK 4a4+i/BV5jU3WzCa/WuB0BPQoIkGKltrxjzrRPsofO+PmjyB8VmLnXiUM0Ygmrki3PMO Zu+Q== X-Gm-Message-State: AOAM532y3A0nWNdGFxHG6/n1BVr72lYuqqJ9rrTN3ocgBL2dUPRMt1G0 mZJdfq8MK9NtIRqbSC+5OwfjQafiLZPgje5bnI+7gWWghuAD+yMngI+3nDs0mDaFzkuNVG4OYih amrEzIKinArZo3/k= X-Received: by 2002:a05:622a:1d4:: with SMTP id t20mr5161521qtw.173.1603315652167; Wed, 21 Oct 2020 14:27:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx9vIjo4GQc6sAWwEBA9I+Tq3BUZgW2AY0FmipYOLK3dgBv+KaZ/BZxBqhk58ytGUfUmf04yA== X-Received: by 2002:a05:622a:1d4:: with SMTP id t20mr5161500qtw.173.1603315651936; Wed, 21 Oct 2020 14:27:31 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Subject: [PATCH v6 5/6] migration/postcopy: Release fd before going into 'postcopy-pause' Date: Wed, 21 Oct 2020 17:27:20 -0400 Message-Id: <20201021212721.440373-6-peterx@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201021212721.440373-1-peterx@redhat.com> References: <20201021212721.440373-1-peterx@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=peterx@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=63.128.21.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/20 22:12:28 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] 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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Thomas Huth , "Dr . David Alan Gilbert" , peterx@redhat.com, Juan Quintela Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Logically below race could trigger with the old code: test program migration thread ------------ ---------------- wait_until('postcopy-pause') postcopy_pause() set_state('postcopy-pause') do_postcopy_recover() arm s->to_dst_file with new fd release s->to_dst_file [1] Here [1] could have released the just-installed recoverying channel. Then = the migration could hang without really resuming. Instead, it should be very safe to release the fd before setting the state = into 'postcopy-pause', because there's no reason for any other thread to touch it during 'postcopy-active'. Dave reported a very rare postcopy recovery hang that the migration-test program waited for the migration to complete in migrate_postcopy_complete(). We do suspect it's the same thing that we're gonna fix here. Hard to tell. However since we've noticed this, fix this irrelevant of the hang report. Cc: Dr. David Alan Gilbert Cc: Juan Quintela Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Peter Xu --- migration/migration.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index e3a958b299..20e04855d9 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -3178,9 +3178,6 @@ static MigThrError postcopy_pause(MigrationState *s) while (true) { QEMUFile *file; =20 - migrate_set_state(&s->state, s->state, - MIGRATION_STATUS_POSTCOPY_PAUSED); - /* Current channel is possibly broken. Release it. */ assert(s->to_dst_file); qemu_mutex_lock(&s->qemu_file_lock); @@ -3191,6 +3188,9 @@ static MigThrError postcopy_pause(MigrationState *s) qemu_file_shutdown(file); qemu_fclose(file); =20 + migrate_set_state(&s->state, s->state, + MIGRATION_STATUS_POSTCOPY_PAUSED); + error_report("Detected IO failure for postcopy. " "Migration paused."); =20 --=20 2.26.2 From nobody Sun May 19 02:26:47 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1603316328; cv=none; d=zohomail.com; s=zohoarc; b=gXHlwYvQMW0aEyKFZ8G5CBZUxaf87uxf4+4YJPN3Ls+7J+5tr/hRMcsxjRGHNqYRnEutR1nVa+47HNMTDguCnzK1kNcnUCXcb8C5Y+KmSODpq0qtRv0phgSlf2Y/1mLkn87cpMK/a+iwicw+Bshjqso3uTRxp7DjrrJEY6d5lSs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603316328; h=Content-Type: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=5YSDXbpiN58TIENBWrzuM3dPsDH2GwMJZmdPK3XRXc4=; b=eOD2iiRTzzvkKD5NDEm80VwzCJ0EL0yQzrW14bmAW5YP510eow4kc56ShqJ0fxUlHhucNyMdGPceulPsOcsvadn5iBMBbPE4YA33XOwMd0/aHI0kL6vXjKr2ePI9WCt+Zdf8xDCUrUQFckHjlj1HlYuJk3XMohNxXOW6g354ctk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1603316328280366.91506362363805; Wed, 21 Oct 2020 14:38:48 -0700 (PDT) Received: from localhost ([::1]:44670 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVLol-0005a4-5r for importer@patchew.org; Wed, 21 Oct 2020 17:38:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46846) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVLe5-0003J0-Q6 for qemu-devel@nongnu.org; Wed, 21 Oct 2020 17:27:45 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:30435) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kVLe0-000261-G1 for qemu-devel@nongnu.org; Wed, 21 Oct 2020 17:27:45 -0400 Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-195-7aKQIljoPzubjwG5wGSB5g-1; Wed, 21 Oct 2020 17:27:34 -0400 Received: by mail-qk1-f200.google.com with SMTP id d5so2590460qkg.16 for ; Wed, 21 Oct 2020 14:27:34 -0700 (PDT) Received: from xz-x1.redhat.com (toroon474qw-lp140-04-174-95-215-133.dsl.bell.ca. [174.95.215.133]) by smtp.gmail.com with ESMTPSA id p187sm2089145qkf.70.2020.10.21.14.27.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Oct 2020 14:27:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603315656; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5YSDXbpiN58TIENBWrzuM3dPsDH2GwMJZmdPK3XRXc4=; b=JCBN4fo+I5hzjpvsGZY0dZZrC1fkAEH7Z7wuOA0hTEJzET2IdQV2o8FN4+Wtb5a0Rvo0Bj dXMPRECnF9p0p3xC7judW2fjEHX4qFlohePpQDuJqb8R7uoNMO7W0/lUlWt+W4aKLVWYJG AVwdCfKfcfaXFTj7DY+bGLcO/9N9WSI= X-MC-Unique: 7aKQIljoPzubjwG5wGSB5g-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=5YSDXbpiN58TIENBWrzuM3dPsDH2GwMJZmdPK3XRXc4=; b=B/K89BPEjnbIeC23zn+0JCRbQwZ2ZOq/jdKs2IoUsHGJEoiTh+52v2UctDedRpYpwy GCUUe/oqxBg3KDeXwVhw5AliR2wEuNnPjZ0LvJVMD1y+IJOOpOIuXNQ/Egf9idgI580o 3/hapxBRqL9pZGdHqYhE1DLZgj7f048DlUoGYydm9H/aBiugC1DHk6EMAJj1MuisyF7o Xc22ws9gSbxV54/4Mbo6OokeaVTC4oT/dyuGpDTfCRHDWziIwViSsvjG3AmAwNrgaSZ2 5YcsQXzM9fn5rMOhtuI5r8NdcnlvHxV3GjGw98wMZsRPf1ZEHRVatZ0dKfMaREkwwTF3 SjvA== X-Gm-Message-State: AOAM532oMWO7fCT0es46DVhkWyuIBysP9qJwoYURZCeSeST5103wpmef wfQgThip6x4EWElgplZo7uw6iKwxtzJzlCGx7JUQZEPdhXR9RRc4gMouItGgU+FlYvdqr5U+bSB an8BCdtBw53MYD+A= X-Received: by 2002:aed:22fa:: with SMTP id q55mr4936237qtc.229.1603315653849; Wed, 21 Oct 2020 14:27:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwsRwuH2QsIYASdsuMXVXoN/2xH0WiD1HQK507D0oTnZ/ZpSmgHCpR9KK+6J+5GGLaMiWjBrw== X-Received: by 2002:aed:22fa:: with SMTP id q55mr4936217qtc.229.1603315653616; Wed, 21 Oct 2020 14:27:33 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Subject: [PATCH v6 6/6] migration-test: Only hide error if !QTEST_LOG Date: Wed, 21 Oct 2020 17:27:21 -0400 Message-Id: <20201021212721.440373-7-peterx@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201021212721.440373-1-peterx@redhat.com> References: <20201021212721.440373-1-peterx@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=peterx@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=216.205.24.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/21 02:16:02 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Thomas Huth , "Dr . David Alan Gilbert" , peterx@redhat.com, Juan Quintela Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" The errors are very useful when debugging qtest failures, especially when QTEST_LOG=3D1 is set. Let's allow override MigrateStart.hide_stderr when QTEST_LOG=3D1 is specified, because that means the user wants to be verbose. Not very nice to introduce the first QTEST_LOG env access in migration-test= .c, however it should be handy. Without this patch, I was hacking error_report= () when debugging such errors. Let's make things easier. Signed-off-by: Peter Xu --- tests/qtest/migration-test.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c index f410ec5996..f2142fbd3c 100644 --- a/tests/qtest/migration-test.c +++ b/tests/qtest/migration-test.c @@ -464,6 +464,10 @@ static void migrate_postcopy_start(QTestState *from, Q= TestState *to) } =20 typedef struct { + /* + * QTEST_LOG=3D1 may override this. When QTEST_LOG=3D1, we always dum= p errors + * unconditionally, because it means the user would like to be verbose. + */ bool hide_stderr; bool use_shmem; /* only launch the target process */ @@ -557,7 +561,7 @@ static int test_migrate_start(QTestState **from, QTestS= tate **to, =20 g_free(bootpath); =20 - if (args->hide_stderr) { + if (!getenv("QTEST_LOG") && args->hide_stderr) { ignore_stderr =3D "2>/dev/null"; } else { ignore_stderr =3D ""; --=20 2.26.2