mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-04-26 15:14:42 +00:00
Add API for copying instances of the qemuCapsPtr object
To allow each VM instance to record additional capabilities without affecting other VMs, there needs to be a way to do a deep copy of the qemuCapsPtr object
This commit is contained in:
parent
116e2facde
commit
4dced75e79
@ -1727,6 +1727,53 @@ no_memory:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
qemuCapsPtr qemuCapsNewCopy(qemuCapsPtr caps)
|
||||||
|
{
|
||||||
|
qemuCapsPtr ret = qemuCapsNew();
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
if (!ret)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
virBitmapCopy(ret->flags, caps->flags);
|
||||||
|
|
||||||
|
ret->version = caps->version;
|
||||||
|
ret->kvmVersion = caps->kvmVersion;
|
||||||
|
|
||||||
|
if (caps->arch &&
|
||||||
|
!(ret->arch = strdup(caps->arch)))
|
||||||
|
goto no_memory;
|
||||||
|
|
||||||
|
if (VIR_ALLOC_N(ret->cpuDefinitions, caps->ncpuDefinitions) < 0)
|
||||||
|
goto no_memory;
|
||||||
|
ret->ncpuDefinitions = caps->ncpuDefinitions;
|
||||||
|
for (i = 0 ; i < caps->ncpuDefinitions ; i++) {
|
||||||
|
if (!(ret->cpuDefinitions[i] = strdup(caps->cpuDefinitions[i])))
|
||||||
|
goto no_memory;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (VIR_ALLOC_N(ret->machineTypes, caps->nmachineTypes) < 0)
|
||||||
|
goto no_memory;
|
||||||
|
if (VIR_ALLOC_N(ret->machineAliases, caps->nmachineTypes) < 0)
|
||||||
|
goto no_memory;
|
||||||
|
ret->nmachineTypes = caps->nmachineTypes;
|
||||||
|
for (i = 0 ; i < caps->nmachineTypes ; i++) {
|
||||||
|
if (!(ret->machineTypes[i] = strdup(caps->machineTypes[i])))
|
||||||
|
goto no_memory;
|
||||||
|
if (caps->machineAliases[i] &&
|
||||||
|
!(ret->machineAliases[i] = strdup(caps->machineAliases[i])))
|
||||||
|
goto no_memory;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
no_memory:
|
||||||
|
virReportOOMError();
|
||||||
|
virObjectUnref(ret);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void qemuCapsDispose(void *obj)
|
void qemuCapsDispose(void *obj)
|
||||||
{
|
{
|
||||||
qemuCapsPtr caps = obj;
|
qemuCapsPtr caps = obj;
|
||||||
|
@ -150,6 +150,7 @@ typedef struct _qemuCaps qemuCaps;
|
|||||||
typedef qemuCaps *qemuCapsPtr;
|
typedef qemuCaps *qemuCapsPtr;
|
||||||
|
|
||||||
qemuCapsPtr qemuCapsNew(void);
|
qemuCapsPtr qemuCapsNew(void);
|
||||||
|
qemuCapsPtr qemuCapsNewCopy(qemuCapsPtr caps);
|
||||||
|
|
||||||
void qemuCapsSet(qemuCapsPtr caps,
|
void qemuCapsSet(qemuCapsPtr caps,
|
||||||
enum qemuCapsFlags flag) ATTRIBUTE_NONNULL(1);
|
enum qemuCapsFlags flag) ATTRIBUTE_NONNULL(1);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user