ia64/xen-unstable
changeset 1090:e40ed5d51284
bitkeeper revision 1.724 (402ca374dzl4iEPzK71tvTWpDEYxgw)
XenoUtil.py, xc_dom_control.py, VBD-HOWTO.txt:
Merge toolset changes from v1.2.
XenoUtil.py, xc_dom_control.py, VBD-HOWTO.txt:
Merge toolset changes from v1.2.
author | kaf24@scramble.cl.cam.ac.uk |
---|---|
date | Fri Feb 13 10:14:12 2004 +0000 (2004-02-13) |
parents | b2a4ceebb019 |
children | 38210918dfa7 |
files | docs/VBD-HOWTO.txt tools/examples/xc_dom_control.py tools/xc/py/XenoUtil.py |
line diff
1.1 --- a/docs/VBD-HOWTO.txt Fri Feb 13 09:47:30 2004 +0000 1.2 +++ b/docs/VBD-HOWTO.txt Fri Feb 13 10:14:12 2004 +0000 1.3 @@ -204,6 +204,26 @@ just before deallocation (automated supp 1.4 date). 1.5 1.6 1.7 +Side note: The xvd* devices 1.8 +--------------------------- 1.9 + 1.10 +The examples in this document make frequent use of the xvd* device nodes for 1.11 +representing virtual block devices. It is not a requirement to use these with 1.12 +Xen, since VBDs can be mapped to any IDE or SCSI device node in the system. 1.13 +Changing the the references to xvd* nodes in the examples below to refer to 1.14 +some unused hd* or sd* node would also be valid. 1.15 + 1.16 +They can be useful when accessing VBDs from dom0, since binding VBDs to xvd* 1.17 +devices under will avoid clashes with real IDE or SCSI drives. 1.18 + 1.19 +There is a shell script provided in tools/misc/xen-mkdevnodes to create these 1.20 +nodes. Specify on the command line the directory that the nodes should be 1.21 +placed under (e.g. /dev): 1.22 + 1.23 +> cd {root of Xen source tree}/tools/misc/ 1.24 +> ./xen-mkdevnodes /dev 1.25 + 1.26 + 1.27 Dynamically Registering VBDs 1.28 ---------------------------- 1.29 1.30 @@ -306,7 +326,7 @@ vbd_list variable, for instance using th 1.31 (Note that you need to use quotes here, since config files are really small 1.32 Python scripts.) 1.33 1.34 -To specify the mapping on the commandline, you'd use the -d switch and supply 1.35 +To specify the mapping on the command line, you'd use the -d switch and supply 1.36 the triple as the argument, e.g.: 1.37 1.38 > xc_dom_create.py [other arguments] -d phy:hdc,/dev/whatever,r
2.1 --- a/tools/examples/xc_dom_control.py Fri Feb 13 09:47:30 2004 +0000 2.2 +++ b/tools/examples/xc_dom_control.py Fri Feb 13 10:14:12 2004 +0000 2.3 @@ -229,6 +229,10 @@ elif cmd == 'vbd_add': 2.4 2.5 segments = XenoUtil.lookup_disk_uname(uname) 2.6 2.7 + if not segments: 2.8 + print "Lookup Failed" 2.9 + sys.exit(1) 2.10 + 2.11 if XenoUtil.vd_extents_validate(segments,writeable) < 0: 2.12 print "That mapping is too unsafe for the current VBD expertise level" 2.13 sys.exit(1)
3.1 --- a/tools/xc/py/XenoUtil.py Fri Feb 13 09:47:30 2004 +0000 3.2 +++ b/tools/xc/py/XenoUtil.py Fri Feb 13 10:14:12 2004 +0000 3.3 @@ -314,7 +314,7 @@ def vd_create(size_mb, expiry): 3.4 FROM vdisks NATURAL JOIN vdisk_extents 3.5 NATURAL JOIN vdisk_part 3.6 WHERE expires AND expiry_time <= datetime('now') 3.7 - ORDER BY expiry_time asc, vdisk_extent_no desc 3.8 + ORDER BY expiry_time ASC, vdisk_extent_no DESC 3.9 """) # aims to reuse the last extents 3.10 # from the longest-expired disks first 3.11 3.12 @@ -389,7 +389,7 @@ def vd_lookup(id): 3.13 3.14 if not count: 3.15 cx.close() 3.16 - return -1 3.17 + return None 3.18 3.19 cu.execute("SELECT size from vdisks WHERE vdisk_id = " + id) 3.20 real_size, = cu.fetchone() 3.21 @@ -410,6 +410,7 @@ def vd_lookup(id): 3.22 NATURAL JOIN vdisk_part 3.23 3.24 WHERE vdisk_extents.vdisk_id = """ + id 3.25 + + " ORDER BY vdisk_extents.vdisk_extent_no ASC" 3.26 ) 3.27 3.28 extent_tuples = cu.fetchall() 3.29 @@ -509,7 +510,7 @@ def vd_enlarge(vdisk_id, extra_size_mb): 3.30 FROM vdisks NATURAL JOIN vdisk_extents 3.31 NATURAL JOIN vdisk_part 3.32 WHERE expires AND expiry_time <= datetime('now') 3.33 - ORDER BY expiry_time asc, vdisk_extent_no desc 3.34 + ORDER BY expiry_time ASC, vdisk_extent_no DESC 3.35 """) # aims to reuse the last extents 3.36 # from the longest-expired disks first 3.37 3.38 @@ -779,7 +780,7 @@ def vd_cp_to_file(vdisk_id,filename): 3.39 3.40 extents = vd_lookup(vdisk_id) 3.41 3.42 - if extents < 0: 3.43 + if not extents: 3.44 return -1 3.45 3.46 file_idx = 0 # index into source file, in sectors 3.47 @@ -827,9 +828,12 @@ def vd_read_from_file(filename,expiry): 3.48 returns [string] : vdisk ID for the destination vdisk 3.49 """ 3.50 3.51 - size_sectors = os.stat(filename).st_size / 512 3.52 + size_bytes = os.stat(filename).st_size 3.53 3.54 - vdisk_id = vd_create(size_sectors / ( 2 * 1024 ),expiry) 3.55 + (size_mb,leftover) = divmod(size_bytes,1048580) # size in megabytes 3.56 + if leftover > 0: size_mb += 1 # round up if not an exact number of MB 3.57 + 3.58 + vdisk_id = vd_create(size_mb, expiry) 3.59 3.60 if vdisk_id < 0: 3.61 return -1 3.62 @@ -840,10 +844,12 @@ def vd_read_from_file(filename,expiry): 3.63 cu.execute("""SELECT partition, extent_size, part_extent_no 3.64 FROM vdisk_part NATURAL JOIN vdisk_extents 3.65 WHERE vdisk_id = """ + vdisk_id + """ 3.66 - ORDER BY vdisk_extent_no""") 3.67 + ORDER BY vdisk_extent_no ASC""") 3.68 3.69 extents = cu.fetchall() 3.70 3.71 + size_sectors = size_mb * 2048 # for feeding to dd 3.72 + 3.73 file_idx = 0 # index into source file, in sectors 3.74 3.75 def write_extent_to_vd((partition, extent_size, part_extent_no), 3.76 @@ -856,7 +862,7 @@ def vd_read_from_file(filename,expiry): 3.77 + " count=" + str(min(extent_size, size_sectors - file_idx)) 3.78 + " > /dev/null") 3.79 3.80 - return file_idx + extent_size 3.81 + return extent_size 3.82 3.83 for i in extents: 3.84 file_idx += write_extent_to_vd(i, file_idx, filename)