提交 dd86df75 编写于 作者: A Anthony Liguori

Merge remote-tracking branch 'sstabellini/for_1.1_rc3' into staging

* sstabellini/for_1.1_rc3:
  Call xc_domain_shutdown with the reboot flag when the guest requests a reboot.
  xen: Fix PV-on-HVM
  xen_disk: properly update stats in ioreq_release()
  xen_disk: use bdrv_aio_flush instead of bdrv_flush
  xen_disk: remove syncwrite option
  xen: disable rtc_clock
  xen: do not initialize the interval timer and PCSPK emulator
...@@ -47,6 +47,7 @@ ...@@ -47,6 +47,7 @@
#include "ui/qemu-spice.h" #include "ui/qemu-spice.h"
#include "memory.h" #include "memory.h"
#include "exec-memory.h" #include "exec-memory.h"
#include "arch_init.h"
/* output Bochs bios info messages */ /* output Bochs bios info messages */
//#define DEBUG_BIOS //#define DEBUG_BIOS
...@@ -1097,7 +1098,7 @@ void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi, ...@@ -1097,7 +1098,7 @@ void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi,
qemu_irq pit_alt_irq = NULL; qemu_irq pit_alt_irq = NULL;
qemu_irq rtc_irq = NULL; qemu_irq rtc_irq = NULL;
qemu_irq *a20_line; qemu_irq *a20_line;
ISADevice *i8042, *port92, *vmmouse, *pit; ISADevice *i8042, *port92, *vmmouse, *pit = NULL;
qemu_irq *cpu_exit_irq; qemu_irq *cpu_exit_irq;
register_ioport_write(0x80, 1, 1, ioport80_write, NULL); register_ioport_write(0x80, 1, 1, ioport80_write, NULL);
...@@ -1126,16 +1127,18 @@ void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi, ...@@ -1126,16 +1127,18 @@ void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi,
qemu_register_boot_set(pc_boot_set, *rtc_state); qemu_register_boot_set(pc_boot_set, *rtc_state);
if (kvm_irqchip_in_kernel()) { if (!xen_enabled()) {
pit = kvm_pit_init(isa_bus, 0x40); if (kvm_irqchip_in_kernel()) {
} else { pit = kvm_pit_init(isa_bus, 0x40);
pit = pit_init(isa_bus, 0x40, pit_isa_irq, pit_alt_irq); } else {
} pit = pit_init(isa_bus, 0x40, pit_isa_irq, pit_alt_irq);
if (hpet) { }
/* connect PIT to output control line of the HPET */ if (hpet) {
qdev_connect_gpio_out(hpet, 0, qdev_get_gpio_in(&pit->qdev, 0)); /* connect PIT to output control line of the HPET */
qdev_connect_gpio_out(hpet, 0, qdev_get_gpio_in(&pit->qdev, 0));
}
pcspk_init(isa_bus, pit);
} }
pcspk_init(isa_bus, pit);
for(i = 0; i < MAX_SERIAL_PORTS; i++) { for(i = 0; i < MAX_SERIAL_PORTS; i++) {
if (serial_hds[i]) { if (serial_hds[i]) {
......
...@@ -148,6 +148,6 @@ static inline int xen_xc_hvm_inject_msi(XenXC xen_xc, domid_t dom, ...@@ -148,6 +148,6 @@ static inline int xen_xc_hvm_inject_msi(XenXC xen_xc, domid_t dom,
} }
#endif #endif
void destroy_hvm_domain(void); void destroy_hvm_domain(bool reboot);
#endif /* QEMU_HW_XEN_COMMON_H */ #endif /* QEMU_HW_XEN_COMMON_H */
...@@ -48,7 +48,6 @@ ...@@ -48,7 +48,6 @@
/* ------------------------------------------------------------- */ /* ------------------------------------------------------------- */
static int syncwrite = 0;
static int batch_maps = 0; static int batch_maps = 0;
static int max_requests = 32; static int max_requests = 32;
...@@ -67,6 +66,7 @@ struct ioreq { ...@@ -67,6 +66,7 @@ struct ioreq {
QEMUIOVector v; QEMUIOVector v;
int presync; int presync;
int postsync; int postsync;
uint8_t mapped;
/* grant mapping */ /* grant mapping */
uint32_t domids[BLKIF_MAX_SEGMENTS_PER_REQUEST]; uint32_t domids[BLKIF_MAX_SEGMENTS_PER_REQUEST];
...@@ -154,7 +154,7 @@ static void ioreq_finish(struct ioreq *ioreq) ...@@ -154,7 +154,7 @@ static void ioreq_finish(struct ioreq *ioreq)
blkdev->requests_finished++; blkdev->requests_finished++;
} }
static void ioreq_release(struct ioreq *ioreq) static void ioreq_release(struct ioreq *ioreq, bool finish)
{ {
struct XenBlkDev *blkdev = ioreq->blkdev; struct XenBlkDev *blkdev = ioreq->blkdev;
...@@ -162,7 +162,11 @@ static void ioreq_release(struct ioreq *ioreq) ...@@ -162,7 +162,11 @@ static void ioreq_release(struct ioreq *ioreq)
memset(ioreq, 0, sizeof(*ioreq)); memset(ioreq, 0, sizeof(*ioreq));
ioreq->blkdev = blkdev; ioreq->blkdev = blkdev;
QLIST_INSERT_HEAD(&blkdev->freelist, ioreq, list); QLIST_INSERT_HEAD(&blkdev->freelist, ioreq, list);
blkdev->requests_finished--; if (finish) {
blkdev->requests_finished--;
} else {
blkdev->requests_inflight--;
}
} }
/* /*
...@@ -189,15 +193,10 @@ static int ioreq_parse(struct ioreq *ioreq) ...@@ -189,15 +193,10 @@ static int ioreq_parse(struct ioreq *ioreq)
ioreq->presync = 1; ioreq->presync = 1;
return 0; return 0;
} }
if (!syncwrite) { ioreq->presync = ioreq->postsync = 1;
ioreq->presync = ioreq->postsync = 1;
}
/* fall through */ /* fall through */
case BLKIF_OP_WRITE: case BLKIF_OP_WRITE:
ioreq->prot = PROT_READ; /* from memory */ ioreq->prot = PROT_READ; /* from memory */
if (syncwrite) {
ioreq->postsync = 1;
}
break; break;
default: default:
xen_be_printf(&blkdev->xendev, 0, "error: unknown operation (%d)\n", xen_be_printf(&blkdev->xendev, 0, "error: unknown operation (%d)\n",
...@@ -248,7 +247,7 @@ static void ioreq_unmap(struct ioreq *ioreq) ...@@ -248,7 +247,7 @@ static void ioreq_unmap(struct ioreq *ioreq)
XenGnttab gnt = ioreq->blkdev->xendev.gnttabdev; XenGnttab gnt = ioreq->blkdev->xendev.gnttabdev;
int i; int i;
if (ioreq->v.niov == 0) { if (ioreq->v.niov == 0 || ioreq->mapped == 0) {
return; return;
} }
if (batch_maps) { if (batch_maps) {
...@@ -274,6 +273,7 @@ static void ioreq_unmap(struct ioreq *ioreq) ...@@ -274,6 +273,7 @@ static void ioreq_unmap(struct ioreq *ioreq)
ioreq->page[i] = NULL; ioreq->page[i] = NULL;
} }
} }
ioreq->mapped = 0;
} }
static int ioreq_map(struct ioreq *ioreq) static int ioreq_map(struct ioreq *ioreq)
...@@ -281,7 +281,7 @@ static int ioreq_map(struct ioreq *ioreq) ...@@ -281,7 +281,7 @@ static int ioreq_map(struct ioreq *ioreq)
XenGnttab gnt = ioreq->blkdev->xendev.gnttabdev; XenGnttab gnt = ioreq->blkdev->xendev.gnttabdev;
int i; int i;
if (ioreq->v.niov == 0) { if (ioreq->v.niov == 0 || ioreq->mapped == 1) {
return 0; return 0;
} }
if (batch_maps) { if (batch_maps) {
...@@ -313,9 +313,12 @@ static int ioreq_map(struct ioreq *ioreq) ...@@ -313,9 +313,12 @@ static int ioreq_map(struct ioreq *ioreq)
ioreq->blkdev->cnt_map++; ioreq->blkdev->cnt_map++;
} }
} }
ioreq->mapped = 1;
return 0; return 0;
} }
static int ioreq_runio_qemu_aio(struct ioreq *ioreq);
static void qemu_aio_complete(void *opaque, int ret) static void qemu_aio_complete(void *opaque, int ret)
{ {
struct ioreq *ioreq = opaque; struct ioreq *ioreq = opaque;
...@@ -327,11 +330,19 @@ static void qemu_aio_complete(void *opaque, int ret) ...@@ -327,11 +330,19 @@ static void qemu_aio_complete(void *opaque, int ret)
} }
ioreq->aio_inflight--; ioreq->aio_inflight--;
if (ioreq->presync) {
ioreq->presync = 0;
ioreq_runio_qemu_aio(ioreq);
return;
}
if (ioreq->aio_inflight > 0) { if (ioreq->aio_inflight > 0) {
return; return;
} }
if (ioreq->postsync) { if (ioreq->postsync) {
bdrv_flush(ioreq->blkdev->bs); ioreq->postsync = 0;
ioreq->aio_inflight++;
bdrv_aio_flush(ioreq->blkdev->bs, qemu_aio_complete, ioreq);
return;
} }
ioreq->status = ioreq->aio_errors ? BLKIF_RSP_ERROR : BLKIF_RSP_OKAY; ioreq->status = ioreq->aio_errors ? BLKIF_RSP_ERROR : BLKIF_RSP_OKAY;
...@@ -351,7 +362,8 @@ static int ioreq_runio_qemu_aio(struct ioreq *ioreq) ...@@ -351,7 +362,8 @@ static int ioreq_runio_qemu_aio(struct ioreq *ioreq)
ioreq->aio_inflight++; ioreq->aio_inflight++;
if (ioreq->presync) { if (ioreq->presync) {
bdrv_flush(blkdev->bs); /* FIXME: aio_flush() ??? */ bdrv_aio_flush(ioreq->blkdev->bs, qemu_aio_complete, ioreq);
return 0;
} }
switch (ioreq->req.operation) { switch (ioreq->req.operation) {
...@@ -449,7 +461,7 @@ static void blk_send_response_all(struct XenBlkDev *blkdev) ...@@ -449,7 +461,7 @@ static void blk_send_response_all(struct XenBlkDev *blkdev)
while (!QLIST_EMPTY(&blkdev->finished)) { while (!QLIST_EMPTY(&blkdev->finished)) {
ioreq = QLIST_FIRST(&blkdev->finished); ioreq = QLIST_FIRST(&blkdev->finished);
send_notify += blk_send_response_one(ioreq); send_notify += blk_send_response_one(ioreq);
ioreq_release(ioreq); ioreq_release(ioreq, true);
} }
if (send_notify) { if (send_notify) {
xen_be_send_notify(&blkdev->xendev); xen_be_send_notify(&blkdev->xendev);
...@@ -505,7 +517,7 @@ static void blk_handle_requests(struct XenBlkDev *blkdev) ...@@ -505,7 +517,7 @@ static void blk_handle_requests(struct XenBlkDev *blkdev)
if (blk_send_response_one(ioreq)) { if (blk_send_response_one(ioreq)) {
xen_be_send_notify(&blkdev->xendev); xen_be_send_notify(&blkdev->xendev);
} }
ioreq_release(ioreq); ioreq_release(ioreq, false);
continue; continue;
} }
......
...@@ -603,6 +603,10 @@ void xen_vcpu_init(void) ...@@ -603,6 +603,10 @@ void xen_vcpu_init(void)
qemu_register_reset(xen_reset_vcpu, first_cpu); qemu_register_reset(xen_reset_vcpu, first_cpu);
xen_reset_vcpu(first_cpu); xen_reset_vcpu(first_cpu);
} }
/* if rtc_clock is left to default (host_clock), disable it */
if (rtc_clock == host_clock) {
qemu_clock_enable(rtc_clock, false);
}
} }
/* get the ioreq packets from share mem */ /* get the ioreq packets from share mem */
...@@ -856,7 +860,7 @@ static void cpu_handle_ioreq(void *opaque) ...@@ -856,7 +860,7 @@ static void cpu_handle_ioreq(void *opaque)
"data: %"PRIx64", count: %" FMT_ioreq_size ", size: %" FMT_ioreq_size "\n", "data: %"PRIx64", count: %" FMT_ioreq_size ", size: %" FMT_ioreq_size "\n",
req->state, req->data_is_ptr, req->addr, req->state, req->data_is_ptr, req->addr,
req->data, req->count, req->size); req->data, req->count, req->size);
destroy_hvm_domain(); destroy_hvm_domain(false);
return; return;
} }
...@@ -870,10 +874,11 @@ static void cpu_handle_ioreq(void *opaque) ...@@ -870,10 +874,11 @@ static void cpu_handle_ioreq(void *opaque)
*/ */
if (runstate_is_running()) { if (runstate_is_running()) {
if (qemu_shutdown_requested_get()) { if (qemu_shutdown_requested_get()) {
destroy_hvm_domain(); destroy_hvm_domain(false);
} }
if (qemu_reset_requested_get()) { if (qemu_reset_requested_get()) {
qemu_system_reset(VMRESET_REPORT); qemu_system_reset(VMRESET_REPORT);
destroy_hvm_domain(true);
} }
} }
...@@ -1159,7 +1164,7 @@ int xen_hvm_init(void) ...@@ -1159,7 +1164,7 @@ int xen_hvm_init(void)
return 0; return 0;
} }
void destroy_hvm_domain(void) void destroy_hvm_domain(bool reboot)
{ {
XenXC xc_handle; XenXC xc_handle;
int sts; int sts;
...@@ -1168,12 +1173,15 @@ void destroy_hvm_domain(void) ...@@ -1168,12 +1173,15 @@ void destroy_hvm_domain(void)
if (xc_handle == XC_HANDLER_INITIAL_VALUE) { if (xc_handle == XC_HANDLER_INITIAL_VALUE) {
fprintf(stderr, "Cannot acquire xenctrl handle\n"); fprintf(stderr, "Cannot acquire xenctrl handle\n");
} else { } else {
sts = xc_domain_shutdown(xc_handle, xen_domid, SHUTDOWN_poweroff); sts = xc_domain_shutdown(xc_handle, xen_domid,
reboot ? SHUTDOWN_reboot : SHUTDOWN_poweroff);
if (sts != 0) { if (sts != 0) {
fprintf(stderr, "? xc_domain_shutdown failed to issue poweroff, " fprintf(stderr, "xc_domain_shutdown failed to issue %s, "
"sts %d, %s\n", sts, strerror(errno)); "sts %d, %s\n", reboot ? "reboot" : "poweroff",
sts, strerror(errno));
} else { } else {
fprintf(stderr, "Issued domain %d poweroff\n", xen_domid); fprintf(stderr, "Issued domain %d %s\n", xen_domid,
reboot ? "reboot" : "poweroff");
} }
xc_interface_close(xc_handle); xc_interface_close(xc_handle);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册