[PATCH 1/2] Forbid new-line char in name of new domain

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



New line character in name of domain is now forbidden because it
mess virsh output and can be confusing for users.
Validation of name is done in drivers, after parsing XML to avoid
problems with dissappeared domains which was already created with
new-line char in name.
---
 src/bhyve/bhyve_driver.c   | 3 +++
 src/esx/esx_driver.c       | 3 +++
 src/libxl/libxl_driver.c   | 3 +++
 src/lxc/lxc_driver.c       | 3 +++
 src/openvz/openvz_driver.c | 3 +++
 src/qemu/qemu_driver.c     | 3 +++
 src/test/test_driver.c     | 3 +++
 src/uml/uml_driver.c       | 3 +++
 src/vmware/vmware_driver.c | 3 +++
 src/vz/vz_driver.c         | 3 +++
 src/xen/xen_driver.c       | 3 +++
 src/xenapi/xenapi_driver.c | 3 +++
 12 files changed, 36 insertions(+)

diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c
index 38fb9f0..17f8524 100644
--- a/src/bhyve/bhyve_driver.c
+++ b/src/bhyve/bhyve_driver.c
@@ -541,6 +541,9 @@ bhyveDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int flag
                                        NULL, parse_flags)) == NULL)
         goto cleanup;
 
+    if (virXMLCheckIllegalChars("name", def->name, "\n") < 0)
+        goto cleanup;
+
     if (virDomainDefineXMLFlagsEnsureACL(conn, def) < 0)
         goto cleanup;
 
diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c
index 17ef00f..166d4bc 100644
--- a/src/esx/esx_driver.c
+++ b/src/esx/esx_driver.c
@@ -3051,6 +3051,9 @@ esxDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int flags)
     if (!def)
         return NULL;
 
+    if (virXMLCheckIllegalChars("name", def->name, "\n") < 0)
+        goto cleanup;
+
     /* Check if an existing domain should be edited */
     if (esxVI_LookupVirtualMachineByUuid(priv->primary, def->uuid, NULL,
                                          &virtualMachine,
diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index b2f3b16..3efa91e 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -2791,6 +2791,9 @@ libxlDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int flag
                                         NULL, parse_flags)))
         goto cleanup;
 
+    if (virXMLCheckIllegalChars("name", def->name, "\n") < 0)
+        goto cleanup;
+
     if (virDomainDefineXMLFlagsEnsureACL(conn, def) < 0)
         goto cleanup;
 
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index 4a0165a..a6776a1 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -475,6 +475,9 @@ lxcDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int flags)
                                         NULL, parse_flags)))
         goto cleanup;
 
+    if (virXMLCheckIllegalChars("name", def->name, "\n") < 0)
+        goto cleanup;
+
     if (virDomainDefineXMLFlagsEnsureACL(conn, def) < 0)
         goto cleanup;
 
diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c
index 38a562e..1dfb1cc 100644
--- a/src/openvz/openvz_driver.c
+++ b/src/openvz/openvz_driver.c
@@ -1000,6 +1000,9 @@ openvzDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int fla
                                          NULL, parse_flags)) == NULL)
         goto cleanup;
 
+    if (virXMLCheckIllegalChars("name", vmdef->name, "\n") < 0)
+        goto cleanup;
+
     if (!(vm = virDomainObjListAdd(driver->domains, vmdef,
                                    driver->xmlopt,
                                    0, NULL)))
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index a82e58b..8d337eb 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -7339,6 +7339,9 @@ qemuDomainDefineXMLFlags(virConnectPtr conn,
                                         NULL, parse_flags)))
         goto cleanup;
 
+    if (virXMLCheckIllegalChars("name", def->name, "\n") < 0)
+        goto cleanup;
+
     if (virDomainDefineXMLFlagsEnsureACL(conn, def) < 0)
         goto cleanup;
 
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index 236874f..1b54839 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -2641,6 +2641,9 @@ static virDomainPtr testDomainDefineXMLFlags(virConnectPtr conn,
                                        NULL, parse_flags)) == NULL)
         goto cleanup;
 
+    if (virXMLCheckIllegalChars("name", def->name, "\n") < 0)
+        goto cleanup;
+
     if (testDomainGenerateIfnames(def) < 0)
         goto cleanup;
     if (!(dom = virDomainObjListAdd(privconn->domains,
diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c
index 4f4a69b..ad89e3e 100644
--- a/src/uml/uml_driver.c
+++ b/src/uml/uml_driver.c
@@ -2074,6 +2074,9 @@ umlDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int flags)
                                         NULL, parse_flags)))
         goto cleanup;
 
+    if (virXMLCheckIllegalChars("name", def->name, "\n") < 0)
+        goto cleanup;
+
     if (virDomainDefineXMLFlagsEnsureACL(conn, def) < 0)
         goto cleanup;
 
diff --git a/src/vmware/vmware_driver.c b/src/vmware/vmware_driver.c
index 9a53b8d..d3497bd 100644
--- a/src/vmware/vmware_driver.c
+++ b/src/vmware/vmware_driver.c
@@ -392,6 +392,9 @@ vmwareDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int fla
                                          NULL, parse_flags)) == NULL)
         goto cleanup;
 
+    if (virXMLCheckIllegalChars("name", vmdef->name, "\n") < 0)
+        goto cleanup;
+
     /* generate vmx file */
     vmx = virVMXFormatConfig(&ctx, driver->xmlopt, vmdef, 7);
     if (vmx == NULL)
diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c
index b7c37bb..7cd89a0 100644
--- a/src/vz/vz_driver.c
+++ b/src/vz/vz_driver.c
@@ -854,6 +854,9 @@ vzDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int flags)
                                        NULL, parse_flags)) == NULL)
         goto cleanup;
 
+    if (virXMLCheckIllegalChars("name", def->name, "\n") < 0)
+        goto cleanup;
+
     if (virDomainDefineXMLFlagsEnsureACL(conn, def) < 0)
         goto cleanup;
 
diff --git a/src/xen/xen_driver.c b/src/xen/xen_driver.c
index 188c2d1..3f9bfa7 100644
--- a/src/xen/xen_driver.c
+++ b/src/xen/xen_driver.c
@@ -1810,6 +1810,9 @@ xenUnifiedDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int
                                         NULL, parse_flags)))
         goto cleanup;
 
+    if (virXMLCheckIllegalChars("name", def->name, "\n") < 0)
+        goto cleanup;
+
     if (virDomainDefineXMLFlagsEnsureACL(conn, def) < 0)
         goto cleanup;
 
diff --git a/src/xenapi/xenapi_driver.c b/src/xenapi/xenapi_driver.c
index dcb79aa..eedfc17 100644
--- a/src/xenapi/xenapi_driver.c
+++ b/src/xenapi/xenapi_driver.c
@@ -1759,6 +1759,9 @@ xenapiDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int fla
     if (!defPtr)
         return NULL;
 
+    if (virXMLCheckIllegalChars("name", defPtr->name, "\n") < 0)
+        goto cleanup;
+
     if (createVMRecordFromXml(conn, defPtr, &record, &vm) != 0) {
         if (!priv->session->ok)
             xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, NULL);
-- 
2.7.4

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]
  Powered by Linux