Created attachment 359442 [details]
patch with extra if clause
Description of problem: "virsh net-create" creates but does not save network definition
Version-Release number of selected component (if applicable): at least since 0.4.6 and up until current git HEAD
How reproducible: always
Steps to Reproduce:
1. have a new network definition ready in an xml file
2. run "virsh -c qemu:///system net-create mynewnetwork.xml"
3. run "find /etc/libvirt/qemu/networks -type f" -- there's no new network saved in there
4. specific commands that require the physical (as in: bits on filesystem) network definition be present in the above directory fail to work, e.g. virsh net-autostart fails with a cryptic message about being unable to symlink null to null
Actual results: virtual network exists according to virsh net-list but not on disk
Expected results: network exists AND is saved on disk
Additional info: I wasn't sure if the behaviour was intentional or not, but as there is no specific net-save command or the like that I can see, I'd guess it's an oversight (and people are not using net-create much if at all...)
Attached are two patches to fix the issue, one with an extra if clause, one with a check consolidated into another already present if clause in the networkCreate function of libvirt.
Patches were created against 0.7.0.
This patch is also present in the RHEL5.4 virtualization beta packages, if someone from Red Hat reads this, it'd be nice if you could make sure to include it before release :)
Created attachment 359443 [details]
patch with save & failure test consolidated into existing if clause
The virsh net-create command creates a *transient* network. It is 100% intentional that no config be saved on disk.
If you wish to have a *persistent* network, then use the following commands
virsh net-define CONFIG
virsh net-start NET-NAME
That's a curious design decision, do you have a pointer to the reasoning?
At any rate, it should be documented if it is by design because this behaviour can hardly be called intuitive.
Created attachment 359574 [details]
Document net-create transiency.
Added in a comment in virsh manpage about domain create transiency too, as it behaves per the API documentation the same way (oddly enough, the API call backing virsh net-create didn't have this documented)
Upstream libvirt has similar language nowadays, so closing as UPSTREAM. Sorry the patch languished.