Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
f30b84f9
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看板
提交
f30b84f9
编写于
3月 08, 2007
作者:
D
Daniel P. Berrange
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Refactored driver reg to avoid type-punning
上级
89de0c87
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
51 addition
and
52 deletion
+51
-52
ChangeLog
ChangeLog
+7
-1
src/libvirt.c
src/libvirt.c
+44
-51
未找到文件。
ChangeLog
浏览文件 @
f30b84f9
Thu Mar 8 09:47:24 EST 2007 Daniel P. Berrange <berrange@redhat.com>
* src/libvirt.c: Refactored driver registration to avoid
type-punning problems by casting different structs. Also
fix network driver opening to open read-only when needed.
Thu Mar 8 15:10:12 CET 2007 Daniel Veillard <veillard@redhat.com>
* src/internal.h src/xend_internal.c src/xm_internal.c src/xml.c:
...
...
@@ -5,7 +11,7 @@ Thu Mar 8 15:10:12 CET 2007 Daniel Veillard <veillard@redhat.com>
had arbitrary minimal memory requirement and use a predefined
macro to clean this up.
Thu Mar 8 08:45:46 EST 2007 Daniel P.
,
Berrange <berrange@redhat.com>
Thu Mar 8 08:45:46 EST 2007 Daniel P. Berrange <berrange@redhat.com>
* src/virsh.c: Added an explicit --readonly option to virsh
to override the simple Xen-specific heuristic when running
...
...
src/libvirt.c
浏览文件 @
f30b84f9
...
...
@@ -42,7 +42,9 @@
*/
static
virDriverPtr
virDriverTab
[
MAX_DRIVERS
];
static
int
virDriverTabCount
=
0
;
static
virNetworkDriverPtr
virNetworkDriverTab
[
MAX_DRIVERS
];
static
int
virNetworkDriverTabCount
=
0
;
static
int
initialized
=
0
;
/**
...
...
@@ -57,8 +59,6 @@ static int initialized = 0;
int
virInitialize
(
void
)
{
int
i
;
if
(
initialized
)
return
(
0
);
initialized
=
1
;
...
...
@@ -66,14 +66,6 @@ virInitialize(void)
if
(
!
bindtextdomain
(
GETTEXT_PACKAGE
,
LOCALEBASEDIR
))
return
(
-
1
);
/*
* should not be needed but...
*/
for
(
i
=
0
;
i
<
MAX_DRIVERS
;
i
++
)
{
virDriverTab
[
i
]
=
NULL
;
virNetworkDriverTab
[
i
]
=
NULL
;
}
/*
* Note that the order is important the first ones have a higher priority
*/
...
...
@@ -163,35 +155,6 @@ virLibNetworkError(virNetworkPtr network, virErrorNumber error,
errmsg
,
info
,
NULL
,
0
,
0
,
errmsg
,
info
);
}
static
int
_virRegisterDriver
(
void
*
driver
,
int
isNetwork
)
{
void
**
drivers
;
int
i
;
if
(
!
initialized
)
if
(
virInitialize
()
<
0
)
return
-
1
;
if
(
driver
==
NULL
)
{
virLibConnError
(
NULL
,
VIR_ERR_INVALID_ARG
,
__FUNCTION__
);
return
(
-
1
);
}
drivers
=
isNetwork
?
(
void
**
)
virNetworkDriverTab
:
(
void
**
)
virDriverTab
;
for
(
i
=
0
;
i
<
MAX_DRIVERS
;
i
++
)
{
if
(
drivers
[
i
]
==
driver
)
return
(
i
);
}
for
(
i
=
0
;
i
<
MAX_DRIVERS
;
i
++
)
{
if
(
drivers
[
i
]
==
NULL
)
{
drivers
[
i
]
=
driver
;
return
(
i
);
}
}
virLibConnError
(
NULL
,
VIR_ERR_INVALID_ARG
,
__FUNCTION__
);
return
(
-
1
);
}
/**
* virRegisterNetworkDriver:
* @driver: pointer to a network driver block
...
...
@@ -203,7 +166,21 @@ _virRegisterDriver(void *driver, int isNetwork)
int
virRegisterNetworkDriver
(
virNetworkDriverPtr
driver
)
{
return
_virRegisterDriver
(
driver
,
1
);
if
(
virInitialize
()
<
0
)
return
-
1
;
if
(
driver
==
NULL
)
{
virLibConnError
(
NULL
,
VIR_ERR_INVALID_ARG
,
__FUNCTION__
);
return
(
-
1
);
}
if
(
virNetworkDriverTabCount
>=
MAX_DRIVERS
)
{
virLibConnError
(
NULL
,
VIR_ERR_INVALID_ARG
,
__FUNCTION__
);
return
(
-
1
);
}
virNetworkDriverTab
[
virNetworkDriverTabCount
]
=
driver
;
return
virNetworkDriverTabCount
++
;
}
/**
...
...
@@ -217,7 +194,21 @@ virRegisterNetworkDriver(virNetworkDriverPtr driver)
int
virRegisterDriver
(
virDriverPtr
driver
)
{
return
_virRegisterDriver
(
driver
,
0
);
if
(
virInitialize
()
<
0
)
return
-
1
;
if
(
driver
==
NULL
)
{
virLibConnError
(
NULL
,
VIR_ERR_INVALID_ARG
,
__FUNCTION__
);
return
(
-
1
);
}
if
(
virDriverTabCount
>=
MAX_DRIVERS
)
{
virLibConnError
(
NULL
,
VIR_ERR_INVALID_ARG
,
__FUNCTION__
);
return
(
-
1
);
}
virDriverTab
[
virDriverTabCount
]
=
driver
;
return
virDriverTabCount
++
;
}
/**
...
...
@@ -252,14 +243,14 @@ virGetVersion(unsigned long *libVer, const char *type,
if
(
typeVer
!=
NULL
)
{
if
(
type
==
NULL
)
type
=
"Xen"
;
for
(
i
=
0
;
i
<
MAX_DRIVERS
;
i
++
)
{
for
(
i
=
0
;
i
<
virDriverTabCount
;
i
++
)
{
if
((
virDriverTab
[
i
]
!=
NULL
)
&&
(
!
strcmp
(
virDriverTab
[
i
]
->
name
,
type
)))
{
*
typeVer
=
virDriverTab
[
i
]
->
ver
;
break
;
}
}
if
(
i
>=
MAX_DRIVERS
)
{
if
(
i
>=
virDriverTabCount
)
{
*
typeVer
=
0
;
virLibConnError
(
NULL
,
VIR_ERR_NO_SUPPORT
,
type
);
return
(
-
1
);
...
...
@@ -300,8 +291,8 @@ virConnectOpen(const char *name)
goto
failed
;
}
for
(
i
=
0
;
i
<
MAX_DRIVERS
;
i
++
)
{
if
((
virDriverTab
[
i
]
!=
NULL
)
&&
(
virDriverTab
[
i
]
->
open
!=
NULL
))
{
for
(
i
=
0
;
i
<
virDriverTabCount
;
i
++
)
{
if
((
virDriverTab
[
i
]
->
open
!=
NULL
))
{
res
=
virDriverTab
[
i
]
->
open
(
ret
,
name
,
VIR_DRV_OPEN_QUIET
);
/*
* For a default connect to Xen make sure we manage to contact
...
...
@@ -316,8 +307,8 @@ virConnectOpen(const char *name)
}
}
for
(
i
=
0
;
i
<
MAX_DRIVERS
;
i
++
)
{
if
((
virNetworkDriverTab
[
i
]
!=
NULL
)
&&
(
virNetworkDriverTab
[
i
]
->
open
!=
NULL
)
&&
for
(
i
=
0
;
i
<
virNetworkDriverTabCount
;
i
++
)
{
if
((
virNetworkDriverTab
[
i
]
->
open
!=
NULL
)
&&
(
res
=
virNetworkDriverTab
[
i
]
->
open
(
ret
,
name
,
VIR_DRV_OPEN_QUIET
))
==
0
)
{
ret
->
networkDrivers
[
ret
->
nb_network_drivers
++
]
=
virNetworkDriverTab
[
i
];
}
...
...
@@ -375,16 +366,18 @@ virConnectOpenReadOnly(const char *name)
goto
failed
;
}
for
(
i
=
0
;
i
<
MAX_DRIVERS
;
i
++
)
{
if
((
virDriverTab
[
i
]
!=
NULL
)
&&
(
virDriverTab
[
i
]
->
open
!=
NULL
))
{
for
(
i
=
0
;
i
<
virDriverTabCount
;
i
++
)
{
if
((
virDriverTab
[
i
]
->
open
!=
NULL
))
{
res
=
virDriverTab
[
i
]
->
open
(
ret
,
name
,
VIR_DRV_OPEN_QUIET
|
VIR_DRV_OPEN_RO
);
if
(
res
==
0
)
ret
->
drivers
[
ret
->
nb_drivers
++
]
=
virDriverTab
[
i
];
}
if
((
virNetworkDriverTab
[
i
]
!=
NULL
)
&&
(
virNetworkDriverTab
[
i
]
->
open
!=
NULL
)
&&
(
res
=
virNetworkDriverTab
[
i
]
->
open
(
ret
,
name
,
VIR_DRV_OPEN_QUIET
))
==
0
)
{
}
for
(
i
=
0
;
i
<
virNetworkDriverTabCount
;
i
++
)
{
if
((
virNetworkDriverTab
[
i
]
->
open
!=
NULL
)
&&
(
res
=
virNetworkDriverTab
[
i
]
->
open
(
ret
,
name
,
VIR_DRV_OPEN_QUIET
|
VIR_DRV_OPEN_RO
))
==
0
)
{
ret
->
networkDrivers
[
ret
->
nb_network_drivers
++
]
=
virNetworkDriverTab
[
i
];
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录