/*
* network_conf.c: network XML handling
*
- * Copyright (C) 2006-2015 Red Hat, Inc.
+ * Copyright (C) 2006-2016 Red Hat, Inc.
* Copyright (C) 2006-2008 Daniel P. Berrange
*
* This library is free software; you can redistribute it and/or
xmlXPathContextPtr ctxt,
virNetworkForwardDefPtr def)
{
- size_t i;
+ size_t i, j;
int ret = -1;
xmlNodePtr *forwardIfNodes = NULL;
xmlNodePtr *forwardPfNodes = NULL;
continue;
}
+ for (j = 0; j < i; j++) {
+ if (STREQ_NULLABLE(def->ifs[j].device.dev, forwardDev)) {
+ virReportError(VIR_ERR_XML_ERROR,
+ _("interface '%s' can only be "
+ "listed once in network %s"),
+ forwardDev, networkName);
+ goto cleanup;
+ }
+ }
+
def->ifs[i].device.dev = forwardDev;
forwardDev = NULL;
def->ifs[i].type = VIR_NETWORK_FORWARD_HOSTDEV_DEVICE_NETDEV;
switch (def->ifs[i].type) {
case VIR_NETWORK_FORWARD_HOSTDEV_DEVICE_PCI:
- if (virDevicePCIAddressParseXML(forwardAddrNodes[i],
- &def->ifs[i].device.pci) < 0) {
+ {
+ virDevicePCIAddressPtr addr = &def->ifs[i].device.pci;
+
+ if (virDevicePCIAddressParseXML(forwardAddrNodes[i], addr) < 0)
goto cleanup;
+
+ for (j = 0; j < i; j++) {
+ if (virDevicePCIAddressEqual(addr, &def->ifs[j].device.pci)) {
+ virReportError(VIR_ERR_XML_ERROR,
+ _("PCI device '%04x:%02x:%02x.%x' can "
+ "only be listed once in network %s"),
+ addr->domain, addr->bus,
+ addr->slot, addr->function,
+ networkName);
+ goto cleanup;
+ }
}
break;
-
+ }
/* Add USB case here if we ever find a reason to support it */
default:
--- /dev/null
+<network>
+ <name>hostdev</name>
+ <uuid>81ff0d90-c91e-6742-64da-4a736edb9a9b</uuid>
+ <forward mode='hostdev' managed='yes'>
+ <address type='pci' domain='0x0000' bus='0x03' slot='0x00' function='0x1'/>
+ <address type='pci' domain='0x0000' bus='0x03' slot='0x00' function='0x2'/>
+ <address type='pci' domain='0x0000' bus='0x03' slot='0x00' function='0x3'/>
+ <address type='pci' domain='0x0000' bus='0x03' slot='0x00' function='0x3'/>
+ <address type='pci' domain='0x0000' bus='0x03' slot='0x00' function='0x4'/>
+ </forward>
+</network>
--- /dev/null
+<network>
+ <name>passthrough-duplicate</name>
+ <uuid>81ff0d90-c91e-6742-64da-4a736edb9a8b</uuid>
+ <forward mode="passthrough">
+ <interface dev="eth1"/>
+ <interface dev="eth2"/>
+ <interface dev="eth3"/>
+ <interface dev="eth3"/>
+ </forward>
+</network>