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

[Xen-devel] [RFC PATCH 3/8] xl/parse: introduce cpu_topology to guest config



Signed-off-by: Chao Gao <chao.gao@xxxxxxxxx>
---
 docs/man/xl.cfg.pod.5.in    | 21 +++++++++++++++++++++
 tools/libxl/libxl_types.idl |  7 +++++++
 tools/xl/xl_parse.c         | 19 +++++++++++++++++++
 3 files changed, 47 insertions(+)

diff --git a/docs/man/xl.cfg.pod.5.in b/docs/man/xl.cfg.pod.5.in
index b7b91d8..8ff401e 100644
--- a/docs/man/xl.cfg.pod.5.in
+++ b/docs/man/xl.cfg.pod.5.in
@@ -501,6 +501,27 @@ Boot the guest using the OVMF UEFI firmware.
 
 Load the specified file as firmware for the guest.
 
+=item B<cpu_topology="CPU_TOPOLOGY_SPEC">
+
+Each B<CPU_TOPOLOGY_SPEC> is a comma-separated list of C<KEY=VALUE>
+settings from the following list:
+
+=over 4
+
+=item B<cores=NUMBER>
+specify the number of cores in each socket.
+
+=item B<threads=NUMBER>
+specify the number of threads in each core.
+
+=item B<real_threads=NUMBER>
+specify the real number of threads in each core. This field can be used
+to expose only part of threads in one core. For example, though the CPUID
+instruction indicates that each core has two threads, but only one thread
+of each core is exposed to the guest.
+
+=back
+
 =back
 
 =head4 PVH guest options
diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl
index a239324..8c80e67 100644
--- a/tools/libxl/libxl_types.idl
+++ b/tools/libxl/libxl_types.idl
@@ -457,6 +457,12 @@ libxl_altp2m_mode = Enumeration("altp2m_mode", [
     (3, "limited"),
     ], init_val = "LIBXL_ALTP2M_MODE_DISABLED")
 
+libxl_cpu_topology = Struct("cpu_topology", [
+    ("cores",           uint8),
+    ("threads",         uint8),
+    ("real_threads",    uint8),
+    ])
+
 libxl_domain_build_info = Struct("domain_build_info",[
     ("max_vcpus",       integer),
     ("avail_vcpus",     libxl_bitmap),
@@ -581,6 +587,7 @@ libxl_domain_build_info = Struct("domain_build_info",[
                                        ("rdm", libxl_rdm_reserve),
                                        ("rdm_mem_boundary_memkb", MemKB),
                                        ("mca_caps",         uint64),
+                                       ("cpu_topology",     
libxl_cpu_topology),
                                        ])),
                  ("pv", Struct(None, [("kernel", string),
                                       ("slack_memkb", MemKB),
diff --git a/tools/xl/xl_parse.c b/tools/xl/xl_parse.c
index 9a692d5..9b76920 100644
--- a/tools/xl/xl_parse.c
+++ b/tools/xl/xl_parse.c
@@ -1373,6 +1373,25 @@ void parse_config_data(const char *config_source,
              */
         }
 
+        if (!xlu_cfg_get_string(config, "cpu_topology", &buf, 0))
+        {
+            char *buf2, *p, *oparg, *strtok_ptr;
+
+            buf2 = strdup(buf);
+
+            for (p = strtok_r(buf2, ",", &strtok_ptr); p;
+                 p = strtok_r(NULL, ",", &strtok_ptr)) {
+                if (MATCH_OPTION("cores", p, oparg)) {
+                    b_info->u.hvm.cpu_topology.cores = parse_ulong(oparg);
+                } else if (MATCH_OPTION("threads", p, oparg)) {
+                    b_info->u.hvm.cpu_topology.threads = parse_ulong(oparg);
+                } else if (MATCH_OPTION("real_threads", p, oparg)) {
+                    b_info->u.hvm.cpu_topology.real_threads =
+                        parse_ulong(oparg);
+                }
+            }
+        }
+
         break;
     case LIBXL_DOMAIN_TYPE_PVH:
     case LIBXL_DOMAIN_TYPE_PV:
-- 
1.8.3.1


_______________________________________________
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®.