diff mbox

[V2,4/4] libxl: support enabling and disabling <hap> feature

Message ID 1456804848-13127-5-git-send-email-jfehlig@suse.com (mailing list archive)
State New, archived
Headers show

Commit Message

Jim Fehlig March 1, 2016, 4 a.m. UTC
Until now, the libxl driver ignored any <hap> setting in domain XML
and deferred to libxl, which enables hap if not specified. While
this is a good default, it prevents disabling hap if desired.

This change allows disabling hap with <hap state='off'/>. hap is
explicitly enabled with <hap/> or <hap state='on/>. Absense of <hap>
retains current behavior of deferring default state to libxl.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
---
 src/libxl/libxl_conf.c | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

Comments

Joao Martins March 8, 2016, 4:37 p.m. UTC | #1
On 03/01/2016 04:00 AM, Jim Fehlig wrote:
> Until now, the libxl driver ignored any <hap> setting in domain XML
> and deferred to libxl, which enables hap if not specified. While
> this is a good default, it prevents disabling hap if desired.
> 
> This change allows disabling hap with <hap state='off'/>. hap is
> explicitly enabled with <hap/> or <hap state='on/>. Absense of <hap>
> retains current behavior of deferring default state to libxl.
> 
> Signed-off-by: Jim Fehlig <jfehlig@suse.com>
> ---
>  src/libxl/libxl_conf.c | 18 ++++++++++++++++--
>  1 file changed, 16 insertions(+), 2 deletions(-)
> 
> diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
> index 6efd9b5..116dc22 100644
> --- a/src/libxl/libxl_conf.c
> +++ b/src/libxl/libxl_conf.c
> @@ -511,10 +511,24 @@ libxlMakeDomCreateInfo(libxl_ctx *ctx,
>  
>      libxl_domain_create_info_init(c_info);
>  
> -    if (def->os.type == VIR_DOMAIN_OSTYPE_HVM)
> +    if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) {
>          c_info->type = LIBXL_DOMAIN_TYPE_HVM;
> -    else
> +        switch ((virTristateSwitch) def->features[VIR_DOMAIN_FEATURE_HAP]) {
> +        case VIR_TRISTATE_SWITCH_OFF:
> +            libxl_defbool_set(&c_info->hap, false);
> +            break;
> +
> +        case VIR_TRISTATE_SWITCH_ON:
> +            libxl_defbool_set(&c_info->hap, true);
> +            break;
> +
> +        case VIR_TRISTATE_SWITCH_ABSENT:
> +        case VIR_TRISTATE_SWITCH_LAST:
> +            break;
> +        }
> +    } else {
>          c_info->type = LIBXL_DOMAIN_TYPE_PV;
> +    }
>  
>      if (VIR_STRDUP(c_info->name, def->name) < 0)
>          goto error;
> 
Tested and Reviewed-by: Joao Martins <joao.m.martins@oracle.com>
diff mbox

Patch

diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
index 6efd9b5..116dc22 100644
--- a/src/libxl/libxl_conf.c
+++ b/src/libxl/libxl_conf.c
@@ -511,10 +511,24 @@  libxlMakeDomCreateInfo(libxl_ctx *ctx,
 
     libxl_domain_create_info_init(c_info);
 
-    if (def->os.type == VIR_DOMAIN_OSTYPE_HVM)
+    if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) {
         c_info->type = LIBXL_DOMAIN_TYPE_HVM;
-    else
+        switch ((virTristateSwitch) def->features[VIR_DOMAIN_FEATURE_HAP]) {
+        case VIR_TRISTATE_SWITCH_OFF:
+            libxl_defbool_set(&c_info->hap, false);
+            break;
+
+        case VIR_TRISTATE_SWITCH_ON:
+            libxl_defbool_set(&c_info->hap, true);
+            break;
+
+        case VIR_TRISTATE_SWITCH_ABSENT:
+        case VIR_TRISTATE_SWITCH_LAST:
+            break;
+        }
+    } else {
         c_info->type = LIBXL_DOMAIN_TYPE_PV;
+    }
 
     if (VIR_STRDUP(c_info->name, def->name) < 0)
         goto error;