Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
qemu
提交
5cec2870
Q
qemu
项目概览
openeuler
/
qemu
通知
10
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Q
qemu
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
5cec2870
编写于
3月 02, 2019
作者:
K
Kevin Wolf
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
file-posix: Factor out raw_reconfigure_getfd()
Signed-off-by:
N
Kevin Wolf
<
kwolf@redhat.com
>
上级
30855137
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
62 addition
and
45 deletion
+62
-45
block/file-posix.c
block/file-posix.c
+62
-45
未找到文件。
block/file-posix.c
浏览文件 @
5cec2870
...
...
@@ -842,6 +842,62 @@ static int raw_handle_perm_lock(BlockDriverState *bs,
return
ret
;
}
static
int
raw_reconfigure_getfd
(
BlockDriverState
*
bs
,
int
flags
,
int
*
open_flags
,
Error
**
errp
)
{
BDRVRawState
*
s
=
bs
->
opaque
;
int
fd
=
-
1
;
int
ret
;
int
fcntl_flags
=
O_APPEND
|
O_NONBLOCK
;
#ifdef O_NOATIME
fcntl_flags
|=
O_NOATIME
;
#endif
*
open_flags
=
0
;
if
(
s
->
type
==
FTYPE_CD
)
{
*
open_flags
|=
O_NONBLOCK
;
}
raw_parse_flags
(
flags
,
open_flags
);
#ifdef O_ASYNC
/* Not all operating systems have O_ASYNC, and those that don't
* will not let us track the state into rs->open_flags (typically
* you achieve the same effect with an ioctl, for example I_SETSIG
* on Solaris). But we do not use O_ASYNC, so that's fine.
*/
assert
((
s
->
open_flags
&
O_ASYNC
)
==
0
);
#endif
if
((
*
open_flags
&
~
fcntl_flags
)
==
(
s
->
open_flags
&
~
fcntl_flags
))
{
/* dup the original fd */
fd
=
qemu_dup
(
s
->
fd
);
if
(
fd
>=
0
)
{
ret
=
fcntl_setfl
(
fd
,
*
open_flags
);
if
(
ret
)
{
qemu_close
(
fd
);
fd
=
-
1
;
}
}
}
/* If we cannot use fcntl, or fcntl failed, fall back to qemu_open() */
if
(
fd
==
-
1
)
{
const
char
*
normalized_filename
=
bs
->
filename
;
ret
=
raw_normalize_devicepath
(
&
normalized_filename
,
errp
);
if
(
ret
>=
0
)
{
assert
(
!
(
*
open_flags
&
O_CREAT
));
fd
=
qemu_open
(
normalized_filename
,
*
open_flags
);
if
(
fd
==
-
1
)
{
error_setg_errno
(
errp
,
errno
,
"Could not reopen file"
);
return
-
1
;
}
}
}
return
fd
;
}
static
int
raw_reopen_prepare
(
BDRVReopenState
*
state
,
BlockReopenQueue
*
queue
,
Error
**
errp
)
{
...
...
@@ -858,7 +914,6 @@ static int raw_reopen_prepare(BDRVReopenState *state,
state
->
opaque
=
g_new0
(
BDRVRawReopenState
,
1
);
rs
=
state
->
opaque
;
rs
->
fd
=
-
1
;
/* Handle options changes */
opts
=
qemu_opts_create
(
&
raw_runtime_opts
,
NULL
,
0
,
&
error_abort
);
...
...
@@ -877,50 +932,12 @@ static int raw_reopen_prepare(BDRVReopenState *state,
* bdrv_reopen_prepare() will detect changes and complain. */
qemu_opts_to_qdict
(
opts
,
state
->
options
);
if
(
s
->
type
==
FTYPE_CD
)
{
rs
->
open_flags
|=
O_NONBLOCK
;
}
raw_parse_flags
(
state
->
flags
,
&
rs
->
open_flags
);
int
fcntl_flags
=
O_APPEND
|
O_NONBLOCK
;
#ifdef O_NOATIME
fcntl_flags
|=
O_NOATIME
;
#endif
#ifdef O_ASYNC
/* Not all operating systems have O_ASYNC, and those that don't
* will not let us track the state into rs->open_flags (typically
* you achieve the same effect with an ioctl, for example I_SETSIG
* on Solaris). But we do not use O_ASYNC, so that's fine.
*/
assert
((
s
->
open_flags
&
O_ASYNC
)
==
0
);
#endif
if
((
rs
->
open_flags
&
~
fcntl_flags
)
==
(
s
->
open_flags
&
~
fcntl_flags
))
{
/* dup the original fd */
rs
->
fd
=
qemu_dup
(
s
->
fd
);
if
(
rs
->
fd
>=
0
)
{
ret
=
fcntl_setfl
(
rs
->
fd
,
rs
->
open_flags
);
if
(
ret
)
{
qemu_close
(
rs
->
fd
);
rs
->
fd
=
-
1
;
}
}
}
/* If we cannot use fcntl, or fcntl failed, fall back to qemu_open() */
if
(
rs
->
fd
==
-
1
)
{
const
char
*
normalized_filename
=
state
->
bs
->
filename
;
ret
=
raw_normalize_devicepath
(
&
normalized_filename
,
errp
);
if
(
ret
>=
0
)
{
assert
(
!
(
rs
->
open_flags
&
O_CREAT
));
rs
->
fd
=
qemu_open
(
normalized_filename
,
rs
->
open_flags
);
if
(
rs
->
fd
==
-
1
)
{
error_setg_errno
(
errp
,
errno
,
"Could not reopen file"
);
ret
=
-
1
;
}
}
rs
->
fd
=
raw_reconfigure_getfd
(
state
->
bs
,
state
->
flags
,
&
rs
->
open_flags
,
&
local_err
);
if
(
local_err
)
{
error_propagate
(
errp
,
local_err
);
ret
=
-
1
;
goto
out
;
}
/* Fail already reopen_prepare() if we can't get a working O_DIRECT
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录