Commit 26d7b995 authored by Anya Harter's avatar Anya Harter Committed by Katerina Koukiou

Implement InterfaceDefineXML method for Connect Interface

Signed-off-by: 's avatarAnya Harter <aharter@redhat.com>
Reviewed-by: 's avatarJán Tomko <jtomko@redhat.com>
parent 692d5e60
......@@ -148,6 +148,13 @@
<arg name="flags" type="u" direction="in"/>
<arg name="sysinfo" type="s" direction="out"/>
</method>
<method name="InterfaceDefineXML">
<annotation name="org.gtk.GDBus.DocString"
value="See https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceDefineXML"/>
<arg name="xml" type="s" direction="in"/>
<arg name="flags" type="u" direction="in"/>
<arg name="interface" type="o" direction="out"/>
</method>
<method name="ListDomains">
<annotation name="org.gtk.GDBus.DocString"
value="See https://libvirt.org/html/libvirt-libvirt-domain.html#virConnectListAllDomains"/>
......
......@@ -735,6 +735,35 @@ virtDBusConnectGetSysinfo(GVariant *inArgs,
*outArgs = g_variant_new("(s)", sysinfo);
}
static void
virtDBusConnectInterfaceDefineXML(GVariant *inArgs,
GUnixFDList *inFDs G_GNUC_UNUSED,
const gchar *objectPath G_GNUC_UNUSED,
gpointer userData,
GVariant **outArgs,
GUnixFDList **outFDs G_GNUC_UNUSED,
GError **error)
{
virtDBusConnect *connect = userData;
g_autoptr(virInterface) interface = NULL;
g_autofree gchar *path = NULL;
const gchar *xml;
guint flags;
g_variant_get(inArgs, "(&su)", &xml, &flags);
if (!virtDBusConnectOpen(connect, error))
return;
interface = virInterfaceDefineXML(connect->connection, xml, flags);
if (!interface)
return virtDBusUtilSetLastVirtError(error);
path = virtDBusUtilBusPathForVirInterface(interface, connect->interfacePath);
*outArgs = g_variant_new("(o)", path);
}
static void
virtDBusConnectListDomains(GVariant *inArgs,
GUnixFDList *inFDs G_GNUC_UNUSED,
......@@ -1766,6 +1795,7 @@ static virtDBusGDBusMethodTable virtDBusConnectMethodTable[] = {
{ "GetCPUModelNames", virtDBusConnectGetCPUModelNames },
{ "GetDomainCapabilities", virtDBusConnectGetDomainCapabilities },
{ "GetSysinfo", virtDBusConnectGetSysinfo },
{ "InterfaceDefineXML", virtDBusConnectInterfaceDefineXML },
{ "ListDomains", virtDBusConnectListDomains },
{ "ListNetworks", virtDBusConnectListNetworks },
{ "ListNodeDevices", virtDBusConnectListNodeDevices },
......
......@@ -84,6 +84,10 @@ class TestConnect(libvirttest.BaseTestClass):
sysinfo = self.connect.GetSysinfo(0)
assert isinstance(sysinfo, dbus.String)
def test_connect_interface_define_xml(self):
path = self.connect.InterfaceDefineXML(xmldata.minimal_interface_xml, 0)
assert isinstance(path, dbus.ObjectPath)
def test_connect_list_networks(self):
networks = self.connect.ListNetworks(0)
assert isinstance(networks, dbus.Array)
......
......@@ -12,6 +12,18 @@ minimal_domain_xml = '''
</domain>
'''
minimal_interface_xml = '''
<interface type='ethernet' name='test-iface'>
<start mode='onboot'/>
<mac address='11:22:33:44:55:66'/>
<mtu size='1492'/>
<protocol family='ipv4'>
<ip address='192.168.15.5' prefix='24'/>
<route gateway='192.168.15.1'/>
</protocol>
</interface>
'''
minimal_network_xml = '''
<network>
<name>bar</name>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment