mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-24 22:55:23 +00:00
qemu: convert DomainLogContext class to use GObject
Signed-off-by: Gaurav Agrawal <agrawalgaurav@gnome.org> Reviewed-by: Ján Tomko <jtomko@redhat.com> Signed-off-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
c34b8cbf1c
commit
d2c43a5b51
@ -151,7 +151,7 @@ qemuDomainObjFromDomain(virDomainPtr domain)
|
|||||||
|
|
||||||
|
|
||||||
struct _qemuDomainLogContext {
|
struct _qemuDomainLogContext {
|
||||||
virObject parent;
|
GObject parent;
|
||||||
|
|
||||||
int writefd;
|
int writefd;
|
||||||
int readfd; /* Only used if manager == NULL */
|
int readfd; /* Only used if manager == NULL */
|
||||||
@ -161,37 +161,46 @@ struct _qemuDomainLogContext {
|
|||||||
virLogManagerPtr manager;
|
virLogManagerPtr manager;
|
||||||
};
|
};
|
||||||
|
|
||||||
static virClassPtr qemuDomainLogContextClass;
|
G_DEFINE_TYPE(qemuDomainLogContext, qemu_domain_log_context, G_TYPE_OBJECT);
|
||||||
static virClassPtr qemuDomainSaveCookieClass;
|
static virClassPtr qemuDomainSaveCookieClass;
|
||||||
|
|
||||||
static void qemuDomainLogContextDispose(void *obj);
|
static void qemuDomainLogContextFinalize(GObject *obj);
|
||||||
static void qemuDomainSaveCookieDispose(void *obj);
|
static void qemuDomainSaveCookieDispose(void *obj);
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
qemuDomainOnceInit(void)
|
qemuDomainOnceInit(void)
|
||||||
{
|
{
|
||||||
if (!VIR_CLASS_NEW(qemuDomainLogContext, virClassForObject()))
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
if (!VIR_CLASS_NEW(qemuDomainSaveCookie, virClassForObject()))
|
if (!VIR_CLASS_NEW(qemuDomainSaveCookie, virClassForObject()))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void qemu_domain_log_context_init(qemuDomainLogContext *logctxt G_GNUC_UNUSED)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
static void qemu_domain_log_context_class_init(qemuDomainLogContextClass *klass)
|
||||||
|
{
|
||||||
|
GObjectClass *obj = G_OBJECT_CLASS(klass);
|
||||||
|
|
||||||
|
obj->finalize = qemuDomainLogContextFinalize;
|
||||||
|
}
|
||||||
|
|
||||||
VIR_ONCE_GLOBAL_INIT(qemuDomain);
|
VIR_ONCE_GLOBAL_INIT(qemuDomain);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
qemuDomainLogContextDispose(void *obj)
|
qemuDomainLogContextFinalize(GObject *object)
|
||||||
{
|
{
|
||||||
qemuDomainLogContextPtr ctxt = obj;
|
qemuDomainLogContextPtr ctxt = QEMU_DOMAIN_LOG_CONTEXT(object);
|
||||||
VIR_DEBUG("ctxt=%p", ctxt);
|
VIR_DEBUG("ctxt=%p", ctxt);
|
||||||
|
|
||||||
virLogManagerFree(ctxt->manager);
|
virLogManagerFree(ctxt->manager);
|
||||||
VIR_FREE(ctxt->path);
|
VIR_FREE(ctxt->path);
|
||||||
VIR_FORCE_CLOSE(ctxt->writefd);
|
VIR_FORCE_CLOSE(ctxt->writefd);
|
||||||
VIR_FORCE_CLOSE(ctxt->readfd);
|
VIR_FORCE_CLOSE(ctxt->readfd);
|
||||||
|
G_OBJECT_CLASS(qemu_domain_log_context_parent_class)->finalize(object);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
@ -10698,13 +10707,7 @@ qemuDomainLogContextPtr qemuDomainLogContextNew(virQEMUDriverPtr driver,
|
|||||||
qemuDomainLogContextMode mode)
|
qemuDomainLogContextMode mode)
|
||||||
{
|
{
|
||||||
g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver);
|
g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver);
|
||||||
qemuDomainLogContextPtr ctxt = NULL;
|
qemuDomainLogContextPtr ctxt = QEMU_DOMAIN_LOG_CONTEXT(g_object_new(QEMU_TYPE_DOMAIN_LOG_CONTEXT, NULL));
|
||||||
|
|
||||||
if (qemuDomainInitialize() < 0)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
if (!(ctxt = virObjectNew(qemuDomainLogContextClass)))
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
VIR_DEBUG("Context new %p stdioLogD=%d", ctxt, cfg->stdioLogD);
|
VIR_DEBUG("Context new %p stdioLogD=%d", ctxt, cfg->stdioLogD);
|
||||||
ctxt->writefd = -1;
|
ctxt->writefd = -1;
|
||||||
@ -10773,7 +10776,7 @@ qemuDomainLogContextPtr qemuDomainLogContextNew(virQEMUDriverPtr driver,
|
|||||||
return ctxt;
|
return ctxt;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
virObjectUnref(ctxt);
|
g_clear_object(&ctxt);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <glib-object.h>
|
||||||
#include "virthread.h"
|
#include "virthread.h"
|
||||||
#include "vircgroup.h"
|
#include "vircgroup.h"
|
||||||
#include "virperf.h"
|
#include "virperf.h"
|
||||||
@ -604,9 +605,9 @@ struct qemuProcessEvent {
|
|||||||
|
|
||||||
void qemuProcessEventFree(struct qemuProcessEvent *event);
|
void qemuProcessEventFree(struct qemuProcessEvent *event);
|
||||||
|
|
||||||
typedef struct _qemuDomainLogContext qemuDomainLogContext;
|
#define QEMU_TYPE_DOMAIN_LOG_CONTEXT qemu_domain_log_context_get_type()
|
||||||
|
G_DECLARE_FINAL_TYPE(qemuDomainLogContext, qemu_domain_log_context, QEMU, DOMAIN_LOG_CONTEXT, GObject);
|
||||||
typedef qemuDomainLogContext *qemuDomainLogContextPtr;
|
typedef qemuDomainLogContext *qemuDomainLogContextPtr;
|
||||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(qemuDomainLogContext, virObjectUnref);
|
|
||||||
|
|
||||||
typedef struct _qemuDomainSaveCookie qemuDomainSaveCookie;
|
typedef struct _qemuDomainSaveCookie qemuDomainSaveCookie;
|
||||||
typedef qemuDomainSaveCookie *qemuDomainSaveCookiePtr;
|
typedef qemuDomainSaveCookie *qemuDomainSaveCookiePtr;
|
||||||
|
@ -1929,7 +1929,7 @@ static void
|
|||||||
qemuProcessMonitorLogFree(void *opaque)
|
qemuProcessMonitorLogFree(void *opaque)
|
||||||
{
|
{
|
||||||
qemuDomainLogContextPtr logCtxt = opaque;
|
qemuDomainLogContextPtr logCtxt = opaque;
|
||||||
virObjectUnref(logCtxt);
|
g_clear_object(&logCtxt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1983,7 +1983,7 @@ qemuConnectMonitor(virQEMUDriverPtr driver, virDomainObjPtr vm, int asyncJob,
|
|||||||
driver);
|
driver);
|
||||||
|
|
||||||
if (mon && logCtxt) {
|
if (mon && logCtxt) {
|
||||||
virObjectRef(logCtxt);
|
g_object_ref(logCtxt);
|
||||||
qemuMonitorSetDomainLog(mon,
|
qemuMonitorSetDomainLog(mon,
|
||||||
qemuProcessMonitorReportLogError,
|
qemuProcessMonitorReportLogError,
|
||||||
logCtxt,
|
logCtxt,
|
||||||
|
Loading…
Reference in New Issue
Block a user