On Thu, 13 Oct 2016, Stefano Stabellini wrote:
> Hi all,
>
> This is the design document of the PV Calls protocol. You can find
> prototypes of the Linux frontend and backend drivers here:
>
> git://git.kernel.org/pub/scm/linux/kernel/git/sstabellini/xen.git pvcalls-7
>
> To use them, make sure to enable CONFIG_XEN_PVCALLS in your kernel
> config and add "pvcalls=1" to the command line of your DomU Linux
> kernel. You also need the toolstack to create the initial xenstore nodes
> for the protocol. To do that, please apply the attached patch to libxl
> (the patch is based on Xen 4.7.0-rc3) and add "pvcalls=1" to your DomU
> config file.
There is a small mistake in the patch attached to my previous email,
which breaks cases where pvcalls is unspecified. This patch should work
as expected.
diff --git a/docs/man/xl.cfg.pod.5 b/docs/man/xl.cfg.pod.5
index a4cc1b3..fd67429 100644
--- a/docs/man/xl.cfg.pod.5
+++ b/docs/man/xl.cfg.pod.5
@@ -488,6 +488,11 @@ Specifies the networking provision (both emulated network
adapters,
and Xen virtual interfaces) to provided to the guest. See
F<docs/misc/xl-network-configuration.markdown>.
+=item B<pvcalls=BOOLEAN>
+
+Enables the paravirtualized function calls protocol. Please see
+F<docs/misc/pvcalls.markdown> for more details.
+
=item B<vtpm=[ "VTPM_SPEC_STRING", "VTPM_SPEC_STRING", ...]>
Specifies the virtual trusted platform module to be
diff --git a/docs/misc/xenstore-paths.markdown
b/docs/misc/xenstore-paths.markdown
index 2a37dae..cea99d5 100644
--- a/docs/misc/xenstore-paths.markdown
+++ b/docs/misc/xenstore-paths.markdown
@@ -275,6 +275,12 @@ 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)
@@ -354,6 +360,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.
+
#### ~/backend/console/$DOMID/$DEVID/* []
A PV console backend. Described in [console.txt](console.txt)
diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
index c39d745..d784a10 100644
--- a/tools/libxl/libxl.c
+++ b/tools/libxl/libxl.c
@@ -2299,6 +2299,70 @@ int libxl_devid_to_device_vtpm(libxl_ctx *ctx,
return rc;
}
+/******************************************************************************/
+
+int libxl__device_pvcalls_setdefault(libxl__gc *gc, libxl_device_pvcalls
*pvcalls)
+{
+ int rc;
+
+ rc = libxl__resolve_domid(gc, pvcalls->backend_domname,
&pvcalls->backend_domid);
+ return rc;
+}
+
+static int libxl__device_from_pvcalls(libxl__gc *gc, uint32_t domid,
+ libxl_device_pvcalls *pvcalls,
+ libxl__device *device)
+{
+ device->backend_devid = pvcalls->devid;
+ device->backend_domid = pvcalls->backend_domid;
+ device->backend_kind = LIBXL__DEVICE_KIND_PVCALLS;
+ device->devid = pvcalls->devid;
+ device->domid = domid;
+ device->kind = LIBXL__DEVICE_KIND_PVCALLS;
+
+ return 0;
+}
+
+
+int libxl__device_pvcalls_add(libxl__gc *gc, uint32_t domid,
+ libxl_device_pvcalls *pvcalls)
+{
+ flexarray_t *front;
+ flexarray_t *back;
+ libxl__device device;
+ int rc;
+
+ rc = libxl__device_pvcalls_setdefault(gc, pvcalls);
+ if (rc) goto out;
+
+ front = flexarray_make(gc, 16, 1);
+ back = flexarray_make(gc, 16, 1);
+
+ if (pvcalls->devid == -1) {
+ if ((pvcalls->devid = libxl__device_nextid(gc, domid, "pvcalls")) < 0)
{
+ rc = ERROR_FAIL;
+ goto out;
+ }
+ }
+
+ rc = libxl__device_from_pvcalls(gc, domid, pvcalls, &device);
+ if (rc != 0) goto out;
+
+ flexarray_append_pair(back, "frontend-id", libxl__sprintf(gc, "%d",
domid));
+ flexarray_append_pair(back, "online", "1");
+ flexarray_append_pair(back, "state", GCSPRINTF("%d",
XenbusStateInitialising));
+ flexarray_append_pair(front, "backend-id",
+ libxl__sprintf(gc, "%d", pvcalls->backend_domid));
+ flexarray_append_pair(front, "state", GCSPRINTF("%d",
XenbusStateInitialising));
+
+ libxl__device_generic_add(gc, XBT_NULL, &device,
+ libxl__xs_kvs_of_flexarray(gc, back,
back->count),
+ libxl__xs_kvs_of_flexarray(gc, front,
front->count),
+ NULL);
+ rc = 0;
+out:
+ return rc;
+}
/******************************************************************************/
@@ -4250,6 +4314,8 @@ out:
* libxl_device_vfb_destroy
* libxl_device_usbctrl_remove
* libxl_device_usbctrl_destroy
+ * libxl_device_pvcalls_remove
+ * libxl_device_pvcalls_destroy
*/
#define DEFINE_DEVICE_REMOVE_EXT(type, remtype, removedestroy, f) \
int libxl_device_##type##_##removedestroy(libxl_ctx *ctx, \
@@ -4311,6 +4377,11 @@ DEFINE_DEVICE_REMOVE(vtpm, destroy, 1)
DEFINE_DEVICE_REMOVE_CUSTOM(usbctrl, remove, 0)
DEFINE_DEVICE_REMOVE_CUSTOM(usbctrl, destroy, 1)
+/* pvcalls */
+
+DEFINE_DEVICE_REMOVE(pvcalls, remove, 0)
+DEFINE_DEVICE_REMOVE(pvcalls, destroy, 1)
+
/* channel/console hotunplug is not implemented. There are 2 possibilities:
* 1. add support for secondary consoles to xenconsoled
* 2. dynamically add/remove qemu chardevs via qmp messages. */
diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h
index 2c0f868..9358071 100644
--- a/tools/libxl/libxl.h
+++ b/tools/libxl/libxl.h
@@ -1753,6 +1753,16 @@ int libxl_device_vfb_destroy(libxl_ctx *ctx, uint32_t
domid,
const libxl_asyncop_how *ao_how)
LIBXL_EXTERNAL_CALLERS_ONLY;
+/* pvcalls */
+int libxl_device_pvcalls_remove(libxl_ctx *ctx, uint32_t domid,
+ libxl_device_pvcalls *pvcalls,
+ const libxl_asyncop_how *ao_how)
+ LIBXL_EXTERNAL_CALLERS_ONLY;
+int libxl_device_pvcalls_destroy(libxl_ctx *ctx, uint32_t domid,
+ libxl_device_pvcalls *pvcalls,
+ 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,
diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c
index 5000bd0..433fd49 100644
--- a/tools/libxl/libxl_create.c
+++ b/tools/libxl/libxl_create.c
@@ -1327,6 +1327,9 @@ static void domcreate_launch_dm(libxl__egc *egc,
libxl__multidev *multidev,
libxl__device_console_dispose(&console);
}
+ if (libxl_defbool_val(d_config->pvcalls.enabled))
+ libxl__device_pvcalls_add(gc, domid, &d_config->pvcalls);
+
switch (d_config->c_info.type) {
case LIBXL_DOMAIN_TYPE_HVM:
{
diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
index c791418..063d926 100644
--- a/tools/libxl/libxl_internal.h
+++ b/tools/libxl/libxl_internal.h
@@ -1224,6 +1224,7 @@ _hidden int libxl__device_vkb_setdefault(libxl__gc *gc,
libxl_device_vkb *vkb);
_hidden int libxl__device_pci_setdefault(libxl__gc *gc, libxl_device_pci *pci);
_hidden void libxl__rdm_setdefault(libxl__gc *gc,
libxl_domain_build_info *b_info);
+_hidden int libxl__device_pvcalls_setdefault(libxl__gc *gc,
libxl_device_pvcalls *pvcalls);
_hidden const char *libxl__device_nic_devname(libxl__gc *gc,
uint32_t domid,
@@ -2647,6 +2648,10 @@ _hidden int libxl__device_vkb_add(libxl__gc *gc,
uint32_t domid,
_hidden int libxl__device_vfb_add(libxl__gc *gc, uint32_t domid,
libxl_device_vfb *vfb);
+/* Internal function to connect a pvcalls device */
+_hidden int libxl__device_pvcalls_add(libxl__gc *gc, uint32_t domid,
+ libxl_device_pvcalls *pvcalls);
+
/* Waits for the passed device to reach state XenbusStateInitWait.
* This is not really useful by itself, but is important when executing
* hotplug scripts, since we need to be sure the device is in the correct
diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl
index 9840f3b..8131a93 100644
--- a/tools/libxl/libxl_types.idl
+++ b/tools/libxl/libxl_types.idl
@@ -685,6 +685,13 @@ libxl_device_vtpm = Struct("device_vtpm", [
("uuid", libxl_uuid),
])
+libxl_device_pvcalls = Struct("device_pvcalls", [
+ ("backend_domid", libxl_domid),
+ ("backend_domname", string),
+ ("devid", libxl_devid),
+ ("enabled", libxl_defbool),
+])
+
libxl_device_channel = Struct("device_channel", [
("backend_domid", libxl_domid),
("backend_domname", string),
@@ -709,6 +716,7 @@ libxl_domain_config = Struct("domain_config", [
("vfbs", Array(libxl_device_vfb, "num_vfbs")),
("vkbs", Array(libxl_device_vkb, "num_vkbs")),
("vtpms", Array(libxl_device_vtpm, "num_vtpms")),
+ ("pvcalls", libxl_device_pvcalls),
# a channel manifests as a console with a name,
# see docs/misc/channels.txt
("channels", Array(libxl_device_channel, "num_channels")),
diff --git a/tools/libxl/libxl_types_internal.idl
b/tools/libxl/libxl_types_internal.idl
index 177f9b7..b41122b 100644
--- a/tools/libxl/libxl_types_internal.idl
+++ b/tools/libxl/libxl_types_internal.idl
@@ -24,6 +24,7 @@ libxl__device_kind = Enumeration("device_kind", [
(8, "VTPM"),
(9, "VUSB"),
(10, "QUSB"),
+ (11, "PVCALLS"),
])
libxl__console_backend = Enumeration("console_backend", [
diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
index 03ab644..0efe7c1 100644
--- a/tools/libxl/xl_cmdimpl.c
+++ b/tools/libxl/xl_cmdimpl.c
@@ -1898,6 +1898,11 @@ static void parse_config_data(const char *config_source,
free(buf2);
}
}
+
+ if (xlu_cfg_get_defbool(config, "pvcalls", &d_config->pvcalls.enabled, 0))
+ libxl_defbool_set(&d_config->pvcalls.enabled, false);
+ else if (libxl_defbool_val(d_config->pvcalls.enabled))
+ replace_string(&d_config->pvcalls.backend_domname, "0");
if (!xlu_cfg_get_list (config, "channel", &channels, 0, 0)) {
d_config->num_channels = 0;
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel