Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
381fa1fc
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,发现更多精彩内容 >>
提交
381fa1fc
编写于
7月 11, 2008
作者:
D
Daniel P. Berrange
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Switch QEMU driver over to generic network APIs
上级
d78c0a68
变更
6
展开全部
隐藏空白更改
内联
并排
Showing
6 changed file
with
235 addition
and
935 deletion
+235
-935
ChangeLog
ChangeLog
+5
-0
src/bridge.c
src/bridge.c
+23
-42
src/bridge.h
src/bridge.h
+1
-3
src/qemu_conf.c
src/qemu_conf.c
+7
-619
src/qemu_conf.h
src/qemu_conf.h
+4
-91
src/qemu_driver.c
src/qemu_driver.c
+195
-180
未找到文件。
ChangeLog
浏览文件 @
381fa1fc
Fri Jul 11 18:32:59 BST 2008 Daniel P. Berrange <berrange@redhat.com>
* src/bridge.c, src/bridge.h, src/qemu_conf.c, src/qemu_conf.h,
src/qemu_driver.c: Switch over to generic network APIs
Fri Jul 11 17:39:59 BST 2008 Daniel P. Berrange <berrange@redhat.com>
Fri Jul 11 17:39:59 BST 2008 Daniel P. Berrange <berrange@redhat.com>
* src/test.c, src/test.h: Convert to the new domain XML apis
* src/test.c, src/test.h: Convert to the new domain XML apis
...
...
src/bridge.c
浏览文件 @
381fa1fc
...
@@ -116,60 +116,41 @@ brShutdown(brControl *ctl)
...
@@ -116,60 +116,41 @@ brShutdown(brControl *ctl)
/**
/**
* brAddBridge:
* brAddBridge:
* @ctl: bridge control pointer
* @ctl: bridge control pointer
* @nameOrFmt: the bridge name (or name template)
* @name: the bridge name
* @name: pointer to @maxlen bytes to store the bridge name
* @maxlen: size of @name array
*
*
* This function register a new bridge, @nameOrFmt can be either
* This function register a new bridge
* a fixed name or a name template with '%d' for dynamic name allocation.
* in either case the final name for the bridge will be stored in @name.
*
*
* Returns 0 in case of success or an errno code in case of failure.
* Returns 0 in case of success or an errno code in case of failure.
*/
*/
#ifdef SIOCBRADDBR
#ifdef SIOCBRADDBR
int
int
brAddBridge
(
brControl
*
ctl
,
brAddBridge
(
brControl
*
ctl
,
const
char
*
nameOrFmt
,
char
**
name
)
char
*
name
,
int
maxlen
)
{
{
int
id
,
subst
;
if
(
!
ctl
||
!
ctl
->
fd
||
!
name
)
if
(
!
ctl
||
!
ctl
->
fd
||
!
nameOrFmt
||
!
name
)
return
EINVAL
;
return
EINVAL
;
if
(
maxlen
>=
BR_IFNAME_MAXLEN
)
if
(
*
name
)
{
maxlen
=
BR_IFNAME_MAXLEN
;
if
(
ioctl
(
ctl
->
fd
,
SIOCBRADDBR
,
*
name
)
==
0
)
subst
=
id
=
0
;
if
(
strstr
(
nameOrFmt
,
"%d"
))
subst
=
1
;
do
{
char
try
[
BR_IFNAME_MAXLEN
];
int
len
;
if
(
subst
)
{
len
=
snprintf
(
try
,
maxlen
,
nameOrFmt
,
id
);
if
(
len
>=
maxlen
)
return
EADDRINUSE
;
}
else
{
len
=
strlen
(
nameOrFmt
);
if
(
len
>=
maxlen
-
1
)
return
EINVAL
;
strncpy
(
try
,
nameOrFmt
,
len
);
try
[
len
]
=
'\0'
;
}
if
(
ioctl
(
ctl
->
fd
,
SIOCBRADDBR
,
try
)
==
0
)
{
strncpy
(
name
,
try
,
maxlen
);
return
0
;
return
0
;
}
}
else
{
int
id
=
0
;
do
{
char
try
[
50
];
snprintf
(
try
,
sizeof
(
try
),
"virbr%d"
,
id
);
if
(
ioctl
(
ctl
->
fd
,
SIOCBRADDBR
,
try
)
==
0
)
{
if
(
!
(
*
name
=
strdup
(
try
)))
{
ioctl
(
ctl
->
fd
,
SIOCBRDELBR
,
name
);
return
ENOMEM
;
}
return
0
;
}
id
++
;
id
++
;
}
while
(
subst
&&
id
<=
MAX_BRIDGE_ID
);
}
while
(
id
<
MAX_BRIDGE_ID
);
}
return
errno
;
return
errno
;
}
}
...
...
src/bridge.h
浏览文件 @
381fa1fc
...
@@ -47,9 +47,7 @@ int brInit (brControl **ctl);
...
@@ -47,9 +47,7 @@ int brInit (brControl **ctl);
void
brShutdown
(
brControl
*
ctl
);
void
brShutdown
(
brControl
*
ctl
);
int
brAddBridge
(
brControl
*
ctl
,
int
brAddBridge
(
brControl
*
ctl
,
const
char
*
nameOrFmt
,
char
**
name
);
char
*
name
,
int
maxlen
);
int
brDeleteBridge
(
brControl
*
ctl
,
int
brDeleteBridge
(
brControl
*
ctl
,
const
char
*
name
);
const
char
*
name
);
...
...
src/qemu_conf.c
浏览文件 @
381fa1fc
此差异已折叠。
点击以展开。
src/qemu_conf.h
浏览文件 @
381fa1fc
...
@@ -32,6 +32,7 @@
...
@@ -32,6 +32,7 @@
#include "bridge.h"
#include "bridge.h"
#include "iptables.h"
#include "iptables.h"
#include "capabilities.h"
#include "capabilities.h"
#include "network_conf.h"
#include <netinet/in.h>
#include <netinet/in.h>
#include <sched.h>
#include <sched.h>
...
@@ -96,12 +97,6 @@ enum qemud_vm_net_type {
...
@@ -96,12 +97,6 @@ enum qemud_vm_net_type {
QEMUD_NET_BRIDGE
,
QEMUD_NET_BRIDGE
,
};
};
/* 2 possible types of forwarding */
enum
qemud_vm_net_forward_type
{
QEMUD_NET_FORWARD_NAT
,
QEMUD_NET_FORWARD_ROUTE
,
};
#define QEMUD_MAX_NAME_LEN 50
#define QEMUD_MAX_NAME_LEN 50
#define QEMUD_MAX_XML_LEN 4096
#define QEMUD_MAX_XML_LEN 4096
#define QEMUD_MAX_ERROR_LEN 1024
#define QEMUD_MAX_ERROR_LEN 1024
...
@@ -349,53 +344,6 @@ struct qemud_vm {
...
@@ -349,53 +344,6 @@ struct qemud_vm {
struct
qemud_vm
*
next
;
struct
qemud_vm
*
next
;
};
};
/* Store start and end addresses of a dhcp range */
struct
qemud_dhcp_range_def
{
char
start
[
BR_INET_ADDR_MAXLEN
];
char
end
[
BR_INET_ADDR_MAXLEN
];
struct
qemud_dhcp_range_def
*
next
;
};
/* Virtual Network main configuration */
struct
qemud_network_def
{
unsigned
char
uuid
[
VIR_UUID_BUFLEN
];
char
name
[
QEMUD_MAX_NAME_LEN
];
char
bridge
[
BR_IFNAME_MAXLEN
];
int
disableSTP
;
int
forwardDelay
;
int
forward
;
int
forwardMode
;
/* From qemud_vm_net_forward_type */
char
forwardDev
[
BR_IFNAME_MAXLEN
];
char
ipAddress
[
BR_INET_ADDR_MAXLEN
];
char
netmask
[
BR_INET_ADDR_MAXLEN
];
char
network
[
BR_INET_ADDR_MAXLEN
+
BR_INET_ADDR_MAXLEN
+
1
];
int
nranges
;
struct
qemud_dhcp_range_def
*
ranges
;
};
/* Virtual Network runtime state */
struct
qemud_network
{
char
configFile
[
PATH_MAX
];
char
autostartLink
[
PATH_MAX
];
struct
qemud_network_def
*
def
;
/* The current definition */
struct
qemud_network_def
*
newDef
;
/* New definition to activate at shutdown */
char
bridge
[
BR_IFNAME_MAXLEN
];
int
dnsmasqPid
;
unsigned
int
active
:
1
;
unsigned
int
autostart
:
1
;
struct
qemud_network
*
next
;
};
/* Main driver state */
/* Main driver state */
struct
qemud_driver
{
struct
qemud_driver
{
int
qemuVersion
;
int
qemuVersion
;
...
@@ -403,9 +351,9 @@ struct qemud_driver {
...
@@ -403,9 +351,9 @@ struct qemud_driver {
int
ninactivevms
;
int
ninactivevms
;
struct
qemud_vm
*
vms
;
struct
qemud_vm
*
vms
;
int
nextvmid
;
int
nextvmid
;
int
nactivenetworks
;
int
ninactive
networks
;
virNetworkObjPtr
networks
;
struct
qemud_network
*
networks
;
brControl
*
brctl
;
brControl
*
brctl
;
iptablesContext
*
iptables
;
iptablesContext
*
iptables
;
char
*
configDir
;
char
*
configDir
;
...
@@ -428,12 +376,6 @@ qemudIsActiveVM(const struct qemud_vm *vm)
...
@@ -428,12 +376,6 @@ qemudIsActiveVM(const struct qemud_vm *vm)
return
vm
->
id
!=
-
1
;
return
vm
->
id
!=
-
1
;
}
}
static
inline
int
qemudIsActiveNetwork
(
const
struct
qemud_network
*
network
)
{
return
network
->
active
;
}
void
qemudReportError
(
virConnectPtr
conn
,
void
qemudReportError
(
virConnectPtr
conn
,
virDomainPtr
dom
,
virDomainPtr
dom
,
virNetworkPtr
net
,
virNetworkPtr
net
,
...
@@ -451,11 +393,6 @@ struct qemud_vm *qemudFindVMByUUID(const struct qemud_driver *driver,
...
@@ -451,11 +393,6 @@ struct qemud_vm *qemudFindVMByUUID(const struct qemud_driver *driver,
struct
qemud_vm
*
qemudFindVMByName
(
const
struct
qemud_driver
*
driver
,
struct
qemud_vm
*
qemudFindVMByName
(
const
struct
qemud_driver
*
driver
,
const
char
*
name
);
const
char
*
name
);
struct
qemud_network
*
qemudFindNetworkByUUID
(
const
struct
qemud_driver
*
driver
,
const
unsigned
char
*
uuid
);
struct
qemud_network
*
qemudFindNetworkByName
(
const
struct
qemud_driver
*
driver
,
const
char
*
name
);
virCapsPtr
qemudCapsInit
(
void
);
virCapsPtr
qemudCapsInit
(
void
);
int
qemudExtractVersion
(
virConnectPtr
conn
,
int
qemudExtractVersion
(
virConnectPtr
conn
,
...
@@ -501,30 +438,6 @@ char * qemudGenerateXML (virConnectPtr conn,
...
@@ -501,30 +438,6 @@ char * qemudGenerateXML (virConnectPtr conn,
struct
qemud_vm_def
*
def
,
struct
qemud_vm_def
*
def
,
int
live
);
int
live
);
void
qemudFreeNetworkDef
(
struct
qemud_network_def
*
def
);
void
qemudFreeNetwork
(
struct
qemud_network
*
network
);
struct
qemud_network
*
qemudAssignNetworkDef
(
virConnectPtr
conn
,
struct
qemud_driver
*
driver
,
struct
qemud_network_def
*
def
);
void
qemudRemoveInactiveNetwork
(
struct
qemud_driver
*
driver
,
struct
qemud_network
*
network
);
struct
qemud_network_def
*
qemudParseNetworkDef
(
virConnectPtr
conn
,
struct
qemud_driver
*
driver
,
const
char
*
xmlStr
,
const
char
*
displayName
);
int
qemudSaveNetworkDef
(
virConnectPtr
conn
,
struct
qemud_driver
*
driver
,
struct
qemud_network
*
network
,
struct
qemud_network_def
*
def
);
char
*
qemudGenerateNetworkXML
(
virConnectPtr
conn
,
struct
qemud_driver
*
driver
,
struct
qemud_network
*
network
,
struct
qemud_network_def
*
def
);
const
char
*
qemudVirtTypeToString
(
int
type
);
const
char
*
qemudVirtTypeToString
(
int
type
);
#endif
/* WITH_QEMU */
#endif
/* WITH_QEMU */
...
...
src/qemu_driver.c
浏览文件 @
381fa1fc
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录