Product SiteDocumentation Site

2.61. net-edit

Allows the user to edit the XML configuration of a virtual network, using their preferred editor.
net-edit launches the command (or script) is defined in the users $EDITOR environment variable, passing it a temporary copy of the XML configuration for the virtual network.
When the user exits the editor, net-edit checks if the temporary file was changed.
If it was, then net-edit validates it to ensure it's error free. If no errors are found, net-edit then overwrites the existing saved virtual network configuration using it.
Usage
net-edit --network network-identifier
Options
Table 2.7. Options
Name Required? Description
--network network-identifier
required
The name or UUID of the virtual network whose XML configuration is to be edited.
The word "--network" itself is optional.

Availability
Available from libvirt 0.4.6 onwards
Platform or Hypervisor specific notes
None yet
Examples
virsh # net-edit mynetwork
Edits the XML configuration for the virtual network named "mynetwork".
virsh # net-edit --network mynetwork
Same as the above example.
virsh # net-edit bfbc4c69-7d6a-cc9a-904c-09910ce179c0
Edits the XML configuration for the virtual network having UUID "bfbc4c69-7d6a-cc9a-904c-09910ce179c0".
virsh # net-edit --network bfbc4c69-7d6a-cc9a-904c-09910ce179c0
Same as the above example.
Example in context
Starting with a few virtual networks already defined:
virsh # net-list --all
Name                 State      Autostart
-----------------------------------------
default              active     yes
examplenetwork       active     no
We use net-dumpxml to view the XML configuration for "examplenetwork":
virsh # net-dumpxml examplenetwork
<network>
  <name>examplenetwork</name>
  <uuid>b7005dec-be1a-fe9a-338a-0cb1301dfcfd</uuid>
  <forward mode='route'/>
  <bridge name='virbr100' stp='on' delay='0' />
  <ip address='10.10.120.1' netmask='255.255.255.0'>
  </ip>
</network>
We want to change one of the values, for example, the Spanning Tree Protocol delay of 0. Let's say want it to be 30 (seconds) instead.
Using net-edit, we launch an editor on the XML fragment. (vi is the editor shown):
virsh # net-edit examplenetwork
The editor window appears, and we make the change directly:
<network>
  <name>examplenetwork</name>
  <uuid>b7005dec-be1a-fe9a-338a-0cb1301dfcfd</uuid>
  <forward mode='route'/>
  <bridge name='virbr100' stp='on' delay='30' />      <-- changed to 30 here
  <ip address='10.10.120.1' netmask='255.255.255.0'>
  </ip>
</network>
~
~
~
~
~
~
"/tmp/virsht2UZ6L" 8L, 238C
Then save the (temporary) file and exit the editor. net-edit automatically copies the temporary XML to the saved configuration, if no errors in it were detected.
Network examplenetwork XML configuration edited.
The next time the "examplenetwork" virtual network is started, it will use the new value.
See also
  • net-dumpxml - Outputs the XML configuration for a virtual network, to stdout.
  • net-list - Displays a list of the virtual networks libvirt is aware of.