Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
15fa84ac
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,体验更适合开发者的 AI 搜索 >>
提交
15fa84ac
编写于
6月 23, 2015
作者:
P
Peter Krempa
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
qemu: Refactor qemuDomainGetBlockInfo
Change the code so that it queries the monitor when the VM is alive.
上级
0d130a01
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
53 addition
and
37 deletion
+53
-37
src/qemu/qemu_driver.c
src/qemu/qemu_driver.c
+53
-37
未找到文件。
src/qemu/qemu_driver.c
浏览文件 @
15fa84ac
...
...
@@ -11800,10 +11800,12 @@ qemuDomainGetBlockInfo(virDomainPtr dom,
virQEMUDriverPtr driver = dom->conn->privateData;
virDomainObjPtr vm;
int ret = -1;
virDomainDiskDefPtr disk = NULL;
virStorageSourcePtr src;
bool activeFail = false;
virDomainDiskDefPtr disk;
virQEMUDriverConfigPtr cfg = NULL;
int rc;
virHashTablePtr stats = NULL;
qemuBlockStats *entry;
char *alias;
virCheckFlags(0, -1);
...
...
@@ -11815,11 +11817,6 @@ qemuDomainGetBlockInfo(virDomainPtr dom,
if (virDomainGetBlockInfoEnsureACL(dom->conn, vm->def) < 0)
goto cleanup;
/* Technically, we only need a job if we are going to query the
* monitor, which is only for active domains that are using
* non-raw block devices. But it is easier to share code if we
* always grab a job; furthermore, grabbing the job ensures that
* hot-plug won't change disk behind our backs. */
if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_QUERY) < 0)
goto cleanup;
...
...
@@ -11829,53 +11826,72 @@ qemuDomainGetBlockInfo(virDomainPtr dom,
goto endjob;
}
src = disk->src;
if (virStorageSourceIsEmpty(src)) {
if (virStorageSourceIsEmpty(disk->src)) {
virReportError(VIR_ERR_INVALID_ARG,
_("disk '%s' does not currently have a source assigned"),
path);
goto endjob;
}
if ((ret = qemuStorageLimitsRefresh(driver, cfg, vm, src)) < 0)
/* for inactive domains we have to peek into the files */
if (!virDomainObjIsActive(vm)) {
if ((qemuStorageLimitsRefresh(driver, cfg, vm, disk->src)) < 0)
goto endjob;
info->capacity = disk->src->capacity;
info->allocation = disk->src->allocation;
info->physical = disk->src->physical;
ret = 0;
goto endjob;
}
if (!disk->info.alias ||
!(alias = qemuDomainStorageAlias(disk->info.alias, 0))) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("missing disk device alias name for %s"), disk->dst);
goto endjob;
}
if (!src->allocation) {
qemuDomainObjPrivatePtr priv = vm->privateData;
qemuDomainObjEnterMonitor(driver, vm);
rc = qemuMonitorGetAllBlockStatsInfo(qemuDomainGetMonitor(vm),
&stats, false);
if (rc >= 0)
rc = qemuMonitorBlockStatsUpdateCapacity(qemuDomainGetMonitor(vm),
stats, false);
/* If the guest is not running, then success/failure return
* depends on whether domain is persistent
*/
if (!virDomainObjIsActive(vm)) {
activeFail = true;
if (qemuDomainObjExitMonitor(driver, vm) < 0 || rc < 0)
goto endjob;
if (!(entry = virHashLookup(stats, alias))) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("failed to gather stats for disk '%s'"), disk->dst);
goto endjob;
}
if (!entry->wr_highest_offset_valid) {
if (virStorageSourceGetActualType(disk->src) == VIR_STORAGE_TYPE_BLOCK &&
disk->src->format != VIR_STORAGE_FILE_RAW) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("failed to query the maximum written offset of "
"block device '%s'"), disk->dst);
goto endjob;
}
qemuDomainObjEnterMonitor(driver, vm);
ret = qemuMonitorGetBlockExtent(priv->mon,
disk->info.alias,
&src->allocation);
if (qemuDomainObjExitMonitor(driver, vm) < 0)
ret = -1;
info->allocation = entry->physical;
} else {
info->allocation = entry->wr_highest_offset;
}
if (ret == 0) {
info->capacity = src->capacity;
info->allocation = src->allocation;
info->physical = src->physical;
}
info->capacity = entry->capacity;
info->physical = entry->physical;
ret = 0;
endjob:
qemuDomainObjEndJob(driver, vm);
cleanup:
/* If we failed to get data from a domain because it's inactive and
* it's not a persistent domain, then force failure.
*/
if (activeFail && vm && !vm->persistent) {
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
_("domain is not running"));
ret = -1;
}
virHashFree(stats);
virDomainObjEndAPI(&vm);
virObjectUnref(cfg);
return ret;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录