Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
9b4654f6
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,发现更多精彩内容 >>
提交
9b4654f6
编写于
10月 13, 2014
作者:
P
Peter Krempa
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
qemu: Implement memory device hotplug
Add code to hot-add memory devices to running qemu instances.
上级
96094fb2
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
120 addition
and
3 deletion
+120
-3
src/qemu/qemu_command.c
src/qemu/qemu_command.c
+2
-2
src/qemu/qemu_command.h
src/qemu/qemu_command.h
+15
-0
src/qemu/qemu_driver.c
src/qemu/qemu_driver.c
+5
-1
src/qemu/qemu_hotplug.c
src/qemu/qemu_hotplug.c
+95
-0
src/qemu/qemu_hotplug.h
src/qemu/qemu_hotplug.h
+3
-0
未找到文件。
src/qemu/qemu_command.c
浏览文件 @
9b4654f6
...
@@ -4599,7 +4599,7 @@ qemuBuildControllerDevStr(virDomainDefPtr domainDef,
...
@@ -4599,7 +4599,7 @@ qemuBuildControllerDevStr(virDomainDefPtr domainDef,
* other configuration was used (to detect legacy configurations). Returns
* other configuration was used (to detect legacy configurations). Returns
* -1 in case of an error.
* -1 in case of an error.
*/
*/
static
int
int
qemuBuildMemoryBackendStr
(
unsigned
long
long
size
,
qemuBuildMemoryBackendStr
(
unsigned
long
long
size
,
unsigned
long
long
pagesize
,
unsigned
long
long
pagesize
,
int
guestNode
,
int
guestNode
,
...
@@ -4873,7 +4873,7 @@ qemuBuildMemoryDimmBackendStr(virDomainMemoryDefPtr mem,
...
@@ -4873,7 +4873,7 @@ qemuBuildMemoryDimmBackendStr(virDomainMemoryDefPtr mem,
}
}
static
char
*
char
*
qemuBuildMemoryDeviceStr
(
virDomainMemoryDefPtr
mem
,
qemuBuildMemoryDeviceStr
(
virDomainMemoryDefPtr
mem
,
virQEMUCapsPtr
qemuCaps
)
virQEMUCapsPtr
qemuCaps
)
{
{
...
...
src/qemu/qemu_command.h
浏览文件 @
9b4654f6
...
@@ -162,6 +162,21 @@ char *qemuBuildSoundDevStr(virDomainDefPtr domainDef,
...
@@ -162,6 +162,21 @@ char *qemuBuildSoundDevStr(virDomainDefPtr domainDef,
virDomainSoundDefPtr
sound
,
virDomainSoundDefPtr
sound
,
virQEMUCapsPtr
qemuCaps
);
virQEMUCapsPtr
qemuCaps
);
int
qemuBuildMemoryBackendStr
(
unsigned
long
long
size
,
unsigned
long
long
pagesize
,
int
guestNode
,
virBitmapPtr
userNodeset
,
virBitmapPtr
autoNodeset
,
virDomainDefPtr
def
,
virQEMUCapsPtr
qemuCaps
,
virQEMUDriverConfigPtr
cfg
,
const
char
**
backendType
,
virJSONValuePtr
*
backendProps
,
bool
force
);
char
*
qemuBuildMemoryDeviceStr
(
virDomainMemoryDefPtr
mem
,
virQEMUCapsPtr
qemuCaps
);
/* Legacy, pre device support */
/* Legacy, pre device support */
char
*
qemuBuildPCIHostdevPCIDevStr
(
virDomainHostdevDefPtr
dev
,
char
*
qemuBuildPCIHostdevPCIDevStr
(
virDomainHostdevDefPtr
dev
,
virQEMUCapsPtr
qemuCaps
);
virQEMUCapsPtr
qemuCaps
);
...
...
src/qemu/qemu_driver.c
浏览文件 @
9b4654f6
...
@@ -7656,8 +7656,12 @@ qemuDomainAttachDeviceLive(virDomainObjPtr vm,
...
@@ -7656,8 +7656,12 @@ qemuDomainAttachDeviceLive(virDomainObjPtr vm,
dev->data.rng = NULL;
dev->data.rng = NULL;
break;
break;
/*TODO: implement later */
case VIR_DOMAIN_DEVICE_MEMORY:
case VIR_DOMAIN_DEVICE_MEMORY:
/* note that qemuDomainAttachMemory always consumes dev->data.memory */
ret = qemuDomainAttachMemory(driver, vm,
dev->data.memory);
dev->data.memory = NULL;
break;
case VIR_DOMAIN_DEVICE_NONE:
case VIR_DOMAIN_DEVICE_NONE:
case VIR_DOMAIN_DEVICE_FS:
case VIR_DOMAIN_DEVICE_FS:
...
...
src/qemu/qemu_hotplug.c
浏览文件 @
9b4654f6
...
@@ -1680,6 +1680,101 @@ qemuDomainAttachRNGDevice(virQEMUDriverPtr driver,
...
@@ -1680,6 +1680,101 @@ qemuDomainAttachRNGDevice(virQEMUDriverPtr driver,
}
}
/**
* qemuDomainAttachMemory:
* @driver: qemu driver data
* @vm: VM object
* @mem: Definition of the memory device to be attached. @mem is always consumed
*
* Attaches memory device described by @mem to domain @vm.
*
* Returns 0 on success -1 on error.
*/
int
qemuDomainAttachMemory
(
virQEMUDriverPtr
driver
,
virDomainObjPtr
vm
,
virDomainMemoryDefPtr
mem
)
{
qemuDomainObjPrivatePtr
priv
=
vm
->
privateData
;
virQEMUDriverConfigPtr
cfg
=
virQEMUDriverGetConfig
(
driver
);
char
*
devstr
=
NULL
;
char
*
objalias
=
NULL
;
const
char
*
backendType
;
virJSONValuePtr
props
=
NULL
;
int
id
;
int
ret
=
-
1
;
if
(
virAsprintf
(
&
mem
->
info
.
alias
,
"dimm%zu"
,
vm
->
def
->
nmems
)
<
0
)
goto
cleanup
;
if
(
virAsprintf
(
&
objalias
,
"mem%s"
,
mem
->
info
.
alias
)
<
0
)
goto
cleanup
;
if
(
!
(
devstr
=
qemuBuildMemoryDeviceStr
(
mem
,
priv
->
qemuCaps
)))
goto
cleanup
;
qemuDomainMemoryDeviceAlignSize
(
mem
);
if
(
qemuBuildMemoryBackendStr
(
mem
->
size
,
mem
->
pagesize
,
mem
->
targetNode
,
mem
->
sourceNodes
,
NULL
,
vm
->
def
,
priv
->
qemuCaps
,
cfg
,
&
backendType
,
&
props
,
true
)
<
0
)
goto
cleanup
;
if
(
virDomainMemoryInsert
(
vm
->
def
,
mem
)
<
0
)
{
virJSONValueFree
(
props
);
goto
cleanup
;
}
qemuDomainObjEnterMonitor
(
driver
,
vm
);
if
(
qemuMonitorAddObject
(
priv
->
mon
,
backendType
,
objalias
,
props
)
<
0
)
goto
removedef
;
if
(
qemuMonitorAddDevice
(
priv
->
mon
,
devstr
)
<
0
)
{
virErrorPtr
err
=
virSaveLastError
();
ignore_value
(
qemuMonitorDelObject
(
priv
->
mon
,
objalias
));
virSetError
(
err
);
virFreeError
(
err
);
goto
removedef
;
}
if
(
qemuDomainObjExitMonitor
(
driver
,
vm
)
<
0
)
{
/* we shouldn't touch mem now, as the def might be freed */
mem
=
NULL
;
goto
cleanup
;
}
/* mem is consumed by vm->def */
mem
=
NULL
;
/* this step is best effort, removing the device would be so much trouble */
ignore_value
(
qemuDomainUpdateMemoryDeviceInfo
(
driver
,
vm
,
QEMU_ASYNC_JOB_NONE
));
ret
=
0
;
cleanup:
virObjectUnref
(
cfg
);
VIR_FREE
(
devstr
);
VIR_FREE
(
objalias
);
virDomainMemoryDefFree
(
mem
);
return
ret
;
removedef:
if
(
qemuDomainObjExitMonitor
(
driver
,
vm
)
<
0
)
{
mem
=
NULL
;
goto
cleanup
;
}
if
((
id
=
virDomainMemoryFindByDef
(
vm
->
def
,
mem
))
>=
0
)
mem
=
virDomainMemoryRemove
(
vm
->
def
,
id
);
else
mem
=
NULL
;
goto
cleanup
;
}
static
int
static
int
qemuDomainAttachHostUSBDevice
(
virQEMUDriverPtr
driver
,
qemuDomainAttachHostUSBDevice
(
virQEMUDriverPtr
driver
,
virDomainObjPtr
vm
,
virDomainObjPtr
vm
,
...
...
src/qemu/qemu_hotplug.h
浏览文件 @
9b4654f6
...
@@ -57,6 +57,9 @@ int qemuDomainAttachHostDevice(virConnectPtr conn,
...
@@ -57,6 +57,9 @@ int qemuDomainAttachHostDevice(virConnectPtr conn,
virDomainHostdevDefPtr
hostdev
);
virDomainHostdevDefPtr
hostdev
);
int
qemuDomainFindGraphicsIndex
(
virDomainDefPtr
def
,
int
qemuDomainFindGraphicsIndex
(
virDomainDefPtr
def
,
virDomainGraphicsDefPtr
dev
);
virDomainGraphicsDefPtr
dev
);
int
qemuDomainAttachMemory
(
virQEMUDriverPtr
driver
,
virDomainObjPtr
vm
,
virDomainMemoryDefPtr
mem
);
int
qemuDomainChangeGraphics
(
virQEMUDriverPtr
driver
,
int
qemuDomainChangeGraphics
(
virQEMUDriverPtr
driver
,
virDomainObjPtr
vm
,
virDomainObjPtr
vm
,
virDomainGraphicsDefPtr
dev
);
virDomainGraphicsDefPtr
dev
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录