@@ -737,48 +737,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);
+}
+
+
+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);
- 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);
+ 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,
@@ -824,9 +822,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 {
@@ -834,7 +832,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) ) {
@@ -884,7 +882,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 ) {
@@ -897,7 +895,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 ) {