return ret;
}
+
+int qemuMonitorGetVirtType(qemuMonitorPtr mon,
+ int *virtType)
+{
+ int ret;
+ VIR_DEBUG("mon=%p", mon);
+
+ if (!mon) {
+ qemuReportError(VIR_ERR_INVALID_ARG, "%s",
+ _("monitor must not be NULL"));
+ return -1;
+ }
+
+ if (mon->json)
+ ret = qemuMonitorJSONGetVirtType(mon, virtType);
+ else
+ ret = qemuMonitorTextGetVirtType(mon, virtType);
+ return ret;
+}
+
+
int qemuMonitorGetBalloonInfo(qemuMonitorPtr mon,
unsigned long *currmem)
{
int qemuMonitorGetCPUInfo(qemuMonitorPtr mon,
int **pids);
+int qemuMonitorGetVirtType(qemuMonitorPtr mon,
+ int *virtType);
int qemuMonitorGetBalloonInfo(qemuMonitorPtr mon,
unsigned long *currmem);
int qemuMonitorGetMemoryStats(qemuMonitorPtr mon,
}
+int qemuMonitorJSONGetVirtType(qemuMonitorPtr mon,
+ int *virtType)
+{
+ int ret;
+ virJSONValuePtr cmd = qemuMonitorJSONMakeCommand("query-kvm",
+ NULL);
+ virJSONValuePtr reply = NULL;
+
+ *virtType = VIR_DOMAIN_VIRT_QEMU;
+
+ if (!cmd)
+ return -1;
+
+ ret = qemuMonitorJSONCommand(mon, cmd, &reply);
+
+ if (ret == 0)
+ ret = qemuMonitorJSONCheckError(cmd, reply);
+
+ if (ret == 0) {
+ virJSONValuePtr data;
+ bool val = false;
+
+ if (!(data = virJSONValueObjectGet(reply, "return"))) {
+ qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("info kvm reply was missing return data"));
+ ret = -1;
+ goto cleanup;
+ }
+
+ if (virJSONValueObjectGetBoolean(data, "enabled", &val) < 0) {
+ qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("info kvm reply missing 'running' field"));
+ ret = -1;
+ goto cleanup;
+ }
+ if (val)
+ *virtType = VIR_DOMAIN_VIRT_KVM;
+ }
+
+cleanup:
+ virJSONValueFree(cmd);
+ virJSONValueFree(reply);
+ return ret;
+}
+
+
/*
* Returns: 0 if balloon not supported, +1 if balloon query worked
* or -1 on failure
int qemuMonitorJSONGetCPUInfo(qemuMonitorPtr mon,
int **pids);
+int qemuMonitorJSONGetVirtType(qemuMonitorPtr mon,
+ int *virtType);
int qemuMonitorJSONGetBalloonInfo(qemuMonitorPtr mon,
unsigned long *currmem);
int qemuMonitorJSONGetMemoryStats(qemuMonitorPtr mon,
return 0;
}
+
+int qemuMonitorTextGetVirtType(qemuMonitorPtr mon,
+ int *virtType)
+{
+ char *reply = NULL;
+
+ *virtType = VIR_DOMAIN_VIRT_QEMU;
+
+ if (qemuMonitorHMPCommand(mon, "info kvm", &reply) < 0) {
+ qemuReportError(VIR_ERR_OPERATION_FAILED,
+ "%s", _("could not query kvm status"));
+ return -1;
+ }
+
+ if (strstr(reply, "enabled"))
+ *virtType = VIR_DOMAIN_VIRT_KVM;
+
+ VIR_FREE(reply);
+ return 0;
+}
+
+
static int parseMemoryStat(char **text, unsigned int tag,
const char *search, virDomainMemoryStatPtr stat)
{
int qemuMonitorTextGetCPUInfo(qemuMonitorPtr mon,
int **pids);
+int qemuMonitorTextGetVirtType(qemuMonitorPtr mon,
+ int *virtType);
int qemuMonitorTextGetBalloonInfo(qemuMonitorPtr mon,
unsigned long *currmem);
int qemuMonitorTextGetMemoryStats(qemuMonitorPtr mon,