From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by passt.top (Postfix) with ESMTP id 3C32A5A0082 for ; Wed, 22 Feb 2023 11:40:37 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677062436; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=2vY0iyKmIJEJ+48n3T62oZQD7Tye0fBCaliLPQTkiR0=; b=AhgMU4cAxsH+mXNZnwOIPnuCPhQTWK27wOmFX9fwzDrApx/wKUbUMoSQOrLQ/szh8CNKVG YQM3dAK44xvuB0N9oFyCjCvbxNFp4i9cI49F4YtCXBHgU0DuRZpYCCdBrXdZuSVUlbiUlu 8mEO2ZrmqneLzx90ianhSyr/HrtIbtk= Received: from mail-pg1-f199.google.com (mail-pg1-f199.google.com [209.85.215.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-356-jAsGmZDHMwmDmEhcudhX2g-1; Wed, 22 Feb 2023 05:40:34 -0500 X-MC-Unique: jAsGmZDHMwmDmEhcudhX2g-1 Received: by mail-pg1-f199.google.com with SMTP id z64-20020a636543000000b004fb4f0424f3so3082780pgb.14 for ; Wed, 22 Feb 2023 02:40:34 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:in-reply-to:mime-version:references :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=2vY0iyKmIJEJ+48n3T62oZQD7Tye0fBCaliLPQTkiR0=; b=L5KfSsVSditiMaAovM+T+2VfflvzVDkxLC4l8NTrNH1PMpklncamlEspvAqbgeayWC g/L+N5+bgtS+twxcnQxrSUf2VNgjEJCsS4Ji0z9plJRYodOldEgzFabx1VhD/QznJrRv 6hrK6PfzrzZUbaQC6cnrf0oHKCcj98Nc9EkfDR8SD5CYMph+eIAL5o+3rhTBW6nMyf88 x797U95hB6RpyHveu1KAcC7BZm284Jo3jR/JkDkYcqruDsEbwbx40c2ZIyEyW8qbtEV7 UCg4UPeYegUL61kiyHRxytpbQmeWszdNQXgb3+KEwj4LXUCxhDzi8b4mY5GuPYZgqk3X 1a6g== X-Gm-Message-State: AO0yUKWu1vCT3Bg4EUe0j9bji+Wg/Kl0nHjnth1a83WxQ+UYSdDm1iK/ EPFooqpKA2MqWFEao72Kpib/FURF/w0qMrjZOZr6RQGs68zl3NlTYnFCJT/aH0wNWRQrgBRzoZy otMcDdfZ6NUEwudMw8YYaiwakxirH X-Received: by 2002:a17:90b:3904:b0:231:f52:ddec with SMTP id ob4-20020a17090b390400b002310f52ddecmr2550323pjb.91.1677062433817; Wed, 22 Feb 2023 02:40:33 -0800 (PST) X-Google-Smtp-Source: AK7set9iQz43GXTLUDHkgonra9YS20zIugwe8DnKE0BVcNZvH79SaVow9PYw37gAJxj6kHLNhQskatu+pXS35IkXV4A= X-Received: by 2002:a17:90b:3904:b0:231:f52:ddec with SMTP id ob4-20020a17090b390400b002310f52ddecmr2550316pjb.91.1677062433113; Wed, 22 Feb 2023 02:40:33 -0800 (PST) Received: from 744723338238 named unknown by gmailapi.google.com with HTTPREST; Wed, 22 Feb 2023 02:40:32 -0800 From: Andrea Bolognani References: <20230221192425.3745394-1-sbrivio@redhat.com> MIME-Version: 1.0 In-Reply-To: <20230221192425.3745394-1-sbrivio@redhat.com> Date: Wed, 22 Feb 2023 02:40:32 -0800 Message-ID: Subject: Re: [PATCH] qrap: Pass PCI device numbers to qemu in base 10, not in base 16 To: Stefano Brivio X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Message-ID-Hash: DJDHU5GKMEGAYLBWNIRPMYYRXVWVC4MO X-Message-ID-Hash: DJDHU5GKMEGAYLBWNIRPMYYRXVWVC4MO X-MailFrom: abologna@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: passt-dev@passt.top, Alona Paz X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: 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