</network>
</hookData></pre>
- <p>In the case of an interface
- being plugged/unplugged to/from the network, the network XML will be
- followed with the full XML description of the domain containing the
- interface that is being plugged/unplugged:</p>
+ <p>In the case of an network port being created / deleted, the network
+ XML will be followed with the full XML description of the port:</p>
<pre><hookData>
<network>
<uuid>afca425a-2c3a-420c-b2fb-dd7b4950d722</uuid>
...
</network>
- <domain type='$domain_type' id='$domain_id'>
- <name>$domain_name</name>
- <uuid>afca425a-2c3a-420c-b2fb-dd7b4950d722</uuid>
- ...
- </domain>
+ <networkport>
+ <uuid>5d744f21-ba4a-4d6e-bdb2-30a35ff3207d</uuid>
+ ...
+ <plug type='direct' dev='ens3' mode='vepa'/>
+ </networkport>
</hookData></pre>
<p>Please note that this approach is different from other cases such as
<pre>/etc/libvirt/hooks/network network_name stopped end -</pre></li>
<li>Later, when network is started and there's an interface from a
domain to be plugged into the network, the hook script is called as:<br/>
- <pre>/etc/libvirt/hooks/network network_name plugged begin -</pre>
+ <pre>/etc/libvirt/hooks/network network_name port-created begin -</pre>
Please note, that in this case, the script is passed both network and
- domain XMLs on its stdin.</li>
+ port XMLs on its stdin.</li>
<li>When network is updated, the hook script is called as:<br/>
<pre>/etc/libvirt/hooks/network network_name updated begin -</pre></li>
<li>When the domain from previous case is shutting down, the interface
is unplugged. This leads to another script invocation:<br/>
- <pre>/etc/libvirt/hooks/network network_name unplugged begin -</pre>
- And again, as in previous case, both network and domain XMLs are passed
+ <pre>/etc/libvirt/hooks/network network_name port-deleted begin -</pre>
+ And again, as in previous case, both network and port XMLs are passed
onto script's stdin.</li>
</ul>
static int
networkRunHook(virNetworkObjPtr obj,
- virDomainDefPtr dom,
- virDomainNetDefPtr iface,
+ virNetworkPortDefPtr port,
int op,
int sub_op)
{
virNetworkDefPtr def;
virBuffer buf = VIR_BUFFER_INITIALIZER;
- char *xml = NULL, *net_xml = NULL, *dom_xml = NULL;
+ char *xml = NULL;
int hookret;
int ret = -1;
virBufferAddLit(&buf, "<hookData>\n");
virBufferAdjustIndent(&buf, 2);
- if (iface && virDomainNetDefFormat(&buf, iface, NULL, 0) < 0)
- goto cleanup;
if (virNetworkDefFormatBuf(&buf, def, 0) < 0)
goto cleanup;
- if (dom && virDomainDefFormatInternal(dom, NULL, 0, &buf, NULL) < 0)
+ if (port && virNetworkPortDefFormatBuf(&buf, port) < 0)
goto cleanup;
virBufferAdjustIndent(&buf, -2);
cleanup:
virBufferFreeAndReset(&buf);
VIR_FREE(xml);
- VIR_FREE(net_xml);
- VIR_FREE(dom_xml);
return ret;
}
/* Run an early hook to set-up missing devices.
* If the script raised an error abort the launch. */
- if (networkRunHook(obj, NULL, NULL,
+ if (networkRunHook(obj, NULL,
VIR_HOOK_NETWORK_OP_START,
VIR_HOOK_SUBOP_BEGIN) < 0)
goto cleanup;
virNetworkObjSetFloorSum(obj, 0);
/* finally we can call the 'started' hook script if any */
- if (networkRunHook(obj, NULL, NULL,
+ if (networkRunHook(obj, NULL,
VIR_HOOK_NETWORK_OP_STARTED,
VIR_HOOK_SUBOP_BEGIN) < 0)
goto cleanup;
}
/* now that we know it's stopped call the hook if present */
- networkRunHook(obj, NULL, NULL, VIR_HOOK_NETWORK_OP_STOPPED,
+ networkRunHook(obj, NULL, VIR_HOOK_NETWORK_OP_STOPPED,
VIR_HOOK_SUBOP_END);
virNetworkObjSetActive(obj, false);
}
/* call the 'updated' network hook script */
- if (networkRunHook(obj, NULL, NULL, VIR_HOOK_NETWORK_OP_UPDATED,
+ if (networkRunHook(obj, NULL, VIR_HOOK_NETWORK_OP_UPDATED,
VIR_HOOK_SUBOP_BEGIN) < 0)
goto cleanup;
if (dev)
dev->connections++;
/* finally we can call the 'plugged' hook script if any */
- if (networkRunHook(obj, dom, iface,
- VIR_HOOK_NETWORK_OP_IFACE_PLUGGED,
+ if (networkRunHook(obj, port,
+ VIR_HOOK_NETWORK_OP_PORT_CREATED,
VIR_HOOK_SUBOP_BEGIN) < 0) {
/* adjust for failure */
netdef->connections--;
if (dev)
dev->connections++;
/* finally we can call the 'plugged' hook script if any */
- if (networkRunHook(obj, dom, iface, VIR_HOOK_NETWORK_OP_IFACE_PLUGGED,
+ if (networkRunHook(obj, port, VIR_HOOK_NETWORK_OP_PORT_CREATED,
VIR_HOOK_SUBOP_BEGIN) < 0) {
/* adjust for failure */
if (dev)
if (dev)
dev->connections--;
/* finally we can call the 'unplugged' hook script if any */
- networkRunHook(obj, dom, iface, VIR_HOOK_NETWORK_OP_IFACE_UNPLUGGED,
+ networkRunHook(obj, port, VIR_HOOK_NETWORK_OP_PORT_DELETED,
VIR_HOOK_SUBOP_BEGIN);
networkLogAllocation(netdef, dev, &port->mac, false);