Re: [libvirt] [PATCH 4/4] Allow choice of shutdown method via virsh

2012-01-19 Thread Eric Blake
On 01/17/2012 04:44 AM, Michal Privoznik wrote:
 Extend the 'shutdown' and 'reboot' methods so that they both
 accept a new argument
 
 --mode acpi|agent
 
 * tools/virsh.c: New args for shutdown/reboot
 * tools/virsh.pod: Document new args
 ---
  tools/virsh.c   |   47 +--
  tools/virsh.pod |   24 
  2 files changed, 61 insertions(+), 10 deletions(-)
 

 @@ -1796,9 +1804,9 @@ Edit the XML configuration file for a storage pool.
  
  This is equivalent to:
  
 - virsh pool-dumpxml pool  pool.xml
 - vi pool.xml (or make changes with your other text editor)
 - virsh pool-define pool.xml
 +virsh pool-dumpxml pool  pool.xml
 +vi pool.xml (or make changes with your other text editor)
 +virsh pool-define pool.xml
  
  except that it does some error checking.
  
 @@ -1853,9 +1861,9 @@ pre-existing volume.
  
  BExample
  
 - virsh vol-dumpxml --pool storagepool1 appvolume1  newvolume.xml
 - vi newvolume.xml (or make changes with your other text editor)
 - virsh vol-create differentstoragepool newvolume.xml
 +virsh vol-dumpxml --pool storagepool1 appvolume1  newvolume.xml
 +vi newvolume.xml (or make changes with your other text editor)
 +virsh vol-create differentstoragepool newvolume.xml

These two whitespace-changing hunks look spurious.  ACK to the rest of
the patch.

-- 
Eric Blake   ebl...@redhat.com+1-919-301-3266
Libvirt virtualization library http://libvirt.org



signature.asc
Description: OpenPGP digital signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [PATCH 4/4] Allow choice of shutdown method via virsh

2012-01-17 Thread Michal Privoznik
Extend the 'shutdown' and 'reboot' methods so that they both
accept a new argument

--mode acpi|agent

* tools/virsh.c: New args for shutdown/reboot
* tools/virsh.pod: Document new args
---
 tools/virsh.c   |   47 +--
 tools/virsh.pod |   24 
 2 files changed, 61 insertions(+), 10 deletions(-)

diff --git a/tools/virsh.c b/tools/virsh.c
index c511e2a..f991604 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -3827,6 +3827,7 @@ static const vshCmdInfo info_shutdown[] = {
 
 static const vshCmdOptDef opts_shutdown[] = {
 {domain, VSH_OT_DATA, VSH_OFLAG_REQ, N_(domain name, id or uuid)},
+{mode, VSH_OT_STRING, VSH_OFLAG_NONE, N_(shutdown mode: acpi|agent)},
 {NULL, 0, 0, NULL}
 };
 
@@ -3836,14 +3837,37 @@ cmdShutdown(vshControl *ctl, const vshCmd *cmd)
 virDomainPtr dom;
 bool ret = true;
 const char *name;
+const char *mode = NULL;
+int flags = 0;
+int rv;
 
 if (!vshConnectionUsability(ctl, ctl-conn))
 return false;
 
+if (vshCommandOptString(cmd, mode, mode)  0) {
+vshError(ctl, %s, _(Invalid type));
+return false;
+}
+
+if (mode) {
+if (STREQ(mode, acpi)) {
+flags |= VIR_DOMAIN_SHUTDOWN_ACPI_POWER_BTN;
+} else if (STREQ(mode, agent)) {
+flags |= VIR_DOMAIN_SHUTDOWN_GUEST_AGENT;
+} else {
+vshError(ctl, _(Unknown mode %s value, expecting 'acpi' or 
'agent'), mode);
+return false;
+}
+}
+
 if (!(dom = vshCommandOptDomain(ctl, cmd, name)))
 return false;
 
-if (virDomainShutdown(dom) == 0) {
+if (flags)
+rv = virDomainShutdownFlags(dom, flags);
+else
+rv = virDomainShutdown(dom);
+if (rv == 0) {
 vshPrint(ctl, _(Domain %s is being shutdown\n), name);
 } else {
 vshError(ctl, _(Failed to shutdown domain %s), name);
@@ -3865,6 +3889,7 @@ static const vshCmdInfo info_reboot[] = {
 
 static const vshCmdOptDef opts_reboot[] = {
 {domain, VSH_OT_DATA, VSH_OFLAG_REQ, N_(domain name, id or uuid)},
+{mode, VSH_OT_STRING, VSH_OFLAG_NONE, N_(shutdown mode: acpi|agent)},
 {NULL, 0, 0, NULL}
 };
 
@@ -3874,14 +3899,32 @@ cmdReboot(vshControl *ctl, const vshCmd *cmd)
 virDomainPtr dom;
 bool ret = true;
 const char *name;
+const char *mode = NULL;
+int flags = 0;
 
 if (!vshConnectionUsability(ctl, ctl-conn))
 return false;
 
+if (vshCommandOptString(cmd, mode, mode)  0) {
+vshError(ctl, %s, _(Invalid type));
+return false;
+}
+
+if (mode) {
+if (STREQ(mode, acpi)) {
+flags |= VIR_DOMAIN_SHUTDOWN_ACPI_POWER_BTN;
+} else if (STREQ(mode, agent)) {
+flags |= VIR_DOMAIN_SHUTDOWN_GUEST_AGENT;
+} else {
+vshError(ctl, _(Unknown mode %s value, expecting 'acpi' or 
'agent'), mode);
+return false;
+}
+}
+
 if (!(dom = vshCommandOptDomain(ctl, cmd, name)))
 return false;
 
-if (virDomainReboot(dom, 0) == 0) {
+if (virDomainReboot(dom, flags) == 0) {
 vshPrint(ctl, _(Domain %s is being rebooted\n), name);
 } else {
 vshError(ctl, _(Failed to reboot domain %s), name);
diff --git a/tools/virsh.pod b/tools/virsh.pod
index c88395b..856be43 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -805,7 +805,7 @@ If I--live is specified, set scheduler information of a 
running guest.
 If I--config is specified, affect the next boot of a persistent guest.
 If I--current is specified, affect the current guest state.
 
-=item Breboot Idomain-id
+=item Breboot Idomain-id [I--mode acpi|agent]
 
 Reboot a domain.  This acts just as if the domain had the Breboot
 command run from the console.  The command returns as soon as it has
@@ -815,6 +815,10 @@ domain actually reboots.
 The exact behavior of a domain when it reboots is set by the
 Ion_reboot parameter in the domain's XML definition.
 
+By default the hypervisor will try to pick a suitable shutdown
+method. To specify an alternative method, the I--mode parameter
+can specify Cacpi or Cagent.
+
 =item Breset Idomain-id
 
 Reset a domain immediately without any guest shutdown. Breset
@@ -1188,7 +1192,7 @@ The I--maximum flag controls the maximum number of 
virtual cpus that can
 be hot-plugged the next time the domain is booted.  As such, it must only be
 used with the I--config flag, and not with the I--live flag.
 
-=item Bshutdown Idomain-id
+=item Bshutdown Idomain-id [I--mode acpi|agent]
 
 Gracefully shuts down a domain.  This coordinates with the domain OS
 to perform graceful shutdown, so there is no guarantee that it will
@@ -1203,6 +1207,10 @@ be lost once the guest stops running, but the snapshot 
contents still
 exist, and a new domain with the same name and UUID can restore the
 snapshot metadata with Bsnapshot-create.
 
+By default the hypervisor will try to pick a suitable shutdown
+method. To 

[libvirt] [PATCH 4/4] Allow choice of shutdown method via virsh

2011-10-05 Thread Daniel P. Berrange
From: Daniel P. Berrange berra...@redhat.com

Extend the 'shutdown' and 'reboot' methods so that they both
accept a new argument

--mode acpi|agent

* tools/virsh.c: New args for shutdown/reboot
* tools/virsh.pod: Document new args
---
 tools/virsh.c   |   42 --
 tools/virsh.pod |   12 ++--
 2 files changed, 50 insertions(+), 4 deletions(-)

diff --git a/tools/virsh.c b/tools/virsh.c
index 3a17971..e84f60a 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -3127,6 +3127,7 @@ static const vshCmdInfo info_shutdown[] = {
 
 static const vshCmdOptDef opts_shutdown[] = {
 {domain, VSH_OT_DATA, VSH_OFLAG_REQ, N_(domain name, id or uuid)},
+{mode, VSH_OT_DATA, 0, N_(shutdown mode: acpi|agent)},
 {NULL, 0, 0, NULL}
 };
 
@@ -3136,14 +3137,37 @@ cmdShutdown(vshControl *ctl, const vshCmd *cmd)
 virDomainPtr dom;
 bool ret = true;
 const char *name;
+const char *mode = NULL;
+int flags = 0;
+int rv;
 
 if (!vshConnectionUsability(ctl, ctl-conn))
 return false;
 
+if (vshCommandOptString(cmd, mode, mode)  0) {
+vshError(ctl, %s, _(Invalid type));
+return false;
+}
+
+if (mode) {
+if (STREQ(mode, acpi)) {
+flags |= VIR_DOMAIN_SHUTDOWN_ACPI_POWER_BTN;
+} else if (STREQ(mode, agent)) {
+flags |= VIR_DOMAIN_SHUTDOWN_GUEST_AGENT;
+} else {
+vshError(ctl, _(Unknown mode %s value, expecting 'acpi' or 
'agent'), mode);
+return false;
+}
+}
+
 if (!(dom = vshCommandOptDomain(ctl, cmd, name)))
 return false;
 
-if (virDomainShutdown(dom) == 0) {
+if (flags)
+rv = virDomainShutdownFlags(dom, flags);
+else
+rv = virDomainShutdown(dom);
+if (rv == 0) {
 vshPrint(ctl, _(Domain %s is being shutdown\n), name);
 } else {
 vshError(ctl, _(Failed to shutdown domain %s), name);
@@ -3165,6 +3189,7 @@ static const vshCmdInfo info_reboot[] = {
 
 static const vshCmdOptDef opts_reboot[] = {
 {domain, VSH_OT_DATA, VSH_OFLAG_REQ, N_(domain name, id or uuid)},
+{mode, VSH_OT_DATA, 0, N_(shutdown mode: acpi|agent)},
 {NULL, 0, 0, NULL}
 };
 
@@ -3174,14 +3199,27 @@ cmdReboot(vshControl *ctl, const vshCmd *cmd)
 virDomainPtr dom;
 bool ret = true;
 const char *name;
+const char *mode = NULL;
+int flags = 0;
 
 if (!vshConnectionUsability(ctl, ctl-conn))
 return false;
 
+if (mode) {
+if (STREQ(mode, acpi)) {
+flags |= VIR_DOMAIN_SHUTDOWN_ACPI_POWER_BTN;
+} else if (STREQ(mode, agent)) {
+flags |= VIR_DOMAIN_SHUTDOWN_GUEST_AGENT;
+} else {
+vshError(ctl, _(Unknown mode %s value, expecting 'acpi' or 
'agent'), mode);
+return false;
+}
+}
+
 if (!(dom = vshCommandOptDomain(ctl, cmd, name)))
 return false;
 
-if (virDomainReboot(dom, 0) == 0) {
+if (virDomainReboot(dom, flags) == 0) {
 vshPrint(ctl, _(Domain %s is being rebooted\n), name);
 } else {
 vshError(ctl, _(Failed to reboot domain %s), name);
diff --git a/tools/virsh.pod b/tools/virsh.pod
index be81afc..7006025 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -780,7 +780,7 @@ migrated to another host.
 
 Get the maximum migration bandwidth (in Mbps) for a domain.
 
-=item Breboot Idomain-id
+=item Breboot Idomain-id [I--mode acpi|agent]
 
 Reboot a domain.  This acts just as if the domain had the Breboot
 command run from the console.  The command returns as soon as it has
@@ -790,6 +790,10 @@ domain actually reboots.
 The exact behavior of a domain when it reboots is set by the
 Ion_reboot parameter in the domain's XML definition.
 
+By default the hypervisor will try to pick a suitable shutdown
+method. To specify an alternative method, the I--mode parameter
+can specify Cacpi or Cagent.
+
 =item Breset Idomain-id
 
 Reset a domain immediately without any guest shutdown. Breset
@@ -1074,7 +1078,7 @@ The I--maximum flag controls the maximum number of 
virtual cpus that can
 be hot-plugged the next time the domain is booted.  As such, it must only be
 used with the I--config flag, and not with the I--live flag.
 
-=item Bshutdown Idomain-id
+=item Bshutdown Idomain-id [I--mode acpi|agent]
 
 Gracefully shuts down a domain.  This coordinates with the domain OS
 to perform graceful shutdown, so there is no guarantee that it will
@@ -1089,6 +1093,10 @@ be lost once the guest stops running, but the snapshot 
contents still
 exist, and a new domain with the same name and UUID can restore the
 snapshot metadata with Bsnapshot-create.
 
+By default the hypervisor will try to pick a suitable shutdown
+method. To specify an alternative method, the I--mode parameter
+can specify Cacpi or Cagent.
+
 =item Bstart Idomain-name [I--console] [I--paused] [I--autodestroy]
 [I--bypass-cache] [I--force-boot]
 
-- 
1.7.6

--
libvir-list mailing list

Re: [libvirt] [PATCH 4/4] Allow choice of shutdown method via virsh

2011-10-05 Thread Eric Blake

On 10/05/2011 11:31 AM, Daniel P. Berrange wrote:

From: Daniel P. Berrangeberra...@redhat.com

Extend the 'shutdown' and 'reboot' methods so that they both
accept a new argument

 --mode acpi|agent

* tools/virsh.c: New args for shutdown/reboot
* tools/virsh.pod: Document new args
---
  tools/virsh.c   |   42 --
  tools/virsh.pod |   12 ++--
  2 files changed, 50 insertions(+), 4 deletions(-)


You remembered the docs.  Thanks :)

ACK.

--
Eric Blake   ebl...@redhat.com+1-801-349-2682
Libvirt virtualization library http://libvirt.org

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list