You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by pe...@apache.org on 2025/04/24 12:37:04 UTC

(cloudstack) branch allow-emoji-volume-name-xen created (now 42b70e77bcd)

This is an automated email from the ASF dual-hosted git repository.

pearl11594 pushed a change to branch allow-emoji-volume-name-xen
in repository https://gitbox.apache.org/repos/asf/cloudstack.git


      at 42b70e77bcd Allow emojis to be accepted in volume name during volume creation

This branch includes the following new commits:

     new 42b70e77bcd Allow emojis to be accepted in volume name during volume creation

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



(cloudstack) 01/01: Allow emojis to be accepted in volume name during volume creation

Posted by pe...@apache.org.
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 <pe...@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();