{domain, network}_conf: disable autostart when deleting config

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>
This commit is contained in:
Michael Chapman 2015-03-11 13:20:28 +11:00 committed by Peter Krempa
parent 64595431cd
commit a6ec4f472d
3 changed files with 2 additions and 1 deletions

View File

@ -20998,6 +20998,7 @@ virDomainDeleteConfig(const char *configDir,
/* Not fatal if this doesn't work */ /* Not fatal if this doesn't work */
unlink(autostartLink); unlink(autostartLink);
dom->autostart = 0;
if (unlink(configFile) < 0 && if (unlink(configFile) < 0 &&
errno != ENOENT) { errno != ENOENT) {

View File

@ -3077,6 +3077,7 @@ int virNetworkDeleteConfig(const char *configDir,
/* Not fatal if this doesn't work */ /* Not fatal if this doesn't work */
unlink(autostartLink); unlink(autostartLink);
net->autostart = 0;
if (unlink(configFile) < 0) { if (unlink(configFile) < 0) {
virReportSystemError(errno, virReportSystemError(errno,

View File

@ -3050,7 +3050,6 @@ networkUndefine(virNetworkPtr net)
driver->networkAutostartDir, driver->networkAutostartDir,
network) < 0) network) < 0)
goto cleanup; goto cleanup;
network->autostart = 0;
event = virNetworkEventLifecycleNew(network->def->name, event = virNetworkEventLifecycleNew(network->def->name,
network->def->uuid, network->def->uuid,