~ubuntu-branches/ubuntu/trusty/qemu/trusty

« back to all changes in this revision

Viewing changes to hw/block/dataplane/virtio-blk.c

  • Committer: Package Import Robot
  • Author(s): Marc Deslauriers
  • Date: 2014-01-27 09:10:37 UTC
  • Revision ID: package-import@ubuntu.com-20140127091037-qf1lsx2iau13d3sk
Tags: 1.7.0+dfsg-2ubuntu8
* SECURITY UPDATE: denial of service via virtio device hot-plugging
  - debian/patches/CVE-2013-4377.patch: upstream commits to refactor
    virtio device unplugging.
  - CVE-2013-4377

Show diffs side-by-side

added added

removed removed

Lines of Context:
380
380
                       s, QEMU_THREAD_JOINABLE);
381
381
}
382
382
 
383
 
bool virtio_blk_data_plane_create(VirtIODevice *vdev, VirtIOBlkConf *blk,
384
 
                                  VirtIOBlockDataPlane **dataplane)
 
383
void virtio_blk_data_plane_create(VirtIODevice *vdev, VirtIOBlkConf *blk,
 
384
                                  VirtIOBlockDataPlane **dataplane,
 
385
                                  Error **errp)
385
386
{
386
387
    VirtIOBlockDataPlane *s;
387
388
    int fd;
389
390
    *dataplane = NULL;
390
391
 
391
392
    if (!blk->data_plane) {
392
 
        return true;
 
393
        return;
393
394
    }
394
395
 
395
396
    if (blk->scsi) {
396
 
        error_report("device is incompatible with x-data-plane, use scsi=off");
397
 
        return false;
 
397
        error_setg(errp,
 
398
                   "device is incompatible with x-data-plane, use scsi=off");
 
399
        return;
398
400
    }
399
401
 
400
402
    if (blk->config_wce) {
401
 
        error_report("device is incompatible with x-data-plane, "
402
 
                     "use config-wce=off");
403
 
        return false;
 
403
        error_setg(errp, "device is incompatible with x-data-plane, "
 
404
                         "use config-wce=off");
 
405
        return;
404
406
    }
405
407
 
406
408
    /* If dataplane is (re-)enabled while the guest is running there could be
407
409
     * block jobs that can conflict.
408
410
     */
409
411
    if (bdrv_in_use(blk->conf.bs)) {
410
 
        error_report("cannot start dataplane thread while device is in use");
411
 
        return false;
 
412
        error_setg(errp,
 
413
                   "cannot start dataplane thread while device is in use");
 
414
        return;
412
415
    }
413
416
 
414
417
    fd = raw_get_aio_fd(blk->conf.bs);
415
418
    if (fd < 0) {
416
 
        error_report("drive is incompatible with x-data-plane, "
417
 
                     "use format=raw,cache=none,aio=native");
418
 
        return false;
 
419
        error_setg(errp, "drive is incompatible with x-data-plane, "
 
420
                         "use format=raw,cache=none,aio=native");
 
421
        return;
419
422
    }
420
423
 
421
424
    s = g_new0(VirtIOBlockDataPlane, 1);
427
430
    bdrv_set_in_use(blk->conf.bs, 1);
428
431
 
429
432
    *dataplane = s;
430
 
    return true;
431
433
}
432
434
 
433
435
void virtio_blk_data_plane_destroy(VirtIOBlockDataPlane *s)