MCPcopy Create free account
hub / github.com/F-Stack/f-stack / unbind_one

Function unbind_one

dpdk/usertools/dpdk-devbind.py:325–347  ·  view source on GitHub ↗

Unbind the device identified by "dev_id" from its current driver

(dev_id, force)

Source from the content-addressed store, hash-verified

323
324
325def unbind_one(dev_id, force):
326 '''Unbind the device identified by "dev_id" from its current driver'''
327 dev = devices[dev_id]
328 if not has_driver(dev_id):
329 print("Notice: %s %s %s is not currently managed by any driver" %
330 (dev["Slot"], dev["Device_str"], dev["Interface"]), file=sys.stderr)
331 return
332
333 # prevent us disconnecting ourselves
334 if dev["Ssh_if"] and not force:
335 print("Warning: routing table indicates that interface %s is active. "
336 "Skipping unbind" % dev_id, file=sys.stderr)
337 return
338
339 # write to /sys to unbind
340 filename = "/sys/bus/pci/drivers/%s/unbind" % dev["Driver_str"]
341 try:
342 f = open(filename, "a")
343 except OSError as err:
344 sys.exit("Error: unbind failed for %s - Cannot open %s: %s" %
345 (dev_id, filename, err))
346 f.write(dev_id)
347 f.close()
348
349
350def bind_one(dev_id, driver, force):

Callers 3

bind_oneFunction · 0.85
unbind_allFunction · 0.85
bind_allFunction · 0.85

Calls 4

has_driverFunction · 0.85
printFunction · 0.50
writeMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected