From nobody Sat Apr 20 12:33:51 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1637758665; cv=none; d=zohomail.com; s=zohoarc; b=WwfGhPsm780+iXw1Sq0+n6SihDmTtgJCtcbZ6CwLoerXVR1tY76J5SiZbH76gdXvqsYDDz7eaXdTcXSnX4b6rxAc398kDFL/88pqRu9wsuK6HnXYOtGTkMYK+whXtNzus04jjG7fnnAh1qR8zyIhvFVGnC3rJhwh67GQWPymZac= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1637758665; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To; bh=r74SuUtul/xQc2wRTfF3lPhJnqC3Q9Cc632P+qkLC8A=; b=lRXXLQX8cetYjPJEpXP7CG9ZPuWWMzxB69e9Uzk7OuBPy70DLVkDV83DP/MZ2WMU1pgWRdrb5uLKeheVuCuX4vZf3kkRf+d+BgmZoEAI5i6yv5GopNi19YHZ6Kzr203H80GPvQpdE9wiAB7rituByc5JQd/tOZedI2EngueUmw0= ARC-Authentication-Results: i=1; mx.zohomail.com; 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 1637758665423376.86732397354467; Wed, 24 Nov 2021 04:57:45 -0800 (PST) Received: from localhost ([::1]:46212 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mprqJ-0000zv-9x for importer@patchew.org; Wed, 24 Nov 2021 07:57:43 -0500 Received: from eggs.gnu.org ([209.51.188.92]:36496) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mprou-0007jS-HF; Wed, 24 Nov 2021 07:56:16 -0500 Received: from szxga01-in.huawei.com ([45.249.212.187]:2958) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mpros-0002Py-0A; Wed, 24 Nov 2021 07:56:16 -0500 Received: from dggemv703-chm.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4Hzgww3vZNzcbKs; Wed, 24 Nov 2021 20:56:00 +0800 (CST) Received: from kwepemm600002.china.huawei.com (7.193.23.29) by dggemv703-chm.china.huawei.com (10.3.19.46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.20; Wed, 24 Nov 2021 20:56:02 +0800 Received: from [10.174.185.187] (10.174.185.187) by kwepemm600002.china.huawei.com (7.193.23.29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2308.20; Wed, 24 Nov 2021 20:56:01 +0800 Message-ID: Date: Wed, 24 Nov 2021 20:56:00 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.2.0 Content-Language: en-US To: "qemu-block@nongnu.org" , QEMU Developers CC: xiexiangyou 00584000 , zhengchuan , , "Fangyi (Eric)" , yebiaoxiang 00470486 Subject: Questions about losing the write lock of raw-format disks after migration Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.174.185.187] X-ClientProxiedBy: dggeme701-chm.china.huawei.com (10.1.199.97) To kwepemm600002.china.huawei.com (7.193.23.29) X-CFilter-Loop: Reflected 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=45.249.212.187; envelope-from=liangpeng10@huawei.com; helo=szxga01-in.huawei.com X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=-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.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" Reply-to: Peng Liang From: Peng Liang via X-ZM-MESSAGEID: 1637758666228100001 Content-Type: text/plain; charset="utf-8" Hi folks, When we test migration with raw-format disk, we found that the QEMU process in the dst will lose the write lock after migration. However, the QEMU process in the dst will still hold the write lock for qcow2-format disk. After reading some block layer's code, I found that the first blk_set_perm in blk_root_activate will set blk->shared_perm to BLK_PERM_ALL (disable all shared permissions?). Then in blk_vm_state_changed, blk_set_perm will set shared_perm to blk->shared_perm, which is BLK_PERM_ALL. And it makes raw_handle_perm_lock not to get the write lock. So I try the following patch and it will fix the problem: diff --git a/block/block-backend.c b/block/block-backend.c index 12ef80ea17..96518fd1f0 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -197,13 +197,6 @@ static void blk_root_activate(BdrvChild *child, Error **errp) blk->disable_perm =3D false; - blk_set_perm(blk, blk->perm, BLK_PERM_ALL, &local_err); - if (local_err) { - error_propagate(errp, local_err); - blk->disable_perm =3D true; - return; - } - if (runstate_check(RUN_STATE_INMIGRATE)) { /* Activation can happen when migration process is still active, for * example when nbd_server_add is called during non-shared storage I'm new to the block layer and I'm not sure that it's a right fix to the problem. Any idea about the problem and the patch? Thanks, Peng