Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
442b733e
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看板
提交
442b733e
编写于
6月 15, 2006
作者:
D
Daniel Veillard
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
* src/libvirt.c src/xend_internal.c src/xend_internal.h
src/xs_internal.c: more cleanups for the driver architecture Daniel
上级
4ab26461
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
127 addition
and
131 deletion
+127
-131
ChangeLog
ChangeLog
+5
-0
src/libvirt.c
src/libvirt.c
+2
-116
src/xend_internal.c
src/xend_internal.c
+119
-4
src/xend_internal.h
src/xend_internal.h
+0
-10
src/xs_internal.c
src/xs_internal.c
+1
-1
未找到文件。
ChangeLog
浏览文件 @
442b733e
Thu Jun 15 14:57:39 EDT 2006 Daniel Veillard <veillard@redhat.com>
* src/libvirt.c src/xend_internal.c src/xend_internal.h
src/xs_internal.c: more cleanups for the driver architecture
Wed Jun 14 18:59:30 EDT 2006 Daniel P. Berrange <berrange@redhat.com>
* src/test.h, src/test.c: Added implementation of the reboot
...
...
src/libvirt.c
浏览文件 @
442b733e
...
...
@@ -592,13 +592,7 @@ virDomainCreateLinux(virConnectPtr conn,
virDomainPtr
virDomainLookupByID
(
virConnectPtr
conn
,
int
id
)
{
char
*
path
=
NULL
;
char
**
names
;
char
**
tmp
;
int
ident
;
virDomainPtr
ret
;
char
*
name
=
NULL
;
unsigned
char
uuid
[
16
];
int
i
;
if
(
!
VIR_IS_CONNECT
(
conn
))
{
...
...
@@ -620,45 +614,6 @@ virDomainLookupByID(virConnectPtr conn, int id)
}
}
/* retrieve home path of the domain */
if
(
conn
->
xshandle
!=
NULL
)
{
path
=
xs_get_domain_path
(
conn
->
xshandle
,
(
unsigned
int
)
id
);
}
/* path does not contain name, use xend API to retrieve name */
names
=
xenDaemonListDomainsOld
(
conn
);
tmp
=
names
;
if
(
names
!=
NULL
)
{
while
(
*
tmp
!=
NULL
)
{
ident
=
xenDaemonDomainLookupByName_ids
(
conn
,
*
tmp
,
&
uuid
[
0
]);
if
(
ident
==
id
)
{
name
=
strdup
(
*
tmp
);
break
;
}
tmp
++
;
}
free
(
names
);
}
if
(
name
==
NULL
)
goto
error
;
ret
=
virGetDomain
(
conn
,
name
,
uuid
);
if
(
ret
==
NULL
)
{
virLibConnError
(
conn
,
VIR_ERR_NO_MEMORY
,
"Allocating domain"
);
goto
error
;
}
ret
->
handle
=
id
;
ret
->
path
=
path
;
if
(
name
!=
NULL
)
free
(
name
);
return
(
ret
);
error:
if
(
name
!=
NULL
)
free
(
name
);
if
(
path
!=
NULL
)
free
(
path
);
return
(
NULL
);
}
...
...
@@ -675,11 +630,6 @@ virDomainPtr
virDomainLookupByUUID
(
virConnectPtr
conn
,
const
unsigned
char
*
uuid
)
{
virDomainPtr
ret
;
char
*
name
=
NULL
;
char
**
names
;
char
**
tmp
;
unsigned
char
ident
[
16
];
int
id
=
-
1
;
int
i
;
if
(
!
VIR_IS_CONNECT
(
conn
))
{
...
...
@@ -701,37 +651,7 @@ virDomainLookupByUUID(virConnectPtr conn, const unsigned char *uuid)
}
}
names
=
xenDaemonListDomainsOld
(
conn
);
tmp
=
names
;
if
(
names
==
NULL
)
{
TODO
/* try to fallback to xenstore lookup */
return
(
NULL
);
}
while
(
*
tmp
!=
NULL
)
{
id
=
xenDaemonDomainLookupByName_ids
(
conn
,
*
tmp
,
&
ident
[
0
]);
if
(
id
>=
0
)
{
if
(
!
memcmp
(
uuid
,
ident
,
16
))
{
name
=
strdup
(
*
tmp
);
break
;
}
}
tmp
++
;
}
free
(
names
);
if
(
name
==
NULL
)
return
(
NULL
);
ret
=
virGetDomain
(
conn
,
name
,
uuid
);
if
(
ret
==
NULL
)
{
if
(
name
!=
NULL
)
free
(
name
);
return
(
NULL
);
}
ret
->
handle
=
id
;
return
(
ret
);
return
(
NULL
);
}
/**
...
...
@@ -816,20 +736,7 @@ virDomainLookupByName(virConnectPtr conn, const char *name)
return
(
ret
);
}
}
/* try first though Xend */
ret
=
xenDaemonDomainLookupByName
(
conn
,
name
);
if
(
ret
!=
NULL
)
{
return
(
ret
);
}
/* then though the XenStore */
ret
=
xenStoreDomainLookupByName
(
conn
,
name
);
if
(
ret
!=
NULL
)
{
return
(
ret
);
}
return
(
ret
);
return
(
NULL
);
}
/**
...
...
@@ -1499,27 +1406,6 @@ virDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info)
}
}
/*
* if we have direct access though the hypervisor do a direct call
*/
if
(
domain
->
conn
->
handle
>=
0
)
{
ret
=
xenHypervisorGetDomainInfo
(
domain
,
info
);
if
(
ret
==
0
)
return
(
0
);
}
/*
* try to extract the informations though access to the Xen Daemon
*/
if
(
xenDaemonDomainGetInfo
(
domain
,
info
)
==
0
)
return
(
0
);
/*
* last fallback, try to get the informations from the Xen store
*/
if
(
xenStoreGetDomainInfo
(
domain
,
info
)
==
0
)
return
(
0
);
return
(
-
1
);
}
...
...
src/xend_internal.c
浏览文件 @
442b733e
...
...
@@ -41,6 +41,9 @@ static int xenDaemonNodeGetInfo(virConnectPtr conn, virNodeInfoPtr info);
static
int
xenDaemonGetVersion
(
virConnectPtr
conn
,
unsigned
long
*
hvVer
);
static
int
xenDaemonListDomains
(
virConnectPtr
conn
,
int
*
ids
,
int
maxids
);
static
int
xenDaemonNumOfDomains
(
virConnectPtr
conn
);
static
virDomainPtr
xenDaemonLookupByID
(
virConnectPtr
conn
,
int
id
);
static
virDomainPtr
xenDaemonLookupByUUID
(
virConnectPtr
conn
,
const
unsigned
char
*
uuid
);
static
virDriver
xenDaemonDriver
=
{
"XenDaemon"
,
...
...
@@ -56,9 +59,9 @@ static virDriver xenDaemonDriver = {
xenDaemonListDomains
,
/* listDomains */
xenDaemonNumOfDomains
,
/* numOfDomains */
NULL
,
/* domainCreateLinux */
NULL
,
/* domainLookupByID */
NULL
,
/* domainLookupByUUID */
NULL
,
/* domainLookupByName */
xenDaemonLookupByID
,
/* domainLookupByID */
xenDaemonLookupByUUID
,
/* domainLookupByUUID */
xenDaemonDomainLookupByName
,
/* domainLookupByName */
xenDaemonDomainSuspend
,
/* domainSuspend */
xenDaemonDomainResume
,
/* domainResume */
xenDaemonDomainShutdown
,
/* domainShutdown */
...
...
@@ -1007,7 +1010,7 @@ xend_sysrq(virConnectPtr xend, const char *name, const char *key)
*
* Returns a list of names or NULL in case of error.
*/
char
**
static
char
**
xenDaemonListDomainsOld
(
virConnectPtr
xend
)
{
size_t
extra
=
0
;
...
...
@@ -2225,3 +2228,115 @@ error:
sexpr_free
(
root
);
return
(
ret
);
}
/**
* xenDaemonLookupByID:
* @conn: pointer to the hypervisor connection
* @id: the domain ID number
*
* Try to find a domain based on the hypervisor ID number
*
* Returns a new domain object or NULL in case of failure
*/
static
virDomainPtr
xenDaemonLookupByID
(
virConnectPtr
conn
,
int
id
)
{
char
**
names
;
char
**
tmp
;
int
ident
;
char
*
name
=
NULL
;
unsigned
char
uuid
[
16
];
virDomainPtr
ret
;
/*
* Xend API forces to collect the full domain list by names, and then
* query each of them until the id is found
*/
names
=
xenDaemonListDomainsOld
(
conn
);
tmp
=
names
;
if
(
names
!=
NULL
)
{
while
(
*
tmp
!=
NULL
)
{
ident
=
xenDaemonDomainLookupByName_ids
(
conn
,
*
tmp
,
&
uuid
[
0
]);
if
(
ident
==
id
)
{
name
=
strdup
(
*
tmp
);
break
;
}
tmp
++
;
}
free
(
names
);
}
if
(
name
==
NULL
)
goto
error
;
ret
=
virGetDomain
(
conn
,
name
,
uuid
);
if
(
ret
==
NULL
)
{
virXendError
(
conn
,
VIR_ERR_NO_MEMORY
,
"Allocating domain"
);
goto
error
;
}
ret
->
handle
=
id
;
if
(
name
!=
NULL
)
free
(
name
);
return
(
ret
);
error:
if
(
name
!=
NULL
)
free
(
name
);
return
(
NULL
);
}
/**
* xenDaemonLookupByUUID:
* @conn: pointer to the hypervisor connection
* @uuid: the raw UUID for the domain
*
* Try to lookup a domain on xend based on its UUID.
*
* Returns a new domain object or NULL in case of failure
*/
static
virDomainPtr
xenDaemonLookupByUUID
(
virConnectPtr
conn
,
const
unsigned
char
*
uuid
)
{
virDomainPtr
ret
;
char
*
name
=
NULL
;
char
**
names
;
char
**
tmp
;
unsigned
char
ident
[
16
];
int
id
=
-
1
;
names
=
xenDaemonListDomainsOld
(
conn
);
tmp
=
names
;
if
(
names
==
NULL
)
{
TODO
/* try to fallback to xenstore lookup */
return
(
NULL
);
}
while
(
*
tmp
!=
NULL
)
{
id
=
xenDaemonDomainLookupByName_ids
(
conn
,
*
tmp
,
&
ident
[
0
]);
if
(
id
>=
0
)
{
if
(
!
memcmp
(
uuid
,
ident
,
16
))
{
name
=
strdup
(
*
tmp
);
break
;
}
}
tmp
++
;
}
free
(
names
);
if
(
name
==
NULL
)
goto
error
;
ret
=
virGetDomain
(
conn
,
name
,
uuid
);
if
(
ret
==
NULL
)
{
virXendError
(
conn
,
VIR_ERR_NO_MEMORY
,
"Allocating domain"
);
goto
error
;
}
ret
->
handle
=
id
;
if
(
name
!=
NULL
)
free
(
name
);
return
(
ret
);
error:
if
(
name
!=
NULL
)
free
(
name
);
return
(
NULL
);
}
src/xend_internal.h
浏览文件 @
442b733e
...
...
@@ -509,16 +509,6 @@ int xenDaemonOpen_unix(virConnectPtr xend, const char *path);
*/
int
xend_sysrq
(
virConnectPtr
xend
,
const
char
*
name
,
const
char
*
key
);
/**
* \brief Obtain a list of currently running domains
* \param xend A xend instance
* \return a NULL terminated array of names; NULL (with errno) on error
*
* This method will return an array of names of currently running
* domains. The memory should be released will a call to free().
*/
char
**
xenDaemonListDomainsOld
(
virConnectPtr
xend
);
/**
* \brief Create a new domain
* \param xend A xend instance
...
...
src/xs_internal.c
浏览文件 @
442b733e
...
...
@@ -46,7 +46,7 @@ static virDriver xenStoreDriver = {
NULL
,
/* domainCreateLinux */
NULL
,
/* domainLookupByID */
NULL
,
/* domainLookupByUUID */
NULL
,
/* domainLookupByName */
xenStoreDomainLookupByName
,
/* domainLookupByName */
NULL
,
/* domainSuspend */
NULL
,
/* domainResume */
xenStoreDomainShutdown
,
/* domainShutdown */
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录