All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] qemu leaving unix sockets behind after VM is shut down
@ 2014-04-01 20:34 Chris Friesen
  2014-05-06 13:39 ` Stefan Hajnoczi
  0 siblings, 1 reply; 6+ messages in thread
From: Chris Friesen @ 2014-04-01 20:34 UTC (permalink / raw)
  To: qemu-devel

When running qemu with something like this

-device virtio-serial \
-chardev socket,path=/tmp/foo,server,nowait,id=foo \
-device virtserialport,chardev=foo,name=host.port.0

the VM starts up as expected and creates a socket at /tmp/foo as expected.

However, when I shut down the VM the socket at /tmp/foo is left behind 
in the filesystem.  Basically qemu has "leaked" a file.

With something like OpenStack where we could be creating/destroying many 
VMs this could end up creating a significant number of files in the 
specified directory.

Has any thought been given to either automatically cleaning up the unix 
socket in the filesystem when qemu exits, or else supporting the 
abstract namespace for unix sockets to allow for automatic cleanup?

Chris

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] qemu leaving unix sockets behind after VM is shut down
  2014-04-01 20:34 [Qemu-devel] qemu leaving unix sockets behind after VM is shut down Chris Friesen
@ 2014-05-06 13:39 ` Stefan Hajnoczi
  2014-05-06 14:29   ` [Qemu-devel] [libvirt] " Daniel P. Berrange
                     ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Stefan Hajnoczi @ 2014-05-06 13:39 UTC (permalink / raw)
  To: Chris Friesen; +Cc: libvir-list, qemu-devel

On Tue, Apr 01, 2014 at 02:34:58PM -0600, Chris Friesen wrote:
> When running qemu with something like this
> 
> -device virtio-serial \
> -chardev socket,path=/tmp/foo,server,nowait,id=foo \
> -device virtserialport,chardev=foo,name=host.port.0
> 
> the VM starts up as expected and creates a socket at /tmp/foo as expected.
> 
> However, when I shut down the VM the socket at /tmp/foo is left
> behind in the filesystem.  Basically qemu has "leaked" a file.
> 
> With something like OpenStack where we could be creating/destroying
> many VMs this could end up creating a significant number of files in
> the specified directory.
> 
> Has any thought been given to either automatically cleaning up the
> unix socket in the filesystem when qemu exits, or else supporting
> the abstract namespace for unix sockets to allow for automatic
> cleanup?

Libvirt has a special case for the monitor socket in its
qemuProcessStop() function.

Are you using the OpenStack libvirt driver?

Perhaps QEMU should support cleanup but first I think we should check
the situation with libvirt.

Stefan

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [libvirt] qemu leaving unix sockets behind after VM is shut down
  2014-05-06 13:39 ` Stefan Hajnoczi
@ 2014-05-06 14:29   ` Daniel P. Berrange
  2014-05-06 14:52   ` [Qemu-devel] " Chris Friesen
  2014-05-13 13:24   ` Ján Tomko
  2 siblings, 0 replies; 6+ messages in thread
From: Daniel P. Berrange @ 2014-05-06 14:29 UTC (permalink / raw)
  To: Stefan Hajnoczi; +Cc: libvir-list, Chris Friesen, qemu-devel

On Tue, May 06, 2014 at 03:39:57PM +0200, Stefan Hajnoczi wrote:
> On Tue, Apr 01, 2014 at 02:34:58PM -0600, Chris Friesen wrote:
> > When running qemu with something like this
> > 
> > -device virtio-serial \
> > -chardev socket,path=/tmp/foo,server,nowait,id=foo \
> > -device virtserialport,chardev=foo,name=host.port.0
> > 
> > the VM starts up as expected and creates a socket at /tmp/foo as expected.
> > 
> > However, when I shut down the VM the socket at /tmp/foo is left
> > behind in the filesystem.  Basically qemu has "leaked" a file.
> > 
> > With something like OpenStack where we could be creating/destroying
> > many VMs this could end up creating a significant number of files in
> > the specified directory.
> > 
> > Has any thought been given to either automatically cleaning up the
> > unix socket in the filesystem when qemu exits, or else supporting
> > the abstract namespace for unix sockets to allow for automatic
> > cleanup?
> 
> Libvirt has a special case for the monitor socket in its
> qemuProcessStop() function.
> 
> Are you using the OpenStack libvirt driver?
> 
> Perhaps QEMU should support cleanup but first I think we should check
> the situation with libvirt.

We have explicit cleanup (ie unlink() call) for the monitor
UNIX socket, but guess we forgot todo the same for other
char device sockets.

We can't rely on QEMU to cleanup since it can obviously
SEGV at any time which would prevent it cleaning up after
itself. So libvirt must have any neccessary cleanup itself,
even if QEMU did make an effort to clean up.

Regards,
Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] qemu leaving unix sockets behind after VM is shut down
  2014-05-06 13:39 ` Stefan Hajnoczi
  2014-05-06 14:29   ` [Qemu-devel] [libvirt] " Daniel P. Berrange
@ 2014-05-06 14:52   ` Chris Friesen
  2014-05-06 17:25     ` [Qemu-devel] [libvirt] " Eric Blake
  2014-05-13 13:24   ` Ján Tomko
  2 siblings, 1 reply; 6+ messages in thread
From: Chris Friesen @ 2014-05-06 14:52 UTC (permalink / raw)
  To: Stefan Hajnoczi; +Cc: libvir-list, qemu-devel

On 05/06/2014 07:39 AM, Stefan Hajnoczi wrote:
> On Tue, Apr 01, 2014 at 02:34:58PM -0600, Chris Friesen wrote:
>> When running qemu with something like this
>>
>> -device virtio-serial \
>> -chardev socket,path=/tmp/foo,server,nowait,id=foo \
>> -device virtserialport,chardev=foo,name=host.port.0
>>
>> the VM starts up as expected and creates a socket at /tmp/foo as expected.
>>
>> However, when I shut down the VM the socket at /tmp/foo is left
>> behind in the filesystem.  Basically qemu has "leaked" a file.
>>
>> With something like OpenStack where we could be creating/destroying
>> many VMs this could end up creating a significant number of files in
>> the specified directory.
>>
>> Has any thought been given to either automatically cleaning up the
>> unix socket in the filesystem when qemu exits, or else supporting
>> the abstract namespace for unix sockets to allow for automatic
>> cleanup?
>
> Libvirt has a special case for the monitor socket in its
> qemuProcessStop() function.
>
> Are you using the OpenStack libvirt driver?
>
> Perhaps QEMU should support cleanup but first I think we should check
> the situation with libvirt.

Yes, I am in fact using OpenStack/libvirt, and did eventually track down 
libvirt as the code that was cleaning up the monitor socket.

Even so, I think this sort of change would be valid in qemu itself. qemu 
created the files, so really it should be up to qemu to delete them when 
it's done with them.

They're not usable for anything with qemu not running, so there's no 
good reason to leave them laying around.

Chris

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [libvirt] qemu leaving unix sockets behind after VM is shut down
  2014-05-06 14:52   ` [Qemu-devel] " Chris Friesen
@ 2014-05-06 17:25     ` Eric Blake
  0 siblings, 0 replies; 6+ messages in thread
From: Eric Blake @ 2014-05-06 17:25 UTC (permalink / raw)
  To: Chris Friesen, Stefan Hajnoczi; +Cc: libvir-list, qemu-devel

[-- Attachment #1: Type: text/plain, Size: 825 bytes --]

On 05/06/2014 08:52 AM, Chris Friesen wrote:
> Yes, I am in fact using OpenStack/libvirt, and did eventually track down
> libvirt as the code that was cleaning up the monitor socket.
> 
> Even so, I think this sort of change would be valid in qemu itself. qemu
> created the files, so really it should be up to qemu to delete them when
> it's done with them.
> 
> They're not usable for anything with qemu not running, so there's no
> good reason to leave them laying around.

In the case of sVirt with SELinux labeling, it's often the case that
libvirt has to pre-create the file (as qemu itself is prevented from
creating the file itself) - that is also an argument for libvirt doing
the cleanup.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [libvirt] qemu leaving unix sockets behind after VM is shut down
  2014-05-06 13:39 ` Stefan Hajnoczi
  2014-05-06 14:29   ` [Qemu-devel] [libvirt] " Daniel P. Berrange
  2014-05-06 14:52   ` [Qemu-devel] " Chris Friesen
@ 2014-05-13 13:24   ` Ján Tomko
  2 siblings, 0 replies; 6+ messages in thread
From: Ján Tomko @ 2014-05-13 13:24 UTC (permalink / raw)
  To: Stefan Hajnoczi, Chris Friesen; +Cc: libvir-list, qemu-devel

[-- Attachment #1: Type: text/plain, Size: 1476 bytes --]

On 05/06/2014 03:39 PM, Stefan Hajnoczi wrote:
> On Tue, Apr 01, 2014 at 02:34:58PM -0600, Chris Friesen wrote:
>> When running qemu with something like this
>>
>> -device virtio-serial \
>> -chardev socket,path=/tmp/foo,server,nowait,id=foo \
>> -device virtserialport,chardev=foo,name=host.port.0
>>
>> the VM starts up as expected and creates a socket at /tmp/foo as expected.
>>
>> However, when I shut down the VM the socket at /tmp/foo is left
>> behind in the filesystem.  Basically qemu has "leaked" a file.
>>
>> With something like OpenStack where we could be creating/destroying
>> many VMs this could end up creating a significant number of files in
>> the specified directory.
>>
>> Has any thought been given to either automatically cleaning up the
>> unix socket in the filesystem when qemu exits, or else supporting
>> the abstract namespace for unix sockets to allow for automatic
>> cleanup?

I have sent a libvirt patch to clean up the sockets on qemu shutdown:
https://www.redhat.com/archives/libvir-list/2014-May/msg00398.html

Jan

> 
> Libvirt has a special case for the monitor socket in its
> qemuProcessStop() function.
> 
> Are you using the OpenStack libvirt driver?
> 
> Perhaps QEMU should support cleanup but first I think we should check
> the situation with libvirt.
> 
> Stefan
> 
> --
> libvir-list mailing list
> libvir-list@redhat.com
> https://www.redhat.com/mailman/listinfo/libvir-list
> 



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2014-05-13 13:24 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-01 20:34 [Qemu-devel] qemu leaving unix sockets behind after VM is shut down Chris Friesen
2014-05-06 13:39 ` Stefan Hajnoczi
2014-05-06 14:29   ` [Qemu-devel] [libvirt] " Daniel P. Berrange
2014-05-06 14:52   ` [Qemu-devel] " Chris Friesen
2014-05-06 17:25     ` [Qemu-devel] [libvirt] " Eric Blake
2014-05-13 13:24   ` Ján Tomko

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.