Signed-off-by: Rafael Fonseca <r4f4rfs(a)gmail.com>
---
src/conf/domain_conf.c | 29 ++--
src/conf/domain_conf.h | 18 +-
src/qemu/qemu_domain.c | 347 ++++++++++++++++----------------------
src/qemu/qemu_domain.h | 145 +++++++++++-----
src/util/virstoragefile.h | 3 +-
5 files changed, 281 insertions(+), 261 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index f3a8a36eb2..eb5155f612 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -1768,7 +1768,8 @@ void virDomainGraphicsDefFree(virDomainGraphicsDefPtr def)
virDomainGraphicsListenDefClear(&def->listens[i]);
VIR_FREE(def->listens);
- virObjectUnref(def->privateData);
+ if (def->privateData)
+ g_object_unref(def->privateData);
VIR_FREE(def);
}
@@ -1816,7 +1817,7 @@ static virDomainVcpuDefPtr
virDomainVcpuDefNew(virDomainXMLOptionPtr xmlopt)
{
virDomainVcpuDefPtr ret = NULL;
- g_autoptr(virObject) priv = NULL;
+ g_autoptr(GObject) priv = NULL;
if (xmlopt && xmlopt->privateData.vcpuNew &&
!(priv = xmlopt->privateData.vcpuNew()))
@@ -1839,7 +1840,8 @@ virDomainVcpuDefFree(virDomainVcpuDefPtr info)
virBitmapFree(info->cpumask);
info->cpumask = NULL;
- virObjectUnref(info->privateData);
+ if (info->privateData)
+ g_object_unref(info->privateData);
VIR_FREE(info);
}
@@ -2141,7 +2143,8 @@ virDomainDiskDefFree(virDomainDiskDefPtr def)
VIR_FREE(def->blkdeviotune.group_name);
VIR_FREE(def->virtio);
virDomainDeviceInfoClear(&def->info);
- virObjectUnref(def->privateData);
+ if (def->privateData)
+ g_object_unref(def->privateData);
VIR_FREE(def);
}
@@ -2343,7 +2346,8 @@ void virDomainFSDefFree(virDomainFSDefPtr def)
VIR_FREE(def->dst);
virDomainDeviceInfoClear(&def->info);
VIR_FREE(def->virtio);
- virObjectUnref(def->privateData);
+ if (def->privateData)
+ g_object_unref(def->privateData);
VIR_FREE(def->binary);
VIR_FREE(def);
@@ -2404,7 +2408,8 @@ virDomainVsockDefFree(virDomainVsockDefPtr vsock)
if (!vsock)
return;
- virObjectUnref(vsock->privateData);
+ if (vsock->privateData)
+ g_object_unref(vsock->privateData);
virDomainDeviceInfoClear(&vsock->info);
VIR_FREE(vsock);
}
@@ -2492,7 +2497,8 @@ virDomainNetDefFree(virDomainNetDefPtr def)
if (!def)
return;
virDomainNetDefClear(def);
- virObjectUnref(def->privateData);
+ if (def->privateData)
+ g_object_unref(def->privateData);
VIR_FREE(def);
}
@@ -2635,7 +2641,8 @@ virDomainChrSourceDefFinalize(GObject *obj)
size_t i;
virDomainChrSourceDefClear(def);
- virObjectUnref(def->privateData);
+ if (def->privateData)
+ g_object_unref(def->privateData);
if (def->seclabels) {
for (i = 0; i < def->nseclabels; i++)
@@ -2881,7 +2888,8 @@ virDomainVideoDefClear(virDomainVideoDefPtr def)
if (def->driver)
VIR_FREE(def->driver->vhost_user_binary);
VIR_FREE(def->driver);
- virObjectUnref(def->privateData);
+ if (def->privateData)
+ g_object_unref(def->privateData);
memset(def, 0, sizeof(*def));
}
@@ -26996,7 +27004,8 @@ virDomainRNGDefFree(virDomainRNGDefPtr def)
VIR_FREE(def->source.file);
break;
case VIR_DOMAIN_RNG_BACKEND_EGD:
- virObjectUnref(def->source.chardev);
+ if (def->source.chardev)
+ g_object_unref(def->source.chardev);
break;
case VIR_DOMAIN_RNG_BACKEND_BUILTIN:
case VIR_DOMAIN_RNG_BACKEND_LAST:
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index b6b2a72dd4..ab1e763ab1 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -528,7 +528,7 @@ typedef enum {
struct _virDomainDiskDef {
virStorageSourcePtr src; /* non-NULL. XXX Allow NULL for empty cdrom? */
- virObjectPtr privateData;
+ GObject *privateData;
int device; /* enum virDomainDiskDevice */
int bus; /* enum virDomainDiskBus */
@@ -837,7 +837,7 @@ struct _virDomainFSDef {
virTristateSwitch posix_lock;
virTristateSwitch flock;
virDomainVirtioOptionsPtr virtio;
- virObjectPtr privateData;
+ GObject *privateData;
};
@@ -1056,7 +1056,7 @@ struct _virDomainNetDef {
unsigned int mtu;
virNetDevCoalescePtr coalesce;
virDomainVirtioOptionsPtr virtio;
- virObjectPtr privateData;
+ GObject *privateData;
};
typedef enum {
@@ -1175,7 +1175,7 @@ struct _virDomainChrSourceReconnectDef {
struct _virDomainChrSourceDef {
GObject parent;
int type; /* virDomainChrType */
- virObjectPtr privateData;
+ GObject *privateData;
union {
/* no <source> for null, vc, stdio */
struct {
@@ -1478,7 +1478,7 @@ struct _virDomainVideoDriverDef {
};
struct _virDomainVideoDef {
- virObjectPtr privateData;
+ GObject *privateData;
int type; /* enum virDomainVideoType */
unsigned int ram; /* kibibytes (multiples of 1024) */
@@ -1625,7 +1625,7 @@ struct _virDomainGraphicsListenDef {
};
struct _virDomainGraphicsDef {
- virObjectPtr privateData;
+ GObject *privateData;
/* Port value discipline:
* Value -1 is legacy syntax indicating that it should be auto-allocated.
@@ -2303,7 +2303,7 @@ struct _virDomainVcpuDef {
virDomainThreadSchedParam sched;
- virObjectPtr privateData;
+ GObject *privateData;
};
struct _virDomainBlkiotune {
@@ -2401,7 +2401,7 @@ typedef enum {
} virDomainVsockModel;
struct _virDomainVsockDef {
- virObjectPtr privateData;
+ GObject *privateData;
virDomainVsockModel model;
unsigned int guest_cid;
@@ -2758,7 +2758,7 @@ struct _virDomainDefParserConfig {
typedef void *(*virDomainXMLPrivateDataAllocFunc)(void *);
typedef void (*virDomainXMLPrivateDataFreeFunc)(void *);
-typedef virObjectPtr (*virDomainXMLPrivateDataNewFunc)(void);
+typedef GObject* (*virDomainXMLPrivateDataNewFunc)(void);
typedef int (*virDomainXMLPrivateDataFormatFunc)(virBufferPtr,
virDomainObjPtr);
typedef int (*virDomainXMLPrivateDataParseFunc)(xmlXPathContextPtr,
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 14b86388b0..eb0403031d 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -1129,38 +1129,32 @@ qemuDomainSecretInfoDestroy(qemuDomainSecretInfoPtr secinfo)
}
-static virClassPtr qemuDomainDiskPrivateClass;
-static void qemuDomainDiskPrivateDispose(void *obj);
+G_DEFINE_TYPE(qemuDomainDiskPrivate, qemu_domain_disk_private, G_TYPE_OBJECT);
+static void qemuDomainDiskPrivateFinalize(GObject *obj);
-static int
-qemuDomainDiskPrivateOnceInit(void)
+static void
+qemu_domain_disk_private_init(qemuDomainDiskPrivate *priv G_GNUC_UNUSED)
{
- if (!VIR_CLASS_NEW(qemuDomainDiskPrivate, virClassForObject()))
- return -1;
-
- return 0;
}
-VIR_ONCE_GLOBAL_INIT(qemuDomainDiskPrivate);
-
-static virObjectPtr
-qemuDomainDiskPrivateNew(void)
+static void
+qemu_domain_disk_private_class_init(qemuDomainDiskPrivateClass *klass)
{
- qemuDomainDiskPrivatePtr priv;
-
- if (qemuDomainDiskPrivateInitialize() < 0)
- return NULL;
+ GObjectClass *obj = G_OBJECT_CLASS(klass);
- if (!(priv = virObjectNew(qemuDomainDiskPrivateClass)))
- return NULL;
+ obj->finalize = qemuDomainDiskPrivateFinalize;
+}
- return (virObjectPtr) priv;
+static GObject *
+qemuDomainDiskPrivateNew(void)
+{
+ return g_object_new(QEMU_TYPE_DOMAIN_DISK_PRIVATE, NULL);
}
static void
-qemuDomainDiskPrivateDispose(void *obj)
+qemuDomainDiskPrivateFinalize(GObject *obj)
{
- qemuDomainDiskPrivatePtr priv = obj;
+ qemuDomainDiskPrivatePtr priv = QEMU_DOMAIN_DISK(obj);
virObjectUnref(priv->migrSource);
VIR_FREE(priv->qomName);
@@ -1171,323 +1165,282 @@ qemuDomainDiskPrivateDispose(void *obj)
G_OBJECT_CLASS(qemu_domain_disk_private_parent_class)->finalize(obj);
}
-static virClassPtr qemuDomainStorageSourcePrivateClass;
-static void qemuDomainStorageSourcePrivateDispose(void *obj);
+G_DEFINE_TYPE(qemuDomainStorageSourcePrivate, qemu_domain_storage_source_private,
G_TYPE_OBJECT);
+static void qemuDomainStorageSourcePrivateFinalize(GObject *obj);
-static int
-qemuDomainStorageSourcePrivateOnceInit(void)
+static void
+qemu_domain_storage_source_private_init(qemuDomainStorageSourcePrivate *priv
G_GNUC_UNUSED)
{
- if (!VIR_CLASS_NEW(qemuDomainStorageSourcePrivate, virClassForObject()))
- return -1;
-
- return 0;
}
-VIR_ONCE_GLOBAL_INIT(qemuDomainStorageSourcePrivate);
-
-virObjectPtr
-qemuDomainStorageSourcePrivateNew(void)
+static void
+qemu_domain_storage_source_private_class_init(qemuDomainStorageSourcePrivateClass
*klass)
{
- qemuDomainStorageSourcePrivatePtr priv;
-
- if (qemuDomainStorageSourcePrivateInitialize() < 0)
- return NULL;
+ GObjectClass *obj = G_OBJECT_CLASS(klass);
- if (!(priv = virObjectNew(qemuDomainStorageSourcePrivateClass)))
- return NULL;
+ obj->finalize = qemuDomainStorageSourcePrivateFinalize;
+}
- return (virObjectPtr) priv;
+GObject *
+qemuDomainStorageSourcePrivateNew(void)
+{
+ return g_object_new(QEMU_TYPE_DOMAIN_STORAGE_SOURCE_PRIVATE, NULL);
}
static void
-qemuDomainStorageSourcePrivateDispose(void *obj)
+qemuDomainStorageSourcePrivateFinalize(GObject *obj)
{
- qemuDomainStorageSourcePrivatePtr priv = obj;
+ qemuDomainStorageSourcePrivatePtr priv = QEMU_DOMAIN_STORAGE_SOURCE(obj);
g_clear_pointer(&priv->secinfo, qemuDomainSecretInfoFree);
g_clear_pointer(&priv->encinfo, qemuDomainSecretInfoFree);
+
+ G_OBJECT_CLASS(qemu_domain_storage_source_private_parent_class)->finalize(obj);
}
-static virClassPtr qemuDomainVcpuPrivateClass;
-static void qemuDomainVcpuPrivateDispose(void *obj);
+G_DEFINE_TYPE(qemuDomainVcpuPrivate, qemu_domain_vcpu_private, G_TYPE_OBJECT);
+static void qemuDomainVcpuPrivateFinalize(GObject *obj);
-static int
-qemuDomainVcpuPrivateOnceInit(void)
+static void
+qemu_domain_vcpu_private_init(qemuDomainVcpuPrivate *priv G_GNUC_UNUSED)
{
- if (!VIR_CLASS_NEW(qemuDomainVcpuPrivate, virClassForObject()))
- return -1;
-
- return 0;
}
-VIR_ONCE_GLOBAL_INIT(qemuDomainVcpuPrivate);
-
-static virObjectPtr
-qemuDomainVcpuPrivateNew(void)
+static void
+qemu_domain_vcpu_private_class_init(qemuDomainVcpuPrivateClass *klass)
{
- qemuDomainVcpuPrivatePtr priv;
-
- if (qemuDomainVcpuPrivateInitialize() < 0)
- return NULL;
+ GObjectClass *obj = G_OBJECT_CLASS(klass);
- if (!(priv = virObjectNew(qemuDomainVcpuPrivateClass)))
- return NULL;
+ obj->finalize = qemuDomainVcpuPrivateFinalize;
+}
- return (virObjectPtr) priv;
+static GObject *
+qemuDomainVcpuPrivateNew(void)
+{
+ return g_object_new(QEMU_TYPE_DOMAIN_VCPU_PRIVATE, NULL);
}
static void
-qemuDomainVcpuPrivateDispose(void *obj)
+qemuDomainVcpuPrivateFinalize(GObject *obj)
{
- qemuDomainVcpuPrivatePtr priv = obj;
+ qemuDomainVcpuPrivatePtr priv = QEMU_DOMAIN_VCPU(obj);
VIR_FREE(priv->type);
VIR_FREE(priv->alias);
virJSONValueFree(priv->props);
- return;
+
+ G_OBJECT_CLASS(qemu_domain_vcpu_private_parent_class)->finalize(obj);
}
-static virClassPtr qemuDomainChrSourcePrivateClass;
-static void qemuDomainChrSourcePrivateDispose(void *obj);
+G_DEFINE_TYPE(qemuDomainChrSourcePrivate, qemu_domain_chr_source_private,
G_TYPE_OBJECT);
+static void qemuDomainChrSourcePrivateFinalize(GObject *obj);
-static int
-qemuDomainChrSourcePrivateOnceInit(void)
+static void
+qemu_domain_chr_source_private_init(qemuDomainChrSourcePrivate *priv G_GNUC_UNUSED)
{
- if (!VIR_CLASS_NEW(qemuDomainChrSourcePrivate, virClassForObject()))
- return -1;
-
- return 0;
}
-VIR_ONCE_GLOBAL_INIT(qemuDomainChrSourcePrivate);
-
-static virObjectPtr
-qemuDomainChrSourcePrivateNew(void)
+static void
+qemu_domain_chr_source_private_class_init(qemuDomainChrSourcePrivateClass *klass)
{
- qemuDomainChrSourcePrivatePtr priv;
-
- if (qemuDomainChrSourcePrivateInitialize() < 0)
- return NULL;
+ GObjectClass *obj = G_OBJECT_CLASS(klass);
- if (!(priv = virObjectNew(qemuDomainChrSourcePrivateClass)))
- return NULL;
+ obj->finalize = qemuDomainChrSourcePrivateFinalize;
+}
- return (virObjectPtr) priv;
+static GObject *
+qemuDomainChrSourcePrivateNew(void)
+{
+ return g_object_new(QEMU_TYPE_DOMAIN_CHR_SOURCE_PRIVATE, NULL);
}
static void
-qemuDomainChrSourcePrivateDispose(void *obj)
+qemuDomainChrSourcePrivateFinalize(GObject *obj)
{
- qemuDomainChrSourcePrivatePtr priv = obj;
+ qemuDomainChrSourcePrivatePtr priv = QEMU_DOMAIN_CHR_SOURCE(obj);
g_clear_pointer(&priv->secinfo, qemuDomainSecretInfoFree);
+
+ G_OBJECT_CLASS(qemu_domain_chr_source_private_parent_class)->finalize(obj);
}
-static virClassPtr qemuDomainVsockPrivateClass;
-static void qemuDomainVsockPrivateDispose(void *obj);
+G_DEFINE_TYPE(qemuDomainVsockPrivate, qemu_domain_vsock_private, G_TYPE_OBJECT);
+static void qemuDomainVsockPrivateFinalize(GObject *obj);
-static int
-qemuDomainVsockPrivateOnceInit(void)
+static void
+qemu_domain_vsock_private_init(qemuDomainVsockPrivate *priv)
{
- if (!VIR_CLASS_NEW(qemuDomainVsockPrivate, virClassForObject()))
- return -1;
-
- return 0;
+ priv->vhostfd = -1;
}
-VIR_ONCE_GLOBAL_INIT(qemuDomainVsockPrivate);
-
-static virObjectPtr
-qemuDomainVsockPrivateNew(void)
+static void
+qemu_domain_vsock_private_class_init(qemuDomainVsockPrivateClass *klass)
{
- qemuDomainVsockPrivatePtr priv;
-
- if (qemuDomainVsockPrivateInitialize() < 0)
- return NULL;
-
- if (!(priv = virObjectNew(qemuDomainVsockPrivateClass)))
- return NULL;
+ GObjectClass *obj = G_OBJECT_CLASS(klass);
- priv->vhostfd = -1;
+ obj->finalize = qemuDomainVsockPrivateFinalize;
+}
- return (virObjectPtr) priv;
+static GObject *
+qemuDomainVsockPrivateNew(void)
+{
+ return g_object_new(QEMU_TYPE_DOMAIN_VSOCK_PRIVATE, NULL);
}
static void
-qemuDomainVsockPrivateDispose(void *obj G_GNUC_UNUSED)
+qemuDomainVsockPrivateFinalize(GObject *obj)
{
- qemuDomainVsockPrivatePtr priv = obj;
+ qemuDomainVsockPrivatePtr priv = QEMU_DOMAIN_VSOCK(obj);
VIR_FORCE_CLOSE(priv->vhostfd);
+
+ G_OBJECT_CLASS(qemu_domain_vsock_private_parent_class)->finalize(obj);
}
-static virClassPtr qemuDomainGraphicsPrivateClass;
-static void qemuDomainGraphicsPrivateDispose(void *obj);
+G_DEFINE_TYPE(qemuDomainGraphicsPrivate, qemu_domain_graphics_private, G_TYPE_OBJECT);
+static void qemuDomainGraphicsPrivateFinalize(GObject *obj);
-static int
-qemuDomainGraphicsPrivateOnceInit(void)
+static void
+qemu_domain_graphics_private_init(qemuDomainGraphicsPrivate *priv G_GNUC_UNUSED)
{
- if (!VIR_CLASS_NEW(qemuDomainGraphicsPrivate, virClassForObject()))
- return -1;
-
- return 0;
}
-VIR_ONCE_GLOBAL_INIT(qemuDomainGraphicsPrivate);
-
-static virObjectPtr
-qemuDomainGraphicsPrivateNew(void)
+static void
+qemu_domain_graphics_private_class_init(qemuDomainGraphicsPrivateClass *klass)
{
- qemuDomainGraphicsPrivatePtr priv;
-
- if (qemuDomainGraphicsPrivateInitialize() < 0)
- return NULL;
+ GObjectClass *obj = G_OBJECT_CLASS(klass);
- if (!(priv = virObjectNew(qemuDomainGraphicsPrivateClass)))
- return NULL;
+ obj->finalize = qemuDomainGraphicsPrivateFinalize;
+}
- return (virObjectPtr) priv;
+static GObject *
+qemuDomainGraphicsPrivateNew(void)
+{
+ return g_object_new(QEMU_TYPE_DOMAIN_GRAPHICS_PRIVATE, NULL);
}
static void
-qemuDomainGraphicsPrivateDispose(void *obj)
+qemuDomainGraphicsPrivateFinalize(GObject *obj)
{
- qemuDomainGraphicsPrivatePtr priv = obj;
+ qemuDomainGraphicsPrivatePtr priv = QEMU_DOMAIN_GRAPHICS(obj);
VIR_FREE(priv->tlsAlias);
g_clear_pointer(&priv->secinfo, qemuDomainSecretInfoFree);
-}
+ G_OBJECT_CLASS(qemu_domain_graphics_private_parent_class)->finalize(obj);
+}
-static virClassPtr qemuDomainNetworkPrivateClass;
-static void qemuDomainNetworkPrivateDispose(void *obj);
+G_DEFINE_TYPE(qemuDomainNetworkPrivate, qemu_domain_network_private, G_TYPE_OBJECT);
+static void qemuDomainNetworkPrivateFinalize(GObject *obj);
-static int
-qemuDomainNetworkPrivateOnceInit(void)
+static void
+qemu_domain_network_private_init(qemuDomainNetworkPrivate *priv G_GNUC_UNUSED)
{
- if (!VIR_CLASS_NEW(qemuDomainNetworkPrivate, virClassForObject()))
- return -1;
-
- return 0;
}
+static void
+qemu_domain_network_private_class_init(qemuDomainNetworkPrivateClass *klass)
+{
+ GObjectClass *obj = G_OBJECT_CLASS(klass);
-VIR_ONCE_GLOBAL_INIT(qemuDomainNetworkPrivate);
+ obj->finalize = qemuDomainNetworkPrivateFinalize;
+}
-static virObjectPtr
+static GObject *
qemuDomainNetworkPrivateNew(void)
{
- qemuDomainNetworkPrivatePtr priv;
-
- if (qemuDomainNetworkPrivateInitialize() < 0)
- return NULL;
-
- if (!(priv = virObjectNew(qemuDomainNetworkPrivateClass)))
- return NULL;
-
- return (virObjectPtr) priv;
+ return g_object_new(QEMU_TYPE_DOMAIN_NETWORK_PRIVATE, NULL);
}
static void
-qemuDomainNetworkPrivateDispose(void *obj G_GNUC_UNUSED)
+qemuDomainNetworkPrivateFinalize(GObject *obj)
{
- qemuDomainNetworkPrivatePtr priv = obj;
+ qemuDomainNetworkPrivatePtr priv = QEMU_DOMAIN_NETWORK(obj);
qemuSlirpFree(priv->slirp);
-}
+ G_OBJECT_CLASS(qemu_domain_network_private_parent_class)->finalize(obj);
+}
-static virClassPtr qemuDomainFSPrivateClass;
-static void qemuDomainFSPrivateDispose(void *obj);
+G_DEFINE_TYPE(qemuDomainFSPrivate, qemu_domain_fs_private, G_TYPE_OBJECT);
+static void qemuDomainFSPrivateFinalize(GObject *obj);
-static int
-qemuDomainFSPrivateOnceInit(void)
+static void
+qemu_domain_fs_private_init(qemuDomainFSPrivate *priv G_GNUC_UNUSED)
{
- if (!VIR_CLASS_NEW(qemuDomainFSPrivate, virClassForObject()))
- return -1;
-
- return 0;
}
+static void
+qemu_domain_fs_private_class_init(qemuDomainFSPrivateClass *klass)
+{
+ GObjectClass *obj = G_OBJECT_CLASS(klass);
-VIR_ONCE_GLOBAL_INIT(qemuDomainFSPrivate);
-
+ obj->finalize = qemuDomainFSPrivateFinalize;
+}
-static virObjectPtr
+static GObject *
qemuDomainFSPrivateNew(void)
{
- qemuDomainFSPrivatePtr priv;
-
- if (qemuDomainFSPrivateInitialize() < 0)
- return NULL;
-
- if (!(priv = virObjectNew(qemuDomainFSPrivateClass)))
- return NULL;
-
- return (virObjectPtr) priv;
+ return g_object_new(QEMU_TYPE_DOMAIN_FS_PRIVATE, NULL);
}
static void
-qemuDomainFSPrivateDispose(void *obj)
+qemuDomainFSPrivateFinalize(GObject *obj)
{
- qemuDomainFSPrivatePtr priv = obj;
+ qemuDomainFSPrivatePtr priv = QEMU_DOMAIN_FS(obj);
g_free(priv->vhostuser_fs_sock);
+
+ G_OBJECT_CLASS(qemu_domain_fs_private_parent_class)->finalize(obj);
}
-static virClassPtr qemuDomainVideoPrivateClass;
-static void qemuDomainVideoPrivateDispose(void *obj);
+G_DEFINE_TYPE(qemuDomainVideoPrivate, qemu_domain_video_private, G_TYPE_OBJECT);
+static void qemuDomainVideoPrivateFinalize(GObject *obj);
+static void
+qemu_domain_video_private_init(qemuDomainVideoPrivate *priv)
+{
+ priv->vhost_user_fd = -1;
+}
-static int
-qemuDomainVideoPrivateOnceInit(void)
+static void
+qemu_domain_video_private_class_init(qemuDomainVideoPrivateClass *klass)
{
- if (!VIR_CLASS_NEW(qemuDomainVideoPrivate, virClassForObject()))
- return -1;
+ GObjectClass *obj = G_OBJECT_CLASS(klass);
- return 0;
+ obj->finalize = qemuDomainVideoPrivateFinalize;
}
-VIR_ONCE_GLOBAL_INIT(qemuDomainVideoPrivate);
-
-static virObjectPtr
+static GObject *
qemuDomainVideoPrivateNew(void)
{
- qemuDomainVideoPrivatePtr priv;
-
- if (qemuDomainVideoPrivateInitialize() < 0)
- return NULL;
-
- if (!(priv = virObjectNew(qemuDomainVideoPrivateClass)))
- return NULL;
-
- priv->vhost_user_fd = -1;
-
- return (virObjectPtr) priv;
+ return g_object_new(QEMU_TYPE_DOMAIN_VIDEO_PRIVATE, NULL);
}
static void
-qemuDomainVideoPrivateDispose(void *obj)
+qemuDomainVideoPrivateFinalize(GObject *obj)
{
- qemuDomainVideoPrivatePtr priv = obj;
+ qemuDomainVideoPrivatePtr priv = QEMU_DOMAIN_VIDEO(obj);
VIR_FORCE_CLOSE(priv->vhost_user_fd);
+
+ G_OBJECT_CLASS(qemu_domain_video_private_parent_class)->finalize(obj);
}
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
index cf19f4d101..7dbd3ffc69 100644
--- a/src/qemu/qemu_domain.h
+++ b/src/qemu/qemu_domain.h
@@ -433,13 +433,8 @@ struct _qemuDomainObjPrivate {
#define QEMU_DOMAIN_PRIVATE(vm) \
((qemuDomainObjPrivatePtr) (vm)->privateData)
-#define QEMU_DOMAIN_DISK_PRIVATE(disk) \
- ((qemuDomainDiskPrivatePtr) (disk)->privateData)
-
-typedef struct _qemuDomainDiskPrivate qemuDomainDiskPrivate;
-typedef qemuDomainDiskPrivate *qemuDomainDiskPrivatePtr;
struct _qemuDomainDiskPrivate {
- virObject parent;
+ GObject parent;
/* ideally we want a smarter way to interlock block jobs on single qemu disk
* in the future, but for now we just disallow any concurrent job on a
@@ -457,13 +452,20 @@ struct _qemuDomainDiskPrivate {
char *nodeCopyOnRead; /* nodename of the disk-wide copy-on-read blockdev layer */
};
-#define QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(src) \
- ((qemuDomainStorageSourcePrivatePtr) (src)->privateData)
+#define QEMU_TYPE_DOMAIN_DISK_PRIVATE qemu_domain_disk_private_get_type()
+G_DECLARE_FINAL_TYPE(qemuDomainDiskPrivate,
+ qemu_domain_disk_private,
+ QEMU,
+ DOMAIN_DISK,
+ GObject);
+typedef qemuDomainDiskPrivate *qemuDomainDiskPrivatePtr;
+
+#define QEMU_DOMAIN_DISK_PRIVATE(disk) \
+ ((qemuDomainDiskPrivatePtr) (disk)->privateData)
+
-typedef struct _qemuDomainStorageSourcePrivate qemuDomainStorageSourcePrivate;
-typedef qemuDomainStorageSourcePrivate *qemuDomainStorageSourcePrivatePtr;
struct _qemuDomainStorageSourcePrivate {
- virObject parent;
+ GObject parent;
/* data required for authentication to the storage source */
qemuDomainSecretInfoPtr secinfo;
@@ -475,12 +477,23 @@ struct _qemuDomainStorageSourcePrivate {
qemuDomainSecretInfoPtr httpcookie;
};
-virObjectPtr qemuDomainStorageSourcePrivateNew(void);
+#define QEMU_TYPE_DOMAIN_STORAGE_SOURCE_PRIVATE
qemu_domain_storage_source_private_get_type()
+G_DECLARE_FINAL_TYPE(qemuDomainStorageSourcePrivate,
+ qemu_domain_storage_source_private,
+ QEMU,
+ DOMAIN_STORAGE_SOURCE,
+ GObject);
+typedef qemuDomainStorageSourcePrivate *qemuDomainStorageSourcePrivatePtr;
+
+#define QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(src) \
+ ((qemuDomainStorageSourcePrivatePtr) (src)->privateData)
+
+
+GObject *qemuDomainStorageSourcePrivateNew(void);
+
-typedef struct _qemuDomainVcpuPrivate qemuDomainVcpuPrivate;
-typedef qemuDomainVcpuPrivate *qemuDomainVcpuPrivatePtr;
struct _qemuDomainVcpuPrivate {
- virObject parent;
+ GObject parent;
pid_t tid; /* vcpu thread id */
int enable_id; /* order in which the vcpus were enabled in qemu */
@@ -500,6 +513,14 @@ struct _qemuDomainVcpuPrivate {
int vcpus;
};
+#define QEMU_TYPE_DOMAIN_VCPU_PRIVATE qemu_domain_vcpu_private_get_type()
+G_DECLARE_FINAL_TYPE(qemuDomainVcpuPrivate,
+ qemu_domain_vcpu_private,
+ QEMU,
+ DOMAIN_VCPU,
+ GObject);
+typedef qemuDomainVcpuPrivate *qemuDomainVcpuPrivatePtr;
+
#define QEMU_DOMAIN_VCPU_PRIVATE(vcpu) \
((qemuDomainVcpuPrivatePtr) (vcpu)->privateData)
@@ -513,77 +534,113 @@ struct qemuDomainDiskInfo {
char *nodename;
};
-#define QEMU_DOMAIN_CHR_SOURCE_PRIVATE(dev) \
- ((qemuDomainChrSourcePrivatePtr) (dev)->privateData)
-
-typedef struct _qemuDomainChrSourcePrivate qemuDomainChrSourcePrivate;
-typedef qemuDomainChrSourcePrivate *qemuDomainChrSourcePrivatePtr;
struct _qemuDomainChrSourcePrivate {
- virObject parent;
+ GObject parent;
/* for char devices using secret
* NB: *not* to be written to qemu domain object XML */
qemuDomainSecretInfoPtr secinfo;
};
+#define QEMU_TYPE_DOMAIN_CHR_SOURCE_PRIVATE qemu_domain_chr_source_private_get_type()
+G_DECLARE_FINAL_TYPE(qemuDomainChrSourcePrivate,
+ qemu_domain_chr_source_private,
+ QEMU,
+ DOMAIN_CHR_SOURCE,
+ GObject);
+typedef qemuDomainChrSourcePrivate *qemuDomainChrSourcePrivatePtr;
+
+#define QEMU_DOMAIN_CHR_SOURCE_PRIVATE(dev) \
+ ((qemuDomainChrSourcePrivatePtr) (dev)->privateData)
+
-typedef struct _qemuDomainVsockPrivate qemuDomainVsockPrivate;
-typedef qemuDomainVsockPrivate *qemuDomainVsockPrivatePtr;
struct _qemuDomainVsockPrivate {
- virObject parent;
+ GObject parent;
int vhostfd;
};
+#define QEMU_TYPE_DOMAIN_VSOCK_PRIVATE qemu_domain_vsock_private_get_type()
+G_DECLARE_FINAL_TYPE(qemuDomainVsockPrivate,
+ qemu_domain_vsock_private,
+ QEMU,
+ DOMAIN_VSOCK,
+ GObject);
+typedef qemuDomainVsockPrivate *qemuDomainVsockPrivatePtr;
-#define QEMU_DOMAIN_VIDEO_PRIVATE(dev) \
- ((qemuDomainVideoPrivatePtr) (dev)->privateData)
-typedef struct _qemuDomainVideoPrivate qemuDomainVideoPrivate;
-typedef qemuDomainVideoPrivate *qemuDomainVideoPrivatePtr;
struct _qemuDomainVideoPrivate {
- virObject parent;
+ GObject parent;
int vhost_user_fd;
};
+#define QEMU_TYPE_DOMAIN_VIDEO_PRIVATE qemu_domain_video_private_get_type()
+G_DECLARE_FINAL_TYPE(qemuDomainVideoPrivate,
+ qemu_domain_video_private,
+ QEMU,
+ DOMAIN_VIDEO,
+ GObject);
+typedef qemuDomainVideoPrivate *qemuDomainVideoPrivatePtr;
+
+#define QEMU_DOMAIN_VIDEO_PRIVATE(dev) \
+ ((qemuDomainVideoPrivatePtr) (dev)->privateData)
-#define QEMU_DOMAIN_GRAPHICS_PRIVATE(dev) \
- ((qemuDomainGraphicsPrivatePtr) (dev)->privateData)
-typedef struct _qemuDomainGraphicsPrivate qemuDomainGraphicsPrivate;
-typedef qemuDomainGraphicsPrivate *qemuDomainGraphicsPrivatePtr;
struct _qemuDomainGraphicsPrivate {
- virObject parent;
+ GObject parent;
char *tlsAlias;
qemuDomainSecretInfoPtr secinfo;
};
+#define QEMU_TYPE_DOMAIN_GRAPHICS_PRIVATE qemu_domain_graphics_private_get_type()
+G_DECLARE_FINAL_TYPE(qemuDomainGraphicsPrivate,
+ qemu_domain_graphics_private,
+ QEMU,
+ DOMAIN_GRAPHICS,
+ GObject);
+typedef qemuDomainGraphicsPrivate *qemuDomainGraphicsPrivatePtr;
+
+#define QEMU_DOMAIN_GRAPHICS_PRIVATE(dev) \
+ ((qemuDomainGraphicsPrivatePtr) (dev)->privateData)
-#define QEMU_DOMAIN_NETWORK_PRIVATE(dev) \
- ((qemuDomainNetworkPrivatePtr) (dev)->privateData)
-typedef struct _qemuDomainNetworkPrivate qemuDomainNetworkPrivate;
-typedef qemuDomainNetworkPrivate *qemuDomainNetworkPrivatePtr;
struct _qemuDomainNetworkPrivate {
- virObject parent;
+ GObject parent;
qemuSlirpPtr slirp;
};
+#define QEMU_TYPE_DOMAIN_NETWORK_PRIVATE qemu_domain_network_private_get_type()
+G_DECLARE_FINAL_TYPE(qemuDomainNetworkPrivate,
+ qemu_domain_network_private,
+ QEMU,
+ DOMAIN_NETWORK,
+ GObject);
+typedef qemuDomainNetworkPrivate *qemuDomainNetworkPrivatePtr;
+
+#define QEMU_DOMAIN_NETWORK_PRIVATE(dev) \
+ ((qemuDomainNetworkPrivatePtr) (dev)->privateData)
-#define QEMU_DOMAIN_FS_PRIVATE(dev) \
- ((qemuDomainFSPrivatePtr) (dev)->privateData)
-typedef struct _qemuDomainFSPrivate qemuDomainFSPrivate;
-typedef qemuDomainFSPrivate *qemuDomainFSPrivatePtr;
struct _qemuDomainFSPrivate {
- virObject parent;
+ GObject parent;
char *vhostuser_fs_sock;
};
+#define QEMU_TYPE_DOMAIN_FS_PRIVATE qemu_domain_fs_private_get_type()
+G_DECLARE_FINAL_TYPE(qemuDomainFSPrivate,
+ qemu_domain_fs_private,
+ QEMU,
+ DOMAIN_FS,
+ GObject);
+typedef qemuDomainFSPrivate *qemuDomainFSPrivatePtr;
+
+#define QEMU_DOMAIN_FS_PRIVATE(dev) \
+ ((qemuDomainFSPrivatePtr) (dev)->privateData)
+
typedef enum {
QEMU_PROCESS_EVENT_WATCHDOG = 0,
diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h
index 7939c09cd5..a744bcbf5c 100644
--- a/src/util/virstoragefile.h
+++ b/src/util/virstoragefile.h
@@ -30,6 +30,7 @@
#include "virsecret.h"
#include "virenum.h"
#include "virpci.h"
+#include <glib-object.h>
/* Minimum header size required to probe all known formats with
* virStorageFileProbeFormat, or obtain metadata from a known format.
@@ -304,7 +305,7 @@ struct _virStorageSource {
virStorageSourceInitiatorDef initiator;
- virObjectPtr privateData;
+ GObject *privateData;
int format; /* virStorageFileFormat in domain backing chains, but
* pool-specific enum for storage volumes */
--
2.25.1