Allow vfio-ccw mdev devices to be created besides vfio-pci mdev devices
as well.
Reviewed-by: Bjoern Walk <bwalk(a)linux.ibm.com>
Signed-off-by: Boris Fiuczynski <fiuczy(a)linux.ibm.com>
---
src/conf/domain_addr.c | 2 +-
src/conf/domain_addr.h | 3 +++
src/libvirt_private.syms | 1 +
src/node_device/node_device_driver.c | 26 ++++++++++++++++++--------
4 files changed, 23 insertions(+), 9 deletions(-)
diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c
index 1068cbf1d2..1bfa164a47 100644
--- a/src/conf/domain_addr.c
+++ b/src/conf/domain_addr.c
@@ -1365,7 +1365,7 @@ virDomainPCIAddressSetAllMulti(virDomainDefPtr def)
}
-static char*
+char*
virDomainCCWAddressAsString(virDomainDeviceCCWAddressPtr addr)
{
return g_strdup_printf("%x.%x.%04x", addr->cssid, addr->ssid,
addr->devno);
diff --git a/src/conf/domain_addr.h b/src/conf/domain_addr.h
index c1363c1490..a0460b4030 100644
--- a/src/conf/domain_addr.h
+++ b/src/conf/domain_addr.h
@@ -208,6 +208,9 @@ int virDomainCCWAddressAssign(virDomainDeviceInfoPtr dev,
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
void virDomainCCWAddressSetFree(virDomainCCWAddressSetPtr addrs);
+char* virDomainCCWAddressAsString(virDomainDeviceCCWAddressPtr addr)
+ ATTRIBUTE_NONNULL(1);
+
virDomainCCWAddressSetPtr
virDomainCCWAddressSetCreateFromDomain(virDomainDefPtr def)
ATTRIBUTE_NONNULL(1);
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 5f1aea3694..5842b8d23d 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -143,6 +143,7 @@ virPCIDeviceAddressParseXML;
# conf/domain_addr.h
virDomainCCWAddressAssign;
+virDomainCCWAddressAsString;
virDomainCCWAddressSetCreateFromDomain;
virDomainCCWAddressSetFree;
virDomainPCIAddressBusIsFullyReserved;
diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_device_driver.c
index e89c8b0ee5..375c1fff32 100644
--- a/src/node_device/node_device_driver.c
+++ b/src/node_device/node_device_driver.c
@@ -28,6 +28,7 @@
#include "virerror.h"
#include "datatypes.h"
+#include "domain_addr.h"
#include "viralloc.h"
#include "virfile.h"
#include "virjson.h"
@@ -628,7 +629,7 @@ nodeDeviceFindAddressByName(const char *name)
{
virNodeDeviceDefPtr def = NULL;
virNodeDevCapsDefPtr caps = NULL;
- char *pci_addr = NULL;
+ char *addr = NULL;
virNodeDeviceObjPtr dev = virNodeDeviceObjListFindByName(driver->devs, name);
if (!dev) {
@@ -640,21 +641,30 @@ nodeDeviceFindAddressByName(const char *name)
def = virNodeDeviceObjGetDef(dev);
for (caps = def->caps; caps != NULL; caps = caps->next) {
if (caps->data.type == VIR_NODE_DEV_CAP_PCI_DEV) {
- virPCIDeviceAddress addr = {
+ virPCIDeviceAddress pci_addr = {
.domain = caps->data.pci_dev.domain,
.bus = caps->data.pci_dev.bus,
.slot = caps->data.pci_dev.slot,
.function = caps->data.pci_dev.function
};
- pci_addr = virPCIDeviceAddressAsString(&addr);
+ addr = virPCIDeviceAddressAsString(&pci_addr);
+ break;
+ } else if (caps->data.type == VIR_NODE_DEV_CAP_CSS_DEV) {
+ virDomainDeviceCCWAddress ccw_addr = {
+ .cssid = caps->data.ccw_dev.cssid,
+ .ssid = caps->data.ccw_dev.ssid,
+ .devno = caps->data.ccw_dev.devno
+ };
+
+ addr = virDomainCCWAddressAsString(&ccw_addr);
break;
}
}
virNodeDeviceObjEndAPI(&dev);
- return pci_addr;
+ return addr;
}
@@ -664,11 +674,11 @@ nodeDeviceGetMdevctlStartCommand(virNodeDeviceDefPtr def,
{
virCommandPtr cmd;
g_autofree char *json = NULL;
- g_autofree char *parent_pci = nodeDeviceFindAddressByName(def->parent);
+ g_autofree char *parent_addr = nodeDeviceFindAddressByName(def->parent);
- if (!parent_pci) {
+ if (!parent_addr) {
virReportError(VIR_ERR_NO_NODE_DEVICE,
- _("unable to find PCI address for parent device
'%s'"), def->parent);
+ _("unable to find parent device '%s'"),
def->parent);
return NULL;
}
@@ -679,7 +689,7 @@ nodeDeviceGetMdevctlStartCommand(virNodeDeviceDefPtr def,
}
cmd = virCommandNewArgList(MDEVCTL, "start",
- "-p", parent_pci,
+ "-p", parent_addr,
"--jsonfile", "/dev/stdin",
NULL);
--
2.25.1