[libvirt] [dbus PATCH v2 21/22] Implement SetMemory method for Domain Interface

Katerina Koukiou posted 22 patches 7 years, 8 months ago
There is a newer version of this series
[libvirt] [dbus PATCH v2 21/22] Implement SetMemory method for Domain Interface
Posted by Katerina Koukiou 7 years, 8 months ago
Signed-off-by: Katerina Koukiou <kkoukiou@redhat.com>
---
 data/org.libvirt.Domain.xml |  6 ++++++
 src/domain.c                | 26 ++++++++++++++++++++++++++
 2 files changed, 32 insertions(+)

diff --git a/data/org.libvirt.Domain.xml b/data/org.libvirt.Domain.xml
index 5d4323b..0937cbb 100644
--- a/data/org.libvirt.Domain.xml
+++ b/data/org.libvirt.Domain.xml
@@ -167,6 +167,12 @@
       <annotation name="org.gtk.GDBus.DocString"
         value="See https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainResume"/>
     </method>
+    <method name="SetMemory">
+      <annotation name="org.gtk.GDBus.DocString"
+        value="See https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainSetMemoryFlags"/>
+      <arg name="memory" type="t" direction="in"/>
+      <arg name="flags" type="u" direction="in"/>
+    </method>
     <method name="SetVcpus">
       <annotation name="org.gtk.GDBus.DocString"
         value="See https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainSetVcpusFlags"/>
diff --git a/src/domain.c b/src/domain.c
index 85395aa..a8d3e6c 100644
--- a/src/domain.c
+++ b/src/domain.c
@@ -915,6 +915,31 @@ virtDBusDomainResume(GVariant *inArgs G_GNUC_UNUSED,
         virtDBusUtilSetLastVirtError(error);
 }
 
+static void
+virtDBusDomainSetMemory(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;
+    gulong memory;
+    guint flags;
+
+    g_variant_get(inArgs, "(tu)", &memory, &flags);
+
+    domain = virtDBusDomainGetVirDomain(connect, objectPath, error);
+    if (!domain)
+        return;
+
+    if (virDomainSetMemoryFlags(domain, memory, flags) < 0)
+        return virtDBusUtilSetLastVirtError(error);
+}
+
 static void
 virtDBusDomainSetVcpus(GVariant *inArgs,
                        GUnixFDList *inFDs G_GNUC_UNUSED,
@@ -1044,6 +1069,7 @@ static virtDBusGDBusMethodTable virtDBusDomainMethodTable[] = {
     { "Reset", virtDBusDomainReset },
     { "Resume", virtDBusDomainResume },
     { "SetVcpus", virtDBusDomainSetVcpus },
+    { "SetMemory", virtDBusDomainSetMemory },
     { "Shutdown", virtDBusDomainShutdown },
     { "Suspend", virtDBusDomainSuspend },
     { "Undefine", virtDBusDomainUndefine },
-- 
2.15.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [dbus PATCH v2 21/22] Implement SetMemory method for Domain Interface
Posted by Pavel Hrdina 7 years, 8 months ago
On Thu, Apr 12, 2018 at 04:33:00PM +0200, Katerina Koukiou wrote:
> Signed-off-by: Katerina Koukiou <kkoukiou@redhat.com>
> ---
>  data/org.libvirt.Domain.xml |  6 ++++++
>  src/domain.c                | 26 ++++++++++++++++++++++++++
>  2 files changed, 32 insertions(+)

[...]

> +static void
> +virtDBusDomainSetMemory(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;
> +    gulong memory;
> +    guint flags;
> +
> +    g_variant_get(inArgs, "(tu)", &memory, &flags);
> +
> +    domain = virtDBusDomainGetVirDomain(connect, objectPath, error);
> +    if (!domain)
> +        return;
> +
> +    if (virDomainSetMemoryFlags(domain, memory, flags) < 0)
> +        return virtDBusUtilSetLastVirtError(error);

No need to use 'return'.

Pavel
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list