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

[libvirt] [PATCH 05/12] conf: add 'script' attribute to disk specification



Script to be called to prepare custom device for domain. Done with Xen
in mind, it maps to libxl_device_disk.script.

XML configuration would be:
<disk type='block' device='disk'>
    <source dev='/dev/mapper/custom-device'/>
    <script path='/script/to/setup/custom-device'/>
    <target dev='xvdc'/>
</disk>
---
 src/conf/domain_conf.c | 10 ++++++++++
 src/conf/domain_conf.h |  1 +
 2 files changed, 11 insertions(+)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index f3fca7f..257a265 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -1102,6 +1102,7 @@ void virDomainDiskDefFree(virDomainDiskDefPtr def)
     VIR_FREE(def->wwn);
     VIR_FREE(def->vendor);
     VIR_FREE(def->product);
+    VIR_FREE(def->script);
     if (def->auth.secretType == VIR_DOMAIN_DISK_SECRET_TYPE_USAGE)
         VIR_FREE(def->auth.secret.usage);
     virStorageEncryptionFree(def->encryption);
@@ -3993,6 +3994,7 @@ virDomainDiskDefParseXML(virCapsPtr caps,
     char *wwn = NULL;
     char *vendor = NULL;
     char *product = NULL;
+    char *script = NULL;
     int expected_secret_usage = -1;
     int auth_secret_usage = -1;
 
@@ -4148,6 +4150,9 @@ virDomainDiskDefParseXML(virCapsPtr caps,
                 if (target &&
                     STRPREFIX(target, "ioemu:"))
                     memmove(target, target+6, strlen(target)-5);
+            } else if (!script &&
+                       xmlStrEqual(cur->name, BAD_CAST "script")) {
+                script = virXMLPropString(cur, "path");
             } else if (xmlStrEqual(cur->name, BAD_CAST "geometry")) {
                 if (virXPathUInt("string(./geometry/@cyls)",
                                  ctxt, &def->geometry.cylinders) < 0) {
@@ -4690,6 +4695,8 @@ virDomainDiskDefParseXML(virCapsPtr caps,
     source = NULL;
     def->dst = target;
     target = NULL;
+    def->script = script;
+    script = NULL;
     def->hosts = hosts;
     hosts = NULL;
     def->nhosts = nhosts;
@@ -4788,6 +4795,7 @@ cleanup:
     VIR_FREE(wwn);
     VIR_FREE(vendor);
     VIR_FREE(product);
+    VIR_FREE(script);
 
     ctxt->node = save_ctxt;
     return def;
@@ -12899,6 +12907,8 @@ virDomainDiskDefFormat(virBufferPtr buf,
         }
     }
 
+    virBufferEscapeString(buf, "      <script path='%s'/>\n", def->script);
+
     virDomainDiskGeometryDefFormat(buf, def);
     virDomainDiskBlockIoDefFormat(buf, def);
 
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index edddf25..d55d209 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -668,6 +668,7 @@ struct _virDomainDiskDef {
     bool rawio_specified;
     int rawio; /* no = 0, yes = 1 */
     int sgio; /* enum virDomainDiskSGIO */
+    char *script;
 
     size_t nseclabels;
     virSecurityDeviceLabelDefPtr *seclabels;
-- 
1.8.1.4



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