<p>
The root element required for all virtual networks is
- named <code>network</code> and has no attributes.
- The network XML format is available <span class="since">since 0.3.0</span>
+ named <code>network</code> and has no configurable attributes
+ (although <span class="since">since 0.10.0</span> there is one
+ optional read-only attribute - when examining the live
+ configuration of a network, the
+ attribute <code>connections</code>, if present, specifies the
+ number of guest interfaces currently connected via this
+ network). The network XML format is
+ available <span class="since">since 0.3.0</span>
</p>
<h3><a name="elementsMetadata">General metadata</a></h3>
</forward>
...
</pre>
- Additionally, <span class="since">since 0.9.10</span>, libvirt
- allows a shorthand for specifying all virtual interfaces
- associated with a single physical function, by using
- the <code><pf></code> subelement to call out the
- corresponding physical interface associated with multiple
- virtual interfaces:
+ <p>
+ <span class="since">since 0.10.0</span>,
+ <code><interface></code> also has an optional read-only
+ attribute - when examining the live configuration of a
+ network, the attribute <code>connections</code>, if present,
+ specifies the number of guest interfaces currently connected
+ via this physical interface.
+ </p>
+ <p>
+ Additionally, <span class="since">since 0.9.10</span>, libvirt
+ allows a shorthand for specifying all virtual interfaces
+ associated with a single physical function, by using
+ the <code><pf></code> subelement to call out the
+ corresponding physical interface associated with multiple
+ virtual interfaces:
+ </p>
<pre>
...
<forward mode='passthrough'>
char uuidstr[VIR_UUID_STRING_BUFLEN];
int ii;
- virBufferAddLit(&buf, "<network>\n");
+ virBufferAddLit(&buf, "<network");
+ if (!(flags & VIR_NETWORK_XML_INACTIVE) && (def->connections > 0)) {
+ virBufferAsprintf(&buf, " connections='%d'", def->connections);
+ }
+ virBufferAddLit(&buf, ">\n");
virBufferEscapeString(&buf, " <name>%s</name>\n", def->name);
uuid = def->uuid;
VIR_DEBUG("Using physical device %s, %d connections",
dev->dev, dev->connections);
}
+
+ netdef->connections++;
+ VIR_DEBUG("Using network %s, %d connections",
+ netdef->name, netdef->connections);
ret = 0;
cleanup:
for (ii = 0; ii < num_virt_fns; ii++)
}
success:
+ netdef->connections++;
+ VIR_DEBUG("Using network %s, %d connections",
+ netdef->name, netdef->connections);
ret = 0;
cleanup:
if (network)
}
success:
+ netdef->connections--;
+ VIR_DEBUG("Releasing network %s, %d connections",
+ netdef->name, netdef->connections);
ret = 0;
cleanup:
if (network)