Changeset 449 for trunk/packages/sipb-xen-guest-installer
- Timestamp:
- Apr 22, 2008, 4:15:57 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/packages/sipb-xen-guest-installer/files/usr/sbin/sipb-xen-lvcopy
r405 r449 9 9 10 10 def losetup(source, offset=0): 11 # XXX we avoid colliding with other instances of ourself, 12 # but when it comes to other loop-device users we just 13 # pick a range things don't seem to use and hope... 14 lockfilename = '/tmp/losetup.lock' 15 os.close(os.open(lockfilename, os.O_CREAT+os.O_EXCL)) #lock 16 try: 17 loopdevice = None 18 for i in xrange(32,60): # totally arbitrary, just looks to be unused on black-mesa 19 filename = '/dev/loop%d'%i 20 if 0 == len(file(filename).read(1)): 21 loopdevice = filename # it's empty 22 break 23 if loopdevice is not None: 24 call(['losetup', '-o', str(offset), loopdevice, source]) 25 else: 26 raise RuntimeError('out of loop devices for copying VM image: too many at once?') 27 finally: 28 os.unlink(lockfilename) #unlock 29 return loopdevice 30 # XX this means we can duplicate 28 at once. Since it takes around 30s, 31 # this seems like an adequate capacity. 11 p = Popen(['sipb-xen-losetup', source, str(offset)], stdout=PIPE) 12 return p.communicate()[0].strip() 32 13 33 14 def frob_copy_in_vm(target, *args):
Note: See TracChangeset
for help on using the changeset viewer.