This is maintained in the same way as the autostart flag, using a
symlink. The difference is that instead of '.xml', the symlink
suffix is '.xml.once'. The link is also deleted immediately after
it has been read.
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
src/conf/domain_conf.c | 6 +++++-
src/conf/domain_conf.h | 1 +
src/conf/virdomainobjlist.c | 7 ++++++-
3 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index af88d0bcfd..4a794d1f71 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -29083,13 +29083,17 @@ virDomainDeleteConfig(const char *configDir,
{
g_autofree char *configFile = NULL;
g_autofree char *autostartLink = NULL;
+ g_autofree char *autostartOnceLink = NULL;
configFile = virDomainConfigFile(configDir, dom->def->name);
autostartLink = virDomainConfigFile(autostartDir, dom->def->name);
+ autostartOnceLink = g_strdup_printf("%s.once", autostartLink);
- /* Not fatal if this doesn't work */
+ /* Not fatal if these don't work */
unlink(autostartLink);
+ unlink(autostartOnceLink);
dom->autostart = 0;
+ dom->autostartOnce = 0;
if (unlink(configFile) < 0 &&
errno != ENOENT) {
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 9f7c28343f..f30143e704 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -3282,6 +3282,7 @@ struct _virDomainObj {
virDomainStateReason state;
unsigned int autostart : 1;
+ unsigned int autostartOnce : 1;
unsigned int persistent : 1;
unsigned int updated : 1;
unsigned int removing : 1;
diff --git a/src/conf/virdomainobjlist.c b/src/conf/virdomainobjlist.c
index 72207450c5..ba2f9f544d 100644
--- a/src/conf/virdomainobjlist.c
+++ b/src/conf/virdomainobjlist.c
@@ -487,9 +487,10 @@ virDomainObjListLoadConfig(virDomainObjList *doms,
{
g_autofree char *configFile = NULL;
g_autofree char *autostartLink = NULL;
+ g_autofree char *autostartOnceLink = NULL;
g_autoptr(virDomainDef) def = NULL;
virDomainObj *dom;
- int autostart;
+ int autostart, autostartOnce;
g_autoptr(virDomainDef) oldDef = NULL;
configFile = virDomainConfigFile(configDir, name);
@@ -500,13 +501,17 @@ virDomainObjListLoadConfig(virDomainObjList *doms,
return NULL;
autostartLink = virDomainConfigFile(autostartDir, name);
+ autostartOnceLink = g_strdup_printf("%s.once", autostartLink);
autostart = virFileLinkPointsTo(autostartLink, configFile);
+ autostartOnce = virFileLinkPointsTo(autostartOnceLink, configFile);
+ unlink(autostartOnceLink);
if (!(dom = virDomainObjListAddLocked(doms, &def, xmlopt, 0, &oldDef)))
return NULL;
dom->autostart = autostart;
+ dom->autostartOnce = autostartOnce;
if (notify)
(*notify)(dom, oldDef == NULL, opaque);
--
2.47.1