Re: [libvirt PATCH v5 14/32] qemu: move qemuProcessReadLog() to qemuLogContext

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2/16/23 8:56 AM, Peter Krempa wrote:
On Tue, Feb 14, 2023 at 11:08:01 -0600, Jonathon Jongsma wrote:
This code can be used by the nbdkit implementation for reading back
filtered log data for error reporting. Move it to qemuLogContext so that
it can be shared. Renamed to qemuLogContextReadFiltered().

Signed-off-by: Jonathon Jongsma <jjongsma@xxxxxxxxxx>
Reviewed-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
  src/qemu/qemu_logcontext.c | 65 ++++++++++++++++++++++++++++++++++++
  src/qemu/qemu_logcontext.h |  3 ++
  src/qemu/qemu_process.c    | 67 +-------------------------------------
  3 files changed, 69 insertions(+), 66 deletions(-)

diff --git a/src/qemu/qemu_logcontext.c b/src/qemu/qemu_logcontext.c
index 6ad0beeeae..fed5112e28 100644
--- a/src/qemu/qemu_logcontext.c
+++ b/src/qemu/qemu_logcontext.c
@@ -21,6 +21,7 @@
  #include "qemu_logcontext.h"
  #include "viralloc.h"
  #include "virlog.h"
+#include "virstring.h"
  #include "virutil.h"
#include <fcntl.h>
@@ -236,6 +237,70 @@ qemuLogContextRead(qemuLogContext *ctxt,
  }
+/**
+ * qemuLogContextFilter: Read and filter log for relevant messages
+ * @ctxt: the domain log context
+ * @msg: pointer to buffer to store the read messages in
+ * @max: maximum length of the message returned in @msg after filtering
+ *
+ * Reads log output from @ctxt and filters it. Skips messages not produced by
+ * the target executable or irrelevant messages. If @max is not zero, @buf will
+ * contain at most @max characters from the end of the log and @buf will start
+ * after a new line if possible.
+ */
+int
+qemuLogContextReadFiltered(qemuLogContext *ctxt,
+                           char **msg,
+                           size_t max)
+{
+    char *buf;
+    char *eol;
+    char *filter_next;
+    size_t skip;
+    ssize_t got;
+
+    if ((got = qemuLogContextRead(ctxt, &buf) < 0))

You've got the quotes wrong here compared to the place where you took it
from

-    if ((got = qemuLogContextRead(logCtxt, &buf)) < 0)


I wonder how that happened as it looks like code movement.


Whoa, that's weird.  I have no idea. Good catch.

Jonathon




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux