]> xenbits.xensource.com Git - libvirt.git/commitdiff
Generalize qemuDomainLogContextNew()
authorJonathon Jongsma <jjongsma@redhat.com>
Wed, 11 Jan 2023 19:54:06 +0000 (13:54 -0600)
committerJonathon Jongsma <jjongsma@redhat.com>
Tue, 19 Sep 2023 19:28:50 +0000 (14:28 -0500)
Allow to specify a basename for the log file so that
qemuDomainLogContextNew() can be used to create log contexts for
secondary loggers.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
src/qemu/qemu_domain.c
src/qemu/qemu_domain.h
src/qemu/qemu_process.c

index da6f8d4b29ae64b4c05cded484c8578f64c0073b..e0605cd2b89361e938fdc9684f823467b48cf42a 100644 (file)
@@ -7104,7 +7104,8 @@ void qemuDomainObjCheckNetTaint(virQEMUDriver *driver,
 
 
 qemuDomainLogContext *qemuDomainLogContextNew(virQEMUDriver *driver,
-                                              virDomainObj *vm)
+                                              virDomainObj *vm,
+                                              const char *basename)
 {
     g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver);
     qemuDomainLogContext *ctxt = QEMU_DOMAIN_LOG_CONTEXT(g_object_new(QEMU_TYPE_DOMAIN_LOG_CONTEXT, NULL));
@@ -7113,7 +7114,7 @@ qemuDomainLogContext *qemuDomainLogContextNew(virQEMUDriver *driver,
     ctxt->writefd = -1;
     ctxt->readfd = -1;
 
-    ctxt->path = g_strdup_printf("%s/%s.log", cfg->logDir, vm->def->name);
+    ctxt->path = g_strdup_printf("%s/%s.log", cfg->logDir, basename);
 
     if (cfg->stdioLogD) {
         ctxt->manager = virLogManagerNew(driver->privileged);
index 67ebee5c2596579396b54bf499d325967ff4e191..088c42916479ae2260957990e7b2d69b2b3bee6c 100644 (file)
@@ -657,7 +657,8 @@ void qemuDomainObjCheckNetTaint(virQEMUDriver *driver,
                                 qemuDomainLogContext *logCtxt);
 
 qemuDomainLogContext *qemuDomainLogContextNew(virQEMUDriver *driver,
-                                              virDomainObj *vm);
+                                              virDomainObj *vm,
+                                              const char *basename);
 int qemuDomainLogContextWrite(qemuDomainLogContext *ctxt,
                               const char *fmt, ...) G_GNUC_PRINTF(2, 3);
 ssize_t qemuDomainLogContextRead(qemuDomainLogContext *ctxt,
index 42837c4a8a56c2352d6279d671bdb3f4841e6e85..71b19666851d3b66d3fc7ee6142cc7991b307a9b 100644 (file)
@@ -7641,7 +7641,7 @@ qemuProcessLaunch(virConnectPtr conn,
     hookData.cfg = cfg;
 
     VIR_DEBUG("Creating domain log file");
-    if (!(logCtxt = qemuDomainLogContextNew(driver, vm))) {
+    if (!(logCtxt = qemuDomainLogContextNew(driver, vm, vm->def->name))) {
         virLastErrorPrefixMessage("%s", _("can't connect to virtlogd"));
         goto cleanup;
     }