libvirt/SOURCES/libvirt-qemuBuildMemoryBack...

173 lines
7.9 KiB
Diff

From c59ebd3e7bd1307ef6907a830dc9617eb6fe39b2 Mon Sep 17 00:00:00 2001
Message-Id: <c59ebd3e7bd1307ef6907a830dc9617eb6fe39b2@dist-git>
From: Michal Privoznik <mprivozn@redhat.com>
Date: Tue, 18 Dec 2018 11:47:35 +0100
Subject: [PATCH] qemuBuildMemoryBackendProps: Pass @priv instead of its
individual members
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
https://bugzilla.redhat.com/show_bug.cgi?id=1624223
So far we have two arguments that we are passing to
qemuBuildMemoryBackendProps() and that are taken from domain
private data: @qemuCaps and @autoNodeset. In the next commit I
will use one more item from there. Therefore, instead of having
it as yet another argument to the function, pass pointer to the
private data object.
There is one change in qemuDomainAttachMemory() where previously
@autoNodeset was NULL but now is priv->autoNodeset (which may be
set). This is safe to do as @autoNodeset is advisory only.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
(cherry picked from commit 9923584c628e160705124ad81d782a7214aac8d3)
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Conflicts:
src/qemu/qemu_command.c: Context mostly, as memfd backend is not
backported (24b74d187ca).
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Message-Id: <71d56cdc7e5cdd0c9b664ded2a4cf93e3e9d38b0.1545129996.git.mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/qemu/qemu_command.c | 28 +++++++++++++---------------
src/qemu/qemu_command.h | 3 +--
src/qemu/qemu_hotplug.c | 2 +-
3 files changed, 15 insertions(+), 18 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index c06f396b44..fa2b904239 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -3041,22 +3041,21 @@ qemuBuildControllerDevCommandLine(virCommandPtr cmd,
* @backendProps: [out] constructed object
* @alias: alias of the device
* @cfg: qemu driver config object
- * @qemuCaps: qemu capabilities object
+ * @priv: pointer to domain private object
* @def: domain definition object
* @mem: memory definition object
- * @autoNodeset: fallback nodeset in case of automatic NUMA placement
* @force: forcibly use one of the backends
*
* Creates a configuration object that represents memory backend of given guest
- * NUMA node (domain @def and @mem). Use @autoNodeset to fine tune the
+ * NUMA node (domain @def and @mem). Use @priv->autoNodeset to fine tune the
* placement of the memory on the host NUMA nodes.
*
* By default, if no memory-backend-* object is necessary to fulfil the guest
* configuration value of 1 is returned. This behaviour can be suppressed by
* setting @force to true in which case 0 would be returned.
*
- * Then, if one of the two memory-backend-* should be used, the @qemuCaps is
- * consulted to check if qemu does support it.
+ * Then, if one of the two memory-backend-* should be used, the @priv->qemuCaps
+ * is consulted to check if qemu does support it.
*
* Returns: 0 on success,
* 1 on success and if there's no need to use memory-backend-*
@@ -3066,10 +3065,9 @@ int
qemuBuildMemoryBackendProps(virJSONValuePtr *backendProps,
const char *alias,
virQEMUDriverConfigPtr cfg,
- virQEMUCapsPtr qemuCaps,
+ qemuDomainObjPrivatePtr priv,
virDomainDefPtr def,
virDomainMemoryDefPtr mem,
- virBitmapPtr autoNodeset,
bool force)
{
const char *backendType = "memory-backend-file";
@@ -3207,7 +3205,7 @@ qemuBuildMemoryBackendProps(virJSONValuePtr *backendProps,
if (!mem->nvdimmPath &&
discard == VIR_TRISTATE_BOOL_YES) {
- if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_MEMORY_FILE_DISCARD)) {
+ if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_OBJECT_MEMORY_FILE_DISCARD)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("this QEMU doesn't support memory discard"));
goto cleanup;
@@ -3244,7 +3242,7 @@ qemuBuildMemoryBackendProps(virJSONValuePtr *backendProps,
if (mem->sourceNodes) {
nodemask = mem->sourceNodes;
} else {
- if (virDomainNumatuneMaybeGetNodeset(def->numa, autoNodeset,
+ if (virDomainNumatuneMaybeGetNodeset(def->numa, priv->autoNodeset,
&nodemask, mem->targetNode) < 0)
goto cleanup;
}
@@ -3270,13 +3268,13 @@ qemuBuildMemoryBackendProps(virJSONValuePtr *backendProps,
} else {
/* otherwise check the required capability */
if (STREQ(backendType, "memory-backend-file") &&
- !virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_MEMORY_FILE)) {
+ !virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_OBJECT_MEMORY_FILE)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("this qemu doesn't support the "
"memory-backend-file object"));
goto cleanup;
} else if (STREQ(backendType, "memory-backend-ram") &&
- !virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_MEMORY_RAM)) {
+ !virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_OBJECT_MEMORY_RAM)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("this qemu doesn't support the "
"memory-backend-ram object"));
@@ -3319,8 +3317,8 @@ qemuBuildMemoryCellBackendStr(virDomainDefPtr def,
mem.targetNode = cell;
mem.info.alias = alias;
- if ((rc = qemuBuildMemoryBackendProps(&props, alias, cfg, priv->qemuCaps,
- def, &mem, priv->autoNodeset, false)) < 0)
+ if ((rc = qemuBuildMemoryBackendProps(&props, alias, cfg,
+ priv, def, &mem, false)) < 0)
goto cleanup;
if (virQEMUBuildObjectCommandlineFromJSON(buf, props) < 0)
@@ -3356,8 +3354,8 @@ qemuBuildMemoryDimmBackendStr(virBufferPtr buf,
if (virAsprintf(&alias, "mem%s", mem->info.alias) < 0)
goto cleanup;
- if (qemuBuildMemoryBackendProps(&props, alias, cfg, priv->qemuCaps,
- def, mem, priv->autoNodeset, true) < 0)
+ if (qemuBuildMemoryBackendProps(&props, alias, cfg,
+ priv, def, mem, true) < 0)
goto cleanup;
if (virQEMUBuildObjectCommandlineFromJSON(buf, props) < 0)
diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h
index e8cd8ed04e..bf46bde48f 100644
--- a/src/qemu/qemu_command.h
+++ b/src/qemu/qemu_command.h
@@ -125,10 +125,9 @@ int qemuBuildControllerDevStr(const virDomainDef *domainDef,
int qemuBuildMemoryBackendProps(virJSONValuePtr *backendProps,
const char *alias,
virQEMUDriverConfigPtr cfg,
- virQEMUCapsPtr qemuCaps,
+ qemuDomainObjPrivatePtr priv,
virDomainDefPtr def,
virDomainMemoryDefPtr mem,
- virBitmapPtr autoNodeset,
bool force);
char *qemuBuildMemoryDeviceStr(virDomainMemoryDefPtr mem);
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 410cdca3c5..5b9a5683bb 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -2121,7 +2121,7 @@ qemuDomainAttachMemory(virQEMUDriverPtr driver,
goto cleanup;
if (qemuBuildMemoryBackendProps(&props, objalias, cfg,
- priv->qemuCaps, vm->def, mem, NULL, true) < 0)
+ priv, vm->def, mem, true) < 0)
goto cleanup;
if (qemuProcessBuildDestroyMemoryPaths(driver, vm, mem, true) < 0)
--
2.22.0