mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
conf: Turn @uuid member of _virDomainMemoryDef struct into a pointer
The _virDomainMemoryDef structure has @uuid member which is needed for PPC64 guests. No other architectures use it. Since the member is VIR_UUID_BUFLEN bytes long, the structure is unnecessary big. If the member is just a pointer then we can also replace some calls of virUUIDIsValid() with plain test against NULL and also simplify formatter code which can now also check the pointer against NULL. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
parent
ae83f592a7
commit
0123b42c54
@ -3116,6 +3116,7 @@ void virDomainMemoryDefFree(virDomainMemoryDefPtr def)
|
||||
|
||||
VIR_FREE(def->nvdimmPath);
|
||||
virBitmapFree(def->sourceNodes);
|
||||
VIR_FREE(def->uuid);
|
||||
virDomainDeviceInfoClear(&def->info);
|
||||
VIR_FREE(def);
|
||||
}
|
||||
@ -15530,6 +15531,7 @@ virDomainMemoryDefParseXML(virDomainXMLOptionPtr xmlopt,
|
||||
/* Extract nvdimm uuid or generate a new one */
|
||||
tmp = virXPathString("string(./uuid[1])", ctxt);
|
||||
|
||||
def->uuid = g_new0(unsigned char, VIR_UUID_BUFLEN);
|
||||
if (!tmp) {
|
||||
if (virUUIDGenerate(def->uuid) < 0) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
@ -22808,7 +22810,9 @@ virDomainMemoryDefCheckABIStability(virDomainMemoryDefPtr src,
|
||||
return false;
|
||||
}
|
||||
|
||||
if (memcmp(src->uuid, dst->uuid, VIR_UUID_BUFLEN) != 0) {
|
||||
if ((src->uuid || dst->uuid) &&
|
||||
!(src->uuid && dst->uuid &&
|
||||
memcmp(src->uuid, dst->uuid, VIR_UUID_BUFLEN) == 0)) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
_("Target NVDIMM UUID doesn't match source NVDIMM"));
|
||||
return false;
|
||||
@ -26560,7 +26564,6 @@ virDomainMemoryTargetDefFormat(virBufferPtr buf,
|
||||
static int
|
||||
virDomainMemoryDefFormat(virBufferPtr buf,
|
||||
virDomainMemoryDefPtr def,
|
||||
const virDomainDef *dom,
|
||||
unsigned int flags)
|
||||
{
|
||||
const char *model = virDomainMemoryModelTypeToString(def->model);
|
||||
@ -26575,8 +26578,7 @@ virDomainMemoryDefFormat(virBufferPtr buf,
|
||||
virBufferAddLit(buf, ">\n");
|
||||
virBufferAdjustIndent(buf, 2);
|
||||
|
||||
if (def->model == VIR_DOMAIN_MEMORY_MODEL_NVDIMM &&
|
||||
ARCH_IS_PPC64(dom->os.arch)) {
|
||||
if (def->uuid) {
|
||||
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
||||
|
||||
virUUIDFormat(def->uuid, uuidstr);
|
||||
@ -28974,7 +28976,7 @@ virDomainDefFormatInternalSetRootName(virDomainDefPtr def,
|
||||
virDomainShmemDefFormat(buf, def->shmems[n], flags);
|
||||
|
||||
for (n = 0; n < def->nmems; n++) {
|
||||
if (virDomainMemoryDefFormat(buf, def->mems[n], def, flags) < 0)
|
||||
if (virDomainMemoryDefFormat(buf, def->mems[n], flags) < 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -30091,7 +30093,7 @@ virDomainDeviceDefCopy(virDomainDeviceDefPtr src,
|
||||
rc = 0;
|
||||
break;
|
||||
case VIR_DOMAIN_DEVICE_MEMORY:
|
||||
rc = virDomainMemoryDefFormat(&buf, src->data.memory, def, flags);
|
||||
rc = virDomainMemoryDefFormat(&buf, src->data.memory, flags);
|
||||
break;
|
||||
case VIR_DOMAIN_DEVICE_SHMEM:
|
||||
virDomainShmemDefFormat(&buf, src->data.shmem, flags);
|
||||
|
@ -2331,7 +2331,7 @@ struct _virDomainMemoryDef {
|
||||
bool readonly; /* valid only for NVDIMM */
|
||||
|
||||
/* required for QEMU NVDIMM ppc64 support */
|
||||
unsigned char uuid[VIR_UUID_BUFLEN];
|
||||
unsigned char *uuid; /* VIR_UUID_BUFLEN bytes long */
|
||||
|
||||
virDomainDeviceInfo info;
|
||||
};
|
||||
|
@ -3319,7 +3319,7 @@ qemuBuildMemoryDeviceStr(const virDomainDef *def,
|
||||
if (mem->labelsize)
|
||||
virBufferAsprintf(&buf, "label-size=%llu,", mem->labelsize * 1024);
|
||||
|
||||
if (virUUIDIsValid(mem->uuid)) {
|
||||
if (mem->uuid) {
|
||||
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
||||
|
||||
virUUIDFormat(mem->uuid, uuidstr);
|
||||
|
Loading…
x
Reference in New Issue
Block a user