[libvirt] [PATCH 3/7] conf: Reintroduce virDomainDef::hpt_resizing

Andrea Bolognani abologna at redhat.com
Mon Jun 25 17:11:57 UTC 2018


We're going to introduce a second HPT-related setting soon,
at which point using a single location to store everything is
no longer going to cut it.

This mostly, but not completely, reverts 3dd1eb3b2650.

Signed-off-by: Andrea Bolognani <abologna at redhat.com>
---
 src/conf/domain_conf.c  | 21 ++++++++++++++-------
 src/conf/domain_conf.h  |  1 +
 src/qemu/qemu_command.c |  7 ++++---
 src/qemu/qemu_domain.c  |  2 +-
 4 files changed, 20 insertions(+), 11 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index f0b604e125..069ff8c2f8 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -19803,9 +19803,12 @@ virDomainDefParseXML(xmlDocPtr xml,
                                    tmp);
                     goto error;
                 }
-                def->features[val] = value;
+                def->hpt_resizing = (virDomainHPTResizing) value;
                 VIR_FREE(tmp);
             }
+
+            if (def->hpt_resizing != VIR_DOMAIN_HPT_RESIZING_NONE)
+                def->features[val] = VIR_TRISTATE_SWITCH_ON;
             break;
 
         /* coverity[dead_error_begin] */
@@ -21983,13 +21986,16 @@ virDomainDefFeaturesCheckABIStability(virDomainDefPtr src,
             break;
 
         case VIR_DOMAIN_FEATURE_HPT:
-            if (src->features[i] != dst->features[i]) {
+            if (src->features[i] != dst->features[i] ||
+                src->hpt_resizing != dst->hpt_resizing) {
                 virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                                _("State of feature '%s' differs: "
-                                 "source: '%s=%s', destination: '%s=%s'"),
+                                 "source: '%s,%s=%s', destination: '%s,%s=%s'"),
                                featureName,
-                               "resizing", virDomainHPTResizingTypeToString(src->features[i]),
-                               "resizing", virDomainHPTResizingTypeToString(dst->features[i]));
+                               virTristateSwitchTypeToString(src->features[i]),
+                               "resizing", virDomainHPTResizingTypeToString(src->hpt_resizing),
+                               virTristateSwitchTypeToString(dst->features[i]),
+                               "resizing", virDomainHPTResizingTypeToString(dst->hpt_resizing));
                 return false;
             }
             break;
@@ -27767,11 +27773,12 @@ virDomainDefFormatInternal(virDomainDefPtr def,
                 break;
 
             case VIR_DOMAIN_FEATURE_HPT:
-                if (def->features[i] == VIR_DOMAIN_HPT_RESIZING_NONE)
+                if (def->features[i] != VIR_TRISTATE_SWITCH_ON ||
+                    def->hpt_resizing == VIR_DOMAIN_HPT_RESIZING_NONE)
                     break;
 
                 virBufferAsprintf(buf, "<hpt resizing='%s'/>\n",
-                                  virDomainHPTResizingTypeToString(def->features[i]));
+                                  virDomainHPTResizingTypeToString(def->hpt_resizing));
                 break;
 
             /* coverity[dead_error_begin] */
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 8cefef535a..39fa2bc35a 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2438,6 +2438,7 @@ struct _virDomainDef {
     int kvm_features[VIR_DOMAIN_KVM_LAST];
     unsigned int hyperv_spinlocks;
     virGICVersion gic_version;
+    virDomainHPTResizing hpt_resizing;
     char *hyperv_vendor_id;
     int apic_eoi;
 
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 446df3e1d8..081314ed0a 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -7244,17 +7244,18 @@ qemuBuildMachineCommandLine(virCommandPtr cmd,
         }
     }
 
-    if (def->features[VIR_DOMAIN_FEATURE_HPT] != VIR_DOMAIN_HPT_RESIZING_NONE) {
+    if (def->features[VIR_DOMAIN_FEATURE_HPT] == VIR_TRISTATE_SWITCH_ON) {
         const char *str;
 
-        if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_MACHINE_PSERIES_RESIZE_HPT)) {
+        if (def->hpt_resizing != VIR_DOMAIN_HPT_RESIZING_NONE &&
+            !virQEMUCapsGet(qemuCaps, QEMU_CAPS_MACHINE_PSERIES_RESIZE_HPT)) {
             virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
                            _("HTP resizing is not supported by this "
                              "QEMU binary"));
             goto cleanup;
         }
 
-        str = virDomainHPTResizingTypeToString(def->features[VIR_DOMAIN_FEATURE_HPT]);
+        str = virDomainHPTResizingTypeToString(def->hpt_resizing);
         if (!str) {
             virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
                            _("Invalid setting for HPT resizing"));
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 95c3e3a8aa..6d203e1f2e 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -3812,7 +3812,7 @@ qemuDomainDefValidateFeatures(const virDomainDef *def,
             break;
 
         case VIR_DOMAIN_FEATURE_HPT:
-            if (def->features[i] != VIR_DOMAIN_HPT_RESIZING_NONE &&
+            if (def->features[i] != VIR_TRISTATE_SWITCH_ABSENT &&
                 !qemuDomainIsPSeries(def)) {
                 virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                                _("The '%s' feature is not supported for "
-- 
2.17.1




More information about the libvir-list mailing list