Skip to contentSkip to conversation

xl/libxl: add pvcalls support

PATCH In review Stefano Stabellini 3 participants 6 messages Mar 29, 2018 – Mar 30, 2018

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 xl/libxl: add pvcalls support

Add pvcalls support to libxl and xl. Create the appropriate pvcalls entries in xenstore.

---

Changes in v2:
- rename pvcalls to pvcallsif internally in libxl to avoid `pvcallss'

---
 docs/misc/xenstore-paths.markdown    |  9 +++++++++
 tools/libxl/Makefile                 |  2 +-
 tools/libxl/libxl.h                  | 10 ++++++++++
 tools/libxl/libxl_create.c           |  4 ++++
 tools/libxl/libxl_internal.h         |  1 +
 tools/libxl/libxl_pvcalls.c          | 37 ++++++++++++++++++++++++++++++++++++
 tools/libxl/libxl_types.idl          |  7 +++++++
 tools/libxl/libxl_types_internal.idl |  1 +
 tools/xl/xl_parse.c                  | 37 +++++++++++++++++++++++++++++++++++-
 9 files changed, 106 insertions(+), 2 deletions(-)
 create mode 100644 tools/libxl/libxl_pvcalls.c
docs/misc/xenstore-paths.markdown +9 -0
index 7be2592..77d1a36 100644
@@ -299,6 +299,11 @@ A virtual scsi device frontend. Described by
 A virtual usb device frontend. Described by
 [xen/include/public/io/usbif.h][USBIF]
 
+#### ~/device/pvcalls/$DEVID/* []
+
+Paravirtualized POSIX function calls frontend. Described by
+[docs/misc/pvcalls.markdown][PVCALLS]
+
 #### ~/console/* []
 
 The primary PV console device. Described in [console.txt](console.txt)
@@ -377,6 +382,10 @@ A PV SCSI backend.
 
 A PV USB backend. Described by
 [xen/include/public/io/usbif.h][USBIF]
+ 
+#### ~/backend/pvcalls/$DOMID/$DEVID/* []
+
+A PVCalls backend. Described in [docs/misc/pvcalls.markdown][PVCALLS].
 
 #### ~/backend/console/$DOMID/$DEVID/* []
 
tools/libxl/Makefile +1 -1
index 917ceb0..035e66e 100644
@@ -140,7 +140,7 @@ LIBXL_OBJS = flexarray.o libxl.o libxl_create.o libxl_dm.o libxl_pci.o \
 			libxl_vtpm.o libxl_nic.o libxl_disk.o libxl_console.o \
 			libxl_cpupool.o libxl_mem.o libxl_sched.o libxl_tmem.o \
 			libxl_9pfs.o libxl_domain.o libxl_vdispl.o \
-                        $(LIBXL_OBJS-y)
+                        libxl_pvcalls.o $(LIBXL_OBJS-y)
 LIBXL_OBJS += libxl_genid.o
 LIBXL_OBJS += _libxl_types.o libxl_flask.o _libxl_types_internal.o
 
tools/libxl/libxl.h +10 -0
index eca0ea2..c4eccc5 100644
@@ -2006,6 +2006,16 @@ int libxl_device_p9_destroy(libxl_ctx *ctx, uint32_t domid,
                             const libxl_asyncop_how *ao_how)
                             LIBXL_EXTERNAL_CALLERS_ONLY;
 
+/* pvcalls interface */
+int libxl_device_pvcallsif_remove(libxl_ctx *ctx, uint32_t domid,
+                                  libxl_device_pvcallsif *pvcallsif,
+                                  const libxl_asyncop_how *ao_how)
+                                  LIBXL_EXTERNAL_CALLERS_ONLY;
+int libxl_device_pvcallsif_destroy(libxl_ctx *ctx, uint32_t domid,
+                                   libxl_device_pvcallsif *pvcallsif,
+                                   const libxl_asyncop_how *ao_how)
+                                   LIBXL_EXTERNAL_CALLERS_ONLY;
+
 /* PCI Passthrough */
 int libxl_device_pci_add(libxl_ctx *ctx, uint32_t domid,
                          libxl_device_pci *pcidev,
tools/libxl/libxl_create.c +4 -0
index c498135..c43f391 100644
@@ -1374,6 +1374,10 @@ static void domcreate_launch_dm(libxl__egc *egc, libxl__multidev *multidev,
     for (i = 0; i < d_config->num_p9s; i++)
         libxl__device_add(gc, domid, &libxl__p9_devtype, &d_config->p9s[i]);
 
+    for (i = 0; i < d_config->num_pvcallsifs; i++)
+        libxl__device_add(gc, domid, &libxl__pvcallsif_devtype,
+                          &d_config->pvcallsifs[i]);
+
     switch (d_config->c_info.type) {
     case LIBXL_DOMAIN_TYPE_HVM:
     {
tools/libxl/libxl_internal.h +1 -0
index 506687f..50209ff 100644
@@ -3648,6 +3648,7 @@ extern const struct libxl_device_type libxl__usbdev_devtype;
 extern const struct libxl_device_type libxl__pcidev_devtype;
 extern const struct libxl_device_type libxl__vdispl_devtype;
 extern const struct libxl_device_type libxl__p9_devtype;
+extern const struct libxl_device_type libxl__pvcallsif_devtype;
 
 extern const struct libxl_device_type *device_type_tbl[];
 
tools/libxl/libxl_pvcalls.c new file +37 -0
new file mode 100644
index 0000000..bb6f307
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2018      Aporeto
+ * Author Stefano Stabellini <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; version 2.1 only. with the special
+ * exception on linking described in file LICENSE.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ */
+
+#include "libxl_osdeps.h"
+
+#include "libxl_internal.h"
+
+static int libxl__device_pvcallsif_setdefault(libxl__gc *gc, uint32_t domid,
+                                            libxl_device_pvcallsif *pvcallsif,
+                                            bool hotplug)
+{
+    return libxl__resolve_domid(gc, pvcallsif->backend_domname,
+                                &pvcallsif->backend_domid);
+}
+
+static LIBXL_DEFINE_UPDATE_DEVID(pvcallsif)
+static LIBXL_DEFINE_DEVICE_FROM_TYPE(pvcallsif)
+
+#define libxl__add_pvcallsifs NULL
+#define libxl_device_pvcallsif_list NULL
+#define libxl_device_pvcallsif_compare NULL
+
+LIBXL_DEFINE_DEVICE_REMOVE(pvcallsif)
+
+DEFINE_DEVICE_TYPE_STRUCT(pvcallsif, PVCALLS);
tools/libxl/libxl_types.idl +7 -0
index 3503812..0037a64 100644
@@ -790,6 +790,12 @@ libxl_device_p9 = Struct("device_p9", [
     ("devid",            libxl_devid),
 ])
 
+libxl_device_pvcallsif = Struct("device_pvcallsif", [
+    ("backend_domid",    libxl_domid),
+    ("backend_domname",  string),
+    ("devid",            libxl_devid),
+])
+
 libxl_device_channel = Struct("device_channel", [
     ("backend_domid", libxl_domid),
     ("backend_domname", string),
@@ -829,6 +835,7 @@ libxl_domain_config = Struct("domain_config", [
     ("vkbs", Array(libxl_device_vkb, "num_vkbs")),
     ("vtpms", Array(libxl_device_vtpm, "num_vtpms")),
     ("p9s", Array(libxl_device_p9, "num_p9s")),
+    ("pvcallsifs", Array(libxl_device_pvcallsif, "num_pvcallsifs")),
     ("vdispls", Array(libxl_device_vdispl, "num_vdispls")),
     # a channel manifests as a console with a name,
     # see docs/misc/channels.txt
tools/libxl/libxl_types_internal.idl +1 -0
index d144dd6..f2ff017 100644
@@ -28,6 +28,7 @@ libxl__device_kind = Enumeration("device_kind", [
     (11, "9PFS"),
     (12, "VDISPL"),
     (13, "VUART"),
+    (14, "PVCALLS"),
     ])
 
 libxl__console_backend = Enumeration("console_backend", [
tools/xl/xl_parse.c +36 -1
index f684254..17fb7ed 100644
@@ -860,7 +860,7 @@ void parse_config_data(const char *config_source,
     long l, vcpus = 0;
     XLU_Config *config;
     XLU_ConfigList *cpus, *vbds, *nics, *pcis, *cvfbs, *cpuids, *vtpms,
-                   *usbctrls, *usbdevs, *p9devs, *vdispls;
+                   *usbctrls, *usbdevs, *p9devs, *vdispls, *pvcallsifs_devs;
     XLU_ConfigList *channels, *ioports, *irqs, *iomem, *viridian, *dtdevs,
                    *mca_caps;
     int num_ioports, num_irqs, num_iomem, num_cpus, num_viridian, num_mca_caps;
@@ -1691,6 +1691,41 @@ void parse_config_data(const char *config_source,
         }
     }
 
+    if (!xlu_cfg_get_list(config, "pvcalls", &pvcallsifs_devs, 0, 0)) {
+        d_config->num_pvcallsifs = 0;
+        d_config->pvcallsifs = NULL;
+        while ((buf = xlu_cfg_get_listitem (pvcallsifs_devs, d_config->num_pvcallsifs)) != NULL) {
+            libxl_device_pvcallsif *pvcallsif;
+            char *backend = NULL;
+            char *p, *p2, *buf2;
+            pvcallsif = ARRAY_EXTEND_INIT(d_config->pvcallsifs,
+                                   d_config->num_pvcallsifs,
+                                   libxl_device_pvcallsif_init);
+
+            buf2 = strdup(buf);
+            p = strtok(buf2, ",");
+            if (p) {
+               do {
+                  while (*p == ' ')
+                     ++p;
+                  if ((p2 = strchr(p, '=')) == NULL)
+                     break;
+                  *p2 = '\0';
+                  if(!strcmp(p, "backend")) {
+                     backend = strdup(p2 + 1);
+                  } else {
+                     fprintf(stderr, "Unknown string `%s' in pvcalls spec\n", p);
+                     exit(1);
+                  }
+               } while ((p = strtok(NULL, ",")) != NULL);
+            }
+            free(buf2);
+
+            if (backend)
+                    replace_string(&pvcallsif->backend_domname, backend);
+        }
+    }
+
     if (!xlu_cfg_get_list (config, "channel", &channels, 0, 0)) {
         d_config->num_channels = 0;
         d_config->channels = NULL;
Signature · 7 lines
1.9.1


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#1 lore raw
Quoted 204 lines · Stefano Stabellini

Add pvcalls support to libxl and xl. Create the appropriate pvcalls entries in xenstore.

---

Changes in v2:
- rename pvcalls to pvcallsif internally in libxl to avoid `pvcallss'

---
  docs/misc/xenstore-paths.markdown    |  9 +++++++++
  tools/libxl/Makefile                 |  2 +-
  tools/libxl/libxl.h                  | 10 ++++++++++
  tools/libxl/libxl_create.c           |  4 ++++
  tools/libxl/libxl_internal.h         |  1 +
  tools/libxl/libxl_pvcalls.c          | 37 ++++++++++++++++++++++++++++++++++++
  tools/libxl/libxl_types.idl          |  7 +++++++
  tools/libxl/libxl_types_internal.idl |  1 +
  tools/xl/xl_parse.c                  | 37 +++++++++++++++++++++++++++++++++++-
  9 files changed, 106 insertions(+), 2 deletions(-)

create mode 100644 tools/libxl/libxl_pvcalls.c

docs/misc/xenstore-paths.markdown +9 -0
index 7be2592..77d1a36 100644
@@ -299,6 +299,11 @@ A virtual scsi device frontend. Described by
  A virtual usb device frontend. Described by
  [xen/include/public/io/usbif.h][USBIF]
 
+#### ~/device/pvcalls/$DEVID/* []
+
+Paravirtualized POSIX function calls frontend. Described by
+[docs/misc/pvcalls.markdown][PVCALLS]
+
  #### ~/console/* []
 
  The primary PV console device. Described in [console.txt](console.txt)
@@ -377,6 +382,10 @@ A PV SCSI backend.
 
  A PV USB backend. Described by
  [xen/include/public/io/usbif.h][USBIF]
+
+#### ~/backend/pvcalls/$DOMID/$DEVID/* []
+
+A PVCalls backend. Described in [docs/misc/pvcalls.markdown][PVCALLS].
 
  #### ~/backend/console/$DOMID/$DEVID/* []
 
tools/libxl/Makefile +1 -1
index 917ceb0..035e66e 100644
@@ -140,7 +140,7 @@ LIBXL_OBJS = flexarray.o libxl.o libxl_create.o libxl_dm.o libxl_pci.o \
  			libxl_vtpm.o libxl_nic.o libxl_disk.o libxl_console.o \
  			libxl_cpupool.o libxl_mem.o libxl_sched.o libxl_tmem.o \
  			libxl_9pfs.o libxl_domain.o libxl_vdispl.o \
-                        $(LIBXL_OBJS-y)
+                        libxl_pvcalls.o $(LIBXL_OBJS-y)
  LIBXL_OBJS += libxl_genid.o
  LIBXL_OBJS += _libxl_types.o libxl_flask.o _libxl_types_internal.o
 
tools/libxl/libxl.h +10 -0
index eca0ea2..c4eccc5 100644
@@ -2006,6 +2006,16 @@ int libxl_device_p9_destroy(libxl_ctx *ctx, uint32_t domid,
                              const libxl_asyncop_how *ao_how)
                              LIBXL_EXTERNAL_CALLERS_ONLY;
 
+/* pvcalls interface */
+int libxl_device_pvcallsif_remove(libxl_ctx *ctx, uint32_t domid,
+                                  libxl_device_pvcallsif *pvcallsif,
+                                  const libxl_asyncop_how *ao_how)
+                                  LIBXL_EXTERNAL_CALLERS_ONLY;
+int libxl_device_pvcallsif_destroy(libxl_ctx *ctx, uint32_t domid,
+                                   libxl_device_pvcallsif *pvcallsif,
+                                   const libxl_asyncop_how *ao_how)
+                                   LIBXL_EXTERNAL_CALLERS_ONLY;
+
  /* PCI Passthrough */
  int libxl_device_pci_add(libxl_ctx *ctx, uint32_t domid,
                           libxl_device_pci *pcidev,
tools/libxl/libxl_create.c +4 -0
index c498135..c43f391 100644
@@ -1374,6 +1374,10 @@ static void domcreate_launch_dm(libxl__egc *egc, libxl__multidev *multidev,
      for (i = 0; i < d_config->num_p9s; i++)
          libxl__device_add(gc, domid, &libxl__p9_devtype, &d_config->p9s[i]);
 
+    for (i = 0; i < d_config->num_pvcallsifs; i++)
+        libxl__device_add(gc, domid, &libxl__pvcallsif_devtype,
+                          &d_config->pvcallsifs[i]);
+
      switch (d_config->c_info.type) {
      case LIBXL_DOMAIN_TYPE_HVM:
      {
tools/libxl/libxl_internal.h +1 -0
index 506687f..50209ff 100644
@@ -3648,6 +3648,7 @@ extern const struct libxl_device_type libxl__usbdev_devtype;
  extern const struct libxl_device_type libxl__pcidev_devtype;
  extern const struct libxl_device_type libxl__vdispl_devtype;
  extern const struct libxl_device_type libxl__p9_devtype;
+extern const struct libxl_device_type libxl__pvcallsif_devtype;
 
  extern const struct libxl_device_type *device_type_tbl[];
 
tools/libxl/libxl_pvcalls.c new file +37 -0
new file mode 100644
index 0000000..bb6f307
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2018      Aporeto
+ * Author Stefano Stabellini <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; version 2.1 only. with the special
+ * exception on linking described in file LICENSE.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ */
+
+#include "libxl_osdeps.h"
+
+#include "libxl_internal.h"
+
+static int libxl__device_pvcallsif_setdefault(libxl__gc *gc, uint32_t domid,
+                                            libxl_device_pvcallsif *pvcallsif,
+                                            bool hotplug)
+{
+    return libxl__resolve_domid(gc, pvcallsif->backend_domname,
+                                &pvcallsif->backend_domid);
+}
+
+static LIBXL_DEFINE_UPDATE_DEVID(pvcallsif)
+static LIBXL_DEFINE_DEVICE_FROM_TYPE(pvcallsif)
+
+#define libxl__add_pvcallsifs NULL
+#define libxl_device_pvcallsif_list NULL
+#define libxl_device_pvcallsif_compare NULL
+
+LIBXL_DEFINE_DEVICE_REMOVE(pvcallsif)
+
+DEFINE_DEVICE_TYPE_STRUCT(pvcallsif, PVCALLS);
tools/libxl/libxl_types.idl +7 -0
index 3503812..0037a64 100644
@@ -790,6 +790,12 @@ libxl_device_p9 = Struct("device_p9", [
      ("devid",            libxl_devid),
  ])
 
+libxl_device_pvcallsif = Struct("device_pvcallsif", [
+    ("backend_domid",    libxl_domid),
+    ("backend_domname",  string),
+    ("devid",            libxl_devid),
+])
+
  libxl_device_channel = Struct("device_channel", [
      ("backend_domid", libxl_domid),
      ("backend_domname", string),
@@ -829,6 +835,7 @@ libxl_domain_config = Struct("domain_config", [
      ("vkbs", Array(libxl_device_vkb, "num_vkbs")),
      ("vtpms", Array(libxl_device_vtpm, "num_vtpms")),
      ("p9s", Array(libxl_device_p9, "num_p9s")),
+    ("pvcallsifs", Array(libxl_device_pvcallsif, "num_pvcallsifs")),
      ("vdispls", Array(libxl_device_vdispl, "num_vdispls")),
      # a channel manifests as a console with a name,
      # see docs/misc/channels.txt
tools/libxl/libxl_types_internal.idl +1 -0
index d144dd6..f2ff017 100644
@@ -28,6 +28,7 @@ libxl__device_kind = Enumeration("device_kind", [
      (11, "9PFS"),
      (12, "VDISPL"),
      (13, "VUART"),
+    (14, "PVCALLS"),
      ])
 
  libxl__console_backend = Enumeration("console_backend", [
tools/xl/xl_parse.c +1 -1
index f684254..17fb7ed 100644
@@ -860,7 +860,7 @@ void parse_config_data(const char *config_source,
      long l, vcpus = 0;
      XLU_Config *config;
      XLU_ConfigList *cpus, *vbds, *nics, *pcis, *cvfbs, *cpuids, *vtpms,
-                   *usbctrls, *usbdevs, *p9devs, *vdispls;
+                   *usbctrls, *usbdevs, *p9devs, *vdispls, *pvcallsifs_devs;
      XLU_ConfigList *channels, *ioports, *irqs, *iomem, *viridian, *dtdevs,
                     *mca_caps;
      int num_ioports, num_irqs, num_iomem, num_cpus, num_viridian, num_mca_caps;

tools/xl/xl_parse.c void parse_config_data(const char *config_source, · line 1694

Quoted 4 lines
tools/xl/xl_parse.c +1 -0
@@ -1691,6 +1691,41 @@ void parse_config_data(const char *config_source,
          }
      }
 
+    if (!xlu_cfg_get_list(config, "pvcalls", &pvcallsifs_devs, 0, 0)) {

It would be nice to see an example of the pvcalls setting in xl.cfg man page :-).

Regards,
Jim

Quoted 28 lines
tools/xl/xl_parse.c +27 -0
+        d_config->num_pvcallsifs = 0;
+        d_config->pvcallsifs = NULL;
+        while ((buf = xlu_cfg_get_listitem (pvcallsifs_devs, d_config->num_pvcallsifs)) != NULL) {
+            libxl_device_pvcallsif *pvcallsif;
+            char *backend = NULL;
+            char *p, *p2, *buf2;
+            pvcallsif = ARRAY_EXTEND_INIT(d_config->pvcallsifs,
+                                   d_config->num_pvcallsifs,
+                                   libxl_device_pvcallsif_init);
+
+            buf2 = strdup(buf);
+            p = strtok(buf2, ",");
+            if (p) {
+               do {
+                  while (*p == ' ')
+                     ++p;
+                  if ((p2 = strchr(p, '=')) == NULL)
+                     break;
+                  *p2 = '\0';
+                  if(!strcmp(p, "backend")) {
+                     backend = strdup(p2 + 1);
+                  } else {
+                     fprintf(stderr, "Unknown string `%s' in pvcalls spec\n", p);
+                     exit(1);
+                  }
+               } while ((p = strtok(NULL, ",")) != NULL);
+            }

tools/xl/xl_parse.c void parse_config_data(const char *config_source, · line 1731

Quoted 10 lines
tools/xl/xl_parse.c +7 -0
+            free(buf2);
+
+            if (backend)
+                    replace_string(&pvcallsif->backend_domname, backend);
+        }
+    }
+
      if (!xlu_cfg_get_list (config, "channel", &channels, 0, 0)) {
          d_config->num_channels = 0;
          d_config->channels = NULL;

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

Acked-by on v2 1/1
#3 lore raw
In reply to Stefano Stabellini
Quoted 4 lines · Stefano Stabellini

Add pvcalls support to libxl and xl. Create the appropriate pvcalls entries in xenstore.

Please also submit a doc patch.

tools/libxl/libxl_pvcalls.c line 22

Quoted 7 lines
tools/libxl/libxl_pvcalls.c new file +7 -0
+#include "libxl_osdeps.h"
+
+#include "libxl_internal.h"
+
+static int libxl__device_pvcallsif_setdefault(libxl__gc *gc, uint32_t domid,
+                                            libxl_device_pvcallsif *pvcallsif,
+                                            bool hotplug)

Indentation needs fixing, but this can be done upon committing.

tools/xl/xl_parse.c void parse_config_data(const char *config_source, · line 1703

Quoted 11 lines
tools/xl/xl_parse.c +10 -0
+    if (!xlu_cfg_get_list(config, "pvcalls", &pvcallsifs_devs, 0, 0)) {
+        d_config->num_pvcallsifs = 0;
+        d_config->pvcallsifs = NULL;
+        while ((buf = xlu_cfg_get_listitem (pvcallsifs_devs, d_config->num_pvcallsifs)) != NULL) {
+            libxl_device_pvcallsif *pvcallsif;
+            char *backend = NULL;
+            char *p, *p2, *buf2;
+            pvcallsif = ARRAY_EXTEND_INIT(d_config->pvcallsifs,
+                                   d_config->num_pvcallsifs,
+                                   libxl_device_pvcallsif_init);

Same here.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#4 lore raw
Quoted 9 lines · Wei Liu
Quoted 4 lines · Stefano Stabellini

Add pvcalls support to libxl and xl. Create the appropriate pvcalls entries in xenstore.

Please also submit a doc patch.

I also realised there was no LIBXL_HAVE macro defined after having committed this patch. Please fix that as well.

Wei.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#2 lore raw
In reply to Jim Fehlig
Quoted 206 lines · Jim Fehlig
Quoted 205 lines · Stefano Stabellini

Add pvcalls support to libxl and xl. Create the appropriate pvcalls entries in xenstore.

---

Changes in v2:
- rename pvcalls to pvcallsif internally in libxl to avoid `pvcallss'

---
  docs/misc/xenstore-paths.markdown    |  9 +++++++++
  tools/libxl/Makefile                 |  2 +-
  tools/libxl/libxl.h                  | 10 ++++++++++
  tools/libxl/libxl_create.c           |  4 ++++
  tools/libxl/libxl_internal.h         |  1 +
  tools/libxl/libxl_pvcalls.c          | 37
++++++++++++++++++++++++++++++++++++
  tools/libxl/libxl_types.idl          |  7 +++++++
  tools/libxl/libxl_types_internal.idl |  1 +
  tools/xl/xl_parse.c                  | 37
+++++++++++++++++++++++++++++++++++-
  9 files changed, 106 insertions(+), 2 deletions(-)

create mode 100644 tools/libxl/libxl_pvcalls.c

docs/misc/xenstore-paths.markdown +8 -0
index 7be2592..77d1a36 100644
@@ -299,6 +299,11 @@ A virtual scsi device frontend. Described by
  A virtual usb device frontend. Described by
  [xen/include/public/io/usbif.h][USBIF]
  +#### ~/device/pvcalls/$DEVID/* []
+
+Paravirtualized POSIX function calls frontend. Described by
+[docs/misc/pvcalls.markdown][PVCALLS]
+
  #### ~/console/* []
    The primary PV console device. Described in [console.txt](console.txt)
@@ -377,6 +382,10 @@ A PV SCSI backend.
    A PV USB backend. Described by
  [xen/include/public/io/usbif.h][USBIF]
+
+#### ~/backend/pvcalls/$DOMID/$DEVID/* []
+
+A PVCalls backend. Described in [docs/misc/pvcalls.markdown][PVCALLS].
    #### ~/backend/console/$DOMID/$DEVID/* []
  diff --git a/tools/libxl/Makefile b/tools/libxl/Makefile

index 917ceb0..035e66e 100644

tools/libxl/Makefile +1 -1
@@ -140,7 +140,7 @@ LIBXL_OBJS = flexarray.o libxl.o libxl_create.o
 libxl_dm.o libxl_pci.o \
  			libxl_vtpm.o libxl_nic.o libxl_disk.o libxl_console.o
 \
  			libxl_cpupool.o libxl_mem.o libxl_sched.o libxl_tmem.o
 \
  			libxl_9pfs.o libxl_domain.o libxl_vdispl.o \
-                        $(LIBXL_OBJS-y)
+                        libxl_pvcalls.o $(LIBXL_OBJS-y)

LIBXL_OBJS += libxl_genid.o
LIBXL_OBJS += _libxl_types.o libxl_flask.o _libxl_types_internal.o diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h
index eca0ea2..c4eccc5 100644

tools/libxl/libxl.h +9 -0
@@ -2006,6 +2006,16 @@ int libxl_device_p9_destroy(libxl_ctx *ctx, uint32_t
 domid,
                              const libxl_asyncop_how *ao_how)
                              LIBXL_EXTERNAL_CALLERS_ONLY;
  +/* pvcalls interface */
+int libxl_device_pvcallsif_remove(libxl_ctx *ctx, uint32_t domid,
+                                  libxl_device_pvcallsif *pvcallsif,
+                                  const libxl_asyncop_how *ao_how)
+                                  LIBXL_EXTERNAL_CALLERS_ONLY;
+int libxl_device_pvcallsif_destroy(libxl_ctx *ctx, uint32_t domid,
+                                   libxl_device_pvcallsif *pvcallsif,
+                                   const libxl_asyncop_how *ao_how)
+                                   LIBXL_EXTERNAL_CALLERS_ONLY;
+
  /* PCI Passthrough */
  int libxl_device_pci_add(libxl_ctx *ctx, uint32_t domid,
                           libxl_device_pci *pcidev,
tools/libxl/libxl_create.c +3 -0
index c498135..c43f391 100644
@@ -1374,6 +1374,10 @@ static void domcreate_launch_dm(libxl__egc *egc,
 libxl__multidev *multidev,
      for (i = 0; i < d_config->num_p9s; i++)
          libxl__device_add(gc, domid, &libxl__p9_devtype,
 &d_config->p9s[i]);
  +    for (i = 0; i < d_config->num_pvcallsifs; i++)
+        libxl__device_add(gc, domid, &libxl__pvcallsif_devtype,
+                          &d_config->pvcallsifs[i]);
+
      switch (d_config->c_info.type) {
      case LIBXL_DOMAIN_TYPE_HVM:
      {
tools/libxl/libxl_internal.h +1 -0
index 506687f..50209ff 100644
@@ -3648,6 +3648,7 @@ extern const struct libxl_device_type
 libxl__usbdev_devtype;
  extern const struct libxl_device_type libxl__pcidev_devtype;
  extern const struct libxl_device_type libxl__vdispl_devtype;
  extern const struct libxl_device_type libxl__p9_devtype;
+extern const struct libxl_device_type libxl__pvcallsif_devtype;
    extern const struct libxl_device_type *device_type_tbl[];
  diff --git a/tools/libxl/libxl_pvcalls.c b/tools/libxl/libxl_pvcalls.c

new file mode 100644
index 0000000..bb6f307

tools/libxl/libxl_pvcalls.c new file +20 -0
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2018      Aporeto
+ * Author Stefano Stabellini <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; version 2.1 only. with the special
+ * exception on linking described in file LICENSE.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ */
+
+#include "libxl_osdeps.h"
+
+#include "libxl_internal.h"
+
+static int libxl__device_pvcallsif_setdefault(libxl__gc *gc, uint32_t

domid,
+ libxl_device_pvcallsif
*pvcallsif,

tools/libxl/libxl_pvcalls.c new file +16 -0
+                                            bool hotplug)
+{
+    return libxl__resolve_domid(gc, pvcallsif->backend_domname,
+                                &pvcallsif->backend_domid);
+}
+
+static LIBXL_DEFINE_UPDATE_DEVID(pvcallsif)
+static LIBXL_DEFINE_DEVICE_FROM_TYPE(pvcallsif)
+
+#define libxl__add_pvcallsifs NULL
+#define libxl_device_pvcallsif_list NULL
+#define libxl_device_pvcallsif_compare NULL
+
+LIBXL_DEFINE_DEVICE_REMOVE(pvcallsif)
+
+DEFINE_DEVICE_TYPE_STRUCT(pvcallsif, PVCALLS);
tools/libxl/libxl_types.idl +6 -0
index 3503812..0037a64 100644
@@ -790,6 +790,12 @@ libxl_device_p9 = Struct("device_p9", [
      ("devid",            libxl_devid),
  ])
  +libxl_device_pvcallsif = Struct("device_pvcallsif", [
+    ("backend_domid",    libxl_domid),
+    ("backend_domname",  string),
+    ("devid",            libxl_devid),
+])
+
  libxl_device_channel = Struct("device_channel", [
      ("backend_domid", libxl_domid),
      ("backend_domname", string),
@@ -829,6 +835,7 @@ libxl_domain_config = Struct("domain_config", [
      ("vkbs", Array(libxl_device_vkb, "num_vkbs")),
      ("vtpms", Array(libxl_device_vtpm, "num_vtpms")),
      ("p9s", Array(libxl_device_p9, "num_p9s")),
+    ("pvcallsifs", Array(libxl_device_pvcallsif, "num_pvcallsifs")),
      ("vdispls", Array(libxl_device_vdispl, "num_vdispls")),
      # a channel manifests as a console with a name,
      # see docs/misc/channels.txt
tools/libxl/libxl_types_internal.idl +1 -0
index d144dd6..f2ff017 100644
@@ -28,6 +28,7 @@ libxl__device_kind = Enumeration("device_kind", [
      (11, "9PFS"),
      (12, "VDISPL"),
      (13, "VUART"),
+    (14, "PVCALLS"),
      ])
    libxl__console_backend = Enumeration("console_backend", [
tools/xl/xl_parse.c +1 -1
index f684254..17fb7ed 100644
@@ -860,7 +860,7 @@ void parse_config_data(const char *config_source,
      long l, vcpus = 0;
      XLU_Config *config;
      XLU_ConfigList *cpus, *vbds, *nics, *pcis, *cvfbs, *cpuids, *vtpms,
-                   *usbctrls, *usbdevs, *p9devs, *vdispls;
+                   *usbctrls, *usbdevs, *p9devs, *vdispls,
 *pvcallsifs_devs;
      XLU_ConfigList *channels, *ioports, *irqs, *iomem, *viridian, *dtdevs,
                     *mca_caps;

int num_ioports, num_irqs, num_iomem, num_cpus, num_viridian,

Quoted 8 lines

tools/xl/xl_parse.c void parse_config_data(const char *config_source, · line 1693

Quoted 5 lines

num_mca_caps;

tools/xl/xl_parse.c +0 -0
@@ -1691,6 +1691,41 @@ void parse_config_data(const char *config_source,
          }
      }
  +    if (!xlu_cfg_get_list(config, "pvcalls", &pvcallsifs_devs, 0, 0)) {

It would be nice to see an example of the pvcalls setting in xl.cfg man page :-).

I will add :-)
However keep in mind that there is one small patch missing in Linux to enable the pvcalls frontend:

git://git.kernel.org/pub/scm/linux/kernel/git/sstabellini/xen.git pvcalls-4.15

specifically commit b2d2494d918609daa252ed8cfa486fa65c8ece1b

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#5 lore raw
In reply to Wei Liu
Quoted 5 lines · Wei Liu
Quoted 4 lines · Wei Liu
Quoted 3 lines · Stefano Stabellini

Add pvcalls support to libxl and xl. Create the appropriate pvcalls entries in xenstore.

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

Please also submit a doc patch.

I also realised there was no LIBXL_HAVE macro defined after having committed this patch. Please fix that as well.

Thank you for committing!

See this patch:

https://marc.info/?l=xen-devel&m=152243117016149

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel