]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
conf: Add helper to get pointer to a certain vCPU definition
authorPeter Krempa <pkrempa@redhat.com>
Tue, 3 Nov 2015 07:47:23 +0000 (08:47 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 9 Dec 2015 13:57:12 +0000 (14:57 +0100)
Once more stuff will be moved into the vCPU data structure it will be
necessary to get a specific one in some ocasions. Add a helper that will
simplify this task.

src/conf/domain_conf.c
src/conf/domain_conf.h
src/libvirt_private.syms

index 19525b309ae5e2164f1c3f5184b7f1a07d464890..5200c278914e140876387203bc976724a6bf0550 100644 (file)
@@ -1374,6 +1374,21 @@ virDomainDefGetVcpus(const virDomainDef *def)
 }
 
 
+virDomainVcpuInfoPtr
+virDomainDefGetVcpu(virDomainDefPtr def,
+                    unsigned int vcpu)
+{
+    if (vcpu > def->maxvcpus) {
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                       _("vCPU '%u' is not present in domain definition"),
+                       vcpu);
+        return NULL;
+    }
+
+    return &def->vcpus[vcpu];
+}
+
+
 virDomainDiskDefPtr
 virDomainDiskDefNew(virDomainXMLOptionPtr xmlopt)
 {
index 6b9fa864463d309980c9eaa63800c334cdd2b2f8..cec681a788be6d85d74dfa7a7054b96e6026de1e 100644 (file)
@@ -2356,6 +2356,8 @@ bool virDomainDefHasVcpusOffline(const virDomainDef *def);
 unsigned int virDomainDefGetVcpusMax(const virDomainDef *def);
 int virDomainDefSetVcpus(virDomainDefPtr def, unsigned int vcpus);
 unsigned int virDomainDefGetVcpus(const virDomainDef *def);
+virDomainVcpuInfoPtr virDomainDefGetVcpu(virDomainDefPtr def, unsigned int vcpu)
+    ATTRIBUTE_RETURN_CHECK;
 
 unsigned long long virDomainDefGetMemoryInitial(const virDomainDef *def);
 void virDomainDefSetMemoryTotal(virDomainDefPtr def, unsigned long long size);
index 402245896a43737d4d63dc9fd1156a1d39127d5f..63d8618fa10d0cbb5b3abd2b64ddc2b476e525c9 100644 (file)
@@ -217,6 +217,7 @@ virDomainDefGetDefaultEmulator;
 virDomainDefGetMemoryActual;
 virDomainDefGetMemoryInitial;
 virDomainDefGetSecurityLabelDef;
+virDomainDefGetVcpu;
 virDomainDefGetVcpus;
 virDomainDefGetVcpusMax;
 virDomainDefHasDeviceAddress;