[libvirt] [dbus PATCH 5/6] Implement SetMetadata method for Domain Interface
Pavel Hrdina
phrdina at redhat.com
Thu Apr 19 08:10:51 UTC 2018
On Wed, Apr 18, 2018 at 05:47:30PM +0200, Katerina Koukiou wrote:
> Signed-off-by: Katerina Koukiou <kkoukiou at redhat.com>
> ---
> data/org.libvirt.Domain.xml | 10 ++++++++++
> src/domain.c | 47 +++++++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 57 insertions(+)
>
> diff --git a/data/org.libvirt.Domain.xml b/data/org.libvirt.Domain.xml
> index 901f84a..f2ecb1f 100644
> --- a/data/org.libvirt.Domain.xml
> +++ b/data/org.libvirt.Domain.xml
> @@ -312,6 +312,16 @@
> <arg name="memory" type="t" direction="in"/>
> <arg name="flags" type="u" direction="in"/>
> </method>
> + <method name="SetMetadata">
> + <annotation name="org.gtk.GDBus.DocString"
> + value="See https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainSetMetadata
> + Empty string can be used to pass a NULL as @key or @uri argument."/>
> + <arg name="type" type="s" direction="in"/>
> + <arg name="metadata" type="s" direction="in"/>
> + <arg name="key" type="s" direction="in"/>
> + <arg name="uri" type="s" direction="in"/>
> + <arg name="flags" type="u" direction="in"/>
> + </method>
> <method name="SetUserPassword">
> <annotation name="org.gtk.GDBus.DocString"
> value="See https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainSetUserPassword"/>
> diff --git a/src/domain.c b/src/domain.c
> index d636328..c3c530e 100644
> --- a/src/domain.c
> +++ b/src/domain.c
> @@ -27,6 +27,13 @@ VIRT_DBUS_ENUM_IMPL(virtDBusDomainMemoryStat,
> "usable",
> "last_update")
>
> +VIRT_DBUS_ENUM_DECL(virtDBusDomainMetadata)
> +VIRT_DBUS_ENUM_IMPL(virtDBusDomainMetadata,
> + VIR_DOMAIN_METADATA_LAST,
> + "description",
> + "title",
> + "element")
> +
> static GVariant *
> virtDBusDomainMemoryStatsToGVariant(virDomainMemoryStatPtr stats,
> gint nr_stats)
> @@ -1487,6 +1494,45 @@ virtDBusDomainSetMemory(GVariant *inArgs,
> virtDBusUtilSetLastVirtError(error);
> }
>
> +static void
> +virtDBusDomainSetMetadata(GVariant *inArgs,
> + GUnixFDList *inFDs G_GNUC_UNUSED,
> + const gchar *objectPath,
> + gpointer userData,
> + GVariant **outArgs G_GNUC_UNUSED,
> + GUnixFDList **outFDs G_GNUC_UNUSED,
> + GError **error)
> +
> +{
> + virtDBusConnect *connect = userData;
> + g_autoptr(virDomain) domain = NULL;
> + const gchar *typeStr;
> + gint type;
> + const gchar *metadata;
> + const gchar *key;
> + const gchar *uri;
> + guint flags;
> +
> + g_variant_get(inArgs, "(&s&s&s&su)", &typeStr, &metadata, &key, &uri, &flags);
> + if (g_str_equal(key, ""))
> + key = NULL;
> + if (g_str_equal(uri, ""))
> + uri = NULL;
> +
> + domain = virtDBusDomainGetVirDomain(connect, objectPath, error);
> + if (!domain)
> + return;
> +
> + type = virtDBusDomainMetadataTypeFromString(typeStr);
> + if (type < 0)
> + g_set_error(error, VIRT_DBUS_ERROR, VIRT_DBUS_ERROR_LIBVIRT,
> + "Can't get valid virDomainMetadataType from string '%s'.",
> + typeStr);
Missing return if the error is set. For some reason I forgot to
mention it.
> +
> + if (virDomainSetMetadata(domain, type, metadata, key, uri, flags) < 0)
> + virtDBusUtilSetLastVirtError(error);
> +}
> +
> static void
> virtDBusDomainSetUserPassword(GVariant *inArgs,
> GUnixFDList *inFDs G_GNUC_UNUSED,
> @@ -1713,6 +1759,7 @@ static virtDBusGDBusMethodTable virtDBusDomainMethodTable[] = {
> { "SendProcessSignal", virtDBusDomainSendProcessSignal },
> { "SetVcpus", virtDBusDomainSetVcpus },
> { "SetMemory", virtDBusDomainSetMemory },
> + { "SetMetadata", virtDBusDomainSetMetadata },
> { "SetTime", virtDBusDomainSetTime },
> { "SetUserPassword", virtDBusDomainSetUserPassword },
> { "Shutdown", virtDBusDomainShutdown },
> --
> 2.15.0
>
> --
> libvir-list mailing list
> libvir-list at redhat.com
> https://www.redhat.com/mailman/listinfo/libvir-list
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20180419/beb67da7/attachment-0001.sig>
More information about the libvir-list
mailing list