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

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



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 1d6bb1f..bc77429 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,
@@ -3544,6 +3545,7 @@ virDomainDiskDefParseXML(virCapsPtr caps,
     char *snapshot = NULL;
     char *rawio = NULL;
     char *cdbfilter = NULL;
+    char *old_cdbfilter = NULL;
     char *driverName = NULL;
     char *driverType = NULL;
     char *source = NULL;
@@ -3607,6 +3609,8 @@ virDomainDiskDefParseXML(virCapsPtr caps,
 
     rawio = virXMLPropString(node, "rawio");
     cdbfilter = virXMLPropString(node, "cdbfilter");
+    if (flags & VIR_DOMAIN_XML_INTERNAL_OLD_DISK_CDBFILTER)
+        old_cdbfilter = virXMLPropString(node, "old_cdbfilter");
 
     cur = node->children;
     while (cur != NULL) {
@@ -4069,6 +4073,19 @@ virDomainDiskDefParseXML(virCapsPtr caps,
         def->cdbfilter = cdbfilter_val;
     }
 
+    if (old_cdbfilter) {
+        int old_cdbfilter_val = 0;
+
+        if ((old_cdbfilter_val =
+             virDomainDiskCDBFilterTypeFromString(old_cdbfilter)) < 0) {
+            virReportError(VIR_ERR_XML_ERROR,
+                           _("unknown disk cdbfilter setting '%s'"),
+                           old_cdbfilter);
+            goto error;
+        }
+        def->old_cdbfilter = old_cdbfilter_val;
+    }
+
     if (bus) {
         if ((def->bus = virDomainDiskBusTypeFromString(bus)) < 0) {
             virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -11985,6 +12002,12 @@ virDomainDiskDefFormat(virBufferPtr buf,
     if (def->cdbfilter)
         virBufferAsprintf(buf, " cdbfilter='%s'",
                           virDomainDiskCDBFilterTypeToString(def->cdbfilter));
+
+    if ((flags & VIR_DOMAIN_XML_INTERNAL_OLD_DISK_CDBFILTER) &&
+        def->old_cdbfilter)
+        virBufferAsprintf(buf, " old_cdbfilter='%s'",
+                          virDomainDiskCDBFilterTypeToString(def->old_cdbfilter));
+
     if (def->snapshot &&
         !(def->snapshot == VIR_DOMAIN_SNAPSHOT_LOCATION_NONE && def->readonly))
         virBufferAsprintf(buf, " snapshot='%s'",
@@ -13654,7 +13677,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_*,
@@ -13676,7 +13700,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))) {
@@ -14434,7 +14459,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;
@@ -14534,7 +14560,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


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