提交 d4ba8cb0 编写于 作者: C Carlos L. Torres 提交者: Paolo Bonzini

qmp: Add example usage of strto*l() qemu wrapper

Signed-off-by: NCarlos L. Torres <carlos.torres@rackspace.com>
Message-Id: <11ac63e95d88551f1c2c9b1216b15d3cb8ba4468.1437346779.git.carlos.torres@rackspace.com>
Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
上级 3904e6bf
......@@ -49,14 +49,20 @@ VersionInfo *qmp_query_version(Error **errp)
{
VersionInfo *info = g_new0(VersionInfo, 1);
const char *version = QEMU_VERSION;
char *tmp;
const char *tmp;
int err;
info->qemu = g_new0(VersionTriple, 1);
info->qemu->major = strtol(version, &tmp, 10);
err = qemu_strtoll(version, &tmp, 10, &info->qemu->major);
assert(err == 0);
tmp++;
info->qemu->minor = strtol(tmp, &tmp, 10);
err = qemu_strtoll(tmp, &tmp, 10, &info->qemu->minor);
assert(err == 0);
tmp++;
info->qemu->micro = strtol(tmp, &tmp, 10);
err = qemu_strtoll(tmp, &tmp, 10, &info->qemu->micro);
assert(err == 0);
info->package = g_strdup(QEMU_PKGVERSION);
return info;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册