qemu_command.c: move QEMU_CAPS_DEVICE_NVDIMM_UNARMED check to qemu_validate.c

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
This commit is contained in:
Daniel Henrique Barboza 2020-10-14 10:11:13 -03:00
parent 0bf8dfb02a
commit 27371bd517
5 changed files with 20 additions and 18 deletions

View File

@ -3199,8 +3199,7 @@ qemuBuildMemoryDimmBackendStr(virBufferPtr buf,
char *
qemuBuildMemoryDeviceStr(virDomainMemoryDefPtr mem,
qemuDomainObjPrivatePtr priv)
qemuBuildMemoryDeviceStr(virDomainMemoryDefPtr mem)
{
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
const char *device;
@ -3236,12 +3235,6 @@ qemuBuildMemoryDeviceStr(virDomainMemoryDefPtr mem,
}
if (mem->readonly) {
if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE_NVDIMM_UNARMED)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("nvdimm readonly property is not available "
"with this QEMU binary"));
return NULL;
}
virBufferAddLit(&buf, "unarmed=on,");
}
@ -7415,7 +7408,7 @@ qemuBuildMemoryDeviceCommandLine(virCommandPtr cmd,
virCommandAddArg(cmd, "-object");
virCommandAddArgBuffer(cmd, &buf);
if (!(dimmStr = qemuBuildMemoryDeviceStr(def->mems[i], priv)))
if (!(dimmStr = qemuBuildMemoryDeviceStr(def->mems[i])))
return -1;
virCommandAddArgList(cmd, "-device", dimmStr, NULL);

View File

@ -154,8 +154,7 @@ int qemuBuildMemoryBackendProps(virJSONValuePtr *backendProps,
const virDomainMemoryDef *mem,
bool force);
char *qemuBuildMemoryDeviceStr(virDomainMemoryDefPtr mem,
qemuDomainObjPrivatePtr priv);
char *qemuBuildMemoryDeviceStr(virDomainMemoryDefPtr mem);
/* Current, best practice */
char *qemuBuildPCIHostdevDevStr(const virDomainDef *def,

View File

@ -2384,7 +2384,7 @@ qemuDomainAttachMemory(virQEMUDriverPtr driver,
objalias = g_strdup_printf("mem%s", mem->info.alias);
if (!(devstr = qemuBuildMemoryDeviceStr(mem, priv)))
if (!(devstr = qemuBuildMemoryDeviceStr(mem)))
goto cleanup;
if (qemuBuildMemoryBackendProps(&props, objalias, cfg,

View File

@ -4506,11 +4506,20 @@ static int
qemuValidateDomainDeviceDefMemory(virDomainMemoryDefPtr mem,
virQEMUCapsPtr qemuCaps)
{
if (mem->model == VIR_DOMAIN_MEMORY_MODEL_NVDIMM &&
!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_NVDIMM)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("nvdimm isn't supported by this QEMU binary"));
return -1;
if (mem->model == VIR_DOMAIN_MEMORY_MODEL_NVDIMM) {
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_NVDIMM)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("nvdimm isn't supported by this QEMU binary"));
return -1;
}
if (mem->readonly &&
!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_NVDIMM_UNARMED)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("nvdimm readonly property is not available "
"with this QEMU binary"));
return -1;
}
}
return 0;

View File

@ -1284,7 +1284,8 @@ mymain(void)
DO_TEST("memory-hotplug-nvdimm-label", QEMU_CAPS_DEVICE_NVDIMM);
DO_TEST("memory-hotplug-nvdimm-align", QEMU_CAPS_DEVICE_NVDIMM);
DO_TEST("memory-hotplug-nvdimm-pmem", QEMU_CAPS_DEVICE_NVDIMM);
DO_TEST("memory-hotplug-nvdimm-readonly", QEMU_CAPS_DEVICE_NVDIMM);
DO_TEST("memory-hotplug-nvdimm-readonly", QEMU_CAPS_DEVICE_NVDIMM,
QEMU_CAPS_DEVICE_NVDIMM_UNARMED);
DO_TEST("memory-hotplug-nvdimm-ppc64", QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
QEMU_CAPS_DEVICE_NVDIMM);
DO_TEST("net-udp", NONE);