Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
94f59b9e
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,发现更多精彩内容 >>
提交
94f59b9e
编写于
1月 14, 2013
作者:
J
Jiri Denemark
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
qemu: Add support for compressed migration
上级
ecfff1da
变更
6
显示空白变更内容
内联
并排
Showing
6 changed file
with
243 addition
and
4 deletion
+243
-4
src/qemu/qemu_migration.c
src/qemu/qemu_migration.c
+56
-3
src/qemu/qemu_migration.h
src/qemu/qemu_migration.h
+2
-1
src/qemu/qemu_monitor.c
src/qemu/qemu_monitor.c
+46
-0
src/qemu/qemu_monitor.h
src/qemu/qemu_monitor.h
+13
-0
src/qemu/qemu_monitor_json.c
src/qemu/qemu_monitor_json.c
+121
-0
src/qemu/qemu_monitor_json.h
src/qemu/qemu_monitor_json.h
+5
-0
未找到文件。
src/qemu/qemu_migration.c
浏览文件 @
94f59b9e
...
...
@@ -1149,6 +1149,47 @@ qemuMigrationSetOffline(virQEMUDriverPtr driver,
}
static
int
qemuMigrationSetCompression
(
virQEMUDriverPtr
driver
,
virDomainObjPtr
vm
,
enum
qemuDomainAsyncJob
job
)
{
qemuDomainObjPrivatePtr
priv
=
vm
->
privateData
;
int
ret
;
if
(
qemuDomainObjEnterMonitorAsync
(
driver
,
vm
,
job
)
<
0
)
return
-
1
;
ret
=
qemuMonitorGetMigrationCapability
(
priv
->
mon
,
QEMU_MONITOR_MIGRATION_CAPS_XBZRLE
);
if
(
ret
<
0
)
{
goto
cleanup
;
}
else
if
(
ret
==
0
)
{
if
(
job
==
QEMU_ASYNC_JOB_MIGRATION_IN
)
{
virReportError
(
VIR_ERR_ARGUMENT_UNSUPPORTED
,
"%s"
,
_
(
"Compressed migration is not supported by "
"target QEMU binary"
));
}
else
{
virReportError
(
VIR_ERR_ARGUMENT_UNSUPPORTED
,
"%s"
,
_
(
"Compressed migration is not supported by "
"source QEMU binary"
));
}
ret
=
-
1
;
goto
cleanup
;
}
ret
=
qemuMonitorSetMigrationCapability
(
priv
->
mon
,
QEMU_MONITOR_MIGRATION_CAPS_XBZRLE
);
cleanup:
qemuDomainObjExitMonitor
(
driver
,
vm
);
return
ret
;
}
static
int
qemuMigrationUpdateJobStatus
(
virQEMUDriverPtr
driver
,
virDomainObjPtr
vm
,
...
...
@@ -1704,13 +1745,16 @@ qemuMigrationPrepareAny(virQEMUDriverPtr driver,
if
(
virFDStreamOpen
(
st
,
dataFD
[
1
])
<
0
)
{
virReportSystemError
(
errno
,
"%s"
,
_
(
"cannot pass pipe for tunnelled migration"
));
virDomainAuditStart
(
vm
,
"migrated"
,
false
);
qemuProcessStop
(
driver
,
vm
,
VIR_DOMAIN_SHUTOFF_FAILED
,
0
);
goto
endjob
;
goto
stop
;
}
dataFD
[
1
]
=
-
1
;
/* 'st' owns the FD now & will close it */
}
if
(
flags
&
VIR_MIGRATE_COMPRESSED
&&
qemuMigrationSetCompression
(
driver
,
vm
,
QEMU_ASYNC_JOB_MIGRATION_IN
)
<
0
)
goto
stop
;
if
(
mig
->
lockState
)
{
VIR_DEBUG
(
"Received lockstate %s"
,
mig
->
lockState
);
VIR_FREE
(
priv
->
lockState
);
...
...
@@ -1776,6 +1820,10 @@ cleanup:
virObjectUnref
(
caps
);
return
ret
;
stop:
virDomainAuditStart
(
vm
,
"migrated"
,
false
);
qemuProcessStop
(
driver
,
vm
,
VIR_DOMAIN_SHUTOFF_FAILED
,
0
);
endjob:
if
(
!
qemuMigrationJobFinish
(
driver
,
vm
))
{
vm
=
NULL
;
...
...
@@ -2255,6 +2303,11 @@ qemuMigrationRun(virQEMUDriverPtr driver,
goto
cleanup
;
}
if
(
flags
&
VIR_MIGRATE_COMPRESSED
&&
qemuMigrationSetCompression
(
driver
,
vm
,
QEMU_ASYNC_JOB_MIGRATION_OUT
)
<
0
)
goto
cleanup
;
if
(
qemuDomainObjEnterMonitorAsync
(
driver
,
vm
,
QEMU_ASYNC_JOB_MIGRATION_OUT
)
<
0
)
goto
cleanup
;
...
...
src/qemu/qemu_migration.h
浏览文件 @
94f59b9e
...
...
@@ -37,7 +37,8 @@
VIR_MIGRATE_NON_SHARED_INC | \
VIR_MIGRATE_CHANGE_PROTECTION | \
VIR_MIGRATE_UNSAFE | \
VIR_MIGRATE_OFFLINE)
VIR_MIGRATE_OFFLINE | \
VIR_MIGRATE_COMPRESSED)
enum
qemuMigrationJobPhase
{
QEMU_MIGRATION_PHASE_NONE
=
0
,
...
...
src/qemu/qemu_monitor.c
浏览文件 @
94f59b9e
...
...
@@ -101,6 +101,10 @@ VIR_ENUM_IMPL(qemuMonitorMigrationStatus,
QEMU_MONITOR_MIGRATION_STATUS_LAST
,
"inactive"
,
"active"
,
"completed"
,
"failed"
,
"cancelled"
)
VIR_ENUM_IMPL
(
qemuMonitorMigrationCaps
,
QEMU_MONITOR_MIGRATION_CAPS_LAST
,
"xbzrle"
)
VIR_ENUM_IMPL
(
qemuMonitorVMStatus
,
QEMU_MONITOR_VM_STATUS_LAST
,
"debug"
,
"inmigrate"
,
"internal-error"
,
"io-error"
,
"paused"
,
...
...
@@ -3383,3 +3387,45 @@ char *qemuMonitorGetTargetArch(qemuMonitorPtr mon)
return
qemuMonitorJSONGetTargetArch
(
mon
);
}
/**
* Returns 1 if @capability is supported, 0 if it's not, or -1 on error.
*/
int
qemuMonitorGetMigrationCapability
(
qemuMonitorPtr
mon
,
qemuMonitorMigrationCaps
capability
)
{
VIR_DEBUG
(
"mon=%p capability=%d"
,
mon
,
capability
);
if
(
!
mon
)
{
virReportError
(
VIR_ERR_INVALID_ARG
,
"%s"
,
_
(
"monitor must not be NULL"
));
return
-
1
;
}
/* No capability is supported without JSON monitor */
if
(
!
mon
->
json
)
return
0
;
return
qemuMonitorJSONGetMigrationCapability
(
mon
,
capability
);
}
int
qemuMonitorSetMigrationCapability
(
qemuMonitorPtr
mon
,
qemuMonitorMigrationCaps
capability
)
{
VIR_DEBUG
(
"mon=%p capability=%d"
,
mon
,
capability
);
if
(
!
mon
)
{
virReportError
(
VIR_ERR_INVALID_ARG
,
"%s"
,
_
(
"monitor must not be NULL"
));
return
-
1
;
}
if
(
!
mon
->
json
)
{
virReportError
(
VIR_ERR_OPERATION_UNSUPPORTED
,
"%s"
,
_
(
"JSON monitor is required"
));
return
-
1
;
}
return
qemuMonitorJSONSetMigrationCapability
(
mon
,
capability
);
}
src/qemu/qemu_monitor.h
浏览文件 @
94f59b9e
...
...
@@ -346,6 +346,19 @@ int qemuMonitorGetMigrationStatus(qemuMonitorPtr mon,
int
qemuMonitorGetSpiceMigrationStatus
(
qemuMonitorPtr
mon
,
bool
*
spice_migrated
);
typedef
enum
{
QEMU_MONITOR_MIGRATION_CAPS_XBZRLE
,
QEMU_MONITOR_MIGRATION_CAPS_LAST
}
qemuMonitorMigrationCaps
;
VIR_ENUM_DECL
(
qemuMonitorMigrationCaps
);
int
qemuMonitorGetMigrationCapability
(
qemuMonitorPtr
mon
,
qemuMonitorMigrationCaps
capability
);
int
qemuMonitorSetMigrationCapability
(
qemuMonitorPtr
mon
,
qemuMonitorMigrationCaps
capability
);
typedef
enum
{
QEMU_MONITOR_MIGRATE_BACKGROUND
=
1
<<
0
,
QEMU_MONITOR_MIGRATE_NON_SHARED_DISK
=
1
<<
1
,
/* migration with non-shared storage with full disk copy */
...
...
src/qemu/qemu_monitor_json.c
浏览文件 @
94f59b9e
...
...
@@ -4359,3 +4359,124 @@ cleanup:
virJSONValueFree
(
reply
);
return
ret
;
}
int
qemuMonitorJSONGetMigrationCapability
(
qemuMonitorPtr
mon
,
qemuMonitorMigrationCaps
capability
)
{
int
ret
;
virJSONValuePtr
cmd
;
virJSONValuePtr
reply
=
NULL
;
virJSONValuePtr
caps
;
int
i
;
if
(
!
(
cmd
=
qemuMonitorJSONMakeCommand
(
"query-migrate-capabilities"
,
NULL
)))
return
-
1
;
ret
=
qemuMonitorJSONCommand
(
mon
,
cmd
,
&
reply
);
if
(
ret
==
0
)
{
if
(
qemuMonitorJSONHasError
(
reply
,
"CommandNotFound"
))
goto
cleanup
;
ret
=
qemuMonitorJSONCheckError
(
cmd
,
reply
);
}
if
(
ret
<
0
)
goto
cleanup
;
ret
=
-
1
;
caps
=
virJSONValueObjectGet
(
reply
,
"return"
);
if
(
!
caps
||
caps
->
type
!=
VIR_JSON_TYPE_ARRAY
)
{
virReportError
(
VIR_ERR_INTERNAL_ERROR
,
"%s"
,
_
(
"missing migration capabilities"
));
goto
cleanup
;
}
for
(
i
=
0
;
i
<
virJSONValueArraySize
(
caps
);
i
++
)
{
virJSONValuePtr
cap
=
virJSONValueArrayGet
(
caps
,
i
);
const
char
*
name
;
if
(
!
cap
||
cap
->
type
!=
VIR_JSON_TYPE_OBJECT
)
{
virReportError
(
VIR_ERR_INTERNAL_ERROR
,
"%s"
,
_
(
"missing entry in migration capabilities list"
));
goto
cleanup
;
}
if
(
!
(
name
=
virJSONValueObjectGetString
(
cap
,
"capability"
)))
{
virReportError
(
VIR_ERR_INTERNAL_ERROR
,
"%s"
,
_
(
"missing migration capability name"
));
goto
cleanup
;
}
if
(
qemuMonitorMigrationCapsTypeFromString
(
name
)
==
capability
)
{
ret
=
1
;
goto
cleanup
;
}
}
ret
=
0
;
cleanup:
virJSONValueFree
(
cmd
);
virJSONValueFree
(
reply
);
return
ret
;
}
int
qemuMonitorJSONSetMigrationCapability
(
qemuMonitorPtr
mon
,
qemuMonitorMigrationCaps
capability
)
{
int
ret
=
-
1
;
virJSONValuePtr
cmd
=
NULL
;
virJSONValuePtr
reply
=
NULL
;
virJSONValuePtr
cap
=
NULL
;
virJSONValuePtr
caps
;
if
(
!
(
caps
=
virJSONValueNewArray
()))
goto
cleanup
;
if
(
!
(
cap
=
virJSONValueNewObject
()))
goto
no_memory
;
if
(
virJSONValueObjectAppendString
(
cap
,
"capability"
,
qemuMonitorMigrationCapsTypeToString
(
capability
))
<
0
)
goto
no_memory
;
if
(
virJSONValueObjectAppendBoolean
(
cap
,
"state"
,
1
)
<
0
)
goto
no_memory
;
if
(
virJSONValueArrayAppend
(
caps
,
cap
)
<
0
)
goto
no_memory
;
cap
=
NULL
;
cmd
=
qemuMonitorJSONMakeCommand
(
"migrate-set-capabilities"
,
"a:capabilities"
,
caps
,
NULL
);
if
(
!
cmd
)
goto
cleanup
;
caps
=
NULL
;
if
((
ret
=
qemuMonitorJSONCommand
(
mon
,
cmd
,
&
reply
))
<
0
)
goto
cleanup
;
ret
=
qemuMonitorJSONCheckError
(
cmd
,
reply
);
cleanup:
virJSONValueFree
(
caps
);
virJSONValueFree
(
cap
);
virJSONValueFree
(
cmd
);
virJSONValueFree
(
reply
);
return
ret
;
no_memory:
virReportOOMError
();
goto
cleanup
;
}
src/qemu/qemu_monitor_json.h
浏览文件 @
94f59b9e
...
...
@@ -126,6 +126,11 @@ int qemuMonitorJSONGetMigrationStatus(qemuMonitorPtr mon,
unsigned
long
long
*
remaining
,
unsigned
long
long
*
total
);
int
qemuMonitorJSONGetMigrationCapability
(
qemuMonitorPtr
mon
,
qemuMonitorMigrationCaps
capability
);
int
qemuMonitorJSONSetMigrationCapability
(
qemuMonitorPtr
mon
,
qemuMonitorMigrationCaps
capability
);
int
qemuMonitorJSONMigrate
(
qemuMonitorPtr
mon
,
unsigned
int
flags
,
const
char
*
uri
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录