提交 d6cb0d25 编写于 作者: P Peter Krempa

domain: Add helper to determine presence of memory baloon

上级 33b9598c
......@@ -24316,3 +24316,17 @@ virDomainDefCheckDuplicateDiskInfo(virDomainDefPtr def)
return 0;
}
/**
* virDomainDefHasMemballoon:
* @def: domain definition
*
* Returns true if domain has a memory ballooning device configured.
*/
bool
virDomainDefHasMemballoon(const virDomainDef *def)
{
return def->memballoon &&
def->memballoon->model != VIR_DOMAIN_MEMBALLOON_MODEL_NONE;
}
......@@ -3160,4 +3160,6 @@ int virDomainDefGetVcpuPinInfoHelper(virDomainDefPtr def,
virBitmapPtr autoCpuset)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(4) ATTRIBUTE_RETURN_CHECK;
bool virDomainDefHasMemballoon(const virDomainDef *def) ATTRIBUTE_NONNULL(1);
#endif /* __DOMAIN_CONF_H */
......@@ -225,6 +225,7 @@ virDomainDefGetVcpuPinInfoHelper;
virDomainDefGetVcpus;
virDomainDefGetVcpusMax;
virDomainDefHasDeviceAddress;
virDomainDefHasMemballoon;
virDomainDefHasMemoryHotplug;
virDomainDefHasVcpusOffline;
virDomainDefMaybeAddController;
......
......@@ -3481,8 +3481,7 @@ qemuBuildMemballoonCommandLine(virCommandPtr cmd,
virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_S390) && def->memballoon)
def->memballoon->model = VIR_DOMAIN_MEMBALLOON_MODEL_NONE;
if (!def->memballoon ||
def->memballoon->model == VIR_DOMAIN_MEMBALLOON_MODEL_NONE)
if (!virDomainDefHasMemballoon(def))
return 0;
if (def->memballoon->model != VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO) {
......
......@@ -4534,8 +4534,7 @@ qemuDomainUpdateCurrentMemorySize(virQEMUDriverPtr driver,
/* if no balloning is available, the current size equals to the current
* full memory size */
if (!vm->def->memballoon ||
vm->def->memballoon->model == VIR_DOMAIN_MEMBALLOON_MODEL_NONE) {
if (!virDomainDefHasMemballoon(vm->def)) {
vm->def->mem.cur_balloon = virDomainDefGetMemoryActual(vm->def);
return 0;
}
......
......@@ -19099,8 +19099,7 @@ qemuDomainGetStatsBalloon(virQEMUDriverPtr driver ATTRIBUTE_UNUSED,
unsigned long long cur_balloon = 0;
int err = 0;
if (dom->def->memballoon &&
dom->def->memballoon->model == VIR_DOMAIN_MEMBALLOON_MODEL_NONE) {
if (!virDomainDefHasMemballoon(dom->def)) {
cur_balloon = virDomainDefGetMemoryActual(dom->def);
} else if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BALLOON_EVENT)) {
cur_balloon = dom->def->mem.cur_balloon;
......
......@@ -2003,8 +2003,7 @@ qemuProcessRefreshBalloonState(virQEMUDriverPtr driver,
/* if no ballooning is available, the current size equals to the current
* full memory size */
if (!vm->def->memballoon ||
vm->def->memballoon->model == VIR_DOMAIN_MEMBALLOON_MODEL_NONE) {
if (!virDomainDefHasMemballoon(vm->def)) {
vm->def->mem.cur_balloon = virDomainDefGetMemoryActual(vm->def);
return 0;
}
......@@ -4456,8 +4455,7 @@ qemuProcessSetupBalloon(virQEMUDriverPtr driver,
int period;
int ret = -1;
if (!vm->def->memballoon ||
vm->def->memballoon->model == VIR_DOMAIN_MEMBALLOON_MODEL_NONE)
if (!virDomainDefHasMemballoon(vm->def))
return 0;
period = vm->def->memballoon->period;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册