提交 aa348082 编写于 作者: A Aurelien Jarno

Merge branch 'for-anthony' of git://repo.or.cz/qemu/kevin

* 'for-anthony' of git://repo.or.cz/qemu/kevin:
  Remove obsolete 'enabled' variable from progress state
  Add dd-style SIGUSR1 progress reporting
  qed: Fix consistency check on 32-bit hosts
  ide/atapi: Introduce CHECK_READY flag for commands
  ide/atapi: Replace bdrv_get_geometry calls by s->nb_sectors
  ide/atapi: Use table instead of switch for commands
  ide/atapi: Factor commands out
  ide: Split atapi.c out
  Improve accuracy of block migration bandwidth calculation
  atapi: Add 'medium ready' to 'medium not ready' transition on cd change
  qemu-img: allow rebase to a NULL backing file when unsafe
......@@ -242,7 +242,7 @@ hw-obj-$(CONFIG_LAN9118) += lan9118.o
hw-obj-$(CONFIG_NE2000_ISA) += ne2000-isa.o
# IDE
hw-obj-$(CONFIG_IDE_CORE) += ide/core.o
hw-obj-$(CONFIG_IDE_CORE) += ide/core.o ide/atapi.o
hw-obj-$(CONFIG_IDE_QDEV) += ide/qdev.o
hw-obj-$(CONFIG_IDE_PCI) += ide/pci.o
hw-obj-$(CONFIG_IDE_ISA) += ide/isa.o
......
......@@ -62,7 +62,6 @@ typedef struct BlkMigBlock {
QEMUIOVector qiov;
BlockDriverAIOCB *aiocb;
int ret;
int64_t time;
QSIMPLEQ_ENTRY(BlkMigBlock) entry;
} BlkMigBlock;
......@@ -78,6 +77,7 @@ typedef struct BlkMigState {
int prev_progress;
int bulk_completed;
long double total_time;
long double prev_time_offset;
int reads;
} BlkMigState;
......@@ -131,12 +131,6 @@ uint64_t blk_mig_bytes_total(void)
return sum << BDRV_SECTOR_BITS;
}
static inline void add_avg_read_time(int64_t time)
{
block_mig_state.reads++;
block_mig_state.total_time += time;
}
static inline long double compute_read_bwidth(void)
{
assert(block_mig_state.total_time != 0);
......@@ -191,13 +185,14 @@ static void alloc_aio_bitmap(BlkMigDevState *bmds)
static void blk_mig_read_cb(void *opaque, int ret)
{
long double curr_time = qemu_get_clock_ns(rt_clock);
BlkMigBlock *blk = opaque;
blk->ret = ret;
blk->time = qemu_get_clock_ns(rt_clock) - blk->time;
add_avg_read_time(blk->time);
block_mig_state.reads++;
block_mig_state.total_time += (curr_time - block_mig_state.prev_time_offset);
block_mig_state.prev_time_offset = curr_time;
QSIMPLEQ_INSERT_TAIL(&block_mig_state.blk_list, blk, entry);
bmds_set_aio_inflight(blk->bmds, blk->sector, blk->nr_sectors, 0);
......@@ -250,7 +245,9 @@ static int mig_save_device_bulk(Monitor *mon, QEMUFile *f,
blk->iov.iov_len = nr_sectors * BDRV_SECTOR_SIZE;
qemu_iovec_init_external(&blk->qiov, &blk->iov, 1);
blk->time = qemu_get_clock_ns(rt_clock);
if (block_mig_state.submitted == 0) {
block_mig_state.prev_time_offset = qemu_get_clock_ns(rt_clock);
}
blk->aiocb = bdrv_aio_readv(bs, cur_sector, &blk->qiov,
nr_sectors, blk_mig_read_cb, blk);
......@@ -409,7 +406,9 @@ static int mig_save_device_dirty(Monitor *mon, QEMUFile *f,
blk->iov.iov_len = nr_sectors * BDRV_SECTOR_SIZE;
qemu_iovec_init_external(&blk->qiov, &blk->iov, 1);
blk->time = qemu_get_clock_ns(rt_clock);
if (block_mig_state.submitted == 0) {
block_mig_state.prev_time_offset = qemu_get_clock_ns(rt_clock);
}
blk->aiocb = bdrv_aio_readv(bmds->bs, sector, &blk->qiov,
nr_sectors, blk_mig_read_cb, blk);
......
......@@ -18,7 +18,7 @@ typedef struct {
BdrvCheckResult *result;
bool fix; /* whether to fix invalid offsets */
size_t nclusters;
uint64_t nclusters;
uint32_t *used_clusters; /* referenced cluster bitmap */
QEDRequest request;
......@@ -177,7 +177,7 @@ static int qed_check_l1_table(QEDCheck *check, QEDTable *table)
static void qed_check_for_leaks(QEDCheck *check)
{
BDRVQEDState *s = check->s;
size_t i;
uint64_t i;
for (i = s->header.header_size; i < check->nclusters; i++) {
if (!qed_test_bit(check->used_clusters, i)) {
......
......@@ -252,7 +252,7 @@ static inline uint64_t qed_offset_into_cluster(BDRVQEDState *s, uint64_t offset)
return offset & (s->header.cluster_size - 1);
}
static inline unsigned int qed_bytes_to_clusters(BDRVQEDState *s, size_t bytes)
static inline uint64_t qed_bytes_to_clusters(BDRVQEDState *s, uint64_t bytes)
{
return qed_start_of_cluster(s, bytes + (s->header.cluster_size - 1)) /
(s->header.cluster_size - 1);
......
此差异已折叠。
此差异已折叠。
......@@ -9,6 +9,7 @@
#include <hw/ide.h>
#include "block_int.h"
#include "iorange.h"
#include "dma.h"
/* debug IDE devices */
//#define DEBUG_IDE
......@@ -570,6 +571,15 @@ void ide_sector_write(IDEState *s);
void ide_sector_read(IDEState *s);
void ide_flush_cache(IDEState *s);
void ide_transfer_start(IDEState *s, uint8_t *buf, int size,
EndTransferFunc *end_transfer_func);
void ide_transfer_stop(IDEState *s);
void ide_set_inactive(IDEState *s);
/* hw/ide/atapi.c */
void ide_atapi_cmd(IDEState *s);
void ide_atapi_cmd_reply_end(IDEState *s);
/* hw/ide/qdev.c */
void ide_bus_new(IDEBus *idebus, DeviceState *dev, int bus_id);
IDEDevice *ide_create_drive(IDEBus *bus, int unit, DriveInfo *drive);
......
......@@ -1240,7 +1240,7 @@ static int img_rebase(int argc, char **argv)
}
}
if ((optind >= argc) || !out_baseimg) {
if ((optind >= argc) || (!unsafe && !out_baseimg)) {
help();
}
filename = argv[optind++];
......
......@@ -26,12 +26,14 @@
#include "osdep.h"
#include "sysemu.h"
#include <stdio.h>
#include <signal.h>
struct progress_state {
int enabled;
float current;
float last_print;
float min_skip;
void (*print)(void);
void (*end)(void);
};
static struct progress_state state;
......@@ -43,28 +45,65 @@ static struct progress_state state;
*/
static void progress_simple_print(void)
{
if (state.enabled) {
printf(" (%3.2f/100%%)\r", state.current);
fflush(stdout);
}
printf(" (%3.2f/100%%)\r", state.current);
fflush(stdout);
}
static void progress_simple_end(void)
{
if (state.enabled) {
printf("\n");
}
printf("\n");
}
static void progress_simple_init(void)
{
state.print = progress_simple_print;
state.end = progress_simple_end;
}
#ifdef CONFIG_POSIX
static void sigusr_print(int signal)
{
printf(" (%3.2f/100%%)\n", state.current);
}
#endif
static void progress_dummy_print(void)
{
}
static void progress_dummy_end(void)
{
}
static void progress_dummy_init(void)
{
#ifdef CONFIG_POSIX
struct sigaction action;
memset(&action, 0, sizeof(action));
sigfillset(&action.sa_mask);
action.sa_handler = sigusr_print;
action.sa_flags = 0;
sigaction(SIGUSR1, &action, NULL);
#endif
state.print = progress_dummy_print;
state.end = progress_dummy_end;
}
void qemu_progress_init(int enabled, float min_skip)
{
state.enabled = enabled;
state.min_skip = min_skip;
if (enabled) {
progress_simple_init();
} else {
progress_dummy_init();
}
}
void qemu_progress_end(void)
{
progress_simple_end();
state.end();
}
void qemu_progress_print(float percent, int max)
......@@ -84,6 +123,6 @@ void qemu_progress_print(float percent, int max)
if (current > (state.last_print + state.min_skip) ||
(current == 100) || (current == 0)) {
state.last_print = state.current;
progress_simple_print();
state.print();
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册