From a6ec4f472d585c0ab3df42b98926fb8c6893d6e4 Mon Sep 17 00:00:00 2001 From: Michael Chapman Date: Wed, 11 Mar 2015 13:20:28 +1100 Subject: [PATCH] {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 --- src/conf/domain_conf.c | 1 + src/conf/network_conf.c | 1 + src/network/bridge_driver.c | 1 - 3 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index cc8616b7c6..a8f4ce26df 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -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) { diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c index 9c1d57842c..779a08aa69 100644 --- a/src/conf/network_conf.c +++ b/src/conf/network_conf.c @@ -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, diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index 5752acb214..5158078084 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -3050,7 +3050,6 @@ networkUndefine(virNetworkPtr net) driver->networkAutostartDir, network) < 0) goto cleanup; - network->autostart = 0; event = virNetworkEventLifecycleNew(network->def->name, network->def->uuid, -- 2.47.3