[libvirt] [PATCH v2.1 13/21] Introduce virDomainEmulatorPinAdd and virDomainEmulatorPinDel functions

Daniel Veillard veillard at redhat.com
Wed Aug 22 08:30:04 UTC 2012


On Tue, Aug 21, 2012 at 05:18:36PM +0800, Hu Tao wrote:
> From: Tang Chen <tangchen at cn.fujitsu.com>
> 
> Introduce 2 APIs to support emulator threads pin.
>     1) virDomainEmulatorPinAdd: setup emulator threads pin with a given cpumap string.
>     2) virDomainEmulatorPinDel: remove all emulator threads pin.
> 
> Signed-off-by: Tang Chen <tangchen at cn.fujitsu.com>
> Signed-off-by: Hu Tao <hutao at cn.fujitsu.com>
> ---
>  src/conf/domain_conf.c   |   71 ++++++++++++++++++++++++++++++++++++++++++++++
>  src/conf/domain_conf.h   |    6 ++++
>  src/libvirt_private.syms |    2 ++
>  3 files changed, 79 insertions(+)
> 
> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
> index 94ec095..dab9c5d 100644
> --- a/src/conf/domain_conf.c
> +++ b/src/conf/domain_conf.c
> @@ -11076,6 +11076,77 @@ virDomainVcpuPinDel(virDomainDefPtr def, int vcpu)
>      return 0;
>  }
>  
> +int
> +virDomainEmulatorPinAdd(virDomainDefPtr def,
> +                        unsigned char *cpumap,
> +                        int maplen)
> +{
> +    virDomainVcpuPinDefPtr emulatorpin = NULL;
> +    char *cpumask = NULL;
> +    int i;
> +
> +    if (VIR_ALLOC_N(cpumask, VIR_DOMAIN_CPUMASK_LEN) < 0) {
> +        virReportOOMError();
> +        goto cleanup;
> +    }
> +
> +    /* Convert bitmap (cpumap) to cpumask, which is byte map. */
> +    for (i = 0; i < maplen; i++) {
> +        int cur;
> +
> +        for (cur = 0; cur < 8; cur++) {
> +            if (cpumap[i] & (1 << cur))
> +                cpumask[i * 8 + cur] = 1;
> +        }
> +    }
> +
> +    if (!def->cputune.emulatorpin) {
> +        /* No emulatorpin exists yet. */
> +        if (VIR_ALLOC(emulatorpin) < 0) {
> +            virReportOOMError();
> +            goto cleanup;
> +        }
> +
> +        emulatorpin->vcpuid = -1;
> +        emulatorpin->cpumask = cpumask;
> +        def->cputune.emulatorpin = emulatorpin;
> +    } else {
> +        /* Since there is only 1 emulatorpin for each vm,
> +         * juest replace the old one.
> +         */
> +        VIR_FREE(def->cputune.emulatorpin->cpumask);
> +        def->cputune.emulatorpin->cpumask = cpumask;
> +    }
> +
> +    return 0;
> +
> +cleanup:
> +    VIR_FREE(cpumask);
> +    return -1;
> +}
> +
> +int
> +virDomainEmulatorPinDel(virDomainDefPtr def)
> +{
> +    virDomainVcpuPinDefPtr emulatorpin = NULL;
> +
> +    /* No emulatorpin exists yet */
> +    if (!def->cputune.emulatorpin) {
> +        return 0;
> +    }
> +
> +    emulatorpin = def->cputune.emulatorpin;
> +
> +    VIR_FREE(emulatorpin->cpumask);
> +    VIR_FREE(emulatorpin);
> +    def->cputune.emulatorpin = NULL;
> +
> +    if (def->cputune.emulatorpin)
> +        return -1;
> +
> +    return 0;
> +}
> +
>  static int
>  virDomainLifecycleDefFormat(virBufferPtr buf,
>                              int type,
> diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
> index a7b2ff6..b6bf5a8 100644
> --- a/src/conf/domain_conf.h
> +++ b/src/conf/domain_conf.h
> @@ -1982,6 +1982,12 @@ int virDomainVcpuPinAdd(virDomainVcpuPinDefPtr *vcpupin_list,
>  
>  int virDomainVcpuPinDel(virDomainDefPtr def, int vcpu);
>  
> +int virDomainEmulatorPinAdd(virDomainDefPtr def,
> +                              unsigned char *cpumap,
> +                              int maplen);
> +
> +int virDomainEmulatorPinDel(virDomainDefPtr def);
> +
>  int virDomainDiskIndexByName(virDomainDefPtr def, const char *name,
>                               bool allow_ambiguous);
>  const char *virDomainDiskPathByName(virDomainDefPtr, const char *name);
> diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
> index 80ea39a..d51a387 100644
> --- a/src/libvirt_private.syms
> +++ b/src/libvirt_private.syms
> @@ -509,6 +509,8 @@ virDomainVcpuPinAdd;
>  virDomainVcpuPinDefCopy;
>  virDomainVcpuPinDefFree;
>  virDomainVcpuPinDel;
> +virDomainEmulatorPinAdd;
> +virDomainEmulatorPinDel;
>  virDomainVcpuPinFindByVcpu;
>  virDomainVcpuPinIsDuplicate;
>  virDomainVideoDefFree;

  Okay, very similar to the Vcpu counterparts.
However the symbols file should be kept sorted so added that fix

Daniel


diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 6af099b..8962de2 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -345,6 +345,8 @@ virDomainDiskSnapshotTypeFromString;
 virDomainDiskSnapshotTypeToString;
 virDomainDiskTypeFromString;
 virDomainDiskTypeToString;
+virDomainEmulatorPinAdd;
+virDomainEmulatorPinDel;
 virDomainFSDefFree;
 virDomainFSIndexByName;
 virDomainFSTypeFromString;
@@ -511,8 +513,6 @@ virDomainVcpuPinAdd;
 virDomainVcpuPinDefCopy;
 virDomainVcpuPinDefFree;
 virDomainVcpuPinDel;
-virDomainEmulatorPinAdd;
-virDomainEmulatorPinDel;
 virDomainVcpuPinFindByVcpu;
 virDomainVcpuPinIsDuplicate;
 virDomainVideoDefFree;

-- 
Daniel Veillard      | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
daniel at veillard.com  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/




More information about the libvir-list mailing list