Fixes an bug that was introduced by <8e24f602>. Signed-off-by: Pavel Hrdina <phrdina@xxxxxxxxxx> --- src/connect.c | 2 +- src/connect.h | 4 ++++ src/domain.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+), 1 deletion(-) diff --git a/src/connect.c b/src/connect.c index e93111f..b31f08e 100644 --- a/src/connect.c +++ b/src/connect.c @@ -53,7 +53,7 @@ virtDBusConnectClose(virtDBusConnect *connect, connect->connection = NULL; } -static int +int virtDBusConnectOpen(virtDBusConnect *connect, sd_bus_error *error) { diff --git a/src/connect.h b/src/connect.h index 1086bc6..9e5f533 100644 --- a/src/connect.h +++ b/src/connect.h @@ -26,6 +26,10 @@ virtDBusConnectNew(virtDBusConnect **connectp, const char *uri, const char *connectPath); +int +virtDBusConnectOpen(virtDBusConnect *connect, + sd_bus_error *error); + virtDBusConnect * virtDBusConnectFree(virtDBusConnect *connect); diff --git a/src/domain.c b/src/domain.c index 8e6489a..3df9113 100644 --- a/src/domain.c +++ b/src/domain.c @@ -19,6 +19,9 @@ virtDBusDomainGetName(sd_bus *bus VIRT_ATTR_UNUSED, _cleanup_(virtDBusUtilVirDomainFreep) virDomainPtr domain = NULL; const char *name = ""; + if (virtDBusConnectOpen(connect, error) < 0) + return -1; + domain = virtDBusUtilVirDomainFromBusPath(connect->connection, path, connect->domainPath); if (domain == NULL) @@ -44,6 +47,9 @@ virtDBusDomainGetUUID(sd_bus *bus VIRT_ATTR_UNUSED, _cleanup_(virtDBusUtilVirDomainFreep) virDomainPtr domain = NULL; char uuid[VIR_UUID_STRING_BUFLEN] = ""; + if (virtDBusConnectOpen(connect, error) < 0) + return -1; + domain = virtDBusUtilVirDomainFromBusPath(connect->connection, path, connect->domainPath); if (domain == NULL) @@ -66,6 +72,9 @@ virtDBusDomainGetId(sd_bus *bus VIRT_ATTR_UNUSED, virtDBusConnect *connect = userdata; _cleanup_(virtDBusUtilVirDomainFreep) virDomainPtr domain = NULL; + if (virtDBusConnectOpen(connect, error) < 0) + return -1; + domain = virtDBusUtilVirDomainFromBusPath(connect->connection, path, connect->domainPath); if (domain == NULL) @@ -86,6 +95,9 @@ virtDBusDomainGetVcpus(sd_bus *bus VIRT_ATTR_UNUSED, virtDBusConnect *connect = userdata; _cleanup_(virtDBusUtilVirDomainFreep) virDomainPtr domain = NULL; + if (virtDBusConnectOpen(connect, error) < 0) + return -1; + domain = virtDBusUtilVirDomainFromBusPath(connect->connection, path, connect->domainPath); if (domain == NULL) @@ -107,6 +119,9 @@ virtDBusDomainGetOsType(sd_bus *bus VIRT_ATTR_UNUSED, _cleanup_(virtDBusUtilVirDomainFreep) virDomainPtr domain = NULL; _cleanup_(virtDBusUtilFreep) char *os_type = NULL; + if (virtDBusConnectOpen(connect, error) < 0) + return -1; + domain = virtDBusUtilVirDomainFromBusPath(connect->connection, path, connect->domainPath); if (domain == NULL) @@ -132,6 +147,9 @@ virtDBusDomainGetActive(sd_bus *bus VIRT_ATTR_UNUSED, _cleanup_(virtDBusUtilVirDomainFreep) virDomainPtr domain = NULL; int active; + if (virtDBusConnectOpen(connect, error) < 0) + return -1; + domain = virtDBusUtilVirDomainFromBusPath(connect->connection, path, connect->domainPath); if (domain == NULL) @@ -157,6 +175,9 @@ virtDBusDomainGetPersistent(sd_bus *bus VIRT_ATTR_UNUSED, _cleanup_(virtDBusUtilVirDomainFreep) virDomainPtr domain = NULL; int persistent; + if (virtDBusConnectOpen(connect, error) < 0) + return -1; + domain = virtDBusUtilVirDomainFromBusPath(connect->connection, path, connect->domainPath); if (domain == NULL) @@ -183,6 +204,9 @@ virtDBusDomainGetState(sd_bus *bus VIRT_ATTR_UNUSED, int state = 0; const char *string; + if (virtDBusConnectOpen(connect, error) < 0) + return -1; + domain = virtDBusUtilVirDomainFromBusPath(connect->connection, path, connect->domainPath); if (domain == NULL) @@ -234,6 +258,9 @@ virtDBusDomainGetAutostart(sd_bus *bus VIRT_ATTR_UNUSED, _cleanup_(virtDBusUtilVirDomainFreep) virDomainPtr domain = NULL; int autostart = 0; + if (virtDBusConnectOpen(connect, error) < 0) + return -1; + domain = virtDBusUtilVirDomainFromBusPath(connect->connection, path, connect->domainPath); if (domain == NULL) @@ -255,6 +282,9 @@ virtDBusDomainGetXMLDesc(sd_bus_message *message, uint32_t flags; int r; + if (virtDBusConnectOpen(connect, error) < 0) + return -1; + domain = virtDBusUtilVirDomainFromBusPath(connect->connection, sd_bus_message_get_path(message), connect->domainPath); @@ -300,6 +330,9 @@ virtDBusDomainGetStats(sd_bus_message *message, if (r < 0) return r; + if (virtDBusConnectOpen(connect, error) < 0) + return -1; + domain = virtDBusUtilVirDomainFromBusPath(connect->connection, sd_bus_message_get_path(message), connect->domainPath); @@ -336,6 +369,9 @@ virtDBusDomainShutdown(sd_bus_message *message, _cleanup_(virtDBusUtilVirDomainFreep) virDomainPtr domain = NULL; int r; + if (virtDBusConnectOpen(connect, error) < 0) + return -1; + domain = virtDBusUtilVirDomainFromBusPath(connect->connection, sd_bus_message_get_path(message), connect->domainPath); @@ -362,6 +398,9 @@ virtDBusDomainDestroy(sd_bus_message *message, _cleanup_(virtDBusUtilVirDomainFreep) virDomainPtr domain = NULL; int r; + if (virtDBusConnectOpen(connect, error) < 0) + return -1; + domain = virtDBusUtilVirDomainFromBusPath(connect->connection, sd_bus_message_get_path(message), connect->domainPath); @@ -393,6 +432,9 @@ virtDBusDomainReboot(sd_bus_message *message, if (r < 0) return r; + if (virtDBusConnectOpen(connect, error) < 0) + return -1; + domain = virtDBusUtilVirDomainFromBusPath(connect->connection, sd_bus_message_get_path(message), connect->domainPath); @@ -424,6 +466,9 @@ virtDBusDomainReset(sd_bus_message *message, if (r < 0) return r; + if (virtDBusConnectOpen(connect, error) < 0) + return -1; + domain = virtDBusUtilVirDomainFromBusPath(connect->connection, sd_bus_message_get_path(message), connect->domainPath); @@ -450,6 +495,9 @@ virtDBusDomainCreate(sd_bus_message *message, _cleanup_(virtDBusUtilVirDomainFreep) virDomainPtr domain = NULL; int r; + if (virtDBusConnectOpen(connect, error) < 0) + return -1; + domain = virtDBusUtilVirDomainFromBusPath(connect->connection, sd_bus_message_get_path(message), connect->domainPath); @@ -476,6 +524,9 @@ virtDBusDomainUndefine(sd_bus_message *message, _cleanup_(virtDBusUtilVirDomainFreep) virDomainPtr domain = NULL; int r; + if (virtDBusConnectOpen(connect, error) < 0) + return -1; + domain = virtDBusUtilVirDomainFromBusPath(connect->connection, sd_bus_message_get_path(message), connect->domainPath); -- 2.14.3 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list