diff --git a/tests/__init__.py b/tests/__init__.py index c1938941..1e7cd36d 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -24,7 +24,7 @@ from tests import utils # Access to protected member, needed to unittest stuff # Force certain helpers to return consistent values -virtinst.util.is_blktap_capable = lambda: False +virtinst.util.is_blktap_capable = lambda ignore: False virtinst.util.default_bridge = lambda ignore1: ["bridge", "eth0"] # Setup logging diff --git a/tests/xmlconfig.py b/tests/xmlconfig.py index f08370c7..848cea6b 100644 --- a/tests/xmlconfig.py +++ b/tests/xmlconfig.py @@ -139,7 +139,7 @@ class TestXMLConfig(unittest.TestCase): def testBootParavirtDiskFileBlktapCapable(self): oldblktap = virtinst.util.is_blktap_capable try: - virtinst.util.is_blktap_capable = lambda: True + virtinst.util.is_blktap_capable = lambda ignore: True g = utils.get_basic_paravirt_guest() g.add_device(utils.get_filedisk()) self._compare(g, "boot-paravirt-disk-drv-tap", False) diff --git a/virtManager/addhardware.py b/virtManager/addhardware.py index e2f519ab..e9c45fee 100644 --- a/virtManager/addhardware.py +++ b/virtManager/addhardware.py @@ -1336,7 +1336,7 @@ class vmmAddHardware(vmmGObjectUI): if (disk.type == virtinst.VirtualDisk.TYPE_FILE and not self.vm.is_hvm() and - virtinst.util.is_blktap_capable()): + virtinst.util.is_blktap_capable(self.conn.get_backend())): disk.driver_name = virtinst.VirtualDisk.DRIVER_TAP except Exception, e: diff --git a/virtinst/Guest.py b/virtinst/Guest.py index 4a013bb5..45d5fad2 100644 --- a/virtinst/Guest.py +++ b/virtinst/Guest.py @@ -1309,8 +1309,8 @@ class Guest(XMLBuilderDomain.XMLBuilderDomain): # Default file backed PV guests to tap driver for d in devlist_func(VirtualDevice.VIRTUAL_DEV_DISK): if (d.type == VirtualDisk.TYPE_FILE - and util.is_blktap_capable() - and d.driver_name is None): + and d.driver_name is None + and util.is_blktap_capable(self.conn)): d.driver_name = VirtualDisk.DRIVER_TAP for d in devlist_func(VirtualDevice.VIRTUAL_DEV_INPUT): diff --git a/virtinst/util.py b/virtinst/util.py index 4a70b84e..522ff3eb 100644 --- a/virtinst/util.py +++ b/virtinst/util.py @@ -393,7 +393,11 @@ def default_connection(): return None -def is_blktap_capable(): +def is_blktap_capable(conn): + # Ideally we would get this from libvirt capabilities XML + if conn.is_remote(): + return False + f = open("/proc/modules") lines = f.readlines() f.close()