Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
c3d9f399
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看板
提交
c3d9f399
编写于
3月 21, 2013
作者:
P
Peter Krempa
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
virsh-domain: Add --live, --config, --current logic to cmdDetachInterface
Use the established approach to improve this function too.
上级
69ce3ffa
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
49 addition
and
17 deletion
+49
-17
tools/virsh-domain.c
tools/virsh-domain.c
+34
-13
tools/virsh.pod
tools/virsh.pod
+15
-4
未找到文件。
tools/virsh-domain.c
浏览文件 @
c3d9f399
...
@@ -9286,13 +9286,21 @@ static const vshCmdOptDef opts_detach_interface[] = {
...
@@ -9286,13 +9286,21 @@ static const vshCmdOptDef opts_detach_interface[] = {
.
help
=
N_
(
"MAC address"
)
.
help
=
N_
(
"MAC address"
)
},
},
{.
name
=
"persistent"
,
{.
name
=
"persistent"
,
.
type
=
VSH_OT_
ALIAS
,
.
type
=
VSH_OT_
BOOL
,
.
help
=
"config"
.
help
=
N_
(
"make live change persistent"
)
},
},
{.
name
=
"config"
,
{.
name
=
"config"
,
.
type
=
VSH_OT_BOOL
,
.
type
=
VSH_OT_BOOL
,
.
help
=
N_
(
"affect next boot"
)
.
help
=
N_
(
"affect next boot"
)
},
},
{.
name
=
"live"
,
.
type
=
VSH_OT_BOOL
,
.
help
=
N_
(
"affect running domain"
)
},
{.
name
=
"current"
,
.
type
=
VSH_OT_BOOL
,
.
help
=
N_
(
"affect current domain"
)
},
{.
name
=
NULL
}
{.
name
=
NULL
}
};
};
...
@@ -9306,12 +9314,26 @@ cmdDetachInterface(vshControl *ctl, const vshCmd *cmd)
...
@@ -9306,12 +9314,26 @@ cmdDetachInterface(vshControl *ctl, const vshCmd *cmd)
xmlNodePtr
cur
=
NULL
,
matchNode
=
NULL
;
xmlNodePtr
cur
=
NULL
,
matchNode
=
NULL
;
xmlBufferPtr
xml_buf
=
NULL
;
xmlBufferPtr
xml_buf
=
NULL
;
const
char
*
mac
=
NULL
,
*
type
=
NULL
;
const
char
*
mac
=
NULL
,
*
type
=
NULL
;
char
*
doc
;
char
*
doc
=
NULL
;
char
buf
[
64
];
char
buf
[
64
];
int
i
=
0
,
diff_mac
;
int
i
=
0
,
diff_mac
;
int
ret
;
int
ret
;
int
functionReturn
=
false
;
int
functionReturn
=
false
;
unsigned
int
flags
;
unsigned
int
flags
=
VIR_DOMAIN_AFFECT_CURRENT
;
bool
current
=
vshCommandOptBool
(
cmd
,
"current"
);
bool
config
=
vshCommandOptBool
(
cmd
,
"config"
);
bool
live
=
vshCommandOptBool
(
cmd
,
"live"
);
bool
persistent
=
vshCommandOptBool
(
cmd
,
"persistent"
);
VSH_EXCLUSIVE_OPTIONS_VAR
(
persistent
,
current
);
VSH_EXCLUSIVE_OPTIONS_VAR
(
current
,
live
);
VSH_EXCLUSIVE_OPTIONS_VAR
(
current
,
config
);
if
(
config
||
persistent
)
flags
|=
VIR_DOMAIN_AFFECT_CONFIG
;
if
(
live
)
flags
|=
VIR_DOMAIN_AFFECT_LIVE
;
if
(
!
(
dom
=
vshCommandOptDomain
(
ctl
,
cmd
,
NULL
)))
if
(
!
(
dom
=
vshCommandOptDomain
(
ctl
,
cmd
,
NULL
)))
return
false
;
return
false
;
...
@@ -9322,13 +9344,14 @@ cmdDetachInterface(vshControl *ctl, const vshCmd *cmd)
...
@@ -9322,13 +9344,14 @@ cmdDetachInterface(vshControl *ctl, const vshCmd *cmd)
if
(
vshCommandOptStringReq
(
ctl
,
cmd
,
"mac"
,
&
mac
)
<
0
)
if
(
vshCommandOptStringReq
(
ctl
,
cmd
,
"mac"
,
&
mac
)
<
0
)
goto
cleanup
;
goto
cleanup
;
doc
=
virDomainGetXMLDesc
(
dom
,
0
);
if
(
persistent
&&
if
(
!
doc
)
virDomainIsActive
(
dom
)
==
1
)
flags
|=
VIR_DOMAIN_AFFECT_LIVE
;
if
(
!
(
doc
=
virDomainGetXMLDesc
(
dom
,
0
)))
goto
cleanup
;
goto
cleanup
;
xml
=
virXMLParseStringCtxt
(
doc
,
_
(
"(domain_definition)"
),
&
ctxt
);
if
(
!
(
xml
=
virXMLParseStringCtxt
(
doc
,
_
(
"(domain_definition)"
),
&
ctxt
)))
{
VIR_FREE
(
doc
);
if
(
!
xml
)
{
vshError
(
ctl
,
"%s"
,
_
(
"Failed to get interface information"
));
vshError
(
ctl
,
"%s"
,
_
(
"Failed to get interface information"
));
goto
cleanup
;
goto
cleanup
;
}
}
...
@@ -9393,10 +9416,7 @@ cmdDetachInterface(vshControl *ctl, const vshCmd *cmd)
...
@@ -9393,10 +9416,7 @@ cmdDetachInterface(vshControl *ctl, const vshCmd *cmd)
goto
cleanup
;
goto
cleanup
;
}
}
if
(
vshCommandOptBool
(
cmd
,
"config"
))
{
if
(
flags
!=
0
)
{
flags
=
VIR_DOMAIN_AFFECT_CONFIG
;
if
(
virDomainIsActive
(
dom
)
==
1
)
flags
|=
VIR_DOMAIN_AFFECT_LIVE
;
ret
=
virDomainDetachDeviceFlags
(
dom
,
ret
=
virDomainDetachDeviceFlags
(
dom
,
(
char
*
)
xmlBufferContent
(
xml_buf
),
(
char
*
)
xmlBufferContent
(
xml_buf
),
flags
);
flags
);
...
@@ -9412,6 +9432,7 @@ cmdDetachInterface(vshControl *ctl, const vshCmd *cmd)
...
@@ -9412,6 +9432,7 @@ cmdDetachInterface(vshControl *ctl, const vshCmd *cmd)
}
}
cleanup:
cleanup:
VIR_FREE
(
doc
);
virDomainFree
(
dom
);
virDomainFree
(
dom
);
xmlXPathFreeObject
(
obj
);
xmlXPathFreeObject
(
obj
);
xmlXPathFreeContext
(
ctxt
);
xmlXPathFreeContext
(
ctxt
);
...
...
tools/virsh.pod
浏览文件 @
c3d9f399
...
@@ -1877,16 +1877,27 @@ If I<--config> is specified, alter persistent configuration, effect observed
...
@@ -1877,16 +1877,27 @@ If I<--config> is specified, alter persistent configuration, effect observed
on next boot, for compatibility purposes, I<--persistent> is alias of
on next boot, for compatibility purposes, I<--persistent> is alias of
I<--config>.
I<--config>.
=item B<detach-interface> I<domain> I<type> [I<--mac mac>] [I<--config>]
=item B<detach-interface> I<domain> I<type> [I<--mac mac>]
[[[I<--live>] [I<--config>] | [I<--current>]] | [I<--persistent>]]
Detach a network interface from a domain.
Detach a network interface from a domain.
I<type> can be either I<network> to indicate a physical network device or
I<type> can be either I<network> to indicate a physical network device or
I<bridge> to indicate a bridge to a device. It is recommended to use the
I<bridge> to indicate a bridge to a device. It is recommended to use the
I<mac> option to distinguish between the interfaces if more than one are
I<mac> option to distinguish between the interfaces if more than one are
present on the domain.
present on the domain.
If I<--config> is specified, alter persistent configuration, effect observed
on next boot, for compatibility purposes, I<--persistent> is alias of
If I<--live> is specified, affect a running domain.
I<--config>.
If I<--config> is specified, affect the next startup of a persistent domain.
If I<--current> is specified, affect the current domain state.
Both I<--live> and I<--config> flags may be given, but I<--current> is
exclusive. When no flag is specified legacy API is used whose behavior depends
on the hypervisor driver.
For compatibility purposes, I<--persistent> behaves like I<--config> for
an offline domain, and like I<--live> I<--config> for a running domain.
Note that older versions of virsh used I<--config> as an alias for
I<--persistent>.
=item B<update-device> I<domain> I<file> [I<--force>]
=item B<update-device> I<domain> I<file> [I<--force>]
[[[I<--live>] [I<--config>] | [I<--current>]] | [I<--persistent>]]
[[[I<--live>] [I<--config>] | [I<--current>]] | [I<--persistent>]]
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录