mirror of https://gitee.com/openkylin/qemu.git
hw/block: Use errp directly rather than local_err
[Drop virtio_blk_data_plane_create() change that misinterprets return value when the virtio transport does not support dataplane. --Stefan] Cc: John Snow <jsnow@redhat.com> Cc: Kevin Wolf <kwolf@redhat.com> Cc: Max Reitz <mreitz@redhat.com> Cc: Keith Busch <keith.busch@intel.com> Cc: Stefan Hajnoczi <stefanha@redhat.com> Cc: "Michael S. Tsirkin" <mst@redhat.com> Cc: Paolo Bonzini <pbonzini@redhat.com> Cc: Gerd Hoffmann <kraxel@redhat.com> Cc: Markus Armbruster <armbru@redhat.com> Signed-off-by: Mao Zhongyi <maozy.fnst@cn.fujitsu.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Message-id: e77848d3735ba590f23ffbf8094379c646c33d79.1511317952.git.maozy.fnst@cn.fujitsu.com Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
parent
9d3b155186
commit
ceff3e1f01
|
@ -473,16 +473,13 @@ static void fd_revalidate(FDrive *drv)
|
||||||
static void fd_change_cb(void *opaque, bool load, Error **errp)
|
static void fd_change_cb(void *opaque, bool load, Error **errp)
|
||||||
{
|
{
|
||||||
FDrive *drive = opaque;
|
FDrive *drive = opaque;
|
||||||
Error *local_err = NULL;
|
|
||||||
|
|
||||||
if (!load) {
|
if (!load) {
|
||||||
blk_set_perm(drive->blk, 0, BLK_PERM_ALL, &error_abort);
|
blk_set_perm(drive->blk, 0, BLK_PERM_ALL, &error_abort);
|
||||||
} else {
|
} else {
|
||||||
blkconf_apply_backend_options(drive->conf,
|
if (!blkconf_apply_backend_options(drive->conf,
|
||||||
blk_is_read_only(drive->blk), false,
|
blk_is_read_only(drive->blk), false,
|
||||||
&local_err);
|
errp)) {
|
||||||
if (local_err) {
|
|
||||||
error_propagate(errp, local_err);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -522,7 +519,6 @@ static void floppy_drive_realize(DeviceState *qdev, Error **errp)
|
||||||
FloppyDrive *dev = FLOPPY_DRIVE(qdev);
|
FloppyDrive *dev = FLOPPY_DRIVE(qdev);
|
||||||
FloppyBus *bus = FLOPPY_BUS(qdev->parent_bus);
|
FloppyBus *bus = FLOPPY_BUS(qdev->parent_bus);
|
||||||
FDrive *drive;
|
FDrive *drive;
|
||||||
Error *local_err = NULL;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (dev->unit == -1) {
|
if (dev->unit == -1) {
|
||||||
|
@ -568,10 +564,9 @@ static void floppy_drive_realize(DeviceState *qdev, Error **errp)
|
||||||
dev->conf.rerror = BLOCKDEV_ON_ERROR_AUTO;
|
dev->conf.rerror = BLOCKDEV_ON_ERROR_AUTO;
|
||||||
dev->conf.werror = BLOCKDEV_ON_ERROR_AUTO;
|
dev->conf.werror = BLOCKDEV_ON_ERROR_AUTO;
|
||||||
|
|
||||||
blkconf_apply_backend_options(&dev->conf, blk_is_read_only(dev->conf.blk),
|
if (!blkconf_apply_backend_options(&dev->conf,
|
||||||
false, &local_err);
|
blk_is_read_only(dev->conf.blk),
|
||||||
if (local_err) {
|
false, errp)) {
|
||||||
error_propagate(errp, local_err);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -928,7 +928,6 @@ static void nvme_realize(PCIDevice *pci_dev, Error **errp)
|
||||||
int i;
|
int i;
|
||||||
int64_t bs_size;
|
int64_t bs_size;
|
||||||
uint8_t *pci_conf;
|
uint8_t *pci_conf;
|
||||||
Error *local_err = NULL;
|
|
||||||
|
|
||||||
if (!n->conf.blk) {
|
if (!n->conf.blk) {
|
||||||
error_setg(errp, "drive property not set");
|
error_setg(errp, "drive property not set");
|
||||||
|
@ -947,10 +946,8 @@ static void nvme_realize(PCIDevice *pci_dev, Error **errp)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
blkconf_blocksizes(&n->conf);
|
blkconf_blocksizes(&n->conf);
|
||||||
blkconf_apply_backend_options(&n->conf, blk_is_read_only(n->conf.blk),
|
if (!blkconf_apply_backend_options(&n->conf, blk_is_read_only(n->conf.blk),
|
||||||
false, &local_err);
|
false, errp)) {
|
||||||
if (local_err) {
|
|
||||||
error_propagate(errp, local_err);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -930,19 +930,16 @@ static void virtio_blk_device_realize(DeviceState *dev, Error **errp)
|
||||||
}
|
}
|
||||||
|
|
||||||
blkconf_serial(&conf->conf, &conf->serial);
|
blkconf_serial(&conf->conf, &conf->serial);
|
||||||
blkconf_apply_backend_options(&conf->conf,
|
if (!blkconf_apply_backend_options(&conf->conf,
|
||||||
blk_is_read_only(conf->conf.blk), true,
|
blk_is_read_only(conf->conf.blk), true,
|
||||||
&err);
|
errp)) {
|
||||||
if (err) {
|
|
||||||
error_propagate(errp, err);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
s->original_wce = blk_enable_write_cache(conf->conf.blk);
|
s->original_wce = blk_enable_write_cache(conf->conf.blk);
|
||||||
blkconf_geometry(&conf->conf, NULL, 65535, 255, 255, &err);
|
if (!blkconf_geometry(&conf->conf, NULL, 65535, 255, 255, errp)) {
|
||||||
if (err) {
|
|
||||||
error_propagate(errp, err);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
blkconf_blocksizes(&conf->conf);
|
blkconf_blocksizes(&conf->conf);
|
||||||
|
|
||||||
virtio_init(vdev, "virtio-blk", VIRTIO_ID_BLOCK,
|
virtio_init(vdev, "virtio-blk", VIRTIO_ID_BLOCK,
|
||||||
|
|
|
@ -160,7 +160,6 @@ static void ide_dev_initfn(IDEDevice *dev, IDEDriveKind kind, Error **errp)
|
||||||
{
|
{
|
||||||
IDEBus *bus = DO_UPCAST(IDEBus, qbus, dev->qdev.parent_bus);
|
IDEBus *bus = DO_UPCAST(IDEBus, qbus, dev->qdev.parent_bus);
|
||||||
IDEState *s = bus->ifs + dev->unit;
|
IDEState *s = bus->ifs + dev->unit;
|
||||||
Error *err = NULL;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (!dev->conf.blk) {
|
if (!dev->conf.blk) {
|
||||||
|
@ -191,16 +190,13 @@ static void ide_dev_initfn(IDEDevice *dev, IDEDriveKind kind, Error **errp)
|
||||||
|
|
||||||
blkconf_serial(&dev->conf, &dev->serial);
|
blkconf_serial(&dev->conf, &dev->serial);
|
||||||
if (kind != IDE_CD) {
|
if (kind != IDE_CD) {
|
||||||
blkconf_geometry(&dev->conf, &dev->chs_trans, 65535, 16, 255, &err);
|
if (!blkconf_geometry(&dev->conf, &dev->chs_trans, 65535, 16, 255,
|
||||||
if (err) {
|
errp)) {
|
||||||
error_propagate(errp, err);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
blkconf_apply_backend_options(&dev->conf, kind == IDE_CD, kind != IDE_CD,
|
if (!blkconf_apply_backend_options(&dev->conf, kind == IDE_CD,
|
||||||
&err);
|
kind != IDE_CD, errp)) {
|
||||||
if (err) {
|
|
||||||
error_propagate(errp, err);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2332,7 +2332,6 @@ static void scsi_disk_unit_attention_reported(SCSIDevice *dev)
|
||||||
static void scsi_realize(SCSIDevice *dev, Error **errp)
|
static void scsi_realize(SCSIDevice *dev, Error **errp)
|
||||||
{
|
{
|
||||||
SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, dev);
|
SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, dev);
|
||||||
Error *err = NULL;
|
|
||||||
|
|
||||||
if (!s->qdev.conf.blk) {
|
if (!s->qdev.conf.blk) {
|
||||||
error_setg(errp, "drive property not set");
|
error_setg(errp, "drive property not set");
|
||||||
|
@ -2356,17 +2355,13 @@ static void scsi_realize(SCSIDevice *dev, Error **errp)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dev->type == TYPE_DISK) {
|
if (dev->type == TYPE_DISK) {
|
||||||
blkconf_geometry(&dev->conf, NULL, 65535, 255, 255, &err);
|
if (!blkconf_geometry(&dev->conf, NULL, 65535, 255, 255, errp)) {
|
||||||
if (err) {
|
|
||||||
error_propagate(errp, err);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
blkconf_apply_backend_options(&dev->conf,
|
if (!blkconf_apply_backend_options(&dev->conf,
|
||||||
blk_is_read_only(s->qdev.conf.blk),
|
blk_is_read_only(s->qdev.conf.blk),
|
||||||
dev->type == TYPE_DISK, &err);
|
dev->type == TYPE_DISK, errp)) {
|
||||||
if (err) {
|
|
||||||
error_propagate(errp, err);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -601,7 +601,6 @@ static void usb_msd_realize_storage(USBDevice *dev, Error **errp)
|
||||||
MSDState *s = USB_STORAGE_DEV(dev);
|
MSDState *s = USB_STORAGE_DEV(dev);
|
||||||
BlockBackend *blk = s->conf.blk;
|
BlockBackend *blk = s->conf.blk;
|
||||||
SCSIDevice *scsi_dev;
|
SCSIDevice *scsi_dev;
|
||||||
Error *err = NULL;
|
|
||||||
|
|
||||||
if (!blk) {
|
if (!blk) {
|
||||||
error_setg(errp, "drive property not set");
|
error_setg(errp, "drive property not set");
|
||||||
|
@ -610,9 +609,8 @@ static void usb_msd_realize_storage(USBDevice *dev, Error **errp)
|
||||||
|
|
||||||
blkconf_serial(&s->conf, &dev->serial);
|
blkconf_serial(&s->conf, &dev->serial);
|
||||||
blkconf_blocksizes(&s->conf);
|
blkconf_blocksizes(&s->conf);
|
||||||
blkconf_apply_backend_options(&s->conf, blk_is_read_only(blk), true, &err);
|
if (!blkconf_apply_backend_options(&s->conf, blk_is_read_only(blk), true,
|
||||||
if (err) {
|
errp)) {
|
||||||
error_propagate(errp, err);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -636,10 +634,9 @@ static void usb_msd_realize_storage(USBDevice *dev, Error **errp)
|
||||||
&usb_msd_scsi_info_storage, NULL);
|
&usb_msd_scsi_info_storage, NULL);
|
||||||
scsi_dev = scsi_bus_legacy_add_drive(&s->bus, blk, 0, !!s->removable,
|
scsi_dev = scsi_bus_legacy_add_drive(&s->bus, blk, 0, !!s->removable,
|
||||||
s->conf.bootindex, dev->serial,
|
s->conf.bootindex, dev->serial,
|
||||||
&err);
|
errp);
|
||||||
blk_unref(blk);
|
blk_unref(blk);
|
||||||
if (!scsi_dev) {
|
if (!scsi_dev) {
|
||||||
error_propagate(errp, err);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
usb_msd_handle_reset(dev);
|
usb_msd_handle_reset(dev);
|
||||||
|
|
Loading…
Reference in New Issue