virDomainCPUFind - to find a cpu within VM def
virDomainCPUInsert - wrapper for inserting a new cpu device into VM def
virDomainCPURemove - wrapper for removing cpu from VM def
Signed-off-by: Zhu Guihua <zhugh.fnst(a)cn.fujitsu.com>
---
src/conf/domain_conf.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++
src/conf/domain_conf.h | 13 +++++++++++
src/libvirt_private.syms | 3 +++
3 files changed, 74 insertions(+)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index dfe0d65..f83eada 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -12128,6 +12128,64 @@ virDomainChrRemove(virDomainDefPtr vmdef,
return ret;
}
+int
+virDomainCPUInsert(virDomainDefPtr vmdef,
+ virDomainCPUDefPtr cpu)
+{
+ return VIR_APPEND_ELEMENT(vmdef->cpus, vmdef->ncpus, cpu);
+}
+
+bool
+virDomainCPUEquals(virDomainCPUDefPtr src,
+ virDomainCPUDefPtr tgt)
+{
+ bool ret = false;
+
+ if (!src || !tgt)
+ return src == tgt;
+
+ ret = virCPUDefIsEqual(src->virCPU, tgt->virCPU);
+
+ return ret;
+}
+
+virDomainCPUDefPtr
+virDomainCPUFind(virDomainDefPtr def,
+ virDomainCPUDefPtr target)
+{
+ virDomainCPUDefPtr cpu;
+ size_t i;
+
+ for (i = 0; i < def->ncpus; i++) {
+ cpu = def->cpus[i];
+ if (virDomainCPUEquals(cpu, target))
+ return cpu;
+ }
+
+ return NULL;
+}
+
+virDomainCPUDefPtr
+virDomainCPURemove(virDomainDefPtr vmdef,
+ virDomainCPUDefPtr cpu)
+{
+ virDomainCPUDefPtr ret;
+ size_t i;
+
+ for (i = 0; i < vmdef->ncpus; i++) {
+ ret = vmdef->cpus[i];
+
+ if (virDomainCPUEquals(ret, cpu))
+ break;
+ }
+
+ if (i == vmdef->ncpus)
+ return NULL;
+
+ VIR_DELETE_ELEMENT(vmdef->cpus, i, vmdef->ncpus);
+ return ret;
+}
+
char *
virDomainDefGetDefaultEmulator(virDomainDefPtr def,
virCapsPtr caps)
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 4096ecc..144f79a 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2674,6 +2674,19 @@ virDomainChrDefPtr
virDomainChrRemove(virDomainDefPtr vmdef,
virDomainChrDefPtr chr);
+int
+virDomainCPUInsert(virDomainDefPtr vmdef,
+ virDomainCPUDefPtr cpu);
+bool
+virDomainCPUEquals(virDomainCPUDefPtr src,
+ virDomainCPUDefPtr tgt);
+virDomainCPUDefPtr
+virDomainCPUFind(virDomainDefPtr def,
+ virDomainCPUDefPtr cpu);
+virDomainCPUDefPtr
+virDomainCPURemove(virDomainDefPtr vmdef,
+ virDomainCPUDefPtr cpu);
+
int virDomainSaveXML(const char *configDir,
virDomainDefPtr def,
const char *xml);
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 897a598..df4f508 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -182,8 +182,11 @@ virDomainControllerModelUSBTypeToString;
virDomainControllerRemove;
virDomainControllerTypeToString;
virDomainCPUDefFree;
+virDomainCPUFind;
+virDomainCPUInsert;
virDomainCpuPlacementModeTypeFromString;
virDomainCpuPlacementModeTypeToString;
+virDomainCPURemove;
virDomainDefAddImplicitControllers;
virDomainDefCheckABIStability;
virDomainDefClearCCWAddresses;
--
1.9.3