Matthew Fioravante
2012-Sep-18 18:17 UTC
[PATCH xm/xl enhancements for vptm 4/6] xl add irq support
This patch adds support for mapping irqs into virtual machines. The syntax is irq = [irqnum,allow] Signed off by Matthew Fioravante matthew.fioravante@jhuapl.edu 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; + int num_disks, num_vifs, num_pcidevs, num_vfbs, num_vkbs, num_vtpms, num_iorngs, num_irqs; libxl_device_disk *disks; libxl_device_nic *vifs; @@ -486,6 +486,7 @@ typedef struct { libxl_device_vkb *vkbs; libxl_device_vtpm *vtpms; libxl_iomem_range *iorngs; + libxl_irq *irqs; 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 @@ -62,6 +62,10 @@ void libxl_domain_config_dispose(libxl_domain_config *d_config) libxl_iomem_range_dispose(&d_config->iorngs[i]); free(d_config->iorngs); + for (i=0; i<d_config->num_irqs; i++) + libxl_irq_dispose(&d_config->irqs[i]); + free(d_config->irqs); + libxl_domain_create_info_dispose(&d_config->c_info); libxl_domain_build_info_dispose(&d_config->b_info); } @@ -731,6 +735,15 @@ static void domcreate_bootloader_done(libxl__egc *egc, goto error_out; } } + for (i = 0; i < d_config->num_irqs; i++) { + ret = xc_domain_irq_permission(ctx->xch, domid, d_config->irqs[i].irq, d_config->irqs[i].allow); + if (ret) { + LIBXL__LOG(ctx, LIBXL__LOG_ERROR, + "cannot add irq %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 @@ -323,6 +323,11 @@ libxl_iomem_range = Struct("iomem_range", [ ("allow", bool), ]); +libxl_irq = Struct("irq", [ + ("irq", 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; + XLU_ConfigList *cpus, *vbds, *nics, *pcis, *cvfbs, *cpuids, *vtpms, *iomems, *irqs; int pci_power_mgmt = 0; int pci_msitranslate = 1; int pci_permissive = 0; @@ -1181,6 +1181,39 @@ skip_vfb: } } + if(!xlu_cfg_get_list(config, "irq", &irqs, 0, 0)) { + int i; + for(i = 0; (buf = xlu_cfg_get_listitem(irqs, i)) != NULL; ++i) { + libxl_irq* irq; + char* buf2 = strdup(buf); + char* irqstr, *al; + + d_config->irqs = realloc(d_config->irqs, sizeof(libxl_irq) * (d_config->num_irqs + 1)); + irq = d_config->irqs + d_config->num_irqs; + + libxl_irq_init(irq); + + irqstr = strtok(buf2, ","); + al = strtok(NULL, ","); + + if(irqstr == NULL || + sscanf(irqstr, "%" PRIu32, &irq->irq) != 1 || + (al != NULL && ((al[0] != ''1'' && al[0] != ''0'') || al[1] != ''\0'')) + ) { + fprintf(stderr, "Malformed irq specification!\n"); + free(buf2); + exit(1); + } + if(al != NULL) { + irq->allow = al[0] - ''0''; + } else { + irq->allow = 1; + } + free(buf2); + d_config->num_irqs++; + } + } + switch (xlu_cfg_get_list(config, "cpuid", &cpuids, 0, 1)) { case 0: { _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel
Ian Campbell
2012-Sep-19 12:34 UTC
Re: [PATCH xm/xl enhancements for vptm 4/6] xl add irq support
On Tue, 2012-09-18 at 19:17 +0100, Matthew Fioravante wrote:> This patch adds support for mapping irqs into virtual machines. The > syntax is > > irq = [irqnum,allow]Xen 4.2 / unstable already has support for specifying irqs. What is allow for (I should have asked this for the previous iomem patch too)? THe default is deny and listing an irq here means allow, do we need to be able to explicitly deny given that? Ian.
Matthew Fioravante
2012-Sep-19 14:06 UTC
Re: [PATCH xm/xl enhancements for vptm 4/6] xl add irq support
its for explicitly saying to allow or deny. It might be redundant since the default is just to deny all of the irqs/mem regions. The allow flag could be excluded. On 09/19/2012 08:34 AM, Ian Campbell wrote:> On Tue, 2012-09-18 at 19:17 +0100, Matthew Fioravante wrote: >> This patch adds support for mapping irqs into virtual machines. The >> syntax is >> >> irq = [irqnum,allow] > Xen 4.2 / unstable already has support for specifying irqs. > > What is allow for (I should have asked this for the previous iomem patch > too)? THe default is deny and listing an irq here means allow, do we > need to be able to explicitly deny given that? > > Ian. > >_______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel