mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 14:15:28 +00:00
domain_conf, qemu: move virDomainNVDimmAlignSizePseries to qemu_domain.c
Since the function is now only used in qemu_domain.c, move it from
domain_conf.c and rename it.
This reverts the work done in commit ace5931553
(conf, qemu: move qemuDomainNVDimmAlignSizePseries to domain_conf.c).
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
This commit is contained in:
parent
198c1eb6b4
commit
4523be1ed7
@ -16817,41 +16817,6 @@ virDomainSEVDefParseXML(xmlNodePtr sevNode,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
|
||||||
virDomainNVDimmAlignSizePseries(virDomainMemoryDefPtr mem)
|
|
||||||
{
|
|
||||||
/* For NVDIMMs in ppc64 in we want to align down the guest
|
|
||||||
* visible space, instead of align up, to avoid writing
|
|
||||||
* beyond the end of file by adding a potential 256MiB
|
|
||||||
* to the user specified size.
|
|
||||||
*
|
|
||||||
* The label-size is mandatory for ppc64 as well, meaning that
|
|
||||||
* the guest visible space will be target_size-label_size.
|
|
||||||
*
|
|
||||||
* Finally, target_size must include label_size.
|
|
||||||
*
|
|
||||||
* The above can be summed up as follows:
|
|
||||||
*
|
|
||||||
* target_size = AlignDown(target_size - label_size) + label_size
|
|
||||||
*/
|
|
||||||
unsigned long long ppc64AlignSize = 256 * 1024;
|
|
||||||
unsigned long long guestArea = mem->size - mem->labelsize;
|
|
||||||
|
|
||||||
/* Align down guest_area. 256MiB is the minimum size. Error
|
|
||||||
* out if target_size is smaller than 256MiB + label_size,
|
|
||||||
* since aligning it up will cause QEMU errors. */
|
|
||||||
if (mem->size < (ppc64AlignSize + mem->labelsize)) {
|
|
||||||
virReportError(VIR_ERR_XML_ERROR, "%s",
|
|
||||||
_("minimum target size for the NVDIMM "
|
|
||||||
"must be 256MB plus the label size"));
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
guestArea = (guestArea/ppc64AlignSize) * ppc64AlignSize;
|
|
||||||
mem->size = guestArea + mem->labelsize;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static virDomainMemoryDefPtr
|
static virDomainMemoryDefPtr
|
||||||
virDomainMemoryDefParseXML(virDomainXMLOptionPtr xmlopt,
|
virDomainMemoryDefParseXML(virDomainXMLOptionPtr xmlopt,
|
||||||
|
@ -3912,9 +3912,6 @@ bool
|
|||||||
virDomainBlockIoTuneInfoEqual(const virDomainBlockIoTuneInfo *a,
|
virDomainBlockIoTuneInfoEqual(const virDomainBlockIoTuneInfo *a,
|
||||||
const virDomainBlockIoTuneInfo *b);
|
const virDomainBlockIoTuneInfo *b);
|
||||||
|
|
||||||
int
|
|
||||||
virDomainNVDimmAlignSizePseries(virDomainMemoryDefPtr mem);
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
virHostdevIsSCSIDevice(const virDomainHostdevDef *hostdev)
|
virHostdevIsSCSIDevice(const virDomainHostdevDef *hostdev)
|
||||||
ATTRIBUTE_NONNULL(1);
|
ATTRIBUTE_NONNULL(1);
|
||||||
|
@ -546,7 +546,6 @@ virDomainNetTypeToString;
|
|||||||
virDomainNetUpdate;
|
virDomainNetUpdate;
|
||||||
virDomainNostateReasonTypeFromString;
|
virDomainNostateReasonTypeFromString;
|
||||||
virDomainNostateReasonTypeToString;
|
virDomainNostateReasonTypeToString;
|
||||||
virDomainNVDimmAlignSizePseries;
|
|
||||||
virDomainObjAssignDef;
|
virDomainObjAssignDef;
|
||||||
virDomainObjBroadcast;
|
virDomainObjBroadcast;
|
||||||
virDomainObjCheckActive;
|
virDomainObjCheckActive;
|
||||||
|
@ -5341,6 +5341,43 @@ qemuDomainTPMDefPostParse(virDomainTPMDefPtr tpm,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
qemuDomainNVDimmAlignSizePseries(virDomainMemoryDefPtr mem)
|
||||||
|
{
|
||||||
|
/* For NVDIMMs in ppc64 in we want to align down the guest
|
||||||
|
* visible space, instead of align up, to avoid writing
|
||||||
|
* beyond the end of file by adding a potential 256MiB
|
||||||
|
* to the user specified size.
|
||||||
|
*
|
||||||
|
* The label-size is mandatory for ppc64 as well, meaning that
|
||||||
|
* the guest visible space will be target_size-label_size.
|
||||||
|
*
|
||||||
|
* Finally, target_size must include label_size.
|
||||||
|
*
|
||||||
|
* The above can be summed up as follows:
|
||||||
|
*
|
||||||
|
* target_size = AlignDown(target_size - label_size) + label_size
|
||||||
|
*/
|
||||||
|
unsigned long long ppc64AlignSize = 256 * 1024;
|
||||||
|
unsigned long long guestArea = mem->size - mem->labelsize;
|
||||||
|
|
||||||
|
/* Align down guest_area. 256MiB is the minimum size. Error
|
||||||
|
* out if target_size is smaller than 256MiB + label_size,
|
||||||
|
* since aligning it up will cause QEMU errors. */
|
||||||
|
if (mem->size < (ppc64AlignSize + mem->labelsize)) {
|
||||||
|
virReportError(VIR_ERR_XML_ERROR, "%s",
|
||||||
|
_("minimum target size for the NVDIMM "
|
||||||
|
"must be 256MB plus the label size"));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
guestArea = (guestArea/ppc64AlignSize) * ppc64AlignSize;
|
||||||
|
mem->size = guestArea + mem->labelsize;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
qemuDomainMemoryDefPostParse(virDomainMemoryDefPtr mem, virArch arch,
|
qemuDomainMemoryDefPostParse(virDomainMemoryDefPtr mem, virArch arch,
|
||||||
unsigned int parseFlags)
|
unsigned int parseFlags)
|
||||||
@ -5362,7 +5399,7 @@ qemuDomainMemoryDefPostParse(virDomainMemoryDefPtr mem, virArch arch,
|
|||||||
unsigned long long ppc64MemModuleAlign = 256 * 1024;
|
unsigned long long ppc64MemModuleAlign = 256 * 1024;
|
||||||
|
|
||||||
if (mem->model == VIR_DOMAIN_MEMORY_MODEL_NVDIMM) {
|
if (mem->model == VIR_DOMAIN_MEMORY_MODEL_NVDIMM) {
|
||||||
if (virDomainNVDimmAlignSizePseries(mem) < 0)
|
if (qemuDomainNVDimmAlignSizePseries(mem) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
mem->size = VIR_ROUND_UP(mem->size, ppc64MemModuleAlign);
|
mem->size = VIR_ROUND_UP(mem->size, ppc64MemModuleAlign);
|
||||||
@ -8129,7 +8166,7 @@ qemuDomainAlignMemorySizes(virDomainDefPtr def)
|
|||||||
for (i = 0; i < def->nmems; i++) {
|
for (i = 0; i < def->nmems; i++) {
|
||||||
if (def->mems[i]->model == VIR_DOMAIN_MEMORY_MODEL_NVDIMM &&
|
if (def->mems[i]->model == VIR_DOMAIN_MEMORY_MODEL_NVDIMM &&
|
||||||
ARCH_IS_PPC64(def->os.arch)) {
|
ARCH_IS_PPC64(def->os.arch)) {
|
||||||
if (virDomainNVDimmAlignSizePseries(def->mems[i]) < 0)
|
if (qemuDomainNVDimmAlignSizePseries(def->mems[i]) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
align = qemuDomainGetMemoryModuleSizeAlignment(def, def->mems[i]);
|
align = qemuDomainGetMemoryModuleSizeAlignment(def, def->mems[i]);
|
||||||
@ -8166,7 +8203,7 @@ qemuDomainMemoryDeviceAlignSize(virDomainDefPtr def,
|
|||||||
{
|
{
|
||||||
if (mem->model == VIR_DOMAIN_MEMORY_MODEL_NVDIMM &&
|
if (mem->model == VIR_DOMAIN_MEMORY_MODEL_NVDIMM &&
|
||||||
ARCH_IS_PPC64(def->os.arch)) {
|
ARCH_IS_PPC64(def->os.arch)) {
|
||||||
return virDomainNVDimmAlignSizePseries(mem);
|
return qemuDomainNVDimmAlignSizePseries(mem);
|
||||||
} else {
|
} else {
|
||||||
mem->size = VIR_ROUND_UP(mem->size,
|
mem->size = VIR_ROUND_UP(mem->size,
|
||||||
qemuDomainGetMemorySizeAlignment(def));
|
qemuDomainGetMemorySizeAlignment(def));
|
||||||
|
Loading…
Reference in New Issue
Block a user