From nobody Wed May 15 19:27:13 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1654087834; cv=none; d=zohomail.com; s=zohoarc; b=lu/++HAdGFtl7qEDt45yh6VcHChN4sKDNzd9rBseMD9DDiZchQ0CDAp1xP2Bj7yV8k5IrE/TGwfEoQBX+WC8zCCwwUGTo4ysFUwEosvu2P6o6HI/i2PTi7JPmeB/MUUlJ5VlTdPk3UEtismRR3kHdNcUhzjnGsUCwApEt1AFzJ4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654087834; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=r2ybUFANwvMh51gkBsHbeaJdoYG9gcNeAqcwgDmQhEM=; b=TwTyh6JcuUqJZZlG3sq9pguOpo96gDIp80T3bqDB0hvvlB0WCzgDcRRvfXx4lterIe2LGknjLbY7/nmvtLcVn+r1l/UsCT0HFAkLB+iW2chs1ysS81b3r5EqjkfDN6qcmdzcmzCSWfuKORnYcWe97ky3NEt3XgNvMvDNcaJ3tRw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1654087834722763.1205352735936; Wed, 1 Jun 2022 05:50:34 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-314-FmKurMdkPGafq4SsUsuYsA-1; Wed, 01 Jun 2022 08:50:31 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 718D1294EDDA; Wed, 1 Jun 2022 12:50:29 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id D74B08289E; Wed, 1 Jun 2022 12:50:28 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id D0A4B1947B89; Wed, 1 Jun 2022 12:50:27 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id A85481947079 for ; Wed, 1 Jun 2022 12:50:26 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 918B42026987; Wed, 1 Jun 2022 12:50:26 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.227]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 70E322026D07; Wed, 1 Jun 2022 12:50:26 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 5D9DE241055; Wed, 1 Jun 2022 14:50:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654087833; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=r2ybUFANwvMh51gkBsHbeaJdoYG9gcNeAqcwgDmQhEM=; b=KsnfoT9I98oV8Pl2EuFly2eTc6CEWnjrN+Gk8ewRHBj6eFANjOFI8+2XFPLJnbpvOF1cji jbsetupWFWy94GAbyhDJRGWzcJgP8XRkmDAJc9g3RC415eIkuCOP9rwlSElPLoIMUkBhge w1I7t80Wb6/QcinLTDvzw+iZjuLjbo0= X-MC-Unique: FmKurMdkPGafq4SsUsuYsA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH v2 01/81] qemu: Add debug messages to job recovery code Date: Wed, 1 Jun 2022 14:49:01 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Krempa , Pavel Hrdina Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1654087835781100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Jiri Denemark Reviewed-by: Peter Krempa Reviewed-by: Pavel Hrdina --- Notes: Version 2: - no change src/qemu/qemu_process.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 1593ca7933..e8936cd623 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -3374,6 +3374,9 @@ qemuProcessRecoverMigrationIn(virQEMUDriver *driver, (state =3D=3D VIR_DOMAIN_RUNNING && reason =3D=3D VIR_DOMAIN_RUNNING_POSTCOPY); =20 + VIR_DEBUG("Active incoming migration in phase %s", + qemuMigrationJobPhaseTypeToString(job->phase)); + switch ((qemuMigrationJobPhase) job->phase) { case QEMU_MIGRATION_PHASE_NONE: case QEMU_MIGRATION_PHASE_PERFORM2: @@ -3435,6 +3438,9 @@ qemuProcessRecoverMigrationOut(virQEMUDriver *driver, reason =3D=3D VIR_DOMAIN_PAUSED_POSTCOPY_FAILED); bool resume =3D false; =20 + VIR_DEBUG("Active outgoing migration in phase %s", + qemuMigrationJobPhaseTypeToString(job->phase)); + switch ((qemuMigrationJobPhase) job->phase) { case QEMU_MIGRATION_PHASE_NONE: case QEMU_MIGRATION_PHASE_PREPARE: @@ -3530,6 +3536,13 @@ qemuProcessRecoverJob(virQEMUDriver *driver, =20 state =3D virDomainObjGetState(vm, &reason); =20 + VIR_DEBUG("Recovering job for domain %s, state=3D%s(%s), async=3D%s, j= ob=3D%s", + vm->def->name, + virDomainStateTypeToString(state), + virDomainStateReasonToString(state, reason), + virDomainAsyncJobTypeToString(job->asyncJob), + virDomainJobTypeToString(job->active)); + switch (job->asyncJob) { case VIR_ASYNC_JOB_MIGRATION_OUT: if (qemuProcessRecoverMigrationOut(driver, vm, job, --=20 2.35.1 From nobody Wed May 15 19:27:13 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1654087848; cv=none; d=zohomail.com; s=zohoarc; b=KJWwrzkNqr7HQiSvRQcjKGzIqMTzKg5IMuPmTRO/TutXJEa5sC9AQopkFN4qfEMdtbAUSB/1ayoQ0OsXad2jTdUGodI4+RzjezXk5ea/IVq282eltIwVzJdL2XJHBwRqmaibfSh7tsHeIe7wfndh/Or6nR5l1BZsJ7FRc4Vl5Es= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654087848; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ppYFmyvoL4hK7quCjG3rtuFue8XbYy0AW9fs1Uaevdg=; b=c9sa++LiTuD4gUuVU1tpZtOlEIPoM3CrQmAP4rHmcdeCpUPLVxm7XRty3O/nFQfJuMm11TaZbu3MZZXIw/IljJCiOVuqJNP58/NhpFm0iFDb6tj/UhgFNaC2/C0b6sdJqynhsQ5WE979FctC4Q2IQphqPS/0qSC2inxuuQIeh1g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1654087848582872.9897191297678; Wed, 1 Jun 2022 05:50:48 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-523-e_Th7AtOMRSfBZXKPTq8-Q-1; Wed, 01 Jun 2022 08:50:35 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 75A9D101A54E; Wed, 1 Jun 2022 12:50:29 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 17D501415100; Wed, 1 Jun 2022 12:50:28 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 96FFB1947079; Wed, 1 Jun 2022 12:50:27 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 9DE94194706A for ; Wed, 1 Jun 2022 12:50:26 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 8E9AD40EC004; Wed, 1 Jun 2022 12:50:26 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.227]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6DD7F40EC002; Wed, 1 Jun 2022 12:50:26 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 5F4C0245B4E; Wed, 1 Jun 2022 14:50:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654087847; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=ppYFmyvoL4hK7quCjG3rtuFue8XbYy0AW9fs1Uaevdg=; b=hDspRFxFE6kBwmIw1URE3dnRtQjjiIC+hj+IUYVJJiPKeu3GTPTOasToKSSeaVF922/BVm AKjy5wJNw14bHH5acHTnMWiDxHnc6TsYYgbnIH7hK8nm+FpyKovpJ5TCxkvwWbjjTAPk3S blSXGhxOUPuAtA0a+lPIAjqmnCJct6k= X-MC-Unique: e_Th7AtOMRSfBZXKPTq8-Q-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH v2 02/81] qemumonitorjsontest: Test more migration capabilities Date: Wed, 1 Jun 2022 14:49:02 +0200 Message-Id: <7ce0bc3427da19ef75dba729e0b4e5a3a50fb075.1654087149.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Krempa , Pavel Hrdina Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1654087849725100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Jiri Denemark Reviewed-by: Peter Krempa Reviewed-by: Pavel Hrdina --- Notes: Version 2: - no change tests/qemumonitorjsontest.c | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c index c3ee771cbb..2de282dcba 100644 --- a/tests/qemumonitorjsontest.c +++ b/tests/qemumonitorjsontest.c @@ -2044,7 +2044,7 @@ testQemuMonitorJSONqemuMonitorJSONGetMigrationCapabil= ities(const void *opaque) { const testGenericData *data =3D opaque; virDomainXMLOption *xmlopt =3D data->xmlopt; - const char *cap; + size_t cap; g_auto(GStrv) caps =3D NULL; g_autoptr(virBitmap) bitmap =3D NULL; g_autoptr(virJSONValue) json =3D NULL; @@ -2054,6 +2054,10 @@ testQemuMonitorJSONqemuMonitorJSONGetMigrationCapabi= lities(const void *opaque) " {" " \"state\": false," " \"capability\": \"xbzrle\"" + " }," + " {" + " \"state\": true," + " \"capability\": \"events\"" " }" " ]," " \"id\": \"libvirt-22\"" @@ -2072,11 +2076,25 @@ testQemuMonitorJSONqemuMonitorJSONGetMigrationCapab= ilities(const void *opaque) &caps) < 0) return -1; =20 - cap =3D qemuMigrationCapabilityTypeToString(QEMU_MIGRATION_CAP_XBZRLE); - if (!g_strv_contains((const char **) caps, cap)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - "Expected capability %s is missing", cap); - return -1; + for (cap =3D 0; cap < QEMU_MIGRATION_CAP_LAST; cap++) { + const char *capStr =3D qemuMigrationCapabilityTypeToString(cap); + bool present =3D g_strv_contains((const char **) caps, capStr); + + switch (cap) { + case QEMU_MIGRATION_CAP_XBZRLE: + case QEMU_MIGRATION_CAP_EVENTS: + if (!present) { + VIR_TEST_VERBOSE("Expected capability %s is missing", capS= tr); + return -1; + } + break; + + default: + if (present) { + VIR_TEST_VERBOSE("Unexpected capability %s found", capStr); + return -1; + } + } } =20 bitmap =3D virBitmapNew(QEMU_MIGRATION_CAP_LAST); --=20 2.35.1 From nobody Wed May 15 19:27:13 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1654087854; cv=none; d=zohomail.com; s=zohoarc; b=i8kumGFEjNelBZvcuSeKj0GT/pZmSX2Z5aASbgfB/YpLs/UdK+AHSvfezxODZ4HraNesjqhn9mfdwNL7CG978KJhq2/mFH9g6DW9XMcFNBW81IOLLzRJIBWTd+QFKKAk7Ic9ItHmdUSDTno8rG7Zigs9zahlc4+79eOpI7e6xl0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654087854; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=YhIgWwizU89ZrgAvfOugS7XUdxuh+Nv6FXe62fxDOqQ=; b=kFByliRR2X1MDmvDx1KLbtoq0tQkE1fYPyUYjFfjagOnbh1MHsDxhYn8UiQejxjZ+ODgZT/vujJw7C9dAkke4BGeMc1zFAyQOq0+3fp/fvI03OAa7TpfzGYeA4SpoEhTg7uBnzd1cW5FiGH5bPXRphTn3pnezlJd6RYfOUD1tAI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 165408785483512.470552196487574; Wed, 1 Jun 2022 05:50:54 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-615-D4MilvvUNtuoZRjnKmanUQ-1; Wed, 01 Jun 2022 08:50:46 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 064311044565; Wed, 1 Jun 2022 12:50:32 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id E197240EC004; Wed, 1 Jun 2022 12:50:31 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 08E8919452D2; Wed, 1 Jun 2022 12:50:30 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id BEB0D1947079 for ; Wed, 1 Jun 2022 12:50:26 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id AD79C2026D07; Wed, 1 Jun 2022 12:50:26 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.227]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 70DAF2026D64 for ; Wed, 1 Jun 2022 12:50:26 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 60FA9245B4F; Wed, 1 Jun 2022 14:50:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654087853; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=YhIgWwizU89ZrgAvfOugS7XUdxuh+Nv6FXe62fxDOqQ=; b=a/8zudN7FvyGAg1Xkk7mqpgM66DmSxbA6cnIUf6UnO0GqGpMsdaVwClolpFIpaC3ICxfEP 1kM7mr36isecVMUuDuD7prPFbo9RciEnf2hzB6VDZC7EmkrGyKD4u01lvP01WmCBDWgn1v QTV4PMJvbofPklxNR7eUYSiJezvGT/M= X-MC-Unique: D4MilvvUNtuoZRjnKmanUQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH v2 03/81] Introduce VIR_DOMAIN_RUNNING_POSTCOPY_FAILED Date: Wed, 1 Jun 2022 14:49:03 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1654087855743100004 Content-Type: text/plain; charset="utf-8" This new "post-copy failed" reason for the running state will be used on the destination host when post-copy migration fails while the domain is already running there. Signed-off-by: Jiri Denemark Reviewed-by: Peter Krempa --- Notes: Version 2: - documented both VIR_DOMAIN_RUNNING_POSTCOPY_FAILED and VIR_DOMAIN_PAUSED_POSTCOPY_FAILED possibilities on the destination examples/c/misc/event-test.c | 3 +++ include/libvirt/libvirt-domain.h | 2 ++ src/conf/domain_conf.c | 1 + src/libvirt-domain.c | 26 +++++++++++++++++++------- src/qemu/qemu_domain.c | 3 +++ tools/virsh-domain-event.c | 3 ++- tools/virsh-domain-monitor.c | 1 + 7 files changed, 31 insertions(+), 8 deletions(-) diff --git a/examples/c/misc/event-test.c b/examples/c/misc/event-test.c index 1165469a65..64652b0153 100644 --- a/examples/c/misc/event-test.c +++ b/examples/c/misc/event-test.c @@ -196,6 +196,9 @@ eventDetailToString(int event, case VIR_DOMAIN_EVENT_RESUMED_POSTCOPY: return "Post-copy"; =20 + case VIR_DOMAIN_EVENT_RESUMED_POSTCOPY_FAILED: + return "Post-copy Error"; + case VIR_DOMAIN_EVENT_RESUMED_LAST: break; } diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-dom= ain.h index 24846046aa..caf99d41bc 100644 --- a/include/libvirt/libvirt-domain.h +++ b/include/libvirt/libvirt-domain.h @@ -108,6 +108,7 @@ typedef enum { wakeup event (Since: 0.9.11= ) */ VIR_DOMAIN_RUNNING_CRASHED =3D 9, /* resumed from crashed (Sin= ce: 1.1.1) */ VIR_DOMAIN_RUNNING_POSTCOPY =3D 10, /* running in post-copy migr= ation mode (Since: 1.3.3) */ + VIR_DOMAIN_RUNNING_POSTCOPY_FAILED =3D 11, /* running in failed post-c= opy migration (Since: 8.5.0) */ =20 # ifdef VIR_ENUM_SENTINELS VIR_DOMAIN_RUNNING_LAST /* (Since: 0.9.10) */ @@ -3801,6 +3802,7 @@ typedef enum { VIR_DOMAIN_EVENT_RESUMED_FROM_SNAPSHOT =3D 2, /* Resumed from snapshot= (Since: 0.9.5) */ VIR_DOMAIN_EVENT_RESUMED_POSTCOPY =3D 3, /* Resumed, but migration i= s still running in post-copy mode = (Since: 1.3.3) */ + VIR_DOMAIN_EVENT_RESUMED_POSTCOPY_FAILED =3D 4, /* Running, but migrat= ion failed in post-copy (Since: 8.5.0) */ =20 # ifdef VIR_ENUM_SENTINELS VIR_DOMAIN_EVENT_RESUMED_LAST /* (Since: 0.9.10) */ diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 6e1bb36ba8..58ca3c7c75 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -1106,6 +1106,7 @@ VIR_ENUM_IMPL(virDomainRunningReason, "wakeup", "crashed", "post-copy", + "post-copy failed", ); =20 VIR_ENUM_IMPL(virDomainBlockedReason, diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c index e3ced700b8..b9f1d73d5a 100644 --- a/src/libvirt-domain.c +++ b/src/libvirt-domain.c @@ -9764,10 +9764,16 @@ virDomainMigrateGetMaxSpeed(virDomainPtr domain, * at most once no matter how fast it changes. On the other hand once the * guest is running on the destination host, the migration can no longer be * rolled back because none of the hosts has complete state. If this happe= ns, - * libvirt will leave the domain paused on both hosts with - * VIR_DOMAIN_PAUSED_POSTCOPY_FAILED reason. It's up to the upper layer to - * decide what to do in such case. Because of this, libvirt will refuse to - * cancel post-copy migration via virDomainAbortJob. + * libvirt will leave the domain paused on the source host with + * VIR_DOMAIN_PAUSED_POSTCOPY_FAILED reason. The domain on the destination= host + * will either remain running with VIR_DOMAIN_RUNNING_POSTCOPY_FAILED reas= on if + * libvirt loses control over the migration (e.g., the daemon is restarted= or + * libvirt connection is broken) while QEMU is still able to continue migr= ating + * memory pages from the source to the destination or it will be paused wi= th + * VIR_DOMAIN_PAUSED_POSTCOPY_FAILED if even the connection between QEMU + * processes gets broken. It's up to the upper layer to decide what to do = in + * such case. Because of this, libvirt will refuse to cancel post-copy + * migration via virDomainAbortJob. * * The following domain life cycle events are emitted during post-copy * migration: @@ -9781,9 +9787,15 @@ virDomainMigrateGetMaxSpeed(virDomainPtr domain, * VIR_DOMAIN_EVENT_RESUMED_MIGRATED (on the destination), * VIR_DOMAIN_EVENT_STOPPED_MIGRATED (on the source) -- migration finished * successfully and the destination host holds a complete guest state. - * VIR_DOMAIN_EVENT_SUSPENDED_POSTCOPY_FAILED (on the destination) -- emi= tted - * when migration fails in post-copy mode and it's unclear whether any - * of the hosts has a complete guest state. + * VIR_DOMAIN_EVENT_SUSPENDED_POSTCOPY_FAILED (on the source), + * VIR_DOMAIN_EVENT_RESUMED_POSTCOPY_FAILED (on the destination) -- emitt= ed + * when migration fails in post-copy mode from libvirt's point of view + * and it's unclear whether any of the hosts has a complete guest sta= te. + * This happens when libvirt loses control over the migration. Virtual + * CPUs on the destination are still running. + * VIR_DOMAIN_EVENT_SUSPENDED_POSTCOPY_FAILED (on the destination) -- QEM= U is + * not able to keep migration running in post-copy mode (i.e., its + * connection is broken) and libvirt stops virtual CPUs on the destin= ation. * * The progress of a post-copy migration can be monitored normally using * virDomainGetJobStats on the source host. Fetching statistics of a compl= eted diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 8ebf152d95..6f358466c5 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -11145,6 +11145,9 @@ qemuDomainRunningReasonToResumeEvent(virDomainRunni= ngReason reason) case VIR_DOMAIN_RUNNING_POSTCOPY: return VIR_DOMAIN_EVENT_RESUMED_POSTCOPY; =20 + case VIR_DOMAIN_RUNNING_POSTCOPY_FAILED: + return VIR_DOMAIN_EVENT_RESUMED_POSTCOPY_FAILED; + case VIR_DOMAIN_RUNNING_UNKNOWN: case VIR_DOMAIN_RUNNING_SAVE_CANCELED: case VIR_DOMAIN_RUNNING_BOOTED: diff --git a/tools/virsh-domain-event.c b/tools/virsh-domain-event.c index 6dbb64a655..2d6db5f881 100644 --- a/tools/virsh-domain-event.c +++ b/tools/virsh-domain-event.c @@ -93,7 +93,8 @@ VIR_ENUM_IMPL(virshDomainEventResumed, N_("Unpaused"), N_("Migrated"), N_("Snapshot"), - N_("Post-copy")); + N_("Post-copy"), + N_("Post-copy Error")); =20 VIR_ENUM_DECL(virshDomainEventStopped); VIR_ENUM_IMPL(virshDomainEventStopped, diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c index 246e8a16c0..dc5fe13e49 100644 --- a/tools/virsh-domain-monitor.c +++ b/tools/virsh-domain-monitor.c @@ -166,6 +166,7 @@ VIR_ENUM_IMPL(virshDomainRunningReason, N_("event wakeup"), N_("crashed"), N_("post-copy"), + N_("post-copy failed"), ); =20 VIR_ENUM_DECL(virshDomainBlockedReason); --=20 2.35.1 From nobody Wed May 15 19:27:13 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1654087834; cv=none; d=zohomail.com; s=zohoarc; b=BzkLuDn8IoReK2+6CnMILnHIIq2rwOIB1TwIj7C6fvDhg5HbrMldD3o7/w8A9QAt/i310ruO1/d3uAMAqIYLoZrgHER6uj7cIeFUqDesued67xgicm99MMk+18NlgPnw+iCcxUMH28oMhON8lMweykLLCeT63nvQuX5qTuhPE/Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654087834; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=kEI8hkTfqi6bu2SRdG/efShtGcNXr2FexaVpXnMzYq4=; b=TVqUnDC3e1Xw9sf5r/conlrLKEJkeRHeVOc1UcWiQguou/Dl+7H3HHZxoX6FwPuJvC3nIphKHG2vE+L0PeyLPr+BNX2Tttu/kDt4lL0zf8guFcL/trwIusGglrGJcN+YpUYG/4A7o21ubwzkllAdLGlsv1ZccwxCiuRBopWYlqs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1654087834565712.5415964254371; Wed, 1 Jun 2022 05:50:34 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-456-f6NtlfVaNluUfSacG8nOhA-1; Wed, 01 Jun 2022 08:50:31 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B6FE6100E658; Wed, 1 Jun 2022 12:50:29 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8D10C40EC008; Wed, 1 Jun 2022 12:50:29 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 28A4B1947B99; Wed, 1 Jun 2022 12:50:28 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id B68CB194706A for ; Wed, 1 Jun 2022 12:50:26 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id A986D400F75F; Wed, 1 Jun 2022 12:50:26 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.227]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6D56140CF8EB for ; Wed, 1 Jun 2022 12:50:26 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 62519245B50; Wed, 1 Jun 2022 14:50:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654087833; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=kEI8hkTfqi6bu2SRdG/efShtGcNXr2FexaVpXnMzYq4=; b=HePaq1oH8Ws6ffKikmBlo2HLmAlfCJg2UKnyoXgEC+sqZVhbZhtLJXBezt2FzMirwZloKR dFBnTtsPNDI462d1Y0p+KTYF8RfzMSTwhWBZis1IWP49ERczg4nrLkU541x3fJrDNd0HIV A0yVOzZI6EBRNLw80MI1uRYTDL/+KJY= X-MC-Unique: f6NtlfVaNluUfSacG8nOhA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH v2 04/81] qemu: Keep domain running on dst on failed post-copy migration Date: Wed, 1 Jun 2022 14:49:04 +0200 Message-Id: <6c28c740c13e8afe7409a667bd00c093a5feb7bd.1654087150.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1654087835805100002 Content-Type: text/plain; charset="utf-8" There's no need to artificially pause a domain when post-copy fails from our point of view unless QEMU connection is broken too as migration may still be progressing well. Signed-off-by: Jiri Denemark Reviewed-by: Peter Krempa --- Notes: Version 2: - commit message and warning text updated - dropped dead code from qemuMigrationSrcPostcopyFailed - source domain is always paused once it enters post-copy, handling RUNNING state there was a leftover from before this patch src/qemu/qemu_migration.c | 51 ++++++++++++++++++++++++++------------- src/qemu/qemu_migration.h | 6 +++-- src/qemu/qemu_process.c | 8 +++--- 3 files changed, 42 insertions(+), 23 deletions(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 6cc68a567a..326e17ddd7 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -1577,34 +1577,51 @@ qemuMigrationSrcIsSafe(virDomainDef *def, =20 =20 void -qemuMigrationAnyPostcopyFailed(virQEMUDriver *driver, - virDomainObj *vm) +qemuMigrationSrcPostcopyFailed(virDomainObj *vm) { virDomainState state; int reason; =20 state =3D virDomainObjGetState(vm, &reason); =20 - if (state !=3D VIR_DOMAIN_PAUSED && - state !=3D VIR_DOMAIN_RUNNING) - return; + VIR_DEBUG("%s/%s", + virDomainStateTypeToString(state), + virDomainStateReasonToString(state, reason)); =20 - if (state =3D=3D VIR_DOMAIN_PAUSED && + if (state !=3D VIR_DOMAIN_PAUSED || reason =3D=3D VIR_DOMAIN_PAUSED_POSTCOPY_FAILED) return; =20 VIR_WARN("Migration of domain %s failed during post-copy; " "leaving the domain paused", vm->def->name); =20 - if (state =3D=3D VIR_DOMAIN_RUNNING) { - if (qemuProcessStopCPUs(driver, vm, - VIR_DOMAIN_PAUSED_POSTCOPY_FAILED, - VIR_ASYNC_JOB_MIGRATION_IN) < 0) - VIR_WARN("Unable to pause guest CPUs for %s", vm->def->name); - } else { - virDomainObjSetState(vm, VIR_DOMAIN_PAUSED, - VIR_DOMAIN_PAUSED_POSTCOPY_FAILED); - } + virDomainObjSetState(vm, VIR_DOMAIN_PAUSED, + VIR_DOMAIN_PAUSED_POSTCOPY_FAILED); +} + + +void +qemuMigrationDstPostcopyFailed(virDomainObj *vm) +{ + virDomainState state; + int reason; + + state =3D virDomainObjGetState(vm, &reason); + + VIR_DEBUG("%s/%s", + virDomainStateTypeToString(state), + virDomainStateReasonToString(state, reason)); + + if (state !=3D VIR_DOMAIN_RUNNING || + reason =3D=3D VIR_DOMAIN_RUNNING_POSTCOPY_FAILED) + return; + + VIR_WARN("Migration protocol failed during incoming migration of domai= n " + "%s, but QEMU keeps migrating; leaving the domain running, th= e " + "migration will be handled as unattended", vm->def->name); + + virDomainObjSetState(vm, VIR_DOMAIN_RUNNING, + VIR_DOMAIN_RUNNING_POSTCOPY_FAILED); } =20 =20 @@ -3453,7 +3470,7 @@ qemuMigrationSrcConfirmPhase(virQEMUDriver *driver, =20 if (virDomainObjGetState(vm, &reason) =3D=3D VIR_DOMAIN_PAUSED && reason =3D=3D VIR_DOMAIN_PAUSED_POSTCOPY) - qemuMigrationAnyPostcopyFailed(driver, vm); + qemuMigrationSrcPostcopyFailed(vm); else qemuMigrationSrcRestoreDomainState(driver, vm); =20 @@ -5826,7 +5843,7 @@ qemuMigrationDstFinish(virQEMUDriver *driver, VIR_DOMAIN_EVENT_STOPPED_FAILED); virObjectEventStateQueue(driver->domainEventState, event); } else { - qemuMigrationAnyPostcopyFailed(driver, vm); + qemuMigrationDstPostcopyFailed(vm); } } =20 diff --git a/src/qemu/qemu_migration.h b/src/qemu/qemu_migration.h index a8afa66119..c4e4228282 100644 --- a/src/qemu/qemu_migration.h +++ b/src/qemu/qemu_migration.h @@ -251,8 +251,10 @@ qemuMigrationDstRun(virQEMUDriver *driver, virDomainAsyncJob asyncJob); =20 void -qemuMigrationAnyPostcopyFailed(virQEMUDriver *driver, - virDomainObj *vm); +qemuMigrationSrcPostcopyFailed(virDomainObj *vm); + +void +qemuMigrationDstPostcopyFailed(virDomainObj *vm); =20 int qemuMigrationSrcFetchMirrorStats(virQEMUDriver *driver, diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index e8936cd623..0d39c67dfc 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -3411,7 +3411,7 @@ qemuProcessRecoverMigrationIn(virQEMUDriver *driver, * confirm success or failure yet; killing it seems safest unless * we already started guest CPUs or we were in post-copy mode */ if (postcopy) { - qemuMigrationAnyPostcopyFailed(driver, vm); + qemuMigrationDstPostcopyFailed(vm); } else if (state !=3D VIR_DOMAIN_RUNNING) { VIR_DEBUG("Killing migrated domain %s", vm->def->name); return -1; @@ -3462,7 +3462,7 @@ qemuProcessRecoverMigrationOut(virQEMUDriver *driver, * post-copy mode */ if (postcopy) { - qemuMigrationAnyPostcopyFailed(driver, vm); + qemuMigrationSrcPostcopyFailed(vm); } else { VIR_DEBUG("Cancelling unfinished migration of domain %s", vm->def->name); @@ -3480,7 +3480,7 @@ qemuProcessRecoverMigrationOut(virQEMUDriver *driver, * post-copy mode we can use PAUSED_POSTCOPY_FAILED state for this */ if (postcopy) - qemuMigrationAnyPostcopyFailed(driver, vm); + qemuMigrationSrcPostcopyFailed(vm); break; =20 case QEMU_MIGRATION_PHASE_CONFIRM3_CANCELLED: @@ -3489,7 +3489,7 @@ qemuProcessRecoverMigrationOut(virQEMUDriver *driver, * as broken in that case */ if (postcopy) { - qemuMigrationAnyPostcopyFailed(driver, vm); + qemuMigrationSrcPostcopyFailed(vm); } else { VIR_DEBUG("Resuming domain %s after failed migration", vm->def->name); --=20 2.35.1 From nobody Wed May 15 19:27:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1654087853; cv=none; d=zohomail.com; s=zohoarc; b=LAxftQb4JjoOR+yuBL0UZDzlcZrGeXfnWqeM/KZ1E1wqTCyov9+qyhU0qtUqN2Fx/QnQ9u36SUCsd0GjS8JahImi79H12gIDeoKdePCBEyx8OWbngroVDIvpDbY7EeqwqvRBta3u4uPQaEpeVZor1g2R9kUYjn18cZioWJyHdeI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654087853; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=sFpn91jdj/eqrrGbqN4YvMrqSFmZBiOJqvtRzTkMnQM=; b=k8lFmGzjos8MPgNuB+TAoyUT0ig3mxISEQ9EyIZ1VoPUltEJWage6k8M4Bhd6fHVqxSwi7OMUj5XdWb/ptzvh8MtkJh81xSaIdq4bj6Lqa4NAXLAm5SsQnjufvV7fdkmM8E1wYNygU8LkAZpnovsDPMe/ypjV389NJUkOdBKI8s= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1654087853323458.4124392176295; Wed, 1 Jun 2022 05:50:53 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-212-aCo6fvg4PQmEZqza5kgZwQ-1; Wed, 01 Jun 2022 08:50:44 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CD6D2833967; Wed, 1 Jun 2022 12:50:31 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id B5EE940EC007; Wed, 1 Jun 2022 12:50:31 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 881FC19451F0; Wed, 1 Jun 2022 12:50:29 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id BAE2619452D8 for ; Wed, 1 Jun 2022 12:50:27 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id B128840CFD0A; Wed, 1 Jun 2022 12:50:27 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.227]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8FF734047828; Wed, 1 Jun 2022 12:50:27 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 63B12245B51; Wed, 1 Jun 2022 14:50:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654087852; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=sFpn91jdj/eqrrGbqN4YvMrqSFmZBiOJqvtRzTkMnQM=; b=QtAbmu5KbOvVwRdkKScABS200tPJbHsHnaEWL6cKpq+bnmI92n92+rPHOud6vzo3JdACgg VF7L6R3S0dWdnsmWZh8A0EFUiwf099nlbACYqDaOtyrqjcvei5HMhG0wC18MWDoSP+6r8g bw92MIJUmv9JOSQsZ8NHFDi9BhhM4G8= X-MC-Unique: aCo6fvg4PQmEZqza5kgZwQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH v2 05/81] qemu: Explicitly emit events on post-copy failure Date: Wed, 1 Jun 2022 14:49:05 +0200 Message-Id: <98d9024700d5c52e751c08653e36eda026435270.1654087150.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Krempa , Pavel Hrdina Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1654087853705100001 Content-Type: text/plain; charset="utf-8" The events would normally be triggered only if we're changing domain state. But most of the time the domain is already in the right state and we're just changing its substate from {PAUSED,RUNNING}_POSTCOPY to *_POSTCOPY_FAILED. Let's emit lifecycle events explicitly when post-copy migration fails to make the failure visible without polling. Signed-off-by: Jiri Denemark Reviewed-by: Peter Krempa Reviewed-by: Pavel Hrdina --- Notes: Version 2: - no change src/qemu/qemu_migration.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 326e17ddd7..274386d6d9 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -1579,6 +1579,9 @@ qemuMigrationSrcIsSafe(virDomainDef *def, void qemuMigrationSrcPostcopyFailed(virDomainObj *vm) { + qemuDomainObjPrivate *priv =3D vm->privateData; + virQEMUDriver *driver =3D priv->driver; + virObjectEvent *event =3D NULL; virDomainState state; int reason; =20 @@ -1597,12 +1600,18 @@ qemuMigrationSrcPostcopyFailed(virDomainObj *vm) =20 virDomainObjSetState(vm, VIR_DOMAIN_PAUSED, VIR_DOMAIN_PAUSED_POSTCOPY_FAILED); + event =3D virDomainEventLifecycleNewFromObj(vm, VIR_DOMAIN_EVENT_SUSPE= NDED, + VIR_DOMAIN_EVENT_SUSPENDED_P= OSTCOPY_FAILED); + virObjectEventStateQueue(driver->domainEventState, event); } =20 =20 void qemuMigrationDstPostcopyFailed(virDomainObj *vm) { + qemuDomainObjPrivate *priv =3D vm->privateData; + virQEMUDriver *driver =3D priv->driver; + virObjectEvent *event =3D NULL; virDomainState state; int reason; =20 @@ -1622,6 +1631,9 @@ qemuMigrationDstPostcopyFailed(virDomainObj *vm) =20 virDomainObjSetState(vm, VIR_DOMAIN_RUNNING, VIR_DOMAIN_RUNNING_POSTCOPY_FAILED); + event =3D virDomainEventLifecycleNewFromObj(vm, VIR_DOMAIN_EVENT_RESUM= ED, + VIR_DOMAIN_EVENT_RESUMED_POS= TCOPY_FAILED); + virObjectEventStateQueue(driver->domainEventState, event); } =20 =20 --=20 2.35.1 From nobody Wed May 15 19:27:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1654087844; cv=none; d=zohomail.com; s=zohoarc; b=UodxTMFpbRIqdAezNapcXAzudU5v7ABWwwxfczHNqHW5RQ0nCT41TyBp8MJy6SagvIdDwCckU9V5bgmYLcAZGneNhzB+ZCLKbDu1hjPx3n/onEqYKS49AMQQzE4xGOcz5/WjrdFgy+Zvc56yVBktjHGaOMSjANV03yqudEuOjNo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654087844; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=GfGD7F+MIO6VU7eNgsnKEWzV/VIOZiY6UU8nRYHrA1A=; b=bHSLH8TtlavnJVP9xnnyg9bMt+hdHeIl+D7uQOkWhUkpgcrfWGmEF9LQIRr0a+5jzUbyp+ycT63Xu865tidzkzyt8JdutYD6NFSvPbAwmojCsEe2CD5NfigdgT4/eEbQ75tOl9Kz/MguPFyeCuHUzxR113iMaCfjW4dwafHH3SU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1654087844586154.7401228852957; Wed, 1 Jun 2022 05:50:44 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-452-N9A-ZLNTP_edWAPGjR-ttw-1; Wed, 01 Jun 2022 08:50:34 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C616F381685F; Wed, 1 Jun 2022 12:50:30 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id B213C492C3B; Wed, 1 Jun 2022 12:50:30 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id BF4951947BAD; Wed, 1 Jun 2022 12:50:28 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id C012419451F0 for ; Wed, 1 Jun 2022 12:50:27 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id B195240CFD0E; Wed, 1 Jun 2022 12:50:27 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.227]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8FFC940CF8EB; Wed, 1 Jun 2022 12:50:27 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 6506D245B52; Wed, 1 Jun 2022 14:50:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654087842; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=GfGD7F+MIO6VU7eNgsnKEWzV/VIOZiY6UU8nRYHrA1A=; b=dS+rtwkULyh2eFms7WQRDlHPdfKgubnpTRvPjJvuOgEJeZc+7JR6V5cs6w+QAByUJdr//Q ROwTxw+i8up6/tJPndUbHK1ibVS4lc9rchAMBca0zNocqYSEyjY+pPDjFjzRM82P8cFMIT QSUjJHx51Crm/kPInzuf/2EwGZywlp4= X-MC-Unique: N9A-ZLNTP_edWAPGjR-ttw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH v2 06/81] qemu: Make qemuDomainCleanupAdd return void Date: Wed, 1 Jun 2022 14:49:06 +0200 Message-Id: <233f467ce744d25b38dfb862f3de23b8b1cb5340.1654087150.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Krempa , Pavel Hrdina Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1654087845659100001 Content-Type: text/plain; charset="utf-8" The function never returns anything but zero. Signed-off-by: Jiri Denemark Reviewed-by: Peter Krempa Reviewed-by: Pavel Hrdina --- Notes: Version 2: - no change src/qemu/qemu_domain.c | 5 ++--- src/qemu/qemu_domain.h | 4 ++-- src/qemu/qemu_migration.c | 3 +-- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 6f358466c5..5dee9c6f26 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -7475,7 +7475,7 @@ qemuDomainCheckDiskStartupPolicy(virQEMUDriver *drive= r, * The vm must be locked when any of the following cleanup functions is * called. */ -int +void qemuDomainCleanupAdd(virDomainObj *vm, qemuDomainCleanupCallback cb) { @@ -7486,7 +7486,7 @@ qemuDomainCleanupAdd(virDomainObj *vm, =20 for (i =3D 0; i < priv->ncleanupCallbacks; i++) { if (priv->cleanupCallbacks[i] =3D=3D cb) - return 0; + return; } =20 VIR_RESIZE_N(priv->cleanupCallbacks, @@ -7494,7 +7494,6 @@ qemuDomainCleanupAdd(virDomainObj *vm, priv->ncleanupCallbacks, 1); =20 priv->cleanupCallbacks[priv->ncleanupCallbacks++] =3D cb; - return 0; } =20 void diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 547d85b5f9..ce2dba499c 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -762,8 +762,8 @@ int qemuDomainPrepareStorageSourceBlockdev(virDomainDis= kDef *disk, qemuDomainObjPrivate *priv, virQEMUDriverConfig *cfg); =20 -int qemuDomainCleanupAdd(virDomainObj *vm, - qemuDomainCleanupCallback cb); +void qemuDomainCleanupAdd(virDomainObj *vm, + qemuDomainCleanupCallback cb); void qemuDomainCleanupRemove(virDomainObj *vm, qemuDomainCleanupCallback cb); void qemuDomainCleanupRun(virQEMUDriver *driver, diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 274386d6d9..fee3e8826b 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -3071,8 +3071,7 @@ qemuMigrationDstPrepareAny(virQEMUDriver *driver, VIR_WARN("Unable to encode migration cookie"); } =20 - if (qemuDomainCleanupAdd(vm, qemuMigrationDstPrepareCleanup) < 0) - goto stopjob; + qemuDomainCleanupAdd(vm, qemuMigrationDstPrepareCleanup); =20 if (!(flags & VIR_MIGRATE_OFFLINE)) { virDomainAuditStart(vm, "migrated", true); --=20 2.35.1 From nobody Wed May 15 19:27:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1654087855; cv=none; d=zohomail.com; s=zohoarc; b=EVZXZ14NGo8ci11DaLhuwfGfsFzlDA6pVr9qlXxTBVrVitIlVxgbX/v0q/6RSnaPiBc7NrQ6fCqL9K1ExzW5ApGAqkySTk19QFW28kXDgQYfRZjqrju2sFEdg3EVhjMy8AkCIyMYsFlZVFvMzFmxPBkfICwjuxjCzJaFMTBt4+w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654087855; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=RSRffN/jMVLesjgmD2gYnvIwUS7VUE0kjIhRgUIwkew=; b=KpX7UYmeIQC46BnWTJEMpc7hWNVqAs5cOTR2XkAiAP8JIDkzAu7v/9b1v6fmmtmGnWe/jRws9bldcsxhX4weZoX2yv6nJ+LAIBMkCF7y3Ye1dtvyzHsLk3SyvcThOQPKweT9y+uAIz8YL9XcZU5g9wUyAfowFEmlYoC2jRQms6k= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1654087855365242.3357596003043; Wed, 1 Jun 2022 05:50:55 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-29-8_Kl2ygYPPmEHrP17uP09g-1; Wed, 01 Jun 2022 08:50:42 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A671E833976; Wed, 1 Jun 2022 12:50:32 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 909FC1415100; Wed, 1 Jun 2022 12:50:32 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id D4E0D1947BA4; Wed, 1 Jun 2022 12:50:30 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id D9BB61947B8B for ; Wed, 1 Jun 2022 12:50:27 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id B2C891410F36; Wed, 1 Jun 2022 12:50:27 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.227]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 90BB5140EBD5; Wed, 1 Jun 2022 12:50:27 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 66B29245B53; Wed, 1 Jun 2022 14:50:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654087854; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=RSRffN/jMVLesjgmD2gYnvIwUS7VUE0kjIhRgUIwkew=; b=TROMWDzZGmPkRUkI2LPjZQR5d30D4PXerFCCct1fXSvKIUHjzGG07yY5LayHmdDY+Y2fHJ RaCzvbushjWn+jgQhdqcPuzIeD3u8m9BptebFMQpj11TpP/corUeK3sJntZjwv5LlPZbiO 1P8hDeTEJblbzuXWRvJtXEah8GE0QpQ= X-MC-Unique: 8_Kl2ygYPPmEHrP17uP09g-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH v2 07/81] conf: Introduce virDomainObjIsFailedPostcopy helper Date: Wed, 1 Jun 2022 14:49:07 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Krempa , Pavel Hrdina Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1654087855711100003 Content-Type: text/plain; charset="utf-8" Signed-off-by: Jiri Denemark Reviewed-by: Peter Krempa Reviewed-by: Pavel Hrdina --- Notes: Version 2: - no change src/conf/domain_conf.c | 10 ++++++++++ src/conf/domain_conf.h | 4 ++++ src/libvirt_private.syms | 1 + 3 files changed, 15 insertions(+) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 58ca3c7c75..34ecc7e7a9 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -29239,6 +29239,16 @@ virDomainObjGetState(virDomainObj *dom, int *reaso= n) } =20 =20 +bool +virDomainObjIsFailedPostcopy(virDomainObj *dom) +{ + return ((dom->state.state =3D=3D VIR_DOMAIN_PAUSED && + dom->state.reason =3D=3D VIR_DOMAIN_PAUSED_POSTCOPY_FAILED) || + (dom->state.state =3D=3D VIR_DOMAIN_RUNNING && + dom->state.reason =3D=3D VIR_DOMAIN_RUNNING_POSTCOPY_FAILED)); +} + + void virDomainObjSetState(virDomainObj *dom, virDomainState state, int reason) { diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index e7e0f24443..da85c6ecd4 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -3886,6 +3886,10 @@ virDomainState virDomainObjGetState(virDomainObj *obj, int *reason) ATTRIBUTE_NONNULL(1); =20 +bool +virDomainObjIsFailedPostcopy(virDomainObj *obj) + ATTRIBUTE_NONNULL(1); + virSecurityLabelDef * virDomainDefGetSecurityLabelDef(const virDomainDef *def, const char *model= ); =20 diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index bfedd85326..0c6dd4fa49 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -577,6 +577,7 @@ virDomainObjGetOneDef; virDomainObjGetOneDefState; virDomainObjGetPersistentDef; virDomainObjGetState; +virDomainObjIsFailedPostcopy; virDomainObjNew; virDomainObjParseFile; virDomainObjParseNode; --=20 2.35.1 From nobody Wed May 15 19:27:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1654087840; cv=none; d=zohomail.com; s=zohoarc; b=BibXOINeQs8RjL5rbaVVr2+DyV67WHVjp/9DMw0v7PHDMk5N/8GlGRaZwpALYEW5Qy6IUL4seYS2k9KLOj8TrjrsEUflGH2gGpla5Hiy3Y5qLpwv8jptGBFospCEwJ8fTkE5icOUoYXGF/+LTkoMRUVEKv/qpbg9DKPolJQmyzE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654087840; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=g4PQGvL4+ybkL9Hu+XDz11YgJZ0A+F37degw4mqEAZQ=; b=Fw45JHl+3rHGbeP24ggkv0cxUVY92bldLottv/rhCwlKB30ZMdB7p97yKV8efekoX1hNbmySZxkJJ5aXl6pYTzZIcwjGqumQzWZFFlJ0gAlaYAWp9kbkxuQzih4N02QtjOeL9tgX/qbTzE+DfbwWH79WEsnkEtPZgqMTd6FwLZA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1654087840014330.3238396926239; Wed, 1 Jun 2022 05:50:40 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-597-x4GPMizINc2stJbF1Fu2_A-1; Wed, 01 Jun 2022 08:50:34 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2ACED180138B; Wed, 1 Jun 2022 12:50:30 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 14E2940EC004; Wed, 1 Jun 2022 12:50:30 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 8D8CD1947BA1; Wed, 1 Jun 2022 12:50:28 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id DE0E61947B8C for ; Wed, 1 Jun 2022 12:50:27 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id B28B0492C3B; Wed, 1 Jun 2022 12:50:27 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.227]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9184D40F06B; Wed, 1 Jun 2022 12:50:27 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 68774245B54; Wed, 1 Jun 2022 14:50:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654087838; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=g4PQGvL4+ybkL9Hu+XDz11YgJZ0A+F37degw4mqEAZQ=; b=WiNgnWc/8GJ1+r23/IL9v4Ngriyfb9ry3BUN0/JTn459isGDhd4MwITZd2szqJLluJszbB E7y6dPe+nOsPfBBrQcoskcUzy1p5NFurjB2KqrV2OaZlOOcN2I0eCPhKF6F+fxeoba/LYb bsBflqWqIg/kloAtqQxUi45dIvDJDUg= X-MC-Unique: x4GPMizINc2stJbF1Fu2_A-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH v2 08/81] conf: Introduce virDomainObjIsPostcopy helper Date: Wed, 1 Jun 2022 14:49:08 +0200 Message-Id: <18a8c33002e83692f8143fbfe4163a4e8f1a1002.1654087150.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Krempa , Pavel Hrdina Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1654087841645100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Jiri Denemark Reviewed-by: Peter Krempa Reviewed-by: Pavel Hrdina --- Notes: Version 2: - no change src/conf/domain_conf.c | 22 ++++++++++++++++++++++ src/conf/domain_conf.h | 4 ++++ src/libvirt_private.syms | 1 + 3 files changed, 27 insertions(+) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 34ecc7e7a9..05fd64b1c3 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -29249,6 +29249,28 @@ virDomainObjIsFailedPostcopy(virDomainObj *dom) } =20 =20 +bool +virDomainObjIsPostcopy(virDomainObj *dom, + virDomainJobOperation op) +{ + if (op !=3D VIR_DOMAIN_JOB_OPERATION_MIGRATION_IN && + op !=3D VIR_DOMAIN_JOB_OPERATION_MIGRATION_OUT) + return false; + + if (op =3D=3D VIR_DOMAIN_JOB_OPERATION_MIGRATION_IN) { + return (dom->state.state =3D=3D VIR_DOMAIN_PAUSED && + dom->state.reason =3D=3D VIR_DOMAIN_PAUSED_POSTCOPY_FAILED= ) || + (dom->state.state =3D=3D VIR_DOMAIN_RUNNING && + (dom->state.reason =3D=3D VIR_DOMAIN_RUNNING_POSTCOPY || + dom->state.reason =3D=3D VIR_DOMAIN_RUNNING_POSTCOPY_FAIL= ED)); + } + + return dom->state.state =3D=3D VIR_DOMAIN_PAUSED && + (dom->state.reason =3D=3D VIR_DOMAIN_PAUSED_POSTCOPY || + dom->state.reason =3D=3D VIR_DOMAIN_PAUSED_POSTCOPY_FAILED); +} + + void virDomainObjSetState(virDomainObj *dom, virDomainState state, int reason) { diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index da85c6ecd4..1efdb439ac 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -3889,6 +3889,10 @@ virDomainObjGetState(virDomainObj *obj, int *reason) bool virDomainObjIsFailedPostcopy(virDomainObj *obj) ATTRIBUTE_NONNULL(1); +bool +virDomainObjIsPostcopy(virDomainObj *dom, + virDomainJobOperation op) + ATTRIBUTE_NONNULL(1); =20 virSecurityLabelDef * virDomainDefGetSecurityLabelDef(const virDomainDef *def, const char *model= ); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 0c6dd4fa49..770dfe459a 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -578,6 +578,7 @@ virDomainObjGetOneDefState; virDomainObjGetPersistentDef; virDomainObjGetState; virDomainObjIsFailedPostcopy; +virDomainObjIsPostcopy; virDomainObjNew; virDomainObjParseFile; virDomainObjParseNode; --=20 2.35.1 From nobody Wed May 15 19:27:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1654087871; cv=none; d=zohomail.com; s=zohoarc; b=OUxFlUYpq2hPf1IWLHz1CUeZDRHOysQoR0Dv7amtUr+rO7+PpkrN3rIHOZqhoJttZAargqD38nNkws3d4XcryzFQQULSXHDvQNh9e47VlpvQB3kZhLUzdeYH+smmmxWGRMaCKrGslsccG9BCt9858cAU9EtvfkNLLNjG04MvmVo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654087871; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=TuqX7DgWUhCrcR4c1oUTC0EtkTTyz//XOIagbUnWFgw=; b=kUJdXXmzYtSEpYLUJE5pdfOwX/3gd2jf8pJPYqae1rO4CzeefCwVnuSZOxkPkoO8+pPWT0UW34p3fnda0He/BdVHKhfLhZQbkeBES2NPWSxtrWqMgjZIzJFfki6p8MtRpj80WE4jqdstSUw++/JFZK9LPRkY/z8QXQPn+cZ+aJ8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1654087871445181.7733244562636; Wed, 1 Jun 2022 05:51:11 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-262-ikRDQMDnMfKJ638bOue7sw-1; Wed, 01 Jun 2022 08:50:55 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id F2C2118E004B; Wed, 1 Jun 2022 12:50:35 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id DD86282882; Wed, 1 Jun 2022 12:50:35 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id EB734194E101; Wed, 1 Jun 2022 12:50:33 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 1AB841947B94 for ; Wed, 1 Jun 2022 12:50:28 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id D00C81410F3B; Wed, 1 Jun 2022 12:50:27 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.227]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AEF2B1410DDB; Wed, 1 Jun 2022 12:50:27 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 6A454245B55; Wed, 1 Jun 2022 14:50:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654087870; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=TuqX7DgWUhCrcR4c1oUTC0EtkTTyz//XOIagbUnWFgw=; b=DB+mSl8vy7pk/Nftpt1V54tHJbl/VloTfwnBK/SmTditvYGEqHiYS/ECAzLYOBStItakHV gYbCCh6DgDvmP01SNRRkY1S2Rjm2d3BOAG8LX8zZ3zRqs0gVBDc65uUhx/QRvva2yPt+Gm 5bnGiShGWqfmdIy//yVHF/EO9zocJzs= X-MC-Unique: ikRDQMDnMfKJ638bOue7sw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH v2 09/81] qemu: Introduce qemuProcessCleanupMigrationJob Date: Wed, 1 Jun 2022 14:49:09 +0200 Message-Id: <23f5a05ce5f84ab365477226dd558e13d223806b.1654087150.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Krempa , Pavel Hrdina Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1654087871866100002 Content-Type: text/plain; charset="utf-8" The function can be used as a callback for qemuDomainCleanupAdd to automatically clean up a migration job when a domain is destroyed. Signed-off-by: Jiri Denemark Reviewed-by: Peter Krempa Reviewed-by: Pavel Hrdina --- Notes: Version 2: - no change src/qemu/qemu_process.c | 25 +++++++++++++++++++++++++ src/qemu/qemu_process.h | 3 +++ 2 files changed, 28 insertions(+) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 0d39c67dfc..2f0167299f 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -3360,6 +3360,31 @@ qemuProcessUpdateState(virQEMUDriver *driver, virDom= ainObj *vm) return 0; } =20 + +void +qemuProcessCleanupMigrationJob(virQEMUDriver *driver, + virDomainObj *vm) +{ + qemuDomainObjPrivate *priv =3D vm->privateData; + virDomainState state; + int reason; + + state =3D virDomainObjGetState(vm, &reason); + + VIR_DEBUG("driver=3D%p, vm=3D%s, asyncJob=3D%s, state=3D%s, reason=3D%= s", + driver, vm->def->name, + virDomainAsyncJobTypeToString(priv->job.asyncJob), + virDomainStateTypeToString(state), + virDomainStateReasonToString(state, reason)); + + if (priv->job.asyncJob !=3D VIR_ASYNC_JOB_MIGRATION_IN && + priv->job.asyncJob !=3D VIR_ASYNC_JOB_MIGRATION_OUT) + return; + + qemuDomainObjDiscardAsyncJob(vm); +} + + static int qemuProcessRecoverMigrationIn(virQEMUDriver *driver, virDomainObj *vm, diff --git a/src/qemu/qemu_process.h b/src/qemu/qemu_process.h index 9866d2bf35..8641534be4 100644 --- a/src/qemu/qemu_process.h +++ b/src/qemu/qemu_process.h @@ -241,3 +241,6 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC(qemuProcessQMP, qemuProce= ssQMPFree); int qemuProcessQMPStart(qemuProcessQMP *proc); =20 bool qemuProcessRebootAllowed(const virDomainDef *def); + +void qemuProcessCleanupMigrationJob(virQEMUDriver *driver, + virDomainObj *vm); --=20 2.35.1 From nobody Wed May 15 19:27:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1654087863; cv=none; d=zohomail.com; s=zohoarc; b=n26SAWx8FoXgN9xWP3V20OYmTxOMn6AEMeCbEh38B4hU2VhoD/DzqgrOqSsDRjXxY72+iIVmJNPRvS2GLozhbwqdqmYqAr/hu2PO96J1EJEr1jbM27pusdfWeCdpvbuokTxNwNvhc2V8C1AlzYRWB46iul3ksB2CXFPNZphwSas= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654087863; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=qDScVcvHsEAJhmcDdz7zgYnQ8cfjXdIqm7+tnFwSmDk=; b=aKkbDUrp9cbguDypqy+2Qg1a7R9tAT9JVcAAeM1UEkGLia8/80zp5a8XqG/4C6ZZNbgZBZS/kA6di1PPjL7TylNh1cJfc0ULmmZmAFIv94eyTDjXc8i45iPk2KMETwxFRZm3jS8GdiTH3b13gP5as25k/lkq5DkwPUC03bEERmU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1654087863666383.0513175228904; Wed, 1 Jun 2022 05:51:03 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-251-_FkCIopRO7-Qig0sucYIwA-1; Wed, 01 Jun 2022 08:50:51 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8782A8219B2; Wed, 1 Jun 2022 12:50:33 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 604EC40EC007; Wed, 1 Jun 2022 12:50:33 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id BAC401937754; Wed, 1 Jun 2022 12:50:31 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id F3A721947B8F for ; Wed, 1 Jun 2022 12:50:27 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id CB23040EC005; Wed, 1 Jun 2022 12:50:27 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.227]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AA82840EC002; Wed, 1 Jun 2022 12:50:27 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 6C691245B56; Wed, 1 Jun 2022 14:50:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654087862; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=qDScVcvHsEAJhmcDdz7zgYnQ8cfjXdIqm7+tnFwSmDk=; b=bVdvz5vFacpzjc9+PLbWk1CmFXQ3dw2m6V6+OOu0Z+bgpT53wZVSW+Ditdv9V/2e3Wgniz dkhKNLda5vxYTqGcK2QhHYr01WMfmParInOcIKDv7I8wDlcyxa1HuV0vk2X8Jn0RpOQ9M2 g1Ss3ZJC0FbMKnBTg+Cy69222TEioUs= X-MC-Unique: _FkCIopRO7-Qig0sucYIwA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH v2 10/81] qemu: Rename qemuDomainObjRestoreJob as qemuDomainObjPreserveJob Date: Wed, 1 Jun 2022 14:49:10 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Krempa , Pavel Hrdina Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1654087865856100001 Content-Type: text/plain; charset="utf-8" It is used for saving job out of domain object. Just like virErrorPreserveLast is used for errors. Let's make the naming consistent as Restore would suggest different semantics. Signed-off-by: Jiri Denemark Reviewed-by: Peter Krempa Reviewed-by: Pavel Hrdina --- Notes: Version 2: - no change src/qemu/qemu_domainjob.c | 14 ++++++++++++-- src/qemu/qemu_domainjob.h | 4 ++-- src/qemu/qemu_process.c | 2 +- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/qemu/qemu_domainjob.c b/src/qemu/qemu_domainjob.c index cb20b798f7..1e5724b505 100644 --- a/src/qemu/qemu_domainjob.c +++ b/src/qemu/qemu_domainjob.c @@ -214,9 +214,19 @@ qemuDomainObjResetAsyncJob(qemuDomainJobObj *job) job->cb->resetJobPrivate(job->privateData); } =20 + +/** + * qemuDomainObjPreserveJob + * @param obj domain with a job that needs to be preserved + * @param job structure where to store job details from @obj + * + * Saves the current job details from @obj to @job and resets the job in @= obj. + * + * Returns 0 on success, -1 on failure. + */ int -qemuDomainObjRestoreJob(virDomainObj *obj, - qemuDomainJobObj *job) +qemuDomainObjPreserveJob(virDomainObj *obj, + qemuDomainJobObj *job) { qemuDomainObjPrivate *priv =3D obj->privateData; =20 diff --git a/src/qemu/qemu_domainjob.h b/src/qemu/qemu_domainjob.h index f67eace36c..2bbccf6329 100644 --- a/src/qemu/qemu_domainjob.h +++ b/src/qemu/qemu_domainjob.h @@ -158,8 +158,8 @@ void qemuDomainObjSetJobPhase(virDomainObj *obj, int phase); void qemuDomainObjSetAsyncJobMask(virDomainObj *obj, unsigned long long allowedJobs); -int qemuDomainObjRestoreJob(virDomainObj *obj, - qemuDomainJobObj *job); +int qemuDomainObjPreserveJob(virDomainObj *obj, + qemuDomainJobObj *job); void qemuDomainObjDiscardAsyncJob(virDomainObj *obj); void qemuDomainObjReleaseAsyncJob(virDomainObj *obj); =20 diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 2f0167299f..18445855db 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -8714,7 +8714,7 @@ qemuProcessReconnect(void *opaque) cfg =3D virQEMUDriverGetConfig(driver); priv =3D obj->privateData; =20 - qemuDomainObjRestoreJob(obj, &oldjob); + qemuDomainObjPreserveJob(obj, &oldjob); if (oldjob.asyncJob =3D=3D VIR_ASYNC_JOB_MIGRATION_IN) stopFlags |=3D VIR_QEMU_PROCESS_STOP_MIGRATED; if (oldjob.asyncJob =3D=3D VIR_ASYNC_JOB_BACKUP && priv->backup) --=20 2.35.1 From nobody Wed May 15 19:27:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1654087866; cv=none; d=zohomail.com; s=zohoarc; b=kABqKf7ISbNaF1qUJKNA1NdTA0VHaARuJS7fiyLpri1rDWrTcRimgkGWGjcOjC4Zv7ip9lnyvEPcOX7J5vkWwN9LZNnv69AZZ5ImRPrSwG26hYsiZcbHiIc87Nu5DY+c6cE2fU74gRb6sNNtPVfRxGIXsiiPhkdFL20boKAG+XU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654087866; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=yXCH/01oDy+MLq7CllJfBInHy8xPJC2SgzmgZumNbMQ=; b=lu+JYAoiAWZ1vhnbO7DJfB1wGTi37XQclp3gLLopWBw+xqAM6wPEae404tzWBK/yz1a/bnXslZAiusU7eS4xXRuB8dk/bqYQpuRNxaQSnMRkayi6WlBGHnRYEbXSYFHoEFwI8JTqJ1oV3w4kGEz+oXHPQPT1MR8DW23SrbO0hJs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 165408786696351.48814024892067; Wed, 1 Jun 2022 05:51:06 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-58-tvsWwRetOFeEst1ERBEy3g-1; Wed, 01 Jun 2022 08:50:41 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3FA988021B6; Wed, 1 Jun 2022 12:50:33 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1049C2026D2D; Wed, 1 Jun 2022 12:50:33 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 65FA91947BA2; Wed, 1 Jun 2022 12:50:31 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 16D1F1947B8C for ; Wed, 1 Jun 2022 12:50:28 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id E615FC27E8F; Wed, 1 Jun 2022 12:50:27 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.227]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A9D39C15E72; Wed, 1 Jun 2022 12:50:27 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 6DC82245B57; Wed, 1 Jun 2022 14:50:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654087864; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=yXCH/01oDy+MLq7CllJfBInHy8xPJC2SgzmgZumNbMQ=; b=AE1mFHeKAUUYXiiSIuyJGF2MkmVzanZdeeBe67ll86Dr7qhRA8xpKB5OYp8Wola3HwRARM T4+3TGwVMiAAkVRXAr66ps7dQL26AOnaw/T2qsxD/dn5kYTWvD42k8SPAuVo7vKZYjrPbO 4x/lQKRNENUHRbNYunWlnVAOEnEBQss= X-MC-Unique: tvsWwRetOFeEst1ERBEy3g-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH v2 11/81] qemu: Add qemuDomainObjRestoreAsyncJob Date: Wed, 1 Jun 2022 14:49:11 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Pavel Hrdina Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1654087867845100003 Content-Type: text/plain; charset="utf-8" The code for setting up a previously active backup job in qemuProcessRecoverJob is generalized into a dedicated function so that it can be later reused in other places. Signed-off-by: Jiri Denemark Reviewed-by: Pavel Hrdina --- Notes: Version 2: - s/priv->job./job->/ src/qemu/qemu_domainjob.c | 35 +++++++++++++++++++++++++++++++++++ src/qemu/qemu_domainjob.h | 8 ++++++++ src/qemu/qemu_process.c | 29 +++++++---------------------- 3 files changed, 50 insertions(+), 22 deletions(-) diff --git a/src/qemu/qemu_domainjob.c b/src/qemu/qemu_domainjob.c index 1e5724b505..f85429a7ce 100644 --- a/src/qemu/qemu_domainjob.c +++ b/src/qemu/qemu_domainjob.c @@ -249,6 +249,41 @@ qemuDomainObjPreserveJob(virDomainObj *obj, return 0; } =20 + +void +qemuDomainObjRestoreAsyncJob(virDomainObj *vm, + virDomainAsyncJob asyncJob, + int phase, + virDomainJobOperation operation, + qemuDomainJobStatsType statsType, + virDomainJobStatus status, + unsigned long long allowedJobs) +{ + qemuDomainObjPrivate *priv =3D vm->privateData; + qemuDomainJobObj *job =3D &priv->job; + unsigned long long now; + + VIR_DEBUG("Restoring %s async job for domain %s", + virDomainAsyncJobTypeToString(asyncJob), vm->def->name); + + ignore_value(virTimeMillisNow(&now)); + + job->jobsQueued++; + job->asyncJob =3D asyncJob; + job->phase =3D phase; + job->asyncOwnerAPI =3D g_strdup(virThreadJobGet()); + job->asyncStarted =3D now; + + qemuDomainObjSetAsyncJobMask(vm, allowedJobs); + + job->current =3D virDomainJobDataInit(&qemuJobDataPrivateDataCallbacks= ); + qemuDomainJobSetStatsType(priv->job.current, statsType); + job->current->operation =3D operation; + job->current->status =3D status; + job->current->started =3D now; +} + + void qemuDomainObjClearJob(qemuDomainJobObj *job) { diff --git a/src/qemu/qemu_domainjob.h b/src/qemu/qemu_domainjob.h index 2bbccf6329..069bb9f8cb 100644 --- a/src/qemu/qemu_domainjob.h +++ b/src/qemu/qemu_domainjob.h @@ -160,6 +160,14 @@ void qemuDomainObjSetAsyncJobMask(virDomainObj *obj, unsigned long long allowedJobs); int qemuDomainObjPreserveJob(virDomainObj *obj, qemuDomainJobObj *job); +void +qemuDomainObjRestoreAsyncJob(virDomainObj *vm, + virDomainAsyncJob asyncJob, + int phase, + virDomainJobOperation operation, + qemuDomainJobStatsType statsType, + virDomainJobStatus status, + unsigned long long allowedJobs); void qemuDomainObjDiscardAsyncJob(virDomainObj *obj); void qemuDomainObjReleaseAsyncJob(virDomainObj *obj); =20 diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 18445855db..b1725ce4cf 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -3557,7 +3557,6 @@ qemuProcessRecoverJob(virQEMUDriver *driver, qemuDomainObjPrivate *priv =3D vm->privateData; virDomainState state; int reason; - unsigned long long now; =20 state =3D virDomainObjGetState(vm, &reason); =20 @@ -3614,28 +3613,14 @@ qemuProcessRecoverJob(virQEMUDriver *driver, break; =20 case VIR_ASYNC_JOB_BACKUP: - ignore_value(virTimeMillisNow(&now)); - /* Restore the config of the async job which is not persisted */ - priv->job.jobsQueued++; - priv->job.asyncJob =3D VIR_ASYNC_JOB_BACKUP; - priv->job.asyncOwnerAPI =3D g_strdup(virThreadJobGet()); - priv->job.asyncStarted =3D now; - - qemuDomainObjSetAsyncJobMask(vm, (VIR_JOB_DEFAULT_MASK | - JOB_MASK(VIR_JOB_SUSPEND) | - JOB_MASK(VIR_JOB_MODIFY))); - - /* We reset the job parameters for backup so that the job will look - * active. This is possible because we are able to recover the sta= te - * of blockjobs and also the backup job allows all sub-job types */ - priv->job.current =3D virDomainJobDataInit(&qemuJobDataPrivateData= Callbacks); - - qemuDomainJobSetStatsType(priv->job.current, - QEMU_DOMAIN_JOB_STATS_TYPE_BACKUP); - priv->job.current->operation =3D VIR_DOMAIN_JOB_OPERATION_BACKUP; - priv->job.current->status =3D VIR_DOMAIN_JOB_STATUS_ACTIVE; - priv->job.current->started =3D now; + qemuDomainObjRestoreAsyncJob(vm, VIR_ASYNC_JOB_BACKUP, 0, + VIR_DOMAIN_JOB_OPERATION_BACKUP, + QEMU_DOMAIN_JOB_STATS_TYPE_BACKUP, + VIR_DOMAIN_JOB_STATUS_ACTIVE, + (VIR_JOB_DEFAULT_MASK | + JOB_MASK(VIR_JOB_SUSPEND) | + JOB_MASK(VIR_JOB_MODIFY))); break; =20 case VIR_ASYNC_JOB_NONE: --=20 2.35.1 From nobody Wed May 15 19:27:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1654087883; cv=none; d=zohomail.com; s=zohoarc; b=PQwYG4VhqaiYgTGJmKVqKqxu9S+ROnXnRJsAXbeC0m1A/Fe1HXHMdmJvxyQxLhZv+Ihs8RXuMIQaY8mSJNxzS/+QGToHRCXKHO8z7tUTrSJf3bLwIj9FfRUVXvmtFBKom44JbY1sKPRVy60g6XLMqV2pOu6qTM5BjjmfXtjbOFw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654087883; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=4HuOqlp7aGQ9oer0G3VlpygWTP5e1xJH7ftD2Ah810Q=; b=H8ziUMQUERWvZInrYDvPP6JwFD0aMAPUvJlr/l/dy5lJUeVPRJK37doibT9x7Umz6uS4bgoVDuNTrgDC2JLCYKlQqX8Ej6XO0lrF6GeMRoRhn0Tq3gIc6vOGWHi281TtLEwwUewVDcmGbkaNxYJQE9AIEIBhqzqfU9NO/09tvaI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1654087883481159.73167264811764; Wed, 1 Jun 2022 05:51:23 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-263-0uiudrgwNfiewxqSgs_uUg-1; Wed, 01 Jun 2022 08:51:10 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4FA978041A5; Wed, 1 Jun 2022 12:50:34 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3BAE52026D64; Wed, 1 Jun 2022 12:50:34 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 706A01947B8C; Wed, 1 Jun 2022 12:50:32 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 220B01947B96 for ; Wed, 1 Jun 2022 12:50:28 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id E891A2026D64; Wed, 1 Jun 2022 12:50:27 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.227]) by smtp.corp.redhat.com (Postfix) with ESMTPS id ABA682026D07; Wed, 1 Jun 2022 12:50:27 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 6F3DF245B58; Wed, 1 Jun 2022 14:50:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654087882; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=4HuOqlp7aGQ9oer0G3VlpygWTP5e1xJH7ftD2Ah810Q=; b=SKek+iWOBMBn9A/Fvf1UD/dp980PnpOFfw9FrvbpEes9mYLH9xnG7RSLQLieDCmFw4l+vv JYNxvQEqY7ITsZ1Nh9kr6ngxDWiwWzu+NijNdKLwSM8yfa3fLm9znvhP2NoEcJVljUm5kG jFf0ZawpMiHT2PmjyiK5fy0S0aWgVvw= X-MC-Unique: 0uiudrgwNfiewxqSgs_uUg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH v2 12/81] qemu: Keep migration job active after failed post-copy Date: Wed, 1 Jun 2022 14:49:12 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Krempa , Pavel Hrdina Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1654087883948100001 Content-Type: text/plain; charset="utf-8" When post-copy migration fails, we can't just abort the migration and resume the domain on the source host as it is already running on the destination host and no host has a complete state of the domain memory. Instead of the current approach of just marking the domain on both ends as paused/running with a post-copy failed sub state, we will keep the migration job active (even though the migration API will return failure) so that the state is more visible and we can better control what APIs can be called on the domains and even allow for resuming the migration. Signed-off-by: Jiri Denemark Reviewed-by: Peter Krempa Reviewed-by: Pavel Hrdina --- Notes: Version 2: - squashed in a one line change from "qemu: Implement VIR_MIGRATE_POSTCOPY_RESUME for Confirm phase" src/qemu/qemu_migration.c | 95 ++++++++++++++++++++++++++++----------- 1 file changed, 69 insertions(+), 26 deletions(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index fee3e8826b..0daf50d836 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -2221,10 +2221,17 @@ qemuMigrationSrcCleanup(virDomainObj *vm, VIR_WARN("Migration of domain %s finished but we don't know if the" " domain was successfully started on destination or not", vm->def->name); - qemuMigrationParamsReset(driver, vm, VIR_ASYNC_JOB_MIGRATION_OUT, - jobPriv->migParams, priv->job.apiFlags); - /* clear the job and let higher levels decide what to do */ - qemuMigrationJobFinish(vm); + + if (virDomainObjIsPostcopy(vm, VIR_DOMAIN_JOB_OPERATION_MIGRATION_= OUT)) { + qemuMigrationSrcPostcopyFailed(vm); + qemuDomainCleanupAdd(vm, qemuProcessCleanupMigrationJob); + qemuMigrationJobContinue(vm); + } else { + qemuMigrationParamsReset(driver, vm, VIR_ASYNC_JOB_MIGRATION_O= UT, + jobPriv->migParams, priv->job.apiFlag= s); + /* clear the job and let higher levels decide what to do */ + qemuMigrationJobFinish(vm); + } break; =20 case QEMU_MIGRATION_PHASE_PERFORM3: @@ -3400,6 +3407,7 @@ qemuMigrationSrcConfirmPhase(virQEMUDriver *driver, qemuDomainObjPrivate *priv =3D vm->privateData; qemuDomainJobPrivate *jobPriv =3D priv->job.privateData; virDomainJobData *jobData =3D NULL; + qemuMigrationJobPhase phase; =20 VIR_DEBUG("driver=3D%p, vm=3D%p, cookiein=3D%s, cookieinlen=3D%d, " "flags=3D0x%x, retcode=3D%d", @@ -3408,10 +3416,17 @@ qemuMigrationSrcConfirmPhase(virQEMUDriver *driver, =20 virCheckFlags(QEMU_MIGRATION_FLAGS, -1); =20 - qemuMigrationJobSetPhase(vm, - retcode =3D=3D 0 - ? QEMU_MIGRATION_PHASE_CONFIRM3 - : QEMU_MIGRATION_PHASE_CONFIRM3_CANCELLED); + /* Keep the original migration phase in case post-copy failed as the j= ob + * will stay active even though migration API finishes with an error. + */ + if (virDomainObjIsFailedPostcopy(vm)) + phase =3D priv->job.phase; + else if (retcode =3D=3D 0) + phase =3D QEMU_MIGRATION_PHASE_CONFIRM3; + else + phase =3D QEMU_MIGRATION_PHASE_CONFIRM3_CANCELLED; + + qemuMigrationJobSetPhase(vm, phase); =20 if (!(mig =3D qemuMigrationCookieParse(driver, vm->def, priv->origname= , priv, cookiein, cookieinlen, @@ -3480,13 +3495,14 @@ qemuMigrationSrcConfirmPhase(virQEMUDriver *driver, virErrorRestore(&orig_err); =20 if (virDomainObjGetState(vm, &reason) =3D=3D VIR_DOMAIN_PAUSED && - reason =3D=3D VIR_DOMAIN_PAUSED_POSTCOPY) + reason =3D=3D VIR_DOMAIN_PAUSED_POSTCOPY) { qemuMigrationSrcPostcopyFailed(vm); - else + } else if (!virDomainObjIsFailedPostcopy(vm)) { qemuMigrationSrcRestoreDomainState(driver, vm); =20 - qemuMigrationParamsReset(driver, vm, VIR_ASYNC_JOB_MIGRATION_OUT, - jobPriv->migParams, priv->job.apiFlags); + qemuMigrationParamsReset(driver, vm, VIR_ASYNC_JOB_MIGRATION_O= UT, + jobPriv->migParams, priv->job.apiFlag= s); + } =20 qemuDomainSaveStatus(vm); } @@ -3504,12 +3520,18 @@ qemuMigrationSrcConfirm(virQEMUDriver *driver, { qemuMigrationJobPhase phase; g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); + qemuDomainObjPrivate *priv =3D vm->privateData; int ret =3D -1; =20 if (!qemuMigrationJobIsActive(vm, VIR_ASYNC_JOB_MIGRATION_OUT)) goto cleanup; =20 - if (cancelled) + /* Keep the original migration phase in case post-copy failed as the j= ob + * will stay active even though migration API finishes with an error. + */ + if (virDomainObjIsFailedPostcopy(vm)) + phase =3D priv->job.phase; + else if (cancelled) phase =3D QEMU_MIGRATION_PHASE_CONFIRM3_CANCELLED; else phase =3D QEMU_MIGRATION_PHASE_CONFIRM3; @@ -3517,12 +3539,19 @@ qemuMigrationSrcConfirm(virQEMUDriver *driver, qemuMigrationJobStartPhase(vm, phase); virCloseCallbacksUnset(driver->closeCallbacks, vm, qemuMigrationSrcCleanup); + qemuDomainCleanupRemove(vm, qemuProcessCleanupMigrationJob); =20 ret =3D qemuMigrationSrcConfirmPhase(driver, vm, cookiein, cookieinlen, flags, cancelled); =20 - qemuMigrationJobFinish(vm); + if (virDomainObjIsFailedPostcopy(vm)) { + qemuDomainCleanupAdd(vm, qemuProcessCleanupMigrationJob); + qemuMigrationJobContinue(vm); + } else { + qemuMigrationJobFinish(vm); + } + if (!virDomainObjIsActive(vm)) { if (!cancelled && ret =3D=3D 0 && flags & VIR_MIGRATE_UNDEFINE_SOU= RCE) { virDomainDeleteConfig(cfg->configDir, cfg->autostartDir, vm); @@ -5334,16 +5363,22 @@ qemuMigrationSrcPerformJob(virQEMUDriver *driver, if (ret < 0) virErrorPreserveLast(&orig_err); =20 - /* v2 proto has no confirm phase so we need to reset migration paramet= ers - * here - */ - if (!v3proto && ret < 0) - qemuMigrationParamsReset(driver, vm, VIR_ASYNC_JOB_MIGRATION_OUT, - jobPriv->migParams, priv->job.apiFlags); + if (virDomainObjIsFailedPostcopy(vm)) { + qemuDomainCleanupAdd(vm, qemuProcessCleanupMigrationJob); + qemuMigrationJobContinue(vm); + } else { + /* v2 proto has no confirm phase so we need to reset migration par= ameters + * here + */ + if (!v3proto && ret < 0) + qemuMigrationParamsReset(driver, vm, VIR_ASYNC_JOB_MIGRATION_O= UT, + jobPriv->migParams, priv->job.apiFlag= s); =20 - qemuMigrationSrcRestoreDomainState(driver, vm); + qemuMigrationSrcRestoreDomainState(driver, vm); + + qemuMigrationJobFinish(vm); + } =20 - qemuMigrationJobFinish(vm); if (!virDomainObjIsActive(vm) && ret =3D=3D 0) { if (flags & VIR_MIGRATE_UNDEFINE_SOURCE) { virDomainDeleteConfig(cfg->configDir, cfg->autostartDir, vm); @@ -5414,11 +5449,12 @@ qemuMigrationSrcPerformPhase(virQEMUDriver *driver, goto endjob; =20 endjob: - if (ret < 0) { + if (ret < 0 && !virDomainObjIsFailedPostcopy(vm)) { qemuMigrationParamsReset(driver, vm, VIR_ASYNC_JOB_MIGRATION_OUT, jobPriv->migParams, priv->job.apiFlags); qemuMigrationJobFinish(vm); } else { + qemuDomainCleanupAdd(vm, qemuProcessCleanupMigrationJob); qemuMigrationJobContinue(vm); } =20 @@ -5879,10 +5915,17 @@ qemuMigrationDstFinish(virQEMUDriver *driver, g_clear_pointer(&priv->job.completed, virDomainJobDataFree); } =20 - qemuMigrationParamsReset(driver, vm, VIR_ASYNC_JOB_MIGRATION_IN, - jobPriv->migParams, priv->job.apiFlags); + if (virDomainObjIsFailedPostcopy(vm)) { + qemuProcessAutoDestroyRemove(driver, vm); + qemuDomainCleanupAdd(vm, qemuProcessCleanupMigrationJob); + qemuMigrationJobContinue(vm); + } else { + qemuMigrationParamsReset(driver, vm, VIR_ASYNC_JOB_MIGRATION_IN, + jobPriv->migParams, priv->job.apiFlags); + + qemuMigrationJobFinish(vm); + } =20 - qemuMigrationJobFinish(vm); if (!virDomainObjIsActive(vm)) qemuDomainRemoveInactive(driver, vm); =20 --=20 2.35.1 From nobody Wed May 15 19:27:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1654087941; cv=none; d=zohomail.com; s=zohoarc; b=YlqS2MQvajOECjJsIpl53qLe79Xc3FtBIMRPNzUckF5cTPLiDOD8EGbJEDtg1XJbOfQYuNXcURGUE9UF8/YzHaL6DFU2idFTvJ5Lal6PVueTB8yjPhjs+Ded6xOte4+a0I9IUgsl2V43Qli4jATtYGHjcsRVM10sP3x0V/dpkxU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654087941; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=eOQNI7CqgkrLj3NVpk2oHvTwP5xedwobhCrEUsRPdlA=; b=X70ajw0cSHIij99kp+v9+ifqhmhtsvltDdk/0G2L9BieEw3RvZjjxiYk5LLaRKQvV+qmXOEbrmgZtU7oGr+QDFI9IvegDq3ieX72FPq3xxRoevKzglCAEtd8xybRf1rTwy5LEwcjySlrc+EaQPhsh0AeSrxi8KXaRgx8GAQYgJk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1654087941287890.3665894539803; Wed, 1 Jun 2022 05:52:21 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-503-LliSqDwVOeSXkpy5J70TzQ-1; Wed, 01 Jun 2022 08:50:55 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 85B53180138E; Wed, 1 Jun 2022 12:50:34 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6E6E92026985; Wed, 1 Jun 2022 12:50:34 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 047F51947B97; Wed, 1 Jun 2022 12:50:33 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 008A81947B90 for ; Wed, 1 Jun 2022 12:50:27 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id D01702166B2C; Wed, 1 Jun 2022 12:50:27 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.227]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AF6CD2166B26; Wed, 1 Jun 2022 12:50:27 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 708E0245B59; Wed, 1 Jun 2022 14:50:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654087939; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=eOQNI7CqgkrLj3NVpk2oHvTwP5xedwobhCrEUsRPdlA=; b=KfPZZZmv5t/5PoP4YdiU4iJjVD2Sa869kyAibqvBLKOddcwOrozMCMei9nWHyPwbYJic9d Jzz07IDrHXXNULzTL6sNra/4K6HKyagBwSOAiIxXIEv3vY2KV7ZkyTyG/gHofYbkc5LUu7 JsRmRR8yjdhyc1zSKrpWxI31d7TMSFw= X-MC-Unique: LliSqDwVOeSXkpy5J70TzQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH v2 13/81] qemu: Abort failed post-copy when we haven't called Finish yet Date: Wed, 1 Jun 2022 14:49:13 +0200 Message-Id: <561d30951c81b16743eec1827895b4106c4d0c6a.1654087150.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Krempa , Pavel Hrdina Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1654087942236100001 Content-Type: text/plain; charset="utf-8" When migration fails after it already switched to post-copy phase on the source, but early enough that we haven't called Finish on the destination yet, we know the vCPUs were not started on the destination and the source host still has a complete state of the domain. Thus we can just ignore the fact post-copy phase started and normally abort the migration and resume vCPUs on the source. Signed-off-by: Jiri Denemark Reviewed-by: Peter Krempa Reviewed-by: Pavel Hrdina --- Notes: Version 2: - put debug message on a single line src/qemu/qemu_migration.c | 8 ++++++++ src/qemu/qemu_process.c | 20 ++++++++------------ 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 0daf50d836..06af16c0e7 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -4412,6 +4412,14 @@ qemuMigrationSrcRun(virQEMUDriver *driver, virErrorPreserveLast(&orig_err); =20 if (virDomainObjIsActive(vm)) { + int reason; + virDomainState state =3D virDomainObjGetState(vm, &reason); + + if (state =3D=3D VIR_DOMAIN_PAUSED && reason =3D=3D VIR_DOMAIN_PAU= SED_POSTCOPY) { + VIR_DEBUG("Aborting failed post-copy migration as the destinat= ion is not running yet"); + virDomainObjSetState(vm, state, VIR_DOMAIN_PAUSED_MIGRATION); + } + if (cancel && priv->job.current->status !=3D VIR_DOMAIN_JOB_STATUS_HYPERVISO= R_COMPLETED && qemuDomainObjEnterMonitorAsync(driver, vm, diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index b1725ce4cf..f5a45c898d 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -3483,20 +3483,16 @@ qemuProcessRecoverMigrationOut(virQEMUDriver *drive= r, case QEMU_MIGRATION_PHASE_PERFORM2: case QEMU_MIGRATION_PHASE_PERFORM3: /* migration is still in progress, let's cancel it and resume the - * domain; however we can only do that before migration enters - * post-copy mode + * domain; we can do so even in post-copy phase as the domain was = not + * resumed on the destination host yet */ - if (postcopy) { - qemuMigrationSrcPostcopyFailed(vm); - } else { - VIR_DEBUG("Cancelling unfinished migration of domain %s", - vm->def->name); - if (qemuMigrationSrcCancel(driver, vm) < 0) { - VIR_WARN("Could not cancel ongoing migration of domain %s", - vm->def->name); - } - resume =3D true; + VIR_DEBUG("Cancelling unfinished migration of domain %s", + vm->def->name); + if (qemuMigrationSrcCancel(driver, vm) < 0) { + VIR_WARN("Could not cancel ongoing migration of domain %s", + vm->def->name); } + resume =3D true; break; =20 case QEMU_MIGRATION_PHASE_PERFORM3_DONE: --=20 2.35.1 From nobody Wed May 15 19:27:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1654087988; cv=none; d=zohomail.com; s=zohoarc; b=cz+1u2MefBUa9MabP1y1JsvZwQqiIUAb16KcNMARmJCGQFKxnl7Ry0C+nz35DvvIEj1q/fKJLjfR+Vxt038CXC3hG+24BS9nByZZ8SdghLZZd+9cTUJ+0Zx6Hzn3KlFJcTPT7hgMhcBIiyVrQjEHf/2qi0zEPAjC+6FARAGtY5U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654087988; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=63VtyviKKGdi4TyCuxvoPU+APOPxkSy/y6SFCCCnijo=; b=S9XcczO11KjHWfLbuq4Hv1lZdyPUDC4OrqDIGtVBNXSnXHr+WpP2sf004/saw8CZi0L/Ok09JKeeXy78KdmJ7ms8ie1SJ3nsHEWuwODaDOqeirYJ9k1AGQeuCzVqmIAtjVmcKCqOdMK3349iW0UasvWA8mBKPyJ43GVqu10yrWE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1654087988966728.6748234050826; Wed, 1 Jun 2022 05:53:08 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-596-M1iyJsneNYy4AfN2rkLzPg-1; Wed, 01 Jun 2022 08:51:00 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4BBCF80419C; Wed, 1 Jun 2022 12:50:35 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 31A1340EC005; Wed, 1 Jun 2022 12:50:35 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 6FE22193F6D5; Wed, 1 Jun 2022 12:50:33 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 1ABA21947B95 for ; Wed, 1 Jun 2022 12:50:28 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id E68971410F36; Wed, 1 Jun 2022 12:50:27 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.227]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A9FC71402410; Wed, 1 Jun 2022 12:50:27 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 71F59245B5A; Wed, 1 Jun 2022 14:50:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654087988; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=63VtyviKKGdi4TyCuxvoPU+APOPxkSy/y6SFCCCnijo=; b=AZqiffvQdm4dhXQLiu+vANrLBYCEOkaRaPbuJtblWFAiZv3zv8JPFxq6b9WfDz5845nBro LZm6kuhi2jCcdO1U4JxxeUXABjAQMatOlouVFQ8+ruiYcGhjzr1FLARd1pEQureinwDbcQ 37G4dONJXaYk8QTaMYupiLRTue0P9GQ= X-MC-Unique: M1iyJsneNYy4AfN2rkLzPg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH v2 14/81] qemu: Restore failed migration job on reconnect Date: Wed, 1 Jun 2022 14:49:14 +0200 Message-Id: <8cea42b357c374cc165a57bf0c386c4e16cb1fea.1654087150.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Krempa , Pavel Hrdina Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1654087990462100012 Content-Type: text/plain; charset="utf-8" Since we keep the migration job active when post-copy migration fails, we need to restore it when reconnecting to running domains. Signed-off-by: Jiri Denemark Reviewed-by: Peter Krempa Reviewed-by: Pavel Hrdina --- Notes: Version 2: - no change src/qemu/qemu_process.c | 128 ++++++++++++++++++++++++++++++---------- 1 file changed, 96 insertions(+), 32 deletions(-) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index f5a45c898d..081b049672 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -3385,20 +3385,48 @@ qemuProcessCleanupMigrationJob(virQEMUDriver *drive= r, } =20 =20 +static void +qemuProcessRestoreMigrationJob(virDomainObj *vm, + qemuDomainJobObj *job) +{ + qemuDomainObjPrivate *priv =3D vm->privateData; + qemuDomainJobPrivate *jobPriv =3D job->privateData; + virDomainJobOperation op; + unsigned long long allowedJobs; + + if (job->asyncJob =3D=3D VIR_ASYNC_JOB_MIGRATION_IN) { + op =3D VIR_DOMAIN_JOB_OPERATION_MIGRATION_IN; + allowedJobs =3D VIR_JOB_NONE; + } else { + op =3D VIR_DOMAIN_JOB_OPERATION_MIGRATION_OUT; + allowedJobs =3D VIR_JOB_DEFAULT_MASK | JOB_MASK(VIR_JOB_MIGRATION_= OP); + } + + qemuDomainObjRestoreAsyncJob(vm, job->asyncJob, job->phase, op, + QEMU_DOMAIN_JOB_STATS_TYPE_MIGRATION, + VIR_DOMAIN_JOB_STATUS_PAUSED, + allowedJobs); + + job->privateData =3D g_steal_pointer(&priv->job.privateData); + priv->job.privateData =3D jobPriv; + priv->job.apiFlags =3D job->apiFlags; + + qemuDomainCleanupAdd(vm, qemuProcessCleanupMigrationJob); +} + + +/* + * Returns + * -1 on error, the domain will be killed, + * 0 the domain should remain running with the migration job discarde= d, + * 1 the daemon was restarted during post-copy phase + */ static int qemuProcessRecoverMigrationIn(virQEMUDriver *driver, virDomainObj *vm, - const qemuDomainJobObj *job, - virDomainState state, - int reason) + qemuDomainJobObj *job, + virDomainState state) { - - qemuDomainJobPrivate *jobPriv =3D job->privateData; - bool postcopy =3D (state =3D=3D VIR_DOMAIN_PAUSED && - reason =3D=3D VIR_DOMAIN_PAUSED_POSTCOPY_FAILED) || - (state =3D=3D VIR_DOMAIN_RUNNING && - reason =3D=3D VIR_DOMAIN_RUNNING_POSTCOPY); - VIR_DEBUG("Active incoming migration in phase %s", qemuMigrationJobPhaseTypeToString(job->phase)); =20 @@ -3435,32 +3463,37 @@ qemuProcessRecoverMigrationIn(virQEMUDriver *driver, /* migration finished, we started resuming the domain but didn't * confirm success or failure yet; killing it seems safest unless * we already started guest CPUs or we were in post-copy mode */ - if (postcopy) { + if (virDomainObjIsPostcopy(vm, VIR_DOMAIN_JOB_OPERATION_MIGRATION_= IN)) { qemuMigrationDstPostcopyFailed(vm); - } else if (state !=3D VIR_DOMAIN_RUNNING) { + return 1; + } + + if (state !=3D VIR_DOMAIN_RUNNING) { VIR_DEBUG("Killing migrated domain %s", vm->def->name); return -1; } break; } =20 - qemuMigrationParamsReset(driver, vm, VIR_ASYNC_JOB_NONE, - jobPriv->migParams, job->apiFlags); return 0; } =20 + +/* + * Returns + * -1 on error, the domain will be killed, + * 0 the domain should remain running with the migration job discarde= d, + * 1 the daemon was restarted during post-copy phase + */ static int qemuProcessRecoverMigrationOut(virQEMUDriver *driver, virDomainObj *vm, - const qemuDomainJobObj *job, + qemuDomainJobObj *job, virDomainState state, int reason, unsigned int *stopFlags) { - qemuDomainJobPrivate *jobPriv =3D job->privateData; - bool postcopy =3D state =3D=3D VIR_DOMAIN_PAUSED && - (reason =3D=3D VIR_DOMAIN_PAUSED_POSTCOPY || - reason =3D=3D VIR_DOMAIN_PAUSED_POSTCOPY_FAILED); + bool postcopy =3D virDomainObjIsPostcopy(vm, VIR_DOMAIN_JOB_OPERATION_= MIGRATION_OUT); bool resume =3D false; =20 VIR_DEBUG("Active outgoing migration in phase %s", @@ -3500,8 +3533,10 @@ qemuProcessRecoverMigrationOut(virQEMUDriver *driver, * of Finish3 step; third party needs to check what to do next; in * post-copy mode we can use PAUSED_POSTCOPY_FAILED state for this */ - if (postcopy) + if (postcopy) { qemuMigrationSrcPostcopyFailed(vm); + return 1; + } break; =20 case QEMU_MIGRATION_PHASE_CONFIRM3_CANCELLED: @@ -3511,11 +3546,12 @@ qemuProcessRecoverMigrationOut(virQEMUDriver *drive= r, */ if (postcopy) { qemuMigrationSrcPostcopyFailed(vm); - } else { - VIR_DEBUG("Resuming domain %s after failed migration", - vm->def->name); - resume =3D true; + return 1; } + + VIR_DEBUG("Resuming domain %s after failed migration", + vm->def->name); + resume =3D true; break; =20 case QEMU_MIGRATION_PHASE_CONFIRM3: @@ -3539,15 +3575,49 @@ qemuProcessRecoverMigrationOut(virQEMUDriver *drive= r, } } =20 + return 0; +} + + +static int +qemuProcessRecoverMigration(virQEMUDriver *driver, + virDomainObj *vm, + qemuDomainJobObj *job, + unsigned int *stopFlags) +{ + qemuDomainJobPrivate *jobPriv =3D job->privateData; + virDomainState state; + int reason; + int rc; + + state =3D virDomainObjGetState(vm, &reason); + + if (job->asyncJob =3D=3D VIR_ASYNC_JOB_MIGRATION_OUT) { + rc =3D qemuProcessRecoverMigrationOut(driver, vm, job, + state, reason, stopFlags); + } else { + rc =3D qemuProcessRecoverMigrationIn(driver, vm, job, state); + } + + if (rc < 0) + return -1; + + if (rc > 0) { + qemuProcessRestoreMigrationJob(vm, job); + return 0; + } + qemuMigrationParamsReset(driver, vm, VIR_ASYNC_JOB_NONE, jobPriv->migParams, job->apiFlags); + return 0; } =20 + static int qemuProcessRecoverJob(virQEMUDriver *driver, virDomainObj *vm, - const qemuDomainJobObj *job, + qemuDomainJobObj *job, unsigned int *stopFlags) { qemuDomainObjPrivate *priv =3D vm->privateData; @@ -3565,14 +3635,8 @@ qemuProcessRecoverJob(virQEMUDriver *driver, =20 switch (job->asyncJob) { case VIR_ASYNC_JOB_MIGRATION_OUT: - if (qemuProcessRecoverMigrationOut(driver, vm, job, - state, reason, stopFlags) < 0) - return -1; - break; - case VIR_ASYNC_JOB_MIGRATION_IN: - if (qemuProcessRecoverMigrationIn(driver, vm, job, - state, reason) < 0) + if (qemuProcessRecoverMigration(driver, vm, job, stopFlags) < 0) return -1; break; =20 --=20 2.35.1 From nobody Wed May 15 19:27:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1654087867; cv=none; d=zohomail.com; s=zohoarc; b=XNejWonBBr7GfM4eJd71FjUAeN4Ln/xmz9xu1osDdD9dDTZxPpBS8ECPmMzBWVmSoFEFjwDovtH36xcgTFi8YMgAbril8U/MOoJPVVfjHXkLmtvm05PN4w+QU8+kgDCyYof2CeUa6xTmfrPyb5NH1YJAltTXwPazFT3HGuM5d9o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654087867; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=d675i56TMQqMgvTv9+wfrPBp9ttY0k1k7WClOSbxOQY=; b=JlCsZmDiwDaBvzfC3tRacMo9lugzGqNs3p1R/dfs0wyDPi3uJj3SJSDlCJgJiMg5zhzEfjVeiDjKuO0B5AAm6640oFON04G0KOtjqnZehcJJs4dZpLgJ4+1h7EGCIySWzL9wpqDH3lrU/1oh11HlFuU5cyPGk5IuSIFF+osj8No= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1654087867530409.6114005257889; Wed, 1 Jun 2022 05:51:07 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-191-2IoLbsF3NN6Uf67VJl-eQQ-1; Wed, 01 Jun 2022 08:50:59 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id ED3AD2802E15; Wed, 1 Jun 2022 12:50:37 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id D755840EC007; Wed, 1 Jun 2022 12:50:37 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 52EEA193F6D5; Wed, 1 Jun 2022 12:50:35 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 31512193F6D6 for ; Wed, 1 Jun 2022 12:50:29 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id F3D353323E; Wed, 1 Jun 2022 12:50:28 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.227]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B57DF8288C for ; Wed, 1 Jun 2022 12:50:28 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 734B7245B5B; Wed, 1 Jun 2022 14:50:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654087866; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=d675i56TMQqMgvTv9+wfrPBp9ttY0k1k7WClOSbxOQY=; b=ivTDon2ABH3Eoc+2k2U8ekouW0JwFjyWznc+olQYP4TsyIRBNiXBHr4+/IoBZqJcMq15vK SoV/IDUeCSBs3jeKq63kzV2+corVpDYSKD0Z59KQvWgj47eHqfL7ZtTMss2ogmuEizsjGX jbn5oO0vOQzbgc9+g+M7T+TvhzGGnFQ= X-MC-Unique: 2IoLbsF3NN6Uf67VJl-eQQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH v2 15/81] qemu: Restore async job start timestamp on reconnect Date: Wed, 1 Jun 2022 14:49:15 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1654087868001100004 Content-Type: text/plain; charset="utf-8" Jobs that are supposed to remain active even when libvirt daemon restarts were reported as started at the time the daemon was restarted. This is not very helpful, we should restore the original timestamp. Signed-off-by: Jiri Denemark Reviewed-by: Peter Krempa --- Notes: Version 2: - use current time as a fallback src/qemu/qemu_domainjob.c | 21 ++++++++++++++----- src/qemu/qemu_domainjob.h | 1 + src/qemu/qemu_process.c | 4 +++- .../migration-in-params-in.xml | 2 +- .../migration-out-nbd-bitmaps-in.xml | 2 +- .../migration-out-nbd-out.xml | 2 +- .../migration-out-nbd-tls-out.xml | 2 +- .../migration-out-params-in.xml | 2 +- 8 files changed, 25 insertions(+), 11 deletions(-) diff --git a/src/qemu/qemu_domainjob.c b/src/qemu/qemu_domainjob.c index f85429a7ce..e76eb7f2cf 100644 --- a/src/qemu/qemu_domainjob.c +++ b/src/qemu/qemu_domainjob.c @@ -235,6 +235,7 @@ qemuDomainObjPreserveJob(virDomainObj *obj, job->owner =3D priv->job.owner; job->asyncJob =3D priv->job.asyncJob; job->asyncOwner =3D priv->job.asyncOwner; + job->asyncStarted =3D priv->job.asyncStarted; job->phase =3D priv->job.phase; job->privateData =3D g_steal_pointer(&priv->job.privateData); job->apiFlags =3D priv->job.apiFlags; @@ -254,6 +255,7 @@ void qemuDomainObjRestoreAsyncJob(virDomainObj *vm, virDomainAsyncJob asyncJob, int phase, + unsigned long long started, virDomainJobOperation operation, qemuDomainJobStatsType statsType, virDomainJobStatus status, @@ -261,18 +263,18 @@ qemuDomainObjRestoreAsyncJob(virDomainObj *vm, { qemuDomainObjPrivate *priv =3D vm->privateData; qemuDomainJobObj *job =3D &priv->job; - unsigned long long now; =20 VIR_DEBUG("Restoring %s async job for domain %s", virDomainAsyncJobTypeToString(asyncJob), vm->def->name); =20 - ignore_value(virTimeMillisNow(&now)); + if (started =3D=3D 0) + ignore_value(virTimeMillisNow(&started)); =20 job->jobsQueued++; job->asyncJob =3D asyncJob; job->phase =3D phase; job->asyncOwnerAPI =3D g_strdup(virThreadJobGet()); - job->asyncStarted =3D now; + job->asyncStarted =3D started; =20 qemuDomainObjSetAsyncJobMask(vm, allowedJobs); =20 @@ -280,7 +282,7 @@ qemuDomainObjRestoreAsyncJob(virDomainObj *vm, qemuDomainJobSetStatsType(priv->job.current, statsType); job->current->operation =3D operation; job->current->status =3D status; - job->current->started =3D now; + job->current->started =3D started; } =20 =20 @@ -1250,8 +1252,10 @@ qemuDomainObjPrivateXMLFormatJob(virBuffer *buf, priv->job.phase)= ); } =20 - if (priv->job.asyncJob !=3D VIR_ASYNC_JOB_NONE) + if (priv->job.asyncJob !=3D VIR_ASYNC_JOB_NONE) { virBufferAsprintf(&attrBuf, " flags=3D'0x%lx'", priv->job.apiFlags= ); + virBufferAsprintf(&attrBuf, " asyncStarted=3D'%llu'", priv->job.as= yncStarted); + } =20 if (priv->job.cb && priv->job.cb->formatJob(&childBuf, &priv->job, vm) < 0) @@ -1307,6 +1311,13 @@ qemuDomainObjPrivateXMLParseJob(virDomainObj *vm, } VIR_FREE(tmp); } + + if (virXPathULongLong("string(@asyncStarted)", ctxt, + &priv->job.asyncStarted) =3D=3D -2) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Invalid async job start")); + return -1; + } } =20 if (virXPathULongHex("string(@flags)", ctxt, &priv->job.apiFlags) =3D= =3D -2) { diff --git a/src/qemu/qemu_domainjob.h b/src/qemu/qemu_domainjob.h index 069bb9f8cb..707d4e91ed 100644 --- a/src/qemu/qemu_domainjob.h +++ b/src/qemu/qemu_domainjob.h @@ -164,6 +164,7 @@ void qemuDomainObjRestoreAsyncJob(virDomainObj *vm, virDomainAsyncJob asyncJob, int phase, + unsigned long long started, virDomainJobOperation operation, qemuDomainJobStatsType statsType, virDomainJobStatus status, diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 081b049672..a87dc9a1fb 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -3402,7 +3402,8 @@ qemuProcessRestoreMigrationJob(virDomainObj *vm, allowedJobs =3D VIR_JOB_DEFAULT_MASK | JOB_MASK(VIR_JOB_MIGRATION_= OP); } =20 - qemuDomainObjRestoreAsyncJob(vm, job->asyncJob, job->phase, op, + qemuDomainObjRestoreAsyncJob(vm, job->asyncJob, job->phase, + job->asyncStarted, op, QEMU_DOMAIN_JOB_STATS_TYPE_MIGRATION, VIR_DOMAIN_JOB_STATUS_PAUSED, allowedJobs); @@ -3675,6 +3676,7 @@ qemuProcessRecoverJob(virQEMUDriver *driver, case VIR_ASYNC_JOB_BACKUP: /* Restore the config of the async job which is not persisted */ qemuDomainObjRestoreAsyncJob(vm, VIR_ASYNC_JOB_BACKUP, 0, + job->asyncStarted, VIR_DOMAIN_JOB_OPERATION_BACKUP, QEMU_DOMAIN_JOB_STATS_TYPE_BACKUP, VIR_DOMAIN_JOB_STATUS_ACTIVE, diff --git a/tests/qemustatusxml2xmldata/migration-in-params-in.xml b/tests= /qemustatusxml2xmldata/migration-in-params-in.xml index 8b0878c82e..1086f5230d 100644 --- a/tests/qemustatusxml2xmldata/migration-in-params-in.xml +++ b/tests/qemustatusxml2xmldata/migration-in-params-in.xml @@ -238,7 +238,7 @@ - + diff --git a/tests/qemustatusxml2xmldata/migration-out-nbd-bitmaps-in.xml b= /tests/qemustatusxml2xmldata/migration-out-nbd-bitmaps-in.xml index 7d55db0996..4ee44ffbd4 100644 --- a/tests/qemustatusxml2xmldata/migration-out-nbd-bitmaps-in.xml +++ b/tests/qemustatusxml2xmldata/migration-out-nbd-bitmaps-in.xml @@ -262,7 +262,7 @@ - + diff --git a/tests/qemustatusxml2xmldata/migration-out-nbd-out.xml b/tests/= qemustatusxml2xmldata/migration-out-nbd-out.xml index 1a918c0b5a..540e385de3 100644 --- a/tests/qemustatusxml2xmldata/migration-out-nbd-out.xml +++ b/tests/qemustatusxml2xmldata/migration-out-nbd-out.xml @@ -231,7 +231,7 @@ - + diff --git a/tests/qemustatusxml2xmldata/migration-out-nbd-tls-out.xml b/te= sts/qemustatusxml2xmldata/migration-out-nbd-tls-out.xml index 87c67f8300..d0e997913f 100644 --- a/tests/qemustatusxml2xmldata/migration-out-nbd-tls-out.xml +++ b/tests/qemustatusxml2xmldata/migration-out-nbd-tls-out.xml @@ -235,7 +235,7 @@ - + diff --git a/tests/qemustatusxml2xmldata/migration-out-params-in.xml b/test= s/qemustatusxml2xmldata/migration-out-params-in.xml index 73ac09fb92..758a6f03b7 100644 --- a/tests/qemustatusxml2xmldata/migration-out-params-in.xml +++ b/tests/qemustatusxml2xmldata/migration-out-params-in.xml @@ -238,7 +238,7 @@ - + --=20 2.35.1 From nobody Wed May 15 19:27:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1654087894; cv=none; d=zohomail.com; s=zohoarc; b=FXY0y/zyUL6dq/d2rqJhoV6AN4nE9hE2E2gRnsXxTrsXSbm/iiaAdJ8FtkGFwdizhfBgg6p8Reghvn3xl7bekMB0ccoYN5iu2PkjqZfYNnt050WAhklBzdquYIsQCdN72SxShGNF/6s4Y1qLwCBXPrhH8xJTkH38d0YiCptCIBE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654087894; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=m72NfIUz5+qzL4nPhL3iKsCyhRucINxM+YG3E5tIC+g=; b=MyEEHQV0NzUcv5NYyjAwvn98GVgYIhgIZ//dE4xdf3qJPYyHS2PE89X8iXFrM8ac1jOciy0VXAHyGoc69EsPy8WRjQ2uf8Tpg1y/ePP5RbV6I874cqW4VZ3PQjPPfq6zhecDcyceUjgCYGZRKNF5jfplDCkxLzN6nUt5B7npiok= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1654087894323252.70543421589707; Wed, 1 Jun 2022 05:51:34 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-261-xtDPMMTvPdqNymFlCcwADA-1; Wed, 01 Jun 2022 08:51:28 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8B0C93802BB9; Wed, 1 Jun 2022 12:50:44 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 741671731B; Wed, 1 Jun 2022 12:50:44 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 6B7001947BAD; Wed, 1 Jun 2022 12:50:41 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 36194194E102 for ; Wed, 1 Jun 2022 12:50:29 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 016F52026987; Wed, 1 Jun 2022 12:50:29 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.227]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B7DA62026D07; Wed, 1 Jun 2022 12:50:28 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 74A00245B5C; Wed, 1 Jun 2022 14:50:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654087892; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=m72NfIUz5+qzL4nPhL3iKsCyhRucINxM+YG3E5tIC+g=; b=X9BtLAPNiKQbdt/a/d+Jq/rEi/dxUZ2fppjmLGl0WTQ9MBIWbIDl0CuH2EFwAVpX4NJNFR ACd5QrTZ0p1GXFoSTnkEXOWB0EPfnx5DF8WuXsml3NFd2tFMExfFtg93rusUqPIvT6k1nX +uG28addPChBwRnn4NnAOKwK4alvGsc= X-MC-Unique: xtDPMMTvPdqNymFlCcwADA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH v2 16/81] qemu: Drop forward declarations in migration code Date: Wed, 1 Jun 2022 14:49:16 +0200 Message-Id: <019b111a81ab1fbee227937776b766e373800423.1654087150.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Krempa , Pavel Hrdina Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1654087895986100007 Content-Type: text/plain; charset="utf-8" Signed-off-by: Jiri Denemark Reviewed-by: Peter Krempa Reviewed-by: Pavel Hrdina --- Notes: Version 2: - no change src/qemu/qemu_migration.c | 176 ++++++++++++++++---------------------- 1 file changed, 76 insertions(+), 100 deletions(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 06af16c0e7..b9a8326fbb 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -81,35 +81,97 @@ VIR_ENUM_IMPL(qemuMigrationJobPhase, "finish3", ); =20 -static int + +static int ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RE= SULT qemuMigrationJobStart(virQEMUDriver *driver, virDomainObj *vm, virDomainAsyncJob job, unsigned long apiFlags) - ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT; +{ + qemuDomainObjPrivate *priv =3D vm->privateData; + virDomainJobOperation op; + unsigned long long mask; =20 -static void + if (job =3D=3D VIR_ASYNC_JOB_MIGRATION_IN) { + op =3D VIR_DOMAIN_JOB_OPERATION_MIGRATION_IN; + mask =3D VIR_JOB_NONE; + } else { + op =3D VIR_DOMAIN_JOB_OPERATION_MIGRATION_OUT; + mask =3D VIR_JOB_DEFAULT_MASK | + JOB_MASK(VIR_JOB_SUSPEND) | + JOB_MASK(VIR_JOB_MIGRATION_OP); + } + + if (qemuDomainObjBeginAsyncJob(driver, vm, job, op, apiFlags) < 0) + return -1; + + qemuDomainJobSetStatsType(priv->job.current, + QEMU_DOMAIN_JOB_STATS_TYPE_MIGRATION); + + qemuDomainObjSetAsyncJobMask(vm, mask); + return 0; +} + + +static void ATTRIBUTE_NONNULL(1) qemuMigrationJobSetPhase(virDomainObj *vm, qemuMigrationJobPhase phase) - ATTRIBUTE_NONNULL(1); +{ + qemuDomainObjPrivate *priv =3D vm->privateData; =20 -static void + if (phase < priv->job.phase) { + VIR_ERROR(_("migration protocol going backwards %s =3D> %s"), + qemuMigrationJobPhaseTypeToString(priv->job.phase), + qemuMigrationJobPhaseTypeToString(phase)); + return; + } + + qemuDomainObjSetJobPhase(vm, phase); +} + + +static void ATTRIBUTE_NONNULL(1) qemuMigrationJobStartPhase(virDomainObj *vm, qemuMigrationJobPhase phase) - ATTRIBUTE_NONNULL(1); +{ + qemuMigrationJobSetPhase(vm, phase); +} =20 -static void -qemuMigrationJobContinue(virDomainObj *obj) - ATTRIBUTE_NONNULL(1); =20 -static bool +static void ATTRIBUTE_NONNULL(1) +qemuMigrationJobContinue(virDomainObj *vm) +{ + qemuDomainObjReleaseAsyncJob(vm); +} + + +static bool ATTRIBUTE_NONNULL(1) qemuMigrationJobIsActive(virDomainObj *vm, virDomainAsyncJob job) - ATTRIBUTE_NONNULL(1); +{ + qemuDomainObjPrivate *priv =3D vm->privateData; + + if (priv->job.asyncJob !=3D job) { + const char *msg; + + if (job =3D=3D VIR_ASYNC_JOB_MIGRATION_IN) + msg =3D _("domain '%s' is not processing incoming migration"); + else + msg =3D _("domain '%s' is not being migrated"); + + virReportError(VIR_ERR_OPERATION_INVALID, msg, vm->def->name); + return false; + } + return true; +} + + +static void ATTRIBUTE_NONNULL(1) +qemuMigrationJobFinish(virDomainObj *vm) +{ + qemuDomainObjEndAsyncJob(vm); +} =20 -static void -qemuMigrationJobFinish(virDomainObj *obj) - ATTRIBUTE_NONNULL(1); =20 static void qemuMigrationSrcStoreDomainState(virDomainObj *vm) @@ -6149,92 +6211,6 @@ qemuMigrationSrcCancel(virQEMUDriver *driver, } =20 =20 -static int -qemuMigrationJobStart(virQEMUDriver *driver, - virDomainObj *vm, - virDomainAsyncJob job, - unsigned long apiFlags) -{ - qemuDomainObjPrivate *priv =3D vm->privateData; - virDomainJobOperation op; - unsigned long long mask; - - if (job =3D=3D VIR_ASYNC_JOB_MIGRATION_IN) { - op =3D VIR_DOMAIN_JOB_OPERATION_MIGRATION_IN; - mask =3D VIR_JOB_NONE; - } else { - op =3D VIR_DOMAIN_JOB_OPERATION_MIGRATION_OUT; - mask =3D VIR_JOB_DEFAULT_MASK | - JOB_MASK(VIR_JOB_SUSPEND) | - JOB_MASK(VIR_JOB_MIGRATION_OP); - } - - if (qemuDomainObjBeginAsyncJob(driver, vm, job, op, apiFlags) < 0) - return -1; - - qemuDomainJobSetStatsType(priv->job.current, - QEMU_DOMAIN_JOB_STATS_TYPE_MIGRATION); - - qemuDomainObjSetAsyncJobMask(vm, mask); - return 0; -} - -static void -qemuMigrationJobSetPhase(virDomainObj *vm, - qemuMigrationJobPhase phase) -{ - qemuDomainObjPrivate *priv =3D vm->privateData; - - if (phase < priv->job.phase) { - VIR_ERROR(_("migration protocol going backwards %s =3D> %s"), - qemuMigrationJobPhaseTypeToString(priv->job.phase), - qemuMigrationJobPhaseTypeToString(phase)); - return; - } - - qemuDomainObjSetJobPhase(vm, phase); -} - -static void -qemuMigrationJobStartPhase(virDomainObj *vm, - qemuMigrationJobPhase phase) -{ - qemuMigrationJobSetPhase(vm, phase); -} - -static void -qemuMigrationJobContinue(virDomainObj *vm) -{ - qemuDomainObjReleaseAsyncJob(vm); -} - -static bool -qemuMigrationJobIsActive(virDomainObj *vm, - virDomainAsyncJob job) -{ - qemuDomainObjPrivate *priv =3D vm->privateData; - - if (priv->job.asyncJob !=3D job) { - const char *msg; - - if (job =3D=3D VIR_ASYNC_JOB_MIGRATION_IN) - msg =3D _("domain '%s' is not processing incoming migration"); - else - msg =3D _("domain '%s' is not being migrated"); - - virReportError(VIR_ERR_OPERATION_INVALID, msg, vm->def->name); - return false; - } - return true; -} - -static void -qemuMigrationJobFinish(virDomainObj *vm) -{ - qemuDomainObjEndAsyncJob(vm); -} - - static void qemuMigrationDstErrorFree(void *data) { --=20 2.35.1 From nobody Wed May 15 19:27:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1654087926; cv=none; d=zohomail.com; s=zohoarc; b=JAOMrtVeBTgE6X6mJ8aIzOvDZWNGCuMLLyV4WWO72BZXvuK3dMHJ8w9DVQr8NYFvk/ilYfP5I7TO9Iy1+qpzfIMxT7TAAU39tb7qwH8GTb5jhNEDZaWr/ajx3naI3mxvv8SWf6szG5AKnZlB5XOKCWWZDeuMjlSqpLp9nIt6MZY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654087926; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=VKNytyJQAlIhrz8HMoQgWXFSqiSQ99Bg1TrRNtNcs0s=; b=k8FFZ/9pATbJv5jOfCgeiwucd0Ia8g6D71wXtEBuySSbeX4CPb3UXIcXYETputx9qzBTO9Aji2x2Z8LQINXeQiTqY5WPkQPw7zTpEl27u3v+kfeThyUbruCoaJG5v3Ki0fBucXMx8c+YgxaIP0YP4EWaTpdHYmcRx3Z/d2Ae+8g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1654087925995967.286864431275; Wed, 1 Jun 2022 05:52:05 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-100-xaM0FuLyM56F_3x1HYbCiQ-1; Wed, 01 Jun 2022 08:51:34 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E33843AF42B1; Wed, 1 Jun 2022 12:50:42 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id CC97C1731B; Wed, 1 Jun 2022 12:50:42 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 7D3A6193769E; Wed, 1 Jun 2022 12:50:39 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id E803E193F6F3 for ; Wed, 1 Jun 2022 12:50:28 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id D70AE40CFD0A; Wed, 1 Jun 2022 12:50:28 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.227]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B1F8340CFD0B; Wed, 1 Jun 2022 12:50:28 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 75ED1245B5D; Wed, 1 Jun 2022 14:50:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654087924; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=VKNytyJQAlIhrz8HMoQgWXFSqiSQ99Bg1TrRNtNcs0s=; b=JLOfc/juYTzcwOn3XBW/88z1k0ljxUpC8sCERvQ+uUdM6PL3eZqcgZl0wKkdbwmYHtOhv9 2pKK6JqLQ1zYUCS1BRFhT2ZqUZEbreJGg15KQWJ6r+hu7g9HSeB3S71k5HMFgtzICJlrGs aMOg48inkO9wHcpEWpL9QuNsc/2ZRIY= X-MC-Unique: xaM0FuLyM56F_3x1HYbCiQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH v2 17/81] qemu: Don't wait for migration job when migration is running Date: Wed, 1 Jun 2022 14:49:17 +0200 Message-Id: <1f57ec2d8514baee34968cbddfeedc2151fe9636.1654087150.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Krempa , Pavel Hrdina Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1654087928126100002 Content-Type: text/plain; charset="utf-8" Migration is a job which takes some time and if it succeeds, there's nothing to call another migration on. If a migration fails, it might make sense to rerun it with different arguments, but this would only be done once the first migration fails rather than while it is still running. If this was not enough, the migration job now stays active even if post-copy migration fails and anyone possibly retrying the migration would be waiting for the job timeout just to get a suboptimal error message. So let's special case getting a migration job when another one is already active. Signed-off-by: Jiri Denemark Reviewed-by: Peter Krempa Reviewed-by: Pavel Hrdina --- Notes: Version 2: - no change src/qemu/qemu_migration.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index b9a8326fbb..f81d1e65ff 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -82,6 +82,23 @@ VIR_ENUM_IMPL(qemuMigrationJobPhase, ); =20 =20 +static bool ATTRIBUTE_NONNULL(1) +qemuMigrationJobIsAllowed(virDomainObj *vm) +{ + qemuDomainObjPrivate *priv =3D vm->privateData; + + if (priv->job.asyncJob =3D=3D VIR_ASYNC_JOB_MIGRATION_IN || + priv->job.asyncJob =3D=3D VIR_ASYNC_JOB_MIGRATION_OUT) { + virReportError(VIR_ERR_OPERATION_INVALID, + _("another migration job is already running for dom= ain '%s'"), + vm->def->name); + return false; + } + + return true; +} + + static int ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RE= SULT qemuMigrationJobStart(virQEMUDriver *driver, virDomainObj *vm, @@ -92,6 +109,9 @@ qemuMigrationJobStart(virQEMUDriver *driver, virDomainJobOperation op; unsigned long long mask; =20 + if (!qemuMigrationJobIsAllowed(vm)) + return -1; + if (job =3D=3D VIR_ASYNC_JOB_MIGRATION_IN) { op =3D VIR_DOMAIN_JOB_OPERATION_MIGRATION_IN; mask =3D VIR_JOB_NONE; @@ -2602,6 +2622,9 @@ qemuMigrationSrcBegin(virConnectPtr conn, goto cleanup; asyncJob =3D VIR_ASYNC_JOB_MIGRATION_OUT; } else { + if (!qemuMigrationJobIsAllowed(vm)) + goto cleanup; + if (qemuDomainObjBeginJob(driver, vm, VIR_JOB_MODIFY) < 0) goto cleanup; asyncJob =3D VIR_ASYNC_JOB_NONE; --=20 2.35.1 From nobody Wed May 15 19:27:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1654088042; cv=none; d=zohomail.com; s=zohoarc; b=lTfl9ztOCfAuL6pcS3Xqj1gcS61Hb0dFYFE94A8+kBe51mEnUo/3AtiqSBkziAsYKhw77n/iZ5A631aGGfXEmMfzhUISN/qJlyu3QyeIsxVQ69lGcfyyLmPKWopYu0/CMt2UyLRoGaI0OvQHl0K+GdP9yf5cRTuRriVquqi6JDU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654088042; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=WC2fIiDUkUtZoDHA9BAcCPaL99gE1sjz4dSMWI1Jdp4=; b=fQ2zGq9Y1777GgssHpoq5JLmTB/uwRS+RbvsEbnVfHh/bqJiNYnX186e2mitKkVaqqVZm4Jlq0iK3kbJnbyQPi0wqegOvubbZ/P77tbzSJOXMHLmxYCTA/3Rd/CABcT/6HEHFitn7eUgTw/x0G8JSzY+kz8riFuIuIvhFNVuPG8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1654088042943656.6148518344746; Wed, 1 Jun 2022 05:54:02 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-30-2K7ZTB-6NbKjwTBx8gUHzQ-1; Wed, 01 Jun 2022 08:51:33 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E09AB108C1E6; Wed, 1 Jun 2022 12:50:37 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id C55253323E; Wed, 1 Jun 2022 12:50:37 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 6CA9C1932201; Wed, 1 Jun 2022 12:50:35 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id E3DDB193F6D5 for ; Wed, 1 Jun 2022 12:50:28 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id D2FF44011960; Wed, 1 Jun 2022 12:50:28 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.227]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B166940CFD0A; Wed, 1 Jun 2022 12:50:28 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 77501245B5E; Wed, 1 Jun 2022 14:50:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654088041; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=WC2fIiDUkUtZoDHA9BAcCPaL99gE1sjz4dSMWI1Jdp4=; b=dy4N/ZrSTiISMGJjtiwYsNduLYsnlCVhpM/ZWdwxW516tHaj2JlHn3K04cYSoSvhjVJF/f f7N44VzDIVaFRpkLN2/DDpg9+Jy5VCnYJfYhvepQhxb4FAf+uSetLmVF8BY9rSTgyoV+7r vEi4XSksCqDXbR3OPmtrmyN5vYhFWog= X-MC-Unique: 2K7ZTB-6NbKjwTBx8gUHzQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH v2 18/81] qemu: Fetch paused migration stats Date: Wed, 1 Jun 2022 14:49:18 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Krempa , Pavel Hrdina Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1654088044698100001 Content-Type: text/plain; charset="utf-8" Even though a migration is paused, we still want to see the amount of data transferred so far and that the migration is indeed not progressing any further. Signed-off-by: Jiri Denemark Reviewed-by: Peter Krempa Reviewed-by: Pavel Hrdina --- Notes: Version 2: - rebased on top of "qemu: Drop QEMU_CAPS_MIGRATION_EVENT" series src/qemu/qemu_driver.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index d3ba74c14a..4f9eb7b987 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -12539,13 +12539,13 @@ qemuDomainGetJobInfoMigrationStats(virQEMUDriver = *driver, case VIR_DOMAIN_JOB_STATUS_MIGRATING: case VIR_DOMAIN_JOB_STATUS_HYPERVISOR_COMPLETED: case VIR_DOMAIN_JOB_STATUS_POSTCOPY: + case VIR_DOMAIN_JOB_STATUS_PAUSED: if (qemuMigrationAnyFetchStats(driver, vm, VIR_ASYNC_JOB_NONE, jobData, NULL) < 0) return -1; break; =20 case VIR_DOMAIN_JOB_STATUS_NONE: - case VIR_DOMAIN_JOB_STATUS_PAUSED: case VIR_DOMAIN_JOB_STATUS_COMPLETED: case VIR_DOMAIN_JOB_STATUS_FAILED: case VIR_DOMAIN_JOB_STATUS_CANCELED: --=20 2.35.1 From nobody Wed May 15 19:27:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1654087986; cv=none; d=zohomail.com; s=zohoarc; b=NK1jqw4gkDi54iwX/MXDUe7zUr2zk17zCPb98q+2eitseWNMvJWsvWS3bBGHGBpvlFcXr4q4rGYdjgWexE1gO1nnRauba59KnvDOf3fN8EhNUwMvrMC7vtyB9+X6JtHuVbbE36CoqaqXPNpdBqwZ8J+MWZgLGLraQR13VIct2rQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654087986; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=mBxbcFKWDlJXaaFebSOdT5bDptCc3TuCpyaPW/o4PSs=; b=K3eyyV7/F5vmPjRP1o53swqlwvu/56HgUZpC+BiIxFVt4s1thclcbkb6LzHAJmTjHYZEvOvHEhXRMo4HRZTEoi49tKWfiSFP8qgzGFSe+W0qgYBjQ01vZZkeIXCRnOrtAfBSQoCBi97jB7mg7OHCFUZG0M7nj+NuUbkwfbHJcWU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1654087986727538.6472420389284; Wed, 1 Jun 2022 05:53:06 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-93--ksYDNKINWioDOYIuETQng-1; Wed, 01 Jun 2022 08:51:00 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3C68580CC5B; Wed, 1 Jun 2022 12:50:37 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 28B3F492C3B; Wed, 1 Jun 2022 12:50:37 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id E23AA1947BA4; Wed, 1 Jun 2022 12:50:34 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id E336A193F6C8 for ; Wed, 1 Jun 2022 12:50:28 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id D36DC40CFD0D; Wed, 1 Jun 2022 12:50:28 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.227]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B11F140CF8EB for ; Wed, 1 Jun 2022 12:50:28 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 789A5245B5F; Wed, 1 Jun 2022 14:50:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654087985; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=mBxbcFKWDlJXaaFebSOdT5bDptCc3TuCpyaPW/o4PSs=; b=hFDVejZXMTQ2Fs+0BGKpXCHVz3J7DqjxA8XKAuDPfTzvmK1ZK57EF2/1THRhwkxalzeeMS CTaf6Upo/DZNRn0uFzpq+RYEFjH5urIqgJPkOI44I2CkbGEYIhu1EkCaC90hvpibRfETeQ yWAHY+3xL44BKnlE5kOU/vAsWIvTXpU= X-MC-Unique: -ksYDNKINWioDOYIuETQng-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH v2 19/81] qemu: Use switch in qemuProcessHandleMigrationStatus Date: Wed, 1 Jun 2022 14:49:19 +0200 Message-Id: <1af895565f2fdb76f2366711e0950ab7d56f66f7.1654087150.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1654087988373100005 Content-Type: text/plain; charset="utf-8" Signed-off-by: Jiri Denemark Reviewed-by: Peter Krempa --- Notes: Version 2: - new patch src/qemu/qemu_process.c | 44 ++++++++++++++++++++++++++++++----------- 1 file changed, 32 insertions(+), 12 deletions(-) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index a87dc9a1fb..f1264909de 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -1472,6 +1472,7 @@ qemuProcessHandleMigrationStatus(qemuMonitor *mon G_G= NUC_UNUSED, qemuDomainJobDataPrivate *privJob =3D NULL; virQEMUDriver *driver; virObjectEvent *event =3D NULL; + virDomainState state; int reason; =20 virObjectLock(vm); @@ -1493,19 +1494,38 @@ qemuProcessHandleMigrationStatus(qemuMonitor *mon G= _GNUC_UNUSED, privJob->stats.mig.status =3D status; virDomainObjBroadcast(vm); =20 - if (status =3D=3D QEMU_MONITOR_MIGRATION_STATUS_POSTCOPY && - priv->job.asyncJob =3D=3D VIR_ASYNC_JOB_MIGRATION_OUT && - virDomainObjGetState(vm, &reason) =3D=3D VIR_DOMAIN_PAUSED && - reason =3D=3D VIR_DOMAIN_PAUSED_MIGRATION) { - VIR_DEBUG("Correcting paused state reason for domain %s to %s", - vm->def->name, - virDomainPausedReasonTypeToString(VIR_DOMAIN_PAUSED_POST= COPY)); + state =3D virDomainObjGetState(vm, &reason); =20 - virDomainObjSetState(vm, VIR_DOMAIN_PAUSED, VIR_DOMAIN_PAUSED_POST= COPY); - event =3D virDomainEventLifecycleNewFromObj(vm, - VIR_DOMAIN_EVENT_SUSPEND= ED, - VIR_DOMAIN_EVENT_SUSPEND= ED_POSTCOPY); - qemuDomainSaveStatus(vm); + switch ((qemuMonitorMigrationStatus) status) { + case QEMU_MONITOR_MIGRATION_STATUS_POSTCOPY: + if (priv->job.asyncJob =3D=3D VIR_ASYNC_JOB_MIGRATION_OUT && + state =3D=3D VIR_DOMAIN_PAUSED && + reason =3D=3D VIR_DOMAIN_PAUSED_MIGRATION) { + VIR_DEBUG("Correcting paused state reason for domain %s to %s", + vm->def->name, + virDomainPausedReasonTypeToString(VIR_DOMAIN_PAUSED_= POSTCOPY)); + + virDomainObjSetState(vm, VIR_DOMAIN_PAUSED, VIR_DOMAIN_PAUSED_= POSTCOPY); + event =3D virDomainEventLifecycleNewFromObj(vm, + VIR_DOMAIN_EVENT_SUS= PENDED, + VIR_DOMAIN_EVENT_SUS= PENDED_POSTCOPY); + qemuDomainSaveStatus(vm); + } + break; + + case QEMU_MONITOR_MIGRATION_STATUS_INACTIVE: + case QEMU_MONITOR_MIGRATION_STATUS_SETUP: + case QEMU_MONITOR_MIGRATION_STATUS_ACTIVE: + case QEMU_MONITOR_MIGRATION_STATUS_PRE_SWITCHOVER: + case QEMU_MONITOR_MIGRATION_STATUS_DEVICE: + case QEMU_MONITOR_MIGRATION_STATUS_COMPLETED: + case QEMU_MONITOR_MIGRATION_STATUS_ERROR: + case QEMU_MONITOR_MIGRATION_STATUS_CANCELLING: + case QEMU_MONITOR_MIGRATION_STATUS_CANCELLED: + case QEMU_MONITOR_MIGRATION_STATUS_WAIT_UNPLUG: + case QEMU_MONITOR_MIGRATION_STATUS_LAST: + default: + break; } =20 cleanup: --=20 2.35.1 From nobody Wed May 15 19:27:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1654087923; cv=none; d=zohomail.com; s=zohoarc; b=kgdk1tAnTHCppH7NgHPmYsDIcgCiQfevVUeIMLO4mdEuml05EC7CSoQ5n7xyQ0sEF1gfXjvLyRt2CXOvOqBPN+3DHhov0sq47Z368TbI1zAJU9hlxEllT606jfs5Zp2IYAYu1nqLKYWesoxN8i9Y8eNT5RrQZY6d7dpD52uLOlA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654087923; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=wsGoOx+L4jv5WEUOCSpuDxxhNj4kTHsRSeK/JEq2UOc=; b=PEsxQgMBzu4Kp+Hod74AvmDEOMn6O3uYLOAGaLy/T14dmIq3Xov33/J0oIewZ7+Ik7RiuZTR5RQW1dKvSI9xTqBwrbeYh+hYAfVCJr9FfIyld5Z3XTkYjogQ8fmCZmb3TZ+mq9/uZ3r8ZIBzGwMQpwWgY/L2aYliZBOzxKgvpWk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1654087923036549.8853817762374; Wed, 1 Jun 2022 05:52:03 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-624-oMe1BREdPK2kQZLLJtpIRg-1; Wed, 01 Jun 2022 08:51:05 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DEF0A8339C9; Wed, 1 Jun 2022 12:50:35 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id CAF72140EBD5; Wed, 1 Jun 2022 12:50:35 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id C4B331955EC1; Wed, 1 Jun 2022 12:50:33 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 2F877193F6F5 for ; Wed, 1 Jun 2022 12:50:29 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id EEAFD492CA3; Wed, 1 Jun 2022 12:50:28 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.227]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B2CA5492C3B for ; Wed, 1 Jun 2022 12:50:28 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 79F5C245B60; Wed, 1 Jun 2022 14:50:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654087922; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=wsGoOx+L4jv5WEUOCSpuDxxhNj4kTHsRSeK/JEq2UOc=; b=LI7CFEDc8Ja0bV+cyUD0DnIxpRKfBvXY7gffczBHJ9fBas68L4qmaEuBG9JJIQICgaY2rf dgRrqK9yhtlf9VmOney83mTkvCpwpyGLIv4wRlqBEeE0linAAXOCClBRLo6eB6Tn3jtOlY JYUitxpvwzUvqzT4fBHFvFFstcR4Ock= X-MC-Unique: oMe1BREdPK2kQZLLJtpIRg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH v2 20/81] qemu: Handle 'postcopy-paused' migration state Date: Wed, 1 Jun 2022 14:49:20 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1654087924102100001 Content-Type: text/plain; charset="utf-8" When connection breaks during post-copy migration, QEMU enters 'postcopy-paused' state. We need to handle this state and make the situation visible to upper layers. Signed-off-by: Jiri Denemark Reviewed-by: Peter Krempa --- Notes: Version 2: - rebased on top of newly added "qemu: Use switch in qemuProcessHandleMigrationStatus" src/hypervisor/domain_job.c | 1 + src/hypervisor/domain_job.h | 1 + src/qemu/qemu_driver.c | 1 + src/qemu/qemu_migration.c | 11 +++++++++++ src/qemu/qemu_monitor.c | 1 + src/qemu/qemu_monitor.h | 1 + src/qemu/qemu_monitor_json.c | 1 + src/qemu/qemu_process.c | 11 +++++++++++ 8 files changed, 28 insertions(+) diff --git a/src/hypervisor/domain_job.c b/src/hypervisor/domain_job.c index ff4e008cb5..49867c3982 100644 --- a/src/hypervisor/domain_job.c +++ b/src/hypervisor/domain_job.c @@ -93,6 +93,7 @@ virDomainJobStatusToType(virDomainJobStatus status) case VIR_DOMAIN_JOB_STATUS_MIGRATING: case VIR_DOMAIN_JOB_STATUS_HYPERVISOR_COMPLETED: case VIR_DOMAIN_JOB_STATUS_POSTCOPY: + case VIR_DOMAIN_JOB_STATUS_POSTCOPY_PAUSED: case VIR_DOMAIN_JOB_STATUS_PAUSED: return VIR_DOMAIN_JOB_UNBOUNDED; =20 diff --git a/src/hypervisor/domain_job.h b/src/hypervisor/domain_job.h index db8b8b1390..fce35ffbf5 100644 --- a/src/hypervisor/domain_job.h +++ b/src/hypervisor/domain_job.h @@ -78,6 +78,7 @@ typedef enum { VIR_DOMAIN_JOB_STATUS_HYPERVISOR_COMPLETED, VIR_DOMAIN_JOB_STATUS_PAUSED, VIR_DOMAIN_JOB_STATUS_POSTCOPY, + VIR_DOMAIN_JOB_STATUS_POSTCOPY_PAUSED, VIR_DOMAIN_JOB_STATUS_COMPLETED, VIR_DOMAIN_JOB_STATUS_FAILED, VIR_DOMAIN_JOB_STATUS_CANCELED, diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 4f9eb7b987..28cb454ab7 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -12540,6 +12540,7 @@ qemuDomainGetJobInfoMigrationStats(virQEMUDriver *d= river, case VIR_DOMAIN_JOB_STATUS_HYPERVISOR_COMPLETED: case VIR_DOMAIN_JOB_STATUS_POSTCOPY: case VIR_DOMAIN_JOB_STATUS_PAUSED: + case VIR_DOMAIN_JOB_STATUS_POSTCOPY_PAUSED: if (qemuMigrationAnyFetchStats(driver, vm, VIR_ASYNC_JOB_NONE, jobData, NULL) < 0) return -1; diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index f81d1e65ff..de4be0e7f9 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -1747,6 +1747,10 @@ qemuMigrationUpdateJobType(virDomainJobData *jobData) jobData->status =3D VIR_DOMAIN_JOB_STATUS_POSTCOPY; break; =20 + case QEMU_MONITOR_MIGRATION_STATUS_POSTCOPY_PAUSED: + jobData->status =3D VIR_DOMAIN_JOB_STATUS_POSTCOPY_PAUSED; + break; + case QEMU_MONITOR_MIGRATION_STATUS_COMPLETED: jobData->status =3D VIR_DOMAIN_JOB_STATUS_HYPERVISOR_COMPLETED; break; @@ -1871,6 +1875,12 @@ qemuMigrationJobCheckStatus(virQEMUDriver *driver, qemuMigrationJobName(vm), _("canceled by client")); return -1; =20 + case VIR_DOMAIN_JOB_STATUS_POSTCOPY_PAUSED: + virReportError(VIR_ERR_OPERATION_FAILED, _("%s: %s"), + qemuMigrationJobName(vm), + _("post-copy phase failed")); + return -1; + case VIR_DOMAIN_JOB_STATUS_COMPLETED: case VIR_DOMAIN_JOB_STATUS_ACTIVE: case VIR_DOMAIN_JOB_STATUS_MIGRATING: @@ -1973,6 +1983,7 @@ qemuMigrationAnyCompleted(virQEMUDriver *driver, =20 case VIR_DOMAIN_JOB_STATUS_FAILED: case VIR_DOMAIN_JOB_STATUS_CANCELED: + case VIR_DOMAIN_JOB_STATUS_POSTCOPY_PAUSED: /* QEMU aborted the migration. */ return -1; =20 diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 2cfe9dbb00..8d0f54e4a0 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -149,6 +149,7 @@ VIR_ENUM_IMPL(qemuMonitorMigrationStatus, "inactive", "setup", "active", "pre-switchover", "device", "postcopy-active", + "postcopy-paused", "completed", "failed", "cancelling", "cancelled", "wait-unplug", diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index be341d5196..90532962fe 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -795,6 +795,7 @@ typedef enum { QEMU_MONITOR_MIGRATION_STATUS_PRE_SWITCHOVER, QEMU_MONITOR_MIGRATION_STATUS_DEVICE, QEMU_MONITOR_MIGRATION_STATUS_POSTCOPY, + QEMU_MONITOR_MIGRATION_STATUS_POSTCOPY_PAUSED, QEMU_MONITOR_MIGRATION_STATUS_COMPLETED, QEMU_MONITOR_MIGRATION_STATUS_ERROR, QEMU_MONITOR_MIGRATION_STATUS_CANCELLING, diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index dc05dfd047..ffff9e7103 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -3242,6 +3242,7 @@ qemuMonitorJSONGetMigrationStatsReply(virJSONValue *r= eply, =20 case QEMU_MONITOR_MIGRATION_STATUS_ACTIVE: case QEMU_MONITOR_MIGRATION_STATUS_POSTCOPY: + case QEMU_MONITOR_MIGRATION_STATUS_POSTCOPY_PAUSED: case QEMU_MONITOR_MIGRATION_STATUS_COMPLETED: case QEMU_MONITOR_MIGRATION_STATUS_CANCELLING: case QEMU_MONITOR_MIGRATION_STATUS_PRE_SWITCHOVER: diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index f1264909de..6acf5c7881 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -1513,6 +1513,17 @@ qemuProcessHandleMigrationStatus(qemuMonitor *mon G_= GNUC_UNUSED, } break; =20 + case QEMU_MONITOR_MIGRATION_STATUS_POSTCOPY_PAUSED: + if (priv->job.asyncJob =3D=3D VIR_ASYNC_JOB_MIGRATION_OUT && + state =3D=3D VIR_DOMAIN_PAUSED) { + /* At this point no thread is watching the migration progress = on + * the source as it is just waiting for the Finish phase to en= d. + * Thus we need to handle the event here. */ + qemuMigrationSrcPostcopyFailed(vm); + qemuDomainSaveStatus(vm); + } + break; + case QEMU_MONITOR_MIGRATION_STATUS_INACTIVE: case QEMU_MONITOR_MIGRATION_STATUS_SETUP: case QEMU_MONITOR_MIGRATION_STATUS_ACTIVE: --=20 2.35.1 From nobody Wed May 15 19:27:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1654087994; cv=none; d=zohomail.com; s=zohoarc; b=bm5MYWnd8C/Gs1p2Tlei4JMW1nHXXGaa6TWaGx554B4XdBK7iMEeGRiCE9ZQ55LXRC3hb1qRX1IkuQ0U9xHqElII3q6Y1EsAYXkfJUKjtO0HIJKHeQm04sEvpV2ADROu3Pn4nJnkquodL4Z4h7zjVLvo52wxP4Cmba1L+v6U94c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654087994; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=/XFo4cr8GwIghZWZQhJcN0ldu629HNS5Cn0ohgwxPLg=; b=WFY8z9AKgyjGcvSW8d1EvSCP6XQE1HsWj8SvyVKCoCKcN4bMwErpvyCngmnhiN1s+MoRdTdvfsY0WqJtE8jnv6XdcOf2Ii3ekvrzs7c+miD4l+1jEJeF03hH17aErZHaMZt+nO5cJGkuEpynsUU6kJWC/+87np/hy7w6dSW81nA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1654087994557986.5025717222195; Wed, 1 Jun 2022 05:53:14 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-142-H08RfxzmOXK7M_DYEfC8uw-1; Wed, 01 Jun 2022 08:51:07 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B299E3C161A6; Wed, 1 Jun 2022 12:50:38 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 996C61400C30; Wed, 1 Jun 2022 12:50:38 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 179431955ECE; Wed, 1 Jun 2022 12:50:36 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 27E70193F6C8 for ; Wed, 1 Jun 2022 12:50:29 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id E6D2C40F06C; Wed, 1 Jun 2022 12:50:28 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.227]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C7126492C3B for ; Wed, 1 Jun 2022 12:50:28 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 7B427245B61; Wed, 1 Jun 2022 14:50:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654087993; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=/XFo4cr8GwIghZWZQhJcN0ldu629HNS5Cn0ohgwxPLg=; b=ZQKefTRMvDY+qkMxjigxGgfr5xOmA06o5scxurjeciS9YrlCpnAv0DjD7cxsg6NXTPahgm xSH1E8oHvg/g2Dw4NUQjszNfG8/VY3uctD2TQRXzoxrGJX5FJ1v/hNnPid7j27s50YBXbu G3YEq5LMM14tH2IQioEP8hbBS/aliZk= X-MC-Unique: H08RfxzmOXK7M_DYEfC8uw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH v2 21/81] qemu: Add support for postcopy-recover QEMU migration state Date: Wed, 1 Jun 2022 14:49:21 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1654087996399100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Jiri Denemark Reviewed-by: Peter Krempa --- Notes: Version 2: - rebased on top of newly added "qemu: Use switch in qemuProcessHandleMigrationStatus" - debug message on a single line src/qemu/qemu_migration.c | 1 + src/qemu/qemu_monitor.c | 2 +- src/qemu/qemu_monitor.h | 1 + src/qemu/qemu_monitor_json.c | 1 + src/qemu/qemu_process.c | 25 +++++++++++++++++++++++++ 5 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index de4be0e7f9..12f06648d7 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -1744,6 +1744,7 @@ qemuMigrationUpdateJobType(virDomainJobData *jobData) =20 switch ((qemuMonitorMigrationStatus) priv->stats.mig.status) { case QEMU_MONITOR_MIGRATION_STATUS_POSTCOPY: + case QEMU_MONITOR_MIGRATION_STATUS_POSTCOPY_RECOVER: jobData->status =3D VIR_DOMAIN_JOB_STATUS_POSTCOPY; break; =20 diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 8d0f54e4a0..ec56d413da 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -149,7 +149,7 @@ VIR_ENUM_IMPL(qemuMonitorMigrationStatus, "inactive", "setup", "active", "pre-switchover", "device", "postcopy-active", - "postcopy-paused", + "postcopy-paused", "postcopy-recover", "completed", "failed", "cancelling", "cancelled", "wait-unplug", diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index 90532962fe..41e8db945c 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -796,6 +796,7 @@ typedef enum { QEMU_MONITOR_MIGRATION_STATUS_DEVICE, QEMU_MONITOR_MIGRATION_STATUS_POSTCOPY, QEMU_MONITOR_MIGRATION_STATUS_POSTCOPY_PAUSED, + QEMU_MONITOR_MIGRATION_STATUS_POSTCOPY_RECOVER, QEMU_MONITOR_MIGRATION_STATUS_COMPLETED, QEMU_MONITOR_MIGRATION_STATUS_ERROR, QEMU_MONITOR_MIGRATION_STATUS_CANCELLING, diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index ffff9e7103..83d0600a75 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -3243,6 +3243,7 @@ qemuMonitorJSONGetMigrationStatsReply(virJSONValue *r= eply, case QEMU_MONITOR_MIGRATION_STATUS_ACTIVE: case QEMU_MONITOR_MIGRATION_STATUS_POSTCOPY: case QEMU_MONITOR_MIGRATION_STATUS_POSTCOPY_PAUSED: + case QEMU_MONITOR_MIGRATION_STATUS_POSTCOPY_RECOVER: case QEMU_MONITOR_MIGRATION_STATUS_COMPLETED: case QEMU_MONITOR_MIGRATION_STATUS_CANCELLING: case QEMU_MONITOR_MIGRATION_STATUS_PRE_SWITCHOVER: diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 6acf5c7881..b039108ff7 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -1524,6 +1524,31 @@ qemuProcessHandleMigrationStatus(qemuMonitor *mon G_= GNUC_UNUSED, } break; =20 + case QEMU_MONITOR_MIGRATION_STATUS_POSTCOPY_RECOVER: + if (virDomainObjIsFailedPostcopy(vm)) { + int eventType =3D -1; + int eventDetail =3D -1; + + if (state =3D=3D VIR_DOMAIN_PAUSED) { + reason =3D VIR_DOMAIN_PAUSED_POSTCOPY; + eventType =3D VIR_DOMAIN_EVENT_SUSPENDED; + eventDetail =3D qemuDomainPausedReasonToSuspendedEvent(rea= son); + } else { + reason =3D VIR_DOMAIN_RUNNING_POSTCOPY; + eventType =3D VIR_DOMAIN_EVENT_RESUMED; + eventDetail =3D qemuDomainRunningReasonToResumeEvent(reaso= n); + } + + VIR_DEBUG("Post-copy migration recovered; correcting state for= domain '%s' to %s/%s", + vm->def->name, + virDomainStateTypeToString(state), + NULLSTR(virDomainStateReasonToString(state, reason))= ); + virDomainObjSetState(vm, state, reason); + event =3D virDomainEventLifecycleNewFromObj(vm, eventType, eve= ntDetail); + qemuDomainSaveStatus(vm); + } + break; + case QEMU_MONITOR_MIGRATION_STATUS_INACTIVE: case QEMU_MONITOR_MIGRATION_STATUS_SETUP: case QEMU_MONITOR_MIGRATION_STATUS_ACTIVE: --=20 2.35.1 From nobody Wed May 15 19:27:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1654087870; cv=none; d=zohomail.com; s=zohoarc; b=GbZ/ljVNe+SIiEEXwNqWqMqGZQjtXYTcAPC+HVVBqHx+PUVu9AVrjqz34Oim1ZPfF+3n1idlkumW/1KcUXBYee0fQBN8RcbRSl+32mWHe+ky83/p6BPjbfTXk83T+O1VDaQ0sGUO1kQ4fpfjDjLmjzl2XYJxx9JW0q7F92YdPsk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654087870; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=fpEDvfDm8vBZNSIba8eFA442HKXwtJcFjT5aqxECqn8=; b=bShRlCL0o1YDkFKFMwQcOmdZ4ZX/kSGkK2eC/LC0T61GAS767Fn+b9Dh7fPd7iwlWB7bJ1gRa+3V7KPGtdRG0bzmlqEy8Qx2Ca8sl5Q/k6OndVP6Khl+ccnPF54Uzqc4iHn+noqmuSYgdhv4xHz7I50OcqKRk2VGtY3hlmmbyd0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1654087870179949.6589153051825; Wed, 1 Jun 2022 05:51:10 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-433-uyU_BD7OOd-nodozyvIJFQ-1; Wed, 01 Jun 2022 08:51:03 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 49A4080418B; Wed, 1 Jun 2022 12:50:35 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 319EC8288A; Wed, 1 Jun 2022 12:50:35 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 58CA21947BB5; Wed, 1 Jun 2022 12:50:33 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id E7E95193F6D6 for ; Wed, 1 Jun 2022 12:50:28 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id D5E94112131B; Wed, 1 Jun 2022 12:50:28 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.227]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B57E71121315; Wed, 1 Jun 2022 12:50:28 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 7C91F245B62; Wed, 1 Jun 2022 14:50:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654087869; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=fpEDvfDm8vBZNSIba8eFA442HKXwtJcFjT5aqxECqn8=; b=L5Hj2saFYHobnzI0PNrT5BT/TpYsKJ1FQPHnxKY5caHt8bkeoH41VagZT7/HOGEKDnYX85 W8Lxe91u0+XZCXJLjzW1k77gb3CdQIXwoTlSuxTltPPO0kiR1kgkt7fO5VvIYhbB0eubiI Yu65Wzw6/fCXC+URPAqRV85kOB7vjUI= X-MC-Unique: uyU_BD7OOd-nodozyvIJFQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH v2 22/81] qemu: Create domain object at the end of qemuMigrationDstFinish Date: Wed, 1 Jun 2022 14:49:22 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Krempa , Pavel Hrdina Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1654087871862100001 Content-Type: text/plain; charset="utf-8" We don't need the object until we get to the "endjob" label. Signed-off-by: Jiri Denemark Reviewed-by: Peter Krempa Reviewed-by: Pavel Hrdina --- Notes: Version 2: - no change src/qemu/qemu_migration.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 12f06648d7..8a1210c8c7 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -5949,11 +5949,7 @@ qemuMigrationDstFinish(virQEMUDriver *driver, VIR_DOMAIN_RUNNING, VIR_DOMAIN_RUNNING_MIGRATED); } - } - - dom =3D virGetDomain(dconn, vm->def->name, vm->def->uuid, vm->def->id); =20 - if (inPostCopy) { /* The only RESUME event during post-copy migration is triggered by * QEMU when the running domain moves from the source to the * destination host, but then the migration keeps running until all @@ -5981,6 +5977,8 @@ qemuMigrationDstFinish(virQEMUDriver *driver, /* Guest is successfully running, so cancel previous auto destroy */ qemuProcessAutoDestroyRemove(driver, vm); =20 + dom =3D virGetDomain(dconn, vm->def->name, vm->def->uuid, vm->def->id); + endjob: if (!dom && !(flags & VIR_MIGRATE_OFFLINE) && --=20 2.35.1 From nobody Wed May 15 19:27:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1654087930; cv=none; d=zohomail.com; s=zohoarc; b=krb18+M80JKYeeFbsL+HEJLQq/fvlLcEBF2aUSKkCzqlVuxP7yFuryiaNIjSeHmrpflUMq9bEahkO/r2t1wifr8dFTMXF8FpILUy7GrTij3ZLfoirT43OprpzPDi+2fZL/JoViKHH+QJasKSpgt2sx+lPWEyazKKyR3RYYM23Es= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654087930; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=VIPNaM+I24bwFk9BqyAiZHuk3w2Mq4kBmFsnf+8K2dM=; b=RIDUrqbR8jH9MypQJYwx4gKR5bObNrDny+6L+bCAr8yh9nMiCe/V/kRErwmfwBvJ0PYVezqJcrZsI0UJJwdh+myy8pOy7bwllwXssNfifp1hzfFN9NTaQemOW2CA14Vzc+qFipwmGarA5oZ5tBJRyomJG0KyYq/CDTAQhZC3S5Y= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1654087930408217.23429939578432; Wed, 1 Jun 2022 05:52:10 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-124-ARlsr9rbNe-bV1HQLnT-CQ-1; Wed, 01 Jun 2022 08:51:08 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 26E508041AA; Wed, 1 Jun 2022 12:50:37 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 12C1940CFD0A; Wed, 1 Jun 2022 12:50:37 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id CE3F61947B99; Wed, 1 Jun 2022 12:50:34 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 305A7193F6F6 for ; Wed, 1 Jun 2022 12:50:29 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id F10D12166B30; Wed, 1 Jun 2022 12:50:28 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.227]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D009E2166B2D; Wed, 1 Jun 2022 12:50:28 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 7DE52245B63; Wed, 1 Jun 2022 14:50:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654087929; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=VIPNaM+I24bwFk9BqyAiZHuk3w2Mq4kBmFsnf+8K2dM=; b=KIROU7zje5elbOKxnf56oc4HGRF4ZlqIT9p8i0p65i+6D8cErsqak3r4BZ8Wd113UWMryM yfCe+dWvC9qo+uT3wuULx7StAAI6WIdxHfxHKgnf928nFHqe6CGNFlyhZu/WmnM8gLjquf 0JKeefcUMseJGWahNh5/3luxW5tgeF0= X-MC-Unique: ARlsr9rbNe-bV1HQLnT-CQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH v2 23/81] qemu: Move success-only code out of endjob in qemuMigrationDstFinish Date: Wed, 1 Jun 2022 14:49:23 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Krempa , Pavel Hrdina Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1654087932143100011 Content-Type: text/plain; charset="utf-8" Code executed only when dom !=3D NULL can be moved before "endjob" label, to the only place where dom is set. Signed-off-by: Jiri Denemark Reviewed-by: Peter Krempa Reviewed-by: Pavel Hrdina --- Notes: Version 2: - fixed indentation src/qemu/qemu_migration.c | 50 ++++++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 22 deletions(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 8a1210c8c7..f6d3200cba 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -5813,8 +5813,16 @@ qemuMigrationDstFinish(virQEMUDriver *driver, =20 if (flags & VIR_MIGRATE_OFFLINE) { if (retcode =3D=3D 0 && - qemuMigrationDstPersist(driver, vm, mig, false) =3D=3D 0) + qemuMigrationDstPersist(driver, vm, mig, false) =3D=3D 0) { dom =3D virGetDomain(dconn, vm->def->name, vm->def->uuid, -1); + + if (dom && + qemuMigrationCookieFormat(mig, driver, vm, + QEMU_MIGRATION_DESTINATION, + cookieout, cookieoutlen, + QEMU_MIGRATION_COOKIE_STATS) < 0) + VIR_WARN("Unable to encode migration cookie"); + } goto endjob; } =20 @@ -5977,6 +5985,25 @@ qemuMigrationDstFinish(virQEMUDriver *driver, /* Guest is successfully running, so cancel previous auto destroy */ qemuProcessAutoDestroyRemove(driver, vm); =20 + if (jobData) { + priv->job.completed =3D g_steal_pointer(&jobData); + priv->job.completed->status =3D VIR_DOMAIN_JOB_STATUS_COMPLETED; + qemuDomainJobSetStatsType(priv->job.completed, + QEMU_DOMAIN_JOB_STATS_TYPE_MIGRATION); + } + + if (qemuMigrationCookieFormat(mig, driver, vm, + QEMU_MIGRATION_DESTINATION, + cookieout, cookieoutlen, + QEMU_MIGRATION_COOKIE_STATS) < 0) + VIR_WARN("Unable to encode migration cookie"); + + /* Remove completed stats for post-copy, everything but timing fields + * is obsolete anyway. + */ + if (inPostCopy) + g_clear_pointer(&priv->job.completed, virDomainJobDataFree); + dom =3D virGetDomain(dconn, vm->def->name, vm->def->uuid, vm->def->id); =20 endjob: @@ -5997,27 +6024,6 @@ qemuMigrationDstFinish(virQEMUDriver *driver, } } =20 - if (dom) { - if (jobData) { - priv->job.completed =3D g_steal_pointer(&jobData); - priv->job.completed->status =3D VIR_DOMAIN_JOB_STATUS_COMPLETE= D; - qemuDomainJobSetStatsType(priv->job.completed, - QEMU_DOMAIN_JOB_STATS_TYPE_MIGRATION= ); - } - - if (qemuMigrationCookieFormat(mig, driver, vm, - QEMU_MIGRATION_DESTINATION, - cookieout, cookieoutlen, - QEMU_MIGRATION_COOKIE_STATS) < 0) - VIR_WARN("Unable to encode migration cookie"); - - /* Remove completed stats for post-copy, everything but timing fie= lds - * is obsolete anyway. - */ - if (inPostCopy) - g_clear_pointer(&priv->job.completed, virDomainJobDataFree); - } - if (virDomainObjIsFailedPostcopy(vm)) { qemuProcessAutoDestroyRemove(driver, vm); qemuDomainCleanupAdd(vm, qemuProcessCleanupMigrationJob); --=20 2.35.1 From nobody Wed May 15 19:27:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1654088001; cv=none; d=zohomail.com; s=zohoarc; b=RSkU1k+t9PTaZSZy1VZhosYWokatHadmWIEB9duv+g04JmxoPVdu7X86RpuX0n8MYcmkGNtteB/8g3YePNuXxExX+7nImfegzkltcgBL2AA6lAzl9+Z8QLT66IsK/GzakJ14YExRuUg/F9WKm+aH7mN9WyPw9vMsDbugKghUsCo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654088001; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=aAnReo1p/l4RWoXa2PnVSIJAzqbe15xpHtht8kGqpe8=; b=ZT2+y0VlwMtOQ9fXKxYyxZG0NDXofAQsDhnkaV4Cx0M7/DQoSkIsuMjJ3KBSCZnL2k//nN8PfgoRqNMcmqvb/tq0ylR9yvtubsSexyJ30YJN61KXSGB/gb/0AAKNSb+ZYbMbh/DZUq73DIhHRuKIP1BM2IQNF7LKJd2y6LI5CM8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1654088001501705.639476815916; Wed, 1 Jun 2022 05:53:21 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-504-z2b4BPVHMZu1oOcZRxFDUw-1; Wed, 01 Jun 2022 08:51:16 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 15E10395AFEB; Wed, 1 Jun 2022 12:50:39 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id F33C22166B26; Wed, 1 Jun 2022 12:50:38 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 830461947B88; Wed, 1 Jun 2022 12:50:36 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 2ACD8193F6D5 for ; Wed, 1 Jun 2022 12:50:29 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id EC9B641638E; Wed, 1 Jun 2022 12:50:28 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.227]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CBCE740F06B; Wed, 1 Jun 2022 12:50:28 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 7F41F245B64; Wed, 1 Jun 2022 14:50:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654088000; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=aAnReo1p/l4RWoXa2PnVSIJAzqbe15xpHtht8kGqpe8=; b=TyJgqYeL8qNrd4E9cBu1JYRo0cheQT+N/pzV6OGS4JyWd+b5MzcWU0nO7/yqhbVju0skBA Je6S4vio2KslYAKutLtPCi8iMYYPoK167ItQvUQmoWSH8a9RC/QgS3/V+ctKpnQqDySc89 3zOMagDA5P10e1fS0JltX+giekcN3bA= X-MC-Unique: z2b4BPVHMZu1oOcZRxFDUw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH v2 24/81] qemu: Separate success and failure path in qemuMigrationDstFinish Date: Wed, 1 Jun 2022 14:49:24 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Krempa , Pavel Hrdina Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1654088002483100010 Content-Type: text/plain; charset="utf-8" Most of the code in "endjob" label is executed only on failure. Let's duplicate the rest so that the label can be used only in error path making the success path easier to follow and refactor. Signed-off-by: Jiri Denemark Reviewed-by: Peter Krempa Reviewed-by: Pavel Hrdina --- Notes: Version 2: - no change src/qemu/qemu_migration.c | 45 ++++++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index f6d3200cba..d2a6e20550 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -5823,7 +5823,9 @@ qemuMigrationDstFinish(virQEMUDriver *driver, QEMU_MIGRATION_COOKIE_STATS) < 0) VIR_WARN("Unable to encode migration cookie"); } - goto endjob; + + qemuMigrationJobFinish(vm); + goto cleanup; } =20 if (retcode !=3D 0) { @@ -6004,12 +6006,31 @@ qemuMigrationDstFinish(virQEMUDriver *driver, if (inPostCopy) g_clear_pointer(&priv->job.completed, virDomainJobDataFree); =20 + qemuMigrationParamsReset(driver, vm, VIR_ASYNC_JOB_MIGRATION_IN, + jobPriv->migParams, priv->job.apiFlags); + dom =3D virGetDomain(dconn, vm->def->name, vm->def->uuid, vm->def->id); =20 + qemuMigrationJobFinish(vm); + + cleanup: + g_clear_pointer(&jobData, virDomainJobDataFree); + virPortAllocatorRelease(port); + if (priv->mon) + qemuMonitorSetDomainLog(priv->mon, NULL, NULL, NULL); + VIR_FREE(priv->origname); + virDomainObjEndAPI(&vm); + virErrorRestore(&orig_err); + + /* Set a special error if Finish is expected to return NULL as a resul= t of + * successful call with retcode !=3D 0 + */ + if (retcode !=3D 0 && !dom && virGetLastErrorCode() =3D=3D VIR_ERR_OK) + virReportError(VIR_ERR_MIGRATE_FINISH_OK, NULL); + return dom; + endjob: - if (!dom && - !(flags & VIR_MIGRATE_OFFLINE) && - virDomainObjIsActive(vm)) { + if (virDomainObjIsActive(vm)) { if (doKill) { qemuProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_FAILED, VIR_ASYNC_JOB_MIGRATION_IN, @@ -6038,21 +6059,7 @@ qemuMigrationDstFinish(virQEMUDriver *driver, if (!virDomainObjIsActive(vm)) qemuDomainRemoveInactive(driver, vm); =20 - cleanup: - g_clear_pointer(&jobData, virDomainJobDataFree); - virPortAllocatorRelease(port); - if (priv->mon) - qemuMonitorSetDomainLog(priv->mon, NULL, NULL, NULL); - VIR_FREE(priv->origname); - virDomainObjEndAPI(&vm); - virErrorRestore(&orig_err); - - /* Set a special error if Finish is expected to return NULL as a resul= t of - * successful call with retcode !=3D 0 - */ - if (retcode !=3D 0 && !dom && virGetLastErrorCode() =3D=3D VIR_ERR_OK) - virReportError(VIR_ERR_MIGRATE_FINISH_OK, NULL); - return dom; + goto cleanup; } =20 =20 --=20 2.35.1 From nobody Wed May 15 19:27:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1654087871; cv=none; d=zohomail.com; s=zohoarc; b=nYIImO/cU3DNAOHfDyhgPittL578W/Y0US2Ga3KiNiXp87UaVEKZnYDIh07ZV6AtLoXs6c2JTXwoVEFkicVAZuxjxiVVnrNkYsS1NlwRb1B1v55n5bh5KSzkBuELWzazREx3lejen+LdIVSpTVCltuFUesZzRMM2kq1vM6y6arE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654087871; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=99uXiUcAO8L7OKCmVzNyMBgChmSKSnb79dKG5UC/i6o=; b=NtzaCpi92KutiOdCf9cwFFXKO8/AqWsoXhIhSiRQwZLDqcUIXFgRxfPGZDlcUfNz1MldPgIZVLeMUAiHgVFLF2RJVs71rVx0UGKAb8G2J6rkY/9HgRhnXsy3xCTENjvO96Iq8RN49WwPMJwoh2QF8REfdMwXdQ9Z+wnl9yIhtD8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1654087871706602.6443984566656; Wed, 1 Jun 2022 05:51:11 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-644-vDFUL1DZMuelwC3LDgJY_g-1; Wed, 01 Jun 2022 08:51:02 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 890493C138B0; Wed, 1 Jun 2022 12:50:36 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 73AFA1121315; Wed, 1 Jun 2022 12:50:36 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 5216B1947B8B; Wed, 1 Jun 2022 12:50:34 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 2D54819451EC for ; Wed, 1 Jun 2022 12:50:29 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id EBB19492C3B; Wed, 1 Jun 2022 12:50:28 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.227]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CB7DB40314B; Wed, 1 Jun 2022 12:50:28 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 80CAB245B65; Wed, 1 Jun 2022 14:50:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654087868; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=99uXiUcAO8L7OKCmVzNyMBgChmSKSnb79dKG5UC/i6o=; b=fPoNlP1r13t0VRaWsa/bR7L2bHZEdKt60X62z0lFHKMFkthSdcrOnhBQNKJGr8IRPqdlAN H5oJMfz3Er9XBiLFzNhPyD47Y1d1FRcWbv9/1B0Zc/2R09jH57UpICt4KHSz95fn1OqUvR mhGEVaIrLbvjzOQ0zpMZs6eCy5EvWL4= X-MC-Unique: vDFUL1DZMuelwC3LDgJY_g-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH v2 25/81] qemu: Rename "endjob" label in qemuMigrationDstFinish Date: Wed, 1 Jun 2022 14:49:25 +0200 Message-Id: <486512dd25a02bc012c81b9351d6879431f302a2.1654087150.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Krempa , Pavel Hrdina Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1654087873886100005 Content-Type: text/plain; charset="utf-8" Let's call it "error" so that it's clear the label is only used in failure path. Signed-off-by: Jiri Denemark Reviewed-by: Peter Krempa Reviewed-by: Pavel Hrdina --- Notes: Version 2: - no change src/qemu/qemu_migration.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index d2a6e20550..792033daa0 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -5809,7 +5809,7 @@ qemuMigrationDstFinish(virQEMUDriver *driver, =20 if (!(mig =3D qemuMigrationCookieParse(driver, vm->def, priv->origname= , priv, cookiein, cookieinlen, cookie_fla= gs))) - goto endjob; + goto error; =20 if (flags & VIR_MIGRATE_OFFLINE) { if (retcode =3D=3D 0 && @@ -5833,31 +5833,31 @@ qemuMigrationDstFinish(virQEMUDriver *driver, * earlier than monitor EOF handler got a chance to process the er= ror */ qemuDomainCheckMonitor(driver, vm, VIR_ASYNC_JOB_MIGRATION_IN); - goto endjob; + goto error; } =20 if (!virDomainObjIsActive(vm)) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("guest unexpectedly quit")); qemuMigrationDstErrorReport(driver, vm->def->name); - goto endjob; + goto error; } =20 if (qemuMigrationDstVPAssociatePortProfiles(vm->def) < 0) - goto endjob; + goto error; =20 if (mig->network && qemuMigrationDstOPDRelocate(driver, vm, mig) < 0) VIR_WARN("unable to provide network data for relocation"); =20 if (qemuMigrationDstStopNBDServer(driver, vm, mig) < 0) - goto endjob; + goto error; =20 if (qemuRefreshVirtioChannelState(driver, vm, VIR_ASYNC_JOB_MIGRATION_IN) < 0) - goto endjob; + goto error; =20 if (qemuConnectAgent(driver, vm) < 0) - goto endjob; + goto error; =20 if (flags & VIR_MIGRATE_PERSIST_DEST) { if (qemuMigrationDstPersist(driver, vm, mig, !v3proto) < 0) { @@ -5874,7 +5874,7 @@ qemuMigrationDstFinish(virQEMUDriver *driver, * to restart during confirm() step, so we kill it off now. */ if (v3proto) - goto endjob; + goto error; } } =20 @@ -5888,7 +5888,7 @@ qemuMigrationDstFinish(virQEMUDriver *driver, * original domain on the source host is already gone. */ if (v3proto) - goto endjob; + goto error; } =20 /* Now that the state data was transferred we can refresh the actual s= tate @@ -5897,7 +5897,7 @@ qemuMigrationDstFinish(virQEMUDriver *driver, /* Similarly to the case above v2 protocol will not be able to rec= over * from this. Let's ignore this and perhaps stuff will not break. = */ if (v3proto) - goto endjob; + goto error; } =20 if (priv->job.current->status =3D=3D VIR_DOMAIN_JOB_STATUS_POSTCOPY) @@ -5929,7 +5929,7 @@ qemuMigrationDstFinish(virQEMUDriver *driver, * things up. */ if (v3proto) - goto endjob; + goto error; } =20 if (inPostCopy) @@ -5952,7 +5952,7 @@ qemuMigrationDstFinish(virQEMUDriver *driver, if (qemuMigrationDstWaitForCompletion(driver, vm, VIR_ASYNC_JOB_MIGRATION_IN, false) < 0) { - goto endjob; + goto error; } if (virDomainObjGetState(vm, NULL) =3D=3D VIR_DOMAIN_RUNNING) { virDomainObjSetState(vm, @@ -6029,7 +6029,7 @@ qemuMigrationDstFinish(virQEMUDriver *driver, virReportError(VIR_ERR_MIGRATE_FINISH_OK, NULL); return dom; =20 - endjob: + error: if (virDomainObjIsActive(vm)) { if (doKill) { qemuProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_FAILED, --=20 2.35.1 From nobody Wed May 15 19:27:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1654087892; cv=none; d=zohomail.com; s=zohoarc; b=H23coqgQ0Wml6RxN0/rb7CzR6+A1I11+VQWPrFldBuJaPEtPdo4lSZdCgjKCl1wK6CrB/NQQ/pBexRwS40F5MH2RgI8w73fALG+VnGebe6cDM0dLsY9kyf8lu1Ral1rJIfox/W1L/O9K4qEG1KclEhPZFS9HOjg5s/HSu7IQnTU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654087892; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=MSkNFwOBGCjWj867AIbNnfSm2z9yIyt7xn+WyRskxjU=; b=dP/iaLwrEZMfka51lKA89MPZ323Ez2I+4iblG6rkd451RhTRN8d7r0JR93kzJ7cempbpzMSlNa6G0Loqc6wr1v50k55Pvct0IHN7M0vF+kkPHrYIvCoRL/RF543xhIItGl/QdKE4zxrReGnoZyOQAhf1GTl7lY9cuwfBUTEjos8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1654087892962880.4557669103211; Wed, 1 Jun 2022 05:51:32 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-596-oFSUWwaxMGiyJR2JTk-I_A-1; Wed, 01 Jun 2022 08:51:12 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id AD7232806973; Wed, 1 Jun 2022 12:50:43 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 98706492C3B; Wed, 1 Jun 2022 12:50:43 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 19069193220B; Wed, 1 Jun 2022 12:50:40 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 20B5E194707F for ; Wed, 1 Jun 2022 12:50:29 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id ED2A4C27EA3; Wed, 1 Jun 2022 12:50:28 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.227]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CBC3BC27E97; Wed, 1 Jun 2022 12:50:28 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 821EE245B66; Wed, 1 Jun 2022 14:50:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654087892; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=MSkNFwOBGCjWj867AIbNnfSm2z9yIyt7xn+WyRskxjU=; b=PoYeJdGkLMPwx4x0/i80HSPvU6XHOHx/AkPS8hniVYm3Kzg+l+WyVTij6o2LGiYH8dQMpx eiIAU9o50TJFZFI4oPxonelGFmMhcIvmrutFtmky1kvB1zE1sVkqQfvL3i9396bd33M3Y6 AKsLp9wxmFfh+rbz6Wdr68BoWPTzeQI= X-MC-Unique: oFSUWwaxMGiyJR2JTk-I_A-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH v2 26/81] qemu: Generate migration cookie in Finish phase earlier Date: Wed, 1 Jun 2022 14:49:26 +0200 Message-Id: <286905cfaa2b1ac2019ff6220a87b20310ef977a.1654087150.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Krempa , Pavel Hrdina Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1654087893981100005 Content-Type: text/plain; charset="utf-8" The final part of Finish phase will be refactored into a dedicated function and we don't want to generate the cookie there. Signed-off-by: Jiri Denemark Reviewed-by: Peter Krempa Reviewed-by: Pavel Hrdina --- Notes: Version 2: - no change src/qemu/qemu_migration.c | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 792033daa0..170caf77e7 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -5948,12 +5948,27 @@ qemuMigrationDstFinish(virQEMUDriver *driver, qemuDomainJobDataUpdateDowntime(jobData); } =20 + if (inPostCopy && + qemuMigrationDstWaitForCompletion(driver, vm, + VIR_ASYNC_JOB_MIGRATION_IN, + false) < 0) { + goto error; + } + + if (jobData) { + priv->job.completed =3D g_steal_pointer(&jobData); + priv->job.completed->status =3D VIR_DOMAIN_JOB_STATUS_COMPLETED; + qemuDomainJobSetStatsType(priv->job.completed, + QEMU_DOMAIN_JOB_STATS_TYPE_MIGRATION); + } + + if (qemuMigrationCookieFormat(mig, driver, vm, + QEMU_MIGRATION_DESTINATION, + cookieout, cookieoutlen, + QEMU_MIGRATION_COOKIE_STATS) < 0) + VIR_WARN("Unable to encode migration cookie"); + if (inPostCopy) { - if (qemuMigrationDstWaitForCompletion(driver, vm, - VIR_ASYNC_JOB_MIGRATION_IN, - false) < 0) { - goto error; - } if (virDomainObjGetState(vm, NULL) =3D=3D VIR_DOMAIN_RUNNING) { virDomainObjSetState(vm, VIR_DOMAIN_RUNNING, @@ -5987,19 +6002,6 @@ qemuMigrationDstFinish(virQEMUDriver *driver, /* Guest is successfully running, so cancel previous auto destroy */ qemuProcessAutoDestroyRemove(driver, vm); =20 - if (jobData) { - priv->job.completed =3D g_steal_pointer(&jobData); - priv->job.completed->status =3D VIR_DOMAIN_JOB_STATUS_COMPLETED; - qemuDomainJobSetStatsType(priv->job.completed, - QEMU_DOMAIN_JOB_STATS_TYPE_MIGRATION); - } - - if (qemuMigrationCookieFormat(mig, driver, vm, - QEMU_MIGRATION_DESTINATION, - cookieout, cookieoutlen, - QEMU_MIGRATION_COOKIE_STATS) < 0) - VIR_WARN("Unable to encode migration cookie"); - /* Remove completed stats for post-copy, everything but timing fields * is obsolete anyway. */ --=20 2.35.1 From nobody Wed May 15 19:27:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1654087983; cv=none; d=zohomail.com; s=zohoarc; b=ACILgSoh/13SSvsBP9o+uq+4lEW3/MObtjHoZXRdaB6Cm8cCaiyrTL7P5K8oDs7PJek11ne7bxl7jZEbYVDrCeperQN4Czbp8+0+kmMnu9FJ0VqxfNDolS6r/O6Ec5uLFpXxZJxjPT+9uIeHrv4WhztZjBrzQZB16tbBzb725B8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654087983; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=DXn44iH3xat3nxVs2tWKshIh+xqpWAE2OSV0pnp6wFI=; b=OdZ9y6k6n2Q8p973atoRXq/a5Qyg0RCWQ0wH5c8zwpIFVo8W7dbZJJZ69BLaJRrfxq74VgOGZuY5W5zb4V1YL/PmTdT6oGGx9CsoeCLByWAVTWVmrXIgp4P1xFbEYv6c7IY5LOq8dWDf7kSjzBIHRZgn0P33uygF4GB9QolClbs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1654087983038509.48287593307236; Wed, 1 Jun 2022 05:53:03 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-576-Y_S57MgUOauQJ7tgeYH_Rg-1; Wed, 01 Jun 2022 08:51:31 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7D4FF10F982B; Wed, 1 Jun 2022 12:50:43 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 618A52166B2C; Wed, 1 Jun 2022 12:50:43 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 086771955EF6; Wed, 1 Jun 2022 12:50:40 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 5B6461937756 for ; Wed, 1 Jun 2022 12:50:29 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 14E31141510A; Wed, 1 Jun 2022 12:50:29 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.227]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CBCF01415102; Wed, 1 Jun 2022 12:50:28 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 8383E245B67; Wed, 1 Jun 2022 14:50:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654087982; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=DXn44iH3xat3nxVs2tWKshIh+xqpWAE2OSV0pnp6wFI=; b=WpYCA6Su2+qJ4keHRlHPmYwYvosS+wBJWO/ocmj6ylE6yfcNgNuG5n1vB6dtbXAMasNIYt TToS8B+PZALa4Nm4daoB65wwXax/NvAai5PPeUJwWVq83n2xD3k8QWYd1ZfdA54wRBtpXO 4QhArjuL+toM35OAQXxjJMlMQMxy0wQ= X-MC-Unique: Y_S57MgUOauQJ7tgeYH_Rg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH v2 27/81] qemu: Make final part of migration Finish phase reusable Date: Wed, 1 Jun 2022 14:49:27 +0200 Message-Id: <0c9b80ec0bb25eb0cf67037c9caee9c2f17119a0.1654087150.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Krempa , Pavel Hrdina Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1654087984369100001 Content-Type: text/plain; charset="utf-8" By separating it into a dedicated qemuMigrationDstComplete function which can be later called in other places. Signed-off-by: Jiri Denemark Reviewed-by: Peter Krempa Reviewed-by: Pavel Hrdina --- Notes: Version 2: - no change src/qemu/qemu_migration.c | 99 ++++++++++++++++++++++----------------- src/qemu/qemu_migration.h | 6 +++ 2 files changed, 63 insertions(+), 42 deletions(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 170caf77e7..10fc99180d 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -5753,6 +5753,61 @@ qemuMigrationDstPersist(virQEMUDriver *driver, } =20 =20 +void +qemuMigrationDstComplete(virQEMUDriver *driver, + virDomainObj *vm, + bool inPostCopy, + virDomainAsyncJob asyncJob) +{ + qemuDomainObjPrivate *priv =3D vm->privateData; + qemuDomainJobPrivate *jobPriv =3D priv->job.privateData; + virObjectEvent *event; + + if (inPostCopy) { + if (virDomainObjGetState(vm, NULL) =3D=3D VIR_DOMAIN_RUNNING) { + virDomainObjSetState(vm, + VIR_DOMAIN_RUNNING, + VIR_DOMAIN_RUNNING_MIGRATED); + } + + /* The only RESUME event during post-copy migration is triggered by + * QEMU when the running domain moves from the source to the + * destination host, but then the migration keeps running until all + * modified memory is transferred from the source host. This will + * result in VIR_DOMAIN_EVENT_RESUMED with RESUMED_POSTCOPY detail. + * However, our API documentation says we need to fire another RES= UMED + * event at the very end of migration with RESUMED_MIGRATED detail. + */ + event =3D virDomainEventLifecycleNewFromObj(vm, + VIR_DOMAIN_EVENT_RESUMED, + VIR_DOMAIN_EVENT_RESUMED= _MIGRATED); + virObjectEventStateQueue(driver->domainEventState, event); + } + + if (virDomainObjGetState(vm, NULL) =3D=3D VIR_DOMAIN_PAUSED) { + virDomainObjSetState(vm, VIR_DOMAIN_PAUSED, VIR_DOMAIN_PAUSED_USER= ); + event =3D virDomainEventLifecycleNewFromObj(vm, + VIR_DOMAIN_EVENT_SUSPEND= ED, + VIR_DOMAIN_EVENT_SUSPEND= ED_PAUSED); + virObjectEventStateQueue(driver->domainEventState, event); + } + + qemuDomainSaveStatus(vm); + + /* Guest is successfully running, so cancel previous auto destroy */ + qemuProcessAutoDestroyRemove(driver, vm); + + /* Remove completed stats for post-copy, everything but timing fields + * is obsolete anyway. + */ + if (inPostCopy) + g_clear_pointer(&priv->job.completed, virDomainJobDataFree); + + qemuMigrationParamsReset(driver, vm, asyncJob, jobPriv->migParams, + priv->job.apiFlags); +} + + virDomainPtr qemuMigrationDstFinish(virQEMUDriver *driver, virConnectPtr dconn, @@ -5968,48 +6023,8 @@ qemuMigrationDstFinish(virQEMUDriver *driver, QEMU_MIGRATION_COOKIE_STATS) < 0) VIR_WARN("Unable to encode migration cookie"); =20 - if (inPostCopy) { - if (virDomainObjGetState(vm, NULL) =3D=3D VIR_DOMAIN_RUNNING) { - virDomainObjSetState(vm, - VIR_DOMAIN_RUNNING, - VIR_DOMAIN_RUNNING_MIGRATED); - } - - /* The only RESUME event during post-copy migration is triggered by - * QEMU when the running domain moves from the source to the - * destination host, but then the migration keeps running until all - * modified memory is transferred from the source host. This will - * result in VIR_DOMAIN_EVENT_RESUMED with RESUMED_POSTCOPY detail. - * However, our API documentation says we need to fire another RES= UMED - * event at the very end of migration with RESUMED_MIGRATED detail. - */ - event =3D virDomainEventLifecycleNewFromObj(vm, - VIR_DOMAIN_EVENT_RESUMED, - VIR_DOMAIN_EVENT_RESUMED= _MIGRATED); - virObjectEventStateQueue(driver->domainEventState, event); - } - - if (virDomainObjGetState(vm, NULL) =3D=3D VIR_DOMAIN_PAUSED) { - virDomainObjSetState(vm, VIR_DOMAIN_PAUSED, VIR_DOMAIN_PAUSED_USER= ); - event =3D virDomainEventLifecycleNewFromObj(vm, - VIR_DOMAIN_EVENT_SUSPEND= ED, - VIR_DOMAIN_EVENT_SUSPEND= ED_PAUSED); - virObjectEventStateQueue(driver->domainEventState, event); - } - - qemuDomainSaveStatus(vm); - - /* Guest is successfully running, so cancel previous auto destroy */ - qemuProcessAutoDestroyRemove(driver, vm); - - /* Remove completed stats for post-copy, everything but timing fields - * is obsolete anyway. - */ - if (inPostCopy) - g_clear_pointer(&priv->job.completed, virDomainJobDataFree); - - qemuMigrationParamsReset(driver, vm, VIR_ASYNC_JOB_MIGRATION_IN, - jobPriv->migParams, priv->job.apiFlags); + qemuMigrationDstComplete(driver, vm, inPostCopy, + VIR_ASYNC_JOB_MIGRATION_IN); =20 dom =3D virGetDomain(dconn, vm->def->name, vm->def->uuid, vm->def->id); =20 diff --git a/src/qemu/qemu_migration.h b/src/qemu/qemu_migration.h index c4e4228282..ecb0ad6302 100644 --- a/src/qemu/qemu_migration.h +++ b/src/qemu/qemu_migration.h @@ -191,6 +191,12 @@ qemuMigrationDstFinish(virQEMUDriver *driver, int retcode, bool v3proto); =20 +void +qemuMigrationDstComplete(virQEMUDriver *driver, + virDomainObj *vm, + bool inPostCopy, + virDomainAsyncJob asyncJob); + int qemuMigrationSrcConfirm(virQEMUDriver *driver, virDomainObj *vm, --=20 2.35.1 From nobody Wed May 15 19:27:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1654088004; cv=none; d=zohomail.com; s=zohoarc; b=Jzc63JtpfAnt4YIukW+O5KnIJwYqsmNHFjlcR+l4vAZH6DXh9oZeKIMBCmbNNjmfd54wbrUOkEkaeKbGYVbPiYCZgMF+zqpXpmQz4jDbe6Df4qilfh4q8MFwdqAcVvp+H/euDPBoInhrjtvksLUoQio8B6+n6+ozH71pyqRXmoc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654088004; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=VExQC+62btyMfmntOrH5ZJCcxS8ORO8+RPGAtvGJmGs=; b=n72HO54jQmaUuzgzC0fjK08KG3hHqd777dx2vsGHm4yx3z/e9Asl7nPSuOenLqCAWhOZ0Vw3Owci+GqYpxlP2d5iY7a1QBSCc7P55/lCkqa4Pv0xUbzeuL4avFoKTqdc4Ok69ArDQoIgdyfGTzbePd+jMHzdy/wwdOOCgTHhRPk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1654088004330347.0224317155287; Wed, 1 Jun 2022 05:53:24 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-523-nod_5cVsOoSvNH__B5qcsQ-1; Wed, 01 Jun 2022 08:51:21 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5603B18E5357; Wed, 1 Jun 2022 12:50:38 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3FFBCC27E92; Wed, 1 Jun 2022 12:50:38 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id CEDB71932209; Wed, 1 Jun 2022 12:50:35 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 32F18193F6F7 for ; Wed, 1 Jun 2022 12:50:29 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id EF77A492CA4; Wed, 1 Jun 2022 12:50:28 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.227]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CBBAA492CA2; Wed, 1 Jun 2022 12:50:28 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 84CB3245B68; Wed, 1 Jun 2022 14:50:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654088002; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=VExQC+62btyMfmntOrH5ZJCcxS8ORO8+RPGAtvGJmGs=; b=a8BF3aGZrBj/lcFrtwSK6hhfTLBqVCuRnrfwD0Yv++vH+uy+VJOitvrqRK7DJOwSPSwJBh yUD0KH227m4zDDqNj8xUK70OIoFS+caijbv2Az1HCiB95EtujXPc5y12beav6E4RrMOW0r kK1A7BwbOJkGddgep5GuiYf2uT0te14= X-MC-Unique: nod_5cVsOoSvNH__B5qcsQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH v2 28/81] qemu: Drop obsolete comment in qemuMigrationDstFinish Date: Wed, 1 Jun 2022 14:49:28 +0200 Message-Id: <1bca3070726493a517f370e3d20a1cd2a9620f57.1654087150.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Krempa , Pavel Hrdina Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1654088006451100002 Content-Type: text/plain; charset="utf-8" The comment about QEMU < 0.10.6 has been irrelevant for years. Signed-off-by: Jiri Denemark Reviewed-by: Peter Krempa Reviewed-by: Pavel Hrdina Reviewed-by: J=C3=A1n Tomko --- Notes: Version 2: - no change src/qemu/qemu_migration.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 10fc99180d..fdc93d7fe1 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -5959,10 +5959,6 @@ qemuMigrationDstFinish(virQEMUDriver *driver, inPostCopy =3D true; =20 if (!(flags & VIR_MIGRATE_PAUSED)) { - /* run 'cont' on the destination, which allows migration on qemu - * >=3D 0.10.6 to work properly. This isn't strictly necessary on - * older qemu's, but it also doesn't hurt anything there - */ if (qemuProcessStartCPUs(driver, vm, inPostCopy ? VIR_DOMAIN_RUNNING_POSTCOPY : VIR_DOMAIN_RUNNING_MIGRATED, --=20 2.35.1 From nobody Wed May 15 19:27:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1654087927; cv=none; d=zohomail.com; s=zohoarc; b=aj9xto7CJuSVsMO2eLdfWgtz0w3j0X7joFzsuP2iGVGmWoTpPOtQgzTVCarISL+OgypS7UuAxZYoJj2h1y8CPUw1wl+8lntoCZM0EKZDqzG5emaG/S6RywXxqObAvb3Io28NFAsqE/txZLr5lGg9UxsBxliKAjf+z+NFkrjQOK0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654087927; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=a4alOgYcbc0eJhQwVl9HSQy1a0P7ZjFF9l/7lGfHoY8=; b=Xid1OytzLSRp6/8oTGz+xeNk1htH7hqRg4l48AGpOc7RnZs+TGsStHcpL6Om15+aMuFwJAv8P+hEK8G5fHKhceay9S9dZQ9aWg7gbhUfDRPCYNZfBp8KA3IrDM3U0OFOdnn8OGBTdfjy0vBNuc/c41pRQyxQnRD7/sOVz5BFBoE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1654087927897140.41785082521915; Wed, 1 Jun 2022 05:52:07 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-34-A3nP7GPwPUGcj_oFQYPTAA-1; Wed, 01 Jun 2022 08:51:34 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D5A5739796B3; Wed, 1 Jun 2022 12:50:40 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id BD4598288C; Wed, 1 Jun 2022 12:50:40 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id B6F061955EC8; Wed, 1 Jun 2022 12:50:37 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 4D08319452D2 for ; Wed, 1 Jun 2022 12:50:29 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 131A5C27E97; Wed, 1 Jun 2022 12:50:29 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.227]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E6A3EC27E98; Wed, 1 Jun 2022 12:50:28 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 86233245B69; Wed, 1 Jun 2022 14:50:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654087926; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=a4alOgYcbc0eJhQwVl9HSQy1a0P7ZjFF9l/7lGfHoY8=; b=ePan9nAwTXbCReOg2M685AcOk2x7t/CJ/kgllyoBSSJoA/KMJXbz1WzJupj3/jiFgHYzl/ teFBrifhnwSAiay8e/wFbiockOuzrvGPJVZK1C9ipWBcVDNHvPlZqxqqXahrfo1QZpgOjN 0mvzEWsQi42BQ7bnvjfJOOo8NhW4oZE= X-MC-Unique: A3nP7GPwPUGcj_oFQYPTAA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH v2 29/81] qemu: Preserve error in qemuMigrationDstFinish Date: Wed, 1 Jun 2022 14:49:29 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Krempa , Pavel Hrdina Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1654087928117100001 Content-Type: text/plain; charset="utf-8" We want to prevent our error path that can potentially kill the domain on the destination host from overwriting an error reported earlier, but we were only doing so in one specific path when starting vCPUs fails. Let's do it in all paths. Signed-off-by: Jiri Denemark Reviewed-by: Peter Krempa Reviewed-by: Pavel Hrdina --- Notes: Version 2: - no change src/qemu/qemu_migration.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index fdc93d7fe1..10c4f7a470 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -5966,11 +5966,6 @@ qemuMigrationDstFinish(virQEMUDriver *driver, if (virGetLastErrorCode() =3D=3D VIR_ERR_OK) virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("resume operation failed")); - /* Need to save the current error, in case shutting - * down the process overwrites it - */ - virErrorPreserveLast(&orig_err); - /* * In v3 protocol, the source VM is still available to * restart during confirm() step, so we kill it off @@ -6043,6 +6038,10 @@ qemuMigrationDstFinish(virQEMUDriver *driver, return dom; =20 error: + /* Need to save the current error, in case shutting down the process + * overwrites it. */ + virErrorPreserveLast(&orig_err); + if (virDomainObjIsActive(vm)) { if (doKill) { qemuProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_FAILED, --=20 2.35.1 From nobody Wed May 15 19:27:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1654087890; cv=none; d=zohomail.com; s=zohoarc; b=itvF4js6oPTithUt5/X0epF7+EnDVXpiqa3YBc+OO/ESBtUpxsIuQ8oeYyisY5uW6nGUvgEeS/bedTK78aARYyoNUCdLUYD9J+gR3Is0QokqFAtpGgXbSaO22a3zJQI9w2mhYOLqBweeegt0aPrrDhBn7CztgAbp7NukMn0cbn4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654087890; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Ex0LvkffgwrZw+DKK36SLRaLyJ92IS8SfXqFZeFoeE4=; b=Tkq0w13SYrNFVGHvJfnc74fCqc50KAV2eg14rHmYIg4IebrOppIErHIGWVcmf8d8nGFZVbjUqKrrawpd5JJkfT/3FIV/zrsEuoOOg0CV9JNVrUwRJ7Pkf7Tl4a7MtdLQ0lM5g98j4Vd3gEnVE2jGjbxqGxmE3mLvJ2UjVzoG9gc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1654087890894618.4164029998201; Wed, 1 Jun 2022 05:51:30 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-615-wJNU15JLOuiaGV8eDXNJ_A-1; Wed, 01 Jun 2022 08:51:21 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E174C833B1B; Wed, 1 Jun 2022 12:50:42 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id CC66840EC007; Wed, 1 Jun 2022 12:50:42 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 75262194E100; Wed, 1 Jun 2022 12:50:39 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 7D9941947079 for ; Wed, 1 Jun 2022 12:50:29 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 4C391492C3B; Wed, 1 Jun 2022 12:50:29 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.227]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E716E475005; Wed, 1 Jun 2022 12:50:28 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 87993245B6A; Wed, 1 Jun 2022 14:50:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654087889; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=Ex0LvkffgwrZw+DKK36SLRaLyJ92IS8SfXqFZeFoeE4=; b=Oo+nKqjhRTBWSb+qV95cXtGk6WCEhMd6yQ9mPTwLOH6Qu5IAswnyDzTah2Bw3qDwHiE0eE 1CtZMt5xQpGDN41QLwD3LlZKeRuPSIWYxhvMCUTLbIzCEsJbyYz08hQbK0CZLz3zsZxFlc tkEDBofn4ESSXQMB2ZfMb81kdFB9XUA= X-MC-Unique: wJNU15JLOuiaGV8eDXNJ_A-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH v2 30/81] qemu: Introduce qemuMigrationDstFinishFresh Date: Wed, 1 Jun 2022 14:49:30 +0200 Message-Id: <4a1236205aed0d4249f5702a259bc27ced5b15cf.1654087150.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Krempa , Pavel Hrdina Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1654087891988100002 Content-Type: text/plain; charset="utf-8" Refactors qemuMigrationDstFinish by moving some parts to a dedicated function for easier introduction of postcopy resume code without duplicating common parts of the Finish phase. The goal is to have the following call graph: - qemuMigrationDstFinish - qemuMigrationDstFinishOffline - qemuMigrationDstFinishActive - qemuMigrationDstFinishFresh - qemuMigrationDstFinishResume Signed-off-by: Jiri Denemark Reviewed-by: Peter Krempa Reviewed-by: Pavel Hrdina --- Notes: Version 2: - no change src/qemu/qemu_migration.c | 234 +++++++++++++++++++++----------------- 1 file changed, 129 insertions(+), 105 deletions(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 10c4f7a470..72f22f09e4 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -5808,111 +5808,38 @@ qemuMigrationDstComplete(virQEMUDriver *driver, } =20 =20 -virDomainPtr -qemuMigrationDstFinish(virQEMUDriver *driver, - virConnectPtr dconn, - virDomainObj *vm, - const char *cookiein, - int cookieinlen, - char **cookieout, - int *cookieoutlen, - unsigned long flags, - int retcode, - bool v3proto) +/* + * Perform Finish phase of a fresh (i.e., not recovery) migration of an ac= tive + * domain. + */ +static int +qemuMigrationDstFinishFresh(virQEMUDriver *driver, + virDomainObj *vm, + qemuMigrationCookie *mig, + unsigned long flags, + bool v3proto, + unsigned long long timeReceived, + bool *doKill, + bool *inPostCopy) { - virDomainPtr dom =3D NULL; - g_autoptr(qemuMigrationCookie) mig =3D NULL; - virErrorPtr orig_err =3D NULL; - int cookie_flags =3D 0; qemuDomainObjPrivate *priv =3D vm->privateData; - qemuDomainJobPrivate *jobPriv =3D priv->job.privateData; - unsigned short port; - unsigned long long timeReceived =3D 0; - virObjectEvent *event; - virDomainJobData *jobData =3D NULL; - bool inPostCopy =3D false; - bool doKill =3D true; - - VIR_DEBUG("driver=3D%p, dconn=3D%p, vm=3D%p, cookiein=3D%s, cookieinle= n=3D%d, " - "cookieout=3D%p, cookieoutlen=3D%p, flags=3D0x%lx, retcode= =3D%d", - driver, dconn, vm, NULLSTR(cookiein), cookieinlen, - cookieout, cookieoutlen, flags, retcode); - - port =3D priv->migrationPort; - priv->migrationPort =3D 0; - - if (!qemuMigrationJobIsActive(vm, VIR_ASYNC_JOB_MIGRATION_IN)) { - qemuMigrationDstErrorReport(driver, vm->def->name); - goto cleanup; - } - - ignore_value(virTimeMillisNow(&timeReceived)); - - qemuMigrationJobStartPhase(vm, - v3proto ? QEMU_MIGRATION_PHASE_FINISH3 - : QEMU_MIGRATION_PHASE_FINISH2); - - qemuDomainCleanupRemove(vm, qemuMigrationDstPrepareCleanup); - g_clear_pointer(&priv->job.completed, virDomainJobDataFree); - - cookie_flags =3D QEMU_MIGRATION_COOKIE_NETWORK | - QEMU_MIGRATION_COOKIE_STATS | - QEMU_MIGRATION_COOKIE_NBD; - /* Some older versions of libvirt always send persistent XML in the co= okie - * even though VIR_MIGRATE_PERSIST_DEST was not used. */ - cookie_flags |=3D QEMU_MIGRATION_COOKIE_PERSISTENT; - - if (!(mig =3D qemuMigrationCookieParse(driver, vm->def, priv->origname= , priv, - cookiein, cookieinlen, cookie_fla= gs))) - goto error; - - if (flags & VIR_MIGRATE_OFFLINE) { - if (retcode =3D=3D 0 && - qemuMigrationDstPersist(driver, vm, mig, false) =3D=3D 0) { - dom =3D virGetDomain(dconn, vm->def->name, vm->def->uuid, -1); - - if (dom && - qemuMigrationCookieFormat(mig, driver, vm, - QEMU_MIGRATION_DESTINATION, - cookieout, cookieoutlen, - QEMU_MIGRATION_COOKIE_STATS) < 0) - VIR_WARN("Unable to encode migration cookie"); - } - - qemuMigrationJobFinish(vm); - goto cleanup; - } - - if (retcode !=3D 0) { - /* Check for a possible error on the monitor in case Finish was ca= lled - * earlier than monitor EOF handler got a chance to process the er= ror - */ - qemuDomainCheckMonitor(driver, vm, VIR_ASYNC_JOB_MIGRATION_IN); - goto error; - } - - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("guest unexpectedly quit")); - qemuMigrationDstErrorReport(driver, vm->def->name); - goto error; - } + g_autoptr(virDomainJobData) jobData =3D NULL; =20 if (qemuMigrationDstVPAssociatePortProfiles(vm->def) < 0) - goto error; + return -1; =20 if (mig->network && qemuMigrationDstOPDRelocate(driver, vm, mig) < 0) VIR_WARN("unable to provide network data for relocation"); =20 if (qemuMigrationDstStopNBDServer(driver, vm, mig) < 0) - goto error; + return -1; =20 if (qemuRefreshVirtioChannelState(driver, vm, VIR_ASYNC_JOB_MIGRATION_IN) < 0) - goto error; + return -1; =20 if (qemuConnectAgent(driver, vm) < 0) - goto error; + return -1; =20 if (flags & VIR_MIGRATE_PERSIST_DEST) { if (qemuMigrationDstPersist(driver, vm, mig, !v3proto) < 0) { @@ -5929,7 +5856,7 @@ qemuMigrationDstFinish(virQEMUDriver *driver, * to restart during confirm() step, so we kill it off now. */ if (v3proto) - goto error; + return -1; } } =20 @@ -5943,7 +5870,7 @@ qemuMigrationDstFinish(virQEMUDriver *driver, * original domain on the source host is already gone. */ if (v3proto) - goto error; + return -1; } =20 /* Now that the state data was transferred we can refresh the actual s= tate @@ -5952,16 +5879,16 @@ qemuMigrationDstFinish(virQEMUDriver *driver, /* Similarly to the case above v2 protocol will not be able to rec= over * from this. Let's ignore this and perhaps stuff will not break. = */ if (v3proto) - goto error; + return -1; } =20 if (priv->job.current->status =3D=3D VIR_DOMAIN_JOB_STATUS_POSTCOPY) - inPostCopy =3D true; + *inPostCopy =3D true; =20 if (!(flags & VIR_MIGRATE_PAUSED)) { if (qemuProcessStartCPUs(driver, vm, - inPostCopy ? VIR_DOMAIN_RUNNING_POSTCOPY - : VIR_DOMAIN_RUNNING_MIGRATED, + *inPostCopy ? VIR_DOMAIN_RUNNING_POSTCOPY + : VIR_DOMAIN_RUNNING_MIGRATED, VIR_ASYNC_JOB_MIGRATION_IN) < 0) { if (virGetLastErrorCode() =3D=3D VIR_ERR_OK) virReportError(VIR_ERR_INTERNAL_ERROR, @@ -5975,11 +5902,11 @@ qemuMigrationDstFinish(virQEMUDriver *driver, * things up. */ if (v3proto) - goto error; + return -1; } =20 - if (inPostCopy) - doKill =3D false; + if (*inPostCopy) + *doKill =3D false; } =20 if (mig->jobData) { @@ -5994,11 +5921,11 @@ qemuMigrationDstFinish(virQEMUDriver *driver, qemuDomainJobDataUpdateDowntime(jobData); } =20 - if (inPostCopy && + if (*inPostCopy && qemuMigrationDstWaitForCompletion(driver, vm, VIR_ASYNC_JOB_MIGRATION_IN, false) < 0) { - goto error; + return -1; } =20 if (jobData) { @@ -6008,6 +5935,106 @@ qemuMigrationDstFinish(virQEMUDriver *driver, QEMU_DOMAIN_JOB_STATS_TYPE_MIGRATION); } =20 + return 0; +} + + +virDomainPtr +qemuMigrationDstFinish(virQEMUDriver *driver, + virConnectPtr dconn, + virDomainObj *vm, + const char *cookiein, + int cookieinlen, + char **cookieout, + int *cookieoutlen, + unsigned long flags, + int retcode, + bool v3proto) +{ + virDomainPtr dom =3D NULL; + g_autoptr(qemuMigrationCookie) mig =3D NULL; + virErrorPtr orig_err =3D NULL; + int cookie_flags =3D 0; + qemuDomainObjPrivate *priv =3D vm->privateData; + qemuDomainJobPrivate *jobPriv =3D priv->job.privateData; + unsigned short port; + unsigned long long timeReceived =3D 0; + virObjectEvent *event; + bool inPostCopy =3D false; + bool doKill =3D true; + int rc; + + VIR_DEBUG("driver=3D%p, dconn=3D%p, vm=3D%p, cookiein=3D%s, cookieinle= n=3D%d, " + "cookieout=3D%p, cookieoutlen=3D%p, flags=3D0x%lx, retcode= =3D%d", + driver, dconn, vm, NULLSTR(cookiein), cookieinlen, + cookieout, cookieoutlen, flags, retcode); + + port =3D priv->migrationPort; + priv->migrationPort =3D 0; + + if (!qemuMigrationJobIsActive(vm, VIR_ASYNC_JOB_MIGRATION_IN)) { + qemuMigrationDstErrorReport(driver, vm->def->name); + goto cleanup; + } + + ignore_value(virTimeMillisNow(&timeReceived)); + + qemuMigrationJobStartPhase(vm, + v3proto ? QEMU_MIGRATION_PHASE_FINISH3 + : QEMU_MIGRATION_PHASE_FINISH2); + + qemuDomainCleanupRemove(vm, qemuMigrationDstPrepareCleanup); + g_clear_pointer(&priv->job.completed, virDomainJobDataFree); + + cookie_flags =3D QEMU_MIGRATION_COOKIE_NETWORK | + QEMU_MIGRATION_COOKIE_STATS | + QEMU_MIGRATION_COOKIE_NBD; + /* Some older versions of libvirt always send persistent XML in the co= okie + * even though VIR_MIGRATE_PERSIST_DEST was not used. */ + cookie_flags |=3D QEMU_MIGRATION_COOKIE_PERSISTENT; + + if (!(mig =3D qemuMigrationCookieParse(driver, vm->def, priv->origname= , priv, + cookiein, cookieinlen, cookie_fla= gs))) + goto error; + + if (flags & VIR_MIGRATE_OFFLINE) { + if (retcode =3D=3D 0 && + qemuMigrationDstPersist(driver, vm, mig, false) =3D=3D 0) { + dom =3D virGetDomain(dconn, vm->def->name, vm->def->uuid, -1); + + if (dom && + qemuMigrationCookieFormat(mig, driver, vm, + QEMU_MIGRATION_DESTINATION, + cookieout, cookieoutlen, + QEMU_MIGRATION_COOKIE_STATS) < 0) + VIR_WARN("Unable to encode migration cookie"); + } + + qemuMigrationJobFinish(vm); + goto cleanup; + } + + if (retcode !=3D 0) { + /* Check for a possible error on the monitor in case Finish was ca= lled + * earlier than monitor EOF handler got a chance to process the er= ror + */ + qemuDomainCheckMonitor(driver, vm, VIR_ASYNC_JOB_MIGRATION_IN); + goto error; + } + + if (!virDomainObjIsActive(vm)) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("guest unexpectedly quit")); + qemuMigrationDstErrorReport(driver, vm->def->name); + goto error; + } + + rc =3D qemuMigrationDstFinishFresh(driver, vm, mig, flags, v3proto, + timeReceived, &doKill, &inPostCopy); + if (rc < 0 || + !(dom =3D virGetDomain(dconn, vm->def->name, vm->def->uuid, vm->de= f->id))) + goto error; + if (qemuMigrationCookieFormat(mig, driver, vm, QEMU_MIGRATION_DESTINATION, cookieout, cookieoutlen, @@ -6017,12 +6044,9 @@ qemuMigrationDstFinish(virQEMUDriver *driver, qemuMigrationDstComplete(driver, vm, inPostCopy, VIR_ASYNC_JOB_MIGRATION_IN); =20 - dom =3D virGetDomain(dconn, vm->def->name, vm->def->uuid, vm->def->id); - qemuMigrationJobFinish(vm); =20 cleanup: - g_clear_pointer(&jobData, virDomainJobDataFree); virPortAllocatorRelease(port); if (priv->mon) qemuMonitorSetDomainLog(priv->mon, NULL, NULL, NULL); --=20 2.35.1 From nobody Wed May 15 19:27:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1654087884; cv=none; d=zohomail.com; s=zohoarc; b=kFkVk9BJya7aHopzZsxRfD/8b/15Kt3wzGCLgyfZp/iz+e9tJ3BjbMC0my6HbE5tfoJY+PCEuLtNRefGlNMDhG4Uh9yADH+DCsj05pQXk8t0Dbyo+jQsfoa87H9WfBVIfd6b87ZYyi+WYr13kk3y7zlMm4Lo+JNniTfgPe7gph4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654087884; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=6ZzK1eM6fNhSGjjzok8NhTVma+v1Olc+JNnMqtZ4q4g=; b=EYd6xiGLz4rTjCKAdH3wd6H2T+sLYJT9r7GxjuW662ApLkrO8HA04Yv8mzNoZza6iCaeaSYxL9qSTPeoB18DcwJaL/MfaOWqICX+CWDhknl1LX/CWdQkRzXbizBwqXo3ewi4JxUjaWLiqVdG5lKt6RHxhLVM3NvZyGqdeeggKkA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1654087884975729.1492484119967; Wed, 1 Jun 2022 05:51:24 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-294-JlF-cZZbMviv3SDVgkMYJw-1; Wed, 01 Jun 2022 08:51:17 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E8B6D10AF7EC; Wed, 1 Jun 2022 12:50:39 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id C83B440EC006; Wed, 1 Jun 2022 12:50:39 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 281AB1947B99; Wed, 1 Jun 2022 12:50:37 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 5364A1937755 for ; Wed, 1 Jun 2022 12:50:29 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 13183112131B; Wed, 1 Jun 2022 12:50:29 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.227]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E6ACB1121315; Wed, 1 Jun 2022 12:50:28 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 88F21245B6B; Wed, 1 Jun 2022 14:50:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654087884; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=6ZzK1eM6fNhSGjjzok8NhTVma+v1Olc+JNnMqtZ4q4g=; b=ZOShGPxgdJ/p9Cb7xEnlgFAafJ4+VDqNZDHums6QeDVmNKESY+Flg7sI4t4FkP1rXWi758 yadZGDkwd5TVqNy8wpLdhRoXZGFGIhLXR8yBR36Q+CAuOo0plHG+jEy/LVs/ermb5bhQke vqZpAvRMZu2rV3BbOV5YOw6DntZZpso= X-MC-Unique: JlF-cZZbMviv3SDVgkMYJw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH v2 31/81] qemu: Introduce qemuMigrationDstFinishOffline Date: Wed, 1 Jun 2022 14:49:31 +0200 Message-Id: <9d058de1f3b0d3bef2a3194e883365dc79745f3a.1654087150.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Krempa , Pavel Hrdina Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1654087885943100003 Content-Type: text/plain; charset="utf-8" Refactors qemuMigrationDstFinish by moving some parts to a dedicated function for easier introduction of postcopy resume code without duplicating common parts of the Finish phase. The goal is to have the following call graph: - qemuMigrationDstFinish - qemuMigrationDstFinishOffline - qemuMigrationDstFinishActive - qemuMigrationDstFinishFresh - qemuMigrationDstFinishResume Signed-off-by: Jiri Denemark Reviewed-by: Peter Krempa Reviewed-by: Pavel Hrdina --- Notes: Version 2: - no change src/qemu/qemu_migration.c | 39 +++++++++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 10 deletions(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 72f22f09e4..01e47e46cc 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -5808,6 +5808,32 @@ qemuMigrationDstComplete(virQEMUDriver *driver, } =20 =20 +static virDomainPtr +qemuMigrationDstFinishOffline(virQEMUDriver *driver, + virConnectPtr dconn, + virDomainObj *vm, + qemuMigrationCookie *mig, + char **cookieout, + int *cookieoutlen) +{ + virDomainPtr dom =3D NULL; + + if (qemuMigrationDstPersist(driver, vm, mig, false) < 0) + return NULL; + + dom =3D virGetDomain(dconn, vm->def->name, vm->def->uuid, -1); + + if (dom && + qemuMigrationCookieFormat(mig, driver, vm, + QEMU_MIGRATION_DESTINATION, + cookieout, cookieoutlen, + QEMU_MIGRATION_COOKIE_STATS) < 0) + VIR_WARN("Unable to encode migration cookie"); + + return dom; +} + + /* * Perform Finish phase of a fresh (i.e., not recovery) migration of an ac= tive * domain. @@ -5998,16 +6024,9 @@ qemuMigrationDstFinish(virQEMUDriver *driver, goto error; =20 if (flags & VIR_MIGRATE_OFFLINE) { - if (retcode =3D=3D 0 && - qemuMigrationDstPersist(driver, vm, mig, false) =3D=3D 0) { - dom =3D virGetDomain(dconn, vm->def->name, vm->def->uuid, -1); - - if (dom && - qemuMigrationCookieFormat(mig, driver, vm, - QEMU_MIGRATION_DESTINATION, - cookieout, cookieoutlen, - QEMU_MIGRATION_COOKIE_STATS) < 0) - VIR_WARN("Unable to encode migration cookie"); + if (retcode =3D=3D 0) { + dom =3D qemuMigrationDstFinishOffline(driver, dconn, vm, mig, + cookieout, cookieoutlen); } =20 qemuMigrationJobFinish(vm); --=20 2.35.1 From nobody Wed May 15 19:27:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1654087932; cv=none; d=zohomail.com; s=zohoarc; b=Xd9NdWB6qbZ8tIfinapP8YuOGpHhmGAFyKshrdfTrazRU8Dc5TF+COZBohfO+JQdrFwdo1gL9/QTHeHMAWd02Jv7mWo4LXw4kTgTG43Dkb3OnQ7DkcwoT6PFMGGScSWM+W+XC2X3rLSfvQ2quBZvxLUhPn37+etj+98eEq+UlDM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654087932; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=MD0W2sRkisrUCK0Q11G5q3yBw1b03TjrGW9ECgMciZo=; b=FypZwnkr/s9oGsHdRW+9UpmeMVku3O/q4RkdEMmc8pSnnqLeeqAYh2xMZcDDt12vrE03N8UMhqxnbRoUieCRt92PpD7qaoxAvhC6WWj9p854N/LX9Iklrv8+U0Zddzk2i3AZ+JxOVuJb1cBSxn560jNOi+FG+FwR8H/q4Uayhro= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1654087932110484.07739949191864; Wed, 1 Jun 2022 05:52:12 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-647-JGkObXnnOxWvPgyHG1y3CQ-1; Wed, 01 Jun 2022 08:51:34 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6E25D8339B7; Wed, 1 Jun 2022 12:50:48 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 579192166B2C; Wed, 1 Jun 2022 12:50:48 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 948241940368; Wed, 1 Jun 2022 12:50:44 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 3824C194E103 for ; Wed, 1 Jun 2022 12:50:29 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 13AA41415108; Wed, 1 Jun 2022 12:50:29 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.227]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E68DD1415103; Wed, 1 Jun 2022 12:50:28 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 8A450245B6C; Wed, 1 Jun 2022 14:50:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654087931; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=MD0W2sRkisrUCK0Q11G5q3yBw1b03TjrGW9ECgMciZo=; b=C594ViHCoBNHhSlzWTisnIyWX1opYUmAgx39IwoEOSGjg4ulcpzZYk1CpmypG42axu0/Rq Gjf+BPD95JhR0yWBWT7ZO4oLUCVk6BSTK9vVFrBl5XA7wHR2ZE17XCu9tWL8BBwmApmT9G DTaNXdUrJimV6Iiz0xIEZ5GSaFEQ/MU= X-MC-Unique: JGkObXnnOxWvPgyHG1y3CQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH v2 32/81] qemu: Separate cookie parsing for qemuMigrationDstFinishOffline Date: Wed, 1 Jun 2022 14:49:32 +0200 Message-Id: <3a813db44731678ea51dc868e7f93f455f38fc78.1654087150.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Krempa , Pavel Hrdina Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1654087934163100015 Content-Type: text/plain; charset="utf-8" To keep all cookie handling (parsing and formatting) in the same function. Signed-off-by: Jiri Denemark Reviewed-by: Peter Krempa Reviewed-by: Pavel Hrdina --- Notes: Version 2: - no change src/qemu/qemu_migration.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 01e47e46cc..3c69ddbd45 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -5812,11 +5812,19 @@ static virDomainPtr qemuMigrationDstFinishOffline(virQEMUDriver *driver, virConnectPtr dconn, virDomainObj *vm, - qemuMigrationCookie *mig, + int cookie_flags, + const char *cookiein, + int cookieinlen, char **cookieout, int *cookieoutlen) { virDomainPtr dom =3D NULL; + qemuDomainObjPrivate *priv =3D vm->privateData; + g_autoptr(qemuMigrationCookie) mig =3D NULL; + + if (!(mig =3D qemuMigrationCookieParse(driver, vm->def, priv->origname= , priv, + cookiein, cookieinlen, cookie_fla= gs))) + return NULL; =20 if (qemuMigrationDstPersist(driver, vm, mig, false) < 0) return NULL; @@ -6019,13 +6027,11 @@ qemuMigrationDstFinish(virQEMUDriver *driver, * even though VIR_MIGRATE_PERSIST_DEST was not used. */ cookie_flags |=3D QEMU_MIGRATION_COOKIE_PERSISTENT; =20 - if (!(mig =3D qemuMigrationCookieParse(driver, vm->def, priv->origname= , priv, - cookiein, cookieinlen, cookie_fla= gs))) - goto error; - if (flags & VIR_MIGRATE_OFFLINE) { if (retcode =3D=3D 0) { - dom =3D qemuMigrationDstFinishOffline(driver, dconn, vm, mig, + dom =3D qemuMigrationDstFinishOffline(driver, dconn, vm, + cookie_flags, + cookiein, cookieinlen, cookieout, cookieoutlen); } =20 @@ -6033,6 +6039,10 @@ qemuMigrationDstFinish(virQEMUDriver *driver, goto cleanup; } =20 + if (!(mig =3D qemuMigrationCookieParse(driver, vm->def, priv->origname= , priv, + cookiein, cookieinlen, cookie_fla= gs))) + goto error; + if (retcode !=3D 0) { /* Check for a possible error on the monitor in case Finish was ca= lled * earlier than monitor EOF handler got a chance to process the er= ror --=20 2.35.1 From nobody Wed May 15 19:27:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1654087926; cv=none; d=zohomail.com; s=zohoarc; b=MeFZrbeJ+62wKPQSgL6nH9Cc+PEMW5/w5vZowKIThtlvfhyHagHIpT3hkR74JvJpsiuldDuWJszQ6r16PppXKuVbm66rl8jSShwU9esjrUTy4242vk9fz752/47YgM7IOCDiw215tnl5Jxwj2TNNce50uStLmp/62RwjzTm8a4A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654087926; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=pPbrNHtbbDFzT6JD/wXQAq+p1cAMJNIM1tH5FWX/IOg=; b=AqHpWfY2P1YxOtB5W7/In/FDskrkIHmffNeQ+AcKHkhQ0KAJCd1dqjUo0PuDPSwWpWgg/lJ3InFjMPfU9dEngGyo8LmaAYB3qRD1854iWoDzNg7EwnK02znWLbu50rRgOOIM2FgKJx+3om3oHx04q1h3QKcSMtiRc42ytCllUHw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1654087926423190.9986871949659; Wed, 1 Jun 2022 05:52:06 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-581-fnt3GwKIOgmQkuFWyCQsQw-1; Wed, 01 Jun 2022 08:51:05 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1865F10B9464; Wed, 1 Jun 2022 12:50:42 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 03FA0C27E8F; Wed, 1 Jun 2022 12:50:42 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 0793E1947079; Wed, 1 Jun 2022 12:50:39 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 56ADE193F6C8 for ; Wed, 1 Jun 2022 12:50:29 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 2F7B9400F75F; Wed, 1 Jun 2022 12:50:29 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.227]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E69A74066CA1 for ; Wed, 1 Jun 2022 12:50:28 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 8B92F245B6D; Wed, 1 Jun 2022 14:50:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654087925; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=pPbrNHtbbDFzT6JD/wXQAq+p1cAMJNIM1tH5FWX/IOg=; b=PQE3rFV4xWh/LVm/nV7FdQmsU0QyZbZCwuhf0Wi1//jdthWrYLB4AEvJBdVr+VqqijugRD S58MwRjBfhIyTAeieZgMUg+ErprJS3vE+jeqCGl8kUkUD1o3x53k7PLDOuaYkQ3wqMVxDS xsHiYRrorXKcvA8aC56PPzKjenXJj6w= X-MC-Unique: fnt3GwKIOgmQkuFWyCQsQw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH v2 33/81] qemu: Introduce qemuMigrationDstFinishActive Date: Wed, 1 Jun 2022 14:49:33 +0200 Message-Id: <16de6daaadb2d855bba4a11699c9728e1c1f74db.1654087150.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1654087928167100003 Content-Type: text/plain; charset="utf-8" Refactors qemuMigrationDstFinish by moving some parts to a dedicated function for easier introduction of postcopy resume code without duplicating common parts of the Finish phase. The goal is to have the following call graph: - qemuMigrationDstFinish - qemuMigrationDstFinishOffline - qemuMigrationDstFinishActive - qemuMigrationDstFinishFresh - qemuMigrationDstFinishResume Signed-off-by: Jiri Denemark Reviewed-by: Peter Krempa --- Notes: Version 2: - dropped orig_err parameter from qemuMigrationDstFinishActive src/qemu/qemu_migration.c | 169 ++++++++++++++++++++++---------------- 1 file changed, 100 insertions(+), 69 deletions(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 3c69ddbd45..195b0fd309 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -5973,71 +5973,32 @@ qemuMigrationDstFinishFresh(virQEMUDriver *driver, } =20 =20 -virDomainPtr -qemuMigrationDstFinish(virQEMUDriver *driver, - virConnectPtr dconn, - virDomainObj *vm, - const char *cookiein, - int cookieinlen, - char **cookieout, - int *cookieoutlen, - unsigned long flags, - int retcode, - bool v3proto) +static virDomainPtr +qemuMigrationDstFinishActive(virQEMUDriver *driver, + virConnectPtr dconn, + virDomainObj *vm, + int cookie_flags, + const char *cookiein, + int cookieinlen, + char **cookieout, + int *cookieoutlen, + unsigned long flags, + int retcode, + bool v3proto, + unsigned long long timeReceived) { + virErrorPtr orig_err =3D NULL; virDomainPtr dom =3D NULL; g_autoptr(qemuMigrationCookie) mig =3D NULL; - virErrorPtr orig_err =3D NULL; - int cookie_flags =3D 0; qemuDomainObjPrivate *priv =3D vm->privateData; qemuDomainJobPrivate *jobPriv =3D priv->job.privateData; - unsigned short port; - unsigned long long timeReceived =3D 0; virObjectEvent *event; bool inPostCopy =3D false; bool doKill =3D true; int rc; =20 - VIR_DEBUG("driver=3D%p, dconn=3D%p, vm=3D%p, cookiein=3D%s, cookieinle= n=3D%d, " - "cookieout=3D%p, cookieoutlen=3D%p, flags=3D0x%lx, retcode= =3D%d", - driver, dconn, vm, NULLSTR(cookiein), cookieinlen, - cookieout, cookieoutlen, flags, retcode); - - port =3D priv->migrationPort; - priv->migrationPort =3D 0; - - if (!qemuMigrationJobIsActive(vm, VIR_ASYNC_JOB_MIGRATION_IN)) { - qemuMigrationDstErrorReport(driver, vm->def->name); - goto cleanup; - } - - ignore_value(virTimeMillisNow(&timeReceived)); - - qemuMigrationJobStartPhase(vm, - v3proto ? QEMU_MIGRATION_PHASE_FINISH3 - : QEMU_MIGRATION_PHASE_FINISH2); - - qemuDomainCleanupRemove(vm, qemuMigrationDstPrepareCleanup); - g_clear_pointer(&priv->job.completed, virDomainJobDataFree); - - cookie_flags =3D QEMU_MIGRATION_COOKIE_NETWORK | - QEMU_MIGRATION_COOKIE_STATS | - QEMU_MIGRATION_COOKIE_NBD; - /* Some older versions of libvirt always send persistent XML in the co= okie - * even though VIR_MIGRATE_PERSIST_DEST was not used. */ - cookie_flags |=3D QEMU_MIGRATION_COOKIE_PERSISTENT; - - if (flags & VIR_MIGRATE_OFFLINE) { - if (retcode =3D=3D 0) { - dom =3D qemuMigrationDstFinishOffline(driver, dconn, vm, - cookie_flags, - cookiein, cookieinlen, - cookieout, cookieoutlen); - } - - qemuMigrationJobFinish(vm); - goto cleanup; - } + VIR_DEBUG("vm=3D%p, flags=3D0x%lx, retcode=3D%d", + vm, flags, retcode); =20 if (!(mig =3D qemuMigrationCookieParse(driver, vm->def, priv->origname= , priv, cookiein, cookieinlen, cookie_fla= gs))) @@ -6075,19 +6036,6 @@ qemuMigrationDstFinish(virQEMUDriver *driver, =20 qemuMigrationJobFinish(vm); =20 - cleanup: - virPortAllocatorRelease(port); - if (priv->mon) - qemuMonitorSetDomainLog(priv->mon, NULL, NULL, NULL); - VIR_FREE(priv->origname); - virDomainObjEndAPI(&vm); - virErrorRestore(&orig_err); - - /* Set a special error if Finish is expected to return NULL as a resul= t of - * successful call with retcode !=3D 0 - */ - if (retcode !=3D 0 && !dom && virGetLastErrorCode() =3D=3D VIR_ERR_OK) - virReportError(VIR_ERR_MIGRATE_FINISH_OK, NULL); return dom; =20 error: @@ -6124,7 +6072,90 @@ qemuMigrationDstFinish(virQEMUDriver *driver, if (!virDomainObjIsActive(vm)) qemuDomainRemoveInactive(driver, vm); =20 - goto cleanup; + virErrorRestore(&orig_err); + return NULL; +} + + +virDomainPtr +qemuMigrationDstFinish(virQEMUDriver *driver, + virConnectPtr dconn, + virDomainObj *vm, + const char *cookiein, + int cookieinlen, + char **cookieout, + int *cookieoutlen, + unsigned long flags, + int retcode, + bool v3proto) +{ + virDomainPtr dom =3D NULL; + int cookie_flags =3D 0; + qemuDomainObjPrivate *priv =3D vm->privateData; + unsigned short port; + unsigned long long timeReceived =3D 0; + + VIR_DEBUG("driver=3D%p, dconn=3D%p, vm=3D%p, cookiein=3D%s, cookieinle= n=3D%d, " + "cookieout=3D%p, cookieoutlen=3D%p, flags=3D0x%lx, retcode= =3D%d", + driver, dconn, vm, NULLSTR(cookiein), cookieinlen, + cookieout, cookieoutlen, flags, retcode); + + port =3D priv->migrationPort; + priv->migrationPort =3D 0; + + if (!qemuMigrationJobIsActive(vm, VIR_ASYNC_JOB_MIGRATION_IN)) { + qemuMigrationDstErrorReport(driver, vm->def->name); + goto cleanup; + } + + ignore_value(virTimeMillisNow(&timeReceived)); + + qemuMigrationJobStartPhase(vm, + v3proto ? QEMU_MIGRATION_PHASE_FINISH3 + : QEMU_MIGRATION_PHASE_FINISH2); + + qemuDomainCleanupRemove(vm, qemuMigrationDstPrepareCleanup); + g_clear_pointer(&priv->job.completed, virDomainJobDataFree); + + cookie_flags =3D QEMU_MIGRATION_COOKIE_NETWORK | + QEMU_MIGRATION_COOKIE_STATS | + QEMU_MIGRATION_COOKIE_NBD; + /* Some older versions of libvirt always send persistent XML in the co= okie + * even though VIR_MIGRATE_PERSIST_DEST was not used. */ + cookie_flags |=3D QEMU_MIGRATION_COOKIE_PERSISTENT; + + if (flags & VIR_MIGRATE_OFFLINE) { + if (retcode =3D=3D 0) { + dom =3D qemuMigrationDstFinishOffline(driver, dconn, vm, + cookie_flags, + cookiein, cookieinlen, + cookieout, cookieoutlen); + } + + qemuMigrationJobFinish(vm); + goto cleanup; + } + + dom =3D qemuMigrationDstFinishActive(driver, dconn, vm, cookie_flags, + cookiein, cookieinlen, + cookieout, cookieoutlen, + flags, retcode, v3proto, timeReceiv= ed); + if (!dom) + goto cleanup; + + cleanup: + virPortAllocatorRelease(port); + if (priv->mon) + qemuMonitorSetDomainLog(priv->mon, NULL, NULL, NULL); + VIR_FREE(priv->origname); + virDomainObjEndAPI(&vm); + + /* Set a special error if Finish is expected to return NULL as a resul= t of + * successful call with retcode !=3D 0 + */ + if (retcode !=3D 0 && !dom && virGetLastErrorCode() =3D=3D VIR_ERR_OK) + virReportError(VIR_ERR_MIGRATE_FINISH_OK, NULL); + return dom; } =20 =20 --=20 2.35.1 From nobody Wed May 15 19:27:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1654087998; cv=none; d=zohomail.com; s=zohoarc; b=J5wzjxF5oppL8vHpQ4MfOEi6d5TBF+AOJNYqKIKnLEYbiegtw+GpYXQXwONZLTsB4WFWRjaPCVa3gDdLnF/MwHvDGNHNmBREeNML8gBgHBVvq2UKa8eK7PDvkp0g0kknCieQZpvGzH7Muh6SWgbzMZrRnHHRK9lPISKfEYLMCsc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654087998; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Nd2PglDUqs9Axa2Ji9CLC8PTeEubAb9aPXQYFEqZDqQ=; b=mZr/aDa5QvyETgoAWVCc3gWJFA+AIVmTa8L7KqySx7BuxKgqGZ9TICNJtIx9mLEyUR+ms0bpog5K/h5kOJ3oDEklJGdtK0Aog3R7joQB2AkwGQ903+pnUX2fhlMc8y44DipN0IOQ0URaG5yMDi44zmZNmq52DvEOVndC5kni/5M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1654087998456257.49445760172534; Wed, 1 Jun 2022 05:53:18 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-655-LUpgIcBRNzeF7pSR_XE4IA-1; Wed, 01 Jun 2022 08:51:26 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 789E38B5AE7; Wed, 1 Jun 2022 12:50:41 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 644341121315; Wed, 1 Jun 2022 12:50:41 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 7F83A1955EC4; Wed, 1 Jun 2022 12:50:38 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 5282C194707F for ; Wed, 1 Jun 2022 12:50:29 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 1491540EC008; Wed, 1 Jun 2022 12:50:29 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.227]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E7D8B40EC005 for ; Wed, 1 Jun 2022 12:50:28 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 8CCEA245B6E; Wed, 1 Jun 2022 14:50:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654087997; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=Nd2PglDUqs9Axa2Ji9CLC8PTeEubAb9aPXQYFEqZDqQ=; b=MAQ/TjV+hKr+xYYEmjFB+ZXtKLkBEcoRTkj8OtypYdtktRb3RfUVk8+xwK3M5C1MfxkaTz 6HF27m7eWDZZf0OsLQmDr2Az4RnKoJKufnfVNW2CExS7VG1eARX0sBH9RWBbOsSnWT/AoK yAFpBnmqjrD8TZIZfhvVnnILBx+q6pQ= X-MC-Unique: LUpgIcBRNzeF7pSR_XE4IA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH v2 34/81] qemu: Handle migration job in qemuMigrationDstFinish Date: Wed, 1 Jun 2022 14:49:34 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1654088000452100007 Content-Type: text/plain; charset="utf-8" The function which started a migration phase should also finish it by calling qemuMigrationJobFinish/qemuMigrationJobContinue so that the code is easier to follow. Signed-off-by: Jiri Denemark Reviewed-by: Peter Krempa --- Notes: Version 2: - rewritten without goto src/qemu/qemu_migration.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 195b0fd309..20209a0dc8 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -5985,7 +5985,8 @@ qemuMigrationDstFinishActive(virQEMUDriver *driver, unsigned long flags, int retcode, bool v3proto, - unsigned long long timeReceived) + unsigned long long timeReceived, + bool *finishJob) { virErrorPtr orig_err =3D NULL; virDomainPtr dom =3D NULL; @@ -6034,8 +6035,6 @@ qemuMigrationDstFinishActive(virQEMUDriver *driver, qemuMigrationDstComplete(driver, vm, inPostCopy, VIR_ASYNC_JOB_MIGRATION_IN); =20 - qemuMigrationJobFinish(vm); - return dom; =20 error: @@ -6061,12 +6060,10 @@ qemuMigrationDstFinishActive(virQEMUDriver *driver, if (virDomainObjIsFailedPostcopy(vm)) { qemuProcessAutoDestroyRemove(driver, vm); qemuDomainCleanupAdd(vm, qemuProcessCleanupMigrationJob); - qemuMigrationJobContinue(vm); + *finishJob =3D false; } else { qemuMigrationParamsReset(driver, vm, VIR_ASYNC_JOB_MIGRATION_IN, jobPriv->migParams, priv->job.apiFlags); - - qemuMigrationJobFinish(vm); } =20 if (!virDomainObjIsActive(vm)) @@ -6131,17 +6128,20 @@ qemuMigrationDstFinish(virQEMUDriver *driver, cookiein, cookieinlen, cookieout, cookieoutlen); } - qemuMigrationJobFinish(vm); - goto cleanup; - } + } else { + bool finishJob =3D true; =20 - dom =3D qemuMigrationDstFinishActive(driver, dconn, vm, cookie_flags, - cookiein, cookieinlen, - cookieout, cookieoutlen, - flags, retcode, v3proto, timeReceiv= ed); - if (!dom) - goto cleanup; + dom =3D qemuMigrationDstFinishActive(driver, dconn, vm, cookie_fla= gs, + cookiein, cookieinlen, + cookieout, cookieoutlen, + flags, retcode, v3proto, timeRe= ceived, + &finishJob); + if (finishJob) + qemuMigrationJobFinish(vm); + else + qemuMigrationJobContinue(vm); + } =20 cleanup: virPortAllocatorRelease(port); --=20 2.35.1 From nobody Wed May 15 19:27:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1654088332; cv=none; d=zohomail.com; s=zohoarc; b=KPqghN/dXQHXqGCWKBv0tXuJFv7eAkDyAziU+tvna5QC9W2l6bHJrxuxYsT0+5VwzSke7ky0fRDPBPbD+ckbWyNCY09z0ot6HUG/+0cP7mOU74I3tetEq9Sk3xeNOMsxsUZvMuUV+P46QklKw/CYSURIc68vl2wgS7QYcK2F/Bk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654088332; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=xPn5jTC2/HLDuC6EkAN0yEpVd5HHN+GVxRG3X1kfICY=; b=F+vwCTydZlPcHp7UOLg8RnOJ+s5fvmFxEHA1DmBsbViAcD3ZfixDdG0G7k3JigJlu9PjwkxoqgC6O45yeibj0fPwLua9xSQO0NlEoEK2I/3gE40K6UH2Bz4mbCVc9rqX91KC445Gmm4f6kJtSUY+9QC7AeH3uNn7NjlI9GI57aE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1654088332785486.2725229152695; Wed, 1 Jun 2022 05:58:52 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-386-SG3_JZKHOQ6k4qBhqyfA2Q-1; Wed, 01 Jun 2022 08:51:37 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 09478833A2B; Wed, 1 Jun 2022 12:50:45 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id B804F1121315; Wed, 1 Jun 2022 12:50:44 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 961181955EC4; Wed, 1 Jun 2022 12:50:41 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 4F7AD1947B98 for ; Wed, 1 Jun 2022 12:50:30 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 202392026985; Wed, 1 Jun 2022 12:50:30 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.227]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D6BC32026D64; Wed, 1 Jun 2022 12:50:29 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 8E2FC245B6F; Wed, 1 Jun 2022 14:50:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654088331; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=xPn5jTC2/HLDuC6EkAN0yEpVd5HHN+GVxRG3X1kfICY=; b=Xa41s7FOFYa0YviXvywwTH/tj9nwvMmTFhSRxj9RAVLqPZ8I7vjrEUGQGG41n6svMcUXFi ujdGHy2h/7ut1LcaebdbUKV4C+i8GdQswIcLzdqoOtkC+RS3qt+6ETYzz7JtwpnlB8WBjP nsqkFsUiF7BtfJ5bWQx/IM0JOh3OSzo= X-MC-Unique: SG3_JZKHOQ6k4qBhqyfA2Q-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH v2 35/81] qemu: Make final part of migration Confirm phase reusable Date: Wed, 1 Jun 2022 14:49:35 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Krempa , Pavel Hrdina Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1654088333284100001 Content-Type: text/plain; charset="utf-8" By separating it into a dedicated qemuMigrationSrcComplete function which can be later called in other places. Signed-off-by: Jiri Denemark Reviewed-by: Peter Krempa Reviewed-by: Pavel Hrdina --- Notes: Version 2: - fixed indentation src/qemu/qemu_migration.c | 70 ++++++++++++++++++++++++--------------- src/qemu/qemu_migration.h | 5 +++ 2 files changed, 48 insertions(+), 27 deletions(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 20209a0dc8..d80a250cac 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -3491,6 +3491,48 @@ qemuMigrationAnyPrepareDef(virQEMUDriver *driver, } =20 =20 +void +qemuMigrationSrcComplete(virQEMUDriver *driver, + virDomainObj *vm, + virDomainAsyncJob asyncJob) +{ + qemuDomainObjPrivate *priv =3D vm->privateData; + virDomainJobData *jobData =3D priv->job.completed; + virObjectEvent *event; + int reason; + + if (jobData) { + /* We need to refresh migration statistics after a completed post-= copy + * migration since jobData contains obsolete data from the time we + * switched to post-copy mode. + */ + if (virDomainObjGetState(vm, &reason) =3D=3D VIR_DOMAIN_PAUSED && + reason =3D=3D VIR_DOMAIN_PAUSED_POSTCOPY) { + VIR_DEBUG("Refreshing migration statistics"); + if (qemuMigrationAnyFetchStats(driver, vm, VIR_ASYNC_JOB_MIGRA= TION_OUT, + jobData, NULL) < 0) + VIR_WARN("Could not refresh migration statistics"); + } + + qemuDomainJobDataUpdateTime(jobData); + } + + /* If guest uses SPICE and supports seamless migration we have to hold + * up domain shutdown until SPICE server transfers its data */ + qemuMigrationSrcWaitForSpice(vm); + + qemuProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_MIGRATED, asyncJob, + VIR_QEMU_PROCESS_STOP_MIGRATED); + virDomainAuditStop(vm, "migrated"); + + event =3D virDomainEventLifecycleNewFromObj(vm, + VIR_DOMAIN_EVENT_STOPPED, + VIR_DOMAIN_EVENT_STOPPED_MIG= RATED); + virObjectEventStateQueue(driver->domainEventState, event); + qemuDomainEventEmitJobCompleted(driver, vm); +} + + static int qemuMigrationSrcConfirmPhase(virQEMUDriver *driver, virDomainObj *vm, @@ -3500,7 +3542,6 @@ qemuMigrationSrcConfirmPhase(virQEMUDriver *driver, int retcode) { g_autoptr(qemuMigrationCookie) mig =3D NULL; - virObjectEvent *event; qemuDomainObjPrivate *priv =3D vm->privateData; qemuDomainJobPrivate *jobPriv =3D priv->job.privateData; virDomainJobData *jobData =3D NULL; @@ -3537,21 +3578,9 @@ qemuMigrationSrcConfirmPhase(virQEMUDriver *driver, =20 /* Update times with the values sent by the destination daemon */ if (mig->jobData && jobData) { - int reason; qemuDomainJobDataPrivate *privJob =3D jobData->privateData; qemuDomainJobDataPrivate *privMigJob =3D mig->jobData->privateData; =20 - /* We need to refresh migration statistics after a completed post-= copy - * migration since priv->job.completed contains obsolete data from= the - * time we switched to post-copy mode. - */ - if (virDomainObjGetState(vm, &reason) =3D=3D VIR_DOMAIN_PAUSED && - reason =3D=3D VIR_DOMAIN_PAUSED_POSTCOPY && - qemuMigrationAnyFetchStats(driver, vm, VIR_ASYNC_JOB_MIGRATION= _OUT, - jobData, NULL) < 0) - VIR_WARN("Could not refresh migration statistics"); - - qemuDomainJobDataUpdateTime(jobData); jobData->timeDeltaSet =3D mig->jobData->timeDeltaSet; jobData->timeDelta =3D mig->jobData->timeDelta; privJob->stats.mig.downtime_set =3D privMigJob->stats.mig.downtime= _set; @@ -3565,20 +3594,7 @@ qemuMigrationSrcConfirmPhase(virQEMUDriver *driver, * If something failed, resume CPUs, but only if we didn't use post-co= py. */ if (retcode =3D=3D 0) { - /* If guest uses SPICE and supports seamless migration we have to = hold - * up domain shutdown until SPICE server transfers its data */ - qemuMigrationSrcWaitForSpice(vm); - - qemuProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_MIGRATED, - VIR_ASYNC_JOB_MIGRATION_OUT, - VIR_QEMU_PROCESS_STOP_MIGRATED); - virDomainAuditStop(vm, "migrated"); - - event =3D virDomainEventLifecycleNewFromObj(vm, - VIR_DOMAIN_EVENT_STOPPED, - VIR_DOMAIN_EVENT_STOPPED_MIGRATED= ); - virObjectEventStateQueue(driver->domainEventState, event); - qemuDomainEventEmitJobCompleted(driver, vm); + qemuMigrationSrcComplete(driver, vm, VIR_ASYNC_JOB_MIGRATION_OUT); } else { virErrorPtr orig_err; int reason; diff --git a/src/qemu/qemu_migration.h b/src/qemu/qemu_migration.h index ecb0ad6302..1d6051859b 100644 --- a/src/qemu/qemu_migration.h +++ b/src/qemu/qemu_migration.h @@ -205,6 +205,11 @@ qemuMigrationSrcConfirm(virQEMUDriver *driver, unsigned int flags, int cancelled); =20 +void +qemuMigrationSrcComplete(virQEMUDriver *driver, + virDomainObj *vm, + virDomainAsyncJob asyncJob); + bool qemuMigrationSrcIsAllowed(virQEMUDriver *driver, virDomainObj *vm, --=20 2.35.1 From nobody Wed May 15 19:27:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1654087987; cv=none; d=zohomail.com; s=zohoarc; b=hplltOI4FYken2yz91hwgnBpkddWqiTOn1Rey9vZDD9q5bAGTXn49FG/s6FSq5QYkxbbvxMKP/3sPTrSkkEJoFhVioJo23MKUJ9f+2NlcWNT4dIA7UyFClICBLokpz8W8fUYj29y5Rb8v4n45Syt6YWByZ8z5oZXxVV8PdFC/lg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654087987; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=xwLp11JwKe7iR3KlsmFWhAuqs7G1xQXTyvzT7W8Kseg=; b=dovh0lKU2QC6i2St8+CM3K73C9N9kqTdQjvnR9OQg9zThY3U7pBXNb+rb8Hh3Jp9tj8uwG1IvKLjt6/Vgz6WgNcvzqkwb3DwhCKRGmp6iRPW/LMt/5TNxqwuPLOe7bV050JD1QkLOWZi7wBsYZ2WSfb9FAh47tG6dDSsg1OEVZU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1654087987683432.48591156460543; Wed, 1 Jun 2022 05:53:07 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-221-WBjehmEiNsa4ZqBsilTqWw-1; Wed, 01 Jun 2022 08:51:32 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2A98880CDAD; Wed, 1 Jun 2022 12:50:50 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 146BE3323E; Wed, 1 Jun 2022 12:50:50 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 3496C193221D; Wed, 1 Jun 2022 12:50:46 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 224261947B8C for ; Wed, 1 Jun 2022 12:50:30 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 0A096C27E8F; Wed, 1 Jun 2022 12:50:30 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.227]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DD622C28114; Wed, 1 Jun 2022 12:50:29 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 8F7C5245B70; Wed, 1 Jun 2022 14:50:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654087986; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=xwLp11JwKe7iR3KlsmFWhAuqs7G1xQXTyvzT7W8Kseg=; b=MHSxlhBioaTnPN6oyOyWlYDA4FJJAMz9iE5iH6moEWyT9EqT7Ub4GaEaVZLp2RQtesP0wg TdJBOIAZhmICr3bgA9LgTkoSVNWuDqIr2apO/AI7HOLWLhyGobt1k9L188X+IQd3VW6+D6 JHC18WbZtfbjd81aiGMvdda6IITST+U= X-MC-Unique: WBjehmEiNsa4ZqBsilTqWw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH v2 36/81] qemu: Make sure migrationPort is released even in callbacks Date: Wed, 1 Jun 2022 14:49:36 +0200 Message-Id: <3f2e99969df417ab137bd2cfd838dfd1a231ec4e.1654087150.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Krempa , Pavel Hrdina Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1654087988375100006 Content-Type: text/plain; charset="utf-8" Normally migrationPort is released in the Finish phase, but we need to make sure it is properly released also in case qemuMigrationDstFinish is not called at all. Currently the only callback which is called in this situation qemuMigrationDstPrepareCleanup which already releases migrationPort. This patch adds similar handling to additional callbacks which will be used in the future. Signed-off-by: Jiri Denemark Reviewed-by: Peter Krempa Reviewed-by: Pavel Hrdina --- Notes: Version 2: - no change src/qemu/qemu_migration.c | 3 +++ src/qemu/qemu_process.c | 2 ++ 2 files changed, 5 insertions(+) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index d80a250cac..53801a29ef 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -5821,6 +5821,9 @@ qemuMigrationDstComplete(virQEMUDriver *driver, =20 qemuMigrationParamsReset(driver, vm, asyncJob, jobPriv->migParams, priv->job.apiFlags); + + virPortAllocatorRelease(priv->migrationPort); + priv->migrationPort =3D 0; } =20 =20 diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index b039108ff7..d3769de496 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -3437,6 +3437,8 @@ qemuProcessCleanupMigrationJob(virQEMUDriver *driver, priv->job.asyncJob !=3D VIR_ASYNC_JOB_MIGRATION_OUT) return; =20 + virPortAllocatorRelease(priv->migrationPort); + priv->migrationPort =3D 0; qemuDomainObjDiscardAsyncJob(vm); } =20 --=20 2.35.1 From nobody Wed May 15 19:27:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1654087904; cv=none; d=zohomail.com; s=zohoarc; b=NeMU5TLlfCfSS6fgaQxWAeskv0loX1Gc5OaOds6utDs5RudntrPRDqAN+W7bpWo6+TO5ka7NOJOIPleI5YPRU9kIjeuNwxLGkkFPzzvN81YCwITuElQoAG3KTlWUyfcIhmlvzzI5QWyEop7bf91cO9Zw0UkgJ8nW3tZU5N1thNk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654087904; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=FTjMRbmGz3LFAQ5tvJXSPe8Z39uguy4ZQ0tmVdWGUew=; b=iyoFSZG417diRTIDTd5gbFqNNXKLFubPrWp6sN/Y7V0DQVBdPPBr1a8Sih93Vs+AbNhfWDSdPkyj7iUjSVTrFxW9UIAysAj/h5kyhUoooIyBoU7lBkX06Y5wX1ldgMbV+Ncy/U9+anpMk2ROXXgPDFv+vQ4t7QQXC0krKXgGia4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1654087904698142.3467589894109; Wed, 1 Jun 2022 05:51:44 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-399-vXQpyU4GMxSQ1RSVx_Gsew-1; Wed, 01 Jun 2022 08:51:39 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3411F88436C; Wed, 1 Jun 2022 12:50:44 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1BE933323E; Wed, 1 Jun 2022 12:50:44 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 97C4E193F6C8; Wed, 1 Jun 2022 12:50:40 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 228411947B8F for ; Wed, 1 Jun 2022 12:50:30 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 013D1417E43; Wed, 1 Jun 2022 12:50:30 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.227]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D4784492C3B; Wed, 1 Jun 2022 12:50:29 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 90CDB245B71; Wed, 1 Jun 2022 14:50:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654087903; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=FTjMRbmGz3LFAQ5tvJXSPe8Z39uguy4ZQ0tmVdWGUew=; b=Mv0QV7RL5QAB47lL3qyZ/pkGtkdrlnvtMTQoIdOW3tzlO4FI+TPjcG9LEJE/mVK8Di8pMc xdR756eERMBNZY6jBKhScdxC4ZRQRVU7HxPJzTrqI8HVNQntjpRqtTsXwhDWlsJ6n6J+kc p/PtA/Jw8g/JXKu8otrIB5YeDp5HYec= X-MC-Unique: vXQpyU4GMxSQ1RSVx_Gsew-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH v2 37/81] qemu: Pass qemuDomainJobObj to qemuMigrationDstComplete Date: Wed, 1 Jun 2022 14:49:37 +0200 Message-Id: <8e8e7a2925cde3d2a6e6fc87940394aad8cb2911.1654087150.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Krempa , Pavel Hrdina Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1654087906017100001 Content-Type: text/plain; charset="utf-8" When reconnecting to an active domain we need to use a different job structure than the one referenced from the VM object. Signed-off-by: Jiri Denemark Reviewed-by: Peter Krempa Reviewed-by: Pavel Hrdina --- Notes: Version 2: - fixed a typo in the commit message src/qemu/qemu_migration.c | 11 ++++++----- src/qemu/qemu_migration.h | 3 ++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 53801a29ef..95b69108dc 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -5773,10 +5773,11 @@ void qemuMigrationDstComplete(virQEMUDriver *driver, virDomainObj *vm, bool inPostCopy, - virDomainAsyncJob asyncJob) + virDomainAsyncJob asyncJob, + qemuDomainJobObj *job) { qemuDomainObjPrivate *priv =3D vm->privateData; - qemuDomainJobPrivate *jobPriv =3D priv->job.privateData; + qemuDomainJobPrivate *jobPriv =3D job->privateData; virObjectEvent *event; =20 if (inPostCopy) { @@ -5817,10 +5818,10 @@ qemuMigrationDstComplete(virQEMUDriver *driver, * is obsolete anyway. */ if (inPostCopy) - g_clear_pointer(&priv->job.completed, virDomainJobDataFree); + g_clear_pointer(&job->completed, virDomainJobDataFree); =20 qemuMigrationParamsReset(driver, vm, asyncJob, jobPriv->migParams, - priv->job.apiFlags); + job->apiFlags); =20 virPortAllocatorRelease(priv->migrationPort); priv->migrationPort =3D 0; @@ -6052,7 +6053,7 @@ qemuMigrationDstFinishActive(virQEMUDriver *driver, VIR_WARN("Unable to encode migration cookie"); =20 qemuMigrationDstComplete(driver, vm, inPostCopy, - VIR_ASYNC_JOB_MIGRATION_IN); + VIR_ASYNC_JOB_MIGRATION_IN, &priv->job); =20 return dom; =20 diff --git a/src/qemu/qemu_migration.h b/src/qemu/qemu_migration.h index 1d6051859b..c099cf99cf 100644 --- a/src/qemu/qemu_migration.h +++ b/src/qemu/qemu_migration.h @@ -195,7 +195,8 @@ void qemuMigrationDstComplete(virQEMUDriver *driver, virDomainObj *vm, bool inPostCopy, - virDomainAsyncJob asyncJob); + virDomainAsyncJob asyncJob, + qemuDomainJobObj *job); =20 int qemuMigrationSrcConfirm(virQEMUDriver *driver, --=20 2.35.1 From nobody Wed May 15 19:27:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1654087935; cv=none; d=zohomail.com; s=zohoarc; b=Pnv9Ecvivkc1hl0fKv+5oiIsvs989JC0qZjA+fuE2ONUPLLMtZ4VYRnSy+0E6atz6fyZUC311qfznzWeFRInIqsUrJp92n52QyZbanURe14okPpl8/OWhw6wmMSABDi8atQzp/Ut82Yswq6jS6rF/lVCik87yfy2szHkeHEA2EM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654087935; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=iCIv8CTUYs2SucDNxv08kPFiO5DvP/6jq49YehYjAVk=; b=C4BaiEa8/BWwbmCCuB1HdsclMNt2zFRxMjLAFWXP/hcetWEVKPbaWPjIice51yLpcTbySx5W2ffEw/En2IZb1k8YQT2reSE4rXvD93VgQrLFfzkBxyQAtl8ODSy7m5Iz19FCT8ufnbNgbSffCfrbLH1doAHQ3DfBY+gwr42xJag= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1654087935855802.3609806321439; Wed, 1 Jun 2022 05:52:15 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-228-XLvJvsjLMJKBEeA50CRE9Q-1; Wed, 01 Jun 2022 08:51:40 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 32CEC382ECF0; Wed, 1 Jun 2022 12:50:49 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1DB282026D07; Wed, 1 Jun 2022 12:50:49 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 3D77F1955EDB; Wed, 1 Jun 2022 12:50:45 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 50FF61947B99 for ; Wed, 1 Jun 2022 12:50:30 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 22D112166B2E; Wed, 1 Jun 2022 12:50:30 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.227]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D72852166B33; Wed, 1 Jun 2022 12:50:29 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 922AB245B72; Wed, 1 Jun 2022 14:50:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654087934; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=iCIv8CTUYs2SucDNxv08kPFiO5DvP/6jq49YehYjAVk=; b=J8LZUKY1vAz/72J9EQ9J3q7ApGLQEjWwgYVnO2BSDxdlM0ChNewpRIU3RUuYEtKWAT1+q2 L4yqWpghATr8LCVDBCz9HkX9P9D8PbMI0e6t25pgWnUBxYEetJqgmPkchD+0LPlIEZI1+E hAN4/G4KeOWyMXmaRH/o8c1OnbNsdnA= X-MC-Unique: XLvJvsjLMJKBEeA50CRE9Q-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH v2 38/81] qemu: Finish completed unattended migration Date: Wed, 1 Jun 2022 14:49:38 +0200 Message-Id: <81afadffa4365c9e364398a6f806eb79f49ac175.1654087150.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Krempa , Pavel Hrdina Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1654087936166100017 Content-Type: text/plain; charset="utf-8" So far migration could only be completed while a migration API was running and waiting for the migration to finish. In case such API could not be called (the connection that initiated the migration is broken) the migration would just be aborted or left in a "don't know what to do" state. But this will change soon and we will be able to successfully complete such migration once we get the corresponding event from QEMU. This is specific to post-copy migration when vCPUs are already running on the destination and we're only waiting for all memory pages to be transferred. Such post-copy migration (which no-one is actively watching) is called unattended migration. Signed-off-by: Jiri Denemark Reviewed-by: Peter Krempa Reviewed-by: Pavel Hrdina --- Notes: Version 2: - no change src/qemu/qemu_domain.c | 1 + src/qemu/qemu_domain.h | 1 + src/qemu/qemu_driver.c | 5 +++++ src/qemu/qemu_migration.c | 43 +++++++++++++++++++++++++++++++++++++-- src/qemu/qemu_migration.h | 6 ++++++ src/qemu/qemu_process.c | 12 ++++++++++- 6 files changed, 65 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 5dee9c6f26..d04ec6cd0c 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -11114,6 +11114,7 @@ qemuProcessEventFree(struct qemuProcessEvent *event) qemuMonitorMemoryDeviceSizeChangeFree(event->data); break; case QEMU_PROCESS_EVENT_PR_DISCONNECT: + case QEMU_PROCESS_EVENT_UNATTENDED_MIGRATION: case QEMU_PROCESS_EVENT_LAST: break; } diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index ce2dba499c..153dfe3a23 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -426,6 +426,7 @@ typedef enum { QEMU_PROCESS_EVENT_RDMA_GID_STATUS_CHANGED, QEMU_PROCESS_EVENT_GUEST_CRASHLOADED, QEMU_PROCESS_EVENT_MEMORY_DEVICE_SIZE_CHANGE, + QEMU_PROCESS_EVENT_UNATTENDED_MIGRATION, =20 QEMU_PROCESS_EVENT_LAST } qemuProcessEventType; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 28cb454ab7..4edf5635c0 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -4307,6 +4307,11 @@ static void qemuProcessEventHandler(void *data, void= *opaque) case QEMU_PROCESS_EVENT_MEMORY_DEVICE_SIZE_CHANGE: processMemoryDeviceSizeChange(driver, vm, processEvent->data); break; + case QEMU_PROCESS_EVENT_UNATTENDED_MIGRATION: + qemuMigrationProcessUnattended(driver, vm, + processEvent->action, + processEvent->status); + break; case QEMU_PROCESS_EVENT_LAST: break; } diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 95b69108dc..d427840d14 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -5811,8 +5811,11 @@ qemuMigrationDstComplete(virQEMUDriver *driver, =20 qemuDomainSaveStatus(vm); =20 - /* Guest is successfully running, so cancel previous auto destroy */ - qemuProcessAutoDestroyRemove(driver, vm); + /* Guest is successfully running, so cancel previous auto destroy. The= re's + * nothing to remove when we are resuming post-copy migration. + */ + if (!virDomainObjIsFailedPostcopy(vm)) + qemuProcessAutoDestroyRemove(driver, vm); =20 /* Remove completed stats for post-copy, everything but timing fields * is obsolete anyway. @@ -6179,6 +6182,42 @@ qemuMigrationDstFinish(virQEMUDriver *driver, } =20 =20 +void +qemuMigrationProcessUnattended(virQEMUDriver *driver, + virDomainObj *vm, + virDomainAsyncJob job, + qemuMonitorMigrationStatus status) +{ + qemuDomainObjPrivate *priv =3D vm->privateData; + qemuMigrationJobPhase phase; + + if (!qemuMigrationJobIsActive(vm, job) || + status !=3D QEMU_MONITOR_MIGRATION_STATUS_COMPLETED) + return; + + VIR_DEBUG("Unattended %s migration of domain %s successfully finished", + job =3D=3D VIR_ASYNC_JOB_MIGRATION_IN ? "incoming" : "outgoi= ng", + vm->def->name); + + if (job =3D=3D VIR_ASYNC_JOB_MIGRATION_IN) + phase =3D QEMU_MIGRATION_PHASE_FINISH3; + else + phase =3D QEMU_MIGRATION_PHASE_CONFIRM3; + + qemuMigrationJobStartPhase(vm, phase); + + if (job =3D=3D VIR_ASYNC_JOB_MIGRATION_IN) + qemuMigrationDstComplete(driver, vm, true, job, &priv->job); + else + qemuMigrationSrcComplete(driver, vm, job); + + qemuMigrationJobFinish(vm); + + if (!virDomainObjIsActive(vm)) + qemuDomainRemoveInactive(driver, vm); +} + + /* Helper function called while vm is active. */ int qemuMigrationSrcToFile(virQEMUDriver *driver, virDomainObj *vm, diff --git a/src/qemu/qemu_migration.h b/src/qemu/qemu_migration.h index c099cf99cf..eeb69a52bf 100644 --- a/src/qemu/qemu_migration.h +++ b/src/qemu/qemu_migration.h @@ -211,6 +211,12 @@ qemuMigrationSrcComplete(virQEMUDriver *driver, virDomainObj *vm, virDomainAsyncJob asyncJob); =20 +void +qemuMigrationProcessUnattended(virQEMUDriver *driver, + virDomainObj *vm, + virDomainAsyncJob job, + qemuMonitorMigrationStatus status); + bool qemuMigrationSrcIsAllowed(virQEMUDriver *driver, virDomainObj *vm, diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index d3769de496..97d84893be 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -1549,12 +1549,22 @@ qemuProcessHandleMigrationStatus(qemuMonitor *mon G= _GNUC_UNUSED, } break; =20 + case QEMU_MONITOR_MIGRATION_STATUS_COMPLETED: + /* A post-copy migration marked as failed when reconnecting to a d= omain + * with running migration may actually still be running, but we're= not + * watching it in any thread. Let's make sure the migration is pro= perly + * finished in case we get a "completed" event. + */ + if (virDomainObjIsFailedPostcopy(vm) && priv->job.asyncOwner =3D= =3D 0) + qemuProcessEventSubmit(vm, QEMU_PROCESS_EVENT_UNATTENDED_MIGRA= TION, + priv->job.asyncJob, status, NULL); + break; + case QEMU_MONITOR_MIGRATION_STATUS_INACTIVE: case QEMU_MONITOR_MIGRATION_STATUS_SETUP: case QEMU_MONITOR_MIGRATION_STATUS_ACTIVE: case QEMU_MONITOR_MIGRATION_STATUS_PRE_SWITCHOVER: case QEMU_MONITOR_MIGRATION_STATUS_DEVICE: - case QEMU_MONITOR_MIGRATION_STATUS_COMPLETED: case QEMU_MONITOR_MIGRATION_STATUS_ERROR: case QEMU_MONITOR_MIGRATION_STATUS_CANCELLING: case QEMU_MONITOR_MIGRATION_STATUS_CANCELLED: --=20 2.35.1 From nobody Wed May 15 19:27:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1654088288; cv=none; d=zohomail.com; s=zohoarc; b=MlP+ge6I8lALa3JwdimkfijJqSAGSpiuplYrZqpmgo+p02X7JuO0MISGJqqAUPAM8qIj9+wlW8hWZVfTUobvDqe735/5ThJxILgl16vGqB066s53Y3H4ZSuh3Pr15GK1Axp59QOhWVtSoSmJNICRciW2P0GmAW29Ab7OtHoscYk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654088288; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=xV4OEQnkn9yC1UP5tu62W4+GtV5vMUcT5ldZ94xf0hU=; b=gpZYJeYn2yvbFMcvE1r6/kneDIbXaBw7jounst9iv6iJpnXadHZ7rQz9IPyCdfJ23WiNMff0GTHf/V6wAlgExA67QqbSlHUTvje539Bdq+y4ZQqOs6Ks9Ta8E/o9kdJYTuCKByNQweVlWPfxsfJ+ucq/gmgdP6xTVlF1fK+BX5Y= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1654088288446562.9796786572905; Wed, 1 Jun 2022 05:58:08 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-152-rk6AEJRwMGCRdLYyAJ24uw-1; Wed, 01 Jun 2022 08:51:45 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4095E88606B; Wed, 1 Jun 2022 12:50:53 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 278892026D07; Wed, 1 Jun 2022 12:50:53 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id A8AF41932200; Wed, 1 Jun 2022 12:50:49 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 94DCD1947B91 for ; Wed, 1 Jun 2022 12:50:30 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 6780F1415101; Wed, 1 Jun 2022 12:50:30 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.227]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 29E751415106; Wed, 1 Jun 2022 12:50:30 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 938D7245B73; Wed, 1 Jun 2022 14:50:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654088287; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=xV4OEQnkn9yC1UP5tu62W4+GtV5vMUcT5ldZ94xf0hU=; b=X40E/DMASx7mCNmaNZwjx3mv3J3P9E9buz7rzYlnI5V1BHev3XSJma5bqHhdPXd7qeJPyW AuZMkoKxInB7cCZFk6JC6VjFfwkrOsfJ9Fcr4NpCd3BTFbdIAxhYp7M245lgt6ruJ6w7M1 ql9Lzd6BfesInHbK1YqQnUnT3FeJI0A= X-MC-Unique: rk6AEJRwMGCRdLYyAJ24uw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH v2 39/81] qemu: Ignore missing memory statistics in query-migrate Date: Wed, 1 Jun 2022 14:49:39 +0200 Message-Id: <46044b1b28d711a5f0299d4b1bcf67a891632f30.1654087150.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Krempa , Pavel Hrdina Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1654088288982100001 Content-Type: text/plain; charset="utf-8" We want to use query-migrate QMP command to check the current migration state when reconnecting to active domains, but the reply we get to this command may not contain any statistics at all if called on the destination host. Signed-off-by: Jiri Denemark Reviewed-by: Peter Krempa Reviewed-by: Pavel Hrdina --- Notes: Version 2: - dropped line breaks from error messages src/qemu/qemu_monitor_json.c | 85 +++++++++++++++++------------------- 1 file changed, 39 insertions(+), 46 deletions(-) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 83d0600a75..86b7f615c8 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -3249,56 +3249,49 @@ qemuMonitorJSONGetMigrationStatsReply(virJSONValue = *reply, case QEMU_MONITOR_MIGRATION_STATUS_PRE_SWITCHOVER: case QEMU_MONITOR_MIGRATION_STATUS_DEVICE: ram =3D virJSONValueObjectGetObject(ret, "ram"); - if (!ram) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("migration was active, but no RAM info was se= t")); - return -1; - } + if (ram) { + if (virJSONValueObjectGetNumberUlong(ram, "transferred", + &stats->ram_transferred) = < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("migration was active, but RAM 'transferr= ed' data was missing")); + return -1; + } + if (virJSONValueObjectGetNumberUlong(ram, "remaining", + &stats->ram_remaining) < = 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("migration was active, but RAM 'remaining= ' data was missing")); + return -1; + } + if (virJSONValueObjectGetNumberUlong(ram, "total", + &stats->ram_total) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("migration was active, but RAM 'total' da= ta was missing")); + return -1; + } =20 - if (virJSONValueObjectGetNumberUlong(ram, "transferred", - &stats->ram_transferred) < 0)= { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("migration was active, but RAM 'transferred' " - "data was missing")); - return -1; - } - if (virJSONValueObjectGetNumberUlong(ram, "remaining", - &stats->ram_remaining) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("migration was active, but RAM 'remaining' " - "data was missing")); - return -1; - } - if (virJSONValueObjectGetNumberUlong(ram, "total", - &stats->ram_total) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("migration was active, but RAM 'total' " - "data was missing")); - return -1; - } + if (virJSONValueObjectGetNumberDouble(ram, "mbps", &mbps) =3D= =3D 0 && + mbps > 0) { + /* mpbs from QEMU reports Mbits/s (M as in 10^6 not Mi as = 2^20) */ + stats->ram_bps =3D mbps * (1000 * 1000 / 8); + } =20 - if (virJSONValueObjectGetNumberDouble(ram, "mbps", &mbps) =3D=3D 0= && - mbps > 0) { - /* mpbs from QEMU reports Mbits/s (M as in 10^6 not Mi as 2^20= ) */ - stats->ram_bps =3D mbps * (1000 * 1000 / 8); + if (virJSONValueObjectGetNumberUlong(ram, "duplicate", + &stats->ram_duplicate) = =3D=3D 0) + stats->ram_duplicate_set =3D true; + ignore_value(virJSONValueObjectGetNumberUlong(ram, "normal", + &stats->ram_norm= al)); + ignore_value(virJSONValueObjectGetNumberUlong(ram, "normal-byt= es", + &stats->ram_norm= al_bytes)); + ignore_value(virJSONValueObjectGetNumberUlong(ram, "dirty-page= s-rate", + &stats->ram_dirt= y_rate)); + ignore_value(virJSONValueObjectGetNumberUlong(ram, "page-size", + &stats->ram_page= _size)); + ignore_value(virJSONValueObjectGetNumberUlong(ram, "dirty-sync= -count", + &stats->ram_iter= ation)); + ignore_value(virJSONValueObjectGetNumberUlong(ram, "postcopy-r= equests", + &stats->ram_post= copy_reqs)); } =20 - if (virJSONValueObjectGetNumberUlong(ram, "duplicate", - &stats->ram_duplicate) =3D=3D= 0) - stats->ram_duplicate_set =3D true; - ignore_value(virJSONValueObjectGetNumberUlong(ram, "normal", - &stats->ram_normal)); - ignore_value(virJSONValueObjectGetNumberUlong(ram, "normal-bytes", - &stats->ram_normal_b= ytes)); - ignore_value(virJSONValueObjectGetNumberUlong(ram, "dirty-pages-ra= te", - &stats->ram_dirty_ra= te)); - ignore_value(virJSONValueObjectGetNumberUlong(ram, "page-size", - &stats->ram_page_siz= e)); - ignore_value(virJSONValueObjectGetNumberUlong(ram, "dirty-sync-cou= nt", - &stats->ram_iteratio= n)); - ignore_value(virJSONValueObjectGetNumberUlong(ram, "postcopy-reque= sts", - &stats->ram_postcopy= _reqs)); - disk =3D virJSONValueObjectGetObject(ret, "disk"); if (disk) { rc =3D virJSONValueObjectGetNumberUlong(disk, "transferred", --=20 2.35.1 From nobody Wed May 15 19:27:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1654087899; cv=none; d=zohomail.com; s=zohoarc; b=X7Z+gOw+HNJgCxeyJ9C8mFX42jKrPqnrpfKrUio8OOLLFqDdRX1Kcyg2+MEmE4OFAWrAqG09qKlFHoKnqOlf8QlRstVF1LMJ7SzlhnxEmZrBwY1Sug0mnf20Jr7Uy5lY+FmlSxlQ/u1gth41gIzy8MQ6wfNuqiRHDLt+IGu7iy8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654087899; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=aoTmFc0KmXst8b5qGWG1bglRekqsyLM8vDP/HvIjWRk=; b=bAGeKX4KY720tRHaEaL1F80AH9panCEXhRwLYIZmcUR7mnOUSkHkYYDQvUFGLq7qPNcAyxU+/9ziUq10+7XnB1gf8DAqe6ppkmtFe240G80Jh+/UTYF+sBG+rJdCW1yQ0d8RNmVzLt02HBH7NXzstL4uwpwWfEpb2NiFqY7H9xA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 165408789938272.313334980788; Wed, 1 Jun 2022 05:51:39 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-600-G0bgd-cgNFCmdpB0mD-T-Q-1; Wed, 01 Jun 2022 08:51:30 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9C0372802B4C; Wed, 1 Jun 2022 12:50:46 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 87F642024CB7; Wed, 1 Jun 2022 12:50:46 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id E65451947B94; Wed, 1 Jun 2022 12:50:42 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 517051947B9A for ; Wed, 1 Jun 2022 12:50:30 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 3580440CF8EB; Wed, 1 Jun 2022 12:50:30 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.227]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E9E7740CFD0D; Wed, 1 Jun 2022 12:50:29 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 94F29245B74; Wed, 1 Jun 2022 14:50:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654087898; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=aoTmFc0KmXst8b5qGWG1bglRekqsyLM8vDP/HvIjWRk=; b=OngW4Xjf/b58bgpISxKXlQFgilwo/vlwQI0lDlxgETQmvfEs99AzgVAWmBY00u85+zQKBV S55JQQsrEdmXxe2y35s3q7uRQdWzEtCdsix7DI8m+KflIJPbc+nGphQvWEXrFvrZNmeSDY wWx8O9oD9yCGuoJv8Z33iW3R0mBDwcI= X-MC-Unique: G0bgd-cgNFCmdpB0mD-T-Q-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH v2 40/81] qemu: Improve post-copy migration handling on reconnect Date: Wed, 1 Jun 2022 14:49:40 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Krempa , Pavel Hrdina Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1654087900023100001 Content-Type: text/plain; charset="utf-8" When libvirt daemon is restarted during an active post-copy migration, we do not always mark the migration as broken. In this phase libvirt is not really needed for migration to finish successfully. In fact the migration could have even finished while libvirt was not running or it may still be happily running. Signed-off-by: Jiri Denemark Reviewed-by: Peter Krempa Reviewed-by: Pavel Hrdina --- Notes: Version 2: - dropped line breaks from debug messages src/qemu/qemu_migration.c | 26 ++++++++++++++++++++++++++ src/qemu/qemu_migration.h | 6 ++++++ src/qemu/qemu_process.c | 39 +++++++++++++++++++++++++++++---------- 3 files changed, 61 insertions(+), 10 deletions(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index d427840d14..5765647ad7 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -2432,6 +2432,32 @@ qemuMigrationSrcBeginPhaseBlockDirtyBitmaps(qemuMigr= ationCookie *mig, } =20 =20 +int +qemuMigrationAnyRefreshStatus(virQEMUDriver *driver, + virDomainObj *vm, + virDomainAsyncJob asyncJob, + virDomainJobStatus *status) +{ + g_autoptr(virDomainJobData) jobData =3D NULL; + qemuDomainJobDataPrivate *priv; + + jobData =3D virDomainJobDataInit(&qemuJobDataPrivateDataCallbacks); + priv =3D jobData->privateData; + + if (qemuMigrationAnyFetchStats(driver, vm, asyncJob, jobData, NULL) < = 0) + return -1; + + qemuMigrationUpdateJobType(jobData); + VIR_DEBUG("QEMU reports domain '%s' is in '%s' migration state, transl= ated as %d", + vm->def->name, + qemuMonitorMigrationStatusTypeToString(priv->stats.mig.statu= s), + jobData->status); + + *status =3D jobData->status; + return 0; +} + + /* The caller is supposed to lock the vm and start a migration job. */ static char * qemuMigrationSrcBeginPhase(virQEMUDriver *driver, diff --git a/src/qemu/qemu_migration.h b/src/qemu/qemu_migration.h index eeb69a52bf..9351d6ac51 100644 --- a/src/qemu/qemu_migration.h +++ b/src/qemu/qemu_migration.h @@ -279,3 +279,9 @@ qemuMigrationSrcFetchMirrorStats(virQEMUDriver *driver, virDomainObj *vm, virDomainAsyncJob asyncJob, virDomainJobData *jobData); + +int +qemuMigrationAnyRefreshStatus(virQEMUDriver *driver, + virDomainObj *vm, + virDomainAsyncJob asyncJob, + virDomainJobStatus *status); diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 97d84893be..6dd643a38b 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -3532,10 +3532,8 @@ qemuProcessRecoverMigrationIn(virQEMUDriver *driver, /* migration finished, we started resuming the domain but didn't * confirm success or failure yet; killing it seems safest unless * we already started guest CPUs or we were in post-copy mode */ - if (virDomainObjIsPostcopy(vm, VIR_DOMAIN_JOB_OPERATION_MIGRATION_= IN)) { - qemuMigrationDstPostcopyFailed(vm); + if (virDomainObjIsPostcopy(vm, VIR_DOMAIN_JOB_OPERATION_MIGRATION_= IN)) return 1; - } =20 if (state !=3D VIR_DOMAIN_RUNNING) { VIR_DEBUG("Killing migrated domain %s", vm->def->name); @@ -3602,10 +3600,8 @@ qemuProcessRecoverMigrationOut(virQEMUDriver *driver, * of Finish3 step; third party needs to check what to do next; in * post-copy mode we can use PAUSED_POSTCOPY_FAILED state for this */ - if (postcopy) { - qemuMigrationSrcPostcopyFailed(vm); + if (postcopy) return 1; - } break; =20 case QEMU_MIGRATION_PHASE_CONFIRM3_CANCELLED: @@ -3613,10 +3609,8 @@ qemuProcessRecoverMigrationOut(virQEMUDriver *driver, * post-copy mode there's no way back, so let's just mark the doma= in * as broken in that case */ - if (postcopy) { - qemuMigrationSrcPostcopyFailed(vm); + if (postcopy) return 1; - } =20 VIR_DEBUG("Resuming domain %s after failed migration", vm->def->name); @@ -3654,6 +3648,7 @@ qemuProcessRecoverMigration(virQEMUDriver *driver, qemuDomainJobObj *job, unsigned int *stopFlags) { + virDomainJobStatus migStatus =3D VIR_DOMAIN_JOB_STATUS_NONE; qemuDomainJobPrivate *jobPriv =3D job->privateData; virDomainState state; int reason; @@ -3661,6 +3656,8 @@ qemuProcessRecoverMigration(virQEMUDriver *driver, =20 state =3D virDomainObjGetState(vm, &reason); =20 + qemuMigrationAnyRefreshStatus(driver, vm, VIR_ASYNC_JOB_NONE, &migStat= us); + if (job->asyncJob =3D=3D VIR_ASYNC_JOB_MIGRATION_OUT) { rc =3D qemuProcessRecoverMigrationOut(driver, vm, job, state, reason, stopFlags); @@ -3672,7 +3669,29 @@ qemuProcessRecoverMigration(virQEMUDriver *driver, return -1; =20 if (rc > 0) { - qemuProcessRestoreMigrationJob(vm, job); + if (migStatus =3D=3D VIR_DOMAIN_JOB_STATUS_POSTCOPY) { + VIR_DEBUG("Post-copy migration of domain %s still running, it = will be handled as unattended", + vm->def->name); + qemuProcessRestoreMigrationJob(vm, job); + return 0; + } + + if (migStatus !=3D VIR_DOMAIN_JOB_STATUS_HYPERVISOR_COMPLETED) { + if (job->asyncJob =3D=3D VIR_ASYNC_JOB_MIGRATION_OUT) + qemuMigrationSrcPostcopyFailed(vm); + else + qemuMigrationDstPostcopyFailed(vm); + + qemuProcessRestoreMigrationJob(vm, job); + return 0; + } + + VIR_DEBUG("Post-copy migration of domain %s already finished", + vm->def->name); + if (job->asyncJob =3D=3D VIR_ASYNC_JOB_MIGRATION_OUT) + qemuMigrationSrcComplete(driver, vm, VIR_ASYNC_JOB_NONE); + else + qemuMigrationDstComplete(driver, vm, true, VIR_ASYNC_JOB_NONE,= job); return 0; } =20 --=20 2.35.1 From nobody Wed May 15 19:27:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1654087989; cv=none; d=zohomail.com; s=zohoarc; b=bIRoHsKLttF9M8l9uXvoyZvJPH5gbGDCHQ2RFtth/k8biGD2KjXnEV0yzZrGIoTykfMmGYXJ8jhc3TQOPd72VBEybx7xTDOGIi+TR7tkSEJwN8ogO1Dpbs4DiDCXq9VOCiThG/zvgEw7qDdLYPe7ZzP8uRxA+6ZerMqc9RhYUXk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654087989; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=SKaaq2EnFXNZKf8/imSPmLlVkZ+4SlBHsoffjiO7doU=; b=lml3dLPUOp1tBvJz2hlkfosqv+A1vG1xM7XMmxvI3iOps75qELJXlFT4y1+Zf7umHiuB8ph+GHei31J6flZGvsNov1UPk4G3fVMQUiTvDcPp2XsQD45UfIlemQu6m+oSLrsonKcEqLjqfuFp+ykVH7+PH6P3AEHNdWDmEdCPQBQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1654087989152340.9784898119376; Wed, 1 Jun 2022 05:53:09 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-183-EScE5YqEMGu7xelFCgdMbw-1; Wed, 01 Jun 2022 08:51:39 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9CF87833B06; Wed, 1 Jun 2022 12:50:50 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 83BE8C28103; Wed, 1 Jun 2022 12:50:50 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id D8E4D1932220; Wed, 1 Jun 2022 12:50:46 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 273531947B90 for ; Wed, 1 Jun 2022 12:50:30 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 144AF492CA4; Wed, 1 Jun 2022 12:50:30 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.227]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E729A492C3B; Wed, 1 Jun 2022 12:50:29 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 9642F245B75; Wed, 1 Jun 2022 14:50:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654087988; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=SKaaq2EnFXNZKf8/imSPmLlVkZ+4SlBHsoffjiO7doU=; b=ZgXulRoAD4MUqwUNLLza8aRKAv7fU/cKC11Umn7WklMfieKmrAcmzTqVoU2OdmHB3VJnuz Az6dgnOQlbK1ealWlCFLh8nXvrQ3HxZra+SPODRKOajmGC9RUoZkwjdUKX5PfmEQeiePaK iGSTvDO+BpXABI3RWHGFlgzbZoIVZHQ= X-MC-Unique: EScE5YqEMGu7xelFCgdMbw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH v2 41/81] qemu: Check flags incompatible with offline migration earlier Date: Wed, 1 Jun 2022 14:49:41 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Krempa , Pavel Hrdina Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1654087990428100011 Content-Type: text/plain; charset="utf-8" Signed-off-by: Jiri Denemark Reviewed-by: Peter Krempa Reviewed-by: Pavel Hrdina --- Notes: Version 2: - dropped line breaks from error messages src/qemu/qemu_migration.c | 41 ++++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 5765647ad7..4e3d823806 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -2512,6 +2512,25 @@ qemuMigrationSrcBeginPhase(virQEMUDriver *driver, return NULL; } =20 + if (flags & VIR_MIGRATE_OFFLINE) { + if (flags & (VIR_MIGRATE_NON_SHARED_DISK | + VIR_MIGRATE_NON_SHARED_INC)) { + virReportError(VIR_ERR_OPERATION_INVALID, "%s", + _("offline migration cannot handle non-shared s= torage")); + return NULL; + } + if (!(flags & VIR_MIGRATE_PERSIST_DEST)) { + virReportError(VIR_ERR_OPERATION_INVALID, "%s", + _("offline migration must be specified with the= persistent flag set")); + return NULL; + } + if (flags & VIR_MIGRATE_TUNNELLED) { + virReportError(VIR_ERR_OPERATION_INVALID, "%s", + _("tunnelled offline migration does not make se= nse")); + return NULL; + } + } + if (flags & (VIR_MIGRATE_NON_SHARED_DISK | VIR_MIGRATE_NON_SHARED_INC)= ) { if (flags & VIR_MIGRATE_NON_SHARED_SYNCHRONOUS_WRITES && !virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV)) { @@ -2591,28 +2610,6 @@ qemuMigrationSrcBeginPhase(virQEMUDriver *driver, cookieFlags) < 0) return NULL; =20 - if (flags & VIR_MIGRATE_OFFLINE) { - if (flags & (VIR_MIGRATE_NON_SHARED_DISK | - VIR_MIGRATE_NON_SHARED_INC)) { - virReportError(VIR_ERR_OPERATION_INVALID, "%s", - _("offline migration cannot handle " - "non-shared storage")); - return NULL; - } - if (!(flags & VIR_MIGRATE_PERSIST_DEST)) { - virReportError(VIR_ERR_OPERATION_INVALID, "%s", - _("offline migration must be specified with " - "the persistent flag set")); - return NULL; - } - if (flags & VIR_MIGRATE_TUNNELLED) { - virReportError(VIR_ERR_OPERATION_INVALID, "%s", - _("tunnelled offline migration does not " - "make sense")); - return NULL; - } - } - if (xmlin) { if (!(def =3D virDomainDefParseString(xmlin, driver->xmlopt, priv-= >qemuCaps, VIR_DOMAIN_DEF_PARSE_INACTIVE | --=20 2.35.1 From nobody Wed May 15 19:27:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1654088048; cv=none; d=zohomail.com; s=zohoarc; b=kc+E1I4yoG3dkMZh0AF24XSY9/p0TTTwHR4skkGk4nxVnrRHWnUW3iWEOA84aJDhGm7X/WKylB6i3oFvWkwVUt1nBZiTuKX8h2UdKZzX7GAU92etScnov2fPLRkV7AqEC5yVH6ZmKV6z0+cY7XKCVikxjWSwQmF/hQt/xdXl1Ns= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654088048; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=rMvmDji0d8aUyXFSauxvfIcAN5SuuOHYiibApBVwAkQ=; b=iQTMlwAxqNQ43VsvMfUIG3R6GMsVO8NoGAxYHjBELbacl4FoT4xBSnn/l+Kn/UzTxyEVTZph9Wbua8ilMZ568VvJT22ANx7HoJQ91T53XamIZzzJ8tPASrSWRmxFP9pA480xVKx0gqiowZCvNYoKGCWPs1h11Abazhw8eqNi/j8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1654088048639315.904102222093; Wed, 1 Jun 2022 05:54:08 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-39-HvMqLzDiPnKylko4WQn-vw-1; Wed, 01 Jun 2022 08:51:28 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BB34D18E6C70; Wed, 1 Jun 2022 12:50:39 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id A7DFD400F75F; Wed, 1 Jun 2022 12:50:39 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id E8CD61955ECA; Wed, 1 Jun 2022 12:50:36 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 59B4D1947B9C for ; Wed, 1 Jun 2022 12:50:30 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 30D7840314B; Wed, 1 Jun 2022 12:50:30 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.227]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E748740F06C; Wed, 1 Jun 2022 12:50:29 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 97A0A245B76; Wed, 1 Jun 2022 14:50:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654088047; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=rMvmDji0d8aUyXFSauxvfIcAN5SuuOHYiibApBVwAkQ=; b=F50Y8hLjiLeh7roiamb5QZInIj6iG5BSjK3kq/F5MKzXHcLQjulJibCcHqJPMzRwTx08oV 4SkGRTsELNkkNFNmHZNMHOQQPm9jAwHHXiB/FnhcvLHEx7xedu7BV9KXN+RdQg/diOX1u8 G/jbjGHQ63MDrRlnt9oIYpkFp8+nuUw= X-MC-Unique: HvMqLzDiPnKylko4WQn-vw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH v2 42/81] qemu: Introduce qemuMigrationSrcBeginXML helper Date: Wed, 1 Jun 2022 14:49:42 +0200 Message-Id: <40171e3002ed6cced7f84f603715bd0306ea1877.1654087150.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Krempa , Pavel Hrdina Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1654088050733100003 Content-Type: text/plain; charset="utf-8" Turn the final part of Begin phase formatting a domain XML for migration into a reusable helper. Signed-off-by: Jiri Denemark Reviewed-by: Peter Krempa Reviewed-by: Pavel Hrdina --- Notes: Version 2: - dropped driver parameter from qemuMigrationSrcBeginXML src/qemu/qemu_migration.c | 95 ++++++++++++++++++++++++--------------- 1 file changed, 58 insertions(+), 37 deletions(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 4e3d823806..02827bd975 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -2458,6 +2458,60 @@ qemuMigrationAnyRefreshStatus(virQEMUDriver *driver, } =20 =20 +static char * +qemuMigrationSrcBeginXML(virDomainObj *vm, + const char *xmlin, + char **cookieout, + int *cookieoutlen, + unsigned int cookieFlags, + const char **migrate_disks, + size_t nmigrate_disks, + unsigned long flags) +{ + qemuDomainObjPrivate *priv =3D vm->privateData; + virQEMUDriver *driver =3D priv->driver; + g_autoptr(qemuMigrationCookie) mig =3D NULL; + + if (priv->origCPU) + cookieFlags |=3D QEMU_MIGRATION_COOKIE_CPU; + + if (!(flags & VIR_MIGRATE_OFFLINE)) + cookieFlags |=3D QEMU_MIGRATION_COOKIE_CAPS; + + if (!(mig =3D qemuMigrationCookieNew(vm->def, priv->origname))) + return NULL; + + if (cookieFlags & QEMU_MIGRATION_COOKIE_NBD && + virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_MIGRATION_PARAM_BLOCK_BIT= MAP_MAPPING) && + qemuMigrationSrcBeginPhaseBlockDirtyBitmaps(mig, vm, migrate_disks, + nmigrate_disks) < 0) + return NULL; + + if (qemuMigrationCookieFormat(mig, driver, vm, + QEMU_MIGRATION_SOURCE, + cookieout, cookieoutlen, + cookieFlags) < 0) + return NULL; + + if (xmlin) { + g_autoptr(virDomainDef) def =3D NULL; + + if (!(def =3D virDomainDefParseString(xmlin, driver->xmlopt, priv-= >qemuCaps, + VIR_DOMAIN_DEF_PARSE_INACTIVE | + VIR_DOMAIN_DEF_PARSE_SKIP_VALI= DATE))) + return NULL; + + if (!qemuDomainCheckABIStability(driver, vm, def)) + return NULL; + + return qemuDomainDefFormatLive(driver, priv->qemuCaps, def, NULL, = false, true); + } + + return qemuDomainDefFormatLive(driver, priv->qemuCaps, vm->def, priv->= origCPU, + false, true); +} + + /* The caller is supposed to lock the vm and start a migration job. */ static char * qemuMigrationSrcBeginPhase(virQEMUDriver *driver, @@ -2470,8 +2524,6 @@ qemuMigrationSrcBeginPhase(virQEMUDriver *driver, const char **migrate_disks, unsigned long flags) { - g_autoptr(qemuMigrationCookie) mig =3D NULL; - g_autoptr(virDomainDef) def =3D NULL; qemuDomainObjPrivate *priv =3D vm->privateData; unsigned int cookieFlags =3D QEMU_MIGRATION_COOKIE_LOCKSTATE; =20 @@ -2589,41 +2641,10 @@ qemuMigrationSrcBeginPhase(virQEMUDriver *driver, vm->newDef && !qemuDomainVcpuHotplugIsInOrder(vm->newDef))) cookieFlags |=3D QEMU_MIGRATION_COOKIE_CPU_HOTPLUG; =20 - if (priv->origCPU) - cookieFlags |=3D QEMU_MIGRATION_COOKIE_CPU; - - if (!(flags & VIR_MIGRATE_OFFLINE)) - cookieFlags |=3D QEMU_MIGRATION_COOKIE_CAPS; - - if (!(mig =3D qemuMigrationCookieNew(vm->def, priv->origname))) - return NULL; - - if (cookieFlags & QEMU_MIGRATION_COOKIE_NBD && - virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_MIGRATION_PARAM_BLOCK_BIT= MAP_MAPPING) && - qemuMigrationSrcBeginPhaseBlockDirtyBitmaps(mig, vm, migrate_disks, - nmigrate_disks) < 0) - return NULL; - - if (qemuMigrationCookieFormat(mig, driver, vm, - QEMU_MIGRATION_SOURCE, - cookieout, cookieoutlen, - cookieFlags) < 0) - return NULL; - - if (xmlin) { - if (!(def =3D virDomainDefParseString(xmlin, driver->xmlopt, priv-= >qemuCaps, - VIR_DOMAIN_DEF_PARSE_INACTIVE | - VIR_DOMAIN_DEF_PARSE_SKIP_VALI= DATE))) - return NULL; - - if (!qemuDomainCheckABIStability(driver, vm, def)) - return NULL; - - return qemuDomainDefFormatLive(driver, priv->qemuCaps, def, NULL, = false, true); - } else { - return qemuDomainDefFormatLive(driver, priv->qemuCaps, vm->def, pr= iv->origCPU, - false, true); - } + return qemuMigrationSrcBeginXML(vm, xmlin, + cookieout, cookieoutlen, cookieFlags, + migrate_disks, nmigrate_disks, + flags); } =20 char * --=20 2.35.1 From nobody Wed May 15 19:27:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1654087991; cv=none; d=zohomail.com; s=zohoarc; b=m2Dm+gnLDDCi0CsgD6RYUam3BlYFqDxRw473idPZ4NQhJN/07wSi3sk1sY9UCNQJ2zbGrAR8KUjnkvRfvYMXGf7sgGjuySHGMJ+GclNmkyRARQ6bttrDYmqBxIYqXS1KYvPFnzDhOOVHK50uKBRbcZTGPmJLvhCBJeO/iRMSvOk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654087991; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=em8gjzt5rJ5hl1DgC7gQt9dHMo20V82g1yNznEnxjvM=; b=T5XoIrPKut0aymM1oJi0tnqfi/IvASDLpyDsN38ZRsCEEfvFwXi1mSyPBBVtCugowzdwIuImFeFU7FhOI3fD6s18Uge616wKKg1ctF3zF6gzVN2z/S5mHTUf60b4ija8d3RpWesmgrSuuoEYyfIre8pH6mMySw8baa5a1JGbfcE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1654087991681550.0734391184294; Wed, 1 Jun 2022 05:53:11 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-658-QhZKV1GAPDGdWpzVcTUFzQ-1; Wed, 01 Jun 2022 08:51:34 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 08BC21C08DA5; Wed, 1 Jun 2022 12:50:46 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id E7F27C15E72; Wed, 1 Jun 2022 12:50:45 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 91DD4193221A; Wed, 1 Jun 2022 12:50:42 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 5A2F41947B9F for ; Wed, 1 Jun 2022 12:50:30 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 3737240CFD13; Wed, 1 Jun 2022 12:50:30 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.227]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E9AEA40CFD0B; Wed, 1 Jun 2022 12:50:29 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 98FD5245B77; Wed, 1 Jun 2022 14:50:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654087990; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=em8gjzt5rJ5hl1DgC7gQt9dHMo20V82g1yNznEnxjvM=; b=aTHu5stXIf3Hz2I4qwA9wToXNT+v1bGomi3OOJWoiWYUWtQNH8R2nzmZRAFt1RYHp2+y+R OZWA7BMJ/ZEmL12Pmqa9akm2ofaVkHpsPYHD+xE4GvANwsR0ijEy+x3Wkt2KqBY2YuyLku jO9tYglNGUlPPEE8D6WGRYo4p6+0fXk= X-MC-Unique: QhZKV1GAPDGdWpzVcTUFzQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH v2 43/81] qemu: Add new migration phases for post-copy recovery Date: Wed, 1 Jun 2022 14:49:43 +0200 Message-Id: <8497a93a4aaaf363a820a1f599177726ac54f776.1654087150.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Krempa , Pavel Hrdina Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1654087992435100018 Content-Type: text/plain; charset="utf-8" When recovering from a failed post-copy migration, we need to go through all migration phases again, but don't need to repeat all the steps in each phase. Let's create a new set of migration phases dedicated to post-copy recovery so that we can easily distinguish between normal and recovery code. Signed-off-by: Jiri Denemark Reviewed-by: Peter Krempa Reviewed-by: Pavel Hrdina --- Notes: Version 2: - additional comments src/qemu/qemu_migration.c | 20 +++++++++++++++++++- src/qemu/qemu_migration.h | 6 ++++++ src/qemu/qemu_process.c | 29 +++++++++++++++++++++++++++-- 3 files changed, 52 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 02827bd975..710aae3eb7 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -79,6 +79,12 @@ VIR_ENUM_IMPL(qemuMigrationJobPhase, "prepare", "finish2", "finish3", + "postcopy_failed", + "begin_resume", + "perform_resume", + "confirm_resume", + "prepare_resume", + "finish_resume", ); =20 =20 @@ -139,7 +145,8 @@ qemuMigrationJobSetPhase(virDomainObj *vm, { qemuDomainObjPrivate *priv =3D vm->privateData; =20 - if (phase < priv->job.phase) { + if (phase < QEMU_MIGRATION_PHASE_POSTCOPY_FAILED && + phase < priv->job.phase) { VIR_ERROR(_("migration protocol going backwards %s =3D> %s"), qemuMigrationJobPhaseTypeToString(priv->job.phase), qemuMigrationJobPhaseTypeToString(phase)); @@ -2328,18 +2335,29 @@ qemuMigrationSrcCleanup(virDomainObj *vm, } break; =20 + case QEMU_MIGRATION_PHASE_BEGIN_RESUME: + case QEMU_MIGRATION_PHASE_PERFORM_RESUME: + qemuMigrationSrcPostcopyFailed(vm); + qemuDomainCleanupAdd(vm, qemuProcessCleanupMigrationJob); + qemuMigrationJobContinue(vm); + break; + case QEMU_MIGRATION_PHASE_PERFORM3: /* cannot be seen without an active migration API; unreachable */ case QEMU_MIGRATION_PHASE_CONFIRM3: case QEMU_MIGRATION_PHASE_CONFIRM3_CANCELLED: + case QEMU_MIGRATION_PHASE_CONFIRM_RESUME: /* all done; unreachable */ case QEMU_MIGRATION_PHASE_PREPARE: case QEMU_MIGRATION_PHASE_FINISH2: case QEMU_MIGRATION_PHASE_FINISH3: + case QEMU_MIGRATION_PHASE_PREPARE_RESUME: + case QEMU_MIGRATION_PHASE_FINISH_RESUME: /* incoming migration; unreachable */ case QEMU_MIGRATION_PHASE_PERFORM2: /* single phase outgoing migration; unreachable */ case QEMU_MIGRATION_PHASE_NONE: + case QEMU_MIGRATION_PHASE_POSTCOPY_FAILED: case QEMU_MIGRATION_PHASE_LAST: /* unreachable */ ; diff --git a/src/qemu/qemu_migration.h b/src/qemu/qemu_migration.h index 9351d6ac51..7eb0d4fe02 100644 --- a/src/qemu/qemu_migration.h +++ b/src/qemu/qemu_migration.h @@ -100,6 +100,12 @@ typedef enum { QEMU_MIGRATION_PHASE_PREPARE, QEMU_MIGRATION_PHASE_FINISH2, QEMU_MIGRATION_PHASE_FINISH3, + QEMU_MIGRATION_PHASE_POSTCOPY_FAILED, /* marker for resume phases */ + QEMU_MIGRATION_PHASE_BEGIN_RESUME, + QEMU_MIGRATION_PHASE_PERFORM_RESUME, + QEMU_MIGRATION_PHASE_CONFIRM_RESUME, + QEMU_MIGRATION_PHASE_PREPARE_RESUME, + QEMU_MIGRATION_PHASE_FINISH_RESUME, =20 QEMU_MIGRATION_PHASE_LAST } qemuMigrationJobPhase; diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 6dd643a38b..f752668b2f 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -3507,6 +3507,10 @@ qemuProcessRecoverMigrationIn(virQEMUDriver *driver, case QEMU_MIGRATION_PHASE_PERFORM3_DONE: case QEMU_MIGRATION_PHASE_CONFIRM3_CANCELLED: case QEMU_MIGRATION_PHASE_CONFIRM3: + case QEMU_MIGRATION_PHASE_POSTCOPY_FAILED: + case QEMU_MIGRATION_PHASE_BEGIN_RESUME: + case QEMU_MIGRATION_PHASE_PERFORM_RESUME: + case QEMU_MIGRATION_PHASE_CONFIRM_RESUME: case QEMU_MIGRATION_PHASE_LAST: /* N/A for incoming migration */ break; @@ -3540,6 +3544,10 @@ qemuProcessRecoverMigrationIn(virQEMUDriver *driver, return -1; } break; + + case QEMU_MIGRATION_PHASE_PREPARE_RESUME: + case QEMU_MIGRATION_PHASE_FINISH_RESUME: + return 1; } =20 return 0; @@ -3548,7 +3556,8 @@ qemuProcessRecoverMigrationIn(virQEMUDriver *driver, =20 /* * Returns - * -1 on error, the domain will be killed, + * -1 the domain should be killed (either after a successful migration= or + * on error), * 0 the domain should remain running with the migration job discarde= d, * 1 the daemon was restarted during post-copy phase */ @@ -3556,6 +3565,7 @@ static int qemuProcessRecoverMigrationOut(virQEMUDriver *driver, virDomainObj *vm, qemuDomainJobObj *job, + virDomainJobStatus migStatus, virDomainState state, int reason, unsigned int *stopFlags) @@ -3571,6 +3581,9 @@ qemuProcessRecoverMigrationOut(virQEMUDriver *driver, case QEMU_MIGRATION_PHASE_PREPARE: case QEMU_MIGRATION_PHASE_FINISH2: case QEMU_MIGRATION_PHASE_FINISH3: + case QEMU_MIGRATION_PHASE_POSTCOPY_FAILED: + case QEMU_MIGRATION_PHASE_PREPARE_RESUME: + case QEMU_MIGRATION_PHASE_FINISH_RESUME: case QEMU_MIGRATION_PHASE_LAST: /* N/A for outgoing migration */ break; @@ -3621,6 +3634,18 @@ qemuProcessRecoverMigrationOut(virQEMUDriver *driver, /* migration completed, we need to kill the domain here */ *stopFlags |=3D VIR_QEMU_PROCESS_STOP_MIGRATED; return -1; + + case QEMU_MIGRATION_PHASE_CONFIRM_RESUME: + if (migStatus =3D=3D VIR_DOMAIN_JOB_STATUS_HYPERVISOR_COMPLETED) { + /* migration completed, we need to kill the domain here */ + *stopFlags |=3D VIR_QEMU_PROCESS_STOP_MIGRATED; + return -1; + } + return 1; + + case QEMU_MIGRATION_PHASE_BEGIN_RESUME: + case QEMU_MIGRATION_PHASE_PERFORM_RESUME: + return 1; } =20 if (resume) { @@ -3659,7 +3684,7 @@ qemuProcessRecoverMigration(virQEMUDriver *driver, qemuMigrationAnyRefreshStatus(driver, vm, VIR_ASYNC_JOB_NONE, &migStat= us); =20 if (job->asyncJob =3D=3D VIR_ASYNC_JOB_MIGRATION_OUT) { - rc =3D qemuProcessRecoverMigrationOut(driver, vm, job, + rc =3D qemuProcessRecoverMigrationOut(driver, vm, job, migStatus, state, reason, stopFlags); } else { rc =3D qemuProcessRecoverMigrationIn(driver, vm, job, state); --=20 2.35.1 From nobody Wed May 15 19:27:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1654087985; cv=none; d=zohomail.com; s=zohoarc; b=JcKf5cdl3kJgIVikbrVyx79LBSMfISMgk3BD38KaaMoflEjisPN55qAl97OI/PVT9Wivo/cPNs5mJM83jdojkrMDRc4gz2wEJEXla4xihJOMYBMGDkvjQ5lHOHgVyscclaJLd0WnbzNEJ+OGpVAWLvaZ/jDCxzK4qcsX+fvERNQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654087985; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=p/bGq0GHpi+bmXIvvTlhGiFzvn7rzIfLlxc/mucoQzU=; b=eholReb19adrmge1OFtAvOqJVYpXFKHMI6MGU5NYNIU8pXS676wB2uQpHXrcD1DcpIJePtpMM6PsIR1iz7ZaOyJTkFR06mHUk7/enL+9wMK5tBYFAXQC5RKTFi5Cifr/vogDFIcB0FWQU4xm8Z0O7W8v8JsE+uufxUQMLTdP+d4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1654087985187942.5385672004842; Wed, 1 Jun 2022 05:53:05 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-470-c0RdHV3OO2uPjwb_wSyK9A-1; Wed, 01 Jun 2022 08:51:40 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 456B03C222FA; Wed, 1 Jun 2022 12:50:45 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2ACC6C27E8F; Wed, 1 Jun 2022 12:50:45 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id DC8951947B8E; Wed, 1 Jun 2022 12:50:41 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 32B461947B91 for ; Wed, 1 Jun 2022 12:50:30 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 195AC1415103; Wed, 1 Jun 2022 12:50:30 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.227]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EAF5C1410F36; Wed, 1 Jun 2022 12:50:29 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 9A496245B78; Wed, 1 Jun 2022 14:50:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654087984; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=p/bGq0GHpi+bmXIvvTlhGiFzvn7rzIfLlxc/mucoQzU=; b=gvli/phgcSGSmU6g3zvMBJHMKHP0Qx5v0VJIOAYzBgZ4DN4bdCBaLes/8R6tf7oi3E2on/ m3yYtw/YrVutKdPuqe7Tg18Dw0sFd5KcB1/UQ6lLpNzE4kzus/Hxwh0nzjoB42lkzbXjJI 7PAyrt9kwFqIb3sDELXe4GpAoM6uZWc= X-MC-Unique: c0RdHV3OO2uPjwb_wSyK9A-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH v2 44/81] qemu: Separate protocol checks from qemuMigrationJobSetPhase Date: Wed, 1 Jun 2022 14:49:44 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Krempa , Pavel Hrdina Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1654087986382100003 Content-Type: text/plain; charset="utf-8" Into a new qemuMigrationCheckPhase helper, which can be reused in other places. Signed-off-by: Jiri Denemark Reviewed-by: Peter Krempa Reviewed-by: Pavel Hrdina --- Notes: Version 2: - no change src/qemu/qemu_migration.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 710aae3eb7..edd3ac2a87 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -139,9 +139,9 @@ qemuMigrationJobStart(virQEMUDriver *driver, } =20 =20 -static void ATTRIBUTE_NONNULL(1) -qemuMigrationJobSetPhase(virDomainObj *vm, - qemuMigrationJobPhase phase) +static int +qemuMigrationCheckPhase(virDomainObj *vm, + qemuMigrationJobPhase phase) { qemuDomainObjPrivate *priv =3D vm->privateData; =20 @@ -150,9 +150,20 @@ qemuMigrationJobSetPhase(virDomainObj *vm, VIR_ERROR(_("migration protocol going backwards %s =3D> %s"), qemuMigrationJobPhaseTypeToString(priv->job.phase), qemuMigrationJobPhaseTypeToString(phase)); - return; + return -1; } =20 + return 0; +} + + +static void ATTRIBUTE_NONNULL(1) +qemuMigrationJobSetPhase(virDomainObj *vm, + qemuMigrationJobPhase phase) +{ + if (qemuMigrationCheckPhase(vm, phase) < 0) + return; + qemuDomainObjSetJobPhase(vm, phase); } =20 --=20 2.35.1 From nobody Wed May 15 19:27:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1654088103; cv=none; d=zohomail.com; s=zohoarc; b=l56lqvpGgKh/TDT6fImaNCbSWMQL7exm5m3BpaomyJPNgoiyAY8jr2wAeqVC64QCUuZ59hyTjwhFpXgBO/e9yY4e0L+VUo4S9reFE+4uX2pj3oP4jF87OcNElMlQMPmX47wb11GzXvn6PMgIvmIGezuKFWK9GF/OjdSgzS9el+A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654088103; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=bOiLi+Y0J5VoRnW3VNR1BQy1RiOmSFvqWqDIIzAy+BQ=; b=c+krHUp/8NlKBzbfLUq3sJEcO0L5WKRU0nW81sUb1/9d33vFeA5/9HzZREK5KXMj69f/b7oNeAruVdFmMvfRQ9kJKLCAH4I4thlQvRZeoW9vMcgupBr/GanwFaJgqUqQ54aAFwyrHFtQJaZyo9KAzum0l7mmaSJLkxGIARHl6x4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1654088103514550.8106589603871; Wed, 1 Jun 2022 05:55:03 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-376-YGamzZRENbuG-qPPzCX50w-1; Wed, 01 Jun 2022 08:51:42 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6ADA2180A5D5; Wed, 1 Jun 2022 12:50:52 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 565CAC28103; Wed, 1 Jun 2022 12:50:52 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id ED1D91937755; Wed, 1 Jun 2022 12:50:48 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 79B141947B90 for ; Wed, 1 Jun 2022 12:50:30 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 3F1FA112131B; Wed, 1 Jun 2022 12:50:30 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.227]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 02AB81121319 for ; Wed, 1 Jun 2022 12:50:29 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 9BA2C245B79; Wed, 1 Jun 2022 14:50:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654088102; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=bOiLi+Y0J5VoRnW3VNR1BQy1RiOmSFvqWqDIIzAy+BQ=; b=MSNI1nnrjQJ/i+iui7Eik7nViGgE5JMLRBMCA61FLzzgoKSxpdWmqQmOD/YElk1gYvE+hm DBBYD3jIKOJNVk14g6wwBXBphXUee4+KKn2Xn8rbda6O7G5VVMZ1dEvOv3G+HDzxeB/YVi H8QIIt1874N9VBipcfBvJpEzhDaW+1Y= X-MC-Unique: YGamzZRENbuG-qPPzCX50w-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH v2 45/81] qemu: Make qemuMigrationCheckPhase failure fatal Date: Wed, 1 Jun 2022 14:49:45 +0200 Message-Id: <72abb82fcc238b35ef94d6b073af0e9e5282de95.1654087150.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1654088105069100001 Content-Type: text/plain; charset="utf-8" The check can reveal a serious bug in our migration code and we should not silently ignore it. Signed-off-by: Jiri Denemark Reviewed-by: Peter Krempa --- Notes: Version 2: - no change src/qemu/qemu_migration.c | 58 ++++++++++++++++++++++++--------------- 1 file changed, 36 insertions(+), 22 deletions(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index edd3ac2a87..4c09caeace 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -147,9 +147,10 @@ qemuMigrationCheckPhase(virDomainObj *vm, =20 if (phase < QEMU_MIGRATION_PHASE_POSTCOPY_FAILED && phase < priv->job.phase) { - VIR_ERROR(_("migration protocol going backwards %s =3D> %s"), - qemuMigrationJobPhaseTypeToString(priv->job.phase), - qemuMigrationJobPhaseTypeToString(phase)); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("migration protocol going backwards %s =3D> %s"), + qemuMigrationJobPhaseTypeToString(priv->job.phase), + qemuMigrationJobPhaseTypeToString(phase)); return -1; } =20 @@ -157,22 +158,23 @@ qemuMigrationCheckPhase(virDomainObj *vm, } =20 =20 -static void ATTRIBUTE_NONNULL(1) +static int G_GNUC_WARN_UNUSED_RESULT qemuMigrationJobSetPhase(virDomainObj *vm, qemuMigrationJobPhase phase) { if (qemuMigrationCheckPhase(vm, phase) < 0) - return; + return -1; =20 qemuDomainObjSetJobPhase(vm, phase); + return 0; } =20 =20 -static void ATTRIBUTE_NONNULL(1) +static int G_GNUC_WARN_UNUSED_RESULT qemuMigrationJobStartPhase(virDomainObj *vm, qemuMigrationJobPhase phase) { - qemuMigrationJobSetPhase(vm, phase); + return qemuMigrationJobSetPhase(vm, phase); } =20 =20 @@ -2567,8 +2569,9 @@ qemuMigrationSrcBeginPhase(virQEMUDriver *driver, * Otherwise we will start the async job later in the perform phase lo= sing * change protection. */ - if (priv->job.asyncJob =3D=3D VIR_ASYNC_JOB_MIGRATION_OUT) - qemuMigrationJobSetPhase(vm, QEMU_MIGRATION_PHASE_BEGIN3); + if (priv->job.asyncJob =3D=3D VIR_ASYNC_JOB_MIGRATION_OUT && + qemuMigrationJobSetPhase(vm, QEMU_MIGRATION_PHASE_BEGIN3) < 0) + return NULL; =20 if (!qemuMigrationSrcIsAllowed(driver, vm, true, flags)) return NULL; @@ -3117,7 +3120,9 @@ qemuMigrationDstPrepareAny(virQEMUDriver *driver, if (qemuMigrationJobStart(driver, vm, VIR_ASYNC_JOB_MIGRATION_IN, flags) < 0) goto cleanup; - qemuMigrationJobSetPhase(vm, QEMU_MIGRATION_PHASE_PREPARE); + + if (qemuMigrationJobSetPhase(vm, QEMU_MIGRATION_PHASE_PREPARE) < 0) + goto stopjob; =20 /* Domain starts inactive, even if the domain XML had an id field. */ vm->def->id =3D -1; @@ -3637,7 +3642,8 @@ qemuMigrationSrcConfirmPhase(virQEMUDriver *driver, else phase =3D QEMU_MIGRATION_PHASE_CONFIRM3_CANCELLED; =20 - qemuMigrationJobSetPhase(vm, phase); + if (qemuMigrationJobSetPhase(vm, phase) < 0) + return -1; =20 if (!(mig =3D qemuMigrationCookieParse(driver, vm->def, priv->origname= , priv, cookiein, cookieinlen, @@ -3722,7 +3728,9 @@ qemuMigrationSrcConfirm(virQEMUDriver *driver, else phase =3D QEMU_MIGRATION_PHASE_CONFIRM3; =20 - qemuMigrationJobStartPhase(vm, phase); + if (qemuMigrationJobStartPhase(vm, phase) < 0) + goto cleanup; + virCloseCallbacksUnset(driver->closeCallbacks, vm, qemuMigrationSrcCleanup); qemuDomainCleanupRemove(vm, qemuProcessCleanupMigrationJob); @@ -4885,7 +4893,7 @@ qemuMigrationSrcPerformPeer2Peer2(virQEMUDriver *driv= er, * until the migration is complete. */ VIR_DEBUG("Perform %p", sconn); - qemuMigrationJobSetPhase(vm, QEMU_MIGRATION_PHASE_PERFORM2); + ignore_value(qemuMigrationJobSetPhase(vm, QEMU_MIGRATION_PHASE_PERFORM= 2)); if (flags & VIR_MIGRATE_TUNNELLED) ret =3D qemuMigrationSrcPerformTunnel(driver, vm, st, NULL, NULL, 0, NULL, NULL, @@ -5129,7 +5137,7 @@ qemuMigrationSrcPerformPeer2Peer3(virQEMUDriver *driv= er, * confirm migration completion. */ VIR_DEBUG("Perform3 %p uri=3D%s", sconn, NULLSTR(uri)); - qemuMigrationJobSetPhase(vm, QEMU_MIGRATION_PHASE_PERFORM3); + ignore_value(qemuMigrationJobSetPhase(vm, QEMU_MIGRATION_PHASE_PERFORM= 3)); VIR_FREE(cookiein); cookiein =3D g_steal_pointer(&cookieout); cookieinlen =3D cookieoutlen; @@ -5154,7 +5162,7 @@ qemuMigrationSrcPerformPeer2Peer3(virQEMUDriver *driv= er, if (ret < 0) { virErrorPreserveLast(&orig_err); } else { - qemuMigrationJobSetPhase(vm, QEMU_MIGRATION_PHASE_PERFORM3_DONE); + ignore_value(qemuMigrationJobSetPhase(vm, QEMU_MIGRATION_PHASE_PER= FORM3_DONE)); } =20 /* If Perform returns < 0, then we need to cancel the VM @@ -5530,7 +5538,9 @@ qemuMigrationSrcPerformJob(virQEMUDriver *driver, migParams, flags, dname, re= source, &v3proto); } else { - qemuMigrationJobSetPhase(vm, QEMU_MIGRATION_PHASE_PERFORM2); + if (qemuMigrationJobSetPhase(vm, QEMU_MIGRATION_PHASE_PERFORM2) < = 0) + goto endjob; + ret =3D qemuMigrationSrcPerformNative(driver, vm, persist_xml, uri= , cookiein, cookieinlen, cookieout, cookieoutlen, flags, resource, NULL, NULL, 0= , NULL, @@ -5622,7 +5632,9 @@ qemuMigrationSrcPerformPhase(virQEMUDriver *driver, return ret; } =20 - qemuMigrationJobStartPhase(vm, QEMU_MIGRATION_PHASE_PERFORM3); + if (qemuMigrationJobStartPhase(vm, QEMU_MIGRATION_PHASE_PERFORM3) < 0) + goto endjob; + virCloseCallbacksUnset(driver->closeCallbacks, vm, qemuMigrationSrcCleanup); =20 @@ -5636,7 +5648,7 @@ qemuMigrationSrcPerformPhase(virQEMUDriver *driver, goto endjob; } =20 - qemuMigrationJobSetPhase(vm, QEMU_MIGRATION_PHASE_PERFORM3_DONE); + ignore_value(qemuMigrationJobSetPhase(vm, QEMU_MIGRATION_PHASE_PERFORM= 3_DONE)); =20 if (virCloseCallbacksSet(driver->closeCallbacks, vm, conn, qemuMigrationSrcCleanup) < 0) @@ -6203,9 +6215,10 @@ qemuMigrationDstFinish(virQEMUDriver *driver, =20 ignore_value(virTimeMillisNow(&timeReceived)); =20 - qemuMigrationJobStartPhase(vm, - v3proto ? QEMU_MIGRATION_PHASE_FINISH3 - : QEMU_MIGRATION_PHASE_FINISH2); + if (qemuMigrationJobStartPhase(vm, + v3proto ? QEMU_MIGRATION_PHASE_FINISH3 + : QEMU_MIGRATION_PHASE_FINISH2)= < 0) + goto cleanup; =20 qemuDomainCleanupRemove(vm, qemuMigrationDstPrepareCleanup); g_clear_pointer(&priv->job.completed, virDomainJobDataFree); @@ -6277,7 +6290,8 @@ qemuMigrationProcessUnattended(virQEMUDriver *driver, else phase =3D QEMU_MIGRATION_PHASE_CONFIRM3; =20 - qemuMigrationJobStartPhase(vm, phase); + if (qemuMigrationJobStartPhase(vm, phase) < 0) + return; =20 if (job =3D=3D VIR_ASYNC_JOB_MIGRATION_IN) qemuMigrationDstComplete(driver, vm, true, job, &priv->job); --=20 2.35.1 From nobody Wed May 15 19:27:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1654087904; cv=none; d=zohomail.com; s=zohoarc; b=BAuJj/A+aHx8xvW3hfqz4pEXxz3yaSEY7n2jbK2JxnD3mYnXhP8uKLxbuK6UsQY6U5PW5m/aeb4q95bz3++LfdIilwIY2XhSlmDdH9wT8psfbmUCm9IT4V2Dgolbkdc/baGpKbEh/b/rFJA/BbhGcvtiQUPPqzkWpOf+bX2Xqow= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654087904; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=1poNsUhjAL88lobxneHa1PSBN8SDDswIsWwwNEmyzqY=; b=aKKzh0u0jOrsMqzohIRg1qwbFc11kOv6IFsRU5ZeL2gc0OFm3Zv9MaJL/wH6dujg7Jy3Gay/BWewsXqBo2qidby+5MdAxS40GHyXh8zkigM2k4yDWQov4nVsdaDSNYZqMGRQWg3KEn7/upugfVkFe5fc/XnZd57TNFKwcKU4kE0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 16540879040836.554216516993847; Wed, 1 Jun 2022 05:51:44 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-628-i3Q0QtPdPkiqgU2jE7BM0Q-1; Wed, 01 Jun 2022 08:51:34 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6F676886069; Wed, 1 Jun 2022 12:50:45 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 574F240EC006; Wed, 1 Jun 2022 12:50:45 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 0A6E71955ECD; Wed, 1 Jun 2022 12:50:42 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 57E95194706A for ; Wed, 1 Jun 2022 12:50:30 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 22FDD8288C; Wed, 1 Jun 2022 12:50:30 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.227]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0207C82892; Wed, 1 Jun 2022 12:50:30 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 9CFE9245B7A; Wed, 1 Jun 2022 14:50:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654087903; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=1poNsUhjAL88lobxneHa1PSBN8SDDswIsWwwNEmyzqY=; b=HAosJ1ua70S6CJtMZcsGJVKdBtlfDs9xnFurxbYIJI1ccMyTPR88IA3BJBee0tniHj2Jks tRk3azyQPctAjREqgpYObM4W0onkhkSLsJkZNQXPXAX3KFjPpsRfn5qIWCbeE0z0iLoheC XbrGu0lW+EKFApSbtcGdNESN3/KXyMk= X-MC-Unique: i3Q0QtPdPkiqgU2jE7BM0Q-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH v2 46/81] qemu: Refactor qemuDomainObjSetJobPhase Date: Wed, 1 Jun 2022 14:49:46 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Krempa , Pavel Hrdina Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1654087906030100004 Content-Type: text/plain; charset="utf-8" We will want to update migration phase without affecting job ownership. Either in the thread that already owns the job or from an event handler which only changes the phase (of a job no-one owns) without assuming it. Let's move the ownership change to a new qemuDomainObjStartJobPhase helper and let qemuDomainObjSetJobPhase set the phase without touching ownership. Signed-off-by: Jiri Denemark Reviewed-by: Peter Krempa Reviewed-by: Pavel Hrdina --- Notes: Version 2: - no change src/qemu/qemu_domainjob.c | 44 +++++++++++++++++++++++++++++++++++---- src/qemu/qemu_domainjob.h | 3 +++ src/qemu/qemu_migration.c | 2 +- 3 files changed, 44 insertions(+), 5 deletions(-) diff --git a/src/qemu/qemu_domainjob.c b/src/qemu/qemu_domainjob.c index e76eb7f2cf..1f6d976558 100644 --- a/src/qemu/qemu_domainjob.c +++ b/src/qemu/qemu_domainjob.c @@ -717,6 +717,10 @@ qemuDomainJobDataToParams(virDomainJobData *jobData, } =20 =20 +/* + * Sets the job phase without changing the job owner. The owner is suppose= d to + * be 0 or the current thread, a warning is issued otherwise. + */ void qemuDomainObjSetJobPhase(virDomainObj *obj, int phase) @@ -731,19 +735,51 @@ qemuDomainObjSetJobPhase(virDomainObj *obj, virDomainAsyncJobTypeToString(priv->job.asyncJob), qemuDomainAsyncJobPhaseToString(priv->job.asyncJob, phase)); =20 + if (priv->job.asyncOwner !=3D 0 && + priv->job.asyncOwner !=3D me) { + VIR_WARN("'%s' async job is owned by thread %llu, API '%s'", + virDomainAsyncJobTypeToString(priv->job.asyncJob), + priv->job.asyncOwner, + NULLSTR(priv->job.asyncOwnerAPI)); + } + + priv->job.phase =3D phase; + qemuDomainSaveStatus(obj); +} + + +/* + * Changes the job owner and sets the job phase. The current owner is supp= osed + * to be 0 or the current thread, a warning is issued otherwise. + */ +void +qemuDomainObjStartJobPhase(virDomainObj *obj, + int phase) +{ + qemuDomainObjPrivate *priv =3D obj->privateData; + unsigned long long me =3D virThreadSelfID(); + + if (!priv->job.asyncJob) + return; + + VIR_DEBUG("Starting phase '%s' of '%s' job", + qemuDomainAsyncJobPhaseToString(priv->job.asyncJob, phase), + virDomainAsyncJobTypeToString(priv->job.asyncJob)); + if (priv->job.asyncOwner =3D=3D 0) { priv->job.asyncOwnerAPI =3D g_strdup(virThreadJobGet()); } else if (me !=3D priv->job.asyncOwner) { - VIR_WARN("'%s' async job is owned by thread %llu", + VIR_WARN("'%s' async job is owned by thread %llu, API '%s'", virDomainAsyncJobTypeToString(priv->job.asyncJob), - priv->job.asyncOwner); + priv->job.asyncOwner, + NULLSTR(priv->job.asyncOwnerAPI)); } =20 - priv->job.phase =3D phase; priv->job.asyncOwner =3D me; - qemuDomainSaveStatus(obj); + qemuDomainObjSetJobPhase(obj, phase); } =20 + void qemuDomainObjSetAsyncJobMask(virDomainObj *obj, unsigned long long allowedJobs) diff --git a/src/qemu/qemu_domainjob.h b/src/qemu/qemu_domainjob.h index 707d4e91ed..e8021a7f04 100644 --- a/src/qemu/qemu_domainjob.h +++ b/src/qemu/qemu_domainjob.h @@ -156,6 +156,9 @@ void qemuDomainObjEndAsyncJob(virDomainObj *obj); void qemuDomainObjAbortAsyncJob(virDomainObj *obj); void qemuDomainObjSetJobPhase(virDomainObj *obj, int phase); +void +qemuDomainObjStartJobPhase(virDomainObj *obj, + int phase); void qemuDomainObjSetAsyncJobMask(virDomainObj *obj, unsigned long long allowedJobs); int qemuDomainObjPreserveJob(virDomainObj *obj, diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 4c09caeace..1c015c0bcb 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -165,7 +165,7 @@ qemuMigrationJobSetPhase(virDomainObj *vm, if (qemuMigrationCheckPhase(vm, phase) < 0) return -1; =20 - qemuDomainObjSetJobPhase(vm, phase); + qemuDomainObjStartJobPhase(vm, phase); return 0; } =20 --=20 2.35.1 From nobody Wed May 15 19:27:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1654087943; cv=none; d=zohomail.com; s=zohoarc; b=UXMEM0QeNy7nwRE/NRvM54l8F04prdo5g1c4FUtPcl76I5lHy0Yy2q9rt7dHZp5ymb0rghE8kW26aKc9CSVSV3wlPigqwNgv85VkrPaWrwdjzrSYLqnKW4FaU447FNBcj3SNYjrkAbWfuWlk+4B89qGNY90ix9IG7IxB7HlrJkI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654087943; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=i3z1q5bf/SEzim8H0bpRg6+BLuCgAfho7hdzAHAJQ4w=; b=S4UVfvYrbIEzhbDoJMWAZL1lK8FOdBbRQmiw5TgWAV6N0T6l90SQNECrg/T/Q1lmmgnLJhfEhRjYcUwYG0SdAloHD8PmpTJBwpbYUsB1h8dfGk7vsApFXRKqF8dJ+4VgsxYJ/o39Nq79XARws38IMPUgK7a7t53pm8jh5LQW7pk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1654087943354407.1713425037175; Wed, 1 Jun 2022 05:52:23 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-500-VDd6nLsPP4yh3RjJhV4lJw-1; Wed, 01 Jun 2022 08:51:21 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4080718E6C40; Wed, 1 Jun 2022 12:50:39 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id ED9EC40EC002; Wed, 1 Jun 2022 12:50:38 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 69E59193220C; Wed, 1 Jun 2022 12:50:36 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 41EC11947B95 for ; Wed, 1 Jun 2022 12:50:30 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 2941240CFD10; Wed, 1 Jun 2022 12:50:30 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.227]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 03DED40CFD18; Wed, 1 Jun 2022 12:50:30 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 9E564245B7B; Wed, 1 Jun 2022 14:50:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654087942; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=i3z1q5bf/SEzim8H0bpRg6+BLuCgAfho7hdzAHAJQ4w=; b=ZJDNBvtlPJz6Jyy1bBa9qJ7c/9uwHnzNwPE7L+QaMWcChHjdqVqek0ddl2091SzSvDnrto yn2bSK2xEaxYwfV/3/nJdQiyOGVga+QSOFBwNhWv3mWTc679IW72OoMIoRJh9Qg1j8WZds sItYN72sqh6+FzpN6kHf/IptfkBVoTE= X-MC-Unique: VDd6nLsPP4yh3RjJhV4lJw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH v2 47/81] qemu: Do not set job owner in qemuMigrationJobSetPhase Date: Wed, 1 Jun 2022 14:49:47 +0200 Message-Id: <8a9e5af6eb46932e70e7eacae031f79453c6b6a9.1654087150.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Krempa , Pavel Hrdina Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1654087944215100005 Content-Type: text/plain; charset="utf-8" Both qemuMigrationJobSetPhase and qemuMigrationJobStartPhase were doing the same thing, which made little sense. Let's follow the difference between qemuDomainObjSetJobPhase and qemuDomainObjStartJobPhase and change job owner only in qemuMigrationJobStartPhase. Signed-off-by: Jiri Denemark Reviewed-by: Peter Krempa Reviewed-by: Pavel Hrdina --- Notes: Version 2: - no change src/qemu/qemu_migration.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 1c015c0bcb..88702c94e4 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -165,7 +165,7 @@ qemuMigrationJobSetPhase(virDomainObj *vm, if (qemuMigrationCheckPhase(vm, phase) < 0) return -1; =20 - qemuDomainObjStartJobPhase(vm, phase); + qemuDomainObjSetJobPhase(vm, phase); return 0; } =20 @@ -174,7 +174,11 @@ static int G_GNUC_WARN_UNUSED_RESULT qemuMigrationJobStartPhase(virDomainObj *vm, qemuMigrationJobPhase phase) { - return qemuMigrationJobSetPhase(vm, phase); + if (qemuMigrationCheckPhase(vm, phase) < 0) + return -1; + + qemuDomainObjStartJobPhase(vm, phase); + return 0; } =20 =20 @@ -2570,7 +2574,7 @@ qemuMigrationSrcBeginPhase(virQEMUDriver *driver, * change protection. */ if (priv->job.asyncJob =3D=3D VIR_ASYNC_JOB_MIGRATION_OUT && - qemuMigrationJobSetPhase(vm, QEMU_MIGRATION_PHASE_BEGIN3) < 0) + qemuMigrationJobStartPhase(vm, QEMU_MIGRATION_PHASE_BEGIN3) < 0) return NULL; =20 if (!qemuMigrationSrcIsAllowed(driver, vm, true, flags)) @@ -3121,7 +3125,7 @@ qemuMigrationDstPrepareAny(virQEMUDriver *driver, flags) < 0) goto cleanup; =20 - if (qemuMigrationJobSetPhase(vm, QEMU_MIGRATION_PHASE_PREPARE) < 0) + if (qemuMigrationJobStartPhase(vm, QEMU_MIGRATION_PHASE_PREPARE) < 0) goto stopjob; =20 /* Domain starts inactive, even if the domain XML had an id field. */ @@ -3642,7 +3646,7 @@ qemuMigrationSrcConfirmPhase(virQEMUDriver *driver, else phase =3D QEMU_MIGRATION_PHASE_CONFIRM3_CANCELLED; =20 - if (qemuMigrationJobSetPhase(vm, phase) < 0) + if (qemuMigrationJobStartPhase(vm, phase) < 0) return -1; =20 if (!(mig =3D qemuMigrationCookieParse(driver, vm->def, priv->origname= , priv, @@ -4893,7 +4897,7 @@ qemuMigrationSrcPerformPeer2Peer2(virQEMUDriver *driv= er, * until the migration is complete. */ VIR_DEBUG("Perform %p", sconn); - ignore_value(qemuMigrationJobSetPhase(vm, QEMU_MIGRATION_PHASE_PERFORM= 2)); + ignore_value(qemuMigrationJobStartPhase(vm, QEMU_MIGRATION_PHASE_PERFO= RM2)); if (flags & VIR_MIGRATE_TUNNELLED) ret =3D qemuMigrationSrcPerformTunnel(driver, vm, st, NULL, NULL, 0, NULL, NULL, @@ -5538,7 +5542,7 @@ qemuMigrationSrcPerformJob(virQEMUDriver *driver, migParams, flags, dname, re= source, &v3proto); } else { - if (qemuMigrationJobSetPhase(vm, QEMU_MIGRATION_PHASE_PERFORM2) < = 0) + if (qemuMigrationJobStartPhase(vm, QEMU_MIGRATION_PHASE_PERFORM2) = < 0) goto endjob; =20 ret =3D qemuMigrationSrcPerformNative(driver, vm, persist_xml, uri= , cookiein, cookieinlen, --=20 2.35.1 From nobody Wed May 15 19:27:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1654088176; cv=none; d=zohomail.com; s=zohoarc; b=I7SCjMvSDw8JEgEAhZhqesKuxGh1ZwFgoM4fYCwhusaqV7srxi0WSZxc3XL2b243NU3a6rzYqKpHaQSVJq61wntCtzI6Dihybxv+BsmjnEQO/4tKBl2mA6KZ/8qpWrgoEJHBDk8PoA4M62s5kM+/0iuGSqdGb/Fz9vAWrrRXeJk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654088176; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=eOmu8qokE6TS6HewJ2IaEGgsiz6J7n3Xn3+VkJ+mFUw=; b=mj9y3cGYqiIIrHsh+YlxawGu0hxdnGmKL3vSZX1PBoKI9lI+ZfiPyHkn4P9fndYy7BuweHEkgJUomI8cGvYjMHIn+C2dvhY0C0gGAWjcMfvQT4+/BJV7obJzne6jfEttu0s7+WDwtT7lhtaI27Jp6E1Yrt/dkWc5i46deY5TcJM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1654088176240205.97166196808485; Wed, 1 Jun 2022 05:56:16 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-103-tyJytPZjMRicycjYnf1b8A-1; Wed, 01 Jun 2022 08:55:59 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 63C5D3804062; Wed, 1 Jun 2022 12:55:55 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4F71D492C3B; Wed, 1 Jun 2022 12:55:55 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id D37EA1947BA7; Wed, 1 Jun 2022 12:55:53 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 43F591947B91 for ; Wed, 1 Jun 2022 12:55:53 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 1914C1731B; Wed, 1 Jun 2022 12:55:53 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.227]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D01243323E; Wed, 1 Jun 2022 12:55:52 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 9FC60245B7C; Wed, 1 Jun 2022 14:50:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654088174; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=eOmu8qokE6TS6HewJ2IaEGgsiz6J7n3Xn3+VkJ+mFUw=; b=FImSdYoIGvAQqcO8ZUZQanND3ALiy5el/RudgUZ99+WyFauX3zKXOz+ELpvURagUmZvqnY yly6isK2nq3aaA6z/hIaaKMEeYE9banPkt7lc8xgPOXKHTdP5dNlVn/mGH6Q8qCvPEJm6O WVqWQZOpiYf/3gkNmOX2tIuT5CpDeSk= X-MC-Unique: tyJytPZjMRicycjYnf1b8A-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH v2 48/81] qemu: Use QEMU_MIGRATION_PHASE_POSTCOPY_FAILED Date: Wed, 1 Jun 2022 14:49:48 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Krempa , Pavel Hrdina Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1654088177155100001 Content-Type: text/plain; charset="utf-8" This phase marks a migration protocol as broken in a post-copy phase. Libvirt is no longer actively watching the migration in this phase as the migration API that started the migration failed. This may either happen when post-copy migration really fails (QEMU enters postcopy-paused migration state) or when the migration still progresses between both QEMU processes, but libvirt lost control of it because the connection between libvirt daemons (in p2p migration) or a daemon and client (non-p2p migration) was closed. For example, when one of the daemons was restarted. Signed-off-by: Jiri Denemark Reviewed-by: Peter Krempa Reviewed-by: Pavel Hrdina --- Notes: Version 2: - moved most of the last hunk to a separate patch src/qemu/qemu_migration.c | 15 +++++++++++---- src/qemu/qemu_process.c | 11 ++++++++--- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 88702c94e4..302589b63c 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -2341,6 +2341,7 @@ qemuMigrationSrcCleanup(virDomainObj *vm, vm->def->name); =20 if (virDomainObjIsPostcopy(vm, VIR_DOMAIN_JOB_OPERATION_MIGRATION_= OUT)) { + ignore_value(qemuMigrationJobSetPhase(vm, QEMU_MIGRATION_PHASE= _POSTCOPY_FAILED)); qemuMigrationSrcPostcopyFailed(vm); qemuDomainCleanupAdd(vm, qemuProcessCleanupMigrationJob); qemuMigrationJobContinue(vm); @@ -2352,8 +2353,10 @@ qemuMigrationSrcCleanup(virDomainObj *vm, } break; =20 + case QEMU_MIGRATION_PHASE_POSTCOPY_FAILED: case QEMU_MIGRATION_PHASE_BEGIN_RESUME: case QEMU_MIGRATION_PHASE_PERFORM_RESUME: + ignore_value(qemuMigrationJobSetPhase(vm, QEMU_MIGRATION_PHASE_POS= TCOPY_FAILED)); qemuMigrationSrcPostcopyFailed(vm); qemuDomainCleanupAdd(vm, qemuProcessCleanupMigrationJob); qemuMigrationJobContinue(vm); @@ -2374,7 +2377,6 @@ qemuMigrationSrcCleanup(virDomainObj *vm, case QEMU_MIGRATION_PHASE_PERFORM2: /* single phase outgoing migration; unreachable */ case QEMU_MIGRATION_PHASE_NONE: - case QEMU_MIGRATION_PHASE_POSTCOPY_FAILED: case QEMU_MIGRATION_PHASE_LAST: /* unreachable */ ; @@ -3744,6 +3746,7 @@ qemuMigrationSrcConfirm(virQEMUDriver *driver, flags, cancelled); =20 if (virDomainObjIsFailedPostcopy(vm)) { + ignore_value(qemuMigrationJobSetPhase(vm, QEMU_MIGRATION_PHASE_POS= TCOPY_FAILED)); qemuDomainCleanupAdd(vm, qemuProcessCleanupMigrationJob); qemuMigrationJobContinue(vm); } else { @@ -5572,6 +5575,7 @@ qemuMigrationSrcPerformJob(virQEMUDriver *driver, virErrorPreserveLast(&orig_err); =20 if (virDomainObjIsFailedPostcopy(vm)) { + ignore_value(qemuMigrationJobSetPhase(vm, QEMU_MIGRATION_PHASE_POS= TCOPY_FAILED)); qemuDomainCleanupAdd(vm, qemuProcessCleanupMigrationJob); qemuMigrationJobContinue(vm); } else { @@ -5664,6 +5668,8 @@ qemuMigrationSrcPerformPhase(virQEMUDriver *driver, jobPriv->migParams, priv->job.apiFlags); qemuMigrationJobFinish(vm); } else { + if (ret < 0) + ignore_value(qemuMigrationJobSetPhase(vm, QEMU_MIGRATION_PHASE= _POSTCOPY_FAILED)); qemuDomainCleanupAdd(vm, qemuProcessCleanupMigrationJob); qemuMigrationJobContinue(vm); } @@ -5903,7 +5909,7 @@ qemuMigrationDstComplete(virQEMUDriver *driver, /* Guest is successfully running, so cancel previous auto destroy. The= re's * nothing to remove when we are resuming post-copy migration. */ - if (!virDomainObjIsFailedPostcopy(vm)) + if (job->phase < QEMU_MIGRATION_PHASE_POSTCOPY_FAILED) qemuProcessAutoDestroyRemove(driver, vm); =20 /* Remove completed stats for post-copy, everything but timing fields @@ -6170,6 +6176,7 @@ qemuMigrationDstFinishActive(virQEMUDriver *driver, } =20 if (virDomainObjIsFailedPostcopy(vm)) { + ignore_value(qemuMigrationJobSetPhase(vm, QEMU_MIGRATION_PHASE_POS= TCOPY_FAILED)); qemuProcessAutoDestroyRemove(driver, vm); qemuDomainCleanupAdd(vm, qemuProcessCleanupMigrationJob); *finishJob =3D false; @@ -6290,9 +6297,9 @@ qemuMigrationProcessUnattended(virQEMUDriver *driver, vm->def->name); =20 if (job =3D=3D VIR_ASYNC_JOB_MIGRATION_IN) - phase =3D QEMU_MIGRATION_PHASE_FINISH3; + phase =3D QEMU_MIGRATION_PHASE_FINISH_RESUME; else - phase =3D QEMU_MIGRATION_PHASE_CONFIRM3; + phase =3D QEMU_MIGRATION_PHASE_CONFIRM_RESUME; =20 if (qemuMigrationJobStartPhase(vm, phase) < 0) return; diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index f752668b2f..8a98c03395 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -1555,9 +1555,12 @@ qemuProcessHandleMigrationStatus(qemuMonitor *mon G_= GNUC_UNUSED, * watching it in any thread. Let's make sure the migration is pro= perly * finished in case we get a "completed" event. */ - if (virDomainObjIsFailedPostcopy(vm) && priv->job.asyncOwner =3D= =3D 0) + if (virDomainObjIsPostcopy(vm, priv->job.current->operation) && + priv->job.phase =3D=3D QEMU_MIGRATION_PHASE_POSTCOPY_FAILED && + priv->job.asyncOwner =3D=3D 0) { qemuProcessEventSubmit(vm, QEMU_PROCESS_EVENT_UNATTENDED_MIGRA= TION, priv->job.asyncJob, status, NULL); + } break; =20 case QEMU_MONITOR_MIGRATION_STATUS_INACTIVE: @@ -3507,7 +3510,6 @@ qemuProcessRecoverMigrationIn(virQEMUDriver *driver, case QEMU_MIGRATION_PHASE_PERFORM3_DONE: case QEMU_MIGRATION_PHASE_CONFIRM3_CANCELLED: case QEMU_MIGRATION_PHASE_CONFIRM3: - case QEMU_MIGRATION_PHASE_POSTCOPY_FAILED: case QEMU_MIGRATION_PHASE_BEGIN_RESUME: case QEMU_MIGRATION_PHASE_PERFORM_RESUME: case QEMU_MIGRATION_PHASE_CONFIRM_RESUME: @@ -3545,6 +3547,7 @@ qemuProcessRecoverMigrationIn(virQEMUDriver *driver, } break; =20 + case QEMU_MIGRATION_PHASE_POSTCOPY_FAILED: case QEMU_MIGRATION_PHASE_PREPARE_RESUME: case QEMU_MIGRATION_PHASE_FINISH_RESUME: return 1; @@ -3581,7 +3584,6 @@ qemuProcessRecoverMigrationOut(virQEMUDriver *driver, case QEMU_MIGRATION_PHASE_PREPARE: case QEMU_MIGRATION_PHASE_FINISH2: case QEMU_MIGRATION_PHASE_FINISH3: - case QEMU_MIGRATION_PHASE_POSTCOPY_FAILED: case QEMU_MIGRATION_PHASE_PREPARE_RESUME: case QEMU_MIGRATION_PHASE_FINISH_RESUME: case QEMU_MIGRATION_PHASE_LAST: @@ -3643,6 +3645,7 @@ qemuProcessRecoverMigrationOut(virQEMUDriver *driver, } return 1; =20 + case QEMU_MIGRATION_PHASE_POSTCOPY_FAILED: case QEMU_MIGRATION_PHASE_BEGIN_RESUME: case QEMU_MIGRATION_PHASE_PERFORM_RESUME: return 1; @@ -3694,6 +3697,8 @@ qemuProcessRecoverMigration(virQEMUDriver *driver, return -1; =20 if (rc > 0) { + job->phase =3D QEMU_MIGRATION_PHASE_POSTCOPY_FAILED; + if (migStatus =3D=3D VIR_DOMAIN_JOB_STATUS_POSTCOPY) { VIR_DEBUG("Post-copy migration of domain %s still running, it = will be handled as unattended", vm->def->name); --=20 2.35.1 From nobody Wed May 15 19:27:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1654087931; cv=none; d=zohomail.com; s=zohoarc; b=nkzcux8kKM3gzXE2+yV3AZ95sstvMMLaYvyEwDqSq0B5poHxbXAYNlxcENr1kmwBvya1mL2XMND8teM6LjRjR/fLOe/2A0pCA39guK126L4B6YKnBcyDAsezWTm4FKnGuL3Smm+/ixHchE1OxJ2pIeaimjPZN38OWBNJ2d0tOWs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654087931; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Voo37eS1MnJIKW/4dga2k2Dr0YTOp35U0+iM0vo1Og4=; b=frv4uigh9e7ZBomK7DLehU6A7eEDvHuTP3ORPlak9BeSSmzWa0gXkKJN2uxcdBRR5mAwcOvifY+ePwQtVQ9EnA+eyHm0KnF+6buIDWjJJmukY+pusuJLiY85AY3w2kXjE0/Y4o86bQE9FTpDxq9cZmhuP3vNPuVpOOrFIRdr0C0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1654087931014100.30741303916864; Wed, 1 Jun 2022 05:52:11 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-55-5_uWrJ_YMyWZ5cDXSFXg8w-1; Wed, 01 Jun 2022 08:51:40 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7050D851788; Wed, 1 Jun 2022 12:50:51 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5B7551415100; Wed, 1 Jun 2022 12:50:51 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 801F3193F6F7; Wed, 1 Jun 2022 12:50:47 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 588691947B9B for ; Wed, 1 Jun 2022 12:50:30 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 3B8722024CC2; Wed, 1 Jun 2022 12:50:30 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.227]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 15D922027EB5; Wed, 1 Jun 2022 12:50:30 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id A1136245B7D; Wed, 1 Jun 2022 14:50:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654087929; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=Voo37eS1MnJIKW/4dga2k2Dr0YTOp35U0+iM0vo1Og4=; b=jElcdCNAFPHPgfpHhIegaWYeKCZjqAVNwQmLQngcS2qLsRl/noRdm8fLXP/2QFrxdzwZNY s0sHRYgkPNcVfaIX/c//qkRszEkLJaNMjeHEkgN8cGYS0zG1j9BP+0dXrtl8HGwMxekuy4 WVTZuHZ9sbXxDsBQY4nuWD5PUJkFHlc= X-MC-Unique: 5_uWrJ_YMyWZ5cDXSFXg8w-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH v2 49/81] Introduce VIR_MIGRATE_POSTCOPY_RESUME flag Date: Wed, 1 Jun 2022 14:49:49 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Krempa , Pavel Hrdina Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1654087932152100012 Content-Type: text/plain; charset="utf-8" This flag can be used to restart post-copy migration once it failed because of a broken connection. Signed-off-by: Jiri Denemark Reviewed-by: Peter Krempa Reviewed-by: Pavel Hrdina --- Notes: Version 2: - no change include/libvirt/libvirt-domain.h | 5 +++++ src/libvirt-domain.c | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-dom= ain.h index caf99d41bc..e7020f19cc 100644 --- a/include/libvirt/libvirt-domain.h +++ b/include/libvirt/libvirt-domain.h @@ -1084,6 +1084,11 @@ typedef enum { */ VIR_MIGRATE_NON_SHARED_SYNCHRONOUS_WRITES =3D (1 << 18), =20 + /* Resume migration which failed in post-copy phase. + * + * Since: 8.5.0 + */ + VIR_MIGRATE_POSTCOPY_RESUME =3D (1 << 19), } virDomainMigrateFlags; =20 =20 diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c index b9f1d73d5a..5141174728 100644 --- a/src/libvirt-domain.c +++ b/src/libvirt-domain.c @@ -9775,6 +9775,12 @@ virDomainMigrateGetMaxSpeed(virDomainPtr domain, * such case. Because of this, libvirt will refuse to cancel post-copy * migration via virDomainAbortJob. * + * Failed post-copy migration can be recovered once the cause for the fail= ure + * (e.g., a network issue) is resolved by repeating the migration with an + * additional VIR_MIGRATE_POSTCOPY_RESUME flag. This will recreate the + * connection and resume migration from the point where it failed. This st= ep + * can be repeated in case the migration breaks again. + * * The following domain life cycle events are emitted during post-copy * migration: * VIR_DOMAIN_EVENT_SUSPENDED_POSTCOPY (on the source) -- migration enter= ed --=20 2.35.1 From nobody Wed May 15 19:27:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1654088001; cv=none; d=zohomail.com; s=zohoarc; b=EYndtRaSwVF6BlFwS7Oe28vODhmlPnKw88U+K5NgAGdIutsd9beULWBUYwSRCOihMKpgQpy6yiUYsXHLzsguFevV4XdofFKKeCw7ZdpWacLrGKvNuOMbRlq/9tRn9BkWKkQBJL6zyDVFwEPPnNdT/6G3ScTggC5A+tnaBFx9y9M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654088001; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=qHbaSY6fsw+2UApiM5N4ZegPXwZmJxD2d5l9Lp9mA2g=; b=LtUszvFynSWOGNmdriBLqerMDaKOJV4XGfGhj/dOA6uwcT2AxShYz2pw7ko2jZTPfExVa1Ksyo4/C/9Q3+3S1JvVlXljoqnAN+b2R5o/myCRezG546JiGtFGMeX3tAuQ0INNmrzFzLgu0MnPv+BzdAu79e8fQG61u/t7AS6qeEM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1654088001588543.5042171356234; Wed, 1 Jun 2022 05:53:21 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-586-TXGJZP41OaatHayhD_7oog-1; Wed, 01 Jun 2022 08:51:23 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5247A2802B38; Wed, 1 Jun 2022 12:50:46 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id ECE482026985; Wed, 1 Jun 2022 12:50:45 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 6A88C1955EE2; Wed, 1 Jun 2022 12:50:42 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 4EEA31947B8C for ; Wed, 1 Jun 2022 12:50:30 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 345E7112131E; Wed, 1 Jun 2022 12:50:30 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.227]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 13519112131B; Wed, 1 Jun 2022 12:50:30 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id A2688245B7E; Wed, 1 Jun 2022 14:50:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654088000; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=qHbaSY6fsw+2UApiM5N4ZegPXwZmJxD2d5l9Lp9mA2g=; b=EFjl78NsPf2Ho5jRGG1qPs7LdiZ1bogFL+LKlyyccINuiS3BSLvVaNODqWEyLyOi/8yXik BMkVrTr96Kc2MDvIOblmAH2VCrYiCxskwZ1X/a56tn07+OS93bVMwOyP464Cyr8995xgZk bJaptsOIeEsjgvWukxYj9ECypP3CP8I= X-MC-Unique: TXGJZP41OaatHayhD_7oog-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH v2 50/81] virsh: Add --postcopy-resume option for migrate command Date: Wed, 1 Jun 2022 14:49:50 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Krempa , Pavel Hrdina Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1654088002478100009 Content-Type: text/plain; charset="utf-8" Signed-off-by: Jiri Denemark Reviewed-by: Peter Krempa Reviewed-by: Pavel Hrdina --- Notes: Version 2: - no change docs/manpages/virsh.rst | 9 +++++++-- tools/virsh-domain.c | 8 ++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/docs/manpages/virsh.rst b/docs/manpages/virsh.rst index 965b89c99d..ecdb54fcd5 100644 --- a/docs/manpages/virsh.rst +++ b/docs/manpages/virsh.rst @@ -3246,7 +3246,8 @@ migrate migrate [--live] [--offline] [--direct] [--p2p [--tunnelled]] [--persistent] [--undefinesource] [--suspend] [--copy-storage-all] [--copy-storage-inc] [--change-protection] [--unsafe] [--verbose] - [--rdma-pin-all] [--abort-on-error] [--postcopy] [--postcopy-after-p= recopy] + [--rdma-pin-all] [--abort-on-error] [--postcopy] + [--postcopy-after-precopy] [--postcopy-resume] domain desturi [migrateuri] [graphicsuri] [listen-address] [dname] [--timeout seconds [--timeout-suspend | --timeout-postcopy]] [--xml file] [--migrate-disks disk-list] [--disks-port port] @@ -3302,7 +3303,11 @@ Once migration is running, the user may switch to po= st-copy using the automatically switch to post-copy after the first pass of pre-copy is fini= shed. The maximum bandwidth consumed during the post-copy phase may be limited u= sing *--postcopy-bandwidth*. The maximum bandwidth consumed during the pre-copy= phase -may be limited using *--bandwidth*. +may be limited using *--bandwidth*. In case connection between the hosts b= reaks +while migration is in post-copy mode, the domain cannot be resumed on eith= er +source or destination host and the ``migrate`` command will report an error +leaving the domain active on both hosts. To recover from such situation re= peat +the original ``migrate`` command with an additional *--postcopy-resume* fl= ag. =20 *--auto-converge* forces convergence during live migration. The initial guest CPU throttling rate can be set with *auto-converge-initial*. If the diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index bac4cc0fb6..dd7862b5e5 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -10807,6 +10807,10 @@ static const vshCmdOptDef opts_migrate[] =3D { .type =3D VSH_OT_BOOL, .help =3D N_("automatically switch to post-copy migration after one p= ass of pre-copy") }, + {.name =3D "postcopy-resume", + .type =3D VSH_OT_BOOL, + .help =3D N_("resume failed post-copy migration") + }, {.name =3D "migrateuri", .type =3D VSH_OT_STRING, .completer =3D virshCompleteEmpty, @@ -11210,6 +11214,9 @@ doMigrate(void *opaque) if (vshCommandOptBool(cmd, "postcopy")) flags |=3D VIR_MIGRATE_POSTCOPY; =20 + if (vshCommandOptBool(cmd, "postcopy-resume")) + flags |=3D VIR_MIGRATE_POSTCOPY_RESUME; + if (vshCommandOptBool(cmd, "tls")) flags |=3D VIR_MIGRATE_TLS; =20 @@ -11314,6 +11321,7 @@ cmdMigrate(vshControl *ctl, const vshCmd *cmd) VSH_EXCLUSIVE_OPTIONS("live", "offline"); VSH_EXCLUSIVE_OPTIONS("timeout-suspend", "timeout-postcopy"); VSH_REQUIRE_OPTION("postcopy-after-precopy", "postcopy"); + VSH_REQUIRE_OPTION("postcopy-resume", "postcopy"); VSH_REQUIRE_OPTION("timeout-postcopy", "postcopy"); VSH_REQUIRE_OPTION("persistent-xml", "persistent"); VSH_REQUIRE_OPTION("tls-destination", "tls"); --=20 2.35.1 From nobody Wed May 15 19:27:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1654088004; cv=none; d=zohomail.com; s=zohoarc; b=eAO1BZrrhK7s15L1dhjm8isEvHaTiY+SdGn2x+h2rpzjdv79WMr8FTOdYatcrYHwOrM8Va4cb6KuaNz5se89cfWBDwmEase6Ckq3ALZJIbIVx1utn4fKLdmfm3XISH0uEA8QdV+eO5g+YGDWtszXzTPj/ftJ0K9BH4MlZ/X6z7U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654088004; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=vB4MXOmHxpBPRJfugt8kXyKx0eHNk4D76/2yPeDeJkA=; b=DnSYuv5ox6NkFGOMZO1C/Fow/6tZVj19NJK91SF2dmTleqIQeFEuesxO7YVx8xr6myWbNnY9ynwR7UXOmcvyOx204Jduka/2GUfOB+3TfEP1VyA99SE3l8v/1zRq0v0DT4BGe71uJgIsXk4NwgATzSorR3qpIdKsorlKCOnCIIk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 165408800475864.90196612416219; Wed, 1 Jun 2022 05:53:24 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-404-lj-S3Z5GMy63eRNUWCU7xA-1; Wed, 01 Jun 2022 08:51:32 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DDEA310666A8; Wed, 1 Jun 2022 12:50:49 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id C924C492C3B; Wed, 1 Jun 2022 12:50:49 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id D2A6A1955ED6; Wed, 1 Jun 2022 12:50:45 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 5E9D31947BA0 for ; Wed, 1 Jun 2022 12:50:30 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 375792166B31; Wed, 1 Jun 2022 12:50:30 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.227]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 137F02166B2D; Wed, 1 Jun 2022 12:50:30 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id A3B57245B7F; Wed, 1 Jun 2022 14:50:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654088003; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=vB4MXOmHxpBPRJfugt8kXyKx0eHNk4D76/2yPeDeJkA=; b=AHUPQbgypEyaNstmVCNApcLEgAUX0WWBLKh4vU7NkgcUc9t+fcp9wZLv/NUU6tQOx+SsiY b/R3zhVKTLORX9QvTEflB1RPqJerK4cK3y8JkZnJIrigRupBCyJxKtFOFSE+udYqfeBgjl JMFyFuET8vF7Sf+WHviwD5NySjMKUi0= X-MC-Unique: lj-S3Z5GMy63eRNUWCU7xA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH v2 51/81] qemu: Don't set VIR_MIGRATE_PAUSED for post-copy resume Date: Wed, 1 Jun 2022 14:49:51 +0200 Message-Id: <4dc3954a332e4feb66b1635ea583b6977d23a81a.1654087150.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Krempa , Pavel Hrdina Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1654088006451100001 Content-Type: text/plain; charset="utf-8" For historical reasons we automatically enabled VIR_MIGRATE_PAUSED flag when a migration was started for a paused domain. However, when resuming failed post-copy migration the domain on the source host will always be paused (as it is already running on the destination host). We must avoid enabling VIR_MIGRATE_PAUSED in this case. Signed-off-by: Jiri Denemark Reviewed-by: Peter Krempa Reviewed-by: Pavel Hrdina --- Notes: Version 2: - no change src/libvirt-domain.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c index 5141174728..d86625526c 100644 --- a/src/libvirt-domain.c +++ b/src/libvirt-domain.c @@ -3290,7 +3290,9 @@ virDomainMigrateVersion3Full(virDomainPtr domain, ret =3D virDomainGetInfo(domain, &info); state =3D info.state; } - if (ret =3D=3D 0 && state =3D=3D VIR_DOMAIN_PAUSED) + if (ret =3D=3D 0 && + state =3D=3D VIR_DOMAIN_PAUSED && + !(flags & VIR_MIGRATE_POSTCOPY_RESUME)) flags |=3D VIR_MIGRATE_PAUSED; =20 destflags =3D flags & ~(VIR_MIGRATE_ABORT_ON_ERROR | --=20 2.35.1 From nobody Wed May 15 19:27:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1654087996; cv=none; d=zohomail.com; s=zohoarc; b=O6HLNsmC/j3U2GoRZxm8jltr63fqRfGlkOnsKbf2ZqEr8c7S6C64Wjmi4w7/Qmoot9cJoHN3oVeOC23LmiNgtj30iB2CCJxTM6zbRbpAq60IbS8P2BqHrGbo25Wt+mBTs3HA7czdYbPjXhzTjCLVXfv++X4TVhibtiUqeIbkdZE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654087996; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Lo7mTuRkj7vIU4RaN2AfGKzwAqBphDhxVCGZg6bvHIg=; b=HnxJAsmmlJh9j5A79T9sBiXWlEhSlwFbUDGgwmtDYMI7PJdgsTWKKpoKVLL7dgSSi7o7tRx/a3+AmWYpbsUygTErxwheljwPK/+9IddFVbFhYO1dB4+hf7n6vd3FREUFYD/BI8om6CNg04PyLOM+O06d6aNb4Upw7hMCDmjyb88= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1654087996427560.7364787543728; Wed, 1 Jun 2022 05:53:16 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-339-dnuSGBeRMsWFzvKTyvK8qQ-1; Wed, 01 Jun 2022 08:51:41 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E45D590187E; Wed, 1 Jun 2022 12:50:51 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id CF969492C3B; Wed, 1 Jun 2022 12:50:51 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 46A5B1947BA1; Wed, 1 Jun 2022 12:50:48 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 813D51947BA2 for ; Wed, 1 Jun 2022 12:50:30 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 5D3D61121319; Wed, 1 Jun 2022 12:50:30 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.227]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1C695111F3B6 for ; Wed, 1 Jun 2022 12:50:30 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id A50B3245B80; Wed, 1 Jun 2022 14:50:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654087995; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=Lo7mTuRkj7vIU4RaN2AfGKzwAqBphDhxVCGZg6bvHIg=; b=jDUmt2Ww6D9/s5/qcb5J3UxZLLcB1oosi4YKyU3UDLQ1tas17/ZlOtuc3KeMe4YtH+qAfK 5O8byIaHSuXroFE2pWJO+cTroHDskzbt16OeVO/z9WuC6xgzCLaQsq9Fx62SeB7q3vu+cg ZA31xN/iXoR7v0uY2B3hOWh64z9kj60= X-MC-Unique: dnuSGBeRMsWFzvKTyvK8qQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH v2 52/81] qemu: Implement VIR_MIGRATE_POSTCOPY_RESUME for Begin phase Date: Wed, 1 Jun 2022 14:49:52 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1654087998449100005 Content-Type: text/plain; charset="utf-8" Mostly we just need to check whether the domain is in a failed post-copy migration that can be resumed. Signed-off-by: Jiri Denemark Reviewed-by: Peter Krempa --- Notes: Version 2: - s/return NULL/return false/ - dropped line breaks from error messages - dropped driver argument when calling qemuMigrationSrcBeginXML src/qemu/qemu_migration.c | 139 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 139 insertions(+) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 302589b63c..45f2788a34 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -2685,6 +2685,139 @@ qemuMigrationSrcBeginPhase(virQEMUDriver *driver, flags); } =20 + +static bool +qemuMigrationAnyCanResume(virDomainObj *vm, + virDomainAsyncJob job, + unsigned long flags, + qemuMigrationJobPhase expectedPhase) +{ + qemuDomainObjPrivate *priv =3D vm->privateData; + + VIR_DEBUG("vm=3D%p, job=3D%s, flags=3D0x%lx, expectedPhase=3D%s", + vm, virDomainAsyncJobTypeToString(job), flags, + qemuDomainAsyncJobPhaseToString(VIR_ASYNC_JOB_MIGRATION_OUT, + expectedPhase)); + + if (!(flags & VIR_MIGRATE_POSTCOPY)) { + virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", + _("resuming failed post-copy migration requires pos= t-copy to be enabled")); + return false; + } + + /* This should never happen since POSTCOPY_RESUME is newer than + * CHANGE_PROTECTION, but let's check it anyway in case we're talking = to + * a weired client. + */ + if (job =3D=3D VIR_ASYNC_JOB_MIGRATION_OUT && + expectedPhase < QEMU_MIGRATION_PHASE_PERFORM_RESUME && + !(flags & VIR_MIGRATE_CHANGE_PROTECTION)) { + virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", + _("resuming failed post-copy migration requires cha= nge protection")); + return false; + } + + if (!qemuMigrationJobIsActive(vm, job)) + return false; + + if (priv->job.asyncOwner !=3D 0 && + priv->job.asyncOwner !=3D virThreadSelfID()) { + virReportError(VIR_ERR_OPERATION_INVALID, + _("migration of domain %s is being actively monitor= ed by another thread"), + vm->def->name); + return false; + } + + if (!virDomainObjIsPostcopy(vm, priv->job.current->operation)) { + virReportError(VIR_ERR_OPERATION_INVALID, + _("migration of domain %s is not in post-copy phase= "), + vm->def->name); + return false; + } + + if (priv->job.phase < QEMU_MIGRATION_PHASE_POSTCOPY_FAILED && + !virDomainObjIsFailedPostcopy(vm)) { + virReportError(VIR_ERR_OPERATION_INVALID, + _("post-copy migration of domain %s has not failed"= ), + vm->def->name); + return false; + } + + if (priv->job.phase > expectedPhase) { + virReportError(VIR_ERR_OPERATION_INVALID, + _("resuming failed post-copy migration of domain %s= already in progress"), + vm->def->name); + return false; + } + + return true; +} + + +static char * +qemuMigrationSrcBeginResume(virQEMUDriver *driver, + virDomainObj *vm, + const char *xmlin, + char **cookieout, + int *cookieoutlen, + unsigned long flags) +{ + virDomainJobStatus status; + + if (qemuMigrationAnyRefreshStatus(driver, vm, VIR_ASYNC_JOB_MIGRATION_= OUT, + &status) < 0) + return NULL; + + if (status !=3D VIR_DOMAIN_JOB_STATUS_POSTCOPY_PAUSED) { + virReportError(VIR_ERR_OPERATION_INVALID, "%s", + _("QEMU reports migration is still running")); + return NULL; + } + + return qemuMigrationSrcBeginXML(vm, xmlin, + cookieout, cookieoutlen, 0, NULL, 0, f= lags); +} + + +static char * +qemuMigrationSrcBeginResumePhase(virConnectPtr conn, + virQEMUDriver *driver, + virDomainObj *vm, + const char *xmlin, + char **cookieout, + int *cookieoutlen, + unsigned long flags) +{ + g_autofree char *xml =3D NULL; + + VIR_DEBUG("vm=3D%p", vm); + + if (!qemuMigrationAnyCanResume(vm, VIR_ASYNC_JOB_MIGRATION_OUT, flags, + QEMU_MIGRATION_PHASE_POSTCOPY_FAILED)) + return NULL; + + if (qemuMigrationJobStartPhase(vm, QEMU_MIGRATION_PHASE_BEGIN_RESUME) = < 0) + return NULL; + + virCloseCallbacksUnset(driver->closeCallbacks, vm, + qemuMigrationSrcCleanup); + qemuDomainCleanupRemove(vm, qemuProcessCleanupMigrationJob); + + xml =3D qemuMigrationSrcBeginResume(driver, vm, xmlin, cookieout, cook= ieoutlen, flags); + + if (virCloseCallbacksSet(driver->closeCallbacks, vm, conn, + qemuMigrationSrcCleanup) < 0) + g_clear_pointer(&xml, g_free); + + if (!xml) + ignore_value(qemuMigrationJobSetPhase(vm, QEMU_MIGRATION_PHASE_POS= TCOPY_FAILED)); + + qemuDomainCleanupAdd(vm, qemuProcessCleanupMigrationJob); + qemuMigrationJobContinue(vm); + return g_steal_pointer(&xml); +} + + char * qemuMigrationSrcBegin(virConnectPtr conn, virDomainObj *vm, @@ -2710,6 +2843,12 @@ qemuMigrationSrcBegin(virConnectPtr conn, goto cleanup; } =20 + if (flags & VIR_MIGRATE_POSTCOPY_RESUME) { + ret =3D qemuMigrationSrcBeginResumePhase(conn, driver, vm, xmlin, + cookieout, cookieoutlen, fl= ags); + goto cleanup; + } + if ((flags & VIR_MIGRATE_CHANGE_PROTECTION)) { if (qemuMigrationJobStart(driver, vm, VIR_ASYNC_JOB_MIGRATION_OUT, flags) < 0) --=20 2.35.1 From nobody Wed May 15 19:27:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1654087905; cv=none; d=zohomail.com; s=zohoarc; b=UOpoVcxlTAMKKnyNRtTM/GCaeugbhO63pXy+YBGksjF4ljoCOTHM2r+HEEcCzxo0iy+kvPe0CkntcTJzPH+ESM5UFClCD6J/Vbmny47sCl3ApnUcLQLokIIL4aZxArwR2oXhdx8bSyQo8LiP84GmQI0aGUEZ8RQhZxgIf+qFHic= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654087905; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=vw7EsXcxyoiQJlzvT+MHZ6nLHX5ubmssWo2siL0p4qA=; b=FODMmFHVCgM4VO/3rNP9zsgkFMwrAHWz1WvOGEK2/WaxAx5bc8cMAYYb4v7Msga7ho+9ucnEmgJ6lYOVg6b8QaOhRdTlvodlX0ZGy2ODdWX5rwb4enVBSGCWSskY01HctvB656FMKgnrRfOYlTIGzcFdcmdrzuNSdLfYBymL1ZE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1654087905451740.5987866568071; Wed, 1 Jun 2022 05:51:45 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-637-Yt-wTQqEN9mDXkMhzf3zNw-1; Wed, 01 Jun 2022 08:51:35 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4E97C3816859; Wed, 1 Jun 2022 12:50:47 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3834182886; Wed, 1 Jun 2022 12:50:47 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 755391947BA9; Wed, 1 Jun 2022 12:50:43 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 70CDE1947BA1 for ; Wed, 1 Jun 2022 12:50:30 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 5743B2024CC6; Wed, 1 Jun 2022 12:50:30 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.227]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 31FFD2024CC5; Wed, 1 Jun 2022 12:50:30 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id A65D6245B81; Wed, 1 Jun 2022 14:50:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654087904; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=vw7EsXcxyoiQJlzvT+MHZ6nLHX5ubmssWo2siL0p4qA=; b=RZ4Bn2zI+h3uru6lHuYKAkdvfILaj5c9GXQu24iOoKiUqXsgEcNkjL9ryewLg+JxHgWwnq YUJsnTwCbvyjqc1uSgOPK27/gha4/Mgx5jTpqUPTC/Zw8cdyDnoAGiYsltoi3/bBl8yrVO j0i/cfqG5SwD3Bt4TEj52x9msj3yCFs= X-MC-Unique: Yt-wTQqEN9mDXkMhzf3zNw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH v2 53/81] qemu: Refactor qemuMigrationSrcPerformPhase Date: Wed, 1 Jun 2022 14:49:53 +0200 Message-Id: <157122743c9e3242b40346e8dca84f6c0743c435.1654087150.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Krempa , Pavel Hrdina Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1654087906024100003 Content-Type: text/plain; charset="utf-8" To make the code flow a bit more sensible. Signed-off-by: Jiri Denemark Reviewed-by: Peter Krempa Reviewed-by: Pavel Hrdina --- Notes: Version 2: - fixed "qmeu" typo in the commit message src/qemu/qemu_migration.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 45f2788a34..3ed1cf3498 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -5780,29 +5780,27 @@ qemuMigrationSrcPerformPhase(virQEMUDriver *driver, } =20 if (qemuMigrationJobStartPhase(vm, QEMU_MIGRATION_PHASE_PERFORM3) < 0) - goto endjob; + goto cleanup; =20 virCloseCallbacksUnset(driver->closeCallbacks, vm, qemuMigrationSrcCleanup); =20 - ret =3D qemuMigrationSrcPerformNative(driver, vm, persist_xml, uri, co= okiein, cookieinlen, - cookieout, cookieoutlen, - flags, resource, NULL, graphicsuri, - nmigrate_disks, migrate_disks, mig= Params, nbdURI); - - if (ret < 0) { - qemuMigrationSrcRestoreDomainState(driver, vm); - goto endjob; - } - - ignore_value(qemuMigrationJobSetPhase(vm, QEMU_MIGRATION_PHASE_PERFORM= 3_DONE)); + if (qemuMigrationSrcPerformNative(driver, vm, persist_xml, uri, cookie= in, cookieinlen, + cookieout, cookieoutlen, + flags, resource, NULL, graphicsuri, + nmigrate_disks, migrate_disks, migPa= rams, nbdURI) < 0) + goto cleanup; =20 if (virCloseCallbacksSet(driver->closeCallbacks, vm, conn, qemuMigrationSrcCleanup) < 0) - goto endjob; + goto cleanup; =20 - endjob: + ignore_value(qemuMigrationJobSetPhase(vm, QEMU_MIGRATION_PHASE_PERFORM= 3_DONE)); + ret =3D 0; + + cleanup: if (ret < 0 && !virDomainObjIsFailedPostcopy(vm)) { + qemuMigrationSrcRestoreDomainState(driver, vm); qemuMigrationParamsReset(driver, vm, VIR_ASYNC_JOB_MIGRATION_OUT, jobPriv->migParams, priv->job.apiFlags); qemuMigrationJobFinish(vm); --=20 2.35.1 From nobody Wed May 15 19:27:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1654087928; cv=none; d=zohomail.com; s=zohoarc; b=UL66lzrVchmaAt70lvUWj3vatSWA+M1aZic4OlphTooDoXiMWwAZegV4j4sQjyy+q+A5chcTl8WQo7U2gxSAGlOZgMc3EeJ7IYZnr3CvdBF33mGvyZr7uN9OKoDYP0nAxdUUlGV3DUG70DYcJiYddBzySdzHVoli1nkBDUYtgy8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654087928; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=M6PkAtao9tcsWrJgGA4JSDMa+VjLkq7s/7Ig/RaY2XU=; b=YExBwVadSmwC7Oc7pHMiHo7xXYkSK575mn5afC1QpEkRUczg24PVkEKXcf+qFzAfacJ3LvWeSUna0U1KWg5iCxZNtoBCEhVKom8tvV0j4loXfkMBB5Lrf5O/T+DaPUO/fJTIOfXr49prJmpIpBxo4mNa95XEAVpYpXOV3qzhvck= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1654087928261469.3618471551807; Wed, 1 Jun 2022 05:52:08 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-480-yABrNzcVPG68tXZEXM06cw-1; Wed, 01 Jun 2022 08:51:33 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7F75A383328B; Wed, 1 Jun 2022 12:50:50 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 680C9492C3B; Wed, 1 Jun 2022 12:50:50 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id B58CB193769E; Wed, 1 Jun 2022 12:50:46 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id B013C1947B8C for ; Wed, 1 Jun 2022 12:50:30 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 8915040314B; Wed, 1 Jun 2022 12:50:30 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.227]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4C8A140F06C; Wed, 1 Jun 2022 12:50:30 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id A7BE5245B82; Wed, 1 Jun 2022 14:50:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654087927; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=M6PkAtao9tcsWrJgGA4JSDMa+VjLkq7s/7Ig/RaY2XU=; b=MxUfOuskKmjm5+n5PMqYUZvIMsU3qcyGPfCljNLntGUxjWNCfuc+7yG0asf/EitZGfu7ti GmfX8XgefCIB+ctQkT/0dwCcvCP4P+RPPXfcbSCr3VVUNWEvLet/2R/O5WEBpY8IlKqZwl BpAaZsDyrneAqhN3FHJbfiLc+JLktTY= X-MC-Unique: yABrNzcVPG68tXZEXM06cw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH v2 54/81] qemu: Separate starting migration from qemuMigrationSrcRun Date: Wed, 1 Jun 2022 14:49:54 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Krempa , Pavel Hrdina Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1654087930182100008 Content-Type: text/plain; charset="utf-8" qemuMigrationSrcRun does a lot of thing before and after telling QEMU to start the migration. Let's make the core reusable by moving it to a new qemuMigrationSrcStart function. Signed-off-by: Jiri Denemark Reviewed-by: Peter Krempa Reviewed-by: Pavel Hrdina --- Notes: Version 2: - dropped driver parameter from qemuMigrationSrcStart src/qemu/qemu_migration.c | 118 +++++++++++++++++++++++--------------- 1 file changed, 71 insertions(+), 47 deletions(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 3ed1cf3498..51feb785f5 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -4379,6 +4379,76 @@ qemuMigrationSrcRunPrepareBlockDirtyBitmaps(virDomai= nObj *vm, } =20 =20 +/* The caller is supposed to enter monitor before calling this. */ +static int +qemuMigrationSrcStart(virDomainObj *vm, + qemuMigrationSpec *spec, + unsigned int migrateFlags, + int *tunnelFd) +{ + qemuDomainObjPrivate *priv =3D vm->privateData; + virQEMUDriver *driver =3D priv->driver; + g_autofree char *timestamp =3D NULL; + int rc; + + /* connect to the destination qemu if needed */ + if ((spec->destType =3D=3D MIGRATION_DEST_CONNECT_HOST || + spec->destType =3D=3D MIGRATION_DEST_CONNECT_SOCKET) && + qemuMigrationSrcConnect(driver, vm, spec) < 0) { + return -1; + } + + /* log start of migration */ + if ((timestamp =3D virTimeStringNow()) !=3D NULL) + qemuDomainLogAppendMessage(driver, vm, "%s: initiating migration\n= ", timestamp); + + switch (spec->destType) { + case MIGRATION_DEST_HOST: + if (STREQ(spec->dest.host.protocol, "rdma") && + vm->def->mem.hard_limit > 0 && + virProcessSetMaxMemLock(vm->pid, vm->def->mem.hard_limit << 10= ) < 0) { + return -1; + } + return qemuMonitorMigrateToHost(priv->mon, migrateFlags, + spec->dest.host.protocol, + spec->dest.host.name, + spec->dest.host.port); + + case MIGRATION_DEST_SOCKET: + qemuSecurityDomainSetPathLabel(driver, vm, spec->dest.socket.path,= false); + return qemuMonitorMigrateToSocket(priv->mon, migrateFlags, + spec->dest.socket.path); + + case MIGRATION_DEST_CONNECT_HOST: + case MIGRATION_DEST_CONNECT_SOCKET: + /* handled above and transformed into MIGRATION_DEST_FD */ + break; + + case MIGRATION_DEST_FD: + if (spec->fwdType !=3D MIGRATION_FWD_DIRECT) { + if (!tunnelFd) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("tunnelFD argument is required for tunnel= led " + "migration")); + VIR_FORCE_CLOSE(spec->dest.fd.local); + VIR_FORCE_CLOSE(spec->dest.fd.qemu); + return -1; + } + *tunnelFd =3D spec->dest.fd.local; + spec->dest.fd.local =3D -1; + } + rc =3D qemuMonitorMigrateToFd(priv->mon, migrateFlags, + spec->dest.fd.qemu); + VIR_FORCE_CLOSE(spec->dest.fd.qemu); + return rc; + } + + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected migration schema: %d"), spec->destType); + return -1; +} + + static int qemuMigrationSrcRun(virQEMUDriver *driver, virDomainObj *vm, @@ -4413,7 +4483,6 @@ qemuMigrationSrcRun(virQEMUDriver *driver, bool cancel =3D false; unsigned int waitFlags; g_autoptr(virDomainDef) persistDef =3D NULL; - g_autofree char *timestamp =3D NULL; int rc; =20 if (resource > 0) @@ -4588,52 +4657,7 @@ qemuMigrationSrcRun(virQEMUDriver *driver, qemuMonitorSetMigrationSpeed(priv->mon, priv->migMaxBandwidth) < 0) goto exit_monitor; =20 - /* connect to the destination qemu if needed */ - if ((spec->destType =3D=3D MIGRATION_DEST_CONNECT_HOST || - spec->destType =3D=3D MIGRATION_DEST_CONNECT_SOCKET) && - qemuMigrationSrcConnect(driver, vm, spec) < 0) { - goto exit_monitor; - } - - /* log start of migration */ - if ((timestamp =3D virTimeStringNow()) !=3D NULL) - qemuDomainLogAppendMessage(driver, vm, "%s: initiating migration\n= ", timestamp); - - rc =3D -1; - switch (spec->destType) { - case MIGRATION_DEST_HOST: - if (STREQ(spec->dest.host.protocol, "rdma") && - vm->def->mem.hard_limit > 0 && - virProcessSetMaxMemLock(vm->pid, vm->def->mem.hard_limit << 10= ) < 0) { - goto exit_monitor; - } - rc =3D qemuMonitorMigrateToHost(priv->mon, migrate_flags, - spec->dest.host.protocol, - spec->dest.host.name, - spec->dest.host.port); - break; - - case MIGRATION_DEST_SOCKET: - qemuSecurityDomainSetPathLabel(driver, vm, spec->dest.socket.path,= false); - rc =3D qemuMonitorMigrateToSocket(priv->mon, migrate_flags, - spec->dest.socket.path); - break; - - case MIGRATION_DEST_CONNECT_HOST: - case MIGRATION_DEST_CONNECT_SOCKET: - /* handled above and transformed into MIGRATION_DEST_FD */ - break; - - case MIGRATION_DEST_FD: - if (spec->fwdType !=3D MIGRATION_FWD_DIRECT) { - fd =3D spec->dest.fd.local; - spec->dest.fd.local =3D -1; - } - rc =3D qemuMonitorMigrateToFd(priv->mon, migrate_flags, - spec->dest.fd.qemu); - VIR_FORCE_CLOSE(spec->dest.fd.qemu); - break; - } + rc =3D qemuMigrationSrcStart(vm, spec, migrate_flags, &fd); =20 qemuDomainObjExitMonitor(vm); if (rc < 0) --=20 2.35.1 From nobody Wed May 15 19:27:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1654088048; cv=none; d=zohomail.com; s=zohoarc; b=SQh/tuyvcREHNaoewLpllQkonQvORiSRhi7KrgcXiPvz8HJ2PKOvUQaaGFC6WHzu903f6aXGYujFOPtPnVUQcYwGofj0ikqz5fvrTNc6z2UUvlXRu+xPAOJiOhvOx2BeTo76cf9yx7vuYqblYFbiyt4rVFR5fH9VhJWyIYi6ozE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654088048; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=RGnYDma5e1JIBGsIoOS/cOtkjRW5z8rs1KCQ0HScu2E=; b=SM4WRITxq7r9dnaVD0c6JDwzeCFPMnr1iXmSxDCV6zrUIFG1SvVr5bQ43AO2TGUpoJcO5DA4uen9A3kRX7dPcdonGEeXC1BwS1FM1gMuCUiDNmnxQ3YPx9RVZLtvMrMwlGe2UzhQk1YliNyU1UlpTfPUYSApXNR5Hon9pVNoTQU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1654088048857134.87513684113105; Wed, 1 Jun 2022 05:54:08 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-53-FbtN-sjvP1CWdEwgd_BFig-1; Wed, 01 Jun 2022 08:51:41 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id F02E518E527A; Wed, 1 Jun 2022 12:50:55 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id D95B440EC005; Wed, 1 Jun 2022 12:50:55 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 5C066193222A; Wed, 1 Jun 2022 12:50:52 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 725DF1947BB0 for ; Wed, 1 Jun 2022 12:50:31 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 4054E492CA5; Wed, 1 Jun 2022 12:50:31 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.227]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1E71E492C3B; Wed, 1 Jun 2022 12:50:31 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id A911B245B83; Wed, 1 Jun 2022 14:50:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654088047; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=RGnYDma5e1JIBGsIoOS/cOtkjRW5z8rs1KCQ0HScu2E=; b=GsyjiS3CGEW6i710oqS8c8PM16aQ90+UQu0iiXjpXvrGbezssBx8IPqhEK08TK+r/DuXhr 7R8rGKN0m4D0cRO4PtkvzThSAH3RGvStFfV7gMOMb4A3MzM6YNn8Swk82876DvLudR+RXv 9Fqhg8S9/v2+n8OwIn0AH8Ku3YKdxik= X-MC-Unique: FbtN-sjvP1CWdEwgd_BFig-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH v2 55/81] qemu: Add support for 'resume' parameter of migrate QMP command Date: Wed, 1 Jun 2022 14:49:55 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Krempa , Pavel Hrdina Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1654088050731100002 Content-Type: text/plain; charset="utf-8" Signed-off-by: Jiri Denemark Reviewed-by: Peter Krempa Reviewed-by: Pavel Hrdina --- Notes: Version 2: - no change src/qemu/qemu_migration.c | 8 ++++++-- src/qemu/qemu_monitor.h | 1 + src/qemu/qemu_monitor_json.c | 2 ++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 51feb785f5..9996227057 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -4399,8 +4399,12 @@ qemuMigrationSrcStart(virDomainObj *vm, } =20 /* log start of migration */ - if ((timestamp =3D virTimeStringNow()) !=3D NULL) - qemuDomainLogAppendMessage(driver, vm, "%s: initiating migration\n= ", timestamp); + if ((timestamp =3D virTimeStringNow()) !=3D NULL) { + if (migrateFlags & QEMU_MONITOR_MIGRATE_RESUME) + qemuDomainLogAppendMessage(driver, vm, "%s: resuming migration= \n", timestamp); + else + qemuDomainLogAppendMessage(driver, vm, "%s: initiating migrati= on\n", timestamp); + } =20 switch (spec->destType) { case MIGRATION_DEST_HOST: diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index 41e8db945c..98496b9037 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -870,6 +870,7 @@ typedef enum { QEMU_MONITOR_MIGRATE_BACKGROUND =3D 1 << 0, QEMU_MONITOR_MIGRATE_NON_SHARED_DISK =3D 1 << 1, /* migration with non-= shared storage with full disk copy */ QEMU_MONITOR_MIGRATE_NON_SHARED_INC =3D 1 << 2, /* migration with non-= shared storage with incremental copy */ + QEMU_MONITOR_MIGRATE_RESUME =3D 1 << 3, /* resume failed post-= copy migration */ QEMU_MONITOR_MIGRATION_FLAGS_LAST } QEMU_MONITOR_MIGRATE; =20 diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 86b7f615c8..8b026e8ade 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -3416,10 +3416,12 @@ int qemuMonitorJSONMigrate(qemuMonitor *mon, bool detach =3D !!(flags & QEMU_MONITOR_MIGRATE_BACKGROUND); bool blk =3D !!(flags & QEMU_MONITOR_MIGRATE_NON_SHARED_DISK); bool inc =3D !!(flags & QEMU_MONITOR_MIGRATE_NON_SHARED_INC); + bool resume =3D !!(flags & QEMU_MONITOR_MIGRATE_RESUME); g_autoptr(virJSONValue) cmd =3D qemuMonitorJSONMakeCommand("migrate", "b:detach", d= etach, "b:blk", blk, "b:inc", inc, + "b:resume", r= esume, "s:uri", uri, NULL); g_autoptr(virJSONValue) reply =3D NULL; --=20 2.35.1 From nobody Wed May 15 19:27:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1654087986; cv=none; d=zohomail.com; s=zohoarc; b=Yc0zP2mU7yPbKh6iTxnMtVVaWeD0hBjHBHLbF6lgkgN1WFMJ8ySphZiTmn1djzSUn+nkDrcWFNxM38mge52FAb2Ifb/riTFhGi+IgMcG+v5zQRWYcz+IboQ9ZttyyAp4w0KEK5c5dOzfeWTCSS334uQ7UMgI8wBvqVcN+3PO43o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654087986; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=4O9ba0y0acac9i/PjtU7mBUgJe7LdtnEI+KmMHU91WM=; b=EXXsQ1JLcn+4Pz0B/PmgD6GzElN8KlEibY0XKTMWiXv3jW8Y/il8hB2NcTG1GcyGcKC8cVdhNgjlJlEzxGr98ciNFDSFDE8u6FpsPQcNPNaE/vX43XpMQqXOD8cVjkH0874qNjrGlnpk00Llc6K8v3WbadeaoQl+9MniV/4aGjs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 165408798628312.709971495577975; Wed, 1 Jun 2022 05:53:06 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-425-VKIHMluIOWqR0U08OFMzdQ-1; Wed, 01 Jun 2022 08:51:43 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2201A1C051AF; Wed, 1 Jun 2022 12:50:56 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0C79E40CFD0A; Wed, 1 Jun 2022 12:50:56 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 83ECD1955EDE; Wed, 1 Jun 2022 12:50:52 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 7FAB61940347 for ; Wed, 1 Jun 2022 12:50:31 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 59E8540F06B; Wed, 1 Jun 2022 12:50:31 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.227]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1D180492C3B; Wed, 1 Jun 2022 12:50:31 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id AA6F3245B84; Wed, 1 Jun 2022 14:50:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654087984; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=4O9ba0y0acac9i/PjtU7mBUgJe7LdtnEI+KmMHU91WM=; b=fjtU6lG6hxK28dbsy6Cxw2YjnXgimS38GD4ojOc8A5V1fuLp5WFZYs4PSkajTtBo67yF41 Fb4JSS8HNN2kXVzbIu2qMNR+6Hbp/3ovk2on7kpMYHXKR/C4LIiwEraA7eaq0EzkMcu21I Kp3ZZ2DbWA9qK7DqQmvKsETjCIISHFs= X-MC-Unique: VKIHMluIOWqR0U08OFMzdQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH v2 56/81] qemu: Implement VIR_MIGRATE_POSTCOPY_RESUME for Perform phase Date: Wed, 1 Jun 2022 14:49:56 +0200 Message-Id: <455836a18b0a0140f9b244f7885b64f47611abac.1654087150.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Krempa , Pavel Hrdina Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1654087988400100007 Content-Type: text/plain; charset="utf-8" It just calls migrate QMP command with resume=3Dtrue without having to worry about migration capabilities or parameters, storage migration, etc. since everything has already been done in the normal Perform phase. Signed-off-by: Jiri Denemark Reviewed-by: Peter Krempa Reviewed-by: Pavel Hrdina --- Notes: Version 2: - dropped driver parameter from qemuMigrationSrcStart and qemuMigrationSrcResume src/qemu/qemu_migration.c | 110 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 106 insertions(+), 4 deletions(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 9996227057..2bc479592c 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -4818,6 +4818,51 @@ qemuMigrationSrcRun(virQEMUDriver *driver, goto error; } =20 + +static int +qemuMigrationSrcResume(virDomainObj *vm, + const char *cookiein, + int cookieinlen, + char **cookieout, + int *cookieoutlen, + qemuMigrationSpec *spec) +{ + qemuDomainObjPrivate *priv =3D vm->privateData; + virQEMUDriver *driver =3D priv->driver; + g_autoptr(qemuMigrationCookie) mig =3D NULL; + unsigned int migrateFlags =3D QEMU_MONITOR_MIGRATE_BACKGROUND | + QEMU_MONITOR_MIGRATE_RESUME; + int rc; + + VIR_DEBUG("vm=3D%p", vm); + + mig =3D qemuMigrationCookieParse(driver, vm->def, priv->origname, priv, + cookiein, cookieinlen, + QEMU_MIGRATION_COOKIE_CAPS); + if (!mig) + return -1; + + if (qemuDomainObjEnterMonitorAsync(driver, vm, + VIR_ASYNC_JOB_MIGRATION_OUT) < 0) + return -1; + + rc =3D qemuMigrationSrcStart(vm, spec, migrateFlags, NULL); + + qemuDomainObjExitMonitor(vm); + if (rc < 0) + return -1; + + if (qemuMigrationCookieFormat(mig, driver, vm, + QEMU_MIGRATION_SOURCE, + cookieout, cookieoutlen, + QEMU_MIGRATION_COOKIE_STATS) < 0) { + VIR_WARN("Unable to encode migration cookie"); + } + + return 0; +} + + /* Perform migration using QEMU's native migrate support, * not encrypted obviously */ @@ -4907,10 +4952,16 @@ qemuMigrationSrcPerformNative(virQEMUDriver *driver, =20 spec.fwdType =3D MIGRATION_FWD_DIRECT; =20 - ret =3D qemuMigrationSrcRun(driver, vm, persist_xml, cookiein, cookiei= nlen, cookieout, - cookieoutlen, flags, resource, &spec, dconn, - graphicsuri, nmigrate_disks, migrate_disks, - migParams, nbdURI); + if (flags & VIR_MIGRATE_POSTCOPY_RESUME) { + ret =3D qemuMigrationSrcResume(vm, cookiein, cookieinlen, + cookieout, cookieoutlen, &spec); + } else { + ret =3D qemuMigrationSrcRun(driver, vm, persist_xml, cookiein, coo= kieinlen, + cookieout, cookieoutlen, flags, resource, + &spec, dconn, graphicsuri, + nmigrate_disks, migrate_disks, + migParams, nbdURI); + } =20 if (spec.destType =3D=3D MIGRATION_DEST_FD) VIR_FORCE_CLOSE(spec.dest.fd.qemu); @@ -5773,6 +5824,51 @@ qemuMigrationSrcPerformJob(virQEMUDriver *driver, return ret; } =20 + +static int +qemuMigrationSrcPerformResume(virQEMUDriver *driver, + virConnectPtr conn, + virDomainObj *vm, + const char *uri, + const char *cookiein, + int cookieinlen, + char **cookieout, + int *cookieoutlen, + unsigned long flags) +{ + int ret; + + VIR_DEBUG("vm=3D%p, uri=3D%s", vm, uri); + + if (!qemuMigrationAnyCanResume(vm, VIR_ASYNC_JOB_MIGRATION_OUT, flags, + QEMU_MIGRATION_PHASE_BEGIN_RESUME)) + return -1; + + if (qemuMigrationJobStartPhase(vm, QEMU_MIGRATION_PHASE_PERFORM_RESUME= ) < 0) + return -1; + + virCloseCallbacksUnset(driver->closeCallbacks, vm, + qemuMigrationSrcCleanup); + qemuDomainCleanupRemove(vm, qemuProcessCleanupMigrationJob); + + ret =3D qemuMigrationSrcPerformNative(driver, vm, NULL, uri, + cookiein, cookieinlen, + cookieout, cookieoutlen, flags, + 0, NULL, NULL, 0, NULL, NULL, NULL= ); + + if (virCloseCallbacksSet(driver->closeCallbacks, vm, conn, + qemuMigrationSrcCleanup) < 0) + ret =3D -1; + + if (ret < 0) + ignore_value(qemuMigrationJobSetPhase(vm, QEMU_MIGRATION_PHASE_POS= TCOPY_FAILED)); + + qemuDomainCleanupAdd(vm, qemuProcessCleanupMigrationJob); + qemuMigrationJobContinue(vm); + return ret; +} + + /* * This implements perform phase of v3 migration protocol. */ @@ -5798,6 +5894,12 @@ qemuMigrationSrcPerformPhase(virQEMUDriver *driver, qemuDomainJobPrivate *jobPriv =3D priv->job.privateData; int ret =3D -1; =20 + if (flags & VIR_MIGRATE_POSTCOPY_RESUME) { + return qemuMigrationSrcPerformResume(driver, conn, vm, uri, + cookiein, cookieinlen, + cookieout, cookieoutlen, flag= s); + } + /* If we didn't start the job in the begin phase, start it now. */ if (!(flags & VIR_MIGRATE_CHANGE_PROTECTION)) { if (qemuMigrationJobStart(driver, vm, VIR_ASYNC_JOB_MIGRATION_OUT, --=20 2.35.1 From nobody Wed May 15 19:27:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1654087890; cv=none; d=zohomail.com; s=zohoarc; b=Y+aMyWAs+I1kc58dYL9R9/wziKZtyC436SOshK/r0GwcQ/McqVk+0Av8MsqdPaQ26xKHgZmdJhovzb+rM9yXdX2Yzxr8cxMTadFxXqOYT9fGd+dqLbG2Pv0eZ2EL4Z/bZuuDjilARizRIrA61X7jP9ANqEURrOPj/Tq7R4XlvEo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654087890; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=d6CD/UYJaOz21/ersHBFes3ZuTbh88+1bDeMF2+co2Y=; b=epHEvvlpD9daECWbDS5eU49LtJ3FzPO197o8b4GFlxJZ3yPYiRLvx8mTdX1zidoj4yhtgoT5JCHGJFaOuhGm6gISIfLm1eG/BZ1UM7NXJwqrM0x6JcOpLlJxIJDE2R0/KuWFRVibh0ETod/9phb9w4YI8KNuvJxWhGwZTLNkiBc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1654087890229676.6226210202173; Wed, 1 Jun 2022 05:51:30 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-75-JjvSwNTfOMaig-tVsynfww-1; Wed, 01 Jun 2022 08:51:15 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 91DFF8517C7; Wed, 1 Jun 2022 12:50:48 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7D0DE1410DDB; Wed, 1 Jun 2022 12:50:48 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id B6C8B194E104; Wed, 1 Jun 2022 12:50:44 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 96C5F193F6F4 for ; Wed, 1 Jun 2022 12:50:31 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 7482B8289E; Wed, 1 Jun 2022 12:50:31 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.227]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1E7F48288C; Wed, 1 Jun 2022 12:50:31 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id ABBED245B85; Wed, 1 Jun 2022 14:50:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654087888; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=d6CD/UYJaOz21/ersHBFes3ZuTbh88+1bDeMF2+co2Y=; b=i5r0V6C2PbFgdqS1rpcc/JVFFHER86CyzdIt1sudRTXeOJGutQP5oH8GOq8nkaqSAWyLa/ G3lQl8Vz1FuKDNCna/pBLgB7nKtC9P+6QUZzfPGK+7s3TRhYrkDibVpxWUWd2r4ORmceN9 tvodorfFSxbfhKijRa/qdO/KuXeKEzI= X-MC-Unique: JjvSwNTfOMaig-tVsynfww-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH v2 57/81] qemu: Implement VIR_MIGRATE_POSTCOPY_RESUME for Confirm phase Date: Wed, 1 Jun 2022 14:49:57 +0200 Message-Id: <340eb3f0dc192b37cc997b1b850e442abb62ff94.1654087150.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Krempa , Pavel Hrdina Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1654087891965100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Jiri Denemark Reviewed-by: Peter Krempa Reviewed-by: Pavel Hrdina --- Notes: Version 2: - moved "qemuDomainCleanupRemove(vm, qemuProcessCleanupMigrationJob)" to patch 12 (qemu: Keep migration job active after failed post-copy) src/qemu/qemu_migration.c | 48 +++++++++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 17 deletions(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 2bc479592c..f87d123836 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -3777,15 +3777,19 @@ qemuMigrationSrcConfirmPhase(virQEMUDriver *driver, =20 virCheckFlags(QEMU_MIGRATION_FLAGS, -1); =20 - /* Keep the original migration phase in case post-copy failed as the j= ob - * will stay active even though migration API finishes with an error. - */ - if (virDomainObjIsFailedPostcopy(vm)) + if (flags & VIR_MIGRATE_POSTCOPY_RESUME) { + phase =3D QEMU_MIGRATION_PHASE_CONFIRM_RESUME; + } else if (virDomainObjIsFailedPostcopy(vm)) { + /* Keep the original migration phase in case post-copy failed as t= he + * job will stay active even though migration API finishes with an + * error. + */ phase =3D priv->job.phase; - else if (retcode =3D=3D 0) + } else if (retcode =3D=3D 0) { phase =3D QEMU_MIGRATION_PHASE_CONFIRM3; - else + } else { phase =3D QEMU_MIGRATION_PHASE_CONFIRM3_CANCELLED; + } =20 if (qemuMigrationJobStartPhase(vm, phase) < 0) return -1; @@ -3860,18 +3864,28 @@ qemuMigrationSrcConfirm(virQEMUDriver *driver, qemuDomainObjPrivate *priv =3D vm->privateData; int ret =3D -1; =20 - if (!qemuMigrationJobIsActive(vm, VIR_ASYNC_JOB_MIGRATION_OUT)) - goto cleanup; + VIR_DEBUG("vm=3D%p, flags=3D0x%x, cancelled=3D%d", vm, flags, cancelle= d); =20 - /* Keep the original migration phase in case post-copy failed as the j= ob - * will stay active even though migration API finishes with an error. - */ - if (virDomainObjIsFailedPostcopy(vm)) - phase =3D priv->job.phase; - else if (cancelled) - phase =3D QEMU_MIGRATION_PHASE_CONFIRM3_CANCELLED; - else - phase =3D QEMU_MIGRATION_PHASE_CONFIRM3; + if (flags & VIR_MIGRATE_POSTCOPY_RESUME) { + if (!qemuMigrationAnyCanResume(vm, VIR_ASYNC_JOB_MIGRATION_OUT, fl= ags, + QEMU_MIGRATION_PHASE_PERFORM_RESUME= )) + goto cleanup; + phase =3D QEMU_MIGRATION_PHASE_CONFIRM_RESUME; + } else { + if (!qemuMigrationJobIsActive(vm, VIR_ASYNC_JOB_MIGRATION_OUT)) + goto cleanup; + + /* Keep the original migration phase in case post-copy failed as t= he + * job will stay active even though migration API finishes with an + * error. + */ + if (virDomainObjIsFailedPostcopy(vm)) + phase =3D priv->job.phase; + else if (cancelled) + phase =3D QEMU_MIGRATION_PHASE_CONFIRM3_CANCELLED; + else + phase =3D QEMU_MIGRATION_PHASE_CONFIRM3; + } =20 if (qemuMigrationJobStartPhase(vm, phase) < 0) goto cleanup; --=20 2.35.1 From nobody Wed May 15 19:27:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1654087904; cv=none; d=zohomail.com; s=zohoarc; b=K1lEsvev4g8V18yMfy7MzMhdppmrEJGaRVV1rsgfXPtcJSPQVkaY5bdr7YUjoKaFhx27Hj4eCBb4yqbGLm7ECA9Xcfbn8mJElz6aarfSMNKnbAMq3vcRoiO4UUdoaKd+F5kJnQyDpXKv0ydKwrmF3bp2EI7vVcmY4Wu1HG8OUQw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654087904; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=OuzEoxn70e/DNw57wySlI29p7ThesRioduDnziCMmr0=; b=T1rL+r1paNdrz8DZ9uQdHyHwsj3brsRpf7Atu5/ruHrAibsT4rHpIjKqTdxFw56pTGXAXAO7547iMX+iSOggON/v1VY26tcV+6JwEZFGsUhlgo/Se4oNQRNkD0Lt2aR1ts37FZSjdODi2A4+/c9AJFBWDEd0ok2bCPZtNOkE7r8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1654087904168497.86250725595585; Wed, 1 Jun 2022 05:51:44 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-620-gM9sjJwkOHSd7ytSdLll4Q-1; Wed, 01 Jun 2022 08:51:33 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id F0E4628005FE; Wed, 1 Jun 2022 12:50:47 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id DAAE18288C; Wed, 1 Jun 2022 12:50:47 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id F3135193220E; Wed, 1 Jun 2022 12:50:43 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 7FD151940368 for ; Wed, 1 Jun 2022 12:50:31 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 5DD6B2024CB6; Wed, 1 Jun 2022 12:50:31 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.227]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1E7222026D64; Wed, 1 Jun 2022 12:50:31 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id AD304245B86; Wed, 1 Jun 2022 14:50:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654087903; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=OuzEoxn70e/DNw57wySlI29p7ThesRioduDnziCMmr0=; b=QlHihwhUHy9NeKhlu+8TEoCjs4gVufSc20xJh28K6o5pG++KdJqbSciwU6UKSSPd/gA99r vCWQPmi0hzlCg22vlQnX+2w2uGQOMVc/rBFWiQMaBktYVeF+iIE3k8Qu16fiYuy6igo3Rh qM5TOlwKx7M35steF36eQd5cmmgGeWE= X-MC-Unique: gM9sjJwkOHSd7ytSdLll4Q-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH v2 58/81] qemu: Introduce qemuMigrationDstPrepareFresh Date: Wed, 1 Jun 2022 14:49:58 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Krempa , Pavel Hrdina Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1654087906036100005 Content-Type: text/plain; charset="utf-8" Moves most of the code from qemuMigrationDstPrepareAny to a new qemuMigrationDstPrepareFresh so that qemuMigrationDstPrepareAny can be shared with post-copy resume. Signed-off-by: Jiri Denemark Reviewed-by: Peter Krempa Reviewed-by: Pavel Hrdina --- Notes: Version 2: - dropped line breaks from error messages src/qemu/qemu_migration.c | 161 +++++++++++++++++++++++--------------- 1 file changed, 99 insertions(+), 62 deletions(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index f87d123836..d4683a9922 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -3084,27 +3084,26 @@ qemuMigrationDstPrepareAnyBlockDirtyBitmaps(virDoma= inObj *vm, =20 =20 static int -qemuMigrationDstPrepareAny(virQEMUDriver *driver, - virConnectPtr dconn, - const char *cookiein, - int cookieinlen, - char **cookieout, - int *cookieoutlen, - virDomainDef **def, - const char *origname, - virStreamPtr st, - const char *protocol, - unsigned short port, - bool autoPort, - const char *listenAddress, - size_t nmigrate_disks, - const char **migrate_disks, - int nbdPort, - const char *nbdURI, - qemuMigrationParams *migParams, - unsigned long flags) +qemuMigrationDstPrepareFresh(virQEMUDriver *driver, + virConnectPtr dconn, + const char *cookiein, + int cookieinlen, + char **cookieout, + int *cookieoutlen, + virDomainDef **def, + const char *origname, + virStreamPtr st, + const char *protocol, + unsigned short port, + bool autoPort, + const char *listenAddress, + size_t nmigrate_disks, + const char **migrate_disks, + int nbdPort, + const char *nbdURI, + qemuMigrationParams *migParams, + unsigned long flags) { - g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); virDomainObj *vm =3D NULL; virObjectEvent *event =3D NULL; virErrorPtr origErr; @@ -3124,55 +3123,18 @@ qemuMigrationDstPrepareAny(virQEMUDriver *driver, int rv; g_autofree char *tlsAlias =3D NULL; =20 + VIR_DEBUG("name=3D%s, origname=3D%s, protocol=3D%s, port=3D%hu, " + "listenAddress=3D%s, nbdPort=3D%d, nbdURI=3D%s, flags=3D0x%l= x", + (*def)->name, NULLSTR(origname), protocol, port, + listenAddress, nbdPort, NULLSTR(nbdURI), flags); + if (flags & VIR_MIGRATE_OFFLINE) { - if (flags & (VIR_MIGRATE_NON_SHARED_DISK | - VIR_MIGRATE_NON_SHARED_INC)) { - virReportError(VIR_ERR_OPERATION_INVALID, "%s", - _("offline migration cannot handle " - "non-shared storage")); - goto cleanup; - } - if (!(flags & VIR_MIGRATE_PERSIST_DEST)) { - virReportError(VIR_ERR_OPERATION_INVALID, "%s", - _("offline migration must be specified with " - "the persistent flag set")); - goto cleanup; - } - if (tunnel) { - virReportError(VIR_ERR_OPERATION_INVALID, "%s", - _("tunnelled offline migration does not " - "make sense")); - goto cleanup; - } cookieFlags =3D 0; } else { cookieFlags =3D QEMU_MIGRATION_COOKIE_GRAPHICS | QEMU_MIGRATION_COOKIE_CAPS; } =20 - if (flags & VIR_MIGRATE_POSTCOPY && - (!(flags & VIR_MIGRATE_LIVE) || - flags & VIR_MIGRATE_PAUSED)) { - virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", - _("post-copy migration is not supported with non-li= ve " - "or paused migration")); - goto cleanup; - } - - if (flags & VIR_MIGRATE_POSTCOPY && flags & VIR_MIGRATE_TUNNELLED) { - virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", - _("post-copy is not supported with tunnelled migrat= ion")); - goto cleanup; - } - - if (cfg->migrateTLSForce && - !(flags & VIR_MIGRATE_TUNNELLED) && - !(flags & VIR_MIGRATE_TLS)) { - virReportError(VIR_ERR_OPERATION_INVALID, "%s", - _("this libvirtd instance allows migration only wit= h VIR_MIGRATE_TLS flag")); - goto cleanup; - } - if (!qemuMigrationSrcIsAllowedHostdev(*def)) goto cleanup; =20 @@ -3464,6 +3426,81 @@ qemuMigrationDstPrepareAny(virQEMUDriver *driver, } =20 =20 +static int +qemuMigrationDstPrepareAny(virQEMUDriver *driver, + virConnectPtr dconn, + const char *cookiein, + int cookieinlen, + char **cookieout, + int *cookieoutlen, + virDomainDef **def, + const char *origname, + virStreamPtr st, + const char *protocol, + unsigned short port, + bool autoPort, + const char *listenAddress, + size_t nmigrate_disks, + const char **migrate_disks, + int nbdPort, + const char *nbdURI, + qemuMigrationParams *migParams, + unsigned long flags) +{ + g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); + + if (flags & VIR_MIGRATE_OFFLINE) { + if (flags & (VIR_MIGRATE_NON_SHARED_DISK | + VIR_MIGRATE_NON_SHARED_INC)) { + virReportError(VIR_ERR_OPERATION_INVALID, "%s", + _("offline migration cannot handle non-shared s= torage")); + return -1; + } + if (!(flags & VIR_MIGRATE_PERSIST_DEST)) { + virReportError(VIR_ERR_OPERATION_INVALID, "%s", + _("offline migration must be specified with the= persistent flag set")); + return -1; + } + if (st) { + virReportError(VIR_ERR_OPERATION_INVALID, "%s", + _("tunnelled offline migration does not make se= nse")); + return -1; + } + } + + if (flags & VIR_MIGRATE_POSTCOPY && + (!(flags & VIR_MIGRATE_LIVE) || + flags & VIR_MIGRATE_PAUSED)) { + virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", + _("post-copy migration is not supported with non-li= ve or paused migration")); + return -1; + } + + if (flags & VIR_MIGRATE_POSTCOPY && flags & VIR_MIGRATE_TUNNELLED) { + virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", + _("post-copy is not supported with tunnelled migrat= ion")); + return -1; + } + + if (cfg->migrateTLSForce && + !(flags & VIR_MIGRATE_TUNNELLED) && + !(flags & VIR_MIGRATE_TLS)) { + virReportError(VIR_ERR_OPERATION_INVALID, "%s", + _("this libvirtd instance allows migration only wit= h VIR_MIGRATE_TLS flag")); + return -1; + } + + return qemuMigrationDstPrepareFresh(driver, dconn, + cookiein, cookieinlen, + cookieout, cookieoutlen, + def, origname, st, protocol, + port, autoPort, listenAddress, + nmigrate_disks, migrate_disks, + nbdPort, nbdURI, + migParams, flags); +} + + /* * This version starts an empty VM listening on a localhost TCP port, and * sets up the corresponding virStream to handle the incoming data. --=20 2.35.1 From nobody Wed May 15 19:27:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1654087988; cv=none; d=zohomail.com; s=zohoarc; b=GhiIYaB/XpS9iP35+sstGEMokTsZXKiuyv5zGnNSxnspeleKOTwm7CIRF8jld85GNzn/ULAuc7YU7BbRa7Ujyrbg/z21G9FiUZZZHyyhdJyh4f136Whr8jJahjQI3ZPEKe2to6TQT/UxDSByfO1z217pUZ6K1GQJ9Mc95MPHKxQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654087988; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=e8QZARivFrTNOPMrV2r07KoAjmBg+L6pUjhphP078OU=; b=mQs07+S15LijI8DxH9V8eIiglCKumQ40cIvKLPGvN6rSofRsCmivhj4G9Pe6iZZoWzzpW7q6TIXewqlmyEnT5Tb2B9tcUtwZmvKiBcWJHM8SGCZvWQ+zonPX6Fpa3Mj9Xh0Lo2fFFn6pD7TPtP/OHiqzVHQB7FMQZZqQ/dKXDQo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1654087988859368.87849784969535; Wed, 1 Jun 2022 05:53:08 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-645-Aw1F8yS_NIaIvqE4bIXQ4A-1; Wed, 01 Jun 2022 08:51:46 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C0D9928013FD; Wed, 1 Jun 2022 12:50:54 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id A2F6E2024CB6; Wed, 1 Jun 2022 12:50:54 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 499DC1947B97; Wed, 1 Jun 2022 12:50:51 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id C14C019451EC for ; Wed, 1 Jun 2022 12:50:31 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id B19171121315; Wed, 1 Jun 2022 12:50:31 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.227]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 216051121330; Wed, 1 Jun 2022 12:50:31 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id AEB5B245B88; Wed, 1 Jun 2022 14:50:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654087987; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=e8QZARivFrTNOPMrV2r07KoAjmBg+L6pUjhphP078OU=; b=B668GHaOjkNTeKDl4dSmm5h1O4xJuCscXcMipHoYwf79gITuH6b5svkjVmNJJfZGhH/fGt p1hNUZyQfCgeBvpL565IpUQ7tSZn3Ev9K53m6h07sDP18muJm+GKUJqN9uCWEPpO/Tz39Z AUlAylOPIU4G7c4bGy9o4QNlirBtol4= X-MC-Unique: Aw1F8yS_NIaIvqE4bIXQ4A-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH v2 59/81] qemu: Refactor qemuMigrationDstPrepareFresh Date: Wed, 1 Jun 2022 14:49:59 +0200 Message-Id: <96ebc7c97bb4a8d22985fde10e5f61d0e4c44a47.1654087150.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Krempa , Pavel Hrdina Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1654087990469100013 Content-Type: text/plain; charset="utf-8" Offline migration jumps over a big part of qemuMigrationDstPrepareFresh. Let's move that part into a new qemuMigrationDstPrepareActive function to make the code easier to follow. Signed-off-by: Jiri Denemark Reviewed-by: Peter Krempa Reviewed-by: Pavel Hrdina --- Notes: Version 2: - dropped line breaks from error messages - fixed indentation - dropped VIR_MIGRATE_OFFLINE check from qemuMigrationDstPrepareActive src/qemu/qemu_migration.c | 371 +++++++++++++++++++++----------------- 1 file changed, 203 insertions(+), 168 deletions(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index d4683a9922..53236b7239 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -3083,6 +3083,197 @@ qemuMigrationDstPrepareAnyBlockDirtyBitmaps(virDoma= inObj *vm, } =20 =20 +static int +qemuMigrationDstPrepareActive(virQEMUDriver *driver, + virDomainObj *vm, + virConnectPtr dconn, + qemuMigrationCookie *mig, + virStreamPtr st, + const char *protocol, + unsigned short port, + const char *listenAddress, + size_t nmigrate_disks, + const char **migrate_disks, + int nbdPort, + const char *nbdURI, + qemuMigrationParams *migParams, + unsigned long flags) +{ + qemuDomainObjPrivate *priv =3D vm->privateData; + qemuDomainJobPrivate *jobPriv =3D priv->job.privateData; + qemuProcessIncomingDef *incoming =3D NULL; + g_autofree char *tlsAlias =3D NULL; + virObjectEvent *event =3D NULL; + virErrorPtr origErr =3D NULL; + int dataFD[2] =3D { -1, -1 }; + bool stopProcess =3D false; + unsigned int startFlags; + bool relabel =3D false; + bool tunnel =3D !!st; + int ret =3D -1; + int rv; + + if (STREQ_NULLABLE(protocol, "rdma") && + !virMemoryLimitIsSet(vm->def->mem.hard_limit)) { + virReportError(VIR_ERR_OPERATION_INVALID, "%s", + _("cannot start RDMA migration with no memory hard = limit set")); + goto error; + } + + if (qemuMigrationDstPrecreateStorage(vm, mig->nbd, + nmigrate_disks, migrate_disks, + !!(flags & VIR_MIGRATE_NON_SHARED= _INC)) < 0) + goto error; + + if (tunnel && + virPipe(dataFD) < 0) + goto error; + + startFlags =3D VIR_QEMU_PROCESS_START_AUTODESTROY; + + if (qemuProcessInit(driver, vm, mig->cpu, VIR_ASYNC_JOB_MIGRATION_IN, + true, startFlags) < 0) + goto error; + stopProcess =3D true; + + if (!(incoming =3D qemuMigrationDstPrepare(vm, tunnel, protocol, + listenAddress, port, + dataFD[0]))) + goto error; + + if (qemuProcessPrepareDomain(driver, vm, startFlags) < 0) + goto error; + + if (qemuProcessPrepareHost(driver, vm, startFlags) < 0) + goto error; + + rv =3D qemuProcessLaunch(dconn, driver, vm, VIR_ASYNC_JOB_MIGRATION_IN, + incoming, NULL, + VIR_NETDEV_VPORT_PROFILE_OP_MIGRATE_IN_START, + startFlags); + if (rv < 0) { + if (rv =3D=3D -2) + relabel =3D true; + goto error; + } + relabel =3D true; + + if (tunnel) { + if (virFDStreamOpen(st, dataFD[1]) < 0) { + virReportSystemError(errno, "%s", + _("cannot pass pipe for tunnelled migrati= on")); + goto error; + } + dataFD[1] =3D -1; /* 'st' owns the FD now & will close it */ + } + + if (STREQ_NULLABLE(protocol, "rdma") && + vm->def->mem.hard_limit > 0 && + virProcessSetMaxMemLock(vm->pid, vm->def->mem.hard_limit << 10) < = 0) { + goto error; + } + + if (qemuMigrationDstPrepareAnyBlockDirtyBitmaps(vm, mig, migParams, fl= ags) < 0) + goto error; + + if (qemuMigrationParamsCheck(driver, vm, VIR_ASYNC_JOB_MIGRATION_IN, + migParams, mig->caps->automatic) < 0) + goto error; + + /* Migrations using TLS need to add the "tls-creds-x509" object and + * set the migration TLS parameters */ + if (flags & VIR_MIGRATE_TLS) { + if (qemuMigrationParamsEnableTLS(driver, vm, true, + VIR_ASYNC_JOB_MIGRATION_IN, + &tlsAlias, NULL, + migParams) < 0) + goto error; + } else { + if (qemuMigrationParamsDisableTLS(vm, migParams) < 0) + goto error; + } + + if (qemuMigrationParamsApply(driver, vm, VIR_ASYNC_JOB_MIGRATION_IN, + migParams) < 0) + goto error; + + if (mig->nbd && + flags & (VIR_MIGRATE_NON_SHARED_DISK | VIR_MIGRATE_NON_SHARED_INC)= && + virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_NBD_SERVER)) { + const char *nbdTLSAlias =3D NULL; + + if (flags & VIR_MIGRATE_TLS) { + if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_NBD_TLS)) { + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", + _("QEMU NBD server does not support TLS tra= nsport")); + goto error; + } + + nbdTLSAlias =3D tlsAlias; + } + + if (qemuMigrationDstStartNBDServer(driver, vm, incoming->address, + nmigrate_disks, migrate_disks, + nbdPort, nbdURI, + nbdTLSAlias) < 0) { + goto error; + } + } + + if (mig->lockState) { + VIR_DEBUG("Received lockstate %s", mig->lockState); + VIR_FREE(priv->lockState); + priv->lockState =3D g_steal_pointer(&mig->lockState); + } else { + VIR_DEBUG("Received no lockstate"); + } + + if (qemuMigrationDstRun(driver, vm, incoming->uri, + VIR_ASYNC_JOB_MIGRATION_IN) < 0) + goto error; + + if (qemuProcessFinishStartup(driver, vm, VIR_ASYNC_JOB_MIGRATION_IN, + false, VIR_DOMAIN_PAUSED_MIGRATION) < 0) + goto error; + + virDomainAuditStart(vm, "migrated", true); + event =3D virDomainEventLifecycleNewFromObj(vm, + VIR_DOMAIN_EVENT_STARTED, + VIR_DOMAIN_EVENT_STARTED_MIG= RATED); + + ret =3D 0; + + cleanup: + qemuProcessIncomingDefFree(incoming); + VIR_FORCE_CLOSE(dataFD[0]); + VIR_FORCE_CLOSE(dataFD[1]); + virObjectEventStateQueue(driver->domainEventState, event); + virErrorRestore(&origErr); + return ret; + + error: + virErrorPreserveLast(&origErr); + qemuMigrationParamsReset(driver, vm, VIR_ASYNC_JOB_MIGRATION_IN, + jobPriv->migParams, priv->job.apiFlags); + + if (stopProcess) { + unsigned int stopFlags =3D VIR_QEMU_PROCESS_STOP_MIGRATED; + if (!relabel) + stopFlags |=3D VIR_QEMU_PROCESS_STOP_NO_RELABEL; + virDomainAuditStart(vm, "migrated", false); + qemuProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_FAILED, + VIR_ASYNC_JOB_MIGRATION_IN, stopFlags); + /* release if port is auto selected which is not the case if + * it is given in parameters + */ + if (nbdPort =3D=3D 0) + virPortAllocatorRelease(priv->nbdPort); + priv->nbdPort =3D 0; + } + goto cleanup; +} + + static int qemuMigrationDstPrepareFresh(virQEMUDriver *driver, virConnectPtr dconn, @@ -3105,32 +3296,20 @@ qemuMigrationDstPrepareFresh(virQEMUDriver *driver, unsigned long flags) { virDomainObj *vm =3D NULL; - virObjectEvent *event =3D NULL; virErrorPtr origErr; int ret =3D -1; - int dataFD[2] =3D { -1, -1 }; qemuDomainObjPrivate *priv =3D NULL; qemuMigrationCookie *mig =3D NULL; - qemuDomainJobPrivate *jobPriv =3D NULL; - bool tunnel =3D !!st; g_autofree char *xmlout =3D NULL; - unsigned int cookieFlags; - unsigned int startFlags; - qemuProcessIncomingDef *incoming =3D NULL; + unsigned int cookieFlags =3D 0; bool taint_hook =3D false; - bool stopProcess =3D false; - bool relabel =3D false; - int rv; - g_autofree char *tlsAlias =3D NULL; =20 VIR_DEBUG("name=3D%s, origname=3D%s, protocol=3D%s, port=3D%hu, " "listenAddress=3D%s, nbdPort=3D%d, nbdURI=3D%s, flags=3D0x%l= x", (*def)->name, NULLSTR(origname), protocol, port, listenAddress, nbdPort, NULLSTR(nbdURI), flags); =20 - if (flags & VIR_MIGRATE_OFFLINE) { - cookieFlags =3D 0; - } else { + if (!(flags & VIR_MIGRATE_OFFLINE)) { cookieFlags =3D QEMU_MIGRATION_COOKIE_GRAPHICS | QEMU_MIGRATION_COOKIE_CAPS; } @@ -3203,7 +3382,6 @@ qemuMigrationDstPrepareFresh(virQEMUDriver *driver, goto cleanup; =20 priv =3D vm->privateData; - jobPriv =3D priv->job.privateData; priv->origname =3D g_strdup(origname); =20 if (taint_hook) { @@ -3211,19 +3389,6 @@ qemuMigrationDstPrepareFresh(virQEMUDriver *driver, priv->hookRun =3D true; } =20 - if (STREQ_NULLABLE(protocol, "rdma") && - !virMemoryLimitIsSet(vm->def->mem.hard_limit)) { - virReportError(VIR_ERR_OPERATION_INVALID, "%s", - _("cannot start RDMA migration with no memory hard " - "limit set")); - goto cleanup; - } - - if (qemuMigrationDstPrecreateStorage(vm, mig->nbd, - nmigrate_disks, migrate_disks, - !!(flags & VIR_MIGRATE_NON_SHARED= _INC)) < 0) - goto cleanup; - if (qemuMigrationJobStart(driver, vm, VIR_ASYNC_JOB_MIGRATION_IN, flags) < 0) goto cleanup; @@ -3234,122 +3399,21 @@ qemuMigrationDstPrepareFresh(virQEMUDriver *driver, /* Domain starts inactive, even if the domain XML had an id field. */ vm->def->id =3D -1; =20 - if (flags & VIR_MIGRATE_OFFLINE) - goto done; - - if (tunnel && - virPipe(dataFD) < 0) - goto stopjob; - - startFlags =3D VIR_QEMU_PROCESS_START_AUTODESTROY; - - if (qemuProcessInit(driver, vm, mig->cpu, VIR_ASYNC_JOB_MIGRATION_IN, - true, startFlags) < 0) - goto stopjob; - stopProcess =3D true; - - if (!(incoming =3D qemuMigrationDstPrepare(vm, tunnel, protocol, - listenAddress, port, - dataFD[0]))) - goto stopjob; - - if (qemuProcessPrepareDomain(driver, vm, startFlags) < 0) - goto stopjob; - - if (qemuProcessPrepareHost(driver, vm, startFlags) < 0) - goto stopjob; - - rv =3D qemuProcessLaunch(dconn, driver, vm, VIR_ASYNC_JOB_MIGRATION_IN, - incoming, NULL, - VIR_NETDEV_VPORT_PROFILE_OP_MIGRATE_IN_START, - startFlags); - if (rv < 0) { - if (rv =3D=3D -2) - relabel =3D true; - goto stopjob; - } - relabel =3D true; - - if (tunnel) { - if (virFDStreamOpen(st, dataFD[1]) < 0) { - virReportSystemError(errno, "%s", - _("cannot pass pipe for tunnelled migrati= on")); - goto stopjob; - } - dataFD[1] =3D -1; /* 'st' owns the FD now & will close it */ - } - - if (STREQ_NULLABLE(protocol, "rdma") && - vm->def->mem.hard_limit > 0 && - virProcessSetMaxMemLock(vm->pid, vm->def->mem.hard_limit << 10) < = 0) { - goto stopjob; - } - - if (qemuMigrationDstPrepareAnyBlockDirtyBitmaps(vm, mig, migParams, fl= ags) < 0) - goto stopjob; - - if (qemuMigrationParamsCheck(driver, vm, VIR_ASYNC_JOB_MIGRATION_IN, - migParams, mig->caps->automatic) < 0) - goto stopjob; - - /* Migrations using TLS need to add the "tls-creds-x509" object and - * set the migration TLS parameters */ - if (flags & VIR_MIGRATE_TLS) { - if (qemuMigrationParamsEnableTLS(driver, vm, true, - VIR_ASYNC_JOB_MIGRATION_IN, - &tlsAlias, NULL, - migParams) < 0) - goto stopjob; - } else { - if (qemuMigrationParamsDisableTLS(vm, migParams) < 0) + if (!(flags & VIR_MIGRATE_OFFLINE)) { + if (qemuMigrationDstPrepareActive(driver, vm, dconn, mig, st, + protocol, port, listenAddress, + nmigrate_disks, migrate_disks, + nbdPort, nbdURI, + migParams, flags) < 0) { goto stopjob; - } - - if (qemuMigrationParamsApply(driver, vm, VIR_ASYNC_JOB_MIGRATION_IN, - migParams) < 0) - goto stopjob; - - if (mig->nbd && - flags & (VIR_MIGRATE_NON_SHARED_DISK | VIR_MIGRATE_NON_SHARED_INC)= && - virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_NBD_SERVER)) { - const char *nbdTLSAlias =3D NULL; - - if (flags & VIR_MIGRATE_TLS) { - if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_NBD_TLS)) { - virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", - _("QEMU NBD server does not support TLS tra= nsport")); - goto stopjob; - } - - nbdTLSAlias =3D tlsAlias; } =20 - if (qemuMigrationDstStartNBDServer(driver, vm, incoming->address, - nmigrate_disks, migrate_disks, - nbdPort, nbdURI, - nbdTLSAlias) < 0) { - goto stopjob; - } - cookieFlags |=3D QEMU_MIGRATION_COOKIE_NBD; + if (mig->nbd && + flags & (VIR_MIGRATE_NON_SHARED_DISK | VIR_MIGRATE_NON_SHARED_= INC) && + virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_NBD_SERVER)) + cookieFlags |=3D QEMU_MIGRATION_COOKIE_NBD; } =20 - if (mig->lockState) { - VIR_DEBUG("Received lockstate %s", mig->lockState); - VIR_FREE(priv->lockState); - priv->lockState =3D g_steal_pointer(&mig->lockState); - } else { - VIR_DEBUG("Received no lockstate"); - } - - if (qemuMigrationDstRun(driver, vm, incoming->uri, - VIR_ASYNC_JOB_MIGRATION_IN) < 0) - goto stopjob; - - if (qemuProcessFinishStartup(driver, vm, VIR_ASYNC_JOB_MIGRATION_IN, - false, VIR_DOMAIN_PAUSED_MIGRATION) < 0) - goto stopjob; - - done: if (qemuMigrationCookieFormat(mig, driver, vm, QEMU_MIGRATION_DESTINATION, cookieout, cookieoutlen, cookieFlags) < = 0) { @@ -3362,13 +3426,6 @@ qemuMigrationDstPrepareFresh(virQEMUDriver *driver, =20 qemuDomainCleanupAdd(vm, qemuMigrationDstPrepareCleanup); =20 - if (!(flags & VIR_MIGRATE_OFFLINE)) { - virDomainAuditStart(vm, "migrated", true); - event =3D virDomainEventLifecycleNewFromObj(vm, - VIR_DOMAIN_EVENT_STARTED, - VIR_DOMAIN_EVENT_STARTED_MIGRATED= ); - } - /* We keep the job active across API calls until the finish() call. * This prevents any other APIs being invoked while incoming * migration is taking place. @@ -3386,41 +3443,19 @@ qemuMigrationDstPrepareFresh(virQEMUDriver *driver, =20 cleanup: virErrorPreserveLast(&origErr); - qemuProcessIncomingDefFree(incoming); - VIR_FORCE_CLOSE(dataFD[0]); - VIR_FORCE_CLOSE(dataFD[1]); if (ret < 0 && priv) { /* priv is set right after vm is added to the list of domains * and there is no 'goto cleanup;' in the middle of those */ VIR_FREE(priv->origname); - /* release if port is auto selected which is not the case if - * it is given in parameters - */ - if (nbdPort =3D=3D 0) - virPortAllocatorRelease(priv->nbdPort); - priv->nbdPort =3D 0; virDomainObjRemoveTransientDef(vm); qemuDomainRemoveInactive(driver, vm); } virDomainObjEndAPI(&vm); - virObjectEventStateQueue(driver->domainEventState, event); qemuMigrationCookieFree(mig); virErrorRestore(&origErr); return ret; =20 stopjob: - qemuMigrationParamsReset(driver, vm, VIR_ASYNC_JOB_MIGRATION_IN, - jobPriv->migParams, priv->job.apiFlags); - - if (stopProcess) { - unsigned int stopFlags =3D VIR_QEMU_PROCESS_STOP_MIGRATED; - if (!relabel) - stopFlags |=3D VIR_QEMU_PROCESS_STOP_NO_RELABEL; - virDomainAuditStart(vm, "migrated", false); - qemuProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_FAILED, - VIR_ASYNC_JOB_MIGRATION_IN, stopFlags); - } - qemuMigrationJobFinish(vm); goto cleanup; } --=20 2.35.1 From nobody Wed May 15 19:27:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1654087929; cv=none; d=zohomail.com; s=zohoarc; b=JVx1Ay3xmXJ5bBtsTo79aHDZJWV8pukjbzuRj1fvFHRbTtx46nCG6q1AakiUMtjngA9xhF5aWSwd2dkQhNbYRcR7jTzqf7Z1GJCUJNVBjBNjMOvn7PiAZ52Kt1q4VP391nrOz44shbbJRWs/khr9Aulkd9ipOrXod7PfjIoSx+8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654087929; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=sxXVVsMhIv3KtFpMlI0kU5P3bLcJUew0H2dWoLc3HCQ=; b=dP52DJK8LGJ1W6fTmw/MgXJpoJXfMt5Htx0AsycpZ835Il8v1n7b6QBMJ7cXAWCAkU20r5/HCSxqhMhZO0Kqys+6sSGYfJnr+y22+LGVgrvA8BPC207H2MFzyXp/bWrufc9BZnQyw7MW4mR2LkuyFACl1t5YJ4Anig+KbcYw7Wc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1654087929816976.9657696148458; Wed, 1 Jun 2022 05:52:09 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-370-Op0UxnrMOLuOBtBh0nadXQ-1; Wed, 01 Jun 2022 08:51:36 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CC2878853CE; Wed, 1 Jun 2022 12:50:53 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id B80161121314; Wed, 1 Jun 2022 12:50:53 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 24A1E1947B88; Wed, 1 Jun 2022 12:50:50 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 62F8B1947B90 for ; Wed, 1 Jun 2022 12:50:31 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 3E20240EC004; Wed, 1 Jun 2022 12:50:31 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.227]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1DE7740EC007 for ; Wed, 1 Jun 2022 12:50:31 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id AFFF6245B89; Wed, 1 Jun 2022 14:50:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654087928; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=sxXVVsMhIv3KtFpMlI0kU5P3bLcJUew0H2dWoLc3HCQ=; b=REEmQKyxJGYB6MS48mKwFjFacX8wFf7InASssYuJXV+7FoiPVQxOq/GFf1+jNi/kZ2e15b lvEYkydCPWMFsAA7CP9Z2amwyfJk8qOHPOeNOsHRNlTHX36HmePHqozE2oKhTs7tSDmGx4 tihfjJgM3CG1KYq2G06pGY5YMSINq9M= X-MC-Unique: Op0UxnrMOLuOBtBh0nadXQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH v2 60/81] qemu: Use autoptr for mig in qemuMigrationDstPrepareFresh Date: Wed, 1 Jun 2022 14:50:00 +0200 Message-Id: <6a66ecde73b837b43a4160069dd44bc96a8d0340.1654087150.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1654087930162100007 Content-Type: text/plain; charset="utf-8" Signed-off-by: Jiri Denemark Reviewed-by: J=C3=A1n Tomko --- Notes: Version 2: - replaces [62/80] qemu: Simplify cleanup in qemuMigrationDstPrepareFresh - it's the same patch with different commit message and changes touching origErr removed :-) src/qemu/qemu_migration.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 53236b7239..e888384570 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -3299,7 +3299,7 @@ qemuMigrationDstPrepareFresh(virQEMUDriver *driver, virErrorPtr origErr; int ret =3D -1; qemuDomainObjPrivate *priv =3D NULL; - qemuMigrationCookie *mig =3D NULL; + g_autoptr(qemuMigrationCookie) mig =3D NULL; g_autofree char *xmlout =3D NULL; unsigned int cookieFlags =3D 0; bool taint_hook =3D false; @@ -3451,7 +3451,6 @@ qemuMigrationDstPrepareFresh(virQEMUDriver *driver, qemuDomainRemoveInactive(driver, vm); } virDomainObjEndAPI(&vm); - qemuMigrationCookieFree(mig); virErrorRestore(&origErr); return ret; =20 --=20 2.35.1 From nobody Wed May 15 19:27:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1654087905; cv=none; d=zohomail.com; s=zohoarc; b=ZE4o5+f0rE3i96o9QDVRbjhL9YmjXMK2fwzDCj+6CtzRmbhWp0+6xenInv19oGNTxTiwPdyM5G8i3R86LE2ErpHEcbrwuVKL2xbyiyo/EqwuvAXeYOTAZKjbHiOu7dX3SNkybNqyDDx3XQQiR2P9x3cAtQUvbQRrrUUoB1vZWuw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654087905; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=pNXwh5lI0sN42L0NARc6xKm8bgOm80VeFGq7z7EViEE=; b=YWaPiMDkSnrc4+i/Rk4JAzU2JgNy4ztsK5KrJEwFfaM0gytdbnfvsGpSafgz9OceiNjRfxExEhLkIhPqjKPEC280YZHWISIavdvXw6s82uvjxPHog7AfotKHgT8a3xmTjq9AWiaVpzntnT0bYrSjIr++cN8fJcNjhFhEgYxXwMg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1654087905075611.8012790233732; Wed, 1 Jun 2022 05:51:45 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-213-jGNaERi3O4au9F7EnjfDdA-1; Wed, 01 Jun 2022 08:51:32 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 37031833B04; Wed, 1 Jun 2022 12:50:51 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2516FC27E8F; Wed, 1 Jun 2022 12:50:51 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 3C10D1955ED0; Wed, 1 Jun 2022 12:50:47 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 51E111947BA1 for ; Wed, 1 Jun 2022 12:50:31 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 40A418289E; Wed, 1 Jun 2022 12:50:31 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.227]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1E41F82882; Wed, 1 Jun 2022 12:50:31 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id B155D245B8A; Wed, 1 Jun 2022 14:50:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654087904; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=pNXwh5lI0sN42L0NARc6xKm8bgOm80VeFGq7z7EViEE=; b=daX45BhW0/07yBHd2ObjgyYSmW0Df5HXcJtTxuQsO8CCKoAqE2X3qpJLmewv1S2gBAHOeF bMx6AYWUA49FdUvjm+HxN+KHOGh+DkoDBhOY2l7pacF0W/4tPbghFEkrCMNND4tf20Pqaf b5yj84VWGIUPre2qFvspob5BKYcWxl4= X-MC-Unique: jGNaERi3O4au9F7EnjfDdA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH v2 61/81] qemu: Add support for migrate-recover QMP command Date: Wed, 1 Jun 2022 14:50:01 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Krempa , Pavel Hrdina Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1654087906023100002 Content-Type: text/plain; charset="utf-8" This command tells QEMU to start listening for an incoming post-copy recovery connection. Just like migrate-incoming is used for starting fresh migration on the destination host. Signed-off-by: Jiri Denemark Reviewed-by: Peter Krempa Reviewed-by: Pavel Hrdina --- Notes: Version 2: - added a case in qemumonitorjsontest src/qemu/qemu_monitor.c | 12 ++++++++++++ src/qemu/qemu_monitor.h | 4 ++++ src/qemu/qemu_monitor_json.c | 19 +++++++++++++++++++ src/qemu/qemu_monitor_json.h | 4 ++++ tests/qemumonitorjsontest.c | 2 ++ 5 files changed, 41 insertions(+) diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index ec56d413da..e9b9390c80 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -4521,3 +4521,15 @@ qemuMonitorChangeMemoryRequestedSize(qemuMonitor *mo= n, =20 return qemuMonitorJSONChangeMemoryRequestedSize(mon, alias, requesteds= ize); } + + +int +qemuMonitorMigrateRecover(qemuMonitor *mon, + const char *uri) +{ + VIR_DEBUG("uri=3D%s", uri); + + QEMU_CHECK_MONITOR(mon); + + return qemuMonitorJSONMigrateRecover(mon, uri); +} diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index 98496b9037..4f6c7e40fd 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -1545,3 +1545,7 @@ int qemuMonitorChangeMemoryRequestedSize(qemuMonitor *mon, const char *alias, unsigned long long requestedsize); + +int +qemuMonitorMigrateRecover(qemuMonitor *mon, + const char *uri); diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 8b026e8ade..99c5e1b40f 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -8970,3 +8970,22 @@ qemuMonitorJSONChangeMemoryRequestedSize(qemuMonitor= *mon, =20 return qemuMonitorJSONSetObjectProperty(mon, path, "requested-size", &= prop); } + + +int +qemuMonitorJSONMigrateRecover(qemuMonitor *mon, + const char *uri) +{ + g_autoptr(virJSONValue) cmd =3D NULL; + g_autoptr(virJSONValue) reply =3D NULL; + + if (!(cmd =3D qemuMonitorJSONMakeCommand("migrate-recover", + "s:uri", uri, + NULL))) + return -1; + + if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) + return -1; + + return qemuMonitorJSONCheckError(cmd, reply); +} diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h index 3c442d669f..305faafce4 100644 --- a/src/qemu/qemu_monitor_json.h +++ b/src/qemu/qemu_monitor_json.h @@ -872,3 +872,7 @@ int qemuMonitorJSONChangeMemoryRequestedSize(qemuMonitor *mon, const char *alias, unsigned long long requestedsize); + +int +qemuMonitorJSONMigrateRecover(qemuMonitor *mon, + const char *uri); diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c index 2de282dcba..96d6da1f47 100644 --- a/tests/qemumonitorjsontest.c +++ b/tests/qemumonitorjsontest.c @@ -1210,6 +1210,7 @@ GEN_TEST_FUNC(qemuMonitorJSONSetMigrationDowntime, 1) GEN_TEST_FUNC(qemuMonitorJSONMigrate, QEMU_MONITOR_MIGRATE_BACKGROUND | QEMU_MONITOR_MIGRATE_NON_SHARED_DISK | QEMU_MONITOR_MIGRATE_NON_SHARED_INC, "tcp:localhost:12345") +GEN_TEST_FUNC(qemuMonitorJSONMigrateRecover, "tcp://destination.host:54321= "); GEN_TEST_FUNC(qemuMonitorJSONDump, "dummy_protocol", "elf", true) GEN_TEST_FUNC(qemuMonitorJSONGraphicsRelocate, VIR_DOMAIN_GRAPHICS_TYPE_SP= ICE, @@ -3109,6 +3110,7 @@ mymain(void) DO_TEST_GEN_DEPRECATED(qemuMonitorJSONSetMigrationSpeed, true); DO_TEST_GEN_DEPRECATED(qemuMonitorJSONSetMigrationDowntime, true); DO_TEST_GEN(qemuMonitorJSONMigrate); + DO_TEST_GEN(qemuMonitorJSONMigrateRecover); DO_TEST_GEN(qemuMonitorJSONDump); DO_TEST_GEN(qemuMonitorJSONGraphicsRelocate); DO_TEST_GEN(qemuMonitorJSONRemoveNetdev); --=20 2.35.1 From nobody Wed May 15 19:27:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1654087941; cv=none; d=zohomail.com; s=zohoarc; b=XJXC+B/g63+VMu+FgHgmgWQSFg95unMD/qWzBz0HgSEKBkqenUcVDdVChCaNsefddrz4PHFsgqMPMUJtHyAM1zZWxx5d5ulE05EhchMjX9C6D8yKXY/jCfX2zuWNkadGEdWwkVMactf4DC7owlgJk+iFIi7ytuI7iK6M8ggXgcc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654087941; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=k5/0fOTDglxuPy32OBnWGxlh0HS+nxicRdFeFUp81q8=; b=KlpCu2g3rAxrdk0MJGOgxaMvw+ipiovHBRRQFG7aXgwOQOk+yx0Z/jUP22ZpnPCZisg6YrIyXiTQc0NZKFV/bGPhcD252rZFdx27N7vc/pJhQQc8DwDo0607oXARs9Abn/pGDIvVufiH7mWasbb8cw20iDWRzqBdnl+wY8kKliQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1654087941464270.7784708627812; Wed, 1 Jun 2022 05:52:21 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-669-NfssTfwxP-aXT7NJ5r6M9Q-1; Wed, 01 Jun 2022 08:51:28 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6B1BA180A5D7; Wed, 1 Jun 2022 12:50:52 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 571332166B26; Wed, 1 Jun 2022 12:50:52 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id D767F194E102; Wed, 1 Jun 2022 12:50:48 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 6DB7C1947BAF for ; Wed, 1 Jun 2022 12:50:31 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 40675492CA6; Wed, 1 Jun 2022 12:50:31 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.227]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1E978492CA2; Wed, 1 Jun 2022 12:50:31 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id B2B32245B8B; Wed, 1 Jun 2022 14:50:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654087940; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=k5/0fOTDglxuPy32OBnWGxlh0HS+nxicRdFeFUp81q8=; b=bO8VqglEWvaUToHxlTAlocPhKnshnX9RGg8Vf1XodRslA2rK+lWvIG/XGWtdib/DeaxGCk OUdS9JQuTqi9Wqb3Xt6wpZzIAkxvBBgf4w7j2aq9s00jAIF9uaxVUNsJERcatMiaawtH3I LvohyOhb+Sn7TEWGxPgVwuKYJNnUim4= X-MC-Unique: NfssTfwxP-aXT7NJ5r6M9Q-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH v2 62/81] qemu: Rename qemuMigrationSrcCleanup Date: Wed, 1 Jun 2022 14:50:02 +0200 Message-Id: <0db7c941140e47cbbb370aae3e85799a567b6ff8.1654087150.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Krempa , Pavel Hrdina Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1654087942240100002 Content-Type: text/plain; charset="utf-8" The function is now called qemuMigrationAnyConnectionClosed to make it clear it is supposed to handle broken connection during migration. It will soon be used on both sides of migration so the "Src" part was changed to "Any" to avoid renaming the function twice in a row. The original *Cleanup name could easily be confused with cleanup callbacks called when a domain is destroyed. Signed-off-by: Jiri Denemark Reviewed-by: Peter Krempa Reviewed-by: Pavel Hrdina --- Notes: Version 2: - no change src/qemu/qemu_migration.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index e888384570..eee73d47ca 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -2309,8 +2309,8 @@ qemuMigrationDstRun(virQEMUDriver *driver, * qemuDomainMigratePerform3 and qemuDomainMigrateConfirm3. */ static void -qemuMigrationSrcCleanup(virDomainObj *vm, - virConnectPtr conn) +qemuMigrationAnyConnectionClosed(virDomainObj *vm, + virConnectPtr conn) { qemuDomainObjPrivate *priv =3D vm->privateData; virQEMUDriver *driver =3D priv->driver; @@ -2800,13 +2800,13 @@ qemuMigrationSrcBeginResumePhase(virConnectPtr conn, return NULL; =20 virCloseCallbacksUnset(driver->closeCallbacks, vm, - qemuMigrationSrcCleanup); + qemuMigrationAnyConnectionClosed); qemuDomainCleanupRemove(vm, qemuProcessCleanupMigrationJob); =20 xml =3D qemuMigrationSrcBeginResume(driver, vm, xmlin, cookieout, cook= ieoutlen, flags); =20 if (virCloseCallbacksSet(driver->closeCallbacks, vm, conn, - qemuMigrationSrcCleanup) < 0) + qemuMigrationAnyConnectionClosed) < 0) g_clear_pointer(&xml, g_free); =20 if (!xml) @@ -2886,7 +2886,7 @@ qemuMigrationSrcBegin(virConnectPtr conn, * place. */ if (virCloseCallbacksSet(driver->closeCallbacks, vm, conn, - qemuMigrationSrcCleanup) < 0) + qemuMigrationAnyConnectionClosed) < 0) goto endjob; } =20 @@ -3962,7 +3962,7 @@ qemuMigrationSrcConfirm(virQEMUDriver *driver, goto cleanup; =20 virCloseCallbacksUnset(driver->closeCallbacks, vm, - qemuMigrationSrcCleanup); + qemuMigrationAnyConnectionClosed); qemuDomainCleanupRemove(vm, qemuProcessCleanupMigrationJob); =20 ret =3D qemuMigrationSrcConfirmPhase(driver, vm, @@ -5933,7 +5933,7 @@ qemuMigrationSrcPerformResume(virQEMUDriver *driver, return -1; =20 virCloseCallbacksUnset(driver->closeCallbacks, vm, - qemuMigrationSrcCleanup); + qemuMigrationAnyConnectionClosed); qemuDomainCleanupRemove(vm, qemuProcessCleanupMigrationJob); =20 ret =3D qemuMigrationSrcPerformNative(driver, vm, NULL, uri, @@ -5942,7 +5942,7 @@ qemuMigrationSrcPerformResume(virQEMUDriver *driver, 0, NULL, NULL, 0, NULL, NULL, NULL= ); =20 if (virCloseCallbacksSet(driver->closeCallbacks, vm, conn, - qemuMigrationSrcCleanup) < 0) + qemuMigrationAnyConnectionClosed) < 0) ret =3D -1; =20 if (ret < 0) @@ -5998,7 +5998,7 @@ qemuMigrationSrcPerformPhase(virQEMUDriver *driver, goto cleanup; =20 virCloseCallbacksUnset(driver->closeCallbacks, vm, - qemuMigrationSrcCleanup); + qemuMigrationAnyConnectionClosed); =20 if (qemuMigrationSrcPerformNative(driver, vm, persist_xml, uri, cookie= in, cookieinlen, cookieout, cookieoutlen, @@ -6007,7 +6007,7 @@ qemuMigrationSrcPerformPhase(virQEMUDriver *driver, goto cleanup; =20 if (virCloseCallbacksSet(driver->closeCallbacks, vm, conn, - qemuMigrationSrcCleanup) < 0) + qemuMigrationAnyConnectionClosed) < 0) goto cleanup; =20 ignore_value(qemuMigrationJobSetPhase(vm, QEMU_MIGRATION_PHASE_PERFORM= 3_DONE)); --=20 2.35.1 From nobody Wed May 15 19:27:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1654087955; cv=none; d=zohomail.com; s=zohoarc; b=buRC+6CuJFzeZybjEnHvkgJByaYWQTDFPy2HCv8lYMjxneRtubMOSW19e1suevBQn3WD1vQA2sTgjJ/Yi2RkqqfFJ1I6Cu9lNXDl5UBqwDKC0fDXnwjQZOSxhc7YBJdoZnVPmtJU67Q3QH8xp6R90xtiUIdAH5hL1gaeo5JWVkE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654087955; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=zazVVzPjPiu/EJmhFZk1w9bW0V35rXLxRXx9BANxurI=; b=L6s0FLy/yYfweYrCZUg1Gj2bWiw6zcjJcaJVedzgc6Xwfz8Owuv4PMevOfaC08Foey3tTF4Wx95repNiWDjcsS4hOF/mzuvnZ52af2h6GV2CEiIEdC708hLppdx9N9pvT6mBFUv55dWx+1zzEovDloK2/8Zf7pqnyO4ssdwTGTg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1654087955914100.62355091836707; Wed, 1 Jun 2022 05:52:35 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-224-3-OX5QClOyS0cSVC2hethA-1; Wed, 01 Jun 2022 08:51:21 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7967C8041B5; Wed, 1 Jun 2022 12:50:41 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 64F4B40EC004; Wed, 1 Jun 2022 12:50:41 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 74A221937754; Wed, 1 Jun 2022 12:50:38 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 8EA6A193F6F3 for ; Wed, 1 Jun 2022 12:50:31 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 6AB2740EC009; Wed, 1 Jun 2022 12:50:31 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.227]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2BAE340EC00A; Wed, 1 Jun 2022 12:50:31 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id B40E4245B8C; Wed, 1 Jun 2022 14:50:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654087955; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=zazVVzPjPiu/EJmhFZk1w9bW0V35rXLxRXx9BANxurI=; b=RIvLmltD8H9MoUokRAq+UvumrczxsluQ/BZIt8F7Qz2KxqIc7wHShtlpFR5O5qSnuxX7xh urLFcfAnveXatboh5c3yzoOm6+xclkGX6O+4zBvHVP0dmD+YbTHg5wp9m3UX+9sp845ODD Z9CYgTBoiqnntdf2le6T9NcoZCRbs6s= X-MC-Unique: 3-OX5QClOyS0cSVC2hethA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH v2 63/81] qemu: Refactor qemuMigrationAnyConnectionClosed Date: Wed, 1 Jun 2022 14:50:03 +0200 Message-Id: <30b5095993919d0c22256442668c8f4b4408ffaf.1654087150.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Krempa , Pavel Hrdina Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1654087956279100001 Content-Type: text/plain; charset="utf-8" To prepare the code for handling incoming migration too. Signed-off-by: Jiri Denemark Reviewed-by: Peter Krempa Reviewed-by: Pavel Hrdina --- Notes: Version 2: - moved relevant cases directly to "all done; unreachable" section to avoid unnecessary churn src/qemu/qemu_migration.c | 68 +++++++++++++++++++++------------------ 1 file changed, 37 insertions(+), 31 deletions(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index eee73d47ca..92833ccbe3 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -2302,11 +2302,12 @@ qemuMigrationDstRun(virQEMUDriver *driver, } =20 =20 -/* This is called for outgoing non-p2p migrations when a connection to the - * client which initiated the migration was closed but we were waiting for= it - * to follow up with the next phase, that is, in between - * qemuDomainMigrateBegin3 and qemuDomainMigratePerform3 or - * qemuDomainMigratePerform3 and qemuDomainMigrateConfirm3. +/* This is called for outgoing non-p2p and incoming migrations when a + * connection to the client which controls the migration was closed but we + * were waiting for it to follow up with the next phase, that is, in betwe= en + * qemuDomainMigrateBegin3 and qemuDomainMigratePerform3, + * qemuDomainMigratePerform3 and qemuDomainMigrateConfirm3, or + * qemuDomainMigratePrepare3 and qemuDomainMigrateFinish3. */ static void qemuMigrationAnyConnectionClosed(virDomainObj *vm, @@ -2315,6 +2316,7 @@ qemuMigrationAnyConnectionClosed(virDomainObj *vm, qemuDomainObjPrivate *priv =3D vm->privateData; virQEMUDriver *driver =3D priv->driver; qemuDomainJobPrivate *jobPriv =3D priv->job.privateData; + bool postcopy =3D false; =20 VIR_DEBUG("vm=3D%s, conn=3D%p, asyncJob=3D%s, phase=3D%s", vm->def->name, conn, @@ -2322,64 +2324,68 @@ qemuMigrationAnyConnectionClosed(virDomainObj *vm, qemuDomainAsyncJobPhaseToString(priv->job.asyncJob, priv->job.phase)); =20 - if (!qemuMigrationJobIsActive(vm, VIR_ASYNC_JOB_MIGRATION_OUT)) + if (!qemuMigrationJobIsActive(vm, VIR_ASYNC_JOB_MIGRATION_IN) && + !qemuMigrationJobIsActive(vm, VIR_ASYNC_JOB_MIGRATION_OUT)) return; =20 - VIR_DEBUG("The connection which started outgoing migration of domain %= s" - " was closed; canceling the migration", + VIR_WARN("The connection which controls migration of domain %s was clo= sed", vm->def->name); =20 switch ((qemuMigrationJobPhase) priv->job.phase) { case QEMU_MIGRATION_PHASE_BEGIN3: - /* just forget we were about to migrate */ - qemuMigrationJobFinish(vm); + VIR_DEBUG("Aborting outgoing migration after Begin phase"); break; =20 case QEMU_MIGRATION_PHASE_PERFORM3_DONE: - VIR_WARN("Migration of domain %s finished but we don't know if the" - " domain was successfully started on destination or not", - vm->def->name); - if (virDomainObjIsPostcopy(vm, VIR_DOMAIN_JOB_OPERATION_MIGRATION_= OUT)) { - ignore_value(qemuMigrationJobSetPhase(vm, QEMU_MIGRATION_PHASE= _POSTCOPY_FAILED)); - qemuMigrationSrcPostcopyFailed(vm); - qemuDomainCleanupAdd(vm, qemuProcessCleanupMigrationJob); - qemuMigrationJobContinue(vm); + VIR_DEBUG("Migration protocol interrupted in post-copy mode"); + postcopy =3D true; } else { - qemuMigrationParamsReset(driver, vm, VIR_ASYNC_JOB_MIGRATION_O= UT, - jobPriv->migParams, priv->job.apiFlag= s); - /* clear the job and let higher levels decide what to do */ - qemuMigrationJobFinish(vm); + VIR_WARN("Migration of domain %s finished but we don't know if= the " + "domain was successfully started on destination or no= t", + vm->def->name); } break; =20 case QEMU_MIGRATION_PHASE_POSTCOPY_FAILED: case QEMU_MIGRATION_PHASE_BEGIN_RESUME: case QEMU_MIGRATION_PHASE_PERFORM_RESUME: - ignore_value(qemuMigrationJobSetPhase(vm, QEMU_MIGRATION_PHASE_POS= TCOPY_FAILED)); - qemuMigrationSrcPostcopyFailed(vm); - qemuDomainCleanupAdd(vm, qemuProcessCleanupMigrationJob); - qemuMigrationJobContinue(vm); + VIR_DEBUG("Connection closed while resuming failed post-copy migra= tion"); + postcopy =3D true; break; =20 + case QEMU_MIGRATION_PHASE_PREPARE: + case QEMU_MIGRATION_PHASE_PREPARE_RESUME: + /* incoming migration; the domain will be autodestroyed */ + return; + case QEMU_MIGRATION_PHASE_PERFORM3: /* cannot be seen without an active migration API; unreachable */ case QEMU_MIGRATION_PHASE_CONFIRM3: case QEMU_MIGRATION_PHASE_CONFIRM3_CANCELLED: case QEMU_MIGRATION_PHASE_CONFIRM_RESUME: - /* all done; unreachable */ - case QEMU_MIGRATION_PHASE_PREPARE: case QEMU_MIGRATION_PHASE_FINISH2: case QEMU_MIGRATION_PHASE_FINISH3: - case QEMU_MIGRATION_PHASE_PREPARE_RESUME: case QEMU_MIGRATION_PHASE_FINISH_RESUME: - /* incoming migration; unreachable */ + /* all done; unreachable */ case QEMU_MIGRATION_PHASE_PERFORM2: /* single phase outgoing migration; unreachable */ case QEMU_MIGRATION_PHASE_NONE: case QEMU_MIGRATION_PHASE_LAST: /* unreachable */ - ; + return; + } + + if (postcopy) { + if (priv->job.asyncJob =3D=3D VIR_ASYNC_JOB_MIGRATION_OUT) + qemuMigrationSrcPostcopyFailed(vm); + ignore_value(qemuMigrationJobSetPhase(vm, QEMU_MIGRATION_PHASE_POS= TCOPY_FAILED)); + qemuDomainCleanupAdd(vm, qemuProcessCleanupMigrationJob); + qemuMigrationJobContinue(vm); + } else { + qemuMigrationParamsReset(driver, vm, priv->job.asyncJob, + jobPriv->migParams, priv->job.apiFlags); + qemuMigrationJobFinish(vm); } } =20 --=20 2.35.1 From nobody Wed May 15 19:27:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1654088049; cv=none; d=zohomail.com; s=zohoarc; b=AhhtSmG0R7QE7npBBZlaSoVu77cLk7/4uNsMTyK40QfuK13jC+YppaSOWKp3MOYgKZmnfFScC4KykneawjAzkQwUaMgn27b+3+mfW9z7HxMxf7GXeGwirFerV5EkFbP/OKUgGh45Rq2yZYzdbIpJ1HiwLjcz3Fc4TAFP2+o8+EY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654088049; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=RDAB/wNSzJNLObBVxcCvnPXC1vo0p474YOeRmhM0Mj8=; b=hgKuvErTTk+wR/ybD3VRLzccv3FGz/Ro/74ym7vd9Q6gM0+veBU6NPY0k8tbdIOy+Ob22KPEX7hM+zPL4YPeq6UQXkzxio9UU/TNQ4v6GWzte6yeKPA96m4Mp/rTRvHnzIzNz13MRhCdOMPWC4GFEWEItchfWr5xmgsAUZn/cNw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 165408804991336.10080177364296; Wed, 1 Jun 2022 05:54:09 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-433-X7Rc1N4dOz6h2lemlyohQQ-1; Wed, 01 Jun 2022 08:51:42 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id AB63881B90E; Wed, 1 Jun 2022 12:50:51 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9603E492C3B; Wed, 1 Jun 2022 12:50:51 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id F28BB1955EEF; Wed, 1 Jun 2022 12:50:47 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 6B1961947BAD for ; Wed, 1 Jun 2022 12:50:31 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 49D362026987; Wed, 1 Jun 2022 12:50:31 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.227]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 295E4202699A; Wed, 1 Jun 2022 12:50:31 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id B5682245B8D; Wed, 1 Jun 2022 14:50:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654088048; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=RDAB/wNSzJNLObBVxcCvnPXC1vo0p474YOeRmhM0Mj8=; b=Q0aNMNrQbqCSQ0ogrHSKeuMBVt8rDRGgpJLmX9sNexImAKgvHUF7uBZ/IcULv2mbeNg484 qyWB1dPNTwWCxLsDLltq7li+ovLhfnDF1Ko/rKDlARshN1e0fos2OKYeLDhWUHwy6Mt8r1 dJTgTpA1Bz7dp4+DKc65v8AvPBojg94= X-MC-Unique: X7Rc1N4dOz6h2lemlyohQQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH v2 64/81] qemu: Handle incoming migration in qemuMigrationAnyConnectionClosed Date: Wed, 1 Jun 2022 14:50:04 +0200 Message-Id: <65814fc940ec15f9ba1c6cbd841347f60d0f17b4.1654087150.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Krempa , Pavel Hrdina Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1654088050715100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Jiri Denemark Reviewed-by: Peter Krempa Reviewed-by: Pavel Hrdina --- Notes: Version 2: - part of this patch squashed into the previous one src/qemu/qemu_migration.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 92833ccbe3..1396c1d9b4 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -2350,12 +2350,12 @@ qemuMigrationAnyConnectionClosed(virDomainObj *vm, case QEMU_MIGRATION_PHASE_POSTCOPY_FAILED: case QEMU_MIGRATION_PHASE_BEGIN_RESUME: case QEMU_MIGRATION_PHASE_PERFORM_RESUME: + case QEMU_MIGRATION_PHASE_PREPARE_RESUME: VIR_DEBUG("Connection closed while resuming failed post-copy migra= tion"); postcopy =3D true; break; =20 case QEMU_MIGRATION_PHASE_PREPARE: - case QEMU_MIGRATION_PHASE_PREPARE_RESUME: /* incoming migration; the domain will be autodestroyed */ return; =20 @@ -2379,6 +2379,8 @@ qemuMigrationAnyConnectionClosed(virDomainObj *vm, if (postcopy) { if (priv->job.asyncJob =3D=3D VIR_ASYNC_JOB_MIGRATION_OUT) qemuMigrationSrcPostcopyFailed(vm); + else + qemuMigrationDstPostcopyFailed(vm); ignore_value(qemuMigrationJobSetPhase(vm, QEMU_MIGRATION_PHASE_POS= TCOPY_FAILED)); qemuDomainCleanupAdd(vm, qemuProcessCleanupMigrationJob); qemuMigrationJobContinue(vm); --=20 2.35.1 From nobody Wed May 15 19:27:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1654088051; cv=none; d=zohomail.com; s=zohoarc; b=b3Ucr9qQNJRUoFpmJVZRbg8bmdFg1c/ksvNSMfZFRRkBgbQTdVya2TZZcQVlVvRzPUKEgxB9ijdOO0QeM7o6ZYyMr+htBRQhV8WVcRD7R9tBSy0Bc1jnp0htJBzXEEmE2PEWAmHVeGqVghZSAwEmBfkTd1v4IF/tbZeGPW5tr4c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654088051; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=yy/RFwytH/yKWaocIrZiCT+PyzHv/eRsaB+MC6/1zFE=; b=Bi/G0XehtKgooN0Em25Fs1WFdlIHwFl4/Jx4BerhHIYWpyQIY9aMBPGarxuxSL60AovmueFcve92/aUcF4/Rwl/8MNBucMchGs22HRqeOvXr0jPFTKo7Tz8iutoikHqK7EiqfWJmI+7yCz9RMaoZvGsuXsaRcIFViFu6dc7hawI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1654088051114625.4177850380432; Wed, 1 Jun 2022 05:54:11 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-564-4fiGt7JIOlm0xKVQXrZLhQ-1; Wed, 01 Jun 2022 08:51:46 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E9BDE2801B9E; Wed, 1 Jun 2022 12:50:56 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id D6793C27E8F; Wed, 1 Jun 2022 12:50:56 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 1568F1955EDB; Wed, 1 Jun 2022 12:50:53 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 8B0AA1947B8C for ; Wed, 1 Jun 2022 12:50:31 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 56C8D1121320; Wed, 1 Jun 2022 12:50:31 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.227]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3450D1121315; Wed, 1 Jun 2022 12:50:31 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id B6B5B245B8E; Wed, 1 Jun 2022 14:50:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654088050; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=yy/RFwytH/yKWaocIrZiCT+PyzHv/eRsaB+MC6/1zFE=; b=hTtwOVHysh4YcEnwvkExzChk2kW0j5Ng3h4dibyDsiUpqegueotvnp2QLqLnW1EgWJViC6 Nc/k0kP0BWyBzGSg2dVLDgPjQtztInqKr3Q3H77n2zN1GnxWNonraz2DRVGr2lwX1uQRhr W1qDArNaTE2ee8qHpdLLd6DQO98WvPI= X-MC-Unique: 4fiGt7JIOlm0xKVQXrZLhQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH v2 65/81] qemu: Start a migration phase in qemuMigrationAnyConnectionClosed Date: Wed, 1 Jun 2022 14:50:05 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Krempa , Pavel Hrdina Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1654088052725100007 Content-Type: text/plain; charset="utf-8" Non-postcopy case talks to QEMU monitor and thus needs to create a nested job. Since qemuMigrationAnyConnectionClosed is called in case there's no thread processing a migration API, we need to make the current thread a temporary owner of the migration job to avoid "This thread doesn't seem to be the async job owner: 0". This is done by starting a migration phase. While no monitor interaction happens in postcopy case and just setting the phase (to indicate a broken postcopy migration) would be enough, being consistent and setting the owner does not hurt anything. Signed-off-by: Jiri Denemark Reviewed-by: Peter Krempa Reviewed-by: Pavel Hrdina --- Notes: Version 2: - no change src/qemu/qemu_migration.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 1396c1d9b4..616f812ef1 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -2317,6 +2317,7 @@ qemuMigrationAnyConnectionClosed(virDomainObj *vm, virQEMUDriver *driver =3D priv->driver; qemuDomainJobPrivate *jobPriv =3D priv->job.privateData; bool postcopy =3D false; + int phase; =20 VIR_DEBUG("vm=3D%s, conn=3D%p, asyncJob=3D%s, phase=3D%s", vm->def->name, conn, @@ -2376,12 +2377,17 @@ qemuMigrationAnyConnectionClosed(virDomainObj *vm, return; } =20 + if (postcopy) + phase =3D QEMU_MIGRATION_PHASE_POSTCOPY_FAILED; + else + phase =3D QEMU_MIGRATION_PHASE_CONFIRM3_CANCELLED; + ignore_value(qemuMigrationJobStartPhase(vm, phase)); + if (postcopy) { if (priv->job.asyncJob =3D=3D VIR_ASYNC_JOB_MIGRATION_OUT) qemuMigrationSrcPostcopyFailed(vm); else qemuMigrationDstPostcopyFailed(vm); - ignore_value(qemuMigrationJobSetPhase(vm, QEMU_MIGRATION_PHASE_POS= TCOPY_FAILED)); qemuDomainCleanupAdd(vm, qemuProcessCleanupMigrationJob); qemuMigrationJobContinue(vm); } else { --=20 2.35.1 From nobody Wed May 15 19:27:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1654087909; cv=none; d=zohomail.com; s=zohoarc; b=kWhxzqnbpMEOeb3bByEf2/QinSozmWiHTeQoTNh178XJRLAIUZpj/l5pXJg/5Aq06KBxLtFSLJYP8IR9pNDvXOe9CEYqmTRO3C8o+VBQOU2X3x1LaQqRACAd1EiLc9z6OXGNgdjSwV8HYkrAnzxQFu3IEaNbD6WN6mDfuNPS3NQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654087909; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=pe32PrXno5JBmNEXEJtqIWTzbAvuVZkuNMeywzNlebo=; b=l4uhEjIcHhLGzrQi5G8ME5szraB3DPHALfVLFjgSaESS2T0XPK57wTDQUtHXoEEXMnxajnUuoXHzz5r3Sl8ETenkerEIt3jNrRKLJmZp606qP2m+FMxsUtwbGfJhORPDnQxYMj3jXpZtmBXieIxLc0QIp4jq4jM4cQrmCBbSObQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1654087909954931.7921756642253; Wed, 1 Jun 2022 05:51:49 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-580--haHM3u9NoqGRsDdKFo4oQ-1; Wed, 01 Jun 2022 08:51:33 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 276171C3E9BA; Wed, 1 Jun 2022 12:50:53 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id D55BB2166B26; Wed, 1 Jun 2022 12:50:52 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 6A2121955ED3; Wed, 1 Jun 2022 12:50:49 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 85B41193F6C8 for ; Wed, 1 Jun 2022 12:50:31 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 71877C2810E; Wed, 1 Jun 2022 12:50:31 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.227]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 34833C28103; Wed, 1 Jun 2022 12:50:31 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id B80E5245B8F; Wed, 1 Jun 2022 14:50:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654087908; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=pe32PrXno5JBmNEXEJtqIWTzbAvuVZkuNMeywzNlebo=; b=ff9/JGBzZpe3cqnaMAhOsU3yIecLJ0RSQ8ukgFHbCvWM0aew4Eudn+EFpfzvXZTBMUjkfS 21j81A0BGUuif2LCV0yy+OWxJjhg2MQ5Nu685Jt/TIyHFUsLvv9zzRGTrS3mLtMoyWAsuk Lq6CjLQ8TDwMbuVJyvTRqzN9LDeB3Dk= X-MC-Unique: -haHM3u9NoqGRsDdKFo4oQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH v2 66/81] qemu: Implement VIR_MIGRATE_POSTCOPY_RESUME for Prepare phase Date: Wed, 1 Jun 2022 14:50:06 +0200 Message-Id: <3333df28473c5aa6c7a785d04bf5fc0e5d17a5f0.1654087150.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Krempa , Pavel Hrdina Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1654087912025100001 Content-Type: text/plain; charset="utf-8" The QEMU process is already running, all we need to do is to call migrate-recover QMP command. Except for some checks and cookie handling, of course. Signed-off-by: Jiri Denemark Reviewed-by: Peter Krempa Reviewed-by: Pavel Hrdina --- Notes: Version 2: - no change src/qemu/qemu_migration.c | 99 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 616f812ef1..dbebd215b4 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -3474,6 +3474,98 @@ qemuMigrationDstPrepareFresh(virQEMUDriver *driver, } =20 =20 +static int +qemuMigrationDstPrepareResume(virQEMUDriver *driver, + virConnectPtr conn, + const char *cookiein, + int cookieinlen, + char **cookieout, + int *cookieoutlen, + virDomainDef *def, + const char *origname, + const char *protocol, + unsigned short port, + const char *listenAddress, + unsigned long flags) +{ + g_autoptr(qemuMigrationCookie) mig =3D NULL; + qemuProcessIncomingDef *incoming =3D NULL; + qemuDomainObjPrivate *priv; + virDomainJobStatus status; + virDomainObj *vm; + int ret =3D -1; + + VIR_DEBUG("name=3D%s, origname=3D%s, protocol=3D%s, port=3D%hu, " + "listenAddress=3D%s, flags=3D0x%lx", + def->name, NULLSTR(origname), protocol, port, + NULLSTR(listenAddress), flags); + + vm =3D virDomainObjListFindByName(driver->domains, def->name); + if (!vm) { + virReportError(VIR_ERR_NO_DOMAIN, + _("no domain with matching name '%s'"), def->name); + qemuMigrationDstErrorReport(driver, def->name); + return -1; + } + priv =3D vm->privateData; + + if (!qemuMigrationAnyCanResume(vm, VIR_ASYNC_JOB_MIGRATION_IN, flags, + QEMU_MIGRATION_PHASE_POSTCOPY_FAILED)) + goto cleanup; + + if (qemuMigrationJobStartPhase(vm, QEMU_MIGRATION_PHASE_PREPARE_RESUME= ) < 0) + goto cleanup; + + qemuDomainCleanupRemove(vm, qemuProcessCleanupMigrationJob); + + if (qemuMigrationAnyRefreshStatus(driver, vm, VIR_ASYNC_JOB_MIGRATION_= IN, + &status) < 0) + goto cleanup; + + if (status !=3D VIR_DOMAIN_JOB_STATUS_POSTCOPY_PAUSED) { + virReportError(VIR_ERR_OPERATION_INVALID, "%s", + _("QEMU reports migration is still running")); + goto cleanup; + } + + if (!(mig =3D qemuMigrationCookieParse(driver, def, origname, NULL, + cookiein, cookieinlen, + QEMU_MIGRATION_COOKIE_CAPS))) + goto cleanup; + + if (!(incoming =3D qemuMigrationDstPrepare(vm, false, protocol, + listenAddress, port, -1))) + goto cleanup; + + if (qemuDomainObjEnterMonitorAsync(driver, vm, VIR_ASYNC_JOB_MIGRATION= _IN) < 0) + goto cleanup; + + ret =3D qemuMonitorMigrateRecover(priv->mon, incoming->uri); + qemuDomainObjExitMonitor(vm); + + if (ret < 0) + goto cleanup; + + if (qemuMigrationCookieFormat(mig, driver, vm, + QEMU_MIGRATION_DESTINATION, + cookieout, cookieoutlen, + QEMU_MIGRATION_COOKIE_CAPS) < 0) + VIR_WARN("Unable to encode migration cookie"); + + virCloseCallbacksSet(driver->closeCallbacks, vm, conn, + qemuMigrationAnyConnectionClosed); + + cleanup: + qemuProcessIncomingDefFree(incoming); + if (ret < 0) + ignore_value(qemuMigrationJobSetPhase(vm, QEMU_MIGRATION_PHASE_POS= TCOPY_FAILED)); + qemuDomainCleanupAdd(vm, qemuProcessCleanupMigrationJob); + qemuMigrationJobContinue(vm); + virDomainObjEndAPI(&vm); + return ret; +} + + static int qemuMigrationDstPrepareAny(virQEMUDriver *driver, virConnectPtr dconn, @@ -3538,6 +3630,13 @@ qemuMigrationDstPrepareAny(virQEMUDriver *driver, return -1; } =20 + if (flags & VIR_MIGRATE_POSTCOPY_RESUME) { + return qemuMigrationDstPrepareResume(driver, dconn, cookiein, cook= ieinlen, + cookieout, cookieoutlen, + *def, origname, protocol, por= t, + listenAddress, flags); + } + return qemuMigrationDstPrepareFresh(driver, dconn, cookiein, cookieinlen, cookieout, cookieoutlen, --=20 2.35.1 From nobody Wed May 15 19:27:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1654088172; cv=none; d=zohomail.com; s=zohoarc; b=YCloXt6BFCZAkVnIj1VVX5vlgu8MavqsORlz76TVdx1aDnrF496tPS6mPq1/CfikZlF7D2TpHHNt9iNC68Mmzp3gKejqEB7tgs2gdXlyU+1JNntWBVmLmkirWhbi1tPC2dh3ZE6NFImS+d4ucX4AO27Jq2qoeB0l5+BfCSAcOhQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654088172; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=iUZLsQ8RMxKgINmMJ/TqAkDg9CKyzuHGoYQH+++s8Bw=; b=Wf+ho068Tj63Hu3iW3LZp4FpZPGhmiE+VnLZm3Xqk6WBNn6mTJ9fcu8mKuABjtJ9Z5LC9DI5c28Lo70w2xzdflYewQmApjeemPpD+QkntsMhC+zDF5D8B5H8z9RxK7J8SxLiMBFT0u5hSRNqZNy0gsa/I0mNfi2atADEIhRhf+U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1654088172525408.09962354297204; Wed, 1 Jun 2022 05:56:12 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-57-EZW7IZmLOVGCtv4gmgfbqQ-1; Wed, 01 Jun 2022 08:56:02 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 786972809CC2; Wed, 1 Jun 2022 12:55:56 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5C6AF1415103; Wed, 1 Jun 2022 12:55:56 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id AF47B1947B8F; Wed, 1 Jun 2022 12:55:54 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 5A93E1947B95 for ; Wed, 1 Jun 2022 12:55:53 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id EAB14112131B; Wed, 1 Jun 2022 12:55:52 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.227]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C9C711121314; Wed, 1 Jun 2022 12:55:52 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id B9712245B90; Wed, 1 Jun 2022 14:50:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654088171; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=iUZLsQ8RMxKgINmMJ/TqAkDg9CKyzuHGoYQH+++s8Bw=; b=Tvdi7TDjJL6nzxJ1GqpRloUkKvHJ1YnH7/RboElxfj2tAH6H+Wbt+JKNJ6Vji7qfy1MgZe uPKvbrCwuaPAx8tYtcNnyqxCihqZw+0Es0yXtiI6QJcZjkBudKyXGZ3VTGtMRheSwWvljW vQtj0Hd4ltbrAqH7Dp1wFc6dqyr1Puc= X-MC-Unique: EZW7IZmLOVGCtv4gmgfbqQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH v2 67/81] qemu: Implement VIR_MIGRATE_POSTCOPY_RESUME for Finish phase Date: Wed, 1 Jun 2022 14:50:07 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Krempa , Pavel Hrdina Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1654088173104100001 Content-Type: text/plain; charset="utf-8" Everything was already done in the normal Finish phase and vCPUs are running. We just need to wait for all remaining data to be transferred. Signed-off-by: Jiri Denemark Reviewed-by: Peter Krempa Reviewed-by: Pavel Hrdina --- Notes: Version 2: - no change src/qemu/qemu_migration.c | 46 ++++++++++++++++++++++++++++++++++----- 1 file changed, 40 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index dbebd215b4..a078cbcd41 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -6556,6 +6556,22 @@ qemuMigrationDstFinishFresh(virQEMUDriver *driver, } =20 =20 +static int +qemuMigrationDstFinishResume(virQEMUDriver *driver, + virDomainObj *vm) +{ + VIR_DEBUG("vm=3D%p", vm); + + if (qemuMigrationDstWaitForCompletion(driver, vm, + VIR_ASYNC_JOB_MIGRATION_IN, + false) < 0) { + return -1; + } + + return 0; +} + + static virDomainPtr qemuMigrationDstFinishActive(virQEMUDriver *driver, virConnectPtr dconn, @@ -6603,8 +6619,14 @@ qemuMigrationDstFinishActive(virQEMUDriver *driver, goto error; } =20 - rc =3D qemuMigrationDstFinishFresh(driver, vm, mig, flags, v3proto, - timeReceived, &doKill, &inPostCopy); + if (flags & VIR_MIGRATE_POSTCOPY_RESUME) { + rc =3D qemuMigrationDstFinishResume(driver, vm); + inPostCopy =3D true; + } else { + rc =3D qemuMigrationDstFinishFresh(driver, vm, mig, flags, v3proto, + timeReceived, &doKill, &inPostCop= y); + } + if (rc < 0 || !(dom =3D virGetDomain(dconn, vm->def->name, vm->def->uuid, vm->de= f->id))) goto error; @@ -6675,6 +6697,8 @@ qemuMigrationDstFinish(virQEMUDriver *driver, qemuDomainObjPrivate *priv =3D vm->privateData; unsigned short port; unsigned long long timeReceived =3D 0; + int phase =3D v3proto ? QEMU_MIGRATION_PHASE_FINISH3 + : QEMU_MIGRATION_PHASE_FINISH2; =20 VIR_DEBUG("driver=3D%p, dconn=3D%p, vm=3D%p, cookiein=3D%s, cookieinle= n=3D%d, " "cookieout=3D%p, cookieoutlen=3D%p, flags=3D0x%lx, retcode= =3D%d", @@ -6689,14 +6713,24 @@ qemuMigrationDstFinish(virQEMUDriver *driver, goto cleanup; } =20 + if (flags & VIR_MIGRATE_POSTCOPY_RESUME) { + if (!qemuMigrationAnyCanResume(vm, VIR_ASYNC_JOB_MIGRATION_IN, fla= gs, + QEMU_MIGRATION_PHASE_PREPARE_RESUME= )) + goto cleanup; + phase =3D QEMU_MIGRATION_PHASE_FINISH_RESUME; + } ignore_value(virTimeMillisNow(&timeReceived)); =20 - if (qemuMigrationJobStartPhase(vm, - v3proto ? QEMU_MIGRATION_PHASE_FINISH3 - : QEMU_MIGRATION_PHASE_FINISH2)= < 0) + if (qemuMigrationJobStartPhase(vm, phase) < 0) goto cleanup; =20 - qemuDomainCleanupRemove(vm, qemuMigrationDstPrepareCleanup); + if (flags & VIR_MIGRATE_POSTCOPY_RESUME) { + virCloseCallbacksUnset(driver->closeCallbacks, vm, + qemuMigrationAnyConnectionClosed); + qemuDomainCleanupRemove(vm, qemuProcessCleanupMigrationJob); + } else { + qemuDomainCleanupRemove(vm, qemuMigrationDstPrepareCleanup); + } g_clear_pointer(&priv->job.completed, virDomainJobDataFree); =20 cookie_flags =3D QEMU_MIGRATION_COOKIE_NETWORK | --=20 2.35.1 From nobody Wed May 15 19:27:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1654087937; cv=none; d=zohomail.com; s=zohoarc; b=Bq3VOzOHsfXb+pDlqEUhfQHrxkvUdT2FuSc/eRnavSin1rOkEXuDzTmBpnDzUA0t/hvAelcgEfXPkvRILhkpYVNHp5z0ulovNkzrzMi5VoybfMDfdGZKYpyA6CdFA3dFSKoBffopF24pOlfC6fI67JwDGkYBTMDb4gOrrcPnr/8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654087937; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=r7bGrfL3YOSOc3qlzHX1UyVKytzD8TdS9I3gnmsE1mM=; b=JcFrgDE6sfo+Ft1B3ei2RNxonQEBlMKw9MmqHAurW/wP2jZvoH0qLqJ6TvP2dwSbd12B+PAey8twpd4GfobpAbVTfzcNjPf87qC1r1lKErqRPep0QpGypbdOtGRWvglySHY7ZEYpjdBMMHrp0g/1s4vuqK46+gq50ghZN56/7lQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1654087937500673.7173152236674; Wed, 1 Jun 2022 05:52:17 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-557-BE0oxX0kORi-cOWGCeByKQ-1; Wed, 01 Jun 2022 08:51:39 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E91D7886488; Wed, 1 Jun 2022 12:50:46 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id CD2521731B; Wed, 1 Jun 2022 12:50:46 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 203E41932208; Wed, 1 Jun 2022 12:50:43 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 7B657194707E for ; Wed, 1 Jun 2022 12:50:31 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 54C2D1415106; Wed, 1 Jun 2022 12:50:31 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.227]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3422D1415100; Wed, 1 Jun 2022 12:50:31 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id BACFD245B91; Wed, 1 Jun 2022 14:50:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654087936; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=r7bGrfL3YOSOc3qlzHX1UyVKytzD8TdS9I3gnmsE1mM=; b=bWVFBfDsJLfjGrte0USGKSI0mhIokeS2p3VDaf/TBgPkWY2HaIwWprpmwUQCsYGqDh471p WB39Aokyes25C8bWD00toF+dqE1uKhuaj47l+eOne11E+lXwbjm+G1nVtpFln4ixxh2rB+ 35BqaIrC6Rts1ypbMMcFCntBVDABkDY= X-MC-Unique: BE0oxX0kORi-cOWGCeByKQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH v2 68/81] qemu: Create completed jobData in qemuMigrationSrcComplete Date: Wed, 1 Jun 2022 14:50:08 +0200 Message-Id: <3d73e25253a368a3a36a4b866c72c68088d1caa7.1654087150.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Krempa , Pavel Hrdina Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1654087938218100019 Content-Type: text/plain; charset="utf-8" Normally the structure is created once the source reports completed migration, but with post-copy migration we can get here even after libvirt daemon was restarted. It doesn't make sense to preserve the structure in our status XML as we're going to rewrite almost all of it while refreshing the stats anyway. So we just create the structure here if it doesn't exist to make sure we can properly report statistics of a completed migration. Signed-off-by: Jiri Denemark Reviewed-by: Peter Krempa Reviewed-by: Pavel Hrdina --- Notes: Version 2: - no change src/qemu/qemu_migration.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index a078cbcd41..49985aba9a 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -3908,22 +3908,26 @@ qemuMigrationSrcComplete(virQEMUDriver *driver, virObjectEvent *event; int reason; =20 - if (jobData) { - /* We need to refresh migration statistics after a completed post-= copy - * migration since jobData contains obsolete data from the time we - * switched to post-copy mode. - */ - if (virDomainObjGetState(vm, &reason) =3D=3D VIR_DOMAIN_PAUSED && - reason =3D=3D VIR_DOMAIN_PAUSED_POSTCOPY) { - VIR_DEBUG("Refreshing migration statistics"); - if (qemuMigrationAnyFetchStats(driver, vm, VIR_ASYNC_JOB_MIGRA= TION_OUT, - jobData, NULL) < 0) - VIR_WARN("Could not refresh migration statistics"); - } + if (!jobData) { + priv->job.completed =3D virDomainJobDataCopy(priv->job.current); + jobData =3D priv->job.completed; + jobData->status =3D VIR_DOMAIN_JOB_STATUS_COMPLETED; + } =20 - qemuDomainJobDataUpdateTime(jobData); + /* We need to refresh migration statistics after a completed post-copy + * migration since jobData contains obsolete data from the time we + * switched to post-copy mode. + */ + if (virDomainObjGetState(vm, &reason) =3D=3D VIR_DOMAIN_PAUSED && + reason =3D=3D VIR_DOMAIN_PAUSED_POSTCOPY) { + VIR_DEBUG("Refreshing migration statistics"); + if (qemuMigrationAnyFetchStats(driver, vm, VIR_ASYNC_JOB_MIGRATION= _OUT, + jobData, NULL) < 0) + VIR_WARN("Could not refresh migration statistics"); } =20 + qemuDomainJobDataUpdateTime(jobData); + /* If guest uses SPICE and supports seamless migration we have to hold * up domain shutdown until SPICE server transfers its data */ qemuMigrationSrcWaitForSpice(vm); --=20 2.35.1 From nobody Wed May 15 19:27:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1654088163; cv=none; d=zohomail.com; s=zohoarc; b=HvU7hlF3roXwWTiYcsk7KuP7ZmFcnHj607wL9nQJ6OArnRMJpZvp1B3sp3xrn5c8vTgTj69Z4hKMLFDU8jCg2AmrsO9MuTbpyuMTp/AQ4zy4mZhzimNsqYS7lhdV4wII+B4XynkesznSEi0zumi5ESwOwwweuyLjfJWQ6qUrjxI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654088163; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=frVSCnKA1a4p/+6EUYlfQpKZ7HJPOV//lgxwbd7zN1w=; b=GlBnz6ueR2sELG9IqoKyB8u0FF2LWb6EVe2B3/lPiwTchT7lmRAVBoR1bJIpXm53+44xZ57vfNf4/KcTmR2YrXrZ3FCzuqWRzHNZzM+/EvMVX3Wn4OxiVjuNJCpGjSNECaMfzEXKP2xksZPXk4DedUbtdrhuj3GQ3Ww90wbDO0w= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1654088163184488.52757321902493; Wed, 1 Jun 2022 05:56:03 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-448-bBoBKzdxOcisQuUIelmvPA-1; Wed, 01 Jun 2022 08:51:19 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 641311D32372; Wed, 1 Jun 2022 12:50:40 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4EA84C27E97; Wed, 1 Jun 2022 12:50:40 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id A773E193F6C8; Wed, 1 Jun 2022 12:50:37 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 7D65E1947BB5 for ; Wed, 1 Jun 2022 12:50:31 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 54F932166B2E; Wed, 1 Jun 2022 12:50:31 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.227]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 349AF2166B2C; Wed, 1 Jun 2022 12:50:31 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id BC23C245B92; Wed, 1 Jun 2022 14:50:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654088162; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=frVSCnKA1a4p/+6EUYlfQpKZ7HJPOV//lgxwbd7zN1w=; b=YXqC1tjDxCnLPNYL40q0ycE/rRqPYo8a8MnDyQQSGO+mOlKY70yL6YQlbIOZuRhXFF/5b4 P4Oi47Fw2+6IWukn+k/S0FB7RjN9bh4ydZXIEkI7nVMz3cuZXZTCYQ9AVsAcDYKyBP9/0U YH4eJmCPTsMn66UyNijrngPR+NYnnTg= X-MC-Unique: bBoBKzdxOcisQuUIelmvPA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH v2 69/81] qemu: Register qemuProcessCleanupMigrationJob after Begin phase Date: Wed, 1 Jun 2022 14:50:09 +0200 Message-Id: <6741afc00e5e1ff6b12df6b9f55fe19f38fbe3a7.1654087150.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Krempa , Pavel Hrdina Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1654088165001100010 Content-Type: text/plain; charset="utf-8" The callback will properly cleanup non-p2p migration job in case the migrating domain dies between Begin and Perform while the client which controls the migration is not cooperating (normally the API for the next migration phase would handle this). The same situation can happen even after Prepare and Perform phases, but they both already register a suitable callback, so no fix is needed there. Signed-off-by: Jiri Denemark Reviewed-by: Peter Krempa Reviewed-by: Pavel Hrdina --- Notes: Version 2: - no change src/qemu/qemu_migration.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 49985aba9a..57919b014d 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -2902,6 +2902,8 @@ qemuMigrationSrcBegin(virConnectPtr conn, if (virCloseCallbacksSet(driver->closeCallbacks, vm, conn, qemuMigrationAnyConnectionClosed) < 0) goto endjob; + + qemuDomainCleanupAdd(vm, qemuProcessCleanupMigrationJob); } =20 ret =3D g_steal_pointer(&xml); --=20 2.35.1 From nobody Wed May 15 19:27:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1654088007; cv=none; d=zohomail.com; s=zohoarc; b=LIMcWjc4UdlDfVEzAnW4qtlcFqC7jN7e2rrPQCa+BibDcEUu0+o9KUtx9pyDr1VB7xn8rRF630zIYh9OejOn4v4IsPjNS7dAr4avUWOe+4Ci5ONz3C3aLffQJS81t6zyIf61dqnVzMVEBT2D3rAi1FReZmPoqGWw3aHI+nccn34= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654088007; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=10riLTRx5WzRE0tIX9fTBGRz86T2tW0f+hxrzicB8TI=; b=TandyWa+apjXczOW+hp49eKNMt+ib+F57VeEg74aBfaQJtd4+Q+eBVhwiuyNzkTFC2fOEsjiS1C3gVwPk3941w6K2WAqXlDVolgAZGkeGrvvvWJ8N83oGBSNWux86rSHgtt1+CoNNqRg9cJRk8w1lqTU/y8OnAqH09YEpEEiMpM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1654088007795713.8288913003736; Wed, 1 Jun 2022 05:53:27 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-630-vU9ZMWw2NvK7ti7x3kcmiQ-1; Wed, 01 Jun 2022 08:51:36 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 66E2C28013E3; Wed, 1 Jun 2022 12:50:54 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 174872026D07; Wed, 1 Jun 2022 12:50:54 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 85DEF193769E; Wed, 1 Jun 2022 12:50:50 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 8FA391947B91 for ; Wed, 1 Jun 2022 12:50:31 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 81903112132C; Wed, 1 Jun 2022 12:50:31 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.227]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3F53C1121319; Wed, 1 Jun 2022 12:50:31 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id BD8AB245B93; Wed, 1 Jun 2022 14:50:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654088006; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=10riLTRx5WzRE0tIX9fTBGRz86T2tW0f+hxrzicB8TI=; b=FVDWffsmkci26Oo2OOFq+nwvqa3zLq1fP9ccuHMB00Ir3+jqAnypts6xm6Qj1RWi9asyXv zACp8wGBb5hK5I7Ku9egfmQL8P7AP0ruo9m6AweBFzBdF3fwbA4FdpC1y5pWr3Orsqz67Q OXQEb2TUfAmo8hkP+CxIu8xumlzrBLc= X-MC-Unique: vU9ZMWw2NvK7ti7x3kcmiQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH v2 70/81] qemu: Call qemuDomainCleanupAdd from qemuMigrationJobContinue Date: Wed, 1 Jun 2022 14:50:10 +0200 Message-Id: <266d1e42d8ecaa46e34b4934d9d18a8fed35edab.1654087150.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Krempa , Pavel Hrdina Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1654088008460100005 Content-Type: text/plain; charset="utf-8" Every single call to qemuMigrationJobContinue needs to register a cleanup callback in case the migrating domain dies between phases or when migration is paused due to a failure in postcopy mode. Let's integrate registering the callback in qemuMigrationJobContinue to make sure the current thread does not release a migration job without setting a cleanup callback. Signed-off-by: Jiri Denemark Reviewed-by: Peter Krempa Reviewed-by: Pavel Hrdina --- Notes: Version 2: - no change src/qemu/qemu_migration.c | 36 +++++++++++++----------------------- 1 file changed, 13 insertions(+), 23 deletions(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 57919b014d..79766b502e 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -183,8 +183,10 @@ qemuMigrationJobStartPhase(virDomainObj *vm, =20 =20 static void ATTRIBUTE_NONNULL(1) -qemuMigrationJobContinue(virDomainObj *vm) +qemuMigrationJobContinue(virDomainObj *vm, + qemuDomainCleanupCallback cleanup) { + qemuDomainCleanupAdd(vm, cleanup); qemuDomainObjReleaseAsyncJob(vm); } =20 @@ -2388,8 +2390,7 @@ qemuMigrationAnyConnectionClosed(virDomainObj *vm, qemuMigrationSrcPostcopyFailed(vm); else qemuMigrationDstPostcopyFailed(vm); - qemuDomainCleanupAdd(vm, qemuProcessCleanupMigrationJob); - qemuMigrationJobContinue(vm); + qemuMigrationJobContinue(vm, qemuProcessCleanupMigrationJob); } else { qemuMigrationParamsReset(driver, vm, priv->job.asyncJob, jobPriv->migParams, priv->job.apiFlags); @@ -2826,8 +2827,7 @@ qemuMigrationSrcBeginResumePhase(virConnectPtr conn, if (!xml) ignore_value(qemuMigrationJobSetPhase(vm, QEMU_MIGRATION_PHASE_POS= TCOPY_FAILED)); =20 - qemuDomainCleanupAdd(vm, qemuProcessCleanupMigrationJob); - qemuMigrationJobContinue(vm); + qemuMigrationJobContinue(vm, qemuProcessCleanupMigrationJob); return g_steal_pointer(&xml); } =20 @@ -2902,8 +2902,6 @@ qemuMigrationSrcBegin(virConnectPtr conn, if (virCloseCallbacksSet(driver->closeCallbacks, vm, conn, qemuMigrationAnyConnectionClosed) < 0) goto endjob; - - qemuDomainCleanupAdd(vm, qemuProcessCleanupMigrationJob); } =20 ret =3D g_steal_pointer(&xml); @@ -2911,7 +2909,7 @@ qemuMigrationSrcBegin(virConnectPtr conn, endjob: if (flags & VIR_MIGRATE_CHANGE_PROTECTION) { if (ret) - qemuMigrationJobContinue(vm); + qemuMigrationJobContinue(vm, qemuProcessCleanupMigrationJob); else qemuMigrationJobFinish(vm); } else { @@ -3440,13 +3438,11 @@ qemuMigrationDstPrepareFresh(virQEMUDriver *driver, VIR_WARN("Unable to encode migration cookie"); } =20 - qemuDomainCleanupAdd(vm, qemuMigrationDstPrepareCleanup); - /* We keep the job active across API calls until the finish() call. * This prevents any other APIs being invoked while incoming * migration is taking place. */ - qemuMigrationJobContinue(vm); + qemuMigrationJobContinue(vm, qemuMigrationDstPrepareCleanup); =20 if (autoPort) priv->migrationPort =3D port; @@ -3561,8 +3557,7 @@ qemuMigrationDstPrepareResume(virQEMUDriver *driver, qemuProcessIncomingDefFree(incoming); if (ret < 0) ignore_value(qemuMigrationJobSetPhase(vm, QEMU_MIGRATION_PHASE_POS= TCOPY_FAILED)); - qemuDomainCleanupAdd(vm, qemuProcessCleanupMigrationJob); - qemuMigrationJobContinue(vm); + qemuMigrationJobContinue(vm, qemuProcessCleanupMigrationJob); virDomainObjEndAPI(&vm); return ret; } @@ -4090,8 +4085,7 @@ qemuMigrationSrcConfirm(virQEMUDriver *driver, =20 if (virDomainObjIsFailedPostcopy(vm)) { ignore_value(qemuMigrationJobSetPhase(vm, QEMU_MIGRATION_PHASE_POS= TCOPY_FAILED)); - qemuDomainCleanupAdd(vm, qemuProcessCleanupMigrationJob); - qemuMigrationJobContinue(vm); + qemuMigrationJobContinue(vm, qemuProcessCleanupMigrationJob); } else { qemuMigrationJobFinish(vm); } @@ -5998,8 +5992,7 @@ qemuMigrationSrcPerformJob(virQEMUDriver *driver, =20 if (virDomainObjIsFailedPostcopy(vm)) { ignore_value(qemuMigrationJobSetPhase(vm, QEMU_MIGRATION_PHASE_POS= TCOPY_FAILED)); - qemuDomainCleanupAdd(vm, qemuProcessCleanupMigrationJob); - qemuMigrationJobContinue(vm); + qemuMigrationJobContinue(vm, qemuProcessCleanupMigrationJob); } else { /* v2 proto has no confirm phase so we need to reset migration par= ameters * here @@ -6067,8 +6060,7 @@ qemuMigrationSrcPerformResume(virQEMUDriver *driver, if (ret < 0) ignore_value(qemuMigrationJobSetPhase(vm, QEMU_MIGRATION_PHASE_POS= TCOPY_FAILED)); =20 - qemuDomainCleanupAdd(vm, qemuProcessCleanupMigrationJob); - qemuMigrationJobContinue(vm); + qemuMigrationJobContinue(vm, qemuProcessCleanupMigrationJob); return ret; } =20 @@ -6141,8 +6133,7 @@ qemuMigrationSrcPerformPhase(virQEMUDriver *driver, } else { if (ret < 0) ignore_value(qemuMigrationJobSetPhase(vm, QEMU_MIGRATION_PHASE= _POSTCOPY_FAILED)); - qemuDomainCleanupAdd(vm, qemuProcessCleanupMigrationJob); - qemuMigrationJobContinue(vm); + qemuMigrationJobContinue(vm, qemuProcessCleanupMigrationJob); } =20 if (!virDomainObjIsActive(vm)) @@ -6671,7 +6662,6 @@ qemuMigrationDstFinishActive(virQEMUDriver *driver, if (virDomainObjIsFailedPostcopy(vm)) { ignore_value(qemuMigrationJobSetPhase(vm, QEMU_MIGRATION_PHASE_POS= TCOPY_FAILED)); qemuProcessAutoDestroyRemove(driver, vm); - qemuDomainCleanupAdd(vm, qemuProcessCleanupMigrationJob); *finishJob =3D false; } else { qemuMigrationParamsReset(driver, vm, VIR_ASYNC_JOB_MIGRATION_IN, @@ -6765,7 +6755,7 @@ qemuMigrationDstFinish(virQEMUDriver *driver, if (finishJob) qemuMigrationJobFinish(vm); else - qemuMigrationJobContinue(vm); + qemuMigrationJobContinue(vm, qemuProcessCleanupMigrationJob); } =20 cleanup: --=20 2.35.1 From nobody Wed May 15 19:27:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1654087906; cv=none; d=zohomail.com; s=zohoarc; b=hQJYf2ZS+2VIMxQrHgPiPjTgbg5k/iH7gs08NecSh9MSy9v5G0Rne3+H9qxRnhjMYKbPkNsWoQeqgA1xmqtNfK7RpjMNRu19MObHEYQRKzS1EXHRA/BXnmHwKIgFSogqvKMcYluknTwGRm0+WNlfBMh3oiDgKHcwt/QroWXwvOM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654087906; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=0s5HPjHcHavs3nBzGPcZzgganiEpAHUym1bUxD37T2Q=; b=GHLrymihaW/m6sMKufe700J3iwppDw2vN/mdkYMw5TCUv7bB3hFMPcI9S6GhPK4jD3URhtlWnEr0Yme7TExgM47Uzqe+IQwCdh2d1hRuJUAxZnPSdZVxpmSwUHJ91zXE6Hacme/CLjPOMRKoC1XAQ57ppxIoDlpinHeho6aHAzg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1654087906053781.2369384165336; Wed, 1 Jun 2022 05:51:46 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-115-LO_63WRzPwmI2jaZ3Mbc7Q-1; Wed, 01 Jun 2022 08:51:37 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 988993C138BD; Wed, 1 Jun 2022 12:50:53 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7F9581121319; Wed, 1 Jun 2022 12:50:53 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id F00D81937429; Wed, 1 Jun 2022 12:50:49 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 88313193F6D5 for ; Wed, 1 Jun 2022 12:50:31 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 773021415100; Wed, 1 Jun 2022 12:50:31 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.227]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 557D51415107; Wed, 1 Jun 2022 12:50:31 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id BEE72245B94; Wed, 1 Jun 2022 14:50:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654087905; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=0s5HPjHcHavs3nBzGPcZzgganiEpAHUym1bUxD37T2Q=; b=PBuUbHuCepfXuD+fnfQ5vC9jGu9dc0FPbx8gf6CIxER6Z+7wF5obxwWGcRU8kB0sCfqU9k CmieLZGPQlp0uS7QnNykO2I+5Aip36t4OMYMDTRpH77c9v0RttWHfau3xDKGtfdklhIKNC sU691IQo+f8KeIfdXBhipdYjIcWd5IU= X-MC-Unique: LO_63WRzPwmI2jaZ3Mbc7Q-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH v2 71/81] qemu: Implement VIR_MIGRATE_POSTCOPY_RESUME for peer-to-peer migration Date: Wed, 1 Jun 2022 14:50:11 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Krempa , Pavel Hrdina Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1654087908043100011 Content-Type: text/plain; charset="utf-8" Signed-off-by: Jiri Denemark Reviewed-by: Peter Krempa Reviewed-by: Pavel Hrdina --- Notes: Version 2: - no change src/qemu/qemu_migration.c | 53 ++++++++++++++++++++++++++------------- 1 file changed, 36 insertions(+), 17 deletions(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 79766b502e..4bf942e6ab 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -2726,7 +2726,7 @@ qemuMigrationAnyCanResume(virDomainObj *vm, */ if (job =3D=3D VIR_ASYNC_JOB_MIGRATION_OUT && expectedPhase < QEMU_MIGRATION_PHASE_PERFORM_RESUME && - !(flags & VIR_MIGRATE_CHANGE_PROTECTION)) { + !(flags & (VIR_MIGRATE_CHANGE_PROTECTION | VIR_MIGRATE_PEER2PEER))= ) { virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", _("resuming failed post-copy migration requires cha= nge protection")); return false; @@ -5429,9 +5429,14 @@ qemuMigrationSrcPerformPeer2Peer3(virQEMUDriver *dri= ver, * bit here, because we are already running inside the context of * a single job. */ =20 - dom_xml =3D qemuMigrationSrcBeginPhase(driver, vm, xmlin, dname, - &cookieout, &cookieoutlen, - nmigrate_disks, migrate_disks, fl= ags); + if (flags & VIR_MIGRATE_POSTCOPY_RESUME) { + dom_xml =3D qemuMigrationSrcBeginResume(driver, vm, xmlin, + &cookieout, &cookieoutlen, f= lags); + } else { + dom_xml =3D qemuMigrationSrcBeginPhase(driver, vm, xmlin, dname, + &cookieout, &cookieoutlen, + nmigrate_disks, migrate_disks= , flags); + } if (!dom_xml) goto cleanup; =20 @@ -5487,7 +5492,8 @@ qemuMigrationSrcPerformPeer2Peer3(virQEMUDriver *driv= er, goto cleanup; } =20 - if (virDomainObjGetState(vm, NULL) =3D=3D VIR_DOMAIN_PAUSED) + if (!(flags & VIR_MIGRATE_POSTCOPY_RESUME) && + virDomainObjGetState(vm, NULL) =3D=3D VIR_DOMAIN_PAUSED) flags |=3D VIR_MIGRATE_PAUSED; =20 destflags =3D flags & ~(VIR_MIGRATE_ABORT_ON_ERROR | @@ -5936,22 +5942,35 @@ qemuMigrationSrcPerformJob(virQEMUDriver *driver, qemuDomainObjPrivate *priv =3D vm->privateData; qemuDomainJobPrivate *jobPriv =3D priv->job.privateData; =20 - if (qemuMigrationJobStart(driver, vm, VIR_ASYNC_JOB_MIGRATION_OUT, - flags) < 0) - goto cleanup; + if (flags & VIR_MIGRATE_POSTCOPY_RESUME) { + if (!qemuMigrationAnyCanResume(vm, VIR_ASYNC_JOB_MIGRATION_OUT, fl= ags, + QEMU_MIGRATION_PHASE_POSTCOPY_FAILE= D)) + goto cleanup; =20 - if (!(flags & VIR_MIGRATE_OFFLINE) && virDomainObjCheckActive(vm) < 0) - goto endjob; + if (qemuMigrationJobStartPhase(vm, QEMU_MIGRATION_PHASE_BEGIN_RESU= ME) < 0) + goto cleanup; =20 - if (!qemuMigrationSrcIsAllowed(driver, vm, true, flags)) - goto endjob; + virCloseCallbacksUnset(driver->closeCallbacks, vm, + qemuMigrationAnyConnectionClosed); + qemuDomainCleanupRemove(vm, qemuProcessCleanupMigrationJob); + } else { + if (qemuMigrationJobStart(driver, vm, VIR_ASYNC_JOB_MIGRATION_OUT, + flags) < 0) + goto cleanup; =20 - if (!(flags & (VIR_MIGRATE_UNSAFE | VIR_MIGRATE_OFFLINE)) && - !qemuMigrationSrcIsSafe(vm->def, priv->qemuCaps, - nmigrate_disks, migrate_disks, flags)) - goto endjob; + if (!(flags & VIR_MIGRATE_OFFLINE) && virDomainObjCheckActive(vm) = < 0) + goto endjob; =20 - qemuMigrationSrcStoreDomainState(vm); + if (!qemuMigrationSrcIsAllowed(driver, vm, true, flags)) + goto endjob; + + if (!(flags & (VIR_MIGRATE_UNSAFE | VIR_MIGRATE_OFFLINE)) && + !qemuMigrationSrcIsSafe(vm->def, priv->qemuCaps, + nmigrate_disks, migrate_disks, flags)) + goto endjob; + + qemuMigrationSrcStoreDomainState(vm); + } =20 if ((flags & (VIR_MIGRATE_TUNNELLED | VIR_MIGRATE_PEER2PEER))) { ret =3D qemuMigrationSrcPerformPeer2Peer(driver, conn, vm, xmlin, = persist_xml, --=20 2.35.1 From nobody Wed May 15 19:27:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1654088162; cv=none; d=zohomail.com; s=zohoarc; b=AEzM7NB+MNkBRD/Ude81xonIBMkvzOq5vaJAqvoj1NNNOLFGLaORC4/kkJww5WlliUhMrHsMDxGbUrJrwMQ3xzVxMIhM+XP8We+d0Je3mWwDqw7MwMay9oyVwlqwIiNnOu6Rdomt913K06s5Q+uNylZh/tIzLURSNDqmaweZaOY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654088162; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=4+Sb18g10feJJPdHEGVrAIKT3WMg48yfbNKGSgsISvY=; b=Mrw97zqKuzKtThCwtfZDXStB49VkHVxWhOxREFZAqGVIQyobXxRfddsr89umQu9ROC3AIrj2U+4j810KtbqpW4xq7ja6+TgwV0J/YavzkvVVDb3gicFhLcPWZB62blE93wFwAhyT8JdHXwt1Nmz3mhwM0T2KR43ij5+4UeZKd1Y= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1654088162060142.24859661969697; Wed, 1 Jun 2022 05:56:02 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-552-j2E_qqKtPG2igfRjHt7kMA-1; Wed, 01 Jun 2022 08:55:58 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DC7623AF42BF; Wed, 1 Jun 2022 12:55:54 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id C7D53C28101; Wed, 1 Jun 2022 12:55:54 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 82A5C1947B95; Wed, 1 Jun 2022 12:55:53 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 010F1194706A for ; Wed, 1 Jun 2022 12:55:52 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id C917F416366; Wed, 1 Jun 2022 12:55:51 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.227]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A814F40314B; Wed, 1 Jun 2022 12:55:51 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id C0341245B95; Wed, 1 Jun 2022 14:50:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654088161; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=4+Sb18g10feJJPdHEGVrAIKT3WMg48yfbNKGSgsISvY=; b=cbOgAkUUa+YADfW38p0ZwtpaPlzfgWKQbuEqssTWNdQcVsiL4No9bOfQCai0gHIvPIDD33 YmeektRcUSydZLeqqBFAhBecWdhNdJ7o9/qAJbqAwajAzpYtAsSbmyt4kqaItIPcgcHWsq uqsWLQbBeZSrEM/JYSMBVD0mRegITbM= X-MC-Unique: j2E_qqKtPG2igfRjHt7kMA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH v2 72/81] qemu: Enable support for VIR_MIGRATE_POSTCOPY_RESUME Date: Wed, 1 Jun 2022 14:50:12 +0200 Message-Id: <260f8be8bcc2c8902194feeeb4ab9cff85cb5725.1654087150.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Krempa , Pavel Hrdina Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1654088163024100003 Content-Type: text/plain; charset="utf-8" Since all parts of post-copy recovery have been implemented now, it's time to enable the corresponding flag. Signed-off-by: Jiri Denemark Reviewed-by: Peter Krempa Reviewed-by: Pavel Hrdina --- Notes: Version 2: - no change src/qemu/qemu_migration.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/qemu/qemu_migration.h b/src/qemu/qemu_migration.h index 7eb0d4fe02..fbc0549b34 100644 --- a/src/qemu/qemu_migration.h +++ b/src/qemu/qemu_migration.h @@ -60,6 +60,7 @@ VIR_MIGRATE_TLS | \ VIR_MIGRATE_PARALLEL | \ VIR_MIGRATE_NON_SHARED_SYNCHRONOUS_WRITES | \ + VIR_MIGRATE_POSTCOPY_RESUME | \ 0) =20 /* All supported migration parameters and their types. */ --=20 2.35.1 From nobody Wed May 15 19:27:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1654088001; cv=none; d=zohomail.com; s=zohoarc; b=nZTqfHsbeFvplUVzvvSbIATnYyY0z8gxnJzXoKzo5W8T5bjcVnueJetaXUO9Z9zyOUe/CfH7Fao0TgZXvslUc96B1+63hBqqbchJ6gTsOnx/UcwHUWAoIVRDLrsTqFRGH6jNnpsoPxHb9wI43i5jbQAIuuPiexrzHeBWM9cnDok= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654088001; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=1mXohULWLKO12FsPMamk/0Jfes5US48iN+0qOHQzSBE=; b=RX78uFSKZWEq//V8yiFVhohJnoPOBcBUoxda6oOB+4OMwV48CIjNHA5ng1HsicnLbybfQjqxfDvkqeMmwBZt25sjVKkxcRGS1luRlKeoDwwo9w10Le9QQkE8iCe6DhIuwRvoMe2e+KmAKB+Qdt5i5hBTTr1ucRW3adgyiHC6PIk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1654088001611982.3919792952428; Wed, 1 Jun 2022 05:53:21 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-515-jltfoiGNMsG7fWzb3AOTiQ-1; Wed, 01 Jun 2022 08:51:44 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 63D792949BA4; Wed, 1 Jun 2022 12:50:49 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1DC2C1415101; Wed, 1 Jun 2022 12:50:49 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 421AB1955EFA; Wed, 1 Jun 2022 12:50:45 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id E3279194707E for ; Wed, 1 Jun 2022 12:50:31 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id A4D70C28103; Wed, 1 Jun 2022 12:50:31 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.227]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 68392C2810D; Wed, 1 Jun 2022 12:50:31 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id C1FD4245B96; Wed, 1 Jun 2022 14:50:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654088000; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=1mXohULWLKO12FsPMamk/0Jfes5US48iN+0qOHQzSBE=; b=eINWm6hU1/dHViMTsTT/DaJW+dtF/GGIm9CPRfMoKGbv2xyUf15cDZXQGRwJWukoQyh5c6 dI9yGr7QBNgEw3NqPZKWsl58r4PvE2pN4iiqxbo39sD08EWAeVQSDfmG+ppFmqFG91sp9A GvbIYj4X2M7tRDXSTT9iQGORbQbW58g= X-MC-Unique: jltfoiGNMsG7fWzb3AOTiQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH v2 73/81] Add virDomainAbortJobFlags public API Date: Wed, 1 Jun 2022 14:50:13 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Krempa , Pavel Hrdina Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1654088002494100011 Content-Type: text/plain; charset="utf-8" The original virDomainAbortJob did not support flags. Signed-off-by: Jiri Denemark Reviewed-by: Peter Krempa Reviewed-by: Pavel Hrdina --- Notes: Version 2: - no change include/libvirt/libvirt-domain.h | 3 +++ src/driver-hypervisor.h | 5 ++++ src/libvirt-domain.c | 45 ++++++++++++++++++++++++++++++++ src/libvirt_public.syms | 5 ++++ src/remote/remote_driver.c | 1 + src/remote/remote_protocol.x | 14 +++++++++- src/remote_protocol-structs | 5 ++++ 7 files changed, 77 insertions(+), 1 deletion(-) diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-dom= ain.h index e7020f19cc..0b321f364a 100644 --- a/include/libvirt/libvirt-domain.h +++ b/include/libvirt/libvirt-domain.h @@ -4099,6 +4099,9 @@ int virDomainGetJobStats(virDomainPtr domain, unsigned int flags); int virDomainAbortJob(virDomainPtr dom); =20 +int virDomainAbortJobFlags(virDomainPtr dom, + unsigned int flags); + /** * virDomainJobOperation: * diff --git a/src/driver-hypervisor.h b/src/driver-hypervisor.h index 69516e8fea..016d5cec7c 100644 --- a/src/driver-hypervisor.h +++ b/src/driver-hypervisor.h @@ -746,6 +746,10 @@ typedef int typedef int (*virDrvDomainAbortJob)(virDomainPtr domain); =20 +typedef int +(*virDrvDomainAbortJobFlags)(virDomainPtr domain, + unsigned int flags); + typedef int (*virDrvDomainMigrateGetMaxDowntime)(virDomainPtr domain, unsigned long long *downtime, @@ -1590,6 +1594,7 @@ struct _virHypervisorDriver { virDrvDomainGetJobInfo domainGetJobInfo; virDrvDomainGetJobStats domainGetJobStats; virDrvDomainAbortJob domainAbortJob; + virDrvDomainAbortJobFlags domainAbortJobFlags; virDrvDomainMigrateGetMaxDowntime domainMigrateGetMaxDowntime; virDrvDomainMigrateSetMaxDowntime domainMigrateSetMaxDowntime; virDrvDomainMigrateGetCompressionCache domainMigrateGetCompressionCach= e; diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c index d86625526c..1b367ca9ba 100644 --- a/src/libvirt-domain.c +++ b/src/libvirt-domain.c @@ -9470,6 +9470,51 @@ virDomainAbortJob(virDomainPtr domain) } =20 =20 +/** + * virDomainAbortJobFlags: + * @domain: a domain object + * @flags: extra flags; not used yet, callers should always pass 0 + * + * Requests that the current background job be aborted at the + * soonest opportunity. In case the job is a migration in a post-copy mode, + * this function will report an error (see virDomainMigrateStartPostCopy f= or + * more details). + * + * Returns 0 in case of success and -1 in case of failure. + * + * Since: 8.5.0 + */ +int +virDomainAbortJobFlags(virDomainPtr domain, + unsigned int flags) +{ + virConnectPtr conn; + + VIR_DOMAIN_DEBUG(domain); + + virResetLastError(); + + virCheckDomainReturn(domain, -1); + conn =3D domain->conn; + + virCheckReadOnlyGoto(conn->flags, error); + + if (conn->driver->domainAbortJobFlags) { + int ret; + ret =3D conn->driver->domainAbortJobFlags(domain, flags); + if (ret < 0) + goto error; + return ret; + } + + virReportUnsupportedError(); + + error: + virDispatchError(conn); + return -1; +} + + /** * virDomainMigrateSetMaxDowntime: * @domain: a domain object diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms index 9f58b52924..297a2c436a 100644 --- a/src/libvirt_public.syms +++ b/src/libvirt_public.syms @@ -922,4 +922,9 @@ LIBVIRT_8.4.0 { virDomainRestoreParams; } LIBVIRT_8.0.0; =20 +LIBVIRT_8.5.0 { + global: + virDomainAbortJobFlags; +} LIBVIRT_8.4.0; + # .... define new API here using predicted next version number .... diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index 423f5f9fb9..3c892bf8e6 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -8534,6 +8534,7 @@ static virHypervisorDriver hypervisor_driver =3D { .domainGetJobInfo =3D remoteDomainGetJobInfo, /* 0.7.7 */ .domainGetJobStats =3D remoteDomainGetJobStats, /* 1.0.3 */ .domainAbortJob =3D remoteDomainAbortJob, /* 0.7.7 */ + .domainAbortJobFlags =3D remoteDomainAbortJobFlags, /* 8.5.0 */ .domainMigrateGetMaxDowntime =3D remoteDomainMigrateGetMaxDowntime, /*= 3.7.0 */ .domainMigrateSetMaxDowntime =3D remoteDomainMigrateSetMaxDowntime, /*= 0.8.0 */ .domainMigrateGetCompressionCache =3D remoteDomainMigrateGetCompressio= nCache, /* 1.0.3 */ diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x index 085631c11b..79ffc63f03 100644 --- a/src/remote/remote_protocol.x +++ b/src/remote/remote_protocol.x @@ -2492,6 +2492,12 @@ struct remote_domain_abort_job_args { }; =20 =20 +struct remote_domain_abort_job_flags_args { + remote_nonnull_domain dom; + unsigned int flags; +}; + + struct remote_domain_migrate_get_max_downtime_args { remote_nonnull_domain dom; unsigned int flags; @@ -6947,5 +6953,11 @@ enum remote_procedure { * @acl: domain:start * @acl: domain:write */ - REMOTE_PROC_DOMAIN_RESTORE_PARAMS =3D 441 + REMOTE_PROC_DOMAIN_RESTORE_PARAMS =3D 441, + + /** + * @generate: both + * @acl: domain:write + */ + REMOTE_PROC_DOMAIN_ABORT_JOB_FLAGS =3D 442 }; diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs index 4ffdce5679..ca5222439d 100644 --- a/src/remote_protocol-structs +++ b/src/remote_protocol-structs @@ -1869,6 +1869,10 @@ struct remote_domain_get_job_stats_ret { struct remote_domain_abort_job_args { remote_nonnull_domain dom; }; +struct remote_domain_abort_job_flags_args { + remote_nonnull_domain dom; + u_int flags; +}; struct remote_domain_migrate_get_max_downtime_args { remote_nonnull_domain dom; u_int flags; @@ -3706,4 +3710,5 @@ enum remote_procedure { REMOTE_PROC_DOMAIN_SET_LAUNCH_SECURITY_STATE =3D 439, REMOTE_PROC_DOMAIN_SAVE_PARAMS =3D 440, REMOTE_PROC_DOMAIN_RESTORE_PARAMS =3D 441, + REMOTE_PROC_DOMAIN_ABORT_JOB_FLAGS =3D 442, }; --=20 2.35.1 From nobody Wed May 15 19:27:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1654088161; cv=none; d=zohomail.com; s=zohoarc; b=VJiwjOd83YzOcy9CYH1TzqYscf8gbOeXVl1WkcJNn7e8Wm86tU3mZDJQlENXZ0hkWyx3jttJADw33jBO/xeMqdxDgi/+j4i01BF4gewE712yfX6UjC32yWv8O7lOXHWlDPIggghUvbmVQTmBHslSrha0PRJaRVl4RV4r/bdlxzg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654088161; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=BpvhwbXvvn50/Hh2oixku51O04gv0vZFlriRK7Iae9U=; b=UagYIcAtmmOp6y0wn3Lzz4kgn2WlKTzgOnVzeCUeb4NqtXZ+y8CWl/WEzQ3pHpEuR2tjlufnY/uIfpZIRe/pP5tKht9U4mT3eaabbTE+B5QNRxr3SCRR/LVqwTwC7jAMuPSHMf7nMqeXhgiIp/1X93+y8Cgaw6lRFTqxsE7pmpg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1654088161046674.537582370913; Wed, 1 Jun 2022 05:56:01 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-550-Q2SXcz9HN5e0GrX5V3DYAg-1; Wed, 01 Jun 2022 08:55:58 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 78890811E76; Wed, 1 Jun 2022 12:55:54 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 56C661410F36; Wed, 1 Jun 2022 12:55:54 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 16EFB1947B8C; Wed, 1 Jun 2022 12:55:53 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id F11941947079 for ; Wed, 1 Jun 2022 12:55:51 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id C981E140EBD5; Wed, 1 Jun 2022 12:55:51 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.227]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A94661415100; Wed, 1 Jun 2022 12:55:51 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id C2EB0245B97; Wed, 1 Jun 2022 14:50:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654088160; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=BpvhwbXvvn50/Hh2oixku51O04gv0vZFlriRK7Iae9U=; b=GPB+5JOzLmJpGbI3Esw1hbKWOO1wQ7N7iuEoiGzvIox19ujkv+r2F6aMOlz63dg5/kCj0W RpgSGOCsXt45KQNNIxexRJjHBcODMBiFE807us42dX07tZ/zZUzm+lITDtLpcx0usimD3s IM4UqMKu77QES8GSylQVCk5mayeVFAk= X-MC-Unique: Q2SXcz9HN5e0GrX5V3DYAg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH v2 74/81] qemu: Implement virDomainAbortJobFlags Date: Wed, 1 Jun 2022 14:50:14 +0200 Message-Id: <43f580d2d89d84d76e5de1c5e98a1aed83b64a5b.1654087150.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Krempa , Pavel Hrdina Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1654088163026100004 Content-Type: text/plain; charset="utf-8" Signed-off-by: Jiri Denemark Reviewed-by: Peter Krempa Reviewed-by: Pavel Hrdina --- Notes: Version 2: - VIR_DEBUG added src/qemu/qemu_driver.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 4edf5635c0..cab2859a6c 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -12783,7 +12783,9 @@ qemuDomainAbortJobMigration(virDomainObj *vm) } =20 =20 -static int qemuDomainAbortJob(virDomainPtr dom) +static int +qemuDomainAbortJobFlags(virDomainPtr dom, + unsigned int flags) { virQEMUDriver *driver =3D dom->conn->privateData; virDomainObj *vm; @@ -12791,10 +12793,14 @@ static int qemuDomainAbortJob(virDomainPtr dom) qemuDomainObjPrivate *priv; int reason; =20 + VIR_DEBUG("flags=3D0x%x", flags); + + virCheckFlags(0, -1); + if (!(vm =3D qemuDomainObjFromDomain(dom))) goto cleanup; =20 - if (virDomainAbortJobEnsureACL(dom->conn, vm->def) < 0) + if (virDomainAbortJobFlagsEnsureACL(dom->conn, vm->def) < 0) goto cleanup; =20 if (qemuDomainObjBeginJob(driver, vm, VIR_JOB_ABORT) < 0) @@ -12873,6 +12879,13 @@ static int qemuDomainAbortJob(virDomainPtr dom) } =20 =20 +static int +qemuDomainAbortJob(virDomainPtr dom) +{ + return qemuDomainAbortJobFlags(dom, 0); +} + + static int qemuDomainMigrateSetMaxDowntime(virDomainPtr dom, unsigned long long downtime, @@ -21037,6 +21050,7 @@ static virHypervisorDriver qemuHypervisorDriver =3D= { .domainGetJobInfo =3D qemuDomainGetJobInfo, /* 0.7.7 */ .domainGetJobStats =3D qemuDomainGetJobStats, /* 1.0.3 */ .domainAbortJob =3D qemuDomainAbortJob, /* 0.7.7 */ + .domainAbortJobFlags =3D qemuDomainAbortJobFlags, /* 8.5.0 */ .domainMigrateGetMaxDowntime =3D qemuDomainMigrateGetMaxDowntime, /* 3= .7.0 */ .domainMigrateSetMaxDowntime =3D qemuDomainMigrateSetMaxDowntime, /* 0= .8.0 */ .domainMigrateGetCompressionCache =3D qemuDomainMigrateGetCompressionC= ache, /* 1.0.3 */ --=20 2.35.1 From nobody Wed May 15 19:27:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1654088058; cv=none; d=zohomail.com; s=zohoarc; b=kstpjsUyog93nVOzeLtoVAXSKzCMoxZCqnDuxxHj6I5bxNOdOZXf30ubCNOkcuOlxckyGevWK7BCdnRWMeI51LnHtDapUhRsfmYq/W8QUs6nRKo/ucmB7qdte/kfC+oG7bUur7RZF63GELtK7LdPzsD5c+VeK1picBCw17W8Cy0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654088058; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=az2a1Kk2C1dToQBElOes7CjycEHtDHQTF9qqKNCYd3A=; b=J6EmMdDj++q9qf6SRhdQ5uQq/opvXLtV1uY55J42+sPvCP0Q3E7BK46S8RNSLR9NY2aGdW7iRikshAEgh2MGu76MgZ5VzLwik8jvdoOfU6+Ikd+pv6BHlEUqlEHllWCg6KzUYZwC+20o7gt1SDStUsj0XZuWvO/TGmPYmvMAG58= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 165408805887986.28750494273402; Wed, 1 Jun 2022 05:54:18 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-615-PTeS-JFiPtGAyxVTsa0bUA-1; Wed, 01 Jun 2022 08:51:44 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 97EE7933C06; Wed, 1 Jun 2022 12:50:54 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 80CAA1731B; Wed, 1 Jun 2022 12:50:54 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id C49021932219; Wed, 1 Jun 2022 12:50:50 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 7F49E1947B91 for ; Wed, 1 Jun 2022 12:50:32 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 6258241637E; Wed, 1 Jun 2022 12:50:32 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.227]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3FD8840314B; Wed, 1 Jun 2022 12:50:32 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id C4317245B98; Wed, 1 Jun 2022 14:50:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654088057; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=az2a1Kk2C1dToQBElOes7CjycEHtDHQTF9qqKNCYd3A=; b=W1HPrZ1GwBzks1Y2MmfpSYYsMvMsuhUACc3jeFgUzpKna38vMcfZ4vbOWiEXbBKlI+YGEB M5WT9Lq/7B/zyc9l0nz9EFTr8ZhWj14drPu1stD9T17bAUnRWqfSIUxIXB8BXz9f1Er9h8 6Z/XpP7lPLOiTJcV3YgacwNBkBEuta4= X-MC-Unique: PTeS-JFiPtGAyxVTsa0bUA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH v2 75/81] Add VIR_DOMAIN_ABORT_JOB_POSTCOPY flag for virDomainAbortJobFlags Date: Wed, 1 Jun 2022 14:50:15 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Krempa , Pavel Hrdina Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1654088060781100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Jiri Denemark Reviewed-by: Peter Krempa Reviewed-by: Pavel Hrdina --- Notes: Version 2: - no change include/libvirt/libvirt-domain.h | 16 ++++++++++++++++ src/libvirt-domain.c | 10 ++++++---- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-dom= ain.h index 0b321f364a..2aec69bc54 100644 --- a/include/libvirt/libvirt-domain.h +++ b/include/libvirt/libvirt-domain.h @@ -4099,6 +4099,22 @@ int virDomainGetJobStats(virDomainPtr domain, unsigned int flags); int virDomainAbortJob(virDomainPtr dom); =20 +/** + * virDomainAbortJobFlagsValues: + * + * Flags OR'ed together to provide specific behavior when aborting a domai= n job. + * + * Since: 8.5.0 + */ +typedef enum { + /* Interrupt post-copy migration. Since migration in a post-copy phase + * cannot be aborted without losing the domain (none of the hosts invo= lved + * in migration has a complete state of the domain), the migration wil= l be + * suspended and it can later be resumed using virDomainMigrate* APIs = with + * VIR_MIGRATE_POSTCOPY_RESUME flag. (Since: 8.5.0) */ + VIR_DOMAIN_ABORT_JOB_POSTCOPY =3D 1 << 0, +} virDomainAbortJobFlagsValues; + int virDomainAbortJobFlags(virDomainPtr dom, unsigned int flags); =20 diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c index 1b367ca9ba..4a4f6424d7 100644 --- a/src/libvirt-domain.c +++ b/src/libvirt-domain.c @@ -9473,12 +9473,12 @@ virDomainAbortJob(virDomainPtr domain) /** * virDomainAbortJobFlags: * @domain: a domain object - * @flags: extra flags; not used yet, callers should always pass 0 + * @flags: bitwise-OR of virDomainAbortJobFlagsValues * * Requests that the current background job be aborted at the * soonest opportunity. In case the job is a migration in a post-copy mode, - * this function will report an error (see virDomainMigrateStartPostCopy f= or - * more details). + * this function will report an error unless VIR_DOMAIN_ABORT_JOB_POSTCOPY + * flag is used (see virDomainMigrateStartPostCopy for more details). * * Returns 0 in case of success and -1 in case of failure. * @@ -9820,7 +9820,9 @@ virDomainMigrateGetMaxSpeed(virDomainPtr domain, * VIR_DOMAIN_PAUSED_POSTCOPY_FAILED if even the connection between QEMU * processes gets broken. It's up to the upper layer to decide what to do = in * such case. Because of this, libvirt will refuse to cancel post-copy - * migration via virDomainAbortJob. + * migration via virDomainAbortJobFlags unless it is called with + * VIR_DOMAIN_ABORT_JOB_POSTCOPY, in which case the post-copy migration wi= ll be + * paused. * * Failed post-copy migration can be recovered once the cause for the fail= ure * (e.g., a network issue) is resolved by repeating the migration with an --=20 2.35.1 From nobody Wed May 15 19:27:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1654087991; cv=none; d=zohomail.com; s=zohoarc; b=i2Ya1yqeZVKro7pU5DpZBR4PPfzFn7juDmiEFDGpy+xWAdJzNyiZDaJCyxj+69bEtIfjiEVrVzgqfADBYn9PidLfWkhoTM/yxEJwAXVlI/eMxUMQEWEm1foPc9tf2n2Z/dZwCdZoxRnVhxL8/2HW02JCrzdDQFW4PGuM0VPlvJ4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654087991; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=egElpT+bgR8gJQEbYsIxCSkUAkE01aJG4xl+C4vF+Xo=; b=lKeDsAiG95U6sfSZGgJ3iRb/yCMGb8rv+8TjqGPDQ6csN2tcNkaynR1Qeg632v4jt6lAqZSj/0TaGDXsBaMImYABUnV7zNyP1wwtdwRLQUR+bxuNVy9eoBKKGhUlA/710JonYXJr5BgoMfN3cta6Ly4m5P23HKRnFXpIWixLdVo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1654087991681610.5096812082174; Wed, 1 Jun 2022 05:53:11 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-135-2swp4DvnPk2QiQupzbAhMA-1; Wed, 01 Jun 2022 08:51:42 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 893768F2459; Wed, 1 Jun 2022 12:50:47 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7291B3323E; Wed, 1 Jun 2022 12:50:47 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id A6B021955EE9; Wed, 1 Jun 2022 12:50:43 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id B7C0619451EC for ; Wed, 1 Jun 2022 12:50:32 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 7C926492C3B; Wed, 1 Jun 2022 12:50:32 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.227]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3FF68492CA3 for ; Wed, 1 Jun 2022 12:50:32 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id C57C9245BA6; Wed, 1 Jun 2022 14:50:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654087990; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=egElpT+bgR8gJQEbYsIxCSkUAkE01aJG4xl+C4vF+Xo=; b=XDgmutcqNn4UJ3FXL8j6RMBUiFTlV6TADPdfuNaPiC6FrR1gubhjA56r/wMud+6UEtIsf9 me1Ex1N9WS1HXxqXjI5JOjn3vulJu4Qk0wDcceUlPaYB5wQ3cyo8uTZP9t2NMAX65DFJqg Ev0ZhT+c71+/Z97Sc+cG8/I7v5umS+Q= X-MC-Unique: 2swp4DvnPk2QiQupzbAhMA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH v2 76/81] qemu: Implement VIR_DOMAIN_ABORT_JOB_POSTCOPY flag Date: Wed, 1 Jun 2022 14:50:16 +0200 Message-Id: <8d7cd4ce6789463784ad5071b12f23333a0d4799.1654087150.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1654087992433100017 Content-Type: text/plain; charset="utf-8" Signed-off-by: Jiri Denemark Reviewed-by: Peter Krempa --- Notes: Version 2: - dropped DeviceNotFound QMP error handling and replaced it with reporting an error if the VIR_DOMAIN_ABORT_JOB_POSTCOPY flag is used for something else than outgoing post-copy migration src/qemu/qemu_driver.c | 48 +++++++++++++++++++++++++++--------- src/qemu/qemu_monitor.c | 9 +++++++ src/qemu/qemu_monitor.h | 3 +++ src/qemu/qemu_monitor_json.c | 19 ++++++++++++++ src/qemu/qemu_monitor_json.h | 3 +++ 5 files changed, 71 insertions(+), 11 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index cab2859a6c..01c4a8470a 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -12783,6 +12783,30 @@ qemuDomainAbortJobMigration(virDomainObj *vm) } =20 =20 +static int +qemuDomainAbortJobPostcopy(virDomainObj *vm, + unsigned int flags) +{ + qemuDomainObjPrivate *priv =3D vm->privateData; + int rc; + + if (!(flags & VIR_DOMAIN_ABORT_JOB_POSTCOPY)) { + virReportError(VIR_ERR_OPERATION_INVALID, "%s", + _("cannot abort migration in post-copy mode")); + return -1; + } + + VIR_DEBUG("Suspending post-copy migration at client request"); + + qemuDomainObjAbortAsyncJob(vm); + qemuDomainObjEnterMonitor(priv->driver, vm); + rc =3D qemuMonitorMigratePause(priv->mon); + qemuDomainObjExitMonitor(vm); + + return rc; +} + + static int qemuDomainAbortJobFlags(virDomainPtr dom, unsigned int flags) @@ -12791,11 +12815,10 @@ qemuDomainAbortJobFlags(virDomainPtr dom, virDomainObj *vm; int ret =3D -1; qemuDomainObjPrivate *priv; - int reason; =20 VIR_DEBUG("flags=3D0x%x", flags); =20 - virCheckFlags(0, -1); + virCheckFlags(VIR_DOMAIN_ABORT_JOB_POSTCOPY, -1); =20 if (!(vm =3D qemuDomainObjFromDomain(dom))) goto cleanup; @@ -12811,6 +12834,14 @@ qemuDomainAbortJobFlags(virDomainPtr dom, =20 priv =3D vm->privateData; =20 + if (flags & VIR_DOMAIN_ABORT_JOB_POSTCOPY && + (priv->job.asyncJob !=3D VIR_ASYNC_JOB_MIGRATION_OUT || + !virDomainObjIsPostcopy(vm, VIR_DOMAIN_JOB_OPERATION_MIGRATION_OU= T))) { + virReportError(VIR_ERR_OPERATION_INVALID, "%s", + _("current job is not outgoing migration in post-co= py mode")); + goto endjob; + } + switch (priv->job.asyncJob) { case VIR_ASYNC_JOB_NONE: virReportError(VIR_ERR_OPERATION_INVALID, "%s", @@ -12830,15 +12861,10 @@ qemuDomainAbortJobFlags(virDomainPtr dom, break; =20 case VIR_ASYNC_JOB_MIGRATION_OUT: - if ((priv->job.current->status =3D=3D VIR_DOMAIN_JOB_STATUS_POSTCO= PY || - (virDomainObjGetState(vm, &reason) =3D=3D VIR_DOMAIN_PAUSED && - reason =3D=3D VIR_DOMAIN_PAUSED_POSTCOPY))) { - virReportError(VIR_ERR_OPERATION_INVALID, "%s", - _("cannot abort migration in post-copy mode")); - goto endjob; - } - - ret =3D qemuDomainAbortJobMigration(vm); + if (virDomainObjIsPostcopy(vm, VIR_DOMAIN_JOB_OPERATION_MIGRATION_= OUT)) + ret =3D qemuDomainAbortJobPostcopy(vm, flags); + else + ret =3D qemuDomainAbortJobMigration(vm); break; =20 case VIR_ASYNC_JOB_SAVE: diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index e9b9390c80..37bcbde31e 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -2425,6 +2425,15 @@ qemuMonitorMigrateCancel(qemuMonitor *mon) } =20 =20 +int +qemuMonitorMigratePause(qemuMonitor *mon) +{ + QEMU_CHECK_MONITOR(mon); + + return qemuMonitorJSONMigratePause(mon); +} + + int qemuMonitorQueryDump(qemuMonitor *mon, qemuMonitorDumpStats *stats) diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index 4f6c7e40fd..91f2d0941c 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -890,6 +890,9 @@ int qemuMonitorMigrateToSocket(qemuMonitor *mon, =20 int qemuMonitorMigrateCancel(qemuMonitor *mon); =20 +int +qemuMonitorMigratePause(qemuMonitor *mon); + int qemuMonitorGetDumpGuestMemoryCapability(qemuMonitor *mon, const char *capability); =20 diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 99c5e1b40f..8b81a07429 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -3455,6 +3455,25 @@ int qemuMonitorJSONMigrateCancel(qemuMonitor *mon) } =20 =20 +int +qemuMonitorJSONMigratePause(qemuMonitor *mon) +{ + g_autoptr(virJSONValue) cmd =3D NULL; + g_autoptr(virJSONValue) reply =3D NULL; + + if (!(cmd =3D qemuMonitorJSONMakeCommand("migrate-pause", NULL))) + return -1; + + if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) + return -1; + + if (qemuMonitorJSONCheckError(cmd, reply) < 0) + return -1; + + return 0; +} + + /* qemuMonitorJSONQueryDump: * @mon: Monitor pointer * @stats: Monitor dump stats diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h index 305faafce4..3b55e380b3 100644 --- a/src/qemu/qemu_monitor_json.h +++ b/src/qemu/qemu_monitor_json.h @@ -207,6 +207,9 @@ qemuMonitorJSONGetSpiceMigrationStatus(qemuMonitor *mon, int qemuMonitorJSONMigrateCancel(qemuMonitor *mon); =20 +int +qemuMonitorJSONMigratePause(qemuMonitor *mon); + int qemuMonitorJSONQueryDump(qemuMonitor *mon, qemuMonitorDumpStats *stats); --=20 2.35.1 From nobody Wed May 15 19:27:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1654088045; cv=none; d=zohomail.com; s=zohoarc; b=eDbb+dYBx+yQ+GDJLWJHdud9QOKyJ/96u0EBisgUf2dS6A772PEDl5XYaLXFbgTe2jKOA2SEE+CeAaod5juxV+VZwR6mlv9OFod5fuc1RAvPpCe2RofygRhlC40XqlfNfbnKOo4fekxKFZMRGEcIdk5Dcdg4Z3csYCkapHqwFXU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654088045; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=HxR+TwJxe7rhku8wf29uL6AGKOX7dUeaX6M3nkfTXX0=; b=e+j1lRcNwIspyRT8BMwqXuahS+z8kbYgB73CmD3KfYKoAcQIyqRv8h0GNxbJfGzRbWuua3Babcpgv0NbatxOLo/k3zIc+vOJQzcl5X3p5wT8ER24YIP9W02zOniUAMTe6+9xEgoEOiN2nTFXa9IcA1XuFtkGJfqcDNcO6b9yNRk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1654088045559515.7294808992134; Wed, 1 Jun 2022 05:54:05 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-463-RhRn7ahuMNaQqghQxEUptQ-1; Wed, 01 Jun 2022 08:51:35 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5E46C39F9CC4; Wed, 1 Jun 2022 12:50:42 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4A19AC27E8F; Wed, 1 Jun 2022 12:50:42 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 0BF5B1955EDE; Wed, 1 Jun 2022 12:50:39 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 8B4E21947B95 for ; Wed, 1 Jun 2022 12:50:32 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 63D91492CA5; Wed, 1 Jun 2022 12:50:32 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.227]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3F91C492CA2; Wed, 1 Jun 2022 12:50:32 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id C6CAE245BA7; Wed, 1 Jun 2022 14:50:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654088044; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=HxR+TwJxe7rhku8wf29uL6AGKOX7dUeaX6M3nkfTXX0=; b=JBSxP84Vs2NruKGSZt31H00nVI0p/uPecCYUBtLXq/tzD7ilWjMuNJsX3Tj/wijiY9vtFy 8zVyD42WtWIyw3/IaUJmPMFSV/RICZ7X5uMSVvwJTPFI+bBjuu9m9v9lun/GAIB7ie5eD/ 8Wa5lWq2wnNwDGUDhakbp/1nYQFdHBE= X-MC-Unique: RhRn7ahuMNaQqghQxEUptQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH v2 77/81] virsh: Add --postcopy option for domjobabort command Date: Wed, 1 Jun 2022 14:50:17 +0200 Message-Id: <675eba38f221bf943deb61dc9340e2905f91324d.1654087150.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Krempa , Pavel Hrdina Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1654088046708100003 Content-Type: text/plain; charset="utf-8" Signed-off-by: Jiri Denemark Reviewed-by: Peter Krempa Reviewed-by: Pavel Hrdina --- Notes: Version 2: - no change docs/manpages/virsh.rst | 8 +++++++- tools/virsh-domain.c | 16 +++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/docs/manpages/virsh.rst b/docs/manpages/virsh.rst index ecdb54fcd5..faac996536 100644 --- a/docs/manpages/virsh.rst +++ b/docs/manpages/virsh.rst @@ -2053,10 +2053,16 @@ domjobabort =20 :: =20 - domjobabort domain + domjobabort domain [--postcopy] =20 Abort the currently running domain job. =20 +When the job to be aborted is a migration which entered post-copy mode, it +cannot be aborted as none of the hosts involved in migration has a complete +state of the domain. Optional *--postcopy* can be used to interrupt such +migration although doing so may effectively suspend the domain until the +migration is resumed (see also *--postcopy-resume* option of ``migrate``). + =20 domjobinfo ---------- diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index dd7862b5e5..5c4a7d7b8d 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -6477,6 +6477,10 @@ static const vshCmdInfo info_domjobabort[] =3D { =20 static const vshCmdOptDef opts_domjobabort[] =3D { VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_ACTIVE), + {.name =3D "postcopy", + .type =3D VSH_OT_BOOL, + .help =3D N_("interrupt post-copy migration") + }, {.name =3D NULL} }; =20 @@ -6484,11 +6488,21 @@ static bool cmdDomjobabort(vshControl *ctl, const vshCmd *cmd) { g_autoptr(virshDomain) dom =3D NULL; + unsigned int flags =3D 0; + int rc; =20 if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 - if (virDomainAbortJob(dom) < 0) + if (vshCommandOptBool(cmd, "postcopy")) + flags |=3D VIR_DOMAIN_ABORT_JOB_POSTCOPY; + + if (flags =3D=3D 0) + rc =3D virDomainAbortJob(dom); + else + rc =3D virDomainAbortJobFlags(dom, flags); + + if (rc < 0) return false; =20 return true; --=20 2.35.1 From nobody Wed May 15 19:27:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1654088163; cv=none; d=zohomail.com; s=zohoarc; b=Rl3axCTMSBOlgOoAKa0Pd+o1UuKiu1u1Dt/0dKAXQzX55m6bULGA01t8I6jQpOyPMQaen7nUtaBk6nMaPstK07vAIYz79ajFlYtEreFxjUEtCd9aBlVzwngpbcW+tiDgbcOTiZLEqbJBYc9+oruRG035Bm7e0L33BVkePkHWo2U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654088163; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=gmqUIK6wk1F/nZsH2hqksJ0vKz+Nlo9CbSEwbTQqRgQ=; b=FHpaGrPlH2C+QuB8sgIBL4AjF4DiaTv4/Zf7XzSRk5k0vgbykyGB4dRK8vnSvVMw3JWRNcy/GML1gokX/0oi9FytSvsrtCkEK75dLCExz/l6q8aCBs7cqVDJFRuBQ8S4Kg1UUlocJnAduXkw8a82UcO6orBt1CDwVcXLnLkaCcY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1654088163940257.2913444080431; Wed, 1 Jun 2022 05:56:03 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-556-66WVnrR2NQyzxuK-fu7GAg-1; Wed, 01 Jun 2022 08:55:58 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 634E11C161B5; Wed, 1 Jun 2022 12:55:55 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4F3B81415102; Wed, 1 Jun 2022 12:55:55 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id D37C61947BA6; Wed, 1 Jun 2022 12:55:53 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id E0C45194707B for ; Wed, 1 Jun 2022 12:55:51 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id C9CDD40EC004; Wed, 1 Jun 2022 12:55:51 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.227]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A8C2540EC002; Wed, 1 Jun 2022 12:55:51 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id C821F245BA8; Wed, 1 Jun 2022 14:50:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654088163; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=gmqUIK6wk1F/nZsH2hqksJ0vKz+Nlo9CbSEwbTQqRgQ=; b=bau4DVaIAXyxZLJpq8wYNzn1NVLP9lxsvKz0LUGqXlXaiz1haw7qBxbvaNaPzcM135Ikan TFXW0we5D6qxnx7nKySuAYl4nul9ddBZbFt9SlfogE6TCm5sZ8THoy3e5QqjkV5+wocQOi TaXR6x+h+dYUq2rqWB1sUTtO4vJ2QrU= X-MC-Unique: 66WVnrR2NQyzxuK-fu7GAg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH v2 78/81] NEWS: Add support for post-copy recovery Date: Wed, 1 Jun 2022 14:50:18 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Krempa , Pavel Hrdina Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1654088164999100009 Content-Type: text/plain; charset="utf-8" Signed-off-by: Jiri Denemark Reviewed-by: Peter Krempa Reviewed-by: Pavel Hrdina --- Notes: Version 2: - s/fecovering/recovering/ - added `` around flag name and virsh command NEWS.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/NEWS.rst b/NEWS.rst index 28ed46e361..94ab4a860e 100644 --- a/NEWS.rst +++ b/NEWS.rst @@ -17,6 +17,11 @@ v8.5.0 (unreleased) =20 * **New features** =20 + * qemu: Add support for post-copy recovery + + A new ``VIR_MIGRATE_POSTCOPY_RESUME`` flag (``virsh migrate --postcopy= -resume``) + was introduced for recovering from a failed post-copy migration. + * **Improvements** =20 * **Bug fixes** --=20 2.35.1 From nobody Wed May 15 19:27:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1654087994; cv=none; d=zohomail.com; s=zohoarc; b=G9gF6IyuihTKKnpXAMZSQl6msgIRVmADnZwMTr4fP77GGWMgVYP0SD7iYv0NjIYu0zuGr7HR7Wi7Sr6she5MzFSkCmrKNerdS9dtwwqg6TAG/JrVTorxPSzOVCMg1tHHhET04s7CcsHsoQC+Pu+6kFOqmffYlGMNLvXbuqr6cMI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654087994; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=vfr9U5otNR9N7TrcTy6uFqs0XQShzAu7vxr291mtMWw=; b=KU4QddKsX9+iVX+Q/OOpkQKmDKRrTKs2lnQpc+qbLP0UHH7MvYmbf442OqY79VRvuALqoqEFCtxws10vgFkF7OkcepQLmaf9IM/fVdEW52A7FkAgSMd8JEfeXtyhubxyJs4iRmFdL+H+qbQPrvUgITHI3zCAj/HMWC02HS3YHUk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1654087994689913.8936204152253; Wed, 1 Jun 2022 05:53:14 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-549-dcT5qXBsOtup3J53QhbLbg-1; Wed, 01 Jun 2022 08:51:40 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 085BD39F9CD4; Wed, 1 Jun 2022 12:50:55 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id E538782882; Wed, 1 Jun 2022 12:50:54 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 811CF194F4BE; Wed, 1 Jun 2022 12:50:51 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 93E151947B97 for ; Wed, 1 Jun 2022 12:50:32 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 63F0C2026D2D; Wed, 1 Jun 2022 12:50:32 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.227]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 41D342026985 for ; Wed, 1 Jun 2022 12:50:32 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id C96F5245BA9; Wed, 1 Jun 2022 14:50:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654087993; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=vfr9U5otNR9N7TrcTy6uFqs0XQShzAu7vxr291mtMWw=; b=fM310WP9vsj88ZG5rsr7GAGGjudXyq6/RLXg956AOFoddxvpCmno7wHOuhuO2TcyBzA8Ny Nnp+moWZRR/22qu7/5XnCVTQGvnh2lZwfslQO9fpeE/TYdJV9on7SnT+RyDTQ0Y1oZYGgm C1nJrIMMflJYDwDDc0D0VM7ttB+opik= X-MC-Unique: dcT5qXBsOtup3J53QhbLbg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH v2 79/81] Introduce VIR_JOB_MIGRATION_SAFE job type Date: Wed, 1 Jun 2022 14:50:19 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1654087996417100002 Content-Type: text/plain; charset="utf-8" This is a special job for operations that need to modify domain state during an active migration. The modification must not affect any state that could conflict with the migration code. This is useful mainly for event handlers that need to be processed during migration and which could otherwise time out on acquiring a normal MODIFY job. Signed-off-by: Jiri Denemark Reviewed-by: Peter Krempa --- Notes: Version 2: - new patch src/hypervisor/domain_job.c | 1 + src/hypervisor/domain_job.h | 4 ++++ src/qemu/qemu_migration.c | 1 + src/qemu/qemu_process.c | 7 +++++++ 4 files changed, 13 insertions(+) diff --git a/src/hypervisor/domain_job.c b/src/hypervisor/domain_job.c index 49867c3982..191dc1c700 100644 --- a/src/hypervisor/domain_job.c +++ b/src/hypervisor/domain_job.c @@ -18,6 +18,7 @@ VIR_ENUM_IMPL(virDomainJob, "modify", "abort", "migration operation", + "migration safe", "none", /* async job is never stored in job.active */ "async nested", ); diff --git a/src/hypervisor/domain_job.h b/src/hypervisor/domain_job.h index fce35ffbf5..24bb93c59f 100644 --- a/src/hypervisor/domain_job.h +++ b/src/hypervisor/domain_job.h @@ -31,6 +31,10 @@ typedef enum { VIR_JOB_MODIFY, /* May change state */ VIR_JOB_ABORT, /* Abort current async job */ VIR_JOB_MIGRATION_OP, /* Operation influencing outgoing migration */ + VIR_JOB_MIGRATION_SAFE, /* Internal only job for event handlers which = need + to be processed even during migration. The = code + may only change state in a way that does not + affect migration. */ =20 /* The following two items must always be the last items before JOB_LA= ST */ VIR_JOB_ASYNC, /* Asynchronous job */ diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 4bf942e6ab..0314fb1148 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -127,6 +127,7 @@ qemuMigrationJobStart(virQEMUDriver *driver, JOB_MASK(VIR_JOB_SUSPEND) | JOB_MASK(VIR_JOB_MIGRATION_OP); } + mask |=3D JOB_MASK(VIR_JOB_MIGRATION_SAFE); =20 if (qemuDomainObjBeginAsyncJob(driver, vm, job, op, apiFlags) < 0) return -1; diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 8a98c03395..ad529dabb4 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -3472,6 +3472,7 @@ qemuProcessRestoreMigrationJob(virDomainObj *vm, op =3D VIR_DOMAIN_JOB_OPERATION_MIGRATION_OUT; allowedJobs =3D VIR_JOB_DEFAULT_MASK | JOB_MASK(VIR_JOB_MIGRATION_= OP); } + allowedJobs |=3D JOB_MASK(VIR_JOB_MIGRATION_SAFE); =20 qemuDomainObjRestoreAsyncJob(vm, job->asyncJob, job->phase, job->asyncStarted, op, @@ -3834,6 +3835,12 @@ qemuProcessRecoverJob(virQEMUDriver *driver, */ break; =20 + case VIR_JOB_MIGRATION_SAFE: + /* event handlers, the reconnection code already handles them as we + * might as well just missed the event while we were not running + */ + break; + case VIR_JOB_MIGRATION_OP: case VIR_JOB_ABORT: case VIR_JOB_ASYNC: --=20 2.35.1 From nobody Wed May 15 19:27:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1654088159; cv=none; d=zohomail.com; s=zohoarc; b=IJZsL4m1pNsenBxVSgDcA6dpk92W58/DBNednL1f/Mg2TooZNZ5YnKXMFwAVVCOdjDA9HrUAIHeevlp9I8UwQ9uvQ6gAxKg90jES0LSpgwVfalQpJhtYKZyTN/uw/vzggRu+6MI92wV5v4p8aDSygeV+1y+U1NJX0HyD9IItuhg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654088159; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=suWKxmX59DpwXp9idKfnSJq2BVVojI6tA4UM5owUPtk=; b=VLkUt0AMskURwJOxUMyExR07cF4ZJDlJpLuPOtKMDx1we9YVdJtBbo/sXCPqn8SjezwEOe4oIo2kjMJb/wtOqVkDofcNqHqpVGQ3VieAHkaDiitsblo0/T5J6+v5xsJKgxwDa3RNjmtBJqKNyMoyEp5v89wfG33+muNRWDjJGBM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1654088159252102.91122522824344; Wed, 1 Jun 2022 05:55:59 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-490-JaaKSjJnMvuVgZ1uVkaxxQ-1; Wed, 01 Jun 2022 08:55:55 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7980A80159B; Wed, 1 Jun 2022 12:55:53 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 210681415101; Wed, 1 Jun 2022 12:55:53 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id B9AEE1947079; Wed, 1 Jun 2022 12:55:52 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id DB9CF1947079 for ; Wed, 1 Jun 2022 12:55:51 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id CBD691121319; Wed, 1 Jun 2022 12:55:51 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.227]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AB9F51121315 for ; Wed, 1 Jun 2022 12:55:51 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id CAB75245BAA; Wed, 1 Jun 2022 14:50:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654088157; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=suWKxmX59DpwXp9idKfnSJq2BVVojI6tA4UM5owUPtk=; b=iZwnb4B7PjADIK0w/b5Fto855ysYc3WRrI2BPvsIXZCNWUHDPwdGiUwxy3yxdsiU3MTlxE 044iizTjR9HdKNJXs+gDya9cOwvWy1B0NtYOliMk5hftpvINI4tLmbb6cfVCKAR7dKU2mU 48nnBhuQqmSmwCQxWcN5F6kOzQTwx/Y= X-MC-Unique: JaaKSjJnMvuVgZ1uVkaxxQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH v2 80/81] qemu: Fix VSERPORT_CHANGE event in post-copy migration Date: Wed, 1 Jun 2022 14:50:20 +0200 Message-Id: <096c36389f965c2dc31765c9a1af2a5c8bfd6bbb.1654087150.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1654088160991100001 Content-Type: text/plain; charset="utf-8" When a domain has a guest agent channel enabled and the agent is running in the guest, we will get VSERPORT_CHANGE event on a destination host as soon as we start vCPUs there. This is not an issue for normal migration, but post-copy migration will remain running after we started vCPUs on the destination. If it runs for more than 30s, the VSERPORT_CHANGE event handler will fail to get a job and log the following error message: Timed out during operation: cannot acquire state change lock (held by monitor=3DremoteDispatchDomainMigrateFinish3Params) and of course we will think the guest agent is not connected and thus all APIs talking to it will fail. Until the agent or libvirt daemon is restarted. Luckily we only need to update the channel state (to mark it as connected) and connect to the agent neither of which conflicts with migration. Thus we can safely enable processing this event during migration. Signed-off-by: Jiri Denemark Reviewed-by: Peter Krempa --- Notes: Version 2: - new patch src/qemu/qemu_driver.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 01c4a8470a..637106f1b3 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -3993,7 +3993,7 @@ processSerialChangedEvent(virQEMUDriver *driver, memset(&dev, 0, sizeof(dev)); } =20 - if (qemuDomainObjBeginJob(driver, vm, VIR_JOB_MODIFY) < 0) + if (qemuDomainObjBeginJob(driver, vm, VIR_JOB_MIGRATION_SAFE) < 0) return; =20 if (!virDomainObjIsActive(vm)) { --=20 2.35.1 From nobody Wed May 15 19:27:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1654088162; cv=none; d=zohomail.com; s=zohoarc; b=OvRM6Nawo7xOfwJLmqIgTCYx15L27P+ho0WW7aHRC5rnGkbGQuTZDQros1yoDvnLVsNseDLbL88r1MRi4tHve2AN+CZSNt6TxTgY4LUUEnz4Zld+bWIeL1AiR5f/sBif9wKc7nPLxNFmGS30KqOnKo3QHT6OYuSBtI6ZJnMD8g4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654088162; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=+YN7ft/wBGWdtCOz7yOkOMDJ3FrzUxi2UwaQ6g2TRPU=; b=hETyhE7IGmIfNhInaKYpcvWqHaryn3H2Rf86J3/YWAbFSSOCq2jtFWjaXQzbM9SUNnv8B2bDQvoWvqEsQ+79QNAv3CsfbuYT1m8JzdQ3mWqYks8j3WNOxifnmugcTseIYu/1jK+paNGyrmhSfBG6pNUo4s3DNakBbU4s0OhZkyY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1654088162572579.8695767600773; Wed, 1 Jun 2022 05:56:02 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-73-VS1GDsmpPRW_kdvnm-V9MA-1; Wed, 01 Jun 2022 08:56:00 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1ECFE3802BBA; Wed, 1 Jun 2022 12:55:56 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0811C40CFD0A; Wed, 1 Jun 2022 12:55:56 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 3D1C5193F6F4; Wed, 1 Jun 2022 12:55:54 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 032A3194707B for ; Wed, 1 Jun 2022 12:55:52 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id ECF821121315; Wed, 1 Jun 2022 12:55:51 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.227]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AA25D1121314; Wed, 1 Jun 2022 12:55:51 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id CC226245BAB; Wed, 1 Jun 2022 14:50:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654088161; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=+YN7ft/wBGWdtCOz7yOkOMDJ3FrzUxi2UwaQ6g2TRPU=; b=T0EoBFkFp9gshIl+ohQjH6fZONhQhhlhaIBlKiVCvUjuD7kADsknPvFERrJx86nzwoqCYM 9rjKgHuvwSezcl3p9sHOZdFHeRVIit9Eb2ivbGZVndGtDxQOKgL5/kXj3XiU2HKt00C9kg mDI8SSsu9bx6EoHSeOJX+Nr7xaJA47E= X-MC-Unique: VS1GDsmpPRW_kdvnm-V9MA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH v2 81/81] RFC: qemu: Keep vCPUs paused while migration is in postcopy-paused Date: Wed, 1 Jun 2022 14:50:21 +0200 Message-Id: <3802648cbaafebaa9ca4b2932a660ac06c66b725.1654087150.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Xu Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1654088163031100005 Content-Type: text/plain; charset="utf-8" QEMU keeps guest CPUs running even in postcopy-paused migration state so that processes that already have all memory pages they need migrated to the destination can keep running. However, this behavior might bring unexpected delays in interprocess communication as some processes will be stopped until migration is recover and their memory pages migrated. So let's make sure all guest CPUs are paused while postcopy migration is paused. --- Notes: Version 2: - new patch - this patch does not currently work as QEMU cannot handle "stop" QMP command while in postcopy-paused state... the monitor just hangs (see https://gitlab.com/qemu-project/qemu/-/issues/1052 ) - an ideal solution of the QEMU bug would be if QEMU itself paused the CPUs for us and we just got notified about it via QMP events - but Peter Xu thinks this behavior is actually worse than keeping vCPUs running - so let's take this patch as a base for discussing what we should be doing with vCPUs in postcopy-paused migration state src/qemu/qemu_domain.c | 1 + src/qemu/qemu_domain.h | 1 + src/qemu/qemu_driver.c | 30 +++++++++++++++++++++++++ src/qemu/qemu_migration.c | 47 +++++++++++++++++++++++++++++++++++++++ src/qemu/qemu_migration.h | 6 +++++ src/qemu/qemu_process.c | 32 ++++++++++++++++++++++++++ 6 files changed, 117 insertions(+) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index d04ec6cd0c..dcd6d5e1b5 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -11115,6 +11115,7 @@ qemuProcessEventFree(struct qemuProcessEvent *event) break; case QEMU_PROCESS_EVENT_PR_DISCONNECT: case QEMU_PROCESS_EVENT_UNATTENDED_MIGRATION: + case QEMU_PROCESS_EVENT_MIGRATION_CPU_STATE: case QEMU_PROCESS_EVENT_LAST: break; } diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 153dfe3a23..f5cdb2235f 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -427,6 +427,7 @@ typedef enum { QEMU_PROCESS_EVENT_GUEST_CRASHLOADED, QEMU_PROCESS_EVENT_MEMORY_DEVICE_SIZE_CHANGE, QEMU_PROCESS_EVENT_UNATTENDED_MIGRATION, + QEMU_PROCESS_EVENT_MIGRATION_CPU_STATE, =20 QEMU_PROCESS_EVENT_LAST } qemuProcessEventType; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 637106f1b3..d0498ef2aa 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -4255,6 +4255,33 @@ processMemoryDeviceSizeChange(virQEMUDriver *driver, } =20 =20 +static void +processMigrationCPUState(virDomainObj *vm, + virDomainState state, + int reason) +{ + qemuDomainObjPrivate *priv =3D vm->privateData; + virQEMUDriver *driver =3D priv->driver; + + if (qemuDomainObjBeginJob(driver, vm, VIR_JOB_MIGRATION_SAFE) < 0) + return; + + if (!virDomainObjIsActive(vm)) { + VIR_DEBUG("Domain '%s' is not running", vm->def->name); + goto endjob; + } + + if (priv->job.asyncJob =3D=3D VIR_ASYNC_JOB_MIGRATION_IN && + virDomainObjIsPostcopy(vm, VIR_DOMAIN_JOB_OPERATION_MIGRATION_IN))= { + qemuMigrationUpdatePostcopyCPUState(vm, state, reason, + VIR_ASYNC_JOB_NONE); + } + + endjob: + qemuDomainObjEndJob(vm); +} + + static void qemuProcessEventHandler(void *data, void *opaque) { struct qemuProcessEvent *processEvent =3D data; @@ -4312,6 +4339,9 @@ static void qemuProcessEventHandler(void *data, void = *opaque) processEvent->action, processEvent->status); break; + case QEMU_PROCESS_EVENT_MIGRATION_CPU_STATE: + processMigrationCPUState(vm, processEvent->action, processEvent->s= tatus); + break; case QEMU_PROCESS_EVENT_LAST: break; } diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 0314fb1148..58d7009363 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -6831,6 +6831,53 @@ qemuMigrationProcessUnattended(virQEMUDriver *driver, } =20 =20 +void +qemuMigrationUpdatePostcopyCPUState(virDomainObj *vm, + virDomainState state, + int reason, + int asyncJob) +{ + virQEMUDriver *driver =3D QEMU_DOMAIN_PRIVATE(vm)->driver; + int current; + + if (state =3D=3D VIR_DOMAIN_PAUSED) { + VIR_DEBUG("Post-copy migration of domain '%s' was paused, stopping= guest CPUs", + vm->def->name); + } else { + VIR_DEBUG("Post-copy migration of domain '%s' was resumed, startin= g guest CPUs", + vm->def->name); + } + + if (virDomainObjGetState(vm, ¤t) =3D=3D state) { + int eventType =3D -1; + int eventDetail =3D -1; + + if (current =3D=3D reason) { + VIR_DEBUG("Guest CPUs are already in the right state"); + return; + } + + VIR_DEBUG("Fixing domain state reason"); + if (state =3D=3D VIR_DOMAIN_PAUSED) { + eventType =3D VIR_DOMAIN_EVENT_SUSPENDED; + eventDetail =3D qemuDomainPausedReasonToSuspendedEvent(reason); + } else { + eventType =3D VIR_DOMAIN_EVENT_RESUMED; + eventDetail =3D qemuDomainRunningReasonToResumeEvent(reason); + } + virDomainObjSetState(vm, state, reason); + qemuDomainSaveStatus(vm); + virObjectEventStateQueue(driver->domainEventState, + virDomainEventLifecycleNewFromObj(vm, eve= ntType, + eventDe= tail)); + } else if (state =3D=3D VIR_DOMAIN_PAUSED) { + qemuProcessStopCPUs(driver, vm, reason, asyncJob); + } else { + qemuProcessStartCPUs(driver, vm, reason, asyncJob); + } +} + + /* Helper function called while vm is active. */ int qemuMigrationSrcToFile(virQEMUDriver *driver, virDomainObj *vm, diff --git a/src/qemu/qemu_migration.h b/src/qemu/qemu_migration.h index fbc0549b34..a1e2d8d171 100644 --- a/src/qemu/qemu_migration.h +++ b/src/qemu/qemu_migration.h @@ -224,6 +224,12 @@ qemuMigrationProcessUnattended(virQEMUDriver *driver, virDomainAsyncJob job, qemuMonitorMigrationStatus status); =20 +void +qemuMigrationUpdatePostcopyCPUState(virDomainObj *vm, + virDomainState state, + int reason, + int asyncJob); + bool qemuMigrationSrcIsAllowed(virQEMUDriver *driver, virDomainObj *vm, diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index ad529dabb4..7fff68c0db 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -1521,6 +1521,10 @@ qemuProcessHandleMigrationStatus(qemuMonitor *mon G_= GNUC_UNUSED, * Thus we need to handle the event here. */ qemuMigrationSrcPostcopyFailed(vm); qemuDomainSaveStatus(vm); + } else if (priv->job.asyncJob =3D=3D VIR_ASYNC_JOB_MIGRATION_IN) { + qemuProcessEventSubmit(vm, QEMU_PROCESS_EVENT_MIGRATION_CPU_ST= ATE, + VIR_DOMAIN_PAUSED, + VIR_DOMAIN_PAUSED_POSTCOPY_FAILED, NULL= ); } break; =20 @@ -1547,6 +1551,12 @@ qemuProcessHandleMigrationStatus(qemuMonitor *mon G_= GNUC_UNUSED, event =3D virDomainEventLifecycleNewFromObj(vm, eventType, eve= ntDetail); qemuDomainSaveStatus(vm); } + + if (priv->job.asyncJob =3D=3D VIR_ASYNC_JOB_MIGRATION_IN) { + qemuProcessEventSubmit(vm, QEMU_PROCESS_EVENT_MIGRATION_CPU_ST= ATE, + VIR_DOMAIN_RUNNING, + VIR_DOMAIN_RUNNING_POSTCOPY, NULL); + } break; =20 case QEMU_MONITOR_MIGRATION_STATUS_COMPLETED: @@ -3703,10 +3713,32 @@ qemuProcessRecoverMigration(virQEMUDriver *driver, if (migStatus =3D=3D VIR_DOMAIN_JOB_STATUS_POSTCOPY) { VIR_DEBUG("Post-copy migration of domain %s still running, it = will be handled as unattended", vm->def->name); + + if (job->asyncJob =3D=3D VIR_ASYNC_JOB_MIGRATION_IN && + state =3D=3D VIR_DOMAIN_PAUSED) { + qemuMigrationUpdatePostcopyCPUState(vm, VIR_DOMAIN_RUNNING, + VIR_DOMAIN_RUNNING_POS= TCOPY, + VIR_ASYNC_JOB_NONE); + } else { + if (state =3D=3D VIR_DOMAIN_RUNNING) + reason =3D VIR_DOMAIN_RUNNING_POSTCOPY; + else + reason =3D VIR_DOMAIN_PAUSED_POSTCOPY; + + virDomainObjSetState(vm, state, reason); + } + qemuProcessRestoreMigrationJob(vm, job); return 0; } =20 + if (job->asyncJob =3D=3D VIR_ASYNC_JOB_MIGRATION_IN && + migStatus =3D=3D VIR_DOMAIN_JOB_STATUS_POSTCOPY_PAUSED) { + qemuMigrationUpdatePostcopyCPUState(vm, VIR_DOMAIN_PAUSED, + VIR_DOMAIN_PAUSED_POSTCOPY, + VIR_ASYNC_JOB_NONE); + } + if (migStatus !=3D VIR_DOMAIN_JOB_STATUS_HYPERVISOR_COMPLETED) { if (job->asyncJob =3D=3D VIR_ASYNC_JOB_MIGRATION_OUT) qemuMigrationSrcPostcopyFailed(vm); --=20 2.35.1