Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
731c7386
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,发现更多精彩内容 >>
提交
731c7386
编写于
1月 20, 2010
作者:
M
Matthias Bolte
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
qemu: Search binaries in PATH instead of hardcoding /usr/bin
上级
72a8405a
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
80 addition
and
54 deletion
+80
-54
src/qemu/qemu_conf.c
src/qemu/qemu_conf.c
+80
-54
未找到文件。
src/qemu/qemu_conf.c
浏览文件 @
731c7386
...
@@ -384,20 +384,20 @@ static const struct qemu_feature_flags const arch_info_x86_64_flags [] = {
...
@@ -384,20 +384,20 @@ static const struct qemu_feature_flags const arch_info_x86_64_flags [] = {
/* The archicture tables for supported QEMU archs */
/* The archicture tables for supported QEMU archs */
static
const
struct
qemu_arch_info
const
arch_info_hvm
[]
=
{
static
const
struct
qemu_arch_info
const
arch_info_hvm
[]
=
{
{
"i686"
,
32
,
NULL
,
"
/usr/bin/
qemu"
,
{
"i686"
,
32
,
NULL
,
"qemu"
,
"
/usr/bin/
qemu-system-x86_64"
,
arch_info_i686_flags
,
4
},
"qemu-system-x86_64"
,
arch_info_i686_flags
,
4
},
{
"x86_64"
,
64
,
NULL
,
"
/usr/bin/
qemu-system-x86_64"
,
{
"x86_64"
,
64
,
NULL
,
"qemu-system-x86_64"
,
NULL
,
arch_info_x86_64_flags
,
2
},
NULL
,
arch_info_x86_64_flags
,
2
},
{
"arm"
,
32
,
NULL
,
"
/usr/bin/
qemu-system-arm"
,
NULL
,
NULL
,
0
},
{
"arm"
,
32
,
NULL
,
"qemu-system-arm"
,
NULL
,
NULL
,
0
},
{
"mips"
,
32
,
NULL
,
"
/usr/bin/
qemu-system-mips"
,
NULL
,
NULL
,
0
},
{
"mips"
,
32
,
NULL
,
"qemu-system-mips"
,
NULL
,
NULL
,
0
},
{
"mipsel"
,
32
,
NULL
,
"
/usr/bin/
qemu-system-mipsel"
,
NULL
,
NULL
,
0
},
{
"mipsel"
,
32
,
NULL
,
"qemu-system-mipsel"
,
NULL
,
NULL
,
0
},
{
"sparc"
,
32
,
NULL
,
"
/usr/bin/
qemu-system-sparc"
,
NULL
,
NULL
,
0
},
{
"sparc"
,
32
,
NULL
,
"qemu-system-sparc"
,
NULL
,
NULL
,
0
},
{
"ppc"
,
32
,
NULL
,
"
/usr/bin/
qemu-system-ppc"
,
NULL
,
NULL
,
0
},
{
"ppc"
,
32
,
NULL
,
"qemu-system-ppc"
,
NULL
,
NULL
,
0
},
};
};
static
const
struct
qemu_arch_info
const
arch_info_xen
[]
=
{
static
const
struct
qemu_arch_info
const
arch_info_xen
[]
=
{
{
"i686"
,
32
,
"xenner"
,
"
/usr/bin/
xenner"
,
NULL
,
arch_info_i686_flags
,
4
},
{
"i686"
,
32
,
"xenner"
,
"xenner"
,
NULL
,
arch_info_i686_flags
,
4
},
{
"x86_64"
,
64
,
"xenner"
,
"
/usr/bin/
xenner"
,
NULL
,
arch_info_x86_64_flags
,
2
},
{
"x86_64"
,
64
,
"xenner"
,
"xenner"
,
NULL
,
arch_info_x86_64_flags
,
2
},
};
};
...
@@ -773,21 +773,27 @@ qemudCapsInitGuest(virCapsPtr caps,
...
@@ -773,21 +773,27 @@ qemudCapsInitGuest(virCapsPtr caps,
int
i
;
int
i
;
int
haskvm
=
0
;
int
haskvm
=
0
;
int
haskqemu
=
0
;
int
haskqemu
=
0
;
c
onst
c
har
*
kvmbin
=
NULL
;
char
*
kvmbin
=
NULL
;
c
onst
c
har
*
binary
=
NULL
;
char
*
binary
=
NULL
;
time_t
binary_mtime
;
time_t
binary_mtime
;
virCapsGuestMachinePtr
*
machines
=
NULL
;
virCapsGuestMachinePtr
*
machines
=
NULL
;
int
nmachines
=
0
;
int
nmachines
=
0
;
struct
stat
st
;
struct
stat
st
;
unsigned
int
ncpus
;
unsigned
int
ncpus
;
int
ret
=
-
1
;
/* Check for existance of base emulator, or alternate base
/* Check for existance of base emulator, or alternate base
* which can be used with magic cpu choice
* which can be used with magic cpu choice
*/
*/
if
(
access
(
info
->
binary
,
X_OK
)
==
0
)
binary
=
virFindFileInPath
(
info
->
binary
);
binary
=
info
->
binary
;
else
if
(
info
->
altbinary
&&
access
(
info
->
altbinary
,
X_OK
)
==
0
)
if
(
binary
==
NULL
||
access
(
binary
,
X_OK
)
!=
0
)
{
binary
=
info
->
altbinary
;
VIR_FREE
(
binary
);
binary
=
virFindFileInPath
(
info
->
altbinary
);
if
(
binary
!=
NULL
&&
access
(
binary
,
X_OK
)
!=
0
)
VIR_FREE
(
binary
);
}
/* Can use acceleration for KVM/KQEMU if
/* Can use acceleration for KVM/KQEMU if
* - host & guest arches match
* - host & guest arches match
...
@@ -797,16 +803,22 @@ qemudCapsInitGuest(virCapsPtr caps,
...
@@ -797,16 +803,22 @@ qemudCapsInitGuest(virCapsPtr caps,
*/
*/
if
(
STREQ
(
info
->
arch
,
hostmachine
)
||
if
(
STREQ
(
info
->
arch
,
hostmachine
)
||
(
STREQ
(
hostmachine
,
"x86_64"
)
&&
STREQ
(
info
->
arch
,
"i686"
)))
{
(
STREQ
(
hostmachine
,
"x86_64"
)
&&
STREQ
(
info
->
arch
,
"i686"
)))
{
const
char
*
const
kvmbins
[]
=
{
"/usr/bin/qemu-kvm"
,
/* Fedora */
if
(
access
(
"/dev/kvm"
,
F_OK
)
==
0
)
{
"/usr/bin/kvm"
};
/* Upstream .spec */
const
char
*
const
kvmbins
[]
=
{
"qemu-kvm"
,
/* Fedora */
"kvm"
};
/* Upstream .spec */
for
(
i
=
0
;
i
<
ARRAY_CARDINALITY
(
kvmbins
);
++
i
)
{
kvmbin
=
virFindFileInPath
(
kvmbins
[
i
]);
if
(
kvmbin
==
NULL
||
access
(
kvmbin
,
X_OK
)
!=
0
)
{
VIR_FREE
(
kvmbin
);
continue
;
}
for
(
i
=
0
;
i
<
ARRAY_CARDINALITY
(
kvmbins
);
++
i
)
{
if
(
access
(
kvmbins
[
i
],
X_OK
)
==
0
&&
access
(
"/dev/kvm"
,
F_OK
)
==
0
)
{
haskvm
=
1
;
haskvm
=
1
;
kvmbin
=
kvmbins
[
i
];
if
(
!
binary
)
if
(
!
binary
)
binary
=
kvmbin
;
binary
=
kvmbin
;
break
;
break
;
}
}
}
}
...
@@ -831,23 +843,20 @@ qemudCapsInitGuest(virCapsPtr caps,
...
@@ -831,23 +843,20 @@ qemudCapsInitGuest(virCapsPtr caps,
virCapsGuestMachinePtr
machine
;
virCapsGuestMachinePtr
machine
;
if
(
VIR_ALLOC
(
machine
)
<
0
)
{
if
(
VIR_ALLOC
(
machine
)
<
0
)
{
virReportOOMError
(
NULL
);
goto
no_memory
;
return
-
1
;
}
}
if
(
!
(
machine
->
name
=
strdup
(
info
->
machine
)))
{
if
(
!
(
machine
->
name
=
strdup
(
info
->
machine
)))
{
virReportOOMError
(
NULL
);
VIR_FREE
(
machine
);
VIR_FREE
(
machine
);
return
-
1
;
goto
no_memory
;
}
}
nmachines
=
1
;
nmachines
=
1
;
if
(
VIR_ALLOC_N
(
machines
,
nmachines
)
<
0
)
{
if
(
VIR_ALLOC_N
(
machines
,
nmachines
)
<
0
)
{
virReportOOMError
(
NULL
);
VIR_FREE
(
machine
->
name
);
VIR_FREE
(
machine
->
name
);
VIR_FREE
(
machine
);
VIR_FREE
(
machine
);
return
-
1
;
goto
no_memory
;
}
}
machines
[
0
]
=
machine
;
machines
[
0
]
=
machine
;
...
@@ -859,7 +868,7 @@ qemudCapsInitGuest(virCapsPtr caps,
...
@@ -859,7 +868,7 @@ qemudCapsInitGuest(virCapsPtr caps,
old_caps
,
&
machines
,
&
nmachines
);
old_caps
,
&
machines
,
&
nmachines
);
if
(
probe
&&
if
(
probe
&&
qemudProbeMachineTypes
(
binary
,
&
machines
,
&
nmachines
)
<
0
)
qemudProbeMachineTypes
(
binary
,
&
machines
,
&
nmachines
)
<
0
)
return
-
1
;
goto
error
;
}
}
/* We register kvm as the base emulator too, since we can
/* We register kvm as the base emulator too, since we can
...
@@ -871,21 +880,18 @@ qemudCapsInitGuest(virCapsPtr caps,
...
@@ -871,21 +880,18 @@ qemudCapsInitGuest(virCapsPtr caps,
binary
,
binary
,
NULL
,
NULL
,
nmachines
,
nmachines
,
machines
))
==
NULL
)
{
machines
))
==
NULL
)
for
(
i
=
0
;
i
<
nmachines
;
i
++
)
{
goto
error
;
VIR_FREE
(
machines
[
i
]
->
name
);
VIR_FREE
(
machines
[
i
]);
machines
=
NULL
;
}
nmachines
=
0
;
VIR_FREE
(
machines
);
return
-
1
;
}
guest
->
arch
.
defaultInfo
.
emulator_mtime
=
binary_mtime
;
guest
->
arch
.
defaultInfo
.
emulator_mtime
=
binary_mtime
;
if
(
qemudProbeCPUModels
(
binary
,
info
->
arch
,
&
ncpus
,
NULL
)
==
0
if
(
qemudProbeCPUModels
(
binary
,
info
->
arch
,
&
ncpus
,
NULL
)
==
0
&&
ncpus
>
0
&&
ncpus
>
0
&&
!
virCapabilitiesAddGuestFeature
(
guest
,
"cpuselection"
,
1
,
0
))
&&
!
virCapabilitiesAddGuestFeature
(
guest
,
"cpuselection"
,
1
,
0
))
return
-
1
;
goto
error
;
if
(
hvm
)
{
if
(
hvm
)
{
if
(
virCapabilitiesAddGuestDomain
(
guest
,
if
(
virCapabilitiesAddGuestDomain
(
guest
,
...
@@ -894,7 +900,7 @@ qemudCapsInitGuest(virCapsPtr caps,
...
@@ -894,7 +900,7 @@ qemudCapsInitGuest(virCapsPtr caps,
NULL
,
NULL
,
0
,
0
,
NULL
)
==
NULL
)
NULL
)
==
NULL
)
return
-
1
;
goto
error
;
if
(
haskqemu
&&
if
(
haskqemu
&&
virCapabilitiesAddGuestDomain
(
guest
,
virCapabilitiesAddGuestDomain
(
guest
,
...
@@ -903,7 +909,7 @@ qemudCapsInitGuest(virCapsPtr caps,
...
@@ -903,7 +909,7 @@ qemudCapsInitGuest(virCapsPtr caps,
NULL
,
NULL
,
0
,
0
,
NULL
)
==
NULL
)
NULL
)
==
NULL
)
return
-
1
;
goto
error
;
if
(
haskvm
)
{
if
(
haskvm
)
{
virCapsGuestDomainPtr
dom
;
virCapsGuestDomainPtr
dom
;
...
@@ -917,9 +923,6 @@ qemudCapsInitGuest(virCapsPtr caps,
...
@@ -917,9 +923,6 @@ qemudCapsInitGuest(virCapsPtr caps,
binary_mtime
=
0
;
binary_mtime
=
0
;
}
}
machines
=
NULL
;
nmachines
=
0
;
if
(
!
STREQ
(
binary
,
kvmbin
))
{
if
(
!
STREQ
(
binary
,
kvmbin
))
{
int
probe
=
1
;
int
probe
=
1
;
if
(
old_caps
&&
binary_mtime
)
if
(
old_caps
&&
binary_mtime
)
...
@@ -928,7 +931,7 @@ qemudCapsInitGuest(virCapsPtr caps,
...
@@ -928,7 +931,7 @@ qemudCapsInitGuest(virCapsPtr caps,
old_caps
,
&
machines
,
&
nmachines
);
old_caps
,
&
machines
,
&
nmachines
);
if
(
probe
&&
if
(
probe
&&
qemudProbeMachineTypes
(
kvmbin
,
&
machines
,
&
nmachines
)
<
0
)
qemudProbeMachineTypes
(
kvmbin
,
&
machines
,
&
nmachines
)
<
0
)
return
-
1
;
goto
error
;
}
}
if
((
dom
=
virCapabilitiesAddGuestDomain
(
guest
,
if
((
dom
=
virCapabilitiesAddGuestDomain
(
guest
,
...
@@ -937,14 +940,12 @@ qemudCapsInitGuest(virCapsPtr caps,
...
@@ -937,14 +940,12 @@ qemudCapsInitGuest(virCapsPtr caps,
NULL
,
NULL
,
nmachines
,
nmachines
,
machines
))
==
NULL
)
{
machines
))
==
NULL
)
{
for
(
i
=
0
;
i
<
nmachines
;
i
++
)
{
goto
error
;
VIR_FREE
(
machines
[
i
]
->
name
);
VIR_FREE
(
machines
[
i
]);
}
VIR_FREE
(
machines
);
return
-
1
;
}
}
machines
=
NULL
;
nmachines
=
0
;
dom
->
info
.
emulator_mtime
=
binary_mtime
;
dom
->
info
.
emulator_mtime
=
binary_mtime
;
}
}
}
else
{
}
else
{
...
@@ -954,7 +955,7 @@ qemudCapsInitGuest(virCapsPtr caps,
...
@@ -954,7 +955,7 @@ qemudCapsInitGuest(virCapsPtr caps,
NULL
,
NULL
,
0
,
0
,
NULL
)
==
NULL
)
NULL
)
==
NULL
)
return
-
1
;
goto
error
;
}
}
if
(
info
->
nflags
)
{
if
(
info
->
nflags
)
{
...
@@ -963,11 +964,30 @@ qemudCapsInitGuest(virCapsPtr caps,
...
@@ -963,11 +964,30 @@ qemudCapsInitGuest(virCapsPtr caps,
info
->
flags
[
i
].
name
,
info
->
flags
[
i
].
name
,
info
->
flags
[
i
].
default_on
,
info
->
flags
[
i
].
default_on
,
info
->
flags
[
i
].
toggle
)
==
NULL
)
info
->
flags
[
i
].
toggle
)
==
NULL
)
return
-
1
;
goto
error
;
}
}
}
}
return
0
;
ret
=
0
;
cleanup:
if
(
binary
==
kvmbin
)
{
/* don't double free */
VIR_FREE
(
binary
);
}
else
{
VIR_FREE
(
binary
);
VIR_FREE
(
kvmbin
);
}
return
ret
;
no_memory:
virReportOOMError
(
NULL
);
error:
virCapabilitiesFreeMachines
(
machines
,
nmachines
);
goto
cleanup
;
}
}
...
@@ -1017,6 +1037,7 @@ virCapsPtr qemudCapsInit(virCapsPtr old_caps) {
...
@@ -1017,6 +1037,7 @@ virCapsPtr qemudCapsInit(virCapsPtr old_caps) {
struct
utsname
utsname
;
struct
utsname
utsname
;
virCapsPtr
caps
;
virCapsPtr
caps
;
int
i
;
int
i
;
char
*
xenner
=
NULL
;
/* Really, this never fails - look at the man-page. */
/* Really, this never fails - look at the man-page. */
uname
(
&
utsname
);
uname
(
&
utsname
);
...
@@ -1057,7 +1078,9 @@ virCapsPtr qemudCapsInit(virCapsPtr old_caps) {
...
@@ -1057,7 +1078,9 @@ virCapsPtr qemudCapsInit(virCapsPtr old_caps) {
goto
no_memory
;
goto
no_memory
;
/* Then possibly the Xen paravirt guests (ie Xenner */
/* Then possibly the Xen paravirt guests (ie Xenner */
if
(
access
(
"/usr/bin/xenner"
,
X_OK
)
==
0
&&
xenner
=
virFindFileInPath
(
"xenner"
);
if
(
xenner
!=
NULL
&&
access
(
xenner
,
X_OK
)
==
0
&&
access
(
"/dev/kvm"
,
F_OK
)
==
0
)
{
access
(
"/dev/kvm"
,
F_OK
)
==
0
)
{
for
(
i
=
0
;
i
<
ARRAY_CARDINALITY
(
arch_info_xen
)
;
i
++
)
for
(
i
=
0
;
i
<
ARRAY_CARDINALITY
(
arch_info_xen
)
;
i
++
)
/* Allow Xen 32-on-32, 32-on-64 and 64-on-64 */
/* Allow Xen 32-on-32, 32-on-64 and 64-on-64 */
...
@@ -1071,12 +1094,15 @@ virCapsPtr qemudCapsInit(virCapsPtr old_caps) {
...
@@ -1071,12 +1094,15 @@ virCapsPtr qemudCapsInit(virCapsPtr old_caps) {
}
}
}
}
VIR_FREE
(
xenner
);
/* QEMU Requires an emulator in the XML */
/* QEMU Requires an emulator in the XML */
virCapabilitiesSetEmulatorRequired
(
caps
);
virCapabilitiesSetEmulatorRequired
(
caps
);
return
caps
;
return
caps
;
no_memory:
no_memory:
VIR_FREE
(
xenner
);
virCapabilitiesFree
(
caps
);
virCapabilitiesFree
(
caps
);
return
NULL
;
return
NULL
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录