From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id EBE2898AAC for ; Wed, 26 Apr 2023 15:15:17 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 5ECDA1ECA8 for ; Wed, 26 Apr 2023 15:14:47 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Wed, 26 Apr 2023 15:14:45 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 945F745799 for ; Wed, 26 Apr 2023 15:14:39 +0200 (CEST) Date: Wed, 26 Apr 2023 15:14:31 +0200 From: Fabian =?iso-8859-1?q?Gr=FCnbichler?= To: Proxmox VE development discussion References: <20230425165233.3745210-1-aderumier@odiso.com> <20230425165233.3745210-3-aderumier@odiso.com> In-Reply-To: <20230425165233.3745210-3-aderumier@odiso.com> MIME-Version: 1.0 User-Agent: astroid/0.16.0 (https://github.com/astroidmail/astroid) Message-Id: <1682514292.71raew01tr.astroid@yuna.none> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-SPAM-LEVEL: Spam detection results: 0 AWL 0.076 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record T_SCC_BODY_TEXT_LINE -0.01 - URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [qemumigrate.pm, qm.pm, qemu.pm, proxmox.com] Subject: Re: [pve-devel] [PATCH v2 qemu-server 2/2] remote-migration: add target-cpu param X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 26 Apr 2023 13:15:18 -0000 On April 25, 2023 6:52 pm, Alexandre Derumier wrote: > This patch add support for remote migration when target > cpu model is different. >=20 > The target vm is restart after the migration so this effectively introduces a new "hybrid" migration mode ;) the changes are a bit smaller than I expected (in part thanks to patch #1), which is good. there are semi-frequent requests for another variant (also applicable to containers) in the form of a two phase migration - storage migrate - stop guest - incremental storage migrate - start guest on target given that it might make sense to save-guard this implementation here, and maybe switch to a new "mode" parameter? online =3D> switching CPU not allowed offline or however-we-call-this-new-mode (or in the future, two-phase-resta= rt) =3D> switching CPU allowed >=20 > Signed-off-by: Alexandre Derumier > --- > PVE/API2/Qemu.pm | 18 ++++++++++++++++++ > PVE/CLI/qm.pm | 6 ++++++ > PVE/QemuMigrate.pm | 25 +++++++++++++++++++++++++ > 3 files changed, 49 insertions(+) >=20 > diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm > index 587bb22..6703c87 100644 > --- a/PVE/API2/Qemu.pm > +++ b/PVE/API2/Qemu.pm > @@ -4460,6 +4460,12 @@ __PACKAGE__->register_method({ > optional =3D> 1, > default =3D> 0, > }, > + 'target-cpu' =3D> { > + optional =3D> 1, > + description =3D> "Target Emulated CPU model. For online migration, the= storage is live migrate, but the memory migration is skipped and the targe= t vm is restarted.", > + type =3D> 'string', > + format =3D> 'pve-vm-cpu-conf', > + }, > 'target-storage' =3D> get_standard_option('pve-targetstorage', { > completion =3D> \&PVE::QemuServer::complete_migration_storage, > optional =3D> 0, > @@ -4557,11 +4563,14 @@ __PACKAGE__->register_method({ > raise_param_exc({ 'target-bridge' =3D> "failed to parse bridge map: $@"= }) > if $@; > =20 > + my $target_cpu =3D extract_param($param, 'target-cpu'); this is okay > + > die "remote migration requires explicit storage mapping!\n" > if $storagemap->{identity}; > =20 > $param->{storagemap} =3D $storagemap; > $param->{bridgemap} =3D $bridgemap; > + $param->{targetcpu} =3D $target_cpu; but this is a bit confusing with the variable/hash key naming ;) > $param->{remote} =3D { > conn =3D> $conn_args, # re-use fingerprint for tunnel > client =3D> $api_client, > @@ -5604,6 +5613,15 @@ __PACKAGE__->register_method({ > PVE::QemuServer::nbd_stop($state->{vmid}); > return; > }, > + 'restart' =3D> sub { > + PVE::QemuServer::vm_stop(undef, $state->{vmid}, 1, 1); > + my $info =3D PVE::QemuServer::vm_start_nolock( > + $state->{storecfg}, > + $state->{vmid}, > + $state->{conf}, > + ); > + return; > + }, > 'resume' =3D> sub { > if (PVE::QemuServer::Helpers::vm_running_locally($state->{vmid})) = { > PVE::QemuServer::vm_resume($state->{vmid}, 1, 1); > diff --git a/PVE/CLI/qm.pm b/PVE/CLI/qm.pm > index c3c2982..06c74c1 100755 > --- a/PVE/CLI/qm.pm > +++ b/PVE/CLI/qm.pm > @@ -189,6 +189,12 @@ __PACKAGE__->register_method({ > optional =3D> 1, > default =3D> 0, > }, > + 'target-cpu' =3D> { > + optional =3D> 1, > + description =3D> "Target Emulated CPU model. For online migration, the= storage is live migrate, but the memory migration is skipped and the targe= t vm is restarted.", > + type =3D> 'string', > + format =3D> 'pve-vm-cpu-conf', > + }, > 'target-storage' =3D> get_standard_option('pve-targetstorage', { > completion =3D> \&PVE::QemuServer::complete_migration_storage, > optional =3D> 0, > diff --git a/PVE/QemuMigrate.pm b/PVE/QemuMigrate.pm > index e182415..04f8053 100644 > --- a/PVE/QemuMigrate.pm > +++ b/PVE/QemuMigrate.pm > @@ -731,6 +731,11 @@ sub cleanup_bitmaps { > sub live_migration { > my ($self, $vmid, $migrate_uri, $spice_port) =3D @_; > =20 > + if($self->{opts}->{targetcpu}){ > + $self->log('info', "target cpu is different - skip live migratio= n."); > + return; > + } > + > my $conf =3D $self->{vmconf}; > =20 > $self->log('info', "starting online/live migration on $migrate_uri")= ; > @@ -995,6 +1000,7 @@ sub phase1_remote { > my $remote_conf =3D PVE::QemuConfig->load_config($vmid); > PVE::QemuConfig->update_volume_ids($remote_conf, $self->{volume_map}= ); > =20 > + $remote_conf->{cpu} =3D $self->{opts}->{targetcpu}; do we need permission checks here (or better, somewhere early on, for doing= this here) > my $bridges =3D map_bridges($remote_conf, $self->{opts}->{bridgemap}= ); > for my $target (keys $bridges->%*) { > for my $nic (keys $bridges->{$target}->%*) { > @@ -1354,6 +1360,21 @@ sub phase2 { > live_migration($self, $vmid, $migrate_uri, $spice_port); > =20 > if ($self->{storage_migration}) { > + > + #freeze source vm io/s if target cpu is different (no livemigrat= ion) > + if ($self->{opts}->{targetcpu}) { > + my $agent_running =3D $self->{conf}->{agent} && PVE::QemuServer::qg= a_check_running($vmid); > + if ($agent_running) { > + print "freeze filesystem\n"; > + eval { mon_cmd($vmid, "guest-fsfreeze-freeze"); }; > + die $@ if $@; die here > + } else { > + print "suspend vm\n"; > + eval { PVE::QemuServer::vm_suspend($vmid, 1); }; > + warn $@ if $@; but warn here? I'd like some more rationale for these two variants, what are the pros and cons? should we make it configurable? > + } > + } > + > # finish block-job with block-job-cancel, to disconnect source VM from = NBD > # to avoid it trying to re-establish it. We are in blockjob ready state= , > # thus, this command changes to it to blockjob complete (see qapi docs) > @@ -1608,6 +1629,10 @@ sub phase3_cleanup { > # clear migrate lock > if ($tunnel && $tunnel->{version} >=3D 2) { > PVE::Tunnel::write_tunnel($tunnel, 10, "unlock"); > + if ($self->{opts}->{targetcpu}) { > + $self->log('info', "target cpu is different - restart target vm."); > + PVE::Tunnel::write_tunnel($tunnel, 10, 'restart'); > + } > =20 > PVE::Tunnel::finish_tunnel($tunnel); > } else { > --=20 > 2.30.2 >=20 >=20 > _______________________________________________ > pve-devel mailing list > pve-devel@lists.proxmox.com > https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel >=20 >=20 >=20