Skip to contentSkip to conversation

xl add irq support

PATCH In review Matthew Fioravante 2 participants 3 messages Sep 18, 2012 – Sep 19, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 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 [email protected]

tools/libxl/libxl.h +0 -1
@@ -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;
tools/libxl/libxl_create.c +0 -0
@@ -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) {
tools/libxl/libxl_types.idl +5 -0
@@ -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),
tools/libxl/xl_cmdimpl.c +0 -1
@@ -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
[email protected]
http://lists.xen.org/xen-devel

#1 lore raw
Quoted 4 lines · Matthew Fioravante

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.

#2 lore raw

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.

Quoted 4 lines · Ian Campbell
Quoted 3 lines · Matthew Fioravante

This patch adds support for mapping irqs into virtual machines. The syntax is

Quoted 10 lines
Quoted 1 line

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
[email protected]
http://lists.xen.org/xen-devel