Bug 1033369

Summary: systemd rejects VM names longer than 64 characters: Invalid machine name
Product: [Community] Virtualization Tools Reporter: Josh Poimboeuf <jpoimboe>
Component: libvirtAssignee: Libvirt Maintainers <libvirt-maint>
Status: CLOSED CURRENTRELEASE QA Contact:
Severity: medium Docs Contact:
Priority: unspecified    
Version: unspecifiedCC: berrange, clalancette, crobinso, dwalsh, itamar, jforbes, jyaworski, lagarcia, laine, libvirt-maint, lpoetter, mfisher, rbalakri, riek, systemd-maint, veillard, virt-maint
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-04-10 15:32:27 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Josh Poimboeuf 2013-11-22 00:06:02 UTC
Description of problem:

Creating a libvirt-lxc domain with virDomainCreateXML fails with EINVAL if the name is longer 60 characters.

error: Failed to create domain from /root/libvirt-lxc-config.xml
error: internal error: guest failed to start: Invalid argument

2013-11-21 23:58:27.520+0000: starting up
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin LIBVIRT_DEBUG=3 LIBVIRT_LOG_OUTPUTS=3:stderr /usr/libexec/libvirt_lxc --name 1234567890123456789012345678901234567890123456789012345678901 --console 22 --security=selinux --handshake 25 --background --veth vnet1
2013-11-21 23:58:28.067+0000: 3195: info : libvirt version: 1.1.4, package: 2.fc21 (Fedora Project, 2013-11-12-14:52:51, buildvm-24.phx2.fedoraproject.org)
2013-11-21 23:58:28.067+0000: 3195: error : virDBusCallMethod:1205 : Invalid argument
Invalid argument

This worked fine in F19.


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

Fedora Rawhide
libvirt-daemon-1.1.4-2.fc21.x86_64
dbus-1.6.18-1.fc21.x86_64
systemd-208-6.fc21.x86_64


How reproducible:

Create a libvirt-lxc domain with a name of 61 characters.


Steps to Reproduce:

[root@rawhide ~]# cat libvirt-lxc-config.xml
<domain type='lxc'>
  <name>1234567890123456789012345678901234567890123456789012345678901</name>
  <memory>500000</memory>
  <os>
    <type>exe</type>
    <init>/bin/sh</init>
  </os>
  <vcpu>1</vcpu>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>destroy</on_crash>
  <clock offset='utc'/>
  <devices>
    <emulator>/usr/libexec/libvirt_lxc</emulator>
    <interface type='network'>
      <source network='default'/>
    </interface>
    <console type='pty'/>
  </devices>
</domain>
[root@rawhide ~]# virsh -c lxc:/// create libvirt-lxc-config.xml
error: Failed to create domain from libvirt-lxc-config.xml
error: internal error: guest failed to start: Invalid argument


Actual results:

Domain creation failure


Expected results:

Domain creation success


Additional info:

Comment 1 Daniel Berrangé 2013-11-22 10:08:59 UTC
Lennart, does either systemd impose some kind of length limit on scope names ?  The "Invalid argument" error we're getting here comes from the CreateMachine dbus api call we're making to systemd-machined.

Comment 2 Cole Robinson 2014-05-03 20:03:34 UTC
Still relevant with latest f20, and libvirt git.

(In reply to Daniel Berrange from comment #1)
> Lennart, does either systemd impose some kind of length limit on scope names
> ?  The "Invalid argument" error we're getting here comes from the
> CreateMachine dbus api call we're making to systemd-machined.

Setting needinfo on systemd-maint. systemd devs, please see the above question

Comment 3 Lennart Poettering 2014-05-20 09:32:20 UTC
Yes, we do enforce limits in syntax and length for unit names (256 chars, but you have to subtract the ".scope" suffix from that. Also if you need weird chars escaping costs three chars per original char extra.

That said, we make much stronger requirements on machine names currently, and thats what is going to bite you more: 64 ch max. That said, thinking about it we should probably change this to match the retrictions usually made on hostnames...

Comment 4 Jaroslav Reznik 2015-03-03 15:13:25 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 22 development cycle.
Changing version to '22'.

More information and reason for this action is here:
https://fedoraproject.org/wiki/Fedora_Program_Management/HouseKeeping/Fedora22

Comment 5 Cole Robinson 2016-04-10 15:32:27 UTC
This should be fixed as of libvirt 1.3.4, there were a bunch of patches in this area recently