}
+/**
+ * virCPUDefStealModel:
+ *
+ * Move CPU model related parts virCPUDef from @src to @dst. If @keepVendor
+ * is true, the function keeps the original vendor/vendor_id in @dst rather
+ * than overwriting it with the values from @src.
+ */
void
virCPUDefStealModel(virCPUDefPtr dst,
- virCPUDefPtr src)
+ virCPUDefPtr src,
+ bool keepVendor)
{
+ char *vendor;
+ char *vendor_id;
+
+ if (keepVendor) {
+ VIR_STEAL_PTR(vendor, dst->vendor);
+ VIR_STEAL_PTR(vendor_id, dst->vendor_id);
+ }
+
virCPUDefFreeModel(dst);
VIR_STEAL_PTR(dst->model, src->model);
- VIR_STEAL_PTR(dst->vendor, src->vendor);
- VIR_STEAL_PTR(dst->vendor_id, src->vendor_id);
VIR_STEAL_PTR(dst->features, src->features);
dst->nfeatures_max = src->nfeatures_max;
src->nfeatures_max = 0;
dst->nfeatures = src->nfeatures;
src->nfeatures = 0;
+
+ if (keepVendor) {
+ dst->vendor = vendor;
+ dst->vendor_id = vendor_id;
+ } else {
+ VIR_STEAL_PTR(dst->vendor, src->vendor);
+ VIR_STEAL_PTR(dst->vendor_id, src->vendor_id);
+ }
}
void
virCPUDefStealModel(virCPUDefPtr dst,
- virCPUDefPtr src);
+ virCPUDefPtr src,
+ bool keepVendor);
virCPUDefPtr
virCPUDefCopy(const virCPUDef *cpu);
if (virCPUDefCopyModel(updated, host, true) < 0)
goto cleanup;
- virCPUDefStealModel(guest, updated);
+ virCPUDefStealModel(guest, updated, false);
guest->mode = VIR_CPU_MODE_CUSTOM;
guest->match = VIR_CPU_MATCH_EXACT;
ret = 0;
goto cleanup;
}
- virCPUDefStealModel(guest, updated);
+ virCPUDefStealModel(guest, updated,
+ guest->mode == VIR_CPU_MODE_CUSTOM);
guest->mode = VIR_CPU_MODE_CUSTOM;
guest->match = VIR_CPU_MATCH_EXACT;
ret = 0;
goto cleanup;
}
- virCPUDefStealModel(cpu, translated);
+ virCPUDefStealModel(cpu, translated, true);
ret = 0;
cleanup:
<cpu mode='custom' match='exact'>
<model fallback='allow'>486</model>
- <vendor>Intel</vendor>
<topology sockets='2' cores='4' threads='1'/>
<feature policy='require' name='de'/>
<feature policy='require' name='tsc'/>
<cpu mode='custom' match='exact'>
<model fallback='allow'>Nehalem</model>
- <vendor>Intel</vendor>
<topology sockets='2' cores='4' threads='1'/>
<feature policy='force' name='pbe'/>
<feature policy='force' name='monitor'/>
<cpu mode='custom' match='exact'>
<model fallback='allow'>Penryn</model>
- <vendor>Intel</vendor>
<feature policy='require' name='dca'/>
<feature policy='require' name='xtpr'/>
<feature policy='require' name='tm2'/>
<cpu mode='custom' match='exact'>
<model fallback='allow'>Penryn</model>
- <vendor>Intel</vendor>
<feature policy='require' name='dca'/>
<feature policy='require' name='xtpr'/>
<feature policy='require' name='tm2'/>
<cpu mode='custom' match='exact'>
<model fallback='allow'>Haswell</model>
- <vendor>Intel</vendor>
<topology sockets='1' cores='2' threads='2'/>
<feature policy='disable' name='hle'/>
<feature policy='disable' name='rtm'/>
<cpu mode='custom' match='exact'>
<model fallback='allow'>Nehalem</model>
- <vendor>Intel</vendor>
<feature policy='require' name='dca'/>
<feature policy='require' name='xtpr'/>
<feature policy='require' name='tm2'/>