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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I almost started crying why it didn't work. But it is fixed, and it works
as a charm :) See updated patch!

Sign-off-by: Stefan de Konink <dekonink@xxxxxxxxxxxxxxxx>


Stefan

ps. One extra suggestion: I would consider it a good thing if the virLog
function in util.c would get a \n
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')");
--
Libvir-list mailing list
Libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]