Allow to match with CCW addresses in addition to PCI addresses
(and MAC addresses).
Signed-off-by: Cornelia Huck <cohuck(a)redhat.com>
---
src/conf/device_conf.c | 12 ++++++++++++
src/conf/device_conf.h | 3 +++
src/conf/domain_conf.c | 23 ++++++++++++++++++++++-
src/libvirt_private.syms | 1 +
4 files changed, 38 insertions(+), 1 deletion(-)
diff --git a/src/conf/device_conf.c b/src/conf/device_conf.c
index 9398191dfd84..87bf32bbc685 100644
--- a/src/conf/device_conf.c
+++ b/src/conf/device_conf.c
@@ -341,6 +341,18 @@ virDomainDeviceCCWAddressParseXML(xmlNodePtr node,
return 0;
}
+bool
+virDomainDeviceCCWAddressEqual(virDomainDeviceCCWAddressPtr addr1,
+ virDomainDeviceCCWAddressPtr addr2)
+{
+ if (addr1->cssid == addr2->cssid &&
+ addr1->ssid == addr2->ssid &&
+ addr1->devno == addr2->devno) {
+ return true;
+ }
+ return false;
+}
+
int
virDomainDeviceDriveAddressParseXML(xmlNodePtr node,
virDomainDeviceDriveAddressPtr addr)
diff --git a/src/conf/device_conf.h b/src/conf/device_conf.h
index d7395f220174..a51bdf10ee6e 100644
--- a/src/conf/device_conf.h
+++ b/src/conf/device_conf.h
@@ -207,6 +207,9 @@ void virPCIDeviceAddressFormat(virBufferPtr buf,
bool virDomainDeviceCCWAddressIsValid(virDomainDeviceCCWAddressPtr addr);
int virDomainDeviceCCWAddressParseXML(xmlNodePtr node,
virDomainDeviceCCWAddressPtr addr);
+bool virDomainDeviceCCWAddressEqual(virDomainDeviceCCWAddressPtr addr1,
+ virDomainDeviceCCWAddressPtr addr2);
+#define VIR_CCW_DEVICE_ADDRESS_FMT "%x.%x.%04x"
int virDomainDeviceDriveAddressParseXML(xmlNodePtr node,
virDomainDeviceDriveAddressPtr addr);
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 8d30557bdcbe..a91dbd4aa95b 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -17816,6 +17816,8 @@ virDomainNetFindIdx(virDomainDefPtr def, virDomainNetDefPtr net)
bool MACAddrSpecified = !net->mac_generated;
bool PCIAddrSpecified = virDomainDeviceAddressIsValid(&net->info,
VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI);
+ bool CCWAddrSpecified = virDomainDeviceAddressIsValid(&net->info,
+
VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW);
for (i = 0; i < def->nnets; i++) {
if (MACAddrSpecified &&
@@ -17827,9 +17829,14 @@ virDomainNetFindIdx(virDomainDefPtr def, virDomainNetDefPtr net)
&net->info.addr.pci))
continue;
+ if (CCWAddrSpecified &&
+ !virDomainDeviceCCWAddressEqual(&def->nets[i]->info.addr.ccw,
+ &net->info.addr.ccw))
+ continue;
+
if (matchidx >= 0) {
/* there were multiple matches on mac address, and no
- * qualifying guest-side PCI address was given, so we must
+ * qualifying guest-side PCI/CCW address was given, so we must
* fail (NB: a USB address isn't adequate, since it may
* specify only vendor and product ID, and there may be
* multiples of those.
@@ -17859,6 +17866,14 @@ virDomainNetFindIdx(virDomainDefPtr def, virDomainNetDefPtr net)
net->info.addr.pci.bus,
net->info.addr.pci.slot,
net->info.addr.pci.function);
+ } else if (MACAddrSpecified && CCWAddrSpecified) {
+ virReportError(VIR_ERR_DEVICE_MISSING,
+ _("no device matching MAC address %s found on "
+ VIR_CCW_DEVICE_ADDRESS_FMT),
+ virMacAddrFormat(&net->mac, mac),
+ net->info.addr.ccw.cssid,
+ net->info.addr.ccw.ssid,
+ net->info.addr.ccw.devno);
} else if (PCIAddrSpecified) {
virReportError(VIR_ERR_DEVICE_MISSING,
_("no device found on "
VIR_PCI_DEVICE_ADDRESS_FMT),
@@ -17866,6 +17881,12 @@ virDomainNetFindIdx(virDomainDefPtr def, virDomainNetDefPtr net)
net->info.addr.pci.bus,
net->info.addr.pci.slot,
net->info.addr.pci.function);
+ } else if (CCWAddrSpecified) {
+ virReportError(VIR_ERR_DEVICE_MISSING,
+ _("no device found on "
VIR_CCW_DEVICE_ADDRESS_FMT),
+ net->info.addr.ccw.cssid,
+ net->info.addr.ccw.ssid,
+ net->info.addr.ccw.devno);
} else if (MACAddrSpecified) {
virReportError(VIR_ERR_DEVICE_MISSING,
_("no device matching MAC address %s found"),
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 1db9970cca08..6bcbfa667d0e 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -128,6 +128,7 @@ virDeviceInfoPCIAddressIsWanted;
virDomainDeviceAddressIsValid;
virDomainDeviceAddressTypeToString;
virDomainDeviceCcidAddressParseXML;
+virDomainDeviceCCWAddressEqual;
virDomainDeviceCCWAddressIsValid;
virDomainDeviceCCWAddressParseXML;
virDomainDeviceDriveAddressParseXML;
--
2.25.4