@@ -718,48 +718,46 @@ static int pciback_dev_unassign(libxl__gc *gc, libxl_device_pci *pci)
return 0;
}
-#define PCIBACK_INFO_PATH "/libxl/pciback"
+#define PCI_INFO_PATH "/libxl/pci"
-static void pci_assignable_driver_path_write(libxl__gc *gc,
- libxl_device_pci *pci,
- char *driver_path)
+static char *pci_info_xs_path(libxl__gc *gc, libxl_device_pci *pci,
+ const char *node)
{
- char *path;
+ return node ?
+ GCSPRINTF(PCI_INFO_PATH"/"PCI_BDF_XSPATH"/%s",
+ pci->domain, pci->bus, pci->dev, pci->func,
+ node) :
+ GCSPRINTF(PCI_INFO_PATH"/"PCI_BDF_XSPATH,
+ pci->domain, pci->bus, pci->dev, pci->func);
+}
- path = GCSPRINTF(PCIBACK_INFO_PATH"/"PCI_BDF_XSPATH"/driver_path",
- pci->domain,
- pci->bus,
- pci->dev,
- pci->func);
- if ( libxl__xs_printf(gc, XBT_NULL, path, "%s", driver_path) < 0 ) {
- LOGE(WARN, "Write of %s to node %s failed.", driver_path, path);
+
+static void pci_info_xs_write(libxl__gc *gc, libxl_device_pci *pci,
+ const char *node, const char *val)
+{
+ char *path = pci_info_xs_path(gc, pci, node);
+
+ if ( libxl__xs_printf(gc, XBT_NULL, path, "%s", val) < 0 ) {
+ LOGE(WARN, "Write of %s to node %s failed.", val, path);
}
}
-static char * pci_assignable_driver_path_read(libxl__gc *gc,
- libxl_device_pci *pci)
+static char *pci_info_xs_read(libxl__gc *gc, libxl_device_pci *pci,
+ const char *node)
{
- return libxl__xs_read(gc, XBT_NULL,
- GCSPRINTF(
- PCIBACK_INFO_PATH "/" PCI_BDF_XSPATH "/driver_path",
- pci->domain,
- pci->bus,
- pci->dev,
- pci->func));
+ char *path = pci_info_xs_path(gc, pci, node);
+
+ return libxl__xs_read(gc, XBT_NULL, path);
}
-static void pci_assignable_driver_path_remove(libxl__gc *gc,
- libxl_device_pci *pci)
+static void pci_info_xs_remove(libxl__gc *gc, libxl_device_pci *pci,
+ const char *node)
{
+ char *path = pci_info_xs_path(gc, pci, node);
libxl_ctx *ctx = libxl__gc_owner(gc);
/* Remove the xenstore entry */
- xs_rm(ctx->xsh, XBT_NULL,
- GCSPRINTF(PCIBACK_INFO_PATH "/" PCI_BDF_XSPATH,
- pci->domain,
- pci->bus,
- pci->dev,
- pci->func) );
+ xs_rm(ctx->xsh, XBT_NULL, path);
}
static int libxl__device_pci_assignable_add(libxl__gc *gc,
@@ -805,9 +803,9 @@ static int libxl__device_pci_assignable_add(libxl__gc *gc,
/* Store driver_path for rebinding to dom0 */
if ( rebind ) {
if ( driver_path ) {
- pci_assignable_driver_path_write(gc, pci, driver_path);
+ pci_info_xs_write(gc, pci, "driver_path", driver_path);
} else if ( (driver_path =
- pci_assignable_driver_path_read(gc, pci)) != NULL ) {
+ pci_info_xs_read(gc, pci, "driver_path")) != NULL ) {
LOG(INFO, PCI_BDF" not bound to a driver, will be rebound to %s",
dom, bus, dev, func, driver_path);
} else {
@@ -815,7 +813,7 @@ static int libxl__device_pci_assignable_add(libxl__gc *gc,
dom, bus, dev, func);
}
} else {
- pci_assignable_driver_path_remove(gc, pci);
+ pci_info_xs_remove(gc, pci, "driver_path");
}
if ( pciback_dev_assign(gc, pci) ) {
@@ -865,7 +863,7 @@ static int libxl__device_pci_assignable_remove(libxl__gc *gc,
}
/* Rebind if necessary */
- driver_path = pci_assignable_driver_path_read(gc, pci);
+ driver_path = pci_info_xs_read(gc, pci, "driver_path");
if ( driver_path ) {
if ( rebind ) {
@@ -878,7 +876,7 @@ static int libxl__device_pci_assignable_remove(libxl__gc *gc,
return -1;
}
- pci_assignable_driver_path_remove(gc, pci);
+ pci_info_xs_remove(gc, pci, "driver_path");
}
} else {
if ( rebind ) {