From nobody Fri Apr 26 05:57:43 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1541199655410130.9556615150184; Fri, 2 Nov 2018 16:00:55 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B286ACA1DD; Fri, 2 Nov 2018 23:00:51 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 97FFE1054FD9; Fri, 2 Nov 2018 23:00:50 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id F018E4BB79; Fri, 2 Nov 2018 23:00:46 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id wA2MYKSB008365 for ; Fri, 2 Nov 2018 18:34:20 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1CA6B5DA62; Fri, 2 Nov 2018 22:34:20 +0000 (UTC) Received: from mx1.redhat.com (ext-mx14.extmail.prod.ext.phx2.redhat.com [10.5.110.43]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1438A4F9D7 for ; Fri, 2 Nov 2018 22:34:14 +0000 (UTC) Received: from smtp2.provo.novell.com (smtp2.provo.novell.com [137.65.250.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5B892308FB8B for ; Fri, 2 Nov 2018 22:34:13 +0000 (UTC) Received: from linux-tbji.provo.novell.com (prv-ext-foundry1int.gns.novell.com [137.65.251.240]) by smtp2.provo.novell.com with ESMTP (NOT encrypted); Fri, 02 Nov 2018 16:34:11 -0600 From: Jim Fehlig To: libvir-list@redhat.com Date: Fri, 2 Nov 2018 16:34:02 -0600 Message-Id: <20181102223402.13931-1-jfehlig@suse.com> X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 216 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Fri, 02 Nov 2018 22:34:13 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Fri, 02 Nov 2018 22:34:13 +0000 (UTC) for IP:'137.65.250.81' DOMAIN:'smtp2.provo.novell.com' HELO:'smtp2.provo.novell.com' FROM:'jfehlig@suse.com' RCPT:'' X-RedHat-Spam-Score: -2.301 (RCVD_IN_DNSWL_MED, SPF_PASS) 137.65.250.81 smtp2.provo.novell.com 137.65.250.81 smtp2.provo.novell.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.43 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [RFC PATCH] Add new migration flag VIR_MIGRATE_DRY_RUN X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Fri, 02 Nov 2018 23:00:53 +0000 (UTC) Content-Type: text/plain; charset="utf-8" A dry run can be used as a best-effort check that a migration command will succeed. The destination host will be checked to see if it can accommodate the resources required by the domain. DRY_RUN will fail if the destination host is not capable of running the domain. Although a subsequent migration will likely succeed, the success of DRY_RUN does not ensure a future migration will succeed. Resources on the destination host could become unavailable between a DRY_RUN and actual migration. Signed-off-by: Jim Fehlig --- If it is agreed this is useful, my thought was to use the begin and prepare phases of migration to implement it. qemuMigrationDstPrepareAny() already does a lot of the heavy lifting wrt checking the host can accommodate the domain. Some of it, and the remaining migration phases, can be short-circuited in the case of dry run. One interesting wrinkle I've observed is the check for cpu compatibility. AFAICT qemu is actually invoked on the dst, "filtered-features" of the cpu are requested via qmp, and results are checked against cpu in domain config. If cpu on dst is insufficient, migration fails in the prepare phase with something like "guest CPU doesn't match specification: missing features: z = y z". I was hoping to avoid launching qemu in the case of dry run, but that may be unavoidable if we'd like a dependable dry run result. Thanks for considering the idea! (BTW, if it is considered useful I will follow up with a V1 series that includes this patch and and impl for the qemu driver.) include/libvirt/libvirt-domain.h | 12 ++++++++++++ src/qemu/qemu_migration.h | 3 ++- tools/virsh-domain.c | 7 +++++++ tools/virsh.pod | 10 +++++++++- 4 files changed, 30 insertions(+), 2 deletions(-) diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-dom= ain.h index fdd2d6b8ea..6d52f6ce50 100644 --- a/include/libvirt/libvirt-domain.h +++ b/include/libvirt/libvirt-domain.h @@ -830,6 +830,18 @@ typedef enum { */ VIR_MIGRATE_TLS =3D (1 << 16), =20 + /* Setting the VIR_MIGRATE_DRY_RUN flag will cause libvirt to make a + * best-effort attempt to check if migration will succeed. The destina= tion + * host will be checked to see if it can accommodate the resources req= uired + * by the domain. For example are the network, disk, memory, and CPU + * resources used by the domain on the source host also available on t= he + * destination host. The dry run will fail if libvirt determines the + * destination host is not capable of running the domain. Although a + * subsequent migration will likely succeed, the success of dry run do= es + * not ensure a future migration will succeed. Resources on the destin= ation + * host could become unavailable between a dry run and actual migratio= n. + */ + VIR_MIGRATE_DRY_RUN =3D (1 << 16), } virDomainMigrateFlags; =20 =20 diff --git a/src/qemu/qemu_migration.h b/src/qemu/qemu_migration.h index e12b6972db..b0e2bc689b 100644 --- a/src/qemu/qemu_migration.h +++ b/src/qemu/qemu_migration.h @@ -57,7 +57,8 @@ VIR_MIGRATE_AUTO_CONVERGE | \ VIR_MIGRATE_RDMA_PIN_ALL | \ VIR_MIGRATE_POSTCOPY | \ - VIR_MIGRATE_TLS) + VIR_MIGRATE_TLS | \ + VIR_MIGRATE_DRY_RUN) =20 /* All supported migration parameters and their types. */ # define QEMU_MIGRATION_PARAMETERS \ diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 372bdb95d3..46f0f44917 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -10450,6 +10450,10 @@ static const vshCmdOptDef opts_migrate[] =3D { .type =3D VSH_OT_BOOL, .help =3D N_("use TLS for migration") }, + {.name =3D "dry-run", + .type =3D VSH_OT_BOOL, + .help =3D N_("check if migration will succeed without actually perfor= ming the migration") + }, {.name =3D NULL} }; =20 @@ -10694,6 +10698,9 @@ doMigrate(void *opaque) if (vshCommandOptBool(cmd, "tls")) flags |=3D VIR_MIGRATE_TLS; =20 + if (vshCommandOptBool(cmd, "dry-run")) + flags |=3D VIR_MIGRATE_DRY_RUN; + if (flags & VIR_MIGRATE_PEER2PEER || vshCommandOptBool(cmd, "direct"))= { if (virDomainMigrateToURI3(dom, desturi, params, nparams, flags) = =3D=3D 0) ret =3D '0'; diff --git a/tools/virsh.pod b/tools/virsh.pod index 86c041d575..715fa3887f 100644 --- a/tools/virsh.pod +++ b/tools/virsh.pod @@ -1845,7 +1845,7 @@ I I [I] [I]= [I] [I] [I<--comp-methods> B] [I<--comp-mt-level>] [I<--comp-mt-threads>] [I<--comp-mt-dthreads>] [I<--comp-xbzrle-cache>] [I<--auto-converge>] [I] -[I] [I<--persistent-xml> B] [I<--tls>] +[I] [I<--persistent-xml> B] [I<--tls>] [I<-= -dry-run>] =20 Migrate domain to another host. Add I<--live> for live migration; <--p2p> for peer-2-peer migration; I<--direct> for direct migration; or I<--tunnel= led> @@ -1937,6 +1937,14 @@ Providing I<--tls> causes the migration to use the h= ost configured TLS setup the migration of the domain. Usage requires proper TLS setup for both sour= ce and target. =20 +I<--dry-run> can be used as a best-effort check that the migration command +will succeed. The destination host will be checked to see if it can +accommodate the resources required by the domain. I<--dry-run> will fail if +the destination host is not capable of running the domain. Although a +subsequent migration will likely succeed, the success of dry run does not +ensure a future migration will succeed. Resources on the destination host +could become unavailable between a dry run and actual migration. + Running migration can be canceled by interrupting virsh (usually using C) or by B command sent from another virsh instance. =20 --=20 2.18.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list