summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--block.c14
-rw-r--r--block.h7
-rw-r--r--block/qcow2.c22
-rw-r--r--block_int.h8
-rw-r--r--hw/pci.c29
-rw-r--r--pc-bios/bios-pq/0013_fix-non-acpi-timer-interrupt-routing.patch38
-rw-r--r--savevm.c46
7 files changed, 82 insertions, 82 deletions
diff --git a/block.c b/block.c
index cefbe7748..39f726cd6 100644
--- a/block.c
+++ b/block.c
@@ -1158,24 +1158,26 @@ int bdrv_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)
return drv->bdrv_get_info(bs, bdi);
}
-int bdrv_put_buffer(BlockDriverState *bs, const uint8_t *buf, int64_t pos, int size)
+int bdrv_save_vmstate(BlockDriverState *bs, const uint8_t *buf,
+ int64_t pos, int size)
{
BlockDriver *drv = bs->drv;
if (!drv)
return -ENOMEDIUM;
- if (!drv->bdrv_put_buffer)
+ if (!drv->bdrv_save_vmstate)
return -ENOTSUP;
- return drv->bdrv_put_buffer(bs, buf, pos, size);
+ return drv->bdrv_save_vmstate(bs, buf, pos, size);
}
-int bdrv_get_buffer(BlockDriverState *bs, uint8_t *buf, int64_t pos, int size)
+int bdrv_load_vmstate(BlockDriverState *bs, uint8_t *buf,
+ int64_t pos, int size)
{
BlockDriver *drv = bs->drv;
if (!drv)
return -ENOMEDIUM;
- if (!drv->bdrv_get_buffer)
+ if (!drv->bdrv_load_vmstate)
return -ENOTSUP;
- return drv->bdrv_get_buffer(bs, buf, pos, size);
+ return drv->bdrv_load_vmstate(bs, buf, pos, size);
}
/**************************************************************/
diff --git a/block.h b/block.h
index 406a19943..ccd4c1e70 100644
--- a/block.h
+++ b/block.h
@@ -159,9 +159,10 @@ void path_combine(char *dest, int dest_size,
const char *base_path,
const char *filename);
-int bdrv_put_buffer(BlockDriverState *bs, const uint8_t *buf,
- int64_t pos, int size);
+int bdrv_save_vmstate(BlockDriverState *bs, const uint8_t *buf,
+ int64_t pos, int size);
-int bdrv_get_buffer(BlockDriverState *bs, uint8_t *buf, int64_t pos, int size);
+int bdrv_load_vmstate(BlockDriverState *bs, uint8_t *buf,
+ int64_t pos, int size);
#endif
diff --git a/block/qcow2.c b/block/qcow2.c
index be507e7a9..a5bf20522 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -890,12 +890,16 @@ static void qcow_flush(BlockDriverState *bs)
bdrv_flush(s->hd);
}
+static int64_t qcow_vm_state_offset(BDRVQcowState *s)
+{
+ return (int64_t)s->l1_vm_state_index << (s->cluster_bits + s->l2_bits);
+}
+
static int qcow_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)
{
BDRVQcowState *s = bs->opaque;
bdi->cluster_size = s->cluster_size;
- bdi->vm_state_offset = (int64_t)s->l1_vm_state_index <<
- (s->cluster_bits + s->l2_bits);
+ bdi->vm_state_offset = qcow_vm_state_offset(s);
return 0;
}
@@ -925,26 +929,28 @@ static void dump_refcounts(BlockDriverState *bs)
}
#endif
-static int qcow_put_buffer(BlockDriverState *bs, const uint8_t *buf,
+static int qcow_save_vmstate(BlockDriverState *bs, const uint8_t *buf,
int64_t pos, int size)
{
+ BDRVQcowState *s = bs->opaque;
int growable = bs->growable;
bs->growable = 1;
- bdrv_pwrite(bs, pos, buf, size);
+ bdrv_pwrite(bs, qcow_vm_state_offset(s) + pos, buf, size);
bs->growable = growable;
return size;
}
-static int qcow_get_buffer(BlockDriverState *bs, uint8_t *buf,
+static int qcow_load_vmstate(BlockDriverState *bs, uint8_t *buf,
int64_t pos, int size)
{
+ BDRVQcowState *s = bs->opaque;
int growable = bs->growable;
int ret;
bs->growable = 1;
- ret = bdrv_pread(bs, pos, buf, size);
+ ret = bdrv_pread(bs, qcow_vm_state_offset(s) + pos, buf, size);
bs->growable = growable;
return ret;
@@ -1001,8 +1007,8 @@ static BlockDriver bdrv_qcow2 = {
.bdrv_snapshot_list = qcow2_snapshot_list,
.bdrv_get_info = qcow_get_info,
- .bdrv_put_buffer = qcow_put_buffer,
- .bdrv_get_buffer = qcow_get_buffer,
+ .bdrv_save_vmstate = qcow_save_vmstate,
+ .bdrv_load_vmstate = qcow_load_vmstate,
.create_options = qcow_create_options,
.bdrv_check = qcow_check,
diff --git a/block_int.h b/block_int.h
index 830b7e9c9..8898d91f4 100644
--- a/block_int.h
+++ b/block_int.h
@@ -84,10 +84,10 @@ struct BlockDriver {
QEMUSnapshotInfo **psn_info);
int (*bdrv_get_info)(BlockDriverState *bs, BlockDriverInfo *bdi);
- int (*bdrv_put_buffer)(BlockDriverState *bs, const uint8_t *buf,
- int64_t pos, int size);
- int (*bdrv_get_buffer)(BlockDriverState *bs, uint8_t *buf,
- int64_t pos, int size);
+ int (*bdrv_save_vmstate)(BlockDriverState *bs, const uint8_t *buf,
+ int64_t pos, int size);
+ int (*bdrv_load_vmstate)(BlockDriverState *bs, uint8_t *buf,
+ int64_t pos, int size);
/* removable device specific */
int (*bdrv_is_inserted)(BlockDriverState *bs);
diff --git a/hw/pci.c b/hw/pci.c
index 820519833..3ef26fc5e 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -31,6 +31,11 @@
#include "device-assignment.h"
//#define DEBUG_PCI
+#ifdef DEBUG_PCI
+# define PCI_DPRINTF(format, ...) printf(format, __VA_ARGS__)
+#else
+# define PCI_DPRINTF(format, ...) do { } while (0)
+#endif
struct PCIBus {
BusState qbus;
@@ -658,9 +663,9 @@ void pci_data_write(void *opaque, uint32_t addr, uint32_t val, int len)
PCIDevice *pci_dev;
int config_addr, bus_num;
-#if defined(DEBUG_PCI) && 0
- printf("pci_data_write: addr=%08x val=%08x len=%d\n",
- addr, val, len);
+#if 0
+ PCI_DPRINTF("pci_data_write: addr=%08x val=%08x len=%d\n",
+ addr, val, len);
#endif
bus_num = (addr >> 16) & 0xff;
while (s && s->bus_num != bus_num)
@@ -671,10 +676,8 @@ void pci_data_write(void *opaque, uint32_t addr, uint32_t val, int len)
if (!pci_dev)
return;
config_addr = addr & 0xff;
-#if defined(DEBUG_PCI)
- printf("pci_config_write: %s: addr=%02x val=%08x len=%d\n",
- pci_dev->name, config_addr, val, len);
-#endif
+ PCI_DPRINTF("pci_config_write: %s: addr=%02x val=%08x len=%d\n",
+ pci_dev->name, config_addr, val, len);
pci_dev->config_write(pci_dev, config_addr, val, len);
}
@@ -709,14 +712,12 @@ uint32_t pci_data_read(void *opaque, uint32_t addr, int len)
}
config_addr = addr & 0xff;
val = pci_dev->config_read(pci_dev, config_addr, len);
-#if defined(DEBUG_PCI)
- printf("pci_config_read: %s: addr=%02x val=%08x len=%d\n",
- pci_dev->name, config_addr, val, len);
-#endif
+ PCI_DPRINTF("pci_config_read: %s: addr=%02x val=%08x len=%d\n",
+ pci_dev->name, config_addr, val, len);
the_end:
-#if defined(DEBUG_PCI) && 0
- printf("pci_data_read: addr=%08x val=%08x len=%d\n",
- addr, val, len);
+#if 0
+ PCI_DPRINTF("pci_data_read: addr=%08x val=%08x len=%d\n",
+ addr, val, len);
#endif
return val;
}
diff --git a/pc-bios/bios-pq/0013_fix-non-acpi-timer-interrupt-routing.patch b/pc-bios/bios-pq/0013_fix-non-acpi-timer-interrupt-routing.patch
index c9d74e838..80e7716c6 100644
--- a/pc-bios/bios-pq/0013_fix-non-acpi-timer-interrupt-routing.patch
+++ b/pc-bios/bios-pq/0013_fix-non-acpi-timer-interrupt-routing.patch
@@ -1,30 +1,49 @@
-Fix non-ACPI Timer Interrupt Routing (Beth Kon)
+From c09142004a409bf27070939f470c5e0b37595a5a Mon Sep 17 00:00:00 2001
+From: Beth Kon <eak@us.ibm.com>
+Date: Fri, 19 Jun 2009 14:22:00 -0400
+Subject: [PATCH] Fix non-ACPI Timer Interrupt Routing - v3
Replicate ACPI irq0->inti2 override in mp table for non-acpi case.
v1 -> v2 adds comment suggested by Ryan.
+v2 -> v3 clarifies comment and corrects entry count
Signed-off-by: Beth Kon <eak@us.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
+---
+ bios/rombios32.c | 14 ++++++++++++++
+ 1 files changed, 14 insertions(+), 0 deletions(-)
diff --git a/bios/rombios32.c b/bios/rombios32.c
-index 7be4216..dc7b5f3 100644
+index 1a1ed64..d789e20 100644
--- a/bios/rombios32.c
+++ b/bios/rombios32.c
-@@ -1168,6 +1168,12 @@ static void mptable_init(void)
+@@ -1124,7 +1124,11 @@ static void mptable_init(void)
+ putstr(&q, "0.1 "); /* vendor id */
+ putle32(&q, 0); /* OEM table ptr */
+ putle16(&q, 0); /* OEM table size */
++#ifdef BX_QEMU
++ putle16(&q, smp_cpus + 17); /* entry count */
++#else
+ putle16(&q, smp_cpus + 18); /* entry count */
++#endif
+ putle32(&q, 0xfee00000); /* local APIC addr */
+ putle16(&q, 0); /* ext table length */
+ putb(&q, 0); /* ext table checksum */
+@@ -1166,6 +1170,12 @@ static void mptable_init(void)
/* irqs */
for(i = 0; i < 16; i++) {
+#ifdef BX_QEMU
-+ /* One entry per ioapic input. Input 2 is covered by
-+ irq0->inti2 override (i == 0). irq 2 is unused */
++ /* One entry per ioapic interrupt destination. Destination 2 is covered
++ by irq0->inti2 override (i == 0). Source IRQ 2 is unused */
+ if (i == 2)
+ continue;
-+#endif
++#endif
putb(&q, 3); /* entry type = I/O interrupt */
putb(&q, 0); /* interrupt type = vectored interrupt */
putb(&q, 0); /* flags: po=0, el=0 */
-@@ -1175,7 +1181,11 @@ static void mptable_init(void)
+@@ -1173,7 +1183,11 @@ static void mptable_init(void)
putb(&q, 0); /* source bus ID = ISA */
putb(&q, i); /* source bus IRQ */
putb(&q, ioapic_id); /* dest I/O APIC ID */
@@ -32,7 +51,10 @@ index 7be4216..dc7b5f3 100644
+ putb(&q, i == 0 ? 2 : i); /* dest I/O APIC interrupt in */
+#else
putb(&q, i); /* dest I/O APIC interrupt in */
-+#endif
++#endif
}
/* patch length */
len = q - mp_config_table;
+--
+1.6.2.5
+
diff --git a/savevm.c b/savevm.c
index 17da35a9f..113f2207c 100644
--- a/savevm.c
+++ b/savevm.c
@@ -337,46 +337,28 @@ fail:
return NULL;
}
-typedef struct QEMUFileBdrv
-{
- BlockDriverState *bs;
- int64_t base_offset;
-} QEMUFileBdrv;
-
static int block_put_buffer(void *opaque, const uint8_t *buf,
int64_t pos, int size)
{
- QEMUFileBdrv *s = opaque;
- bdrv_put_buffer(s->bs, buf, s->base_offset + pos, size);
+ bdrv_save_vmstate(opaque, buf, pos, size);
return size;
}
static int block_get_buffer(void *opaque, uint8_t *buf, int64_t pos, int size)
{
- QEMUFileBdrv *s = opaque;
- return bdrv_get_buffer(s->bs, buf, s->base_offset + pos, size);
+ return bdrv_load_vmstate(opaque, buf, pos, size);
}
static int bdrv_fclose(void *opaque)
{
- QEMUFileBdrv *s = opaque;
- qemu_free(s);
return 0;
}
-static QEMUFile *qemu_fopen_bdrv(BlockDriverState *bs, int64_t offset, int is_writable)
+static QEMUFile *qemu_fopen_bdrv(BlockDriverState *bs, int is_writable)
{
- QEMUFileBdrv *s;
-
- s = qemu_mallocz(sizeof(QEMUFileBdrv));
-
- s->bs = bs;
- s->base_offset = offset;
-
if (is_writable)
- return qemu_fopen_ops(s, block_put_buffer, NULL, bdrv_fclose, NULL, NULL);
-
- return qemu_fopen_ops(s, NULL, block_get_buffer, bdrv_fclose, NULL, NULL);
+ return qemu_fopen_ops(bs, block_put_buffer, NULL, bdrv_fclose, NULL, NULL);
+ return qemu_fopen_ops(bs, NULL, block_get_buffer, bdrv_fclose, NULL, NULL);
}
QEMUFile *qemu_fopen_ops(void *opaque, QEMUFilePutBufferFunc *put_buffer,
@@ -1069,7 +1051,6 @@ void do_savevm(Monitor *mon, const char *name)
BlockDriverState *bs, *bs1;
QEMUSnapshotInfo sn1, *sn = &sn1, old_sn1, *old_sn = &old_sn1;
int must_delete, ret, i;
- BlockDriverInfo bdi1, *bdi = &bdi1;
QEMUFile *f;
int saved_vm_running;
uint32_t vm_state_size;
@@ -1119,14 +1100,8 @@ void do_savevm(Monitor *mon, const char *name)
#endif
sn->vm_clock_nsec = qemu_get_clock(vm_clock);
- if (bdrv_get_info(bs, bdi) < 0 || bdi->vm_state_offset <= 0) {
- monitor_printf(mon, "Device %s does not support VM state snapshots\n",
- bdrv_get_device_name(bs));
- goto the_end;
- }
-
/* save the VM state */
- f = qemu_fopen_bdrv(bs, bdi->vm_state_offset, 1);
+ f = qemu_fopen_bdrv(bs, 1);
if (!f) {
monitor_printf(mon, "Could not open VM state file\n");
goto the_end;
@@ -1170,7 +1145,6 @@ void do_savevm(Monitor *mon, const char *name)
void do_loadvm(Monitor *mon, const char *name)
{
BlockDriverState *bs, *bs1;
- BlockDriverInfo bdi1, *bdi = &bdi1;
QEMUSnapshotInfo sn;
QEMUFile *f;
int i, ret;
@@ -1218,19 +1192,13 @@ void do_loadvm(Monitor *mon, const char *name)
}
}
- if (bdrv_get_info(bs, bdi) < 0 || bdi->vm_state_offset <= 0) {
- monitor_printf(mon, "Device %s does not support VM state snapshots\n",
- bdrv_get_device_name(bs));
- return;
- }
-
/* Don't even try to load empty VM states */
ret = bdrv_snapshot_find(bs, &sn, name);
if ((ret >= 0) && (sn.vm_state_size == 0))
goto the_end;
/* restore the VM state */
- f = qemu_fopen_bdrv(bs, bdi->vm_state_offset, 0);
+ f = qemu_fopen_bdrv(bs, 0);
if (!f) {
monitor_printf(mon, "Could not open VM state file\n");
goto the_end;