mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 12:35:17 +00:00
Helper function for making a copy of virCPUDefPtr
This commit is contained in:
parent
661ae104c2
commit
284805e666
@ -67,6 +67,43 @@ virCPUDefFree(virCPUDefPtr def)
|
||||
}
|
||||
|
||||
|
||||
virCPUDefPtr
|
||||
virCPUDefCopy(const virCPUDefPtr cpu)
|
||||
{
|
||||
virCPUDefPtr copy;
|
||||
unsigned int i;
|
||||
|
||||
if (!cpu)
|
||||
return NULL;
|
||||
|
||||
if (VIR_ALLOC(copy) < 0
|
||||
|| (cpu->arch && !(copy->arch = strdup(cpu->arch)))
|
||||
|| (cpu->model && !(copy->model = strdup(cpu->model)))
|
||||
|| VIR_ALLOC_N(copy->features, cpu->nfeatures) < 0)
|
||||
goto no_memory;
|
||||
|
||||
copy->type = cpu->type;
|
||||
copy->match = cpu->match;
|
||||
copy->sockets = cpu->sockets;
|
||||
copy->cores = cpu->cores;
|
||||
copy->threads = cpu->threads;
|
||||
copy->nfeatures = cpu->nfeatures;
|
||||
|
||||
for (i = 0; i < copy->nfeatures; i++) {
|
||||
copy->features[i].policy = cpu->features[i].policy;
|
||||
if (!(copy->features[i].name = strdup(cpu->features[i].name)))
|
||||
goto no_memory;
|
||||
}
|
||||
|
||||
return copy;
|
||||
|
||||
no_memory:
|
||||
virReportOOMError();
|
||||
virCPUDefFree(copy);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
#ifndef PROXY
|
||||
virCPUDefPtr
|
||||
virCPUDefParseXML(const xmlNodePtr node,
|
||||
|
@ -83,6 +83,9 @@ struct _virCPUDef {
|
||||
void
|
||||
virCPUDefFree(virCPUDefPtr def);
|
||||
|
||||
virCPUDefPtr
|
||||
virCPUDefCopy(const virCPUDefPtr cpu);
|
||||
|
||||
# ifndef PROXY
|
||||
virCPUDefPtr
|
||||
virCPUDefParseXML(const xmlNodePtr node,
|
||||
|
@ -90,6 +90,7 @@ virCPUDefParseXML;
|
||||
virCPUDefFormat;
|
||||
virCPUDefFormatBuf;
|
||||
virCPUDefAddFeature;
|
||||
virCPUDefCopy;
|
||||
|
||||
|
||||
# datatypes.h
|
||||
|
Loading…
x
Reference in New Issue
Block a user