Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
0d4efed0
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,发现更多精彩内容 >>
提交
0d4efed0
编写于
3月 05, 2014
作者:
C
Chunyan Liu
提交者:
Daniel P. Berrange
3月 12, 2014
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
lxc: use general virhostdev lists instead of its own
上级
e640e98f
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
27 addition
and
22 deletion
+27
-22
src/lxc/lxc_conf.h
src/lxc/lxc_conf.h
+2
-3
src/lxc/lxc_driver.c
src/lxc/lxc_driver.c
+7
-5
src/lxc/lxc_hostdev.c
src/lxc/lxc_hostdev.c
+18
-14
未找到文件。
src/lxc/lxc_conf.h
浏览文件 @
0d4efed0
...
@@ -37,6 +37,7 @@
...
@@ -37,6 +37,7 @@
# include "virsysinfo.h"
# include "virsysinfo.h"
# include "virusb.h"
# include "virusb.h"
# include "virclosecallbacks.h"
# include "virclosecallbacks.h"
# include "virhostdev.h"
# define LXC_DRIVER_NAME "LXC"
# define LXC_DRIVER_NAME "LXC"
...
@@ -93,9 +94,7 @@ struct _virLXCDriver {
...
@@ -93,9 +94,7 @@ struct _virLXCDriver {
/* Immutable pointer, self-locking APIs */
/* Immutable pointer, self-locking APIs */
virDomainObjListPtr
domains
;
virDomainObjListPtr
domains
;
/* Immutable pointer. Requires lock to be held before
virHostdevManagerPtr
hostdevMgr
;
* calling APIs. */
virUSBDeviceListPtr
activeUsbHostdevs
;
/* Immutable pointer, self-locking APIs */
/* Immutable pointer, self-locking APIs */
virObjectEventStatePtr
domainEventState
;
virObjectEventStatePtr
domainEventState
;
...
...
src/lxc/lxc_driver.c
浏览文件 @
0d4efed0
...
@@ -71,6 +71,7 @@
...
@@ -71,6 +71,7 @@
#include "virstring.h"
#include "virstring.h"
#include "viraccessapicheck.h"
#include "viraccessapicheck.h"
#include "viraccessapichecklxc.h"
#include "viraccessapichecklxc.h"
#include "virhostdev.h"
#define VIR_FROM_THIS VIR_FROM_LXC
#define VIR_FROM_THIS VIR_FROM_LXC
...
@@ -1557,7 +1558,7 @@ static int lxcStateInitialize(bool privileged,
...
@@ -1557,7 +1558,7 @@ static int lxcStateInitialize(bool privileged,
if
(
!
(
lxc_driver
->
securityManager
=
lxcSecurityInit
(
cfg
)))
if
(
!
(
lxc_driver
->
securityManager
=
lxcSecurityInit
(
cfg
)))
goto
cleanup
;
goto
cleanup
;
if
(
(
lxc_driver
->
activeUsbHostdevs
=
virUSBDeviceListNew
())
==
NULL
)
if
(
!
(
lxc_driver
->
hostdevMgr
=
virHostdevManagerGetDefault
())
)
goto
cleanup
;
goto
cleanup
;
if
((
virLXCDriverGetCapabilities
(
lxc_driver
,
true
))
==
NULL
)
if
((
virLXCDriverGetCapabilities
(
lxc_driver
,
true
))
==
NULL
)
...
@@ -1674,7 +1675,7 @@ static int lxcStateCleanup(void)
...
@@ -1674,7 +1675,7 @@ static int lxcStateCleanup(void)
virSysinfoDefFree
(
lxc_driver
->
hostsysinfo
);
virSysinfoDefFree
(
lxc_driver
->
hostsysinfo
);
virObjectUnref
(
lxc_driver
->
activeUsbHostdevs
);
virObjectUnref
(
lxc_driver
->
hostdevMgr
);
virObjectUnref
(
lxc_driver
->
caps
);
virObjectUnref
(
lxc_driver
->
caps
);
virObjectUnref
(
lxc_driver
->
securityManager
);
virObjectUnref
(
lxc_driver
->
securityManager
);
virObjectUnref
(
lxc_driver
->
xmlopt
);
virObjectUnref
(
lxc_driver
->
xmlopt
);
...
@@ -4697,6 +4698,7 @@ lxcDomainDetachDeviceHostdevUSBLive(virLXCDriverPtr driver,
...
@@ -4697,6 +4698,7 @@ lxcDomainDetachDeviceHostdevUSBLive(virLXCDriverPtr driver,
int
idx
,
ret
=
-
1
;
int
idx
,
ret
=
-
1
;
char
*
dst
=
NULL
;
char
*
dst
=
NULL
;
virUSBDevicePtr
usb
=
NULL
;
virUSBDevicePtr
usb
=
NULL
;
virHostdevManagerPtr
hostdev_mgr
=
driver
->
hostdevMgr
;
if
((
idx
=
virDomainHostdevFind
(
vm
->
def
,
if
((
idx
=
virDomainHostdevFind
(
vm
->
def
,
dev
->
data
.
hostdev
,
dev
->
data
.
hostdev
,
...
@@ -4733,9 +4735,9 @@ lxcDomainDetachDeviceHostdevUSBLive(virLXCDriverPtr driver,
...
@@ -4733,9 +4735,9 @@ lxcDomainDetachDeviceHostdevUSBLive(virLXCDriverPtr driver,
VIR_WARN
(
"cannot deny device %s for domain %s"
,
VIR_WARN
(
"cannot deny device %s for domain %s"
,
dst
,
vm
->
def
->
name
);
dst
,
vm
->
def
->
name
);
virObjectLock
(
drive
r
->
activeUsbHostdevs
);
virObjectLock
(
hostdev_mg
r
->
activeUsbHostdevs
);
virUSBDeviceListDel
(
drive
r
->
activeUsbHostdevs
,
usb
);
virUSBDeviceListDel
(
hostdev_mg
r
->
activeUsbHostdevs
,
usb
);
virObjectUnlock
(
drive
r
->
activeUsbHostdevs
);
virObjectUnlock
(
hostdev_mg
r
->
activeUsbHostdevs
);
virDomainHostdevRemove
(
vm
->
def
,
idx
);
virDomainHostdevRemove
(
vm
->
def
,
idx
);
virDomainHostdevDefFree
(
def
);
virDomainHostdevDefFree
(
def
);
...
...
src/lxc/lxc_hostdev.c
浏览文件 @
0d4efed0
...
@@ -27,6 +27,7 @@
...
@@ -27,6 +27,7 @@
#include "viralloc.h"
#include "viralloc.h"
#include "virlog.h"
#include "virlog.h"
#include "virerror.h"
#include "virerror.h"
#include "virhostdev.h"
#define VIR_FROM_THIS VIR_FROM_LXC
#define VIR_FROM_THIS VIR_FROM_LXC
...
@@ -36,6 +37,7 @@ virLXCUpdateActiveUsbHostdevs(virLXCDriverPtr driver,
...
@@ -36,6 +37,7 @@ virLXCUpdateActiveUsbHostdevs(virLXCDriverPtr driver,
{
{
virDomainHostdevDefPtr
hostdev
=
NULL
;
virDomainHostdevDefPtr
hostdev
=
NULL
;
size_t
i
;
size_t
i
;
virHostdevManagerPtr
hostdev_mgr
=
driver
->
hostdevMgr
;
if
(
!
def
->
nhostdevs
)
if
(
!
def
->
nhostdevs
)
return
0
;
return
0
;
...
@@ -62,13 +64,13 @@ virLXCUpdateActiveUsbHostdevs(virLXCDriverPtr driver,
...
@@ -62,13 +64,13 @@ virLXCUpdateActiveUsbHostdevs(virLXCDriverPtr driver,
virUSBDeviceSetUsedBy
(
usb
,
LXC_DRIVER_NAME
,
def
->
name
);
virUSBDeviceSetUsedBy
(
usb
,
LXC_DRIVER_NAME
,
def
->
name
);
virObjectLock
(
drive
r
->
activeUsbHostdevs
);
virObjectLock
(
hostdev_mg
r
->
activeUsbHostdevs
);
if
(
virUSBDeviceListAdd
(
drive
r
->
activeUsbHostdevs
,
usb
)
<
0
)
{
if
(
virUSBDeviceListAdd
(
hostdev_mg
r
->
activeUsbHostdevs
,
usb
)
<
0
)
{
virObjectUnlock
(
drive
r
->
activeUsbHostdevs
);
virObjectUnlock
(
hostdev_mg
r
->
activeUsbHostdevs
);
virUSBDeviceFree
(
usb
);
virUSBDeviceFree
(
usb
);
return
-
1
;
return
-
1
;
}
}
virObjectUnlock
(
drive
r
->
activeUsbHostdevs
);
virObjectUnlock
(
hostdev_mg
r
->
activeUsbHostdevs
);
}
}
return
0
;
return
0
;
...
@@ -83,13 +85,14 @@ virLXCPrepareHostdevUSBDevices(virLXCDriverPtr driver,
...
@@ -83,13 +85,14 @@ virLXCPrepareHostdevUSBDevices(virLXCDriverPtr driver,
size_t
i
,
j
;
size_t
i
,
j
;
unsigned
int
count
;
unsigned
int
count
;
virUSBDevicePtr
tmp
;
virUSBDevicePtr
tmp
;
virHostdevManagerPtr
hostdev_mgr
=
driver
->
hostdevMgr
;
count
=
virUSBDeviceListCount
(
list
);
count
=
virUSBDeviceListCount
(
list
);
virObjectLock
(
drive
r
->
activeUsbHostdevs
);
virObjectLock
(
hostdev_mg
r
->
activeUsbHostdevs
);
for
(
i
=
0
;
i
<
count
;
i
++
)
{
for
(
i
=
0
;
i
<
count
;
i
++
)
{
virUSBDevicePtr
usb
=
virUSBDeviceListGet
(
list
,
i
);
virUSBDevicePtr
usb
=
virUSBDeviceListGet
(
list
,
i
);
if
((
tmp
=
virUSBDeviceListFind
(
drive
r
->
activeUsbHostdevs
,
usb
)))
{
if
((
tmp
=
virUSBDeviceListFind
(
hostdev_mg
r
->
activeUsbHostdevs
,
usb
)))
{
const
char
*
other_drvname
;
const
char
*
other_drvname
;
const
char
*
other_domname
;
const
char
*
other_domname
;
...
@@ -115,18 +118,18 @@ virLXCPrepareHostdevUSBDevices(virLXCDriverPtr driver,
...
@@ -115,18 +118,18 @@ virLXCPrepareHostdevUSBDevices(virLXCDriverPtr driver,
* from the virUSBDeviceList that passed in on success,
* from the virUSBDeviceList that passed in on success,
* perform rollback on failure.
* perform rollback on failure.
*/
*/
if
(
virUSBDeviceListAdd
(
drive
r
->
activeUsbHostdevs
,
usb
)
<
0
)
if
(
virUSBDeviceListAdd
(
hostdev_mg
r
->
activeUsbHostdevs
,
usb
)
<
0
)
goto
error
;
goto
error
;
}
}
virObjectUnlock
(
drive
r
->
activeUsbHostdevs
);
virObjectUnlock
(
hostdev_mg
r
->
activeUsbHostdevs
);
return
0
;
return
0
;
error:
error:
for
(
j
=
0
;
j
<
i
;
j
++
)
{
for
(
j
=
0
;
j
<
i
;
j
++
)
{
tmp
=
virUSBDeviceListGet
(
list
,
i
);
tmp
=
virUSBDeviceListGet
(
list
,
i
);
virUSBDeviceListSteal
(
drive
r
->
activeUsbHostdevs
,
tmp
);
virUSBDeviceListSteal
(
hostdev_mg
r
->
activeUsbHostdevs
,
tmp
);
}
}
virObjectUnlock
(
drive
r
->
activeUsbHostdevs
);
virObjectUnlock
(
hostdev_mg
r
->
activeUsbHostdevs
);
return
-
1
;
return
-
1
;
}
}
...
@@ -350,8 +353,9 @@ virLXCDomainReAttachHostUsbDevices(virLXCDriverPtr driver,
...
@@ -350,8 +353,9 @@ virLXCDomainReAttachHostUsbDevices(virLXCDriverPtr driver,
int
nhostdevs
)
int
nhostdevs
)
{
{
size_t
i
;
size_t
i
;
virHostdevManagerPtr
hostdev_mgr
=
driver
->
hostdevMgr
;
virObjectLock
(
drive
r
->
activeUsbHostdevs
);
virObjectLock
(
hostdev_mg
r
->
activeUsbHostdevs
);
for
(
i
=
0
;
i
<
nhostdevs
;
i
++
)
{
for
(
i
=
0
;
i
<
nhostdevs
;
i
++
)
{
virDomainHostdevDefPtr
hostdev
=
hostdevs
[
i
];
virDomainHostdevDefPtr
hostdev
=
hostdevs
[
i
];
virUSBDevicePtr
usb
,
tmp
;
virUSBDevicePtr
usb
,
tmp
;
...
@@ -383,7 +387,7 @@ virLXCDomainReAttachHostUsbDevices(virLXCDriverPtr driver,
...
@@ -383,7 +387,7 @@ virLXCDomainReAttachHostUsbDevices(virLXCDriverPtr driver,
* Therefore we want to steal only those devices from
* Therefore we want to steal only those devices from
* the list which were taken by @name */
* the list which were taken by @name */
tmp
=
virUSBDeviceListFind
(
drive
r
->
activeUsbHostdevs
,
usb
);
tmp
=
virUSBDeviceListFind
(
hostdev_mg
r
->
activeUsbHostdevs
,
usb
);
virUSBDeviceFree
(
usb
);
virUSBDeviceFree
(
usb
);
if
(
!
tmp
)
{
if
(
!
tmp
)
{
...
@@ -402,10 +406,10 @@ virLXCDomainReAttachHostUsbDevices(virLXCDriverPtr driver,
...
@@ -402,10 +406,10 @@ virLXCDomainReAttachHostUsbDevices(virLXCDriverPtr driver,
hostdev
->
source
.
subsys
.
u
.
usb
.
device
,
hostdev
->
source
.
subsys
.
u
.
usb
.
device
,
name
);
name
);
virUSBDeviceListDel
(
drive
r
->
activeUsbHostdevs
,
tmp
);
virUSBDeviceListDel
(
hostdev_mg
r
->
activeUsbHostdevs
,
tmp
);
}
}
}
}
virObjectUnlock
(
drive
r
->
activeUsbHostdevs
);
virObjectUnlock
(
hostdev_mg
r
->
activeUsbHostdevs
);
}
}
void
virLXCDomainReAttachHostDevices
(
virLXCDriverPtr
driver
,
void
virLXCDomainReAttachHostDevices
(
virLXCDriverPtr
driver
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录