Adds a new checkbox to the migration dialog, if it is a live/online-migration and both the source and target nodes have support for our dbus-vmstate helper.
If the checkbox is active, it passes along the `with-conntrack-state` parameter to the migrate API call. Signed-off-by: Christoph Heiss <c.he...@proxmox.com> --- www/manager6/window/Migrate.js | 73 ++++++++++++++++++++++++++++++++-- 1 file changed, 69 insertions(+), 4 deletions(-) diff --git a/www/manager6/window/Migrate.js b/www/manager6/window/Migrate.js index 78d03921e..e8a68eed9 100644 --- a/www/manager6/window/Migrate.js +++ b/www/manager6/window/Migrate.js @@ -28,8 +28,9 @@ Ext.define('PVE.window.Migrate', { allowedNodes: undefined, overwriteLocalResourceCheck: false, hasLocalResources: false, + withConntrackState: true, + bothHaveDbusVmstate: false, }, - }, formulas: { @@ -59,6 +60,9 @@ Ext.define('PVE.window.Migrate', { return false; } }, + conntrackStateCheckboxHidden: get => + !get('running') || get('vmtype') !== 'qemu' || + !get('migration.bothHaveDbusVmstate'), }, }, @@ -133,6 +137,10 @@ Ext.define('PVE.window.Migrate', { params.force = 1; } + if (vm.get('migration.bothHaveDbusVmstate') && vm.get('migration.withConntrackState')) { + params['with-conntrack-state'] = 1; + } + Proxmox.Utils.API2Request({ params: params, url: '/nodes/' + vm.get('nodename') + '/' + vm.get('vmtype') + '/' + vm.get('vmid') + '/migrate', @@ -199,12 +207,28 @@ Ext.define('PVE.window.Migrate', { method: 'GET', }); migrateStats = result.data; - me.fetchingNodeMigrateInfo = false; } catch (error) { Ext.Msg.alert(gettext('Error'), error.htmlStatus); + me.fetchingNodeMigrateInfo = false; return; } + const target = me.lookup('pveNodeSelector').value; + let targetCapabilities = {}; + + try { + const { result } = await Proxmox.Async.api2({ + url: `/nodes/${target}/capabilities/qemu/migration`, + method: 'GET', + }); + targetCapabilities = result.data; + } catch (err) { + // In the case the target node does not (yet) support the + // `capabilites/qemu/migration` endpoint, just ignore it. + } + + me.fetchingNodeMigrateInfo = false; + if (migrateStats.running) { vm.set('running', true); } @@ -217,7 +241,6 @@ Ext.define('PVE.window.Migrate', { if (migrateStats.allowed_nodes) { migration.allowedNodes = migrateStats.allowed_nodes; - let target = me.lookup('pveNodeSelector').value; if (target.length && !migrateStats.allowed_nodes.includes(target)) { let disallowed = migrateStats.not_allowed_nodes[target] ?? {}; if (disallowed.unavailable_storages !== undefined) { @@ -303,6 +326,29 @@ Ext.define('PVE.window.Migrate', { }); } + migration.bothHaveDbusVmstate = migrateStats['has-dbus-vmstate'] && targetCapabilities['has-dbus-vmstate']; + if (vm.get('running')) { + if (migration.withConntrackState && !migrateStats['has-dbus-vmstate']) { + migration.preconditions.push({ + text: gettext('Cannot migrate conntrack state, source node is lacking support. Active network connections might get dropped.'), + severity: 'warning', + }); + } + if (migration.withConntrackState && !targetCapabilities['has-dbus-vmstate']) { + migration.preconditions.push({ + text: gettext('Cannot migrate conntrack state, target node is lacking support. Active network connections might get dropped.'), + severity: 'warning', + }); + } + + if (migration.bothHaveDbusVmstate && !migration.withConntrackState) { + migration.preconditions.push({ + text: gettext('Conntrack state migration disabled. Active network connections might get dropped.'), + severity: 'warning', + }); + } + } + vm.set('migration', migration); }, checkLxcPreconditions: function(resetMigrationPossible) { @@ -394,7 +440,26 @@ Ext.define('PVE.window.Migrate', { extraArg: true, }, }, - }], + }, + { + xtype: 'proxmoxcheckbox', + name: 'withConntrackState', + fieldLabel: gettext('Conntrack state'), + autoEl: { + tag: 'div', + 'data-qtip': gettext('Enables live migration of conntrack entries for this VM.'), + }, + bind: { + hidden: '{conntrackStateCheckboxHidden}', + value: '{migration.withConntrackState}', + }, + listeners: { + change: { + fn: 'checkMigratePreconditions', + extraArg: true, + }, + }, + }], }, ], }, -- 2.48.1 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel