1c767ae62SDaniel P. Berrange /* 2c767ae62SDaniel P. Berrange * QEMU I/O channels utility APIs 3c767ae62SDaniel P. Berrange * 4c767ae62SDaniel P. Berrange * Copyright (c) 2016 Red Hat, Inc. 5c767ae62SDaniel P. Berrange * 6c767ae62SDaniel P. Berrange * This library is free software; you can redistribute it and/or 7c767ae62SDaniel P. Berrange * modify it under the terms of the GNU Lesser General Public 8c767ae62SDaniel P. Berrange * License as published by the Free Software Foundation; either 9*c8198bd5SChetan Pant * version 2.1 of the License, or (at your option) any later version. 10c767ae62SDaniel P. Berrange * 11c767ae62SDaniel P. Berrange * This library is distributed in the hope that it will be useful, 12c767ae62SDaniel P. Berrange * but WITHOUT ANY WARRANTY; without even the implied warranty of 13c767ae62SDaniel P. Berrange * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14c767ae62SDaniel P. Berrange * Lesser General Public License for more details. 15c767ae62SDaniel P. Berrange * 16c767ae62SDaniel P. Berrange * You should have received a copy of the GNU Lesser General Public 17c767ae62SDaniel P. Berrange * License along with this library; if not, see <http://www.gnu.org/licenses/>. 18c767ae62SDaniel P. Berrange * 19c767ae62SDaniel P. Berrange */ 20c767ae62SDaniel P. Berrange 2130456d5bSPeter Maydell #include "qemu/osdep.h" 22c767ae62SDaniel P. Berrange #include "io/channel-util.h" 23c767ae62SDaniel P. Berrange #include "io/channel-file.h" 24c767ae62SDaniel P. Berrange #include "io/channel-socket.h" 25c767ae62SDaniel P. Berrange 26c767ae62SDaniel P. Berrange 27c767ae62SDaniel P. Berrange QIOChannel *qio_channel_new_fd(int fd, 28c767ae62SDaniel P. Berrange Error **errp) 29c767ae62SDaniel P. Berrange { 30c767ae62SDaniel P. Berrange QIOChannel *ioc; 31c767ae62SDaniel P. Berrange 32c767ae62SDaniel P. Berrange if (fd_is_socket(fd)) { 33c767ae62SDaniel P. Berrange ioc = QIO_CHANNEL(qio_channel_socket_new_fd(fd, errp)); 34c767ae62SDaniel P. Berrange } else { 35c767ae62SDaniel P. Berrange ioc = QIO_CHANNEL(qio_channel_file_new_fd(fd)); 36c767ae62SDaniel P. Berrange } 37c767ae62SDaniel P. Berrange return ioc; 38c767ae62SDaniel P. Berrange } 39