]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
esx: URI encode inventory objects twice
authorMichal Privoznik <mprivozn@redhat.com>
Tue, 6 Jan 2026 16:18:03 +0000 (17:18 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Thu, 8 Jan 2026 14:16:47 +0000 (15:16 +0100)
While discouraged by a KB article to use special characters in
inventory object names [1], ESX won't stop you. And thus users
can end up with a datastore named "datastore2+", for instance.
The datastore name (and datacenter path) are important when
fetching/uploading a .vmx file (used in APIs like
virDomainGetXMLDesc() or virDomainDefineXML()). And while we do
URI encode both (dcPath and dsName), encoding them once is not
enough. Cole Robinson discovered [2] that they need to be
URI-encoded twice. Use newly introduced
esxUtil_EscapeInventoryObject() helper to encode them twice.

1: https://knowledge.broadcom.com/external/article/386368/vcenter-inventory-object-name-with-speci.html
2: https://issues.redhat.com/browse/RHEL-133729#comment-28604072
Resolves: https://issues.redhat.com/browse/RHEL-134127
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
src/esx/esx_driver.c

index 9f965811b1a3f454df1264a0e29adee50eb3211e..02f30c2b191f49f650b92443d8da0faa55688e5d 100644 (file)
@@ -2567,9 +2567,9 @@ esxDomainGetXMLDesc(virDomainPtr domain, unsigned int flags)
                       domain->conn->uri->server, domain->conn->uri->port);
     virBufferURIEncodeString(&buffer, directoryAndFileName);
     virBufferAddLit(&buffer, "?dcPath=");
-    virBufferURIEncodeString(&buffer, priv->primary->datacenterPath);
+    esxUtil_EscapeInventoryObject(&buffer, priv->primary->datacenterPath);
     virBufferAddLit(&buffer, "&dsName=");
-    virBufferURIEncodeString(&buffer, datastoreName);
+    esxUtil_EscapeInventoryObject(&buffer, datastoreName);
 
     url = virBufferContentAndReset(&buffer);
 
@@ -3002,9 +3002,9 @@ esxDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int flags)
 
     virBufferURIEncodeString(&buffer, escapedName);
     virBufferAddLit(&buffer, ".vmx?dcPath=");
-    virBufferURIEncodeString(&buffer, priv->primary->datacenterPath);
+    esxUtil_EscapeInventoryObject(&buffer, priv->primary->datacenterPath);
     virBufferAddLit(&buffer, "&dsName=");
-    virBufferURIEncodeString(&buffer, datastoreName);
+    esxUtil_EscapeInventoryObject(&buffer, datastoreName);
 
     url = virBufferContentAndReset(&buffer);