[libvirt PATCH 2/7] qemuSaveImageStartProcess: allow setting reason for audit log

Pavel Hrdina posted 7 patches 2 years, 5 months ago
There is a newer version of this series
[libvirt PATCH 2/7] qemuSaveImageStartProcess: allow setting reason for audit log
Posted by Pavel Hrdina 2 years, 5 months ago
When called by snapshot code we will need to use different reason.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
---
 src/qemu/qemu_saveimage.c | 6 ++++--
 src/qemu/qemu_saveimage.h | 1 +
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/qemu/qemu_saveimage.c b/src/qemu/qemu_saveimage.c
index 86f31d1820..1eedc900b9 100644
--- a/src/qemu/qemu_saveimage.c
+++ b/src/qemu/qemu_saveimage.c
@@ -576,6 +576,7 @@ qemuSaveImageOpen(virQEMUDriver *driver,
  * @cookie: cookie 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
@@ -593,6 +594,7 @@ qemuSaveImageStartProcess(virConnectPtr conn,
                           qemuDomainSaveCookie *cookie,
                           virDomainAsyncJob asyncJob,
                           unsigned int start_flags,
+                          const char *reason,
                           bool *started)
 {
     qemuDomainObjPrivate *priv = vm->privateData;
@@ -660,7 +662,7 @@ qemuSaveImageStartProcess(virConnectPtr conn,
         rc = -1;
     }
 
-    virDomainAuditStart(vm, "restored", *started);
+    virDomainAuditStart(vm, reason, started);
     if (!*started || rc < 0)
         return -1;
 
@@ -700,7 +702,7 @@ qemuSaveImageStartVM(virConnectPtr conn,
         goto cleanup;
 
     if (qemuSaveImageStartProcess(conn, driver, vm, fd, path, header, cookie,
-                                  asyncJob, start_flags, &started) < 0) {
+                                  asyncJob, start_flags, "restored", &started) < 0) {
         goto cleanup;
     }
 
diff --git a/src/qemu/qemu_saveimage.h b/src/qemu/qemu_saveimage.h
index af30b7f2ec..c6a701dcf5 100644
--- a/src/qemu/qemu_saveimage.h
+++ b/src/qemu/qemu_saveimage.h
@@ -67,6 +67,7 @@ qemuSaveImageStartProcess(virConnectPtr conn,
                           qemuDomainSaveCookie *cookie,
                           virDomainAsyncJob asyncJob,
                           unsigned int start_flags,
+                          const char *reason,
                           bool *started);
 
 int
-- 
2.41.0
Re: [libvirt PATCH 2/7] qemuSaveImageStartProcess: allow setting reason for audit log
Posted by Peter Krempa 2 years, 5 months ago
On Thu, Aug 31, 2023 at 16:55:01 +0200, Pavel Hrdina wrote:
> When called by snapshot code we will need to use different reason.
> 
> Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
> ---
>  src/qemu/qemu_saveimage.c | 6 ++++--
>  src/qemu/qemu_saveimage.h | 1 +
>  2 files changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/src/qemu/qemu_saveimage.c b/src/qemu/qemu_saveimage.c
> index 86f31d1820..1eedc900b9 100644
> --- a/src/qemu/qemu_saveimage.c
> +++ b/src/qemu/qemu_saveimage.c
> @@ -576,6 +576,7 @@ qemuSaveImageOpen(virQEMUDriver *driver,
>   * @cookie: cookie from memory state file
>   * @asyncJob: type of asynchronous job
>   * @start_flags: flags to start QEMU process with
> + * @reason: audit log reason

Put expected values into the comment.

>   * @started: boolean to store if QEMU process was started
>   *
>   * Start VM with existing memory state. Make sure that the stored memory state


Reviewed-by: Peter Krempa <pkrempa@redhat.com>