Move testing of [Get,Set]Vcpus to seperate test. Signed-off-by: Katerina Koukiou <kkoukiou@xxxxxxxxxx> --- data/org.libvirt.Domain.xml | 6 ++++++ src/domain.c | 26 ++++++++++++++++++++++++++ test/test_domain.py | 9 +++++++-- 3 files changed, 39 insertions(+), 2 deletions(-) diff --git a/data/org.libvirt.Domain.xml b/data/org.libvirt.Domain.xml index f300b59..41814c7 100644 --- a/data/org.libvirt.Domain.xml +++ b/data/org.libvirt.Domain.xml @@ -138,6 +138,12 @@ <annotation name="org.gtk.GDBus.DocString" value="See https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainResume"/> </method> + <method name="SetVcpus"> + <annotation name="org.gtk.GDBus.DocString" + value="See https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainSetVcpusFlags"/> + <arg name="vcpus" type="u" direction="in"/> + <arg name="flags" type="u" direction="in"/> + </method> <method name="Shutdown"> <annotation name="org.gtk.GDBus.DocString" value="See https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainShutdownFlags"/> diff --git a/src/domain.c b/src/domain.c index 5f83b33..9b8779b 100644 --- a/src/domain.c +++ b/src/domain.c @@ -781,6 +781,31 @@ virtDBusDomainResume(GVariant *inArgs G_GNUC_UNUSED, virtDBusUtilSetLastVirtError(error); } +static void +virtDBusDomainSetVcpus(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 vcpus; + guint flags; + + g_variant_get(inArgs, "(uu)", &vcpus, &flags); + + domain = virtDBusDomainGetVirDomain(connect, objectPath, error); + if (!domain) + return; + + if (virDomainSetVcpusFlags(domain, vcpus, flags) < 0) + virtDBusUtilSetLastVirtError(error); +} + static void virtDBusDomainShutdown(GVariant *inArgs, GUnixFDList *inFDs G_GNUC_UNUSED, @@ -879,6 +904,7 @@ static virtDBusGDBusMethodTable virtDBusDomainMethodTable[] = { { "Reboot", virtDBusDomainReboot }, { "Reset", virtDBusDomainReset }, { "Resume", virtDBusDomainResume }, + { "SetVcpus", virtDBusDomainSetVcpus }, { "Shutdown", virtDBusDomainShutdown }, { "Suspend", virtDBusDomainSuspend }, { "Undefine", virtDBusDomainUndefine }, diff --git a/test/test_domain.py b/test/test_domain.py index 45a99f9..31e09bf 100755 --- a/test/test_domain.py +++ b/test/test_domain.py @@ -27,8 +27,6 @@ class TestDomain(libvirttest.BaseTestClass): xml = domain.GetXMLDesc(0) assert isinstance(xml, dbus.String) - vcpus = domain.GetVcpus(0) - assert isinstance(vcpus, dbus.UInt32) domain.Reboot(0) domain.Shutdown(0) @@ -123,5 +121,12 @@ class TestDomain(libvirttest.BaseTestClass): self.main_loop() + def test_domain_vcpus(self): + obj, domain = self.domain() + vcpus_expected = 2 + domain.SetVcpus(vcpus_expected, 0) + assert domain.GetVcpus(0) == dbus.Int32(vcpus_expected) + + if __name__ == '__main__': libvirttest.run() -- 2.15.0 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list