Bug 639923 - libvirt allows you to create a domain with '/' in the name
Summary: libvirt allows you to create a domain with '/' in the name
Keywords:
Status: CLOSED UPSTREAM
Alias: None
Product: Virtualization Tools
Classification: Community
Component: libvirt
Version: unspecified
Hardware: All
OS: Linux
low
medium
Target Milestone: ---
Assignee: Libvirt Maintainers
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2010-10-04 10:40 UTC by Richard W.M. Jones
Modified: 2016-05-04 15:03 UTC (History)
6 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-05-02 14:19:42 UTC
Embargoed:


Attachments (Terms of Use)

Description Richard W.M. Jones 2010-10-04 10:40:57 UTC
Description of problem:

You can create a libvirt domain (using virsh define) where the name
of the domain contains a '/' character.  However this causes
unexpected failures with logfile creation.

The log file is named

  /var/log/libvirt/qemu/<name>.log

If <name> is "/" or contains a slash character then you get a
log file like:

  /var/log/libvirt/qemu/.log

or a complete failure:

  error: Failed to define domain from /tmp/chars.xml
  error: cannot create config file '/etc/libvirt/qemu/a/b.xml': No such file or directory

Version-Release number of selected component (if applicable):

libvirt-0.8.3-2.fc14.x86_64

How reproducible:

Always.

Steps to Reproduce:
1. Try to define a domain which contains '/' character in the name.
2.
3.

Upstream discussion:

https://www.redhat.com/archives/libvir-list/2010-October/thread.html#00053

Comment 1 Richard W.M. Jones 2010-10-04 10:42:26 UTC
Oops, that's the config file, not the log file, but the
same argument applies.

Comment 2 Martin Kletzander 2015-04-14 13:50:37 UTC
Somebody might have a domain named e.g. "/asdf" which would disappear if we fix this.  I'm inclined to close this as wontfix.

Comment 3 Daniel Berrangé 2015-04-14 13:53:31 UTC
I think that's a pretty unlikely scenario. Plus if they have a '/' anywhere except for the first character, it will cause libvirt to try to create things in the wrong directory which is even worse. IMHO it is worth explicitly denying use of '/' because the liklihood of breaking people is really slim and worthwhile IMHO.

Comment 4 Cole Robinson 2016-04-26 19:24:12 UTC
Patch posted upstream:

http://www.redhat.com/archives/libvir-list/2016-April/msg01764.html

Comment 5 Cole Robinson 2016-05-02 14:19:42 UTC
Upstream now:

commit b1fc6a7b73f2058742b4c980c2e3573e9d0c65a2
Author: Cole Robinson <crobinso>
Date:   Tue Apr 26 11:23:12 2016 -0400

    conf: domain: reject name containing '/'

Comment 6 Fangge Jin 2016-05-04 09:50:27 UTC
I did some testing, and find that the patch works well with "virsh define"(step 1~3) and "virsh edit"(step4), but for "virsh domrename"(step 5&6), it still doesn't check the '/'.

1) 
# /usr/local/bin/virsh define /tmp/rhel7.xml 
error: Failed to define domain from /tmp/rhel7.xml
error: XML error: name rhel7/ cannot contain '/'

2)
# /usr/local/bin/virsh define /tmp/rhel7.xml 
error: Failed to define domain from /tmp/rhel7.xml
error: XML error: name /rhel7 cannot contain '/'


3)
# /usr/local/bin/virsh define /tmp/rhel7.xml 
error: Failed to define domain from /tmp/rhel7.xml
error: XML error: name / cannot contain '/'


4) 
# /usr/local/bin/virsh define /tmp/rhel7.xml 
Domain rhel7 defined from /tmp/rhel7.xml

# /usr/local/bin/virsh list --all
 Id    Name                           State
----------------------------------------------------
 -     rhel7                          shut off

# /usr/local/bin/virsh edit rhel7
error: XML error: name rh/el7 cannot contain '/'
Failed. Try again? [y,n,i,f,?]: 
error: XML error: name / cannot contain '/'
Failed. Try again? [y,n,i,f,?]: 
error: XML error: name rhel7/ cannot contain '/'
Failed. Try again? [y,n,i,f,?]: 

5)
# /usr/local/bin/virsh domrename rhel7 /
Domain successfully renamed

# /usr/local/bin/virsh list --all
 Id    Name                           State
----------------------------------------------------
 -     /                              shut off

# /usr/local/bin/virsh start /
error: Failed to start domain /
error: XML error: name / cannot contain '/'

6)
# /usr/local/bin/virsh domrename / /rhel7
Domain successfully renamed

# /usr/local/bin/virsh list --all
 Id    Name                           State
----------------------------------------------------
 -     /rhel7                         shut off

# /usr/local/bin/virsh start /rhel7
error: Failed to start domain /rhel7
error: XML error: name /rhel7 cannot contain '/'

Comment 7 Cole Robinson 2016-05-04 15:03:51 UTC
Please file a separate bug for the rename issue: rename should be calling DomainDefPostParse after editing the domain definition but before saving the config to disk


Note You need to log in before you can comment on or make changes to this bug.