Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
0aa19f35
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看板
提交
0aa19f35
编写于
5月 23, 2016
作者:
P
Peter Krempa
1
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
qemu: hotplug: Extract code for waiting for tray eject
The code grew rather convoluted. Extract it to a separate function.
上级
894dc85f
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
46 addition
and
39 deletion
+46
-39
src/qemu/qemu_hotplug.c
src/qemu/qemu_hotplug.c
+46
-39
未找到文件。
src/qemu/qemu_hotplug.c
浏览文件 @
0aa19f35
...
...
@@ -145,6 +145,40 @@ qemuDomainPrepareDisk(virQEMUDriverPtr driver,
}
static
int
qemuHotplugWaitForTrayEject
(
virQEMUDriverPtr
driver
,
virDomainObjPtr
vm
,
virDomainDiskDefPtr
disk
,
const
char
*
driveAlias
,
bool
force
)
{
unsigned
long
long
now
;
int
rc
;
if
(
virTimeMillisNow
(
&
now
)
<
0
)
return
-
1
;
while
(
disk
->
tray_status
!=
VIR_DOMAIN_DISK_TRAY_OPEN
)
{
if
((
rc
=
virDomainObjWaitUntil
(
vm
,
now
+
CHANGE_MEDIA_TIMEOUT
))
<
0
)
return
-
1
;
if
(
rc
>
0
)
{
virReportError
(
VIR_ERR_INTERNAL_ERROR
,
"%s"
,
_
(
"timed out waiting for disk tray status update"
));
return
-
1
;
}
}
/* re-issue ejection command to pop out the media */
qemuDomainObjEnterMonitor
(
driver
,
vm
);
rc
=
qemuMonitorEjectMedia
(
qemuDomainGetMonitor
(
vm
),
driveAlias
,
force
);
if
(
qemuDomainObjExitMonitor
(
driver
,
vm
)
<
0
||
rc
<
0
)
return
-
1
;
return
0
;
}
/**
* qemuDomainChangeEjectableMedia:
* @driver: qemu driver structure
...
...
@@ -172,8 +206,6 @@ qemuDomainChangeEjectableMedia(virQEMUDriverPtr driver,
qemuDomainObjPrivatePtr
priv
=
vm
->
privateData
;
const
char
*
format
=
NULL
;
char
*
sourcestr
=
NULL
;
bool
ejectRetry
=
false
;
unsigned
long
long
now
;
if
(
!
disk
->
info
.
alias
)
{
virReportError
(
VIR_ERR_INTERNAL_ERROR
,
...
...
@@ -195,45 +227,20 @@ qemuDomainChangeEjectableMedia(virQEMUDriverPtr driver,
if
(
!
(
driveAlias
=
qemuDeviceDriveHostAlias
(
disk
)))
goto
error
;
do
{
qemuDomainObjEnterMonitor
(
driver
,
vm
);
rc
=
qemuMonitorEjectMedia
(
priv
->
mon
,
driveAlias
,
force
);
if
(
qemuDomainObjExitMonitor
(
driver
,
vm
)
<
0
)
goto
cleanup
;
/* skip all retrying if qemu doesn't notify us on tray change */
if
(
!
virQEMUCapsGet
(
priv
->
qemuCaps
,
QEMU_CAPS_DEVICE_TRAY_MOVED
))
{
if
(
rc
==
0
)
break
;
if
(
rc
<
0
)
goto
error
;
}
if
(
rc
<
0
)
{
/* we've already tried, error out */
if
(
ejectRetry
)
goto
error
;
ejectRetry
=
true
;
VIR_DEBUG
(
"tray may be locked, wait for the guest to unlock "
"the tray and try to eject it again"
);
}
qemuDomainObjEnterMonitor
(
driver
,
vm
);
rc
=
qemuMonitorEjectMedia
(
priv
->
mon
,
driveAlias
,
force
);
if
(
qemuDomainObjExitMonitor
(
driver
,
vm
)
<
0
)
goto
cleanup
;
if
(
virTimeMillisNow
(
&
now
)
<
0
)
/* If the tray change event is supported wait for it to open. */
if
(
virQEMUCapsGet
(
priv
->
qemuCaps
,
QEMU_CAPS_DEVICE_TRAY_MOVED
))
{
if
(
qemuHotplugWaitForTrayEject
(
driver
,
vm
,
disk
,
driveAlias
,
force
)
<
0
)
goto
error
;
while
(
disk
->
tray_status
!=
VIR_DOMAIN_DISK_TRAY_OPEN
)
{
int
wait_rc
=
virDomainObjWaitUntil
(
vm
,
now
+
CHANGE_MEDIA_TIMEOUT
);
if
(
wait_rc
>
0
)
{
virReportError
(
VIR_ERR_INTERNAL_ERROR
,
"%s"
,
_
(
"timed out waiting for "
"disk tray status update"
));
}
if
(
wait_rc
!=
0
)
goto
error
;
}
}
while
(
rc
<
0
);
}
else
{
/* otherwise report possible errors from the attempt to eject the media*/
if
(
rc
<
0
)
goto
error
;
}
if
(
!
virStorageSourceIsEmpty
(
newsrc
))
{
qemuDomainDiskPrivatePtr
diskPriv
=
QEMU_DOMAIN_DISK_PRIVATE
(
disk
);
...
...
tester丶
🤺
@ssszwink
mentioned in commit
49f05e04
·
9月 10, 2020
mentioned in commit
49f05e04
mentioned in commit 49f05e044359bb43c3aa79e464285cce4ff44a4c
开关提交列表
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录