So far we are repeating the following lines over and over:
virClassNew(virClassForObject(),
"virSomeObject",
sizeof(virSomeObject),
virSomeObjectDispose);
While this works, it is impossible to do some checking. Firstly,
the class name (the 2nd argument) doesn't match the name in the
code in all cases (the 3rd argument). Secondly, the current style
is needlessly verbose. This commit turns example into following:
VIR_CLASS_NEW(virClassForObject(),
virSomeObject);
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/access/viraccessmanager.c | 6 +-
src/bhyve/bhyve_conf.c | 6 +-
src/conf/capabilities.c | 6 +-
src/conf/domain_capabilities.c | 12 +--
src/conf/domain_conf.c | 18 ++---
src/conf/domain_event.c | 126 +++++++++++---------------------
src/conf/network_event.c | 12 +--
src/conf/node_device_event.c | 18 ++---
src/conf/object_event.c | 12 +--
src/conf/secret_event.c | 18 ++---
src/conf/storage_event.c | 18 ++---
src/conf/virdomainobjlist.c | 6 +-
src/conf/virinterfaceobj.c | 12 +--
src/conf/virnetworkobj.c | 12 +--
src/conf/virnodedeviceobj.c | 12 +--
src/conf/virsecretobj.c | 12 +--
src/conf/virstorageobj.c | 24 ++----
src/datatypes.c | 6 +-
src/interface/interface_backend_netcf.c | 6 +-
src/libvirt-admin.c | 6 +-
src/libxl/libxl_conf.c | 6 +-
src/libxl/libxl_domain.c | 6 +-
src/libxl/libxl_migration.c | 6 +-
src/logging/log_handler.c | 6 +-
src/lxc/lxc_conf.c | 6 +-
src/lxc/lxc_monitor.c | 6 +-
src/node_device/node_device_udev.c | 6 +-
src/qemu/qemu_agent.c | 6 +-
src/qemu/qemu_capabilities.c | 6 +-
src/qemu/qemu_conf.c | 6 +-
src/qemu/qemu_domain.c | 36 +++------
src/qemu/qemu_monitor.c | 6 +-
src/rpc/virkeepalive.c | 6 +-
src/rpc/virnetclient.c | 6 +-
src/rpc/virnetclientprogram.c | 6 +-
src/rpc/virnetclientstream.c | 6 +-
src/rpc/virnetdaemon.c | 6 +-
src/rpc/virnetlibsshsession.c | 6 +-
src/rpc/virnetsaslcontext.c | 12 +--
src/rpc/virnetserver.c | 6 +-
src/rpc/virnetserverclient.c | 6 +-
src/rpc/virnetserverprogram.c | 6 +-
src/rpc/virnetserverservice.c | 6 +-
src/rpc/virnetsocket.c | 6 +-
src/rpc/virnetsshsession.c | 6 +-
src/rpc/virnettlscontext.c | 12 +--
src/security/security_manager.c | 6 +-
src/util/virclosecallbacks.c | 6 +-
src/util/virdnsmasq.c | 7 +-
src/util/virfdstream.c | 6 +-
src/util/virfilecache.c | 6 +-
src/util/virhash.c | 6 +-
src/util/virhostdev.c | 6 +-
src/util/viridentity.c | 6 +-
src/util/virmacmap.c | 6 +-
src/util/virmdev.c | 6 +-
src/util/virobject.c | 12 +--
src/util/virobject.h | 4 +
src/util/virpci.c | 6 +-
src/util/virportallocator.c | 6 +-
src/util/virresctrl.c | 12 +--
src/util/virscsi.c | 6 +-
src/util/virscsivhost.c | 6 +-
src/util/virusb.c | 6 +-
src/vbox/vbox_common.c | 6 +-
src/vz/vz_driver.c | 6 +-
tests/virfilecachetest.c | 6 +-
67 files changed, 230 insertions(+), 453 deletions(-)
diff --git a/src/access/viraccessmanager.c b/src/access/viraccessmanager.c
index c268ec57f7..2940692598 100644
--- a/src/access/viraccessmanager.c
+++ b/src/access/viraccessmanager.c
@@ -54,10 +54,8 @@ static void virAccessManagerDispose(void *obj);
static int virAccessManagerOnceInit(void)
{
- if (!(virAccessManagerClass = virClassNew(virClassForObjectLockable(),
- "virAccessManagerClass",
- sizeof(virAccessManager),
- virAccessManagerDispose)))
+ if (!(virAccessManagerClass = VIR_CLASS_NEW(virClassForObjectLockable(),
+ virAccessManager)))
return -1;
return 0;
diff --git a/src/bhyve/bhyve_conf.c b/src/bhyve/bhyve_conf.c
index b0b40c5754..027311ad37 100644
--- a/src/bhyve/bhyve_conf.c
+++ b/src/bhyve/bhyve_conf.c
@@ -36,10 +36,8 @@ static void virBhyveDriverConfigDispose(void *obj);
static int virBhyveConfigOnceInit(void)
{
- if (!(virBhyveDriverConfigClass = virClassNew(virClassForObject(),
- "virBhyveDriverConfig",
- sizeof(virBhyveDriverConfig),
- virBhyveDriverConfigDispose)))
+ if (!(virBhyveDriverConfigClass = VIR_CLASS_NEW(virClassForObject(),
+ virBhyveDriverConfig)))
return -1;
return 0;
diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c
index 33b9194041..239d409388 100644
--- a/src/conf/capabilities.c
+++ b/src/conf/capabilities.c
@@ -62,10 +62,8 @@ static void virCapsDispose(void *obj);
static int virCapabilitiesOnceInit(void)
{
- if (!(virCapsClass = virClassNew(virClassForObject(),
- "virCaps",
- sizeof(virCaps),
- virCapsDispose)))
+ if (!(virCapsClass = VIR_CLASS_NEW(virClassForObject(),
+ virCaps)))
return -1;
return 0;
diff --git a/src/conf/domain_capabilities.c b/src/conf/domain_capabilities.c
index f7d9be50f8..aad93392ea 100644
--- a/src/conf/domain_capabilities.c
+++ b/src/conf/domain_capabilities.c
@@ -40,16 +40,12 @@ static void virDomainCapsCPUModelsDispose(void *obj);
static int virDomainCapsOnceInit(void)
{
- if (!(virDomainCapsClass = virClassNew(virClassForObjectLockable(),
- "virDomainCapsClass",
- sizeof(virDomainCaps),
- virDomainCapsDispose)))
+ if (!(virDomainCapsClass = VIR_CLASS_NEW(virClassForObjectLockable(),
+ virDomainCaps)))
return -1;
- virDomainCapsCPUModelsClass = virClassNew(virClassForObject(),
- "virDomainCapsCPUModelsClass",
- sizeof(virDomainCapsCPUModels),
- virDomainCapsCPUModelsDispose);
+ virDomainCapsCPUModelsClass = VIR_CLASS_NEW(virClassForObject(),
+ virDomainCapsCPUModels);
if (!virDomainCapsCPUModelsClass)
return -1;
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 4dad8e3b20..364f41f384 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -938,16 +938,12 @@ static void virDomainXMLOptionDispose(void *obj);
static int virDomainObjOnceInit(void)
{
- if (!(virDomainObjClass = virClassNew(virClassForObjectLockable(),
- "virDomainObj",
- sizeof(virDomainObj),
- virDomainObjDispose)))
+ if (!(virDomainObjClass = VIR_CLASS_NEW(virClassForObjectLockable(),
+ virDomainObj)))
return -1;
- if (!(virDomainXMLOptionClass = virClassNew(virClassForObject(),
- "virDomainXMLOption",
- sizeof(virDomainXMLOption),
- virDomainXMLOptionDispose)))
+ if (!(virDomainXMLOptionClass = VIR_CLASS_NEW(virClassForObject(),
+ virDomainXMLOption)))
return -1;
return 0;
@@ -12223,10 +12219,8 @@ static virClassPtr virDomainChrSourceDefClass;
static int
virDomainChrSourceDefOnceInit(void)
{
- virDomainChrSourceDefClass = virClassNew(virClassForObject(),
- "virDomainChrSourceDef",
- sizeof(virDomainChrSourceDef),
- virDomainChrSourceDefDispose);
+ virDomainChrSourceDefClass = VIR_CLASS_NEW(virClassForObject(),
+ virDomainChrSourceDef);
if (!virDomainChrSourceDefClass)
return -1;
else
diff --git a/src/conf/domain_event.c b/src/conf/domain_event.c
index fdb48a1eaa..2272844085 100644
--- a/src/conf/domain_event.c
+++ b/src/conf/domain_event.c
@@ -296,130 +296,88 @@ static int
virDomainEventsOnceInit(void)
{
if (!(virDomainEventClass =
- virClassNew(virClassForObjectEvent(),
- "virDomainEvent",
- sizeof(virDomainEvent),
- virDomainEventDispose)))
+ VIR_CLASS_NEW(virClassForObjectEvent(),
+ virDomainEvent)))
return -1;
if (!(virDomainEventLifecycleClass =
- virClassNew(virDomainEventClass,
- "virDomainEventLifecycle",
- sizeof(virDomainEventLifecycle),
- virDomainEventLifecycleDispose)))
+ VIR_CLASS_NEW(virDomainEventClass,
+ virDomainEventLifecycle)))
return -1;
if (!(virDomainEventRTCChangeClass =
- virClassNew(virDomainEventClass,
- "virDomainEventRTCChange",
- sizeof(virDomainEventRTCChange),
- virDomainEventRTCChangeDispose)))
+ VIR_CLASS_NEW(virDomainEventClass,
+ virDomainEventRTCChange)))
return -1;
if (!(virDomainEventWatchdogClass =
- virClassNew(virDomainEventClass,
- "virDomainEventWatchdog",
- sizeof(virDomainEventWatchdog),
- virDomainEventWatchdogDispose)))
+ VIR_CLASS_NEW(virDomainEventClass,
+ virDomainEventWatchdog)))
return -1;
if (!(virDomainEventIOErrorClass =
- virClassNew(virDomainEventClass,
- "virDomainEventIOError",
- sizeof(virDomainEventIOError),
- virDomainEventIOErrorDispose)))
+ VIR_CLASS_NEW(virDomainEventClass,
+ virDomainEventIOError)))
return -1;
if (!(virDomainEventGraphicsClass =
- virClassNew(virDomainEventClass,
- "virDomainEventGraphics",
- sizeof(virDomainEventGraphics),
- virDomainEventGraphicsDispose)))
+ VIR_CLASS_NEW(virDomainEventClass,
+ virDomainEventGraphics)))
return -1;
if (!(virDomainEventBlockJobClass =
- virClassNew(virDomainEventClass,
- "virDomainEventBlockJob",
- sizeof(virDomainEventBlockJob),
- virDomainEventBlockJobDispose)))
+ VIR_CLASS_NEW(virDomainEventClass,
+ virDomainEventBlockJob)))
return -1;
if (!(virDomainEventDiskChangeClass =
- virClassNew(virDomainEventClass,
- "virDomainEventDiskChange",
- sizeof(virDomainEventDiskChange),
- virDomainEventDiskChangeDispose)))
+ VIR_CLASS_NEW(virDomainEventClass,
+ virDomainEventDiskChange)))
return -1;
if (!(virDomainEventTrayChangeClass =
- virClassNew(virDomainEventClass,
- "virDomainEventTrayChange",
- sizeof(virDomainEventTrayChange),
- virDomainEventTrayChangeDispose)))
+ VIR_CLASS_NEW(virDomainEventClass,
+ virDomainEventTrayChange)))
return -1;
if (!(virDomainEventBalloonChangeClass =
- virClassNew(virDomainEventClass,
- "virDomainEventBalloonChange",
- sizeof(virDomainEventBalloonChange),
- virDomainEventBalloonChangeDispose)))
+ VIR_CLASS_NEW(virDomainEventClass,
+ virDomainEventBalloonChange)))
return -1;
if (!(virDomainEventDeviceRemovedClass =
- virClassNew(virDomainEventClass,
- "virDomainEventDeviceRemoved",
- sizeof(virDomainEventDeviceRemoved),
- virDomainEventDeviceRemovedDispose)))
+ VIR_CLASS_NEW(virDomainEventClass,
+ virDomainEventDeviceRemoved)))
return -1;
if (!(virDomainEventDeviceAddedClass =
- virClassNew(virDomainEventClass,
- "virDomainEventDeviceAdded",
- sizeof(virDomainEventDeviceAdded),
- virDomainEventDeviceAddedDispose)))
+ VIR_CLASS_NEW(virDomainEventClass,
+ virDomainEventDeviceAdded)))
return -1;
if (!(virDomainEventPMClass =
- virClassNew(virDomainEventClass,
- "virDomainEventPM",
- sizeof(virDomainEventPM),
- virDomainEventPMDispose)))
+ VIR_CLASS_NEW(virDomainEventClass,
+ virDomainEventPM)))
return -1;
if (!(virDomainQemuMonitorEventClass =
- virClassNew(virClassForObjectEvent(),
- "virDomainQemuMonitorEvent",
- sizeof(virDomainQemuMonitorEvent),
- virDomainQemuMonitorEventDispose)))
+ VIR_CLASS_NEW(virClassForObjectEvent(),
+ virDomainQemuMonitorEvent)))
return -1;
if (!(virDomainEventTunableClass =
- virClassNew(virDomainEventClass,
- "virDomainEventTunable",
- sizeof(virDomainEventTunable),
- virDomainEventTunableDispose)))
+ VIR_CLASS_NEW(virDomainEventClass,
+ virDomainEventTunable)))
return -1;
if (!(virDomainEventAgentLifecycleClass =
- virClassNew(virDomainEventClass,
- "virDomainEventAgentLifecycle",
- sizeof(virDomainEventAgentLifecycle),
- virDomainEventAgentLifecycleDispose)))
+ VIR_CLASS_NEW(virDomainEventClass,
+ virDomainEventAgentLifecycle)))
return -1;
if (!(virDomainEventMigrationIterationClass =
- virClassNew(virDomainEventClass,
- "virDomainEventMigrationIteration",
- sizeof(virDomainEventMigrationIteration),
- virDomainEventMigrationIterationDispose)))
+ VIR_CLASS_NEW(virDomainEventClass,
+ virDomainEventMigrationIteration)))
return -1;
if (!(virDomainEventJobCompletedClass =
- virClassNew(virDomainEventClass,
- "virDomainEventJobCompleted",
- sizeof(virDomainEventJobCompleted),
- virDomainEventJobCompletedDispose)))
+ VIR_CLASS_NEW(virDomainEventClass,
+ virDomainEventJobCompleted)))
return -1;
if (!(virDomainEventDeviceRemovalFailedClass =
- virClassNew(virDomainEventClass,
- "virDomainEventDeviceRemovalFailed",
- sizeof(virDomainEventDeviceRemovalFailed),
- virDomainEventDeviceRemovalFailedDispose)))
+ VIR_CLASS_NEW(virDomainEventClass,
+ virDomainEventDeviceRemovalFailed)))
return -1;
if (!(virDomainEventMetadataChangeClass =
- virClassNew(virDomainEventClass,
- "virDomainEventMetadataChange",
- sizeof(virDomainEventMetadataChange),
- virDomainEventMetadataChangeDispose)))
+ VIR_CLASS_NEW(virDomainEventClass,
+ virDomainEventMetadataChange)))
return -1;
if (!(virDomainEventBlockThresholdClass =
- virClassNew(virDomainEventClass,
- "virDomainEventBlockThreshold",
- sizeof(virDomainEventBlockThreshold),
- virDomainEventBlockThresholdDispose)))
+ VIR_CLASS_NEW(virDomainEventClass,
+ virDomainEventBlockThreshold)))
return -1;
return 0;
}
diff --git a/src/conf/network_event.c b/src/conf/network_event.c
index e0d1a3d5ca..2a94aceb6e 100644
--- a/src/conf/network_event.c
+++ b/src/conf/network_event.c
@@ -58,16 +58,12 @@ static int
virNetworkEventsOnceInit(void)
{
if (!(virNetworkEventClass =
- virClassNew(virClassForObjectEvent(),
- "virNetworkEvent",
- sizeof(virNetworkEvent),
- virNetworkEventDispose)))
+ VIR_CLASS_NEW(virClassForObjectEvent(),
+ virNetworkEvent)))
return -1;
if (!(virNetworkEventLifecycleClass =
- virClassNew(virNetworkEventClass,
- "virNetworkEventLifecycle",
- sizeof(virNetworkEventLifecycle),
- virNetworkEventLifecycleDispose)))
+ VIR_CLASS_NEW(virNetworkEventClass,
+ virNetworkEventLifecycle)))
return -1;
return 0;
}
diff --git a/src/conf/node_device_event.c b/src/conf/node_device_event.c
index 312ef512d1..0fbb4da49d 100644
--- a/src/conf/node_device_event.c
+++ b/src/conf/node_device_event.c
@@ -67,22 +67,16 @@ static int
virNodeDeviceEventsOnceInit(void)
{
if (!(virNodeDeviceEventClass =
- virClassNew(virClassForObjectEvent(),
- "virNodeDeviceEvent",
- sizeof(virNodeDeviceEvent),
- virNodeDeviceEventDispose)))
+ VIR_CLASS_NEW(virClassForObjectEvent(),
+ virNodeDeviceEvent)))
return -1;
if (!(virNodeDeviceEventLifecycleClass =
- virClassNew(virNodeDeviceEventClass,
- "virNodeDeviceEventLifecycle",
- sizeof(virNodeDeviceEventLifecycle),
- virNodeDeviceEventLifecycleDispose)))
+ VIR_CLASS_NEW(virNodeDeviceEventClass,
+ virNodeDeviceEventLifecycle)))
return -1;
if (!(virNodeDeviceEventUpdateClass =
- virClassNew(virNodeDeviceEventClass,
- "virNodeDeviceEventUpdate",
- sizeof(virNodeDeviceEventUpdate),
- virNodeDeviceEventUpdateDispose)))
+ VIR_CLASS_NEW(virNodeDeviceEventClass,
+ virNodeDeviceEventUpdate)))
return -1;
return 0;
}
diff --git a/src/conf/object_event.c b/src/conf/object_event.c
index e8116b880c..5a3dccc70b 100644
--- a/src/conf/object_event.c
+++ b/src/conf/object_event.c
@@ -93,17 +93,13 @@ static int
virObjectEventOnceInit(void)
{
if (!(virObjectEventStateClass =
- virClassNew(virClassForObjectLockable(),
- "virObjectEventState",
- sizeof(virObjectEventState),
- virObjectEventStateDispose)))
+ VIR_CLASS_NEW(virClassForObjectLockable(),
+ virObjectEventState)))
return -1;
if (!(virObjectEventClass =
- virClassNew(virClassForObject(),
- "virObjectEvent",
- sizeof(virObjectEvent),
- virObjectEventDispose)))
+ VIR_CLASS_NEW(virClassForObject(),
+ virObjectEvent)))
return -1;
return 0;
diff --git a/src/conf/secret_event.c b/src/conf/secret_event.c
index c130909282..4b9898a9d1 100644
--- a/src/conf/secret_event.c
+++ b/src/conf/secret_event.c
@@ -66,22 +66,16 @@ static int
virSecretEventsOnceInit(void)
{
if (!(virSecretEventClass =
- virClassNew(virClassForObjectEvent(),
- "virSecretEvent",
- sizeof(virSecretEvent),
- virSecretEventDispose)))
+ VIR_CLASS_NEW(virClassForObjectEvent(),
+ virSecretEvent)))
return -1;
if (!(virSecretEventLifecycleClass =
- virClassNew(virSecretEventClass,
- "virSecretEventLifecycle",
- sizeof(virSecretEventLifecycle),
- virSecretEventLifecycleDispose)))
+ VIR_CLASS_NEW(virSecretEventClass,
+ virSecretEventLifecycle)))
return -1;
if (!(virSecretEventValueChangedClass =
- virClassNew(virSecretEventClass,
- "virSecretEventValueChanged",
- sizeof(virSecretEventValueChanged),
- virSecretEventValueChangedDispose)))
+ VIR_CLASS_NEW(virSecretEventClass,
+ virSecretEventValueChanged)))
return -1;
return 0;
}
diff --git a/src/conf/storage_event.c b/src/conf/storage_event.c
index f9b796878a..83aa165787 100644
--- a/src/conf/storage_event.c
+++ b/src/conf/storage_event.c
@@ -67,22 +67,16 @@ static int
virStoragePoolEventsOnceInit(void)
{
if (!(virStoragePoolEventClass =
- virClassNew(virClassForObjectEvent(),
- "virStoragePoolEvent",
- sizeof(virStoragePoolEvent),
- virStoragePoolEventDispose)))
+ VIR_CLASS_NEW(virClassForObjectEvent(),
+ virStoragePoolEvent)))
return -1;
if (!(virStoragePoolEventLifecycleClass =
- virClassNew(virStoragePoolEventClass,
- "virStoragePoolEventLifecycle",
- sizeof(virStoragePoolEventLifecycle),
- virStoragePoolEventLifecycleDispose)))
+ VIR_CLASS_NEW(virStoragePoolEventClass,
+ virStoragePoolEventLifecycle)))
return -1;
if (!(virStoragePoolEventRefreshClass =
- virClassNew(virStoragePoolEventClass,
- "virStoragePoolEventRefresh",
- sizeof(virStoragePoolEventRefresh),
- virStoragePoolEventRefreshDispose)))
+ VIR_CLASS_NEW(virStoragePoolEventClass,
+ virStoragePoolEventRefresh)))
return -1;
return 0;
}
diff --git a/src/conf/virdomainobjlist.c b/src/conf/virdomainobjlist.c
index 7022abe094..5df4921187 100644
--- a/src/conf/virdomainobjlist.c
+++ b/src/conf/virdomainobjlist.c
@@ -56,10 +56,8 @@ struct _virDomainObjList {
static int virDomainObjListOnceInit(void)
{
- if (!(virDomainObjListClass = virClassNew(virClassForObjectRWLockable(),
- "virDomainObjList",
- sizeof(virDomainObjList),
- virDomainObjListDispose)))
+ if (!(virDomainObjListClass = VIR_CLASS_NEW(virClassForObjectRWLockable(),
+ virDomainObjList)))
return -1;
return 0;
diff --git a/src/conf/virinterfaceobj.c b/src/conf/virinterfaceobj.c
index f90c0bd9c4..8c572fbb23 100644
--- a/src/conf/virinterfaceobj.c
+++ b/src/conf/virinterfaceobj.c
@@ -58,16 +58,12 @@ static void virInterfaceObjListDispose(void *obj);
static int
virInterfaceObjOnceInit(void)
{
- if (!(virInterfaceObjClass = virClassNew(virClassForObjectLockable(),
- "virInterfaceObj",
- sizeof(virInterfaceObj),
- virInterfaceObjDispose)))
+ if (!(virInterfaceObjClass = VIR_CLASS_NEW(virClassForObjectLockable(),
+ virInterfaceObj)))
return -1;
- if (!(virInterfaceObjListClass = virClassNew(virClassForObjectRWLockable(),
- "virInterfaceObjList",
- sizeof(virInterfaceObjList),
- virInterfaceObjListDispose)))
+ if (!(virInterfaceObjListClass = VIR_CLASS_NEW(virClassForObjectRWLockable(),
+ virInterfaceObjList)))
return -1;
return 0;
diff --git a/src/conf/virnetworkobj.c b/src/conf/virnetworkobj.c
index 8cd1b62c1c..38522445e1 100644
--- a/src/conf/virnetworkobj.c
+++ b/src/conf/virnetworkobj.c
@@ -74,16 +74,12 @@ static void virNetworkObjListDispose(void *obj);
static int
virNetworkObjOnceInit(void)
{
- if (!(virNetworkObjClass = virClassNew(virClassForObjectLockable(),
- "virNetworkObj",
- sizeof(virNetworkObj),
- virNetworkObjDispose)))
+ if (!(virNetworkObjClass = VIR_CLASS_NEW(virClassForObjectLockable(),
+ virNetworkObj)))
return -1;
- if (!(virNetworkObjListClass = virClassNew(virClassForObjectRWLockable(),
- "virNetworkObjList",
- sizeof(virNetworkObjList),
- virNetworkObjListDispose)))
+ if (!(virNetworkObjListClass = VIR_CLASS_NEW(virClassForObjectRWLockable(),
+ virNetworkObjList)))
return -1;
return 0;
}
diff --git a/src/conf/virnodedeviceobj.c b/src/conf/virnodedeviceobj.c
index 9d2996046f..09402d82f1 100644
--- a/src/conf/virnodedeviceobj.c
+++ b/src/conf/virnodedeviceobj.c
@@ -58,16 +58,12 @@ static bool virNodeDeviceObjHasCap(const virNodeDeviceObj *obj, int
type);
static int
virNodeDeviceObjOnceInit(void)
{
- if (!(virNodeDeviceObjClass = virClassNew(virClassForObjectLockable(),
- "virNodeDeviceObj",
- sizeof(virNodeDeviceObj),
- virNodeDeviceObjDispose)))
+ if (!(virNodeDeviceObjClass = VIR_CLASS_NEW(virClassForObjectLockable(),
+ virNodeDeviceObj)))
return -1;
- if (!(virNodeDeviceObjListClass = virClassNew(virClassForObjectRWLockable(),
- "virNodeDeviceObjList",
- sizeof(virNodeDeviceObjList),
- virNodeDeviceObjListDispose)))
+ if (!(virNodeDeviceObjListClass = VIR_CLASS_NEW(virClassForObjectRWLockable(),
+ virNodeDeviceObjList)))
return -1;
return 0;
diff --git a/src/conf/virsecretobj.c b/src/conf/virsecretobj.c
index 47e0b28968..fee31ff366 100644
--- a/src/conf/virsecretobj.c
+++ b/src/conf/virsecretobj.c
@@ -68,16 +68,12 @@ struct virSecretSearchData {
static int
virSecretObjOnceInit(void)
{
- if (!(virSecretObjClass = virClassNew(virClassForObjectLockable(),
- "virSecretObj",
- sizeof(virSecretObj),
- virSecretObjDispose)))
+ if (!(virSecretObjClass = VIR_CLASS_NEW(virClassForObjectLockable(),
+ virSecretObj)))
return -1;
- if (!(virSecretObjListClass = virClassNew(virClassForObjectRWLockable(),
- "virSecretObjList",
- sizeof(virSecretObjList),
- virSecretObjListDispose)))
+ if (!(virSecretObjListClass = VIR_CLASS_NEW(virClassForObjectRWLockable(),
+ virSecretObjList)))
return -1;
return 0;
diff --git a/src/conf/virstorageobj.c b/src/conf/virstorageobj.c
index 799b8c9fa3..7ed187e30f 100644
--- a/src/conf/virstorageobj.c
+++ b/src/conf/virstorageobj.c
@@ -110,16 +110,12 @@ struct _virStoragePoolObjList {
static int
virStorageVolObjOnceInit(void)
{
- if (!(virStorageVolObjClass = virClassNew(virClassForObjectLockable(),
- "virStorageVolObj",
- sizeof(virStorageVolObj),
- virStorageVolObjDispose)))
+ if (!(virStorageVolObjClass = VIR_CLASS_NEW(virClassForObjectLockable(),
+ virStorageVolObj)))
return -1;
- if (!(virStorageVolObjListClass = virClassNew(virClassForObjectRWLockable(),
- "virStorageVolObjList",
- sizeof(virStorageVolObjList),
- virStorageVolObjListDispose)))
+ if (!(virStorageVolObjListClass = VIR_CLASS_NEW(virClassForObjectRWLockable(),
+ virStorageVolObjList)))
return -1;
return 0;
@@ -207,16 +203,12 @@ virStorageVolObjListDispose(void *opaque)
static int
virStoragePoolObjOnceInit(void)
{
- if (!(virStoragePoolObjClass = virClassNew(virClassForObjectLockable(),
- "virStoragePoolObj",
- sizeof(virStoragePoolObj),
- virStoragePoolObjDispose)))
+ if (!(virStoragePoolObjClass = VIR_CLASS_NEW(virClassForObjectLockable(),
+ virStoragePoolObj)))
return -1;
- if (!(virStoragePoolObjListClass = virClassNew(virClassForObjectRWLockable(),
- "virStoragePoolObjList",
- sizeof(virStoragePoolObjList),
- virStoragePoolObjListDispose)))
+ if (!(virStoragePoolObjListClass = VIR_CLASS_NEW(virClassForObjectRWLockable(),
+ virStoragePoolObjList)))
return -1;
return 0;
diff --git a/src/datatypes.c b/src/datatypes.c
index 0c3c66a9ce..3016e45076 100644
--- a/src/datatypes.c
+++ b/src/datatypes.c
@@ -74,10 +74,8 @@ static int
virDataTypesOnceInit(void)
{
#define DECLARE_CLASS_COMMON(basename, parent) \
- if (!(basename ## Class = virClassNew(parent, \
- #basename, \
- sizeof(basename), \
- basename ## Dispose))) \
+ if (!(basename ## Class = VIR_CLASS_NEW(parent, \
+ basename))) \
return -1;
#define DECLARE_CLASS(basename) \
DECLARE_CLASS_COMMON(basename, virClassForObject())
diff --git a/src/interface/interface_backend_netcf.c
b/src/interface/interface_backend_netcf.c
index cc2402febb..8acccf8940 100644
--- a/src/interface/interface_backend_netcf.c
+++ b/src/interface/interface_backend_netcf.c
@@ -55,10 +55,8 @@ static void virNetcfDriverStateDispose(void *obj);
static int
virNetcfDriverStateOnceInit(void)
{
- if (!(virNetcfDriverStateClass = virClassNew(virClassForObjectLockable(),
- "virNetcfDriverState",
- sizeof(virNetcfDriverState),
- virNetcfDriverStateDispose)))
+ if (!(virNetcfDriverStateClass = VIR_CLASS_NEW(virClassForObjectLockable(),
+ virNetcfDriverStat)))
return -1;
return 0;
}
diff --git a/src/libvirt-admin.c b/src/libvirt-admin.c
index 7f695311b4..cb2ec9d633 100644
--- a/src/libvirt-admin.c
+++ b/src/libvirt-admin.c
@@ -67,10 +67,8 @@ virAdmGlobalInit(void)
if (!bindtextdomain(PACKAGE, LOCALEDIR))
goto error;
- if (!(remoteAdminPrivClass = virClassNew(virClassForObjectLockable(),
- "remoteAdminPriv",
- sizeof(remoteAdminPriv),
- remoteAdminPrivDispose)))
+ if (!(remoteAdminPrivClass = VIR_CLASS_NEW(virClassForObjectLockable(),
+ remoteAdminPriv)))
goto error;
return;
diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
index df1cece82f..b398cbee67 100644
--- a/src/libxl/libxl_conf.c
+++ b/src/libxl/libxl_conf.c
@@ -62,10 +62,8 @@ static void libxlDriverConfigDispose(void *obj);
static int libxlConfigOnceInit(void)
{
- if (!(libxlDriverConfigClass = virClassNew(virClassForObject(),
- "libxlDriverConfig",
- sizeof(libxlDriverConfig),
- libxlDriverConfigDispose)))
+ if (!(libxlDriverConfigClass = VIR_CLASS_NEW(virClassForObject(),
+ libxlDriverConfig)))
return -1;
return 0;
diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c
index ef9a902671..0882a9fc98 100644
--- a/src/libxl/libxl_domain.c
+++ b/src/libxl/libxl_domain.c
@@ -58,10 +58,8 @@ libxlDomainObjPrivateDispose(void *obj);
static int
libxlDomainObjPrivateOnceInit(void)
{
- if (!(libxlDomainObjPrivateClass = virClassNew(virClassForObjectLockable(),
- "libxlDomainObjPrivate",
- sizeof(libxlDomainObjPrivate),
- libxlDomainObjPrivateDispose)))
+ if (!(libxlDomainObjPrivateClass = VIR_CLASS_NEW(virClassForObjectLockable(),
+ libxlDomainObjPrivate)))
return -1;
return 0;
diff --git a/src/libxl/libxl_migration.c b/src/libxl/libxl_migration.c
index 5c0fd4b052..93e72bf815 100644
--- a/src/libxl/libxl_migration.c
+++ b/src/libxl/libxl_migration.c
@@ -244,10 +244,8 @@ libxlMigrationDstArgsDispose(void *obj)
static int
libxlMigrationDstArgsOnceInit(void)
{
- if (!(libxlMigrationDstArgsClass = virClassNew(virClassForObject(),
- "libxlMigrationDstArgs",
- sizeof(libxlMigrationDstArgs),
- libxlMigrationDstArgsDispose)))
+ if (!(libxlMigrationDstArgsClass = VIR_CLASS_NEW(virClassForObject(),
+ libxlMigrationDstArgs)))
return -1;
return 0;
diff --git a/src/logging/log_handler.c b/src/logging/log_handler.c
index cd0ba6ec24..7d275d4a80 100644
--- a/src/logging/log_handler.c
+++ b/src/logging/log_handler.c
@@ -76,10 +76,8 @@ static void virLogHandlerDispose(void *obj);
static int
virLogHandlerOnceInit(void)
{
- if (!(virLogHandlerClass = virClassNew(virClassForObjectLockable(),
- "virLogHandler",
- sizeof(virLogHandler),
- virLogHandlerDispose)))
+ if (!(virLogHandlerClass = VIR_CLASS_NEW(virClassForObjectLockable(),
+ virLogHandler)))
return -1;
return 0;
diff --git a/src/lxc/lxc_conf.c b/src/lxc/lxc_conf.c
index 92a82a4768..f623685be8 100644
--- a/src/lxc/lxc_conf.c
+++ b/src/lxc/lxc_conf.c
@@ -48,10 +48,8 @@ static void virLXCDriverConfigDispose(void *obj);
static int virLXCConfigOnceInit(void)
{
- if (!(virLXCDriverConfigClass = virClassNew(virClassForObject(),
- "virLXCDriverConfig",
- sizeof(virLXCDriverConfig),
- virLXCDriverConfigDispose)))
+ if (!(virLXCDriverConfigClass = VIR_CLASS_NEW(virClassForObject(),
+ virLXCDriverConfig)))
return -1;
return 0;
diff --git a/src/lxc/lxc_monitor.c b/src/lxc/lxc_monitor.c
index 9cab6c2035..0c6daf5882 100644
--- a/src/lxc/lxc_monitor.c
+++ b/src/lxc/lxc_monitor.c
@@ -51,10 +51,8 @@ static void virLXCMonitorDispose(void *obj);
static int virLXCMonitorOnceInit(void)
{
- if (!(virLXCMonitorClass = virClassNew(virClassForObjectLockable(),
- "virLXCMonitor",
- sizeof(virLXCMonitor),
- virLXCMonitorDispose)))
+ if (!(virLXCMonitorClass = VIR_CLASS_NEW(virClassForObjectLockable(),
+ virLXCMonitor)))
return -1;
return 0;
diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c
index de01816402..e87b5886b8 100644
--- a/src/node_device/node_device_udev.c
+++ b/src/node_device/node_device_udev.c
@@ -93,10 +93,8 @@ udevEventDataDispose(void *obj)
static int
udevEventDataOnceInit(void)
{
- if (!(udevEventDataClass = virClassNew(virClassForObjectLockable(),
- "udevEventData",
- sizeof(udevEventData),
- udevEventDataDispose)))
+ if (!(udevEventDataClass = VIR_CLASS_NEW(virClassForObjectLockable(),
+ udevEventData)))
return -1;
return 0;
diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c
index 85af53d194..3e03997f07 100644
--- a/src/qemu/qemu_agent.c
+++ b/src/qemu/qemu_agent.c
@@ -138,10 +138,8 @@ static void qemuAgentDispose(void *obj);
static int qemuAgentOnceInit(void)
{
- if (!(qemuAgentClass = virClassNew(virClassForObjectLockable(),
- "qemuAgent",
- sizeof(qemuAgent),
- qemuAgentDispose)))
+ if (!(qemuAgentClass = VIR_CLASS_NEW(virClassForObjectLockable(),
+ qemuAgent)))
return -1;
return 0;
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index b5347b6cad..656dac18bf 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -548,10 +548,8 @@ static void virQEMUCapsDispose(void *obj);
static int virQEMUCapsOnceInit(void)
{
- if (!(virQEMUCapsClass = virClassNew(virClassForObject(),
- "virQEMUCaps",
- sizeof(virQEMUCaps),
- virQEMUCapsDispose)))
+ if (!(virQEMUCapsClass = VIR_CLASS_NEW(virClassForObject(),
+ virQEMUCaps)))
return -1;
return 0;
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 36cf3a281c..5e05fedb9e 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -80,10 +80,8 @@ static void virQEMUDriverConfigDispose(void *obj);
static int virQEMUConfigOnceInit(void)
{
- virQEMUDriverConfigClass = virClassNew(virClassForObject(),
- "virQEMUDriverConfig",
- sizeof(virQEMUDriverConfig),
- virQEMUDriverConfigDispose);
+ virQEMUDriverConfigClass = VIR_CLASS_NEW(virClassForObject(),
+ virQEMUDriverConfig);
if (!virQEMUDriverConfigClass)
return -1;
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 7000de6a91..133506dd18 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -130,16 +130,12 @@ static void qemuDomainSaveCookieDispose(void *obj);
static int
qemuDomainOnceInit(void)
{
- if (!(qemuDomainLogContextClass = virClassNew(virClassForObject(),
- "qemuDomainLogContext",
- sizeof(qemuDomainLogContext),
- qemuDomainLogContextDispose)))
+ if (!(qemuDomainLogContextClass = VIR_CLASS_NEW(virClassForObject(),
+ qemuDomainLogContext)))
return -1;
- if (!(qemuDomainSaveCookieClass = virClassNew(virClassForObject(),
- "qemuDomainSaveCookie",
- sizeof(qemuDomainSaveCookie),
- qemuDomainSaveCookieDispose)))
+ if (!(qemuDomainSaveCookieClass = VIR_CLASS_NEW(virClassForObject(),
+ qemuDomainSaveCookie)))
return -1;
return 0;
@@ -988,10 +984,8 @@ static void qemuDomainDiskPrivateDispose(void *obj);
static int
qemuDomainDiskPrivateOnceInit(void)
{
- qemuDomainDiskPrivateClass = virClassNew(virClassForObject(),
- "qemuDomainDiskPrivate",
- sizeof(qemuDomainDiskPrivate),
- qemuDomainDiskPrivateDispose);
+ qemuDomainDiskPrivateClass = VIR_CLASS_NEW(virClassForObject(),
+ qemuDomainDiskPrivate);
if (!qemuDomainDiskPrivateClass)
return -1;
else
@@ -1028,10 +1022,8 @@ static void qemuDomainStorageSourcePrivateDispose(void *obj);
static int
qemuDomainStorageSourcePrivateOnceInit(void)
{
- qemuDomainStorageSourcePrivateClass = virClassNew(virClassForObject(),
-
"qemuDomainStorageSourcePrivate",
-
sizeof(qemuDomainStorageSourcePrivate),
-
qemuDomainStorageSourcePrivateDispose);
+ qemuDomainStorageSourcePrivateClass = VIR_CLASS_NEW(virClassForObject(),
+ qemuDomainStorageSourcePrivate);
if (!qemuDomainStorageSourcePrivateClass)
return -1;
else
@@ -1071,10 +1063,8 @@ static void qemuDomainVcpuPrivateDispose(void *obj);
static int
qemuDomainVcpuPrivateOnceInit(void)
{
- qemuDomainVcpuPrivateClass = virClassNew(virClassForObject(),
- "qemuDomainVcpuPrivate",
- sizeof(qemuDomainVcpuPrivate),
- qemuDomainVcpuPrivateDispose);
+ qemuDomainVcpuPrivateClass = VIR_CLASS_NEW(virClassForObject(),
+ qemuDomainVcpuPrivate);
if (!qemuDomainVcpuPrivateClass)
return -1;
else
@@ -1116,10 +1106,8 @@ static int
qemuDomainChrSourcePrivateOnceInit(void)
{
qemuDomainChrSourcePrivateClass =
- virClassNew(virClassForObject(),
- "qemuDomainChrSourcePrivate",
- sizeof(qemuDomainChrSourcePrivate),
- qemuDomainChrSourcePrivateDispose);
+ VIR_CLASS_NEW(virClassForObject(),
+ qemuDomainChrSourcePrivate);
if (!qemuDomainChrSourcePrivateClass)
return -1;
else
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index 7b647525b3..a8b2ba91b5 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -165,10 +165,8 @@ static void qemuMonitorDispose(void *obj);
static int qemuMonitorOnceInit(void)
{
- if (!(qemuMonitorClass = virClassNew(virClassForObjectLockable(),
- "qemuMonitor",
- sizeof(qemuMonitor),
- qemuMonitorDispose)))
+ if (!(qemuMonitorClass = VIR_CLASS_NEW(virClassForObjectLockable(),
+ qemuMonitor)))
return -1;
return 0;
diff --git a/src/rpc/virkeepalive.c b/src/rpc/virkeepalive.c
index 4f666fd09b..aa49e6c7f4 100644
--- a/src/rpc/virkeepalive.c
+++ b/src/rpc/virkeepalive.c
@@ -58,10 +58,8 @@ static void virKeepAliveDispose(void *obj);
static int virKeepAliveOnceInit(void)
{
- if (!(virKeepAliveClass = virClassNew(virClassForObjectLockable(),
- "virKeepAlive",
- sizeof(virKeepAlive),
- virKeepAliveDispose)))
+ if (!(virKeepAliveClass = VIR_CLASS_NEW(virClassForObjectLockable(),
+ virKeepAlive)))
return -1;
return 0;
diff --git a/src/rpc/virnetclient.c b/src/rpc/virnetclient.c
index 0c8d58c32c..5fa304b24f 100644
--- a/src/rpc/virnetclient.c
+++ b/src/rpc/virnetclient.c
@@ -120,10 +120,8 @@ static void virNetClientDispose(void *obj);
static int virNetClientOnceInit(void)
{
- if (!(virNetClientClass = virClassNew(virClassForObjectLockable(),
- "virNetClient",
- sizeof(virNetClient),
- virNetClientDispose)))
+ if (!(virNetClientClass = VIR_CLASS_NEW(virClassForObjectLockable(),
+ virNetClient)))
return -1;
return 0;
diff --git a/src/rpc/virnetclientprogram.c b/src/rpc/virnetclientprogram.c
index d1e54a0892..04f5dea7ad 100644
--- a/src/rpc/virnetclientprogram.c
+++ b/src/rpc/virnetclientprogram.c
@@ -54,10 +54,8 @@ static void virNetClientProgramDispose(void *obj);
static int virNetClientProgramOnceInit(void)
{
- if (!(virNetClientProgramClass = virClassNew(virClassForObject(),
- "virNetClientProgram",
- sizeof(virNetClientProgram),
- virNetClientProgramDispose)))
+ if (!(virNetClientProgramClass = VIR_CLASS_NEW(virClassForObject(),
+ virNetClientProgram)))
return -1;
return 0;
diff --git a/src/rpc/virnetclientstream.c b/src/rpc/virnetclientstream.c
index 2f037db0dc..963634b5af 100644
--- a/src/rpc/virnetclientstream.c
+++ b/src/rpc/virnetclientstream.c
@@ -71,10 +71,8 @@ static void virNetClientStreamDispose(void *obj);
static int virNetClientStreamOnceInit(void)
{
- if (!(virNetClientStreamClass = virClassNew(virClassForObjectLockable(),
- "virNetClientStream",
- sizeof(virNetClientStream),
- virNetClientStreamDispose)))
+ if (!(virNetClientStreamClass = VIR_CLASS_NEW(virClassForObjectLockable(),
+ virNetClientStream)))
return -1;
return 0;
diff --git a/src/rpc/virnetdaemon.c b/src/rpc/virnetdaemon.c
index 6f00bfd9d1..8658878b0a 100644
--- a/src/rpc/virnetdaemon.c
+++ b/src/rpc/virnetdaemon.c
@@ -110,10 +110,8 @@ virNetDaemonDispose(void *obj)
static int
virNetDaemonOnceInit(void)
{
- if (!(virNetDaemonClass = virClassNew(virClassForObjectLockable(),
- "virNetDaemon",
- sizeof(virNetDaemon),
- virNetDaemonDispose)))
+ if (!(virNetDaemonClass = VIR_CLASS_NEW(virClassForObjectLockable(),
+ virNetDaemon)))
return -1;
return 0;
diff --git a/src/rpc/virnetlibsshsession.c b/src/rpc/virnetlibsshsession.c
index 25f93cec97..5875c258df 100644
--- a/src/rpc/virnetlibsshsession.c
+++ b/src/rpc/virnetlibsshsession.c
@@ -161,10 +161,8 @@ virNetLibsshSessionOnceInit(void)
{
const char *dbgLevelStr;
- if (!(virNetLibsshSessionClass = virClassNew(virClassForObjectLockable(),
- "virNetLibsshSession",
- sizeof(virNetLibsshSession),
- virNetLibsshSessionDispose)))
+ if (!(virNetLibsshSessionClass = VIR_CLASS_NEW(virClassForObjectLockable(),
+ virNetLibsshSession)))
return -1;
if (ssh_init() < 0) {
diff --git a/src/rpc/virnetsaslcontext.c b/src/rpc/virnetsaslcontext.c
index f1f8bdc855..56fa57ff7e 100644
--- a/src/rpc/virnetsaslcontext.c
+++ b/src/rpc/virnetsaslcontext.c
@@ -57,16 +57,12 @@ static void virNetSASLSessionDispose(void *obj);
static int virNetSASLContextOnceInit(void)
{
- if (!(virNetSASLContextClass = virClassNew(virClassForObjectLockable(),
- "virNetSASLContext",
- sizeof(virNetSASLContext),
- virNetSASLContextDispose)))
+ if (!(virNetSASLContextClass = VIR_CLASS_NEW(virClassForObjectLockable(),
+ virNetSASLContext)))
return -1;
- if (!(virNetSASLSessionClass = virClassNew(virClassForObjectLockable(),
- "virNetSASLSession",
- sizeof(virNetSASLSession),
- virNetSASLSessionDispose)))
+ if (!(virNetSASLSessionClass = VIR_CLASS_NEW(virClassForObjectLockable(),
+ virNetSASLSession)))
return -1;
return 0;
diff --git a/src/rpc/virnetserver.c b/src/rpc/virnetserver.c
index 3ce21a8f53..de0692f3cf 100644
--- a/src/rpc/virnetserver.c
+++ b/src/rpc/virnetserver.c
@@ -93,10 +93,8 @@ static inline size_t
virNetServerTrackCompletedAuthLocked(virNetServerPtr srv);
static int virNetServerOnceInit(void)
{
- if (!(virNetServerClass = virClassNew(virClassForObjectLockable(),
- "virNetServer",
- sizeof(virNetServer),
- virNetServerDispose)))
+ if (!(virNetServerClass = VIR_CLASS_NEW(virClassForObjectLockable(),
+ virNetServer)))
return -1;
return 0;
diff --git a/src/rpc/virnetserverclient.c b/src/rpc/virnetserverclient.c
index d5f0cf448f..2ef590641c 100644
--- a/src/rpc/virnetserverclient.c
+++ b/src/rpc/virnetserverclient.c
@@ -129,10 +129,8 @@ static void virNetServerClientDispose(void *obj);
static int virNetServerClientOnceInit(void)
{
- if (!(virNetServerClientClass = virClassNew(virClassForObjectLockable(),
- "virNetServerClient",
- sizeof(virNetServerClient),
- virNetServerClientDispose)))
+ if (!(virNetServerClientClass = VIR_CLASS_NEW(virClassForObjectLockable(),
+ virNetServerClient)))
return -1;
return 0;
diff --git a/src/rpc/virnetserverprogram.c b/src/rpc/virnetserverprogram.c
index f28274fc22..75cd01b299 100644
--- a/src/rpc/virnetserverprogram.c
+++ b/src/rpc/virnetserverprogram.c
@@ -51,10 +51,8 @@ static void virNetServerProgramDispose(void *obj);
static int virNetServerProgramOnceInit(void)
{
- if (!(virNetServerProgramClass = virClassNew(virClassForObject(),
- "virNetServerProgram",
- sizeof(virNetServerProgram),
- virNetServerProgramDispose)))
+ if (!(virNetServerProgramClass = VIR_CLASS_NEW(virClassForObject(),
+ virNetServerProgram)))
return -1;
return 0;
diff --git a/src/rpc/virnetserverservice.c b/src/rpc/virnetserverservice.c
index d2350b2b91..11a1d164fd 100644
--- a/src/rpc/virnetserverservice.c
+++ b/src/rpc/virnetserverservice.c
@@ -57,10 +57,8 @@ static void virNetServerServiceDispose(void *obj);
static int virNetServerServiceOnceInit(void)
{
- if (!(virNetServerServiceClass = virClassNew(virClassForObject(),
- "virNetServerService",
- sizeof(virNetServerService),
- virNetServerServiceDispose)))
+ if (!(virNetServerServiceClass = VIR_CLASS_NEW(virClassForObject(),
+ virNetServerService)))
return -1;
return 0;
diff --git a/src/rpc/virnetsocket.c b/src/rpc/virnetsocket.c
index f362a09555..f605db3930 100644
--- a/src/rpc/virnetsocket.c
+++ b/src/rpc/virnetsocket.c
@@ -124,10 +124,8 @@ static void virNetSocketDispose(void *obj);
static int virNetSocketOnceInit(void)
{
- if (!(virNetSocketClass = virClassNew(virClassForObjectLockable(),
- "virNetSocket",
- sizeof(virNetSocket),
- virNetSocketDispose)))
+ if (!(virNetSocketClass = VIR_CLASS_NEW(virClassForObjectLockable(),
+ virNetSocket)))
return -1;
return 0;
diff --git a/src/rpc/virnetsshsession.c b/src/rpc/virnetsshsession.c
index e742175654..a5f905b88d 100644
--- a/src/rpc/virnetsshsession.c
+++ b/src/rpc/virnetsshsession.c
@@ -167,10 +167,8 @@ static virClassPtr virNetSSHSessionClass;
static int
virNetSSHSessionOnceInit(void)
{
- if (!(virNetSSHSessionClass = virClassNew(virClassForObjectLockable(),
- "virNetSSHSession",
- sizeof(virNetSSHSession),
- virNetSSHSessionDispose)))
+ if (!(virNetSSHSessionClass = VIR_CLASS_NEW(virClassForObjectLockable(),
+ virNetSSHSession)))
return -1;
return 0;
diff --git a/src/rpc/virnettlscontext.c b/src/rpc/virnettlscontext.c
index 5699eb8f24..a419c5f831 100644
--- a/src/rpc/virnettlscontext.c
+++ b/src/rpc/virnettlscontext.c
@@ -90,16 +90,12 @@ static void virNetTLSSessionDispose(void *obj);
static int virNetTLSContextOnceInit(void)
{
- if (!(virNetTLSContextClass = virClassNew(virClassForObjectLockable(),
- "virNetTLSContext",
- sizeof(virNetTLSContext),
- virNetTLSContextDispose)))
+ if (!(virNetTLSContextClass = VIR_CLASS_NEW(virClassForObjectLockable(),
+ virNetTLSContext)))
return -1;
- if (!(virNetTLSSessionClass = virClassNew(virClassForObjectLockable(),
- "virNetTLSSession",
- sizeof(virNetTLSSession),
- virNetTLSSessionDispose)))
+ if (!(virNetTLSSessionClass = VIR_CLASS_NEW(virClassForObjectLockable(),
+ virNetTLSSession)))
return -1;
return 0;
diff --git a/src/security/security_manager.c b/src/security/security_manager.c
index fdeea4d533..422de15060 100644
--- a/src/security/security_manager.c
+++ b/src/security/security_manager.c
@@ -59,10 +59,8 @@ void virSecurityManagerDispose(void *obj)
static int
virSecurityManagerOnceInit(void)
{
- if (!(virSecurityManagerClass = virClassNew(virClassForObjectLockable(),
- "virSecurityManagerClass",
- sizeof(virSecurityManager),
- virSecurityManagerDispose)))
+ if (!(virSecurityManagerClass = VIR_CLASS_NEW(virClassForObjectLockable(),
+ virSecurityManager)))
return -1;
return 0;
diff --git a/src/util/virclosecallbacks.c b/src/util/virclosecallbacks.c
index 49dac65892..11d8fd8cbd 100644
--- a/src/util/virclosecallbacks.c
+++ b/src/util/virclosecallbacks.c
@@ -53,10 +53,8 @@ static void virCloseCallbacksDispose(void *obj);
static int virCloseCallbacksOnceInit(void)
{
- virCloseCallbacksClass = virClassNew(virClassForObjectLockable(),
- "virCloseCallbacks",
- sizeof(virCloseCallbacks),
- virCloseCallbacksDispose);
+ virCloseCallbacksClass = VIR_CLASS_NEW(virClassForObjectLockable(),
+ virCloseCallbacks);
if (!virCloseCallbacksClass)
return -1;
diff --git a/src/util/virdnsmasq.c b/src/util/virdnsmasq.c
index db5c51b6a2..3af3785a23 100644
--- a/src/util/virdnsmasq.c
+++ b/src/util/virdnsmasq.c
@@ -641,12 +641,9 @@ dnsmasqCapsDispose(void *obj)
static int dnsmasqCapsOnceInit(void)
{
- if (!(dnsmasqCapsClass = virClassNew(virClassForObject(),
- "dnsmasqCaps",
- sizeof(dnsmasqCaps),
- dnsmasqCapsDispose))) {
+ if (!(dnsmasqCapsClass = VIR_CLASS_NEW(virClassForObject(),
+ dnsmasqCaps)))
return -1;
- }
return 0;
}
diff --git a/src/util/virfdstream.c b/src/util/virfdstream.c
index e2d3f365cd..e7d2e4a954 100644
--- a/src/util/virfdstream.c
+++ b/src/util/virfdstream.c
@@ -129,10 +129,8 @@ virFDStreamDataDispose(void *obj)
static int virFDStreamDataOnceInit(void)
{
- if (!(virFDStreamDataClass = virClassNew(virClassForObjectLockable(),
- "virFDStreamData",
- sizeof(virFDStreamData),
- virFDStreamDataDispose)))
+ if (!(virFDStreamDataClass = VIR_CLASS_NEW(virClassForObjectLockable(),
+ virFDStreamData)))
return -1;
return 0;
diff --git a/src/util/virfilecache.c b/src/util/virfilecache.c
index e24eb5a68c..a1ff518386 100644
--- a/src/util/virfilecache.c
+++ b/src/util/virfilecache.c
@@ -86,10 +86,8 @@ virFileCacheDispose(void *obj)
static int
virFileCacheOnceInit(void)
{
- if (!(virFileCacheClass = virClassNew(virClassForObjectLockable(),
- "virFileCache",
- sizeof(virFileCache),
- virFileCacheDispose)))
+ if (!(virFileCacheClass = VIR_CLASS_NEW(virClassForObjectLockable(),
+ virFileCache)))
return -1;
return 0;
diff --git a/src/util/virhash.c b/src/util/virhash.c
index 475c2b0281..bd00b7f359 100644
--- a/src/util/virhash.c
+++ b/src/util/virhash.c
@@ -77,10 +77,8 @@ static void virHashAtomicDispose(void *obj);
static int virHashAtomicOnceInit(void)
{
- virHashAtomicClass = virClassNew(virClassForObjectLockable(),
- "virHashAtomic",
- sizeof(virHashAtomic),
- virHashAtomicDispose);
+ virHashAtomicClass = VIR_CLASS_NEW(virClassForObjectLockable(),
+ virHashAtomic);
if (!virHashAtomicClass)
return -1;
else
diff --git a/src/util/virhostdev.c b/src/util/virhostdev.c
index a12224c58f..b8a5d4d5d3 100644
--- a/src/util/virhostdev.c
+++ b/src/util/virhostdev.c
@@ -120,10 +120,8 @@ static int virHostdevIsPCINodeDeviceUsed(virPCIDeviceAddressPtr
devAddr, void *o
static int virHostdevManagerOnceInit(void)
{
- if (!(virHostdevManagerClass = virClassNew(virClassForObject(),
- "virHostdevManager",
- sizeof(virHostdevManager),
- virHostdevManagerDispose)))
+ if (!(virHostdevManagerClass = VIR_CLASS_NEW(virClassForObject(),
+ virHostdevManager)))
return -1;
if (!(manager = virHostdevManagerNew()))
diff --git a/src/util/viridentity.c b/src/util/viridentity.c
index 52a0a30a45..b9ffeecefa 100644
--- a/src/util/viridentity.c
+++ b/src/util/viridentity.c
@@ -54,10 +54,8 @@ static void virIdentityDispose(void *obj);
static int virIdentityOnceInit(void)
{
- if (!(virIdentityClass = virClassNew(virClassForObject(),
- "virIdentity",
- sizeof(virIdentity),
- virIdentityDispose)))
+ if (!(virIdentityClass = VIR_CLASS_NEW(virClassForObject(),
+ virIdentity)))
return -1;
if (virThreadLocalInit(&virIdentityCurrent,
diff --git a/src/util/virmacmap.c b/src/util/virmacmap.c
index d3be3066cc..3e376c0c73 100644
--- a/src/util/virmacmap.c
+++ b/src/util/virmacmap.c
@@ -74,10 +74,8 @@ virMacMapDispose(void *obj)
static int virMacMapOnceInit(void)
{
- if (!(virMacMapClass = virClassNew(virClassForObjectLockable(),
- "virMacMapClass",
- sizeof(virMacMap),
- virMacMapDispose)))
+ if (!(virMacMapClass = VIR_CLASS_NEW(virClassForObjectLockable(),
+ virMacMap)))
return -1;
return 0;
diff --git a/src/util/virmdev.c b/src/util/virmdev.c
index 27541cf34f..a74a7d5554 100644
--- a/src/util/virmdev.c
+++ b/src/util/virmdev.c
@@ -58,10 +58,8 @@ virMediatedDeviceListDispose(void *obj);
static int
virMediatedOnceInit(void)
{
- if (!(virMediatedDeviceListClass = virClassNew(virClassForObjectLockable(),
- "virMediatedDeviceList",
- sizeof(virMediatedDeviceList),
- virMediatedDeviceListDispose)))
+ if (!(virMediatedDeviceListClass = VIR_CLASS_NEW(virClassForObjectLockable(),
+ virMediatedDeviceList)))
return -1;
return 0;
diff --git a/src/util/virobject.c b/src/util/virobject.c
index 1723df6b2f..c5a98d21cc 100644
--- a/src/util/virobject.c
+++ b/src/util/virobject.c
@@ -81,16 +81,12 @@ virObjectOnceInit(void)
NULL)))
return -1;
- if (!(virObjectLockableClass = virClassNew(virObjectClass,
- "virObjectLockable",
- sizeof(virObjectLockable),
- virObjectLockableDispose)))
+ if (!(virObjectLockableClass = VIR_CLASS_NEW(virObjectClass,
+ virObjectLockable)))
return -1;
- if (!(virObjectRWLockableClass = virClassNew(virObjectClass,
- "virObjectRWLockable",
- sizeof(virObjectRWLockable),
- virObjectRWLockableDispose)))
+ if (!(virObjectRWLockableClass = VIR_CLASS_NEW(virObjectClass,
+ virObjectRWLockable)))
return -1;
return 0;
diff --git a/src/util/virobject.h b/src/util/virobject.h
index ac6cf22f9e..92dd512399 100644
--- a/src/util/virobject.h
+++ b/src/util/virobject.h
@@ -74,6 +74,10 @@ virClassPtr virClassForObjectRWLockable(void);
# ifndef VIR_PARENT_REQUIRED
# define VIR_PARENT_REQUIRED ATTRIBUTE_NONNULL(1)
# endif
+
+# define VIR_CLASS_NEW(prnt, name) \
+ virClassNew(prnt, #name, sizeof(name), name##Dispose)
+
virClassPtr
virClassNew(virClassPtr parent,
const char *name,
diff --git a/src/util/virpci.c b/src/util/virpci.c
index 55e4c3e492..ba8449116a 100644
--- a/src/util/virpci.c
+++ b/src/util/virpci.c
@@ -204,10 +204,8 @@ static void virPCIDeviceListDispose(void *obj);
static int virPCIOnceInit(void)
{
- if (!(virPCIDeviceListClass = virClassNew(virClassForObjectLockable(),
- "virPCIDeviceList",
- sizeof(virPCIDeviceList),
- virPCIDeviceListDispose)))
+ if (!(virPCIDeviceListClass = VIR_CLASS_NEW(virClassForObjectLockable(),
+ virPCIDeviceList)))
return -1;
return 0;
diff --git a/src/util/virportallocator.c b/src/util/virportallocator.c
index 25200fbbb2..63c0be0b6e 100644
--- a/src/util/virportallocator.c
+++ b/src/util/virportallocator.c
@@ -80,10 +80,8 @@ virPortAllocatorNew(void)
static int
virPortAllocatorOnceInit(void)
{
- if (!(virPortAllocatorClass = virClassNew(virClassForObjectLockable(),
- "virPortAllocator",
- sizeof(virPortAllocator),
- virPortAllocatorDispose)))
+ if (!(virPortAllocatorClass = VIR_CLASS_NEW(virClassForObjectLockable(),
+ virPortAllocator)))
return -1;
if (!(virPortAllocatorInstance = virPortAllocatorNew()))
diff --git a/src/util/virresctrl.c b/src/util/virresctrl.c
index 9639e00468..d78612f521 100644
--- a/src/util/virresctrl.c
+++ b/src/util/virresctrl.c
@@ -133,10 +133,8 @@ virResctrlInfoDispose(void *obj)
static int
virResctrlInfoOnceInit(void)
{
- if (!(virResctrlInfoClass = virClassNew(virClassForObject(),
- "virResctrlInfo",
- sizeof(virResctrlInfo),
- virResctrlInfoDispose)))
+ if (!(virResctrlInfoClass = VIR_CLASS_NEW(virClassForObject(),
+ virResctrlInfo)))
return -1;
return 0;
@@ -271,10 +269,8 @@ virResctrlAllocDispose(void *obj)
static int
virResctrlAllocOnceInit(void)
{
- if (!(virResctrlAllocClass = virClassNew(virClassForObject(),
- "virResctrlAlloc",
- sizeof(virResctrlAlloc),
- virResctrlAllocDispose)))
+ if (!(virResctrlAllocClass = VIR_CLASS_NEW(virClassForObject(),
+ virResctrlAlloc)))
return -1;
return 0;
diff --git a/src/util/virscsi.c b/src/util/virscsi.c
index 22f2677a3f..c1e2eb3790 100644
--- a/src/util/virscsi.c
+++ b/src/util/virscsi.c
@@ -85,10 +85,8 @@ static void virSCSIDeviceListDispose(void *obj);
static int
virSCSIOnceInit(void)
{
- if (!(virSCSIDeviceListClass = virClassNew(virClassForObjectLockable(),
- "virSCSIDeviceList",
- sizeof(virSCSIDeviceList),
- virSCSIDeviceListDispose)))
+ if (!(virSCSIDeviceListClass = VIR_CLASS_NEW(virClassForObjectLockable(),
+ virSCSIDeviceList)))
return -1;
return 0;
diff --git a/src/util/virscsivhost.c b/src/util/virscsivhost.c
index 5f176e177f..c28403809d 100644
--- a/src/util/virscsivhost.c
+++ b/src/util/virscsivhost.c
@@ -70,10 +70,8 @@ virSCSIVHostDeviceListDispose(void *obj)
static int
virSCSIVHostOnceInit(void)
{
- if (!(virSCSIVHostDeviceListClass = virClassNew(virClassForObjectLockable(),
- "virSCSIVHostDeviceList",
- sizeof(virSCSIVHostDeviceList),
- virSCSIVHostDeviceListDispose)))
+ if (!(virSCSIVHostDeviceListClass = VIR_CLASS_NEW(virClassForObjectLockable(),
+ virSCSIVHostDeviceList)))
return -1;
return 0;
diff --git a/src/util/virusb.c b/src/util/virusb.c
index be7be5dc18..67a679afda 100644
--- a/src/util/virusb.c
+++ b/src/util/virusb.c
@@ -80,10 +80,8 @@ static void virUSBDeviceListDispose(void *obj);
static int virUSBOnceInit(void)
{
- if (!(virUSBDeviceListClass = virClassNew(virClassForObjectLockable(),
- "virUSBDeviceList",
- sizeof(virUSBDeviceList),
- virUSBDeviceListDispose)))
+ if (!(virUSBDeviceListClass = VIR_CLASS_NEW(virClassForObjectLockable(),
+ virUSBDeviceList)))
return -1;
return 0;
diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c
index 920af4c010..2adfe0660d 100644
--- a/src/vbox/vbox_common.c
+++ b/src/vbox/vbox_common.c
@@ -118,10 +118,8 @@ vboxDriverDispose(void *obj)
static int
vboxDriverOnceInit(void)
{
- if (!(vboxDriverClass = virClassNew(virClassForObjectLockable(),
- "vboxDriver",
- sizeof(vboxDriver),
- vboxDriverDispose)))
+ if (!(vboxDriverClass = VIR_CLASS_NEW(virClassForObjectLockable(),
+ vboxDriver)))
return -1;
return 0;
diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c
index e51d968f28..11120e6ff9 100644
--- a/src/vz/vz_driver.c
+++ b/src/vz/vz_driver.c
@@ -161,10 +161,8 @@ static void vzDriverDispose(void * obj)
static int vzDriverOnceInit(void)
{
- if (!(vzDriverClass = virClassNew(virClassForObjectLockable(),
- "vzDriver",
- sizeof(vzDriver),
- vzDriverDispose)))
+ if (!(vzDriverClass = VIR_CLASS_NEW(virClassForObjectLockable(),
+ vzDriver)))
return -1;
return 0;
diff --git a/tests/virfilecachetest.c b/tests/virfilecachetest.c
index d4a9d598ef..13724011b7 100644
--- a/tests/virfilecachetest.c
+++ b/tests/virfilecachetest.c
@@ -49,10 +49,8 @@ testFileCacheObjDispose(void *opaque)
static int
testFileCacheObjOnceInit(void)
{
- if (!(testFileCacheObjClass = virClassNew(virClassForObject(),
- "testFileCacheObj",
- sizeof(testFileCacheObj),
- testFileCacheObjDispose)))
+ if (!(testFileCacheObjClass = VIR_CLASS_NEW(virClassForObject(),
+ testFileCacheObj)))
return -1;
return 0;
--
2.16.1