From nobody Sat May 4 20:44:06 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=1616597925; cv=none; d=zohomail.com; s=zohoarc; b=noZQ26ql8vFjw0PMGgbihPxE3JwcDlXzEn12Xaa8GlVb23TPQcDyPFVfxBPUEUVjLEa0ZkChnHsUcGwT9x5jBGrbRf7D2sr2QehSGjCv7A/WjcHON4gNtuR3lrH4AOaP4Ss641uqaKxBKkPwPce/eVv8SOmfykommtSsNHco9wI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616597925; 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=jHP1iJZcWdIYe64zKdhbh7qOkXhTit7y8nXfYPBENB8=; b=PC0wgWknAuSV4Z0czndb9EBJzM/FEbnPh7lMu+6EmpoI3zkKBpQExmb5mzu/oIFYwF8CHjtA+OjwKMado/aTYUXOFlEo2VG8OIhSNWlZpoiC6h636lDD1cLZj/j3POO5vH0SllIhtHSliqN8LyT3HzlKOvo8wAjFyz1CgkylNW0= 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 1616597925626509.14889782505975; Wed, 24 Mar 2021 07:58:45 -0700 (PDT) Received: from localhost ([::1]:42666 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lP4y3-0007G7-Ui for importer@patchew.org; Wed, 24 Mar 2021 10:58:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57424) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lP4s3-00087d-LT for qemu-devel@nongnu.org; Wed, 24 Mar 2021 10:52:31 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:46522) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lP4s1-0002Nk-Ov for qemu-devel@nongnu.org; Wed, 24 Mar 2021 10:52:31 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-437-DV6ba5v4PR2wkI3g9hZ8LA-1; Wed, 24 Mar 2021 10:52:26 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3E88DEC1A3; Wed, 24 Mar 2021 14:52:24 +0000 (UTC) Received: from localhost (ovpn-115-111.ams2.redhat.com [10.36.115.111]) by smtp.corp.redhat.com (Postfix) with ESMTP id CE7E85DEAD; Wed, 24 Mar 2021 14:52:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1616597549; 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=jHP1iJZcWdIYe64zKdhbh7qOkXhTit7y8nXfYPBENB8=; b=jElVK1QZzzGOXeLc+U7cQ56aFUju3grO/bROju/aUIScHoSEMxmWy/GDVCLvTnriyxdzwd xBtsKRu+MUJUNzpzrHN2KHZRBUQAcE+Ikvc04517wzcF0lqeGEVlMUDHDIumfYiRp6Ux14 jghpdtwW7TGnL7nvh0s/EHrTqELnfGQ= X-MC-Unique: DV6ba5v4PR2wkI3g9hZ8LA-1 From: Stefan Hajnoczi To: Peter Maydell , qemu-devel@nongnu.org Subject: [PULL 1/2] migration/block-dirty-bitmap: make incoming disabled bitmaps busy Date: Wed, 24 Mar 2021 14:52:01 +0000 Message-Id: <20210324145202.430759-2-stefanha@redhat.com> In-Reply-To: <20210324145202.430759-1-stefanha@redhat.com> References: <20210324145202.430759-1-stefanha@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=stefanha@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=stefanha@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.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, MIME_BASE64_TEXT=1.741, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=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: Fam Zheng , Kevin Wolf , Vladimir Sementsov-Ogievskiy , Eduardo Habkost , qemu-block@nongnu.org, Juan Quintela , John Snow , "Michael S. Tsirkin" , "Dr. David Alan Gilbert" , Stefan Hajnoczi , Max Reitz 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" From: Vladimir Sementsov-Ogievskiy Incoming enabled bitmaps are busy, because we do bdrv_dirty_bitmap_create_successor() for them. But disabled bitmaps being migrated are not marked busy, and user can remove them during the incoming migration. Then we may crash in cancel_incoming_locked() when try to remove the bitmap that was already removed by user, like this: #0 qemu_mutex_lock_impl (mutex=3D0x5593d88c50d1, file=3D0x559680554b20 "../block/dirty-bitmap.c", line=3D64) at ../util/qemu-thread-posix.c:77 #1 bdrv_dirty_bitmaps_lock (bs=3D0x5593d88c0ee9) at ../block/dirty-bitmap.c:64 #2 bdrv_release_dirty_bitmap (bitmap=3D0x5596810e9570) at ../block/dirty-bitmap.c:362 #3 cancel_incoming_locked (s=3D0x559680be8208 ) at ../migration/block-dirty-bitmap.c:918 #4 dirty_bitmap_load (f=3D0x559681d02b10, opaque=3D0x559680be81e0 , version_id=3D1) at ../migration/block-dirty-bitmap.c:1194 #5 vmstate_load (f=3D0x559681d02b10, se=3D0x559680fb5810) at ../migration/savevm.c:908 #6 qemu_loadvm_section_part_end (f=3D0x559681d02b10, mis=3D0x559680fb4a30) at ../migration/savevm.c:2473 #7 qemu_loadvm_state_main (f=3D0x559681d02b10, mis=3D0x559680fb4a30) at ../migration/savevm.c:2626 #8 postcopy_ram_listen_thread (opaque=3D0x0) at ../migration/savevm.c:1871 #9 qemu_thread_start (args=3D0x5596817ccd10) at ../util/qemu-thread-posix.c:521 #10 start_thread () at /lib64/libpthread.so.0 #11 clone () at /lib64/libc.so.6 Note bs pointer taken from bitmap: it's definitely bad aligned. That's because we are in use after free, bitmap is already freed. So, let's make disabled bitmaps (being migrated) busy during incoming migration. Signed-off-by: Vladimir Sementsov-Ogievskiy Signed-off-by: Stefan Hajnoczi Message-Id: <20210322094906.5079-2-vsementsov@virtuozzo.com> --- migration/block-dirty-bitmap.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/migration/block-dirty-bitmap.c b/migration/block-dirty-bitmap.c index 975093610a..35f5ef688d 100644 --- a/migration/block-dirty-bitmap.c +++ b/migration/block-dirty-bitmap.c @@ -839,6 +839,8 @@ static int dirty_bitmap_load_start(QEMUFile *f, DBMLoad= State *s) error_report_err(local_err); return -EINVAL; } + } else { + bdrv_dirty_bitmap_set_busy(s->bitmap, true); } =20 b =3D g_new(LoadBitmapState, 1); @@ -914,6 +916,8 @@ static void cancel_incoming_locked(DBMLoadState *s) assert(!s->before_vm_start_handled || !b->migrated); if (bdrv_dirty_bitmap_has_successor(b->bitmap)) { bdrv_reclaim_dirty_bitmap(b->bitmap, &error_abort); + } else { + bdrv_dirty_bitmap_set_busy(b->bitmap, false); } bdrv_release_dirty_bitmap(b->bitmap); } @@ -951,6 +955,8 @@ static void dirty_bitmap_load_complete(QEMUFile *f, DBM= LoadState *s) =20 if (bdrv_dirty_bitmap_has_successor(s->bitmap)) { bdrv_reclaim_dirty_bitmap(s->bitmap, &error_abort); + } else { + bdrv_dirty_bitmap_set_busy(s->bitmap, false); } =20 for (item =3D s->bitmaps; item; item =3D g_slist_next(item)) { --=20 2.30.2 From nobody Sat May 4 20:44:06 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=1616598156; cv=none; d=zohomail.com; s=zohoarc; b=OmdIFT4CVPXcO+6Uwo5Acbp0YDvOKh4rC4igazWl1OXIbWGOK9gU1dIQiBYkksyw6cq+B88zrMEhxSMoPbGorW4iAbcCbF0eFXztSu9Kl17c1H2MVx1ejs5jJsKZePGmqbfQ5uLrwXXVZ04Ac/IYvnM1WSyYBXrDO6LVGDflecQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616598156; 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=H2BrJXy2Vl2C8DXZfkgJnxWmIEPwr5BP/v+1qy7ukXE=; b=MC3YnN/JD/A63KJHbGvIASU5HsiGdMl1R9bAXnG8tJ3DyRXvunQaBbTtHqmsRmxY0Lf9TYw3mR43i4PDeLZEWHMw4esZ0VSfCzNqSsctmshNz1+uYwes510KNIJhEqknZBN4T9RUlI3UYWU9GJ9jLrZhzKIrb88bsB8kn9n9aio= 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 16165981569511003.505101016682; Wed, 24 Mar 2021 08:02:36 -0700 (PDT) Received: from localhost ([::1]:54438 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lP51o-0003zS-7N for importer@patchew.org; Wed, 24 Mar 2021 11:02:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57456) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lP4s7-0008FT-2F for qemu-devel@nongnu.org; Wed, 24 Mar 2021 10:52:35 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:24184) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lP4s5-0002Q1-Jf for qemu-devel@nongnu.org; Wed, 24 Mar 2021 10:52:34 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-300-_X9U46HoP8K3msyU-95DgA-1; Wed, 24 Mar 2021 10:52:27 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E0A2D83DD37; Wed, 24 Mar 2021 14:52:25 +0000 (UTC) Received: from localhost (ovpn-115-111.ams2.redhat.com [10.36.115.111]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7A51B19C71; Wed, 24 Mar 2021 14:52:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1616597552; 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=H2BrJXy2Vl2C8DXZfkgJnxWmIEPwr5BP/v+1qy7ukXE=; b=M4Z2dIWRiudOva9DsX8afaLGm7DrJMjf1NPpEaIgMefLFitpZKow3GmcQ8J4tvMr5r6WIB lKjs7aEyxdnBVZLpCIA9++/NlM5oHzXufbk8uibCKxxJmm4sHw0IEHJNK0vVHDWqiY5uws LpLCMUnl+/zQDMoOy08IXK8PW+Tbdes= X-MC-Unique: _X9U46HoP8K3msyU-95DgA-1 From: Stefan Hajnoczi To: Peter Maydell , qemu-devel@nongnu.org Subject: [PULL 2/2] migrate-bitmaps-postcopy-test: check that we can't remove in-flight bitmaps Date: Wed, 24 Mar 2021 14:52:02 +0000 Message-Id: <20210324145202.430759-3-stefanha@redhat.com> In-Reply-To: <20210324145202.430759-1-stefanha@redhat.com> References: <20210324145202.430759-1-stefanha@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=stefanha@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=170.10.133.124; envelope-from=stefanha@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.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, MIME_BASE64_TEXT=1.741, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=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: Fam Zheng , Kevin Wolf , Vladimir Sementsov-Ogievskiy , Eduardo Habkost , qemu-block@nongnu.org, Juan Quintela , John Snow , "Michael S. Tsirkin" , "Dr. David Alan Gilbert" , Stefan Hajnoczi , Max Reitz 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" From: Vladimir Sementsov-Ogievskiy Check that we can't remove bitmaps being migrated on destination vm. The new check proves that previous commit helps. Signed-off-by: Vladimir Sementsov-Ogievskiy Signed-off-by: Stefan Hajnoczi Message-Id: <20210322094906.5079-3-vsementsov@virtuozzo.com> --- tests/qemu-iotests/tests/migrate-bitmaps-postcopy-test | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/qemu-iotests/tests/migrate-bitmaps-postcopy-test b/tests= /qemu-iotests/tests/migrate-bitmaps-postcopy-test index d046ebeb94..584062b412 100755 --- a/tests/qemu-iotests/tests/migrate-bitmaps-postcopy-test +++ b/tests/qemu-iotests/tests/migrate-bitmaps-postcopy-test @@ -224,6 +224,16 @@ class TestDirtyBitmapPostcopyMigration(iotests.QMPTest= Case): self.start_postcopy() =20 self.vm_b_events +=3D self.vm_b.get_qmp_events() + + # While being here, let's check that we can't remove in-flight bit= maps. + for vm in (self.vm_a, self.vm_b): + for i in range(0, nb_bitmaps): + result =3D vm.qmp('block-dirty-bitmap-remove', node=3D'dri= ve0', + name=3Df'bitmap{i}') + self.assert_qmp(result, 'error/desc', + f"Bitmap 'bitmap{i}' is currently in use b= y " + "another operation and cannot be used") + self.vm_b.shutdown() # recreate vm_b, so there is no incoming option, which prevents # loading bitmaps from disk --=20 2.30.2