Blob Blame History Raw
From e2bf7a17d464c989378278c3121425e7b90442e3 Mon Sep 17 00:00:00 2001
Message-Id: <e2bf7a17d464c989378278c3121425e7b90442e3@dist-git>
From: Andrea Bolognani <abologna@redhat.com>
Date: Mon, 21 Aug 2017 14:46:39 +0200
Subject: [PATCH] conf: Use the correct limit for the number of PHBs

I mistakenly thought pSeries guests supported 32 PHBs,
but it turns out they only support 31. Validate the
target index accordingly.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1479647

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
(cherry picked from commit 64357c3f9373127aa8bdf5a829df4a9d895e1ef9)

Bug: https://bugzilla.redhat.com/show_bug.cgi?id=1479647

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
---
 src/conf/domain_conf.c                                              | 4 ++--
 .../qemuxml2argv-pseries-phb-invalid-target-index-3.xml             | 6 +++---
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 7889f5335c..3d38f668fa 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -5058,10 +5058,10 @@ virDomainControllerDefValidate(const virDomainControllerDef *controller)
         /* Only validate the target index if it's been set */
         if (opts->targetIndex != -1) {
 
-            if (opts->targetIndex < 0 || opts->targetIndex > 31) {
+            if (opts->targetIndex < 0 || opts->targetIndex > 30) {
                 virReportError(VIR_ERR_XML_ERROR,
                                _("PCI controller target index '%d' out of "
-                                 "range - must be 0-31"),
+                                 "range - must be 0-30"),
                                opts->targetIndex);
                 return -1;
             }
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-phb-invalid-target-index-3.xml b/tests/qemuxml2argvdata/qemuxml2argv-pseries-phb-invalid-target-index-3.xml
index 864c5d8758..3d99da4995 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-pseries-phb-invalid-target-index-3.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-phb-invalid-target-index-3.xml
@@ -8,10 +8,10 @@
   </os>
   <devices>
     <emulator>/usr/bin/qemu-system-ppc64</emulator>
-    <!-- QEMU only supports 32 PHBs with target index in the range 0-31,
-         so attempting to use target index 32 should fail -->
+    <!-- QEMU only supports 31 PHBs with target index in the range 0-30,
+         so attempting to use target index 31 should fail -->
     <controller type='pci' model='pci-root'>
-      <target index='32'/>
+      <target index='31'/>
     </controller>
     <controller type='usb' model='none'/>
     <memballoon model='none'/>
-- 
2.14.1