Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
bc7b3043
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看板
提交
bc7b3043
编写于
11月 22, 2013
作者:
C
Cédric Bosdonnat
提交者:
Daniel P. Berrange
12月 10, 2013
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Create virDomainEventDiskChange to get rid of the huge union
上级
0ac4c9ed
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
56 addition
and
31 deletion
+56
-31
src/conf/domain_event.c
src/conf/domain_event.c
+56
-31
未找到文件。
src/conf/domain_event.c
浏览文件 @
bc7b3043
...
...
@@ -91,6 +91,8 @@ static virClassPtr virDomainEventWatchdogClass;
static
virClassPtr
virDomainEventIOErrorClass
;
static
virClassPtr
virDomainEventGraphicsClass
;
static
virClassPtr
virDomainEventBlockJobClass
;
static
virClassPtr
virDomainEventDiskChangeClass
;
static
void
virObjectEventDispose
(
void
*
obj
);
static
void
virDomainEventDispose
(
void
*
obj
);
static
void
virDomainEventLifecycleDispose
(
void
*
obj
);
...
...
@@ -99,6 +101,7 @@ static void virDomainEventWatchdogDispose(void *obj);
static
void
virDomainEventIOErrorDispose
(
void
*
obj
);
static
void
virDomainEventGraphicsDispose
(
void
*
obj
);
static
void
virDomainEventBlockJobDispose
(
void
*
obj
);
static
void
virDomainEventDiskChangeDispose
(
void
*
obj
);
struct
_virObjectEvent
{
virObject
parent
;
...
...
@@ -111,12 +114,6 @@ struct _virDomainEvent {
virObjectMeta
meta
;
union
{
struct
{
char
*
oldSrcPath
;
char
*
newSrcPath
;
char
*
devAlias
;
int
reason
;
}
diskChange
;
struct
{
char
*
devAlias
;
int
reason
;
...
...
@@ -189,6 +186,18 @@ struct _virDomainEventGraphics {
typedef
struct
_virDomainEventGraphics
virDomainEventGraphics
;
typedef
virDomainEventGraphics
*
virDomainEventGraphicsPtr
;
struct
_virDomainEventDiskChange
{
virDomainEvent
parent
;
char
*
oldSrcPath
;
char
*
newSrcPath
;
char
*
devAlias
;
int
reason
;
};
typedef
struct
_virDomainEventDiskChange
virDomainEventDiskChange
;
typedef
virDomainEventDiskChange
*
virDomainEventDiskChangePtr
;
static
int
virObjectEventOnceInit
(
void
)
{
if
(
!
(
virObjectEventClass
=
...
...
@@ -239,6 +248,12 @@ static int virObjectEventOnceInit(void)
sizeof
(
virDomainEventBlockJob
),
virDomainEventBlockJobDispose
)))
return
-
1
;
if
(
!
(
virDomainEventDiskChangeClass
=
virClassNew
(
virDomainEventClass
,
"virDomainEventDiskChange"
,
sizeof
(
virDomainEventDiskChange
),
virDomainEventDiskChangeDispose
)))
return
-
1
;
return
0
;
}
...
...
@@ -271,11 +286,6 @@ static void virDomainEventDispose(void *obj)
switch
(
virObjectEventGetEventID
(
event
))
{
case
VIR_DOMAIN_EVENT_ID_DISK_CHANGE
:
VIR_FREE
(
event
->
data
.
diskChange
.
oldSrcPath
);
VIR_FREE
(
event
->
data
.
diskChange
.
newSrcPath
);
VIR_FREE
(
event
->
data
.
diskChange
.
devAlias
);
break
;
case
VIR_DOMAIN_EVENT_ID_TRAY_CHANGE
:
VIR_FREE
(
event
->
data
.
trayChange
.
devAlias
);
break
;
...
...
@@ -349,6 +359,16 @@ static void virDomainEventBlockJobDispose(void *obj)
VIR_FREE
(
event
->
path
);
}
static
void
virDomainEventDiskChangeDispose
(
void
*
obj
)
{
virDomainEventDiskChangePtr
event
=
obj
;
VIR_DEBUG
(
"obj=%p"
,
event
);
VIR_FREE
(
event
->
oldSrcPath
);
VIR_FREE
(
event
->
newSrcPath
);
VIR_FREE
(
event
->
devAlias
);
}
/**
* virObjectEventCallbackListFree:
* @list: event callback list head
...
...
@@ -1249,35 +1269,35 @@ virDomainEventPtr virDomainEventControlErrorNewFromObj(virDomainObjPtr obj)
return
ev
;
}
static
virDomainEventPtr
virDomainEventDiskChangeNew
(
int
id
,
const
char
*
name
,
static
virDomainEvent
Ptr
virDomainEvent
DiskChangeNew
(
int
id
,
const
char
*
name
,
unsigned
char
*
uuid
,
const
char
*
oldSrcPath
,
const
char
*
newSrcPath
,
const
char
*
devAlias
,
int
reason
)
{
virDomainEventPtr
ev
;
virDomainEvent
DiskChange
Ptr
ev
;
if
(
virObjectEventInitialize
()
<
0
)
return
NULL
;
if
(
!
(
ev
=
virDomainEventNew
(
virDomainEventClass
,
if
(
!
(
ev
=
virDomainEventNew
(
virDomainEvent
DiskChange
Class
,
VIR_DOMAIN_EVENT_ID_DISK_CHANGE
,
id
,
name
,
uuid
)))
return
NULL
;
if
(
VIR_STRDUP
(
ev
->
d
ata
.
diskChange
.
d
evAlias
,
devAlias
)
<
0
)
if
(
VIR_STRDUP
(
ev
->
devAlias
,
devAlias
)
<
0
)
goto
error
;
if
(
VIR_STRDUP
(
ev
->
data
.
diskChange
.
oldSrcPath
,
oldSrcPath
)
<
0
)
if
(
VIR_STRDUP
(
ev
->
oldSrcPath
,
oldSrcPath
)
<
0
)
goto
error
;
if
(
VIR_STRDUP
(
ev
->
data
.
diskChange
.
newSrcPath
,
newSrcPath
)
<
0
)
if
(
VIR_STRDUP
(
ev
->
newSrcPath
,
newSrcPath
)
<
0
)
goto
error
;
ev
->
data
.
diskChange
.
reason
=
reason
;
ev
->
reason
=
reason
;
return
ev
;
return
(
virDomainEventPtr
)
ev
;
error:
virObjectUnref
(
ev
);
...
...
@@ -1671,13 +1691,18 @@ virDomainEventDispatchDefaultFunc(virConnectPtr conn,
}
case
VIR_DOMAIN_EVENT_ID_DISK_CHANGE
:
{
virDomainEventDiskChangePtr
diskChangeEvent
;
diskChangeEvent
=
(
virDomainEventDiskChangePtr
)
event
;
((
virConnectDomainEventDiskChangeCallback
)
cb
)(
conn
,
dom
,
event
->
data
.
diskChange
.
oldSrcPath
,
event
->
data
.
diskChange
.
newSrcPath
,
event
->
data
.
diskChange
.
devAlias
,
event
->
data
.
diskChange
.
reason
,
diskChangeEvent
->
oldSrcPath
,
diskChangeEvent
->
newSrcPath
,
diskChangeEvent
->
devAlias
,
diskChangeEvent
->
reason
,
cbopaque
);
goto
cleanup
;
}
case
VIR_DOMAIN_EVENT_ID_TRAY_CHANGE
:
((
virConnectDomainEventTrayChangeCallback
)
cb
)(
conn
,
dom
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录