[libvirt] [PATCH 1/6] qemuBuildPCIHostdevDevStr: Always format PCI domain onto cmd line

Michal Privoznik posted 6 patches 6 years, 6 months ago
[libvirt] [PATCH 1/6] qemuBuildPCIHostdevDevStr: Always format PCI domain onto cmd line
Posted by Michal Privoznik 6 years, 6 months ago
QEMU is perfectly capable of dealing with fully expanded PCI
address. Format PCI domain always as it will simplify next
commits.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---
 src/qemu/qemu_command.c                                   | 8 ++++----
 tests/qemuxml2argvdata/hostdev-pci-address-device.args    | 2 +-
 tests/qemuxml2argvdata/hostdev-pci-address.args           | 2 +-
 .../qemuxml2argvdata/hostdev-vfio-zpci-autogenerate.args  | 2 +-
 tests/qemuxml2argvdata/hostdev-vfio-zpci-boundaries.args  | 2 +-
 tests/qemuxml2argvdata/hostdev-vfio-zpci.args             | 2 +-
 tests/qemuxml2argvdata/hostdev-vfio.args                  | 2 +-
 tests/qemuxml2argvdata/net-hostdev-bootorder.args         | 3 ++-
 tests/qemuxml2argvdata/net-hostdev-vfio.args              | 2 +-
 tests/qemuxml2argvdata/net-hostdev.args                   | 2 +-
 tests/qemuxml2argvdata/pci-rom.args                       | 4 ++--
 11 files changed, 16 insertions(+), 15 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index fee51158a9..1871c6ef81 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -4933,10 +4933,10 @@ qemuBuildPCIHostdevDevStr(const virDomainDef *def,
     }
 
     virBufferAddLit(&buf, ",host=");
-    if (pcisrc->addr.domain)
-        virBufferAsprintf(&buf, "%.4x:", pcisrc->addr.domain);
-    virBufferAsprintf(&buf, "%.2x:%.2x.%.1x",
-                      pcisrc->addr.bus, pcisrc->addr.slot,
+    virBufferAsprintf(&buf, "%.4x:%.2x:%.2x.%.1x",
+                      pcisrc->addr.domain,
+                      pcisrc->addr.bus,
+                      pcisrc->addr.slot,
                       pcisrc->addr.function);
     virBufferAsprintf(&buf, ",id=%s", dev->info->alias);
     if (dev->info->bootIndex)
diff --git a/tests/qemuxml2argvdata/hostdev-pci-address-device.args b/tests/qemuxml2argvdata/hostdev-pci-address-device.args
index 4763e1a147..5159b00ef1 100644
--- a/tests/qemuxml2argvdata/hostdev-pci-address-device.args
+++ b/tests/qemuxml2argvdata/hostdev-pci-address-device.args
@@ -27,5 +27,5 @@ server,nowait \
 -usb \
 -drive file=/dev/HostVG/QEMUGuest2,format=raw,if=none,id=drive-ide0-0-0 \
 -device ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \
--device pci-assign,host=06:12.5,id=hostdev0,bus=pci.0,addr=0x3 \
+-device pci-assign,host=0000:06:12.5,id=hostdev0,bus=pci.0,addr=0x3 \
 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x4
diff --git a/tests/qemuxml2argvdata/hostdev-pci-address.args b/tests/qemuxml2argvdata/hostdev-pci-address.args
index d90fb2c085..fe6acaaf62 100644
--- a/tests/qemuxml2argvdata/hostdev-pci-address.args
+++ b/tests/qemuxml2argvdata/hostdev-pci-address.args
@@ -27,4 +27,4 @@ server,nowait \
 -usb \
 -drive file=/dev/HostVG/QEMUGuest2,format=raw,if=none,id=drive-ide0-0-0 \
 -device ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \
--device pci-assign,host=06:12.5,id=hostdev0,bus=pci.0,addr=0x3
+-device pci-assign,host=0000:06:12.5,id=hostdev0,bus=pci.0,addr=0x3
diff --git a/tests/qemuxml2argvdata/hostdev-vfio-zpci-autogenerate.args b/tests/qemuxml2argvdata/hostdev-vfio-zpci-autogenerate.args
index 1861811e8b..963d508066 100644
--- a/tests/qemuxml2argvdata/hostdev-vfio-zpci-autogenerate.args
+++ b/tests/qemuxml2argvdata/hostdev-vfio-zpci-autogenerate.args
@@ -24,6 +24,6 @@ server,nowait \
 -rtc base=utc \
 -no-shutdown \
 -device zpci,uid=1,fid=0,target=hostdev0,id=zpci1 \
--device vfio-pci,host=00:00.0,id=hostdev0,bus=pci.0,addr=0x1 \
+-device vfio-pci,host=0000:00:00.0,id=hostdev0,bus=pci.0,addr=0x1 \
 -device zpci,uid=2,fid=1,target=balloon0,id=zpci2 \
 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x2
diff --git a/tests/qemuxml2argvdata/hostdev-vfio-zpci-boundaries.args b/tests/qemuxml2argvdata/hostdev-vfio-zpci-boundaries.args
index 4a58a1eb8d..2fc4200c23 100644
--- a/tests/qemuxml2argvdata/hostdev-vfio-zpci-boundaries.args
+++ b/tests/qemuxml2argvdata/hostdev-vfio-zpci-boundaries.args
@@ -28,6 +28,6 @@ server,nowait \
 -device zpci,uid=65535,fid=4294967295,target=hostdev0,id=zpci65535 \
 -device vfio-pci,host=ffff:00:00.0,id=hostdev0,bus=pci.1,addr=0x1f \
 -device zpci,uid=1,fid=0,target=hostdev1,id=zpci1 \
--device vfio-pci,host=00:00.0,id=hostdev1,bus=pci.0,addr=0x2 \
+-device vfio-pci,host=0000:00:00.0,id=hostdev1,bus=pci.0,addr=0x2 \
 -device zpci,uid=2,fid=1,target=balloon0,id=zpci2 \
 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
diff --git a/tests/qemuxml2argvdata/hostdev-vfio-zpci.args b/tests/qemuxml2argvdata/hostdev-vfio-zpci.args
index 07405c7c14..d3a762e5d4 100644
--- a/tests/qemuxml2argvdata/hostdev-vfio-zpci.args
+++ b/tests/qemuxml2argvdata/hostdev-vfio-zpci.args
@@ -24,6 +24,6 @@ server,nowait \
 -rtc base=utc \
 -no-shutdown \
 -device zpci,uid=25,fid=31,target=hostdev0,id=zpci25 \
--device vfio-pci,host=00:00.0,id=hostdev0,bus=pci.0,addr=0x8 \
+-device vfio-pci,host=0000:00:00.0,id=hostdev0,bus=pci.0,addr=0x8 \
 -device zpci,uid=1,fid=0,target=balloon0,id=zpci1 \
 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x1
diff --git a/tests/qemuxml2argvdata/hostdev-vfio.args b/tests/qemuxml2argvdata/hostdev-vfio.args
index b86181e267..79654f44bb 100644
--- a/tests/qemuxml2argvdata/hostdev-vfio.args
+++ b/tests/qemuxml2argvdata/hostdev-vfio.args
@@ -27,5 +27,5 @@ server,nowait \
 -usb \
 -drive file=/dev/HostVG/QEMUGuest2,format=raw,if=none,id=drive-ide0-0-0 \
 -device ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \
--device vfio-pci,host=06:12.5,id=hostdev0,bus=pci.0,addr=0x3 \
+-device vfio-pci,host=0000:06:12.5,id=hostdev0,bus=pci.0,addr=0x3 \
 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x4
diff --git a/tests/qemuxml2argvdata/net-hostdev-bootorder.args b/tests/qemuxml2argvdata/net-hostdev-bootorder.args
index 700ed5366b..eefc247eed 100644
--- a/tests/qemuxml2argvdata/net-hostdev-bootorder.args
+++ b/tests/qemuxml2argvdata/net-hostdev-bootorder.args
@@ -27,4 +27,5 @@ server,nowait \
 -usb \
 -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
 -device ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=2 \
--device pci-assign,host=03:07.1,id=hostdev0,bootindex=1,bus=pci.0,addr=0x3
+-device pci-assign,host=0000:03:07.1,id=hostdev0,bootindex=1,bus=pci.0,\
+addr=0x3
diff --git a/tests/qemuxml2argvdata/net-hostdev-vfio.args b/tests/qemuxml2argvdata/net-hostdev-vfio.args
index fcc8716fdf..aa9e91db82 100644
--- a/tests/qemuxml2argvdata/net-hostdev-vfio.args
+++ b/tests/qemuxml2argvdata/net-hostdev-vfio.args
@@ -27,5 +27,5 @@ server,nowait \
 -usb \
 -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
 -device ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \
--device vfio-pci,host=03:07.1,id=hostdev0,bus=pci.0,addr=0x3 \
+-device vfio-pci,host=0000:03:07.1,id=hostdev0,bus=pci.0,addr=0x3 \
 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x4
diff --git a/tests/qemuxml2argvdata/net-hostdev.args b/tests/qemuxml2argvdata/net-hostdev.args
index 75f6934d0d..94eac176f3 100644
--- a/tests/qemuxml2argvdata/net-hostdev.args
+++ b/tests/qemuxml2argvdata/net-hostdev.args
@@ -27,5 +27,5 @@ server,nowait \
 -usb \
 -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
 -device ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \
--device pci-assign,host=03:07.1,id=hostdev0,bus=pci.0,addr=0x3 \
+-device pci-assign,host=0000:03:07.1,id=hostdev0,bus=pci.0,addr=0x3 \
 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x4
diff --git a/tests/qemuxml2argvdata/pci-rom.args b/tests/qemuxml2argvdata/pci-rom.args
index 5f33b20b4e..7235642ee8 100644
--- a/tests/qemuxml2argvdata/pci-rom.args
+++ b/tests/qemuxml2argvdata/pci-rom.args
@@ -33,7 +33,7 @@ addr=0x3,rombar=1 \
 -netdev user,id=hostnet1 \
 -device virtio-net-pci,netdev=hostnet1,id=net1,mac=52:54:00:24:a5:9e,bus=pci.0,\
 addr=0x4,romfile=/etc/fake/bootrom.bin \
--device pci-assign,host=06:12.5,id=hostdev0,bus=pci.0,addr=0x5,rombar=0 \
--device pci-assign,host=06:12.6,id=hostdev1,bus=pci.0,addr=0x6,rombar=1,\
+-device pci-assign,host=0000:06:12.5,id=hostdev0,bus=pci.0,addr=0x5,rombar=0 \
+-device pci-assign,host=0000:06:12.6,id=hostdev1,bus=pci.0,addr=0x6,rombar=1,\
 romfile=/etc/fake/bootrom.bin \
 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x7
-- 
2.21.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 1/6] qemuBuildPCIHostdevDevStr: Always format PCI domain onto cmd line
Posted by Daniel P. Berrangé 6 years, 6 months ago
On Wed, Jul 31, 2019 at 10:32:19AM +0200, Michal Privoznik wrote:
> QEMU is perfectly capable of dealing with fully expanded PCI
> address. Format PCI domain always as it will simplify next
> commits.

Are you sure about that for old QEMUs ?  I have a feeling that
it did not support that in the past.


Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 1/6] qemuBuildPCIHostdevDevStr: Always format PCI domain onto cmd line
Posted by Michal Privoznik 6 years, 6 months ago
On 7/31/19 10:36 AM, Daniel P. Berrangé wrote:
> On Wed, Jul 31, 2019 at 10:32:19AM +0200, Michal Privoznik wrote:
>> QEMU is perfectly capable of dealing with fully expanded PCI
>> address. Format PCI domain always as it will simplify next
>> commits.
> 
> Are you sure about that for old QEMUs ?  I have a feeling that
> it did not support that in the past.

It's not only the commit that Jano referred to, but also the commit that 
introduced PCI address parsing in QEMU supports this from the very 
beginning v1.2.0-rc0~242^2~4. Therefore I think we can safely assume all 
QEMUs we care about are capable of dealing with PCI domain. But let me 
record this in commit message to avoid confusion. The new commit mesage 
now reads:

     qemuBuildPCIHostdevDevStr: Always format PCI domain onto cmd line

     While it's true that older QEMUs were not able to deal with PCI
     domains, we don't support those versions anymore (see
     4a42ece13a538). Therefore it is safe to always format fully
     expanded PCI address. Format PCI domain always as it will
     simplify next commits.


Michal

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 1/6] qemuBuildPCIHostdevDevStr: Always format PCI domain onto cmd line
Posted by Ján Tomko 6 years, 6 months ago
On Wed, Jul 31, 2019 at 09:36:47AM +0100, Daniel P. Berrangé wrote:
>On Wed, Jul 31, 2019 at 10:32:19AM +0200, Michal Privoznik wrote:
>> QEMU is perfectly capable of dealing with fully expanded PCI
>> address. Format PCI domain always as it will simplify next
>> commits.
>
>Are you sure about that for old QEMUs ?  I have a feeling that
>it did not support that in the past.
>
>
commit 4a42ece13a53810410567323dea1719d63877e1f
Author:     Ján Tomko <jtomko@redhat.com>
AuthorDate: 2018-03-29 12:51:55 +0200
Commit:     Ján Tomko <jtomko@redhat.com>
CommitDate: 2018-04-17 14:40:38 +0200

    qemu: deprecate QEMU_CAPS_HOST_PCI_MULTIDOMAIN

    Implied by QEMU >= 1.2.0.

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