[PATCH 4/5] conf: add 'format' attribute to domain/os/nvram element

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

 



By default libvirt's qemu driver creates nvram file as a copy
of the file specified in 'template' attribute and use it as
a 'raw' image file.

'raw' image format doesn't support snapshotting. 'format'
attribut can be used to specify different format for nvram
image file.

This patch introduces 'format' attribute with two possible
values: 'raw' and 'qcow2'.
---
 docs/schemas/domaincommon.rng |  8 ++++++++
 src/conf/domain_conf.c        | 18 ++++++++++++++++++
 src/conf/domain_conf.h        |  1 +
 3 files changed, 27 insertions(+)

diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 4804c69..7c609b5 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -275,6 +275,14 @@
               </attribute>
             </optional>
             <optional>
+              <attribute name='format'>
+                <choice>
+                  <value>raw</value>
+                  <value>qcow2</value>
+                </choice>
+              </attribute>
+            </optional>
+            <optional>
               <ref name="absFilePath"/>
             </optional>
           </element>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 2f5c0ed..ce47522 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -15526,6 +15526,19 @@ virDomainDefParseXML(xmlDocPtr xml,
 
             def->os.loader->nvram = virXPathString("string(./os/nvram[1])", ctxt);
             def->os.loader->templt = virXPathString("string(./os/nvram[1]/@template)", ctxt);
+
+            if ((tmp = virXPathString("string(./os/nvram[1]/@format)", ctxt))) {
+                int format = virStorageFileFormatTypeFromString(tmp);
+                if (format < 0) {
+                    virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                                   _("invalid value of format attribute "
+                                     "for NVRAM '%s'"), tmp);
+                    goto error;
+                }
+
+                VIR_FREE(tmp);
+                def->os.loader->format = format;
+            }
         }
     }
 
@@ -21270,6 +21283,7 @@ virDomainLoaderDefFormat(virBufferPtr buf,
 {
     const char *readonly = virTristateBoolTypeToString(loader->readonly);
     const char *type = virDomainLoaderTypeToString(loader->type);
+    const char *format = virStorageFileFormatTypeToString(loader->format);
 
     virBufferAddLit(buf, "<loader");
 
@@ -21282,6 +21296,10 @@ virDomainLoaderDefFormat(virBufferPtr buf,
     if (loader->nvram || loader->templt) {
         virBufferAddLit(buf, "<nvram");
         virBufferEscapeString(buf, " template='%s'", loader->templt);
+
+        if (format && loader->format > 0)
+            virBufferEscapeString(buf, " format='%s'", format);
+
         if (loader->nvram)
             virBufferEscapeString(buf, ">%s</nvram>\n", loader->nvram);
         else
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 90d8e13..4607fac 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1816,6 +1816,7 @@ struct _virDomainLoaderDef {
     virDomainLoader type;
     char *nvram;    /* path to non-volatile RAM */
     char *templt;   /* user override of path to master nvram */
+    int format;     /* virStorageFileFormat */
 };
 
 void virDomainLoaderDefFree(virDomainLoaderDefPtr loader);
-- 
1.8.3.1

--
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]