Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
3d45429e
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,发现更多精彩内容 >>
提交
3d45429e
编写于
11月 13, 2014
作者:
M
Martin Kletzander
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove unnecessary curly brackets in src/vmx/vmx.c
Signed-off-by:
N
Martin Kletzander
<
mkletzan@redhat.com
>
上级
247ad915
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
81 addition
and
162 deletion
+81
-162
src/vmx/vmx.c
src/vmx/vmx.c
+81
-162
未找到文件。
src/vmx/vmx.c
浏览文件 @
3d45429e
...
...
@@ -565,9 +565,8 @@ virVMXEscapeHex(const char *string, char escape, const char *special)
/* Calculate length of escaped string */
while
(
*
tmp1
!=
'\0'
)
{
if
(
*
tmp1
==
escape
||
strspn
(
tmp1
,
special
)
>
0
)
{
if
(
*
tmp1
==
escape
||
strspn
(
tmp1
,
special
)
>
0
)
length
+=
2
;
}
++
tmp1
;
++
length
;
...
...
@@ -610,9 +609,8 @@ virVMXUnescapeHex(char *string, char escape)
/* Unescape from 'cXX' where c is the escape char and X is a hex digit */
while
(
*
tmp1
!=
'\0'
)
{
if
(
*
tmp1
==
escape
)
{
if
(
!
c_isxdigit
(
tmp1
[
1
])
||
!
c_isxdigit
(
tmp1
[
2
]))
{
if
(
!
c_isxdigit
(
tmp1
[
1
])
||
!
c_isxdigit
(
tmp1
[
2
]))
return
-
1
;
}
*
tmp2
++
=
virHexToBin
(
tmp1
[
1
])
*
16
+
virHexToBin
(
tmp1
[
2
]);
tmp1
+=
3
;
...
...
@@ -676,9 +674,8 @@ virVMXGetConfigString(virConfPtr conf, const char *name, char **string,
value
=
virConfGetValue
(
conf
,
name
);
if
(
value
==
NULL
)
{
if
(
optional
)
{
if
(
optional
)
return
0
;
}
virReportError
(
VIR_ERR_INTERNAL_ERROR
,
_
(
"Missing essential config entry '%s'"
),
name
);
...
...
@@ -692,9 +689,8 @@ virVMXGetConfigString(virConfPtr conf, const char *name, char **string,
}
if
(
value
->
str
==
NULL
)
{
if
(
optional
)
{
if
(
optional
)
return
0
;
}
virReportError
(
VIR_ERR_INTERNAL_ERROR
,
_
(
"Missing essential config entry '%s'"
),
name
);
...
...
@@ -882,9 +878,8 @@ virVMXSCSIDiskNameToControllerAndUnit(const char *name, int *controller, int *un
*
unit
=
idx
%
15
;
/* Skip the controller ifself at unit 7 */
if
(
*
unit
>=
7
)
{
if
(
*
unit
>=
7
)
++
(
*
unit
);
}
return
0
;
}
...
...
@@ -1082,17 +1077,15 @@ virVMXHandleLegacySCSIDiskDriverName(virDomainDefPtr def,
const
char
*
driver
=
virDomainDiskGetDriver
(
disk
);
char
*
copy
;
if
(
disk
->
bus
!=
VIR_DOMAIN_DISK_BUS_SCSI
||
!
driver
)
{
if
(
disk
->
bus
!=
VIR_DOMAIN_DISK_BUS_SCSI
||
!
driver
)
return
0
;
}
if
(
VIR_STRDUP
(
copy
,
driver
)
<
0
)
return
-
1
;
tmp
=
copy
;
for
(;
*
tmp
!=
'\0'
;
++
tmp
)
{
for
(;
*
tmp
!=
'\0'
;
++
tmp
)
*
tmp
=
c_tolower
(
*
tmp
);
}
model
=
virDomainControllerModelSCSITypeFromString
(
copy
);
VIR_FREE
(
copy
);
...
...
@@ -1278,14 +1271,12 @@ virVMXParseConfig(virVMXContext *ctx,
conf
=
virConfReadMem
(
vmx
,
strlen
(
vmx
),
VIR_CONF_FLAG_VMX_FORMAT
);
if
(
conf
==
NULL
)
{
if
(
conf
==
NULL
)
return
NULL
;
}
/* vmx:.encoding */
if
(
virVMXGetConfigString
(
conf
,
".encoding"
,
&
encoding
,
true
)
<
0
)
{
if
(
virVMXGetConfigString
(
conf
,
".encoding"
,
&
encoding
,
true
)
<
0
)
goto
cleanup
;
}
if
(
encoding
==
NULL
||
STRCASEEQ
(
encoding
,
"UTF-8"
))
{
/* nothing */
...
...
@@ -1295,17 +1286,15 @@ virVMXParseConfig(virVMXContext *ctx,
utf8
=
virVMXConvertToUTF8
(
encoding
,
vmx
);
if
(
utf8
==
NULL
)
{
if
(
utf8
==
NULL
)
goto
cleanup
;
}
conf
=
virConfReadMem
(
utf8
,
strlen
(
utf8
),
VIR_CONF_FLAG_VMX_FORMAT
);
VIR_FREE
(
utf8
);
if
(
conf
==
NULL
)
{
if
(
conf
==
NULL
)
goto
cleanup
;
}
}
/* Allocate domain def */
...
...
@@ -1344,14 +1333,12 @@ virVMXParseConfig(virVMXContext *ctx,
/* vmx:uuid.bios -> def:uuid */
/* FIXME: Need to handle 'uuid.action = "create"' */
if
(
virVMXGetConfigUUID
(
conf
,
"uuid.bios"
,
def
->
uuid
,
true
)
<
0
)
{
if
(
virVMXGetConfigUUID
(
conf
,
"uuid.bios"
,
def
->
uuid
,
true
)
<
0
)
goto
cleanup
;
}
/* vmx:displayName -> def:name */
if
(
virVMXGetConfigString
(
conf
,
"displayName"
,
&
def
->
name
,
true
)
<
0
)
{
if
(
virVMXGetConfigString
(
conf
,
"displayName"
,
&
def
->
name
,
true
)
<
0
)
goto
cleanup
;
}
if
(
def
->
name
!=
NULL
)
{
if
(
virVMXUnescapeHexPercent
(
def
->
name
)
<
0
||
...
...
@@ -1378,9 +1365,8 @@ virVMXParseConfig(virVMXContext *ctx,
}
/* vmx:memsize -> def:mem.max_balloon */
if
(
virVMXGetConfigLong
(
conf
,
"memsize"
,
&
memsize
,
32
,
true
)
<
0
)
{
if
(
virVMXGetConfigLong
(
conf
,
"memsize"
,
&
memsize
,
32
,
true
)
<
0
)
goto
cleanup
;
}
if
(
memsize
<=
0
||
memsize
%
4
!=
0
)
{
virReportError
(
VIR_ERR_INTERNAL_ERROR
,
...
...
@@ -1397,15 +1383,13 @@ virVMXParseConfig(virVMXContext *ctx,
goto
cleanup
;
}
if
(
sched_mem_max
<
0
)
{
if
(
sched_mem_max
<
0
)
sched_mem_max
=
memsize
;
}
def
->
mem
.
cur_balloon
=
sched_mem_max
*
1024
;
/* Scale from megabytes to kilobytes */
if
(
def
->
mem
.
cur_balloon
>
def
->
mem
.
max_balloon
)
{
if
(
def
->
mem
.
cur_balloon
>
def
->
mem
.
max_balloon
)
def
->
mem
.
cur_balloon
=
def
->
mem
.
max_balloon
;
}
/* vmx:sched.mem.minsize -> def:mem.min_guarantee */
if
(
virVMXGetConfigLong
(
conf
,
"sched.mem.minsize"
,
&
sched_mem_minsize
,
0
,
...
...
@@ -1413,20 +1397,17 @@ virVMXParseConfig(virVMXContext *ctx,
goto
cleanup
;
}
if
(
sched_mem_minsize
<
0
)
{
if
(
sched_mem_minsize
<
0
)
sched_mem_minsize
=
0
;
}
def
->
mem
.
min_guarantee
=
sched_mem_minsize
*
1024
;
/* Scale from megabytes to kilobytes */
if
(
def
->
mem
.
min_guarantee
>
def
->
mem
.
max_balloon
)
{
if
(
def
->
mem
.
min_guarantee
>
def
->
mem
.
max_balloon
)
def
->
mem
.
min_guarantee
=
def
->
mem
.
max_balloon
;
}
/* vmx:numvcpus -> def:vcpus */
if
(
virVMXGetConfigLong
(
conf
,
"numvcpus"
,
&
numvcpus
,
1
,
true
)
<
0
)
{
if
(
virVMXGetConfigLong
(
conf
,
"numvcpus"
,
&
numvcpus
,
1
,
true
)
<
0
)
goto
cleanup
;
}
if
(
numvcpus
<=
0
||
(
numvcpus
%
2
!=
0
&&
numvcpus
!=
1
))
{
virReportError
(
VIR_ERR_INTERNAL_ERROR
,
...
...
@@ -1474,9 +1455,8 @@ virVMXParseConfig(virVMXContext *ctx,
goto
cleanup
;
}
if
(
number
+
1
>
cpumasklen
)
{
if
(
number
+
1
>
cpumasklen
)
cpumasklen
=
number
+
1
;
}
ignore_value
(
virBitmapSetBit
(
def
->
cpumask
,
number
));
++
count
;
...
...
@@ -1542,9 +1522,8 @@ virVMXParseConfig(virVMXContext *ctx,
goto
cleanup
;
/* vmx:guestOS -> def:os.arch */
if
(
virVMXGetConfigString
(
conf
,
"guestOS"
,
&
guestOS
,
true
)
<
0
)
{
if
(
virVMXGetConfigString
(
conf
,
"guestOS"
,
&
guestOS
,
true
)
<
0
)
goto
cleanup
;
}
if
(
guestOS
!=
NULL
&&
virFileHasSuffix
(
guestOS
,
"-64"
))
{
def
->
os
.
arch
=
VIR_ARCH_X86_64
;
...
...
@@ -1558,9 +1537,8 @@ virVMXParseConfig(virVMXContext *ctx,
goto
cleanup
;
}
if
(
smbios_reflecthost
)
{
if
(
smbios_reflecthost
)
def
->
os
.
smbios_mode
=
VIR_DOMAIN_SMBIOS_HOST
;
}
/* def:features */
/* FIXME */
...
...
@@ -1574,13 +1552,11 @@ virVMXParseConfig(virVMXContext *ctx,
def
->
ngraphics
=
0
;
if
(
virVMXParseVNC
(
conf
,
&
def
->
graphics
[
def
->
ngraphics
])
<
0
)
{
if
(
virVMXParseVNC
(
conf
,
&
def
->
graphics
[
def
->
ngraphics
])
<
0
)
goto
cleanup
;
}
if
(
def
->
graphics
[
def
->
ngraphics
]
!=
NULL
)
{
if
(
def
->
graphics
[
def
->
ngraphics
]
!=
NULL
)
++
def
->
ngraphics
;
}
/* def:disks: 4 * 15 scsi + 2 * 2 ide + 2 floppy = 66 */
if
(
VIR_ALLOC_N
(
def
->
disks
,
66
)
<
0
)
...
...
@@ -1595,9 +1571,8 @@ virVMXParseConfig(virVMXContext *ctx,
goto
cleanup
;
}
if
(
!
present
)
{
if
(
!
present
)
continue
;
}
for
(
unit
=
0
;
unit
<
16
;
++
unit
)
{
if
(
unit
==
7
)
{
...
...
@@ -1625,9 +1600,8 @@ virVMXParseConfig(virVMXContext *ctx,
goto
cleanup
;
}
if
(
def
->
disks
[
def
->
ndisks
]
!=
NULL
)
{
if
(
def
->
disks
[
def
->
ndisks
]
!=
NULL
)
++
def
->
ndisks
;
}
}
}
...
...
@@ -1651,9 +1625,8 @@ virVMXParseConfig(virVMXContext *ctx,
goto
cleanup
;
}
if
(
def
->
disks
[
def
->
ndisks
]
!=
NULL
)
{
if
(
def
->
disks
[
def
->
ndisks
]
!=
NULL
)
++
def
->
ndisks
;
}
}
}
...
...
@@ -1665,9 +1638,8 @@ virVMXParseConfig(virVMXContext *ctx,
goto
cleanup
;
}
if
(
def
->
disks
[
def
->
ndisks
]
!=
NULL
)
{
if
(
def
->
disks
[
def
->
ndisks
]
!=
NULL
)
++
def
->
ndisks
;
}
}
/* def:controllers */
...
...
@@ -1716,9 +1688,8 @@ virVMXParseConfig(virVMXContext *ctx,
goto
cleanup
;
}
if
(
def
->
fss
[
def
->
nfss
]
!=
NULL
)
{
if
(
def
->
fss
[
def
->
nfss
]
!=
NULL
)
++
def
->
nfss
;
}
}
}
}
...
...
@@ -1735,9 +1706,8 @@ virVMXParseConfig(virVMXContext *ctx,
goto
cleanup
;
}
if
(
def
->
nets
[
def
->
nnets
]
!=
NULL
)
{
if
(
def
->
nets
[
def
->
nnets
]
!=
NULL
)
++
def
->
nnets
;
}
}
/* def:inputs */
...
...
@@ -1749,9 +1719,8 @@ virVMXParseConfig(virVMXContext *ctx,
def
->
nvideos
=
0
;
if
(
virVMXParseSVGA
(
conf
,
&
def
->
videos
[
def
->
nvideos
])
<
0
)
{
if
(
virVMXParseSVGA
(
conf
,
&
def
->
videos
[
def
->
nvideos
])
<
0
)
goto
cleanup
;
}
def
->
nvideos
=
1
;
...
...
@@ -1773,9 +1742,8 @@ virVMXParseConfig(virVMXContext *ctx,
goto
cleanup
;
}
if
(
def
->
serials
[
def
->
nserials
]
!=
NULL
)
{
if
(
def
->
serials
[
def
->
nserials
]
!=
NULL
)
++
def
->
nserials
;
}
}
/* def:parallels */
...
...
@@ -1790,9 +1758,8 @@ virVMXParseConfig(virVMXContext *ctx,
goto
cleanup
;
}
if
(
def
->
parallels
[
def
->
nparallels
]
!=
NULL
)
{
if
(
def
->
parallels
[
def
->
nparallels
]
!=
NULL
)
++
def
->
nparallels
;
}
}
success
=
true
;
...
...
@@ -1831,9 +1798,8 @@ virVMXParseVNC(virConfPtr conf, virDomainGraphicsDefPtr *def)
return
-
1
;
}
if
(
!
enabled
)
{
if
(
!
enabled
)
return
0
;
}
if
(
VIR_ALLOC
(
*
def
)
<
0
)
goto
failure
;
...
...
@@ -1864,9 +1830,8 @@ virVMXParseVNC(virConfPtr conf, virDomainGraphicsDefPtr *def)
(
*
def
)
->
data
.
vnc
.
port
=
0
;
(
*
def
)
->
data
.
vnc
.
autoport
=
true
;
}
else
{
if
(
port
<
5900
||
port
>
5964
)
{
if
(
port
<
5900
||
port
>
5964
)
VIR_WARN
(
"VNC port %lld it out of [5900..5964] range"
,
port
);
}
(
*
def
)
->
data
.
vnc
.
port
=
port
;
(
*
def
)
->
data
.
vnc
.
autoport
=
false
;
...
...
@@ -1910,9 +1875,8 @@ virVMXParseSCSIController(virConfPtr conf, int controller, bool *present,
snprintf
(
virtualDev_name
,
sizeof
(
virtualDev_name
),
"scsi%d.virtualDev"
,
controller
);
if
(
virVMXGetConfigBoolean
(
conf
,
present_name
,
present
,
false
,
true
)
<
0
)
{
if
(
virVMXGetConfigBoolean
(
conf
,
present_name
,
present
,
false
,
true
)
<
0
)
goto
cleanup
;
}
if
(
!
*
present
)
{
result
=
0
;
...
...
@@ -1927,9 +1891,8 @@ virVMXParseSCSIController(virConfPtr conf, int controller, bool *present,
if
(
virtualDev_string
!=
NULL
)
{
tmp
=
virtualDev_string
;
for
(;
*
tmp
!=
'\0'
;
++
tmp
)
{
for
(;
*
tmp
!=
'\0'
;
++
tmp
)
*
tmp
=
c_tolower
(
*
tmp
);
}
*
virtualDev
=
virVMXControllerModelSCSITypeFromString
(
virtualDev_string
);
...
...
@@ -2045,9 +2008,8 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virConfPtr con
virIndexToDiskName
(
controllerOrBus
*
15
+
(
unit
<
7
?
unit
:
unit
-
1
),
"sd"
);
if
((
*
def
)
->
dst
==
NULL
)
{
if
((
*
def
)
->
dst
==
NULL
)
goto
cleanup
;
}
}
else
if
(
busType
==
VIR_DOMAIN_DISK_BUS_IDE
)
{
if
(
controllerOrBus
<
0
||
controllerOrBus
>
1
)
{
virReportError
(
VIR_ERR_INTERNAL_ERROR
,
...
...
@@ -2067,9 +2029,8 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virConfPtr con
(
*
def
)
->
dst
=
virIndexToDiskName
(
controllerOrBus
*
2
+
unit
,
"hd"
);
if
((
*
def
)
->
dst
==
NULL
)
{
if
((
*
def
)
->
dst
==
NULL
)
goto
cleanup
;
}
}
else
{
virReportError
(
VIR_ERR_CONFIG_UNSUPPORTED
,
_
(
"Unsupported bus type '%s' for device type '%s'"
),
...
...
@@ -2098,9 +2059,8 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virConfPtr con
(
*
def
)
->
dst
=
virIndexToDiskName
(
unit
,
"fd"
);
if
((
*
def
)
->
dst
==
NULL
)
{
if
((
*
def
)
->
dst
==
NULL
)
goto
cleanup
;
}
}
else
{
virReportError
(
VIR_ERR_CONFIG_UNSUPPORTED
,
_
(
"Unsupported bus type '%s' for device type '%s'"
),
...
...
@@ -2125,9 +2085,8 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virConfPtr con
VMX_BUILD_NAME
(
mode
);
/* vmx:present */
if
(
virVMXGetConfigBoolean
(
conf
,
present_name
,
&
present
,
false
,
true
)
<
0
)
{
if
(
virVMXGetConfigBoolean
(
conf
,
present_name
,
&
present
,
false
,
true
)
<
0
)
goto
cleanup
;
}
/* vmx:startConnected */
if
(
virVMXGetConfigBoolean
(
conf
,
startConnected_name
,
&
startConnected
,
...
...
@@ -2136,14 +2095,12 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virConfPtr con
}
/* FIXME: Need to distiguish between active and inactive domains here */
if
(
!
present
/* && ! startConnected*/
)
{
if
(
!
present
/* && ! startConnected*/
)
goto
ignore
;
}
/* vmx:deviceType -> def:type */
if
(
virVMXGetConfigString
(
conf
,
deviceType_name
,
&
deviceType
,
true
)
<
0
)
{
if
(
virVMXGetConfigString
(
conf
,
deviceType_name
,
&
deviceType
,
true
)
<
0
)
goto
cleanup
;
}
/* vmx:clientDevice */
if
(
virVMXGetConfigBoolean
(
conf
,
clientDevice_name
,
&
clientDevice
,
false
,
...
...
@@ -2152,9 +2109,8 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virConfPtr con
}
/* vmx:mode -> def:transient */
if
(
virVMXGetConfigString
(
conf
,
mode_name
,
&
mode
,
true
)
<
0
)
{
if
(
virVMXGetConfigString
(
conf
,
mode_name
,
&
mode
,
true
)
<
0
)
goto
cleanup
;
}
if
(
clientDevice
)
{
/*
...
...
@@ -2165,14 +2121,12 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virConfPtr con
}
/* vmx:fileType -> def:type */
if
(
virVMXGetConfigString
(
conf
,
fileType_name
,
&
fileType
,
true
)
<
0
)
{
if
(
virVMXGetConfigString
(
conf
,
fileType_name
,
&
fileType
,
true
)
<
0
)
goto
cleanup
;
}
/* vmx:fileName -> def:src, def:type */
if
(
virVMXGetConfigString
(
conf
,
fileName_name
,
&
fileName
,
false
)
<
0
)
{
if
(
virVMXGetConfigString
(
conf
,
fileName_name
,
&
fileName
,
false
)
<
0
)
goto
cleanup
;
}
/* vmx:writeThrough -> def:cachemode */
if
(
virVMXGetConfigBoolean
(
conf
,
writeThrough_name
,
&
writeThrough
,
false
,
...
...
@@ -2396,31 +2350,26 @@ int virVMXParseFileSystem(virConfPtr conf, int number, virDomainFSDefPtr *def)
VMX_BUILD_NAME
(
writeAccess
);
/* vmx:present */
if
(
virVMXGetConfigBoolean
(
conf
,
present_name
,
&
present
,
false
,
true
)
<
0
)
{
if
(
virVMXGetConfigBoolean
(
conf
,
present_name
,
&
present
,
false
,
true
)
<
0
)
goto
cleanup
;
}
/* vmx:enabled */
if
(
virVMXGetConfigBoolean
(
conf
,
enabled_name
,
&
enabled
,
false
,
true
)
<
0
)
{
if
(
virVMXGetConfigBoolean
(
conf
,
enabled_name
,
&
enabled
,
false
,
true
)
<
0
)
goto
cleanup
;
}
if
(
!
(
present
&&
enabled
))
{
if
(
!
(
present
&&
enabled
))
goto
ignore
;
}
/* vmx:hostPath */
if
(
virVMXGetConfigString
(
conf
,
hostPath_name
,
&
hostPath
,
false
)
<
0
)
{
if
(
virVMXGetConfigString
(
conf
,
hostPath_name
,
&
hostPath
,
false
)
<
0
)
goto
cleanup
;
}
(
*
def
)
->
src
=
hostPath
;
hostPath
=
NULL
;
/* vmx:guestName */
if
(
virVMXGetConfigString
(
conf
,
guestName_name
,
&
guestName
,
false
)
<
0
)
{
if
(
virVMXGetConfigString
(
conf
,
guestName_name
,
&
guestName
,
false
)
<
0
)
goto
cleanup
;
}
(
*
def
)
->
dst
=
guestName
;
guestName
=
NULL
;
...
...
@@ -2522,9 +2471,8 @@ virVMXParseEthernet(virConfPtr conf, int controller, virDomainNetDefPtr *def)
VMX_BUILD_NAME
(
vnet
);
/* vmx:present */
if
(
virVMXGetConfigBoolean
(
conf
,
present_name
,
&
present
,
false
,
true
)
<
0
)
{
if
(
virVMXGetConfigBoolean
(
conf
,
present_name
,
&
present
,
false
,
true
)
<
0
)
goto
cleanup
;
}
/* vmx:startConnected */
if
(
virVMXGetConfigBoolean
(
conf
,
startConnected_name
,
&
startConnected
,
...
...
@@ -2533,9 +2481,8 @@ virVMXParseEthernet(virConfPtr conf, int controller, virDomainNetDefPtr *def)
}
/* FIXME: Need to distiguish between active and inactive domains here */
if
(
!
present
/* && ! startConnected*/
)
{
if
(
!
present
/* && ! startConnected*/
)
goto
ignore
;
}
/* vmx:connectionType -> def:type */
if
(
virVMXGetConfigString
(
conf
,
connectionType_name
,
&
connectionType
,
...
...
@@ -2736,9 +2683,8 @@ virVMXParseSerial(virVMXContext *ctx, virConfPtr conf, int port,
VMX_BUILD_NAME_EXTRA
(
network_endPoint
,
"network.endPoint"
);
/* vmx:present */
if
(
virVMXGetConfigBoolean
(
conf
,
present_name
,
&
present
,
false
,
true
)
<
0
)
{
if
(
virVMXGetConfigBoolean
(
conf
,
present_name
,
&
present
,
false
,
true
)
<
0
)
goto
cleanup
;
}
/* vmx:startConnected */
if
(
virVMXGetConfigBoolean
(
conf
,
startConnected_name
,
&
startConnected
,
...
...
@@ -2747,19 +2693,16 @@ virVMXParseSerial(virVMXContext *ctx, virConfPtr conf, int port,
}
/* FIXME: Need to distiguish between active and inactive domains here */
if
(
!
present
/* && ! startConnected*/
)
{
if
(
!
present
/* && ! startConnected*/
)
goto
ignore
;
}
/* vmx:fileType -> def:type */
if
(
virVMXGetConfigString
(
conf
,
fileType_name
,
&
fileType
,
false
)
<
0
)
{
if
(
virVMXGetConfigString
(
conf
,
fileType_name
,
&
fileType
,
false
)
<
0
)
goto
cleanup
;
}
/* vmx:fileName -> def:data.file.path */
if
(
virVMXGetConfigString
(
conf
,
fileName_name
,
&
fileName
,
true
)
<
0
)
{
if
(
virVMXGetConfigString
(
conf
,
fileName_name
,
&
fileName
,
true
)
<
0
)
goto
cleanup
;
}
/* vmx:network.endPoint -> def:data.tcp.listen */
if
(
virVMXGetConfigString
(
conf
,
network_endPoint_name
,
&
network_endPoint
,
...
...
@@ -2780,9 +2723,8 @@ virVMXParseSerial(virVMXContext *ctx, virConfPtr conf, int port,
(
*
def
)
->
source
.
data
.
file
.
path
=
ctx
->
parseFileName
(
fileName
,
ctx
->
opaque
);
if
((
*
def
)
->
source
.
data
.
file
.
path
==
NULL
)
{
if
((
*
def
)
->
source
.
data
.
file
.
path
==
NULL
)
goto
cleanup
;
}
}
else
if
(
STRCASEEQ
(
fileType
,
"pipe"
))
{
/*
* FIXME: Differences between client/server and VM/application pipes
...
...
@@ -2924,9 +2866,8 @@ virVMXParseParallel(virVMXContext *ctx, virConfPtr conf, int port,
VMX_BUILD_NAME
(
fileName
);
/* vmx:present */
if
(
virVMXGetConfigBoolean
(
conf
,
present_name
,
&
present
,
false
,
true
)
<
0
)
{
if
(
virVMXGetConfigBoolean
(
conf
,
present_name
,
&
present
,
false
,
true
)
<
0
)
goto
cleanup
;
}
/* vmx:startConnected */
if
(
virVMXGetConfigBoolean
(
conf
,
startConnected_name
,
&
startConnected
,
...
...
@@ -2935,19 +2876,16 @@ virVMXParseParallel(virVMXContext *ctx, virConfPtr conf, int port,
}
/* FIXME: Need to distiguish between active and inactive domains here */
if
(
!
present
/* && ! startConnected*/
)
{
if
(
!
present
/* && ! startConnected*/
)
goto
ignore
;
}
/* vmx:fileType -> def:type */
if
(
virVMXGetConfigString
(
conf
,
fileType_name
,
&
fileType
,
false
)
<
0
)
{
if
(
virVMXGetConfigString
(
conf
,
fileType_name
,
&
fileType
,
false
)
<
0
)
goto
cleanup
;
}
/* vmx:fileName -> def:data.file.path */
if
(
virVMXGetConfigString
(
conf
,
fileName_name
,
&
fileName
,
false
)
<
0
)
{
if
(
virVMXGetConfigString
(
conf
,
fileName_name
,
&
fileName
,
false
)
<
0
)
goto
cleanup
;
}
/* Setup virDomainChrDef */
if
(
STRCASEEQ
(
fileType
,
"device"
))
{
...
...
@@ -2962,9 +2900,8 @@ virVMXParseParallel(virVMXContext *ctx, virConfPtr conf, int port,
(
*
def
)
->
source
.
data
.
file
.
path
=
ctx
->
parseFileName
(
fileName
,
ctx
->
opaque
);
if
((
*
def
)
->
source
.
data
.
file
.
path
==
NULL
)
{
if
((
*
def
)
->
source
.
data
.
file
.
path
==
NULL
)
goto
cleanup
;
}
}
else
{
virReportError
(
VIR_ERR_INTERNAL_ERROR
,
_
(
"Expecting VMX entry '%s' to be 'device' or 'file' but "
...
...
@@ -3122,15 +3059,13 @@ virVMXFormatConfig(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virDomainDe
/* def:name -> vmx:displayName */
preliminaryDisplayName
=
virVMXEscapeHexPipe
(
def
->
name
);
if
(
preliminaryDisplayName
==
NULL
)
{
if
(
preliminaryDisplayName
==
NULL
)
goto
cleanup
;
}
displayName
=
virVMXEscapeHexPercent
(
preliminaryDisplayName
);
if
(
displayName
==
NULL
)
{
if
(
displayName
==
NULL
)
goto
cleanup
;
}
virBufferAsprintf
(
&
buffer
,
"displayName =
\"
%s
\"\n
"
,
displayName
);
...
...
@@ -3188,9 +3123,8 @@ virVMXFormatConfig(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virDomainDe
sched_cpu_affinity_length
=
0
;
bit
=
-
1
;
while
((
bit
=
virBitmapNextSetBit
(
def
->
cpumask
,
bit
))
>=
0
)
{
while
((
bit
=
virBitmapNextSetBit
(
def
->
cpumask
,
bit
))
>=
0
)
++
sched_cpu_affinity_length
;
}
if
(
sched_cpu_affinity_length
<
def
->
maxvcpus
)
{
virReportError
(
VIR_ERR_INTERNAL_ERROR
,
...
...
@@ -3204,9 +3138,8 @@ virVMXFormatConfig(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virDomainDe
while
((
bit
=
virBitmapNextSetBit
(
def
->
cpumask
,
bit
))
>=
0
)
{
virBufferAsprintf
(
&
buffer
,
"%d"
,
bit
);
if
(
sched_cpu_affinity_length
>
1
)
{
if
(
sched_cpu_affinity_length
>
1
)
virBufferAddChar
(
&
buffer
,
','
);
}
--
sched_cpu_affinity_length
;
}
...
...
@@ -3233,9 +3166,8 @@ virVMXFormatConfig(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virDomainDe
for
(
i
=
0
;
i
<
def
->
ngraphics
;
++
i
)
{
switch
(
def
->
graphics
[
i
]
->
type
)
{
case
VIR_DOMAIN_GRAPHICS_TYPE_VNC
:
if
(
virVMXFormatVNC
(
def
->
graphics
[
i
],
&
buffer
)
<
0
)
{
if
(
virVMXFormatVNC
(
def
->
graphics
[
i
],
&
buffer
)
<
0
)
goto
cleanup
;
}
break
;
...
...
@@ -3277,9 +3209,8 @@ virVMXFormatConfig(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virDomainDe
case
VIR_DOMAIN_DISK_DEVICE_DISK
:
case
VIR_DOMAIN_DISK_DEVICE_CDROM
:
case
VIR_DOMAIN_DISK_DEVICE_LUN
:
if
(
virVMXFormatDisk
(
ctx
,
def
->
disks
[
i
],
&
buffer
)
<
0
)
{
if
(
virVMXFormatDisk
(
ctx
,
def
->
disks
[
i
],
&
buffer
)
<
0
)
goto
cleanup
;
}
break
;
...
...
@@ -3301,9 +3232,8 @@ virVMXFormatConfig(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virDomainDe
for
(
i
=
0
;
i
<
2
;
++
i
)
{
/* floppy[0..1].present defaults to true, disable it explicitly */
if
(
!
floppy_present
[
i
])
{
if
(
!
floppy_present
[
i
])
virBufferAsprintf
(
&
buffer
,
"floppy%zu.present =
\"
false
\"\n
"
,
i
);
}
}
/* def:fss */
...
...
@@ -3313,16 +3243,14 @@ virVMXFormatConfig(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virDomainDe
}
for
(
i
=
0
;
i
<
def
->
nfss
;
++
i
)
{
if
(
virVMXFormatFileSystem
(
def
->
fss
[
i
],
i
,
&
buffer
)
<
0
)
{
if
(
virVMXFormatFileSystem
(
def
->
fss
[
i
],
i
,
&
buffer
)
<
0
)
goto
cleanup
;
}
}
/* def:nets */
for
(
i
=
0
;
i
<
def
->
nnets
;
++
i
)
{
if
(
virVMXFormatEthernet
(
def
->
nets
[
i
],
i
,
&
buffer
)
<
0
)
{
if
(
virVMXFormatEthernet
(
def
->
nets
[
i
],
i
,
&
buffer
)
<
0
)
goto
cleanup
;
}
}
/* def:inputs */
...
...
@@ -3339,9 +3267,8 @@ virVMXFormatConfig(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virDomainDe
goto
cleanup
;
}
if
(
virVMXFormatSVGA
(
def
->
videos
[
0
],
&
buffer
)
<
0
)
{
if
(
virVMXFormatSVGA
(
def
->
videos
[
0
],
&
buffer
)
<
0
)
goto
cleanup
;
}
}
/* def:hostdevs */
...
...
@@ -3349,16 +3276,14 @@ virVMXFormatConfig(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virDomainDe
/* def:serials */
for
(
i
=
0
;
i
<
def
->
nserials
;
++
i
)
{
if
(
virVMXFormatSerial
(
ctx
,
def
->
serials
[
i
],
&
buffer
)
<
0
)
{
if
(
virVMXFormatSerial
(
ctx
,
def
->
serials
[
i
],
&
buffer
)
<
0
)
goto
cleanup
;
}
}
/* def:parallels */
for
(
i
=
0
;
i
<
def
->
nparallels
;
++
i
)
{
if
(
virVMXFormatParallel
(
ctx
,
def
->
parallels
[
i
],
&
buffer
)
<
0
)
{
if
(
virVMXFormatParallel
(
ctx
,
def
->
parallels
[
i
],
&
buffer
)
<
0
)
goto
cleanup
;
}
}
/* Get final VMX output */
...
...
@@ -3368,9 +3293,8 @@ virVMXFormatConfig(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virDomainDe
vmx
=
virBufferContentAndReset
(
&
buffer
);
cleanup:
if
(
vmx
==
NULL
)
{
if
(
vmx
==
NULL
)
virBufferFreeAndReset
(
&
buffer
);
}
VIR_FREE
(
preliminaryDisplayName
);
VIR_FREE
(
displayName
);
...
...
@@ -3518,9 +3442,8 @@ virVMXFormatDisk(virVMXContext *ctx, virDomainDiskDefPtr def,
fileName
=
ctx
->
formatFileName
(
src
,
ctx
->
opaque
);
if
(
fileName
==
NULL
)
{
if
(
fileName
==
NULL
)
return
-
1
;
}
virBufferAsprintf
(
buffer
,
"%s%d:%d.fileName =
\"
%s
\"\n
"
,
busType
,
controllerOrBus
,
unit
,
fileName
);
...
...
@@ -3575,9 +3498,8 @@ virVMXFormatFloppy(virVMXContext *ctx, virDomainDiskDefPtr def,
return
-
1
;
}
if
(
virVMXFloppyDiskNameToUnit
(
def
->
dst
,
&
unit
)
<
0
)
{
if
(
virVMXFloppyDiskNameToUnit
(
def
->
dst
,
&
unit
)
<
0
)
return
-
1
;
}
floppy_present
[
unit
]
=
true
;
...
...
@@ -3589,9 +3511,8 @@ virVMXFormatFloppy(virVMXContext *ctx, virDomainDiskDefPtr def,
if
(
src
)
{
fileName
=
ctx
->
formatFileName
(
src
,
ctx
->
opaque
);
if
(
fileName
==
NULL
)
{
if
(
fileName
==
NULL
)
return
-
1
;
}
virBufferAsprintf
(
buffer
,
"floppy%d.fileName =
\"
%s
\"\n
"
,
unit
,
fileName
);
...
...
@@ -3784,9 +3705,8 @@ virVMXFormatSerial(virVMXContext *ctx, virDomainChrDefPtr def,
fileName
=
ctx
->
formatFileName
(
def
->
source
.
data
.
file
.
path
,
ctx
->
opaque
);
if
(
fileName
==
NULL
)
{
if
(
fileName
==
NULL
)
return
-
1
;
}
virBufferAsprintf
(
buffer
,
"serial%d.fileName =
\"
%s
\"\n
"
,
def
->
target
.
port
,
fileName
);
...
...
@@ -3891,9 +3811,8 @@ virVMXFormatParallel(virVMXContext *ctx, virDomainChrDefPtr def,
fileName
=
ctx
->
formatFileName
(
def
->
source
.
data
.
file
.
path
,
ctx
->
opaque
);
if
(
fileName
==
NULL
)
{
if
(
fileName
==
NULL
)
return
-
1
;
}
virBufferAsprintf
(
buffer
,
"parallel%d.fileName =
\"
%s
\"\n
"
,
def
->
target
.
port
,
fileName
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录