This is an automated email from the ASF dual-hosted git repository. pearl11594 pushed a commit to branch allow-emoji-volume-name-xen in repository https://gitbox.apache.org/repos/asf/cloudstack.git
commit 42b70e77bcdd59de681523ece5e4b7bf3b862daf Author: Pearl Dsilva <pearl1...@gmail.com> AuthorDate: Thu Apr 24 18:06:51 2025 +0530 Allow emojis to be accepted in volume name during volume creation --- .../xenserver/resource/XenServerStorageProcessor.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/plugins/hypervisors/xenserver/src/main/java/com/cloud/hypervisor/xenserver/resource/XenServerStorageProcessor.java b/plugins/hypervisors/xenserver/src/main/java/com/cloud/hypervisor/xenserver/resource/XenServerStorageProcessor.java index 4298c9a7218..7114d4aaea6 100644 --- a/plugins/hypervisors/xenserver/src/main/java/com/cloud/hypervisor/xenserver/resource/XenServerStorageProcessor.java +++ b/plugins/hypervisors/xenserver/src/main/java/com/cloud/hypervisor/xenserver/resource/XenServerStorageProcessor.java @@ -23,6 +23,7 @@ import static com.cloud.utils.ReflectUtil.flattenProperties; import static com.google.common.collect.Lists.newArrayList; import java.io.File; +import java.io.UnsupportedEncodingException; import java.net.URI; import java.util.ArrayList; import java.util.Arrays; @@ -810,7 +811,7 @@ public class XenServerStorageProcessor implements StorageProcessor { final SR poolSr = hypervisorResource.getStorageRepository(conn, CitrixHelper.getSRNameLabel(primaryStore.getUuid(), primaryStore.getPoolType(), primaryStore.getPath())); VDI.Record vdir = new VDI.Record(); - vdir.nameLabel = volume.getName(); + vdir.nameLabel = getEncodedVolumeName(volume.getName()); vdir.SR = poolSr; vdir.type = Types.VdiType.USER; @@ -831,6 +832,18 @@ public class XenServerStorageProcessor implements StorageProcessor { } } + private String getEncodedVolumeName(String volumeName) throws UnsupportedEncodingException { + byte[] utf8Bytes = volumeName.getBytes("UTF-8"); + // Decode UTF-8 into a Java String (UTF-16) + String decoded = new String(utf8Bytes, "UTF-8"); + // Print each code unit as a Unicode escape + StringBuilder unicodeEscaped = new StringBuilder(); + for (char ch : decoded.toCharArray()) { + unicodeEscaped.append(String.format("\\u%04X", (int) ch)); + } + return unicodeEscaped.toString(); + } + @Override public Answer cloneVolumeFromBaseTemplate(final CopyCommand cmd) { final Connection conn = hypervisorResource.getConnection();