[libvirt] Domain XML format using defined storage volume + RFC

Stefan de Konink skinkie at xs4all.nl
Thu May 15 23:00:16 UTC 2008


On Thu, 15 May 2008, Stefan de Konink wrote:

> On Thu, 15 May 2008, Stefan de Konink wrote:
>
> > I almost started crying why it didn't work. But it is fixed, and it works
> > as a charm :) See updated patch!
>
> I guess I need to write the 'check' tool and documentation update too?

Since there is currently no check build for pools in that directory, I'm
passing this to someother person.

Patch incorporates now a documentation update.


Sign-off-by: Stefan de Konink <dekonink at kinkrsoftware.nl>


Stefan
-------------- next part --------------
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 02ca509..8e2a7b6 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -344,7 +344,7 @@
     <dl>
       <dt><code>disk</code></dt>
       <dd>The <code>disk</code> element is the main container for describing
-	disks. The <code>type</code> attribute is either "file" or "block"
+	disks. The <code>type</code> attribute is either "file", "block" or "pool"
 	and refers to the underlying source for the disk. The optional
 	<code>device</code> attribute indicates how the disk is to be exposed
 	to the guest OS. Possible values for this attribute are "floppy", "disk"
@@ -354,7 +354,11 @@
       <dd>If the disk <code>type</code> is "file", then the <code>file</code> attribute
 	specifies the fully-qualified path to the file holding the disk. If the disk
 	<code>type</code> is "block", then the <code>dev</code> attribute specifies
-	the path to the host device to serve as the disk. <span class="since">Since 0.0.3</span></dd>
+	the path to the host device to serve as the disk. If the disk <code>type</code>
+    is "pool", then the <code>pool</code> and <code>volume</code> specify the
+    virtual location of the disk, the path is automatically resolved if the pool
+    and the volume exist.
+    <span class="since">Since 0.0.3</span></dd>
       <dt><code>target</code></dt>
       <dd>The <code>target</code> element controls the bus / device under which the
 	disk is exposed to the guest OS. The <code>dev</code> attribute indicates
diff --git a/src/xml.c b/src/xml.c
index 22dc211..9fd093e 100644
--- a/src/xml.c
+++ b/src/xml.c
@@ -1300,6 +1300,8 @@ virDomainParseXMLDiskDesc(virConnectPtr conn, xmlNodePtr node,
             typ = 0;
         else if (xmlStrEqual(type, BAD_CAST "block"))
             typ = 1;
+        else if (xmlStrEqual(type, BAD_CAST "pool"))
+            typ = 2;
         xmlFree(type);
     }
     device = xmlGetProp(node, BAD_CAST "device");
@@ -1309,11 +1311,24 @@ virDomainParseXMLDiskDesc(virConnectPtr conn, xmlNodePtr node,
         if (cur->type == XML_ELEMENT_NODE) {
             if ((source == NULL) &&
                 (xmlStrEqual(cur->name, BAD_CAST "source"))) {
-
                 if (typ == 0)
                     source = xmlGetProp(cur, BAD_CAST "file");
-                else
+                else if (typ == 1)
                     source = xmlGetProp(cur, BAD_CAST "dev");
+                else if (typ == 2) {
+                    xmlChar *pool   = xmlGetProp(cur, BAD_CAST "pool");
+                    xmlChar *volume = xmlGetProp(cur, BAD_CAST "volume");
+                    if (pool != NULL && volume != NULL) {
+                        virStoragePoolPtr virPool;
+                        virPool = virStoragePoolLookupByName(conn, (const char *) pool);
+                        if (virPool != NULL) {
+                            virStorageVolPtr virVol;
+                            virVol = virStorageVolLookupByName(virPool, (const char *) volume);
+                            if (virVol != NULL)
+                                source = BAD_CAST virStorageVolGetPath(virVol);
+                        }
+                    }
+                }
             } else if ((target == NULL) &&
                        (xmlStrEqual(cur->name, BAD_CAST "target"))) {
                 target = xmlGetProp(cur, BAD_CAST "dev");
@@ -1411,7 +1426,8 @@ virDomainParseXMLDiskDesc(virConnectPtr conn, xmlNodePtr node,
                 virBufferVSprintf(buf, "(uname 'phy:%s')", source);
             else
                 virBufferVSprintf(buf, "(uname 'phy:/dev/%s')", source);
-        }
+        } else if (typ == 2)
+            virBufferVSprintf(buf, "(uname 'phy:%s')", source);
     }
     if (ro == 1)
         virBufferAddLit(buf, "(mode 'r')");


More information about the libvir-list mailing list