[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH xm/xl enhancements for vptm 5/6] add ioport support to libxl
This patch adds support for mapping ioports to vms using xl, similar to the function in xm. Signed of by Matthew Fioravante matthew.fioravante@xxxxxxxxxx diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h --- a/tools/libxl/libxl.h +++ b/tools/libxl/libxl.h @@ -477,7 +477,7 @@ typedef struct { libxl_domain_create_info c_info; libxl_domain_build_info b_info; - int num_disks, num_vifs, num_pcidevs, num_vfbs, num_vkbs, num_vtpms, num_iorngs, num_irqs; + int num_disks, num_vifs, num_pcidevs, num_vfbs, num_vkbs, num_vtpms, num_iorngs, num_irqs, num_ioports; libxl_device_disk *disks; libxl_device_nic *vifs; @@ -487,6 +487,7 @@ typedef struct { libxl_device_vtpm *vtpms; libxl_iomem_range *iorngs; libxl_irq *irqs; + libxl_ioport_range *ioports; libxl_action_on_shutdown on_poweroff; libxl_action_on_shutdown on_reboot; diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c --- a/tools/libxl/libxl_create.c +++ b/tools/libxl/libxl_create.c @@ -66,6 +66,10 @@ void libxl_domain_config_dispose(libxl_domain_config *d_config) libxl_irq_dispose(&d_config->irqs[i]); free(d_config->irqs); + for (i=0; i<d_config->num_ioports; i++) + libxl_ioport_range_dispose(&d_config->ioports[i]); + free(d_config->ioports); + libxl_domain_create_info_dispose(&d_config->c_info); libxl_domain_build_info_dispose(&d_config->b_info); } @@ -744,6 +748,16 @@ static void domcreate_bootloader_done(libxl__egc *egc, goto error_out; } } + for (i = 0; i < d_config->num_ioports; i++) { + printf("PORT %d %d %d\n", d_config->ioports[i].start, d_config->ioports[i].nr_ports, d_config->ioports[i].allow); + ret = xc_domain_ioport_permission(ctx->xch, domid, d_config->ioports[i].start, d_config->ioports[i].nr_ports, d_config->ioports[i].allow); + if (ret) { + LIBXL__LOG(ctx, LIBXL__LOG_ERROR, + "cannot add ioport %d to domain: %d", i, ret); + ret = ERROR_FAIL; + goto error_out; + } + } for (i = 0; i < d_config->num_disks; i++) { ret = libxl_device_disk_add(ctx, domid, &d_config->disks[i]); if (ret) { diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl --- a/tools/libxl/libxl_types.idl +++ b/tools/libxl/libxl_types.idl @@ -328,6 +328,13 @@ libxl_irq = Struct("irq", [ ("allow", bool), ]) +libxl_ioport_range = Struct("ioport_range", [ + ("start", uint32), + ("nr_ports", uint32), + ("allow", bool), +]); + + libxl_device_vfb = Struct("device_vfb", [ ("backend_domid", libxl_domid), ("devid", libxl_devid), diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c --- a/tools/libxl/xl_cmdimpl.c +++ b/tools/libxl/xl_cmdimpl.c @@ -560,7 +560,7 @@ static void parse_config_data(const char *config_source, const char *buf; long l; XLU_Config *config; - XLU_ConfigList *cpus, *vbds, *nics, *pcis, *cvfbs, *cpuids, *vtpms, *iomems, *irqs; + XLU_ConfigList *cpus, *vbds, *nics, *pcis, *cvfbs, *cpuids, *vtpms, *iomems, *irqs, *ioports; int pci_power_mgmt = 0; int pci_msitranslate = 1; int pci_permissive = 0; @@ -1214,6 +1214,44 @@ skip_vfb: } } + if(!xlu_cfg_get_list(config, "ioport", &ioports, 0, 0)) { + int i; + for(i =0; (buf = xlu_cfg_get_listitem(ioports, i)) != NULL; ++i) { + libxl_ioport_range* ioport; + char* buf2 = strdup(buf); + char *st, *len, *al; + + d_config->ioports = realloc(d_config->ioports, sizeof(libxl_ioport_range) * (d_config->num_ioports + 1)); + ioport = d_config->ioports + d_config->num_ioports; + + libxl_ioport_range_init(ioport); + + st = strtok(buf2, ","); + len = strtok(NULL, ","); + al = strtok(NULL, ","); + + if(st == NULL || len == NULL || + sscanf(st, "%" PRIu32, &ioport->start) != 1 || + sscanf(len, "%" PRIu32, &ioport->nr_ports) != 1 || + (al != NULL && ((al[0] != '1' && al[0] != '0') || al[1] != '\0')) + ) { + fprintf(stderr, "Malformed ioport specification!\n"); + free(buf2); + exit(1); + } + if(al != NULL) { + ioport->allow = al[0] - '0'; + } else { + ioport->allow = 1; + } + + free(buf2); + d_config->num_ioports++; + } + } + + + switch (xlu_cfg_get_list(config, "cpuid", &cpuids, 0, 1)) { case 0: { Attachment:
smime.p7s _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |