Skip to contentSkip to conversation

Monitor file path length limitation

Qemu-devel Simon 3 participants 4 messages May 24, 2017

lore
Share & tools
lore

Simon

author
#0 lore raw

Hello,

It seems that the monitor file path length is limited to about 100 characters (107 to be precise).

Currently I'm using the '-monitor' parameter to create the monitor file in a directory which gather all the files related to a given VM (monitor file, PID file, disk image, etc.):

-monitor 'unix:/home/user/vmtools/test/out/foobar.iso/foobar.iso_A/foobar.iso_B/foobar.iso_C/foobar.iso_D/foobar.iso_E/monitor.sock,server,nowait'

With this command Qemu does not produce any warning or error message but create the socket file "mon" instead of the expected "monitor.sock".

Things go even worse if I add a further nesting:

-monitor 'unix:/home/user/vmtools/test/out/foobar.iso/foobar.iso_A/foobar.iso_B/foobar.iso_C/foobar.iso_D/foobar.iso_E/foobar.iso_F/monitor.sock,server,nowait'

Now, still without any warning, Qemu creates a file named "foo" in the parent directory ('foobar.iso_E/') instead of the expected directory ('foobar.iso_E/').

Is there a clean way to work around this limitation? For instance, is there an alternative option I can use to generate this monitor file? Or should I just assume that absolute paths are not supported in the '-monitor' option and change the working directory before launching Qemu so I can pass "./monitor.sock" as monitor file path (I really prefer to use absolute path whenever possible though).

As a side-note, is there any technical reason for such a limitation?

Regards,
Simon.

#1 lore raw
Quoted 4 lines · Simon

Hello,

It seems that the monitor file path length is limited to about 100 characters (107 to be precise).

Welcome to the joy of Unix socket (AF_UNIX) files. The kernel imposes a hard length limit on sockaddr_un.sun_path[] (see 'man 7 unix') - and it is indeed 107 characters plus a NUL terminator.

Quoted 6 lines

-monitor 'unix:/home/user/vmtools/test/out/foobar.iso/foobar.iso_A/foobar.iso_B/foobar.iso_C/foobar.iso_D/foobar.iso_E/monitor.sock,server,nowait'

With this command Qemu does not produce any warning or error message but create the socket file "mon" instead of the expected "monitor.sock".

Ideally, qemu should be telling you your path is too long to be created as a unix socket, and failing up front, rather than silently truncating and perhaps doing the wrong thing.

Quoted 1 line

Is there a clean way to work around this limitation?

Don't use longer path names than the kernel supports.

Quoted 2 lines

As a side-note, is there any technical reason for such a limitation?

Yes, but you'll have to ask kernel folks for the reason.

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org
author
#2 lore raw

Thank you for your answer Eric, I've learned a new thing today :) !

#3 lore raw
In reply to Eric Blake
Quoted 14 lines · Eric Blake
Quoted 4 lines · Simon

Hello,

It seems that the monitor file path length is limited to about 100 characters (107 to be precise).

Welcome to the joy of Unix socket (AF_UNIX) files. The kernel imposes a hard length limit on sockaddr_un.sun_path[] (see 'man 7 unix') - and it is indeed 107 characters plus a NUL terminator.

Quoted 4 lines

-monitor 'unix:/home/user/vmtools/test/out/foobar.iso/foobar.iso_A/foobar.iso_B/foobar.iso_C/foobar.iso_D/foobar.iso_E/monitor.sock,server,nowait'

Quoted 6 lines
Quoted 2 lines

With this command Qemu does not produce any warning or error message but create the socket file "mon" instead of the expected "monitor.sock".

Ideally, qemu should be telling you your path is too long to be created as a unix socket, and failing up front, rather than silently truncating and perhaps doing the wrong thing.

I just copied you on a patch todo that :-)

Regards,
Daniel

Signature · 3 lines
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|