Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
a8d7d679
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,发现更多精彩内容 >>
提交
a8d7d679
编写于
12月 12, 2005
作者:
D
Daniel Veillard
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
* src/libvir.c src/xen_internal.c src/xen_internal.h: completing the
API implementation, only CreateLinux is now missing. Daniel
上级
2da25a15
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
179 addition
and
23 deletion
+179
-23
ChangeLog
ChangeLog
+5
-0
docs/index.html
docs/index.html
+1
-2
src/libvir.c
src/libvir.c
+145
-21
src/xen_internal.c
src/xen_internal.c
+25
-0
src/xen_internal.h
src/xen_internal.h
+3
-0
未找到文件。
ChangeLog
浏览文件 @
a8d7d679
Mon Dec 12 14:21:18 CET 2005 Daniel Veillard <veillard@redhat.com>
* src/libvir.c src/xen_internal.c src/xen_internal.h: completing the
API implementation, only CreateLinux is now missing.
Fri Dec 9 15:39:18 CET 2005 Daniel Veillard <veillard@redhat.com>
Fri Dec 9 15:39:18 CET 2005 Daniel Veillard <veillard@redhat.com>
* docs/search.php docs/index.py docs/*.xsl docs/html/*: fixed the
* docs/search.php docs/index.py docs/*.xsl docs/html/*: fixed the
...
...
docs/index.html
浏览文件 @
a8d7d679
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html
xmlns=
"http://www.w3.org/1999/xhtml"
>
<html
xmlns=
"http://www.w3.org/1999/xhtml"
>
<head>
<head><meta
http-equiv=
"Content-Type"
content=
"text/html; charset=ISO-8859-1"
/>
<meta
http-equiv=
"Content-Type"
content=
"text/html; charset=ISO-8859-1"
/>
<link
rel=
"SHORTCUT ICON"
href=
"/favicon.ico"
/>
<link
rel=
"SHORTCUT ICON"
href=
"/favicon.ico"
/>
<style
type=
"text/css"
>
<style
type=
"text/css"
>
TD
{
font-family
:
Verdana
,
Arial
,
Helvetica
}
TD
{
font-family
:
Verdana
,
Arial
,
Helvetica
}
...
...
src/libvir.c
浏览文件 @
a8d7d679
...
@@ -194,6 +194,30 @@ failed:
...
@@ -194,6 +194,30 @@ failed:
return
(
NULL
);
return
(
NULL
);
}
}
/**
* virConnectCheckStoreID:
* @conn: pointer to the hypervisor connection
* @id: the id number as returned from Xenstore
*
* the xenstore sometimes list non-running domains, double check
* from the hypervisor if we have direct access
*
* Returns -1 if the check failed, 0 if successful or not possible to check
*/
static
int
virConnectCheckStoreID
(
virConnectPtr
conn
,
int
id
)
{
if
(
conn
->
handle
>=
0
)
{
dom0_getdomaininfo_t
dominfo
;
int
tmp
;
dominfo
.
domain
=
id
;
tmp
=
xenHypervisorGetDomainInfo
(
conn
->
handle
,
id
,
&
dominfo
);
if
(
tmp
<
0
)
return
(
-
1
);
}
return
(
0
);
}
/**
/**
* virDomainFreeName:
* virDomainFreeName:
* @domain: a domain object
* @domain: a domain object
...
@@ -317,6 +341,9 @@ virConnectListDomains(virConnectPtr conn, int *ids, int maxids) {
...
@@ -317,6 +341,9 @@ virConnectListDomains(virConnectPtr conn, int *ids, int maxids) {
ret
=
-
1
;
ret
=
-
1
;
goto
done
;
goto
done
;
}
}
if
(
virConnectCheckStoreID
(
conn
,
(
int
)
id
)
<
0
)
continue
;
ids
[
ret
++
]
=
(
int
)
id
;
ids
[
ret
++
]
=
(
int
)
id
;
}
}
...
@@ -385,23 +412,6 @@ virDomainCreateLinux(virConnectPtr conn, const char *kernel_path,
...
@@ -385,23 +412,6 @@ virDomainCreateLinux(virConnectPtr conn, const char *kernel_path,
return
(
NULL
);
return
(
NULL
);
}
}
/**
* virDomainLookupByName:
* @conn: pointer to the hypervisor connection
* @name: name for the domain
*
* Try to lookup a domain on the given hypervisor
*
* Returns a new domain object or NULL in case of failure
*/
virDomainPtr
virDomainLookupByName
(
virConnectPtr
conn
,
const
char
*
name
)
{
if
((
conn
==
NULL
)
||
(
conn
->
magic
!=
VIR_CONNECT_MAGIC
)
||
(
name
==
NULL
))
return
(
NULL
);
TODO
return
(
NULL
);
}
#if 0
#if 0
/* Not used ATM */
/* Not used ATM */
/**
/**
...
@@ -525,6 +535,74 @@ virDomainLookupByID(virConnectPtr conn, int id) {
...
@@ -525,6 +535,74 @@ virDomainLookupByID(virConnectPtr conn, int id) {
return
(
ret
);
return
(
ret
);
}
}
/**
* virDomainLookupByName:
* @conn: pointer to the hypervisor connection
* @name: name for the domain
*
* Try to lookup a domain on the given hypervisor
*
* Returns a new domain object or NULL in case of failure
*/
virDomainPtr
virDomainLookupByName
(
virConnectPtr
conn
,
const
char
*
name
)
{
struct
xs_transaction_handle
*
t
;
virDomainPtr
ret
=
NULL
;
unsigned
int
num
,
i
,
len
;
long
id
;
char
**
idlist
=
NULL
,
*
endptr
;
char
prop
[
200
],
*
tmp
;
int
found
=
0
;
if
((
conn
==
NULL
)
||
(
conn
->
magic
!=
VIR_CONNECT_MAGIC
)
||
(
name
==
NULL
))
return
(
NULL
);
t
=
xs_transaction_start
(
conn
->
xshandle
);
if
(
t
==
NULL
)
goto
done
;
idlist
=
xs_directory
(
conn
->
xshandle
,
t
,
"/local/domain"
,
&
num
);
if
(
idlist
==
NULL
)
goto
done
;
for
(
i
=
0
;
i
<
num
;
i
++
)
{
id
=
strtol
(
idlist
[
i
],
&
endptr
,
10
);
if
((
endptr
==
idlist
[
i
])
||
(
*
endptr
!=
0
))
{
goto
done
;
}
if
(
virConnectCheckStoreID
(
conn
,
(
int
)
id
)
<
0
)
continue
;
snprintf
(
prop
,
199
,
"/local/domain/%s/name"
,
idlist
[
i
]);
prop
[
199
]
=
0
;
tmp
=
xs_read
(
conn
->
xshandle
,
t
,
prop
,
&
len
);
if
(
tmp
!=
NULL
)
{
found
=
!
strcmp
(
name
,
tmp
);
free
(
tmp
);
if
(
found
)
break
;
}
}
if
(
found
)
{
ret
=
(
virDomainPtr
)
malloc
(
sizeof
(
virDomain
));
if
(
ret
==
NULL
)
goto
done
;
ret
->
magic
=
VIR_DOMAIN_MAGIC
;
ret
->
conn
=
conn
;
ret
->
handle
=
id
;
ret
->
path
=
xs_get_domain_path
(
conn
->
xshandle
,
(
unsigned
int
)
id
);
ret
->
name
=
strdup
(
name
);
}
done:
if
(
t
!=
NULL
)
xs_transaction_end
(
conn
->
xshandle
,
t
,
0
);
if
(
idlist
!=
NULL
)
free
(
idlist
);
return
(
ret
);
}
/**
/**
* virDomainDestroy:
* virDomainDestroy:
* @domain: a domain object
* @domain: a domain object
...
@@ -655,10 +733,29 @@ virDomainGetID(virDomainPtr domain) {
...
@@ -655,10 +733,29 @@ virDomainGetID(virDomainPtr domain) {
*/
*/
unsigned
long
unsigned
long
virDomainGetMaxMemory
(
virDomainPtr
domain
)
{
virDomainGetMaxMemory
(
virDomainPtr
domain
)
{
unsigned
long
ret
=
0
;
if
((
domain
==
NULL
)
||
(
domain
->
magic
!=
VIR_DOMAIN_MAGIC
))
if
((
domain
==
NULL
)
||
(
domain
->
magic
!=
VIR_DOMAIN_MAGIC
))
return
(
0
);
return
(
0
);
TODO
if
(
domain
->
conn
->
flags
&
VIR_CONNECT_RO
)
{
return
(
0
);
char
*
tmp
;
tmp
=
virDomainDoStoreQuery
(
domain
,
"memory/target"
);
if
(
tmp
!=
NULL
)
{
ret
=
(
unsigned
long
)
atol
(
tmp
);
free
(
tmp
);
}
}
else
{
dom0_getdomaininfo_t
dominfo
;
int
tmp
;
dominfo
.
domain
=
domain
->
handle
;
tmp
=
xenHypervisorGetDomainInfo
(
domain
->
conn
->
handle
,
domain
->
handle
,
&
dominfo
);
if
(
tmp
>=
0
)
ret
=
dominfo
.
max_pages
*
4
;
}
return
(
ret
);
}
}
/**
/**
...
@@ -674,11 +771,38 @@ virDomainGetMaxMemory(virDomainPtr domain) {
...
@@ -674,11 +771,38 @@ virDomainGetMaxMemory(virDomainPtr domain) {
*/
*/
int
int
virDomainSetMaxMemory
(
virDomainPtr
domain
,
unsigned
long
memory
)
{
virDomainSetMaxMemory
(
virDomainPtr
domain
,
unsigned
long
memory
)
{
int
ret
;
char
s
[
256
],
v
[
30
];
struct
xs_transaction_handle
*
t
;
if
((
domain
==
NULL
)
||
(
domain
->
magic
!=
VIR_DOMAIN_MAGIC
)
||
if
((
domain
==
NULL
)
||
(
domain
->
magic
!=
VIR_DOMAIN_MAGIC
)
||
(
memory
<
4096
))
(
memory
<
4096
))
return
(
-
1
);
return
(
-
1
);
TODO
if
(
domain
->
conn
->
flags
&
VIR_CONNECT_RO
)
return
(
-
1
);
return
(
-
1
);
ret
=
xenHypervisorSetMaxMemory
(
domain
->
conn
->
handle
,
domain
->
handle
,
memory
);
if
(
ret
<
0
)
return
(
-
1
);
/*
* try to update at the Xenstore level too
* Failing to do so should not be considered fatal though as long
* as the hypervisor call succeeded
*/
snprintf
(
s
,
255
,
"/local/domain/%d/memory/target"
,
domain
->
handle
);
s
[
255
]
=
0
;
snprintf
(
v
,
29
,
"%lu"
,
memory
);
v
[
30
]
=
0
;
t
=
xs_transaction_start
(
domain
->
conn
->
xshandle
);
if
(
t
==
NULL
)
return
(
0
);
xs_write
(
domain
->
conn
->
xshandle
,
t
,
&
s
[
0
],
&
v
[
0
],
strlen
(
v
));
xs_transaction_end
(
domain
->
conn
->
xshandle
,
t
,
0
);
return
(
ret
);
}
}
/**
/**
...
...
src/xen_internal.c
浏览文件 @
a8d7d679
...
@@ -249,3 +249,28 @@ xenHypervisorDestroyDomain(int handle, int domain) {
...
@@ -249,3 +249,28 @@ xenHypervisorDestroyDomain(int handle, int domain) {
return
(
0
);
return
(
0
);
}
}
/**
* xenHypervisorSetMaxMemory:
* @handle: the handle to the Xen hypervisor
* @domain: the domain ID
* @memory: the max memory size in kilobytes.
*
* Do an hypervisor call to change the maximum amount of memory used
*
* Returns 0 in case of success, -1 in case of error.
*/
int
xenHypervisorSetMaxMemory
(
int
handle
,
int
domain
,
unsigned
long
memory
)
{
dom0_op_t
op
;
int
ret
;
op
.
cmd
=
DOM0_SETDOMAINMAXMEM
;
op
.
u
.
setdomainmaxmem
.
domain
=
(
domid_t
)
domain
;
op
.
u
.
setdomainmaxmem
.
max_memkb
=
memory
;
ret
=
xenHypervisorDoOp
(
handle
,
&
op
);
if
(
ret
<
0
)
return
(
-
1
);
return
(
0
);
}
src/xen_internal.h
浏览文件 @
a8d7d679
...
@@ -32,6 +32,9 @@ int xenHypervisorPauseDomain (int handle,
...
@@ -32,6 +32,9 @@ int xenHypervisorPauseDomain (int handle,
int
xenHypervisorGetDomainInfo
(
int
handle
,
int
xenHypervisorGetDomainInfo
(
int
handle
,
int
domain
,
int
domain
,
dom0_getdomaininfo_t
*
info
);
dom0_getdomaininfo_t
*
info
);
int
xenHypervisorSetMaxMemory
(
int
handle
,
int
domain
,
unsigned
long
memory
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录