Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
4dcc4c2d
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看板
提交
4dcc4c2d
编写于
12月 15, 2005
作者:
K
Karel Zak
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
remove --id/name from virsh
上级
5b282f0e
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
86 addition
and
120 deletion
+86
-120
ChangeLog
ChangeLog
+6
-0
src/virsh.c
src/virsh.c
+80
-120
未找到文件。
ChangeLog
浏览文件 @
4dcc4c2d
Thu Dec 15 17:56:27 CET 2005 Karel Zak <kzak@redhat.com>
* src/virsh.c: remove --id / --name options
* include/libvir.h: add missing declaration of virDomainGetXMLDesc()
Wed Dec 14 16:28:24 CET 2005 Daniel Veillard <veillard@redhat.com>
Wed Dec 14 16:28:24 CET 2005 Daniel Veillard <veillard@redhat.com>
* src/xml.c: add dump of os/boot informations
* src/xml.c: add dump of os/boot informations
...
...
src/virsh.c
浏览文件 @
4dcc4c2d
...
@@ -178,9 +178,12 @@ static vshCmdOpt *vshCommandOpt(vshCmd *cmd, const char *name);
...
@@ -178,9 +178,12 @@ static vshCmdOpt *vshCommandOpt(vshCmd *cmd, const char *name);
static
int
vshCommandOptInt
(
vshCmd
*
cmd
,
const
char
*
name
,
int
*
found
);
static
int
vshCommandOptInt
(
vshCmd
*
cmd
,
const
char
*
name
,
int
*
found
);
static
char
*
vshCommandOptString
(
vshCmd
*
cmd
,
const
char
*
name
,
int
*
found
);
static
char
*
vshCommandOptString
(
vshCmd
*
cmd
,
const
char
*
name
,
int
*
found
);
static
int
vshCommandOptBool
(
vshCmd
*
cmd
,
const
char
*
name
);
static
int
vshCommandOptBool
(
vshCmd
*
cmd
,
const
char
*
name
);
static
virDomainPtr
vshCommandOptDomain
(
vshControl
*
ctl
,
vshCmd
*
cmd
,
const
char
*
optname
,
char
**
name
);
static
void
vshPrint
(
vshControl
*
ctl
,
vshOutType
out
,
const
char
*
format
,
...);
static
void
vshPrint
(
vshControl
*
ctl
,
vshOutType
out
,
const
char
*
format
,
...);
static
const
char
*
vshDomainStateToString
(
int
state
);
static
const
char
*
vshDomainStateToString
(
int
state
);
static
int
vshConnectionUsability
(
vshControl
*
ctl
,
virConnectPtr
conn
,
int
showerror
);
static
int
vshConnectionUsability
(
vshControl
*
ctl
,
virConnectPtr
conn
,
int
showerror
);
...
@@ -313,38 +316,27 @@ cmdList(vshControl *ctl, vshCmd *cmd ATTRIBUTE_UNUSED) {
...
@@ -313,38 +316,27 @@ cmdList(vshControl *ctl, vshCmd *cmd ATTRIBUTE_UNUSED) {
* "dstate" command
* "dstate" command
*/
*/
static
vshCmdInfo
info_dstate
[]
=
{
static
vshCmdInfo
info_dstate
[]
=
{
{
"syntax"
,
"dstate
[--id <number> | --name <string> ]
"
},
{
"syntax"
,
"dstate
<domain>
"
},
{
"help"
,
"domain state"
},
{
"help"
,
"domain state"
},
{
"desc"
,
"Returns state about
the
domain."
},
{
"desc"
,
"Returns state about
a running
domain."
},
{
NULL
,
NULL
}
{
NULL
,
NULL
}
};
};
static
vshCmdOptDef
opts_dstate
[]
=
{
static
vshCmdOptDef
opts_dstate
[]
=
{
{
"name"
,
VSH_OT_STRING
,
0
,
"domain name"
},
{
"domain"
,
VSH_OT_DATA
,
0
,
"domain name or id"
},
{
"id"
,
VSH_OT_INT
,
0
,
"domain id"
},
{
NULL
,
0
,
0
,
NULL
}
{
NULL
,
0
,
0
,
NULL
}
};
};
static
int
static
int
cmdDstate
(
vshControl
*
ctl
,
vshCmd
*
cmd
)
{
cmdDstate
(
vshControl
*
ctl
,
vshCmd
*
cmd
)
{
virDomainInfo
info
;
virDomainInfo
info
;
virDomainPtr
dom
;
virDomainPtr
dom
;
int
found
,
ret
=
TRUE
;
int
ret
=
TRUE
;
char
*
name
=
vshCommandOptString
(
cmd
,
"name"
,
NULL
);
int
id
=
vshCommandOptInt
(
cmd
,
"id"
,
&
found
);
if
(
!
vshConnectionUsability
(
ctl
,
ctl
->
conn
,
TRUE
))
if
(
!
vshConnectionUsability
(
ctl
,
ctl
->
conn
,
TRUE
))
return
FALSE
;
return
FALSE
;
if
(
found
)
{
if
(
!
(
dom
=
vshCommandOptDomain
(
ctl
,
cmd
,
"domain"
,
NULL
)))
if
(
!
(
dom
=
virDomainLookupByID
(
ctl
->
conn
,
id
)))
vshError
(
ctl
,
FALSE
,
"failed to get domain '%d'"
,
id
);
}
else
{
if
(
!
(
dom
=
virDomainLookupByName
(
ctl
->
conn
,
name
)))
vshError
(
ctl
,
FALSE
,
"failed to get domain '%s'"
,
name
);
}
if
(
!
dom
)
return
FALSE
;
return
FALSE
;
if
(
virDomainGetInfo
(
dom
,
&
info
)
==
0
)
if
(
virDomainGetInfo
(
dom
,
&
info
)
==
0
)
...
@@ -360,44 +352,31 @@ cmdDstate(vshControl *ctl, vshCmd *cmd) {
...
@@ -360,44 +352,31 @@ cmdDstate(vshControl *ctl, vshCmd *cmd) {
* "suspend" command
* "suspend" command
*/
*/
static
vshCmdInfo
info_suspend
[]
=
{
static
vshCmdInfo
info_suspend
[]
=
{
{
"syntax"
,
"suspend
[--id <number> | --name <string> ]
"
},
{
"syntax"
,
"suspend
<domain>
"
},
{
"help"
,
"
domain state
"
},
{
"help"
,
"
suspend a domain
"
},
{
"desc"
,
"Suspend a running domain."
},
{
"desc"
,
"Suspend a running domain."
},
{
NULL
,
NULL
}
{
NULL
,
NULL
}
};
};
static
vshCmdOptDef
opts_suspend
[]
=
{
static
vshCmdOptDef
opts_suspend
[]
=
{
{
"name"
,
VSH_OT_STRING
,
0
,
"domain name"
},
{
"domain"
,
VSH_OT_DATA
,
0
,
"domain name or id"
},
{
"id"
,
VSH_OT_INT
,
0
,
"domain id"
},
{
NULL
,
0
,
0
,
NULL
}
{
NULL
,
0
,
0
,
NULL
}
};
};
static
int
static
int
cmdSuspend
(
vshControl
*
ctl
,
vshCmd
*
cmd
)
{
cmdSuspend
(
vshControl
*
ctl
,
vshCmd
*
cmd
)
{
virDomainPtr
dom
;
virDomainPtr
dom
;
int
found
,
ret
=
TRUE
;
char
*
name
;
char
*
name
=
vshCommandOptString
(
cmd
,
"name"
,
NULL
);
int
ret
=
TRUE
;
int
id
=
vshCommandOptInt
(
cmd
,
"id"
,
&
found
);
if
(
!
vshConnectionUsability
(
ctl
,
ctl
->
conn
,
TRUE
))
if
(
!
vshConnectionUsability
(
ctl
,
ctl
->
conn
,
TRUE
))
return
FALSE
;
return
FALSE
;
if
(
found
)
{
if
(
!
(
dom
=
vshCommandOptDomain
(
ctl
,
cmd
,
"domain"
,
&
name
)))
if
(
!
(
dom
=
virDomainLookupByID
(
ctl
->
conn
,
id
)))
vshError
(
ctl
,
FALSE
,
"failed to get domain '%d'"
,
id
);
}
else
{
if
(
!
(
dom
=
virDomainLookupByName
(
ctl
->
conn
,
name
)))
vshError
(
ctl
,
FALSE
,
"failed to get domain '%s'"
,
name
);
}
if
(
!
dom
)
return
FALSE
;
return
FALSE
;
if
(
virDomainSuspend
(
dom
)
==
0
)
{
if
(
virDomainSuspend
(
dom
)
==
0
)
{
if
(
found
)
vshPrint
(
ctl
,
VSH_MESG
,
"Domain %s suspended
\n
"
,
name
);
vshPrint
(
ctl
,
VSH_MESG
,
"Domain %d suspended
\n
"
,
found
);
else
vshPrint
(
ctl
,
VSH_MESG
,
"Domain %s suspended
\n
"
,
name
);
}
else
{
}
else
{
vshError
(
ctl
,
FALSE
,
"Failed to suspend domain
\n
"
);
vshError
(
ctl
,
FALSE
,
"Failed to suspend domain
\n
"
);
ret
=
FALSE
;
ret
=
FALSE
;
...
@@ -411,44 +390,31 @@ cmdSuspend(vshControl *ctl, vshCmd *cmd) {
...
@@ -411,44 +390,31 @@ cmdSuspend(vshControl *ctl, vshCmd *cmd) {
* "resume" command
* "resume" command
*/
*/
static
vshCmdInfo
info_resume
[]
=
{
static
vshCmdInfo
info_resume
[]
=
{
{
"syntax"
,
"resume
[--id <number> | --name <string> ]
"
},
{
"syntax"
,
"resume
<domain>
"
},
{
"help"
,
"
domain state
"
},
{
"help"
,
"
resume a domain
"
},
{
"desc"
,
"Resume a previously suspended domain."
},
{
"desc"
,
"Resume a previously suspended domain."
},
{
NULL
,
NULL
}
{
NULL
,
NULL
}
};
};
static
vshCmdOptDef
opts_resume
[]
=
{
static
vshCmdOptDef
opts_resume
[]
=
{
{
"name"
,
VSH_OT_STRING
,
0
,
"domain name"
},
{
"domain"
,
VSH_OT_DATA
,
0
,
"domain name or id"
},
{
"id"
,
VSH_OT_INT
,
0
,
"domain id"
},
{
NULL
,
0
,
0
,
NULL
}
{
NULL
,
0
,
0
,
NULL
}
};
};
static
int
static
int
cmdResume
(
vshControl
*
ctl
,
vshCmd
*
cmd
)
{
cmdResume
(
vshControl
*
ctl
,
vshCmd
*
cmd
)
{
virDomainPtr
dom
;
virDomainPtr
dom
;
int
found
,
ret
=
TRUE
;
int
ret
=
TRUE
;
char
*
name
=
vshCommandOptString
(
cmd
,
"name"
,
NULL
);
char
*
name
;
int
id
=
vshCommandOptInt
(
cmd
,
"id"
,
&
found
);
if
(
!
vshConnectionUsability
(
ctl
,
ctl
->
conn
,
TRUE
))
if
(
!
vshConnectionUsability
(
ctl
,
ctl
->
conn
,
TRUE
))
return
FALSE
;
return
FALSE
;
if
(
found
)
{
if
(
!
(
dom
=
vshCommandOptDomain
(
ctl
,
cmd
,
"domain"
,
&
name
)))
if
(
!
(
dom
=
virDomainLookupByID
(
ctl
->
conn
,
id
)))
vshError
(
ctl
,
FALSE
,
"failed to get domain '%d'"
,
id
);
}
else
{
if
(
!
(
dom
=
virDomainLookupByName
(
ctl
->
conn
,
name
)))
vshError
(
ctl
,
FALSE
,
"failed to get domain '%s'"
,
name
);
}
if
(
!
dom
)
return
FALSE
;
return
FALSE
;
if
(
virDomainResume
(
dom
)
==
0
)
{
if
(
virDomainResume
(
dom
)
==
0
)
{
if
(
found
)
vshPrint
(
ctl
,
VSH_MESG
,
"Domain %s resumed
\n
"
,
name
);
vshPrint
(
ctl
,
VSH_MESG
,
"Domain %d resumed
\n
"
,
found
);
else
vshPrint
(
ctl
,
VSH_MESG
,
"Domain %s resumed
\n
"
,
name
);
}
else
{
}
else
{
vshError
(
ctl
,
FALSE
,
"Failed to resume domain
\n
"
);
vshError
(
ctl
,
FALSE
,
"Failed to resume domain
\n
"
);
ret
=
FALSE
;
ret
=
FALSE
;
...
@@ -462,44 +428,31 @@ cmdResume(vshControl *ctl, vshCmd *cmd) {
...
@@ -462,44 +428,31 @@ cmdResume(vshControl *ctl, vshCmd *cmd) {
* "destroy" command
* "destroy" command
*/
*/
static
vshCmdInfo
info_destroy
[]
=
{
static
vshCmdInfo
info_destroy
[]
=
{
{
"syntax"
,
"destroy
[--id <number> | --name <string> ]
"
},
{
"syntax"
,
"destroy
<domain>
"
},
{
"help"
,
"d
omain state
"
},
{
"help"
,
"d
estroy a domain
"
},
{
"desc"
,
"Destroy a given domain."
},
{
"desc"
,
"Destroy a given domain."
},
{
NULL
,
NULL
}
{
NULL
,
NULL
}
};
};
static
vshCmdOptDef
opts_destroy
[]
=
{
static
vshCmdOptDef
opts_destroy
[]
=
{
{
"name"
,
VSH_OT_STRING
,
0
,
"domain name"
},
{
"domain"
,
VSH_OT_DATA
,
0
,
"domain name or id"
},
{
"id"
,
VSH_OT_INT
,
0
,
"domain id"
},
{
NULL
,
0
,
0
,
NULL
}
{
NULL
,
0
,
0
,
NULL
}
};
};
static
int
static
int
cmdDestroy
(
vshControl
*
ctl
,
vshCmd
*
cmd
)
{
cmdDestroy
(
vshControl
*
ctl
,
vshCmd
*
cmd
)
{
virDomainPtr
dom
;
virDomainPtr
dom
;
int
found
,
ret
=
TRUE
;
int
ret
=
TRUE
;
char
*
name
=
vshCommandOptString
(
cmd
,
"name"
,
NULL
);
char
*
name
;
int
id
=
vshCommandOptInt
(
cmd
,
"id"
,
&
found
);
if
(
!
vshConnectionUsability
(
ctl
,
ctl
->
conn
,
TRUE
))
if
(
!
vshConnectionUsability
(
ctl
,
ctl
->
conn
,
TRUE
))
return
FALSE
;
return
FALSE
;
if
(
found
)
{
if
(
!
(
dom
=
vshCommandOptDomain
(
ctl
,
cmd
,
"domain"
,
&
name
)))
if
(
!
(
dom
=
virDomainLookupByID
(
ctl
->
conn
,
id
)))
vshError
(
ctl
,
FALSE
,
"failed to get domain '%d'"
,
id
);
}
else
{
if
(
!
(
dom
=
virDomainLookupByName
(
ctl
->
conn
,
name
)))
vshError
(
ctl
,
FALSE
,
"failed to get domain '%s'"
,
name
);
}
if
(
!
dom
)
return
FALSE
;
return
FALSE
;
if
(
virDomainDestroy
(
dom
)
==
0
)
{
if
(
virDomainDestroy
(
dom
)
==
0
)
{
if
(
found
)
vshPrint
(
ctl
,
VSH_MESG
,
"Domain %s destroyed
\n
"
,
name
);
vshPrint
(
ctl
,
VSH_MESG
,
"Domain %d destroyed
\n
"
,
found
);
else
vshPrint
(
ctl
,
VSH_MESG
,
"Domain %s destroyed
\n
"
,
name
);
}
else
{
}
else
{
vshError
(
ctl
,
FALSE
,
"Failed to destroy domain
\n
"
);
vshError
(
ctl
,
FALSE
,
"Failed to destroy domain
\n
"
);
ret
=
FALSE
;
ret
=
FALSE
;
...
@@ -513,15 +466,14 @@ cmdDestroy(vshControl *ctl, vshCmd *cmd) {
...
@@ -513,15 +466,14 @@ cmdDestroy(vshControl *ctl, vshCmd *cmd) {
* "dinfo" command
* "dinfo" command
*/
*/
static
vshCmdInfo
info_dinfo
[]
=
{
static
vshCmdInfo
info_dinfo
[]
=
{
{
"syntax"
,
"dinfo
[--id <number> | --name <string> ]
"
},
{
"syntax"
,
"dinfo
<domain>
"
},
{
"help"
,
"domain information"
},
{
"help"
,
"domain information"
},
{
"desc"
,
"Returns basic information about the domain."
},
{
"desc"
,
"Returns basic information about the domain."
},
{
NULL
,
NULL
}
{
NULL
,
NULL
}
};
};
static
vshCmdOptDef
opts_dinfo
[]
=
{
static
vshCmdOptDef
opts_dinfo
[]
=
{
{
"name"
,
VSH_OT_STRING
,
0
,
"domain name"
},
{
"domain"
,
VSH_OT_DATA
,
0
,
"domain name or id"
},
{
"id"
,
VSH_OT_INT
,
0
,
"domain id"
},
{
NULL
,
0
,
0
,
NULL
}
{
NULL
,
0
,
0
,
NULL
}
};
};
...
@@ -529,22 +481,12 @@ static int
...
@@ -529,22 +481,12 @@ static int
cmdDinfo
(
vshControl
*
ctl
,
vshCmd
*
cmd
)
{
cmdDinfo
(
vshControl
*
ctl
,
vshCmd
*
cmd
)
{
virDomainInfo
info
;
virDomainInfo
info
;
virDomainPtr
dom
;
virDomainPtr
dom
;
int
found
,
ret
=
TRUE
;
int
ret
=
TRUE
;
char
*
name
=
vshCommandOptString
(
cmd
,
"name"
,
NULL
);
int
id
=
vshCommandOptInt
(
cmd
,
"id"
,
&
found
);
if
(
!
vshConnectionUsability
(
ctl
,
ctl
->
conn
,
TRUE
))
if
(
!
vshConnectionUsability
(
ctl
,
ctl
->
conn
,
TRUE
))
return
FALSE
;
return
FALSE
;
if
(
found
)
{
if
(
!
(
dom
=
vshCommandOptDomain
(
ctl
,
cmd
,
"domain"
,
NULL
)))
if
(
!
(
dom
=
virDomainLookupByID
(
ctl
->
conn
,
id
)))
vshError
(
ctl
,
FALSE
,
"failed to get domain '%d'"
,
id
);
}
else
{
if
(
!
(
dom
=
virDomainLookupByName
(
ctl
->
conn
,
name
)))
vshError
(
ctl
,
FALSE
,
"failed to get domain '%s'"
,
name
);
}
if
(
!
dom
)
return
FALSE
;
return
FALSE
;
if
(
virDomainGetInfo
(
dom
,
&
info
)
==
0
)
{
if
(
virDomainGetInfo
(
dom
,
&
info
)
==
0
)
{
...
@@ -557,12 +499,12 @@ cmdDinfo(vshControl *ctl, vshCmd *cmd) {
...
@@ -557,12 +499,12 @@ cmdDinfo(vshControl *ctl, vshCmd *cmd) {
vshPrint
(
ctl
,
VSH_MESG
,
"%-15s %d
\n
"
,
"CPU(s):"
,
vshPrint
(
ctl
,
VSH_MESG
,
"%-15s %d
\n
"
,
"CPU(s):"
,
info
.
nrVirtCpu
);
info
.
nrVirtCpu
);
if
(
info
.
cpuTime
!=
0
)
if
(
info
.
cpuTime
!=
0
)
{
{
float
cpuUsed
=
info
.
cpuTime
;
float
cpuUsed
=
info
.
cpuTime
;
cpuUsed
/=
1000000000
;
cpuUsed
/=
1000000000
;
vshPrint
(
ctl
,
VSH_MESG
,
"%-15s %.1fs
\n
"
,
"CPU time:"
,
cpuUsed
);
vshPrint
(
ctl
,
VSH_MESG
,
"%-15s %.1fs
\n
"
,
"CPU time:"
,
cpuUsed
);
}
}
vshPrint
(
ctl
,
VSH_MESG
,
"%-15s %lu kB
\n
"
,
"Max memory:"
,
vshPrint
(
ctl
,
VSH_MESG
,
"%-15s %lu kB
\n
"
,
"Max memory:"
,
...
@@ -582,38 +524,27 @@ cmdDinfo(vshControl *ctl, vshCmd *cmd) {
...
@@ -582,38 +524,27 @@ cmdDinfo(vshControl *ctl, vshCmd *cmd) {
* "dumpxml" command
* "dumpxml" command
*/
*/
static
vshCmdInfo
info_dumpxml
[]
=
{
static
vshCmdInfo
info_dumpxml
[]
=
{
{
"syntax"
,
"dumpxml
[--id <number> | --name <string> ]
"
},
{
"syntax"
,
"dumpxml
<name>
"
},
{
"help"
,
"domain information in XML"
},
{
"help"
,
"domain information in XML"
},
{
"desc"
,
"Ouput the domain informations as an XML dump to stdout"
},
{
"desc"
,
"Ouput the domain informations as an XML dump to stdout"
},
{
NULL
,
NULL
}
{
NULL
,
NULL
}
};
};
static
vshCmdOptDef
opts_dumpxml
[]
=
{
static
vshCmdOptDef
opts_dumpxml
[]
=
{
{
"name"
,
VSH_OT_STRING
,
0
,
"domain name"
},
{
"domain"
,
VSH_OT_DATA
,
0
,
"domain name or id"
},
{
"id"
,
VSH_OT_INT
,
0
,
"domain id"
},
{
NULL
,
0
,
0
,
NULL
}
{
NULL
,
0
,
0
,
NULL
}
};
};
static
int
static
int
cmdDumpXML
(
vshControl
*
ctl
,
vshCmd
*
cmd
)
{
cmdDumpXML
(
vshControl
*
ctl
,
vshCmd
*
cmd
)
{
virDomainPtr
dom
;
virDomainPtr
dom
;
int
found
,
ret
=
TRUE
;
int
ret
=
TRUE
;
char
*
name
=
vshCommandOptString
(
cmd
,
"name"
,
NULL
);
int
id
=
vshCommandOptInt
(
cmd
,
"id"
,
&
found
);
char
*
dump
;
char
*
dump
;
if
(
!
vshConnectionUsability
(
ctl
,
ctl
->
conn
,
TRUE
))
if
(
!
vshConnectionUsability
(
ctl
,
ctl
->
conn
,
TRUE
))
return
FALSE
;
return
FALSE
;
if
(
found
)
{
if
(
!
(
dom
=
vshCommandOptDomain
(
ctl
,
cmd
,
"domain"
,
NULL
)))
if
(
!
(
dom
=
virDomainLookupByID
(
ctl
->
conn
,
id
)))
vshError
(
ctl
,
FALSE
,
"failed to get domain '%d'"
,
id
);
}
else
{
if
(
!
(
dom
=
virDomainLookupByName
(
ctl
->
conn
,
name
)))
vshError
(
ctl
,
FALSE
,
"failed to get domain '%s'"
,
name
);
}
if
(
!
dom
)
return
FALSE
;
return
FALSE
;
dump
=
virDomainGetXMLDesc
(
dom
,
0
);
dump
=
virDomainGetXMLDesc
(
dom
,
0
);
...
@@ -633,7 +564,7 @@ cmdDumpXML(vshControl *ctl, vshCmd *cmd) {
...
@@ -633,7 +564,7 @@ cmdDumpXML(vshControl *ctl, vshCmd *cmd) {
*/
*/
static
vshCmdInfo
info_nameof
[]
=
{
static
vshCmdInfo
info_nameof
[]
=
{
{
"syntax"
,
"nameof <id>"
},
{
"syntax"
,
"nameof <id>"
},
{
"help"
,
"convert domain Id to domain name"
},
{
"help"
,
"convert
a
domain Id to domain name"
},
{
NULL
,
NULL
}
{
NULL
,
NULL
}
};
};
...
@@ -669,7 +600,7 @@ cmdNameof(vshControl *ctl, vshCmd *cmd) {
...
@@ -669,7 +600,7 @@ cmdNameof(vshControl *ctl, vshCmd *cmd) {
*/
*/
static
vshCmdInfo
info_idof
[]
=
{
static
vshCmdInfo
info_idof
[]
=
{
{
"syntax"
,
"idof <name>"
},
{
"syntax"
,
"idof <name>"
},
{
"help"
,
"convert domain name to domain Id"
},
{
"help"
,
"convert
a
domain name to domain Id"
},
{
NULL
,
NULL
}
{
NULL
,
NULL
}
};
};
...
@@ -989,6 +920,35 @@ vshCommandOptBool(vshCmd *cmd, const char *name) {
...
@@ -989,6 +920,35 @@ vshCommandOptBool(vshCmd *cmd, const char *name) {
return
vshCommandOpt
(
cmd
,
name
)
?
TRUE
:
FALSE
;
return
vshCommandOpt
(
cmd
,
name
)
?
TRUE
:
FALSE
;
}
}
static
virDomainPtr
vshCommandOptDomain
(
vshControl
*
ctl
,
vshCmd
*
cmd
,
const
char
*
optname
,
char
**
name
)
{
virDomainPtr
dom
=
NULL
;
char
*
n
,
*
end
=
NULL
;
int
id
;
if
(
!
(
n
=
vshCommandOptString
(
cmd
,
optname
,
NULL
)))
{
vshError
(
ctl
,
FALSE
,
"undefined domain name or id"
);
return
NULL
;
}
if
(
name
)
*
name
=
n
;
/* try it by ID */
id
=
(
int
)
strtol
(
n
,
&
end
,
10
);
if
(
id
>=
0
&&
end
&&
*
end
==
'\0'
)
dom
=
virDomainLookupByID
(
ctl
->
conn
,
id
);
/* try it by NAME */
if
(
!
dom
)
dom
=
virDomainLookupByName
(
ctl
->
conn
,
n
);
if
(
!
dom
)
vshError
(
ctl
,
FALSE
,
"failed to get domain '%s'"
,
n
);
return
dom
;
}
/*
/*
* Executes command(s) and returns return code from last command
* Executes command(s) and returns return code from last command
*/
*/
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录