From nobody Mon Nov 25 01:46:09 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1718650750; cv=none; d=zohomail.com; s=zohoarc; b=evmsshllOUr/0ySGyuN/TLAlXTcvTjdsYgInEEnjzM7oc5w8Rc0c5dL5WFz7Hdax40y40sdYxejjG9u+rm0ILZTUMtBYVZLR76err8Nu4yQoMS80Z+2X+Q2smIqIzPzS/32YcOdYtSkX8iErLN6Vcib0/9+cgRuCVS3PlZ2bPpM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1718650750; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=WXqEOrVZdg1+BOI5G1h/hvBtQRGXPcKHvzMkiAmrGfU=; b=VKzJG5kYeQDs53TlgDc3EEMDHTIIy0pqUTguinthEeTRgFIecPmL6HE+x/1IoNXDGl0ACi8b72iYLadNbvO88a7A7OOzlh6kua9j/1DQjfvan8EDDbno4D7kDks06hOwQiKQ/g5E0bMltoCNjh5v6FmalYf0vrDfD2phZBaKCoA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1718650750810727.1634856178365; Mon, 17 Jun 2024 11:59:10 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sJHY0-0003ju-RF; Mon, 17 Jun 2024 14:57:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sJHXy-0003j5-Ok for qemu-devel@nongnu.org; Mon, 17 Jun 2024 14:57:42 -0400 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 1sJHXw-0004l8-WF for qemu-devel@nongnu.org; Mon, 17 Jun 2024 14:57:42 -0400 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 F346D21AD4; Mon, 17 Jun 2024 18:57:37 +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 10B2C139AB; Mon, 17 Jun 2024 18:57:35 +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 6L4XMh+HcGYJKAAAD6G6ig (envelope-from ); Mon, 17 Jun 2024 18:57:35 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1718650658; 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=WXqEOrVZdg1+BOI5G1h/hvBtQRGXPcKHvzMkiAmrGfU=; b=DJSt6meGjR3KluHIwi7DNVMBIWbFTM+SXg9DvMx2IkQTd823o/8Xhe3j35+FlqQ3dhN8QP k4qt92bQUOVYaJeqkO+LTxL2lEHbQnGUz66aVE+m7XRICahRfIyzwa6TovsOvrziZzV+xi 1LG5eVIeYuDZzaBlcmrZ/oKJmLAn4UQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1718650658; 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=WXqEOrVZdg1+BOI5G1h/hvBtQRGXPcKHvzMkiAmrGfU=; b=oW4VsHtcvIJ3DN2FMIZ3lIEsbnTGLdBLAyMnEQ28QoeWbRho3r+v5ZaPtmncQWXTzBwSNG eQckOBY5PQ2njvDQ== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1718650658; 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=WXqEOrVZdg1+BOI5G1h/hvBtQRGXPcKHvzMkiAmrGfU=; b=DJSt6meGjR3KluHIwi7DNVMBIWbFTM+SXg9DvMx2IkQTd823o/8Xhe3j35+FlqQ3dhN8QP k4qt92bQUOVYaJeqkO+LTxL2lEHbQnGUz66aVE+m7XRICahRfIyzwa6TovsOvrziZzV+xi 1LG5eVIeYuDZzaBlcmrZ/oKJmLAn4UQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1718650658; 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=WXqEOrVZdg1+BOI5G1h/hvBtQRGXPcKHvzMkiAmrGfU=; b=oW4VsHtcvIJ3DN2FMIZ3lIEsbnTGLdBLAyMnEQ28QoeWbRho3r+v5ZaPtmncQWXTzBwSNG eQckOBY5PQ2njvDQ== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: berrange@redhat.com, armbru@redhat.com, Peter Xu , Claudio Fontana , Jim Fehlig Subject: [PATCH v3 01/16] migration: Drop reference to QIOChannel if file seeking fails Date: Mon, 17 Jun 2024 15:57:16 -0300 Message-Id: <20240617185731.9725-2-farosas@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240617185731.9725-1-farosas@suse.de> References: <20240617185731.9725-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spamd-Result: default: False [-2.79 / 50.00]; BAYES_HAM(-3.00)[99.97%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_COUNT_TWO(0.00)[2]; TO_DN_SOME(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; RCVD_TLS_ALL(0.00)[]; RCPT_COUNT_FIVE(0.00)[6]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email] X-Spam-Score: -2.79 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=2a07:de40:b251:101:10:150:64:1; 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @suse.de) X-ZM-MESSAGEID: 1718650752037100005 Content-Type: text/plain; charset="utf-8" We forgot to drop the reference to the QIOChannel in the error path of the offset adjustment. Do it now. Signed-off-by: Fabiano Rosas Reviewed-by: Peter Xu --- migration/file.c | 1 + 1 file changed, 1 insertion(+) diff --git a/migration/file.c b/migration/file.c index ab18ba505a..2bb8c64092 100644 --- a/migration/file.c +++ b/migration/file.c @@ -94,6 +94,7 @@ void file_start_outgoing_migration(MigrationState *s, =20 ioc =3D QIO_CHANNEL(fioc); if (offset && qio_channel_io_seek(ioc, offset, SEEK_SET, errp) < 0) { + object_unref(OBJECT(fioc)); return; } qio_channel_set_name(ioc, "migration-file-outgoing"); --=20 2.35.3 From nobody Mon Nov 25 01:46:09 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1718650709; cv=none; d=zohomail.com; s=zohoarc; b=B4+jroBkbSe5UejHRxUltDBrPonWW8VZl70Di6H5M83dI4ftZaSnsdxzPrizbHwplItTSA2HnHs6+pps0DeHRlwDQwc14pO7nX9pB/m3A6xYZsdFHkZHsgklx3dIyxLwDrBVAlkjv2A0Zbz3rItXWwhTayH/rTdIxER7wp99lOU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1718650709; h=Content-Type: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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=hKJ7OgowTW5xAwPODDARLGeRGWa3PEf/OcdtH34X+gM=; b=jypna6cyfUcw5QiODzuQfmi8wtjWD27yEgWs04fEOweqRMqEWAwGPrQ3w9GnUDIRZSrjWdfU9DgLx5tct82XJLO4r8ubij9g1+KSMCq87UyOHqy6RZtMt1fkNUT7Cxj2a0q1z0QRNLD4goq1pcc2kQGrADqNkY64IXjBFvXbCP8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1718650709376842.2311424693529; Mon, 17 Jun 2024 11:58:29 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sJHY0-0003jq-NW; Mon, 17 Jun 2024 14:57:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sJHXz-0003jW-IX for qemu-devel@nongnu.org; Mon, 17 Jun 2024 14:57:43 -0400 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 1sJHXx-0004mg-SZ for qemu-devel@nongnu.org; Mon, 17 Jun 2024 14:57:43 -0400 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 797F021AD6; Mon, 17 Jun 2024 18:57:40 +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 657D4139AB; Mon, 17 Jun 2024 18:57:38 +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 UEVQCyKHcGYJKAAAD6G6ig (envelope-from ); Mon, 17 Jun 2024 18:57:38 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1718650660; h=from:from:reply-to: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=hKJ7OgowTW5xAwPODDARLGeRGWa3PEf/OcdtH34X+gM=; b=cgi97+RPWPEi45tM5pwqMsR3Dtwcnx01XEFKSpCeACjJmtBTIUV12FKl3psTYsFMi4fulD bu4s2dhC2Yj/s6fybrgRp/9DLfCpg28H0mtXFMgrHf3h6MwCSUlgWT38sbzAASd+n57kai ZxV5QWTrJTSJrifsbCB9yVbnQGIWdus= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1718650660; h=from:from:reply-to: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=hKJ7OgowTW5xAwPODDARLGeRGWa3PEf/OcdtH34X+gM=; b=h3Tbg5ir0frsqNyZmxW7mh+a70fgpydFY7Mvjx4jOenE/lKSD/Z2Nx0b3m1psxhD74nzLv eW4FT6aVCS1JoMAg== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=cgi97+RP; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=h3Tbg5ir DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1718650660; h=from:from:reply-to: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=hKJ7OgowTW5xAwPODDARLGeRGWa3PEf/OcdtH34X+gM=; b=cgi97+RPWPEi45tM5pwqMsR3Dtwcnx01XEFKSpCeACjJmtBTIUV12FKl3psTYsFMi4fulD bu4s2dhC2Yj/s6fybrgRp/9DLfCpg28H0mtXFMgrHf3h6MwCSUlgWT38sbzAASd+n57kai ZxV5QWTrJTSJrifsbCB9yVbnQGIWdus= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1718650660; h=from:from:reply-to: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=hKJ7OgowTW5xAwPODDARLGeRGWa3PEf/OcdtH34X+gM=; b=h3Tbg5ir0frsqNyZmxW7mh+a70fgpydFY7Mvjx4jOenE/lKSD/Z2Nx0b3m1psxhD74nzLv eW4FT6aVCS1JoMAg== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: berrange@redhat.com, armbru@redhat.com, Peter Xu , Claudio Fontana , Jim Fehlig , Prasad Pandit Subject: [PATCH v3 02/16] migration: Fix file migration with fdset Date: Mon, 17 Jun 2024 15:57:17 -0300 Message-Id: <20240617185731.9725-3-farosas@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240617185731.9725-1-farosas@suse.de> References: <20240617185731.9725-1-farosas@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Queue-Id: 797F021AD6 X-Spam-Score: -3.51 X-Spamd-Result: default: False [-3.51 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; 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)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; ARC_NA(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; RCVD_TLS_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; FROM_EQ_ENVFROM(0.00)[]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RCPT_COUNT_SEVEN(0.00)[7]; RCVD_VIA_SMTP_AUTH(0.00)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; DKIM_TRACE(0.00)[suse.de:+]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email,suse.de:dkim] X-Rspamd-Action: no action X-Rspamd-Server: rspamd1.dmz-prg2.suse.org 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=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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @suse.de) X-ZM-MESSAGEID: 1718650710451100001 When the "file:" migration support was added we missed the special case in the qemu_open_old implementation that allows for a particular file name format to be used to refer to a set of file descriptors that have been previously provided to QEMU via the add-fd QMP command. When using this fdset feature, we should not truncate the migration file because being given an fd means that the management layer is in control of the file and will likely already have some data written to it. This is further indicated by the presence of the 'offset' argument, which indicates the start of the region where QEMU is allowed to write. Fix the issue by replacing the O_TRUNC flag on open by an ftruncate call, which will take the offset into consideration. Fixes: 385f510df5 ("migration: file URI offset") Suggested-by: Daniel P. Berrang=C3=A9 Reviewed-by: Prasad Pandit Reviewed-by: Peter Xu Reviewed-by: Daniel P. Berrang=C3=A9 Signed-off-by: Fabiano Rosas --- migration/file.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/migration/file.c b/migration/file.c index 2bb8c64092..a903710f06 100644 --- a/migration/file.c +++ b/migration/file.c @@ -84,12 +84,19 @@ void file_start_outgoing_migration(MigrationState *s, =20 trace_migration_file_outgoing(filename); =20 - fioc =3D qio_channel_file_new_path(filename, O_CREAT | O_WRONLY | O_TR= UNC, - 0600, errp); + fioc =3D qio_channel_file_new_path(filename, O_CREAT | O_WRONLY, 0600,= errp); if (!fioc) { return; } =20 + if (ftruncate(fioc->fd, offset)) { + error_setg_errno(errp, errno, + "failed to truncate migration file to offset %" P= RIx64, + offset); + object_unref(OBJECT(fioc)); + return; + } + outgoing_args.fname =3D g_strdup(filename); =20 ioc =3D QIO_CHANNEL(fioc); --=20 2.35.3 From nobody Mon Nov 25 01:46:09 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1718650999; cv=none; d=zohomail.com; s=zohoarc; b=hYOBeqxtuVm0Ce+vPJEmkOjHttSQY0i6ZVqxIKtg2d2nysPVT0xWpDTvxZDPNf3EO7qilKCeWTepRk89f8SAxF6pKe10da8xSHTJURul1IaCyp5zHiCAqta3bNB3FHA/Dw4q16MF6wRIKIp4n660X4nZ6nGhhl7kvPJPRPIkTgY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1718650999; h=Content-Type: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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=zqG1BJBm4U7LvvpBbGDyqk1DGPRidUb8RgqRFwNrWpY=; b=W8/vNnvShVmg7nOGB9IP7YVJa+9TnefgxJkYA3SwsOj9Nc7QGey5iIxVVAKE/nUBgiXnTrdTsE0qBJdABQGrbeEPZFfTdIjrfw+FYX+BNmvdEv9AbvZsw5agnV9oHalVQeOr5UgfwYtpi+VzCmGRxGeavL10VWKLodtnVU2DDM4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1718650999354864.4139557789358; Mon, 17 Jun 2024 12:03:19 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sJHY4-0003lI-BP; Mon, 17 Jun 2024 14:57:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sJHY2-0003kz-HH for qemu-devel@nongnu.org; Mon, 17 Jun 2024 14:57:46 -0400 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 1sJHY0-0004nE-O0 for qemu-devel@nongnu.org; Mon, 17 Jun 2024 14:57:46 -0400 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 7C4471F443; Mon, 17 Jun 2024 18:57: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 ED000139AB; Mon, 17 Jun 2024 18:57:40 +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 EDgELCSHcGYJKAAAD6G6ig (envelope-from ); Mon, 17 Jun 2024 18:57:40 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1718650663; h=from:from:reply-to: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=zqG1BJBm4U7LvvpBbGDyqk1DGPRidUb8RgqRFwNrWpY=; b=NK1k1t2DAw4XQZsgJT8LW5jt6tbgYeQrcbij7YzWdDfXYH+lqTGJDWqZEKcgWlzqYVCeuy qrgIzD6L4vo+7b1vtOT8HJHzuUPKrjEZP6rtRxivYUPmRw5Vuv/zCC7Eba0Wz8xU2XFB7Q /mBuCrjp/3jl7f0u7ON+npnVDBsCuqU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1718650663; h=from:from:reply-to: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=zqG1BJBm4U7LvvpBbGDyqk1DGPRidUb8RgqRFwNrWpY=; b=Y7Q1CehkT/N/NhH2WdGKFS57T6WFzuK7DUxHhWUoUBXieGI7kd7LOhU6017fdLvELYzW7z KJtYDKd+l32K7eAg== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=NK1k1t2D; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=Y7Q1Cehk DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1718650663; h=from:from:reply-to: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=zqG1BJBm4U7LvvpBbGDyqk1DGPRidUb8RgqRFwNrWpY=; b=NK1k1t2DAw4XQZsgJT8LW5jt6tbgYeQrcbij7YzWdDfXYH+lqTGJDWqZEKcgWlzqYVCeuy qrgIzD6L4vo+7b1vtOT8HJHzuUPKrjEZP6rtRxivYUPmRw5Vuv/zCC7Eba0Wz8xU2XFB7Q /mBuCrjp/3jl7f0u7ON+npnVDBsCuqU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1718650663; h=from:from:reply-to: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=zqG1BJBm4U7LvvpBbGDyqk1DGPRidUb8RgqRFwNrWpY=; b=Y7Q1CehkT/N/NhH2WdGKFS57T6WFzuK7DUxHhWUoUBXieGI7kd7LOhU6017fdLvELYzW7z KJtYDKd+l32K7eAg== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: berrange@redhat.com, armbru@redhat.com, Peter Xu , Claudio Fontana , Jim Fehlig , Thomas Huth , Laurent Vivier , Paolo Bonzini Subject: [PATCH v3 03/16] tests/qtest/migration: Fix file migration offset check Date: Mon, 17 Jun 2024 15:57:18 -0300 Message-Id: <20240617185731.9725-4-farosas@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240617185731.9725-1-farosas@suse.de> References: <20240617185731.9725-1-farosas@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Spamd-Result: default: False [-3.51 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; 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)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; ARC_NA(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; RCVD_TLS_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; FROM_EQ_ENVFROM(0.00)[]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RCPT_COUNT_SEVEN(0.00)[9]; RCVD_VIA_SMTP_AUTH(0.00)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; DKIM_TRACE(0.00)[suse.de:+]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email,suse.de:dkim] X-Rspamd-Action: no action X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Queue-Id: 7C4471F443 X-Spam-Score: -3.51 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=2a07:de40:b251:101:10:150:64:2; envelope-from=farosas@suse.de; helo=smtp-out2.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @suse.de) X-ZM-MESSAGEID: 1718651001616100007 When doing file migration, QEMU accepts an offset that should be skipped when writing the migration stream to the file. The purpose of the offset is to allow the management layer to put its own metadata at the start of the file. We have tests for this in migration-test, but only testing that the migration stream starts at the correct offset and not that it actually leaves the data intact. Unsurprisingly, there's been a bug in that area that the tests didn't catch. Fix the tests to write some data to the offset region and check that it's actually there after the migration. While here, switch to using g_get_file_contents() which is more portable than mmap(). Reviewed-by: Peter Xu Reviewed-by: Daniel P. Berrang=C3=A9 Signed-off-by: Fabiano Rosas --- tests/qtest/migration-test.c | 79 ++++++++++++++++++++++-------------- 1 file changed, 48 insertions(+), 31 deletions(-) diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c index 0dccb4beff..0a529a527b 100644 --- a/tests/qtest/migration-test.c +++ b/tests/qtest/migration-test.c @@ -68,6 +68,7 @@ static QTestMigrationState dst_state; #define QEMU_VM_FILE_MAGIC 0x5145564d #define FILE_TEST_FILENAME "migfile" #define FILE_TEST_OFFSET 0x1000 +#define FILE_TEST_MARKER 'X' #define QEMU_ENV_SRC "QTEST_QEMU_BINARY_SRC" #define QEMU_ENV_DST "QTEST_QEMU_BINARY_DST" =20 @@ -1693,10 +1694,43 @@ finish: test_migrate_end(from, to, args->result =3D=3D MIG_TEST_SUCCEED); } =20 +static void file_dirty_offset_region(void) +{ + g_autofree char *path =3D g_strdup_printf("%s/%s", tmpfs, FILE_TEST_FI= LENAME); + size_t size =3D FILE_TEST_OFFSET; + g_autofree char *data =3D g_new0(char, size); + + memset(data, FILE_TEST_MARKER, size); + g_assert(g_file_set_contents(path, data, size, NULL)); +} + +static void file_check_offset_region(void) +{ + g_autofree char *path =3D g_strdup_printf("%s/%s", tmpfs, FILE_TEST_FI= LENAME); + size_t size =3D FILE_TEST_OFFSET; + g_autofree char *expected =3D g_new0(char, size); + g_autofree char *actual =3D NULL; + uint64_t *stream_start; + + /* + * Ensure the skipped offset region's data has not been touched + * and the migration stream starts at the right place. + */ + + memset(expected, FILE_TEST_MARKER, size); + + g_assert(g_file_get_contents(path, &actual, NULL, NULL)); + g_assert(!memcmp(actual, expected, size)); + + stream_start =3D (uint64_t *)(actual + size); + g_assert_cmpint(cpu_to_be64(*stream_start) >> 32, =3D=3D, QEMU_VM_FILE= _MAGIC); +} + static void test_file_common(MigrateCommon *args, bool stop_src) { QTestState *from, *to; void *data_hook =3D NULL; + bool check_offset =3D false; =20 if (test_migrate_start(&from, &to, args->listen_uri, &args->start)) { return; @@ -1709,6 +1743,16 @@ static void test_file_common(MigrateCommon *args, bo= ol stop_src) */ g_assert_false(args->live); =20 + if (g_strrstr(args->connect_uri, "offset=3D")) { + check_offset =3D true; + /* + * This comes before the start_hook because it's equivalent to + * a management application creating the file and writing to + * it so hooks should expect the file to be already present. + */ + file_dirty_offset_region(); + } + if (args->start_hook) { data_hook =3D args->start_hook(from, to); } @@ -1743,6 +1787,10 @@ static void test_file_common(MigrateCommon *args, bo= ol stop_src) =20 wait_for_serial("dest_serial"); =20 + if (check_offset) { + file_check_offset_region(); + } + finish: if (args->finish_hook) { args->finish_hook(from, to, data_hook); @@ -1942,36 +1990,6 @@ static void test_precopy_file(void) test_file_common(&args, true); } =20 -static void file_offset_finish_hook(QTestState *from, QTestState *to, - void *opaque) -{ -#if defined(__linux__) - g_autofree char *path =3D g_strdup_printf("%s/%s", tmpfs, FILE_TEST_FI= LENAME); - size_t size =3D FILE_TEST_OFFSET + sizeof(QEMU_VM_FILE_MAGIC); - uintptr_t *addr, *p; - int fd; - - fd =3D open(path, O_RDONLY); - g_assert(fd !=3D -1); - addr =3D mmap(NULL, size, PROT_READ, MAP_SHARED, fd, 0); - g_assert(addr !=3D MAP_FAILED); - - /* - * Ensure the skipped offset contains zeros and the migration - * stream starts at the right place. - */ - p =3D addr; - while (p < addr + FILE_TEST_OFFSET / sizeof(uintptr_t)) { - g_assert(*p =3D=3D 0); - p++; - } - g_assert_cmpint(cpu_to_be64(*p) >> 32, =3D=3D, QEMU_VM_FILE_MAGIC); - - munmap(addr, size); - close(fd); -#endif -} - static void test_precopy_file_offset(void) { g_autofree char *uri =3D g_strdup_printf("file:%s/%s,offset=3D%d", tmp= fs, @@ -1980,7 +1998,6 @@ static void test_precopy_file_offset(void) MigrateCommon args =3D { .connect_uri =3D uri, .listen_uri =3D "defer", - .finish_hook =3D file_offset_finish_hook, }; =20 test_file_common(&args, false); --=20 2.35.3 From nobody Mon Nov 25 01:46:09 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1718650922; cv=none; d=zohomail.com; s=zohoarc; b=Q0kVORo6WLPSyiT2KGnrrXwQhlgZeoeItrb0ihoPSqvB7EUX1yvH9BWkSKV3wDEqpSlS+t9IuKD7Ougzk5++cwcMS2qn5Gr7fhvWyAu6G1eLI+ymVP+YglW7gDoogUW/RsoKXVodV8ZJM3jAEmOt5T79rC+Qv3Sn1Vwif8/vdlw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1718650922; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=BHDDc9Txz5UoWG2oPka59YLq/Od6MbDAayJ9RVr1JIo=; b=jTTdDqqLad2ypl5satargZ7rWcDs5OrZtsYcVT8kVCZnkbo0NRJLZZB9Jq6Kf2XtrrtXYAlhUSmsTieczCBDzp35uXlCioOgS5P55GTJf3vhEG+X6WJQMkc5YugfQsIDnl7YHnXuYDJD5afqrG5mKXOxuHmW5Ajq21tIKhxYbUU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1718650922132301.97308061748686; Mon, 17 Jun 2024 12:02:02 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sJHY7-0003mf-E8; Mon, 17 Jun 2024 14:57:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sJHY5-0003m0-Pz for qemu-devel@nongnu.org; Mon, 17 Jun 2024 14:57:49 -0400 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 1sJHY3-0004nk-QT for qemu-devel@nongnu.org; Mon, 17 Jun 2024 14:57:49 -0400 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 7E16A1F443; Mon, 17 Jun 2024 18:57:46 +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 EFDF6139AB; Mon, 17 Jun 2024 18:57:43 +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 oJ/ULCeHcGYJKAAAD6G6ig (envelope-from ); Mon, 17 Jun 2024 18:57:43 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1718650666; 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=BHDDc9Txz5UoWG2oPka59YLq/Od6MbDAayJ9RVr1JIo=; b=vhrDImY3EzLhjx1PnQb/hyyj7YQTeQfdgv0YwEEjd06v45wVJPkCe3+yASNjPMn9rtPFAb 0YFNVXmUw62dEY8d0BnWuSd8/Z2kyGkDgFsUJZVQtKu4mYtXNh5nDmbwHAiRFKl3s0wBFO mDkbXHopyrC6vXW9fxxC4LmWLhiZXaU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1718650666; 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=BHDDc9Txz5UoWG2oPka59YLq/Od6MbDAayJ9RVr1JIo=; b=2iK+MnZ7/hZdVMEPBRHCsV7Xafs7z1HXVsnfwDJxBeGhgC9PY4l9QfAXpbbuJ2r7sAPxrL Xodn9ECFq0du9aBA== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=vhrDImY3; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=2iK+MnZ7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1718650666; 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=BHDDc9Txz5UoWG2oPka59YLq/Od6MbDAayJ9RVr1JIo=; b=vhrDImY3EzLhjx1PnQb/hyyj7YQTeQfdgv0YwEEjd06v45wVJPkCe3+yASNjPMn9rtPFAb 0YFNVXmUw62dEY8d0BnWuSd8/Z2kyGkDgFsUJZVQtKu4mYtXNh5nDmbwHAiRFKl3s0wBFO mDkbXHopyrC6vXW9fxxC4LmWLhiZXaU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1718650666; 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=BHDDc9Txz5UoWG2oPka59YLq/Od6MbDAayJ9RVr1JIo=; b=2iK+MnZ7/hZdVMEPBRHCsV7Xafs7z1HXVsnfwDJxBeGhgC9PY4l9QfAXpbbuJ2r7sAPxrL Xodn9ECFq0du9aBA== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: berrange@redhat.com, armbru@redhat.com, Peter Xu , Claudio Fontana , Jim Fehlig , Thomas Huth , Laurent Vivier , Paolo Bonzini Subject: [PATCH v3 04/16] tests/qtest/migration: Add a precopy file test with fdset Date: Mon, 17 Jun 2024 15:57:19 -0300 Message-Id: <20240617185731.9725-5-farosas@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240617185731.9725-1-farosas@suse.de> References: <20240617185731.9725-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spamd-Result: default: False [-3.01 / 50.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)[]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; MIME_TRACE(0.00)[0:+]; FUZZY_BLOCKED(0.00)[rspamd.com]; TO_DN_SOME(0.00)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; RCPT_COUNT_SEVEN(0.00)[9]; FROM_EQ_ENVFROM(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCVD_TLS_ALL(0.00)[]; DKIM_TRACE(0.00)[suse.de:+]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email,suse.de:dkim] X-Rspamd-Action: no action X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Queue-Id: 7E16A1F443 X-Spam-Score: -3.01 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=2a07:de40:b251:101:10:150:64:2; envelope-from=farosas@suse.de; helo=smtp-out2.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @suse.de) X-ZM-MESSAGEID: 1718650923018100003 Content-Type: text/plain; charset="utf-8" Add a test for file migration using fdset. The passing of fds is more complex than using a file path. This is also the scenario where it's most important we ensure that the initial migration stream offset is respected because the fdset interface is the one used by the management layer when providing a non empty migration file. Note that fd passing is not available on Windows, so anything that uses add-fd needs to exclude that platform. Reviewed-by: Peter Xu Signed-off-by: Fabiano Rosas --- tests/qtest/migration-test.c | 44 ++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c index 0a529a527b..22b07bc0ec 100644 --- a/tests/qtest/migration-test.c +++ b/tests/qtest/migration-test.c @@ -1990,6 +1990,46 @@ static void test_precopy_file(void) test_file_common(&args, true); } =20 +#ifndef _WIN32 +static void fdset_add_fds(QTestState *qts, const char *file, int flags, + int num_fds) +{ + for (int i =3D 0; i < num_fds; i++) { + int fd; + + fd =3D open(file, flags, 0660); + assert(fd !=3D -1); + + qtest_qmp_fds_assert_success(qts, &fd, 1, "{'execute': 'add-fd', " + "'arguments': {'fdset-id': 1}}"); + close(fd); + } +} + +static void *file_offset_fdset_start_hook(QTestState *from, QTestState *to) +{ + g_autofree char *file =3D g_strdup_printf("%s/%s", tmpfs, FILE_TEST_FI= LENAME); + + fdset_add_fds(from, file, O_WRONLY, 1); + fdset_add_fds(to, file, O_RDONLY, 1); + + return NULL; +} + +static void test_precopy_file_offset_fdset(void) +{ + g_autofree char *uri =3D g_strdup_printf("file:/dev/fdset/1,offset=3D%= d", + FILE_TEST_OFFSET); + MigrateCommon args =3D { + .connect_uri =3D uri, + .listen_uri =3D "defer", + .start_hook =3D file_offset_fdset_start_hook, + }; + + test_file_common(&args, false); +} +#endif + static void test_precopy_file_offset(void) { g_autofree char *uri =3D g_strdup_printf("file:%s/%s,offset=3D%d", tmp= fs, @@ -3527,6 +3567,10 @@ int main(int argc, char **argv) test_precopy_file); migration_test_add("/migration/precopy/file/offset", test_precopy_file_offset); +#ifndef _WIN32 + migration_test_add("/migration/precopy/file/offset/fdset", + test_precopy_file_offset_fdset); +#endif migration_test_add("/migration/precopy/file/offset/bad", test_precopy_file_offset_bad); =20 --=20 2.35.3 From nobody Mon Nov 25 01:46:09 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1718650733; cv=none; d=zohomail.com; s=zohoarc; b=dR5eqW5nZhFO4sOZZ7cg2RYielZcYyaHUY5lN4OwZubsK5r3KWhmpKNRjMK+GE+ziFOdSx/uA9zWm6cjZDc9CaEsEs9DlNHIVc5/v3Mb8W5nwKkbAxJcWR8Wwd8vwj+xYw96VGdK99WC5JqKrL2K5Ao6Qnn26MGbxBF/5nSh5uw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1718650733; h=Content-Type: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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ej2WTQ/a70FEnSwNeGX5ZJIjI8llyrpp7m9fi688FQk=; b=E0tpeVUVUhRVOzwtqGQBCuxDQqZpeQ/Qi+nTfnYpZEyaY5aW/VQ6VQGutHNMYTsbEC6om4TiEvYV+7zkLBldKVgOHV1rtkXVECjxeUjJIXmsN8bwmff3/9XhKefQLCl4kd5w+f9tcrqFy+8/StnrkW7Y0lnCiVYNVwENc7jfVJw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1718650733533559.2061476779814; Mon, 17 Jun 2024 11:58:53 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sJHYB-0003oC-3E; Mon, 17 Jun 2024 14:57:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sJHY8-0003mr-VD for qemu-devel@nongnu.org; Mon, 17 Jun 2024 14:57:52 -0400 Received: from smtp-out2.suse.de ([195.135.223.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sJHY7-0004p8-2c for qemu-devel@nongnu.org; Mon, 17 Jun 2024 14:57:52 -0400 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-out2.suse.de (Postfix) with ESMTPS id 80A681F7B0; Mon, 17 Jun 2024 18:57:49 +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 00464139AB; Mon, 17 Jun 2024 18:57:46 +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 ODwSLiqHcGYJKAAAD6G6ig (envelope-from ); Mon, 17 Jun 2024 18:57:46 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1718650669; h=from:from:reply-to: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=ej2WTQ/a70FEnSwNeGX5ZJIjI8llyrpp7m9fi688FQk=; b=r2Bp8P2buLBhzvab6jVtWB1hCUtEcc//ifK+d8o3f+gIMV+Ri8fGFFjibQw9sn5iVhOAPj nAG78rhBxnRSCdvnFawtS/3DGXjcVYkdKJRHUDTgyQlGsog0ESyZOR7Bk8Sk1rQ2A2KDOj 42/cVdHHos4VVgNn6LOegyHFzKXWOiU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1718650669; h=from:from:reply-to: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=ej2WTQ/a70FEnSwNeGX5ZJIjI8llyrpp7m9fi688FQk=; b=toSTv19mCAhQxVmbHds/EnkN9EUmetcnunRtJPqsWwaMtBtNspQiy/IIP5qvsi1hUubnQj pXCHG1JHP8nM9FDw== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1718650669; h=from:from:reply-to: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=ej2WTQ/a70FEnSwNeGX5ZJIjI8llyrpp7m9fi688FQk=; b=r2Bp8P2buLBhzvab6jVtWB1hCUtEcc//ifK+d8o3f+gIMV+Ri8fGFFjibQw9sn5iVhOAPj nAG78rhBxnRSCdvnFawtS/3DGXjcVYkdKJRHUDTgyQlGsog0ESyZOR7Bk8Sk1rQ2A2KDOj 42/cVdHHos4VVgNn6LOegyHFzKXWOiU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1718650669; h=from:from:reply-to: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=ej2WTQ/a70FEnSwNeGX5ZJIjI8llyrpp7m9fi688FQk=; b=toSTv19mCAhQxVmbHds/EnkN9EUmetcnunRtJPqsWwaMtBtNspQiy/IIP5qvsi1hUubnQj pXCHG1JHP8nM9FDw== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: berrange@redhat.com, armbru@redhat.com, Peter Xu , Claudio Fontana , Jim Fehlig , "Dr . David Alan Gilbert" , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Paolo Bonzini Subject: [PATCH v3 05/16] monitor: Drop monitor_fdset_dup_fd_find/_remove() Date: Mon, 17 Jun 2024 15:57:20 -0300 Message-Id: <20240617185731.9725-6-farosas@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240617185731.9725-1-farosas@suse.de> References: <20240617185731.9725-1-farosas@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Spam-Score: -3.30 X-Spamd-Result: default: False [-3.30 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-0.20)[-0.998]; MIME_GOOD(-0.10)[text/plain]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; RCVD_TLS_ALL(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; TO_DN_SOME(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; RCPT_COUNT_SEVEN(0.00)[9]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email] 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=195.135.223.131; envelope-from=farosas@suse.de; helo=smtp-out2.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @suse.de) X-ZM-MESSAGEID: 1718650734009100005 From: Peter Xu Those functions are not needed, one remove function should already work. Clean it up. Here the code doesn't really care about whether we need to keep that dupfd around if close() failed: when that happens something got very wrong, keeping the dup_fd around the fdsets may not help that situation so far. Cc: Dr. David Alan Gilbert Cc: Markus Armbruster Cc: Philippe Mathieu-Daud=C3=A9 Cc: Paolo Bonzini Cc: Daniel P. Berrang=C3=A9 Signed-off-by: Peter Xu Reviewed-by: Daniel P. Berrang=C3=A9 [add missing return statement, removal during traversal is not safe] Signed-off-by: Fabiano Rosas --- include/monitor/monitor.h | 1 - monitor/fds.c | 28 ++++++---------------------- stubs/fdset.c | 5 ----- util/osdep.c | 15 +-------------- 4 files changed, 7 insertions(+), 42 deletions(-) diff --git a/include/monitor/monitor.h b/include/monitor/monitor.h index 965f5d5450..fd9b3f538c 100644 --- a/include/monitor/monitor.h +++ b/include/monitor/monitor.h @@ -53,7 +53,6 @@ AddfdInfo *monitor_fdset_add_fd(int fd, bool has_fdset_id= , int64_t fdset_id, const char *opaque, Error **errp); int monitor_fdset_dup_fd_add(int64_t fdset_id, int flags); void monitor_fdset_dup_fd_remove(int dup_fd); -int64_t monitor_fdset_dup_fd_find(int dup_fd); =20 void monitor_register_hmp(const char *name, bool info, void (*cmd)(Monitor *mon, const QDict *qdict)); diff --git a/monitor/fds.c b/monitor/fds.c index d86c2c674c..fb9f58c056 100644 --- a/monitor/fds.c +++ b/monitor/fds.c @@ -458,7 +458,7 @@ int monitor_fdset_dup_fd_add(int64_t fdset_id, int flag= s) #endif } =20 -static int64_t monitor_fdset_dup_fd_find_remove(int dup_fd, bool remove) +void monitor_fdset_dup_fd_remove(int dup_fd) { MonFdset *mon_fdset; MonFdsetFd *mon_fdset_fd_dup; @@ -467,31 +467,15 @@ static int64_t monitor_fdset_dup_fd_find_remove(int d= up_fd, bool remove) QLIST_FOREACH(mon_fdset, &mon_fdsets, next) { QLIST_FOREACH(mon_fdset_fd_dup, &mon_fdset->dup_fds, next) { if (mon_fdset_fd_dup->fd =3D=3D dup_fd) { - if (remove) { - QLIST_REMOVE(mon_fdset_fd_dup, next); - g_free(mon_fdset_fd_dup); - if (QLIST_EMPTY(&mon_fdset->dup_fds)) { - monitor_fdset_cleanup(mon_fdset); - } - return -1; - } else { - return mon_fdset->id; + QLIST_REMOVE(mon_fdset_fd_dup, next); + g_free(mon_fdset_fd_dup); + if (QLIST_EMPTY(&mon_fdset->dup_fds)) { + monitor_fdset_cleanup(mon_fdset); } + return; } } } - - return -1; -} - -int64_t monitor_fdset_dup_fd_find(int dup_fd) -{ - return monitor_fdset_dup_fd_find_remove(dup_fd, false); -} - -void monitor_fdset_dup_fd_remove(int dup_fd) -{ - monitor_fdset_dup_fd_find_remove(dup_fd, true); } =20 int monitor_fd_param(Monitor *mon, const char *fdname, Error **errp) diff --git a/stubs/fdset.c b/stubs/fdset.c index d7c39a28ac..389e368a29 100644 --- a/stubs/fdset.c +++ b/stubs/fdset.c @@ -9,11 +9,6 @@ int monitor_fdset_dup_fd_add(int64_t fdset_id, int flags) return -1; } =20 -int64_t monitor_fdset_dup_fd_find(int dup_fd) -{ - return -1; -} - void monitor_fdset_dup_fd_remove(int dupfd) { } diff --git a/util/osdep.c b/util/osdep.c index 5d23bbfbec..756de9a745 100644 --- a/util/osdep.c +++ b/util/osdep.c @@ -398,21 +398,8 @@ int qemu_open_old(const char *name, int flags, ...) =20 int qemu_close(int fd) { - int64_t fdset_id; - /* Close fd that was dup'd from an fdset */ - fdset_id =3D monitor_fdset_dup_fd_find(fd); - if (fdset_id !=3D -1) { - int ret; - - ret =3D close(fd); - if (ret =3D=3D 0) { - monitor_fdset_dup_fd_remove(fd); - } - - return ret; - } - + monitor_fdset_dup_fd_remove(fd); return close(fd); } =20 --=20 2.35.3 From nobody Mon Nov 25 01:46:09 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1718650731; cv=none; d=zohomail.com; s=zohoarc; b=jzlS6+UZ1PAAwsKQHWqEZ3j8e9SqXg1n0WAQSfMiCPw+QnDMO0cszWFTva4KH75dxi4IFXJ/9+rPhSg0WUHfNSztaPPhJtZPfmzulXwqcgVbdN60DcMcghmMlodFJRICsWqvRaWxlKKQYF1gEC3p8Y9vbFJ7BTVQmaSfyKBFK5Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1718650731; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=v1KaYbtoCrYR/UVJrzg71LPk0e1FdJi5ikFfwJo+cZ4=; b=gXsFHrdcVGbhzalwLaHGsiCgRQ9i5lNNOxqdtQBqOJ3u/mdp4u+cJ9nhTeR3VBT6pHKHJvgBu3H4VxKKedkPVE3qwDdzWdPqUcr1WwfmgAY5GAk5ghhXO2lNXwm6AKCnui586qfgqWBIIxfRE0+dLJZdIRzagRbRzdEygnrvEmM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1718650731379248.8365566937241; Mon, 17 Jun 2024 11:58:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sJHYB-0003oE-BD; Mon, 17 Jun 2024 14:57:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sJHYA-0003o1-JD for qemu-devel@nongnu.org; Mon, 17 Jun 2024 14:57:54 -0400 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 1sJHY8-0004pw-VG for qemu-devel@nongnu.org; Mon, 17 Jun 2024 14:57:54 -0400 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-out2.suse.de (Postfix) with ESMTPS id CF1761F443; Mon, 17 Jun 2024 18:57:51 +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 F2734139AB; Mon, 17 Jun 2024 18:57:49 +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 2NmnLS2HcGYJKAAAD6G6ig (envelope-from ); Mon, 17 Jun 2024 18:57:49 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1718650671; 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=v1KaYbtoCrYR/UVJrzg71LPk0e1FdJi5ikFfwJo+cZ4=; b=UedMv8DEOyN2qJnu4muE/x0pB9Kk3dal1JKeb4mFOcP0Vvpt4j0kb51G6bzAXDUzvcJzZq uG7fYmZuv9NWdF9sphlnF9jVwbI5HQoJMIVNp/XXRuaPoXZmefQZLLuuVznEcbTObezbyz gr2e+nFttRnF4efwv8n6lUOWu4TqGIk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1718650671; 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=v1KaYbtoCrYR/UVJrzg71LPk0e1FdJi5ikFfwJo+cZ4=; b=fE8uISXUJSKuI2698kwXwdxciuUz+R/ajA46/SUbG0kEj8JNWvZlwbRrmk49/Y8PIZNe9l j2Eq+0CO7MlF/lDw== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1718650671; 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=v1KaYbtoCrYR/UVJrzg71LPk0e1FdJi5ikFfwJo+cZ4=; b=UedMv8DEOyN2qJnu4muE/x0pB9Kk3dal1JKeb4mFOcP0Vvpt4j0kb51G6bzAXDUzvcJzZq uG7fYmZuv9NWdF9sphlnF9jVwbI5HQoJMIVNp/XXRuaPoXZmefQZLLuuVznEcbTObezbyz gr2e+nFttRnF4efwv8n6lUOWu4TqGIk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1718650671; 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=v1KaYbtoCrYR/UVJrzg71LPk0e1FdJi5ikFfwJo+cZ4=; b=fE8uISXUJSKuI2698kwXwdxciuUz+R/ajA46/SUbG0kEj8JNWvZlwbRrmk49/Y8PIZNe9l j2Eq+0CO7MlF/lDw== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: berrange@redhat.com, armbru@redhat.com, Peter Xu , Claudio Fontana , Jim Fehlig Subject: [PATCH v3 06/16] monitor: Introduce monitor_fdset_*free Date: Mon, 17 Jun 2024 15:57:21 -0300 Message-Id: <20240617185731.9725-7-farosas@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240617185731.9725-1-farosas@suse.de> References: <20240617185731.9725-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spamd-Result: default: False [-2.80 / 50.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)[-1.000]; MIME_GOOD(-0.10)[text/plain]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_COUNT_TWO(0.00)[2]; TO_DN_SOME(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; RCVD_TLS_ALL(0.00)[]; RCPT_COUNT_FIVE(0.00)[6]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email] X-Spam-Score: -2.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=lists.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: -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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @suse.de) X-ZM-MESSAGEID: 1718650731987100001 Content-Type: text/plain; charset="utf-8" Introduce new functions to remove and free no longer used fds and fdsets. We need those to decouple the remove/free routines from monitor_fdset_cleanup() which will go away in the next patches. The new functions: - monitor_fdset_free/_if_empty() will be used when a monitor connection closes and when an fd is removed to cleanup any fdset that is now empty. - monitor_fdset_fd_free() will be used to remove one or more fds that have been explicitly targeted by qmp_remove_fd(). Reviewed-by: Peter Xu Signed-off-by: Fabiano Rosas --- monitor/fds.c | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/monitor/fds.c b/monitor/fds.c index fb9f58c056..bd45a26368 100644 --- a/monitor/fds.c +++ b/monitor/fds.c @@ -167,6 +167,27 @@ int monitor_get_fd(Monitor *mon, const char *fdname, E= rror **errp) return -1; } =20 +static void monitor_fdset_free(MonFdset *mon_fdset) +{ + QLIST_REMOVE(mon_fdset, next); + g_free(mon_fdset); +} + +static void monitor_fdset_free_if_empty(MonFdset *mon_fdset) +{ + if (QLIST_EMPTY(&mon_fdset->fds) && QLIST_EMPTY(&mon_fdset->dup_fds)) { + monitor_fdset_free(mon_fdset); + } +} + +static void monitor_fdset_fd_free(MonFdsetFd *mon_fdset_fd) +{ + close(mon_fdset_fd->fd); + g_free(mon_fdset_fd->opaque); + QLIST_REMOVE(mon_fdset_fd, next); + g_free(mon_fdset_fd); +} + static void monitor_fdset_cleanup(MonFdset *mon_fdset) { MonFdsetFd *mon_fdset_fd; @@ -176,17 +197,11 @@ static void monitor_fdset_cleanup(MonFdset *mon_fdset) if ((mon_fdset_fd->removed || (QLIST_EMPTY(&mon_fdset->dup_fds) && mon_refcount =3D=3D 0= )) && runstate_is_running()) { - close(mon_fdset_fd->fd); - g_free(mon_fdset_fd->opaque); - QLIST_REMOVE(mon_fdset_fd, next); - g_free(mon_fdset_fd); + monitor_fdset_fd_free(mon_fdset_fd); } } =20 - if (QLIST_EMPTY(&mon_fdset->fds) && QLIST_EMPTY(&mon_fdset->dup_fds)) { - QLIST_REMOVE(mon_fdset, next); - g_free(mon_fdset); - } + monitor_fdset_free_if_empty(mon_fdset); } =20 void monitor_fdsets_cleanup(void) --=20 2.35.3 From nobody Mon Nov 25 01:46:09 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1718650754; cv=none; d=zohomail.com; s=zohoarc; b=QrLiWPOQvLiVdXzyJ/WfuJM6qdRn0Sm52geMqvxT8JlApppBjfezqY53zZqqSVF1kD+vBawCmiRhPxLOB51DR5KoteKPGK1fsFjqrMvEVr2m4lWGVhJBO85+9PtnLewktoEFxQxkrhlfzOInLwboWAACW/FkVUfWuTlJ+UxcUaw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1718650754; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ceChUQ59yKW8r+uZdm7f/uUA8rCn96xY3ZW0kVrinNg=; b=NM6HjyPr7ZItV0FqtvJF40R+APuO4OQEAbQQ8eE5mMWK/xCMHXnsiTDoq2e0azmbRPY5Lz9G3MJDMhsn2r4IISxtTAX6ewHAlcbxji/RPmhK+P3QjIhEkUQ7sqxTnkKMSakFvnGR57Uo3Lfg3jtU+zduxoOcqC/m6cOtS14h5U0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1718650754692653.4850643905548; Mon, 17 Jun 2024 11:59:14 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sJHYE-0003pt-Am; Mon, 17 Jun 2024 14:57:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sJHYD-0003pV-Ky for qemu-devel@nongnu.org; Mon, 17 Jun 2024 14:57:57 -0400 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 1sJHYB-0004sm-PZ for qemu-devel@nongnu.org; Mon, 17 Jun 2024 14:57:57 -0400 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-out2.suse.de (Postfix) with ESMTPS id 6CD9E1F443; Mon, 17 Jun 2024 18:57:54 +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 54BE1139AB; Mon, 17 Jun 2024 18:57:52 +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 OMQVBzCHcGYJKAAAD6G6ig (envelope-from ); Mon, 17 Jun 2024 18:57:52 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1718650674; 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=ceChUQ59yKW8r+uZdm7f/uUA8rCn96xY3ZW0kVrinNg=; b=0bvs6lGPLOeVN4l/8HluTH0ActiUL/HrHVimoBfTfe37oGx6ew7nugTutgfjQ96Qjr2zM7 iVscsUS2W7mivFweg0X8h8lu2+8/FFX2dTNJt/RgnOd70+6uPruBigHs8++NoXqK3qjTc8 9c9py1bb7yygNHTwDo9iuKRC8YX4+wA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1718650674; 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=ceChUQ59yKW8r+uZdm7f/uUA8rCn96xY3ZW0kVrinNg=; b=U1wuhfyZCdv5oUeI8nULLIKE03FEAoRL559d8KuNwruQ9V4l8yZwH7wzpp808yEPUVvDDI yKibZS0b4HinPODA== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1718650674; 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=ceChUQ59yKW8r+uZdm7f/uUA8rCn96xY3ZW0kVrinNg=; b=0bvs6lGPLOeVN4l/8HluTH0ActiUL/HrHVimoBfTfe37oGx6ew7nugTutgfjQ96Qjr2zM7 iVscsUS2W7mivFweg0X8h8lu2+8/FFX2dTNJt/RgnOd70+6uPruBigHs8++NoXqK3qjTc8 9c9py1bb7yygNHTwDo9iuKRC8YX4+wA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1718650674; 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=ceChUQ59yKW8r+uZdm7f/uUA8rCn96xY3ZW0kVrinNg=; b=U1wuhfyZCdv5oUeI8nULLIKE03FEAoRL559d8KuNwruQ9V4l8yZwH7wzpp808yEPUVvDDI yKibZS0b4HinPODA== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: berrange@redhat.com, armbru@redhat.com, Peter Xu , Claudio Fontana , Jim Fehlig , "Dr. David Alan Gilbert" Subject: [PATCH v3 07/16] monitor: Stop removing non-duplicated fds Date: Mon, 17 Jun 2024 15:57:22 -0300 Message-Id: <20240617185731.9725-8-farosas@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240617185731.9725-1-farosas@suse.de> References: <20240617185731.9725-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.80 X-Spamd-Result: default: False [-2.80 / 50.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)[-1.000]; MIME_GOOD(-0.10)[text/plain]; ARC_NA(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_TRACE(0.00)[0:+]; FUZZY_BLOCKED(0.00)[rspamd.com]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RCVD_TLS_ALL(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; RCPT_COUNT_SEVEN(0.00)[7]; RCVD_COUNT_TWO(0.00)[2]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email] 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=2a07:de40:b251:101:10:150:64:2; envelope-from=farosas@suse.de; helo=smtp-out2.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @suse.de) X-ZM-MESSAGEID: 1718650756080100001 Content-Type: text/plain; charset="utf-8" monitor_fdsets_cleanup() currently has three responsibilities: 1- Remove the fds that have been marked for removal(->removed=3Dtrue) by qmp_remove_fd(). This is overly complicated, but ok. 2- Remove any file descriptors that have been passed into QEMU and never duplicated[1,2]. A file descriptor without duplicates indicates that no part of QEMU has made use of it. This is problematic because the current implementation does it only if the guest is not running and the monitor is closed. 3- Remove/free fdsets that have become empty due to the above removals. This is ok. The scenario described in (2) is starting to show some cracks now that we're trying to consume fds from the migration code: - Doing cleanup every time the last monitor connection closes works to reap unused fds, but also has the side effect of forcing the management layer to pass the file descriptors again in case of a disconnect/re-connect, if that happened to be the only monitor connection. Another side effect is that removing an fd with qmp_remove_fd() is effectively delayed until the last monitor connection closes. The usage of mon_refcount is also problematic because it's racy. - Checking runstate_is_running() skips the cleanup unless the VM is running and avoids premature cleanup of the fds, but also has the side effect of blocking the legitimate removal of an fd via qmp_remove_fd() if the VM happens to be in another state. This affects qmp_remove_fd() and qmp_query_fdsets() in particular because requesting a removal at a bad time (guest stopped) might cause an fd to never be removed, or to be removed at a much later point in time, causing the query command to continue showing the supposedly removed fd/fdset. Note that file descriptors that *have* been duplicated are owned by the code that uses them and will be removed after qemu_close() is called. Therefore we've decided that the best course of action to avoid the undesired side-effects is to stop managing non-duplicated file descriptors. 1- efb87c1697 ("monitor: Clean up fd sets on monitor disconnect") 2- ebe52b592d ("monitor: Prevent removing fd from set during init") Reviewed-by: Peter Xu Signed-off-by: Fabiano Rosas --- monitor/fds.c | 15 ++++++++------- monitor/hmp.c | 2 -- monitor/monitor-internal.h | 1 - monitor/monitor.c | 1 - monitor/qmp.c | 2 -- 5 files changed, 8 insertions(+), 13 deletions(-) diff --git a/monitor/fds.c b/monitor/fds.c index bd45a26368..ea85ba1f05 100644 --- a/monitor/fds.c +++ b/monitor/fds.c @@ -175,6 +175,11 @@ static void monitor_fdset_free(MonFdset *mon_fdset) =20 static void monitor_fdset_free_if_empty(MonFdset *mon_fdset) { + /* + * Only remove an empty fdset. The fds are owned by the user and + * should have been removed with qmp_remove_fd(). The dup_fds are + * owned by QEMU and should have been removed with qemu_close(). + */ if (QLIST_EMPTY(&mon_fdset->fds) && QLIST_EMPTY(&mon_fdset->dup_fds)) { monitor_fdset_free(mon_fdset); } @@ -194,9 +199,7 @@ static void monitor_fdset_cleanup(MonFdset *mon_fdset) MonFdsetFd *mon_fdset_fd_next; =20 QLIST_FOREACH_SAFE(mon_fdset_fd, &mon_fdset->fds, next, mon_fdset_fd_n= ext) { - if ((mon_fdset_fd->removed || - (QLIST_EMPTY(&mon_fdset->dup_fds) && mon_refcount =3D=3D 0= )) && - runstate_is_running()) { + if (mon_fdset_fd->removed) { monitor_fdset_fd_free(mon_fdset_fd); } } @@ -211,7 +214,7 @@ void monitor_fdsets_cleanup(void) =20 QEMU_LOCK_GUARD(&mon_fdsets_lock); QLIST_FOREACH_SAFE(mon_fdset, &mon_fdsets, next, mon_fdset_next) { - monitor_fdset_cleanup(mon_fdset); + monitor_fdset_free_if_empty(mon_fdset); } } =20 @@ -484,9 +487,7 @@ void monitor_fdset_dup_fd_remove(int dup_fd) if (mon_fdset_fd_dup->fd =3D=3D dup_fd) { QLIST_REMOVE(mon_fdset_fd_dup, next); g_free(mon_fdset_fd_dup); - if (QLIST_EMPTY(&mon_fdset->dup_fds)) { - monitor_fdset_cleanup(mon_fdset); - } + monitor_fdset_free(mon_fdset); return; } } diff --git a/monitor/hmp.c b/monitor/hmp.c index 69c1b7e98a..460e8832f6 100644 --- a/monitor/hmp.c +++ b/monitor/hmp.c @@ -1437,11 +1437,9 @@ static void monitor_event(void *opaque, QEMUChrEvent= event) monitor_resume(mon); } qemu_mutex_unlock(&mon->mon_lock); - mon_refcount++; break; =20 case CHR_EVENT_CLOSED: - mon_refcount--; monitor_fdsets_cleanup(); break; =20 diff --git a/monitor/monitor-internal.h b/monitor/monitor-internal.h index 252de85681..cb628f681d 100644 --- a/monitor/monitor-internal.h +++ b/monitor/monitor-internal.h @@ -168,7 +168,6 @@ extern bool qmp_dispatcher_co_shutdown; extern QmpCommandList qmp_commands, qmp_cap_negotiation_commands; extern QemuMutex monitor_lock; extern MonitorList mon_list; -extern int mon_refcount; =20 extern HMPCommand hmp_cmds[]; =20 diff --git a/monitor/monitor.c b/monitor/monitor.c index 01ede1babd..db52a9c7ef 100644 --- a/monitor/monitor.c +++ b/monitor/monitor.c @@ -71,7 +71,6 @@ static GHashTable *monitor_qapi_event_state; static GHashTable *coroutine_mon; /* Maps Coroutine* to Monitor* */ =20 MonitorList mon_list; -int mon_refcount; static bool monitor_destroyed; =20 Monitor *monitor_cur(void) diff --git a/monitor/qmp.c b/monitor/qmp.c index a239945e8d..5e538f34c0 100644 --- a/monitor/qmp.c +++ b/monitor/qmp.c @@ -466,7 +466,6 @@ static void monitor_qmp_event(void *opaque, QEMUChrEven= t event) data =3D qmp_greeting(mon); qmp_send_response(mon, data); qobject_unref(data); - mon_refcount++; break; case CHR_EVENT_CLOSED: /* @@ -479,7 +478,6 @@ static void monitor_qmp_event(void *opaque, QEMUChrEven= t event) json_message_parser_destroy(&mon->parser); json_message_parser_init(&mon->parser, handle_qmp_command, mon, NULL); - mon_refcount--; monitor_fdsets_cleanup(); break; case CHR_EVENT_BREAK: --=20 2.35.3 From nobody Mon Nov 25 01:46:09 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1718650922; cv=none; d=zohomail.com; s=zohoarc; b=Upyin3fKbSoPGvnniSs2MJAYVxDGPPRs4wy2Hw8PuFrc7r/B7rpuLJim3T+EN8r5dIN4cJST0pBFICkYND4yUdzHkd4+GkA2kUc6YyM1viKefxX22GoI3C4RQPeRtqKqr89g4U2mLkYJewZ9Du3i5ns7Ys8YTzcjXi2t84rU+0s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1718650922; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=m5glxF5lwObcrsY3f6BymucM17SLdTEERvlIWQxgAPs=; b=JS1S08m127W7t5P42IaWd9i3mST/KK59mLlE7Sy2vdI5jEnlT8j9lUy9IO7827zBfo3pSvWkKnfxDp+CM/kCQsy2Gm7UFc/onp5MkIlJL1y5imagLSyWWaUoJq6jvJlzOIcSgPmAPSVjaLsuq78RO7LODkn2kQMfsVxVhPZ2IVQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1718650922088555.2223065058052; Mon, 17 Jun 2024 12:02:02 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sJHYH-0003r4-3H; Mon, 17 Jun 2024 14:58:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sJHYF-0003qY-NU for qemu-devel@nongnu.org; Mon, 17 Jun 2024 14:57:59 -0400 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 1sJHYD-0004tU-T3 for qemu-devel@nongnu.org; Mon, 17 Jun 2024 14:57:59 -0400 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-out2.suse.de (Postfix) with ESMTPS id BB7A91F7A6; Mon, 17 Jun 2024 18:57:56 +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 DF541139AB; Mon, 17 Jun 2024 18:57:54 +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 OLbyKDKHcGYJKAAAD6G6ig (envelope-from ); Mon, 17 Jun 2024 18:57:54 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1718650676; 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=m5glxF5lwObcrsY3f6BymucM17SLdTEERvlIWQxgAPs=; b=tSZLmuW5VecjSjohMAF2HlY1GrssgJ6HF5GL6/nMLCDZOYIN+uWL/2AM3KN+kC3JgL/cfM Ezmb6vSLi1Q06nYKHqbP+b5F2Uj6JidNf9BfIIOH/O/prYGztfvivFv5iZvj7FyGr7fQrU buu6xKa/P0KBjXagm4im567BWFDDruE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1718650676; 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=m5glxF5lwObcrsY3f6BymucM17SLdTEERvlIWQxgAPs=; b=+DT2e1sSt059uvL2LMyvOaakX9C4VyvJIL05hVQeqn3OC7SV5t5syIKtVA1ufu6PSvuAsN Bu5SpEz/fNbOMxCQ== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1718650676; 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=m5glxF5lwObcrsY3f6BymucM17SLdTEERvlIWQxgAPs=; b=tSZLmuW5VecjSjohMAF2HlY1GrssgJ6HF5GL6/nMLCDZOYIN+uWL/2AM3KN+kC3JgL/cfM Ezmb6vSLi1Q06nYKHqbP+b5F2Uj6JidNf9BfIIOH/O/prYGztfvivFv5iZvj7FyGr7fQrU buu6xKa/P0KBjXagm4im567BWFDDruE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1718650676; 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=m5glxF5lwObcrsY3f6BymucM17SLdTEERvlIWQxgAPs=; b=+DT2e1sSt059uvL2LMyvOaakX9C4VyvJIL05hVQeqn3OC7SV5t5syIKtVA1ufu6PSvuAsN Bu5SpEz/fNbOMxCQ== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: berrange@redhat.com, armbru@redhat.com, Peter Xu , Claudio Fontana , Jim Fehlig Subject: [PATCH v3 08/16] monitor: Simplify fdset and fd removal Date: Mon, 17 Jun 2024 15:57:23 -0300 Message-Id: <20240617185731.9725-9-farosas@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240617185731.9725-1-farosas@suse.de> References: <20240617185731.9725-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_FIVE(0.00)[6]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email]; RCVD_TLS_ALL(0.00)[] X-Spam-Score: -2.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=lists.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: -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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @suse.de) X-ZM-MESSAGEID: 1718650922957100001 Content-Type: text/plain; charset="utf-8" Remove fds right away instead of setting the ->removed flag. We don't need the extra complexity of having a cleanup function reap the removed entries at a later time. Reviewed-by: Peter Xu Signed-off-by: Fabiano Rosas --- monitor/fds.c | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-) diff --git a/monitor/fds.c b/monitor/fds.c index ea85ba1f05..32b79c621e 100644 --- a/monitor/fds.c +++ b/monitor/fds.c @@ -43,7 +43,6 @@ struct mon_fd_t { typedef struct MonFdsetFd MonFdsetFd; struct MonFdsetFd { int fd; - bool removed; char *opaque; QLIST_ENTRY(MonFdsetFd) next; }; @@ -193,20 +192,6 @@ static void monitor_fdset_fd_free(MonFdsetFd *mon_fdse= t_fd) g_free(mon_fdset_fd); } =20 -static void monitor_fdset_cleanup(MonFdset *mon_fdset) -{ - MonFdsetFd *mon_fdset_fd; - MonFdsetFd *mon_fdset_fd_next; - - QLIST_FOREACH_SAFE(mon_fdset_fd, &mon_fdset->fds, next, mon_fdset_fd_n= ext) { - if (mon_fdset_fd->removed) { - monitor_fdset_fd_free(mon_fdset_fd); - } - } - - monitor_fdset_free_if_empty(mon_fdset); -} - void monitor_fdsets_cleanup(void) { MonFdset *mon_fdset; @@ -281,7 +266,7 @@ void qmp_get_win32_socket(const char *infos, const char= *fdname, Error **errp) void qmp_remove_fd(int64_t fdset_id, bool has_fd, int64_t fd, Error **errp) { MonFdset *mon_fdset; - MonFdsetFd *mon_fdset_fd; + MonFdsetFd *mon_fdset_fd, *mon_fdset_fd_next; char fd_str[60]; =20 QEMU_LOCK_GUARD(&mon_fdsets_lock); @@ -289,21 +274,22 @@ void qmp_remove_fd(int64_t fdset_id, bool has_fd, int= 64_t fd, Error **errp) if (mon_fdset->id !=3D fdset_id) { continue; } - QLIST_FOREACH(mon_fdset_fd, &mon_fdset->fds, next) { + QLIST_FOREACH_SAFE(mon_fdset_fd, &mon_fdset->fds, next, + mon_fdset_fd_next) { if (has_fd) { if (mon_fdset_fd->fd !=3D fd) { continue; } - mon_fdset_fd->removed =3D true; + monitor_fdset_fd_free(mon_fdset_fd); break; } else { - mon_fdset_fd->removed =3D true; + monitor_fdset_fd_free(mon_fdset_fd); } } if (has_fd && !mon_fdset_fd) { goto error; } - monitor_fdset_cleanup(mon_fdset); + monitor_fdset_free_if_empty(mon_fdset); return; } =20 @@ -413,7 +399,6 @@ AddfdInfo *monitor_fdset_add_fd(int fd, bool has_fdset_= id, int64_t fdset_id, =20 mon_fdset_fd =3D g_malloc0(sizeof(*mon_fdset_fd)); mon_fdset_fd->fd =3D fd; - mon_fdset_fd->removed =3D false; mon_fdset_fd->opaque =3D g_strdup(opaque); QLIST_INSERT_HEAD(&mon_fdset->fds, mon_fdset_fd, next); =20 --=20 2.35.3 From nobody Mon Nov 25 01:46:09 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1718650965; cv=none; d=zohomail.com; s=zohoarc; b=oDSE76QPZxZit94yMfA7+S2oSmfM1Ksmc2Tqs3ckXow0mdZ0GZvvz+Kg71yS48WBqJ4Zug//EXeEtLqkaJ30bX2YqJqwTI1HTjlRRMDGhoobZXAW7YzvIs7iCi3cSXQxuNYhscRFXuwU7XdKxOI+nRCvqsxnOu1td23pLtdoDAM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1718650965; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=J86dMl3/etDW3csrRkGzvqR2SczYwEFvt8sEKFb+bhk=; b=ZzFNAc7FS562GBa5km6d89pFu7gSgdO4BRnW6ojSnK53d6gwCTS30faeJjL/Z2t1FNdPzxcPxv7PqYTpno9jV2oORhOaoeLUmAvx8MrLOQWWRr2aK4hp1g2t6xxHeaRaTxHaYdgOB0dKx1AEHym8l7rIBfxhkx5B4HxrhJGiR2s= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1718650965538284.6787832045977; Mon, 17 Jun 2024 12:02:45 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sJHYK-0003s7-3D; Mon, 17 Jun 2024 14:58:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sJHYI-0003rc-KE for qemu-devel@nongnu.org; Mon, 17 Jun 2024 14:58:02 -0400 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 1sJHYG-0004tr-MX for qemu-devel@nongnu.org; Mon, 17 Jun 2024 14:58:02 -0400 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 5538E21AD5; Mon, 17 Jun 2024 18:57:59 +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 3EA69139AB; Mon, 17 Jun 2024 18:57:57 +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 sBGSATWHcGYJKAAAD6G6ig (envelope-from ); Mon, 17 Jun 2024 18:57:57 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1718650679; 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=J86dMl3/etDW3csrRkGzvqR2SczYwEFvt8sEKFb+bhk=; b=GQ7fj2FsdtemDw2E3kDMHuuXc7XcSxxNKNPOEGNeDKViCu6Ku8QOm+5TliGBRWQDRDw17g 8FMoEGL92JtjX8PLy5D2BVUY9vkOUERzXVKc47wWYvKHfaYVjdoMnBMbCaFjVobfkK0qNO nlltkpC1/ELz9cOXEfKX1M3LhGeeJ64= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1718650679; 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=J86dMl3/etDW3csrRkGzvqR2SczYwEFvt8sEKFb+bhk=; b=8Kv2BbdI1Z25+HwXMqmSfXXB21OJjZLBr3cdQS95nnyu0BO+cKPCUPT0JqLOinTzP8htAY ExobjrgntW0za9Cw== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=GQ7fj2Fs; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=8Kv2BbdI DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1718650679; 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=J86dMl3/etDW3csrRkGzvqR2SczYwEFvt8sEKFb+bhk=; b=GQ7fj2FsdtemDw2E3kDMHuuXc7XcSxxNKNPOEGNeDKViCu6Ku8QOm+5TliGBRWQDRDw17g 8FMoEGL92JtjX8PLy5D2BVUY9vkOUERzXVKc47wWYvKHfaYVjdoMnBMbCaFjVobfkK0qNO nlltkpC1/ELz9cOXEfKX1M3LhGeeJ64= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1718650679; 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=J86dMl3/etDW3csrRkGzvqR2SczYwEFvt8sEKFb+bhk=; b=8Kv2BbdI1Z25+HwXMqmSfXXB21OJjZLBr3cdQS95nnyu0BO+cKPCUPT0JqLOinTzP8htAY ExobjrgntW0za9Cw== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: berrange@redhat.com, armbru@redhat.com, Peter Xu , Claudio Fontana , Jim Fehlig , Paolo Bonzini Subject: [PATCH v3 09/16] monitor: Report errors from monitor_fdset_dup_fd_add Date: Mon, 17 Jun 2024 15:57:24 -0300 Message-Id: <20240617185731.9725-10-farosas@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240617185731.9725-1-farosas@suse.de> References: <20240617185731.9725-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spamd-Result: default: False [-3.01 / 50.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)[]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; MIME_TRACE(0.00)[0:+]; FUZZY_BLOCKED(0.00)[rspamd.com]; TO_DN_SOME(0.00)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; RCPT_COUNT_SEVEN(0.00)[7]; FROM_EQ_ENVFROM(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCVD_TLS_ALL(0.00)[]; DKIM_TRACE(0.00)[suse.de:+]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email,suse.de:dkim] X-Rspamd-Action: no action X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Queue-Id: 5538E21AD5 X-Spam-Score: -3.01 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=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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @suse.de) X-ZM-MESSAGEID: 1718650967146100007 Content-Type: text/plain; charset="utf-8" I'm keeping the EACCES because callers expect to be able to look at errno. Reviewed-by: Peter Xu Signed-off-by: Fabiano Rosas --- include/monitor/monitor.h | 2 +- monitor/fds.c | 10 +++++++++- stubs/fdset.c | 2 +- util/osdep.c | 10 +--------- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/include/monitor/monitor.h b/include/monitor/monitor.h index fd9b3f538c..c3740ec616 100644 --- a/include/monitor/monitor.h +++ b/include/monitor/monitor.h @@ -51,7 +51,7 @@ int monitor_read_password(MonitorHMP *mon, ReadLineFunc *= readline_func, =20 AddfdInfo *monitor_fdset_add_fd(int fd, bool has_fdset_id, int64_t fdset_i= d, const char *opaque, Error **errp); -int monitor_fdset_dup_fd_add(int64_t fdset_id, int flags); +int monitor_fdset_dup_fd_add(int64_t fdset_id, int flags, Error **errp); void monitor_fdset_dup_fd_remove(int dup_fd); =20 void monitor_register_hmp(const char *name, bool info, diff --git a/monitor/fds.c b/monitor/fds.c index 32b79c621e..fd87e7db8b 100644 --- a/monitor/fds.c +++ b/monitor/fds.c @@ -409,9 +409,10 @@ AddfdInfo *monitor_fdset_add_fd(int fd, bool has_fdset= _id, int64_t fdset_id, return fdinfo; } =20 -int monitor_fdset_dup_fd_add(int64_t fdset_id, int flags) +int monitor_fdset_dup_fd_add(int64_t fdset_id, int flags, Error **errp) { #ifdef _WIN32 + error_setg(errp, "Platform does not support fd passing (fdset)"); return -ENOENT; #else MonFdset *mon_fdset; @@ -431,6 +432,8 @@ int monitor_fdset_dup_fd_add(int64_t fdset_id, int flag= s) QLIST_FOREACH(mon_fdset_fd, &mon_fdset->fds, next) { mon_fd_flags =3D fcntl(mon_fdset_fd->fd, F_GETFL); if (mon_fd_flags =3D=3D -1) { + error_setg(errp, "Failed to read file status flags for fd= =3D%d", + mon_fdset_fd->fd); return -1; } =20 @@ -442,11 +445,15 @@ int monitor_fdset_dup_fd_add(int64_t fdset_id, int fl= ags) =20 if (fd =3D=3D -1) { errno =3D EACCES; + error_setg(errp, + "Failed to find file descriptor with matching flags= =3D0x%x", + flags); return -1; } =20 dup_fd =3D qemu_dup_flags(fd, flags); if (dup_fd =3D=3D -1) { + error_setg(errp, "Failed to dup() given file descriptor fd=3D%= d", fd); return -1; } =20 @@ -456,6 +463,7 @@ int monitor_fdset_dup_fd_add(int64_t fdset_id, int flag= s) return dup_fd; } =20 + error_setg(errp, "Failed to find fdset /dev/fdset/%" PRId64, fdset_id); errno =3D ENOENT; return -1; #endif diff --git a/stubs/fdset.c b/stubs/fdset.c index 389e368a29..2950fd91fd 100644 --- a/stubs/fdset.c +++ b/stubs/fdset.c @@ -3,7 +3,7 @@ #include "monitor/monitor.h" #include "../monitor/monitor-internal.h" =20 -int monitor_fdset_dup_fd_add(int64_t fdset_id, int flags) +int monitor_fdset_dup_fd_add(int64_t fdset_id, int flags, Error **errp) { errno =3D ENOSYS; return -1; diff --git a/util/osdep.c b/util/osdep.c index 756de9a745..5bbfdfac7a 100644 --- a/util/osdep.c +++ b/util/osdep.c @@ -310,7 +310,6 @@ qemu_open_internal(const char *name, int flags, mode_t = mode, Error **errp) /* Attempt dup of fd from fd set */ if (strstart(name, "/dev/fdset/", &fdset_id_str)) { int64_t fdset_id; - int dupfd; =20 fdset_id =3D qemu_parse_fdset(fdset_id_str); if (fdset_id =3D=3D -1) { @@ -319,14 +318,7 @@ qemu_open_internal(const char *name, int flags, mode_t= mode, Error **errp) return -1; } =20 - dupfd =3D monitor_fdset_dup_fd_add(fdset_id, flags); - if (dupfd =3D=3D -1) { - error_setg_errno(errp, errno, "Could not dup FD for %s flags %= x", - name, flags); - return -1; - } - - return dupfd; + return monitor_fdset_dup_fd_add(fdset_id, flags, errp); } #endif =20 --=20 2.35.3 From nobody Mon Nov 25 01:46:09 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1718651005; cv=none; d=zohomail.com; s=zohoarc; b=HtKxaMLL7jTrhBE5ucyCgMNHkCKnNnsuwaosAZ+G2GP7JaCk7yBq6nRDuwem0Jo/mBgjg83zEaH/48E8tgx62CgPw2YYeOTB03c3nM/0TK9ByexHNVkqLEcgciCNHF1Q1u3mxJLL3tkaKqTs25vMQ7EyspOKpv9/x+/tRc1CCxA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1718651005; h=Content-Type: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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=iUojXKKi7au5lbz0GBdgGak+ICpTnFKCQZykBCuYuWk=; b=UAsvAlAzzTNVNwJdNWRVI/6JeMXafqfXmgquclDZF0iZYI5Ao/l/sGLbXTnmZFrnwHbmV5NG/7a5E2QfpWfuOnoBAZ6UIVRW8Qg37O2sKhdp9fxvks1WEpPak6BrWZXq+O4Bf9BZkA9T85PWAjKaiUeaDNbjohpIa1y6ikzCREE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1718651005820263.3674317127096; Mon, 17 Jun 2024 12:03:25 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sJHYL-0003sT-GG; Mon, 17 Jun 2024 14:58:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sJHYK-0003sK-Jk for qemu-devel@nongnu.org; Mon, 17 Jun 2024 14:58:04 -0400 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 1sJHYJ-0004tx-3e for qemu-devel@nongnu.org; Mon, 17 Jun 2024 14:58:04 -0400 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 A178921AD6; Mon, 17 Jun 2024 18:58:01 +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 C51D7139AB; Mon, 17 Jun 2024 18:57:59 +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 uBl/IjeHcGYJKAAAD6G6ig (envelope-from ); Mon, 17 Jun 2024 18:57:59 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1718650681; h=from:from:reply-to: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=iUojXKKi7au5lbz0GBdgGak+ICpTnFKCQZykBCuYuWk=; b=m5HmwUY48raWZeD1wdUEvFcEujs5kgw3XQSyDFyUXoqM3Nrr3wIGnej27Qzs0+92wwTkIc 8n7malZY7y8eDezj9R9GISDhN4qU+13CqLsjByT8d0HTRwp4bgkMQOh7Sd+OUKYEgSqjZ8 UJvxmT5dv9dpQ5aPeIsaxsaFEWXErY4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1718650681; h=from:from:reply-to: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=iUojXKKi7au5lbz0GBdgGak+ICpTnFKCQZykBCuYuWk=; b=ztbejBloYR6sRSqwzAyrh+PAIyLWFCv0/iJXKzikLFGq65U0ucAqzMvWpJO/Zf0LviJd8L WCVd5lOGF6C/lSDQ== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1718650681; h=from:from:reply-to: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=iUojXKKi7au5lbz0GBdgGak+ICpTnFKCQZykBCuYuWk=; b=m5HmwUY48raWZeD1wdUEvFcEujs5kgw3XQSyDFyUXoqM3Nrr3wIGnej27Qzs0+92wwTkIc 8n7malZY7y8eDezj9R9GISDhN4qU+13CqLsjByT8d0HTRwp4bgkMQOh7Sd+OUKYEgSqjZ8 UJvxmT5dv9dpQ5aPeIsaxsaFEWXErY4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1718650681; h=from:from:reply-to: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=iUojXKKi7au5lbz0GBdgGak+ICpTnFKCQZykBCuYuWk=; b=ztbejBloYR6sRSqwzAyrh+PAIyLWFCv0/iJXKzikLFGq65U0ucAqzMvWpJO/Zf0LviJd8L WCVd5lOGF6C/lSDQ== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: berrange@redhat.com, armbru@redhat.com, Peter Xu , Claudio Fontana , Jim Fehlig Subject: [PATCH v3 10/16] io: Stop using qemu_open_old in channel-file Date: Mon, 17 Jun 2024 15:57:25 -0300 Message-Id: <20240617185731.9725-11-farosas@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240617185731.9725-1-farosas@suse.de> References: <20240617185731.9725-1-farosas@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Spam-Score: -3.30 X-Spamd-Result: default: False [-3.30 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_SHORT(-0.20)[-0.997]; MIME_GOOD(-0.10)[text/plain]; MIME_TRACE(0.00)[0:+]; RCVD_VIA_SMTP_AUTH(0.00)[]; TO_DN_SOME(0.00)[]; ARC_NA(0.00)[]; RCVD_TLS_ALL(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCPT_COUNT_FIVE(0.00)[6]; FROM_HAS_DN(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FROM_EQ_ENVFROM(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email] 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=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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @suse.de) X-ZM-MESSAGEID: 1718651007356100007 We want to make use of the Error object to report fdset errors from qemu_open_internal() and passing the error pointer to qemu_open_old() would require changing all callers. Move the file channel to the new API instead. Reviewed-by: Daniel P. Berrang=C3=A9 Reviewed-by: Peter Xu Signed-off-by: Fabiano Rosas --- io/channel-file.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/io/channel-file.c b/io/channel-file.c index 6436cfb6ae..2ea8d08360 100644 --- a/io/channel-file.c +++ b/io/channel-file.c @@ -68,11 +68,13 @@ qio_channel_file_new_path(const char *path, =20 ioc =3D QIO_CHANNEL_FILE(object_new(TYPE_QIO_CHANNEL_FILE)); =20 - ioc->fd =3D qemu_open_old(path, flags, mode); + if (flags & O_CREAT) { + ioc->fd =3D qemu_create(path, flags & ~O_CREAT, mode, errp); + } else { + ioc->fd =3D qemu_open(path, flags, errp); + } if (ioc->fd < 0) { object_unref(OBJECT(ioc)); - error_setg_errno(errp, errno, - "Unable to open %s", path); return NULL; } =20 --=20 2.35.3 From nobody Mon Nov 25 01:46:10 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1718650784; cv=none; d=zohomail.com; s=zohoarc; b=G7mFhO5+vaLu2GPUgJ5SkAYJQjNf1nj3mTiivDCm/pu6RX0LuizXlFcNnNtYSy9XZ0Rqc2ETqZniVo2R+zjBGQqIdFc5aDlgsZeKKVY54f3W98nVLXx1bOaZRUxT9Cxt88dMQ64vkwdaWT1B3sRduNWmPDmXpnCi4UZVwTNZkbk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1718650784; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=hlkxaYgY8mSil0KBcsjbPyn9bEQ8GI9qfd/aA4XAzyM=; b=Y4D5r+pPEICpC3YVMoVNSBL+7ZbyIRv2zK285Amqdt+Y4nDCFPZ1MsdcO30XJvtyhCNvhQEzBa96ALHgaTC/p1ETfo3e8PKQB5l+pmQvbp0D5ubTMhMr01OwU8NHWu7YzslXvh/bdvak1lsQGVVep5kxQE2ZMBqx3iERL81Pfcg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1718650784371592.377535144148; Mon, 17 Jun 2024 11:59:44 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sJHYO-0003tb-R4; Mon, 17 Jun 2024 14:58:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sJHYN-0003tI-7x for qemu-devel@nongnu.org; Mon, 17 Jun 2024 14:58:07 -0400 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 1sJHYL-0004uB-Co for qemu-devel@nongnu.org; Mon, 17 Jun 2024 14:58:07 -0400 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 42F8521AD5; Mon, 17 Jun 2024 18:58:04 +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 27C79139AB; Mon, 17 Jun 2024 18:58:01 +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 iCWnNzmHcGYJKAAAD6G6ig (envelope-from ); Mon, 17 Jun 2024 18:58:01 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1718650684; 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=hlkxaYgY8mSil0KBcsjbPyn9bEQ8GI9qfd/aA4XAzyM=; b=rTfhPWLnIPgZmgE4Ri/VUSGJPp0yqEBrz9rMfQ20Q67FWkT3vr6mGn/fJgsjVW2m4IOTKi PL9Ai06nMY/hzQISmD5QU9RyHTPX78dAKvJr4EXo3WQ63wSN55sTMVJ7t2Hpi2gPK2L8u1 rqby3Wz6JJim4JOb0UXEQBedNKgL+oo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1718650684; 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=hlkxaYgY8mSil0KBcsjbPyn9bEQ8GI9qfd/aA4XAzyM=; b=c4BIPP8IPLQleUoeujtz5aj95WLevZLgLVD4wlU60Dt8EArixQo0gZvmhw+rGpSIzQAecY wEt6njoyZdMecnCQ== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1718650684; 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=hlkxaYgY8mSil0KBcsjbPyn9bEQ8GI9qfd/aA4XAzyM=; b=rTfhPWLnIPgZmgE4Ri/VUSGJPp0yqEBrz9rMfQ20Q67FWkT3vr6mGn/fJgsjVW2m4IOTKi PL9Ai06nMY/hzQISmD5QU9RyHTPX78dAKvJr4EXo3WQ63wSN55sTMVJ7t2Hpi2gPK2L8u1 rqby3Wz6JJim4JOb0UXEQBedNKgL+oo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1718650684; 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=hlkxaYgY8mSil0KBcsjbPyn9bEQ8GI9qfd/aA4XAzyM=; b=c4BIPP8IPLQleUoeujtz5aj95WLevZLgLVD4wlU60Dt8EArixQo0gZvmhw+rGpSIzQAecY wEt6njoyZdMecnCQ== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: berrange@redhat.com, armbru@redhat.com, Peter Xu , Claudio Fontana , Jim Fehlig , Eric Blake Subject: [PATCH v3 11/16] migration: Add direct-io parameter Date: Mon, 17 Jun 2024 15:57:26 -0300 Message-Id: <20240617185731.9725-12-farosas@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240617185731.9725-1-farosas@suse.de> References: <20240617185731.9725-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.80 X-Spamd-Result: default: False [-2.80 / 50.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)[-1.000]; MIME_GOOD(-0.10)[text/plain]; RCPT_COUNT_SEVEN(0.00)[7]; RCVD_VIA_SMTP_AUTH(0.00)[]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; 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]; RCVD_TLS_ALL(0.00)[] 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=2a07:de40:b251:101:10:150:64:1; 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @suse.de) X-ZM-MESSAGEID: 1718650786270100007 Content-Type: text/plain; charset="utf-8" Add the direct-io migration parameter that tells the migration code to use O_DIRECT when opening the migration stream file whenever possible. This is currently only used with the mapped-ram migration that has a clear window guaranteed to perform aligned writes. Acked-by: Markus Armbruster Reviewed-by: Peter Xu Signed-off-by: Fabiano Rosas --- include/qemu/osdep.h | 2 ++ migration/migration-hmp-cmds.c | 11 +++++++++++ migration/options.c | 35 ++++++++++++++++++++++++++++++++++ migration/options.h | 1 + qapi/migration.json | 21 +++++++++++++++++--- util/osdep.c | 9 +++++++++ 6 files changed, 76 insertions(+), 3 deletions(-) diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h index f61edcfdc2..191916f38e 100644 --- a/include/qemu/osdep.h +++ b/include/qemu/osdep.h @@ -612,6 +612,8 @@ int qemu_lock_fd_test(int fd, int64_t start, int64_t le= n, bool exclusive); bool qemu_has_ofd_lock(void); #endif =20 +bool qemu_has_direct_io(void); + #if defined(__HAIKU__) && defined(__i386__) #define FMT_pid "%ld" #elif defined(WIN64) diff --git a/migration/migration-hmp-cmds.c b/migration/migration-hmp-cmds.c index 9f0e8029e0..7d608d26e1 100644 --- a/migration/migration-hmp-cmds.c +++ b/migration/migration-hmp-cmds.c @@ -351,6 +351,13 @@ void hmp_info_migrate_parameters(Monitor *mon, const Q= Dict *qdict) monitor_printf(mon, "%s: %s\n", MigrationParameter_str(MIGRATION_PARAMETER_MODE), qapi_enum_lookup(&MigMode_lookup, params->mode)); + + if (params->has_direct_io) { + monitor_printf(mon, "%s: %s\n", + MigrationParameter_str( + MIGRATION_PARAMETER_DIRECT_IO), + params->direct_io ? "on" : "off"); + } } =20 qapi_free_MigrationParameters(params); @@ -624,6 +631,10 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDi= ct *qdict) p->has_mode =3D true; visit_type_MigMode(v, param, &p->mode, &err); break; + case MIGRATION_PARAMETER_DIRECT_IO: + p->has_direct_io =3D true; + visit_type_bool(v, param, &p->direct_io, &err); + break; default: assert(0); } diff --git a/migration/options.c b/migration/options.c index 5ab5b6d85d..645f55003d 100644 --- a/migration/options.c +++ b/migration/options.c @@ -702,6 +702,25 @@ bool migrate_cpu_throttle_tailslow(void) return s->parameters.cpu_throttle_tailslow; } =20 +bool migrate_direct_io(void) +{ + MigrationState *s =3D migrate_get_current(); + + /* + * O_DIRECT is only supported with mapped-ram and multifd. + * + * mapped-ram is needed because filesystems impose restrictions on + * O_DIRECT IO alignment (see MAPPED_RAM_FILE_OFFSET_ALIGNMENT). + * + * multifd is needed to keep the unaligned portion of the stream + * isolated to the main migration thread while multifd channels + * process the aligned data with O_DIRECT enabled. + */ + return s->parameters.direct_io && + s->capabilities[MIGRATION_CAPABILITY_MAPPED_RAM] && + s->capabilities[MIGRATION_CAPABILITY_MULTIFD]; +} + uint64_t migrate_downtime_limit(void) { MigrationState *s =3D migrate_get_current(); @@ -905,6 +924,8 @@ MigrationParameters *qmp_query_migrate_parameters(Error= **errp) params->mode =3D s->parameters.mode; params->has_zero_page_detection =3D true; params->zero_page_detection =3D s->parameters.zero_page_detection; + params->has_direct_io =3D true; + params->direct_io =3D s->parameters.direct_io; =20 return params; } @@ -937,6 +958,7 @@ void migrate_params_init(MigrationParameters *params) params->has_vcpu_dirty_limit =3D true; params->has_mode =3D true; params->has_zero_page_detection =3D true; + params->has_direct_io =3D true; } =20 /* @@ -1110,6 +1132,11 @@ bool migrate_params_check(MigrationParameters *param= s, Error **errp) return false; } =20 + if (params->has_direct_io && params->direct_io && !qemu_has_direct_io(= )) { + error_setg(errp, "No build-time support for direct-io"); + return false; + } + return true; } =20 @@ -1216,6 +1243,10 @@ static void migrate_params_test_apply(MigrateSetPara= meters *params, if (params->has_zero_page_detection) { dest->zero_page_detection =3D params->zero_page_detection; } + + if (params->has_direct_io) { + dest->direct_io =3D params->direct_io; + } } =20 static void migrate_params_apply(MigrateSetParameters *params, Error **err= p) @@ -1341,6 +1372,10 @@ static void migrate_params_apply(MigrateSetParameter= s *params, Error **errp) if (params->has_zero_page_detection) { s->parameters.zero_page_detection =3D params->zero_page_detection; } + + if (params->has_direct_io) { + s->parameters.direct_io =3D params->direct_io; + } } =20 void qmp_migrate_set_parameters(MigrateSetParameters *params, Error **errp) diff --git a/migration/options.h b/migration/options.h index 4b21cc2669..a2397026db 100644 --- a/migration/options.h +++ b/migration/options.h @@ -69,6 +69,7 @@ uint32_t migrate_checkpoint_delay(void); uint8_t migrate_cpu_throttle_increment(void); uint8_t migrate_cpu_throttle_initial(void); bool migrate_cpu_throttle_tailslow(void); +bool migrate_direct_io(void); uint64_t migrate_downtime_limit(void); uint8_t migrate_max_cpu_throttle(void); uint64_t migrate_max_bandwidth(void); diff --git a/qapi/migration.json b/qapi/migration.json index 470f746cc5..de6c8b0444 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -821,6 +821,10 @@ # See description in @ZeroPageDetection. Default is 'multifd'. # (since 9.0) # +# @direct-io: Open migration files with O_DIRECT when possible. This +# only has effect if the @mapped-ram capability is enabled. +# (Since 9.1) +# # Features: # # @unstable: Members @x-checkpoint-delay and @@ -845,7 +849,8 @@ { 'name': 'x-vcpu-dirty-limit-period', 'features': ['unstable']= }, 'vcpu-dirty-limit', 'mode', - 'zero-page-detection'] } + 'zero-page-detection', + 'direct-io'] } =20 ## # @MigrateSetParameters: @@ -991,6 +996,10 @@ # See description in @ZeroPageDetection. Default is 'multifd'. # (since 9.0) # +# @direct-io: Open migration files with O_DIRECT when possible. This +# only has effect if the @mapped-ram capability is enabled. +# (Since 9.1) +# # Features: # # @unstable: Members @x-checkpoint-delay and @@ -1030,7 +1039,8 @@ 'features': [ 'unstable' ] }, '*vcpu-dirty-limit': 'uint64', '*mode': 'MigMode', - '*zero-page-detection': 'ZeroPageDetection'} } + '*zero-page-detection': 'ZeroPageDetection', + '*direct-io': 'bool' } } =20 ## # @migrate-set-parameters: @@ -1190,6 +1200,10 @@ # See description in @ZeroPageDetection. Default is 'multifd'. # (since 9.0) # +# @direct-io: Open migration files with O_DIRECT when possible. This +# only has effect if the @mapped-ram capability is enabled. +# (Since 9.1) +# # Features: # # @unstable: Members @x-checkpoint-delay and @@ -1226,7 +1240,8 @@ 'features': [ 'unstable' ] }, '*vcpu-dirty-limit': 'uint64', '*mode': 'MigMode', - '*zero-page-detection': 'ZeroPageDetection'} } + '*zero-page-detection': 'ZeroPageDetection', + '*direct-io': 'bool' } } =20 ## # @query-migrate-parameters: diff --git a/util/osdep.c b/util/osdep.c index 5bbfdfac7a..770369831b 100644 --- a/util/osdep.c +++ b/util/osdep.c @@ -282,6 +282,15 @@ int qemu_lock_fd_test(int fd, int64_t start, int64_t l= en, bool exclusive) } #endif =20 +bool qemu_has_direct_io(void) +{ +#ifdef O_DIRECT + return true; +#else + return false; +#endif +} + static int qemu_open_cloexec(const char *name, int flags, mode_t mode) { int ret; --=20 2.35.3 From nobody Mon Nov 25 01:46:10 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1718650750; cv=none; d=zohomail.com; s=zohoarc; b=nSp+pW1D8CfjehpOfpILpuj4xTGbMiwRu3hWyV8xRsAD18yJZq+f5bGiiZTWL1F0I2LTefjSQpj1R2Lw+hTUlXRAo6PXIfU791N3Z83Frv3xzZLQUAjlXS+3J8YFvNBxfe33IhXAgDzGpQOpzWX1Yy+sokfvQ+jgMC99wgIRfB8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1718650750; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=V2RXA+Fyk511u+QU1eiu5Q2LRU6vzATiXBtyBQ4Exfs=; b=atIPpK50UVv88GBso4+vl3YTVuFQ4CRzZaepDCCiZcAUwMitlsrD4bASLWkSFMBsG2pyo6I9qxH4H18KbKbU0F1Q7FQEk2xETcc5hooDcAvKxesXKRGBKoNoTOAdPAFZTHLtPBa7q6gnSz8UNwv7naenglKBX6i2dX5nwkkhT7A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1718650750837193.29358163793154; Mon, 17 Jun 2024 11:59:10 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sJHYQ-0003uG-IN; Mon, 17 Jun 2024 14:58:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sJHYP-0003ty-IU for qemu-devel@nongnu.org; Mon, 17 Jun 2024 14:58:09 -0400 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 1sJHYN-0004uQ-Nv for qemu-devel@nongnu.org; Mon, 17 Jun 2024 14:58:09 -0400 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 90C251F443; Mon, 17 Jun 2024 18:58:06 +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 B735B139AB; Mon, 17 Jun 2024 18:58:04 +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 oIxAHzyHcGYJKAAAD6G6ig (envelope-from ); Mon, 17 Jun 2024 18:58:04 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1718650686; 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=V2RXA+Fyk511u+QU1eiu5Q2LRU6vzATiXBtyBQ4Exfs=; b=E9y+K++JJ7B48C6O27icUIRQXnY36v6UQkRfK7lCpjZqy1K0CUOMNiHzmXd45O/DT7dBp7 SPxrzlThGiqYqbyDayQrt+4UIAvfCugQYYiE1HLv7fWzI56rVD5E1NKUfkE3uCdi2sUgXl bGswwdDmFbYFQiPdS768Yc0XBXHaTww= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1718650686; 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=V2RXA+Fyk511u+QU1eiu5Q2LRU6vzATiXBtyBQ4Exfs=; b=GfogCzxy+WS9OfRNkJcDzASKb+7Hehzo7a4hxE4dvtMqG5yvh2kqsNTOJ42/G22voqSsg/ xn+T5SwKTnxpGfBg== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=E9y+K++J; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=GfogCzxy DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1718650686; 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=V2RXA+Fyk511u+QU1eiu5Q2LRU6vzATiXBtyBQ4Exfs=; b=E9y+K++JJ7B48C6O27icUIRQXnY36v6UQkRfK7lCpjZqy1K0CUOMNiHzmXd45O/DT7dBp7 SPxrzlThGiqYqbyDayQrt+4UIAvfCugQYYiE1HLv7fWzI56rVD5E1NKUfkE3uCdi2sUgXl bGswwdDmFbYFQiPdS768Yc0XBXHaTww= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1718650686; 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=V2RXA+Fyk511u+QU1eiu5Q2LRU6vzATiXBtyBQ4Exfs=; b=GfogCzxy+WS9OfRNkJcDzASKb+7Hehzo7a4hxE4dvtMqG5yvh2kqsNTOJ42/G22voqSsg/ xn+T5SwKTnxpGfBg== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: berrange@redhat.com, armbru@redhat.com, Peter Xu , Claudio Fontana , Jim Fehlig Subject: [PATCH v3 12/16] migration/multifd: Add direct-io support Date: Mon, 17 Jun 2024 15:57:27 -0300 Message-Id: <20240617185731.9725-13-farosas@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240617185731.9725-1-farosas@suse.de> References: <20240617185731.9725-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; 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)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; MIME_TRACE(0.00)[0:+]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; TO_DN_SOME(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email,suse.de:dkim]; RCVD_TLS_ALL(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; RCPT_COUNT_FIVE(0.00)[6]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; DKIM_TRACE(0.00)[suse.de:+] X-Rspamd-Action: no action X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Queue-Id: 90C251F443 X-Spam-Score: -3.01 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=2a07:de40:b251:101:10:150:64:2; envelope-from=farosas@suse.de; helo=smtp-out2.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @suse.de) X-ZM-MESSAGEID: 1718650752061100006 Content-Type: text/plain; charset="utf-8" When multifd is used along with mapped-ram, we can take benefit of a filesystem that supports the O_DIRECT flag and perform direct I/O in the multifd threads. This brings a significant performance improvement because direct-io writes bypass the page cache which would otherwise be thrashed by the multifd data which is unlikely to be needed again in a short period of time. To be able to use a multifd channel opened with O_DIRECT, we must ensure that a certain aligment is used. Filesystems usually require a block-size alignment for direct I/O. The way to achieve this is by enabling the mapped-ram feature, which already aligns its I/O properly (see MAPPED_RAM_FILE_OFFSET_ALIGNMENT at ram.c). By setting O_DIRECT on the multifd channels, all writes to the same file descriptor need to be aligned as well, even the ones that come from outside multifd, such as the QEMUFile I/O from the main migration code. This makes it impossible to use the same file descriptor for the QEMUFile and for the multifd channels. The various flags and metadata written by the main migration code will always be unaligned by virtue of their small size. To workaround this issue, we'll require a second file descriptor to be used exclusively for direct I/O. The second file descriptor can be obtained by QEMU by re-opening the migration file (already possible), or by being provided by the user or management application (support to be added in future patches). Signed-off-by: Fabiano Rosas Reviewed-by: Peter Xu --- migration/file.c | 33 ++++++++++++++++++++++++++++----- migration/file.h | 1 - migration/migration.c | 23 +++++++++++++++++++++++ 3 files changed, 51 insertions(+), 6 deletions(-) diff --git a/migration/file.c b/migration/file.c index a903710f06..db870f2cf0 100644 --- a/migration/file.c +++ b/migration/file.c @@ -50,12 +50,31 @@ void file_cleanup_outgoing_migration(void) outgoing_args.fname =3D NULL; } =20 +static void file_enable_direct_io(int *flags) +{ +#ifdef O_DIRECT + *flags |=3D O_DIRECT; +#else + /* it should have been rejected when setting the parameter */ + g_assert_not_reached(); +#endif +} + bool file_send_channel_create(gpointer opaque, Error **errp) { QIOChannelFile *ioc; int flags =3D O_WRONLY; bool ret =3D true; =20 + if (migrate_direct_io()) { + /* + * Enable O_DIRECT for the secondary channels. These are used + * for sending ram pages and writes should be guaranteed to be + * aligned to at least page size. + */ + file_enable_direct_io(&flags); + } + ioc =3D qio_channel_file_new_path(outgoing_args.fname, flags, 0, errp); if (!ioc) { ret =3D false; @@ -117,21 +136,25 @@ static gboolean file_accept_incoming_migration(QIOCha= nnel *ioc, return G_SOURCE_REMOVE; } =20 -void file_create_incoming_channels(QIOChannel *ioc, Error **errp) +static void file_create_incoming_channels(QIOChannel *ioc, char *filename, + Error **errp) { - int i, fd, channels =3D 1; + int i, channels =3D 1; g_autofree QIOChannel **iocs =3D NULL; + int flags =3D O_RDONLY; =20 if (migrate_multifd()) { channels +=3D migrate_multifd_channels(); + if (migrate_direct_io()) { + file_enable_direct_io(&flags); + } } =20 iocs =3D g_new0(QIOChannel *, channels); - fd =3D QIO_CHANNEL_FILE(ioc)->fd; iocs[0] =3D ioc; =20 for (i =3D 1; i < channels; i++) { - QIOChannelFile *fioc =3D qio_channel_file_new_dupfd(fd, errp); + QIOChannelFile *fioc =3D qio_channel_file_new_path(filename, flags= , 0, errp); =20 if (!fioc) { while (i) { @@ -171,7 +194,7 @@ void file_start_incoming_migration(FileMigrationArgs *f= ile_args, Error **errp) return; } =20 - file_create_incoming_channels(QIO_CHANNEL(fioc), errp); + file_create_incoming_channels(QIO_CHANNEL(fioc), filename, errp); } =20 int file_write_ramblock_iov(QIOChannel *ioc, const struct iovec *iov, diff --git a/migration/file.h b/migration/file.h index 7699c04677..9f71e87f74 100644 --- a/migration/file.h +++ b/migration/file.h @@ -20,7 +20,6 @@ void file_start_outgoing_migration(MigrationState *s, int file_parse_offset(char *filespec, uint64_t *offsetp, Error **errp); void file_cleanup_outgoing_migration(void); bool file_send_channel_create(gpointer opaque, Error **errp); -void file_create_incoming_channels(QIOChannel *ioc, Error **errp); int file_write_ramblock_iov(QIOChannel *ioc, const struct iovec *iov, int niov, RAMBlock *block, Error **errp); int multifd_file_recv_data(MultiFDRecvParams *p, Error **errp); diff --git a/migration/migration.c b/migration/migration.c index e1b269624c..e03c80b3aa 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -155,6 +155,16 @@ static bool migration_needs_seekable_channel(void) return migrate_mapped_ram(); } =20 +static bool migration_needs_extra_fds(void) +{ + /* + * When doing direct-io, multifd requires two different, + * non-duplicated file descriptors so we can use one of them for + * unaligned IO. + */ + return migrate_multifd() && migrate_direct_io(); +} + static bool transport_supports_seeking(MigrationAddress *addr) { if (addr->transport =3D=3D MIGRATION_ADDRESS_TYPE_FILE) { @@ -164,6 +174,12 @@ static bool transport_supports_seeking(MigrationAddres= s *addr) return false; } =20 +static bool transport_supports_extra_fds(MigrationAddress *addr) +{ + /* file: works because QEMU can open it multiple times */ + return addr->transport =3D=3D MIGRATION_ADDRESS_TYPE_FILE; +} + static bool migration_channels_and_transport_compatible(MigrationAddress *addr, Error **errp) @@ -180,6 +196,13 @@ migration_channels_and_transport_compatible(MigrationA= ddress *addr, return false; } =20 + if (migration_needs_extra_fds() && + !transport_supports_extra_fds(addr)) { + error_setg(errp, + "Migration requires a transport that allows for extra f= ds (e.g. file)"); + return false; + } + return true; } =20 --=20 2.35.3 From nobody Mon Nov 25 01:46:10 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1718650810; cv=none; d=zohomail.com; s=zohoarc; b=k5PGlova9KZW8O7l4VhW1MktH5G8jNP7/TaPM8a5d5vpiYn4n2r3aZhA39bRjWGc4s65XDiKvVV4hwRmn9RmmZcMql9bHt4i3HJQQvudfjT+yv4YTj7jwFOS+kBP7boffnn45Vl6wkj/Wcmw5lweeOwLwFwCFVkFg3yEWZmQYFU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1718650810; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=6Lgbs6WXgUOubcuUls5+VQriQr9iuKrCP4tGbDJbZEU=; b=nO3i8N6/phduibwCzIzb4BnjiiFD7GcxzDwV/Y07qpV8rXz9PPbSdWkmoFnNx0+kOvJUnp/og+bYvGChCAuj8aiw73DY3KHPil9CYlBUei74VOJwx2QsRN70VLPzt3ATMAKZOIqVvHL/C7EWMt7+HRccKFx2d6Jo+DkBkcWpMuY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1718650810388733.3312002647357; Mon, 17 Jun 2024 12:00:10 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sJHYU-0003uq-22; Mon, 17 Jun 2024 14:58:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sJHYS-0003ua-Is for qemu-devel@nongnu.org; Mon, 17 Jun 2024 14:58:12 -0400 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 1sJHYQ-0004uj-Qn for qemu-devel@nongnu.org; Mon, 17 Jun 2024 14:58:12 -0400 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 9927121AD5; Mon, 17 Jun 2024 18:58:09 +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 1366B139AB; Mon, 17 Jun 2024 18:58:06 +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 MDq9Mj6HcGYJKAAAD6G6ig (envelope-from ); Mon, 17 Jun 2024 18:58:06 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1718650689; 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=6Lgbs6WXgUOubcuUls5+VQriQr9iuKrCP4tGbDJbZEU=; b=O0hhZClCw2bWlpjf8fBGTYRXqQVZ8l/Wo+AgLCmxx0YOlz+02QtXPRPkzy2DTZDIjCrjuC ITMU1Xy1g1jjB8RleuH2tUtbzdon2KCoAJmaIlU7DDmoRbfEPs6a4p5nmglH/vhJsZFmPb OGeO6xdZqriJAdFZ4B7ww8dHmOP5W8I= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1718650689; 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=6Lgbs6WXgUOubcuUls5+VQriQr9iuKrCP4tGbDJbZEU=; b=dhlgZ/x6oVad6CSLPbhkKj0yg1+PeDxq12iTaa6NgYDlN1xlMwPtaVnBVnlT9Qcz/VYpDW TbhYGRaofj7WAjAw== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=O0hhZClC; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b="dhlgZ/x6" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1718650689; 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=6Lgbs6WXgUOubcuUls5+VQriQr9iuKrCP4tGbDJbZEU=; b=O0hhZClCw2bWlpjf8fBGTYRXqQVZ8l/Wo+AgLCmxx0YOlz+02QtXPRPkzy2DTZDIjCrjuC ITMU1Xy1g1jjB8RleuH2tUtbzdon2KCoAJmaIlU7DDmoRbfEPs6a4p5nmglH/vhJsZFmPb OGeO6xdZqriJAdFZ4B7ww8dHmOP5W8I= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1718650689; 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=6Lgbs6WXgUOubcuUls5+VQriQr9iuKrCP4tGbDJbZEU=; b=dhlgZ/x6oVad6CSLPbhkKj0yg1+PeDxq12iTaa6NgYDlN1xlMwPtaVnBVnlT9Qcz/VYpDW TbhYGRaofj7WAjAw== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: berrange@redhat.com, armbru@redhat.com, Peter Xu , Claudio Fontana , Jim Fehlig , Thomas Huth , Laurent Vivier , Paolo Bonzini Subject: [PATCH v3 13/16] tests/qtest/migration: Add tests for file migration with direct-io Date: Mon, 17 Jun 2024 15:57:28 -0300 Message-Id: <20240617185731.9725-14-farosas@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240617185731.9725-1-farosas@suse.de> References: <20240617185731.9725-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Rspamd-Queue-Id: 9927121AD5 X-Spam-Score: -3.01 X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; 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)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RCVD_COUNT_TWO(0.00)[2]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCPT_COUNT_SEVEN(0.00)[9]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email,suse.de:dkim]; RCVD_TLS_ALL(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; DKIM_TRACE(0.00)[suse.de:+] X-Rspamd-Action: no action X-Rspamd-Server: rspamd1.dmz-prg2.suse.org 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=2a07:de40:b251:101:10:150:64:1; 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @suse.de) X-ZM-MESSAGEID: 1718650812359100003 Content-Type: text/plain; charset="utf-8" The tests are only allowed to run in systems that know about the O_DIRECT flag and in filesystems which support it. Note: this also brings back migrate_set_parameter_bool() which went away when we removed the compression tests. I copied it verbatim. Signed-off-by: Fabiano Rosas Reviewed-by: Peter Xu --- tests/qtest/migration-helpers.c | 44 +++++++++++++++++++++++ tests/qtest/migration-helpers.h | 8 +++++ tests/qtest/migration-test.c | 62 +++++++++++++++++++++++++++++++++ 3 files changed, 114 insertions(+) diff --git a/tests/qtest/migration-helpers.c b/tests/qtest/migration-helper= s.c index ce6d6615b5..0ac49ceb54 100644 --- a/tests/qtest/migration-helpers.c +++ b/tests/qtest/migration-helpers.c @@ -18,6 +18,7 @@ #include "qapi/error.h" #include "qapi/qmp/qlist.h" #include "qemu/cutils.h" +#include "qemu/memalign.h" =20 #include "migration-helpers.h" =20 @@ -473,3 +474,46 @@ void migration_test_add(const char *path, void (*fn)(v= oid)) qtest_add_data_func_full(path, test, migration_test_wrapper, migration_test_destroy); } + +#ifdef O_DIRECT +/* + * Probe for O_DIRECT support on the filesystem. Since this is used + * for tests, be conservative, if anything fails, assume it's + * unsupported. + */ +bool probe_o_direct_support(const char *tmpfs) +{ + g_autofree char *filename =3D g_strdup_printf("%s/probe-o-direct", tmp= fs); + int fd, flags =3D O_CREAT | O_RDWR | O_TRUNC | O_DIRECT; + void *buf; + ssize_t ret, len; + uint64_t offset; + + fd =3D open(filename, flags, 0660); + if (fd < 0) { + unlink(filename); + return false; + } + + /* + * Using 1MB alignment as conservative choice to satisfy any + * plausible architecture default page size, and/or filesystem + * alignment restrictions. + */ + len =3D 0x100000; + offset =3D 0x100000; + + buf =3D qemu_try_memalign(len, len); + g_assert(buf); + + ret =3D pwrite(fd, buf, len, offset); + unlink(filename); + g_free(buf); + + if (ret < 0) { + return false; + } + + return true; +} +#endif diff --git a/tests/qtest/migration-helpers.h b/tests/qtest/migration-helper= s.h index 1339835698..50095fca4a 100644 --- a/tests/qtest/migration-helpers.h +++ b/tests/qtest/migration-helpers.h @@ -54,5 +54,13 @@ char *find_common_machine_version(const char *mtype, con= st char *var1, const char *var2); char *resolve_machine_version(const char *alias, const char *var1, const char *var2); +#ifdef O_DIRECT +bool probe_o_direct_support(const char *tmpfs); +#else +static inline bool probe_o_direct_support(const char *tmpfs) +{ + return false; +} +#endif void migration_test_add(const char *path, void (*fn)(void)); #endif /* MIGRATION_HELPERS_H */ diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c index 22b07bc0ec..928f0ca6ce 100644 --- a/tests/qtest/migration-test.c +++ b/tests/qtest/migration-test.c @@ -407,6 +407,38 @@ static void migrate_set_parameter_str(QTestState *who,= const char *parameter, migrate_check_parameter_str(who, parameter, value); } =20 +static long long migrate_get_parameter_bool(QTestState *who, + const char *parameter) +{ + QDict *rsp; + int result; + + rsp =3D qtest_qmp_assert_success_ref( + who, "{ 'execute': 'query-migrate-parameters' }"); + result =3D qdict_get_bool(rsp, parameter); + qobject_unref(rsp); + return !!result; +} + +static void migrate_check_parameter_bool(QTestState *who, const char *para= meter, + int value) +{ + int result; + + result =3D migrate_get_parameter_bool(who, parameter); + g_assert_cmpint(result, =3D=3D, value); +} + +static void migrate_set_parameter_bool(QTestState *who, const char *parame= ter, + int value) +{ + qtest_qmp_assert_success(who, + "{ 'execute': 'migrate-set-parameters'," + "'arguments': { %s: %i } }", + parameter, value); + migrate_check_parameter_bool(who, parameter, value); +} + static void migrate_ensure_non_converge(QTestState *who) { /* Can't converge with 1ms downtime + 3 mbs bandwidth limit */ @@ -2155,6 +2187,33 @@ static void test_multifd_file_mapped_ram(void) test_file_common(&args, true); } =20 +static void *multifd_mapped_ram_dio_start(QTestState *from, QTestState *to) +{ + migrate_multifd_mapped_ram_start(from, to); + + migrate_set_parameter_bool(from, "direct-io", true); + migrate_set_parameter_bool(to, "direct-io", true); + + return NULL; +} + +static void test_multifd_file_mapped_ram_dio(void) +{ + g_autofree char *uri =3D g_strdup_printf("file:%s/%s", tmpfs, + FILE_TEST_FILENAME); + MigrateCommon args =3D { + .connect_uri =3D uri, + .listen_uri =3D "defer", + .start_hook =3D multifd_mapped_ram_dio_start, + }; + + if (!probe_o_direct_support(tmpfs)) { + g_test_skip("Filesystem does not support O_DIRECT"); + return; + } + + test_file_common(&args, true); +} =20 static void test_precopy_tcp_plain(void) { @@ -3592,6 +3651,9 @@ int main(int argc, char **argv) migration_test_add("/migration/multifd/file/mapped-ram/live", test_multifd_file_mapped_ram_live); =20 + migration_test_add("/migration/multifd/file/mapped-ram/dio", + test_multifd_file_mapped_ram_dio); + #ifdef CONFIG_GNUTLS migration_test_add("/migration/precopy/unix/tls/psk", test_precopy_unix_tls_psk); --=20 2.35.3 From nobody Mon Nov 25 01:46:10 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1718650749; cv=none; d=zohomail.com; s=zohoarc; b=hHe05Qiy3A/zr9JZbfNORCtLAcQU3DznQ4PKU6gzwhCkoRTDXfRg/RfMomQii4+ph89Qpu6ItxZ4QbWEVKzYLLbzfe358uQalN2o6ELhA96htHxJqpTdeBxb7Qz0BRnFQTBYfpKK43ptcoRcqZ/lDY+8DaSyTdRIumsW1YizUQ4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1718650749; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=a03gkYH2QZOFOSa6odfujVtphMi3cC8MquQiUv1hbjQ=; b=k2IkKuOKLY3ugkVTOOnSjyNk2yKt/OaUwF+cOZ2Qt1haYxz018GbCImmqb1bBP9YmZ8XJvQz2JPL3vgKDN0kh0gKvJxSqwcEF1XvglFuW6bId/0NmedNakgXKseXu8pqyrb5czULoLC1Pvt585pBSs/Tl4i73mmGPrdN5q4i9kU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1718650749398612.2305518979281; Mon, 17 Jun 2024 11:59:09 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sJHYW-0003vM-VG; Mon, 17 Jun 2024 14:58:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sJHYV-0003ut-2d for qemu-devel@nongnu.org; Mon, 17 Jun 2024 14:58:15 -0400 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 1sJHYT-0004uu-Hi for qemu-devel@nongnu.org; Mon, 17 Jun 2024 14:58:14 -0400 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-out2.suse.de (Postfix) with ESMTPS id E6B381F443; Mon, 17 Jun 2024 18:58:11 +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 17495139AB; Mon, 17 Jun 2024 18:58:09 +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 cP/FM0GHcGYJKAAAD6G6ig (envelope-from ); Mon, 17 Jun 2024 18:58:09 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1718650692; 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=a03gkYH2QZOFOSa6odfujVtphMi3cC8MquQiUv1hbjQ=; b=nn95MGlxZUVVBkgXFal0UP+srQ4roZJG1GWR2F5msyOFxUegZ+rh3ghZs/zs63YQ6IGEnX VNk8Z/jtlFoG6rzNE9sBSvmzPpWOafBP4Ra8tviDFBx6AlC2UQj0LTF2P7+JFmoV7+hFJY R387U0hXjTvM3lBckVKvKhQWZqoqp8E= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1718650692; 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=a03gkYH2QZOFOSa6odfujVtphMi3cC8MquQiUv1hbjQ=; b=ZPY2uyHVIxaC79NFBztdwkF4sfNCZdjtosjzITFufUR13DD1i7v6L9m9oyz+NEZwONxpLm vyVXfkzg0uwBz+BA== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1718650691; 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=a03gkYH2QZOFOSa6odfujVtphMi3cC8MquQiUv1hbjQ=; b=wvOIINc1jbByhZLukz+gPKoz21DuLQpuWPcYxALqy3Nmleehuvfh4iL8ysmMb8uyWjQkvj P43H6rXlK9SAhcf+r+La0hQxJ4AexoMBeyC4fbTh/jfO3VB7G3yY6iIbm3rM9mYWKgHNjG XRRpqpZ9ZGUug0+kQMtEBX2yEcxPtvQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1718650691; 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=a03gkYH2QZOFOSa6odfujVtphMi3cC8MquQiUv1hbjQ=; b=QYoVDsMTgrtn9ytRcHr2/v93N/f/Ry7Cz7TvEbKnyzyJy0jO0uX+m9XkPub8EXR9MLWtR/ iZdLVAC1HNyyjnDw== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: berrange@redhat.com, armbru@redhat.com, Peter Xu , Claudio Fontana , Jim Fehlig Subject: [PATCH v3 14/16] monitor: fdset: Match against O_DIRECT Date: Mon, 17 Jun 2024 15:57:29 -0300 Message-Id: <20240617185731.9725-15-farosas@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240617185731.9725-1-farosas@suse.de> References: <20240617185731.9725-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.80 X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_FIVE(0.00)[6]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email]; RCVD_TLS_ALL(0.00)[] 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=2a07:de40:b251:101:10:150:64:2; envelope-from=farosas@suse.de; helo=smtp-out2.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @suse.de) (identity @suse.de) X-ZM-MESSAGEID: 1718650750349100001 Content-Type: text/plain; charset="utf-8" We're about to enable the use of O_DIRECT in the migration code and due to the alignment restrictions imposed by filesystems we need to make sure the flag is only used when doing aligned IO. The migration will do parallel IO to different regions of a file, so we need to use more than one file descriptor. Those cannot be obtained by duplicating (dup()) since duplicated file descriptors share the file status flags, including O_DIRECT. If one migration channel does unaligned IO while another sets O_DIRECT to do aligned IO, the filesystem would fail the unaligned operation. The add-fd QMP command along with the fdset code are specifically designed to allow the user to pass a set of file descriptors with different access flags into QEMU to be later fetched by code that needs to alternate between those flags when doing IO. Extend the fdset matching to behave the same with the O_DIRECT flag. Reviewed-by: Peter Xu Signed-off-by: Fabiano Rosas --- monitor/fds.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/monitor/fds.c b/monitor/fds.c index fd87e7db8b..436d5d80b8 100644 --- a/monitor/fds.c +++ b/monitor/fds.c @@ -424,6 +424,11 @@ int monitor_fdset_dup_fd_add(int64_t fdset_id, int fla= gs, Error **errp) int fd =3D -1; int dup_fd; int mon_fd_flags; + int mask =3D O_ACCMODE; + +#ifdef O_DIRECT + mask |=3D O_DIRECT; +#endif =20 if (mon_fdset->id !=3D fdset_id) { continue; @@ -437,7 +442,7 @@ int monitor_fdset_dup_fd_add(int64_t fdset_id, int flag= s, Error **errp) return -1; } =20 - if ((flags & O_ACCMODE) =3D=3D (mon_fd_flags & O_ACCMODE)) { + if ((flags & mask) =3D=3D (mon_fd_flags & mask)) { fd =3D mon_fdset_fd->fd; break; } --=20 2.35.3 From nobody Mon Nov 25 01:46:10 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1718650830; cv=none; d=zohomail.com; s=zohoarc; b=mh69eW4UJe/MC7SBfHkO5zxZdAwt5MTclPmXv32Pp385t9UVUZUAF0+38Qv6Tb0eIpQqJyB7h3IN+h4FAY09wOkv07y7tle2nbYP+bghB+CD3x/uZz1h2JkSgRL9ctDcT/nBLBTI3MHBm4QvyPp6N6FNZssOYEoRxY/iQkH/2aM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1718650830; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=dpaA8UyxtRDsfB5RjDLzg2FDrDvAArW4wQMiSrS11Zc=; b=VXEyWPJkFxktJ0eGyAiLNofEZlak/xXsiWQbc+iCWYAOj871UhpEvAqgdW7aPBr9Rg+NofMCYjomMtLUTJiaIw9IY9SRUYVcomXV6BhDDRqyE/F0GzkmxAaY3tcLKB3LIJBonDB/PBWrSWvrJEi5w9TCwHyQQ9Y3AW73otU33mc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1718650830463809.7920758515919; Mon, 17 Jun 2024 12:00:30 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sJHYZ-0003w8-9o; Mon, 17 Jun 2024 14:58:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sJHYX-0003vi-DT for qemu-devel@nongnu.org; Mon, 17 Jun 2024 14:58:17 -0400 Received: from smtp-out2.suse.de ([195.135.223.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sJHYV-0004v9-HE for qemu-devel@nongnu.org; Mon, 17 Jun 2024 14:58:17 -0400 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-out2.suse.de (Postfix) with ESMTPS id 41C741F7A6; Mon, 17 Jun 2024 18:58:14 +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 659A6139AB; Mon, 17 Jun 2024 18:58:12 +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 EG5EC0SHcGYJKAAAD6G6ig (envelope-from ); Mon, 17 Jun 2024 18:58:12 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1718650694; 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=dpaA8UyxtRDsfB5RjDLzg2FDrDvAArW4wQMiSrS11Zc=; b=wASqEzQmQuQYa6iRWJL/VKvh9H+L2Bk3skkYbpAofBZqkDVtpL+B7Nk62FnQOkUwKFRwbb yAQJzHOsb7GXyA+6YCt1wGTD4Y5e24QgeDzt2xYNAYIw4jb2SNPugOBFCQ5sjm07kKUyHX yWXPihA/f45AHAoi7ObXZBd4EdGFigk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1718650694; 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=dpaA8UyxtRDsfB5RjDLzg2FDrDvAArW4wQMiSrS11Zc=; b=1np21OVr7AxYYxIS9oSXXieS9XzzcjD2QzmDYKmRUo5IZ8Mu3Is6CiRyf6Rk3QASCWZtkg dqjE+CIKPuVIygCA== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1718650694; 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=dpaA8UyxtRDsfB5RjDLzg2FDrDvAArW4wQMiSrS11Zc=; b=wASqEzQmQuQYa6iRWJL/VKvh9H+L2Bk3skkYbpAofBZqkDVtpL+B7Nk62FnQOkUwKFRwbb yAQJzHOsb7GXyA+6YCt1wGTD4Y5e24QgeDzt2xYNAYIw4jb2SNPugOBFCQ5sjm07kKUyHX yWXPihA/f45AHAoi7ObXZBd4EdGFigk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1718650694; 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=dpaA8UyxtRDsfB5RjDLzg2FDrDvAArW4wQMiSrS11Zc=; b=1np21OVr7AxYYxIS9oSXXieS9XzzcjD2QzmDYKmRUo5IZ8Mu3Is6CiRyf6Rk3QASCWZtkg dqjE+CIKPuVIygCA== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: berrange@redhat.com, armbru@redhat.com, Peter Xu , Claudio Fontana , Jim Fehlig Subject: [PATCH v3 15/16] migration: Add documentation for fdset with multifd + file Date: Mon, 17 Jun 2024 15:57:30 -0300 Message-Id: <20240617185731.9725-16-farosas@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240617185731.9725-1-farosas@suse.de> References: <20240617185731.9725-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_FIVE(0.00)[6]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email]; RCVD_TLS_ALL(0.00)[] X-Spam-Score: -2.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=lists.gnu.org; Received-SPF: pass client-ip=195.135.223.131; envelope-from=farosas@suse.de; helo=smtp-out2.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @suse.de) X-ZM-MESSAGEID: 1718650832498100007 Content-Type: text/plain; charset="utf-8" With the last few changes to the fdset infrastructure, we now allow multifd to use an fdset when migrating to a file. This is useful for the scenario where the management layer wants to have control over the migration file. By receiving the file descriptors directly, QEMU can delegate some high level operating system operations to the management layer (such as mandatory access control). The management layer might also want to add its own headers before the migration stream. Document the "file:/dev/fdset/#" syntax for the multifd migration with mapped-ram. The requirements for the fdset mechanism are: - the fdset must contain two fds that are not duplicates between themselves; - if direct-io is to be used, exactly one of the fds must have the O_DIRECT flag set; - the file must be opened with WRONLY on the migration source side; - the file must be opened with RDONLY on the migration destination side. Reviewed-by: Peter Xu Signed-off-by: Fabiano Rosas --- docs/devel/migration/main.rst | 24 +++++++++++++++++++----- docs/devel/migration/mapped-ram.rst | 6 +++++- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/docs/devel/migration/main.rst b/docs/devel/migration/main.rst index 495cdcb112..784c899dca 100644 --- a/docs/devel/migration/main.rst +++ b/docs/devel/migration/main.rst @@ -47,11 +47,25 @@ over any transport. QEMU interference. Note that QEMU does not flush cached file data/metadata at the end of migration. =20 -In addition, support is included for migration using RDMA, which -transports the page data using ``RDMA``, where the hardware takes care of -transporting the pages, and the load on the CPU is much lower. While the -internals of RDMA migration are a bit different, this isn't really visible -outside the RAM migration code. + The file migration also supports using a file that has already been + opened. A set of file descriptors is passed to QEMU via an "fdset" + (see add-fd QMP command documentation). This method allows a + management application to have control over the migration file + opening operation. There are, however, strict requirements to this + interface if the multifd capability is enabled: + + - the fdset must contain two file descriptors that are not + duplicates between themselves; + - if the direct-io capability is to be used, exactly one of the + file descriptors must have the O_DIRECT flag set; + - the file must be opened with WRONLY on the migration source side + and RDONLY on the migration destination side. + +- rdma migration: support is included for migration using RDMA, which + transports the page data using ``RDMA``, where the hardware takes + care of transporting the pages, and the load on the CPU is much + lower. While the internals of RDMA migration are a bit different, + this isn't really visible outside the RAM migration code. =20 All these migration protocols use the same infrastructure to save/restore state devices. This infrastructure is shared with the diff --git a/docs/devel/migration/mapped-ram.rst b/docs/devel/migration/map= ped-ram.rst index fa4cefd9fc..d352b546e9 100644 --- a/docs/devel/migration/mapped-ram.rst +++ b/docs/devel/migration/mapped-ram.rst @@ -16,7 +16,7 @@ location in the file, rather than constantly being added = to a sequential stream. Having the pages at fixed offsets also allows the usage of O_DIRECT for save/restore of the migration stream as the pages are ensured to be written respecting O_DIRECT alignment -restrictions (direct-io support not yet implemented). +restrictions. =20 Usage ----- @@ -35,6 +35,10 @@ Use a ``file:`` URL for migration: Mapped-ram migration is best done non-live, i.e. by stopping the VM on the source side before migrating. =20 +For best performance enable the ``direct-io`` parameter as well: + + ``migrate_set_parameter direct-io on`` + Use-cases --------- =20 --=20 2.35.3 From nobody Mon Nov 25 01:46:10 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1718650930; cv=none; d=zohomail.com; s=zohoarc; b=mefXvgrOoLG0zcE7dD+J9bX1pNKY+SZmKDbQfFNfJ8sUQrLFBqTrJdWg+ujjbCZPGm992vDCrBM5PIWN5yNt0SHS53VhdZIF7qKPHrgm2zrph5bkW5gA9ss+NQzKn9z6+RUvygBdMh85zTTp6zJdE9cSHEKySBA/lVobutEUv7g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1718650930; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=e7+I+YqymBBSdik7DLw05Z9r+gdDjzbBZ4qUANuFuc8=; b=U3Rrqk8O/Ex4CUlmhSlgsdcuGqaazhxDaHsUK6wxmzIefn7z99eafPo4DZu5AbjMR3yaR4aWzL+5z0yZeZwVozr4JpZzAsZ3COXCd4zUthF5Y6YQ3XIy9g7jkvT08jVpWAkxTvSHrH8oPbsBW2Jb2s3GvcBfsHz5r1jYL0+kUJc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1718650930899408.59443214827854; Mon, 17 Jun 2024 12:02:10 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sJHYd-0003x3-B7; Mon, 17 Jun 2024 14:58:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sJHYb-0003we-Lh for qemu-devel@nongnu.org; Mon, 17 Jun 2024 14:58:21 -0400 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 1sJHYZ-0004vU-M6 for qemu-devel@nongnu.org; Mon, 17 Jun 2024 14:58:21 -0400 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 440F221AD5; Mon, 17 Jun 2024 18:58:17 +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 B400F139AB; Mon, 17 Jun 2024 18:58:14 +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 QIleHkaHcGYJKAAAD6G6ig (envelope-from ); Mon, 17 Jun 2024 18:58:14 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1718650698; 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=e7+I+YqymBBSdik7DLw05Z9r+gdDjzbBZ4qUANuFuc8=; b=h/s4ngmtgY/9LFJ5qjM98BzFAfntmpDzIsjgkKkJVOw1psvQ43rir+1/kUP6czdKmZURAc vhE3cllxhY4gF0WH+aI9Ut0j1erxqr77f2E+PhIFhgg025DuKO68EnDYMfSl2r9XJGThxL oc6NNuIM7eOUKee5tUW3dUe2gjM+UyQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1718650698; 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=e7+I+YqymBBSdik7DLw05Z9r+gdDjzbBZ4qUANuFuc8=; b=u5E1C5d4userhCuDN9EQBn2k+9/Q+HHH/88ZwpS4C+eFYH4kCdQO/7dZT0dD1NQkC0XYcK +WAqKlpWI/x5u6Bw== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=kE6bkKjq; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=rg4xYjx3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1718650697; 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=e7+I+YqymBBSdik7DLw05Z9r+gdDjzbBZ4qUANuFuc8=; b=kE6bkKjqQs14gvkH8qMuiT2jv7nMM23O9LcbKHYHiBilRzkrh7akaePCY34C3b8Uv5q8Ym 2nHnkGyTqSiHkJSbg3kBYQXqqsjSGGelN/pipMe8w1XHBD0bF9c0p6yTbd0j0NrPihVMNe VX6+oDaC5jUihleFqBPV/x5k6vEklBc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1718650697; 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=e7+I+YqymBBSdik7DLw05Z9r+gdDjzbBZ4qUANuFuc8=; b=rg4xYjx395vnElNDVIpzE27TilBEbCvnRMdXtLnwJwcukbNdEF27l8ImWSgrSidY+uT8iQ 29KbXl5VgaS6mpBg== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: berrange@redhat.com, armbru@redhat.com, Peter Xu , Claudio Fontana , Jim Fehlig , Thomas Huth , Laurent Vivier , Paolo Bonzini Subject: [PATCH v3 16/16] tests/qtest/migration: Add a test for mapped-ram with passing of fds Date: Mon, 17 Jun 2024 15:57:31 -0300 Message-Id: <20240617185731.9725-17-farosas@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240617185731.9725-1-farosas@suse.de> References: <20240617185731.9725-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; 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)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RCVD_COUNT_TWO(0.00)[2]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCPT_COUNT_SEVEN(0.00)[9]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email,suse.de:dkim]; RCVD_TLS_ALL(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; DKIM_TRACE(0.00)[suse.de:+] X-Rspamd-Action: no action X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Queue-Id: 440F221AD5 X-Spam-Score: -3.01 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=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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @suse.de) (identity @suse.de) X-ZM-MESSAGEID: 1718650933032100003 Content-Type: text/plain; charset="utf-8" Add a multifd test for mapped-ram with passing of fds into QEMU. This is how libvirt will consume the feature. There are a couple of details to the fdset mechanism: - multifd needs two distinct file descriptors (not duplicated with dup()) so it can enable O_DIRECT only on the channels that do aligned IO. The dup() system call creates file descriptors that share status flags, of which O_DIRECT is one. - the open() access mode flags used for the fds passed into QEMU need to match the flags QEMU uses to open the file. Currently O_WRONLY for src and O_RDONLY for dst. Note that fdset code goes under _WIN32 because fd passing is not supported on Windows. Signed-off-by: Fabiano Rosas Reviewed-by: Peter Xu --- - dropped Peter's r-b - stopped removing the fdset at the end of the tests. The migration code should always cleanup after itself. --- tests/qtest/migration-test.c | 98 ++++++++++++++++++++++++++++++++++-- 1 file changed, 95 insertions(+), 3 deletions(-) diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c index 928f0ca6ce..85a21ff5e9 100644 --- a/tests/qtest/migration-test.c +++ b/tests/qtest/migration-test.c @@ -2024,11 +2024,18 @@ static void test_precopy_file(void) =20 #ifndef _WIN32 static void fdset_add_fds(QTestState *qts, const char *file, int flags, - int num_fds) + int num_fds, bool direct_io) { for (int i =3D 0; i < num_fds; i++) { int fd; =20 +#ifdef O_DIRECT + /* only secondary channels can use direct-io */ + if (direct_io && i !=3D 0) { + flags |=3D O_DIRECT; + } +#endif + fd =3D open(file, flags, 0660); assert(fd !=3D -1); =20 @@ -2042,8 +2049,8 @@ static void *file_offset_fdset_start_hook(QTestState = *from, QTestState *to) { g_autofree char *file =3D g_strdup_printf("%s/%s", tmpfs, FILE_TEST_FI= LENAME); =20 - fdset_add_fds(from, file, O_WRONLY, 1); - fdset_add_fds(to, file, O_RDONLY, 1); + fdset_add_fds(from, file, O_WRONLY, 1, false); + fdset_add_fds(to, file, O_RDONLY, 1, false); =20 return NULL; } @@ -2215,6 +2222,84 @@ static void test_multifd_file_mapped_ram_dio(void) test_file_common(&args, true); } =20 +#ifndef _WIN32 +static void multifd_mapped_ram_fdset_end(QTestState *from, QTestState *to, + void *opaque) +{ + QDict *resp; + QList *fdsets; + + /* + * Make sure no fdsets are left after migration, otherwise a + * second migration would fail due fdset reuse. + */ + resp =3D qtest_qmp(from, "{'execute': 'query-fdsets', " + "'arguments': {}}"); + g_assert(qdict_haskey(resp, "return")); + fdsets =3D qdict_get_qlist(resp, "return"); + g_assert(fdsets && qlist_empty(fdsets)); +} + +static void *multifd_mapped_ram_fdset_dio(QTestState *from, QTestState *to) +{ + g_autofree char *file =3D g_strdup_printf("%s/%s", tmpfs, FILE_TEST_FI= LENAME); + + fdset_add_fds(from, file, O_WRONLY, 2, true); + fdset_add_fds(to, file, O_RDONLY, 2, true); + + migrate_multifd_mapped_ram_start(from, to); + migrate_set_parameter_bool(from, "direct-io", true); + migrate_set_parameter_bool(to, "direct-io", true); + + return NULL; +} + +static void *multifd_mapped_ram_fdset(QTestState *from, QTestState *to) +{ + g_autofree char *file =3D g_strdup_printf("%s/%s", tmpfs, FILE_TEST_FI= LENAME); + + fdset_add_fds(from, file, O_WRONLY, 2, false); + fdset_add_fds(to, file, O_RDONLY, 2, false); + + migrate_multifd_mapped_ram_start(from, to); + + return NULL; +} + +static void test_multifd_file_mapped_ram_fdset(void) +{ + g_autofree char *uri =3D g_strdup_printf("file:/dev/fdset/1,offset=3D%= d", + FILE_TEST_OFFSET); + MigrateCommon args =3D { + .connect_uri =3D uri, + .listen_uri =3D "defer", + .start_hook =3D multifd_mapped_ram_fdset, + .finish_hook =3D multifd_mapped_ram_fdset_end, + }; + + test_file_common(&args, true); +} + +static void test_multifd_file_mapped_ram_fdset_dio(void) +{ + g_autofree char *uri =3D g_strdup_printf("file:/dev/fdset/1,offset=3D%= d", + FILE_TEST_OFFSET); + MigrateCommon args =3D { + .connect_uri =3D uri, + .listen_uri =3D "defer", + .start_hook =3D multifd_mapped_ram_fdset_dio, + .finish_hook =3D multifd_mapped_ram_fdset_end, + }; + + if (!probe_o_direct_support(tmpfs)) { + g_test_skip("Filesystem does not support O_DIRECT"); + return; + } + + test_file_common(&args, true); +} +#endif /* !_WIN32 */ + static void test_precopy_tcp_plain(void) { MigrateCommon args =3D { @@ -3654,6 +3739,13 @@ int main(int argc, char **argv) migration_test_add("/migration/multifd/file/mapped-ram/dio", test_multifd_file_mapped_ram_dio); =20 +#ifndef _WIN32 + migration_test_add("/migration/multifd/file/mapped-ram/fdset", + test_multifd_file_mapped_ram_fdset); + migration_test_add("/migration/multifd/file/mapped-ram/fdset/dio", + test_multifd_file_mapped_ram_fdset_dio); +#endif + #ifdef CONFIG_GNUTLS migration_test_add("/migration/precopy/unix/tls/psk", test_precopy_unix_tls_psk); --=20 2.35.3