daemon: Allow --channel fd:N

In this case, the daemon has been passed an open file descriptor which
it uses directly for the channel.
This commit is contained in:
Richard W.M. Jones
2015-11-07 12:20:23 +00:00
parent 49ad09bae3
commit 2ee2003d56
2 changed files with 28 additions and 17 deletions

View File

@@ -284,23 +284,29 @@ main (int argc, char *argv[])
int sock;
if (!listen_mode) {
sock = open (channel, O_RDWR|O_CLOEXEC);
if (sock == -1) {
fprintf (stderr,
"\n"
"Failed to connect to virtio-serial channel.\n"
"\n"
"This is a fatal error and the appliance will now exit.\n"
"\n"
"Usually this error is caused by either QEMU or the appliance\n"
"kernel not supporting the vmchannel method that the\n"
"libguestfs library chose to use. Please run\n"
"'libguestfs-test-tool' and provide the complete, unedited\n"
"output to the libguestfs developers, either in a bug report\n"
"or on the libguestfs redhat com mailing list.\n"
"\n");
perror (channel);
exit (EXIT_FAILURE);
if (STRPREFIX (channel, "fd:")) {
if (sscanf (channel+3, "%d", &sock) != 1)
error (EXIT_FAILURE, 0, "cannot parse --channel %s", channel);
}
else {
sock = open (channel, O_RDWR|O_CLOEXEC);
if (sock == -1) {
fprintf (stderr,
"\n"
"Failed to connect to virtio-serial channel.\n"
"\n"
"This is a fatal error and the appliance will now exit.\n"
"\n"
"Usually this error is caused by either QEMU or the appliance\n"
"kernel not supporting the vmchannel method that the\n"
"libguestfs library chose to use. Please run\n"
"'libguestfs-test-tool' and provide the complete, unedited\n"
"output to the libguestfs developers, either in a bug report\n"
"or on the libguestfs redhat com mailing list.\n"
"\n");
perror (channel);
exit (EXIT_FAILURE);
}
}
}
else {

View File

@@ -54,10 +54,15 @@ Display brief help.
=item B<--channel> CHANNEL
=item B<--channel> fd:N
Pass the name of the virtio-serial channel, serial port, etc. over
which guestfsd will communicate with the library. If this parameter
is not given, then an internal default port is used.
The C<fd:N> form causes guestfsd to use the file descriptor C<N>
directly.
=item B<-l>
=item B<--listen>