[libvirt] [dbus PATCH 10/15] Implement StorageVolLookupByPath method for Connect Interface

Ján Tomko jtomko at redhat.com
Thu Jun 14 13:25:39 UTC 2018


On Tue, Jun 12, 2018 at 11:00:23AM +0200, Katerina Koukiou wrote:
>Signed-off-by: Katerina Koukiou <kkoukiou at redhat.com>
>---
> data/org.libvirt.Connect.xml |  6 ++++++
> src/connect.c                | 29 +++++++++++++++++++++++++++++
> tests/test_connect.py        |  1 +
> 3 files changed, 36 insertions(+)
>
>diff --git a/src/connect.c b/src/connect.c
>index c526808..157cdb3 100644
>--- a/src/connect.c
>+++ b/src/connect.c
>@@ -1573,6 +1573,34 @@ virtDBusConnectStorageVolLookupByKey(GVariant *inArgs,
>     *outArgs = g_variant_new("(o)", path);
> }
>
>+static void
>+virtDBusConnectStorageVolLookupByPath(GVariant *inArgs,
>+                                      GUnixFDList *inFDs G_GNUC_UNUSED,
>+                                      const gchar *objectPath G_GNUC_UNUSED,
>+                                      gpointer userData,
>+                                      GVariant **outArgs,
>+                                      GUnixFDList **outFDs G_GNUC_UNUSED,
>+                                      GError **error)
>+{
>+    virtDBusConnect *connect = userData;
>+    g_autoptr(virStorageVol) storageVol = NULL;
>+    g_autofree gchar *path = NULL;
>+
>+    g_variant_get(inArgs, "(s)", &path);

I'd suggest using a different variable for the input parameter,
e.g.

const gchar *inPath and "(&s)" here, to save g_variant_get the trouble
of strdup-ing the path and us the trouble of freeing it before reusing
the variable for the storage volume object path.

Reviewed-by: Ján Tomko <jtomko at redhat.com>

Jano

>+
>+    if (!virtDBusConnectOpen(connect, error))
>+        return;
>+
>+    storageVol = virStorageVolLookupByPath(connect->connection, path);
>+    if (!storageVol)
>+        return virtDBusUtilSetLastVirtError(error);
>+
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20180614/0f8e3391/attachment-0001.sig>


More information about the libvir-list mailing list