6d3351
From 7e3b03cbdee6a9fc694046ea3c98c5cdef941c92 Mon Sep 17 00:00:00 2001
6d3351
Message-Id: <7e3b03cbdee6a9fc694046ea3c98c5cdef941c92@dist-git>
6d3351
From: Andrea Bolognani <abologna@redhat.com>
6d3351
Date: Tue, 25 Jul 2017 10:29:27 +0200
6d3351
Subject: [PATCH] conf: Fix backwards migration of pSeries guests
6d3351
6d3351
Recent commits made it so that pci-root controllers for
6d3351
pSeries guests are automatically assigned the
6d3351
spapr-pci-host-bridge model name; however, that prevents
6d3351
guests to migrate to older versions of libvirt which don't
6d3351
know about that model name at all, which at the moment is
6d3351
all of them :)
6d3351
6d3351
To avoid the issue, just strip the model name from PHBs
6d3351
when formatting the migratable XML; guests that use more
6d3351
than one PHB are not going to be migratable anyway.
6d3351
6d3351
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
6d3351
(cherry picked from commit 9b45cd8fab1c7d7d07dd3ae64970b3c93b78e04c)
6d3351
6d3351
Conflicts:
6d3351
6d3351
  * src/conf/domain_conf.c:
6d3351
6d3351
    caused by e146264aaadf5aecf727d8c7b3d85683b55b6c48,
6d3351
    which significantly refactored
6d3351
    virDomainControllerDefFormat(), not being in the tree.
6d3351
6d3351
Bug: https://bugzilla.redhat.com/show_bug.cgi?id=1431193
6d3351
6d3351
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
6d3351
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
6d3351
---
6d3351
 src/conf/domain_conf.c | 17 +++++++++++++++++
6d3351
 1 file changed, 17 insertions(+)
6d3351
6d3351
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
6d3351
index 86415964dc..f28f6aff63 100644
6d3351
--- a/src/conf/domain_conf.c
6d3351
+++ b/src/conf/domain_conf.c
6d3351
@@ -21670,6 +21670,23 @@ virDomainControllerDefFormat(virBufferPtr buf,
6d3351
             pcihole64 = true;
6d3351
         if (def->opts.pciopts.modelName != VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_NONE)
6d3351
             pciModel = true;
6d3351
+        /* Historically, libvirt didn't support specifying a model name for
6d3351
+         * pci-root controllers; starting from 3.6.0, however, pSeries guests
6d3351
+         * use pci-root controllers with model name spapr-pci-host-bridge to
6d3351
+         * represent all PHBs, including the default one.
6d3351
+         *
6d3351
+         * In order to allow migration of pSeries guests from older libvirt
6d3351
+         * versions and back, we don't format the model name in the migratable
6d3351
+         * XML if it's spapr-pci-host-bridge, thus making "no model name" and
6d3351
+         * "spapr-pci-host-bridge model name" basically equivalent.
6d3351
+         *
6d3351
+         * The spapr-pci-host-bridge device is specific to pSeries.
6d3351
+         */
6d3351
+        if (def->model == VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT &&
6d3351
+            def->opts.pciopts.modelName == VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_SPAPR_PCI_HOST_BRIDGE &&
6d3351
+            flags & VIR_DOMAIN_DEF_FORMAT_MIGRATABLE) {
6d3351
+            pciModel = false;
6d3351
+        }
6d3351
         if (def->opts.pciopts.chassisNr != -1 ||
6d3351
             def->opts.pciopts.chassis != -1 ||
6d3351
             def->opts.pciopts.port != -1 ||
6d3351
-- 
6d3351
2.13.3
6d3351