Bug 520683

Summary: virsh net-create does not save network definition
Product: [Community] Virtualization Tools Reporter: Filip Van Raemdonck <mechanix>
Component: libvirtAssignee: Libvirt Maintainers <libvirt-maint>
Status: CLOSED UPSTREAM QA Contact:
Severity: medium Docs Contact:
Priority: low    
Version: unspecifiedCC: berrange, crobinso, shyu, xen-maint
Target Milestone: ---Keywords: Reopened
Target Release: ---   
Hardware: All   
OS: All   
URL: http://blog.sysfs.net/
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-01-17 18:33:02 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
patch with extra if clause
none
patch with save & failure test consolidated into existing if clause
none
documentation patch none

Description Filip Van Raemdonck 2009-09-01 19:36:09 UTC
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 :)

Comment 1 Filip Van Raemdonck 2009-09-01 19:37:38 UTC
Created attachment 359443 [details]
patch with save & failure test consolidated into existing if clause

Comment 2 Daniel Berrangé 2009-09-01 19:49:02 UTC
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

Comment 3 Filip Van Raemdonck 2009-09-02 18:28:07 UTC
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.

Patch follows.

Comment 4 Filip Van Raemdonck 2009-09-02 18:38:23 UTC
Created attachment 359574 [details]
documentation patch

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)

Comment 5 Cole Robinson 2014-01-17 18:33:02 UTC
Upstream libvirt has similar language nowadays, so closing as UPSTREAM. Sorry the patch languished.