tap: Permit incremental conversion of tap_open() to Error
Convert the trivial ones immediately: tap-aix and tap-haiku. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-id: 1431691143-1015-11-git-send-email-armbru@redhat.com Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
parent
ac4fcf5639
commit
468dd82408
@ -26,9 +26,9 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int tap_open(char *ifname, int ifname_size, int *vnet_hdr,
|
||||
int vnet_hdr_required, int mq_required)
|
||||
int vnet_hdr_required, int mq_required, Error **errp)
|
||||
{
|
||||
fprintf(stderr, "no tap on AIX\n");
|
||||
error_setg(errp, "no tap on AIX");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -35,8 +35,9 @@
|
||||
|
||||
#ifndef __FreeBSD__
|
||||
int tap_open(char *ifname, int ifname_size, int *vnet_hdr,
|
||||
int vnet_hdr_required, int mq_required)
|
||||
int vnet_hdr_required, int mq_required, Error **errp)
|
||||
{
|
||||
/* FIXME error_setg(errp, ...) on failure */
|
||||
int fd;
|
||||
#ifdef TAPGIFNAME
|
||||
struct ifreq ifr;
|
||||
@ -114,8 +115,9 @@ int tap_open(char *ifname, int ifname_size, int *vnet_hdr,
|
||||
#define PATH_NET_TAP "/dev/tap"
|
||||
|
||||
int tap_open(char *ifname, int ifname_size, int *vnet_hdr,
|
||||
int vnet_hdr_required, int mq_required)
|
||||
int vnet_hdr_required, int mq_required, Error **errp)
|
||||
{
|
||||
/* FIXME error_setg(errp, ...) on failure */
|
||||
int fd, s, ret;
|
||||
struct ifreq ifr;
|
||||
|
||||
|
@ -26,9 +26,9 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int tap_open(char *ifname, int ifname_size, int *vnet_hdr,
|
||||
int vnet_hdr_required, int mq_required)
|
||||
int vnet_hdr_required, int mq_required, Error **errp)
|
||||
{
|
||||
fprintf(stderr, "no tap on Haiku\n");
|
||||
error_setg(errp, "no tap on Haiku");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -37,8 +37,9 @@
|
||||
#define PATH_NET_TUN "/dev/net/tun"
|
||||
|
||||
int tap_open(char *ifname, int ifname_size, int *vnet_hdr,
|
||||
int vnet_hdr_required, int mq_required)
|
||||
int vnet_hdr_required, int mq_required, Error **errp)
|
||||
{
|
||||
/* FIXME error_setg(errp, ...) on failure */
|
||||
struct ifreq ifr;
|
||||
int fd, ret;
|
||||
int len = sizeof(struct virtio_net_hdr);
|
||||
|
@ -174,8 +174,9 @@ static int tap_alloc(char *dev, size_t dev_size)
|
||||
}
|
||||
|
||||
int tap_open(char *ifname, int ifname_size, int *vnet_hdr,
|
||||
int vnet_hdr_required, int mq_required)
|
||||
int vnet_hdr_required, int mq_required, Error **errp)
|
||||
{
|
||||
/* FIXME error_setg(errp, ...) on failure */
|
||||
char dev[10]="";
|
||||
int fd;
|
||||
if( (fd = tap_alloc(dev, sizeof(dev))) < 0 ){
|
||||
|
13
net/tap.c
13
net/tap.c
@ -581,7 +581,7 @@ int net_init_bridge(const NetClientOptions *opts, const char *name,
|
||||
|
||||
static int net_tap_init(const NetdevTapOptions *tap, int *vnet_hdr,
|
||||
const char *setup_script, char *ifname,
|
||||
size_t ifname_sz, int mq_required)
|
||||
size_t ifname_sz, int mq_required, Error **errp)
|
||||
{
|
||||
Error *err = NULL;
|
||||
int fd, vnet_hdr_required;
|
||||
@ -595,8 +595,12 @@ static int net_tap_init(const NetdevTapOptions *tap, int *vnet_hdr,
|
||||
}
|
||||
|
||||
TFR(fd = tap_open(ifname, ifname_sz, vnet_hdr, vnet_hdr_required,
|
||||
mq_required));
|
||||
mq_required, errp));
|
||||
if (fd < 0) {
|
||||
/* FIXME drop when all tap_open() store an Error */
|
||||
if (errp && !*errp) {
|
||||
error_setg(errp, "can't open tap device");
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -605,7 +609,7 @@ static int net_tap_init(const NetdevTapOptions *tap, int *vnet_hdr,
|
||||
strcmp(setup_script, "no") != 0) {
|
||||
launch_script(setup_script, ifname, fd, &err);
|
||||
if (err) {
|
||||
error_report_err(err);
|
||||
error_propagate(errp, err);
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
@ -853,8 +857,9 @@ int net_init_tap(const NetClientOptions *opts, const char *name,
|
||||
|
||||
for (i = 0; i < queues; i++) {
|
||||
fd = net_tap_init(tap, &vnet_hdr, i >= 1 ? "no" : script,
|
||||
ifname, sizeof ifname, queues > 1);
|
||||
ifname, sizeof ifname, queues > 1, &err);
|
||||
if (fd == -1) {
|
||||
error_report_err(err);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,7 @@
|
||||
#include "qapi-types.h"
|
||||
|
||||
int tap_open(char *ifname, int ifname_size, int *vnet_hdr,
|
||||
int vnet_hdr_required, int mq_required);
|
||||
int vnet_hdr_required, int mq_required, Error **errp);
|
||||
|
||||
ssize_t tap_read_packet(int tapfd, uint8_t *buf, int maxlen);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user