Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
62aa1b56
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看板
提交
62aa1b56
编写于
4月 24, 2009
作者:
D
Daniel P. Berrange
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add virNodeDeviceCreateXML / virNodeDeviceDestroy boilerplate public API and remote protocol impl
上级
1aac8114
变更
15
隐藏空白更改
内联
并排
Showing
15 changed file
with
345 addition
and
3 deletion
+345
-3
ChangeLog
ChangeLog
+21
-0
include/libvirt/libvirt.h
include/libvirt/libvirt.h
+6
-0
include/libvirt/libvirt.h.in
include/libvirt/libvirt.h.in
+6
-0
qemud/remote.c
qemud/remote.c
+48
-0
qemud/remote_dispatch_args.h
qemud/remote_dispatch_args.h
+2
-0
qemud/remote_dispatch_prototypes.h
qemud/remote_dispatch_prototypes.h
+14
-0
qemud/remote_dispatch_ret.h
qemud/remote_dispatch_ret.h
+1
-0
qemud/remote_dispatch_table.h
qemud/remote_dispatch_table.h
+12
-2
qemud/remote_protocol.c
qemud/remote_protocol.c
+29
-0
qemud/remote_protocol.h
qemud/remote_protocol.h
+24
-0
qemud/remote_protocol.x
qemud/remote_protocol.x
+17
-1
src/driver.h
src/driver.h
+7
-0
src/libvirt.c
src/libvirt.c
+97
-0
src/libvirt_public.syms
src/libvirt_public.syms
+6
-0
src/remote_internal.c
src/remote_internal.c
+55
-0
未找到文件。
ChangeLog
浏览文件 @
62aa1b56
Fri Apr 24 14:07:22 BST 2009 Daniel P. Berrange <berrange@redhat.com>
Add virNodeDeviceCreateXML / virNodeDeviceDestroy boilerplate
public API and remote protocol impl
* include/libvirt/libvirt.h, include/libvirt/libvirt.h.in,
src/libvirt_public.syms: Public API definition of new
virNodeDeviceCreateXML and virNodeDeviceDestroy methods
* qemud/remote.c: Dispatch code for new APIs
* qemud/remote_dispatch_args.h, qemud/remote_dispatch_prototypes.h,
qemud/remote_dispatch_ret.h, qemud/remote_dispatch_table.h:
Re-generate stubs for dispatcher
* qemud/remote_protocol.x: Define wire protocol for node
device create / destroy APIs
* qemud/remote_protocol.c, qemud/remote_protocol.h:
Re-generate based off protocol additions
* src/driver.h: Define internal driver API contract for
new public APIs
* src/libvirt.c: Wire up public API to driver API for
virNodeDeviceCreateXML/virNodeDeviceDestroy
* src/remote_internal.c: Client for new node device methods
Fri Apr 24 13:19:47 BST 2009 Daniel P. Berrange <berrange@redhat.com>
* src/libvirt_private.syms: Add virDomainHostdevDefFree needed
...
...
include/libvirt/libvirt.h
浏览文件 @
62aa1b56
...
...
@@ -1124,6 +1124,12 @@ int virNodeDeviceDettach (virNodeDevicePtr dev);
int
virNodeDeviceReAttach
(
virNodeDevicePtr
dev
);
int
virNodeDeviceReset
(
virNodeDevicePtr
dev
);
virNodeDevicePtr
virNodeDeviceCreateXML
(
virConnectPtr
conn
,
const
char
*
xmlDesc
,
unsigned
int
flags
);
int
virNodeDeviceDestroy
(
virNodeDevicePtr
dev
);
/*
* Domain Event Notification
*/
...
...
include/libvirt/libvirt.h.in
浏览文件 @
62aa1b56
...
...
@@ -1124,6 +1124,12 @@ int virNodeDeviceDettach (virNodeDevicePtr dev);
int
virNodeDeviceReAttach
(
virNodeDevicePtr
dev
);
int
virNodeDeviceReset
(
virNodeDevicePtr
dev
);
virNodeDevicePtr
virNodeDeviceCreateXML
(
virConnectPtr
conn
,
const
char
*
xmlDesc
,
unsigned
int
flags
);
int
virNodeDeviceDestroy
(
virNodeDevicePtr
dev
);
/*
* Domain Event Notification
*/
...
...
qemud/remote.c
浏览文件 @
62aa1b56
...
...
@@ -4323,6 +4323,54 @@ remoteDispatchNodeDeviceReset (struct qemud_server *server ATTRIBUTE_UNUSED,
}
static
int
remoteDispatchNodeDeviceCreateXml
(
struct
qemud_server
*
server
ATTRIBUTE_UNUSED
,
struct
qemud_client
*
client
ATTRIBUTE_UNUSED
,
virConnectPtr
conn
,
remote_error
*
rerr
,
remote_node_device_create_xml_args
*
args
,
remote_node_device_create_xml_ret
*
ret
)
{
virNodeDevicePtr
dev
;
dev
=
virNodeDeviceCreateXML
(
conn
,
args
->
xml_desc
,
args
->
flags
);
if
(
dev
==
NULL
)
{
remoteDispatchConnError
(
rerr
,
conn
);
return
-
1
;
}
make_nonnull_node_device
(
&
ret
->
dev
,
dev
);
virNodeDeviceFree
(
dev
);
return
0
;
}
static
int
remoteDispatchNodeDeviceDestroy
(
struct
qemud_server
*
server
ATTRIBUTE_UNUSED
,
struct
qemud_client
*
client
ATTRIBUTE_UNUSED
,
virConnectPtr
conn
,
remote_error
*
rerr
,
remote_node_device_destroy_args
*
args
,
void
*
ret
ATTRIBUTE_UNUSED
)
{
virNodeDevicePtr
dev
;
dev
=
virNodeDeviceLookupByName
(
conn
,
args
->
name
);
if
(
dev
==
NULL
)
{
remoteDispatchFormatError
(
rerr
,
"%s"
,
_
(
"node_device not found"
));
return
-
1
;
}
if
(
virNodeDeviceDestroy
(
dev
)
==
-
1
)
{
remoteDispatchConnError
(
rerr
,
conn
);
return
-
1
;
}
return
0
;
}
/**************************
* Async Events
**************************/
...
...
qemud/remote_dispatch_args.h
浏览文件 @
62aa1b56
...
...
@@ -103,3 +103,5 @@
remote_node_device_re_attach_args
val_remote_node_device_re_attach_args
;
remote_node_device_reset_args
val_remote_node_device_reset_args
;
remote_domain_get_security_label_args
val_remote_domain_get_security_label_args
;
remote_node_device_create_xml_args
val_remote_node_device_create_xml_args
;
remote_node_device_destroy_args
val_remote_node_device_destroy_args
;
qemud/remote_dispatch_prototypes.h
浏览文件 @
62aa1b56
...
...
@@ -527,6 +527,20 @@ static int remoteDispatchNetworkUndefine(
remote_error
*
err
,
remote_network_undefine_args
*
args
,
void
*
ret
);
static
int
remoteDispatchNodeDeviceCreateXml
(
struct
qemud_server
*
server
,
struct
qemud_client
*
client
,
virConnectPtr
conn
,
remote_error
*
err
,
remote_node_device_create_xml_args
*
args
,
remote_node_device_create_xml_ret
*
ret
);
static
int
remoteDispatchNodeDeviceDestroy
(
struct
qemud_server
*
server
,
struct
qemud_client
*
client
,
virConnectPtr
conn
,
remote_error
*
err
,
remote_node_device_destroy_args
*
args
,
void
*
ret
);
static
int
remoteDispatchNodeDeviceDettach
(
struct
qemud_server
*
server
,
struct
qemud_client
*
client
,
...
...
qemud/remote_dispatch_ret.h
浏览文件 @
62aa1b56
...
...
@@ -88,3 +88,4 @@
remote_node_device_list_caps_ret
val_remote_node_device_list_caps_ret
;
remote_domain_get_security_label_ret
val_remote_domain_get_security_label_ret
;
remote_node_get_security_model_ret
val_remote_node_get_security_model_ret
;
remote_node_device_create_xml_ret
val_remote_node_device_create_xml_ret
;
qemud/remote_dispatch_table.h
浏览文件 @
62aa1b56
...
...
@@ -607,13 +607,23 @@
.
args_filter
=
(
xdrproc_t
)
xdr_remote_node_device_reset_args
,
.
ret_filter
=
(
xdrproc_t
)
xdr_void
,
},
{
/* DomainGetSecurityLabel => 1
18
*/
{
/* DomainGetSecurityLabel => 1
21
*/
.
fn
=
(
dispatch_fn
)
remoteDispatchDomainGetSecurityLabel
,
.
args_filter
=
(
xdrproc_t
)
xdr_remote_domain_get_security_label_args
,
.
ret_filter
=
(
xdrproc_t
)
xdr_remote_domain_get_security_label_ret
,
},
{
/* NodeGetSecurityModel => 1
19
*/
{
/* NodeGetSecurityModel => 1
22
*/
.
fn
=
(
dispatch_fn
)
remoteDispatchNodeGetSecurityModel
,
.
args_filter
=
(
xdrproc_t
)
xdr_void
,
.
ret_filter
=
(
xdrproc_t
)
xdr_remote_node_get_security_model_ret
,
},
{
/* NodeDeviceCreateXml => 123 */
.
fn
=
(
dispatch_fn
)
remoteDispatchNodeDeviceCreateXml
,
.
args_filter
=
(
xdrproc_t
)
xdr_remote_node_device_create_xml_args
,
.
ret_filter
=
(
xdrproc_t
)
xdr_remote_node_device_create_xml_ret
,
},
{
/* NodeDeviceDestroy => 124 */
.
fn
=
(
dispatch_fn
)
remoteDispatchNodeDeviceDestroy
,
.
args_filter
=
(
xdrproc_t
)
xdr_remote_node_device_destroy_args
,
.
ret_filter
=
(
xdrproc_t
)
xdr_void
,
},
qemud/remote_protocol.c
浏览文件 @
62aa1b56
...
...
@@ -2229,6 +2229,35 @@ xdr_remote_node_device_reset_args (XDR *xdrs, remote_node_device_reset_args *obj
return
TRUE
;
}
bool_t
xdr_remote_node_device_create_xml_args
(
XDR
*
xdrs
,
remote_node_device_create_xml_args
*
objp
)
{
if
(
!
xdr_remote_nonnull_string
(
xdrs
,
&
objp
->
xml_desc
))
return
FALSE
;
if
(
!
xdr_int
(
xdrs
,
&
objp
->
flags
))
return
FALSE
;
return
TRUE
;
}
bool_t
xdr_remote_node_device_create_xml_ret
(
XDR
*
xdrs
,
remote_node_device_create_xml_ret
*
objp
)
{
if
(
!
xdr_remote_nonnull_node_device
(
xdrs
,
&
objp
->
dev
))
return
FALSE
;
return
TRUE
;
}
bool_t
xdr_remote_node_device_destroy_args
(
XDR
*
xdrs
,
remote_node_device_destroy_args
*
objp
)
{
if
(
!
xdr_remote_nonnull_string
(
xdrs
,
&
objp
->
name
))
return
FALSE
;
return
TRUE
;
}
bool_t
xdr_remote_domain_events_register_ret
(
XDR
*
xdrs
,
remote_domain_events_register_ret
*
objp
)
{
...
...
qemud/remote_protocol.h
浏览文件 @
62aa1b56
...
...
@@ -1255,6 +1255,22 @@ struct remote_node_device_reset_args {
};
typedef
struct
remote_node_device_reset_args
remote_node_device_reset_args
;
struct
remote_node_device_create_xml_args
{
remote_nonnull_string
xml_desc
;
int
flags
;
};
typedef
struct
remote_node_device_create_xml_args
remote_node_device_create_xml_args
;
struct
remote_node_device_create_xml_ret
{
remote_nonnull_node_device
dev
;
};
typedef
struct
remote_node_device_create_xml_ret
remote_node_device_create_xml_ret
;
struct
remote_node_device_destroy_args
{
remote_nonnull_string
name
;
};
typedef
struct
remote_node_device_destroy_args
remote_node_device_destroy_args
;
struct
remote_domain_events_register_ret
{
int
cb_registered
;
};
...
...
@@ -1397,6 +1413,8 @@ enum remote_procedure {
REMOTE_PROC_NODE_DEVICE_RESET
=
120
,
REMOTE_PROC_DOMAIN_GET_SECURITY_LABEL
=
121
,
REMOTE_PROC_NODE_GET_SECURITY_MODEL
=
122
,
REMOTE_PROC_NODE_DEVICE_CREATE_XML
=
123
,
REMOTE_PROC_NODE_DEVICE_DESTROY
=
124
,
};
typedef
enum
remote_procedure
remote_procedure
;
...
...
@@ -1629,6 +1647,9 @@ extern bool_t xdr_remote_node_device_list_caps_ret (XDR *, remote_node_device_l
extern
bool_t
xdr_remote_node_device_dettach_args
(
XDR
*
,
remote_node_device_dettach_args
*
);
extern
bool_t
xdr_remote_node_device_re_attach_args
(
XDR
*
,
remote_node_device_re_attach_args
*
);
extern
bool_t
xdr_remote_node_device_reset_args
(
XDR
*
,
remote_node_device_reset_args
*
);
extern
bool_t
xdr_remote_node_device_create_xml_args
(
XDR
*
,
remote_node_device_create_xml_args
*
);
extern
bool_t
xdr_remote_node_device_create_xml_ret
(
XDR
*
,
remote_node_device_create_xml_ret
*
);
extern
bool_t
xdr_remote_node_device_destroy_args
(
XDR
*
,
remote_node_device_destroy_args
*
);
extern
bool_t
xdr_remote_domain_events_register_ret
(
XDR
*
,
remote_domain_events_register_ret
*
);
extern
bool_t
xdr_remote_domain_events_deregister_ret
(
XDR
*
,
remote_domain_events_deregister_ret
*
);
extern
bool_t
xdr_remote_domain_event_ret
(
XDR
*
,
remote_domain_event_ret
*
);
...
...
@@ -1840,6 +1861,9 @@ extern bool_t xdr_remote_node_device_list_caps_ret ();
extern
bool_t
xdr_remote_node_device_dettach_args
();
extern
bool_t
xdr_remote_node_device_re_attach_args
();
extern
bool_t
xdr_remote_node_device_reset_args
();
extern
bool_t
xdr_remote_node_device_create_xml_args
();
extern
bool_t
xdr_remote_node_device_create_xml_ret
();
extern
bool_t
xdr_remote_node_device_destroy_args
();
extern
bool_t
xdr_remote_domain_events_register_ret
();
extern
bool_t
xdr_remote_domain_events_deregister_ret
();
extern
bool_t
xdr_remote_domain_event_ret
();
...
...
qemud/remote_protocol.x
浏览文件 @
62aa1b56
...
...
@@ -1109,6 +1109,19 @@ struct remote_node_device_reset_args {
remote_nonnull_string
name
;
};
struct
remote_node_device_create_xml_args
{
remote_nonnull_string
xml_desc
;
int
flags
;
};
struct
remote_node_device_create_xml_ret
{
remote_nonnull_node_device
dev
;
};
struct
remote_node_device_destroy_args
{
remote_nonnull_string
name
;
};
/**
* Events Register/Deregister:
...
...
@@ -1270,7 +1283,10 @@ enum remote_procedure {
REMOTE_PROC_NODE_DEVICE_RESET
=
120
,
REMOTE_PROC_DOMAIN_GET_SECURITY_LABEL
=
121
,
REMOTE_PROC_NODE_GET_SECURITY_MODEL
=
122
REMOTE_PROC_NODE_GET_SECURITY_MODEL
=
122
,
REMOTE_PROC_NODE_DEVICE_CREATE_XML
=
123
,
REMOTE_PROC_NODE_DEVICE_DESTROY
=
124
};
/* Custom RPC structure. */
...
...
src/driver.h
浏览文件 @
62aa1b56
...
...
@@ -684,6 +684,11 @@ typedef int (*virDevMonDeviceListCaps)(virNodeDevicePtr dev,
char
**
const
names
,
int
maxnames
);
typedef
virNodeDevicePtr
(
*
virDrvNodeDeviceCreateXML
)(
virConnectPtr
conn
,
const
char
*
xmlDesc
,
unsigned
int
flags
);
typedef
int
(
*
virDrvNodeDeviceDestroy
)(
virNodeDevicePtr
dev
);
/**
* _virDeviceMonitor:
*
...
...
@@ -702,6 +707,8 @@ struct _virDeviceMonitor {
virDevMonDeviceGetParent
deviceGetParent
;
virDevMonDeviceNumOfCaps
deviceNumOfCaps
;
virDevMonDeviceListCaps
deviceListCaps
;
virDrvNodeDeviceCreateXML
deviceCreateXML
;
virDrvNodeDeviceDestroy
deviceDestroy
;
};
/*
...
...
src/libvirt.c
浏览文件 @
62aa1b56
...
...
@@ -7491,6 +7491,103 @@ error:
}
/**
* virNodeDeviceCreateXML:
* @conn: pointer to the hypervisor connection
* @xmlDesc: string containing an XML description of the device to be created
* @flags: callers should always pass 0
*
* Create a new device on the VM host machine, for example, virtual
* HBAs created using vport_create.
*
* Returns a node device object if successful, NULL in case of failure
*/
virNodeDevicePtr
virNodeDeviceCreateXML
(
virConnectPtr
conn
,
const
char
*
xmlDesc
,
unsigned
int
flags
)
{
VIR_DEBUG
(
"conn=%p, xmlDesc=%s, flags=%d"
,
conn
,
xmlDesc
,
flags
);
virResetLastError
();
if
(
!
VIR_IS_CONNECT
(
conn
))
{
virLibConnError
(
NULL
,
VIR_ERR_INVALID_CONN
,
__FUNCTION__
);
return
NULL
;
}
if
(
conn
->
flags
&
VIR_CONNECT_RO
)
{
virLibConnError
(
conn
,
VIR_ERR_OPERATION_DENIED
,
__FUNCTION__
);
goto
error
;
}
if
(
xmlDesc
==
NULL
)
{
virLibConnError
(
conn
,
VIR_ERR_INVALID_ARG
,
__FUNCTION__
);
goto
error
;
}
if
(
conn
->
deviceMonitor
&&
conn
->
deviceMonitor
->
deviceCreateXML
)
{
virNodeDevicePtr
dev
=
conn
->
deviceMonitor
->
deviceCreateXML
(
conn
,
xmlDesc
,
flags
);
if
(
dev
==
NULL
)
goto
error
;
return
dev
;
}
virLibConnError
(
conn
,
VIR_ERR_NO_SUPPORT
,
__FUNCTION__
);
error:
/* Copy to connection error object for back compatability */
virSetConnError
(
conn
);
return
NULL
;
}
/**
* virNodeDeviceDestroy:
* @dev: a device object
*
* Destroy the device object. The virtual device is removed from the host operating system.
* This function may require privileged access
*
* Returns 0 in case of success and -1 in case of failure.
*/
int
virNodeDeviceDestroy
(
virNodeDevicePtr
dev
)
{
DEBUG
(
"dev=%p"
,
dev
);
virResetLastError
();
if
(
!
VIR_IS_CONNECTED_NODE_DEVICE
(
dev
))
{
virLibNodeDeviceError
(
NULL
,
VIR_ERR_INVALID_NODE_DEVICE
,
__FUNCTION__
);
return
(
-
1
);
}
if
(
dev
->
conn
->
flags
&
VIR_CONNECT_RO
)
{
virLibConnError
(
dev
->
conn
,
VIR_ERR_OPERATION_DENIED
,
__FUNCTION__
);
goto
error
;
}
if
(
dev
->
conn
->
deviceMonitor
&&
dev
->
conn
->
deviceMonitor
->
deviceDestroy
)
{
int
retval
=
dev
->
conn
->
deviceMonitor
->
deviceDestroy
(
dev
);
if
(
retval
<
0
)
{
goto
error
;
}
return
0
;
}
virLibConnError
(
dev
->
conn
,
VIR_ERR_NO_SUPPORT
,
__FUNCTION__
);
error:
/* Copy to connection error object for back compatability */
virSetConnError
(
dev
->
conn
);
return
-
1
;
}
/*
* Domain Event Notification
*/
...
...
src/libvirt_public.syms
浏览文件 @
62aa1b56
...
...
@@ -258,4 +258,10 @@ LIBVIRT_0.6.1 {
virNodeGetSecurityModel;
} LIBVIRT_0.6.0;
LIBVIRT_0.6.3 {
global:
virNodeDeviceCreateXML;
virNodeDeviceDestroy;
} LIBVIRT_0.6.1;
# .... define new API here using predicted next version number ....
src/remote_internal.c
浏览文件 @
62aa1b56
...
...
@@ -4987,6 +4987,59 @@ done:
}
static
virNodeDevicePtr
remoteNodeDeviceCreateXML
(
virConnectPtr
conn
,
const
char
*
xmlDesc
,
unsigned
int
flags
)
{
remote_node_device_create_xml_args
args
;
remote_node_device_create_xml_ret
ret
;
virNodeDevicePtr
dev
=
NULL
;
struct
private_data
*
priv
=
conn
->
privateData
;
remoteDriverLock
(
priv
);
memset
(
&
ret
,
0
,
sizeof
ret
);
args
.
xml_desc
=
(
char
*
)
xmlDesc
;
args
.
flags
=
flags
;
if
(
call
(
conn
,
priv
,
0
,
REMOTE_PROC_NODE_DEVICE_CREATE_XML
,
(
xdrproc_t
)
xdr_remote_node_device_create_xml_args
,
(
char
*
)
&
args
,
(
xdrproc_t
)
xdr_remote_node_device_create_xml_ret
,
(
char
*
)
&
ret
)
==
-
1
)
goto
done
;
dev
=
get_nonnull_node_device
(
conn
,
ret
.
dev
);
xdr_free
((
xdrproc_t
)
xdr_remote_node_device_create_xml_ret
,
(
char
*
)
&
ret
);
done:
remoteDriverUnlock
(
priv
);
return
dev
;
}
static
int
remoteNodeDeviceDestroy
(
virNodeDevicePtr
dev
)
{
int
rv
=
-
1
;
remote_node_device_destroy_args
args
;
struct
private_data
*
priv
=
dev
->
conn
->
privateData
;
remoteDriverLock
(
priv
);
args
.
name
=
dev
->
name
;
if
(
call
(
dev
->
conn
,
priv
,
0
,
REMOTE_PROC_NODE_DEVICE_RESET
,
(
xdrproc_t
)
xdr_remote_node_device_destroy_args
,
(
char
*
)
&
args
,
(
xdrproc_t
)
xdr_void
,
(
char
*
)
NULL
)
==
-
1
)
goto
done
;
rv
=
0
;
done:
remoteDriverUnlock
(
priv
);
return
rv
;
}
/*----------------------------------------------------------------------*/
static
int
...
...
@@ -6991,6 +7044,8 @@ static virDeviceMonitor dev_monitor = {
.
deviceGetParent
=
remoteNodeDeviceGetParent
,
.
deviceNumOfCaps
=
remoteNodeDeviceNumOfCaps
,
.
deviceListCaps
=
remoteNodeDeviceListCaps
,
.
deviceCreateXML
=
remoteNodeDeviceCreateXML
,
.
deviceDestroy
=
remoteNodeDeviceDestroy
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录