Signed-off-by: Pavel Hrdina <phrd...@redhat.com> --- src/domain.c | 38 ++++++++++++++++++------------------ src/domain.h | 2 +- src/events.c | 14 +++++++------- src/events.h | 2 +- src/main.c | 4 ++-- src/manager.c | 62 +++++++++++++++++++++++++++++------------------------------ src/manager.h | 14 +++++++------- 7 files changed, 68 insertions(+), 68 deletions(-)
diff --git a/src/domain.c b/src/domain.c index 4bfb314..ab56ab1 100644 --- a/src/domain.c +++ b/src/domain.c @@ -10,7 +10,7 @@ domain_get_name(sd_bus *bus, void *userdata, sd_bus_error *error) { - VirtManager *manager = userdata; + virtDBusManager *manager = userdata; _cleanup_(virtDBusVirDomainFreep) virDomainPtr domain = NULL; const char *name = ""; @@ -34,7 +34,7 @@ domain_get_uuid(sd_bus *bus, void *userdata, sd_bus_error *error) { - VirtManager *manager = userdata; + virtDBusManager *manager = userdata; _cleanup_(virtDBusVirDomainFreep) virDomainPtr domain = NULL; char uuid[VIR_UUID_STRING_BUFLEN] = ""; @@ -56,7 +56,7 @@ domain_get_id(sd_bus *bus, void *userdata, sd_bus_error *error) { - VirtManager *manager = userdata; + virtDBusManager *manager = userdata; _cleanup_(virtDBusVirDomainFreep) virDomainPtr domain = NULL; domain = virtDBusVirDomainFromBusPath(manager->connection, path); @@ -75,7 +75,7 @@ domain_get_vcpus(sd_bus *bus, void *userdata, sd_bus_error *error) { - VirtManager *manager = userdata; + virtDBusManager *manager = userdata; _cleanup_(virtDBusVirDomainFreep) virDomainPtr domain = NULL; domain = virtDBusVirDomainFromBusPath(manager->connection, path); @@ -94,7 +94,7 @@ domain_get_os_type(sd_bus *bus, void *userdata, sd_bus_error *error) { - VirtManager *manager = userdata; + virtDBusManager *manager = userdata; _cleanup_(virtDBusVirDomainFreep) virDomainPtr domain = NULL; _cleanup_(virtDBusFreep) char *os_type = NULL; @@ -118,7 +118,7 @@ domain_get_active(sd_bus *bus, void *userdata, sd_bus_error *error) { - VirtManager *manager = userdata; + virtDBusManager *manager = userdata; _cleanup_(virtDBusVirDomainFreep) virDomainPtr domain = NULL; int active; @@ -142,7 +142,7 @@ domain_get_persistent(sd_bus *bus, void *userdata, sd_bus_error *error) { - VirtManager *manager = userdata; + virtDBusManager *manager = userdata; _cleanup_(virtDBusVirDomainFreep) virDomainPtr domain = NULL; int persistent; @@ -166,7 +166,7 @@ domain_get_state(sd_bus *bus, void *userdata, sd_bus_error *error) { - VirtManager *manager = userdata; + virtDBusManager *manager = userdata; _cleanup_(virtDBusVirDomainFreep) virDomainPtr domain = NULL; int state = 0; const char *string; @@ -217,7 +217,7 @@ domain_get_autostart(sd_bus *bus, void *userdata, sd_bus_error *error) { - VirtManager *manager = userdata; + virtDBusManager *manager = userdata; _cleanup_(virtDBusVirDomainFreep) virDomainPtr domain = NULL; int autostart = 0; @@ -235,7 +235,7 @@ domain_get_xml_desc(sd_bus_message *message, void *userdata, sd_bus_error *error) { - VirtManager *manager = userdata; + virtDBusManager *manager = userdata; _cleanup_(virtDBusVirDomainFreep) virDomainPtr domain = NULL; _cleanup_(virtDBusFreep) char *description = NULL; uint32_t flags; @@ -273,7 +273,7 @@ domain_get_stats(sd_bus_message *message, void *userdata, sd_bus_error *error) { - VirtManager *manager = userdata; + virtDBusManager *manager = userdata; _cleanup_(virtDBusVirDomainFreep) virDomainPtr domain = NULL; virDomainPtr domains[2]; _cleanup_(virDomainStatsRecordListFreep) virDomainStatsRecordPtr *records = NULL; @@ -316,7 +316,7 @@ domain_shutdown(sd_bus_message *message, void *userdata, sd_bus_error *error) { - VirtManager *manager = userdata; + virtDBusManager *manager = userdata; _cleanup_(virtDBusVirDomainFreep) virDomainPtr domain = NULL; int r; @@ -341,7 +341,7 @@ domain_destroy(sd_bus_message *message, void *userdata, sd_bus_error *error) { - VirtManager *manager = userdata; + virtDBusManager *manager = userdata; _cleanup_(virtDBusVirDomainFreep) virDomainPtr domain = NULL; int r; @@ -366,7 +366,7 @@ domain_reboot(sd_bus_message *message, void *userdata, sd_bus_error *error) { - VirtManager *manager = userdata; + virtDBusManager *manager = userdata; _cleanup_(virtDBusVirDomainFreep) virDomainPtr domain = NULL; uint32_t flags; int r; @@ -396,7 +396,7 @@ domain_reset(sd_bus_message *message, void *userdata, sd_bus_error *error) { - VirtManager *manager = userdata; + virtDBusManager *manager = userdata; _cleanup_(virtDBusVirDomainFreep) virDomainPtr domain = NULL; uint32_t flags; int r; @@ -426,7 +426,7 @@ domain_create(sd_bus_message *message, void *userdata, sd_bus_error *error) { - VirtManager *manager = userdata; + virtDBusManager *manager = userdata; _cleanup_(virtDBusVirDomainFreep) virDomainPtr domain = NULL; int r; @@ -451,7 +451,7 @@ domain_undefine(sd_bus_message *message, void *userdata, sd_bus_error *error) { - VirtManager *manager = userdata; + virtDBusManager *manager = userdata; _cleanup_(virtDBusVirDomainFreep) virDomainPtr domain = NULL; int r; @@ -509,7 +509,7 @@ lookup_domain(sd_bus *bus, void **found, sd_bus_error *error) { - VirtManager *manager = userdata; + virtDBusManager *manager = userdata; _cleanup_(virtDBusFreep) char *name = NULL; _cleanup_(virtDBusVirDomainFreep) virDomainPtr domain = NULL; int r; @@ -536,7 +536,7 @@ lookup_domain(sd_bus *bus, } int -domain_register(VirtManager *manager, +domain_register(virtDBusManager *manager, sd_bus *bus) { return sd_bus_add_fallback_vtable(bus, diff --git a/src/domain.h b/src/domain.h index 3f347e8..9007165 100644 --- a/src/domain.h +++ b/src/domain.h @@ -5,5 +5,5 @@ #include <libvirt/libvirt.h> #include <systemd/sd-bus.h> -int domain_register(VirtManager *manager, +int domain_register(virtDBusManager *manager, sd_bus *bus); diff --git a/src/events.c b/src/events.c index 74f3d6f..c94cfd7 100644 --- a/src/events.c +++ b/src/events.c @@ -12,7 +12,7 @@ handle_domain_lifecycle_event(virConnectPtr connection, int detail, void *opaque) { - VirtManager *manager = opaque; + virtDBusManager *manager = opaque; _cleanup_(sd_bus_message_unrefp) sd_bus_message *message = NULL; const char *signal = NULL; const char *name; @@ -75,7 +75,7 @@ handle_domain_device_added_event(virConnectPtr connection, const char *device, void *opaque) { - VirtManager *manager = opaque; + virtDBusManager *manager = opaque; _cleanup_(sd_bus_message_unrefp) sd_bus_message *message = NULL; _cleanup_(virtDBusFreep) char *path = NULL; int r; @@ -103,7 +103,7 @@ handle_domain_device_removed_event(virConnectPtr connection, const char *device, void *opaque) { - VirtManager *manager = opaque; + virtDBusManager *manager = opaque; _cleanup_(sd_bus_message_unrefp) sd_bus_message *message = NULL; _cleanup_(virtDBusFreep) char *path = NULL; int r; @@ -132,7 +132,7 @@ handle_domain_disk_change_event(virConnectPtr connection, int reason, void *opaque) { - VirtManager *manager = opaque; + virtDBusManager *manager = opaque; _cleanup_(sd_bus_message_unrefp) sd_bus_message *message = NULL; _cleanup_(virtDBusFreep) char *path = NULL; const char *reasonstr; @@ -176,7 +176,7 @@ handle_domain_tray_change_event(virConnectPtr connection, int reason, void *opaque) { - VirtManager *manager = opaque; + virtDBusManager *manager = opaque; _cleanup_(sd_bus_message_unrefp) sd_bus_message *message = NULL; _cleanup_(virtDBusFreep) char *path = NULL; const char *reasonstr; @@ -212,7 +212,7 @@ handle_domain_tray_change_event(virConnectPtr connection, } static void -virt_manager_register_event(VirtManager *manager, +virt_manager_register_event(virtDBusManager *manager, int id, virConnectDomainEventGenericCallback callback) { @@ -227,7 +227,7 @@ virt_manager_register_event(VirtManager *manager, } void -virt_manager_register_events(VirtManager *manager) +virt_manager_register_events(virtDBusManager *manager) { virt_manager_register_event(manager, VIR_DOMAIN_EVENT_ID_LIFECYCLE, diff --git a/src/events.h b/src/events.h index 7f1dfca..b5cadcb 100644 --- a/src/events.h +++ b/src/events.h @@ -6,4 +6,4 @@ void -virt_manager_register_events(VirtManager *manager); +virt_manager_register_events(virtDBusManager *manager); diff --git a/src/main.c b/src/main.c index 493edcb..30b96fd 100644 --- a/src/main.c +++ b/src/main.c @@ -98,7 +98,7 @@ main(int argc, char *argv[]) bool system_bus; const char *uri = NULL; - _cleanup_(virt_manager_freep) VirtManager *manager = NULL; + _cleanup_(virtDBusManagerFreep) virtDBusManager *manager = NULL; _cleanup_(sd_bus_unrefp) sd_bus *bus = NULL; _cleanup_(virtDBusClosep) int signal_fd = -1; _cleanup_(virtDBusVirEventRemoveHandlep) int bus_watch = -1; @@ -162,7 +162,7 @@ main(int argc, char *argv[]) return EXIT_FAILURE; } - r = virt_manager_new(&manager, bus, uri); + r = virtDBusManagerNew(&manager, bus, uri); if (r < 0) { fprintf(stderr, "Failed to connect to libvirt"); return EXIT_FAILURE; diff --git a/src/manager.c b/src/manager.c index 8b25354..7a6e7b5 100644 --- a/src/manager.c +++ b/src/manager.c @@ -7,13 +7,13 @@ #include <stdlib.h> static int -enumerate_domains(sd_bus *bus, - const char *path, - void *userdata, - char ***nodes, - sd_bus_error *error) +virtDBusManagerEnumarateDomains(sd_bus *bus, + const char *path, + void *userdata, + char ***nodes, + sd_bus_error *error) { - VirtManager *manager = userdata; + virtDBusManager *manager = userdata; _cleanup_(virtDBusVirDomainListFreep) virDomainPtr *domains = NULL; _cleanup_(virtDBusStrvFreep) char **paths = NULL; int n_domains; @@ -34,11 +34,11 @@ enumerate_domains(sd_bus *bus, } static int -virt_manager_list_domains(sd_bus_message *message, - void *userdata, - sd_bus_error *error) +virtDBusManagerListDomains(sd_bus_message *message, + void *userdata, + sd_bus_error *error) { - VirtManager *manager = userdata; + virtDBusManager *manager = userdata; _cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL; _cleanup_(virtDBusVirDomainListFreep) virDomainPtr *domains = NULL; uint32_t flags; @@ -78,11 +78,11 @@ virt_manager_list_domains(sd_bus_message *message, } static int -virt_manager_create_xml(sd_bus_message *message, - void *userdata, - sd_bus_error *error) +virtDBusManagerCreateXML(sd_bus_message *message, + void *userdata, + sd_bus_error *error) { - VirtManager *manager = userdata; + virtDBusManager *manager = userdata; const char *xml; uint32_t flags; _cleanup_(virtDBusVirDomainFreep) virDomainPtr domain = NULL; @@ -103,11 +103,11 @@ virt_manager_create_xml(sd_bus_message *message, } static int -virt_manager_define_xml(sd_bus_message *message, - void *userdata, - sd_bus_error *error) +virtDBusManagerDefineXML(sd_bus_message *message, + void *userdata, + sd_bus_error *error) { - VirtManager *manager = userdata; + virtDBusManager *manager = userdata; const char *xml; _cleanup_(virtDBusVirDomainFreep) virDomainPtr domain = NULL; _cleanup_(virtDBusFreep) char *path = NULL; @@ -129,9 +129,9 @@ virt_manager_define_xml(sd_bus_message *message, static const sd_bus_vtable virt_manager_vtable[] = { SD_BUS_VTABLE_START(0), - SD_BUS_METHOD("ListDomains", "u", "ao", virt_manager_list_domains, SD_BUS_VTABLE_UNPRIVILEGED), - SD_BUS_METHOD("CreateXML", "su", "o", virt_manager_create_xml, SD_BUS_VTABLE_UNPRIVILEGED), - SD_BUS_METHOD("DefineXML", "s", "o", virt_manager_define_xml, SD_BUS_VTABLE_UNPRIVILEGED), + 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_SIGNAL("DomainDefined", "so", 0), SD_BUS_SIGNAL("DomainUndefined", "so", 0), @@ -147,14 +147,14 @@ static const sd_bus_vtable virt_manager_vtable[] = { }; int -virt_manager_new(VirtManager **managerp, - sd_bus *bus, - const char *uri) +virtDBusManagerNew(virtDBusManager **managerp, + sd_bus *bus, + const char *uri) { - _cleanup_(virt_manager_freep) VirtManager *manager = NULL; + _cleanup_(virtDBusManagerFreep) virtDBusManager *manager = NULL; int r; - manager = calloc(1, sizeof(VirtManager)); + manager = calloc(1, sizeof(virtDBusManager)); for (int i = 0; i < VIR_DOMAIN_EVENT_ID_LAST; i += 1) manager->callback_ids[i] = -1; @@ -175,7 +175,7 @@ virt_manager_new(VirtManager **managerp, if (r < 0) return r; - r = sd_bus_add_node_enumerator(bus, NULL, "/org/libvirt/domain", enumerate_domains, manager); + r = sd_bus_add_node_enumerator(bus, NULL, "/org/libvirt/domain", virtDBusManagerEnumarateDomains, manager); if (r < 0) return r; @@ -188,8 +188,8 @@ virt_manager_new(VirtManager **managerp, return 0; } -VirtManager * -virt_manager_free(VirtManager *manager) +virtDBusManager * +virtDBusManagerFree(virtDBusManager *manager) { if (manager->bus) sd_bus_unref(manager->bus); @@ -209,8 +209,8 @@ virt_manager_free(VirtManager *manager) } void -virt_manager_freep(VirtManager **managerp) +virtDBusManagerFreep(virtDBusManager **managerp) { if (*managerp) - virt_manager_free(*managerp); + virtDBusManagerFree(*managerp); } diff --git a/src/manager.h b/src/manager.h index 06aaa04..a1fefa6 100644 --- a/src/manager.h +++ b/src/manager.h @@ -5,16 +5,16 @@ #include <libvirt/libvirt.h> #include <systemd/sd-bus.h> -struct VirtManager { +struct virtDBusManager { sd_bus *bus; virConnectPtr connection; int callback_ids[VIR_DOMAIN_EVENT_ID_LAST]; }; -typedef struct VirtManager VirtManager; +typedef struct virtDBusManager virtDBusManager; -int virt_manager_new(VirtManager **managerp, - sd_bus *bus, - const char *uri); -VirtManager *virt_manager_free(VirtManager *manager); -void virt_manager_freep(VirtManager **managerp); +int virtDBusManagerNew(virtDBusManager **managerp, + sd_bus *bus, + const char *uri); +virtDBusManager *virtDBusManagerFree(virtDBusManager *manager); +void virtDBusManagerFreep(virtDBusManager **managerp); -- 2.13.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list