[libvirt] [PATCH] domain: avoid slash characters to the new domain name.

Julio Faracco posted 1 patch 5 years, 11 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/20180417032727.11030-1-jcfaracco@gmail.com
Test syntax-check passed
src/internal.h       | 9 +++++++++
src/libvirt-domain.c | 1 +
2 files changed, 10 insertions(+)
[libvirt] [PATCH] domain: avoid slash characters to the new domain name.
Posted by Julio Faracco 5 years, 11 months ago
The 'domrename' command needs to check if the new domain name contains
the slash character. This character is not accepted by libvirt XML
definition because it is an invalid char (see Cole's commit b1fc6a7b7).
This commit enhace the 'domrename' command adding this check.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1333232

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
---
 src/internal.h       | 9 +++++++++
 src/libvirt-domain.c | 1 +
 2 files changed, 10 insertions(+)

diff --git a/src/internal.h b/src/internal.h
index 1760e3b69..e976b1caa 100644
--- a/src/internal.h
+++ b/src/internal.h
@@ -484,6 +484,15 @@
             goto label; \
         } \
     } while (0)
+# define virCheckNonSlashGoto(argname, label) \
+    do { \
+        if (strchr(argname, '/')) { \
+           virReportInvalidArg(ctl, \
+                               _("name %s cannot contain '/'"), \
+                               argname); \
+            goto label; \
+        } \
+    } while (0)
 
 
 
diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c
index 63d2ae23d..47bc59b11 100644
--- a/src/libvirt-domain.c
+++ b/src/libvirt-domain.c
@@ -8536,6 +8536,7 @@ virDomainRename(virDomainPtr dom,
     virResetLastError();
     virCheckDomainReturn(dom, -1);
     virCheckNonEmptyStringArgGoto(new_name, error);
+    virCheckNonSlashGoto(new_name, error);
     virCheckReadOnlyGoto(dom->conn->flags, error);
 
     if (dom->conn->driver->domainRename) {
-- 
2.14.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] domain: avoid slash characters to the new domain name.
Posted by Peter Krempa 5 years, 11 months ago
On Tue, Apr 17, 2018 at 00:27:27 -0300, Julio Faracco wrote:
> The 'domrename' command needs to check if the new domain name contains
> the slash character. This character is not accepted by libvirt XML
> definition because it is an invalid char (see Cole's commit b1fc6a7b7).
> This commit enhace the 'domrename' command adding this check.
> 
> Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1333232
> 
> Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
> ---
>  src/internal.h       | 9 +++++++++
>  src/libvirt-domain.c | 1 +
>  2 files changed, 10 insertions(+)

Slash in VM name may be allowed for some hypervisors and when defining
the hypervisor defines this via VIR_DOMAIN_DEF_FEATURE_NAME_SLASH parser
feature flag.

Currently it appears that virtualbox, phyp, vmx, and xenapi driver
support a slash so the fix below is wrong as it would forbid the slash
when renaming the VM for those drivers.

This needs to be implemented in the qemu driver according to the BZ.
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] domain: avoid slash characters to the new domain name.
Posted by Julio Faracco 5 years, 11 months ago
Hi Peter,

I read the BZ comments and Cole's suggestion, but I didn't know about
the requirements of the other hypervisors.
Since slash is commonly used for paths.

I will investigate it properly.

--
Julio Cesar Faracco

2018-04-17 4:14 GMT-03:00 Peter Krempa <pkrempa@redhat.com>:
>
> On Tue, Apr 17, 2018 at 00:27:27 -0300, Julio Faracco wrote:
> > The 'domrename' command needs to check if the new domain name contains
> > the slash character. This character is not accepted by libvirt XML
> > definition because it is an invalid char (see Cole's commit b1fc6a7b7).
> > This commit enhace the 'domrename' command adding this check.
> >
> > Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1333232
> >
> > Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
> > ---
> >  src/internal.h       | 9 +++++++++
> >  src/libvirt-domain.c | 1 +
> >  2 files changed, 10 insertions(+)
>
> Slash in VM name may be allowed for some hypervisors and when defining
> the hypervisor defines this via VIR_DOMAIN_DEF_FEATURE_NAME_SLASH parser
> feature flag.
>
> Currently it appears that virtualbox, phyp, vmx, and xenapi driver
> support a slash so the fix below is wrong as it would forbid the slash
> when renaming the VM for those drivers.
>
> This needs to be implemented in the qemu driver according to the BZ.

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