本文整理汇总了C++中qemu_mallocz函数的典型用法代码示例。如果您正苦于以下问题:C++ qemu_mallocz函数的具体用法?C++ qemu_mallocz怎么用?C++ qemu_mallocz使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了qemu_mallocz函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void *ps2_kbd_init(void (*update_irq)(void *, int), void *update_arg)
{
PS2KbdState *s = (PS2KbdState *)qemu_mallocz(sizeof(PS2KbdState));
s->common.update_irq = update_irq;
s->common.update_arg = update_arg;
s->scancode_set = 2;
ps2_reset(&s->common);
register_savevm("ps2kbd", 0, 3, ps2_kbd_save, ps2_kbd_load, s);
gui_register_dev_key_callback(ps2_put_keycode, s);
qemu_register_reset(ps2_reset, &s->common);
return s;
}
示例2: qemu_mallocz
QEMUDeviceClass *qdev_new(const char *name, QDEVCreateFn create, int nirq)
{
QEMUDeviceClass *dc = qemu_mallocz(sizeof(*dc));
dc->num_irqs = nirq;
dc->create = create;
dc->name = qemu_strdup(name);
dc->next = all_dc;
all_dc = dc;
return dc;
}
示例3:
void *ps2_kbd_init(void (*update_irq)(void *, int), void *update_arg)
{
PS2KbdState *s = (PS2KbdState *)qemu_mallocz(sizeof(PS2KbdState));
TEMU_KbdState = s;
s->common.update_irq = update_irq;
s->common.update_arg = update_arg;
ps2_reset(&s->common);
register_savevm("ps2kbd", 0, 2, ps2_kbd_save, ps2_kbd_load, s);
qemu_add_kbd_event_handler(ps2_put_keycode, s);
qemu_register_reset(ps2_reset, &s->common);
return s;
}
示例4: msix_init
/* Initialize the MSI-X structures. Note: if MSI-X is supported, BAR size is
* modified, it should be retrieved with msix_bar_size. */
int msix_init(struct PCIDevice *dev, unsigned short nentries,
MemoryRegion *bar,
unsigned bar_nr, unsigned bar_size)
{
int ret;
/* Nothing to do if MSI is not supported by interrupt controller */
if (!msix_supported)
return -ENOTSUP;
if (nentries > MSIX_MAX_ENTRIES)
return -EINVAL;
dev->msix_entry_used = qemu_mallocz(MSIX_MAX_ENTRIES *
sizeof *dev->msix_entry_used);
dev->msix_table_page = qemu_mallocz(MSIX_PAGE_SIZE);
msix_mask_all(dev, nentries);
memory_region_init_io(&dev->msix_mmio, &msix_mmio_ops, dev,
"msix", MSIX_PAGE_SIZE);
dev->msix_entries_nr = nentries;
ret = msix_add_config(dev, nentries, bar_nr, bar_size);
if (ret)
goto err_config;
dev->cap_present |= QEMU_PCI_CAP_MSIX;
msix_mmio_setup(dev, bar);
return 0;
err_config:
dev->msix_entries_nr = 0;
memory_region_destroy(&dev->msix_mmio);
qemu_free(dev->msix_table_page);
dev->msix_table_page = NULL;
qemu_free(dev->msix_entry_used);
dev->msix_entry_used = NULL;
return ret;
}
示例5: qmp_user_def_cmd2
UserDefTwo * qmp_user_def_cmd2(UserDefOne * ud1a, UserDefOne * ud1b, Error **errp)
{
UserDefTwo *ret;
UserDefOne *ud1c = qemu_mallocz(sizeof(UserDefOne));
UserDefOne *ud1d = qemu_mallocz(sizeof(UserDefOne));
ud1c->string = strdup(ud1a->string);
ud1c->integer = ud1a->integer;
ud1d->string = strdup(ud1b->string);
ud1d->integer = ud1b->integer;
ret = qemu_mallocz(sizeof(UserDefTwo));
ret->string = strdup("blah1");
ret->dict.string = strdup("blah2");
ret->dict.dict.userdef = ud1c;
ret->dict.dict.string = strdup("blah3");
ret->dict.has_dict2 = true;
ret->dict.dict2.userdef = ud1d;
ret->dict.dict2.string = strdup("blah4");
return ret;
}
示例6: hostmem_init
void hostmem_init(HostMem *hostmem)
{
memset(hostmem, 0, sizeof(*hostmem));
qemu_mutex_init(&hostmem->mem_lock);
hostmem->mem = qemu_mallocz(sizeof(*hostmem->mem));
hostmem->client.set_memory = hostmem_client_set_memory;
hostmem->client.sync_dirty_bitmap = hostmem_client_sync_dirty_bitmap;
hostmem->client.migration_log = hostmem_client_migration_log;
cpu_register_phys_memory_client(&hostmem->client);
}
示例7: qemu_mallocz
MigrationState *exec_start_outgoing_migration(const char *command,
int64_t bandwidth_limit,
int detach)
{
FdMigrationState *s;
FILE *f;
s = qemu_mallocz(sizeof(*s));
f = popen(command, "w");
if (f == NULL) {
dprintf("Unable to popen exec target\n");
goto err_after_alloc;
}
s->fd = fileno(f);
if (s->fd == -1) {
dprintf("Unable to retrieve file descriptor for popen'd handle\n");
goto err_after_open;
}
if (fcntl(s->fd, F_SETFD, O_NONBLOCK) == -1) {
dprintf("Unable to set nonblocking mode on file descriptor\n");
goto err_after_open;
}
s->opaque = qemu_popen(f, "w");
s->close = exec_close;
s->get_error = file_errno;
s->write = file_write;
s->mig_state.cancel = migrate_fd_cancel;
s->mig_state.get_status = migrate_fd_get_status;
s->mig_state.release = migrate_fd_release;
s->state = MIG_STATE_ACTIVE;
s->mon_resume = NULL;
s->bandwidth_limit = bandwidth_limit;
if (!detach)
migrate_fd_monitor_suspend(s);
migrate_fd_connect(s);
return &s->mig_state;
err_after_open:
pclose(f);
err_after_alloc:
qemu_free(s);
return NULL;
}
示例8: get_image_size
void *load_device_tree(const char *filename_path, void *load_addr)
{
int dt_file_size;
int dt_file_load_size;
int new_dt_size;
int ret;
void *dt_file = NULL;
void *fdt;
dt_file_size = get_image_size(filename_path);
if (dt_file_size < 0) {
printf("Unable to get size of device tree file '%s'\n",
filename_path);
goto fail;
}
/* First allocate space in qemu for device tree */
dt_file = qemu_mallocz(dt_file_size);
if (dt_file == NULL) {
printf("Unable to allocate memory in qemu for device tree\n");
goto fail;
}
dt_file_load_size = load_image(filename_path, dt_file);
/* Second we place new copy of 2x size in guest memory
* This give us enough room for manipulation.
*/
new_dt_size = dt_file_size * 2;
fdt = load_addr;
ret = fdt_open_into(dt_file, fdt, new_dt_size);
if (ret) {
printf("Unable to copy device tree in memory\n");
goto fail;
}
/* Check sanity of device tree */
if (fdt_check_header(fdt)) {
printf ("Device tree file loaded into memory is invalid: %s\n",
filename_path);
goto fail;
}
/* free qemu memory with old device tree */
qemu_free(dt_file);
return fdt;
fail:
qemu_free(dt_file);
return NULL;
}
示例9: nand_dev_init
/* initialize the QFB device */
void nand_dev_init(uint32_t base)
{
int iomemtype;
static int instance_id = 0;
nand_dev_controller_state *s;
s = (nand_dev_controller_state *)qemu_mallocz(sizeof(nand_dev_controller_state));
iomemtype = cpu_register_io_memory(nand_dev_readfn, nand_dev_writefn, s);
cpu_register_physical_memory(base, 0x00000fff, iomemtype);
s->base = base;
register_savevm( "nand_dev", instance_id++, NAND_DEV_STATE_SAVE_VERSION,
nand_dev_controller_state_save, nand_dev_controller_state_load, s);
}
示例10: qemu_mallocz
static QEMUClock *qemu_new_clock(int type)
{
QEMUClock *clock;
clock = qemu_mallocz(sizeof(QEMUClock));
clock->type = type;
clock->enabled = 1;
notifier_list_init(&clock->reset_notifiers);
/* required to detect & report backward jumps */
if (type == QEMU_CLOCK_HOST) {
clock->last = get_clock_realtime();
}
return clock;
}
示例11: qemu_mallocz
static qemu_irq *r2d_fpga_init(target_phys_addr_t base, qemu_irq irl)
{
int iomemtype;
r2d_fpga_t *s;
s = qemu_mallocz(sizeof(r2d_fpga_t));
s->irl = irl;
iomemtype = cpu_register_io_memory(r2d_fpga_readfn,
r2d_fpga_writefn, s);
cpu_register_physical_memory(base, 0x40, iomemtype);
return qemu_allocate_irqs(r2d_fpga_irq_set, s, NR_IRQS);
}
示例12: qemu_mallocz
static QEMUFile *qemu_fopen_bdrv(BlockDriverState *bs, int64_t offset, 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);
}
示例13: syborg_int_init
static void syborg_int_init(SysBusDevice *dev)
{
SyborgIntState *s = FROM_SYSBUS(SyborgIntState, dev);
int iomemtype;
sysbus_init_irq(dev, &s->parent_irq);
qdev_init_gpio_in(&dev->qdev, syborg_int_set_irq, s->num_irqs);
iomemtype = cpu_register_io_memory(syborg_int_readfn,
syborg_int_writefn, s);
sysbus_init_mmio(dev, 0x1000, iomemtype);
s->flags = qemu_mallocz(s->num_irqs * sizeof(syborg_int_flags));
register_savevm("syborg_int", -1, 1, syborg_int_save, syborg_int_load, s);
}
示例14:
static arm_timer_state *arm_timer_init(uint32_t freq)
{
arm_timer_state *s;
QEMUBH *bh;
s = (arm_timer_state *)qemu_mallocz(sizeof(arm_timer_state));
s->freq = freq;
s->control = TIMER_CTRL_IE;
bh = qemu_bh_new(arm_timer_tick, s);
s->timer = ptimer_init(bh);
register_savevm("arm_timer", -1, 1, arm_timer_save, arm_timer_load, s);
return s;
}
示例15: qemu_mallocz
MigrationState *fd_start_outgoing_migration(Monitor *mon,
const char *fdname,
int64_t bandwidth_limit,
int detach,
int blk,
int inc)
{
FdMigrationState *s;
s = qemu_mallocz(sizeof(*s));
s->fd = monitor_get_fd(mon, fdname);
if (s->fd == -1) {
DPRINTF("fd_migration: invalid file descriptor identifier\n");
goto err_after_alloc;
}
if (fcntl(s->fd, F_SETFL, O_NONBLOCK) == -1) {
DPRINTF("Unable to set nonblocking mode on file descriptor\n");
goto err_after_open;
}
s->get_error = fd_errno;
s->write = fd_write;
s->close = fd_close;
s->mig_state.cancel = migrate_fd_cancel;
s->mig_state.get_status = migrate_fd_get_status;
s->mig_state.release = migrate_fd_release;
s->mig_state.blk = blk;
s->mig_state.shared = inc;
s->state = MIG_STATE_ACTIVE;
s->mon = NULL;
s->bandwidth_limit = bandwidth_limit;
if (!detach) {
migrate_fd_monitor_suspend(s, mon);
}
migrate_fd_connect(s);
return &s->mig_state;
err_after_open:
close(s->fd);
err_after_alloc:
qemu_free(s);
return NULL;
}