Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
0d7d6997
L
libvirt
项目概览
openeuler
/
libvirt
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
L
libvirt
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
0d7d6997
编写于
4月 03, 2010
作者:
M
Matthias Bolte
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
macvtap: Remove virConnectPtr from ReportError
Also rename ReportError to macvtapError.
上级
1870e707
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
32 addition
and
38 deletion
+32
-38
cfg.mk
cfg.mk
+1
-1
src/qemu/qemu_conf.c
src/qemu/qemu_conf.c
+1
-1
src/util/macvtap.c
src/util/macvtap.c
+29
-34
src/util/macvtap.h
src/util/macvtap.h
+1
-2
未找到文件。
cfg.mk
浏览文件 @
0d7d6997
...
...
@@ -175,7 +175,7 @@ msg_gen_function += ERROR0
msg_gen_function
+=
ESX_ERROR
msg_gen_function
+=
ESX_VI_ERROR
msg_gen_function
+=
REMOTE_DEBUG
msg_gen_function
+=
Report
Error
msg_gen_function
+=
macvtap
Error
msg_gen_function
+=
VIR_FREE
msg_gen_function
+=
VIR_INFO
msg_gen_function
+=
VIR_USE_CPU
...
...
src/qemu/qemu_conf.c
浏览文件 @
0d7d6997
...
...
@@ -1469,7 +1469,7 @@ qemudPhysIfaceConnect(virConnectPtr conn,
net
->
model
&&
STREQ
(
net
->
model
,
"virtio"
))
vnet_hdr
=
1
;
rc
=
openMacvtapTap
(
conn
,
net
->
ifname
,
net
->
mac
,
linkdev
,
brmode
,
rc
=
openMacvtapTap
(
net
->
ifname
,
net
->
mac
,
linkdev
,
brmode
,
&
res_ifname
,
vnet_hdr
);
if
(
rc
>=
0
)
{
VIR_FREE
(
net
->
ifname
);
...
...
src/util/macvtap.c
浏览文件 @
0d7d6997
...
...
@@ -49,8 +49,8 @@
# define VIR_FROM_THIS VIR_FROM_NET
# define
ReportError(conn, code, ...)
\
virReportErrorHelper(
conn, VIR_FROM_NET, code, __FILE__,
\
# define
macvtapError(code, ...)
\
virReportErrorHelper(
NULL, VIR_FROM_NET, code, __FILE__,
\
__FUNCTION__, __LINE__, __VA_ARGS__)
# define MACVTAP_NAME_PREFIX "macvtap"
...
...
@@ -193,7 +193,7 @@ nlAppend(struct nlmsghdr *nlm, int totlen, const void *data, int datalen)
static
int
getIfIndex
(
virConnectPtr
conn
,
getIfIndex
(
bool
reportError
,
const
char
*
ifname
,
int
*
idx
)
{
...
...
@@ -206,8 +206,8 @@ getIfIndex(virConnectPtr conn,
if
(
virStrncpy
(
ifreq
.
ifr_name
,
ifname
,
strlen
(
ifname
),
sizeof
(
ifreq
.
ifr_name
))
==
NULL
)
{
if
(
conn
)
ReportError
(
conn
,
VIR_ERR_INTERNAL_ERROR
,
if
(
reportError
)
macvtapError
(
VIR_ERR_INTERNAL_ERROR
,
_
(
"invalid interface name %s"
),
ifname
);
rc
=
EINVAL
;
...
...
@@ -216,8 +216,8 @@ getIfIndex(virConnectPtr conn,
if
(
ioctl
(
fd
,
SIOCGIFINDEX
,
&
ifreq
)
>=
0
)
*
idx
=
ifreq
.
ifr_ifindex
;
else
{
if
(
conn
)
ReportError
(
conn
,
VIR_ERR_INTERNAL_ERROR
,
if
(
reportError
)
macvtapError
(
VIR_ERR_INTERNAL_ERROR
,
_
(
"interface %s does not exist"
),
ifname
);
rc
=
ENODEV
;
...
...
@@ -296,8 +296,7 @@ ifUp(const char *name, int up)
static
int
link_add
(
virConnectPtr
conn
,
const
char
*
type
,
link_add
(
const
char
*
type
,
const
unsigned
char
*
macaddress
,
int
macaddrsize
,
const
char
*
ifname
,
const
char
*
srcdev
,
...
...
@@ -315,7 +314,7 @@ link_add(virConnectPtr conn,
char
*
recvbuf
=
NULL
;
int
recvbuflen
;
if
(
getIfIndex
(
conn
,
srcdev
,
&
ifindex
)
!=
0
)
if
(
getIfIndex
(
true
,
srcdev
,
&
ifindex
)
!=
0
)
return
-
1
;
*
retry
=
0
;
...
...
@@ -434,14 +433,14 @@ link_add(virConnectPtr conn,
return
rc
;
malformed_resp:
ReportError
(
conn
,
VIR_ERR_INTERNAL_ERROR
,
"%s"
,
_
(
"malformed netlink response message"
));
macvtapError
(
VIR_ERR_INTERNAL_ERROR
,
"%s"
,
_
(
"malformed netlink response message"
));
VIR_FREE
(
recvbuf
);
return
-
1
;
buffer_too_small:
ReportError
(
conn
,
VIR_ERR_INTERNAL_ERROR
,
"%s"
,
_
(
"internal buffer is too small"
));
macvtapError
(
VIR_ERR_INTERNAL_ERROR
,
"%s"
,
_
(
"internal buffer is too small"
));
return
-
1
;
}
...
...
@@ -512,21 +511,20 @@ link_del(const char *name)
return
rc
;
malformed_resp:
ReportError
(
NULL
,
VIR_ERR_INTERNAL_ERROR
,
"%s"
,
_
(
"malformed netlink response message"
));
macvtapError
(
VIR_ERR_INTERNAL_ERROR
,
"%s"
,
_
(
"malformed netlink response message"
));
VIR_FREE
(
recvbuf
);
return
-
1
;
buffer_too_small:
ReportError
(
NULL
,
VIR_ERR_INTERNAL_ERROR
,
"%s"
,
_
(
"internal buffer is too small"
));
macvtapError
(
VIR_ERR_INTERNAL_ERROR
,
"%s"
,
_
(
"internal buffer is too small"
));
return
-
1
;
}
/* Open the macvtap's tap device.
* @conn: Pointer to virConnect object
* @name: Name of the macvtap interface
* @ifname: Name of the macvtap interface
* @retries : Number of retries in case udev for example may need to be
* waited for to create the tap chardev
* Returns negative value in case of error, the file descriptor otherwise.
...
...
@@ -677,7 +675,6 @@ configMacvtapTap(int tapfd, int vnet_hdr)
* openMacvtapTap:
* Create an instance of a macvtap device and open its tap character
* device.
* @conn: Pointer to virConnect object
* @tgifname: Interface name that the macvtap is supposed to have. May
* be NULL if this function is supposed to choose a name
* @macaddress: The MAC address for the macvtap device
...
...
@@ -689,13 +686,11 @@ configMacvtapTap(int tapfd, int vnet_hdr)
* to the caller to free the string.
*
* Returns file descriptor of the tap device in case of success,
* negative value otherwise with error message attached to the 'conn'
* object.
* negative value otherwise with error reported.
*
*/
int
openMacvtapTap
(
virConnectPtr
conn
,
const
char
*
tgifname
,
openMacvtapTap
(
const
char
*
tgifname
,
const
unsigned
char
*
macaddress
,
const
char
*
linkdev
,
int
mode
,
...
...
@@ -713,7 +708,7 @@ openMacvtapTap(virConnectPtr conn,
*
res_ifname
=
NULL
;
if
(
tgifname
)
{
if
(
getIfIndex
(
NULL
,
tgifname
,
&
ifindex
)
==
0
)
{
if
(
getIfIndex
(
false
,
tgifname
,
&
ifindex
)
==
0
)
{
if
(
STRPREFIX
(
tgifname
,
MACVTAP_NAME_PREFIX
))
{
goto
create_name
;
...
...
@@ -723,7 +718,7 @@ openMacvtapTap(virConnectPtr conn,
return
-
1
;
}
cr_ifname
=
tgifname
;
rc
=
link_add
(
conn
,
type
,
macaddress
,
6
,
tgifname
,
linkdev
,
rc
=
link_add
(
type
,
macaddress
,
6
,
tgifname
,
linkdev
,
macvtapMode
,
&
do_retry
);
if
(
rc
)
return
-
1
;
...
...
@@ -732,8 +727,8 @@ create_name:
retries
=
5
;
for
(
c
=
0
;
c
<
8192
;
c
++
)
{
snprintf
(
ifname
,
sizeof
(
ifname
),
MACVTAP_NAME_PATTERN
,
c
);
if
(
getIfIndex
(
NULL
,
ifname
,
&
ifindex
)
==
ENODEV
)
{
rc
=
link_add
(
conn
,
type
,
macaddress
,
6
,
ifname
,
linkdev
,
if
(
getIfIndex
(
false
,
ifname
,
&
ifindex
)
==
ENODEV
)
{
rc
=
link_add
(
type
,
macaddress
,
6
,
ifname
,
linkdev
,
macvtapMode
,
&
do_retry
);
if
(
rc
==
0
)
break
;
...
...
src/util/macvtap.h
浏览文件 @
0d7d6997
...
...
@@ -28,8 +28,7 @@
# include "internal.h"
int
openMacvtapTap
(
virConnectPtr
conn
,
const
char
*
ifname
,
int
openMacvtapTap
(
const
char
*
ifname
,
const
unsigned
char
*
macaddress
,
const
char
*
linkdev
,
int
mode
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录