From 30697181dc1146133181a0477858236a8d4e077a Mon Sep 17 00:00:00 2001 From: Michael Chapman Date: Mon, 13 Jun 2011 13:05:45 +1000 Subject: [PATCH] Fix autostart flag when loading running domains Drivers load running persistent and transient domain configs before inactive persistent domain configs, however only the latter would set a domain's autostart flag. This mismatch between the loaded and on-disk state could later cause problems with "virsh autostart": # virsh autostart example error: Failed to mark domain example as autostarted error: Failed to create symlink '/etc/libvirt/qemu/autostart/example.xml to '/etc/libvirt/qemu/example.xml': File exists This patch ensures the autostart flag is set correctly even when the domain is already defined. Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=632100 https://bugzilla.redhat.com/show_bug.cgi?id=675319 Signed-off-by: Michael Chapman --- AUTHORS | 1 + src/conf/domain_conf.c | 19 +++++++++++-------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/AUTHORS b/AUTHORS index 63661b11ae..dbc00c775f 100644 --- a/AUTHORS +++ b/AUTHORS @@ -175,6 +175,7 @@ Patches have also been contributed by: Heath Petersen Neil Wilson Ohad Levy + Michael Chapman [....send patches to get your name here....] diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 65d4f8957f..be5267bf2c 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -9862,21 +9862,24 @@ static virDomainObjPtr virDomainLoadConfig(virCapsPtr caps, VIR_DOMAIN_XML_INACTIVE))) goto error; - /* if the domain is already in our hashtable, we don't need to do - * anything further + if ((autostartLink = virDomainConfigFile(autostartDir, name)) == NULL) + goto error; + + if ((autostart = virFileLinkPointsTo(autostartLink, configFile)) < 0) + goto error; + + /* if the domain is already in our hashtable, we only need to + * update the autostart flag */ if ((dom = virDomainFindByUUID(doms, def->uuid))) { + dom->autostart = autostart; + VIR_FREE(configFile); + VIR_FREE(autostartLink); virDomainDefFree(def); return dom; } - if ((autostartLink = virDomainConfigFile(autostartDir, name)) == NULL) - goto error; - - if ((autostart = virFileLinkPointsTo(autostartLink, configFile)) < 0) - goto error; - if (!(dom = virDomainAssignDef(caps, doms, def, false))) goto error; -- GitLab