@@ -45,19 +45,23 @@ class VirtualDisk:
4545 TYPE_FILE = "file"
4646 TYPE_BLOCK = "block"
4747
48- def __init__ (self , path , size = None , transient = False , type = None , device = DEVICE_DISK , driverName = None , driverType = None , readOnly = False , sparse = True ):
48+ def __init__ (self , path = None , size = None , transient = False , type = None , device = DEVICE_DISK , driverName = None , driverType = None , readOnly = False , sparse = True ):
4949 """@path is the path to the disk image.
5050 @size is the size of the disk image in gigabytes."""
5151 self .size = size
5252 self .sparse = sparse
5353 self .transient = transient
54- self .path = os .path .abspath (path )
55-
56- if os .path .isdir (self .path ):
54+ if path != None :
55+ self .path = os .path .abspath (path )
56+ else :
57+ self .path = None
58+ type = "VirtualDisk.TYPE_FILE" # Arbitrary choice but avoids the null-path null-type case
59+
60+ if self .path != None and os .path .isdir (self .path ):
5761 raise ValueError , \
5862 _ ("The disk path must be a file or a device, not a directory" )
5963
60- if not self .path .startswith ("/" ):
64+ if self . path != None and not self .path .startswith ("/" ):
6165 raise ValueError , \
6266 _ ("The disk path must be an absolute path location, beginning with '/'" )
6367
@@ -75,7 +79,7 @@ def __init__(self, path, size = None, transient=False, type=None, device=DEVICE_
7579 else :
7680 self ._type = type
7781
78- if self ._type == VirtualDisk .TYPE_FILE :
82+ if self ._type == VirtualDisk .TYPE_FILE and self . path != None :
7983 if size is None and not os .path .exists (self .path ):
8084 raise ValueError , \
8185 _ ("A size must be provided for non-existent disks" )
0 commit comments