public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
From: Andrea Bolognani <abologna@redhat.com>
To: Stefano Brivio <sbrivio@redhat.com>
Cc: passt-dev@passt.top, Alona Paz <alkaplan@redhat.com>
Subject: Re: [PATCH] qrap: Pass PCI device numbers to qemu in base 10, not in base 16
Date: Wed, 22 Feb 2023 02:40:32 -0800	[thread overview]
Message-ID: <CABJz62Op3xZyh9Gbqw9J7b-F7SpY3ziW33B8g4M00BU7z-4C7g@mail.gmail.com> (raw)
In-Reply-To: <20230221192425.3745394-1-sbrivio@redhat.com>

On Tue, Feb 21, 2023 at 08:24:25PM +0100, Stefano Brivio wrote:
>  		if (!has_json) {
>  			snprintf(dev_str, ARG_MAX,
> -			         "%s,%s%x%s,netdev=hostnet0,x-txburst=4096",
> +			         "%s,%s%i%s,netdev=hostnet0,x-txburst=4096",
>  			         dev->name, dev->template, i, dev->template_post);
>  		} else {
>  			snprintf(dev_str, ARG_MAX,
> -			         "{\"driver\":\"%s\",%s%x\"%s,\"netdev\":\"hostnet0\",\"x-txburst\":4096}",
> +			         "{\"driver\":\"%s\",%s%i\"%s,\"netdev\":\"hostnet0\",\"x-txburst\":4096}",
>  			         dev->name, dev->template_json, i, dev->template_json_post);
>  		}

I don't think this is going to work.

The problem is that, while PCI buses are indeed named with increasing
numbers in integer format (pci.9, pci.10 and so on), PCI slots are
addressed using hexadecimal format (0x9, 0xa and so on). libvirt uses
this naming convention because it matches QEMU's.

So if you have an i440fx machine with many devices, they will all[1]
be put on pci.0, the corresponding arguments will look like

  -device virtio-net-pci,bus=pci.0,addr=0xa

and the original version of the code will work correctly.

If the machine is q35, however, devices will not be put on pcie.0
directly but rather attached to pcie-root-ports, each one of which
creates a separate PCI bus. So the arguments will look like

  -device virtio-net-pci,bus=pci.10,addr=0x0

where it is the new version of the code that would do the right
thing.

What I think needs to happen, is that each pci_dev should contain a
base value (16 for i440fx and 10 for q35), which is used both in the
strtol() call used to parse the command line produced by libvirt and
to decide whether %x or %i should be used with snprintf() to generate
qrap's own arguments.


[1] Up until the point where are too many devices to fit into pci.0
    and adding a pci-bridge becomes necessary. I think qrap wouldn't
    be able to handle this scenario correctly anyway.
-- 
Andrea Bolognani / Red Hat / Virtualization


  parent reply	other threads:[~2023-02-22 10:40 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-21 19:24 [PATCH] qrap: Pass PCI device numbers to qemu in base 10, not in base 16 Stefano Brivio
2023-02-22  0:27 ` David Gibson
2023-02-22 10:40 ` Andrea Bolognani [this message]
2023-02-22 10:45   ` Stefano Brivio
2023-02-22 12:47     ` Andrea Bolognani
2023-02-22 13:02       ` Stefano Brivio
2023-02-22 22:27   ` David Gibson
2023-02-23 14:06     ` Andrea Bolognani
2023-02-24  7:14       ` Stefano Brivio
2023-02-24 19:05         ` Andrea Bolognani
2023-02-24 19:32           ` Stefano Brivio
2023-02-25  1:44             ` David Gibson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CABJz62Op3xZyh9Gbqw9J7b-F7SpY3ziW33B8g4M00BU7z-4C7g@mail.gmail.com \
    --to=abologna@redhat.com \
    --cc=alkaplan@redhat.com \
    --cc=passt-dev@passt.top \
    --cc=sbrivio@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://passt.top/passt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).