Manager was a good name for the original design. However, the design
will be changed that for now libvirt-dbus will be using only local
connection and will support multiple drivers.
Signed-off-by: Pavel Hrdina <phrdina(a)redhat.com>
---
src/Makefile.am | 2 +-
src/{manager.c => connect.c} | 93 ++++++++++++++++---------------
src/{manager.h => connect.h} | 10 ++--
src/domain.c | 80 +++++++++++++-------------
src/domain.h | 4 +-
src/events.c | 54 +++++++++---------
src/events.h | 4 +-
src/main.c | 8 +--
test/Makefile.am | 2 +-
test/libvirttest.py | 4 +-
test/{test_manager.py => test_connect.py} | 12 ++--
test/test_domain.py | 6 +-
12 files changed, 140 insertions(+), 139 deletions(-)
rename src/{manager.c => connect.c} (64%)
rename src/{manager.h => connect.h} (53%)
rename test/{test_manager.py => test_connect.py} (79%)
diff --git a/src/Makefile.am b/src/Makefile.am
index 5d4cb04..1a5b50b 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -3,7 +3,7 @@ AM_CPPFLAGS = \
DAEMON_SOURCES = \
main.c \
- manager.c manager.h \
+ connect.c connect.h \
util.c util.h \
domain.c domain.h \
events.c events.h
diff --git a/src/manager.c b/src/connect.c
similarity index 64%
rename from src/manager.c
rename to src/connect.c
index f289a7a..cb19c39 100644
--- a/src/manager.c
+++ b/src/connect.c
@@ -1,24 +1,24 @@
#include "domain.h"
#include "events.h"
-#include "manager.h"
+#include "connect.h"
#include "util.h"
#include <errno.h>
#include <stdlib.h>
static int
-virtDBusManagerEnumarateDomains(sd_bus *bus VIR_ATTR_UNUSED,
+virtDBusConnectEnumarateDomains(sd_bus *bus VIR_ATTR_UNUSED,
const char *path VIR_ATTR_UNUSED,
void *userdata,
char ***nodes,
sd_bus_error *error)
{
- virtDBusManager *manager = userdata;
+ virtDBusConnect *connect = userdata;
_cleanup_(virtDBusUtilVirDomainListFreep) virDomainPtr *domains = NULL;
_cleanup_(virtDBusUtilStrvFreep) char **paths = NULL;
int n_domains;
- n_domains = virConnectListAllDomains(manager->connection, &domains, 0);
+ n_domains = virConnectListAllDomains(connect->connection, &domains, 0);
if (n_domains < 0)
return virtDBusUtilSetLastVirtError(error);
@@ -34,11 +34,11 @@ virtDBusManagerEnumarateDomains(sd_bus *bus VIR_ATTR_UNUSED,
}
static int
-virtDBusManagerListDomains(sd_bus_message *message,
+virtDBusConnectListDomains(sd_bus_message *message,
void *userdata,
sd_bus_error *error)
{
- virtDBusManager *manager = userdata;
+ virtDBusConnect *connect = userdata;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
_cleanup_(virtDBusUtilVirDomainListFreep) virDomainPtr *domains = NULL;
uint32_t flags;
@@ -48,7 +48,7 @@ virtDBusManagerListDomains(sd_bus_message *message,
if (r < 0)
return r;
- r = virConnectListAllDomains(manager->connection, &domains, flags);
+ r = virConnectListAllDomains(connect->connection, &domains, flags);
if (r < 0)
return virtDBusUtilSetLastVirtError(error);
@@ -78,11 +78,11 @@ virtDBusManagerListDomains(sd_bus_message *message,
}
static int
-virtDBusManagerCreateXML(sd_bus_message *message,
+virtDBusConnectCreateXML(sd_bus_message *message,
void *userdata,
sd_bus_error *error)
{
- virtDBusManager *manager = userdata;
+ virtDBusConnect *connect = userdata;
const char *xml;
uint32_t flags;
_cleanup_(virtDBusUtilVirDomainFreep) virDomainPtr domain = NULL;
@@ -93,7 +93,7 @@ virtDBusManagerCreateXML(sd_bus_message *message,
if (r < 0)
return r;
- domain = virDomainCreateXML(manager->connection, xml, flags);
+ domain = virDomainCreateXML(connect->connection, xml, flags);
if (!domain)
return virtDBusUtilSetLastVirtError(error);
@@ -103,11 +103,11 @@ virtDBusManagerCreateXML(sd_bus_message *message,
}
static int
-virtDBusManagerDefineXML(sd_bus_message *message,
+virtDBusConnectDefineXML(sd_bus_message *message,
void *userdata,
sd_bus_error *error)
{
- virtDBusManager *manager = userdata;
+ virtDBusConnect *connect = userdata;
const char *xml;
_cleanup_(virtDBusUtilVirDomainFreep) virDomainPtr domain = NULL;
_cleanup_(virtDBusUtilFreep) char *path = NULL;
@@ -117,7 +117,7 @@ virtDBusManagerDefineXML(sd_bus_message *message,
if (r < 0)
return r;
- domain = virDomainDefineXML(manager->connection, xml);
+ domain = virDomainDefineXML(connect->connection, xml);
if (!domain)
return virtDBusUtilSetLastVirtError(error);
@@ -126,12 +126,12 @@ virtDBusManagerDefineXML(sd_bus_message *message,
return sd_bus_reply_method_return(message, "o", path);
}
-static const sd_bus_vtable virt_manager_vtable[] = {
+static const sd_bus_vtable virt_connect_vtable[] = {
SD_BUS_VTABLE_START(0),
- SD_BUS_METHOD("ListDomains", "u", "ao",
virtDBusManagerListDomains, SD_BUS_VTABLE_UNPRIVILEGED),
- SD_BUS_METHOD("CreateXML", "su", "o",
virtDBusManagerCreateXML, SD_BUS_VTABLE_UNPRIVILEGED),
- SD_BUS_METHOD("DefineXML", "s", "o",
virtDBusManagerDefineXML, SD_BUS_VTABLE_UNPRIVILEGED),
+ SD_BUS_METHOD("ListDomains", "u", "ao",
virtDBusConnectListDomains, SD_BUS_VTABLE_UNPRIVILEGED),
+ SD_BUS_METHOD("CreateXML", "su", "o",
virtDBusConnectCreateXML, SD_BUS_VTABLE_UNPRIVILEGED),
+ SD_BUS_METHOD("DefineXML", "s", "o",
virtDBusConnectDefineXML, SD_BUS_VTABLE_UNPRIVILEGED),
SD_BUS_SIGNAL("DomainDefined", "so", 0),
SD_BUS_SIGNAL("DomainUndefined", "so", 0),
@@ -147,70 +147,71 @@ static const sd_bus_vtable virt_manager_vtable[] = {
};
int
-virtDBusManagerNew(virtDBusManager **managerp,
+virtDBusConnectNew(virtDBusConnect **connectp,
sd_bus *bus,
const char *uri)
{
- _cleanup_(virtDBusManagerFreep) virtDBusManager *manager = NULL;
+ _cleanup_(virtDBusConnectFreep) virtDBusConnect *connect = NULL;
int r;
- manager = calloc(1, sizeof(virtDBusManager));
+ connect = calloc(1, sizeof(virtDBusConnect));
for (int i = 0; i < VIR_DOMAIN_EVENT_ID_LAST; i += 1)
- manager->callback_ids[i] = -1;
+ connect->callback_ids[i] = -1;
- manager->bus = sd_bus_ref(bus);
+ connect->bus = sd_bus_ref(bus);
- manager->connection = virConnectOpenAuth(uri, virConnectAuthPtrDefault, 0);
- if (!manager->connection)
+ connect->connection = virConnectOpenAuth(uri, virConnectAuthPtrDefault, 0);
+ if (!connect->connection)
return -EINVAL;
- virtDBusEventsRegister(manager);
+ virtDBusEventsRegister(connect);
- r = sd_bus_add_object_vtable(manager->bus,
+ r = sd_bus_add_object_vtable(connect->bus,
NULL,
- "/org/libvirt/Manager",
- "org.libvirt.Manager",
- virt_manager_vtable,
- manager);
+ "/org/libvirt/Connect",
+ "org.libvirt.Connect",
+ virt_connect_vtable,
+ connect);
if (r < 0)
return r;
- r = sd_bus_add_node_enumerator(bus, NULL, "/org/libvirt/domain",
virtDBusManagerEnumarateDomains, manager);
+ r = sd_bus_add_node_enumerator(bus, NULL, "/org/libvirt/domain",
+ virtDBusConnectEnumarateDomains, connect);
if (r < 0)
return r;
- if ((r = virtDBusDomainRegister(manager, bus) < 0))
+ if ((r = virtDBusDomainRegister(connect, bus) < 0))
return r;
- *managerp = manager;
- manager = NULL;
+ *connectp = connect;
+ connect = NULL;
return 0;
}
-virtDBusManager *
-virtDBusManagerFree(virtDBusManager *manager)
+virtDBusConnect *
+virtDBusConnectFree(virtDBusConnect *connect)
{
- if (manager->bus)
- sd_bus_unref(manager->bus);
+ if (connect->bus)
+ sd_bus_unref(connect->bus);
- if (manager->connection) {
+ if (connect->connection) {
for (int i = 0; i < VIR_DOMAIN_EVENT_ID_LAST; i += 1) {
- if (manager->callback_ids[i] >= 0)
- virConnectDomainEventDeregisterAny(manager->connection,
manager->callback_ids[i]);
+ if (connect->callback_ids[i] >= 0)
+ virConnectDomainEventDeregisterAny(connect->connection,
connect->callback_ids[i]);
}
- virConnectClose(manager->connection);
+ virConnectClose(connect->connection);
}
- free(manager);
+ free(connect);
return NULL;
}
void
-virtDBusManagerFreep(virtDBusManager **managerp)
+virtDBusConnectFreep(virtDBusConnect **connectp)
{
- if (*managerp)
- virtDBusManagerFree(*managerp);
+ if (*connectp)
+ virtDBusConnectFree(*connectp);
}
diff --git a/src/manager.h b/src/connect.h
similarity index 53%
rename from src/manager.h
rename to src/connect.h
index a1fefa6..5d64a10 100644
--- a/src/manager.h
+++ b/src/connect.h
@@ -5,16 +5,16 @@
#include <libvirt/libvirt.h>
#include <systemd/sd-bus.h>
-struct virtDBusManager {
+struct virtDBusConnect {
sd_bus *bus;
virConnectPtr connection;
int callback_ids[VIR_DOMAIN_EVENT_ID_LAST];
};
-typedef struct virtDBusManager virtDBusManager;
+typedef struct virtDBusConnect virtDBusConnect;
-int virtDBusManagerNew(virtDBusManager **managerp,
+int virtDBusConnectNew(virtDBusConnect **connectp,
sd_bus *bus,
const char *uri);
-virtDBusManager *virtDBusManagerFree(virtDBusManager *manager);
-void virtDBusManagerFreep(virtDBusManager **managerp);
+virtDBusConnect *virtDBusConnectFree(virtDBusConnect *connect);
+void virtDBusConnectFreep(virtDBusConnect **connectp);
diff --git a/src/domain.c b/src/domain.c
index 5527778..a3e1d0b 100644
--- a/src/domain.c
+++ b/src/domain.c
@@ -10,11 +10,11 @@ virtDBusDomainGetName(sd_bus *bus VIR_ATTR_UNUSED,
void *userdata,
sd_bus_error *error VIR_ATTR_UNUSED)
{
- virtDBusManager *manager = userdata;
+ virtDBusConnect *connect = userdata;
_cleanup_(virtDBusUtilVirDomainFreep) virDomainPtr domain = NULL;
const char *name = "";
- domain = virtDBusUtilVirDomainFromBusPath(manager->connection, path);
+ domain = virtDBusUtilVirDomainFromBusPath(connect->connection, path);
if (domain == NULL)
return sd_bus_message_append(reply, "s", "");
@@ -34,11 +34,11 @@ virtDBusDomainGetUUID(sd_bus *bus VIR_ATTR_UNUSED,
void *userdata,
sd_bus_error *error VIR_ATTR_UNUSED)
{
- virtDBusManager *manager = userdata;
+ virtDBusConnect *connect = userdata;
_cleanup_(virtDBusUtilVirDomainFreep) virDomainPtr domain = NULL;
char uuid[VIR_UUID_STRING_BUFLEN] = "";
- domain = virtDBusUtilVirDomainFromBusPath(manager->connection, path);
+ domain = virtDBusUtilVirDomainFromBusPath(connect->connection, path);
if (domain == NULL)
return sd_bus_message_append(reply, "s", "");
@@ -56,10 +56,10 @@ virtDBusDomainGetId(sd_bus *bus VIR_ATTR_UNUSED,
void *userdata,
sd_bus_error *error VIR_ATTR_UNUSED)
{
- virtDBusManager *manager = userdata;
+ virtDBusConnect *connect = userdata;
_cleanup_(virtDBusUtilVirDomainFreep) virDomainPtr domain = NULL;
- domain = virtDBusUtilVirDomainFromBusPath(manager->connection, path);
+ domain = virtDBusUtilVirDomainFromBusPath(connect->connection, path);
if (domain == NULL)
return sd_bus_message_append(reply, "u", 0);
@@ -75,10 +75,10 @@ virtDBusDomainGetVcpus(sd_bus *bus VIR_ATTR_UNUSED,
void *userdata,
sd_bus_error *error VIR_ATTR_UNUSED)
{
- virtDBusManager *manager = userdata;
+ virtDBusConnect *connect = userdata;
_cleanup_(virtDBusUtilVirDomainFreep) virDomainPtr domain = NULL;
- domain = virtDBusUtilVirDomainFromBusPath(manager->connection, path);
+ domain = virtDBusUtilVirDomainFromBusPath(connect->connection, path);
if (domain == NULL)
return sd_bus_message_append(reply, "u", 0);
@@ -94,11 +94,11 @@ virtDBusDomainGetOsType(sd_bus *bus VIR_ATTR_UNUSED,
void *userdata,
sd_bus_error *error VIR_ATTR_UNUSED)
{
- virtDBusManager *manager = userdata;
+ virtDBusConnect *connect = userdata;
_cleanup_(virtDBusUtilVirDomainFreep) virDomainPtr domain = NULL;
_cleanup_(virtDBusUtilFreep) char *os_type = NULL;
- domain = virtDBusUtilVirDomainFromBusPath(manager->connection, path);
+ domain = virtDBusUtilVirDomainFromBusPath(connect->connection, path);
if (domain == NULL)
return sd_bus_message_append(reply, "s", "");
@@ -118,11 +118,11 @@ virtDBusDomainGetActive(sd_bus *bus VIR_ATTR_UNUSED,
void *userdata,
sd_bus_error *error VIR_ATTR_UNUSED)
{
- virtDBusManager *manager = userdata;
+ virtDBusConnect *connect = userdata;
_cleanup_(virtDBusUtilVirDomainFreep) virDomainPtr domain = NULL;
int active;
- domain = virtDBusUtilVirDomainFromBusPath(manager->connection, path);
+ domain = virtDBusUtilVirDomainFromBusPath(connect->connection, path);
if (domain == NULL)
return sd_bus_message_append(reply, "b", 0);
@@ -142,11 +142,11 @@ virtDBusDomainGetPersistent(sd_bus *bus VIR_ATTR_UNUSED,
void *userdata,
sd_bus_error *error VIR_ATTR_UNUSED)
{
- virtDBusManager *manager = userdata;
+ virtDBusConnect *connect = userdata;
_cleanup_(virtDBusUtilVirDomainFreep) virDomainPtr domain = NULL;
int persistent;
- domain = virtDBusUtilVirDomainFromBusPath(manager->connection, path);
+ domain = virtDBusUtilVirDomainFromBusPath(connect->connection, path);
if (domain == NULL)
return sd_bus_message_append(reply, "b", 0);
@@ -166,12 +166,12 @@ virtDBusDomainGetState(sd_bus *bus VIR_ATTR_UNUSED,
void *userdata,
sd_bus_error *error VIR_ATTR_UNUSED)
{
- virtDBusManager *manager = userdata;
+ virtDBusConnect *connect = userdata;
_cleanup_(virtDBusUtilVirDomainFreep) virDomainPtr domain = NULL;
int state = 0;
const char *string;
- domain = virtDBusUtilVirDomainFromBusPath(manager->connection, path);
+ domain = virtDBusUtilVirDomainFromBusPath(connect->connection, path);
if (domain == NULL)
return sd_bus_message_append(reply, "s", "");
@@ -217,11 +217,11 @@ virtDBusDomainGetAutostart(sd_bus *bus VIR_ATTR_UNUSED,
void *userdata,
sd_bus_error *error VIR_ATTR_UNUSED)
{
- virtDBusManager *manager = userdata;
+ virtDBusConnect *connect = userdata;
_cleanup_(virtDBusUtilVirDomainFreep) virDomainPtr domain = NULL;
int autostart = 0;
- domain = virtDBusUtilVirDomainFromBusPath(manager->connection, path);
+ domain = virtDBusUtilVirDomainFromBusPath(connect->connection, path);
if (domain == NULL)
return sd_bus_message_append(reply, "b", 0);
@@ -235,13 +235,13 @@ virtDBusDomainGetXMLDesc(sd_bus_message *message,
void *userdata,
sd_bus_error *error)
{
- virtDBusManager *manager = userdata;
+ virtDBusConnect *connect = userdata;
_cleanup_(virtDBusUtilVirDomainFreep) virDomainPtr domain = NULL;
_cleanup_(virtDBusUtilFreep) char *description = NULL;
uint32_t flags;
int r;
- domain = virtDBusUtilVirDomainFromBusPath(manager->connection,
+ domain = virtDBusUtilVirDomainFromBusPath(connect->connection,
sd_bus_message_get_path(message));
if (domain == NULL) {
return sd_bus_reply_method_errorf(message,
@@ -273,7 +273,7 @@ virtDBusDomainGetStats(sd_bus_message *message,
void *userdata,
sd_bus_error *error)
{
- virtDBusManager *manager = userdata;
+ virtDBusConnect *connect = userdata;
_cleanup_(virtDBusUtilVirDomainFreep) virDomainPtr domain = NULL;
virDomainPtr domains[2];
_cleanup_(virtDBusDomainStatsRecordListFreep) virDomainStatsRecordPtr *records =
NULL;
@@ -285,7 +285,7 @@ virtDBusDomainGetStats(sd_bus_message *message,
if (r < 0)
return r;
- domain = virtDBusUtilVirDomainFromBusPath(manager->connection,
+ domain = virtDBusUtilVirDomainFromBusPath(connect->connection,
sd_bus_message_get_path(message));
if (domain == NULL) {
return sd_bus_reply_method_errorf(message,
@@ -316,11 +316,11 @@ virtDBusDomainShutdown(sd_bus_message *message,
void *userdata,
sd_bus_error *error)
{
- virtDBusManager *manager = userdata;
+ virtDBusConnect *connect = userdata;
_cleanup_(virtDBusUtilVirDomainFreep) virDomainPtr domain = NULL;
int r;
- domain = virtDBusUtilVirDomainFromBusPath(manager->connection,
+ domain = virtDBusUtilVirDomainFromBusPath(connect->connection,
sd_bus_message_get_path(message));
if (domain == NULL) {
return sd_bus_reply_method_errorf(message,
@@ -341,11 +341,11 @@ virtDBusDomainDestroy(sd_bus_message *message,
void *userdata,
sd_bus_error *error)
{
- virtDBusManager *manager = userdata;
+ virtDBusConnect *connect = userdata;
_cleanup_(virtDBusUtilVirDomainFreep) virDomainPtr domain = NULL;
int r;
- domain = virtDBusUtilVirDomainFromBusPath(manager->connection,
+ domain = virtDBusUtilVirDomainFromBusPath(connect->connection,
sd_bus_message_get_path(message));
if (domain == NULL) {
return sd_bus_reply_method_errorf(message,
@@ -366,7 +366,7 @@ virtDBusDomainReboot(sd_bus_message *message,
void *userdata,
sd_bus_error *error)
{
- virtDBusManager *manager = userdata;
+ virtDBusConnect *connect = userdata;
_cleanup_(virtDBusUtilVirDomainFreep) virDomainPtr domain = NULL;
uint32_t flags;
int r;
@@ -375,7 +375,7 @@ virtDBusDomainReboot(sd_bus_message *message,
if (r < 0)
return r;
- domain = virtDBusUtilVirDomainFromBusPath(manager->connection,
+ domain = virtDBusUtilVirDomainFromBusPath(connect->connection,
sd_bus_message_get_path(message));
if (domain == NULL) {
return sd_bus_reply_method_errorf(message,
@@ -396,7 +396,7 @@ virtDBusDomainReset(sd_bus_message *message,
void *userdata,
sd_bus_error *error)
{
- virtDBusManager *manager = userdata;
+ virtDBusConnect *connect = userdata;
_cleanup_(virtDBusUtilVirDomainFreep) virDomainPtr domain = NULL;
uint32_t flags;
int r;
@@ -405,7 +405,7 @@ virtDBusDomainReset(sd_bus_message *message,
if (r < 0)
return r;
- domain = virtDBusUtilVirDomainFromBusPath(manager->connection,
+ domain = virtDBusUtilVirDomainFromBusPath(connect->connection,
sd_bus_message_get_path(message));
if (domain == NULL) {
return sd_bus_reply_method_errorf(message,
@@ -426,11 +426,11 @@ virtDBusDomainCreate(sd_bus_message *message,
void *userdata,
sd_bus_error *error)
{
- virtDBusManager *manager = userdata;
+ virtDBusConnect *connect = userdata;
_cleanup_(virtDBusUtilVirDomainFreep) virDomainPtr domain = NULL;
int r;
- domain = virtDBusUtilVirDomainFromBusPath(manager->connection,
+ domain = virtDBusUtilVirDomainFromBusPath(connect->connection,
sd_bus_message_get_path(message));
if (domain == NULL) {
return sd_bus_reply_method_errorf(message,
@@ -451,11 +451,11 @@ virtDBusDomainUndefine(sd_bus_message *message,
void *userdata,
sd_bus_error *error)
{
- virtDBusManager *manager = userdata;
+ virtDBusConnect *connect = userdata;
_cleanup_(virtDBusUtilVirDomainFreep) virDomainPtr domain = NULL;
int r;
- domain = virtDBusUtilVirDomainFromBusPath(manager->connection,
+ domain = virtDBusUtilVirDomainFromBusPath(connect->connection,
sd_bus_message_get_path(message));
if (domain == NULL) {
return sd_bus_reply_method_errorf(message,
@@ -509,7 +509,7 @@ virtDBusDomainLookup(sd_bus *bus VIR_ATTR_UNUSED,
void **found,
sd_bus_error *error VIR_ATTR_UNUSED)
{
- virtDBusManager *manager = userdata;
+ virtDBusConnect *connect = userdata;
_cleanup_(virtDBusUtilFreep) char *name = NULL;
_cleanup_(virtDBusUtilVirDomainFreep) virDomainPtr domain = NULL;
int r;
@@ -521,22 +521,22 @@ virtDBusDomainLookup(sd_bus *bus VIR_ATTR_UNUSED,
if (*name == '\0')
return 0;
- domain = virDomainLookupByUUIDString(manager->connection, name);
+ domain = virDomainLookupByUUIDString(connect->connection, name);
if (!domain)
return 0;
/*
* There's no way to unref the pointer we're returning here. So,
- * return the manager object and look up the domain again in the
+ * return the connect object and look up the domain again in the
* domain_* callbacks.
*/
- *found = manager;
+ *found = connect;
return 1;
}
int
-virtDBusDomainRegister(virtDBusManager *manager,
+virtDBusDomainRegister(virtDBusConnect *connect,
sd_bus *bus)
{
return sd_bus_add_fallback_vtable(bus,
@@ -545,5 +545,5 @@ virtDBusDomainRegister(virtDBusManager *manager,
"org.libvirt.Domain",
virt_domain_vtable,
virtDBusDomainLookup,
- manager);
+ connect);
}
diff --git a/src/domain.h b/src/domain.h
index 165e452..adadc6a 100644
--- a/src/domain.h
+++ b/src/domain.h
@@ -1,10 +1,10 @@
#pragma once
-#include "manager.h"
+#include "connect.h"
#include <libvirt/libvirt.h>
#include <systemd/sd-bus.h>
int
-virtDBusDomainRegister(virtDBusManager *manager,
+virtDBusDomainRegister(virtDBusConnect *connect,
sd_bus *bus);
diff --git a/src/events.c b/src/events.c
index 731ef02..92f280d 100644
--- a/src/events.c
+++ b/src/events.c
@@ -12,7 +12,7 @@ virtDBusEventsDomainLifecycle(virConnectPtr connection VIR_ATTR_UNUSED,
int detail VIR_ATTR_UNUSED,
void *opaque)
{
- virtDBusManager *manager = opaque;
+ virtDBusConnect *connect = opaque;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *message = NULL;
const char *signal = NULL;
const char *name;
@@ -51,10 +51,10 @@ virtDBusEventsDomainLifecycle(virConnectPtr connection
VIR_ATTR_UNUSED,
return 0;
}
- r = sd_bus_message_new_signal(manager->bus,
+ r = sd_bus_message_new_signal(connect->bus,
&message,
- "/org/libvirt/Manager",
- "org.libvirt.Manager",
+ "/org/libvirt/Connect",
+ "org.libvirt.connect",
signal);
if (r < 0)
return r;
@@ -66,7 +66,7 @@ virtDBusEventsDomainLifecycle(virConnectPtr connection VIR_ATTR_UNUSED,
if (r < 0)
return r;
- return sd_bus_send(manager->bus, message, NULL);
+ return sd_bus_send(connect->bus, message, NULL);
}
static int
@@ -75,14 +75,14 @@ virtDBusEventsDomainDeviceAdded(virConnectPtr connection
VIR_ATTR_UNUSED,
const char *device,
void *opaque)
{
- virtDBusManager *manager = opaque;
+ virtDBusConnect *connect = opaque;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *message = NULL;
_cleanup_(virtDBusUtilFreep) char *path = NULL;
int r;
path = virtDBusUtilBusPathForVirDomain(domain);
- r = sd_bus_message_new_signal(manager->bus,
+ r = sd_bus_message_new_signal(connect->bus,
&message,
path,
"org.libvirt.Domain",
@@ -94,7 +94,7 @@ virtDBusEventsDomainDeviceAdded(virConnectPtr connection
VIR_ATTR_UNUSED,
if (r < 0)
return r;
- return sd_bus_send(manager->bus, message, NULL);
+ return sd_bus_send(connect->bus, message, NULL);
}
static int
@@ -103,14 +103,14 @@ virtDBusEventsDomainDeviceRemoved(virConnectPtr connection
VIR_ATTR_UNUSED,
const char *device,
void *opaque)
{
- virtDBusManager *manager = opaque;
+ virtDBusConnect *connect = opaque;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *message = NULL;
_cleanup_(virtDBusUtilFreep) char *path = NULL;
int r;
path = virtDBusUtilBusPathForVirDomain(domain);
- r = sd_bus_message_new_signal(manager->bus,
+ r = sd_bus_message_new_signal(connect->bus,
&message,
path,
"org.libvirt.Domain",
@@ -122,7 +122,7 @@ virtDBusEventsDomainDeviceRemoved(virConnectPtr connection
VIR_ATTR_UNUSED,
if (r < 0)
return r;
- return sd_bus_send(manager->bus, message, NULL);
+ return sd_bus_send(connect->bus, message, NULL);
}
static int
@@ -132,7 +132,7 @@ virtDBusEventsDomainDiskChange(virConnectPtr connection
VIR_ATTR_UNUSED,
int reason,
void *opaque)
{
- virtDBusManager *manager = opaque;
+ virtDBusConnect *connect = opaque;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *message = NULL;
_cleanup_(virtDBusUtilFreep) char *path = NULL;
const char *reasonstr;
@@ -140,7 +140,7 @@ virtDBusEventsDomainDiskChange(virConnectPtr connection
VIR_ATTR_UNUSED,
path = virtDBusUtilBusPathForVirDomain(domain);
- r = sd_bus_message_new_signal(manager->bus,
+ r = sd_bus_message_new_signal(connect->bus,
&message,
path,
"org.libvirt.Domain",
@@ -164,7 +164,7 @@ virtDBusEventsDomainDiskChange(virConnectPtr connection
VIR_ATTR_UNUSED,
if (r < 0)
return r;
- return sd_bus_send(manager->bus, message, NULL);
+ return sd_bus_send(connect->bus, message, NULL);
}
static int
@@ -176,7 +176,7 @@ virtDBusEventsDomainTrayChange(virConnectPtr connection
VIR_ATTR_UNUSED,
int reason,
void *opaque)
{
- virtDBusManager *manager = opaque;
+ virtDBusConnect *connect = opaque;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *message = NULL;
_cleanup_(virtDBusUtilFreep) char *path = NULL;
const char *reasonstr;
@@ -184,7 +184,7 @@ virtDBusEventsDomainTrayChange(virConnectPtr connection
VIR_ATTR_UNUSED,
path = virtDBusUtilBusPathForVirDomain(domain);
- r = sd_bus_message_new_signal(manager->bus,
+ r = sd_bus_message_new_signal(connect->bus,
&message,
path,
"org.libvirt.Domain",
@@ -208,44 +208,44 @@ virtDBusEventsDomainTrayChange(virConnectPtr connection
VIR_ATTR_UNUSED,
if (r < 0)
return r;
- return sd_bus_send(manager->bus, message, NULL);
+ return sd_bus_send(connect->bus, message, NULL);
}
static void
-virtDBusEventsRegisterEvent(virtDBusManager *manager,
+virtDBusEventsRegisterEvent(virtDBusConnect *connect,
int id,
virConnectDomainEventGenericCallback callback)
{
- assert(manager->callback_ids[id] == -1);
+ assert(connect->callback_ids[id] == -1);
- manager->callback_ids[id] =
virConnectDomainEventRegisterAny(manager->connection,
+ connect->callback_ids[id] =
virConnectDomainEventRegisterAny(connect->connection,
NULL,
id,
VIR_DOMAIN_EVENT_CALLBACK(callback),
- manager,
+ connect,
NULL);
}
void
-virtDBusEventsRegister(virtDBusManager *manager)
+virtDBusEventsRegister(virtDBusConnect *connect)
{
- virtDBusEventsRegisterEvent(manager,
+ virtDBusEventsRegisterEvent(connect,
VIR_DOMAIN_EVENT_ID_LIFECYCLE,
VIR_DOMAIN_EVENT_CALLBACK(virtDBusEventsDomainLifecycle));
- virtDBusEventsRegisterEvent(manager,
+ virtDBusEventsRegisterEvent(connect,
VIR_DOMAIN_EVENT_ID_DEVICE_ADDED,
VIR_DOMAIN_EVENT_CALLBACK(virtDBusEventsDomainDeviceAdded));
- virtDBusEventsRegisterEvent(manager,
+ virtDBusEventsRegisterEvent(connect,
VIR_DOMAIN_EVENT_ID_DEVICE_REMOVED,
VIR_DOMAIN_EVENT_CALLBACK(virtDBusEventsDomainDeviceRemoved));
- virtDBusEventsRegisterEvent(manager,
+ virtDBusEventsRegisterEvent(connect,
VIR_DOMAIN_EVENT_ID_DISK_CHANGE,
VIR_DOMAIN_EVENT_CALLBACK(virtDBusEventsDomainTrayChange));
- virtDBusEventsRegisterEvent(manager,
+ virtDBusEventsRegisterEvent(connect,
VIR_DOMAIN_EVENT_ID_TRAY_CHANGE,
VIR_DOMAIN_EVENT_CALLBACK(virtDBusEventsDomainDiskChange));
diff --git a/src/events.h b/src/events.h
index d64bd94..f588c85 100644
--- a/src/events.h
+++ b/src/events.h
@@ -1,9 +1,9 @@
#pragma once
-#include "manager.h"
+#include "connect.h"
#include <libvirt/libvirt.h>
void
-virtDBusEventsRegister(virtDBusManager *manager);
+virtDBusEventsRegister(virtDBusConnect *connect);
diff --git a/src/main.c b/src/main.c
index 225fb46..95522f5 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1,6 +1,6 @@
#include "config.h"
-#include "manager.h"
+#include "connect.h"
#include "util.h"
#include <errno.h>
@@ -98,7 +98,7 @@ main(int argc, char *argv[])
bool system_bus;
const char *uri = NULL;
- _cleanup_(virtDBusManagerFreep) virtDBusManager *manager = NULL;
+ _cleanup_(virtDBusConnectFreep) virtDBusConnect *connect = NULL;
_cleanup_(sd_bus_unrefp) sd_bus *bus = NULL;
_cleanup_(virtDBusUtilClosep) int signal_fd = -1;
_cleanup_(virtDBusVirEventRemoveHandlep) int bus_watch = -1;
@@ -170,9 +170,9 @@ main(int argc, char *argv[])
return EXIT_FAILURE;
}
- r = virtDBusManagerNew(&manager, bus, uri);
+ r = virtDBusConnectNew(&connect, bus, uri);
if (r < 0) {
- fprintf(stderr, "Failed to connect to libvirt");
+ fprintf(stderr, "Failed to connect to libvirt.");
return EXIT_FAILURE;
}
diff --git a/test/Makefile.am b/test/Makefile.am
index a7f22d0..4651d08 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -2,7 +2,7 @@ test_helpers = \
libvirttest.py
test_programs = \
- test_manager.py \
+ test_connect.py \
test_domain.py
TESTS = $(test_programs)
diff --git a/test/libvirttest.py b/test/libvirttest.py
index f5c2020..2c735e9 100644
--- a/test/libvirttest.py
+++ b/test/libvirttest.py
@@ -38,8 +38,8 @@ class TestCase(unittest.TestCase):
else:
raise TimeoutError('error starting libvirt-dbus')
- obj = self.bus.get_object('org.libvirt', '/org/libvirt/Manager')
- self.manager = dbus.Interface(obj, 'org.libvirt.Manager')
+ obj = self.bus.get_object('org.libvirt', '/org/libvirt/Connect')
+ self.connect = dbus.Interface(obj, 'org.libvirt.Connect')
def tearDown(self):
self.daemon.terminate()
diff --git a/test/test_manager.py b/test/test_connect.py
similarity index 79%
rename from test/test_manager.py
rename to test/test_connect.py
index 1f58b9d..4ec3fe0 100755
--- a/test/test_manager.py
+++ b/test/test_connect.py
@@ -14,9 +14,9 @@ minimal_xml = '''
</domain>
'''
-class TestManager(libvirttest.TestCase):
+class TestConnect(libvirttest.TestCase):
def test_list_domains(self):
- domains = self.manager.ListDomains(0)
+ domains = self.connect.ListDomains(0)
self.assertEqual(type(domains), dbus.Array)
self.assertEqual(len(domains), 1)
@@ -33,9 +33,9 @@ class TestManager(libvirttest.TestCase):
self.assertEqual(type(path), dbus.ObjectPath)
self.loop.quit()
- self.manager.connect_to_signal('DomainStarted', domain_started)
+ self.connect.connect_to_signal('DomainStarted', domain_started)
- path = self.manager.CreateXML(minimal_xml, 0)
+ path = self.connect.CreateXML(minimal_xml, 0)
self.assertEqual(type(path), dbus.ObjectPath)
self.main_loop()
@@ -46,9 +46,9 @@ class TestManager(libvirttest.TestCase):
self.assertEqual(type(path), dbus.ObjectPath)
self.loop.quit()
- self.manager.connect_to_signal('DomainDefined', domain_defined)
+ self.connect.connect_to_signal('DomainDefined', domain_defined)
- path = self.manager.DefineXML(minimal_xml)
+ path = self.connect.DefineXML(minimal_xml)
self.assertEqual(type(path), dbus.ObjectPath)
self.main_loop()
diff --git a/test/test_domain.py b/test/test_domain.py
index 2b15285..b1ab7a5 100755
--- a/test/test_domain.py
+++ b/test/test_domain.py
@@ -6,7 +6,7 @@ import unittest
class TestDomain(libvirttest.TestCase):
def domain(self):
- path = self.manager.ListDomains(0)[0]
+ path = self.connect.ListDomains(0)[0]
obj = self.bus.get_object('org.libvirt', path)
return obj, dbus.Interface(obj, 'org.libvirt.Domain')
@@ -42,7 +42,7 @@ class TestDomain(libvirttest.TestCase):
self.assertEqual(type(path), dbus.ObjectPath)
self.loop.quit()
- self.manager.connect_to_signal('DomainStopped', domain_stopped)
+ self.connect.connect_to_signal('DomainStopped', domain_stopped)
obj, domain = self.domain()
domain.Shutdown()
@@ -58,7 +58,7 @@ class TestDomain(libvirttest.TestCase):
self.assertEqual(type(path), dbus.ObjectPath)
self.loop.quit()
- self.manager.connect_to_signal('DomainUndefined', domain_undefined)
+ self.connect.connect_to_signal('DomainUndefined', domain_undefined)
_, domain = self.domain()
domain.Shutdown()
--
2.14.3