/* * QEMU Management Protocol * * Copyright IBM, Corp. 2011 * * Authors: * Anthony Liguori * * This work is licensed under the terms of the GNU GPL, version 2. See * the COPYING file in the top-level directory. * * Contributions after 2012-01-13 are licensed under the terms of the * GNU GPL, version 2 or (at your option) any later version. */ #include "qemu/osdep.h" #include "qemu/cutils.h" #include "monitor/monitor.h" #include "sysemu/sysemu.h" #include "qmp-commands.h" #include "sysemu/char.h" #include "ui/qemu-spice.h" #include "ui/vnc.h" #include "sysemu/kvm.h" #include "sysemu/arch_init.h" #include "hw/qdev.h" #include "sysemu/blockdev.h" #include "sysemu/block-backend.h" #include "qom/qom-qobject.h" #include "qapi/qmp/qerror.h" #include "qapi/qmp/qobject.h" #include "qapi/qmp-input-visitor.h" #include "hw/boards.h" #include "qom/object_interfaces.h" #include "hw/mem/pc-dimm.h" #include "hw/acpi/acpi_dev_interface.h" NameInfo *qmp_query_name(Error **errp) { NameInfo *info = g_malloc0(sizeof(*info)); if (qemu_name) { info->has_name = true; info->name = g_strdup(qemu_name); } return info; } VersionInfo *qmp_query_version(Error **errp) { VersionInfo *info = g_new0(VersionInfo, 1); const char *version = QEMU_VERSION; const char *tmp; int err; info->qemu = g_new0(VersionTriple, 1); err = qemu_strtoll(version, &tmp, 10, &info->qemu->major); assert(err == 0); tmp++; err = qemu_strtoll(tmp, &tmp, 10, &info->qemu->minor); assert(err == 0); tmp++; err = qemu_strtoll(tmp, &tmp, 10, &info->qemu->micro); assert(err == 0); info->package = g_strdup(QEMU_PKGVERSION); return info; } KvmInfo *qmp_query_kvm(Error **errp) { KvmInfo *info = g_malloc0(sizeof(*info)); info->enabled = kvm_enabled(); info->present = kvm_available(); return info; } UuidInfo *qmp_query_uuid(Error **errp) { UuidInfo *info = g_malloc0(sizeof(*info)); char uuid[64]; snprintf(uuid, sizeof(uuid), UUID_FMT, qemu_uuid[0], qemu_uuid[1], qemu_uuid[2], qemu_uuid[3], qemu_uuid[4], qemu_uuid[5], qemu_uuid[6], qemu_uuid[7], qemu_uuid[8], qemu_uuid[9], qemu_uuid[10], qemu_uuid[11], qemu_uuid[12], qemu_uuid[13], qemu_uuid[14], qemu_uuid[15]); info->UUID = g_strdup(uuid); return info; } void qmp_quit(Error **errp) { no_shutdown = 0; qemu_system_shutdown_request(); } void qmp_stop(Error **errp) { /* if there is a dump in background, we should wait until the dump * finished */ if (dump_in_progress()) { error_setg(errp, "There is a dump in process, please wait."); return; } if (runstate_check(RUN_STATE_INMIGRATE)) { autostart = 0; } else { vm_stop(RUN_STATE_PAUSED); } } void qmp_system_reset(Error **errp) { qemu_system_reset_request(); } void qmp_system_powerdown(Error **erp) { qemu_system_powerdown_request(); } void qmp_cpu(int64_t index, Error **errp) { /* Just do nothing */ } void qmp_cpu_add(int64_t id, Error **errp) { MachineClass *mc; mc = MACHINE_GET_CLASS(current_machine); if (mc->hot_add_cpu) { mc->hot_add_cpu(id, errp); } else { error_setg(errp, "Not supported"); } } #ifndef CONFIG_VNC /* If VNC support is enabled, the "true" query-vnc command is defined in the VNC subsystem */ VncInfo *qmp_query_vnc(Error **errp) { error_setg(errp, QERR_FEATURE_DISABLED, "vnc"); return NULL; }; VncInfo2List *qmp_query_vnc_servers(Error **errp) { error_setg(errp, QERR_FEATURE_DISABLED, "vnc"); return NULL; }; #endif #ifndef CONFIG_SPICE /* * qmp-commands.hx ensures that QMP command query-spice exists only * #ifdef CONFIG_SPICE. Necessary for an accurate query-commands * result. However, the QAPI schema is blissfully unaware of that, * and the QAPI code generator happily generates a dead * qmp_marshal_query_spice() that calls qmp_query_spice(). Provide it * one, or else linking fails. FIXME Educate the QAPI schema on * CONFIG_SPICE. */ SpiceInfo *qmp_query_spice(Error **errp) { abort(); }; #endif void qmp_cont(Error **errp) { Error *local_err = NULL; BlockBackend *blk; BlockDriverState *bs; /* if there is a dump in background, we should wait until the dump * finished */ if (dump_in_progress()) { error_setg(errp, "There is a dump in process, please wait."); return; } if (runstate_needs_reset()) { error_setg(errp, "Resetting the Virtual Machine is required"); return; } else if (runstate_check(RUN_STATE_SUSPENDED)) { return; } for (blk = blk_next(NULL); blk; blk = blk_next(blk)) { blk_iostatus_reset(blk); } for (bs = bdrv_next(NULL); bs; bs = bdrv_next(bs)) { bdrv_add_key(bs, NULL, &local_err); if (local_err) { error_propagate(errp, local_err); return; } } /* Continuing after completed migration. Images have been inactivated to * allow the destination to take control. Need to get control back now. */ if (runstate_check(RUN_STATE_FINISH_MIGRATE) || runstate_check(RUN_STATE_POSTMIGRATE)) { bdrv_invalidate_cache_all(&local_err); if (local_err) { error_propagate(errp, local_err); return; } } if (runstate_check(RUN_STATE_INMIGRATE)) { autostart = 1; } else { vm_start(); } } void qmp_system_wakeup(Error **errp) { qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER); } ObjectPropertyInfoList *qmp_qom_list(const char *path, Error **errp) { Object *obj; boo
#include <linux/kernel.h>
#include <linux/stat.h>
#include <asm/macio.h>


#define macio_config_of_attr(field, format_string)			\
static ssize_t								\
field##_show (struct device *dev, struct device_attribute *attr,	\
              char *buf)						\
{									\
	struct macio_dev *mdev = to_macio_device (dev);			\
	return sprintf (buf, format_string, mdev->ofdev.dev.of_node->field); \
}

static ssize_t
compatible_show (struct device *dev, struct device_attribute *attr, char *buf)
{
	struct platform_device *of;
	const char *compat;
	int cplen;
	int length = 0;

	of = &to_macio_device (dev)->ofdev;
	compat = of_get_property(of->dev.of_node, "compatible", &cplen);
	if (!compat) {
		*buf = '\0';
		return 0;
	}
	while (cplen > 0) {
		int l;
		length += sprintf (buf, "%s\n", compat);
		buf += length;
		l = strlen (compat) + 1;
		compat += l;
		cplen -= l;
	}

	return length;
}

static ssize_t modalias_show (struct device *dev, struct device_attribute