qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PULL 0/1] qdev: Fix assert in PCI address property when used by vfio-pci
@ 2016-11-15 18:28 Eduardo Habkost
  2016-11-15 18:29 ` [Qemu-devel] [PULL 1/1] " Eduardo Habkost
  2016-11-15 19:17 ` [Qemu-devel] [PULL 0/1] " Stefan Hajnoczi
  0 siblings, 2 replies; 3+ messages in thread
From: Eduardo Habkost @ 2016-11-15 18:28 UTC (permalink / raw)
  To: qemu-devel, Peter Maydell; +Cc: Igor Mammedov, Marcel Apfelbaum

One bug fix for -rc0.

The following changes since commit 97e53cf82ca0ffa9abe2def2fabc5fc75b914d90:

  Merge remote-tracking branch 'jasowang/tags/net-pull-request' into staging (2016-11-15 12:07:53 +0000)

are available in the git repository at:

  git://github.com/ehabkost/qemu.git tags/machine-pull-request

for you to fetch changes up to 00b8702581f312aa46f797a8b3153d9b2892d967:

  qdev: Fix assert in PCI address property when used by vfio-pci (2016-11-15 15:50:04 -0200)

----------------------------------------------------------------
qdev: Fix assert in PCI address property when used by vfio-pci

----------------------------------------------------------------

Daniel Oram (1):
  qdev: Fix assert in PCI address property when used by vfio-pci

 hw/core/qdev-properties.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

-- 
2.7.4

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Qemu-devel] [PULL 1/1] qdev: Fix assert in PCI address property when used by vfio-pci
  2016-11-15 18:28 [Qemu-devel] [PULL 0/1] qdev: Fix assert in PCI address property when used by vfio-pci Eduardo Habkost
@ 2016-11-15 18:29 ` Eduardo Habkost
  2016-11-15 19:17 ` [Qemu-devel] [PULL 0/1] " Stefan Hajnoczi
  1 sibling, 0 replies; 3+ messages in thread
From: Eduardo Habkost @ 2016-11-15 18:29 UTC (permalink / raw)
  To: qemu-devel, Peter Maydell; +Cc: Igor Mammedov, Marcel Apfelbaum, Daniel Oram

From: Daniel Oram <daniel.oram@gmail.com>

Allow the PCIHostDeviceAddress structure to work as the host property
in vfio-pci when it has it's default value of all fields set to ~0. In
this form the property indicates a non-existant device but given the
field bit sizes gets asserted as excess (and invalid) precision
overflows the string buffer. The BDF of an invalid device
"FFFF:FF:FF.F" is returned instead.

Signed-off-by: Daniel Oram <daniel.oram@gmail.com>
Reviewed-by: Alex Williamson <alex.williamson@redhat.com>
Message-Id: <71f06765c4ba16dcd71cbf78e877619948f04ed9.1478777270.git.daniel.oram@gmail.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 hw/core/qdev-properties.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
index 311af6d..2a82768 100644
--- a/hw/core/qdev-properties.c
+++ b/hw/core/qdev-properties.c
@@ -705,13 +705,19 @@ static void get_pci_host_devaddr(Object *obj, Visitor *v, const char *name,
     DeviceState *dev = DEVICE(obj);
     Property *prop = opaque;
     PCIHostDeviceAddress *addr = qdev_get_prop_ptr(dev, prop);
-    char buffer[] = "xxxx:xx:xx.x";
+    char buffer[] = "ffff:ff:ff.f";
     char *p = buffer;
     int rc = 0;
 
-    rc = snprintf(buffer, sizeof(buffer), "%04x:%02x:%02x.%d",
-                  addr->domain, addr->bus, addr->slot, addr->function);
-    assert(rc == sizeof(buffer) - 1);
+    /*
+     * Catch "invalid" device reference from vfio-pci and allow the
+     * default buffer representing the non-existant device to be used.
+     */
+    if (~addr->domain || ~addr->bus || ~addr->slot || ~addr->function) {
+        rc = snprintf(buffer, sizeof(buffer), "%04x:%02x:%02x.%0d",
+                      addr->domain, addr->bus, addr->slot, addr->function);
+        assert(rc == sizeof(buffer) - 1);
+    }
 
     visit_type_str(v, name, &p, errp);
 }
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PULL 0/1] qdev: Fix assert in PCI address property when used by vfio-pci
  2016-11-15 18:28 [Qemu-devel] [PULL 0/1] qdev: Fix assert in PCI address property when used by vfio-pci Eduardo Habkost
  2016-11-15 18:29 ` [Qemu-devel] [PULL 1/1] " Eduardo Habkost
@ 2016-11-15 19:17 ` Stefan Hajnoczi
  1 sibling, 0 replies; 3+ messages in thread
From: Stefan Hajnoczi @ 2016-11-15 19:17 UTC (permalink / raw)
  To: Eduardo Habkost
  Cc: qemu-devel, Peter Maydell, Marcel Apfelbaum, Igor Mammedov

[-- Attachment #1: Type: text/plain, Size: 1118 bytes --]

On Tue, Nov 15, 2016 at 04:28:59PM -0200, Eduardo Habkost wrote:
> One bug fix for -rc0.
> 
> The following changes since commit 97e53cf82ca0ffa9abe2def2fabc5fc75b914d90:
> 
>   Merge remote-tracking branch 'jasowang/tags/net-pull-request' into staging (2016-11-15 12:07:53 +0000)
> 
> are available in the git repository at:
> 
>   git://github.com/ehabkost/qemu.git tags/machine-pull-request
> 
> for you to fetch changes up to 00b8702581f312aa46f797a8b3153d9b2892d967:
> 
>   qdev: Fix assert in PCI address property when used by vfio-pci (2016-11-15 15:50:04 -0200)
> 
> ----------------------------------------------------------------
> qdev: Fix assert in PCI address property when used by vfio-pci
> 
> ----------------------------------------------------------------
> 
> Daniel Oram (1):
>   qdev: Fix assert in PCI address property when used by vfio-pci
> 
>  hw/core/qdev-properties.c | 14 ++++++++++----
>  1 file changed, 10 insertions(+), 4 deletions(-)
> 
> -- 
> 2.7.4
> 
> 

Thanks, applied to my master tree:
https://github.com/stefanha/qemu/commits/master

Stefan

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 455 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-11-15 19:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-15 18:28 [Qemu-devel] [PULL 0/1] qdev: Fix assert in PCI address property when used by vfio-pci Eduardo Habkost
2016-11-15 18:29 ` [Qemu-devel] [PULL 1/1] " Eduardo Habkost
2016-11-15 19:17 ` [Qemu-devel] [PULL 0/1] " Stefan Hajnoczi

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 NNTP newsgroup(s).