qemu_ram_alloc: Add DeviceState and name parameters
These will be used to generate unique id strings for ramblocks. The name
field is required, the device pointer is optional as most callers don't
have a device. When there's no device or the device isn't a child of
a bus implementing BusInfo.get_dev_path, the name should be unique for
the platform.
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
diff --git a/hw/pci.c b/hw/pci.c
index 79f1f11..fe7c5c3 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -1713,6 +1713,7 @@
int size;
char *path;
void *ptr;
+ char name[32];
if (!pdev->romfile)
return 0;
@@ -1748,7 +1749,11 @@
size = 1 << qemu_fls(size);
}
- pdev->rom_offset = qemu_ram_alloc(size);
+ if (pdev->qdev.info->vmsd)
+ snprintf(name, sizeof(name), "%s.rom", pdev->qdev.info->vmsd->name);
+ else
+ snprintf(name, sizeof(name), "%s.rom", pdev->qdev.info->name);
+ pdev->rom_offset = qemu_ram_alloc(&pdev->qdev, name, size);
ptr = qemu_get_ram_ptr(pdev->rom_offset);
load_image(path, ptr);