Re: [libvirt] [PATCH v4 1/3] Add per-guest S3/S4 state configuration

2012-09-03 Thread Martin Kletzander
On 08/31/2012 07:42 PM, Eric Blake wrote:
 On 08/31/2012 07:59 AM, Martin Kletzander wrote:
 There is a new pm/ element implemented that can control what ACPI
 sleeping states will be advertised by BIOS and allowed to be switched
 to by libvirt. The default keeps defaults on hypervisor, otherwise
 forces chosen setting.
 The documentation of the pm element is added as well.
 ---
 
 +pre
 +  ...
 +  lt;pmgt;
 +lt;suspend-to-disk enabled='no'/gt;
 +lt;suspend-to-ram enabled='yes'/gt;
 
 'no' and 'yes' here...
 
 +  lt;/pmgt;
 +  .../pre
 +
 +dl
 +  dtcodepm/code/dt
 +  ddThese elements enable ('on') or disable ('off') BIOS support
 
 'on' and 'off' here...
 
!--
 +  Control ACPI sleep states (dis)allowed for the domain
 +  For each of the states the following rules apply:
 +  on: the state will be forcefully enabled
 +  off: the state will be forcefully disabled
 +  not specified: hypervisor will be left to decide its defaults
 
 +  define name=suspendChoices
 +interleave
 +  optional
 +attribute name=enabled
 +  choice
 +valueyes/value
 +valueno/value
 
 ...back to 'yes' and 'no' here.  Fix the .html.in version to use the
 right naming.
 
 +  /choice
 +/attribute
 +  /optional
 +/interleave
 
 The interleave layer is not necessary here (you only have one
 sub-entry; furthermore, the sub-entry is an attribute which is already
 auto-interleaved; only element entries need interleaving).
 
 ACK with those tweaks.
 

Fixed and pushed, thanks.

Martin

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


[libvirt] [PATCH v4 1/3] Add per-guest S3/S4 state configuration

2012-08-31 Thread Martin Kletzander
There is a new pm/ element implemented that can control what ACPI
sleeping states will be advertised by BIOS and allowed to be switched
to by libvirt. The default keeps defaults on hypervisor, otherwise
forces chosen setting.
The documentation of the pm element is added as well.
---
 docs/formatdomain.html.in | 24 +
 docs/schemas/domaincommon.rng | 39 +
 src/conf/domain_conf.c| 50 +++
 src/conf/domain_conf.h| 15 +
 src/libvirt_private.syms  |  2 ++
 5 files changed, 130 insertions(+)

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 671ce17..810c5a6 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -960,6 +960,30 @@
 domain will be restarted with the same configuration/dd
 /dl

+h3a name=elementsPowerManagementPower Management/a/h3
+
+p
+  span class=sinceSince 0.10.2/span it is possible to
+  forcibly enable or disable BIOS advertisements to the guest
+  OS. (NB: Only qemu driver support)
+/p
+
+pre
+  ...
+  lt;pmgt;
+lt;suspend-to-disk enabled='no'/gt;
+lt;suspend-to-ram enabled='yes'/gt;
+  lt;/pmgt;
+  .../pre
+
+dl
+  dtcodepm/code/dt
+  ddThese elements enable ('on') or disable ('off') BIOS support
+for S3 (suspend-to-disk) and S4 (suspend-to-mem) ACPI sleep
+states. If nothing is specified, then the hypervisor will be
+left with its default value./dd
+/dl
+
 h3a name=elementsFeaturesHypervisor features/a/h3

 p
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 145caf7..6b7113c 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -53,6 +53,9 @@
 ref name=features/
 ref name=termination/
 optional
+  ref name=pm/
+/optional
+optional
   ref name=devices/
 /optional
 zeroOrMore
@@ -2255,6 +2258,42 @@
 /choice
   /define
   !--
+  Control ACPI sleep states (dis)allowed for the domain
+  For each of the states the following rules apply:
+  on: the state will be forcefully enabled
+  off: the state will be forcefully disabled
+  not specified: hypervisor will be left to decide its defaults
+  --
+  define name=pm
+element name=pm
+  interleave
+optional
+  element name=suspend-to-mem
+ref name=suspendChoices/
+  /element
+/optional
+optional
+  element name=suspend-to-disk
+ref name=suspendChoices/
+  /element
+/optional
+  /interleave
+  empty/
+/element
+  /define
+  define name=suspendChoices
+interleave
+  optional
+attribute name=enabled
+  choice
+valueyes/value
+valueno/value
+  /choice
+/attribute
+  /optional
+/interleave
+  /define
+  !--
   Specific setup for a qemu emulated character device.  Note: this
   definition doesn't fully specify the constraints on this node.
 --
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 49327df..12fb3a9 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -124,6 +124,11 @@ VIR_ENUM_IMPL(virDomainLifecycleCrash, 
VIR_DOMAIN_LIFECYCLE_CRASH_LAST,
   coredump-destroy,
   coredump-restart)

+VIR_ENUM_IMPL(virDomainPMState, VIR_DOMAIN_PM_STATE_LAST,
+  default,
+  yes,
+  no)
+
 VIR_ENUM_IMPL(virDomainDevice, VIR_DOMAIN_DEVICE_LAST,
   none,
   disk,
@@ -7211,6 +7216,28 @@ static int virDomainLifecycleParseXML(xmlXPathContextPtr 
ctxt,
 return 0;
 }

+static int
+virDomainPMStateParseXML(xmlXPathContextPtr ctxt,
+ const char *xpath,
+ int *val)
+{
+int ret = -1;
+char *tmp = virXPathString(xpath, ctxt);
+if (tmp) {
+*val = virDomainPMStateTypeFromString(tmp);
+if (*val  0) {
+virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+   _(unknown PM state value %s), tmp);
+goto cleanup;
+}
+}
+
+ret = 0;
+ cleanup:
+VIR_FREE(tmp);
+return ret;
+}
+
 virDomainDeviceDefPtr virDomainDeviceDefParse(virCapsPtr caps,
   virDomainDefPtr def,
   const char *xmlStr,
@@ -8583,6 +8610,16 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr 
caps,
virDomainLifecycleCrashTypeFromString)  0)
 goto error;

+if (virDomainPMStateParseXML(ctxt,
+ string(./pm/suspend-to-mem/@enabled),
+ def-pm.s3)  0)
+goto error;
+
+if (virDomainPMStateParseXML(ctxt,
+ 

Re: [libvirt] [PATCH v4 1/3] Add per-guest S3/S4 state configuration

2012-08-31 Thread Eric Blake
On 08/31/2012 07:59 AM, Martin Kletzander wrote:
 There is a new pm/ element implemented that can control what ACPI
 sleeping states will be advertised by BIOS and allowed to be switched
 to by libvirt. The default keeps defaults on hypervisor, otherwise
 forces chosen setting.
 The documentation of the pm element is added as well.
 ---

 +pre
 +  ...
 +  lt;pmgt;
 +lt;suspend-to-disk enabled='no'/gt;
 +lt;suspend-to-ram enabled='yes'/gt;

'no' and 'yes' here...

 +  lt;/pmgt;
 +  .../pre
 +
 +dl
 +  dtcodepm/code/dt
 +  ddThese elements enable ('on') or disable ('off') BIOS support

'on' and 'off' here...

!--
 +  Control ACPI sleep states (dis)allowed for the domain
 +  For each of the states the following rules apply:
 +  on: the state will be forcefully enabled
 +  off: the state will be forcefully disabled
 +  not specified: hypervisor will be left to decide its defaults

 +  define name=suspendChoices
 +interleave
 +  optional
 +attribute name=enabled
 +  choice
 +valueyes/value
 +valueno/value

...back to 'yes' and 'no' here.  Fix the .html.in version to use the
right naming.

 +  /choice
 +/attribute
 +  /optional
 +/interleave

The interleave layer is not necessary here (you only have one
sub-entry; furthermore, the sub-entry is an attribute which is already
auto-interleaved; only element entries need interleaving).

ACK with those tweaks.

-- 
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 v4 1/3] Add per-guest S3/S4 state configuration

2012-08-23 Thread Martin Kletzander
There is a new pm/ element implemented that can control what ACPI
sleeping states will be advertised by BIOS and allowed to be switched
to by libvirt. The default keeps defaults on hypervisor, otherwise
forces chosen setting.
The documentation of the pm element is added as well.
---
 docs/formatdomain.html.in | 24 
 docs/schemas/domaincommon.rng | 39 
 src/conf/domain_conf.c| 52 ++-
 src/conf/domain_conf.h| 15 +
 src/libvirt_private.syms  |  2 ++
 5 files changed, 131 insertions(+), 1 deletion(-)

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index e671e36..b5a35f6 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -957,6 +957,30 @@
 domain will be restarted with the same configuration/dd
 /dl

+h3a name=elementsPowerManagementPower Management/a/h3
+
+p
+  span class=sinceSince 0.10.1/span it is possible to
+  forcibly enable or disable BIOS advertisements to the guest
+  OS. (NB: Only qemu driver support)
+/p
+
+pre
+  ...
+  lt;pmgt;
+lt;suspend-to-disk enabled='no'/gt;
+lt;suspend-to-ram enabled='yes'/gt;
+  lt;/pmgt;
+  .../pre
+
+dl
+  dtcodepm/code/dt
+  ddThese elements enable ('on') or disable ('off') BIOS support
+for S3 (suspend-to-disk) and S4 (suspend-to-mem) ACPI sleep
+states. If nothing is specified, then the hypervisor will be
+left with its default value./dd
+/dl
+
 h3a name=elementsFeaturesHypervisor features/a/h3

 p
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 145caf7..6b7113c 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -53,6 +53,9 @@
 ref name=features/
 ref name=termination/
 optional
+  ref name=pm/
+/optional
+optional
   ref name=devices/
 /optional
 zeroOrMore
@@ -2255,6 +2258,42 @@
 /choice
   /define
   !--
+  Control ACPI sleep states (dis)allowed for the domain
+  For each of the states the following rules apply:
+  on: the state will be forcefully enabled
+  off: the state will be forcefully disabled
+  not specified: hypervisor will be left to decide its defaults
+  --
+  define name=pm
+element name=pm
+  interleave
+optional
+  element name=suspend-to-mem
+ref name=suspendChoices/
+  /element
+/optional
+optional
+  element name=suspend-to-disk
+ref name=suspendChoices/
+  /element
+/optional
+  /interleave
+  empty/
+/element
+  /define
+  define name=suspendChoices
+interleave
+  optional
+attribute name=enabled
+  choice
+valueyes/value
+valueno/value
+  /choice
+/attribute
+  /optional
+/interleave
+  /define
+  !--
   Specific setup for a qemu emulated character device.  Note: this
   definition doesn't fully specify the constraints on this node.
 --
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 419088c..94a4eb7 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -125,6 +125,11 @@ VIR_ENUM_IMPL(virDomainLifecycleCrash, 
VIR_DOMAIN_LIFECYCLE_CRASH_LAST,
   coredump-destroy,
   coredump-restart)

+VIR_ENUM_IMPL(virDomainPMState, VIR_DOMAIN_PM_STATE_LAST,
+  default,
+  yes,
+  no)
+
 VIR_ENUM_IMPL(virDomainDevice, VIR_DOMAIN_DEVICE_LAST,
   none,
   disk,
@@ -7202,6 +7207,28 @@ static int virDomainLifecycleParseXML(xmlXPathContextPtr 
ctxt,
 return 0;
 }

+static int
+virDomainPMStateParseXML(xmlXPathContextPtr ctxt,
+ const char *xpath,
+ int *val)
+{
+int ret = -1;
+char *tmp = virXPathString(xpath, ctxt);
+if (tmp) {
+*val = virDomainPMStateTypeFromString(tmp);
+if (*val  0) {
+virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+   _(unknown PM state value %s), tmp);
+goto cleanup;
+}
+}
+
+ret = 0;
+ cleanup:
+VIR_FREE(tmp);
+return ret;
+}
+
 virDomainDeviceDefPtr virDomainDeviceDefParse(virCapsPtr caps,
   virDomainDefPtr def,
   const char *xmlStr,
@@ -8569,11 +8596,21 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr 
caps,
 goto error;

 if (virDomainLifecycleParseXML(ctxt, string(./on_crash[1]),
-def-onCrash,
+   def-onCrash,
VIR_DOMAIN_LIFECYCLE_CRASH_DESTROY,
virDomainLifecycleCrashTypeFromString)  0)
 goto error;

+if 

Re: [libvirt] [PATCH v4 1/3] Add per-guest S3/S4 state configuration

2012-08-23 Thread Michal Privoznik
On 23.08.2012 13:47, Martin Kletzander wrote:
 There is a new pm/ element implemented that can control what ACPI
 sleeping states will be advertised by BIOS and allowed to be switched
 to by libvirt. The default keeps defaults on hypervisor, otherwise
 forces chosen setting.
 The documentation of the pm element is added as well.
 ---
  docs/formatdomain.html.in | 24 
  docs/schemas/domaincommon.rng | 39 
  src/conf/domain_conf.c| 52 
 ++-
  src/conf/domain_conf.h| 15 +
  src/libvirt_private.syms  |  2 ++
  5 files changed, 131 insertions(+), 1 deletion(-)
 
 diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
 index 419088c..94a4eb7 100644
 --- a/src/conf/domain_conf.c
 +++ b/src/conf/domain_conf.c
 @@ -125,6 +125,11 @@ VIR_ENUM_IMPL(virDomainLifecycleCrash, 
 VIR_DOMAIN_LIFECYCLE_CRASH_LAST,
coredump-destroy,
coredump-restart)
 
 +VIR_ENUM_IMPL(virDomainPMState, VIR_DOMAIN_PM_STATE_LAST,
 +  default,
 +  yes,
 +  no)
 +
  VIR_ENUM_IMPL(virDomainDevice, VIR_DOMAIN_DEVICE_LAST,
none,
disk,
 @@ -7202,6 +7207,28 @@ static int 
 virDomainLifecycleParseXML(xmlXPathContextPtr ctxt,
  return 0;
  }
 
 +static int
 +virDomainPMStateParseXML(xmlXPathContextPtr ctxt,
 + const char *xpath,
 + int *val)
 +{
 +int ret = -1;
 +char *tmp = virXPathString(xpath, ctxt);
 +if (tmp) {
 +*val = virDomainPMStateTypeFromString(tmp);
 +if (*val  0) {
 +virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
 +   _(unknown PM state value %s), tmp);
 +goto cleanup;
 +}
 +}
 +
 +ret = 0;
 + cleanup:
 +VIR_FREE(tmp);
 +return ret;
 +}
 +
  virDomainDeviceDefPtr virDomainDeviceDefParse(virCapsPtr caps,
virDomainDefPtr def,
const char *xmlStr,
 @@ -8569,11 +8596,21 @@ static virDomainDefPtr 
 virDomainDefParseXML(virCapsPtr caps,
  goto error;
 
  if (virDomainLifecycleParseXML(ctxt, string(./on_crash[1]),
 -def-onCrash,
 +   def-onCrash,

This indentation change is not relevant to this patch. I'd save it for a
separate patch.

 VIR_DOMAIN_LIFECYCLE_CRASH_DESTROY,
 virDomainLifecycleCrashTypeFromString)  
 0)
  goto error;
 
 +if (virDomainPMStateParseXML(ctxt,
 + string(./pm/suspend-to-mem/@enabled),
 + def-pm.s3)  0)
 +goto error;
 +
 +if (virDomainPMStateParseXML(ctxt,
 + string(./pm/suspend-to-disk/@enabled),
 + def-pm.s4)  0)
 +goto error;
 +
  tmp = virXPathString(string(./clock/@offset), ctxt);
  if (tmp) {
  if ((def-clock.offset = virDomainClockOffsetTypeFromString(tmp))  
 0) {

ACK modulo indent change.

Michal

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


Re: [libvirt] [PATCH v4 1/3] Add per-guest S3/S4 state configuration

2012-08-23 Thread Eric Blake
On 08/23/2012 05:47 AM, Martin Kletzander wrote:
 There is a new pm/ element implemented that can control what ACPI
 sleeping states will be advertised by BIOS and allowed to be switched
 to by libvirt. The default keeps defaults on hypervisor, otherwise
 forces chosen setting.
 The documentation of the pm element is added as well.
 ---

 +  define name=suspendChoices
 +interleave
 +  optional
 +attribute name=enabled
 +  choice
 +valueyes/value
 +valueno/value
 +  /choice
 +/attribute
 +  /optional
 +/interleave

The interleave is not necessary - you only have one thing inside the
group; and for that matter, attributes are already interleaved.  Only
elements need interleave treatment.

-- 
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