ssize_t len;
do {
- len = recv(s->fd, (void *)buf, size, 0);
+ len = qemu_recv(s->fd, buf, size, 0);
} while (len == -1 && socket_error() == EINTR);
if (len == -1)
static int socket_close(void *opaque)
{
QEMUFileSocket *s = opaque;
- qemu_free(s);
+ g_free(s);
return 0;
}
QEMUFileStdio *s = opaque;
int ret;
ret = pclose(s->stdio_file);
- qemu_free(s);
+ g_free(s);
return ret;
}
{
QEMUFileStdio *s = opaque;
fclose(s->stdio_file);
- qemu_free(s);
+ g_free(s);
return 0;
}
return NULL;
}
- s = qemu_mallocz(sizeof(QEMUFileStdio));
+ s = g_malloc0(sizeof(QEMUFileStdio));
s->stdio_file = stdio_file;
return NULL;
}
- s = qemu_mallocz(sizeof(QEMUFileStdio));
+ s = g_malloc0(sizeof(QEMUFileStdio));
s->stdio_file = fdopen(fd, mode);
if (!s->stdio_file)
goto fail;
return s->file;
fail:
- qemu_free(s);
+ g_free(s);
return NULL;
}
QEMUFile *qemu_fopen_socket(int fd)
{
- QEMUFileSocket *s = qemu_mallocz(sizeof(QEMUFileSocket));
+ QEMUFileSocket *s = g_malloc0(sizeof(QEMUFileSocket));
s->fd = fd;
s->file = qemu_fopen_ops(s, NULL, socket_get_buffer, socket_close,
return NULL;
}
- s = qemu_mallocz(sizeof(QEMUFileStdio));
+ s = g_malloc0(sizeof(QEMUFileStdio));
s->stdio_file = fopen(filename, mode);
if (!s->stdio_file)
}
return s->file;
fail:
- qemu_free(s);
+ g_free(s);
return NULL;
}
{
QEMUFile *f;
- f = qemu_mallocz(sizeof(QEMUFile));
+ f = g_malloc0(sizeof(QEMUFile));
f->opaque = opaque;
f->put_buffer = put_buffer;
qemu_fflush(f);
if (f->close)
ret = f->close(f->opaque);
- qemu_free(f);
+ g_free(f);
return ret;
}
{
SaveStateEntry *se;
- se = qemu_mallocz(sizeof(SaveStateEntry));
+ se = g_malloc0(sizeof(SaveStateEntry));
se->version_id = version_id;
se->section_id = global_section_id++;
se->set_params = set_params;
if (id) {
pstrcpy(se->idstr, sizeof(se->idstr), id);
pstrcat(se->idstr, sizeof(se->idstr), "/");
- qemu_free(id);
+ g_free(id);
- se->compat = qemu_mallocz(sizeof(CompatEntry));
+ se->compat = g_malloc0(sizeof(CompatEntry));
pstrcpy(se->compat->idstr, sizeof(se->compat->idstr), idstr);
se->compat->instance_id = instance_id == -1 ?
calculate_compat_instance_id(idstr) : instance_id;
if (path) {
pstrcpy(id, sizeof(id), path);
pstrcat(id, sizeof(id), "/");
- qemu_free(path);
+ g_free(path);
}
}
pstrcat(id, sizeof(id), idstr);
if (strcmp(se->idstr, id) == 0 && se->opaque == opaque) {
QTAILQ_REMOVE(&savevm_handlers, se, entry);
if (se->compat) {
- qemu_free(se->compat);
+ g_free(se->compat);
}
- qemu_free(se);
+ g_free(se);
}
}
}
if (path) {
pstrcpy(id, sizeof(id), path);
pstrcat(id, sizeof(id), "/");
- qemu_free(path);
+ g_free(path);
}
}
pstrcat(id, sizeof(id), idstr);
/* If this triggers, alias support can be dropped for the vmsd. */
assert(alias_id == -1 || required_for_version >= vmsd->minimum_version_id);
- se = qemu_mallocz(sizeof(SaveStateEntry));
+ se = g_malloc0(sizeof(SaveStateEntry));
se->version_id = vmsd->version_id;
se->section_id = global_section_id++;
se->save_live_state = NULL;
se->opaque = opaque;
se->vmsd = vmsd;
se->alias_id = alias_id;
+ se->no_migrate = vmsd->unmigratable;
if (dev && dev->parent_bus && dev->parent_bus->info->get_dev_path) {
char *id = dev->parent_bus->info->get_dev_path(dev);
if (id) {
pstrcpy(se->idstr, sizeof(se->idstr), id);
pstrcat(se->idstr, sizeof(se->idstr), "/");
- qemu_free(id);
+ g_free(id);
- se->compat = qemu_mallocz(sizeof(CompatEntry));
+ se->compat = g_malloc0(sizeof(CompatEntry));
pstrcpy(se->compat->idstr, sizeof(se->compat->idstr), vmsd->name);
se->compat->instance_id = instance_id == -1 ?
calculate_compat_instance_id(vmsd->name) : instance_id;
if (se->vmsd == vmsd && se->opaque == opaque) {
QTAILQ_REMOVE(&savevm_handlers, se, entry);
if (se->compat) {
- qemu_free(se->compat);
+ g_free(se->compat);
}
- qemu_free(se);
+ g_free(se);
}
}
}
int saved_vm_running;
int ret;
- saved_vm_running = vm_running;
- vm_stop(VMSTOP_SAVEVM);
+ saved_vm_running = runstate_is_running();
+ vm_stop(RUN_STATE_SAVE_VM);
if (qemu_savevm_state_blocked(mon)) {
ret = -EINVAL;
}
/* Add entry */
- le = qemu_mallocz(sizeof(*le));
+ le = g_malloc0(sizeof(*le));
le->se = se;
le->section_id = section_id;
out:
QLIST_FOREACH_SAFE(le, &loadvm_handlers, entry, new_le) {
QLIST_REMOVE(le, entry);
- qemu_free(le);
+ g_free(le);
}
if (qemu_file_has_error(f))
break;
}
}
- qemu_free(sn_tab);
+ g_free(sn_tab);
return ret;
}
bs = NULL;
while ((bs = bdrv_next(bs))) {
- if (bdrv_is_removable(bs) || bdrv_is_read_only(bs)) {
+ if (!bdrv_is_inserted(bs) || bdrv_is_read_only(bs)) {
continue;
}
return;
}
- saved_vm_running = vm_running;
- vm_stop(VMSTOP_SAVEVM);
+ saved_vm_running = runstate_is_running();
+ vm_stop(RUN_STATE_SAVE_VM);
memset(sn, 0, sizeof(*sn));
bs = NULL;
while ((bs = bdrv_next(bs))) {
- if (bdrv_is_removable(bs) || bdrv_is_read_only(bs)) {
+ if (!bdrv_is_inserted(bs) || bdrv_is_read_only(bs)) {
continue;
}
return;
}
- available_snapshots = qemu_mallocz(sizeof(int) * nb_sns);
+ available_snapshots = g_malloc0(sizeof(int) * nb_sns);
total = 0;
for (i = 0; i < nb_sns; i++) {
sn = &sn_tab[i];
monitor_printf(mon, "There is no suitable snapshot available\n");
}
- qemu_free(sn_tab);
- qemu_free(available_snapshots);
+ g_free(sn_tab);
+ g_free(available_snapshots);
}