Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
b4129753
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,发现更多精彩内容 >>
提交
b4129753
编写于
8月 11, 2014
作者:
T
Taowei
提交者:
Michal Privoznik
8月 15, 2014
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
vbox: Rewrite vboxDomainGetInfo
上级
2cd7a218
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
108 addition
and
82 deletion
+108
-82
src/vbox/vbox_common.c
src/vbox/vbox_common.c
+79
-0
src/vbox/vbox_tmpl.c
src/vbox/vbox_tmpl.c
+24
-82
src/vbox/vbox_uniformed_api.h
src/vbox/vbox_uniformed_api.h
+5
-0
未找到文件。
src/vbox/vbox_common.c
浏览文件 @
b4129753
...
@@ -2669,3 +2669,82 @@ int vboxDomainSetMemory(virDomainPtr dom, unsigned long memory)
...
@@ -2669,3 +2669,82 @@ int vboxDomainSetMemory(virDomainPtr dom, unsigned long memory)
vboxIIDUnalloc
(
&
iid
);
vboxIIDUnalloc
(
&
iid
);
return
ret
;
return
ret
;
}
}
int
vboxDomainGetInfo
(
virDomainPtr
dom
,
virDomainInfoPtr
info
)
{
VBOX_OBJECT_CHECK
(
dom
->
conn
,
int
,
-
1
);
vboxArray
machines
=
VBOX_ARRAY_INITIALIZER
;
char
*
machineName
=
NULL
;
PRUnichar
*
machineNameUtf16
=
NULL
;
nsresult
rc
;
size_t
i
=
0
;
rc
=
gVBoxAPI
.
UArray
.
vboxArrayGet
(
&
machines
,
data
->
vboxObj
,
ARRAY_GET_MACHINES
);
if
(
NS_FAILED
(
rc
))
{
virReportError
(
VIR_ERR_INTERNAL_ERROR
,
_
(
"Could not get list of machines, rc=%08x"
),
(
unsigned
)
rc
);
goto
cleanup
;
}
info
->
nrVirtCpu
=
0
;
for
(
i
=
0
;
i
<
machines
.
count
;
++
i
)
{
IMachine
*
machine
=
machines
.
items
[
i
];
PRBool
isAccessible
=
PR_FALSE
;
if
(
!
machine
)
continue
;
gVBoxAPI
.
UIMachine
.
GetAccessible
(
machine
,
&
isAccessible
);
if
(
!
isAccessible
)
continue
;
gVBoxAPI
.
UIMachine
.
GetName
(
machine
,
&
machineNameUtf16
);
VBOX_UTF16_TO_UTF8
(
machineNameUtf16
,
&
machineName
);
if
(
STREQ
(
dom
->
name
,
machineName
))
{
/* Get the Machine State (also match it with
* virDomainState). Get the Machine memory and
* for time being set max_balloon and cur_balloon to same
* Also since there is no direct way of checking
* the cputime required (one condition being the
* VM is remote), return zero for cputime. Get the
* number of CPU.
*/
PRUint32
CPUCount
=
0
;
PRUint32
memorySize
=
0
;
PRUint32
state
;
PRUint32
maxMemorySize
=
4
*
1024
;
ISystemProperties
*
systemProperties
=
NULL
;
gVBoxAPI
.
UIVirtualBox
.
GetSystemProperties
(
data
->
vboxObj
,
&
systemProperties
);
if
(
systemProperties
)
{
gVBoxAPI
.
UISystemProperties
.
GetMaxGuestRAM
(
systemProperties
,
&
maxMemorySize
);
VBOX_RELEASE
(
systemProperties
);
systemProperties
=
NULL
;
}
gVBoxAPI
.
UIMachine
.
GetCPUCount
(
machine
,
&
CPUCount
);
gVBoxAPI
.
UIMachine
.
GetMemorySize
(
machine
,
&
memorySize
);
gVBoxAPI
.
UIMachine
.
GetState
(
machine
,
&
state
);
info
->
cpuTime
=
0
;
info
->
nrVirtCpu
=
CPUCount
;
info
->
memory
=
memorySize
*
1024
;
info
->
maxMem
=
maxMemorySize
*
1024
;
info
->
state
=
gVBoxAPI
.
vboxConvertState
(
state
);
ret
=
0
;
}
VBOX_UTF8_FREE
(
machineName
);
VBOX_COM_UNALLOC_MEM
(
machineNameUtf16
);
if
(
info
->
nrVirtCpu
)
break
;
}
gVBoxAPI
.
UArray
.
vboxArrayRelease
(
&
machines
);
cleanup:
return
ret
;
}
src/vbox/vbox_tmpl.c
浏览文件 @
b4129753
...
@@ -933,7 +933,7 @@ vboxSocketParseAddrUtf16(vboxGlobalData *data, const PRUnichar *utf16,
...
@@ -933,7 +933,7 @@ vboxSocketParseAddrUtf16(vboxGlobalData *data, const PRUnichar *utf16,
return
result
;
return
result
;
}
}
static
virDomainState
vboxConvertState
(
enum
MachineState
state
)
static
virDomainState
_vboxConvertState
(
PRUint32
state
)
{
{
switch
(
state
)
{
switch
(
state
)
{
case
MachineState_Running
:
case
MachineState_Running
:
...
@@ -955,86 +955,6 @@ static virDomainState vboxConvertState(enum MachineState state)
...
@@ -955,86 +955,6 @@ static virDomainState vboxConvertState(enum MachineState state)
}
}
}
}
static
int
vboxDomainGetInfo
(
virDomainPtr
dom
,
virDomainInfoPtr
info
)
{
VBOX_OBJECT_CHECK
(
dom
->
conn
,
int
,
-
1
);
vboxArray
machines
=
VBOX_ARRAY_INITIALIZER
;
char
*
machineName
=
NULL
;
PRUnichar
*
machineNameUtf16
=
NULL
;
nsresult
rc
;
size_t
i
=
0
;
rc
=
vboxArrayGet
(
&
machines
,
data
->
vboxObj
,
data
->
vboxObj
->
vtbl
->
GetMachines
);
if
(
NS_FAILED
(
rc
))
{
virReportError
(
VIR_ERR_INTERNAL_ERROR
,
_
(
"Could not get list of machines, rc=%08x"
),
(
unsigned
)
rc
);
goto
cleanup
;
}
info
->
nrVirtCpu
=
0
;
for
(
i
=
0
;
i
<
machines
.
count
;
++
i
)
{
IMachine
*
machine
=
machines
.
items
[
i
];
PRBool
isAccessible
=
PR_FALSE
;
if
(
!
machine
)
continue
;
machine
->
vtbl
->
GetAccessible
(
machine
,
&
isAccessible
);
if
(
isAccessible
)
{
machine
->
vtbl
->
GetName
(
machine
,
&
machineNameUtf16
);
VBOX_UTF16_TO_UTF8
(
machineNameUtf16
,
&
machineName
);
if
(
STREQ
(
dom
->
name
,
machineName
))
{
/* Get the Machine State (also match it with
* virDomainState). Get the Machine memory and
* for time being set max_balloon and cur_balloon to same
* Also since there is no direct way of checking
* the cputime required (one condition being the
* VM is remote), return zero for cputime. Get the
* number of CPU.
*/
PRUint32
CPUCount
=
0
;
PRUint32
memorySize
=
0
;
PRUint32
state
=
MachineState_Null
;
PRUint32
maxMemorySize
=
4
*
1024
;
ISystemProperties
*
systemProperties
=
NULL
;
data
->
vboxObj
->
vtbl
->
GetSystemProperties
(
data
->
vboxObj
,
&
systemProperties
);
if
(
systemProperties
)
{
systemProperties
->
vtbl
->
GetMaxGuestRAM
(
systemProperties
,
&
maxMemorySize
);
VBOX_RELEASE
(
systemProperties
);
systemProperties
=
NULL
;
}
machine
->
vtbl
->
GetCPUCount
(
machine
,
&
CPUCount
);
machine
->
vtbl
->
GetMemorySize
(
machine
,
&
memorySize
);
machine
->
vtbl
->
GetState
(
machine
,
&
state
);
info
->
cpuTime
=
0
;
info
->
nrVirtCpu
=
CPUCount
;
info
->
memory
=
memorySize
*
1024
;
info
->
maxMem
=
maxMemorySize
*
1024
;
info
->
state
=
vboxConvertState
(
state
);
ret
=
0
;
}
VBOX_UTF8_FREE
(
machineName
);
VBOX_COM_UNALLOC_MEM
(
machineNameUtf16
);
if
(
info
->
nrVirtCpu
)
break
;
}
}
vboxArrayRelease
(
&
machines
);
cleanup:
return
ret
;
}
static
int
static
int
vboxDomainGetState
(
virDomainPtr
dom
,
vboxDomainGetState
(
virDomainPtr
dom
,
int
*
state
,
int
*
state
,
...
@@ -1059,7 +979,7 @@ vboxDomainGetState(virDomainPtr dom,
...
@@ -1059,7 +979,7 @@ vboxDomainGetState(virDomainPtr dom,
machine
->
vtbl
->
GetState
(
machine
,
&
mstate
);
machine
->
vtbl
->
GetState
(
machine
,
&
mstate
);
*
state
=
vboxConvertState
(
mstate
);
*
state
=
_
vboxConvertState
(
mstate
);
if
(
reason
)
if
(
reason
)
*
reason
=
0
;
*
reason
=
0
;
...
@@ -9556,12 +9476,24 @@ _machineGetUSBCommon(IMachine *machine, IUSBCommon **USBCommon)
...
@@ -9556,12 +9476,24 @@ _machineGetUSBCommon(IMachine *machine, IUSBCommon **USBCommon)
#endif
#endif
}
}
static
nsresult
_machineGetCPUCount
(
IMachine
*
machine
,
PRUint32
*
CPUCount
)
{
return
machine
->
vtbl
->
GetCPUCount
(
machine
,
CPUCount
);
}
static
nsresult
static
nsresult
_machineSetCPUCount
(
IMachine
*
machine
,
PRUint32
CPUCount
)
_machineSetCPUCount
(
IMachine
*
machine
,
PRUint32
CPUCount
)
{
{
return
machine
->
vtbl
->
SetCPUCount
(
machine
,
CPUCount
);
return
machine
->
vtbl
->
SetCPUCount
(
machine
,
CPUCount
);
}
}
static
nsresult
_machineGetMemorySize
(
IMachine
*
machine
,
PRUint32
*
memorySize
)
{
return
machine
->
vtbl
->
GetMemorySize
(
machine
,
memorySize
);
}
static
nsresult
static
nsresult
_machineSetMemorySize
(
IMachine
*
machine
,
PRUint32
memorySize
)
_machineSetMemorySize
(
IMachine
*
machine
,
PRUint32
memorySize
)
{
{
...
@@ -9829,6 +9761,12 @@ _systemPropertiesGetMaxDevicesPerPortForStorageBus(ISystemProperties *systemProp
...
@@ -9829,6 +9761,12 @@ _systemPropertiesGetMaxDevicesPerPortForStorageBus(ISystemProperties *systemProp
}
}
#endif
#endif
static
nsresult
_systemPropertiesGetMaxGuestRAM
(
ISystemProperties
*
systemProperties
,
PRUint32
*
maxGuestRAM
)
{
return
systemProperties
->
vtbl
->
GetMaxGuestRAM
(
systemProperties
,
maxGuestRAM
);
}
static
nsresult
static
nsresult
_biosSettingsSetACPIEnabled
(
IBIOSSettings
*
bios
,
PRBool
ACPIEnabled
)
_biosSettingsSetACPIEnabled
(
IBIOSSettings
*
bios
,
PRBool
ACPIEnabled
)
{
{
...
@@ -10235,7 +10173,9 @@ static vboxUniformedIMachine _UIMachine = {
...
@@ -10235,7 +10173,9 @@ static vboxUniformedIMachine _UIMachine = {
.
GetParallelPort
=
_machineGetParallelPort
,
.
GetParallelPort
=
_machineGetParallelPort
,
.
GetVRDxServer
=
_machineGetVRDxServer
,
.
GetVRDxServer
=
_machineGetVRDxServer
,
.
GetUSBCommon
=
_machineGetUSBCommon
,
.
GetUSBCommon
=
_machineGetUSBCommon
,
.
GetCPUCount
=
_machineGetCPUCount
,
.
SetCPUCount
=
_machineSetCPUCount
,
.
SetCPUCount
=
_machineSetCPUCount
,
.
GetMemorySize
=
_machineGetMemorySize
,
.
SetMemorySize
=
_machineSetMemorySize
,
.
SetMemorySize
=
_machineSetMemorySize
,
.
SetCPUProperty
=
_machineSetCPUProperty
,
.
SetCPUProperty
=
_machineSetCPUProperty
,
.
SetBootOrder
=
_machineSetBootOrder
,
.
SetBootOrder
=
_machineSetBootOrder
,
...
@@ -10279,6 +10219,7 @@ static vboxUniformedISystemProperties _UISystemProperties = {
...
@@ -10279,6 +10219,7 @@ static vboxUniformedISystemProperties _UISystemProperties = {
.
GetParallelPortCount
=
_systemPropertiesGetParallelPortCount
,
.
GetParallelPortCount
=
_systemPropertiesGetParallelPortCount
,
.
GetMaxPortCountForStorageBus
=
_systemPropertiesGetMaxPortCountForStorageBus
,
.
GetMaxPortCountForStorageBus
=
_systemPropertiesGetMaxPortCountForStorageBus
,
.
GetMaxDevicesPerPortForStorageBus
=
_systemPropertiesGetMaxDevicesPerPortForStorageBus
,
.
GetMaxDevicesPerPortForStorageBus
=
_systemPropertiesGetMaxDevicesPerPortForStorageBus
,
.
GetMaxGuestRAM
=
_systemPropertiesGetMaxGuestRAM
,
};
};
static
vboxUniformedIBIOSSettings
_UIBIOSSettings
=
{
static
vboxUniformedIBIOSSettings
_UIBIOSSettings
=
{
...
@@ -10363,6 +10304,7 @@ void NAME(InstallUniformedAPI)(vboxUniformedAPI *pVBoxAPI)
...
@@ -10363,6 +10304,7 @@ void NAME(InstallUniformedAPI)(vboxUniformedAPI *pVBoxAPI)
pVBoxAPI
->
unregisterMachine
=
_unregisterMachine
;
pVBoxAPI
->
unregisterMachine
=
_unregisterMachine
;
pVBoxAPI
->
deleteConfig
=
_deleteConfig
;
pVBoxAPI
->
deleteConfig
=
_deleteConfig
;
pVBoxAPI
->
vboxAttachDrivesOld
=
_vboxAttachDrivesOld
;
pVBoxAPI
->
vboxAttachDrivesOld
=
_vboxAttachDrivesOld
;
pVBoxAPI
->
vboxConvertState
=
_vboxConvertState
;
pVBoxAPI
->
UPFN
=
_UPFN
;
pVBoxAPI
->
UPFN
=
_UPFN
;
pVBoxAPI
->
UIID
=
_UIID
;
pVBoxAPI
->
UIID
=
_UIID
;
pVBoxAPI
->
UArray
=
_UArray
;
pVBoxAPI
->
UArray
=
_UArray
;
...
...
src/vbox/vbox_uniformed_api.h
浏览文件 @
b4129753
...
@@ -212,7 +212,9 @@ typedef struct {
...
@@ -212,7 +212,9 @@ typedef struct {
nsresult
(
*
GetParallelPort
)(
IMachine
*
machine
,
PRUint32
slot
,
IParallelPort
**
port
);
nsresult
(
*
GetParallelPort
)(
IMachine
*
machine
,
PRUint32
slot
,
IParallelPort
**
port
);
nsresult
(
*
GetVRDxServer
)(
IMachine
*
machine
,
IVRDxServer
**
VRDxServer
);
nsresult
(
*
GetVRDxServer
)(
IMachine
*
machine
,
IVRDxServer
**
VRDxServer
);
nsresult
(
*
GetUSBCommon
)(
IMachine
*
machine
,
IUSBCommon
**
USBCommon
);
nsresult
(
*
GetUSBCommon
)(
IMachine
*
machine
,
IUSBCommon
**
USBCommon
);
nsresult
(
*
GetCPUCount
)(
IMachine
*
machine
,
PRUint32
*
CPUCount
);
nsresult
(
*
SetCPUCount
)(
IMachine
*
machine
,
PRUint32
CPUCount
);
nsresult
(
*
SetCPUCount
)(
IMachine
*
machine
,
PRUint32
CPUCount
);
nsresult
(
*
GetMemorySize
)(
IMachine
*
machine
,
PRUint32
*
memorySize
);
nsresult
(
*
SetMemorySize
)(
IMachine
*
machine
,
PRUint32
memorySize
);
nsresult
(
*
SetMemorySize
)(
IMachine
*
machine
,
PRUint32
memorySize
);
nsresult
(
*
SetCPUProperty
)(
IMachine
*
machine
,
PRUint32
property
,
PRBool
value
);
nsresult
(
*
SetCPUProperty
)(
IMachine
*
machine
,
PRUint32
property
,
PRBool
value
);
nsresult
(
*
SetBootOrder
)(
IMachine
*
machine
,
PRUint32
position
,
PRUint32
device
);
nsresult
(
*
SetBootOrder
)(
IMachine
*
machine
,
PRUint32
position
,
PRUint32
device
);
...
@@ -263,6 +265,7 @@ typedef struct {
...
@@ -263,6 +265,7 @@ typedef struct {
PRUint32
*
maxPortCount
);
PRUint32
*
maxPortCount
);
nsresult
(
*
GetMaxDevicesPerPortForStorageBus
)(
ISystemProperties
*
systemProperties
,
nsresult
(
*
GetMaxDevicesPerPortForStorageBus
)(
ISystemProperties
*
systemProperties
,
PRUint32
bus
,
PRUint32
*
maxDevicesPerPort
);
PRUint32
bus
,
PRUint32
*
maxDevicesPerPort
);
nsresult
(
*
GetMaxGuestRAM
)(
ISystemProperties
*
systemProperties
,
PRUint32
*
maxGuestRAM
);
}
vboxUniformedISystemProperties
;
}
vboxUniformedISystemProperties
;
/* Functions for IBIOSSettings */
/* Functions for IBIOSSettings */
...
@@ -360,6 +363,7 @@ typedef struct {
...
@@ -360,6 +363,7 @@ typedef struct {
nsresult
(
*
unregisterMachine
)(
vboxGlobalData
*
data
,
vboxIIDUnion
*
iidu
,
IMachine
**
machine
);
nsresult
(
*
unregisterMachine
)(
vboxGlobalData
*
data
,
vboxIIDUnion
*
iidu
,
IMachine
**
machine
);
void
(
*
deleteConfig
)(
IMachine
*
machine
);
void
(
*
deleteConfig
)(
IMachine
*
machine
);
void
(
*
vboxAttachDrivesOld
)(
virDomainDefPtr
def
,
vboxGlobalData
*
data
,
IMachine
*
machine
);
void
(
*
vboxAttachDrivesOld
)(
virDomainDefPtr
def
,
vboxGlobalData
*
data
,
IMachine
*
machine
);
virDomainState
(
*
vboxConvertState
)(
PRUint32
state
);
vboxUniformedPFN
UPFN
;
vboxUniformedPFN
UPFN
;
vboxUniformedIID
UIID
;
vboxUniformedIID
UIID
;
vboxUniformedArray
UArray
;
vboxUniformedArray
UArray
;
...
@@ -431,6 +435,7 @@ int vboxDomainDestroyFlags(virDomainPtr dom, unsigned int flags);
...
@@ -431,6 +435,7 @@ int vboxDomainDestroyFlags(virDomainPtr dom, unsigned int flags);
int
vboxDomainDestroy
(
virDomainPtr
dom
);
int
vboxDomainDestroy
(
virDomainPtr
dom
);
char
*
vboxDomainGetOSType
(
virDomainPtr
dom
);
char
*
vboxDomainGetOSType
(
virDomainPtr
dom
);
int
vboxDomainSetMemory
(
virDomainPtr
dom
,
unsigned
long
memory
);
int
vboxDomainSetMemory
(
virDomainPtr
dom
,
unsigned
long
memory
);
int
vboxDomainGetInfo
(
virDomainPtr
dom
,
virDomainInfoPtr
info
);
/* Version specified functions for installing uniformed API */
/* Version specified functions for installing uniformed API */
void
vbox22InstallUniformedAPI
(
vboxUniformedAPI
*
pVBoxAPI
);
void
vbox22InstallUniformedAPI
(
vboxUniformedAPI
*
pVBoxAPI
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录