Message ID | alpine.DEB.2.10.1608021655500.10093@sstabellini-ThinkPad-X260 (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Tue, Aug 02, 2016 at 05:35:08PM -0700, 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-4 > > To use them, make sure to enable CONFIG_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. > > Note that previous versions of the protocols were named XenSock. It has > been renamed for clarity of scope and to avoid confusion with hv_sock > and vsock, which are used for inter-VMs communications. > > Cheers, > > Stefano > > Changes in v4: > - rename xensock to pvcalls > > Changes in v3: > - add a dummy element to struct xen_xensock_request to make sure the > size of the struct is the same on both x86_32 and x86_64 > > Changes in v2: > - add max-dataring-page-order > - add "Publish backend features and transport parameters" to backend > xenbus workflow > - update new cmd values > - update xen_xensock_request > - add backlog parameter to listen and binary layout > - add description of new data ring format (interface+data) > - modify connect and accept to reflect new data ring format > - add link to POSIX docs > - add error numbers > - add address format section and relevant numeric definitions > - add explicit mention of unimplemented commands > - add protocol node name > - add xenbus shutdown diagram > - add socket operation > > --- > > # PV Calls Protocol > > ## Rationale > > PV Calls is a paravirtualized protocol for the POSIX socket API. > > The purpose of PV Calls is to allow the implementation of a specific set > of POSIX functions to be done in a domain other than your own. It allows > connect, accept, bind, release, listen, poll, recvmsg and sendmsg to be > implemented in another domain. > The wording isn't really clear here. This design document as-is would inevitably make people start to compare PV Calls to various HV socks I'm afraid. Is PV Calls going to cover other stuff other than socket API? If it targets POSIX interfaces, maybe call it PV POSIX? But then, if you extend the scope to cover POSIX APIs, I think you might want some discovery mechanism to see what APIs are paravirtualised? Wei.
On Wed, 3 Aug 2016, Wei Liu wrote: > > # PV Calls Protocol > > > > ## Rationale > > > > PV Calls is a paravirtualized protocol for the POSIX socket API. > > > > The purpose of PV Calls is to allow the implementation of a specific set > > of POSIX functions to be done in a domain other than your own. It allows > > connect, accept, bind, release, listen, poll, recvmsg and sendmsg to be > > implemented in another domain. > > > > The wording isn't really clear here. This design document as-is would > inevitably make people start to compare PV Calls to various HV socks I'm > afraid. You are right, thanks for the feedback. I'll clarify it. > Is PV Calls going to cover other stuff other than socket API? If it > targets POSIX interfaces, maybe call it PV POSIX? > > But then, if you extend the scope to cover POSIX APIs, I think you might > want some discovery mechanism to see what APIs are paravirtualised? Yes, it can potentially cover other interfaces -- I have a couple of ideas in that area but I need to do some experiments first. I fully agree that we need a discovery mechanism. What it is briefly covered by this document, is that if a cmd is not supported by the backend, ret is ENOTSUPP. But maybe we could also add a version node to xenstore, that could be used to version the protocol supported by the backend.
On Wed, 3 Aug 2016, Stefano Stabellini wrote: > On Wed, 3 Aug 2016, Wei Liu wrote: > > > # PV Calls Protocol > > > > > > ## Rationale > > > > > > PV Calls is a paravirtualized protocol for the POSIX socket API. > > > > > > The purpose of PV Calls is to allow the implementation of a specific set > > > of POSIX functions to be done in a domain other than your own. It allows > > > connect, accept, bind, release, listen, poll, recvmsg and sendmsg to be > > > implemented in another domain. > > > > > > > The wording isn't really clear here. This design document as-is would > > inevitably make people start to compare PV Calls to various HV socks I'm > > afraid. > > You are right, thanks for the feedback. I'll clarify it. Actually there are quite a few things I should change to make this document more generic. They'll be in the next version. > > Is PV Calls going to cover other stuff other than socket API? If it > > targets POSIX interfaces, maybe call it PV POSIX? > > > > But then, if you extend the scope to cover POSIX APIs, I think you might > > want some discovery mechanism to see what APIs are paravirtualised? > > Yes, it can potentially cover other interfaces -- I have a couple of > ideas in that area but I need to do some experiments first. > > I fully agree that we need a discovery mechanism. What it is briefly > covered by this document, is that if a cmd is not supported by the > backend, ret is ENOTSUPP. But maybe we could also add a version node to > xenstore, that could be used to version the protocol supported by the > backend.
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..f019c37 100644 --- a/tools/libxl/libxl_create.c +++ b/tools/libxl/libxl_create.c @@ -1374,6 +1374,8 @@ static void domcreate_launch_dm(libxl__egc *egc, libxl__multidev *multidev, libxl__device_vfb_add(gc, domid, &d_config->vfbs[i]); libxl__device_vkb_add(gc, domid, &d_config->vkbs[i]); } + for (i = 0; i < d_config->num_pvcallss; i++) + libxl__device_pvcalls_add(gc, domid, &d_config->pvcallss[i]); init_console_info(gc, &console, 0); console.backend_domid = state->console_domid; 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..a99c7be 100644 --- a/tools/libxl/libxl_types.idl +++ b/tools/libxl/libxl_types.idl @@ -685,6 +685,12 @@ 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), +]) + libxl_device_channel = Struct("device_channel", [ ("backend_domid", libxl_domid), ("backend_domname", string), @@ -709,6 +715,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")), + ("pvcallss", Array(libxl_device_pvcalls, "num_pvcallss")), # 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..23f9793 100644 --- a/tools/libxl/xl_cmdimpl.c +++ b/tools/libxl/xl_cmdimpl.c @@ -1898,6 +1898,18 @@ static void parse_config_data(const char *config_source, free(buf2); } } + + if (!xlu_cfg_get_long(config, "pvcalls", &l, 0)) { + libxl_device_pvcalls *pvcalls; + fprintf(stderr, "Creating pvcalls l=%lu\n", l); + d_config->num_pvcallss = 0; + d_config->pvcallss = NULL; + pvcalls = ARRAY_EXTEND_INIT(d_config->pvcallss, + d_config->num_pvcallss, + libxl_device_pvcalls_init); + libxl_device_pvcalls_init(pvcalls); + replace_string(&pvcalls->backend_domname, "0"); + } if (!xlu_cfg_get_list (config, "channel", &channels, 0, 0)) { d_config->num_channels = 0;