From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id B1B041FF187 for ; Tue, 18 Nov 2025 13:21:06 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 0B5E412B37; Tue, 18 Nov 2025 13:21:11 +0100 (CET) From: Hannes Laimer To: pdm-devel@lists.proxmox.com Date: Tue, 18 Nov 2025 13:21:05 +0100 Message-ID: <20251118122105.119918-3-h.laimer@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251118122105.119918-1-h.laimer@proxmox.com> References: <20251118122105.119918-1-h.laimer@proxmox.com> MIME-Version: 1.0 X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1763468437565 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.048 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 URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [lib.rs, lxc.rs, qemu.rs] Subject: [pdm-devel] [PATCH datacenter-manager 2/2] api: migrate: use arrays for storage and bridge mappings X-BeenThere: pdm-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Datacenter Manager development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox Datacenter Manager development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pdm-devel-bounces@lists.proxmox.com Sender: "pdm-devel" With [1] we generate actual arrays for string-lists, so the generated functions we use for migration take these types containing Vec's instead of Strings. This updates the PDM migrate endpoints to accept arrays so they can be passed to the functions. This also updates the strigify function used by the UI to create those mapping strings. Now, instead of a single string it produces a list of mapping strings. [1] bd8eca6 ("pve-api-types: schema2rust: generate arrays for types with format `-list`") Signed-off-by: Hannes Laimer --- lib/pdm-client/src/lib.rs | 31 +++++++++++++------------------ server/src/api/pve/lxc.rs | 27 +++++++++++++++++++++------ server/src/api/pve/qemu.rs | 27 +++++++++++++++++++++------ 3 files changed, 55 insertions(+), 30 deletions(-) diff --git a/lib/pdm-client/src/lib.rs b/lib/pdm-client/src/lib.rs index df2ebe0..642a6c1 100644 --- a/lib/pdm-client/src/lib.rs +++ b/lib/pdm-client/src/lib.rs @@ -1395,32 +1395,27 @@ where return serializer.serialize_none(); } - let mut output = String::new(); + let mut list = Vec::with_capacity(mapping.len()); + if mapping.len() == 1 { let (key, value) = mapping.iter().next().unwrap(); - // special case 1: '* = *' => identity mapping if key == "*" && value == "*" { - return serializer.serialize_str("1"); - } - - // special case 2: '* = ' => single value of ) - return serializer.serialize_str(value); - } - - for (from, to) in mapping.iter() { - if !output.is_empty() { - output.reserve(from.len() + to.len() + 2); - output.push(','); + // special case 1: '* = *' => identity mapping + list.push("1".to_string()); + } else if key == "*" { + // special case 2: '* = ' => single value of + list.push(value.clone()); } else { - output.reserve(from.len() + to.len() + 1); + list.push(format!("{key}:{value}")); + } + } else { + for (from, to) in mapping.iter() { + list.push(format!("{from}:{to}")); } - output.push_str(from); - output.push(':'); - output.push_str(to); } - serializer.serialize_str(&output) + list.serialize(serializer) } #[derive(Serialize)] diff --git a/server/src/api/pve/lxc.rs b/server/src/api/pve/lxc.rs index 1ef936d..ecf0bef 100644 --- a/server/src/api/pve/lxc.rs +++ b/server/src/api/pve/lxc.rs @@ -301,8 +301,13 @@ pub async fn lxc_shutdown( optional: true, }, "target-storage": { - description: "Mapping of source storages to target storages.", + description: "List of storage mappings", optional: true, + items: { + description: "Mappings of source storages to target storages.", + type: String, + }, + type: Array, }, bwlimit: { description: "Override I/O bandwidth limit (in KiB/s).", @@ -331,7 +336,7 @@ pub async fn lxc_migrate( restart: Option, online: Option, target: String, - target_storage: Option, + target_storage: Option>, timeout: Option, ) -> Result { let bwlimit = bwlimit.map(|n| n as f64); @@ -386,10 +391,20 @@ pub async fn lxc_migrate( default: false, }, "target-storage": { - description: "Mapping of source storages to target storages.", + description: "List of storage mappings", + items: { + description: "Mappings of source storages to target storages.", + type: String, + }, + type: Array, }, "target-bridge": { - description: "Mapping of source bridges to remote bridges.", + description: "List of bridge mappings", + items: { + description: "Mappings of source bridges to remote bridges.", + type: String, + }, + type: Array, }, bwlimit: { description: "Override I/O bandwidth limit (in KiB/s).", @@ -428,8 +443,8 @@ pub async fn lxc_remote_migrate( target_vmid: Option, delete: bool, online: bool, - target_storage: String, - target_bridge: String, + target_storage: Vec, + target_bridge: Vec, bwlimit: Option, restart: Option, timeout: Option, diff --git a/server/src/api/pve/qemu.rs b/server/src/api/pve/qemu.rs index 5e66a48..4f144b7 100644 --- a/server/src/api/pve/qemu.rs +++ b/server/src/api/pve/qemu.rs @@ -303,8 +303,13 @@ pub async fn qemu_shutdown( optional: true, }, "target-storage": { - description: "Mapping of source storages to target storages.", + description: "List of storage mappings", optional: true, + items: { + description: "Mappings of source storages to target storages.", + type: String, + }, + type: Array, }, bwlimit: { description: "Override I/O bandwidth limit (in KiB/s).", @@ -350,7 +355,7 @@ pub async fn qemu_migrate( migration_type: Option, online: Option, target: String, - target_storage: Option, + target_storage: Option>, with_local_disks: Option, ) -> Result { log::info!("in-cluster migration requested for remote {remote:?} vm {vmid} to node {target:?}"); @@ -443,10 +448,20 @@ async fn qemu_migrate_preconditions( default: false, }, "target-storage": { - description: "Mapping of source storages to target storages.", + description: "List of storage mappings", + items: { + description: "Mappings of source storages to target storages.", + type: String, + }, + type: Array, }, "target-bridge": { - description: "Mapping of source bridges to remote bridges.", + description: "List of bridge mappings", + items: { + description: "Mappings of source bridges to remote bridges.", + type: String, + }, + type: Array, }, bwlimit: { description: "Override I/O bandwidth limit (in KiB/s).", @@ -477,8 +492,8 @@ pub async fn qemu_remote_migrate( target_vmid: Option, delete: bool, online: bool, - target_storage: String, - target_bridge: String, + target_storage: Vec, + target_bridge: Vec, bwlimit: Option, target_endpoint: Option, rpcenv: &mut dyn RpcEnvironment, -- 2.47.3 _______________________________________________ pdm-devel mailing list pdm-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel