~ubuntu-branches/ubuntu/precise/qemu-kvm/precise

« back to all changes in this revision

Viewing changes to dma-helpers.c

  • Committer: Serge Hallyn
  • Date: 2011-10-19 07:37:43 UTC
  • mfrom: (1.2.7)
  • Revision ID: serge.hallyn@ubuntu.com-20111019073743-7i7n9irsxlm38wic
Tags: 0.15.0+noroms-0ubuntu1
* New upstream release
* Remaining changes from upstream:
  - removed all binary roms and tests/pi_10.com
* Removed Detect-and-use-GCC-atomic-builtins-for-locking.patch - non-NPTL
  implementations were removed with commit
  02615337ef295443daa03233e492194e289a807e
* Drop spice-qxl-locking-fix-for-qemu-kvm.patch - should be unnecessary
  as of commit 196a778428989217b82de042725dc8eb29c8f8d8
* drop patches applied upstream:
  - CVE-2011-1751.diff
  - virtio-guard-against-negative-vq-notifies-CVE-2011-2512.diff
  - CVE-2011-2527.patch
  - fix-pa-configure.patch
* Refreshed the remaining patches:
  - larger_default_ram_size.patch
  - CVE-2011-2212-virtqueue-indirect-overflow.patch
  - qemuifup-fix-paths.patch
  - vpc.patch
* e1000-Dont-set-the-Capabilities-List-bit.patch - switched to the
  cherrypicked upstream patch (as the source file changed quite a bit,
  and the hand-ported patch backported to 0.14.1 does not apply).
* Drop qemu-kvm-spice (all changes from 0.14.1+noroms-0ubuntu7), it will
  need its own source package (LP: #878162)

Show diffs side-by-side

added added

removed removed

Lines of Context:
47
47
    target_phys_addr_t sg_cur_byte;
48
48
    QEMUIOVector iov;
49
49
    QEMUBH *bh;
 
50
    DMAIOFunc *io_func;
50
51
} DMAAIOCB;
51
52
 
52
53
static void dma_bdrv_cb(void *opaque, int ret);
116
117
        return;
117
118
    }
118
119
 
119
 
    if (dbs->is_write) {
120
 
        dbs->acb = bdrv_aio_writev(dbs->bs, dbs->sector_num, &dbs->iov,
121
 
                                   dbs->iov.size / 512, dma_bdrv_cb, dbs);
122
 
    } else {
123
 
        dbs->acb = bdrv_aio_readv(dbs->bs, dbs->sector_num, &dbs->iov,
124
 
                                  dbs->iov.size / 512, dma_bdrv_cb, dbs);
125
 
    }
 
120
    dbs->acb = dbs->io_func(dbs->bs, dbs->sector_num, &dbs->iov,
 
121
                            dbs->iov.size / 512, dma_bdrv_cb, dbs);
126
122
    if (!dbs->acb) {
127
123
        dma_bdrv_unmap(dbs);
128
124
        qemu_iovec_destroy(&dbs->iov);
144
140
    .cancel             = dma_aio_cancel,
145
141
};
146
142
 
147
 
static BlockDriverAIOCB *dma_bdrv_io(
 
143
BlockDriverAIOCB *dma_bdrv_io(
148
144
    BlockDriverState *bs, QEMUSGList *sg, uint64_t sector_num,
149
 
    BlockDriverCompletionFunc *cb, void *opaque,
150
 
    int is_write)
 
145
    DMAIOFunc *io_func, BlockDriverCompletionFunc *cb,
 
146
    void *opaque, int is_write)
151
147
{
152
 
    DMAAIOCB *dbs =  qemu_aio_get(&dma_aio_pool, bs, cb, opaque);
 
148
    DMAAIOCB *dbs = qemu_aio_get(&dma_aio_pool, bs, cb, opaque);
153
149
 
154
150
    dbs->acb = NULL;
155
151
    dbs->bs = bs;
158
154
    dbs->sg_cur_index = 0;
159
155
    dbs->sg_cur_byte = 0;
160
156
    dbs->is_write = is_write;
 
157
    dbs->io_func = io_func;
161
158
    dbs->bh = NULL;
162
159
    qemu_iovec_init(&dbs->iov, sg->nsg);
163
 
    /*
164
 
     * DMA flushing is handled in dma_bdrv_cb() calling dma_bdrv_unmap()
165
 
     * so we don't need to do that here.
166
 
     */
167
160
    dma_bdrv_cb(dbs, 0);
168
161
    if (!dbs->acb) {
169
162
        qemu_aio_release(dbs);
177
170
                                QEMUSGList *sg, uint64_t sector,
178
171
                                void (*cb)(void *opaque, int ret), void *opaque)
179
172
{
180
 
    return dma_bdrv_io(bs, sg, sector, cb, opaque, 0);
 
173
    return dma_bdrv_io(bs, sg, sector, bdrv_aio_readv, cb, opaque, 0);
181
174
}
182
175
 
183
176
BlockDriverAIOCB *dma_bdrv_write(BlockDriverState *bs,
184
177
                                 QEMUSGList *sg, uint64_t sector,
185
178
                                 void (*cb)(void *opaque, int ret), void *opaque)
186
179
{
187
 
    return dma_bdrv_io(bs, sg, sector, cb, opaque, 1);
 
180
    return dma_bdrv_io(bs, sg, sector, bdrv_aio_writev, cb, opaque, 1);
188
181
}