Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
6318a801
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看板
提交
6318a801
编写于
3月 23, 2014
作者:
D
David Shane Holden
提交者:
Roman Bogorodskiy
4月 05, 2014
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
bhyve: domain autostart support
Signed-off-by:
N
Roman Bogorodskiy
<
bogorodskiy@gmail.com
>
上级
9673418c
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
139 addition
and
1 deletion
+139
-1
src/bhyve/bhyve_driver.c
src/bhyve/bhyve_driver.c
+134
-1
src/bhyve/bhyve_utils.h
src/bhyve/bhyve_utils.h
+5
-0
未找到文件。
src/bhyve/bhyve_driver.c
浏览文件 @
6318a801
...
@@ -72,6 +72,44 @@ bhyveDriverUnlock(bhyveConnPtr driver)
...
@@ -72,6 +72,44 @@ bhyveDriverUnlock(bhyveConnPtr driver)
virMutexUnlock
(
&
driver
->
lock
);
virMutexUnlock
(
&
driver
->
lock
);
}
}
static
int
bhyveAutostartDomain
(
virDomainObjPtr
vm
,
void
*
opaque
)
{
const
struct
bhyveAutostartData
*
data
=
opaque
;
int
ret
=
0
;
virObjectLock
(
vm
);
if
(
vm
->
autostart
&&
!
virDomainObjIsActive
(
vm
))
{
virResetLastError
();
ret
=
virBhyveProcessStart
(
data
->
conn
,
data
->
driver
,
vm
,
VIR_DOMAIN_RUNNING_BOOTED
,
0
);
if
(
ret
<
0
)
{
virErrorPtr
err
=
virGetLastError
();
VIR_ERROR
(
_
(
"Failed to autostart VM '%s': %s"
),
vm
->
def
->
name
,
err
?
err
->
message
:
_
(
"unknown error"
));
}
}
virObjectUnlock
(
vm
);
return
ret
;
}
static
void
bhyveAutostartDomains
(
bhyveConnPtr
driver
)
{
/* XXX: Figure out a better way todo this. The domain
* startup code needs a connection handle in order
* to lookup the bridge associated with a virtual
* network
*/
virConnectPtr
conn
=
virConnectOpen
(
"bhyve:///system"
);
/* Ignoring NULL conn which is mostly harmless here */
struct
bhyveAutostartData
data
=
{
driver
,
conn
};
virDomainObjListForEach
(
driver
->
domains
,
bhyveAutostartDomain
,
&
data
);
virObjectUnref
(
conn
);
}
static
virCapsPtr
static
virCapsPtr
bhyveBuildCapabilities
(
void
)
bhyveBuildCapabilities
(
void
)
{
{
...
@@ -261,6 +299,89 @@ bhyveDomainGetState(virDomainPtr domain,
...
@@ -261,6 +299,89 @@ bhyveDomainGetState(virDomainPtr domain,
return
ret
;
return
ret
;
}
}
static
int
bhyveDomainGetAutostart
(
virDomainPtr
domain
,
int
*
autostart
)
{
virDomainObjPtr
vm
;
int
ret
=
-
1
;
if
(
!
(
vm
=
bhyveDomObjFromDomain
(
domain
)))
goto
cleanup
;
if
(
virDomainGetAutostartEnsureACL
(
domain
->
conn
,
vm
->
def
)
<
0
)
goto
cleanup
;
*
autostart
=
vm
->
autostart
;
ret
=
0
;
cleanup:
virObjectUnlock
(
vm
);
return
ret
;
}
static
int
bhyveDomainSetAutostart
(
virDomainPtr
domain
,
int
autostart
)
{
virDomainObjPtr
vm
;
char
*
configFile
=
NULL
;
char
*
autostartLink
=
NULL
;
int
ret
=
-
1
;
if
(
!
(
vm
=
bhyveDomObjFromDomain
(
domain
)))
goto
cleanup
;
if
(
virDomainSetAutostartEnsureACL
(
domain
->
conn
,
vm
->
def
)
<
0
)
goto
cleanup
;
if
(
!
vm
->
persistent
)
{
virReportError
(
VIR_ERR_OPERATION_INVALID
,
"%s"
,
_
(
"cannot set autostart for transient domain"
));
goto
cleanup
;
}
autostart
=
(
autostart
!=
0
);
if
(
vm
->
autostart
!=
autostart
)
{
if
((
configFile
=
virDomainConfigFile
(
BHYVE_CONFIG_DIR
,
vm
->
def
->
name
))
==
NULL
)
goto
cleanup
;
if
((
autostartLink
=
virDomainConfigFile
(
BHYVE_AUTOSTART_DIR
,
vm
->
def
->
name
))
==
NULL
)
goto
cleanup
;
if
(
autostart
)
{
if
(
virFileMakePath
(
BHYVE_AUTOSTART_DIR
)
<
0
)
{
virReportSystemError
(
errno
,
_
(
"cannot create autostart directory %s"
),
BHYVE_AUTOSTART_DIR
);
goto
cleanup
;
}
if
(
symlink
(
configFile
,
autostartLink
)
<
0
)
{
virReportSystemError
(
errno
,
_
(
"Failed to create symlink '%s' to '%s'"
),
autostartLink
,
configFile
);
goto
cleanup
;
}
}
else
{
if
(
unlink
(
autostartLink
)
<
0
&&
errno
!=
ENOENT
&&
errno
!=
ENOTDIR
)
{
virReportSystemError
(
errno
,
_
(
"Failed to delete symlink '%s'"
),
autostartLink
);
goto
cleanup
;
}
}
vm
->
autostart
=
autostart
;
}
ret
=
0
;
cleanup:
VIR_FREE
(
configFile
);
VIR_FREE
(
autostartLink
);
virObjectUnlock
(
vm
);
return
ret
;
}
static
int
static
int
bhyveDomainIsActive
(
virDomainPtr
domain
)
bhyveDomainIsActive
(
virDomainPtr
domain
)
{
{
...
@@ -729,7 +850,7 @@ bhyveStateInitialize(bool priveleged ATTRIBUTE_UNUSED,
...
@@ -729,7 +850,7 @@ bhyveStateInitialize(bool priveleged ATTRIBUTE_UNUSED,
if
(
virDomainObjListLoadAllConfigs
(
bhyve_driver
->
domains
,
if
(
virDomainObjListLoadAllConfigs
(
bhyve_driver
->
domains
,
BHYVE_CONFIG_DIR
,
BHYVE_CONFIG_DIR
,
NULL
,
0
,
BHYVE_AUTOSTART_DIR
,
0
,
bhyve_driver
->
caps
,
bhyve_driver
->
caps
,
bhyve_driver
->
xmlopt
,
bhyve_driver
->
xmlopt
,
1
<<
VIR_DOMAIN_VIRT_BHYVE
,
1
<<
VIR_DOMAIN_VIRT_BHYVE
,
...
@@ -743,6 +864,15 @@ bhyveStateInitialize(bool priveleged ATTRIBUTE_UNUSED,
...
@@ -743,6 +864,15 @@ bhyveStateInitialize(bool priveleged ATTRIBUTE_UNUSED,
return
-
1
;
return
-
1
;
}
}
static
void
bhyveStateAutoStart
(
void
)
{
if
(
!
bhyve_driver
)
return
;
bhyveAutostartDomains
(
bhyve_driver
);
}
static
int
static
int
bhyveConnectGetMaxVcpus
(
virConnectPtr
conn
ATTRIBUTE_UNUSED
,
bhyveConnectGetMaxVcpus
(
virConnectPtr
conn
ATTRIBUTE_UNUSED
,
const
char
*
type
)
const
char
*
type
)
...
@@ -832,6 +962,8 @@ static virDriver bhyveDriver = {
...
@@ -832,6 +962,8 @@ static virDriver bhyveDriver = {
.
domainGetXMLDesc
=
bhyveDomainGetXMLDesc
,
/* 1.2.2 */
.
domainGetXMLDesc
=
bhyveDomainGetXMLDesc
,
/* 1.2.2 */
.
domainIsActive
=
bhyveDomainIsActive
,
/* 1.2.2 */
.
domainIsActive
=
bhyveDomainIsActive
,
/* 1.2.2 */
.
domainIsPersistent
=
bhyveDomainIsPersistent
,
/* 1.2.2 */
.
domainIsPersistent
=
bhyveDomainIsPersistent
,
/* 1.2.2 */
.
domainGetAutostart
=
bhyveDomainGetAutostart
,
/* 1.2.4 */
.
domainSetAutostart
=
bhyveDomainSetAutostart
,
/* 1.2.4 */
.
nodeGetCPUStats
=
bhyveNodeGetCPUStats
,
/* 1.2.2 */
.
nodeGetCPUStats
=
bhyveNodeGetCPUStats
,
/* 1.2.2 */
.
nodeGetMemoryStats
=
bhyveNodeGetMemoryStats
,
/* 1.2.2 */
.
nodeGetMemoryStats
=
bhyveNodeGetMemoryStats
,
/* 1.2.2 */
.
nodeGetInfo
=
bhyveNodeGetInfo
,
/* 1.2.3 */
.
nodeGetInfo
=
bhyveNodeGetInfo
,
/* 1.2.3 */
...
@@ -846,6 +978,7 @@ static virDriver bhyveDriver = {
...
@@ -846,6 +978,7 @@ static virDriver bhyveDriver = {
static
virStateDriver
bhyveStateDriver
=
{
static
virStateDriver
bhyveStateDriver
=
{
.
name
=
"bhyve"
,
.
name
=
"bhyve"
,
.
stateInitialize
=
bhyveStateInitialize
,
.
stateInitialize
=
bhyveStateInitialize
,
.
stateAutoStart
=
bhyveStateAutoStart
,
.
stateCleanup
=
bhyveStateCleanup
,
.
stateCleanup
=
bhyveStateCleanup
,
};
};
...
...
src/bhyve/bhyve_utils.h
浏览文件 @
6318a801
...
@@ -46,6 +46,11 @@ struct _bhyveConn {
...
@@ -46,6 +46,11 @@ struct _bhyveConn {
typedef
struct
_bhyveConn
bhyveConn
;
typedef
struct
_bhyveConn
bhyveConn
;
typedef
struct
_bhyveConn
*
bhyveConnPtr
;
typedef
struct
_bhyveConn
*
bhyveConnPtr
;
struct
bhyveAutostartData
{
bhyveConnPtr
driver
;
virConnectPtr
conn
;
};
void
bhyveDriverLock
(
bhyveConnPtr
driver
);
void
bhyveDriverLock
(
bhyveConnPtr
driver
);
void
bhyveDriverUnlock
(
bhyveConnPtr
driver
);
void
bhyveDriverUnlock
(
bhyveConnPtr
driver
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录