commit 45aaf962a338ccc13825c0a8d455a428b8ca2495 Author: Ondrej Lichtner olichtne@redhat.com Date: Fri Nov 22 14:37:08 2013 +0100
VirtualInterface: add support for setting device driver
Using the libvirt API binding allows us to create dynamic devices with specific device drivers easily. This commit adds that functionality.
To specify a device driver you need to set a parameter of your dynamically created device in your recipe like this: <eth ...> ... <params> <param name="driver" value="e1000"/> </params> ... </eth>
Keep in mind that this will be used as a matching restriction for matching of physical devices, and when matching virtual machines the value needs to be supported by libvirt. An invalid value will result in an exception being raised.
Signed-off-by: Ondrej Lichtner olichtne@redhat.com Signed-off-by: Jiri Pirko jiri@resnulli.us
lnst/Controller/Machine.py | 9 ++++++++- lnst/Controller/SlavePool.py | 8 +++++--- 2 files changed, 13 insertions(+), 4 deletions(-) --- diff --git a/lnst/Controller/Machine.py b/lnst/Controller/Machine.py index 8ff372f..1c77f38 100644 --- a/lnst/Controller/Machine.py +++ b/lnst/Controller/Machine.py @@ -499,6 +499,13 @@ class VirtualInterface(Interface): """ def __init__(self, machine, if_id, if_type): super(VirtualInterface, self).__init__(machine, if_id, if_type) + self._driver = "rtl8139" + + def set_driver(self, driver): + self._driver = driver + + def get_driver(self): + return self._driver
def get_orig_hwaddr(self): if not self._orig_hwaddr: @@ -537,7 +544,7 @@ class VirtualInterface(Interface): self.get_id(), self._hwaddr, self._machine.get_id())
self._orig_hwaddr = self._hwaddr - domain_ctl.attach_interface(self._hwaddr, net_name) + domain_ctl.attach_interface(self._hwaddr, net_name, self._driver)
# The sleep here is necessary, because udev sometimes renames the diff --git a/lnst/Controller/SlavePool.py b/lnst/Controller/SlavePool.py index 7266eaf..00ee4b8 100644 --- a/lnst/Controller/SlavePool.py +++ b/lnst/Controller/SlavePool.py @@ -307,6 +307,8 @@ class SlavePool: iface.set_network(if_data["network"]) if "hwaddr" in if_data["params"]: iface.set_hwaddr(if_data["params"]["hwaddr"]) + if "driver" in if_data["params"]: + iface.set_driver(if_data["params"]["driver"])
return machine
@@ -673,10 +675,10 @@ class SetupMapper: for if_id, interface in m["interfaces"].iteritems(): if "params" in interface: for name, val in interface["params"].iteritems(): - if name != "hwaddr": + if name not in ["hwaddr", "driver"]: msg = "Dynamically created interfaces "\ - "only support the 'hwaddr' option. "\ - "'%s=%s' found on machine '%s' "\ + "only support the 'hwaddr' and 'driver' "\ + "option. '%s=%s' found on machine '%s' "\ "interface '%s'" % (name, val, m_id, if_id) raise MapperError(msg)
lnst-developers@lists.fedorahosted.org