]> rtime.felk.cvut.cz Git - lisovros/qemu_apohw.git/commitdiff
tap: introduce a helper to get the name of an interface
authorJason Wang <jasowang@redhat.com>
Wed, 30 Jan 2013 11:12:33 +0000 (19:12 +0800)
committerAnthony Liguori <aliguori@us.ibm.com>
Fri, 1 Feb 2013 17:03:02 +0000 (11:03 -0600)
This patch introduces a helper tap_get_ifname() to get the device name of tap
device. This is needed when ifname is unspecified in the command line and qemu
were asked to create tap device by itself. In this situation, the name were
allocated by kernel, so if multiqueue is asked, we need to fetch its name after
creating the first queue.

Only linux has this support since it's the only platform that supports
multiqueue tap.

Signed-off-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
include/net/tap.h
net/tap-aix.c
net/tap-bsd.c
net/tap-haiku.c
net/tap-linux.c
net/tap-solaris.c
net/tap_int.h

index a994f20447a42db24669538901cf93c3a43403fd..c3eb85a74e3240adbac062aa7289ed3fd99450a6 100644 (file)
@@ -37,6 +37,7 @@ void tap_set_offload(NetClientState *nc, int csum, int tso4, int tso6, int ecn,
 void tap_set_vnet_hdr_len(NetClientState *nc, int len);
 int tap_enable(NetClientState *nc);
 int tap_disable(NetClientState *nc);
+int tap_get_ifname(NetClientState *nc, char *ifname);
 
 int tap_get_fd(NetClientState *nc);
 
index 66e0574fd7c5658dd0d7bbd56a132d146361bbdc..e760e9a0e7d792f9fe49a5802115ba1078406fb6 100644 (file)
@@ -69,3 +69,9 @@ int tap_fd_disable(int fd)
 {
     return -1;
 }
+
+int tap_fd_get_ifname(int fd, char *ifname)
+{
+    return -1;
+}
+
index cfc7a289f884069cb9a94cfe0c85af5b82a20b10..4f22109e942754597e5bfd02a2881c53ba6850bd 100644 (file)
@@ -156,3 +156,7 @@ int tap_fd_disable(int fd)
     return -1;
 }
 
+int tap_fd_get_ifname(int fd, char *ifname)
+{
+    return -1;
+}
index 664d40fb4dc87c2a1b2d1bbe700be8a98cdd52bc..b3b5fbb61eab7f307399efe4a47c8a466ba8fed8 100644 (file)
@@ -70,3 +70,7 @@ int tap_fd_disable(int fd)
     return -1;
 }
 
+int tap_fd_get_ifname(int fd, char *ifname)
+{
+    return -1;
+}
index bdb0a790c8ead8180ec2a93cfde83762dca43d94..3b21662c130d1f80ad07482b6b1f962fe7a9dbfb 100644 (file)
@@ -261,3 +261,16 @@ int tap_fd_disable(int fd)
     return ret;
 }
 
+int tap_fd_get_ifname(int fd, char *ifname)
+{
+    struct ifreq ifr;
+
+    if (ioctl(fd, TUNGETIFF, &ifr) != 0) {
+        error_report("TUNGETIFF ioctl() failed: %s",
+                     strerror(errno));
+        return -1;
+    }
+
+    pstrcpy(ifname, sizeof(ifr.ifr_name), ifr.ifr_name);
+    return 0;
+}
index 12cc392c94ff2f66233c9fec25b74f173322d7c6..214d95e626fed6b662706ba4b28318f822a45f82 100644 (file)
@@ -236,3 +236,7 @@ int tap_fd_disable(int fd)
     return -1;
 }
 
+int tap_fd_get_ifname(int fd, char *ifname)
+{
+    return -1;
+}
index ca1c21b451a5c034906f03ba8f58ffca2d208706..125f83d5b04118e35626b99a2bdb507eee433a0a 100644 (file)
@@ -44,5 +44,6 @@ void tap_fd_set_offload(int fd, int csum, int tso4, int tso6, int ecn, int ufo);
 void tap_fd_set_vnet_hdr_len(int fd, int len);
 int tap_fd_enable(int fd);
 int tap_fd_disable(int fd);
+int tap_fd_get_ifname(int fd, char *ifname);
 
 #endif /* QEMU_TAP_H */