[et-mgmt-tools] [PATCH 3 of 4] Allow naming disk storage elements with an id and use that to reference them from the boot descriptor

David Lutterkort dlutter at redhat.com
Wed Dec 5 00:44:58 UTC 2007


diff -r 11d9412efc34 -r ea7588e72c26 doc/image.rng
--- a/doc/image.rng	Tue Dec 04 15:17:12 2007 -0800
+++ b/doc/image.rng	Tue Dec 04 15:17:48 2007 -0800
@@ -150,8 +150,12 @@
   <define name="storage">
     <oneOrMore>
       <!-- A disk for mapping into a virtual machine
-           file: file name (file must be in the same dir as the
-                            image descriptor)
+           id:   a shorthand for referencing the disk. If this is missing,
+                 the value of the file attribute is used to reference  the
+                 disk
+           file: file name, must be a legal Unix path name. Only relative 
+                 paths are allowed, and they are interpreted relative to the 
+                 location of the image descriptor.
            use:  only important for updating existing images
                  through replacement of entire disks
            size: size of the disk in MB, needed only for user and scratch
@@ -161,6 +165,9 @@
                    iso for an ISO
       -->
       <element name="disk">
+        <optional>
+          <attribute name="id"><data type="ID"/></attribute>
+        </optional>
         <attribute name="file"><ref name="relFilePath"/></attribute>
         <attribute name="use">
           <choice>
diff -r 11d9412efc34 -r ea7588e72c26 virtinst/ImageParser.py
--- a/virtinst/ImageParser.py	Tue Dec 04 15:17:12 2007 -0800
+++ b/virtinst/ImageParser.py	Tue Dec 04 15:17:48 2007 -0800
@@ -46,11 +46,12 @@ class Image:
         for d in node.xpathEval("storage/disk"):
             disk = Disk(d)
             if disk.file is None:
+                disk.id = "disk%d.img" % len(self.storage)
                 disk.file = "disk%d.img" % (len(self.storage) + 1)
-            if self.storage.has_key(disk.file):
+            if self.storage.has_key(disk.id):
                 raise ParserException("Disk file '%s' defined twice"
                                            % disk.file)
-            self.storage[disk.file] = disk
+            self.storage[disk.id] = disk
         lm = node.xpathEval("domain")
         if len(lm) == 1:
             self.domain = Domain(lm[0])
@@ -176,6 +177,7 @@ class Disk:
     USE_SCRATCH = "scratch"
 
     def __init__(self, node = None):
+        self.id = None
         self.file = None
         self.format = None
         self.size = None
@@ -185,6 +187,7 @@ class Disk:
 
     def parseXML(self, node):
         self.file = xpathString(node, "@file")
+        self.id = xpathString(node, "@id", self.file)
         self.format = xpathString(node, "@format", Disk.FORMAT_RAW)
         self.size = xpathString(node, "@size")
         self.use = xpathString(node, "@use", Disk.USE_SYSTEM)




More information about the et-mgmt-tools mailing list