qdev: Fix assert in PCI address property when used by vfio-pci
-----BEGIN PGP SIGNATURE----- iQIcBAABCAAGBQJYK1OGAAoJECgHk2+YTcWm564QALuTbxPJVXBkOsWOURmXx337 e2tnfAM0zci+gyuA4wF2OzUrn6QfwsNf61XTWkkzLoAttlJGQxktbrjglkUF16Kn VbG2XQKBGRhXxCjziO9IKz5JtJkLpvSBc5nzkUL6HGWRY3wAbFibHwP00xv4ZJWx irZaJJz1acVhpdFEzFUTTc0H/QhFmg5Oewx4lwTvHj7WLmd112Y2Wst/iTpwokcX cKCBhQUSL5tiAwt8QWb4aR+0PpT+oNwB14xFJXrVRBmy/+dln5inZO9wLpEWRkv1 UeCz7UyHrReBNAD9Dv2j4NEOPB8ANe/iCFL0++C4TihJ8kJbSgrNjDnfL3/bUpO/ HK7rueJ6VVXght43je94V75F1R8HowAflNny2fDwNhP8n5RBUQTwvj8Yue2JWh0W RaK4UweDVGRbADVifgnIdTVEGEHfnj5Dy13dA0sU3UgcxkGGQ4uBMhVNhuHFh3Aq rTWHyd5VFwOZfFNTc5wK1C+ZXu10ZDLETm1V8bjI6NUQeEhOC3JSwxQJKy8SyDEw OE5mf+4yzA9fgsn+q5EHun63x0ddI3Y8+/6vJi9cyutiYoYsxvet0aBc8omLrdV2 /GRMf7pLl6MF3917IqxOKTY892AYDOkmGCVe4OBq63FVxWLEzCGmRjNEK33Jc7pd q4cst1qaZ5UEdBB4sRBy =/oL0 -----END PGP SIGNATURE----- Merge remote-tracking branch 'ehabkost/tags/machine-pull-request' into staging qdev: Fix assert in PCI address property when used by vfio-pci # gpg: Signature made Tue 15 Nov 2016 06:27:18 PM GMT # gpg: using RSA key 0x2807936F984DC5A6 # gpg: Good signature from "Eduardo Habkost <ehabkost@redhat.com>" # Primary key fingerprint: 5A32 2FD5 ABC4 D3DB ACCF D1AA 2807 936F 984D C5A6 * ehabkost/tags/machine-pull-request: qdev: Fix assert in PCI address property when used by vfio-pci Message-id: 1479234540-3192-1-git-send-email-ehabkost@redhat.com Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
commit
60c5a47a16
@ -705,13 +705,19 @@ static void get_pci_host_devaddr(Object *obj, Visitor *v, const char *name,
|
|||||||
DeviceState *dev = DEVICE(obj);
|
DeviceState *dev = DEVICE(obj);
|
||||||
Property *prop = opaque;
|
Property *prop = opaque;
|
||||||
PCIHostDeviceAddress *addr = qdev_get_prop_ptr(dev, prop);
|
PCIHostDeviceAddress *addr = qdev_get_prop_ptr(dev, prop);
|
||||||
char buffer[] = "xxxx:xx:xx.x";
|
char buffer[] = "ffff:ff:ff.f";
|
||||||
char *p = buffer;
|
char *p = buffer;
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
|
||||||
rc = snprintf(buffer, sizeof(buffer), "%04x:%02x:%02x.%d",
|
/*
|
||||||
|
* 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);
|
addr->domain, addr->bus, addr->slot, addr->function);
|
||||||
assert(rc == sizeof(buffer) - 1);
|
assert(rc == sizeof(buffer) - 1);
|
||||||
|
}
|
||||||
|
|
||||||
visit_type_str(v, name, &p, errp);
|
visit_type_str(v, name, &p, errp);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user