]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
{domain, network}_conf: disable autostart when deleting config
authorMichael Chapman <mike@very.puzzling.org>
Wed, 11 Mar 2015 02:20:28 +0000 (13:20 +1100)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 11 Mar 2015 06:16:25 +0000 (07:16 +0100)
Undefining a running, autostarted domain removes the autostart link, but
dom->autostart is not cleared. If the domain is subsequently redefined,
libvirt thinks it is already autostarted and will not create the link
even if requested:

  # virsh dominfo example | grep Autostart
  Autostart:      enable

  # ls /etc/libvirt/qemu/autostart/example.xml
  /etc/libvirt/qemu/autostart/example.xml

  # virsh undefine example
  Domain example has been undefined

  # virsh define example.xml
  Domain example defined from example.xml

  # virsh dominfo example | grep Autostart
  Autostart:      enable

  # virsh autostart example
  Domain example marked as autostarted

  # ls /etc/libvirt/qemu/autostart/example.xml
  ls: cannot access /etc/libvirt/qemu/autostart/example.xml: No such file or directory

This commit ensures dom->autostart is cleared whenever the config and
autostart link (if present) are removed.

The bridge network driver cleared this flag itself in networkUndefine.
This commit moves this into virNetworkDeleteConfig for symmetry with
virDomainDeleteConfig, and to ensure it is not missed in future network
drivers.

Signed-off-by: Michael Chapman <mike@very.puzzling.org>
src/conf/domain_conf.c
src/conf/network_conf.c
src/network/bridge_driver.c

index cc8616b7c69b48d446beea81f480f5320e6ac008..a8f4ce26df851d4d92205ba96486b8bc892e7a1a 100644 (file)
@@ -20998,6 +20998,7 @@ virDomainDeleteConfig(const char *configDir,
 
     /* Not fatal if this doesn't work */
     unlink(autostartLink);
+    dom->autostart = 0;
 
     if (unlink(configFile) < 0 &&
         errno != ENOENT) {
index 9c1d57842c7baa1e4f53bcdee7426f64ea4a8fc7..779a08aa6927e698fd847f3c1c184f44487758da 100644 (file)
@@ -3077,6 +3077,7 @@ int virNetworkDeleteConfig(const char *configDir,
 
     /* Not fatal if this doesn't work */
     unlink(autostartLink);
+    net->autostart = 0;
 
     if (unlink(configFile) < 0) {
         virReportSystemError(errno,
index 5752acb214efb8d5ee8a376257c8f67592072fce..515807808459ef2b3e2d843257019a04d91caa21 100644 (file)
@@ -3050,7 +3050,6 @@ networkUndefine(virNetworkPtr net)
                                driver->networkAutostartDir,
                                network) < 0)
         goto cleanup;
-    network->autostart = 0;
 
     event = virNetworkEventLifecycleNew(network->def->name,
                                         network->def->uuid,