Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
26d94012
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看板
提交
26d94012
编写于
5月 02, 2011
作者:
J
Jiri Denemark
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Implement basic virDomainGetState in all drivers
Reason is currently always set to 0 (i.e., *_UNKNOWN).
上级
0eaf4d93
变更
20
隐藏空白更改
内联
并排
Showing
20 changed file
with
644 addition
and
36 deletion
+644
-36
src/esx/esx_driver.c
src/esx/esx_driver.c
+44
-1
src/libxl/libxl_driver.c
src/libxl/libxl_driver.c
+35
-1
src/lxc/lxc_driver.c
src/lxc/lxc_driver.c
+37
-1
src/openvz/openvz_driver.c
src/openvz/openvz_driver.c
+36
-1
src/phyp/phyp_driver.c
src/phyp/phyp_driver.c
+16
-1
src/qemu/qemu_driver.c
src/qemu/qemu_driver.c
+37
-1
src/test/test_driver.c
src/test/test_driver.c
+35
-1
src/uml/uml_driver.c
src/uml/uml_driver.c
+36
-1
src/vbox/vbox_tmpl.c
src/vbox/vbox_tmpl.c
+60
-1
src/vmware/vmware_driver.c
src/vmware/vmware_driver.c
+35
-1
src/xen/xen_driver.c
src/xen/xen_driver.c
+42
-1
src/xen/xen_hypervisor.c
src/xen/xen_hypervisor.c
+36
-0
src/xen/xen_hypervisor.h
src/xen/xen_hypervisor.h
+5
-0
src/xen/xend_internal.c
src/xen/xend_internal.c
+75
-24
src/xen/xend_internal.h
src/xen/xend_internal.h
+4
-0
src/xen/xm_internal.c
src/xen/xm_internal.c
+20
-0
src/xen/xm_internal.h
src/xen/xm_internal.h
+4
-0
src/xen/xs_internal.c
src/xen/xs_internal.c
+34
-0
src/xen/xs_internal.h
src/xen/xs_internal.h
+4
-0
src/xenapi/xenapi_driver.c
src/xenapi/xenapi_driver.c
+49
-1
未找到文件。
src/esx/esx_driver.c
浏览文件 @
26d94012
...
...
@@ -2451,6 +2451,49 @@ esxDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info)
static
int
esxDomainGetState
(
virDomainPtr
domain
,
int
*
state
,
int
*
reason
,
unsigned
int
flags
)
{
int
result
=
-
1
;
esxPrivate
*
priv
=
domain
->
conn
->
privateData
;
esxVI_String
*
propertyNameList
=
NULL
;
esxVI_ObjectContent
*
virtualMachine
=
NULL
;
esxVI_VirtualMachinePowerState
powerState
;
virCheckFlags
(
0
,
-
1
);
if
(
esxVI_EnsureSession
(
priv
->
primary
)
<
0
)
{
return
-
1
;
}
if
(
esxVI_String_AppendValueToList
(
&
propertyNameList
,
"runtime.powerState"
)
<
0
||
esxVI_LookupVirtualMachineByUuid
(
priv
->
primary
,
domain
->
uuid
,
propertyNameList
,
&
virtualMachine
,
esxVI_Occurrence_RequiredItem
)
<
0
||
esxVI_GetVirtualMachinePowerState
(
virtualMachine
,
&
powerState
)
<
0
)
{
goto
cleanup
;
}
*
state
=
esxVI_VirtualMachinePowerState_ConvertToLibvirt
(
powerState
);
if
(
reason
)
*
reason
=
0
;
result
=
0
;
cleanup:
esxVI_String_Free
(
&
propertyNameList
);
esxVI_ObjectContent_Free
(
&
virtualMachine
);
return
result
;
}
static
int
esxDomainSetVcpusFlags
(
virDomainPtr
domain
,
unsigned
int
nvcpus
,
unsigned
int
flags
)
...
...
@@ -4623,7 +4666,7 @@ static virDriver esxDriver = {
NULL
,
/* domainSetBlkioParameters */
NULL
,
/* domainGetBlkioParameters */
esxDomainGetInfo
,
/* domainGetInfo */
NULL
,
/* domainGetState */
esxDomainGetState
,
/* domainGetState */
NULL
,
/* domainSave */
NULL
,
/* domainRestore */
NULL
,
/* domainCoreDump */
...
...
src/libxl/libxl_driver.c
浏览文件 @
26d94012
...
...
@@ -1581,6 +1581,40 @@ libxlDomainGetInfo(virDomainPtr dom, virDomainInfoPtr info)
return
ret
;
}
static
int
libxlDomainGetState
(
virDomainPtr
dom
,
int
*
state
,
int
*
reason
,
unsigned
int
flags
)
{
libxlDriverPrivatePtr
driver
=
dom
->
conn
->
privateData
;
virDomainObjPtr
vm
;
int
ret
=
-
1
;
virCheckFlags
(
0
,
-
1
);
libxlDriverLock
(
driver
);
vm
=
virDomainFindByUUID
(
&
driver
->
domains
,
dom
->
uuid
);
libxlDriverUnlock
(
driver
);
if
(
!
vm
)
{
libxlError
(
VIR_ERR_NO_DOMAIN
,
"%s"
,
_
(
"no domain with matching uuid"
));
goto
cleanup
;
}
*
state
=
vm
->
state
;
if
(
reason
)
*
reason
=
0
;
ret
=
0
;
cleanup:
if
(
vm
)
virDomainObjUnlock
(
vm
);
return
ret
;
}
static
int
libxlDomainSetVcpusFlags
(
virDomainPtr
dom
,
unsigned
int
nvcpus
,
unsigned
int
flags
)
...
...
@@ -2679,7 +2713,7 @@ static virDriver libxlDriver = {
NULL
,
/* domainSetBlkioParameters */
NULL
,
/* domainGetBlkioParameters */
libxlDomainGetInfo
,
/* domainGetInfo */
NULL
,
/* domainGetState */
libxlDomainGetState
,
/* domainGetState */
NULL
,
/* domainSave */
NULL
,
/* domainRestore */
NULL
,
/* domainCoreDump */
...
...
src/lxc/lxc_driver.c
浏览文件 @
26d94012
...
...
@@ -567,6 +567,42 @@ cleanup:
return
ret
;
}
static
int
lxcDomainGetState
(
virDomainPtr
dom
,
int
*
state
,
int
*
reason
,
unsigned
int
flags
)
{
lxc_driver_t
*
driver
=
dom
->
conn
->
privateData
;
virDomainObjPtr
vm
;
int
ret
=
-
1
;
virCheckFlags
(
0
,
-
1
);
lxcDriverLock
(
driver
);
vm
=
virDomainFindByUUID
(
&
driver
->
domains
,
dom
->
uuid
);
lxcDriverUnlock
(
driver
);
if
(
!
vm
)
{
char
uuidstr
[
VIR_UUID_STRING_BUFLEN
];
virUUIDFormat
(
dom
->
uuid
,
uuidstr
);
lxcError
(
VIR_ERR_NO_DOMAIN
,
_
(
"No domain with matching uuid '%s'"
),
uuidstr
);
goto
cleanup
;
}
*
state
=
vm
->
state
;
if
(
reason
)
*
reason
=
0
;
ret
=
0
;
cleanup:
if
(
vm
)
virDomainObjUnlock
(
vm
);
return
ret
;
}
static
char
*
lxcGetOSType
(
virDomainPtr
dom
)
{
lxc_driver_t
*
driver
=
dom
->
conn
->
privateData
;
...
...
@@ -2708,7 +2744,7 @@ static virDriver lxcDriver = {
NULL
,
/* domainSetBlkioParameters */
NULL
,
/* domainGetBlkioParameters */
lxcDomainGetInfo
,
/* domainGetInfo */
NULL
,
/* domainGetState */
lxcDomainGetState
,
/* domainGetState */
NULL
,
/* domainSave */
NULL
,
/* domainRestore */
NULL
,
/* domainCoreDump */
...
...
src/openvz/openvz_driver.c
浏览文件 @
26d94012
...
...
@@ -377,6 +377,41 @@ cleanup:
}
static
int
openvzDomainGetState
(
virDomainPtr
dom
,
int
*
state
,
int
*
reason
,
unsigned
int
flags
)
{
struct
openvz_driver
*
driver
=
dom
->
conn
->
privateData
;
virDomainObjPtr
vm
;
int
ret
=
-
1
;
virCheckFlags
(
0
,
-
1
);
openvzDriverLock
(
driver
);
vm
=
virDomainFindByUUID
(
&
driver
->
domains
,
dom
->
uuid
);
openvzDriverUnlock
(
driver
);
if
(
!
vm
)
{
openvzError
(
VIR_ERR_NO_DOMAIN
,
"%s"
,
_
(
"no domain with matching uuid"
));
goto
cleanup
;
}
*
state
=
vm
->
state
;
if
(
reason
)
*
reason
=
0
;
ret
=
0
;
cleanup:
if
(
vm
)
virDomainObjUnlock
(
vm
);
return
ret
;
}
static
int
openvzDomainIsActive
(
virDomainPtr
dom
)
{
struct
openvz_driver
*
driver
=
dom
->
conn
->
privateData
;
...
...
@@ -1577,7 +1612,7 @@ static virDriver openvzDriver = {
NULL
,
/* domainSetBlkioParameters */
NULL
,
/* domainGetBlkioParameters */
openvzDomainGetInfo
,
/* domainGetInfo */
NULL
,
/* domainGetState */
openvzDomainGetState
,
/* domainGetState */
NULL
,
/* domainSave */
NULL
,
/* domainRestore */
NULL
,
/* domainCoreDump */
...
...
src/phyp/phyp_driver.c
浏览文件 @
26d94012
...
...
@@ -3475,6 +3475,21 @@ phypDomainGetInfo(virDomainPtr dom, virDomainInfoPtr info)
return
0
;
}
static
int
phypDomainGetState
(
virDomainPtr
dom
,
int
*
state
,
int
*
reason
,
unsigned
int
flags
)
{
virCheckFlags
(
0
,
-
1
);
*
state
=
phypGetLparState
(
dom
->
conn
,
dom
->
id
);
if
(
reason
)
*
reason
=
0
;
return
0
;
}
static
int
phypDomainDestroy
(
virDomainPtr
dom
)
{
...
...
@@ -3757,7 +3772,7 @@ static virDriver phypDriver = {
NULL
,
/* domainSetBlkioParameters */
NULL
,
/* domainGetBlkioParameters */
phypDomainGetInfo
,
/* domainGetInfo */
NULL
,
/* domainGetState */
phypDomainGetState
,
/* domainGetState */
NULL
,
/* domainSave */
NULL
,
/* domainRestore */
NULL
,
/* domainCoreDump */
...
...
src/qemu/qemu_driver.c
浏览文件 @
26d94012
...
...
@@ -1829,6 +1829,42 @@ cleanup:
return
ret
;
}
static
int
qemuDomainGetState
(
virDomainPtr
dom
,
int
*
state
,
int
*
reason
,
unsigned
int
flags
)
{
struct
qemud_driver
*
driver
=
dom
->
conn
->
privateData
;
virDomainObjPtr
vm
;
int
ret
=
-
1
;
virCheckFlags
(
0
,
-
1
);
qemuDriverLock
(
driver
);
vm
=
virDomainFindByUUID
(
&
driver
->
domains
,
dom
->
uuid
);
qemuDriverUnlock
(
driver
);
if
(
!
vm
)
{
char
uuidstr
[
VIR_UUID_STRING_BUFLEN
];
virUUIDFormat
(
dom
->
uuid
,
uuidstr
);
qemuReportError
(
VIR_ERR_NO_DOMAIN
,
_
(
"no domain with matching uuid '%s'"
),
uuidstr
);
goto
cleanup
;
}
*
state
=
vm
->
state
;
if
(
reason
)
*
reason
=
0
;
ret
=
0
;
cleanup:
if
(
vm
)
virDomainObjUnlock
(
vm
);
return
ret
;
}
#define QEMUD_SAVE_MAGIC "LibvirtQemudSave"
#define QEMUD_SAVE_VERSION 2
...
...
@@ -7246,7 +7282,7 @@ static virDriver qemuDriver = {
qemuDomainSetBlkioParameters
,
/* domainSetBlkioParameters */
qemuDomainGetBlkioParameters
,
/* domainGetBlkioParameters */
qemudDomainGetInfo
,
/* domainGetInfo */
NULL
,
/* domainGetState */
qemuDomainGetState
,
/* domainGetState */
qemudDomainSave
,
/* domainSave */
qemuDomainRestore
,
/* domainRestore */
qemudDomainCoreDump
,
/* domainCoreDump */
...
...
src/test/test_driver.c
浏览文件 @
26d94012
...
...
@@ -1674,6 +1674,40 @@ cleanup:
return
ret
;
}
static
int
testDomainGetState
(
virDomainPtr
domain
,
int
*
state
,
int
*
reason
,
unsigned
int
flags
)
{
testConnPtr
privconn
=
domain
->
conn
->
privateData
;
virDomainObjPtr
privdom
;
int
ret
=
-
1
;
virCheckFlags
(
0
,
-
1
);
testDriverLock
(
privconn
);
privdom
=
virDomainFindByName
(
&
privconn
->
domains
,
domain
->
name
);
testDriverUnlock
(
privconn
);
if
(
privdom
==
NULL
)
{
testError
(
VIR_ERR_INVALID_ARG
,
__FUNCTION__
);
goto
cleanup
;
}
*
state
=
privdom
->
state
;
if
(
reason
)
*
reason
=
0
;
ret
=
0
;
cleanup:
if
(
privdom
)
virDomainObjUnlock
(
privdom
);
return
ret
;
}
#define TEST_SAVE_MAGIC "TestGuestMagic"
static
int
testDomainSave
(
virDomainPtr
domain
,
...
...
@@ -5310,7 +5344,7 @@ static virDriver testDriver = {
NULL
,
/* domainSetBlkioParameters */
NULL
,
/* domainGetBlkioParameters */
testGetDomainInfo
,
/* domainGetInfo */
NULL
,
/* domainGetState */
testDomainGetState
,
/* domainGetState */
testDomainSave
,
/* domainSave */
testDomainRestore
,
/* domainRestore */
testDomainCoreDump
,
/* domainCoreDump */
...
...
src/uml/uml_driver.c
浏览文件 @
26d94012
...
...
@@ -1522,6 +1522,41 @@ cleanup:
}
static
int
umlDomainGetState
(
virDomainPtr
dom
,
int
*
state
,
int
*
reason
,
unsigned
int
flags
)
{
struct
uml_driver
*
driver
=
dom
->
conn
->
privateData
;
virDomainObjPtr
vm
;
int
ret
=
-
1
;
virCheckFlags
(
0
,
-
1
);
umlDriverLock
(
driver
);
vm
=
virDomainFindByUUID
(
&
driver
->
domains
,
dom
->
uuid
);
umlDriverUnlock
(
driver
);
if
(
!
vm
)
{
umlReportError
(
VIR_ERR_NO_DOMAIN
,
"%s"
,
_
(
"no domain with matching uuid"
));
goto
cleanup
;
}
*
state
=
vm
->
state
;
if
(
reason
)
*
reason
=
0
;
ret
=
0
;
cleanup:
if
(
vm
)
virDomainObjUnlock
(
vm
);
return
ret
;
}
static
char
*
umlDomainGetXMLDesc
(
virDomainPtr
dom
,
int
flags
ATTRIBUTE_UNUSED
)
{
struct
uml_driver
*
driver
=
dom
->
conn
->
privateData
;
...
...
@@ -2178,7 +2213,7 @@ static virDriver umlDriver = {
NULL
,
/* domainSetBlkioParameters */
NULL
,
/* domainGetBlkioParameters */
umlDomainGetInfo
,
/* domainGetInfo */
NULL
,
/* domainGetState */
umlDomainGetState
,
/* domainGetState */
NULL
,
/* domainSave */
NULL
,
/* domainRestore */
NULL
,
/* domainCoreDump */
...
...
src/vbox/vbox_tmpl.c
浏览文件 @
26d94012
...
...
@@ -1915,6 +1915,65 @@ cleanup:
return
ret
;
}
static
int
vboxDomainGetState
(
virDomainPtr
dom
,
int
*
state
,
int
*
reason
,
unsigned
int
flags
)
{
VBOX_OBJECT_CHECK
(
dom
->
conn
,
int
,
-
1
);
vboxIID
domiid
=
VBOX_IID_INITIALIZER
;
IMachine
*
machine
=
NULL
;
PRUint32
mstate
=
MachineState_Null
;
nsresult
rc
;
virCheckFlags
(
0
,
-
1
);
vboxIIDFromUUID
(
&
domiid
,
dom
->
uuid
);
rc
=
VBOX_OBJECT_GET_MACHINE
(
domiid
.
value
,
&
machine
);
if
(
NS_FAILED
(
rc
))
{
vboxError
(
VIR_ERR_NO_DOMAIN
,
"%s"
,
_
(
"no domain with matching UUID"
));
goto
cleanup
;
}
machine
->
vtbl
->
GetState
(
machine
,
&
mstate
);
switch
(
mstate
)
{
case
MachineState_Running
:
*
state
=
VIR_DOMAIN_RUNNING
;
break
;
case
MachineState_Stuck
:
*
state
=
VIR_DOMAIN_BLOCKED
;
break
;
case
MachineState_Paused
:
*
state
=
VIR_DOMAIN_PAUSED
;
break
;
case
MachineState_Stopping
:
*
state
=
VIR_DOMAIN_SHUTDOWN
;
break
;
case
MachineState_PoweredOff
:
*
state
=
VIR_DOMAIN_SHUTOFF
;
break
;
case
MachineState_Aborted
:
*
state
=
VIR_DOMAIN_CRASHED
;
break
;
case
MachineState_Null
:
default:
*
state
=
VIR_DOMAIN_NOSTATE
;
break
;
}
if
(
reason
)
*
reason
=
0
;
ret
=
0
;
cleanup:
vboxIIDUnalloc
(
&
domiid
);
return
ret
;
}
static
int
vboxDomainSave
(
virDomainPtr
dom
,
const
char
*
path
ATTRIBUTE_UNUSED
)
{
VBOX_OBJECT_CHECK
(
dom
->
conn
,
int
,
-
1
);
IConsole
*
console
=
NULL
;
...
...
@@ -8695,7 +8754,7 @@ virDriver NAME(Driver) = {
NULL
,
/* domainSetBlkioParameters */
NULL
,
/* domainGetBlkioParameters */
vboxDomainGetInfo
,
/* domainGetInfo */
NULL
,
/* domainGetState */
vboxDomainGetState
,
/* domainGetState */
vboxDomainSave
,
/* domainSave */
NULL
,
/* domainRestore */
NULL
,
/* domainCoreDump */
...
...
src/vmware/vmware_driver.c
浏览文件 @
26d94012
...
...
@@ -896,6 +896,40 @@ vmwareDomainGetInfo(virDomainPtr dom, virDomainInfoPtr info)
return
ret
;
}
static
int
vmwareDomainGetState
(
virDomainPtr
dom
,
int
*
state
,
int
*
reason
,
unsigned
int
flags
)
{
struct
vmware_driver
*
driver
=
dom
->
conn
->
privateData
;
virDomainObjPtr
vm
;
int
ret
=
-
1
;
virCheckFlags
(
0
,
-
1
);
vmwareDriverLock
(
driver
);
vm
=
virDomainFindByUUID
(
&
driver
->
domains
,
dom
->
uuid
);
vmwareDriverUnlock
(
driver
);
if
(
!
vm
)
{
vmwareError
(
VIR_ERR_NO_DOMAIN
,
"%s"
,
_
(
"no domain with matching uuid"
));
goto
cleanup
;
}
*
state
=
vm
->
state
;
if
(
reason
)
*
reason
=
0
;
ret
=
0
;
cleanup:
if
(
vm
)
virDomainObjUnlock
(
vm
);
return
ret
;
}
static
virDriver
vmwareDriver
=
{
VIR_DRV_VMWARE
,
"VMWARE"
,
...
...
@@ -931,7 +965,7 @@ static virDriver vmwareDriver = {
NULL
,
/* domainSetBlkioParameters */
NULL
,
/* domainGetBlkioParameters */
vmwareDomainGetInfo
,
/* domainGetInfo */
NULL
,
/* domainGetState */
vmwareDomainGetState
,
/* domainGetState */
NULL
,
/* domainSave */
NULL
,
/* domainRestore */
NULL
,
/* domainCoreDump */
...
...
src/xen/xen_driver.c
浏览文件 @
26d94012
...
...
@@ -1009,6 +1009,47 @@ xenUnifiedDomainGetInfo (virDomainPtr dom, virDomainInfoPtr info)
return
-
1
;
}
static
int
xenUnifiedDomainGetState
(
virDomainPtr
dom
,
int
*
state
,
int
*
reason
,
unsigned
int
flags
)
{
GET_PRIVATE
(
dom
->
conn
);
int
ret
;
virCheckFlags
(
0
,
-
1
);
/* trying drivers in the same order as GetInfo for consistent results:
* hypervisor, xend, xs, and xm */
if
(
priv
->
opened
[
XEN_UNIFIED_HYPERVISOR_OFFSET
])
{
ret
=
xenHypervisorGetDomainState
(
dom
,
state
,
reason
,
flags
);
if
(
ret
>=
0
)
return
ret
;
}
if
(
priv
->
opened
[
XEN_UNIFIED_XEND_OFFSET
])
{
ret
=
xenDaemonDomainGetState
(
dom
,
state
,
reason
,
flags
);
if
(
ret
>=
0
)
return
ret
;
}
if
(
priv
->
opened
[
XEN_UNIFIED_XS_OFFSET
])
{
ret
=
xenStoreDomainGetState
(
dom
,
state
,
reason
,
flags
);
if
(
ret
>=
0
)
return
ret
;
}
if
(
priv
->
opened
[
XEN_UNIFIED_XM_OFFSET
])
{
ret
=
xenXMDomainGetState
(
dom
,
state
,
reason
,
flags
);
if
(
ret
>=
0
)
return
ret
;
}
return
-
1
;
}
static
int
xenUnifiedDomainSave
(
virDomainPtr
dom
,
const
char
*
to
)
{
...
...
@@ -2133,7 +2174,7 @@ static virDriver xenUnifiedDriver = {
NULL
,
/* domainSetBlkioParameters */
NULL
,
/* domainGetBlkioParameters */
xenUnifiedDomainGetInfo
,
/* domainGetInfo */
NULL
,
/* domainGetState */
xenUnifiedDomainGetState
,
/* domainGetState */
xenUnifiedDomainSave
,
/* domainSave */
xenUnifiedDomainRestore
,
/* domainRestore */
xenUnifiedDomainCoreDump
,
/* domainCoreDump */
...
...
src/xen/xen_hypervisor.c
浏览文件 @
26d94012
...
...
@@ -3238,6 +3238,42 @@ xenHypervisorGetDomainInfo(virDomainPtr domain, virDomainInfoPtr info)
}
/**
* xenHypervisorGetDomainState:
* @domain: pointer to the domain block
* @state: returned state of the domain
* @reason: returned reason for the state
* @flags: additional flags, 0 for now
*
* Do a hypervisor call to get the related set of domain information.
*
* Returns 0 in case of success, -1 in case of error.
*/
int
xenHypervisorGetDomainState
(
virDomainPtr
domain
,
int
*
state
,
int
*
reason
,
unsigned
int
flags
ATTRIBUTE_UNUSED
)
{
xenUnifiedPrivatePtr
priv
=
domain
->
conn
->
privateData
;
virDomainInfo
info
;
if
(
domain
->
conn
==
NULL
)
return
-
1
;
if
(
priv
->
handle
<
0
||
domain
->
id
<
0
)
return
-
1
;
if
(
xenHypervisorGetDomInfo
(
domain
->
conn
,
domain
->
id
,
&
info
)
<
0
)
return
-
1
;
*
state
=
info
.
state
;
if
(
reason
)
*
reason
=
0
;
return
0
;
}
/**
* xenHypervisorNodeGetCellsFreeMemory:
* @conn: pointer to the hypervisor connection
...
...
src/xen/xen_hypervisor.h
浏览文件 @
26d94012
...
...
@@ -66,6 +66,11 @@ int xenHypervisorPauseDomain (virDomainPtr domain)
int
xenHypervisorGetDomainInfo
(
virDomainPtr
domain
,
virDomainInfoPtr
info
)
ATTRIBUTE_NONNULL
(
1
);
int
xenHypervisorGetDomainState
(
virDomainPtr
domain
,
int
*
state
,
int
*
reason
,
unsigned
int
flags
)
ATTRIBUTE_NONNULL
(
1
);
int
xenHypervisorGetDomInfo
(
virConnectPtr
conn
,
int
id
,
virDomainInfoPtr
info
);
...
...
src/xen/xend_internal.c
浏览文件 @
26d94012
...
...
@@ -1019,6 +1019,43 @@ xend_detect_config_version(virConnectPtr conn) {
}
/**
* sexpr_to_xend_domain_state:
* @root: an S-Expression describing a domain
*
* Internal routine getting the domain's state from the domain root provided.
*
* Returns domain's state.
*/
static
int
ATTRIBUTE_NONNULL
(
1
)
ATTRIBUTE_NONNULL
(
2
)
sexpr_to_xend_domain_state
(
virDomainPtr
domain
,
const
struct
sexpr
*
root
)
{
const
char
*
flags
;
int
state
=
VIR_DOMAIN_NOSTATE
;
if
((
flags
=
sexpr_node
(
root
,
"domain/state"
)))
{
if
(
strchr
(
flags
,
'c'
))
state
=
VIR_DOMAIN_CRASHED
;
else
if
(
strchr
(
flags
,
's'
))
state
=
VIR_DOMAIN_SHUTOFF
;
else
if
(
strchr
(
flags
,
'd'
))
state
=
VIR_DOMAIN_SHUTDOWN
;
else
if
(
strchr
(
flags
,
'p'
))
state
=
VIR_DOMAIN_PAUSED
;
else
if
(
strchr
(
flags
,
'b'
))
state
=
VIR_DOMAIN_BLOCKED
;
else
if
(
strchr
(
flags
,
'r'
))
state
=
VIR_DOMAIN_RUNNING
;
}
else
if
(
domain
->
id
<
0
)
{
/* Inactive domains don't have a state reported, so
mark them SHUTOFF, rather than NOSTATE */
state
=
VIR_DOMAIN_SHUTOFF
;
}
return
state
;
}
/**
* sexpr_to_xend_domain_info:
* @root: an S-Expression describing a domain
...
...
@@ -1033,38 +1070,16 @@ static int
sexpr_to_xend_domain_info
(
virDomainPtr
domain
,
const
struct
sexpr
*
root
,
virDomainInfoPtr
info
)
{
const
char
*
flags
;
int
vcpus
;
if
((
root
==
NULL
)
||
(
info
==
NULL
))
return
(
-
1
);
info
->
state
=
sexpr_to_xend_domain_state
(
domain
,
root
);
info
->
memory
=
sexpr_u64
(
root
,
"domain/memory"
)
<<
10
;
info
->
maxMem
=
sexpr_u64
(
root
,
"domain/maxmem"
)
<<
10
;
flags
=
sexpr_node
(
root
,
"domain/state"
);
if
(
flags
)
{
if
(
strchr
(
flags
,
'c'
))
info
->
state
=
VIR_DOMAIN_CRASHED
;
else
if
(
strchr
(
flags
,
's'
))
info
->
state
=
VIR_DOMAIN_SHUTOFF
;
else
if
(
strchr
(
flags
,
'd'
))
info
->
state
=
VIR_DOMAIN_SHUTDOWN
;
else
if
(
strchr
(
flags
,
'p'
))
info
->
state
=
VIR_DOMAIN_PAUSED
;
else
if
(
strchr
(
flags
,
'b'
))
info
->
state
=
VIR_DOMAIN_BLOCKED
;
else
if
(
strchr
(
flags
,
'r'
))
info
->
state
=
VIR_DOMAIN_RUNNING
;
}
else
{
/* Inactive domains don't have a state reported, so
mark them SHUTOFF, rather than NOSTATE */
if
(
domain
->
id
<
0
)
info
->
state
=
VIR_DOMAIN_SHUTOFF
;
else
info
->
state
=
VIR_DOMAIN_NOSTATE
;
}
info
->
cpuTime
=
sexpr_float
(
root
,
"domain/cpu_time"
)
*
1000000000
;
vcpus
=
sexpr_int
(
root
,
"domain/vcpus"
);
info
->
nrVirtCpu
=
count_one_bits_l
(
sexpr_u64
(
root
,
"domain/vcpu_avail"
));
if
(
!
info
->
nrVirtCpu
||
vcpus
<
info
->
nrVirtCpu
)
...
...
@@ -1893,6 +1908,42 @@ xenDaemonDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info)
}
/**
* xenDaemonDomainGetState:
* @domain: a domain object
* @state: returned domain's state
* @reason: returned reason for the state
* @flags: additional flags, 0 for now
*
* This method looks up domain state and reason.
*
* Returns 0 in case of success, -1 in case of error
*/
int
xenDaemonDomainGetState
(
virDomainPtr
domain
,
int
*
state
,
int
*
reason
,
unsigned
int
flags
ATTRIBUTE_UNUSED
)
{
xenUnifiedPrivatePtr
priv
=
domain
->
conn
->
privateData
;
struct
sexpr
*
root
;
if
(
domain
->
id
<
0
&&
priv
->
xendConfigVersion
<
3
)
return
-
1
;
root
=
sexpr_get
(
domain
->
conn
,
"/xend/domain/%s?detail=1"
,
domain
->
name
);
if
(
!
root
)
return
-
1
;
*
state
=
sexpr_to_xend_domain_state
(
domain
,
root
);
if
(
reason
)
*
reason
=
0
;
sexpr_free
(
root
);
return
0
;
}
/**
* xenDaemonLookupByName:
* @conn: A xend instance
...
...
src/xen/xend_internal.h
浏览文件 @
26d94012
...
...
@@ -110,6 +110,10 @@ int xenDaemonDomainRestore(virConnectPtr conn, const char *filename);
int
xenDaemonDomainSetMemory
(
virDomainPtr
domain
,
unsigned
long
memory
);
int
xenDaemonDomainSetMaxMemory
(
virDomainPtr
domain
,
unsigned
long
memory
);
int
xenDaemonDomainGetInfo
(
virDomainPtr
domain
,
virDomainInfoPtr
info
);
int
xenDaemonDomainGetState
(
virDomainPtr
domain
,
int
*
state
,
int
*
reason
,
unsigned
int
flags
);
char
*
xenDaemonDomainGetXMLDesc
(
virDomainPtr
domain
,
int
flags
,
const
char
*
cpus
);
unsigned
long
xenDaemonDomainGetMaxMemory
(
virDomainPtr
domain
);
char
**
xenDaemonListDomainsOld
(
virConnectPtr
xend
);
...
...
src/xen/xm_internal.c
浏览文件 @
26d94012
...
...
@@ -469,6 +469,26 @@ int xenXMClose(virConnectPtr conn) {
return
(
0
);
}
/*
* Since these are all offline domains, the state is always SHUTOFF.
*/
int
xenXMDomainGetState
(
virDomainPtr
domain
,
int
*
state
,
int
*
reason
,
unsigned
int
flags
ATTRIBUTE_UNUSED
)
{
if
(
domain
->
id
!=
-
1
)
return
-
1
;
*
state
=
VIR_DOMAIN_SHUTOFF
;
if
(
reason
)
*
reason
=
0
;
return
0
;
}
/*
* Since these are all offline domains, we only return info about
* VCPUs and memory.
...
...
src/xen/xm_internal.h
浏览文件 @
26d94012
...
...
@@ -40,6 +40,10 @@ virDrvOpenStatus xenXMOpen(virConnectPtr conn, virConnectAuthPtr auth, int flags
int
xenXMClose
(
virConnectPtr
conn
);
const
char
*
xenXMGetType
(
virConnectPtr
conn
);
int
xenXMDomainGetInfo
(
virDomainPtr
domain
,
virDomainInfoPtr
info
);
int
xenXMDomainGetState
(
virDomainPtr
domain
,
int
*
state
,
int
*
reason
,
unsigned
int
flags
);
char
*
xenXMDomainGetXMLDesc
(
virDomainPtr
domain
,
int
flags
);
int
xenXMDomainSetMemory
(
virDomainPtr
domain
,
unsigned
long
memory
);
int
xenXMDomainSetMaxMemory
(
virDomainPtr
domain
,
unsigned
long
memory
);
...
...
src/xen/xs_internal.c
浏览文件 @
26d94012
...
...
@@ -449,6 +449,40 @@ xenStoreGetDomainInfo(virDomainPtr domain, virDomainInfoPtr info)
return
(
0
);
}
/**
* xenStoreDomainGetState:
* @domain: pointer to the domain block
* @state: returned domain's state
* @reason: returned state reason
* @flags: additional flags, 0 for now
*
* Returns 0 in case of success, -1 in case of error.
*/
int
xenStoreDomainGetState
(
virDomainPtr
domain
,
int
*
state
,
int
*
reason
,
unsigned
int
flags
ATTRIBUTE_UNUSED
)
{
char
*
running
;
if
(
domain
->
id
==
-
1
)
return
-
1
;
running
=
virDomainDoStoreQuery
(
domain
->
conn
,
domain
->
id
,
"running"
);
if
(
running
&&
*
running
==
'1'
)
*
state
=
VIR_DOMAIN_RUNNING
;
else
*
state
=
VIR_DOMAIN_NOSTATE
;
if
(
reason
)
*
reason
=
0
;
VIR_FREE
(
running
);
return
0
;
}
/**
* xenStoreDomainSetMemory:
* @domain: pointer to the domain block
...
...
src/xen/xs_internal.h
浏览文件 @
26d94012
...
...
@@ -23,6 +23,10 @@ virDrvOpenStatus xenStoreOpen (virConnectPtr conn,
int
xenStoreClose
(
virConnectPtr
conn
);
int
xenStoreGetDomainInfo
(
virDomainPtr
domain
,
virDomainInfoPtr
info
);
int
xenStoreDomainGetState
(
virDomainPtr
domain
,
int
*
state
,
int
*
reason
,
unsigned
int
flags
);
int
xenStoreNumOfDomains
(
virConnectPtr
conn
);
int
xenStoreListDomains
(
virConnectPtr
conn
,
int
*
ids
,
...
...
src/xenapi/xenapi_driver.c
浏览文件 @
26d94012
...
...
@@ -994,6 +994,54 @@ xenapiDomainGetInfo (virDomainPtr dom, virDomainInfoPtr info)
return
-
1
;
}
/*
* xenapiDomainGetState:
*
* Retrieves domain status and its reason.
*
* Returns 0 on success or -1 in case of error
*/
static
int
xenapiDomainGetState
(
virDomainPtr
dom
,
int
*
state
,
int
*
reason
,
unsigned
int
flags
)
{
struct
_xenapiPrivate
*
priv
=
dom
->
conn
->
privateData
;
enum
xen_vm_power_state
powerState
=
XEN_VM_POWER_STATE_UNDEFINED
;
xen_vm_set
*
vms
=
NULL
;
xen_vm
vm
;
int
ret
=
-
1
;
virCheckFlags
(
0
,
-
1
);
if
(
!
xen_vm_get_by_name_label
(
priv
->
session
,
&
vms
,
dom
->
name
)
||
vms
->
size
==
0
)
{
xenapiSessionErrorHandler
(
dom
->
conn
,
VIR_ERR_NO_DOMAIN
,
NULL
);
goto
cleanup
;
}
if
(
vms
->
size
!=
1
)
{
xenapiSessionErrorHandler
(
dom
->
conn
,
VIR_ERR_INTERNAL_ERROR
,
_
(
"Domain name is not unique"
));
goto
cleanup
;
}
vm
=
vms
->
contents
[
0
];
xen_vm_get_power_state
(
priv
->
session
,
&
powerState
,
vm
);
*
state
=
mapPowerState
(
powerState
);
if
(
reason
)
*
reason
=
0
;
ret
=
0
;
cleanup:
if
(
vms
)
xen_vm_set_free
(
vms
);
return
ret
;
}
/*
* xenapiDomainSetVcpusFlags
...
...
@@ -1813,7 +1861,7 @@ static virDriver xenapiDriver = {
NULL
,
/* domainSetBlkioParameters */
NULL
,
/* domainGetBlkioParameters */
xenapiDomainGetInfo
,
/* domainGetInfo */
NULL
,
/* domainGetState */
xenapiDomainGetState
,
/* domainGetState */
NULL
,
/* domainSave */
NULL
,
/* domainRestore */
NULL
,
/* domainCoreDump */
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录