Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
fb828ed2
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,发现更多精彩内容 >>
提交
fb828ed2
编写于
5月 27, 2009
作者:
D
Daniel P. Berrange
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix error location logging
上级
ad8a5e5d
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
72 addition
and
40 deletion
+72
-40
ChangeLog
ChangeLog
+7
-0
src/virterror.c
src/virterror.c
+43
-29
src/virterror_internal.h
src/virterror_internal.h
+22
-11
未找到文件。
ChangeLog
浏览文件 @
fb828ed2
Tue May 26 13:09:30 BST 2009 Daniel P. Berrange <berrange@redhat.com>
Fix error location logging
* src/virterror.c, src/virterror_internal.h: Re-factor error
reporting APIs to ensure correct source location info is
passed through to eventual virLogMessage call.
Tue May 26 11:25:30 BST 2009 Daniel P. Berrange <berrange@redhat.com>
Tue May 26 11:25:30 BST 2009 Daniel P. Berrange <berrange@redhat.com>
* tests/Makefile.am: Add ocaml intermediate files to CLEANFILES
* tests/Makefile.am: Add ocaml intermediate files to CLEANFILES
...
...
src/virterror.c
浏览文件 @
fb828ed2
...
@@ -590,10 +590,11 @@ virSetConnError(virConnectPtr conn)
...
@@ -590,10 +590,11 @@ virSetConnError(virConnectPtr conn)
/**
/**
* virRaiseError:
* virRaiseError
Full
:
* @conn: the connection to the hypervisor if available
* @conn: the connection to the hypervisor if available
* @dom: the domain if available
* @filename: filename where error was raised
* @net: the network if available
* @funcname: function name where error was raised
* @linenr: line number where error was raised
* @domain: the virErrorDomain indicating where it's coming from
* @domain: the virErrorDomain indicating where it's coming from
* @code: the virErrorNumber code for the error
* @code: the virErrorNumber code for the error
* @level: the virErrorLevel for the error
* @level: the virErrorLevel for the error
...
@@ -609,12 +610,19 @@ virSetConnError(virConnectPtr conn)
...
@@ -609,12 +610,19 @@ virSetConnError(virConnectPtr conn)
* immediately if a callback is found and store it for later handling.
* immediately if a callback is found and store it for later handling.
*/
*/
void
void
virRaiseError
(
virConnectPtr
conn
,
virRaiseErrorFull
(
virConnectPtr
conn
,
virDomainPtr
dom
ATTRIBUTE_UNUSED
,
const
char
*
filename
ATTRIBUTE_UNUSED
,
virNetworkPtr
net
ATTRIBUTE_UNUSED
,
const
char
*
funcname
,
int
domain
,
int
code
,
virErrorLevel
level
,
size_t
linenr
,
const
char
*
str1
,
const
char
*
str2
,
const
char
*
str3
,
int
domain
,
int
int1
,
int
int2
,
const
char
*
msg
,
...)
int
code
,
virErrorLevel
level
,
const
char
*
str1
,
const
char
*
str2
,
const
char
*
str3
,
int
int1
,
int
int2
,
const
char
*
fmt
,
...)
{
{
virErrorPtr
to
;
virErrorPtr
to
;
void
*
userData
=
virUserData
;
void
*
userData
=
virUserData
;
...
@@ -650,18 +658,18 @@ virRaiseError(virConnectPtr conn,
...
@@ -650,18 +658,18 @@ virRaiseError(virConnectPtr conn,
/*
/*
* formats the message
* formats the message
*/
*/
if
(
msg
==
NULL
)
{
if
(
fmt
==
NULL
)
{
str
=
strdup
(
_
(
"No error message provided"
));
str
=
strdup
(
_
(
"No error message provided"
));
}
else
{
}
else
{
VIR_GET_VAR_STR
(
msg
,
str
);
VIR_GET_VAR_STR
(
fmt
,
str
);
}
}
/*
/*
* Hook up the error or warning to the logging facility
* Hook up the error or warning to the logging facility
*
TODO: pass function name and lineno
*
XXXX should we include filename as 'category' instead of domain name ?
*/
*/
virLogMessage
(
virErrorDomainName
(
domain
),
virErrorLevelPriority
(
level
),
virLogMessage
(
virErrorDomainName
(
domain
),
virErrorLevelPriority
(
level
),
NULL
,
0
,
1
,
"%s"
,
str
);
funcname
,
linenr
,
1
,
"%s"
,
str
);
/*
/*
* Save the information about the error
* Save the information about the error
...
@@ -1067,10 +1075,12 @@ virErrorMsg(virErrorNumber error, const char *info)
...
@@ -1067,10 +1075,12 @@ virErrorMsg(virErrorNumber error, const char *info)
* Helper function to do most of the grunt work for individual driver
* Helper function to do most of the grunt work for individual driver
* ReportError
* ReportError
*/
*/
void
virReportErrorHelper
(
virConnectPtr
conn
,
int
domcode
,
int
errcode
,
void
virReportErrorHelper
(
virConnectPtr
conn
,
const
char
*
filename
ATTRIBUTE_UNUSED
,
int
domcode
,
const
char
*
funcname
ATTRIBUTE_UNUSED
,
int
errcode
,
size_t
linenr
ATTRIBUTE_UNUSED
,
const
char
*
filename
,
const
char
*
funcname
,
size_t
linenr
,
const
char
*
fmt
,
...)
const
char
*
fmt
,
...)
{
{
va_list
args
;
va_list
args
;
...
@@ -1086,8 +1096,10 @@ void virReportErrorHelper(virConnectPtr conn, int domcode, int errcode,
...
@@ -1086,8 +1096,10 @@ void virReportErrorHelper(virConnectPtr conn, int domcode, int errcode,
}
}
virerr
=
virErrorMsg
(
errcode
,
(
errorMessage
[
0
]
?
errorMessage
:
NULL
));
virerr
=
virErrorMsg
(
errcode
,
(
errorMessage
[
0
]
?
errorMessage
:
NULL
));
virRaiseError
(
conn
,
NULL
,
NULL
,
domcode
,
errcode
,
VIR_ERR_ERROR
,
virRaiseErrorFull
(
conn
,
filename
,
funcname
,
linenr
,
virerr
,
errorMessage
,
NULL
,
-
1
,
-
1
,
virerr
,
errorMessage
);
domcode
,
errcode
,
VIR_ERR_ERROR
,
virerr
,
errorMessage
,
NULL
,
-
1
,
-
1
,
virerr
,
errorMessage
);
}
}
...
@@ -1116,9 +1128,9 @@ const char *virStrerror(int theerrno, char *errBuf, size_t errBufLen)
...
@@ -1116,9 +1128,9 @@ const char *virStrerror(int theerrno, char *errBuf, size_t errBufLen)
void
virReportSystemErrorFull
(
virConnectPtr
conn
,
void
virReportSystemErrorFull
(
virConnectPtr
conn
,
int
domcode
,
int
domcode
,
int
theerrno
,
int
theerrno
,
const
char
*
filename
ATTRIBUTE_UNUSED
,
const
char
*
filename
,
const
char
*
funcname
ATTRIBUTE_UNUSED
,
const
char
*
funcname
,
size_t
linenr
ATTRIBUTE_UNUSED
,
size_t
linenr
,
const
char
*
fmt
,
...)
const
char
*
fmt
,
...)
{
{
char
strerror_buf
[
1024
];
char
strerror_buf
[
1024
];
...
@@ -1148,19 +1160,21 @@ void virReportSystemErrorFull(virConnectPtr conn,
...
@@ -1148,19 +1160,21 @@ void virReportSystemErrorFull(virConnectPtr conn,
if
(
!
msgDetail
)
if
(
!
msgDetail
)
msgDetail
=
errnoDetail
;
msgDetail
=
errnoDetail
;
virRaiseError
(
conn
,
NULL
,
NULL
,
domcode
,
VIR_ERR_SYSTEM_ERROR
,
VIR_ERR_ERROR
,
virRaiseErrorFull
(
conn
,
filename
,
funcname
,
linenr
,
domcode
,
VIR_ERR_SYSTEM_ERROR
,
VIR_ERR_ERROR
,
msg
,
msgDetail
,
NULL
,
-
1
,
-
1
,
msg
,
msgDetail
);
msg
,
msgDetail
,
NULL
,
-
1
,
-
1
,
msg
,
msgDetail
);
}
}
void
virReportOOMErrorFull
(
virConnectPtr
conn
,
void
virReportOOMErrorFull
(
virConnectPtr
conn
,
int
domcode
,
int
domcode
,
const
char
*
filename
ATTRIBUTE_UNUSED
,
const
char
*
filename
,
const
char
*
funcname
ATTRIBUTE_UNUSED
,
const
char
*
funcname
,
size_t
linenr
ATTRIBUTE_UNUSED
)
size_t
linenr
)
{
{
const
char
*
virerr
;
const
char
*
virerr
;
virerr
=
virErrorMsg
(
VIR_ERR_NO_MEMORY
,
NULL
);
virerr
=
virErrorMsg
(
VIR_ERR_NO_MEMORY
,
NULL
);
virRaiseError
(
conn
,
NULL
,
NULL
,
domcode
,
VIR_ERR_NO_MEMORY
,
VIR_ERR_ERROR
,
virRaiseErrorFull
(
conn
,
filename
,
funcname
,
linenr
,
domcode
,
VIR_ERR_NO_MEMORY
,
VIR_ERR_ERROR
,
virerr
,
NULL
,
NULL
,
-
1
,
-
1
,
virerr
,
NULL
);
virerr
,
NULL
,
NULL
,
-
1
,
-
1
,
virerr
,
NULL
);
}
}
src/virterror_internal.h
浏览文件 @
fb828ed2
...
@@ -33,17 +33,28 @@ extern void *virUserData;
...
@@ -33,17 +33,28 @@ extern void *virUserData;
* *
* *
************************************************************************/
************************************************************************/
int
virErrorInitialize
(
void
);
int
virErrorInitialize
(
void
);
void
virRaiseError
(
virConnectPtr
conn
,
void
virRaiseErrorFull
(
virConnectPtr
conn
,
virDomainPtr
dom
,
const
char
*
filename
,
virNetworkPtr
net
,
const
char
*
funcname
,
size_t
linenr
,
int
domain
,
int
domain
,
int
code
,
int
code
,
virErrorLevel
level
,
virErrorLevel
level
,
const
char
*
str1
,
const
char
*
str1
,
const
char
*
str2
,
const
char
*
str2
,
const
char
*
str3
,
const
char
*
str3
,
int
int1
,
int
int2
,
const
char
*
msg
,
...)
int
int1
,
ATTRIBUTE_FORMAT
(
printf
,
12
,
13
);
int
int2
,
const
char
*
fmt
,
...)
ATTRIBUTE_FORMAT
(
printf
,
13
,
14
);
/* Includes 'dom' and 'net' for compatbility, but they're ignored */
#define virRaiseError(conn, dom, net, domain, code, level, \
str1, str2, str3, int1, int2, msg, ...) \
virRaiseErrorFull(conn, __FILE__, __FUNCTION__, __LINE__, \
domain, code, level, str1, str2, str3, int1, int2, \
msg, __VA_ARGS__)
const
char
*
virErrorMsg
(
virErrorNumber
error
,
const
char
*
info
);
const
char
*
virErrorMsg
(
virErrorNumber
error
,
const
char
*
info
);
void
virReportErrorHelper
(
virConnectPtr
conn
,
int
domcode
,
int
errcode
,
void
virReportErrorHelper
(
virConnectPtr
conn
,
int
domcode
,
int
errcode
,
const
char
*
filename
ATTRIBUTE_UNUSED
,
const
char
*
filename
ATTRIBUTE_UNUSED
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录