[libvirt] [PATCH] qemuBuildDeviceAddressStr: Prefer default alias for PCI bus

Michal Privoznik posted 1 patch 6 years, 5 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/fa3c7c5e910a7dd5124420795c19e78ee262b195.1510676779.git.mprivozn@redhat.com
src/qemu/qemu_command.c | 25 +++++++++++++++++--------
1 file changed, 17 insertions(+), 8 deletions(-)
[libvirt] [PATCH] qemuBuildDeviceAddressStr: Prefer default alias for PCI bus
Posted by Michal Privoznik 6 years, 5 months ago
https://bugzilla.redhat.com/show_bug.cgi?id=1434451

Just like in 9324f67a572f9b32 we need to put default pci-root
alias onto the command line instead of the one provided by user.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---
 src/qemu/qemu_command.c | 25 +++++++++++++++++--------
 1 file changed, 17 insertions(+), 8 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index eb72db33b..affad43e1 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -318,16 +318,25 @@ qemuBuildDeviceAddressStr(virBufferPtr buf,
 
             if (cont->type == VIR_DOMAIN_CONTROLLER_TYPE_PCI &&
                 cont->idx == info->addr.pci.bus) {
-                contAlias = cont->info.alias;
                 contIsPHB = virDomainControllerIsPSeriesPHB(cont);
                 contTargetIndex = cont->opts.pciopts.targetIndex;
-                if (!contAlias) {
-                    virReportError(VIR_ERR_INTERNAL_ERROR,
-                                   _("Device alias was not set for PCI "
-                                     "controller with index %u required "
-                                     "for device at address %s"),
-                                   info->addr.pci.bus, devStr);
-                    goto cleanup;
+
+                /* When domain has builtin pci-root controller we don't put it
+                 * onto cmd line. Therefore we can't set its alias. In that
+                 * case, use the default one. */
+                if (!qemuDomainIsPSeries(domainDef) &&
+                    cont->model == VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT) {
+                    contAlias = "pci.0";
+                } else {
+                    contAlias = cont->info.alias;
+                    if (!contAlias) {
+                        virReportError(VIR_ERR_INTERNAL_ERROR,
+                                       _("Device alias was not set for PCI "
+                                         "controller with index %u required "
+                                         "for device at address %s"),
+                                       info->addr.pci.bus, devStr);
+                        goto cleanup;
+                    }
                 }
                 break;
             }
-- 
2.13.6

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] qemuBuildDeviceAddressStr: Prefer default alias for PCI bus
Posted by Ján Tomko 6 years, 5 months ago
On Tue, Nov 14, 2017 at 05:26:32PM +0100, Michal Privoznik wrote:
>https://bugzilla.redhat.com/show_bug.cgi?id=1434451
>
>Just like in 9324f67a572f9b32 we need to put default pci-root
>alias onto the command line instead of the one provided by user.
>
>Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
>---
> src/qemu/qemu_command.c | 25 +++++++++++++++++--------
> 1 file changed, 17 insertions(+), 8 deletions(-)
>

Looking at qemuBuildControllerDevCommandLine,
qemuBuildControllerDevStr is skipped for the following devices:
CONTROLLER_MODEL_PCIE_ROOT,
CONTROLLER_MODEL_PCI_ROOT (except for PSeries),
CONTROLLER_TYPE_SATA for Q35 machines,
CONTROLLER_TYPE_IDE for machines with built-in IDE.

All of those cannot use the custom alias and we refer to them when
building the command line.

>diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
>index eb72db33b..affad43e1 100644
>--- a/src/qemu/qemu_command.c
>+++ b/src/qemu/qemu_command.c
>@@ -318,16 +318,25 @@ qemuBuildDeviceAddressStr(virBufferPtr buf,
>
>             if (cont->type == VIR_DOMAIN_CONTROLLER_TYPE_PCI &&
>                 cont->idx == info->addr.pci.bus) {
>-                contAlias = cont->info.alias;
>                 contIsPHB = virDomainControllerIsPSeriesPHB(cont);
>                 contTargetIndex = cont->opts.pciopts.targetIndex;
>-                if (!contAlias) {
>-                    virReportError(VIR_ERR_INTERNAL_ERROR,
>-                                   _("Device alias was not set for PCI "
>-                                     "controller with index %u required "
>-                                     "for device at address %s"),
>-                                   info->addr.pci.bus, devStr);
>-                    goto cleanup;
>+
>+                /* When domain has builtin pci-root controller we don't put it
>+                 * onto cmd line. Therefore we can't set its alias. In that
>+                 * case, use the default one. */
>+                if (!qemuDomainIsPSeries(domainDef) &&
>+                    cont->model == VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT) {
>+                    contAlias = "pci.0";

This is not necessarily the alias for the implicit PCI root,
some architectures use "pci", see the fun logic in qemuAssignDeviceControllerAlias.

Jan
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list