[libvirt] [dbus PATCH 18/25] Implement PinEmulator method for Domain Interface

Katerina Koukiou posted 25 patches 7 years, 8 months ago
There is a newer version of this series
[libvirt] [dbus PATCH 18/25] Implement PinEmulator 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                | 34 ++++++++++++++++++++++++++++++++++
 2 files changed, 40 insertions(+)

diff --git a/data/org.libvirt.Domain.xml b/data/org.libvirt.Domain.xml
index f2ef3dd..97c5471 100644
--- a/data/org.libvirt.Domain.xml
+++ b/data/org.libvirt.Domain.xml
@@ -268,6 +268,12 @@
         value="See https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainMigrateStartPostCopy"/>
       <arg name="flags" type="u" direction="in"/>
     </method>
+    <method name="PinEmulator">
+      <annotation name="org.gtk.GDBus.DocString"
+        value="See https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainPinEmulator"/>
+      <arg name="cpumap" type="ay" direction="in"/>
+      <arg name="flags" type="u" direction="in"/>
+    </method>
     <method name="Reboot">
       <annotation name="org.gtk.GDBus.DocString"
         value="See https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainReboot"/>
diff --git a/src/domain.c b/src/domain.c
index f50043d..92799ac 100644
--- a/src/domain.c
+++ b/src/domain.c
@@ -1363,6 +1363,39 @@ virtDBusDomainMigrateStartPostCopy(GVariant *inArgs,
         virtDBusUtilSetLastVirtError(error);
 }
 
+static void
+virtDBusDomainPinEmulator(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;
+    g_autofree const guchar *cpumap = NULL;
+    gsize maplen;
+    guint flags;
+    GVariant *v;
+
+    v = g_variant_get_child_value(inArgs, 0);
+    cpumap = g_variant_get_fixed_array(v, &maplen, sizeof(guchar));
+    g_variant_unref(v);
+
+    v = g_variant_get_child_value(inArgs, 1);
+    flags = g_variant_get_uint32(v);
+    g_variant_unref(v);
+
+    domain = virtDBusDomainGetVirDomain(connect, objectPath, error);
+    if (!domain)
+        return;
+
+    if (virDomainPinEmulator(domain, (guchar *)cpumap, maplen, flags) < 0)
+        virtDBusUtilSetLastVirtError(error);
+}
+
 static void
 virtDBusDomainReboot(GVariant *inArgs,
                      GUnixFDList *inFDs G_GNUC_UNUSED,
@@ -1643,6 +1676,7 @@ static virtDBusGDBusMethodTable virtDBusDomainMethodTable[] = {
     { "MigrateSetMaxDowntime", virtDBusDomainMigrateSetMaxDowntime },
     { "MigrateSetMaxSpeed", virtDBusDomainMigrateSetMaxSpeed },
     { "MigrateStartPostCopy", virtDBusDomainMigrateStartPostCopy },
+    { "PinEmulator", virtDBusDomainPinEmulator },
     { "Reboot", virtDBusDomainReboot },
     { "Reset", virtDBusDomainReset },
     { "Resume", virtDBusDomainResume },
-- 
2.15.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [dbus PATCH 18/25] Implement PinEmulator method for Domain Interface
Posted by Pavel Hrdina 7 years, 8 months ago
On Tue, Apr 17, 2018 at 02:04:37PM +0200, Katerina Koukiou wrote:
> Signed-off-by: Katerina Koukiou <kkoukiou@redhat.com>
> ---
>  data/org.libvirt.Domain.xml |  6 ++++++
>  src/domain.c                | 34 ++++++++++++++++++++++++++++++++++
>  2 files changed, 40 insertions(+)
> 
> diff --git a/data/org.libvirt.Domain.xml b/data/org.libvirt.Domain.xml
> index f2ef3dd..97c5471 100644
> --- a/data/org.libvirt.Domain.xml
> +++ b/data/org.libvirt.Domain.xml
> @@ -268,6 +268,12 @@
>          value="See https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainMigrateStartPostCopy"/>
>        <arg name="flags" type="u" direction="in"/>
>      </method>
> +    <method name="PinEmulator">
> +      <annotation name="org.gtk.GDBus.DocString"
> +        value="See https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainPinEmulator"/>
> +      <arg name="cpumap" type="ay" direction="in"/>

We need to figure out a better way how to represent the CPU map in
libvirt-dbus.  IMHO using an array of unsigned char is not the best
from for D-Bus.

There are two possible forms, using the string representation as we
have in virsh, so for example "0,3-7,^5" which is 10011011.

The second form is the one that libvirt-python uses, a tuple of boolean
values, which in case of D-Bus would be represented as array of boolean
values.

The first form is better suited for humans so I guess we should go with
the second form in D-Bus.

Pavel
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [dbus PATCH 18/25] Implement PinEmulator method for Domain Interface
Posted by Daniel P. Berrangé 7 years, 8 months ago
On Wed, Apr 18, 2018 at 03:03:20PM +0200, Pavel Hrdina wrote:
> On Tue, Apr 17, 2018 at 02:04:37PM +0200, Katerina Koukiou wrote:
> > Signed-off-by: Katerina Koukiou <kkoukiou@redhat.com>
> > ---
> >  data/org.libvirt.Domain.xml |  6 ++++++
> >  src/domain.c                | 34 ++++++++++++++++++++++++++++++++++
> >  2 files changed, 40 insertions(+)
> > 
> > diff --git a/data/org.libvirt.Domain.xml b/data/org.libvirt.Domain.xml
> > index f2ef3dd..97c5471 100644
> > --- a/data/org.libvirt.Domain.xml
> > +++ b/data/org.libvirt.Domain.xml
> > @@ -268,6 +268,12 @@
> >          value="See https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainMigrateStartPostCopy"/>
> >        <arg name="flags" type="u" direction="in"/>
> >      </method>
> > +    <method name="PinEmulator">
> > +      <annotation name="org.gtk.GDBus.DocString"
> > +        value="See https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainPinEmulator"/>
> > +      <arg name="cpumap" type="ay" direction="in"/>
> 
> We need to figure out a better way how to represent the CPU map in
> libvirt-dbus.  IMHO using an array of unsigned char is not the best
> from for D-Bus.
> 
> There are two possible forms, using the string representation as we
> have in virsh, so for example "0,3-7,^5" which is 10011011.
> 
> The second form is the one that libvirt-python uses, a tuple of boolean
> values, which in case of D-Bus would be represented as array of boolean
> values.

array of boolean is better than array of char in that it is explicitly
typed. It is inefficient though - each boolean value takes up 32-bit on
the wire !

> The first form is better suited for humans so I guess we should go with
> the second form in D-Bus.

Ultimately you should think about how a dbus client will consume the
data. If you use  array of boolean, that all the DBus clients will
map that into native boolean types which are easy to acess for apps.

If you use the string syntax, then every application has to write
parsing & formatting code for this syntax.

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [dbus PATCH 18/25] Implement PinEmulator method for Domain Interface
Posted by Pavel Hrdina 7 years, 8 months ago
On Wed, Apr 18, 2018 at 02:41:19PM +0100, Daniel P. Berrangé wrote:
> On Wed, Apr 18, 2018 at 03:03:20PM +0200, Pavel Hrdina wrote:
> > On Tue, Apr 17, 2018 at 02:04:37PM +0200, Katerina Koukiou wrote:
> > > Signed-off-by: Katerina Koukiou <kkoukiou@redhat.com>
> > > ---
> > >  data/org.libvirt.Domain.xml |  6 ++++++
> > >  src/domain.c                | 34 ++++++++++++++++++++++++++++++++++
> > >  2 files changed, 40 insertions(+)
> > > 
> > > diff --git a/data/org.libvirt.Domain.xml b/data/org.libvirt.Domain.xml
> > > index f2ef3dd..97c5471 100644
> > > --- a/data/org.libvirt.Domain.xml
> > > +++ b/data/org.libvirt.Domain.xml
> > > @@ -268,6 +268,12 @@
> > >          value="See https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainMigrateStartPostCopy"/>
> > >        <arg name="flags" type="u" direction="in"/>
> > >      </method>
> > > +    <method name="PinEmulator">
> > > +      <annotation name="org.gtk.GDBus.DocString"
> > > +        value="See https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainPinEmulator"/>
> > > +      <arg name="cpumap" type="ay" direction="in"/>
> > 
> > We need to figure out a better way how to represent the CPU map in
> > libvirt-dbus.  IMHO using an array of unsigned char is not the best
> > from for D-Bus.
> > 
> > There are two possible forms, using the string representation as we
> > have in virsh, so for example "0,3-7,^5" which is 10011011.
> > 
> > The second form is the one that libvirt-python uses, a tuple of boolean
> > values, which in case of D-Bus would be represented as array of boolean
> > values.
> 
> array of boolean is better than array of char in that it is explicitly
> typed. It is inefficient though - each boolean value takes up 32-bit on
> the wire !
> 
> > The first form is better suited for humans so I guess we should go with
> > the second form in D-Bus.
> 
> Ultimately you should think about how a dbus client will consume the
> data. If you use  array of boolean, that all the DBus clients will
> map that into native boolean types which are easy to acess for apps.
> 
> If you use the string syntax, then every application has to write
> parsing & formatting code for this syntax.

I completely agree, that's why I suggested using an array of boolean.

Thanks,

Pavel
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [dbus PATCH 18/25] Implement PinEmulator method for Domain Interface
Posted by Daniel P. Berrangé 7 years, 8 months ago
On Wed, Apr 18, 2018 at 03:44:51PM +0200, Pavel Hrdina wrote:
> On Wed, Apr 18, 2018 at 02:41:19PM +0100, Daniel P. Berrangé wrote:
> > On Wed, Apr 18, 2018 at 03:03:20PM +0200, Pavel Hrdina wrote:
> > > On Tue, Apr 17, 2018 at 02:04:37PM +0200, Katerina Koukiou wrote:
> > > > Signed-off-by: Katerina Koukiou <kkoukiou@redhat.com>
> > > > ---
> > > >  data/org.libvirt.Domain.xml |  6 ++++++
> > > >  src/domain.c                | 34 ++++++++++++++++++++++++++++++++++
> > > >  2 files changed, 40 insertions(+)
> > > > 
> > > > diff --git a/data/org.libvirt.Domain.xml b/data/org.libvirt.Domain.xml
> > > > index f2ef3dd..97c5471 100644
> > > > --- a/data/org.libvirt.Domain.xml
> > > > +++ b/data/org.libvirt.Domain.xml
> > > > @@ -268,6 +268,12 @@
> > > >          value="See https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainMigrateStartPostCopy"/>
> > > >        <arg name="flags" type="u" direction="in"/>
> > > >      </method>
> > > > +    <method name="PinEmulator">
> > > > +      <annotation name="org.gtk.GDBus.DocString"
> > > > +        value="See https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainPinEmulator"/>
> > > > +      <arg name="cpumap" type="ay" direction="in"/>
> > > 
> > > We need to figure out a better way how to represent the CPU map in
> > > libvirt-dbus.  IMHO using an array of unsigned char is not the best
> > > from for D-Bus.
> > > 
> > > There are two possible forms, using the string representation as we
> > > have in virsh, so for example "0,3-7,^5" which is 10011011.
> > > 
> > > The second form is the one that libvirt-python uses, a tuple of boolean
> > > values, which in case of D-Bus would be represented as array of boolean
> > > values.
> > 
> > array of boolean is better than array of char in that it is explicitly
> > typed. It is inefficient though - each boolean value takes up 32-bit on
> > the wire !
> > 
> > > The first form is better suited for humans so I guess we should go with
> > > the second form in D-Bus.
> > 
> > Ultimately you should think about how a dbus client will consume the
> > data. If you use  array of boolean, that all the DBus clients will
> > map that into native boolean types which are easy to acess for apps.
> > 
> > If you use the string syntax, then every application has to write
> > parsing & formatting code for this syntax.
> 
> I completely agree, that's why I suggested using an array of boolean.

Yeah, my gut feeling is that array of boolean is best despite the
wire inefficience.

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

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