]> xenbits.xensource.com Git - libvirt.git/commitdiff
conf: refactor hyperv features xml output
authorNikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Thu, 10 Mar 2016 12:43:48 +0000 (15:43 +0300)
committerJohn Ferlan <jferlan@redhat.com>
Mon, 28 Mar 2016 17:10:18 +0000 (13:10 -0400)
1. All hyperv features are tristate ones. So make tristate generating part common.
2. Reduce nesting on spinlocks.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Signed-off-by: John Ferlan <jferlan@redhat.com>
src/conf/domain_conf.c

index f1ffdbec04a51eed7a022a023588941c2c7419ac..797570a42f9b433e90ced5e91e856bbe02d580af 100644 (file)
@@ -22331,33 +22331,32 @@ virDomainDefFormatInternal(virDomainDefPtr def,
                 virBufferAddLit(buf, "<hyperv>\n");
                 virBufferAdjustIndent(buf, 2);
                 for (j = 0; j < VIR_DOMAIN_HYPERV_LAST; j++) {
+                    if (def->hyperv_features[j] == VIR_TRISTATE_SWITCH_ABSENT)
+                        continue;
+
+                    virBufferAsprintf(buf, "<%s state='%s'",
+                                      virDomainHypervTypeToString(j),
+                                      virTristateSwitchTypeToString(
+                                          def->hyperv_features[j]));
+
                     switch ((virDomainHyperv) j) {
                     case VIR_DOMAIN_HYPERV_RELAXED:
                     case VIR_DOMAIN_HYPERV_VAPIC:
-                        if (def->hyperv_features[j])
-                            virBufferAsprintf(buf, "<%s state='%s'/>\n",
-                                              virDomainHypervTypeToString(j),
-                                              virTristateSwitchTypeToString(
-                                                  def->hyperv_features[j]));
                         break;
 
                     case VIR_DOMAIN_HYPERV_SPINLOCKS:
-                        if (def->hyperv_features[j] == 0)
+                        if (def->hyperv_features[j] != VIR_TRISTATE_SWITCH_ON)
                             break;
-
-                        virBufferAsprintf(buf, "<spinlocks state='%s'",
-                                          virTristateSwitchTypeToString(
-                                              def->hyperv_features[j]));
-                        if (def->hyperv_features[j] == VIR_TRISTATE_SWITCH_ON)
-                            virBufferAsprintf(buf, " retries='%d'",
-                                              def->hyperv_spinlocks);
-                        virBufferAddLit(buf, "/>\n");
+                        virBufferAsprintf(buf, " retries='%d'",
+                                          def->hyperv_spinlocks);
                         break;
 
                     /* coverity[dead_error_begin] */
                     case VIR_DOMAIN_HYPERV_LAST:
                         break;
                     }
+
+                    virBufferAddLit(buf, "/>\n");
                 }
                 virBufferAdjustIndent(buf, -2);
                 virBufferAddLit(buf, "</hyperv>\n");