Fix error handling during zpci device creation.

-----BEGIN PGP SIGNATURE-----
 
 iQJGBAABCAAwFiEEw9DWbcNiT/aowBjO3s9rk8bwL68FAlvr9CsSHGNvaHVja0By
 ZWRoYXQuY29tAAoJEN7Pa5PG8C+vtDoP/j3m/iwzmSclKQlnipcg3QQQ8Lv65TAU
 nTF8Oq+F6FEG5h2WoaMWSnG6hhycxxA1sbKlPNNmGwJscb9FaGLtxFmg5UTfwZUk
 NXenftO35rjP98b9bUTJVvXncSraFG8lZjwuKbEg0fJbZ0mr+D1W6OgS+FGp1Moz
 pcyfI4rTnJN167++k56LD72rse7c3GKFOVbtSq5bXrUFD3bo7hGSKJ+RRmDigVFi
 CicFLoc87P2XLVSroAygarK9FMCCNufqKPKjZdU0TZHg5WChLiw72ZtZYwO80ZuJ
 fcQ8L013oMpcytF82ZgQ9voTDgoHRc321IJqCeTFLwSSOVKbHa3uQ/s9wuu41X84
 Xy9GNB01StjNqz/RO88/Q/1HBbhhrnPzcl1oIMSvTh2fFkjSAPZpfuKVv7znNonU
 XTwUfBTadcSSf1D5r3ggqtfdtu9KYoh2hE55C/eRFXH6pF6SKgSOfqr/yedauzmN
 gwyPjBdySB3OUPdjMzZRMBAtp3/y3sXeoGKBkyumkc+RxnJzwNEt6GtkG99Pde1i
 5tW4DCdvmJJDiMPID+acpZ8qKv4/Ccs30mq4OONbEufjrPPgP+nP7Z7JB2NZAmua
 jBzjELXyDWe5Pu+EJgP8wOOtT+Q6Gue8wMf6r95Y7vYSmu2tnEdTo2ump3SQx46F
 PNVTH023qsYZ
 =jqHW
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'remotes/cohuck/tags/s390x-20181114' into staging

Fix error handling during zpci device creation.

# gpg: Signature made Wed 14 Nov 2018 10:08:43 GMT
# gpg:                using RSA key DECF6B93C6F02FAF
# gpg: Good signature from "Cornelia Huck <conny@cornelia-huck.de>"
# gpg:                 aka "Cornelia Huck <huckc@linux.vnet.ibm.com>"
# gpg:                 aka "Cornelia Huck <cornelia.huck@de.ibm.com>"
# gpg:                 aka "Cornelia Huck <cohuck@kernel.org>"
# gpg:                 aka "Cornelia Huck <cohuck@redhat.com>"
# Primary key fingerprint: C3D0 D66D C362 4FF6 A8C0  18CE DECF 6B93 C6F0 2FAF

* remotes/cohuck/tags/s390x-20181114:
  s390x/pci: properly fail if the zPCI device cannot be created

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Peter Maydell 2018-11-15 10:01:16 +00:00
commit 18d30e7b59

View File

@ -780,17 +780,31 @@ static void s390_pci_msix_free(S390PCIBusDevice *pbdev)
}
static S390PCIBusDevice *s390_pci_device_new(S390pciState *s,
const char *target)
const char *target, Error **errp)
{
DeviceState *dev = NULL;
Error *local_err = NULL;
DeviceState *dev;
dev = qdev_try_create(BUS(s->bus), TYPE_S390_PCI_DEVICE);
if (!dev) {
error_setg(errp, "zPCI device could not be created");
return NULL;
}
qdev_prop_set_string(dev, "target", target);
qdev_init_nofail(dev);
object_property_set_str(OBJECT(dev), target, "target", &local_err);
if (local_err) {
object_unparent(OBJECT(dev));
error_propagate_prepend(errp, local_err,
"zPCI device could not be created: ");
return NULL;
}
object_property_set_bool(OBJECT(dev), true, "realized", &local_err);
if (local_err) {
object_unparent(OBJECT(dev));
error_propagate_prepend(errp, local_err,
"zPCI device could not be created: ");
return NULL;
}
return S390_PCI_DEVICE(dev);
}
@ -865,9 +879,8 @@ static void s390_pcihost_hot_plug(HotplugHandler *hotplug_dev,
pbdev = s390_pci_find_dev_by_target(s, dev->id);
if (!pbdev) {
pbdev = s390_pci_device_new(s, dev->id);
pbdev = s390_pci_device_new(s, dev->id, errp);
if (!pbdev) {
error_setg(errp, "create zpci device failed");
return;
}
}