socket shutdown

Add QEMUFile interface to allow a socket to be 'shut down' - i.e. any
reads/writes will fail (and any blocking read/write will be woken).

Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Amit Shah <amit.shah@redhat.com>
Signed-off-by: Amit Shah <amit.shah@redhat.com>
This commit is contained in:
Dr. David Alan Gilbert 2015-01-08 11:11:30 +00:00 committed by Amit Shah
parent 8580b06498
commit e1a8c9b67f
4 changed files with 48 additions and 4 deletions

View file

@ -30,6 +30,18 @@
#include "migration/qemu-file-internal.h"
#include "trace.h"
/*
* Stop a file from being read/written - not all backing files can do this
* typically only sockets can.
*/
int qemu_file_shutdown(QEMUFile *f)
{
if (!f->ops->shut_down) {
return -ENOSYS;
}
return f->ops->shut_down(f->opaque, true, true);
}
bool qemu_file_mode_is_not_valid(const char *mode)
{
if (mode == NULL ||