Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
739dfb53
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,发现更多精彩内容 >>
提交
739dfb53
编写于
2月 27, 2006
作者:
D
Daniel Veillard
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
* include/virterror.h src/virterror.c src/xend_internal.c: more work
plugging in the error system in the code. Daniel
上级
596b6010
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
122 addition
and
21 deletion
+122
-21
ChangeLog
ChangeLog
+5
-0
include/libvirt/virterror.h
include/libvirt/virterror.h
+6
-1
include/virterror.h
include/virterror.h
+6
-1
src/virterror.c
src/virterror.c
+24
-0
src/xend_internal.c
src/xend_internal.c
+81
-19
未找到文件。
ChangeLog
浏览文件 @
739dfb53
Mon Feb 27 14:56:57 EST 2006 Daniel Veillard <veillard@redhat.com>
* include/virterror.h src/virterror.c src/xend_internal.c: more work
plugging in the error system in the code.
Mon Feb 27 17:25:48 CET 2006 Daniel Veillard <veillard@redhat.com>
* TODO: updated
...
...
include/libvirt/virterror.h
浏览文件 @
739dfb53
...
...
@@ -40,7 +40,8 @@ typedef enum {
VIR_FROM_NONE
=
0
,
VIR_FROM_XEN
,
/* Error at Xen hypervisor layer */
VIR_FROM_XEND
,
/* Error at connection with xend daemon */
VIR_FROM_DOM
/* Error when operating on a domain */
VIR_FROM_SEXPR
,
/* Error in the S-Epression code */
VIR_FROM_DOM
,
/* Error when operating on a domain */
}
virErrorDomain
;
...
...
@@ -76,11 +77,15 @@ typedef enum {
VIR_ERR_INTERNAL_ERROR
,
/* internal error */
VIR_ERR_NO_MEMORY
,
/* memory allocation failure */
VIR_ERR_NO_SUPPORT
,
/* no support for this connection */
VIR_ERR_UNKNOWN_HOST
,
/* could not resolve hostname */
VIR_ERR_NO_CONNECT
,
/* can't connect to hypervisor */
VIR_ERR_INVALID_CONN
,
/* invalid connection object */
VIR_ERR_INVALID_DOMAIN
,
/* invalid domain object */
VIR_ERR_INVALID_ARG
,
/* invalid function argument */
VIR_ERR_OPERATION_FAILED
,
/* a command to hypervisor failed */
VIR_ERR_GET_FAILED
,
/* a HTTP GET command to failed */
VIR_ERR_POST_FAILED
,
/* a HTTP POST command to failed */
VIR_ERR_HTTP_ERROR
,
/* unexpected HTTP error code */
}
virErrorNumber
;
/**
...
...
include/virterror.h
浏览文件 @
739dfb53
...
...
@@ -40,7 +40,8 @@ typedef enum {
VIR_FROM_NONE
=
0
,
VIR_FROM_XEN
,
/* Error at Xen hypervisor layer */
VIR_FROM_XEND
,
/* Error at connection with xend daemon */
VIR_FROM_DOM
/* Error when operating on a domain */
VIR_FROM_SEXPR
,
/* Error in the S-Epression code */
VIR_FROM_DOM
,
/* Error when operating on a domain */
}
virErrorDomain
;
...
...
@@ -76,11 +77,15 @@ typedef enum {
VIR_ERR_INTERNAL_ERROR
,
/* internal error */
VIR_ERR_NO_MEMORY
,
/* memory allocation failure */
VIR_ERR_NO_SUPPORT
,
/* no support for this connection */
VIR_ERR_UNKNOWN_HOST
,
/* could not resolve hostname */
VIR_ERR_NO_CONNECT
,
/* can't connect to hypervisor */
VIR_ERR_INVALID_CONN
,
/* invalid connection object */
VIR_ERR_INVALID_DOMAIN
,
/* invalid domain object */
VIR_ERR_INVALID_ARG
,
/* invalid function argument */
VIR_ERR_OPERATION_FAILED
,
/* a command to hypervisor failed */
VIR_ERR_GET_FAILED
,
/* a HTTP GET command to failed */
VIR_ERR_POST_FAILED
,
/* a HTTP POST command to failed */
VIR_ERR_HTTP_ERROR
,
/* unexpected HTTP error code */
}
virErrorNumber
;
/**
...
...
src/virterror.c
浏览文件 @
739dfb53
...
...
@@ -385,6 +385,30 @@ __virErrorMsg(virErrorNumber error, const char *info) {
case
VIR_ERR_INVALID_ARG
:
errmsg
=
"invalid domain pointer in"
;
break
;
case
VIR_ERR_OPERATION_FAILED
:
if
(
info
!=
NULL
)
errmsg
=
"operation failed: %s"
;
else
errmsg
=
"operation failed"
;
break
;
case
VIR_ERR_GET_FAILED
:
if
(
info
!=
NULL
)
errmsg
=
"GET operation failed: %s"
;
else
errmsg
=
"GET operation failed"
;
break
;
case
VIR_ERR_POST_FAILED
:
if
(
info
!=
NULL
)
errmsg
=
"POST operation failed: %s"
;
else
errmsg
=
"POST operation failed"
;
break
;
case
VIR_ERR_HTTP_ERROR
:
errmsg
=
"got unknown HTTP error code %d"
;
break
;
case
VIR_ERR_UNKNOWN_HOST
:
errmsg
=
"Unknown host %s"
;
break
;
}
return
(
errmsg
);
}
...
...
src/xend_internal.c
浏览文件 @
739dfb53
...
...
@@ -78,6 +78,27 @@ virXendError(virConnectPtr conn, virErrorNumber error, const char *info) {
errmsg
,
info
,
NULL
,
0
,
0
,
errmsg
,
info
);
}
/**
* virXendErrorInt:
* @conn: the connection if available
* @error: the error noumber
* @val: extra integer information
*
* Handle an error at the xend daemon interface
*/
static
void
virXendErrorInt
(
virConnectPtr
conn
,
virErrorNumber
error
,
int
val
)
{
const
char
*
errmsg
;
if
(
error
==
VIR_ERR_OK
)
return
;
errmsg
=
__virErrorMsg
(
error
,
NULL
);
__virRaiseError
(
conn
,
NULL
,
VIR_FROM_XEND
,
error
,
VIR_ERR_ERROR
,
errmsg
,
NULL
,
NULL
,
val
,
0
,
errmsg
,
val
);
}
#define foreach(iterator, start) \
for (_for_i = (start), *iterator = (start)->car; \
...
...
@@ -343,8 +364,7 @@ xend_get(virConnectPtr xend, const char *path,
close
(
s
);
if
((
ret
<
0
)
||
(
ret
>=
300
))
{
virXendError
(
NULL
,
VIR_ERR_OPERATION_FAILED
,
content
);
virXendError
(
NULL
,
VIR_ERR_GET_FAILED
,
content
);
}
return
ret
;
...
...
@@ -392,8 +412,7 @@ xend_post(virConnectPtr xend, const char *path, const char *ops,
close
(
s
);
if
((
ret
<
0
)
||
(
ret
>=
300
))
{
virXendError
(
NULL
,
VIR_ERR_OPERATION_FAILED
,
content
);
virXendError
(
NULL
,
VIR_ERR_POST_FAILED
,
content
);
}
return
ret
;
...
...
@@ -421,7 +440,7 @@ http2unix(int ret)
errno
=
ESRCH
;
break
;
default:
printf
(
"unknown error code %d
\n
"
,
ret
);
virXendErrorInt
(
NULL
,
VIR_ERR_HTTP_ERROR
,
ret
);
errno
=
EINVAL
;
break
;
}
...
...
@@ -1048,6 +1067,7 @@ xend_setup_tcp(virConnectPtr xend, const char *host, int port)
pent
=
gethostbyname
(
host
);
if
(
pent
==
NULL
)
{
if
(
inet_aton
(
host
,
&
ip
)
==
0
)
{
virXendError
(
xend
,
VIR_ERR_UNKNOWN_HOST
,
host
);
errno
=
ESRCH
;
return
(
-
1
);
}
...
...
@@ -1152,8 +1172,11 @@ xend_unpause(virConnectPtr xend, const char *name)
int
xend_rename
(
virConnectPtr
xend
,
const
char
*
old
,
const
char
*
new
)
{
if
((
xend
==
NULL
)
||
(
old
==
NULL
)
||
(
new
==
NULL
))
if
((
xend
==
NULL
)
||
(
old
==
NULL
)
||
(
new
==
NULL
))
{
/* this should be caught at the interface but ... */
virXendError
(
xend
,
VIR_ERR_INVALID_ARG
,
__FUNCTION__
);
return
(
-
1
);
}
return
xend_op
(
xend
,
old
,
"op"
,
"rename"
,
"name"
,
new
,
NULL
);
}
...
...
@@ -1169,8 +1192,11 @@ xend_rename(virConnectPtr xend, const char *old, const char *new)
int
xend_reboot
(
virConnectPtr
xend
,
const
char
*
name
)
{
if
((
xend
==
NULL
)
||
(
name
==
NULL
))
if
((
xend
==
NULL
)
||
(
name
==
NULL
))
{
/* this should be caught at the interface but ... */
virXendError
(
xend
,
VIR_ERR_INVALID_ARG
,
__FUNCTION__
);
return
(
-
1
);
}
return
xend_op
(
xend
,
name
,
"op"
,
"shutdown"
,
"reason"
,
"reboot"
,
NULL
);
}
...
...
@@ -1187,8 +1213,11 @@ xend_reboot(virConnectPtr xend, const char *name)
int
xend_shutdown
(
virConnectPtr
xend
,
const
char
*
name
)
{
if
((
xend
==
NULL
)
||
(
name
==
NULL
))
if
((
xend
==
NULL
)
||
(
name
==
NULL
))
{
/* this should be caught at the interface but ... */
virXendError
(
xend
,
VIR_ERR_INVALID_ARG
,
__FUNCTION__
);
return
(
-
1
);
}
return
xend_op
(
xend
,
name
,
"op"
,
"shutdown"
,
"reason"
,
"halt"
,
NULL
);
}
...
...
@@ -1206,8 +1235,11 @@ xend_shutdown(virConnectPtr xend, const char *name)
int
xend_sysrq
(
virConnectPtr
xend
,
const
char
*
name
,
const
char
*
key
)
{
if
((
xend
==
NULL
)
||
(
name
==
NULL
)
||
(
key
==
NULL
))
if
((
xend
==
NULL
)
||
(
name
==
NULL
)
||
(
key
==
NULL
))
{
/* this should be caught at the interface but ... */
virXendError
(
xend
,
VIR_ERR_INVALID_ARG
,
__FUNCTION__
);
return
(
-
1
);
}
return
xend_op
(
xend
,
name
,
"op"
,
"sysrq"
,
"key"
,
key
,
NULL
);
}
...
...
@@ -1225,8 +1257,11 @@ xend_sysrq(virConnectPtr xend, const char *name, const char *key)
int
xend_destroy
(
virConnectPtr
xend
,
const
char
*
name
)
{
if
((
xend
==
NULL
)
||
(
name
==
NULL
))
if
((
xend
==
NULL
)
||
(
name
==
NULL
))
{
/* this should be caught at the interface but ... */
virXendError
(
xend
,
VIR_ERR_INVALID_ARG
,
__FUNCTION__
);
return
(
-
1
);
}
return
xend_op
(
xend
,
name
,
"op"
,
"destroy"
,
NULL
);
}
...
...
@@ -1247,8 +1282,11 @@ xend_destroy(virConnectPtr xend, const char *name)
int
xend_save
(
virConnectPtr
xend
,
const
char
*
name
,
const
char
*
filename
)
{
if
((
xend
==
NULL
)
||
(
filename
==
NULL
))
if
((
xend
==
NULL
)
||
(
filename
==
NULL
))
{
/* this should be caught at the interface but ... */
virXendError
(
xend
,
VIR_ERR_INVALID_ARG
,
__FUNCTION__
);
return
(
-
1
);
}
return
xend_op
(
xend
,
name
,
"op"
,
"save"
,
"file"
,
filename
,
NULL
);
}
...
...
@@ -1266,8 +1304,11 @@ xend_save(virConnectPtr xend, const char *name, const char *filename)
int
xend_restore
(
virConnectPtr
xend
,
const
char
*
filename
)
{
if
((
xend
==
NULL
)
||
(
filename
==
NULL
))
if
((
xend
==
NULL
)
||
(
filename
==
NULL
))
{
/* this should be caught at the interface but ... */
virXendError
(
xend
,
VIR_ERR_INVALID_ARG
,
__FUNCTION__
);
return
(
-
1
);
}
return
xend_op
(
xend
,
""
,
"op"
,
"restore"
,
"file"
,
filename
,
NULL
);
}
...
...
@@ -1463,6 +1504,12 @@ xend_create_sexpr(virConnectPtr xend, const char *sexpr)
char
*
ptr
;
ptr
=
urlencode
(
sexpr
);
if
(
ptr
==
NULL
)
{
/* this should be caught at the interface but ... */
virXendError
(
xend
,
VIR_ERR_INTERNAL_ERROR
,
"Failed to urlencode the create S-Expr"
);
return
(
-
1
);
}
ret
=
xend_op
(
xend
,
""
,
"op"
,
"create"
,
"config"
,
ptr
,
NULL
);
...
...
@@ -1977,14 +2024,22 @@ xend_get_domain_ids(virConnectPtr xend, const char *domname,
goto
error
;
value
=
sexpr_node
(
root
,
"domain/domid"
);
if
(
value
==
NULL
)
if
(
value
==
NULL
)
{
virXendError
(
xend
,
VIR_ERR_INTERNAL_ERROR
,
"domain informations incomplete, missing domid"
);
goto
error
;
}
ret
=
strtol
(
value
,
NULL
,
0
);
if
((
ret
==
0
)
&&
(
value
[
0
]
!=
'0'
))
{
virXendError
(
xend
,
VIR_ERR_INTERNAL_ERROR
,
"domain informations incorrect domid not numberic"
);
ret
=
-
1
;
}
else
if
(
uuid
!=
NULL
)
{
char
**
ptr
=
(
char
**
)
&
uuid
;
sexpr_uuid
(
ptr
,
root
,
"domain/uuid"
);
if
(
sexpr_uuid
(
ptr
,
root
,
"domain/uuid"
)
==
NULL
)
{
virXendError
(
xend
,
VIR_ERR_INTERNAL_ERROR
,
"domain informations incomplete, missing uuid"
);
}
}
error:
...
...
@@ -2188,7 +2243,8 @@ xend_parse_sexp_desc(struct sexpr *root) {
sexpr_int
(
root
,
"domain/domid"
));
tmp
=
sexpr_node
(
root
,
"domain/name"
);
if
(
tmp
==
NULL
)
{
/* VIR_ERR_NO_NAME */
virXendError
(
NULL
,
VIR_ERR_INTERNAL_ERROR
,
"domain informations incomplete, missing name"
);
goto
error
;
}
virBufferVSprintf
(
&
buf
,
" <name>%s</name>
\n
"
,
tmp
);
...
...
@@ -2197,7 +2253,8 @@ xend_parse_sexp_desc(struct sexpr *root) {
/*
* TODO: we will need some fallback here for other guest OSes
*/
/* VIR_ERR_NO_KERNEL */
virXendError
(
NULL
,
VIR_ERR_INTERNAL_ERROR
,
"domain informations incomplete, missing kernel"
);
goto
error
;
}
virBufferAdd
(
&
buf
,
" <os>
\n
"
,
7
);
...
...
@@ -2230,7 +2287,8 @@ xend_parse_sexp_desc(struct sexpr *root) {
virBufferVSprintf
(
&
buf
,
" <source file='%s'/>
\n
"
,
tmp
);
tmp
=
sexpr_node
(
node
,
"device/vbd/dev"
);
if
(
tmp
==
NULL
)
{
/* VIR_ERR_NO_DEV */
virXendError
(
NULL
,
VIR_ERR_INTERNAL_ERROR
,
"domain informations incomplete, vbd has no dev"
);
goto
error
;
}
virBufferVSprintf
(
&
buf
,
" <target dev='%s'/>
\n
"
,
tmp
);
...
...
@@ -2244,7 +2302,8 @@ xend_parse_sexp_desc(struct sexpr *root) {
virBufferVSprintf
(
&
buf
,
" <source dev='%s'/>
\n
"
,
tmp
);
tmp
=
sexpr_node
(
node
,
"device/vbd/dev"
);
if
(
tmp
==
NULL
)
{
/* VIR_ERR_NO_DEV */
virXendError
(
NULL
,
VIR_ERR_INTERNAL_ERROR
,
"domain informations incomplete, vbd has no dev"
);
goto
error
;
}
virBufferVSprintf
(
&
buf
,
" <target dev='%s'/>
\n
"
,
tmp
);
...
...
@@ -2316,8 +2375,11 @@ xend_get_domain_xml(virDomainPtr domain) {
char
*
ret
=
NULL
;
struct
sexpr
*
root
;
if
(
!
VIR_IS_DOMAIN
(
domain
))
if
(
!
VIR_IS_DOMAIN
(
domain
))
{
/* this should be caught at the interface but ... */
virXendError
(
NULL
,
VIR_ERR_INVALID_ARG
,
__FUNCTION__
);
return
(
NULL
);
}
root
=
sexpr_get
(
domain
->
conn
,
"/xend/domain/%s?detail=1"
,
domain
->
name
);
if
(
root
==
NULL
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录