Skip to content

Commit

Permalink
0.12.5 - upstream 174f225 - Jul 22, 2010
Browse files Browse the repository at this point in the history
  • Loading branch information
gdwnldsKSC committed Sep 25, 2024
1 parent bcd9c6b commit baae3fc
Show file tree
Hide file tree
Showing 57 changed files with 594 additions and 442 deletions.
47 changes: 47 additions & 0 deletions qemu/Changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,50 @@
version 0.12.5
- audio/alsa: Handle SND_PCM_STATE_SETUP in alsa_poll_handler
- block: Handle multiwrite errors only when all requests have completed
- block: Fix early failure in multiwrite
- vpc: Use bdrv_(p)write_sync for metadata writes
- vmdk: Use bdrv_(p)write_sync for metadata writes
- qcow2: Use bdrv_(p)write_sync for metadata writes
- qcow: Use bdrv_(p)write_sync for metadata writes
- block: Add bdrv_(p)write_sync
- qcow2: Restore L1 entry on l2_allocate failure
- block/vdi: Fix image opening and creation for odd disk sizes
- block/vpc: Fix conversion from size to disk geometry
- qcow2: Remove abort on free_clusters failure
- vmdk: Fix COW
- qcow2: Fix creation of large images
- vmdk: fix double free
- qemu-options: add documentation for stdio signal=on|off
- target-arm : fix parallel saturated subtraction implementation
- target-arm : fix thumb2 parallel add/sub opcode decoding
- target-arm: fix addsub/subadd implementation
- target-i386: fix xchg rax,r8
- block/vvfat.c: fix warnings with _FORTIFY_SOURCE
- audio/alsa: Spelling typo (paramters)
- target-mips: fix DINSU instruction
- Correct definitions for FD_CMD_SAVE and FD_CMD_RESTORE
- qcow2: Fix corruption after error in update_refcount
- qcow2: Fix corruption after refblock allocation
- block: Fix multiwrite with overlapping requests
- qcow2: Fix error handling in l2_allocate
- qcow2: Clear L2 table cache after write error
- ide: Fix ide_dma_cancel
- usb-bus: fix no params
- Avoid crash on '-usbdevice <device>' without parameters
- Fix -usbdevice crash
- Fix multiboot compilation
- Fix missing symbols in .rel/.rela.plt sections
- target-ppc: fix RFI by clearing some bits of MSR
- Fix typo in balloon help
- arm_timer: fix oneshot mode
- arm_timer: reload timer when enabled
- qemu-sockets: avoid strlen of NULL pointer
- block: fix aio_flush segfaults for read-only protocols (e.g. curl)
- virtio-blk: fix barrier support
- block: fix sector comparism in multiwrite_req_compare
- pci: irq_state vmstate breakage
- qemu-img: use the heap instead of the huge stack array for win32

version 0.12.4
- Workaround for broken OSS_GETVERSION on FreeBSD, part two (Juergen Lock)
- oss: fix fragment setting (malc)
Expand Down
2 changes: 1 addition & 1 deletion qemu/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.12.4
0.12.5
4 changes: 3 additions & 1 deletion qemu/aio.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,9 @@ void qemu_aio_flush(void)
qemu_aio_wait();

QLIST_FOREACH(node, &aio_handlers, node) {
ret |= node->io_flush(node->opaque);
if (node->io_flush) {
ret |= node->io_flush(node->opaque);
}
}
} while (qemu_bh_poll() || ret > 0);
}
Expand Down
6 changes: 5 additions & 1 deletion qemu/audio/alsaaudio.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,10 @@ static void alsa_poll_handler (void *opaque)

state = snd_pcm_state (hlp->handle);
switch (state) {
case SND_PCM_STATE_SETUP:
alsa_recover (hlp->handle);
break;

case SND_PCM_STATE_XRUN:
alsa_recover (hlp->handle);
break;
Expand Down Expand Up @@ -665,7 +669,7 @@ static int alsa_open (int in, struct alsa_params_req *req,
(obt->fmt != req->fmt ||
obt->nchannels != req->nchannels ||
obt->freq != req->freq)) {
dolog ("Audio paramters for %s\n", typ);
dolog ("Audio parameters for %s\n", typ);
alsa_dump_info (req, obt);
}

Expand Down
2 changes: 1 addition & 1 deletion qemu/audio/mixeng.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#ifdef FLOAT_MIXENG
typedef float mixeng_real;
struct mixeng_volume { int mute; mixeng_real r; mixeng_real l; };
struct mixeng_sample { mixeng_real l; mixeng_real r; };
struct st_sample { mixeng_real l; mixeng_real r; };
#else
struct mixeng_volume { int mute; int64_t r; int64_t l; };
struct st_sample { int64_t l; int64_t r; };
Expand Down
100 changes: 87 additions & 13 deletions qemu/block.c
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,8 @@ int bdrv_open2(BlockDriverState *bs, const char *filename, int flags,
(flags & (BDRV_O_CACHE_MASK|BDRV_O_NATIVE_AIO));
else
open_flags = flags & ~(BDRV_O_FILE | BDRV_O_SNAPSHOT);

bs->open_flags = open_flags;
if (use_bdrv_whitelist && !bdrv_is_whitelisted(drv))
ret = -ENOTSUP;
else
Expand Down Expand Up @@ -791,6 +793,43 @@ int bdrv_pwrite(BlockDriverState *bs, int64_t offset,
return count1;
}

/*
* Writes to the file and ensures that no writes are reordered across this
* request (acts as a barrier)
*
* Returns 0 on success, -errno in error cases.
*/
int bdrv_pwrite_sync(BlockDriverState *bs, int64_t offset,
const void *buf, int count)
{
int ret;

ret = bdrv_pwrite(bs, offset, buf, count);
if (ret < 0) {
return ret;
}

/* No flush needed for cache=writethrough, it uses O_DSYNC */
if ((bs->open_flags & BDRV_O_CACHE_MASK) != 0) {
bdrv_flush(bs);
}

return 0;
}

/*
* Writes to the file and ensures that no writes are reordered across this
* request (acts as a barrier)
*
* Returns 0 on success, -errno in error cases.
*/
int bdrv_write_sync(BlockDriverState *bs, int64_t sector_num,
const uint8_t *buf, int nb_sectors)
{
return bdrv_pwrite_sync(bs, BDRV_SECTOR_SIZE * sector_num,
buf, BDRV_SECTOR_SIZE * nb_sectors);
}

/**
* Truncate file to 'offset' bytes (needed only for file protocols)
*/
Expand Down Expand Up @@ -1633,6 +1672,9 @@ static void multiwrite_user_cb(MultiwriteCB *mcb)

for (i = 0; i < mcb->num_callbacks; i++) {
mcb->callbacks[i].cb(mcb->callbacks[i].opaque, mcb->error);
if (mcb->callbacks[i].free_qiov) {
qemu_iovec_destroy(mcb->callbacks[i].free_qiov);
}
qemu_free(mcb->callbacks[i].free_qiov);
qemu_vfree(mcb->callbacks[i].free_buf);
}
Expand All @@ -1644,21 +1686,30 @@ static void multiwrite_cb(void *opaque, int ret)

if (ret < 0 && !mcb->error) {
mcb->error = ret;
multiwrite_user_cb(mcb);
}

mcb->num_requests--;
if (mcb->num_requests == 0) {
if (mcb->error == 0) {
multiwrite_user_cb(mcb);
}
multiwrite_user_cb(mcb);
qemu_free(mcb);
}
}

static int multiwrite_req_compare(const void *a, const void *b)
{
return (((BlockRequest*) a)->sector - ((BlockRequest*) b)->sector);
const BlockRequest *req1 = a, *req2 = b;

/*
* Note that we can't simply subtract req2->sector from req1->sector
* here as that could overflow the return value.
*/
if (req1->sector > req2->sector) {
return 1;
} else if (req1->sector < req2->sector) {
return -1;
} else {
return 0;
}
}

/*
Expand Down Expand Up @@ -1721,7 +1772,7 @@ static int multiwrite_merge(BlockDriverState *bs, BlockRequest *reqs,
// Add the second request
qemu_iovec_concat(qiov, reqs[i].qiov, reqs[i].qiov->size);

reqs[outidx].nb_sectors += reqs[i].nb_sectors;
reqs[outidx].nb_sectors = qiov->size >> 9;
reqs[outidx].qiov = qiov;

mcb->callbacks[i].free_qiov = reqs[outidx].qiov;
Expand Down Expand Up @@ -1773,32 +1824,55 @@ int bdrv_aio_multiwrite(BlockDriverState *bs, BlockRequest *reqs, int num_reqs)
// Check for mergable requests
num_reqs = multiwrite_merge(bs, reqs, num_reqs, mcb);

// Run the aio requests
/*
* Run the aio requests. As soon as one request can't be submitted
* successfully, fail all requests that are not yet submitted (we must
* return failure for all requests anyway)
*
* num_requests cannot be set to the right value immediately: If
* bdrv_aio_writev fails for some request, num_requests would be too high
* and therefore multiwrite_cb() would never recognize the multiwrite
* request as completed. We also cannot use the loop variable i to set it
* when the first request fails because the callback may already have been
* called for previously submitted requests. Thus, num_requests must be
* incremented for each request that is submitted.
*
* The problem that callbacks may be called early also means that we need
* to take care that num_requests doesn't become 0 before all requests are
* submitted - multiwrite_cb() would consider the multiwrite request
* completed. A dummy request that is "completed" by a manual call to
* multiwrite_cb() takes care of this.
*/
mcb->num_requests = 1;

for (i = 0; i < num_reqs; i++) {
mcb->num_requests++;
acb = bdrv_aio_writev(bs, reqs[i].sector, reqs[i].qiov,
reqs[i].nb_sectors, multiwrite_cb, mcb);

if (acb == NULL) {
// We can only fail the whole thing if no request has been
// submitted yet. Otherwise we'll wait for the submitted AIOs to
// complete and report the error in the callback.
if (mcb->num_requests == 0) {
reqs[i].error = -EIO;
if (i == 0) {
goto fail;
} else {
mcb->num_requests++;
multiwrite_cb(mcb, -EIO);
break;
}
} else {
mcb->num_requests++;
}
}

/* Complete the dummy request */
multiwrite_cb(mcb, 0);

return 0;

fail:
free(mcb);
for (i = 0; i < mcb->num_callbacks; i++) {
reqs[i].error = -EIO;
}
qemu_free(mcb);
return -1;
}

Expand Down
4 changes: 4 additions & 0 deletions qemu/block.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ int bdrv_pread(BlockDriverState *bs, int64_t offset,
void *buf, int count);
int bdrv_pwrite(BlockDriverState *bs, int64_t offset,
const void *buf, int count);
int bdrv_pwrite_sync(BlockDriverState *bs, int64_t offset,
const void *buf, int count);
int bdrv_write_sync(BlockDriverState *bs, int64_t sector_num,
const uint8_t *buf, int nb_sectors);
int bdrv_truncate(BlockDriverState *bs, int64_t offset);
int64_t bdrv_getlength(BlockDriverState *bs);
void bdrv_get_geometry(BlockDriverState *bs, uint64_t *nb_sectors_ptr);
Expand Down
18 changes: 10 additions & 8 deletions qemu/block/qcow.c
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,9 @@ static uint64_t get_cluster_offset(BlockDriverState *bs,
/* update the L1 entry */
s->l1_table[l1_index] = l2_offset;
tmp = cpu_to_be64(l2_offset);
if (bdrv_pwrite(s->hd, s->l1_table_offset + l1_index * sizeof(tmp),
&tmp, sizeof(tmp)) != sizeof(tmp))
if (bdrv_pwrite_sync(s->hd,
s->l1_table_offset + l1_index * sizeof(tmp),
&tmp, sizeof(tmp)) < 0)
return 0;
new_l2_table = 1;
}
Expand Down Expand Up @@ -306,8 +307,8 @@ static uint64_t get_cluster_offset(BlockDriverState *bs,
l2_table = s->l2_cache + (min_index << s->l2_bits);
if (new_l2_table) {
memset(l2_table, 0, s->l2_size * sizeof(uint64_t));
if (bdrv_pwrite(s->hd, l2_offset, l2_table, s->l2_size * sizeof(uint64_t)) !=
s->l2_size * sizeof(uint64_t))
if (bdrv_pwrite_sync(s->hd, l2_offset, l2_table,
s->l2_size * sizeof(uint64_t)) < 0)
return 0;
} else {
if (bdrv_pread(s->hd, l2_offset, l2_table, s->l2_size * sizeof(uint64_t)) !=
Expand Down Expand Up @@ -372,8 +373,8 @@ static uint64_t get_cluster_offset(BlockDriverState *bs,
/* update L2 table */
tmp = cpu_to_be64(cluster_offset);
l2_table[l2_index] = tmp;
if (bdrv_pwrite(s->hd,
l2_offset + l2_index * sizeof(tmp), &tmp, sizeof(tmp)) != sizeof(tmp))
if (bdrv_pwrite_sync(s->hd, l2_offset + l2_index * sizeof(tmp),
&tmp, sizeof(tmp)) < 0)
return 0;
}
return cluster_offset;
Expand Down Expand Up @@ -821,8 +822,9 @@ static int qcow_make_empty(BlockDriverState *bs)
int ret;

memset(s->l1_table, 0, l1_length);
if (bdrv_pwrite(s->hd, s->l1_table_offset, s->l1_table, l1_length) < 0)
return -1;
if (bdrv_pwrite_sync(s->hd, s->l1_table_offset, s->l1_table,
l1_length) < 0)
return -1;
ret = bdrv_truncate(s->hd, s->l1_table_offset + l1_length);
if (ret < 0)
return ret;
Expand Down
Loading

0 comments on commit baae3fc

Please sign in to comment.