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;