Signed-off-by: Katerina Koukiou <kkoukiou(a)redhat.com>
---
data/org.libvirt.Domain.xml | 7 +++++++
src/domain.c | 41 +++++++++++++++++++++++++++++++++++++++++
2 files changed, 48 insertions(+)
diff --git a/data/org.libvirt.Domain.xml b/data/org.libvirt.Domain.xml
index 725aadc..00b4988 100644
--- a/data/org.libvirt.Domain.xml
+++ b/data/org.libvirt.Domain.xml
@@ -395,6 +395,13 @@
<arg name="cpumap" type="ab" direction="in"/>
<arg name="flags" type="u" direction="in"/>
</method>
+ <method name="PinVcpu">
+ <annotation name="org.gtk.GDBus.DocString"
+ value="See
https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainPinVcpuFlag...
+ <arg name="vcpu" type="u" direction="in"/>
+ <arg name="cpumap" type="ab" 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 eff4e34..5772e7e 100644
--- a/src/domain.c
+++ b/src/domain.c
@@ -2145,6 +2145,46 @@ virtDBusDomainPinIOThread(GVariant *inArgs,
virtDBusUtilSetLastVirtError(error);
}
+static void
+virtDBusDomainPinVcpu(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;
+ guint vcpu;
+ g_autoptr(GVariantIter) iter = NULL;
+ guint flags;
+ guint cpus;
+ guint cpumaplen;
+ g_autofree guchar *cpumap = NULL;
+ gboolean usable;
+ guint cnt = 0;
+
+ g_variant_get(inArgs, "(uabu)", &vcpu, &iter, &flags);
+
+ domain = virtDBusDomainGetVirDomain(connect, objectPath, error);
+ if (!domain)
+ return;
+
+ cpus = g_variant_iter_n_children(iter);
+ cpumaplen = VIR_CPU_MAPLEN(cpus);
+ cpumap = g_new0(guchar, cpumaplen);
+ while (g_variant_iter_loop(iter, "b", &usable)) {
+ if (usable)
+ VIR_USE_CPU(cpumap, cnt);
+ cnt++;
+ }
+
+ if (virDomainPinVcpuFlags(domain, vcpu, cpumap, cpumaplen, flags) < 0)
+ virtDBusUtilSetLastVirtError(error);
+}
+
static void
virtDBusDomainReboot(GVariant *inArgs,
GUnixFDList *inFDs G_GNUC_UNUSED,
@@ -2878,6 +2918,7 @@ static virtDBusGDBusMethodTable virtDBusDomainMethodTable[] = {
{ "MigrateStartPostCopy", virtDBusDomainMigrateStartPostCopy },
{ "PinEmulator", virtDBusDomainPinEmulator },
{ "PinIOThread", virtDBusDomainPinIOThread },
+ { "PinVcpu", virtDBusDomainPinVcpu },
{ "Reboot", virtDBusDomainReboot },
{ "Rename", virtDBusDomainRename },
{ "Reset", virtDBusDomainReset },
--
2.15.0