diff mbox

[2/6] libxl: introduce a new structure to represent static shared memory regions

Message ID 20170822180840.20981-3-blackskygg@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Sky Liu Aug. 22, 2017, 6:08 p.m. UTC
Add a new structure to the IDL famliy to represent static shared memory regions,
as proposed in the proposal "Allow setting up shared memory areas between VMs
from xl config file" (see [1]).

[1] https://lists.xenproject.org/archives/html/xen-devel/2017-07/msg03047.html

Signed-off-by: Zhongze Liu <blackskygg@gmail.com>

Cc: Wei Liu <wei.liu2@citrix.com>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Stefano Stabellini <sstabellini@kernel.org>
Cc: Julien Grall <julien.grall@arm.com>
Cc: xen-devel@lists.xen.org
---
 tools/libxl/libxl.h         |  4 ++++
 tools/libxl/libxl_types.idl | 36 ++++++++++++++++++++++++++++++++----
 2 files changed, 36 insertions(+), 4 deletions(-)

Comments

Stefano Stabellini Aug. 22, 2017, 8:05 p.m. UTC | #1
On Wed, 23 Aug 2017, Zhongze Liu wrote:
> Add a new structure to the IDL famliy to represent static shared memory regions,
                                  ^ family


> as proposed in the proposal "Allow setting up shared memory areas between VMs
> from xl config file" (see [1]).
> 
> [1] https://lists.xenproject.org/archives/html/xen-devel/2017-07/msg03047.html
> 
> Signed-off-by: Zhongze Liu <blackskygg@gmail.com>
> 
> Cc: Wei Liu <wei.liu2@citrix.com>
> Cc: Ian Jackson <ian.jackson@eu.citrix.com>
> Cc: Stefano Stabellini <sstabellini@kernel.org>
> Cc: Julien Grall <julien.grall@arm.com>
> Cc: xen-devel@lists.xen.org
> ---
>  tools/libxl/libxl.h         |  4 ++++
>  tools/libxl/libxl_types.idl | 36 ++++++++++++++++++++++++++++++++----
>  2 files changed, 36 insertions(+), 4 deletions(-)
> 
> diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h
> index 229e289750..3ee788642f 100644
> --- a/tools/libxl/libxl.h
> +++ b/tools/libxl/libxl.h
> @@ -2237,6 +2237,10 @@ int libxl_fd_set_nonblock(libxl_ctx *ctx, int fd, int nonblock);
>  int libxl_qemu_monitor_command(libxl_ctx *ctx, uint32_t domid,
>                                 const char *command_line, char **output);
>  
> +/* Constants for libxl_static_shm */
> +#define LIBXL_SSHM_RANGE_UNKNOWN UINT64_MAX
> +#define LIBXL_SSHM_ID_MAXLEN    128
> +
>  #include <libxl_event.h>
>  
>  #endif /* LIBXL_H */
> diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl
> index 6e80d36256..6c9e79c05d 100644
> --- a/tools/libxl/libxl_types.idl
> +++ b/tools/libxl/libxl_types.idl
> @@ -472,7 +472,7 @@ libxl_domain_build_info = Struct("domain_build_info",[
>      ("blkdev_start",    string),
>  
>      ("vnuma_nodes", Array(libxl_vnode_info, "num_vnuma_nodes")),
> -    
> +

Although your code style corrections are appropriate, usually we do them
in separate patches to separate them out from more meaningful changes.
However, different maintainers have different styles, so Wei might be OK
with this.

In any case:

Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>


>      ("device_model_version", libxl_device_model_version),
>      ("device_model_stubdomain", libxl_defbool),
>      # if you set device_model you must set device_model_version too
> @@ -494,7 +494,7 @@ libxl_domain_build_info = Struct("domain_build_info",[
>      ("ioports",          Array(libxl_ioport_range, "num_ioports")),
>      ("irqs",             Array(uint32, "num_irqs")),
>      ("iomem",            Array(libxl_iomem_range, "num_iomem")),
> -    ("claim_mode",	     libxl_defbool),
> +    ("claim_mode",           libxl_defbool),
>      ("event_channels",   uint32),
>      ("kernel",           string),
>      ("cmdline",          string),
> @@ -543,10 +543,10 @@ libxl_domain_build_info = Struct("domain_build_info",[
>                                         ("keymap",           string),
>                                         ("sdl",              libxl_sdl_info),
>                                         ("spice",            libxl_spice_info),
> -                                       
> +
>                                         ("gfx_passthru",     libxl_defbool),
>                                         ("gfx_passthru_kind", libxl_gfx_passthru_kind),
> -                                       
> +
>                                         ("serial",           string),
>                                         ("boot",             string),
>                                         ("usb",              libxl_defbool),
> @@ -779,6 +779,33 @@ libxl_device_channel = Struct("device_channel", [
>             ])),
>  ])
>  
> +libxl_sshm_cachepolicy = Enumeration("sshm_cachepolicy", [
> +    (-1, "UNKNOWN"),
> +    (0,  "ARM_NORMAL"),  # ARM policies should be < 32
> +    (32,  "X86_NORMAL"), # X86 policies should be >= 32
> +    ], init_val = "LIBXL_SSHM_CHCHE_POLICY_UNKNOWN")
> +
> +libxl_sshm_prot = Enumeration("sshm_prot", [
> +    (-1, "UNKNOWN"),
> +    (3,  "RW"),
> +    ], init_val = "LIBXL_SSHM_PROT_UNKNOWN")
> +
> +libxl_sshm_role = Enumeration("sshm_role", [
> +    (-1, "UNKNOWN"),
> +    (0,  "MASTER"),
> +    (1,  "SLAVE"),
> +    ], init_val = "LIBXL_SSHM_ROLE_UNKNOWN")
> +
> +libxl_static_shm = Struct("static_shm", [
> +    ("id", string),
> +    ("offset", uint64, {'init_val': 'LIBXL_SSHM_RANGE_UNKNOWN'}),
> +    ("begin", uint64, {'init_val': 'LIBXL_SSHM_RANGE_UNKNOWN'}),
> +    ("end", uint64, {'init_val': 'LIBXL_SSHM_RANGE_UNKNOWN'}),
> +    ("prot", libxl_sshm_prot, {'init_val': 'LIBXL_SSHM_PROT_UNKNOWN'}),
> +    ("cache_policy", libxl_sshm_cachepolicy, {'init_val': 'LIBXL_SSHM_CACHEPOLICY_UNKNOWN'}),
> +    ("role", libxl_sshm_role, {'init_val': 'LIBXL_SSHM_ROLE_UNKNOWN'}),
> +])
> +
>  libxl_domain_config = Struct("domain_config", [
>      ("c_info", libxl_domain_create_info),
>      ("b_info", libxl_domain_build_info),
> @@ -797,6 +824,7 @@ libxl_domain_config = Struct("domain_config", [
>      ("channels", Array(libxl_device_channel, "num_channels")),
>      ("usbctrls", Array(libxl_device_usbctrl, "num_usbctrls")),
>      ("usbdevs", Array(libxl_device_usbdev, "num_usbdevs")),
> +    ("sshms", Array(libxl_static_shm, "num_sshms")),
>  
>      ("on_poweroff", libxl_action_on_shutdown),
>      ("on_reboot", libxl_action_on_shutdown),
> -- 
> 2.14.0
>
Sky Liu Aug. 23, 2017, 2:05 a.m. UTC | #2
Hi Stefano,

2017-08-23 4:05 GMT+08:00 Stefano Stabellini <sstabellini@kernel.org>:
> On Wed, 23 Aug 2017, Zhongze Liu wrote:
>> Add a new structure to the IDL famliy to represent static shared memory regions,
>                                   ^ family
>
>
>> as proposed in the proposal "Allow setting up shared memory areas between VMs
>> from xl config file" (see [1]).
>>
>> [1] https://lists.xenproject.org/archives/html/xen-devel/2017-07/msg03047.html
>>
>> Signed-off-by: Zhongze Liu <blackskygg@gmail.com>
>>
>> Cc: Wei Liu <wei.liu2@citrix.com>
>> Cc: Ian Jackson <ian.jackson@eu.citrix.com>
>> Cc: Stefano Stabellini <sstabellini@kernel.org>
>> Cc: Julien Grall <julien.grall@arm.com>
>> Cc: xen-devel@lists.xen.org
>> ---
>>  tools/libxl/libxl.h         |  4 ++++
>>  tools/libxl/libxl_types.idl | 36 ++++++++++++++++++++++++++++++++----
>>  2 files changed, 36 insertions(+), 4 deletions(-)
>>
>> diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h
>> index 229e289750..3ee788642f 100644
>> --- a/tools/libxl/libxl.h
>> +++ b/tools/libxl/libxl.h
>> @@ -2237,6 +2237,10 @@ int libxl_fd_set_nonblock(libxl_ctx *ctx, int fd, int nonblock);
>>  int libxl_qemu_monitor_command(libxl_ctx *ctx, uint32_t domid,
>>                                 const char *command_line, char **output);
>>
>> +/* Constants for libxl_static_shm */
>> +#define LIBXL_SSHM_RANGE_UNKNOWN UINT64_MAX
>> +#define LIBXL_SSHM_ID_MAXLEN    128
>> +
>>  #include <libxl_event.h>
>>
>>  #endif /* LIBXL_H */
>> diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl
>> index 6e80d36256..6c9e79c05d 100644
>> --- a/tools/libxl/libxl_types.idl
>> +++ b/tools/libxl/libxl_types.idl
>> @@ -472,7 +472,7 @@ libxl_domain_build_info = Struct("domain_build_info",[
>>      ("blkdev_start",    string),
>>
>>      ("vnuma_nodes", Array(libxl_vnode_info, "num_vnuma_nodes")),
>> -
>> +
>
> Although your code style corrections are appropriate, usually we do them
> in separate patches to separate them out from more meaningful changes.
> However, different maintainers have different styles, so Wei might be OK
> with this.
>
> In any case:
>
> Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>

Thanks for reviewing. This is actually a
'clean-trailing-white-space-on-save' feature
of my editor. I always turn it off when modifying the toolstack code,
because there
are trailing white spaces at many unexpected corners and this will screw up the
diff. I don't know why I somehow missed this file. But I think it's
not a big problem
though. I will wait for Wei's comments on this. And it won't be too
hard to restore
the style corrections.

But I think we really should do a big white spaces cleanup in the
toolstack code.

Cheers,

Zhongze Liu
>
>
>>      ("device_model_version", libxl_device_model_version),
>>      ("device_model_stubdomain", libxl_defbool),
>>      # if you set device_model you must set device_model_version too
>> @@ -494,7 +494,7 @@ libxl_domain_build_info = Struct("domain_build_info",[
>>      ("ioports",          Array(libxl_ioport_range, "num_ioports")),
>>      ("irqs",             Array(uint32, "num_irqs")),
>>      ("iomem",            Array(libxl_iomem_range, "num_iomem")),
>> -    ("claim_mode",        libxl_defbool),
>> +    ("claim_mode",           libxl_defbool),
>>      ("event_channels",   uint32),
>>      ("kernel",           string),
>>      ("cmdline",          string),
>> @@ -543,10 +543,10 @@ libxl_domain_build_info = Struct("domain_build_info",[
>>                                         ("keymap",           string),
>>                                         ("sdl",              libxl_sdl_info),
>>                                         ("spice",            libxl_spice_info),
>> -
>> +
>>                                         ("gfx_passthru",     libxl_defbool),
>>                                         ("gfx_passthru_kind", libxl_gfx_passthru_kind),
>> -
>> +
>>                                         ("serial",           string),
>>                                         ("boot",             string),
>>                                         ("usb",              libxl_defbool),
>> @@ -779,6 +779,33 @@ libxl_device_channel = Struct("device_channel", [
>>             ])),
>>  ])
>>
>> +libxl_sshm_cachepolicy = Enumeration("sshm_cachepolicy", [
>> +    (-1, "UNKNOWN"),
>> +    (0,  "ARM_NORMAL"),  # ARM policies should be < 32
>> +    (32,  "X86_NORMAL"), # X86 policies should be >= 32
>> +    ], init_val = "LIBXL_SSHM_CHCHE_POLICY_UNKNOWN")
>> +
>> +libxl_sshm_prot = Enumeration("sshm_prot", [
>> +    (-1, "UNKNOWN"),
>> +    (3,  "RW"),
>> +    ], init_val = "LIBXL_SSHM_PROT_UNKNOWN")
>> +
>> +libxl_sshm_role = Enumeration("sshm_role", [
>> +    (-1, "UNKNOWN"),
>> +    (0,  "MASTER"),
>> +    (1,  "SLAVE"),
>> +    ], init_val = "LIBXL_SSHM_ROLE_UNKNOWN")
>> +
>> +libxl_static_shm = Struct("static_shm", [
>> +    ("id", string),
>> +    ("offset", uint64, {'init_val': 'LIBXL_SSHM_RANGE_UNKNOWN'}),
>> +    ("begin", uint64, {'init_val': 'LIBXL_SSHM_RANGE_UNKNOWN'}),
>> +    ("end", uint64, {'init_val': 'LIBXL_SSHM_RANGE_UNKNOWN'}),
>> +    ("prot", libxl_sshm_prot, {'init_val': 'LIBXL_SSHM_PROT_UNKNOWN'}),
>> +    ("cache_policy", libxl_sshm_cachepolicy, {'init_val': 'LIBXL_SSHM_CACHEPOLICY_UNKNOWN'}),
>> +    ("role", libxl_sshm_role, {'init_val': 'LIBXL_SSHM_ROLE_UNKNOWN'}),
>> +])
>> +
>>  libxl_domain_config = Struct("domain_config", [
>>      ("c_info", libxl_domain_create_info),
>>      ("b_info", libxl_domain_build_info),
>> @@ -797,6 +824,7 @@ libxl_domain_config = Struct("domain_config", [
>>      ("channels", Array(libxl_device_channel, "num_channels")),
>>      ("usbctrls", Array(libxl_device_usbctrl, "num_usbctrls")),
>>      ("usbdevs", Array(libxl_device_usbdev, "num_usbdevs")),
>> +    ("sshms", Array(libxl_static_shm, "num_sshms")),
>>
>>      ("on_poweroff", libxl_action_on_shutdown),
>>      ("on_reboot", libxl_action_on_shutdown),
>> --
>> 2.14.0
>>
diff mbox

Patch

diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h
index 229e289750..3ee788642f 100644
--- a/tools/libxl/libxl.h
+++ b/tools/libxl/libxl.h
@@ -2237,6 +2237,10 @@  int libxl_fd_set_nonblock(libxl_ctx *ctx, int fd, int nonblock);
 int libxl_qemu_monitor_command(libxl_ctx *ctx, uint32_t domid,
                                const char *command_line, char **output);
 
+/* Constants for libxl_static_shm */
+#define LIBXL_SSHM_RANGE_UNKNOWN UINT64_MAX
+#define LIBXL_SSHM_ID_MAXLEN    128
+
 #include <libxl_event.h>
 
 #endif /* LIBXL_H */
diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl
index 6e80d36256..6c9e79c05d 100644
--- a/tools/libxl/libxl_types.idl
+++ b/tools/libxl/libxl_types.idl
@@ -472,7 +472,7 @@  libxl_domain_build_info = Struct("domain_build_info",[
     ("blkdev_start",    string),
 
     ("vnuma_nodes", Array(libxl_vnode_info, "num_vnuma_nodes")),
-    
+
     ("device_model_version", libxl_device_model_version),
     ("device_model_stubdomain", libxl_defbool),
     # if you set device_model you must set device_model_version too
@@ -494,7 +494,7 @@  libxl_domain_build_info = Struct("domain_build_info",[
     ("ioports",          Array(libxl_ioport_range, "num_ioports")),
     ("irqs",             Array(uint32, "num_irqs")),
     ("iomem",            Array(libxl_iomem_range, "num_iomem")),
-    ("claim_mode",	     libxl_defbool),
+    ("claim_mode",           libxl_defbool),
     ("event_channels",   uint32),
     ("kernel",           string),
     ("cmdline",          string),
@@ -543,10 +543,10 @@  libxl_domain_build_info = Struct("domain_build_info",[
                                        ("keymap",           string),
                                        ("sdl",              libxl_sdl_info),
                                        ("spice",            libxl_spice_info),
-                                       
+
                                        ("gfx_passthru",     libxl_defbool),
                                        ("gfx_passthru_kind", libxl_gfx_passthru_kind),
-                                       
+
                                        ("serial",           string),
                                        ("boot",             string),
                                        ("usb",              libxl_defbool),
@@ -779,6 +779,33 @@  libxl_device_channel = Struct("device_channel", [
            ])),
 ])
 
+libxl_sshm_cachepolicy = Enumeration("sshm_cachepolicy", [
+    (-1, "UNKNOWN"),
+    (0,  "ARM_NORMAL"),  # ARM policies should be < 32
+    (32,  "X86_NORMAL"), # X86 policies should be >= 32
+    ], init_val = "LIBXL_SSHM_CHCHE_POLICY_UNKNOWN")
+
+libxl_sshm_prot = Enumeration("sshm_prot", [
+    (-1, "UNKNOWN"),
+    (3,  "RW"),
+    ], init_val = "LIBXL_SSHM_PROT_UNKNOWN")
+
+libxl_sshm_role = Enumeration("sshm_role", [
+    (-1, "UNKNOWN"),
+    (0,  "MASTER"),
+    (1,  "SLAVE"),
+    ], init_val = "LIBXL_SSHM_ROLE_UNKNOWN")
+
+libxl_static_shm = Struct("static_shm", [
+    ("id", string),
+    ("offset", uint64, {'init_val': 'LIBXL_SSHM_RANGE_UNKNOWN'}),
+    ("begin", uint64, {'init_val': 'LIBXL_SSHM_RANGE_UNKNOWN'}),
+    ("end", uint64, {'init_val': 'LIBXL_SSHM_RANGE_UNKNOWN'}),
+    ("prot", libxl_sshm_prot, {'init_val': 'LIBXL_SSHM_PROT_UNKNOWN'}),
+    ("cache_policy", libxl_sshm_cachepolicy, {'init_val': 'LIBXL_SSHM_CACHEPOLICY_UNKNOWN'}),
+    ("role", libxl_sshm_role, {'init_val': 'LIBXL_SSHM_ROLE_UNKNOWN'}),
+])
+
 libxl_domain_config = Struct("domain_config", [
     ("c_info", libxl_domain_create_info),
     ("b_info", libxl_domain_build_info),
@@ -797,6 +824,7 @@  libxl_domain_config = Struct("domain_config", [
     ("channels", Array(libxl_device_channel, "num_channels")),
     ("usbctrls", Array(libxl_device_usbctrl, "num_usbctrls")),
     ("usbdevs", Array(libxl_device_usbdev, "num_usbdevs")),
+    ("sshms", Array(libxl_static_shm, "num_sshms")),
 
     ("on_poweroff", libxl_action_on_shutdown),
     ("on_reboot", libxl_action_on_shutdown),