Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
a776fad3
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看板
提交
a776fad3
编写于
1月 20, 2009
作者:
D
Daniel P. Berrange
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add public APIs for ref counting on public objects
上级
0466ff28
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
214 addition
and
1 deletion
+214
-1
ChangeLog
ChangeLog
+8
-0
include/libvirt/libvirt.h
include/libvirt/libvirt.h
+6
-0
include/libvirt/libvirt.h.in
include/libvirt/libvirt.h.in
+6
-0
src/libvirt.c
src/libvirt.c
+183
-0
src/libvirt_public.syms
src/libvirt_public.syms
+11
-1
未找到文件。
ChangeLog
浏览文件 @
a776fad3
Tue Jan 20 12:08:53 GMT 2009 Daniel P. Berrange <berrange@redhat.com>
* include/libvirt/libvirt.h, include/libvirt/libvirt.h.in,
src/libvirt.c, src/libvirt_public.syms: Add new ref counting
APIs for public objects: virConnectRef, virDomainRef,
virNetworkRef, virStoragePoolRef, virStorageVolRef,
virNodeDeviceRef
Tue Jan 20 12:03:53 GMT 2009 Daniel P. Berrange <berrange@redhat.com>
* tests/cpuset, tests/read-bufsiz, tests/start, tests/undefine,
...
...
include/libvirt/libvirt.h
浏览文件 @
a776fad3
...
...
@@ -396,6 +396,7 @@ virConnectPtr virConnectOpenReadOnly (const char *name);
virConnectPtr
virConnectOpenAuth
(
const
char
*
name
,
virConnectAuthPtr
auth
,
int
flags
);
int
virConnectRef
(
virConnectPtr
conn
);
int
virConnectClose
(
virConnectPtr
conn
);
const
char
*
virConnectGetType
(
virConnectPtr
conn
);
int
virConnectGetVersion
(
virConnectPtr
conn
,
...
...
@@ -453,6 +454,7 @@ int virDomainShutdown (virDomainPtr domain);
int
virDomainReboot
(
virDomainPtr
domain
,
unsigned
int
flags
);
int
virDomainDestroy
(
virDomainPtr
domain
);
int
virDomainRef
(
virDomainPtr
domain
);
int
virDomainFree
(
virDomainPtr
domain
);
/*
...
...
@@ -765,6 +767,7 @@ int virNetworkCreate (virNetworkPtr network);
* Network destroy/free
*/
int
virNetworkDestroy
(
virNetworkPtr
network
);
int
virNetworkRef
(
virNetworkPtr
network
);
int
virNetworkFree
(
virNetworkPtr
network
);
/*
...
...
@@ -925,6 +928,7 @@ int virStoragePoolCreate (virStoragePoolPtr pool,
int
virStoragePoolDestroy
(
virStoragePoolPtr
pool
);
int
virStoragePoolDelete
(
virStoragePoolPtr
pool
,
unsigned
int
flags
);
int
virStoragePoolRef
(
virStoragePoolPtr
pool
);
int
virStoragePoolFree
(
virStoragePoolPtr
pool
);
int
virStoragePoolRefresh
(
virStoragePoolPtr
pool
,
unsigned
int
flags
);
...
...
@@ -978,6 +982,7 @@ virStorageVolPtr virStorageVolCreateXML (virStoragePoolPtr pool,
unsigned
int
flags
);
int
virStorageVolDelete
(
virStorageVolPtr
vol
,
unsigned
int
flags
);
int
virStorageVolRef
(
virStorageVolPtr
vol
);
int
virStorageVolFree
(
virStorageVolPtr
vol
);
int
virStorageVolGetInfo
(
virStorageVolPtr
vol
,
...
...
@@ -1045,6 +1050,7 @@ int virNodeDeviceListCaps (virNodeDevicePtr dev,
char
*
virNodeDeviceGetXMLDesc
(
virNodeDevicePtr
dev
,
unsigned
int
flags
);
int
virNodeDeviceRef
(
virNodeDevicePtr
dev
);
int
virNodeDeviceFree
(
virNodeDevicePtr
dev
);
/*
...
...
include/libvirt/libvirt.h.in
浏览文件 @
a776fad3
...
...
@@ -396,6 +396,7 @@ virConnectPtr virConnectOpenReadOnly (const char *name);
virConnectPtr
virConnectOpenAuth
(
const
char
*
name
,
virConnectAuthPtr
auth
,
int
flags
);
int
virConnectRef
(
virConnectPtr
conn
);
int
virConnectClose
(
virConnectPtr
conn
);
const
char
*
virConnectGetType
(
virConnectPtr
conn
);
int
virConnectGetVersion
(
virConnectPtr
conn
,
...
...
@@ -453,6 +454,7 @@ int virDomainShutdown (virDomainPtr domain);
int
virDomainReboot
(
virDomainPtr
domain
,
unsigned
int
flags
);
int
virDomainDestroy
(
virDomainPtr
domain
);
int
virDomainRef
(
virDomainPtr
domain
);
int
virDomainFree
(
virDomainPtr
domain
);
/*
...
...
@@ -765,6 +767,7 @@ int virNetworkCreate (virNetworkPtr network);
* Network destroy/free
*/
int
virNetworkDestroy
(
virNetworkPtr
network
);
int
virNetworkRef
(
virNetworkPtr
network
);
int
virNetworkFree
(
virNetworkPtr
network
);
/*
...
...
@@ -925,6 +928,7 @@ int virStoragePoolCreate (virStoragePoolPtr pool,
int
virStoragePoolDestroy
(
virStoragePoolPtr
pool
);
int
virStoragePoolDelete
(
virStoragePoolPtr
pool
,
unsigned
int
flags
);
int
virStoragePoolRef
(
virStoragePoolPtr
pool
);
int
virStoragePoolFree
(
virStoragePoolPtr
pool
);
int
virStoragePoolRefresh
(
virStoragePoolPtr
pool
,
unsigned
int
flags
);
...
...
@@ -978,6 +982,7 @@ virStorageVolPtr virStorageVolCreateXML (virStoragePoolPtr pool,
unsigned
int
flags
);
int
virStorageVolDelete
(
virStorageVolPtr
vol
,
unsigned
int
flags
);
int
virStorageVolRef
(
virStorageVolPtr
vol
);
int
virStorageVolFree
(
virStorageVolPtr
vol
);
int
virStorageVolGetInfo
(
virStorageVolPtr
vol
,
...
...
@@ -1045,6 +1050,7 @@ int virNodeDeviceListCaps (virNodeDevicePtr dev,
char
*
virNodeDeviceGetXMLDesc
(
virNodeDevicePtr
dev
,
unsigned
int
flags
);
int
virNodeDeviceRef
(
virNodeDevicePtr
dev
);
int
virNodeDeviceFree
(
virNodeDevicePtr
dev
);
/*
...
...
src/libvirt.c
浏览文件 @
a776fad3
...
...
@@ -1119,6 +1119,35 @@ virConnectClose(virConnectPtr conn)
return
(
0
);
}
/**
* virConnectRef:
* @conn: the connection to hold a reference on
*
* Increment the reference count on the connection. For each
* additional call to this method, there shall be a corresponding
* call to virConnectClose to release the reference count, once
* the caller no longer needs the reference to this object.
*
* This method is typically useful for applications where multiple
* threads are using a connection, and it is required that the
* connection remain open until all threads have finished using
* it. ie, each new thread using a connection would increment
* the reference count.
*/
int
virConnectRef
(
virConnectPtr
conn
)
{
if
((
!
VIR_IS_CONNECT
(
conn
)))
{
virLibConnError
(
NULL
,
VIR_ERR_INVALID_ARG
,
__FUNCTION__
);
return
(
-
1
);
}
virMutexLock
(
&
conn
->
lock
);
DEBUG
(
"conn=%p refs=%d"
,
conn
,
conn
->
refs
);
conn
->
refs
++
;
virMutexUnlock
(
&
conn
->
lock
);
return
0
;
}
/*
* Not for public use. This function is part of the internal
* implementation of driver features in the remote case.
...
...
@@ -1776,6 +1805,36 @@ virDomainFree(virDomainPtr domain)
return
(
0
);
}
/**
* virDomainRef:
* @conn: the domain to hold a reference on
*
* Increment the reference count on the domain. For each
* additional call to this method, there shall be a corresponding
* call to virDomainFree to release the reference count, once
* the caller no longer needs the reference to this object.
*
* This method is typically useful for applications where multiple
* threads are using a connection, and it is required that the
* connection remain open until all threads have finished using
* it. ie, each new thread using a domain would increment
* the reference count.
*/
int
virDomainRef
(
virDomainPtr
domain
)
{
if
((
!
VIR_IS_CONNECTED_DOMAIN
(
domain
)))
{
virLibConnError
(
NULL
,
VIR_ERR_INVALID_ARG
,
__FUNCTION__
);
return
(
-
1
);
}
virMutexLock
(
&
domain
->
conn
->
lock
);
DEBUG
(
"domain=%p refs=%d"
,
domain
,
domain
->
refs
);
domain
->
refs
++
;
virMutexUnlock
(
&
domain
->
conn
->
lock
);
return
0
;
}
/**
* virDomainSuspend:
* @domain: a domain object
...
...
@@ -4813,6 +4872,35 @@ virNetworkFree(virNetworkPtr network)
return
(
0
);
}
/**
* virNetworkRef:
* @conn: the network to hold a reference on
*
* Increment the reference count on the network. For each
* additional call to this method, there shall be a corresponding
* call to virNetworkFree to release the reference count, once
* the caller no longer needs the reference to this object.
*
* This method is typically useful for applications where multiple
* threads are using a connection, and it is required that the
* connection remain open until all threads have finished using
* it. ie, each new thread using a network would increment
* the reference count.
*/
int
virNetworkRef
(
virNetworkPtr
network
)
{
if
((
!
VIR_IS_CONNECTED_NETWORK
(
network
)))
{
virLibConnError
(
NULL
,
VIR_ERR_INVALID_ARG
,
__FUNCTION__
);
return
(
-
1
);
}
virMutexLock
(
&
network
->
conn
->
lock
);
DEBUG
(
"network=%p refs=%d"
,
network
,
network
->
refs
);
network
->
refs
++
;
virMutexUnlock
(
&
network
->
conn
->
lock
);
return
0
;
}
/**
* virNetworkGetName:
* @network: a network object
...
...
@@ -5868,6 +5956,35 @@ virStoragePoolFree(virStoragePoolPtr pool)
}
/**
* virStoragePoolRef:
* @conn: the pool to hold a reference on
*
* Increment the reference count on the pool. For each
* additional call to this method, there shall be a corresponding
* call to virStoragePoolFree to release the reference count, once
* the caller no longer needs the reference to this object.
*
* This method is typically useful for applications where multiple
* threads are using a connection, and it is required that the
* connection remain open until all threads have finished using
* it. ie, each new thread using a pool would increment
* the reference count.
*/
int
virStoragePoolRef
(
virStoragePoolPtr
pool
)
{
if
((
!
VIR_IS_CONNECTED_STORAGE_POOL
(
pool
)))
{
virLibConnError
(
NULL
,
VIR_ERR_INVALID_ARG
,
__FUNCTION__
);
return
(
-
1
);
}
virMutexLock
(
&
pool
->
conn
->
lock
);
DEBUG
(
"pool=%p refs=%d"
,
pool
,
pool
->
refs
);
pool
->
refs
++
;
virMutexUnlock
(
&
pool
->
conn
->
lock
);
return
0
;
}
/**
* virStoragePoolRefresh:
* @pool: pointer to storage pool
...
...
@@ -6620,6 +6737,35 @@ virStorageVolFree(virStorageVolPtr vol)
}
/**
* virStorageVolRef:
* @conn: the vol to hold a reference on
*
* Increment the reference count on the vol. For each
* additional call to this method, there shall be a corresponding
* call to virStorageVolFree to release the reference count, once
* the caller no longer needs the reference to this object.
*
* This method is typically useful for applications where multiple
* threads are using a connection, and it is required that the
* connection remain open until all threads have finished using
* it. ie, each new thread using a vol would increment
* the reference count.
*/
int
virStorageVolRef
(
virStorageVolPtr
vol
)
{
if
((
!
VIR_IS_CONNECTED_STORAGE_VOL
(
vol
)))
{
virLibConnError
(
NULL
,
VIR_ERR_INVALID_ARG
,
__FUNCTION__
);
return
(
-
1
);
}
virMutexLock
(
&
vol
->
conn
->
lock
);
DEBUG
(
"vol=%p refs=%d"
,
vol
,
vol
->
refs
);
vol
->
refs
++
;
virMutexUnlock
(
&
vol
->
conn
->
lock
);
return
0
;
}
/**
* virStorageVolGetInfo:
* @vol: pointer to storage volume
...
...
@@ -7093,6 +7239,36 @@ int virNodeDeviceFree(virNodeDevicePtr dev)
}
/**
* virNodeDeviceRef:
* @conn: the dev to hold a reference on
*
* Increment the reference count on the dev. For each
* additional call to this method, there shall be a corresponding
* call to virNodeDeviceFree to release the reference count, once
* the caller no longer needs the reference to this object.
*
* This method is typically useful for applications where multiple
* threads are using a connection, and it is required that the
* connection remain open until all threads have finished using
* it. ie, each new thread using a dev would increment
* the reference count.
*/
int
virNodeDeviceRef
(
virNodeDevicePtr
dev
)
{
if
((
!
VIR_IS_CONNECTED_NODE_DEVICE
(
dev
)))
{
virLibConnError
(
NULL
,
VIR_ERR_INVALID_ARG
,
__FUNCTION__
);
return
(
-
1
);
}
virMutexLock
(
&
dev
->
conn
->
lock
);
DEBUG
(
"dev=%p refs=%d"
,
dev
,
dev
->
refs
);
dev
->
refs
++
;
virMutexUnlock
(
&
dev
->
conn
->
lock
);
return
0
;
}
/*
* Domain Event Notification
*/
...
...
@@ -7107,6 +7283,13 @@ int virNodeDeviceFree(virNodeDevicePtr dev)
* Adds a Domain Event Callback.
* Registering for a domain callback will enable delivery of the events
*
* The virDomainPtr object handle passed into the callback upon delivery
* of an event is only valid for the duration of execution of the callback.
* If the callback wishes to keep the domain object after the callback
* returns, it shall take a reference to it, by calling virDomainRef.
* The reference can be released once the object is no longer required
* by calling virDomainFree.
*
* Returns 0 on success, -1 on failure
*/
int
...
...
src/libvirt_public.syms
浏览文件 @
a776fad3
...
...
@@ -236,5 +236,15 @@ LIBVIRT_0.5.0 {
} LIBVIRT_0.4.5;
# no new entry point in 0.5.1
LIBVIRT_0.6.0 {
global:
virConnectRef;
virDomainRef;
virNetworkRef;
virStoragePoolRef;
virStorageVolRef;
virNodeDeviceRef;
} LIBVIRT_0.5.0;
# .... define new API here using predicted next version number ....
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录