tap-solaris and tap-bsd realize only tap_open() interface and all other functions are duplicated with tap-stub. Let's split tap-stub so that we can reuse all stubs except for tap_open() for solaris and bsd.
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsement...@virtuozzo.com> --- net/tap-bsd.c | 53 --------------------------------------------- net/tap-open-stub.c | 34 +++++++++++++++++++++++++++++ net/tap-solaris.c | 53 --------------------------------------------- net/tap-stub.c | 7 ------ net/meson.build | 3 +++ 5 files changed, 37 insertions(+), 113 deletions(-) create mode 100644 net/tap-open-stub.c diff --git a/net/tap-bsd.c b/net/tap-bsd.c index 77aaf674b1..5667e87c9a 100644 --- a/net/tap-bsd.c +++ b/net/tap-bsd.c @@ -206,56 +206,3 @@ error: return -1; } #endif /* __FreeBSD__ */ - -void tap_set_sndbuf(int fd, const NetdevTapOptions *tap, Error **errp) -{ -} - -int tap_probe_vnet_hdr(int fd, Error **errp) -{ - return 0; -} - -int tap_probe_has_ufo(int fd) -{ - return 0; -} - -int tap_probe_vnet_hdr_len(int fd, int len) -{ - return 0; -} - -void tap_fd_set_vnet_hdr_len(int fd, int len) -{ -} - -int tap_fd_set_vnet_le(int fd, int is_le) -{ - return -EINVAL; -} - -int tap_fd_set_vnet_be(int fd, int is_be) -{ - return -EINVAL; -} - -void tap_fd_set_offload(int fd, int csum, int tso4, - int tso6, int ecn, int ufo) -{ -} - -int tap_fd_enable(int fd) -{ - return -1; -} - -int tap_fd_disable(int fd) -{ - return -1; -} - -int tap_fd_get_ifname(int fd, char *ifname) -{ - return -1; -} diff --git a/net/tap-open-stub.c b/net/tap-open-stub.c new file mode 100644 index 0000000000..01cc03f630 --- /dev/null +++ b/net/tap-open-stub.c @@ -0,0 +1,34 @@ +/* + * QEMU System Emulator + * + * Copyright (c) 2003-2008 Fabrice Bellard + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "tap_int.h" + +int tap_open(char *ifname, int ifname_size, int *vnet_hdr, + int vnet_hdr_required, int mq_required, Error **errp) +{ + error_setg(errp, "tap is not supported in this build"); + return -1; +} diff --git a/net/tap-solaris.c b/net/tap-solaris.c index 0475a58207..920b4df2fe 100644 --- a/net/tap-solaris.c +++ b/net/tap-solaris.c @@ -202,56 +202,3 @@ int tap_open(char *ifname, int ifname_size, int *vnet_hdr, fcntl(fd, F_SETFL, O_NONBLOCK); return fd; } - -void tap_set_sndbuf(int fd, const NetdevTapOptions *tap, Error **errp) -{ -} - -int tap_probe_vnet_hdr(int fd, Error **errp) -{ - return 0; -} - -int tap_probe_has_ufo(int fd) -{ - return 0; -} - -int tap_probe_vnet_hdr_len(int fd, int len) -{ - return 0; -} - -void tap_fd_set_vnet_hdr_len(int fd, int len) -{ -} - -int tap_fd_set_vnet_le(int fd, int is_le) -{ - return -EINVAL; -} - -int tap_fd_set_vnet_be(int fd, int is_be) -{ - return -EINVAL; -} - -void tap_fd_set_offload(int fd, int csum, int tso4, - int tso6, int ecn, int ufo) -{ -} - -int tap_fd_enable(int fd) -{ - return -1; -} - -int tap_fd_disable(int fd) -{ - return -1; -} - -int tap_fd_get_ifname(int fd, char *ifname) -{ - return -1; -} diff --git a/net/tap-stub.c b/net/tap-stub.c index de525a2e69..6fa130758b 100644 --- a/net/tap-stub.c +++ b/net/tap-stub.c @@ -26,13 +26,6 @@ #include "qapi/error.h" #include "tap_int.h" -int tap_open(char *ifname, int ifname_size, int *vnet_hdr, - int vnet_hdr_required, int mq_required, Error **errp) -{ - error_setg(errp, "tap is not supported in this build"); - return -1; -} - void tap_set_sndbuf(int fd, const NetdevTapOptions *tap, Error **errp) { } diff --git a/net/meson.build b/net/meson.build index 1076b0a7ab..73b2ab78c2 100644 --- a/net/meson.build +++ b/net/meson.build @@ -32,6 +32,9 @@ softmmu_ss.add(when: 'CONFIG_BSD', if_true: files('tap-bsd.c')) softmmu_ss.add(when: 'CONFIG_SOLARIS', if_true: files('tap-solaris.c')) tap_posix = ['tap.c'] if not config_host.has_key('CONFIG_LINUX') and not config_host.has_key('CONFIG_BSD') and not config_host.has_key('CONFIG_SOLARIS') + tap_posix += 'tap-open-stub.c' +endif +if not config_host.has_key('CONFIG_LINUX') tap_posix += 'tap-stub.c' endif softmmu_ss.add(when: 'CONFIG_POSIX', if_true: files(tap_posix)) -- 2.28.0