Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
5184f398
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,发现更多精彩内容 >>
提交
5184f398
编写于
7月 01, 2016
作者:
P
Peter Krempa
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
qemu: Store vCPU thread ids in vcpu private data objects
Rather than storing them in an external array store them directly.
上级
3f57ce4a
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
71 addition
and
54 deletion
+71
-54
src/qemu/qemu_domain.c
src/qemu/qemu_domain.c
+69
-47
src/qemu/qemu_domain.h
src/qemu/qemu_domain.h
+2
-5
src/qemu/qemu_process.c
src/qemu/qemu_process.c
+0
-2
未找到文件。
src/qemu/qemu_domain.c
浏览文件 @
5184f398
...
@@ -1296,7 +1296,6 @@ qemuDomainObjPrivateFree(void *data)
...
@@ -1296,7 +1296,6 @@ qemuDomainObjPrivateFree(void *data)
virDomainVirtioSerialAddrSetFree
(
priv
->
vioserialaddrs
);
virDomainVirtioSerialAddrSetFree
(
priv
->
vioserialaddrs
);
virDomainChrSourceDefFree
(
priv
->
monConfig
);
virDomainChrSourceDefFree
(
priv
->
monConfig
);
qemuDomainObjFreeJob
(
priv
);
qemuDomainObjFreeJob
(
priv
);
VIR_FREE
(
priv
->
vcpupids
);
VIR_FREE
(
priv
->
lockState
);
VIR_FREE
(
priv
->
lockState
);
VIR_FREE
(
priv
->
origname
);
VIR_FREE
(
priv
->
origname
);
...
@@ -1325,19 +1324,25 @@ qemuDomainObjPrivateFree(void *data)
...
@@ -1325,19 +1324,25 @@ qemuDomainObjPrivateFree(void *data)
static
void
static
void
qemuDomainObjPrivateXMLFormatVcpus
(
virBufferPtr
buf
,
qemuDomainObjPrivateXMLFormatVcpus
(
virBufferPtr
buf
,
int
*
vcpupids
,
virDomainDefPtr
def
)
int
nvcpupids
)
{
{
size_t
i
;
size_t
i
;
size_t
maxvcpus
=
virDomainDefGetVcpusMax
(
def
);
if
(
!
nvcpupids
)
virDomainVcpuDefPtr
vcpu
;
return
;
pid_t
tid
;
virBufferAddLit
(
buf
,
"<vcpus>
\n
"
);
virBufferAddLit
(
buf
,
"<vcpus>
\n
"
);
virBufferAdjustIndent
(
buf
,
2
);
virBufferAdjustIndent
(
buf
,
2
);
for
(
i
=
0
;
i
<
nvcpupids
;
i
++
)
for
(
i
=
0
;
i
<
maxvcpus
;
i
++
)
{
virBufferAsprintf
(
buf
,
"<vcpu id='%zu' pid='%d'/>
\n
"
,
i
,
vcpupids
[
i
]);
vcpu
=
virDomainDefGetVcpu
(
def
,
i
);
tid
=
QEMU_DOMAIN_VCPU_PRIVATE
(
vcpu
)
->
tid
;
if
(
!
vcpu
->
online
||
tid
==
0
)
continue
;
virBufferAsprintf
(
buf
,
"<vcpu id='%zu' pid='%d'/>
\n
"
,
i
,
tid
);
}
virBufferAdjustIndent
(
buf
,
-
2
);
virBufferAdjustIndent
(
buf
,
-
2
);
virBufferAddLit
(
buf
,
"</vcpus>
\n
"
);
virBufferAddLit
(
buf
,
"</vcpus>
\n
"
);
...
@@ -1371,7 +1376,7 @@ qemuDomainObjPrivateXMLFormat(virBufferPtr buf,
...
@@ -1371,7 +1376,7 @@ qemuDomainObjPrivateXMLFormat(virBufferPtr buf,
virDomainChrTypeToString
(
priv
->
monConfig
->
type
));
virDomainChrTypeToString
(
priv
->
monConfig
->
type
));
}
}
qemuDomainObjPrivateXMLFormatVcpus
(
buf
,
priv
->
vcpupids
,
priv
->
nvcpupids
);
qemuDomainObjPrivateXMLFormatVcpus
(
buf
,
vm
->
def
);
if
(
priv
->
qemuCaps
)
{
if
(
priv
->
qemuCaps
)
{
size_t
i
;
size_t
i
;
...
@@ -1464,27 +1469,31 @@ qemuDomainObjPrivateXMLFormat(virBufferPtr buf,
...
@@ -1464,27 +1469,31 @@ qemuDomainObjPrivateXMLFormat(virBufferPtr buf,
static
int
static
int
qemuDomainObjPrivateXMLParseVcpu
(
xmlNodePtr
node
,
qemuDomainObjPrivateXMLParseVcpu
(
xmlNodePtr
node
,
unsigned
int
idx
,
unsigned
int
idx
,
qemuDomainObjPrivatePtr
priv
)
virDomainDefPtr
def
)
{
{
virDomainVcpuDefPtr
vcpu
;
char
*
idstr
;
char
*
idstr
;
char
*
pidstr
;
char
*
pidstr
;
unsigned
int
tmp
;
int
ret
=
-
1
;
int
ret
=
-
1
;
i
f
((
idstr
=
virXMLPropString
(
node
,
"id"
)))
{
i
dstr
=
virXMLPropString
(
node
,
"id"
);
if
(
virStrToLong_uip
(
idstr
,
NULL
,
10
,
&
idx
)
<
0
||
idx
>=
priv
->
nvcpupids
)
{
if
((
idstr
&&
virStrToLong_uip
(
idstr
,
NULL
,
10
,
&
idx
))
<
0
||
virReportError
(
VIR_ERR_INTERNAL_ERROR
,
!
(
vcpu
=
virDomainDefGetVcpu
(
def
,
idx
)))
{
_
(
"invalid vcpu index '%s'"
),
idstr
);
virReportError
(
VIR_ERR_INTERNAL_ERROR
,
goto
cleanup
;
_
(
"invalid vcpu index '%s'"
),
idstr
)
;
}
goto
cleanup
;
}
}
if
(
!
(
pidstr
=
virXMLPropString
(
node
,
"pid"
)))
if
(
!
(
pidstr
=
virXMLPropString
(
node
,
"pid"
)))
goto
cleanup
;
goto
cleanup
;
if
(
virStrToLong_
i
(
pidstr
,
NULL
,
10
,
&
(
priv
->
vcpupids
[
idx
])
)
<
0
)
if
(
virStrToLong_
uip
(
pidstr
,
NULL
,
10
,
&
tmp
)
<
0
)
goto
cleanup
;
goto
cleanup
;
QEMU_DOMAIN_VCPU_PRIVATE
(
vcpu
)
->
tid
=
tmp
;
ret
=
0
;
ret
=
0
;
cleanup:
cleanup:
...
@@ -1547,12 +1556,8 @@ qemuDomainObjPrivateXMLParse(xmlXPathContextPtr ctxt,
...
@@ -1547,12 +1556,8 @@ qemuDomainObjPrivateXMLParse(xmlXPathContextPtr ctxt,
if
((
n
=
virXPathNodeSet
(
"./vcpus/vcpu"
,
ctxt
,
&
nodes
))
<
0
)
if
((
n
=
virXPathNodeSet
(
"./vcpus/vcpu"
,
ctxt
,
&
nodes
))
<
0
)
goto
error
;
goto
error
;
priv
->
nvcpupids
=
n
;
if
(
VIR_REALLOC_N
(
priv
->
vcpupids
,
priv
->
nvcpupids
)
<
0
)
goto
error
;
for
(
i
=
0
;
i
<
n
;
i
++
)
{
for
(
i
=
0
;
i
<
n
;
i
++
)
{
if
(
qemuDomainObjPrivateXMLParseVcpu
(
nodes
[
i
],
i
,
priv
)
<
0
)
if
(
qemuDomainObjPrivateXMLParseVcpu
(
nodes
[
i
],
i
,
vm
->
def
)
<
0
)
goto
error
;
goto
error
;
}
}
VIR_FREE
(
nodes
);
VIR_FREE
(
nodes
);
...
@@ -5506,9 +5511,18 @@ qemuDomainAdjustMaxMemLock(virDomainObjPtr vm)
...
@@ -5506,9 +5511,18 @@ qemuDomainAdjustMaxMemLock(virDomainObjPtr vm)
bool
bool
qemuDomainHasVcpuPids
(
virDomainObjPtr
vm
)
qemuDomainHasVcpuPids
(
virDomainObjPtr
vm
)
{
{
qemuDomainObjPrivatePtr
priv
=
vm
->
privateData
;
size_t
i
;
size_t
maxvcpus
=
virDomainDefGetVcpusMax
(
vm
->
def
);
virDomainVcpuDefPtr
vcpu
;
for
(
i
=
0
;
i
<
maxvcpus
;
i
++
)
{
vcpu
=
virDomainDefGetVcpu
(
vm
->
def
,
i
);
return
priv
->
nvcpupids
>
0
;
if
(
QEMU_DOMAIN_VCPU_PRIVATE
(
vcpu
)
->
tid
>
0
)
return
true
;
}
return
false
;
}
}
...
@@ -5521,14 +5535,10 @@ qemuDomainHasVcpuPids(virDomainObjPtr vm)
...
@@ -5521,14 +5535,10 @@ qemuDomainHasVcpuPids(virDomainObjPtr vm)
*/
*/
pid_t
pid_t
qemuDomainGetVcpuPid
(
virDomainObjPtr
vm
,
qemuDomainGetVcpuPid
(
virDomainObjPtr
vm
,
unsigned
int
vcpu
)
unsigned
int
vcpu
id
)
{
{
qemuDomainObjPrivatePtr
priv
=
vm
->
privateData
;
virDomainVcpuDefPtr
vcpu
=
virDomainDefGetVcpu
(
vm
->
def
,
vcpuid
);
return
QEMU_DOMAIN_VCPU_PRIVATE
(
vcpu
)
->
tid
;
if
(
vcpu
>=
priv
->
nvcpupids
)
return
0
;
return
priv
->
vcpupids
[
vcpu
];
}
}
...
@@ -5548,9 +5558,12 @@ qemuDomainDetectVcpuPids(virQEMUDriverPtr driver,
...
@@ -5548,9 +5558,12 @@ qemuDomainDetectVcpuPids(virQEMUDriverPtr driver,
virDomainObjPtr
vm
,
virDomainObjPtr
vm
,
int
asyncJob
)
int
asyncJob
)
{
{
virDomainVcpuDefPtr
vcpu
;
size_t
maxvcpus
=
virDomainDefGetVcpusMax
(
vm
->
def
);
pid_t
*
cpupids
=
NULL
;
pid_t
*
cpupids
=
NULL
;
int
ncpupids
=
0
;
int
ncpupids
;
qemuDomainObjPrivatePtr
priv
=
vm
->
privateData
;
size_t
i
;
int
ret
=
-
1
;
/*
/*
* Current QEMU *can* report info about host threads mapped
* Current QEMU *can* report info about host threads mapped
...
@@ -5581,22 +5594,32 @@ qemuDomainDetectVcpuPids(virQEMUDriverPtr driver,
...
@@ -5581,22 +5594,32 @@ qemuDomainDetectVcpuPids(virQEMUDriverPtr driver,
* to try to do this hard work.
* to try to do this hard work.
*/
*/
if
(
vm
->
def
->
virtType
==
VIR_DOMAIN_VIRT_QEMU
)
if
(
vm
->
def
->
virtType
==
VIR_DOMAIN_VIRT_QEMU
)
goto
done
;
return
0
;
if
(
qemuDomainObjEnterMonitorAsync
(
driver
,
vm
,
asyncJob
)
<
0
)
if
(
qemuDomainObjEnterMonitorAsync
(
driver
,
vm
,
asyncJob
)
<
0
)
return
-
1
;
return
-
1
;
ncpupids
=
qemuMonitorGetCPUInfo
(
priv
->
mon
,
&
cpupids
);
ncpupids
=
qemuMonitorGetCPUInfo
(
qemuDomainGetMonitor
(
vm
)
,
&
cpupids
);
if
(
qemuDomainObjExitMonitor
(
driver
,
vm
)
<
0
)
{
if
(
qemuDomainObjExitMonitor
(
driver
,
vm
)
<
0
)
{
VIR_FREE
(
cpupids
)
;
ret
=
-
2
;
return
-
2
;
goto
cleanup
;
}
}
/* failure to get the VCPU <-> PID mapping or to execute the query
/* failure to get the VCPU <-> PID mapping or to execute the query
* command will not be treated fatal as some versions of qemu don't
* command will not be treated fatal as some versions of qemu don't
* support this command */
* support this command */
if
(
ncpupids
<=
0
)
{
if
(
ncpupids
<=
0
)
{
virResetLastError
();
virResetLastError
();
ncpupids
=
0
;
ret
=
0
;
goto
done
;
goto
cleanup
;
}
for
(
i
=
0
;
i
<
maxvcpus
;
i
++
)
{
vcpu
=
virDomainDefGetVcpu
(
vm
->
def
,
i
);
if
(
i
<
ncpupids
)
QEMU_DOMAIN_VCPU_PRIVATE
(
vcpu
)
->
tid
=
cpupids
[
i
];
else
QEMU_DOMAIN_VCPU_PRIVATE
(
vcpu
)
->
tid
=
0
;
}
}
if
(
ncpupids
!=
virDomainDefGetVcpus
(
vm
->
def
))
{
if
(
ncpupids
!=
virDomainDefGetVcpus
(
vm
->
def
))
{
...
@@ -5604,15 +5627,14 @@ qemuDomainDetectVcpuPids(virQEMUDriverPtr driver,
...
@@ -5604,15 +5627,14 @@ qemuDomainDetectVcpuPids(virQEMUDriverPtr driver,
_
(
"got wrong number of vCPU pids from QEMU monitor. "
_
(
"got wrong number of vCPU pids from QEMU monitor. "
"got %d, wanted %d"
),
"got %d, wanted %d"
),
ncpupids
,
virDomainDefGetVcpus
(
vm
->
def
));
ncpupids
,
virDomainDefGetVcpus
(
vm
->
def
));
VIR_FREE
(
cpupids
);
goto
cleanup
;
return
-
1
;
}
}
done:
ret
=
ncpupids
;
VIR_FREE
(
priv
->
vcpupids
);
priv
->
nvcpupids
=
ncpupids
;
cleanup:
priv
->
vcpupids
=
cpupids
;
VIR_FREE
(
cpupids
)
;
return
ncpupids
;
return
ret
;
}
}
...
...
src/qemu/qemu_domain.h
浏览文件 @
5184f398
...
@@ -184,9 +184,6 @@ struct _qemuDomainObjPrivate {
...
@@ -184,9 +184,6 @@ struct _qemuDomainObjPrivate {
bool
beingDestroyed
;
bool
beingDestroyed
;
char
*
pidfile
;
char
*
pidfile
;
int
nvcpupids
;
int
*
vcpupids
;
virDomainPCIAddressSetPtr
pciaddrs
;
virDomainPCIAddressSetPtr
pciaddrs
;
virDomainCCWAddressSetPtr
ccwaddrs
;
virDomainCCWAddressSetPtr
ccwaddrs
;
virDomainVirtioSerialAddrSetPtr
vioserialaddrs
;
virDomainVirtioSerialAddrSetPtr
vioserialaddrs
;
...
@@ -318,7 +315,7 @@ typedef qemuDomainVcpuPrivate *qemuDomainVcpuPrivatePtr;
...
@@ -318,7 +315,7 @@ typedef qemuDomainVcpuPrivate *qemuDomainVcpuPrivatePtr;
struct
_qemuDomainVcpuPrivate
{
struct
_qemuDomainVcpuPrivate
{
virObject
parent
;
virObject
parent
;
int
dummy
;
pid_t
tid
;
/* vcpu thread id */
};
};
# define QEMU_DOMAIN_VCPU_PRIVATE(vcpu) \
# define QEMU_DOMAIN_VCPU_PRIVATE(vcpu) \
...
@@ -649,7 +646,7 @@ int qemuDomainDefValidateMemoryHotplug(const virDomainDef *def,
...
@@ -649,7 +646,7 @@ int qemuDomainDefValidateMemoryHotplug(const virDomainDef *def,
const
virDomainMemoryDef
*
mem
);
const
virDomainMemoryDef
*
mem
);
bool
qemuDomainHasVcpuPids
(
virDomainObjPtr
vm
);
bool
qemuDomainHasVcpuPids
(
virDomainObjPtr
vm
);
pid_t
qemuDomainGetVcpuPid
(
virDomainObjPtr
vm
,
unsigned
int
vcpu
);
pid_t
qemuDomainGetVcpuPid
(
virDomainObjPtr
vm
,
unsigned
int
vcpu
id
);
int
qemuDomainDetectVcpuPids
(
virQEMUDriverPtr
driver
,
virDomainObjPtr
vm
,
int
qemuDomainDetectVcpuPids
(
virQEMUDriverPtr
driver
,
virDomainObjPtr
vm
,
int
asyncJob
);
int
asyncJob
);
...
...
src/qemu/qemu_process.c
浏览文件 @
5184f398
...
@@ -5899,8 +5899,6 @@ void qemuProcessStop(virQEMUDriverPtr driver,
...
@@ -5899,8 +5899,6 @@ void qemuProcessStop(virQEMUDriverPtr driver,
vm
->
taint
=
0
;
vm
->
taint
=
0
;
vm
->
pid
=
-
1
;
vm
->
pid
=
-
1
;
virDomainObjSetState
(
vm
,
VIR_DOMAIN_SHUTOFF
,
reason
);
virDomainObjSetState
(
vm
,
VIR_DOMAIN_SHUTOFF
,
reason
);
VIR_FREE
(
priv
->
vcpupids
);
priv
->
nvcpupids
=
0
;
for
(
i
=
0
;
i
<
vm
->
def
->
niothreadids
;
i
++
)
for
(
i
=
0
;
i
<
vm
->
def
->
niothreadids
;
i
++
)
vm
->
def
->
iothreadids
[
i
]
->
thread_id
=
0
;
vm
->
def
->
iothreadids
[
i
]
->
thread_id
=
0
;
virObjectUnref
(
priv
->
qemuCaps
);
virObjectUnref
(
priv
->
qemuCaps
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录