Commit fe0d864b authored by Katerina Koukiou's avatar Katerina Koukiou

Implement NodeDeviceCreateXML method for Connect Interface

Signed-off-by: 's avatarKaterina Koukiou <kkoukiou@redhat.com>
Reviewed-by: Pavel Hrdina's avatarPavel Hrdina <phrdina@redhat.com>
parent b21275a0
......@@ -208,6 +208,13 @@
<arg name="uuid" type="s" direction="in"/>
<arg name="network" type="o" direction="out"/>
</method>
<method name="NodeDeviceCreateXML">
<annotation name="org.gtk.GDBus.DocString"
value="See https://libvirt.org/html/libvirt-libvirt-nodedev.html#virNodeDeviceCreateXML"/>
<arg name="xml" type="s" direction="in"/>
<arg name="flags" type="u" direction="in"/>
<arg name="dev" type="o" direction="out"/>
</method>
<method name="NWFilterDefineXML">
<annotation name="org.gtk.GDBus.DocString"
value="See https://libvirt.org/html/libvirt-libvirt-nwfilter.html#virNWFilterDefineXML"/>
......
......@@ -1069,6 +1069,35 @@ virtDBusConnectNetworkLookupByUUID(GVariant *inArgs,
*outArgs = g_variant_new("(o)", path);
}
static void
virtDBusConnectNodeDeviceCreateXML(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(virNodeDevice) dev = NULL;
g_autofree gchar *path = NULL;
gchar *xml;
guint flags;
g_variant_get(inArgs, "(&su)", &xml, &flags);
if (!virtDBusConnectOpen(connect, error))
return;
dev = virNodeDeviceCreateXML(connect->connection, xml, flags);
if (!dev)
return virtDBusUtilSetLastVirtError(error);
path = virtDBusUtilBusPathForVirNodeDevice(dev, connect->nodeDevPath);
*outArgs = g_variant_new("(o)", path);
}
static void
virtDBusConnectNWFilterDefineXML(GVariant *inArgs,
GUnixFDList *inFDs G_GNUC_UNUSED,
......@@ -1687,6 +1716,7 @@ static virtDBusGDBusMethodTable virtDBusConnectMethodTable[] = {
{ "NetworkDefineXML", virtDBusConnectNetworkDefineXML },
{ "NetworkLookupByName", virtDBusConnectNetworkLookupByName },
{ "NetworkLookupByUUID", virtDBusConnectNetworkLookupByUUID },
{ "NodeDeviceCreateXML", virtDBusConnectNodeDeviceCreateXML },
{ "NWFilterDefineXML", virtDBusConnectNWFilterDefineXML },
{ "NWFilterLookupByName", virtDBusConnectNWFilterLookupByName },
{ "NWFilterLookupByUUID", virtDBusConnectNWFilterLookupByUUID },
......
......@@ -217,6 +217,9 @@ class NetworkEvent(IntEnum):
STARTED = 2
STOPPED = 3
class NodeDeviceEvent(IntEnum):
CREATED = 0
DELETED = 1
class StoragePoolBuildFlags(IntEnum):
NEW = 0
......
......@@ -155,6 +155,20 @@ class TestConnect(libvirttest.BaseTestClass):
path = getattr(self.connect, lookup_method_name)(prop)
assert original_path == path
def test_connect_node_device_create_xml(self):
def node_device_created(path, event, _detail):
if event != libvirttest.NodeDeviceEvent.CREATED:
return
assert isinstance(path, dbus.ObjectPath)
self.loop.quit()
self.connect.connect_to_signal('NodeDeviceEvent', node_device_created)
path = self.connect.NodeDeviceCreateXML(xmldata.minimal_node_device_xml, 0)
assert isinstance(path, dbus.ObjectPath)
self.main_loop()
def test_connect_node_get_cpu_stats(self):
stats = self.connect.NodeGetCPUStats(0, 0)
assert isinstance(stats, dbus.Dictionary)
......
......@@ -26,6 +26,22 @@ minimal_network_xml = '''
</network>
'''
minimal_node_device_xml = '''
<device>
<name>scsi_host22</name>
<parent>scsi_host2</parent>
<capability type='scsi_host'>
<host>22</host>
<unique_id>22</unique_id>
<capability type='fc_host'>
<wwnn>2000000098765432</wwnn>
<wwpn>1000000098765432</wwpn>
<fabric_wwn>2000000098769876</fabric_wwn>
</capability>
</capability>
</device>
'''
minimal_storage_pool_xml = '''
<pool type='dir'>
<name>foo</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