On Thu, Jun 10, 2010 at 11:16:13AM -0600, Eric Blake wrote:
Make 'start --paused' mirror 'create --paused'.
* tools/virsh.c (cmdStart): Try new virDomainCreateWithFlags API
first.
* tools/virsh.pod (start): Document --paused.
---
tools/virsh.c | 9 ++++++++-
tools/virsh.pod | 7 +++++--
2 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/tools/virsh.c b/tools/virsh.c
index d60c27b..b208cae 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -1306,6 +1306,7 @@ static const vshCmdOptDef opts_start[] = {
#ifndef WIN32
{"console", VSH_OT_BOOL, 0, N_("attach to console after
creation")},
#endif
+ {"paused", VSH_OT_BOOL, 0, N_("leave the guest paused after
creation")},
{NULL, 0, 0, NULL}
};
@@ -1317,6 +1318,7 @@ cmdStart(vshControl *ctl, const vshCmd *cmd)
#ifndef WIN32
int console = vshCommandOptBool(cmd, "console");
#endif
+ unsigned int flags = VIR_DOMAIN_NONE;
if (!vshConnectionUsability(ctl, ctl->conn, TRUE))
return FALSE;
@@ -1330,7 +1332,12 @@ cmdStart(vshControl *ctl, const vshCmd *cmd)
return FALSE;
}
- if (virDomainCreate(dom) == 0) {
+ if (vshCommandOptBool(cmd, "paused"))
+ flags |= VIR_DOMAIN_START_PAUSED;
+
+ /* Try newer API first, but fall back to older one if possible. */
+ if (virDomainCreateWithFlags(dom, flags) == 0 ||
+ (flags == 0 && virDomainCreate(dom) == 0)) {
vshPrint(ctl, _("Domain %s started\n"),
virDomainGetName(dom));
This should really be
if (flags)
virDomainCreateWithFlags(dom, flags)
else
virDomainCreate(dom);
avoiding the need for any try-and-fallback behaviour in the case
where flags=0
Regards,
Daniel
--
|: Red Hat, Engineering, London -o-
http://people.redhat.com/berrange/ :|
|:
http://libvirt.org -o-
http://virt-manager.org -o-
http://deltacloud.org :|
|:
http://autobuild.org -o-
http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|