all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Fiona Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH container v2 12/14] pct: introduce mtunnel command
Date: Wed, 25 Feb 2026 16:18:35 +0100	[thread overview]
Message-ID: <20260225151931.176335-13-f.ebner@proxmox.com> (raw)
In-Reply-To: <20260225151931.176335-1-f.ebner@proxmox.com>

Similar to what we already have in qemu-server. There is a 'config'
command used for checking that the configuration can be understood by
the migration target.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---

New in v2.

 src/PVE/CLI/pct.pm | 57 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 57 insertions(+)

diff --git a/src/PVE/CLI/pct.pm b/src/PVE/CLI/pct.pm
index df8f4c3..74dfc92 100755
--- a/src/PVE/CLI/pct.pm
+++ b/src/PVE/CLI/pct.pm
@@ -12,6 +12,7 @@ use PVE::CLIHandler;
 use PVE::Cluster;
 use PVE::CpuSet;
 use PVE::Exception qw(raise_param_exc);
+use PVE::File;
 use PVE::GuestHelpers;
 use PVE::INotify;
 use PVE::JSONSchema qw(get_standard_option);
@@ -1051,6 +1052,60 @@ __PACKAGE__->register_method({
     },
 });
 
+__PACKAGE__->register_method({
+    name => 'mtunnel',
+    path => 'mtunnel',
+    method => 'POST',
+    description => "For internal use by intra-cluster migration only.",
+    parameters => {
+        additionalProperties => 0,
+        properties => {},
+    },
+    returns => { type => 'null' },
+    code => sub {
+        my ($param) = @_;
+
+        if (!PVE::Cluster::check_cfs_quorum(1)) {
+            print "no quorum\n";
+            return;
+        }
+
+        my $tunnel_write = sub {
+            my $text = shift;
+            chomp $text;
+            print "$text\n";
+            *STDOUT->flush();
+        };
+
+        $tunnel_write->("tunnel online");
+        $tunnel_write->("ver 1");
+
+        while (my $line = <STDIN>) {
+            chomp $line;
+            if ($line =~ /^quit$/) {
+                $tunnel_write->("OK");
+                last;
+            } elsif ($line =~ /^config (\d+) (\S+)$/) {
+                my ($vmid, $node) = ($1, $2);
+                eval {
+                    my $conf_fn = PVE::LXC::Config->config_file($vmid, $node);
+                    my $raw = PVE::File::file_get_contents($conf_fn);
+                    PVE::LXC::Config::parse_pct_config($conf_fn, $raw, 1);
+                };
+                if (my $err = $@) {
+                    $tunnel_write->("ERR: strict config check for target node failed - $err");
+                } else {
+                    $tunnel_write->("OK");
+                }
+            } else {
+                $tunnel_write->("ERR: unknown command '$line'");
+            }
+        }
+
+        return;
+    },
+});
+
 our $cmddef = {
     list => [
         'PVE::API2::LXC',
@@ -1191,6 +1246,8 @@ our $cmddef = {
     rescan => [__PACKAGE__, 'rescan', []],
     cpusets => [__PACKAGE__, 'cpusets', []],
     fstrim => [__PACKAGE__, 'fstrim', ['vmid']],
+
+    mtunnel => [__PACKAGE__, 'mtunnel', []],
 };
 
 1;
-- 
2.47.3





  parent reply	other threads:[~2026-02-25 15:19 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-25 15:18 [PATCH-SERIES qemu-server/guest-common/container v2 00/14] migration: strict config check for intra-cluster migration Fiona Ebner
2026-02-25 15:18 ` [PATCH qemu-server v2 01/14] d/control: bump versioned build dependency for libpve-common-perl to 9.0.12 Fiona Ebner
2026-02-25 15:18 ` [PATCH qemu-server v2 02/14] tests: migration: get rid of mocking for removed PVE::QemuMigrate::read_tunnel() Fiona Ebner
2026-02-25 15:18 ` [PATCH qemu-server v2 03/14] qm: mtunnel: avoid using deprecated check_running() helper Fiona Ebner
2026-02-25 15:18 ` [PATCH qemu-server v2 04/14] mtunnel: add 'conf' command to do strict configuration parsing Fiona Ebner
2026-02-25 15:18 ` [PATCH qemu-server v2 05/14] qm: mtunnel: reply when a command is unknown Fiona Ebner
2026-02-25 15:18 ` [PATCH qemu-server v2 06/14] migration: intra-cluster: check config can be parsed on target node Fiona Ebner
2026-02-25 15:18 ` [PATCH guest-common v2 07/14] tunnel: add missing IO::File module import Fiona Ebner
2026-02-25 15:18 ` [PATCH guest-common v2 08/14] tunnel: end module with true value as recommended by perlcritic Fiona Ebner
2026-02-25 15:18 ` [PATCH guest-common v2 09/14] tunnel: redirect stderr to log function Fiona Ebner
2026-02-25 15:18 ` [PATCH container v2 10/14] pct: add missing module imports and group according to style guide Fiona Ebner
2026-02-25 15:18 ` [PATCH container v2 11/14] migrate: add missing module imports Fiona Ebner
2026-02-25 15:18 ` Fiona Ebner [this message]
2026-02-25 15:18 ` [PATCH container v2 13/14] d/control: bump versioned build dependency for libpve-common-perl to 9.0.12 Fiona Ebner
2026-02-25 15:18 ` [PATCH container v2 14/14] migration: intra-cluster: check config can be parsed on target node Fiona Ebner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260225151931.176335-13-f.ebner@proxmox.com \
    --to=f.ebner@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal