mirror of
https://github.com/qemu/qemu.git
synced 2024-11-24 19:33:39 +08:00
tap-linux: Convert tap_open() to Error
Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-id: 1431691143-1015-12-git-send-email-armbru@redhat.com Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
parent
468dd82408
commit
47896e2fd3
@ -39,7 +39,6 @@
|
||||
int tap_open(char *ifname, int ifname_size, int *vnet_hdr,
|
||||
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);
|
||||
@ -47,7 +46,7 @@ int tap_open(char *ifname, int ifname_size, int *vnet_hdr,
|
||||
|
||||
TFR(fd = open(PATH_NET_TUN, O_RDWR));
|
||||
if (fd < 0) {
|
||||
error_report("could not open %s: %m", PATH_NET_TUN);
|
||||
error_setg_errno(errp, errno, "could not open %s", PATH_NET_TUN);
|
||||
return -1;
|
||||
}
|
||||
memset(&ifr, 0, sizeof(ifr));
|
||||
@ -71,8 +70,8 @@ int tap_open(char *ifname, int ifname_size, int *vnet_hdr,
|
||||
}
|
||||
|
||||
if (vnet_hdr_required && !*vnet_hdr) {
|
||||
error_report("vnet_hdr=1 requested, but no kernel "
|
||||
"support for IFF_VNET_HDR available");
|
||||
error_setg(errp, "vnet_hdr=1 requested, but no kernel "
|
||||
"support for IFF_VNET_HDR available");
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
@ -87,8 +86,8 @@ int tap_open(char *ifname, int ifname_size, int *vnet_hdr,
|
||||
|
||||
if (mq_required) {
|
||||
if (!(features & IFF_MULTI_QUEUE)) {
|
||||
error_report("multiqueue required, but no kernel "
|
||||
"support for IFF_MULTI_QUEUE available");
|
||||
error_setg(errp, "multiqueue required, but no kernel "
|
||||
"support for IFF_MULTI_QUEUE available");
|
||||
close(fd);
|
||||
return -1;
|
||||
} else {
|
||||
@ -103,9 +102,11 @@ int tap_open(char *ifname, int ifname_size, int *vnet_hdr,
|
||||
ret = ioctl(fd, TUNSETIFF, (void *) &ifr);
|
||||
if (ret != 0) {
|
||||
if (ifname[0] != '\0') {
|
||||
error_report("could not configure %s (%s): %m", PATH_NET_TUN, ifr.ifr_name);
|
||||
error_setg_errno(errp, errno, "could not configure %s (%s)",
|
||||
PATH_NET_TUN, ifr.ifr_name);
|
||||
} else {
|
||||
error_report("could not configure %s: %m", PATH_NET_TUN);
|
||||
error_setg_errno(errp, errno, "could not configure %s",
|
||||
PATH_NET_TUN);
|
||||
}
|
||||
close(fd);
|
||||
return -1;
|
||||
|
Loading…
Reference in New Issue
Block a user