[{"id":3629444,"web_url":"http://patchwork.ozlabs.org/comment/3629444/","msgid":"<aVKuvS54yhtAY0Is@x1.local>","list_archive_url":null,"date":"2025-12-29T16:39:25","subject":"Re: [RFC PATCH 08/25] migration: Free the error earlier in the\n resume case'","submitter":{"id":67717,"url":"http://patchwork.ozlabs.org/api/people/67717/","name":"Peter Xu","email":"peterx@redhat.com"},"content":"On Fri, Dec 26, 2025 at 06:19:10PM -0300, Fabiano Rosas wrote:\n> Freeing the error at migration_connect() is redundant in the normal\n> migration case. The freeing already happened at migrate_init():\n> \n> qmp_migrate()\n> -> migrate_prepare()\n>    -> migrate_init()\n> -> qmp_migrate_finish()\n>    -> *_start_outgoing_migration()\n>    -> migration_channel_connect()\n>       -> migration_connect()\n> \n> For the resume case, migrate_prepare() returns early and doesn't reach\n> migrate_init(). Move the extra migrate_error_free() call to\n> migrate_prepare() along with the resume check.\n> \n> Signed-off-by: Fabiano Rosas <farosas@suse.de>\n\nReviewed-by: Peter Xu <peterx@redhat.com>\n\nWe could also use migrate_error_free() in migrate_init(), to be clear on\nwhen the error can be erased.\n\n> ---\n>  migration/migration.c | 14 +++++++-------\n>  1 file changed, 7 insertions(+), 7 deletions(-)\n> \n> diff --git a/migration/migration.c b/migration/migration.c\n> index 4b1afcab24..a56f8fb05e 100644\n> --- a/migration/migration.c\n> +++ b/migration/migration.c\n> @@ -2088,6 +2088,13 @@ static bool migrate_prepare(MigrationState *s, bool resume, Error **errp)\n>          migrate_set_state(&s->state, MIGRATION_STATUS_POSTCOPY_PAUSED,\n>                            MIGRATION_STATUS_POSTCOPY_RECOVER_SETUP);\n>  \n> +        /*\n> +         * If there's a previous error, free it and prepare for\n> +         * another one. For the non-resume case, this happens at\n> +         * migrate_init() below.\n> +         */\n> +        migrate_error_free(s);\n> +\n>          /* This is a resume, skip init status */\n>          return true;\n>      }\n> @@ -4016,13 +4023,6 @@ void migration_connect(MigrationState *s, Error *error_in)\n>      bool resume = (s->state == MIGRATION_STATUS_POSTCOPY_RECOVER_SETUP);\n>      int ret;\n>  \n> -    /*\n> -     * If there's a previous error, free it and prepare for another one.\n> -     * Meanwhile if migration completes successfully, there won't have an error\n> -     * dumped when calling migration_cleanup().\n> -     */\n> -    migrate_error_free(s);\n> -\n>      s->expected_downtime = migrate_downtime_limit();\n>      if (error_in) {\n>          migration_connect_error_propagate(s, error_in);\n> -- \n> 2.51.0\n>","headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (1024-bit key;\n unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256\n header.s=mimecast20190719 header.b=DqDWtomJ;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256\n header.s=google header.b=TA7Jwb2B;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org\n (client-ip=209.51.188.17; helo=lists.gnu.org;\n envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n receiver=patchwork.ozlabs.org)"],"Received":["from lists.gnu.org (lists.gnu.org [209.51.188.17])\n\t(using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4dg24z0lW4z1xpS\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 30 Dec 2025 03:40:03 +1100 (AEDT)","from localhost ([::1] helo=lists1p.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.90_1)\n\t(envelope-from <qemu-devel-bounces@nongnu.org>)\n\tid 1vaGHV-00006N-Ud; Mon, 29 Dec 2025 11:39:43 -0500","from eggs.gnu.org ([2001:470:142:3::10])\n by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <peterx@redhat.com>) id 1vaGHM-0008WS-MM\n for qemu-devel@nongnu.org; Mon, 29 Dec 2025 11:39:32 -0500","from us-smtp-delivery-124.mimecast.com ([170.10.133.124])\n by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <peterx@redhat.com>) id 1vaGHK-0008N7-Oq\n for qemu-devel@nongnu.org; Mon, 29 Dec 2025 11:39:32 -0500","from mail-qk1-f200.google.com (mail-qk1-f200.google.com\n [209.85.222.200]) by relay.mimecast.com with ESMTP with STARTTLS\n (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id\n us-mta-138-jeq_40GGPt2GYcoO7jhAnw-1; Mon, 29 Dec 2025 11:39:27 -0500","by mail-qk1-f200.google.com with SMTP id\n af79cd13be357-8c2a3a614b5so48506285a.0\n for <qemu-devel@nongnu.org>; Mon, 29 Dec 2025 08:39:27 -0800 (PST)","from x1.local ([142.188.210.156]) by smtp.gmail.com with ESMTPSA id\n af79cd13be357-8c0971ee182sm2392772185a.33.2025.12.29.08.39.25\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Mon, 29 Dec 2025 08:39:26 -0800 (PST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1767026369;\n h=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n to:to:cc:cc:mime-version:mime-version:content-type:content-type:\n in-reply-to:in-reply-to:references:references;\n bh=6Vv0kzW/OBZtkZeFJwtFPl861a0tnJnouUTswpexiN0=;\n b=DqDWtomJ9FIWOj9TtJLVvxbhopumXQhCfXLmc9FnM+hOpX5nS60dF2i3g/cQv0DEFgUSiF\n YG0rkKyh8TebKMk4znPFHG+0vSdbMZJEELQdRmWyixkOufZ7kpjWoVHKsyqsnfNDfmvwH1\n tOYNw3Hn0GFEgF34y5nmf2xWHAJ/t+0=","v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=redhat.com; s=google; t=1767026367; x=1767631167; darn=nongnu.org;\n h=in-reply-to:content-disposition:mime-version:references:message-id\n :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to;\n bh=6Vv0kzW/OBZtkZeFJwtFPl861a0tnJnouUTswpexiN0=;\n b=TA7Jwb2BcYA0ELfyGGzJvm5CA1QkadPUSGD0LEJesPSkkguVq5ZBHCQgTF4RuGaWKB\n FG45v1VMJ4uSeDDkbug30XfMI1YQWTSEgFP1C+4IYLLLOnGSO/dOAEGHBGy3vaoO2VlC\n uXpevO9+P7yvvzlUA9g2EPxP/d8z2ZNCdQUAVabcCEjsFDRNBOG+5BAjs0grAG/CKPFl\n yV6RYMduzDbv15roSYfEfNIMMURxdYLk9Q/ZZyCUk8pleqZuoxPIxI1cVQ17nOCRxeT+\n OWiwFBdzemshHA7fHjrYFKNFVbyv3kDgF9qAhXpOxQLArU5Rc1GnkTFFehaPvpWw+JqD\n hziw=="],"X-MC-Unique":"jeq_40GGPt2GYcoO7jhAnw-1","X-Mimecast-MFC-AGG-ID":"jeq_40GGPt2GYcoO7jhAnw_1767026367","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20230601; t=1767026367; x=1767631167;\n h=in-reply-to:content-disposition:mime-version:references:message-id\n :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc\n :subject:date:message-id:reply-to;\n bh=6Vv0kzW/OBZtkZeFJwtFPl861a0tnJnouUTswpexiN0=;\n b=ie+y1o0DDn7Kord2YB2VRYRXJAtFxo+bIk0SDbJihvFNxOukuQ6yGbghfU3jKx2npS\n ODgmewq0kDgk4hqQOMHsSW8cNcn/tYMY9rVR27At/p3cIHOQJJ7xuxgAP38l25oCeKmv\n kwYZzlvplVxMS5clYOh4Lfs7tdSxyWReLelcoXiH65rJmempmbvQGcFxHritfCOqb++G\n uWegd+U6cpPsiDMzC62flEQMOEBgANJfCyvpJJ0UWxYq/HV8JHylPDsJ7mHvGKPn7T4H\n Cg25VkwtlVB5crcXx/dlK2013Jv1FP1LvQRd3XWUTkoiP95SyiB3pO5LpLPe3rSwh05o\n LsJA==","X-Gm-Message-State":"AOJu0Yy7r70pL2niT3yqzo4fiFjkqO40qkaE19hHsi1PKWIVjX6arxOf\n JMebT506PGzNPE8d+DUOXWKoGN84K1n8stYdgads2V29HyJ1x86sZ7jS7fTZrwPZ9ieNzAk1TmN\n c8VuyWPmmRqFKMD+N4btZzJ4CxYrmzJ9l4v89dw11UZMunmIsKCYHwzkM","X-Gm-Gg":"AY/fxX7ggH8EkmV1PNER9gbtLShF1XjlukP5kTYFf/oyVHXknJL4R2Q/mbnMsrn31ww\n yIifyYj9U27A1wPc4X+eISe1Kf4LDq266vSF1NhQO1SPxlzjSKNrIROYEjxrxaoQRpMAnW+4RQ8\n BghuFP+BtUof0oZI30/4WmucMrGdvjPmRZCl3meWCwhMRpvkSDRplrtnwuwufoIHexMEs/oZFrL\n lvPaHQHQNSmaLTfDuZaDOjPJLmybnD8fFc5cCa8wWZP4ZvU8Hige7knE/QsEzmypj5dLFA1qapY\n L8GjW+UwqWrKGiDAFU4eg+yBeOPGTixwpB4zBT5D9nLkzf73BC5YTkcHspC9EewMTevIEvk3WvW\n xS6Y=","X-Received":["by 2002:a05:620a:4686:b0:891:e10a:9d3f with SMTP id\n af79cd13be357-8c08fc0e898mr4145764885a.10.1767026366864;\n Mon, 29 Dec 2025 08:39:26 -0800 (PST)","by 2002:a05:620a:4686:b0:891:e10a:9d3f with SMTP id\n af79cd13be357-8c08fc0e898mr4145761385a.10.1767026366368;\n Mon, 29 Dec 2025 08:39:26 -0800 (PST)"],"X-Google-Smtp-Source":"\n AGHT+IGbvyjUPMjIjS+EXl1cWez40BimhqYGu3VdCQIgMy9LHr8NUXbRcqP4sjoUQWNl6au5UKWEEQ==","Date":"Mon, 29 Dec 2025 11:39:25 -0500","From":"Peter Xu <peterx@redhat.com>","To":"Fabiano Rosas <farosas@suse.de>","Cc":"qemu-devel@nongnu.org","Subject":"Re: [RFC PATCH 08/25] migration: Free the error earlier in the\n resume case'","Message-ID":"<aVKuvS54yhtAY0Is@x1.local>","References":"<20251226211930.27565-1-farosas@suse.de>\n <20251226211930.27565-9-farosas@suse.de>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20251226211930.27565-9-farosas@suse.de>","Received-SPF":"pass client-ip=170.10.133.124; envelope-from=peterx@redhat.com;\n helo=us-smtp-delivery-124.mimecast.com","X-Spam_score_int":"-20","X-Spam_score":"-2.1","X-Spam_bar":"--","X-Spam_report":"(-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001,\n DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,\n RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001,\n RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001,\n SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no","X-Spam_action":"no action","X-BeenThere":"qemu-devel@nongnu.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<https://lists.nongnu.org/archive/html/qemu-devel>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org"}}]