def attachNBD(cow, flags=''):
 cow = abspath(cow)
 log('* Checking for unused /dev/nbdX device ')
 for i in range(0, 63):
  nbd = ('/dev/nbd%d' % i)
  if (call(['pgrep', '-f', nbd]) == 0):
   continue
  srun('modprobe nbd max-part=64')
  srun(('qemu-nbd %s -c %s %s' % (flags, nbd, cow)))
  print ()
  return nbd
 raise Exception('Error: could not find unused /dev/nbdX device')

def attachNBD ( cow , flags = '' ) : cow = abspath ( cow ) log ( '* Checking for unused /dev/nbdX device ' ) for i in range ( 0 , 63 ) : nbd = ( '/dev/nbd%d' % i ) if ( call ( [ 'pgrep' , '-f' , nbd ] ) == 0 ) : continue srun ( 'modprobe nbd max-part=64' ) srun ( ( 'qemu-nbd %s -c %s %s' % ( flags , nbd , cow ) ) ) print ( ) return nbd raise Exception ( 'Error: could not find unused /dev/nbdX device' )
attempt to attach a cow disk image and return its nbd device flags: additional flags for qemu-nbd .