When called by snapshot code we will need to use different reason.
Signed-off-by: Pavel Hrdina <phrdina(a)redhat.com>
Reviewed-by: Peter Krempa <pkrempa(a)redhat.com>
---
src/qemu/qemu_process.c | 6 +++++-
src/qemu/qemu_process.h | 1 +
src/qemu/qemu_saveimage.c | 3 ++-
3 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 0de8ceb244..d414a40fd5 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -8167,11 +8167,14 @@ qemuProcessStart(virConnectPtr conn,
* @data: data from memory state file
* @asyncJob: type of asynchronous job
* @start_flags: flags to start QEMU process with
+ * @reason: audit log reason
* @started: boolean to store if QEMU process was started
*
* Start VM with existing memory state. Make sure that the stored memory state
* is correctly decompressed so it can be loaded by QEMU process.
*
+ * For audit purposes the expected @reason is one of `restored` or `from-snapshot`.
+ *
* Returns 0 on success, -1 on error.
*/
int
@@ -8183,6 +8186,7 @@ qemuProcessStartWithMemoryState(virConnectPtr conn,
virQEMUSaveData *data,
virDomainAsyncJob asyncJob,
unsigned int start_flags,
+ const char *reason,
bool *started)
{
qemuDomainObjPrivate *priv = vm->privateData;
@@ -8217,7 +8221,7 @@ qemuProcessStartWithMemoryState(virConnectPtr conn,
rc = qemuSaveImageDecompressionStop(cmd, fd, &intermediatefd, errbuf, *started,
path);
- virDomainAuditStart(vm, "restored", *started);
+ virDomainAuditStart(vm, reason, *started);
if (!*started || rc < 0)
return -1;
diff --git a/src/qemu/qemu_process.h b/src/qemu/qemu_process.h
index d758b4f51a..26c9a04969 100644
--- a/src/qemu/qemu_process.h
+++ b/src/qemu/qemu_process.h
@@ -99,6 +99,7 @@ int qemuProcessStartWithMemoryState(virConnectPtr conn,
virQEMUSaveData *data,
virDomainAsyncJob asyncJob,
unsigned int start_flags,
+ const char *reason,
bool *started);
int qemuProcessCreatePretendCmdPrepare(virQEMUDriver *driver,
diff --git a/src/qemu/qemu_saveimage.c b/src/qemu/qemu_saveimage.c
index 1fbc7891b1..92dcf4b616 100644
--- a/src/qemu/qemu_saveimage.c
+++ b/src/qemu/qemu_saveimage.c
@@ -699,7 +699,8 @@ qemuSaveImageStartVM(virConnectPtr conn,
start_flags |= VIR_QEMU_PROCESS_START_RESET_NVRAM;
if (qemuProcessStartWithMemoryState(conn, driver, vm, fd, path, data,
- asyncJob, start_flags, &started) < 0) {
+ asyncJob, start_flags, "restored",
+ &started) < 0) {
goto cleanup;
}
--
2.41.0