Bug 520683 - virsh net-create does not save network definition
Summary: virsh net-create does not save network definition
Alias: None
Product: Virtualization Tools
Classification: Community
Component: libvirt
Version: unspecified
Hardware: All
OS: All
Target Milestone: ---
Assignee: Libvirt Maintainers
QA Contact:
URL: http://blog.sysfs.net/
Depends On:
TreeView+ depends on / blocked
Reported: 2009-09-01 19:36 UTC by Filip Van Raemdonck
Modified: 2014-01-17 18:33 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Last Closed: 2014-01-17 18:33:02 UTC

Attachments (Terms of Use)
patch with extra if clause (714 bytes, patch)
2009-09-01 19:36 UTC, Filip Van Raemdonck
no flags Details | Diff
patch with save & failure test consolidated into existing if clause (656 bytes, patch)
2009-09-01 19:37 UTC, Filip Van Raemdonck
no flags Details | Diff
documentation patch (1.53 KB, patch)
2009-09-02 18:38 UTC, Filip Van Raemdonck
no flags Details | Diff

System ID Priority Status Summary Last Updated
Debian BTS 543970 None None None Never

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 Berrange 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.

Note You need to log in before you can comment on or make changes to this bug.