Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
383ae8c4
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看板
提交
383ae8c4
编写于
8月 14, 2007
作者:
D
Daniel P. Berrange
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added qemudEscapeShellArg(), and saferead()/safewrite() APIs
上级
79a37542
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
116 addition
and
2 deletion
+116
-2
ChangeLog
ChangeLog
+11
-2
src/qemu_driver.c
src/qemu_driver.c
+66
-0
src/util.c
src/util.c
+37
-0
src/util.h
src/util.h
+2
-0
未找到文件。
ChangeLog
浏览文件 @
383ae8c4
Mon Aug 13 21:33:48 EST 2007 Daniel P. Berrange <berrange@redhat.com>
* src/qemu_driver.c: added qemudEscapeShellArg() helper function
for future save impl. Patch from Jim Paris
* src/util.c, src/util.h: Added saferead/safewrite convenience
functions for doing read/write safe from signals. Patch from
Jim Paris
Mon Aug 13 21:26:48 EST 2007 Daniel P. Berrange <berrange@redhat.com>
* src/qemu_conf.c, src/qemu_conf.h, src/qemu_driver.c: Add support
for passing -incoming option to QEMU for migration/restore.
for passing -incoming option to QEMU for migration/restore. Patch
from Jim Paris
Mon Aug 13 21:18:48 EST 2007 Daniel P. Berrange <berrange@redhat.com>
* src/util.h, src/util.c: Allow a file descriptor to be supplied
for STDIN when calling virExec(), or if -1, redirect from /dev/null
* src/qemu_driver.c, src/openvz_driver.c: Pass in -1 for new stdin
parameter above where neccessary
parameter above where neccessary
. Patch from Jim Paris
Mon Aug 13 20:13:48 EST 2007 Daniel P. Berrange <berrange@redhat.com>
...
...
src/qemu_driver.c
浏览文件 @
383ae8c4
...
...
@@ -1855,6 +1855,72 @@ static int qemudDomainGetInfo(virDomainPtr dom,
}
static
char
*
qemudEscapeShellArg
(
const
char
*
in
)
{
int
len
=
0
;
int
i
,
j
;
char
*
out
;
/* To pass through the QEMU monitor, we need to use escape
sequences: \r, \n, \", \\
To pass through both QEMU + the shell, we need to escape
the single character ' as the five characters '\\''
*/
for
(
i
=
0
;
in
[
i
]
!=
'\0'
;
i
++
)
{
switch
(
in
[
i
])
{
case
'\r'
:
case
'\n'
:
case
'"'
:
case
'\\'
:
len
+=
2
;
break
;
case
'\''
:
len
+=
5
;
break
;
default:
len
+=
1
;
break
;
}
}
if
((
out
=
(
char
*
)
malloc
(
len
+
1
))
==
NULL
)
return
NULL
;
for
(
i
=
j
=
0
;
in
[
i
]
!=
'\0'
;
i
++
)
{
switch
(
in
[
i
])
{
case
'\r'
:
out
[
j
++
]
=
'\\'
;
out
[
j
++
]
=
'r'
;
break
;
case
'\n'
:
out
[
j
++
]
=
'\\'
;
out
[
j
++
]
=
'n'
;
break
;
case
'"'
:
case
'\\'
:
out
[
j
++
]
=
'\\'
;
out
[
j
++
]
=
in
[
i
];
break
;
case
'\''
:
out
[
j
++
]
=
'\''
;
out
[
j
++
]
=
'\\'
;
out
[
j
++
]
=
'\\'
;
out
[
j
++
]
=
'\''
;
out
[
j
++
]
=
'\''
;
break
;
default:
out
[
j
++
]
=
in
[
i
];
break
;
}
}
out
[
j
]
=
'\0'
;
return
out
;
}
static
int
qemudDomainSave
(
virDomainPtr
dom
,
const
char
*
path
ATTRIBUTE_UNUSED
)
{
struct
qemud_driver
*
driver
=
(
struct
qemud_driver
*
)
dom
->
conn
->
privateData
;
...
...
src/util.c
浏览文件 @
383ae8c4
...
...
@@ -189,3 +189,40 @@ virExecNonBlock(virConnectPtr conn,
return
(
_virExec
(
conn
,
argv
,
retpid
,
infd
,
outfd
,
errfd
,
1
));
}
/* Like read(), but restarts after EINTR */
int
saferead
(
int
fd
,
void
*
buf
,
size_t
count
)
{
size_t
nread
=
0
;
while
(
count
>
0
)
{
int
r
=
read
(
fd
,
buf
,
count
);
if
(
r
<
0
&&
errno
==
EINTR
)
continue
;
if
(
r
<
0
)
return
r
;
if
(
r
==
0
)
return
nread
;
buf
=
(
unsigned
char
*
)
buf
+
r
;
count
-=
r
;
nread
+=
r
;
}
return
nread
;
}
/* Like write(), but restarts after EINTR */
ssize_t
safewrite
(
int
fd
,
const
void
*
buf
,
size_t
count
)
{
size_t
nwritten
=
0
;
while
(
count
>
0
)
{
int
r
=
write
(
fd
,
buf
,
count
);
if
(
r
<
0
&&
errno
==
EINTR
)
continue
;
if
(
r
<
0
)
return
r
;
if
(
r
==
0
)
return
nwritten
;
buf
=
(
unsigned
char
*
)
buf
+
r
;
count
-=
r
;
nwritten
+=
r
;
}
return
nwritten
;
}
src/util.h
浏览文件 @
383ae8c4
...
...
@@ -24,3 +24,5 @@
int
virExec
(
virConnectPtr
conn
,
char
**
argv
,
int
*
retpid
,
int
infd
,
int
*
outfd
,
int
*
errfd
);
int
virExecNonBlock
(
virConnectPtr
conn
,
char
**
argv
,
int
*
retpid
,
int
infd
,
int
*
outfd
,
int
*
errfd
);
int
saferead
(
int
fd
,
void
*
buf
,
size_t
count
);
ssize_t
safewrite
(
int
fd
,
const
void
*
buf
,
size_t
count
);
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录