From nobody Mon Nov 23 04:28:06 2026 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=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1794926002; cv=none; d=zohomail.com; s=zohoarc; b=gwNlNiYQ3ndhAtZLFiNS4dhio0/vAdLlAurPZYVGtokKNqO+XEcZxJTZzU9zGRUw6qgOqMspxjgGjicHrsWoSM+0BSsqLlA0lCEYJ8ysHK3jmBbSE4KPPzypZCARqRTbOCoE5lfwxBHcJAzWF2ckLg6tlyrMPPm15WcVDiGxpL8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794926002; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=JR1MwD668yPmOfS9wAte8Q/rLaWYUqNujJRB4p7iiUk=; b=I9QmYCqex74XXZC7ovCwO25pPPu+c5vQBKndhfLzo+uodgaehm4xY40+RfI2jpreEdoqXS233LvJ5tINn2WGy0YIz69TL4c6MfIoMjpXzrjYe49pR1GwMoCm0VXGaJHGTeT8fNQQSl052U0hu3uy/hZzahpPeFvREsUwxw2Cnzg= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1794926002757817.6551537574632; Tue, 17 Nov 2026 06:33:22 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xTKEo-0007cv-IY; Tue, 17 Nov 2026 09:32:46 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xTKEm-0007bT-J5 for qemu-devel@nongnu.org; Tue, 17 Nov 2026 09:32:44 -0500 Received: from smtp-out1.suse.de ([2a07:de40:b251:101:10:150:64:1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xTKEk-00041y-SS for qemu-devel@nongnu.org; Tue, 17 Nov 2026 09:32:44 -0500 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id DD56322314; Tue, 17 Nov 2026 14:32:39 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id D9EA5134B8; Tue, 17 Nov 2026 14:32:37 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id lN5qDIRl/GpRQAAAD6G6ig:T2 (envelope-from ); Tue, 17 Nov 2026 14:32:37 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1794925961; h=from:from:reply-to: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=JR1MwD668yPmOfS9wAte8Q/rLaWYUqNujJRB4p7iiUk=; b=x74JF2O7jDiMiDG+AcPTnl11N/qiomPYNfZsR+oOv9S6Tq02WL/aSglbPIVwv5vWagFOJz KBVjEhH3R5qqZYpmzeGm34OLQHjHe6r+dri5PUJ9PLBEwaokKHC8gAC/5iZz7oVoZ2Tk2+ tXln0EE7MJTMPCZp+ZsD8UgzxSxe8As= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1794925961; h=from:from:reply-to: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=JR1MwD668yPmOfS9wAte8Q/rLaWYUqNujJRB4p7iiUk=; b=wmCgp/T0cBwd7SuT2tq57QfiGZ+IOsZrCz+98QCHhqUug6dMhYtdXs+TU1XNgwPQKmzDMk /tEjGMjXxOgrQwCg== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=dujBMMF0; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=8w8g+Kgr DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1794925959; h=from:from:reply-to: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=JR1MwD668yPmOfS9wAte8Q/rLaWYUqNujJRB4p7iiUk=; b=dujBMMF0D2UdpdDKnMioIXr5pyhFHnEHKu12JbwPGVQVDPgWr+IDgyIIM2HVLxxMXIVhOb 8JAPXwaGWdj093M1nsR+fdzC0y95Y0friy+3i8yjpFNDM8y5iZq68ybu2X0VqOvkKLJDhf f2p7EasahwusOkq2zX41a03Px2wZhGY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1794925959; h=from:from:reply-to: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=JR1MwD668yPmOfS9wAte8Q/rLaWYUqNujJRB4p7iiUk=; b=8w8g+KgrOF6C0t8bHpqomAOFn5iArJSEQIteyB/+Mmleoov6MzyE0/ZIAdHzw+qFsHocQe QDNStKrtLLXrESBA== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Peter Xu , "Denis V. Lunev" , "Maciej S. Szmigiero" , Mark Kanda , Ben Chaney , Steve Sistare Subject: [PULL 1/3] migration/cpr: document the BQL as the cpr fd table lock Date: Tue, 17 Nov 2026 11:32:31 -0300 Message-ID: <20261117143234.1794926-2-farosas@suse.de> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261117143234.1794926-1-farosas@suse.de> References: <20261117143234.1794926-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spamd-Result: default: False [-12.01 / 50.00]; SUSE_INTERNAL_BYPASS(-9.00)[]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FROM_EQ_ENVFROM(0.00)[]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; FROM_HAS_DN(0.00)[]; URIBL_BLOCKED(0.00)[imap1.dmz-prg2.suse.org:rdns,imap1.dmz-prg2.suse.org:helo,oracle.com:email,suse.de:email,suse.de:dkim]; RCVD_TLS_ALL(0.00)[]; RCPT_COUNT_SEVEN(0.00)[7]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RCVD_COUNT_TWO(0.00)[2]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:rdns,imap1.dmz-prg2.suse.org:helo,suse.de:email,suse.de:dkim]; DWL_DNSWL_BLOCKED(0.00)[suse.de:dkim]; TO_DN_SOME(0.00)[]; DKIM_TRACE(0.00)[suse.de:+] X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Rspamd-Action: no action X-Spam-Score: -12.01 X-Rspamd-Queue-Id: DD56322314 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a07:de40:b251:101:10:150:64:1; envelope-from=farosas@suse.de; helo=smtp-out1.suse.de 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, 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: qemu development 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 @suse.de) (identity @suse.de) X-ZM-MESSAGEID: 1794926004284158500 Content-Type: text/plain; charset="utf-8" From: "Denis V. Lunev" Every user of the cpr fd table runs under the BQL: device realize and unrealize, backend creation, RAM block allocation and freeing (the latter also from RCU callbacks, which take the BQL), vfio MSI-X vector setup from vCPU threads, and the cpr state save, load and cpr-exec walk on the main thread. The table has no lock of its own and depends on that, but nothing says so. Say it at the declarations. The obvious way to break it is a socket chardev preserved across CPR: its connection hooks run in the chardev's GMainContext, which for the monitor is the QMP iothread, and that thread must not take the BQL or out-of-band commands stop working. Such a user needs the table to grow a lock of its own, and has to keep the saved table and the preserved fds in agreement when a connection comes or goes during cpr-exec. Both belong with the series that adds it. Signed-off-by: Denis V. Lunev Cc: Maciej S. Szmigiero Cc: Peter Xu Cc: Fabiano Rosas Cc: Mark Kanda Cc: Ben Chaney Cc: Steve Sistare Acked-by: Maciej S. Szmigiero Signed-off-by: Fabiano Rosas --- include/migration/cpr.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/migration/cpr.h b/include/migration/cpr.h index 3ad084d5bab..5ac46b62073 100644 --- a/include/migration/cpr.h +++ b/include/migration/cpr.h @@ -28,6 +28,7 @@ typedef struct CprState { =20 extern CprState cpr_state; =20 +/* The cpr fd table, including cpr_walk_fd(), is protected by the BQL. */ bool cpr_save_fd(const char *name, int id, int fd, Error **errp); void cpr_delete_fd(const char *name, int id); int cpr_find_fd(const char *name, int id); --=20 2.53.0 From nobody Mon Nov 23 04:28:06 2026 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=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1794926017; cv=none; d=zohomail.com; s=zohoarc; b=V9CFnylojHOM+5SYUFGcGPk8K1Gc/EDyTLDs27beUOBZUGwirA6FGDX/0s1268OvMffKwk2v4cVeikXTc+H3J6ZPRAHFrsUS8n3Y0xQpIzTpI6jbNSpIhOgbSBj4fAl0GulRi2xCtj+8O+dQ/BK4dIv1tTxRJ4aOR6w00h4yGzw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794926017; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=aWk6QXenceXHDB2foceOzqdWr7mbh8OdPJHbQGcw+Zg=; b=gSmqn3KnyYXxFMkfIERRXjsPSXkO5pbhuMiGe4JEPmVTOIajICX+iG5i4nxwjipDsm8+Z+HhEzfbj6PT81VF30QJg3udUADFzPt0iSLCMWSXan5E+/xFAPBQqBOfMrRKA6HmVEgwZaa9+1Abowjs+V9MU2JNlE1PDc8imoeMLaI= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1794926017269705.7994103424484; Tue, 17 Nov 2026 06:33:37 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xTKEr-0007dv-5D; Tue, 17 Nov 2026 09:32:49 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xTKEp-0007da-Mg for qemu-devel@nongnu.org; Tue, 17 Nov 2026 09:32:47 -0500 Received: from smtp-out2.suse.de ([2a07:de40:b251:101:10:150:64:2]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xTKEo-00042T-2a for qemu-devel@nongnu.org; Tue, 17 Nov 2026 09:32:47 -0500 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 7F66B1F7A4; Tue, 17 Nov 2026 14:32:41 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 2A18813507; Tue, 17 Nov 2026 14:32:39 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id lN5qDIRl/GpRQAAAD6G6ig:T3 (envelope-from ); Tue, 17 Nov 2026 14:32:39 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1794925963; h=from:from:reply-to: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=aWk6QXenceXHDB2foceOzqdWr7mbh8OdPJHbQGcw+Zg=; b=w62znqvKiz0fjvu4VgNavOtMOipkXhjbr7wpwlgjw+I6xy+UJ75tZRQ6NcfhcvKY40tMWs rM0OkYg0Q7nJiS9deNCLyGwtKrvd6hgHVBbzFsyTVYA1vMC7mSzCCastk2Ifh/a6NRBf9F WWSbabXu+0ib9aTLT91BtMSbroSZYYw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1794925963; h=from:from:reply-to: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=aWk6QXenceXHDB2foceOzqdWr7mbh8OdPJHbQGcw+Zg=; b=g88/3Jw1aIVS0OzS4BD6iAA1v+l9gUTToXJYMeHswTrb6QvqNOZZT5Ud35OJ+f5AmcgVl0 Hzjbszu1D1SWOWCw== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b="jpn3/Txw"; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=mSkfj8I8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1794925961; h=from:from:reply-to: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=aWk6QXenceXHDB2foceOzqdWr7mbh8OdPJHbQGcw+Zg=; b=jpn3/TxwQw1HwgpH7kuvlxhhG/zE5UiVOIc76z3VRckVheBwL2VTFOELCg1BfJd9OkitCb ax38lfizN7bgvKDLGMKW6utQbeHwjBQGZcmFrr3THKARTPAmc5aqKb275vFR/hYqCuA6Kp 4L/wpuZj+dmaBNvETXd4sZcgzL0L0So= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1794925961; h=from:from:reply-to: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=aWk6QXenceXHDB2foceOzqdWr7mbh8OdPJHbQGcw+Zg=; b=mSkfj8I8QG8Hs3KRvIN2BQj7UEpwgc9J5JO2tI+ZdrJku3vLe2uU7BOZw9qT4ZpdHmCxgf BpxCKituT9RLUfBA== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Peter Xu , niming , zhuwei Subject: [PULL 2/3] migration: free migration blocker error in migrate_del_blocker() stub Date: Tue, 17 Nov 2026 11:32:32 -0300 Message-ID: <20261117143234.1794926-3-farosas@suse.de> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261117143234.1794926-1-farosas@suse.de> References: <20261117143234.1794926-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spamd-Result: default: False [-12.01 / 50.00]; SUSE_INTERNAL_BYPASS(-9.00)[]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; URIBL_BLOCKED(0.00)[suse.de:email,suse.de:dkim,imap1.dmz-prg2.suse.org:rdns,imap1.dmz-prg2.suse.org:helo]; FROM_EQ_ENVFROM(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RCVD_TLS_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email,suse.de:dkim,sangfor.com.cn:email,imap1.dmz-prg2.suse.org:rdns,imap1.dmz-prg2.suse.org:helo]; DWL_DNSWL_BLOCKED(0.00)[suse.de:dkim]; RCPT_COUNT_THREE(0.00)[4]; DKIM_TRACE(0.00)[suse.de:+] X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Rspamd-Action: no action X-Spam-Score: -12.01 X-Rspamd-Queue-Id: 7F66B1F7A4 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a07:de40:b251:101:10:150:64:2; envelope-from=farosas@suse.de; helo=smtp-out2.suse.de 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, 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: qemu development 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 @suse.de) (identity @suse.de) X-ZM-MESSAGEID: 1794926018635158500 Content-Type: text/plain; charset="utf-8" From: niming The migrate_del_blocker() implementation in stubs/migr-blocker.c was an empty no-op, while the real one in migration/migration.c takes ownership of the Error from the migration blocker, frees it and then clears the pointer: void migrate_del_blocker(Error **reasonp) { if (*reasonp) { ... error_free(*reasonp); *reasonp =3D NULL; } } Command line tools such as qemu-img link against the stub API. Block drivers like vmdk allocate a migration blocker Error during open() (see error_setg() in vmdk_open(), "does not support live migration") and pass it to migrate_add_blocker_normal(). Because the stub migrate_add_blocker*() is a no-op it does not take ownership of the Error, so on close the stub migrate_del_blocker() has to free it itself; leaving the body empty leaks the error message. This becomes visible when running under ASan: "qemu-img info foo.vmdk" leaks the migration-blocker error and hangs / fails to exit when the image is closed. Free the Error in the stub migrate_del_blocker() and set the pointer to NULL to match the semantics of the real implementation. This also covers every other driver that uses a migration blocker through the stub. Signed-off-by: niming Signed-off-by: zhuwei Reviewed-by: Fabiano Rosas Signed-off-by: Fabiano Rosas --- stubs/migr-blocker.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/stubs/migr-blocker.c b/stubs/migr-blocker.c index e54c7160d3d..3c1f2813814 100644 --- a/stubs/migr-blocker.c +++ b/stubs/migr-blocker.c @@ -1,5 +1,6 @@ #include "qemu/osdep.h" #include "migration/blocker.h" +#include "qapi/error.h" =20 int migrate_add_blocker(Error **reasonp, Error **errp) { @@ -18,4 +19,12 @@ int migrate_add_blocker_modes(Error **reasonp, unsigned = modes, Error **errp) =20 void migrate_del_blocker(Error **reasonp) { + /* + * migrate_add_blocker*() is a no-op here, so nobody owns the Error; + * free it to avoid a leak (e.g. "qemu-img info foo.vmdk"). + */ + if (reasonp && *reasonp) { + error_free(*reasonp); + *reasonp =3D NULL; + } } --=20 2.53.0 From nobody Mon Nov 23 04:28:06 2026 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=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1794926026; cv=none; d=zohomail.com; s=zohoarc; b=nypEyK+blkc3Yfv+oo90jKQGKET8g8cINF4X8NrMosYDuvQkh7ac+u7USK6qbMQQZKABtf2kIBHQLDVYiuE7ffkH65KFTAUFg/+XFRxG1R+v5JYDD5gbqygiooNHNvc594d7GZpXK22IQ/jsk/udawlpg2Vw5jGwIoHXaAGH3m8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794926026; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=G/ZErue8AsC6VlgD7OA3rBeSvKsJAVD60f9x4gvoZpk=; b=Eusnm6hd80u4TvRmRABON+k3RHBSInh4xgj8A5WIhSQKJrhPGTTlVIfjqyPAkva4xztVWcwypk7P8PjpWt231yoLe38ClWQvbu4NEPrh/VP+/tuza2C50GbzLUIR2Kv9k25gMGp5OlICimzhmgQAkD07JocVKLEEdj8EjAyO5m0= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1794926026267894.0660803816622; Tue, 17 Nov 2026 06:33:46 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xTKEr-0007e1-LP; Tue, 17 Nov 2026 09:32:49 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xTKEq-0007dj-5a; Tue, 17 Nov 2026 09:32:48 -0500 Received: from smtp-out1.suse.de ([195.135.223.130]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xTKEn-00042K-Qg; Tue, 17 Nov 2026 09:32:47 -0500 Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id CE8FB22311; Tue, 17 Nov 2026 14:32:43 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id CA44113302; Tue, 17 Nov 2026 14:32:41 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id lN5qDIRl/GpRQAAAD6G6ig:T4 (envelope-from ); Tue, 17 Nov 2026 14:32:41 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1794925964; h=from:from:reply-to: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=G/ZErue8AsC6VlgD7OA3rBeSvKsJAVD60f9x4gvoZpk=; b=loVEcato7F9/wBM8yVXIqH+Cl59GY1hMJ+alp3qkLHxOINtg6KM/ZlZQCFkSLC356+6ZGg scvF/6wxjC+XJEnlzDV5CruDgBQkOD+mHnQ4Y2/OdXnQeEy3j6eJWK0sXtjJu0dyKdztqS BnTNOee2GW4v+l9/dQ4IrAJ+O8uaNgs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1794925964; h=from:from:reply-to: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=G/ZErue8AsC6VlgD7OA3rBeSvKsJAVD60f9x4gvoZpk=; b=xqyQON1RLnKLYGbNN8cXoZhxi+Dp1NRtQoAWgvglcJv2aWtNy3BorAzNtg36m89XlL89VU 5QBp9iOtK+UN14Bw== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1794925963; h=from:from:reply-to: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=G/ZErue8AsC6VlgD7OA3rBeSvKsJAVD60f9x4gvoZpk=; b=MyDd7ksLOcKasmppK2ohPOAD2Y1QvVLmhnomUQ9WRVS76+7rHLE9kvrNEbwmu5+HPnFU+5 ZtOsKBd3Ux3QAdEJYXX15q6F42O23Cf7QSRNkcIseDgPViIccPvXRBbSSWgYwBeqo+S7HZ 1TM1fEii0rSHvfg+cBRDWwYj8DxCKzQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1794925963; h=from:from:reply-to: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=G/ZErue8AsC6VlgD7OA3rBeSvKsJAVD60f9x4gvoZpk=; b=/xwSD3emlD/nnM8PUwZ2gHOaRZgUE0+vZZftRqBGj/oh+YColoLoTQWGZCM7+UqoGz89wX brem1Fc5vfd4a9BQ== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Peter Xu , "Denis V. Lunev" , Vladimir Sementsov-Ogievskiy , Eric Blake , John Snow , qemu-block@nongnu.org Subject: [PULL 3/3] migration/block-dirty-bitmap: don't hold the load lock across stream reads Date: Tue, 17 Nov 2026 11:32:33 -0300 Message-ID: <20261117143234.1794926-4-farosas@suse.de> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261117143234.1794926-1-farosas@suse.de> References: <20261117143234.1794926-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spamd-Result: default: False [-11.80 / 50.00]; SUSE_INTERNAL_BYPASS(-9.00)[]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-0.996]; MIME_GOOD(-0.10)[text/plain]; ARC_NA(0.00)[]; RCPT_COUNT_SEVEN(0.00)[7]; MIME_TRACE(0.00)[0:+]; RCVD_VIA_SMTP_AUTH(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; URIBL_BLOCKED(0.00)[imap1.dmz-prg2.suse.org:helo,suse.de:email]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email,imap1.dmz-prg2.suse.org:helo]; RCVD_TLS_ALL(0.00)[] X-Spam-Score: -11.80 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=lists1p.gnu.org; Received-SPF: pass client-ip=195.135.223.130; envelope-from=farosas@suse.de; helo=smtp-out1.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, 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: qemu development 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 @suse.de) (identity @suse.de) X-ZM-MESSAGEID: 1794926028893158500 Content-Type: text/plain; charset="utf-8" From: "Denis V. Lunev" dirty_bitmap_load() takes dbm_state.load.lock for each chunk and holds it while it reads the chunk from the migration stream. In precopy the load runs in the incoming migration coroutine, which yields in qemu_fill_buffer() while it waits for data, still holding the lock. A quit on the destination at that point never completes: migration_shutdown() calls dirty_bitmap_mig_cancel_incoming(), which takes the same lock in the same main thread. In postcopy the load runs in the listen thread, and the main thread takes the lock in dirty_bitmap_mig_before_vm_start(), called from loadvm_postcopy_handle_run_bh(), and in migration_shutdown(). The main loop then waits until the source sends the next chunk. Read each chunk into a DBMLoadChunk first and take the lock only to resolve the names and apply the chunk. The lock protects the bitmaps list and the resolved node and bitmap, which the main thread uses. The flags and alias strings read from the stream are only touched by the code doing the load. Signed-off-by: Denis V. Lunev Cc: Vladimir Sementsov-Ogievskiy Cc: Eric Blake Cc: John Snow Cc: Peter Xu Cc: Fabiano Rosas Cc: qemu-block@nongnu.org Reviewed-by: Eric Blake Signed-off-by: Fabiano Rosas --- migration/block-dirty-bitmap.c | 222 +++++++++++++++++++-------------- 1 file changed, 130 insertions(+), 92 deletions(-) diff --git a/migration/block-dirty-bitmap.c b/migration/block-dirty-bitmap.c index 35623379eb6..14e5a984e47 100644 --- a/migration/block-dirty-bitmap.c +++ b/migration/block-dirty-bitmap.c @@ -796,12 +796,22 @@ static void dirty_bitmap_state_pending(void *opaque, = MigPendingData *data, data->postcopy_bytes +=3D pending; } =20 +/* Chunk payload, read from the stream without holding DBMLoadState.lock */ +typedef struct DBMLoadChunk { + uint32_t granularity; + uint8_t start_flags; + uint64_t first_byte; + uint64_t nr_bytes; + uint64_t buf_size; + uint8_t *buf; +} DBMLoadChunk; + /* First occurrence of this bitmap. It should be created if doesn't exist = */ -static int dirty_bitmap_load_start(QEMUFile *f, DBMLoadState *s) +static int dirty_bitmap_load_start(DBMLoadState *s, DBMLoadChunk *c) { Error *local_err =3D NULL; - uint32_t granularity =3D qemu_get_be32(f); - uint8_t flags =3D qemu_get_byte(f); + uint32_t granularity =3D c->granularity; + uint8_t flags =3D c->start_flags; LoadBitmapState *b; bool persistent; =20 @@ -959,7 +969,7 @@ void dirty_bitmap_mig_cancel_incoming(void) qemu_mutex_unlock(&s->lock); } =20 -static void dirty_bitmap_load_complete(QEMUFile *f, DBMLoadState *s) +static void dirty_bitmap_load_complete(DBMLoadState *s) { GSList *item; trace_dirty_bitmap_load_complete(); @@ -990,71 +1000,43 @@ static void dirty_bitmap_load_complete(QEMUFile *f, = DBMLoadState *s) } } =20 -static int dirty_bitmap_load_bits(QEMUFile *f, DBMLoadState *s) +static int dirty_bitmap_load_bits(DBMLoadState *s, DBMLoadChunk *c) { - uint64_t first_byte =3D qemu_get_be64(f) << BDRV_SECTOR_BITS; - uint64_t nr_bytes =3D (uint64_t)qemu_get_be32(f) << BDRV_SECTOR_BITS; - trace_dirty_bitmap_load_bits_enter(first_byte >> BDRV_SECTOR_BITS, - nr_bytes >> BDRV_SECTOR_BITS); + uint64_t needed_size; + + trace_dirty_bitmap_load_bits_enter(c->first_byte >> BDRV_SECTOR_BITS, + c->nr_bytes >> BDRV_SECTOR_BITS); =20 if (s->flags & DIRTY_BITMAP_MIG_FLAG_ZEROES) { trace_dirty_bitmap_load_bits_zeroes(); if (!s->cancelled) { - bdrv_dirty_bitmap_deserialize_zeroes(s->bitmap, first_byte, - nr_bytes, false); - } - } else { - size_t ret; - g_autofree uint8_t *buf =3D NULL; - uint64_t buf_size =3D qemu_get_be64(f); - uint64_t needed_size; - - /* - * The actual check for buf_size is done a bit later. We can't do = it in - * cancelled mode as we don't have the bitmap to check the constra= ints - * (so, we allocate a buffer and read prior to the check). On the = other - * hand, we shouldn't blindly g_malloc the number from the stream. - * Actually one chunk should not be larger than CHUNK_SIZE. Let's = allow - * a bit larger (which means that bitmap migration will fail anywa= y and - * the whole migration will most probably fail soon due to broken - * stream). - */ - if (buf_size > 10 * CHUNK_SIZE) { - error_report("Bitmap migration stream buffer allocation reques= t " - "is too large"); - return -EIO; - } - - buf =3D g_malloc(buf_size); - ret =3D qemu_get_buffer(f, buf, buf_size); - if (ret !=3D buf_size) { - error_report("Failed to read bitmap bits"); - return -EIO; - } - - if (s->cancelled) { - return 0; + bdrv_dirty_bitmap_deserialize_zeroes(s->bitmap, c->first_byte, + c->nr_bytes, false); } + return 0; + } =20 - needed_size =3D bdrv_dirty_bitmap_serialization_size(s->bitmap, - first_byte, - nr_bytes); + if (s->cancelled) { + return 0; + } =20 - if (needed_size > buf_size || - buf_size > QEMU_ALIGN_UP(needed_size, 4 * sizeof(long)) - /* Here used same alignment as in send_bitmap_bits */ - ) { - error_report("Migrated bitmap granularity doesn't " - "match the destination bitmap '%s' granularity", - bdrv_dirty_bitmap_name(s->bitmap)); - cancel_incoming_locked(s); - return 0; - } + needed_size =3D bdrv_dirty_bitmap_serialization_size(s->bitmap, + c->first_byte, + c->nr_bytes); =20 - bdrv_dirty_bitmap_deserialize_part(s->bitmap, buf, first_byte, nr_= bytes, - false); + if (needed_size > c->buf_size || + c->buf_size > QEMU_ALIGN_UP(needed_size, 4 * sizeof(long)) + /* Here used same alignment as in send_bitmap_bits */ + ) { + error_report("Migrated bitmap granularity doesn't " + "match the destination bitmap '%s' granularity", + bdrv_dirty_bitmap_name(s->bitmap)); + cancel_incoming_locked(s); + return 0; } =20 + bdrv_dirty_bitmap_deserialize_part(s->bitmap, c->buf, c->first_byte, + c->nr_bytes, false); return 0; } =20 @@ -1105,23 +1087,73 @@ static BdrvDirtyBitmap *dirty_bitmap_load_find_bitm= ap(DBMLoadState *s) return NULL; } =20 -static int dirty_bitmap_load_header(QEMUFile *f, DBMLoadState *s, - GHashTable *alias_map) +static int dirty_bitmap_read_chunk(QEMUFile *f, DBMLoadState *s, + DBMLoadChunk *c) { - GHashTable *bitmap_alias_map =3D NULL; - Error *local_err =3D NULL; - bool nothing; s->flags =3D qemu_get_bitmap_flags(f); trace_dirty_bitmap_load_header(s->flags); =20 + if ((s->flags & DIRTY_BITMAP_MIG_FLAG_DEVICE_NAME) && + !qemu_get_counted_string(f, s->node_alias)) { + error_report("Unable to read node alias string"); + return -EINVAL; + } + + if ((s->flags & DIRTY_BITMAP_MIG_FLAG_BITMAP_NAME) && + !qemu_get_counted_string(f, s->bitmap_alias)) { + error_report("Unable to read bitmap alias string"); + return -EINVAL; + } + + if (s->flags & DIRTY_BITMAP_MIG_FLAG_START) { + c->granularity =3D qemu_get_be32(f); + c->start_flags =3D qemu_get_byte(f); + } else if (s->flags & DIRTY_BITMAP_MIG_FLAG_COMPLETE) { + /* no payload */ + } else if (s->flags & DIRTY_BITMAP_MIG_FLAG_BITS) { + c->first_byte =3D qemu_get_be64(f) << BDRV_SECTOR_BITS; + c->nr_bytes =3D (uint64_t)qemu_get_be32(f) << BDRV_SECTOR_BITS; + + if (!(s->flags & DIRTY_BITMAP_MIG_FLAG_ZEROES)) { + c->buf_size =3D qemu_get_be64(f); + + /* + * The actual check for buf_size is done when the chunk is + * applied. We can't do it in cancelled mode as we don't have = the + * bitmap to check the constraints (so, we allocate a buffer a= nd + * read prior to the check). On the other hand, we shouldn't + * blindly g_malloc the number from the stream. Actually one c= hunk + * should not be larger than CHUNK_SIZE. Let's allow a bit lar= ger + * (which means that bitmap migration will fail anyway and the + * whole migration will most probably fail soon due to broken + * stream). + */ + if (c->buf_size > 10 * CHUNK_SIZE) { + error_report("Bitmap migration stream buffer allocation " + "request is too large"); + return -EIO; + } + + c->buf =3D g_malloc(c->buf_size); + if (qemu_get_buffer(f, c->buf, c->buf_size) !=3D c->buf_size) { + error_report("Failed to read bitmap bits"); + return -EIO; + } + } + } + + return qemu_file_get_error(f); +} + +static void dirty_bitmap_load_header(DBMLoadState *s, GHashTable *alias_ma= p) +{ + GHashTable *bitmap_alias_map =3D NULL; + Error *local_err =3D NULL; + bool nothing; + nothing =3D s->flags =3D=3D (s->flags & DIRTY_BITMAP_MIG_FLAG_EOS); =20 if (s->flags & DIRTY_BITMAP_MIG_FLAG_DEVICE_NAME) { - if (!qemu_get_counted_string(f, s->node_alias)) { - error_report("Unable to read node alias string"); - return -EINVAL; - } - if (!s->cancelled) { if (alias_map) { const AliasMapInnerNode *amin; @@ -1165,11 +1197,6 @@ static int dirty_bitmap_load_header(QEMUFile *f, DBM= LoadState *s, if (s->flags & DIRTY_BITMAP_MIG_FLAG_BITMAP_NAME) { const char *bitmap_name; =20 - if (!qemu_get_counted_string(f, s->bitmap_alias)) { - error_report("Unable to read bitmap alias string"); - return -EINVAL; - } - bitmap_name =3D s->bitmap_alias; if (!s->cancelled && bitmap_alias_map) { BitmapMigrationBitmapAlias *bmap_inner; @@ -1206,7 +1233,23 @@ static int dirty_bitmap_load_header(QEMUFile *f, DBM= LoadState *s, error_report("Error: block device name is not set"); cancel_incoming_locked(s); } +} =20 +static int dirty_bitmap_apply_chunk(DBMLoadState *s, DBMLoadChunk *c, + GHashTable *alias_map) +{ + dirty_bitmap_load_header(s, alias_map); + + if (s->flags & DIRTY_BITMAP_MIG_FLAG_START) { + return dirty_bitmap_load_start(s, c); + } + if (s->flags & DIRTY_BITMAP_MIG_FLAG_COMPLETE) { + dirty_bitmap_load_complete(s); + return 0; + } + if (s->flags & DIRTY_BITMAP_MIG_FLAG_BITS) { + return dirty_bitmap_load_bits(s, c); + } return 0; } =20 @@ -1240,28 +1283,23 @@ static int dirty_bitmap_load(QEMUFile *f, void *opa= que, int version_id) } =20 do { - QEMU_LOCK_GUARD(&s->lock); + DBMLoadChunk c =3D {}; =20 - ret =3D dirty_bitmap_load_header(f, s, alias_map); - if (ret < 0) { - cancel_incoming_locked(s); - goto fail; + /* + * dirty_bitmap_mig_before_vm_start() takes the lock from the main + * thread, so never hold it while waiting for the stream. + */ + ret =3D dirty_bitmap_read_chunk(f, s, &c); + WITH_QEMU_LOCK_GUARD(&s->lock) { + if (!ret) { + ret =3D dirty_bitmap_apply_chunk(s, &c, alias_map); + } + if (ret) { + cancel_incoming_locked(s); + } } - - if (s->flags & DIRTY_BITMAP_MIG_FLAG_START) { - ret =3D dirty_bitmap_load_start(f, s); - } else if (s->flags & DIRTY_BITMAP_MIG_FLAG_COMPLETE) { - dirty_bitmap_load_complete(f, s); - } else if (s->flags & DIRTY_BITMAP_MIG_FLAG_BITS) { - ret =3D dirty_bitmap_load_bits(f, s); - } - - if (!ret) { - ret =3D qemu_file_get_error(f); - } - + g_free(c.buf); if (ret) { - cancel_incoming_locked(s); goto fail; } } while (!(s->flags & DIRTY_BITMAP_MIG_FLAG_EOS)); --=20 2.53.0