提交 9b3322c7 编写于 作者: T Tal Kain 提交者: Eric Blake

qemu: simplify use of virArchFromHost

Reusing the result of virArchFromHost instead of calling it multiple times
Signed-off-by: NTal Kain <tal.kain@ravellosystems.com>
Signed-off-by: NEric Blake <eblake@redhat.com>
上级 0f4f5cb2
...@@ -864,8 +864,9 @@ virCapsPtr virQEMUCapsInit(virQEMUCapsCachePtr cache) ...@@ -864,8 +864,9 @@ virCapsPtr virQEMUCapsInit(virQEMUCapsCachePtr cache)
{ {
virCapsPtr caps; virCapsPtr caps;
int i; int i;
virArch hostarch = virArchFromHost();
if ((caps = virCapabilitiesNew(virArchFromHost(), if ((caps = virCapabilitiesNew(hostarch,
1, 1)) == NULL) 1, 1)) == NULL)
goto error; goto error;
...@@ -878,7 +879,7 @@ virCapsPtr virQEMUCapsInit(virQEMUCapsCachePtr cache) ...@@ -878,7 +879,7 @@ virCapsPtr virQEMUCapsInit(virQEMUCapsCachePtr cache)
VIR_WARN("Failed to query host NUMA topology, disabling NUMA capabilities"); VIR_WARN("Failed to query host NUMA topology, disabling NUMA capabilities");
} }
if (virQEMUCapsInitCPU(caps, virArchFromHost()) < 0) if (virQEMUCapsInitCPU(caps, hostarch) < 0)
VIR_WARN("Failed to get host CPU"); VIR_WARN("Failed to get host CPU");
/* Add the power management features of the host */ /* Add the power management features of the host */
...@@ -895,7 +896,7 @@ virCapsPtr virQEMUCapsInit(virQEMUCapsCachePtr cache) ...@@ -895,7 +896,7 @@ virCapsPtr virQEMUCapsInit(virQEMUCapsCachePtr cache)
*/ */
for (i = 0 ; i < VIR_ARCH_LAST ; i++) for (i = 0 ; i < VIR_ARCH_LAST ; i++)
if (virQEMUCapsInitGuest(caps, cache, if (virQEMUCapsInitGuest(caps, cache,
virArchFromHost(), hostarch,
i) < 0) i) < 0)
goto error; goto error;
...@@ -1643,17 +1644,19 @@ int virQEMUCapsGetDefaultVersion(virCapsPtr caps, ...@@ -1643,17 +1644,19 @@ int virQEMUCapsGetDefaultVersion(virCapsPtr caps,
{ {
const char *binary; const char *binary;
virQEMUCapsPtr qemucaps; virQEMUCapsPtr qemucaps;
virArch hostarch;
if (*version > 0) if (*version > 0)
return 0; return 0;
hostarch = virArchFromHost();
if ((binary = virCapabilitiesDefaultGuestEmulator(caps, if ((binary = virCapabilitiesDefaultGuestEmulator(caps,
"hvm", "hvm",
virArchFromHost(), hostarch,
"qemu")) == NULL) { "qemu")) == NULL) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("Cannot find suitable emulator for %s"), _("Cannot find suitable emulator for %s"),
virArchToString(virArchFromHost())); virArchToString(hostarch));
return -1; return -1;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册