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 8C0485A0082 for ; Wed, 22 Feb 2023 11:45:19 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677062718; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZDOLH7j4qhp6bUUemJ1pQXAXs1Mu5Dq90oA5s88LXnk=; b=UbHdLB/alrUNUQqOQF1mHpG4q55jJxYTR3ykJF8J6LzIvYCPHGeXRcZqXBqXzx1vTgc21w Bvt3PAKXpFiRjZHXI1d2+i5HKsPXSsles19LwkFDAHAMNTJbY+C/aBikL2zjK/Q81ppxcx BozCFyEOSoy9S1R106HNX9tico32JFs= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-390-hsN9dPGuPMqbhK_73m56pA-1; Wed, 22 Feb 2023 05:45:11 -0500 X-MC-Unique: hsN9dPGuPMqbhK_73m56pA-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3529785D185 for ; Wed, 22 Feb 2023 10:45:11 +0000 (UTC) Received: from maya.cloud.tilaa.com (unknown [10.33.32.23]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0C3E9C15BA0; Wed, 22 Feb 2023 10:45:11 +0000 (UTC) Date: Wed, 22 Feb 2023 11:45:08 +0100 From: Stefano Brivio To: Andrea Bolognani Subject: Re: [PATCH] qrap: Pass PCI device numbers to qemu in base 10, not in base 16 Message-ID: <20230222114508.10c0fd74@elisabeth> In-Reply-To: References: <20230221192425.3745394-1-sbrivio@redhat.com> Organization: Red Hat MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: VBXAQYUJNIRLOLGJC2NKTO5ZNUCZA2RG X-Message-ID-Hash: VBXAQYUJNIRLOLGJC2NKTO5ZNUCZA2RG X-MailFrom: sbrivio@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 Wed, 22 Feb 2023 02:40:32 -0800 Andrea Bolognani wrote: > 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. Oh, oops, I didn't know that. > 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. Right, I think it makes sense. Will you prepare a patch in this sense or should I try? -- Stefano