Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into…
Browse files Browse the repository at this point in the history
… staging

SCSI changes that enable sending vendor-specific commands via virtio-scsi.

Memory changes for QOMification and automatic tracking of MR lifetime.

# gpg: Signature made Mon 18 Aug 2014 13:03:09 BST using RSA key ID 9B4D86F2
# gpg: Good signature from "Paolo Bonzini <[email protected]>"
# gpg:                 aka "Paolo Bonzini <[email protected]>"

* remotes/bonzini/tags/for-upstream:
  mtree: remove write-only field
  memory: Use canonical path component as the name
  memory: Use memory_region_name for name access
  memory: constify memory_region_name
  exec: Abstract away ref to memory region names
  loader: Abstract away ref to memory region names
  tpm_tis: remove instance_finalize callback
  memory: remove memory_region_destroy
  memory: convert memory_region_destroy to object_unparent
  ioport: split deletion and destruction
  nic: do not destroy memory regions in cleanup functions
  vga: do not dynamically allocate chain4_alias
  sysbus: remove unused function sysbus_del_io
  qom: object: move unparenting to the child property's release callback
  qom: object: delete properties before calling instance_finalize
  virtio-scsi: implement parse_cdb
  scsi-block, scsi-generic: implement parse_cdb
  scsi-block: extract scsi_block_is_passthrough
  scsi-bus: introduce parse_cdb in SCSIDeviceClass and SCSIBusInfo
  scsi-bus: prepare scsi_req_new for introduction of parse_cdb

Signed-off-by: Peter Maydell <[email protected]>
  • Loading branch information
pm215 committed Aug 19, 2014
2 parents 8e6e2c2 + f54bb15 commit 0e4a773
Show file tree
Hide file tree
Showing 62 changed files with 183 additions and 308 deletions.
10 changes: 0 additions & 10 deletions backends/hostmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -257,15 +257,6 @@ static void host_memory_backend_init(Object *obj)
host_memory_backend_set_policy, NULL, NULL, NULL);
}

static void host_memory_backend_finalize(Object *obj)
{
HostMemoryBackend *backend = MEMORY_BACKEND(obj);

if (memory_region_size(&backend->mr)) {
memory_region_destroy(&backend->mr);
}
}

MemoryRegion *
host_memory_backend_get_memory(HostMemoryBackend *backend, Error **errp)
{
Expand Down Expand Up @@ -360,7 +351,6 @@ static const TypeInfo host_memory_backend_info = {
.class_init = host_memory_backend_class_init,
.instance_size = sizeof(HostMemoryBackend),
.instance_init = host_memory_backend_init,
.instance_finalize = host_memory_backend_finalize,
.interfaces = (InterfaceInfo[]) {
{ TYPE_USER_CREATABLE },
{ }
Expand Down
15 changes: 10 additions & 5 deletions docs/memory.txt
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,16 @@ Region lifecycle
----------------

A region is created by one of the constructor functions (memory_region_init*())
and destroyed by the destructor (memory_region_destroy()). In between,
a region can be added to an address space by using memory_region_add_subregion()
and removed using memory_region_del_subregion(). Region attributes may be
changed at any point; they take effect once the region becomes exposed to the
guest.
and attached to an object. It is then destroyed by object_unparent() or simply
when the parent object dies.

In between, a region can be added to an address space
by using memory_region_add_subregion() and removed using
memory_region_del_subregion(). Destroying the region implicitly
removes the region from the address space.

Region attributes may be changed at any point; they take effect once
the region becomes exposed to the guest.

Overlapping regions and priority
--------------------------------
Expand Down
4 changes: 2 additions & 2 deletions exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -1044,7 +1044,7 @@ static void *file_ram_alloc(RAMBlock *block,
}

/* Make name safe to use with mkstemp by replacing '/' with '_'. */
sanitized_name = g_strdup(block->mr->name);
sanitized_name = g_strdup(memory_region_name(block->mr));
for (c = sanitized_name; *c != '\0'; c++) {
if (*c == '/')
*c = '_';
Expand Down Expand Up @@ -1242,7 +1242,7 @@ static ram_addr_t ram_block_add(RAMBlock *new_block)
new_block->host = phys_mem_alloc(new_block->length);
if (!new_block->host) {
fprintf(stderr, "Cannot set up guest memory '%s': %s\n",
new_block->mr->name, strerror(errno));
memory_region_name(new_block->mr), strerror(errno));
exit(1);
}
memory_try_enable_merging(new_block->host, new_block->length);
Expand Down
9 changes: 0 additions & 9 deletions hw/audio/ac97.c
Original file line number Diff line number Diff line change
Expand Up @@ -1388,14 +1388,6 @@ static int ac97_initfn (PCIDevice *dev)
return 0;
}

static void ac97_exitfn (PCIDevice *dev)
{
AC97LinkState *s = DO_UPCAST (AC97LinkState, dev, dev);

memory_region_destroy (&s->io_nam);
memory_region_destroy (&s->io_nabm);
}

static int ac97_init (PCIBus *bus)
{
pci_create_simple (bus, -1, "AC97");
Expand All @@ -1413,7 +1405,6 @@ static void ac97_class_init (ObjectClass *klass, void *data)
PCIDeviceClass *k = PCI_DEVICE_CLASS (klass);

k->init = ac97_initfn;
k->exit = ac97_exitfn;
k->vendor_id = PCI_VENDOR_ID_INTEL;
k->device_id = PCI_DEVICE_ID_INTEL_82801AA_5;
k->revision = 0x01;
Expand Down
8 changes: 0 additions & 8 deletions hw/audio/es1370.c
Original file line number Diff line number Diff line change
Expand Up @@ -1042,13 +1042,6 @@ static int es1370_initfn (PCIDevice *dev)
return 0;
}

static void es1370_exitfn (PCIDevice *dev)
{
ES1370State *s = DO_UPCAST (ES1370State, dev, dev);

memory_region_destroy (&s->io);
}

static int es1370_init (PCIBus *bus)
{
pci_create_simple (bus, -1, "ES1370");
Expand All @@ -1061,7 +1054,6 @@ static void es1370_class_init (ObjectClass *klass, void *data)
PCIDeviceClass *k = PCI_DEVICE_CLASS (klass);

k->init = es1370_initfn;
k->exit = es1370_exitfn;
k->vendor_id = PCI_VENDOR_ID_ENSONIQ;
k->device_id = PCI_DEVICE_ID_ENSONIQ_ES1370;
k->class_id = PCI_CLASS_MULTIMEDIA_AUDIO;
Expand Down
1 change: 0 additions & 1 deletion hw/audio/intel-hda.c
Original file line number Diff line number Diff line change
Expand Up @@ -1156,7 +1156,6 @@ static void intel_hda_exit(PCIDevice *pci)
IntelHDAState *d = INTEL_HDA(pci);

msi_uninit(&d->pci);
memory_region_destroy(&d->mmio);
}

static int intel_hda_post_load(void *opaque, int version)
Expand Down
1 change: 0 additions & 1 deletion hw/block/nvme.c
Original file line number Diff line number Diff line change
Expand Up @@ -839,7 +839,6 @@ static void nvme_exit(PCIDevice *pci_dev)
g_free(n->cq);
g_free(n->sq);
msix_uninit_exclusive_bar(pci_dev);
memory_region_destroy(&n->iomem);
}

static Property nvme_props[] = {
Expand Down
1 change: 0 additions & 1 deletion hw/block/pflash_cfi01.c
Original file line number Diff line number Diff line change
Expand Up @@ -781,7 +781,6 @@ static void pflash_cfi01_realize(DeviceState *dev, Error **errp)

if (ret < 0) {
vmstate_unregister_ram(&pfl->mem, DEVICE(pfl));
memory_region_destroy(&pfl->mem);
error_setg(errp, "failed to read the initial flash content");
return;
}
Expand Down
1 change: 0 additions & 1 deletion hw/block/pflash_cfi02.c
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,6 @@ static void pflash_cfi02_realize(DeviceState *dev, Error **errp)
ret = bdrv_read(pfl->bs, 0, pfl->storage, chip_len >> 9);
if (ret < 0) {
vmstate_unregister_ram(&pfl->orig_mem, DEVICE(pfl));
memory_region_destroy(&pfl->orig_mem);
error_setg(errp, "failed to read the initial flash content");
return;
}
Expand Down
3 changes: 0 additions & 3 deletions hw/char/serial-pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ static void serial_pci_exit(PCIDevice *dev)
SerialState *s = &pci->state;

serial_exit_core(s);
memory_region_destroy(&s->io);
qemu_free_irq(s->irq);
}

Expand All @@ -149,10 +148,8 @@ static void multi_serial_pci_exit(PCIDevice *dev)
s = pci->state + i;
serial_exit_core(s);
memory_region_del_subregion(&pci->iobar, &s->io);
memory_region_destroy(&s->io);
g_free(pci->name[i]);
}
memory_region_destroy(&pci->iobar);
qemu_free_irqs(pci->irqs, pci->ports);
}

Expand Down
2 changes: 1 addition & 1 deletion hw/core/loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -955,7 +955,7 @@ void do_info_roms(Monitor *mon, const QDict *qdict)
if (rom->mr) {
monitor_printf(mon, "%s"
" size=0x%06zx name=\"%s\"\n",
rom->mr->name,
memory_region_name(rom->mr),
rom->romsize,
rom->name);
} else if (!rom->fw_file) {
Expand Down
5 changes: 0 additions & 5 deletions hw/core/sysbus.c
Original file line number Diff line number Diff line change
Expand Up @@ -242,11 +242,6 @@ void sysbus_add_io(SysBusDevice *dev, hwaddr addr,
memory_region_add_subregion(get_system_io(), addr, mem);
}

void sysbus_del_io(SysBusDevice *dev, MemoryRegion *mem)
{
memory_region_del_subregion(get_system_io(), mem);
}

MemoryRegion *sysbus_address_space(SysBusDevice *dev)
{
return get_system_memory();
Expand Down
24 changes: 10 additions & 14 deletions hw/display/vga.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,15 +168,18 @@ static uint8_t expand4to8[16];

static void vga_update_memory_access(VGACommonState *s)
{
MemoryRegion *region, *old_region = s->chain4_alias;
hwaddr base, offset, size;

if (s->legacy_address_space == NULL) {
return;
}

s->chain4_alias = NULL;

if (s->has_chain4_alias) {
memory_region_del_subregion(s->legacy_address_space, &s->chain4_alias);
object_unparent(OBJECT(&s->chain4_alias));
s->has_chain4_alias = false;
s->plane_updated = 0xf;
}
if ((s->sr[VGA_SEQ_PLANE_WRITE] & VGA_SR02_ALL_PLANES) ==
VGA_SR02_ALL_PLANES && s->sr[VGA_SEQ_MEMORY_MODE] & VGA_SR04_CHN_4M) {
offset = 0;
Expand All @@ -201,18 +204,11 @@ static void vga_update_memory_access(VGACommonState *s)
break;
}
base += isa_mem_base;
region = g_malloc(sizeof(*region));
memory_region_init_alias(region, memory_region_owner(&s->vram),
memory_region_init_alias(&s->chain4_alias, memory_region_owner(&s->vram),
"vga.chain4", &s->vram, offset, size);
memory_region_add_subregion_overlap(s->legacy_address_space, base,
region, 2);
s->chain4_alias = region;
}
if (old_region) {
memory_region_del_subregion(s->legacy_address_space, old_region);
memory_region_destroy(old_region);
g_free(old_region);
s->plane_updated = 0xf;
&s->chain4_alias, 2);
s->has_chain4_alias = true;
}
}

Expand Down Expand Up @@ -1321,7 +1317,7 @@ static void vga_draw_text(VGACommonState *s, int full_update)
s->font_offsets[1] = offset;
full_update = 1;
}
if (s->plane_updated & (1 << 2) || s->chain4_alias) {
if (s->plane_updated & (1 << 2) || s->has_chain4_alias) {
/* if the plane 2 was modified since the last display, it
indicates the font may have been modified */
s->plane_updated = 0;
Expand Down
3 changes: 2 additions & 1 deletion hw/display/vga_int.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ typedef struct VGACommonState {
uint32_t vram_size;
uint32_t vram_size_mb; /* property */
uint32_t latch;
MemoryRegion *chain4_alias;
bool has_chain4_alias;
MemoryRegion chain4_alias;
uint8_t sr_index;
uint8_t sr[256];
uint8_t gr_index;
Expand Down
8 changes: 0 additions & 8 deletions hw/i386/kvm/pci-assign.c
Original file line number Diff line number Diff line change
Expand Up @@ -697,8 +697,6 @@ static void free_assigned_device(AssignedDevice *dev)
if (region->u.r_baseport) {
memory_region_del_subregion(&region->container,
&region->real_iomem);
memory_region_destroy(&region->real_iomem);
memory_region_destroy(&region->container);
}
} else if (pci_region->type & IORESOURCE_MEM) {
if (region->u.r_virtbase) {
Expand All @@ -712,9 +710,6 @@ static void free_assigned_device(AssignedDevice *dev)
memory_region_del_subregion(&region->container,
&dev->mmio);
}

memory_region_destroy(&region->real_iomem);
memory_region_destroy(&region->container);
if (munmap(region->u.r_virtbase,
(pci_region->size + 0xFFF) & 0xFFFFF000)) {
error_report("Failed to unmap assigned device region: %s",
Expand Down Expand Up @@ -1680,8 +1675,6 @@ static void assigned_dev_unregister_msix_mmio(AssignedDevice *dev)
return;
}

memory_region_destroy(&dev->mmio);

if (munmap(dev->msix_table, MSIX_PAGE_SIZE) == -1) {
error_report("error unmapping msix_table! %s", strerror(errno));
}
Expand Down Expand Up @@ -1953,7 +1946,6 @@ static void assigned_dev_load_option_rom(AssignedDevice *dev)
error_printf("Device option ROM contents are probably invalid "
"(check dmesg).\nSkip option ROM probe with rombar=0, "
"or load from file with romfile=\n");
memory_region_destroy(&dev->dev.rom);
goto close_rom;
}

Expand Down
2 changes: 1 addition & 1 deletion hw/i386/kvmvapic.c
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ static int vapic_map_rom_writable(VAPICROMState *s)

if (s->rom_mapped_writable) {
memory_region_del_subregion(as, &s->rom);
memory_region_destroy(&s->rom);
object_unparent(OBJECT(&s->rom));
}

/* grab RAM memory region (region @rom_paddr may still be pc.rom) */
Expand Down
2 changes: 0 additions & 2 deletions hw/ide/ahci.c
Original file line number Diff line number Diff line change
Expand Up @@ -1228,8 +1228,6 @@ void ahci_init(AHCIState *s, DeviceState *qdev, AddressSpace *as, int ports)

void ahci_uninit(AHCIState *s)
{
memory_region_destroy(&s->mem);
memory_region_destroy(&s->idp);
g_free(s->dev);
}

Expand Down
5 changes: 0 additions & 5 deletions hw/ide/cmd646.c
Original file line number Diff line number Diff line change
Expand Up @@ -384,13 +384,8 @@ static void pci_cmd646_ide_exitfn(PCIDevice *dev)

for (i = 0; i < 2; ++i) {
memory_region_del_subregion(&d->bmdma_bar, &d->bmdma[i].extra_io);
memory_region_destroy(&d->bmdma[i].extra_io);
memory_region_del_subregion(&d->bmdma_bar, &d->bmdma[i].addr_ioport);
memory_region_destroy(&d->bmdma[i].addr_ioport);
memory_region_destroy(&d->cmd646_bar[i].cmd);
memory_region_destroy(&d->cmd646_bar[i].data);
}
memory_region_destroy(&d->bmdma_bar);
}

void pci_cmd646_ide_init(PCIBus *bus, DriveInfo **hd_table,
Expand Down
3 changes: 0 additions & 3 deletions hw/ide/piix.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,11 +207,8 @@ static void pci_piix_ide_exitfn(PCIDevice *dev)

for (i = 0; i < 2; ++i) {
memory_region_del_subregion(&d->bmdma_bar, &d->bmdma[i].extra_io);
memory_region_destroy(&d->bmdma[i].extra_io);
memory_region_del_subregion(&d->bmdma_bar, &d->bmdma[i].addr_ioport);
memory_region_destroy(&d->bmdma[i].addr_ioport);
}
memory_region_destroy(&d->bmdma_bar);
}

/* hd_table must contain 4 block drivers */
Expand Down
3 changes: 0 additions & 3 deletions hw/ide/via.c
Original file line number Diff line number Diff line change
Expand Up @@ -198,11 +198,8 @@ static void vt82c686b_ide_exitfn(PCIDevice *dev)

for (i = 0; i < 2; ++i) {
memory_region_del_subregion(&d->bmdma_bar, &d->bmdma[i].extra_io);
memory_region_destroy(&d->bmdma[i].extra_io);
memory_region_del_subregion(&d->bmdma_bar, &d->bmdma[i].addr_ioport);
memory_region_destroy(&d->bmdma[i].addr_ioport);
}
memory_region_destroy(&d->bmdma_bar);
}

void vt82c686b_ide_init(PCIBus *bus, DriveInfo **hd_table, int devfn)
Expand Down
13 changes: 0 additions & 13 deletions hw/ipack/tpci200.c
Original file line number Diff line number Diff line change
Expand Up @@ -613,18 +613,6 @@ static int tpci200_initfn(PCIDevice *pci_dev)
return 0;
}

static void tpci200_exitfn(PCIDevice *pci_dev)
{
TPCI200State *s = TPCI200(pci_dev);

memory_region_destroy(&s->mmio);
memory_region_destroy(&s->io);
memory_region_destroy(&s->las0);
memory_region_destroy(&s->las1);
memory_region_destroy(&s->las2);
memory_region_destroy(&s->las3);
}

static const VMStateDescription vmstate_tpci200 = {
.name = "tpci200",
.version_id = 1,
Expand All @@ -645,7 +633,6 @@ static void tpci200_class_init(ObjectClass *klass, void *data)
PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);

k->init = tpci200_initfn;
k->exit = tpci200_exitfn;
k->vendor_id = PCI_VENDOR_ID_TEWS;
k->device_id = PCI_DEVICE_ID_TEWS_TPCI200;
k->class_id = PCI_CLASS_BRIDGE_OTHER;
Expand Down
2 changes: 1 addition & 1 deletion hw/mips/gt64xxx_pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ static void gt64120_pci_mapping(GT64120State *s)
if (s->PCI0IO_length)
{
memory_region_del_subregion(get_system_memory(), &s->PCI0IO_mem);
memory_region_destroy(&s->PCI0IO_mem);
object_unparent(OBJECT(&s->PCI0IO_mem));
}
/* Map new IO address */
s->PCI0IO_start = s->regs[GT_PCI0IOLD] << 21;
Expand Down
3 changes: 0 additions & 3 deletions hw/misc/ivshmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -793,11 +793,8 @@ static void pci_ivshmem_uninit(PCIDevice *dev)
error_free(s->migration_blocker);
}

memory_region_destroy(&s->ivshmem_mmio);
memory_region_del_subregion(&s->bar, &s->ivshmem);
vmstate_unregister_ram(&s->ivshmem, DEVICE(dev));
memory_region_destroy(&s->ivshmem);
memory_region_destroy(&s->bar);
unregister_savevm(DEVICE(dev), "ivshmem", s);
}

Expand Down
2 changes: 1 addition & 1 deletion hw/misc/omap_gpmc.c
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ static void omap_gpmc_cs_unmap(struct omap_gpmc_s *s, int cs)
}
memory_region_del_subregion(get_system_memory(), &f->container);
memory_region_del_subregion(&f->container, omap_gpmc_cs_memregion(s, cs));
memory_region_destroy(&f->container);
object_unparent(OBJECT(&f->container));
}

void omap_gpmc_reset(struct omap_gpmc_s *s)
Expand Down
Loading

0 comments on commit 0e4a773

Please sign in to comment.