All libvirt-dbus function should use virtDBus preffix and use only one coding style, camelCase.
Signed-off-by: Pavel Hrdina <phrd...@redhat.com> --- src/domain.c | 110 +++++++++++++++++++++++++++++----------------------------- src/events.c | 20 +++++------ src/main.c | 2 +- src/manager.c | 32 ++++++++--------- src/util.c | 17 ++++----- src/util.h | 26 +++++++------- 6 files changed, 105 insertions(+), 102 deletions(-) diff --git a/src/domain.c b/src/domain.c index 1bda3b8..4bfb314 100644 --- a/src/domain.c +++ b/src/domain.c @@ -11,10 +11,10 @@ domain_get_name(sd_bus *bus, sd_bus_error *error) { VirtManager *manager = userdata; - _cleanup_(virDomainFreep) virDomainPtr domain = NULL; + _cleanup_(virtDBusVirDomainFreep) virDomainPtr domain = NULL; const char *name = ""; - domain = domain_from_bus_path(manager->connection, path); + domain = virtDBusVirDomainFromBusPath(manager->connection, path); if (domain == NULL) return sd_bus_message_append(reply, "s", ""); @@ -35,10 +35,10 @@ domain_get_uuid(sd_bus *bus, sd_bus_error *error) { VirtManager *manager = userdata; - _cleanup_(virDomainFreep) virDomainPtr domain = NULL; + _cleanup_(virtDBusVirDomainFreep) virDomainPtr domain = NULL; char uuid[VIR_UUID_STRING_BUFLEN] = ""; - domain = domain_from_bus_path(manager->connection, path); + domain = virtDBusVirDomainFromBusPath(manager->connection, path); if (domain == NULL) return sd_bus_message_append(reply, "s", ""); @@ -57,9 +57,9 @@ domain_get_id(sd_bus *bus, sd_bus_error *error) { VirtManager *manager = userdata; - _cleanup_(virDomainFreep) virDomainPtr domain = NULL; + _cleanup_(virtDBusVirDomainFreep) virDomainPtr domain = NULL; - domain = domain_from_bus_path(manager->connection, path); + domain = virtDBusVirDomainFromBusPath(manager->connection, path); if (domain == NULL) return sd_bus_message_append(reply, "u", 0); @@ -76,9 +76,9 @@ domain_get_vcpus(sd_bus *bus, sd_bus_error *error) { VirtManager *manager = userdata; - _cleanup_(virDomainFreep) virDomainPtr domain = NULL; + _cleanup_(virtDBusVirDomainFreep) virDomainPtr domain = NULL; - domain = domain_from_bus_path(manager->connection, path); + domain = virtDBusVirDomainFromBusPath(manager->connection, path); if (domain == NULL) return sd_bus_message_append(reply, "u", 0); @@ -95,10 +95,10 @@ domain_get_os_type(sd_bus *bus, sd_bus_error *error) { VirtManager *manager = userdata; - _cleanup_(virDomainFreep) virDomainPtr domain = NULL; - _cleanup_(freep) char *os_type = NULL; + _cleanup_(virtDBusVirDomainFreep) virDomainPtr domain = NULL; + _cleanup_(virtDBusFreep) char *os_type = NULL; - domain = domain_from_bus_path(manager->connection, path); + domain = virtDBusVirDomainFromBusPath(manager->connection, path); if (domain == NULL) return sd_bus_message_append(reply, "s", ""); @@ -119,10 +119,10 @@ domain_get_active(sd_bus *bus, sd_bus_error *error) { VirtManager *manager = userdata; - _cleanup_(virDomainFreep) virDomainPtr domain = NULL; + _cleanup_(virtDBusVirDomainFreep) virDomainPtr domain = NULL; int active; - domain = domain_from_bus_path(manager->connection, path); + domain = virtDBusVirDomainFromBusPath(manager->connection, path); if (domain == NULL) return sd_bus_message_append(reply, "b", 0); @@ -143,10 +143,10 @@ domain_get_persistent(sd_bus *bus, sd_bus_error *error) { VirtManager *manager = userdata; - _cleanup_(virDomainFreep) virDomainPtr domain = NULL; + _cleanup_(virtDBusVirDomainFreep) virDomainPtr domain = NULL; int persistent; - domain = domain_from_bus_path(manager->connection, path); + domain = virtDBusVirDomainFromBusPath(manager->connection, path); if (domain == NULL) return sd_bus_message_append(reply, "b", 0); @@ -167,11 +167,11 @@ domain_get_state(sd_bus *bus, sd_bus_error *error) { VirtManager *manager = userdata; - _cleanup_(virDomainFreep) virDomainPtr domain = NULL; + _cleanup_(virtDBusVirDomainFreep) virDomainPtr domain = NULL; int state = 0; const char *string; - domain = domain_from_bus_path(manager->connection, path); + domain = virtDBusVirDomainFromBusPath(manager->connection, path); if (domain == NULL) return sd_bus_message_append(reply, "s", ""); @@ -218,10 +218,10 @@ domain_get_autostart(sd_bus *bus, sd_bus_error *error) { VirtManager *manager = userdata; - _cleanup_(virDomainFreep) virDomainPtr domain = NULL; + _cleanup_(virtDBusVirDomainFreep) virDomainPtr domain = NULL; int autostart = 0; - domain = domain_from_bus_path(manager->connection, path); + domain = virtDBusVirDomainFromBusPath(manager->connection, path); if (domain == NULL) return sd_bus_message_append(reply, "b", 0); @@ -236,13 +236,13 @@ domain_get_xml_desc(sd_bus_message *message, sd_bus_error *error) { VirtManager *manager = userdata; - _cleanup_(virDomainFreep) virDomainPtr domain = NULL; - _cleanup_(freep) char *description = NULL; + _cleanup_(virtDBusVirDomainFreep) virDomainPtr domain = NULL; + _cleanup_(virtDBusFreep) char *description = NULL; uint32_t flags; int r; - domain = domain_from_bus_path(manager->connection, - sd_bus_message_get_path(message)); + domain = virtDBusVirDomainFromBusPath(manager->connection, + sd_bus_message_get_path(message)); if (domain == NULL) { return sd_bus_reply_method_errorf(message, SD_BUS_ERROR_UNKNOWN_OBJECT, @@ -256,7 +256,7 @@ domain_get_xml_desc(sd_bus_message *message, description = virDomainGetXMLDesc(domain, flags); if (!description) - return bus_error_set_last_virt_error(error); + return virtDBusSetLastVirtError(error); return sd_bus_reply_method_return(message, "s", description); } @@ -274,7 +274,7 @@ domain_get_stats(sd_bus_message *message, sd_bus_error *error) { VirtManager *manager = userdata; - _cleanup_(virDomainFreep) virDomainPtr domain = NULL; + _cleanup_(virtDBusVirDomainFreep) virDomainPtr domain = NULL; virDomainPtr domains[2]; _cleanup_(virDomainStatsRecordListFreep) virDomainStatsRecordPtr *records = NULL; _cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL; @@ -285,8 +285,8 @@ domain_get_stats(sd_bus_message *message, if (r < 0) return r; - domain = domain_from_bus_path(manager->connection, - sd_bus_message_get_path(message)); + domain = virtDBusVirDomainFromBusPath(manager->connection, + sd_bus_message_get_path(message)); if (domain == NULL) { return sd_bus_reply_method_errorf(message, SD_BUS_ERROR_UNKNOWN_OBJECT, @@ -298,13 +298,13 @@ domain_get_stats(sd_bus_message *message, domains[1] = NULL; if (virDomainListGetStats(domains, stats, &records, flags) != 1) - return bus_error_set_last_virt_error(error); + return virtDBusSetLastVirtError(error); r = sd_bus_message_new_method_return(message, &reply); if (r < 0) return r; - r = bus_message_append_typed_parameters(reply, records[0]->params, records[0]->nparams); + r = virtDBusMessageAppendTypedParameters(reply, records[0]->params, records[0]->nparams); if (r < 0) return r; @@ -317,11 +317,11 @@ domain_shutdown(sd_bus_message *message, sd_bus_error *error) { VirtManager *manager = userdata; - _cleanup_(virDomainFreep) virDomainPtr domain = NULL; + _cleanup_(virtDBusVirDomainFreep) virDomainPtr domain = NULL; int r; - domain = domain_from_bus_path(manager->connection, - sd_bus_message_get_path(message)); + domain = virtDBusVirDomainFromBusPath(manager->connection, + sd_bus_message_get_path(message)); if (domain == NULL) { return sd_bus_reply_method_errorf(message, SD_BUS_ERROR_UNKNOWN_OBJECT, @@ -331,7 +331,7 @@ domain_shutdown(sd_bus_message *message, r = virDomainShutdown(domain); if (r < 0) - return bus_error_set_last_virt_error(error); + return virtDBusSetLastVirtError(error); return sd_bus_reply_method_return(message, ""); } @@ -342,11 +342,11 @@ domain_destroy(sd_bus_message *message, sd_bus_error *error) { VirtManager *manager = userdata; - _cleanup_(virDomainFreep) virDomainPtr domain = NULL; + _cleanup_(virtDBusVirDomainFreep) virDomainPtr domain = NULL; int r; - domain = domain_from_bus_path(manager->connection, - sd_bus_message_get_path(message)); + domain = virtDBusVirDomainFromBusPath(manager->connection, + sd_bus_message_get_path(message)); if (domain == NULL) { return sd_bus_reply_method_errorf(message, SD_BUS_ERROR_UNKNOWN_OBJECT, @@ -356,7 +356,7 @@ domain_destroy(sd_bus_message *message, r = virDomainDestroy(domain); if (r < 0) - return bus_error_set_last_virt_error(error); + return virtDBusSetLastVirtError(error); return sd_bus_reply_method_return(message, ""); } @@ -367,7 +367,7 @@ domain_reboot(sd_bus_message *message, sd_bus_error *error) { VirtManager *manager = userdata; - _cleanup_(virDomainFreep) virDomainPtr domain = NULL; + _cleanup_(virtDBusVirDomainFreep) virDomainPtr domain = NULL; uint32_t flags; int r; @@ -375,8 +375,8 @@ domain_reboot(sd_bus_message *message, if (r < 0) return r; - domain = domain_from_bus_path(manager->connection, - sd_bus_message_get_path(message)); + domain = virtDBusVirDomainFromBusPath(manager->connection, + sd_bus_message_get_path(message)); if (domain == NULL) { return sd_bus_reply_method_errorf(message, SD_BUS_ERROR_UNKNOWN_OBJECT, @@ -386,7 +386,7 @@ domain_reboot(sd_bus_message *message, r = virDomainReboot(domain, flags); if (r < 0) - return bus_error_set_last_virt_error(error); + return virtDBusSetLastVirtError(error); return sd_bus_reply_method_return(message, ""); } @@ -397,7 +397,7 @@ domain_reset(sd_bus_message *message, sd_bus_error *error) { VirtManager *manager = userdata; - _cleanup_(virDomainFreep) virDomainPtr domain = NULL; + _cleanup_(virtDBusVirDomainFreep) virDomainPtr domain = NULL; uint32_t flags; int r; @@ -405,8 +405,8 @@ domain_reset(sd_bus_message *message, if (r < 0) return r; - domain = domain_from_bus_path(manager->connection, - sd_bus_message_get_path(message)); + domain = virtDBusVirDomainFromBusPath(manager->connection, + sd_bus_message_get_path(message)); if (domain == NULL) { return sd_bus_reply_method_errorf(message, SD_BUS_ERROR_UNKNOWN_OBJECT, @@ -416,7 +416,7 @@ domain_reset(sd_bus_message *message, r = virDomainReset(domain, flags); if (r < 0) - return bus_error_set_last_virt_error(error); + return virtDBusSetLastVirtError(error); return sd_bus_reply_method_return(message, ""); } @@ -427,11 +427,11 @@ domain_create(sd_bus_message *message, sd_bus_error *error) { VirtManager *manager = userdata; - _cleanup_(virDomainFreep) virDomainPtr domain = NULL; + _cleanup_(virtDBusVirDomainFreep) virDomainPtr domain = NULL; int r; - domain = domain_from_bus_path(manager->connection, - sd_bus_message_get_path(message)); + domain = virtDBusVirDomainFromBusPath(manager->connection, + sd_bus_message_get_path(message)); if (domain == NULL) { return sd_bus_reply_method_errorf(message, SD_BUS_ERROR_UNKNOWN_OBJECT, @@ -441,7 +441,7 @@ domain_create(sd_bus_message *message, r = virDomainCreate(domain); if (r < 0) - return bus_error_set_last_virt_error(error); + return virtDBusSetLastVirtError(error); return sd_bus_reply_method_return(message, ""); } @@ -452,11 +452,11 @@ domain_undefine(sd_bus_message *message, sd_bus_error *error) { VirtManager *manager = userdata; - _cleanup_(virDomainFreep) virDomainPtr domain = NULL; + _cleanup_(virtDBusVirDomainFreep) virDomainPtr domain = NULL; int r; - domain = domain_from_bus_path(manager->connection, - sd_bus_message_get_path(message)); + domain = virtDBusVirDomainFromBusPath(manager->connection, + sd_bus_message_get_path(message)); if (domain == NULL) { return sd_bus_reply_method_errorf(message, SD_BUS_ERROR_UNKNOWN_OBJECT, @@ -466,7 +466,7 @@ domain_undefine(sd_bus_message *message, r = virDomainUndefine(domain); if (r < 0) - return bus_error_set_last_virt_error(error); + return virtDBusSetLastVirtError(error); return sd_bus_reply_method_return(message, ""); } @@ -510,8 +510,8 @@ lookup_domain(sd_bus *bus, sd_bus_error *error) { VirtManager *manager = userdata; - _cleanup_(freep) char *name = NULL; - _cleanup_(virDomainFreep) virDomainPtr domain = NULL; + _cleanup_(virtDBusFreep) char *name = NULL; + _cleanup_(virtDBusVirDomainFreep) virDomainPtr domain = NULL; int r; r = sd_bus_path_decode(path, "/org/libvirt/domain", &name); diff --git a/src/events.c b/src/events.c index 4572e39..74f3d6f 100644 --- a/src/events.c +++ b/src/events.c @@ -16,7 +16,7 @@ handle_domain_lifecycle_event(virConnectPtr connection, _cleanup_(sd_bus_message_unrefp) sd_bus_message *message = NULL; const char *signal = NULL; const char *name; - _cleanup_(freep) char *path = NULL; + _cleanup_(virtDBusFreep) char *path = NULL; int r; switch (event) { @@ -60,7 +60,7 @@ handle_domain_lifecycle_event(virConnectPtr connection, return r; name = virDomainGetName(domain); - path = bus_path_for_domain(domain); + path = virtDBusBusPathForVirDomain(domain); r = sd_bus_message_append(message, "so", name ? : "", path); if (r < 0) @@ -77,10 +77,10 @@ handle_domain_device_added_event(virConnectPtr connection, { VirtManager *manager = opaque; _cleanup_(sd_bus_message_unrefp) sd_bus_message *message = NULL; - _cleanup_(freep) char *path = NULL; + _cleanup_(virtDBusFreep) char *path = NULL; int r; - path = bus_path_for_domain(domain); + path = virtDBusBusPathForVirDomain(domain); r = sd_bus_message_new_signal(manager->bus, &message, @@ -105,10 +105,10 @@ handle_domain_device_removed_event(virConnectPtr connection, { VirtManager *manager = opaque; _cleanup_(sd_bus_message_unrefp) sd_bus_message *message = NULL; - _cleanup_(freep) char *path = NULL; + _cleanup_(virtDBusFreep) char *path = NULL; int r; - path = bus_path_for_domain(domain); + path = virtDBusBusPathForVirDomain(domain); r = sd_bus_message_new_signal(manager->bus, &message, @@ -134,11 +134,11 @@ handle_domain_disk_change_event(virConnectPtr connection, { VirtManager *manager = opaque; _cleanup_(sd_bus_message_unrefp) sd_bus_message *message = NULL; - _cleanup_(freep) char *path = NULL; + _cleanup_(virtDBusFreep) char *path = NULL; const char *reasonstr; int r; - path = bus_path_for_domain(domain); + path = virtDBusBusPathForVirDomain(domain); r = sd_bus_message_new_signal(manager->bus, &message, @@ -178,11 +178,11 @@ handle_domain_tray_change_event(virConnectPtr connection, { VirtManager *manager = opaque; _cleanup_(sd_bus_message_unrefp) sd_bus_message *message = NULL; - _cleanup_(freep) char *path = NULL; + _cleanup_(virtDBusFreep) char *path = NULL; const char *reasonstr; int r; - path = bus_path_for_domain(domain); + path = virtDBusBusPathForVirDomain(domain); r = sd_bus_message_new_signal(manager->bus, &message, diff --git a/src/main.c b/src/main.c index a0cff38..a1d9cd1 100644 --- a/src/main.c +++ b/src/main.c @@ -100,7 +100,7 @@ main(int argc, char *argv[]) _cleanup_(virt_manager_freep) VirtManager *manager = NULL; _cleanup_(sd_bus_unrefp) sd_bus *bus = NULL; - _cleanup_(closep) int signal_fd = -1; + _cleanup_(virtDBusClosep) int signal_fd = -1; _cleanup_(virEventRemoveHandlep) int bus_watch = -1; _cleanup_(virEventRemoveHandlep) int signal_watch = -1; sigset_t mask; diff --git a/src/manager.c b/src/manager.c index 32f38bb..8b25354 100644 --- a/src/manager.c +++ b/src/manager.c @@ -14,18 +14,18 @@ enumerate_domains(sd_bus *bus, sd_bus_error *error) { VirtManager *manager = userdata; - _cleanup_(virDomainListFreep) virDomainPtr *domains = NULL; - _cleanup_(strv_freep) char **paths = NULL; + _cleanup_(virtDBusVirDomainListFreep) virDomainPtr *domains = NULL; + _cleanup_(virtDBusStrvFreep) char **paths = NULL; int n_domains; n_domains = virConnectListAllDomains(manager->connection, &domains, 0); if (n_domains < 0) - return bus_error_set_last_virt_error(error); + return virtDBusSetLastVirtError(error); paths = calloc(n_domains + 1, sizeof(char *)); for (int i = 0; i < n_domains; i += 1) - paths[i] = bus_path_for_domain(domains[i]); + paths[i] = virtDBusBusPathForVirDomain(domains[i]); *nodes = paths; paths = NULL; @@ -40,7 +40,7 @@ virt_manager_list_domains(sd_bus_message *message, { VirtManager *manager = userdata; _cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL; - _cleanup_(virDomainListFreep) virDomainPtr *domains = NULL; + _cleanup_(virtDBusVirDomainListFreep) virDomainPtr *domains = NULL; uint32_t flags; int r; @@ -50,7 +50,7 @@ virt_manager_list_domains(sd_bus_message *message, r = virConnectListAllDomains(manager->connection, &domains, flags); if (r < 0) - return bus_error_set_last_virt_error(error); + return virtDBusSetLastVirtError(error); r = sd_bus_message_new_method_return(message, &reply); if (r < 0) @@ -61,9 +61,9 @@ virt_manager_list_domains(sd_bus_message *message, return r; for (int i = 0; domains[i] != NULL; i += 1) { - _cleanup_(freep) char *path = NULL; + _cleanup_(virtDBusFreep) char *path = NULL; - path = bus_path_for_domain(domains[i]); + path = virtDBusBusPathForVirDomain(domains[i]); r = sd_bus_message_append(reply, "o", path); if (r < 0) @@ -85,8 +85,8 @@ virt_manager_create_xml(sd_bus_message *message, VirtManager *manager = userdata; const char *xml; uint32_t flags; - _cleanup_(virDomainFreep) virDomainPtr domain = NULL; - _cleanup_(freep) char *path = NULL; + _cleanup_(virtDBusVirDomainFreep) virDomainPtr domain = NULL; + _cleanup_(virtDBusFreep) char *path = NULL; int r; r = sd_bus_message_read(message, "su", &xml, &flags); @@ -95,9 +95,9 @@ virt_manager_create_xml(sd_bus_message *message, domain = virDomainCreateXML(manager->connection, xml, flags); if (!domain) - return bus_error_set_last_virt_error(error); + return virtDBusSetLastVirtError(error); - path = bus_path_for_domain(domain); + path = virtDBusBusPathForVirDomain(domain); return sd_bus_reply_method_return(message, "o", path); } @@ -109,8 +109,8 @@ virt_manager_define_xml(sd_bus_message *message, { VirtManager *manager = userdata; const char *xml; - _cleanup_(virDomainFreep) virDomainPtr domain = NULL; - _cleanup_(freep) char *path = NULL; + _cleanup_(virtDBusVirDomainFreep) virDomainPtr domain = NULL; + _cleanup_(virtDBusFreep) char *path = NULL; int r; r = sd_bus_message_read(message, "s", &xml); @@ -119,9 +119,9 @@ virt_manager_define_xml(sd_bus_message *message, domain = virDomainDefineXML(manager->connection, xml); if (!domain) - return bus_error_set_last_virt_error(error); + return virtDBusSetLastVirtError(error); - path = bus_path_for_domain(domain); + path = virtDBusBusPathForVirDomain(domain); return sd_bus_reply_method_return(message, "o", path); } diff --git a/src/util.c b/src/util.c index 99cd6b5..21a9453 100644 --- a/src/util.c +++ b/src/util.c @@ -3,9 +3,9 @@ #include <libvirt/virterror.h> int -bus_message_append_typed_parameters(sd_bus_message *message, - virTypedParameterPtr parameters, - int n_parameters) +virtDBusMessageAppendTypedParameters(sd_bus_message *message, + virTypedParameterPtr parameters, + int n_parameters) { int r; @@ -57,7 +57,8 @@ bus_message_append_typed_parameters(sd_bus_message *message, return sd_bus_message_close_container(message); } -int bus_error_set_last_virt_error(sd_bus_error *error) +int +virtDBusSetLastVirtError(sd_bus_error *error) { virErrorPtr vir_error; @@ -69,7 +70,7 @@ int bus_error_set_last_virt_error(sd_bus_error *error) } char * -bus_path_for_domain(virDomainPtr domain) +virtDBusBusPathForVirDomain(virDomainPtr domain) { char *path = NULL; char uuid[VIR_UUID_STRING_BUFLEN] = ""; @@ -81,10 +82,10 @@ bus_path_for_domain(virDomainPtr domain) } virDomainPtr -domain_from_bus_path(virConnectPtr connection, - const char *path) +virtDBusVirDomainFromBusPath(virConnectPtr connection, + const char *path) { - _cleanup_(freep) char *name = NULL; + _cleanup_(virtDBusFreep) char *name = NULL; int r; r = sd_bus_path_decode(path, "/org/libvirt/domain", &name); diff --git a/src/util.h b/src/util.h index bc39f44..9ac7932 100644 --- a/src/util.h +++ b/src/util.h @@ -7,34 +7,36 @@ #define _cleanup_(_x) __attribute__((__cleanup__(_x))) -int bus_message_append_typed_parameters(sd_bus_message *message, - virTypedParameterPtr parameters, - int n_parameters); +int +virtDBusMessageAppendTypedParameters(sd_bus_message *message, + virTypedParameterPtr parameters, + int n_parameters); -int bus_error_set_last_virt_error(sd_bus_error *error); +int +virtDBusSetLastVirtError(sd_bus_error *error); char * -bus_path_for_domain(virDomainPtr domain); +virtDBusBusPathForVirDomain(virDomainPtr domain); virDomainPtr -domain_from_bus_path(virConnectPtr connection, - const char *path); +virtDBusVirDomainFromBusPath(virConnectPtr connection, + const char *path); static inline void -freep(void *p) +virtDBusFreep(void *p) { free(*(void **)p); } static inline void -closep(int *fdp) +virtDBusClosep(int *fdp) { if (*fdp >= 0) close(*fdp); } static inline void -strv_freep(void *p) +virtDBusStrvFreep(void *p) { char **strv = *(char ***)p; @@ -48,14 +50,14 @@ strv_freep(void *p) } static inline void -virDomainFreep(virDomainPtr *domainp) +virtDBusVirDomainFreep(virDomainPtr *domainp) { if (*domainp) virDomainFree(*domainp); } static inline void -virDomainListFreep(virDomainPtr **domainsp) +virtDBusVirDomainListFreep(virDomainPtr **domainsp) { virDomainPtr *domains = *domainsp; -- 2.13.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list