Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
9112a139
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看板
提交
9112a139
编写于
8月 10, 2007
作者:
D
Daniel P. Berrange
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Speed up impl of lookupbyid/uuid and getostype for Xen by using HV where available
上级
46b433f0
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
197 addition
and
1 deletion
+197
-1
ChangeLog
ChangeLog
+8
-0
src/xen_internal.c
src/xen_internal.c
+146
-1
src/xen_internal.h
src/xen_internal.h
+9
-0
src/xen_unified.c
src/xen_unified.c
+14
-0
src/xs_internal.c
src/xs_internal.c
+16
-0
src/xs_internal.h
src/xs_internal.h
+4
-0
未找到文件。
ChangeLog
浏览文件 @
9112a139
Fri Aug 10 14:25:00 EST 2007 Daniel P. Berrange <berrange@redhat.com>
* src/xen_internal.c, src/xen_internal.h, src/xen_unified.c:
Add impls of the DomainGetOSType, DomainLookupByID and
DomainLookupByName drivers using the HV for speed
* src/xs_internal.c, src/xs_internal.h: Add helper method to
lookup a domain name based on its ID
Thu Aug 9 14:27:00 EST 2007 Daniel P. Berrange <berrange@redhat.com>
* src/libvirt.c, src/openvz_conf.c, src/qemu_conf.c,
...
...
src/xen_internal.c
浏览文件 @
9112a139
...
...
@@ -27,6 +27,7 @@
#include <regex.h>
#include <errno.h>
#include <sys/utsname.h>
#include "xs_internal.h"
/* required for dom0_getdomaininfo_t */
#include <xen/dom0_ops.h>
...
...
@@ -229,6 +230,13 @@ typedef union xen_getschedulerid xen_getschedulerid;
domlist.v2[n].domain : \
domlist.v2d5[n].domain))
#define XEN_GETDOMAININFOLIST_UUID(domlist, n) \
(hypervisor_version < 2 ? \
domlist.v0[n].handle : \
(dom_interface_version < 5 ? \
domlist.v2[n].handle : \
domlist.v2d5[n].handle))
#define XEN_GETDOMAININFOLIST_DATA(domlist) \
(hypervisor_version < 2 ? \
(void*)(domlist->v0) : \
...
...
@@ -299,6 +307,13 @@ typedef union xen_getschedulerid xen_getschedulerid;
dominfo.v2.max_pages : \
dominfo.v2d5.max_pages))
#define XEN_GETDOMAININFO_UUID(dominfo) \
(hypervisor_version < 2 ? \
dominfo.v0.handle : \
(dom_interface_version < 5 ? \
dominfo.v2.handle : \
dominfo.v2d5.handle))
struct
xen_v0_getdomaininfolistop
{
...
...
@@ -626,7 +641,7 @@ struct xenUnifiedDriver xenHypervisorDriver = {
NULL
,
/* domainShutdown */
NULL
,
/* domainReboot */
xenHypervisorDestroyDomain
,
/* domainDestroy */
NULL
,
/* domainGetOSType */
xenHypervisorDomainGetOSType
,
/* domainGetOSType */
xenHypervisorGetMaxMemory
,
/* domainGetMaxMemory */
xenHypervisorSetMaxMemory
,
/* domainSetMaxMemory */
NULL
,
/* domainSetMemory */
...
...
@@ -2437,6 +2452,136 @@ xenHypervisorListDomains(virConnectPtr conn, int *ids, int maxids)
return
(
nbids
);
}
#ifndef PROXY
char
*
xenHypervisorDomainGetOSType
(
virDomainPtr
dom
)
{
xenUnifiedPrivatePtr
priv
;
xen_getdomaininfo
dominfo
;
priv
=
(
xenUnifiedPrivatePtr
)
dom
->
conn
->
privateData
;
if
(
priv
->
handle
<
0
)
return
(
NULL
);
/* HV's earlier than 3.1.0 don't include the HVM flags in guests status*/
if
(
hypervisor_version
<
2
||
dom_interface_version
<
4
)
return
(
NULL
);
XEN_GETDOMAININFO_CLEAR
(
dominfo
);
if
(
virXen_getdomaininfo
(
priv
->
handle
,
dom
->
id
,
&
dominfo
)
<
0
)
return
(
NULL
);
if
(
XEN_GETDOMAININFO_DOMAIN
(
dominfo
)
!=
dom
->
id
)
return
(
NULL
);
if
(
XEN_GETDOMAININFO_FLAGS
(
dominfo
)
&
DOMFLAGS_HVM
)
return
strdup
(
"hvm"
);
return
strdup
(
"linux"
);
}
virDomainPtr
xenHypervisorLookupDomainByID
(
virConnectPtr
conn
,
int
id
)
{
xenUnifiedPrivatePtr
priv
;
xen_getdomaininfo
dominfo
;
virDomainPtr
ret
;
char
*
name
;
priv
=
(
xenUnifiedPrivatePtr
)
conn
->
privateData
;
if
(
priv
->
handle
<
0
)
return
(
NULL
);
XEN_GETDOMAININFO_CLEAR
(
dominfo
);
if
(
virXen_getdomaininfo
(
priv
->
handle
,
id
,
&
dominfo
)
<
0
)
return
(
NULL
);
if
(
XEN_GETDOMAININFO_DOMAIN
(
dominfo
)
!=
id
)
return
(
NULL
);
if
(
!
(
name
=
xenStoreDomainGetName
(
conn
,
id
)))
return
(
NULL
);
ret
=
virGetDomain
(
conn
,
name
,
XEN_GETDOMAININFO_UUID
(
dominfo
));
if
(
ret
)
ret
->
id
=
id
;
free
(
name
);
return
ret
;
}
virDomainPtr
xenHypervisorLookupDomainByUUID
(
virConnectPtr
conn
,
const
unsigned
char
*
uuid
)
{
xen_getdomaininfolist
dominfos
;
xenUnifiedPrivatePtr
priv
;
virDomainPtr
ret
;
char
*
name
;
int
maxids
=
100
,
nids
,
i
,
id
;
priv
=
(
xenUnifiedPrivatePtr
)
conn
->
privateData
;
if
(
priv
->
handle
<
0
)
return
(
NULL
);
retry:
if
(
!
(
XEN_GETDOMAININFOLIST_ALLOC
(
dominfos
,
maxids
)))
{
virXenError
(
VIR_ERR_NO_MEMORY
,
"allocating %d domain info"
,
maxids
);
return
(
NULL
);
}
XEN_GETDOMAININFOLIST_CLEAR
(
dominfos
,
maxids
);
nids
=
virXen_getdomaininfolist
(
priv
->
handle
,
0
,
maxids
,
&
dominfos
);
if
(
nids
<
0
)
{
XEN_GETDOMAININFOLIST_FREE
(
dominfos
);
return
(
NULL
);
}
/* Can't possibly have more than 65,000 concurrent guests
* so limit how many times we try, to avoid increasing
* without bound & thus allocating all of system memory !
* XXX I'll regret this comment in a few years time ;-)
*/
if
(
nids
==
maxids
)
{
XEN_GETDOMAININFOLIST_FREE
(
dominfos
);
if
(
maxids
<
65000
)
{
maxids
*=
2
;
goto
retry
;
}
return
(
NULL
);
}
id
=
-
1
;
for
(
i
=
0
;
i
<
nids
;
i
++
)
{
if
(
memcmp
(
XEN_GETDOMAININFOLIST_UUID
(
dominfos
,
i
),
uuid
,
VIR_UUID_BUFLEN
)
==
0
)
{
id
=
XEN_GETDOMAININFOLIST_DOMAIN
(
dominfos
,
i
);
break
;
}
}
XEN_GETDOMAININFOLIST_FREE
(
dominfos
);
if
(
id
==
-
1
)
return
(
NULL
);
if
(
!
(
name
=
xenStoreDomainGetName
(
conn
,
id
)))
return
(
NULL
);
ret
=
virGetDomain
(
conn
,
name
,
uuid
);
if
(
ret
)
ret
->
id
=
id
;
free
(
name
);
return
ret
;
}
#endif
/**
* xenHypervisorGetMaxVcpus:
*
...
...
src/xen_internal.h
浏览文件 @
9112a139
...
...
@@ -20,6 +20,15 @@ int xenHypervisorInit (void);
/* The following calls are made directly by the Xen proxy: */
virDomainPtr
xenHypervisorLookupDomainByID
(
virConnectPtr
conn
,
int
id
);
virDomainPtr
xenHypervisorLookupDomainByUUID
(
virConnectPtr
conn
,
const
unsigned
char
*
uuid
);
char
*
xenHypervisorDomainGetOSType
(
virDomainPtr
dom
);
int
xenHypervisorOpen
(
virConnectPtr
conn
,
const
char
*
name
,
int
flags
);
...
...
src/xen_unified.c
浏览文件 @
9112a139
...
...
@@ -377,6 +377,13 @@ xenUnifiedDomainLookupByID (virConnectPtr conn, int id)
*/
virConnResetLastError
(
conn
);
/* Try hypervisor/xenstore combo. */
if
(
priv
->
opened
[
XEN_UNIFIED_HYPERVISOR_OFFSET
])
{
ret
=
xenHypervisorLookupDomainByID
(
conn
,
id
);
if
(
ret
||
conn
->
err
.
code
!=
VIR_ERR_OK
)
return
ret
;
}
/* Try proxy. */
if
(
priv
->
opened
[
XEN_UNIFIED_PROXY_OFFSET
])
{
ret
=
xenProxyLookupByID
(
conn
,
id
);
...
...
@@ -408,6 +415,13 @@ xenUnifiedDomainLookupByUUID (virConnectPtr conn,
*/
virConnResetLastError
(
conn
);
/* Try hypervisor/xenstore combo. */
if
(
priv
->
opened
[
XEN_UNIFIED_HYPERVISOR_OFFSET
])
{
ret
=
xenHypervisorLookupDomainByUUID
(
conn
,
uuid
);
if
(
ret
||
conn
->
err
.
code
!=
VIR_ERR_OK
)
return
ret
;
}
/* Try proxy. */
if
(
priv
->
opened
[
XEN_UNIFIED_PROXY_OFFSET
])
{
ret
=
xenProxyLookupByUUID
(
conn
,
uuid
);
...
...
src/xs_internal.c
浏览文件 @
9112a139
...
...
@@ -875,6 +875,22 @@ xenStoreDomainGetNetworkID(virConnectPtr conn, int id, const char *mac) {
return
(
ret
);
}
char
*
xenStoreDomainGetName
(
virConnectPtr
conn
,
int
id
)
{
char
prop
[
200
];
xenUnifiedPrivatePtr
priv
;
unsigned
int
len
;
priv
=
(
xenUnifiedPrivatePtr
)
conn
->
privateData
;
if
(
priv
->
xshandle
==
NULL
)
return
(
NULL
);
snprintf
(
prop
,
199
,
"/local/domain/%d/name"
,
id
);
prop
[
199
]
=
0
;
return
xs_read
(
priv
->
xshandle
,
0
,
prop
,
&
len
);
}
#endif
/* WITH_XEN */
/*
* Local variables:
...
...
src/xs_internal.h
浏览文件 @
9112a139
...
...
@@ -15,6 +15,8 @@
extern
"C"
{
#endif
#include "internal.h"
extern
struct
xenUnifiedDriver
xenStoreDriver
;
int
xenStoreInit
(
void
);
...
...
@@ -48,6 +50,8 @@ char * xenStoreDomainGetOSTypeID(virConnectPtr conn,
char
*
xenStoreDomainGetNetworkID
(
virConnectPtr
conn
,
int
id
,
const
char
*
mac
);
char
*
xenStoreDomainGetName
(
virConnectPtr
conn
,
int
id
);
#ifdef __cplusplus
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录