[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH-for-4.13 v2 1/2] libxl: replace 'enabled' with 'unknown' in libxl_passthrough enumeration



This is mostly a cosmetic patch to avoid the default enumeration value
being 'enabled'. The only non-cosmetic parts are in xl_parse.c where it now
becomes necessary to explicitly parse the 'enabled' value for xl.cfg
'passthrough' option, and error on the value 'unknown', because there is no
longer a direct mapping between valid xl.cfg values and the enumeration.

Suggested-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
Signed-off-by: Paul Durrant <paul.durrant@xxxxxxxxxx>
---
Cc: Wei Liu <wl@xxxxxxx>
Cc: Anthony PERARD <anthony.perard@xxxxxxxxxx>
Cc: Juergen Gross <jgross@xxxxxxxx>

v2:
 - new in v2
---
 tools/libxl/libxl_create.c  |  4 ++--
 tools/libxl/libxl_types.idl |  2 +-
 tools/xl/xl_parse.c         | 26 +++++++++++++++-----------
 3 files changed, 18 insertions(+), 14 deletions(-)

diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c
index b58e030376..5f2972bc03 100644
--- a/tools/libxl/libxl_create.c
+++ b/tools/libxl/libxl_create.c
@@ -64,7 +64,7 @@ int libxl__domain_create_info_setdefault(libxl__gc *gc,
         c_info->ssidref = SECINITSID_DOMU;
 
     if (info.cap_hvm_directio &&
-        (c_info->passthrough == LIBXL_PASSTHROUGH_ENABLED)) {
+        (c_info->passthrough == LIBXL_PASSTHROUGH_UNKNOWN)) {
         c_info->passthrough = ((c_info->type == LIBXL_DOMAIN_TYPE_PV) ||
                                !info.cap_iommu_hap_pt_share) ?
             LIBXL_PASSTHROUGH_SYNC_PT : LIBXL_PASSTHROUGH_SHARE_PT;
@@ -586,7 +586,7 @@ int libxl__domain_make(libxl__gc *gc, libxl_domain_config 
*d_config,
                 libxl_defbool_val(info->oos) ? 0 : XEN_DOMCTL_CDF_oos_off;
         }
 
-        assert(info->passthrough != LIBXL_PASSTHROUGH_ENABLED);
+        assert(info->passthrough != LIBXL_PASSTHROUGH_UNKNOWN);
         LOG(DETAIL, "passthrough: %s",
             libxl_passthrough_to_string(info->passthrough));
 
diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl
index 54ac685f50..3ac9494b80 100644
--- a/tools/libxl/libxl_types.idl
+++ b/tools/libxl/libxl_types.idl
@@ -264,7 +264,7 @@ libxl_vkb_backend = Enumeration("vkb_backend", [
     ])
 
 libxl_passthrough = Enumeration("passthrough", [
-    (0, "enabled"),
+    (0, "unknown"),
     (1, "disabled"),
     (2, "sync_pt"),
     (3, "share_pt"),
diff --git a/tools/xl/xl_parse.c b/tools/xl/xl_parse.c
index c2e61b680f..03a2c54dd2 100644
--- a/tools/xl/xl_parse.c
+++ b/tools/xl/xl_parse.c
@@ -1512,23 +1512,27 @@ void parse_config_data(const char *config_source,
     if (xlu_cfg_get_string(config, "passthrough", &buf, 0)) {
         c_info->passthrough =
             (d_config->num_pcidevs || d_config->num_dtdevs)
-            ? LIBXL_PASSTHROUGH_ENABLED : LIBXL_PASSTHROUGH_DISABLED;
+            ? LIBXL_PASSTHROUGH_UNKNOWN : LIBXL_PASSTHROUGH_DISABLED;
     } else {
-        libxl_passthrough o;
+        if (!strcasecmp("enabled", buf))
+            c_info->passthrough = LIBXL_PASSTHROUGH_UNKNOWN;
+        else {
+            libxl_passthrough o;
 
-        e = libxl_passthrough_from_string(buf, &o);
-        if (e) {
-            fprintf(stderr,
-                    "ERROR: unknown passthrough option '%s'\n",
-                    buf);
-            exit(-ERROR_FAIL);
-        }
+            e = libxl_passthrough_from_string(buf, &o);
+            if (e || !strcasecmp("unknown", buf)) {
+                fprintf(stderr,
+                        "ERROR: unknown passthrough option '%s'\n",
+                        buf);
+                exit(-ERROR_FAIL);
+            }
 
-        c_info->passthrough = o;
+            c_info->passthrough = o;
+        }
     }
 
     switch (c_info->passthrough) {
-    case LIBXL_PASSTHROUGH_ENABLED:
+    case LIBXL_PASSTHROUGH_UNKNOWN:
         /*
          * Choose a suitable default. libxl would also do this but
          * choosing here allows the code calculating 'iommu_memkb'
-- 
2.20.1.2.gb21ebb671


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.