提交 7be5fe66 编写于 作者: D Daniel P. Berrangé

qemu: directly create virResctrlInfo ignoring capabilities

We always refresh the capabilities object when using virResctrlInfo
during process startup. This is undesirable overhead, because we can
just directly create a virResctrlInfo instead.
Reviewed-by: NMichal Privoznik <mprivozn@redhat.com>
Signed-off-by: NDaniel P. Berrangé <berrange@redhat.com>
上级 adf009b4
...@@ -2724,29 +2724,24 @@ qemuProcessSetupEmulator(virDomainObjPtr vm) ...@@ -2724,29 +2724,24 @@ qemuProcessSetupEmulator(virDomainObjPtr vm)
static int static int
qemuProcessResctrlCreate(virQEMUDriverPtr driver, qemuProcessResctrlCreate(virDomainObjPtr vm)
virDomainObjPtr vm)
{ {
int ret = -1;
size_t i = 0; size_t i = 0;
virCapsPtr caps = NULL;
qemuDomainObjPrivatePtr priv = vm->privateData; qemuDomainObjPrivatePtr priv = vm->privateData;
g_autoptr(virResctrlInfo) resctrl = NULL;
if (!vm->def->nresctrls) if (!vm->def->nresctrls)
return 0; return 0;
/* Force capability refresh since resctrl info can change if (!(resctrl = virResctrlInfoNew()))
* XXX: move cache info into virresctrl so caps are not needed */
caps = virQEMUDriverGetCapabilities(driver, true);
if (!caps)
return -1; return -1;
for (i = 0; i < vm->def->nresctrls; i++) { for (i = 0; i < vm->def->nresctrls; i++) {
size_t j = 0; size_t j = 0;
if (virResctrlAllocCreate(caps->host.resctrl, if (virResctrlAllocCreate(resctrl,
vm->def->resctrls[i]->alloc, vm->def->resctrls[i]->alloc,
priv->machineName) < 0) priv->machineName) < 0)
goto cleanup; return -1;
for (j = 0; j < vm->def->resctrls[i]->nmonitors; j++) { for (j = 0; j < vm->def->resctrls[i]->nmonitors; j++) {
virDomainResctrlMonDefPtr mon = NULL; virDomainResctrlMonDefPtr mon = NULL;
...@@ -2754,14 +2749,11 @@ qemuProcessResctrlCreate(virQEMUDriverPtr driver, ...@@ -2754,14 +2749,11 @@ qemuProcessResctrlCreate(virQEMUDriverPtr driver,
mon = vm->def->resctrls[i]->monitors[j]; mon = vm->def->resctrls[i]->monitors[j];
if (virResctrlMonitorCreate(mon->instance, if (virResctrlMonitorCreate(mon->instance,
priv->machineName) < 0) priv->machineName) < 0)
goto cleanup; return -1;
} }
} }
ret = 0; return 0;
cleanup:
virObjectUnref(caps);
return ret;
} }
...@@ -6882,7 +6874,7 @@ qemuProcessLaunch(virConnectPtr conn, ...@@ -6882,7 +6874,7 @@ qemuProcessLaunch(virConnectPtr conn,
goto cleanup; goto cleanup;
VIR_DEBUG("Setting up resctrl"); VIR_DEBUG("Setting up resctrl");
if (qemuProcessResctrlCreate(driver, vm) < 0) if (qemuProcessResctrlCreate(vm) < 0)
goto cleanup; goto cleanup;
VIR_DEBUG("Setting up managed PR daemon"); VIR_DEBUG("Setting up managed PR daemon");
......
...@@ -100,6 +100,8 @@ typedef virResctrlInfo *virResctrlInfoPtr; ...@@ -100,6 +100,8 @@ typedef virResctrlInfo *virResctrlInfoPtr;
virResctrlInfoPtr virResctrlInfoPtr
virResctrlInfoNew(void); virResctrlInfoNew(void);
G_DEFINE_AUTOPTR_CLEANUP_FUNC(virResctrlInfo, virObjectUnref);
int int
virResctrlInfoGetCache(virResctrlInfoPtr resctrl, virResctrlInfoGetCache(virResctrlInfoPtr resctrl,
unsigned int level, unsigned int level,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册