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