[PATCH 12/12] conf: Save disk's original unpriv_sgio state into status XML

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

 



This allows the disk's original_unpriv value is not lost after
restarting or reloading libvirtd.
---
 src/conf/domain_conf.c |   35 +++++++++++++++++++++++++++++++----
 1 files changed, 31 insertions(+), 4 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 1edba69..599d299 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -70,6 +70,7 @@ typedef enum {
    VIR_DOMAIN_XML_INTERNAL_PCI_ORIG_STATES = (1<<18),
    VIR_DOMAIN_XML_INTERNAL_ALLOW_ROM = (1<<19),
    VIR_DOMAIN_XML_INTERNAL_ALLOW_BOOT = (1<<20),
+   VIR_DOMAIN_XML_INTERNAL_OLD_DISK_CDBFILTER = (1<<21),
 } virDomainXMLInternalFlags;
 
 VIR_ENUM_IMPL(virDomainTaint, VIR_DOMAIN_TAINT_LAST,
@@ -3535,6 +3536,7 @@ virDomainDiskDefParseXML(virCapsPtr caps,
     char *snapshot = NULL;
     char *rawio = NULL;
     char *cdbfilter = NULL;
+    char *orig_cdbfilter = NULL;
     char *driverName = NULL;
     char *driverType = NULL;
     char *source = NULL;
@@ -3600,6 +3602,8 @@ virDomainDiskDefParseXML(virCapsPtr caps,
 
     rawio = virXMLPropString(node, "rawio");
     cdbfilter = virXMLPropString(node, "cdbfilter");
+    if (flags & VIR_DOMAIN_XML_INTERNAL_OLD_DISK_CDBFILTER)
+        orig_cdbfilter = virXMLPropString(node, "orig_cdbfilter");
 
     cur = node->children;
     while (cur != NULL) {
@@ -4092,6 +4096,19 @@ virDomainDiskDefParseXML(virCapsPtr caps,
         def->cdbfilter = cdbfilter_val;
     }
 
+    if (orig_cdbfilter) {
+        int orig_cdbfilter_val = 0;
+
+        if ((orig_cdbfilter_val =
+             virDomainDiskCDBFilterTypeFromString(orig_cdbfilter)) < 0) {
+            virReportError(VIR_ERR_XML_ERROR,
+                           _("unknown disk cdbfilter setting '%s'"),
+                           orig_cdbfilter);
+            goto error;
+        }
+        def->orig_cdbfilter = orig_cdbfilter_val;
+    }
+
     if (bus) {
         if ((def->bus = virDomainDiskBusTypeFromString(bus)) < 0) {
             virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -12014,6 +12031,12 @@ virDomainDiskDefFormat(virBufferPtr buf,
     if (def->cdbfilter)
         virBufferAsprintf(buf, " cdbfilter='%s'",
                           virDomainDiskCDBFilterTypeToString(def->cdbfilter));
+
+    if ((flags & VIR_DOMAIN_XML_INTERNAL_OLD_DISK_CDBFILTER) &&
+        def->orig_cdbfilter)
+        virBufferAsprintf(buf, " orig_cdbfilter='%s'",
+                          virDomainDiskCDBFilterTypeToString(def->orig_cdbfilter));
+
     if (def->snapshot &&
         !(def->snapshot == VIR_DOMAIN_SNAPSHOT_LOCATION_NONE && def->readonly))
         virBufferAsprintf(buf, " snapshot='%s'",
@@ -13685,7 +13708,8 @@ virDomainIsAllVcpupinInherited(virDomainDefPtr def)
 
 verify(((VIR_DOMAIN_XML_INTERNAL_STATUS |
          VIR_DOMAIN_XML_INTERNAL_ACTUAL_NET |
-         VIR_DOMAIN_XML_INTERNAL_PCI_ORIG_STATES)
+         VIR_DOMAIN_XML_INTERNAL_PCI_ORIG_STATES |
+         VIR_DOMAIN_XML_INTERNAL_OLD_DISK_CDBFILTER)
         & DUMPXML_FLAGS) == 0);
 
 /* This internal version can accept VIR_DOMAIN_XML_INTERNAL_*,
@@ -13707,7 +13731,8 @@ virDomainDefFormatInternal(virDomainDefPtr def,
     virCheckFlags(DUMPXML_FLAGS |
                   VIR_DOMAIN_XML_INTERNAL_STATUS |
                   VIR_DOMAIN_XML_INTERNAL_ACTUAL_NET |
-                  VIR_DOMAIN_XML_INTERNAL_PCI_ORIG_STATES,
+                  VIR_DOMAIN_XML_INTERNAL_PCI_ORIG_STATES |
+                  VIR_DOMAIN_XML_INTERNAL_OLD_DISK_CDBFILTER,
                   -1);
 
     if (!(type = virDomainVirtTypeToString(def->virtType))) {
@@ -14465,7 +14490,8 @@ int virDomainSaveStatus(virCapsPtr caps,
     unsigned int flags = (VIR_DOMAIN_XML_SECURE |
                           VIR_DOMAIN_XML_INTERNAL_STATUS |
                           VIR_DOMAIN_XML_INTERNAL_ACTUAL_NET |
-                          VIR_DOMAIN_XML_INTERNAL_PCI_ORIG_STATES);
+                          VIR_DOMAIN_XML_INTERNAL_PCI_ORIG_STATES |
+                          VIR_DOMAIN_XML_INTERNAL_OLD_DISK_CDBFILTER);
 
     int ret = -1;
     char *xml;
@@ -14565,7 +14591,8 @@ static virDomainObjPtr virDomainLoadStatus(virCapsPtr caps,
     if (!(obj = virDomainObjParseFile(caps, statusFile, expectedVirtTypes,
                                       VIR_DOMAIN_XML_INTERNAL_STATUS |
                                       VIR_DOMAIN_XML_INTERNAL_ACTUAL_NET |
-                                      VIR_DOMAIN_XML_INTERNAL_PCI_ORIG_STATES)))
+                                      VIR_DOMAIN_XML_INTERNAL_PCI_ORIG_STATES |
+                                      VIR_DOMAIN_XML_INTERNAL_OLD_DISK_CDBFILTER)))
         goto error;
 
     virUUIDFormat(obj->def->uuid, uuidstr);
-- 
1.7.7.6

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