On Sun, Apr 03, 2011 at 02:43:55PM +0200, Matthias Bolte wrote:
> ---
>  src/vmx/vmx.c                                    |   43 
> ++++++++++++++++++++++
>  tests/vmx2xmldata/vmx2xml-case-insensitive-1.vmx |    2 +-
>  tests/vmx2xmldata/vmx2xml-case-insensitive-1.xml |    3 ++
>  tests/vmx2xmldata/vmx2xml-case-insensitive-2.xml |    3 ++
>  tests/vmx2xmldata/vmx2xml-esx-in-the-wild-1.vmx  |    2 +-
>  tests/vmx2xmldata/vmx2xml-esx-in-the-wild-1.xml  |    3 ++
>  tests/vmx2xmldata/vmx2xml-esx-in-the-wild-4.xml  |    3 ++
>  tests/vmx2xmldata/vmx2xml-esx-in-the-wild-5.xml  |    3 ++
>  tests/xml2vmxdata/xml2vmx-esx-in-the-wild-1.vmx  |    1 +
>  tests/xml2vmxdata/xml2vmx-esx-in-the-wild-1.xml  |    3 ++
>  tests/xml2vmxdata/xml2vmx-esx-in-the-wild-4.vmx  |    1 +
>  tests/xml2vmxdata/xml2vmx-esx-in-the-wild-4.xml  |    3 ++
>  tests/xml2vmxdata/xml2vmx-esx-in-the-wild-5.vmx  |    1 +
>  tests/xml2vmxdata/xml2vmx-esx-in-the-wild-5.xml  |    3 ++
>  14 files changed, 72 insertions(+), 2 deletions(-)
> 
> diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c
> index 9a482ef..b0d3218 100644
> --- a/src/vmx/vmx.c
> +++ b/src/vmx/vmx.c
> @@ -55,6 +55,8 @@ def->mem.cur_balloon = <value kilobyte>    <=>   
> sched.mem.max = "<value megabyt
>  def->mem.min_guarantee = <value kilobyte>  <=>   sched.mem.minsize = "<value 
> megabyte>"  # defaults to 0
>  def->maxvcpus = <value>           <=>   numvcpus = "<value>"                 
>    # must be 1 or a multiple of 2, defaults to 1
>  def->cpumask = <uint list>        <=>   sched.cpu.affinity = "<uint list>"
> +def->cputune.shares = <value>     <=>   sched.cpu.shares = "<value>"         
>    # with handling for special values
> +                                                                             
>    # "high", "normal", "low"
>  
>  
>  
> @@ -1200,6 +1202,7 @@ virVMXParseConfig(virVMXContext *ctx, virCapsPtr caps, 
> const char *vmx)
>      long long sched_mem_minsize = 0;
>      long long numvcpus = 0;
>      char *sched_cpu_affinity = NULL;
> +    char *sched_cpu_shares = NULL;
>      char *guestOS = NULL;
>      bool smbios_reflecthost = false;
>      int controller;
> @@ -1449,6 +1452,30 @@ virVMXParseConfig(virVMXContext *ctx, virCapsPtr caps, 
> const char *vmx)
>          }
>      }
>  
> +    /* vmx:sched.cpu.shares -> def:cputune.shares */
> +    if (virVMXGetConfigString(conf, "sched.cpu.shares", &sched_cpu_shares,
> +                              true) < 0) {
> +        goto cleanup;
> +    }
> +
> +    if (sched_cpu_shares != NULL) {
> +        /* See 
> http://www.vmware.com/support/developer/vc-sdk/visdk41pubs/ApiReference/vim.SharesInfo.Level.html
>  */
> +        if (STRCASEEQ(sched_cpu_shares, "low")) {
> +            def->cputune.shares = def->vcpus * 500;
> +        } else if (STRCASEEQ(sched_cpu_shares, "normal")) {
> +            def->cputune.shares = def->vcpus * 1000;
> +        } else if (STRCASEEQ(sched_cpu_shares, "high")) {
> +            def->cputune.shares = def->vcpus * 2000;
> +        } else if (virStrToLong_ul(sched_cpu_shares, NULL, 10,
> +                                   &def->cputune.shares) < 0) {
> +            VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
> +                      _("Expecting VMX entry 'sched.cpu.shares' to be an "
> +                        "unsigned integer or 'low', 'normal' or 'high' but "
> +                        "found '%s'"), sched_cpu_shares);
> +            goto cleanup;
> +        }
> +    }
> +
>      /* def:lifecycle */
>      def->onReboot = VIR_DOMAIN_LIFECYCLE_RESTART;
>      def->onPoweroff = VIR_DOMAIN_LIFECYCLE_DESTROY;
> @@ -1715,6 +1742,7 @@ virVMXParseConfig(virVMXContext *ctx, virCapsPtr caps, 
> const char *vmx)
>      virConfFree(conf);
>      VIR_FREE(encoding);
>      VIR_FREE(sched_cpu_affinity);
> +    VIR_FREE(sched_cpu_shares);
>      VIR_FREE(guestOS);
>  
>      return def;
> @@ -2998,6 +3026,21 @@ virVMXFormatConfig(virVMXContext *ctx, virCapsPtr 
> caps, virDomainDefPtr def,
>          virBufferAddLit(&buffer, "\"\n");
>      }
>  
> +    /* def:cputune.shares -> vmx:sched.cpu.shares */
> +    if (def->cputune.shares > 0) {
> +        /* See 
> http://www.vmware.com/support/developer/vc-sdk/visdk41pubs/ApiReference/vim.SharesInfo.Level.html
>  */
> +        if (def->cputune.shares == def->vcpus * 500) {
> +            virBufferAddLit(&buffer, "sched.cpu.shares = \"low\"\n");
> +        } else if (def->cputune.shares == def->vcpus * 1000) {
> +            virBufferAddLit(&buffer, "sched.cpu.shares = \"normal\"\n");
> +        } else if (def->cputune.shares == def->vcpus * 2000) {
> +            virBufferAddLit(&buffer, "sched.cpu.shares = \"high\"\n");
> +        } else {
> +            virBufferVSprintf(&buffer, "sched.cpu.shares = \"%lu\"\n",
> +                              def->cputune.shares);
> +        }
> +    }
> +
>      /* def:graphics */
>      for (i = 0; i < def->ngraphics; ++i) {
>          switch (def->graphics[i]->type) {
> diff --git a/tests/vmx2xmldata/vmx2xml-case-insensitive-1.vmx 
> b/tests/vmx2xmldata/vmx2xml-case-insensitive-1.vmx
> index bd36cf8..8641c5c 100644
> --- a/tests/vmx2xmldata/vmx2xml-case-insensitive-1.vmx
> +++ b/tests/vmx2xmldata/vmx2xml-case-insensitive-1.vmx
> @@ -35,7 +35,7 @@ UUID.BIOS = "50 11 5E 16 9B DC 49 D7-F1 71 53 C4 D7 F9 17 
> 10"
>  SNAPSHOT.ACTION = "KEEP"
>  SCHED.CPU.MIN = "0"
>  SCHED.CPU.UNITS = "MHZ"
> -SCHED.CPU.SHARES = "NORMAL"
> +SCHED.CPU.SHARES = "4223"
>  SCHED.MEM.MINSIZE = "0"
>  SCHED.MEM.SHARES = "NORMAL"
>  TOOLSCRIPTS.AFTERPOWERON = "TRUE"
> diff --git a/tests/vmx2xmldata/vmx2xml-case-insensitive-1.xml 
> b/tests/vmx2xmldata/vmx2xml-case-insensitive-1.xml
> index 7a5ff5b..ef6edd8 100644
> --- a/tests/vmx2xmldata/vmx2xml-case-insensitive-1.xml
> +++ b/tests/vmx2xmldata/vmx2xml-case-insensitive-1.xml
> @@ -4,6 +4,9 @@
>    <memory>1048576</memory>
>    <currentMemory>1048576</currentMemory>
>    <vcpu>1</vcpu>
> +  <cputune>
> +    <shares>4223</shares>
> +  </cputune>
>    <os>
>      <type arch='i686'>hvm</type>
>    </os>
> diff --git a/tests/vmx2xmldata/vmx2xml-case-insensitive-2.xml 
> b/tests/vmx2xmldata/vmx2xml-case-insensitive-2.xml
> index 18d6461..02771b9 100644
> --- a/tests/vmx2xmldata/vmx2xml-case-insensitive-2.xml
> +++ b/tests/vmx2xmldata/vmx2xml-case-insensitive-2.xml
> @@ -4,6 +4,9 @@
>    <memory>1048576</memory>
>    <currentMemory>1048576</currentMemory>
>    <vcpu>1</vcpu>
> +  <cputune>
> +    <shares>1000</shares>
> +  </cputune>
>    <os>
>      <type arch='i686'>hvm</type>
>    </os>
> diff --git a/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-1.vmx 
> b/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-1.vmx
> index 4392062..78741ae 100644
> --- a/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-1.vmx
> +++ b/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-1.vmx
> @@ -36,7 +36,7 @@ uuid.bios = "50 11 5e 16 9b dc 49 d7-f1 71 53 c4 d7 f9 17 
> 10"
>  snapshot.action = "keep"
>  sched.cpu.min = "0"
>  sched.cpu.units = "mhz"
> -sched.cpu.shares = "normal"
> +sched.cpu.shares = "low"
>  sched.mem.minsize = "0"
>  sched.mem.shares = "normal"
>  toolScripts.afterPowerOn = "true"
> diff --git a/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-1.xml 
> b/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-1.xml
> index 5e67e74..e8f9307 100644
> --- a/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-1.xml
> +++ b/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-1.xml
> @@ -4,6 +4,9 @@
>    <memory>1048576</memory>
>    <currentMemory>1048576</currentMemory>
>    <vcpu>1</vcpu>
> +  <cputune>
> +    <shares>500</shares>
> +  </cputune>
>    <os>
>      <type arch='i686'>hvm</type>
>    </os>
> diff --git a/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-4.xml 
> b/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-4.xml
> index 419df51..2824d66 100644
> --- a/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-4.xml
> +++ b/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-4.xml
> @@ -4,6 +4,9 @@
>    <memory>524288</memory>
>    <currentMemory>524288</currentMemory>
>    <vcpu>1</vcpu>
> +  <cputune>
> +    <shares>1000</shares>
> +  </cputune>
>    <os>
>      <type arch='i686'>hvm</type>
>    </os>
> diff --git a/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-5.xml 
> b/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-5.xml
> index 0040163..6f0a9d1 100644
> --- a/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-5.xml
> +++ b/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-5.xml
> @@ -8,6 +8,9 @@
>      <min_guarantee>262144</min_guarantee>
>    </memtune>
>    <vcpu>2</vcpu>
> +  <cputune>
> +    <shares>2000</shares>
> +  </cputune>
>    <os>
>      <type arch='x86_64'>hvm</type>
>    </os>
> diff --git a/tests/xml2vmxdata/xml2vmx-esx-in-the-wild-1.vmx 
> b/tests/xml2vmxdata/xml2vmx-esx-in-the-wild-1.vmx
> index e72ca80..9059197 100644
> --- a/tests/xml2vmxdata/xml2vmx-esx-in-the-wild-1.vmx
> +++ b/tests/xml2vmxdata/xml2vmx-esx-in-the-wild-1.vmx
> @@ -6,6 +6,7 @@ uuid.bios = "50 11 5e 16 9b dc 49 d7-f1 71 53 c4 d7 f9 17 10"
>  displayName = "Fedora11"
>  memsize = "1024"
>  numvcpus = "1"
> +sched.cpu.shares = "low"
>  scsi0.present = "true"
>  scsi0.virtualDev = "lsilogic"
>  scsi0:0.present = "true"
> diff --git a/tests/xml2vmxdata/xml2vmx-esx-in-the-wild-1.xml 
> b/tests/xml2vmxdata/xml2vmx-esx-in-the-wild-1.xml
> index 3f4ff88..ea59778 100644
> --- a/tests/xml2vmxdata/xml2vmx-esx-in-the-wild-1.xml
> +++ b/tests/xml2vmxdata/xml2vmx-esx-in-the-wild-1.xml
> @@ -4,6 +4,9 @@
>    <memory>1048576</memory>
>    <currentMemory>1048576</currentMemory>
>    <vcpu>1</vcpu>
> +  <cputune>
> +    <shares>500</shares>
> +  </cputune>
>    <os>
>      <type>hvm</type>
>    </os>
> diff --git a/tests/xml2vmxdata/xml2vmx-esx-in-the-wild-4.vmx 
> b/tests/xml2vmxdata/xml2vmx-esx-in-the-wild-4.vmx
> index 627fcfb..504997f 100644
> --- a/tests/xml2vmxdata/xml2vmx-esx-in-the-wild-4.vmx
> +++ b/tests/xml2vmxdata/xml2vmx-esx-in-the-wild-4.vmx
> @@ -6,6 +6,7 @@ uuid.bios = "56 4d 9b ef ac d9 b4 e0-c8 f0 ae a8 b9 10 35 15"
>  displayName = "virtMonServ1"
>  memsize = "512"
>  numvcpus = "1"
> +sched.cpu.shares = "normal"
>  scsi0.present = "true"
>  scsi0.virtualDev = "lsilogic"
>  scsi0:0.present = "true"
> diff --git a/tests/xml2vmxdata/xml2vmx-esx-in-the-wild-4.xml 
> b/tests/xml2vmxdata/xml2vmx-esx-in-the-wild-4.xml
> index 078753a..443aacd 100644
> --- a/tests/xml2vmxdata/xml2vmx-esx-in-the-wild-4.xml
> +++ b/tests/xml2vmxdata/xml2vmx-esx-in-the-wild-4.xml
> @@ -4,6 +4,9 @@
>    <memory>524288</memory>
>    <currentMemory>524288</currentMemory>
>    <vcpu>1</vcpu>
> +  <cputune>
> +    <shares>1000</shares>
> +  </cputune>
>    <os>
>      <type>hvm</type>
>    </os>
> diff --git a/tests/xml2vmxdata/xml2vmx-esx-in-the-wild-5.vmx 
> b/tests/xml2vmxdata/xml2vmx-esx-in-the-wild-5.vmx
> index cc2485f..2e3b856 100644
> --- a/tests/xml2vmxdata/xml2vmx-esx-in-the-wild-5.vmx
> +++ b/tests/xml2vmxdata/xml2vmx-esx-in-the-wild-5.vmx
> @@ -8,6 +8,7 @@ annotation = "Centos 5.5 64bit Server"
>  memsize = "2048"
>  sched.mem.minsize = "256"
>  numvcpus = "2"
> +sched.cpu.shares = "normal"
>  scsi0.present = "true"
>  scsi0.virtualDev = "lsilogic"
>  scsi0:0.present = "true"
> diff --git a/tests/xml2vmxdata/xml2vmx-esx-in-the-wild-5.xml 
> b/tests/xml2vmxdata/xml2vmx-esx-in-the-wild-5.xml
> index d55bf6b..f28c15e 100644
> --- a/tests/xml2vmxdata/xml2vmx-esx-in-the-wild-5.xml
> +++ b/tests/xml2vmxdata/xml2vmx-esx-in-the-wild-5.xml
> @@ -8,6 +8,9 @@
>      <min_guarantee>262144</min_guarantee>
>    </memtune>
>    <vcpu>2</vcpu>
> +  <cputune>
> +    <shares>2000</shares>
> +  </cputune>
>    <os>
>      <type arch='x86_64'>hvm</type>
>    </os>

  ACK, while nice, it may be a bit late for 0.9.0, okay to wait for the
next cycle ? We already have this for xen and qemu, seeing it for ESX
confirms the design is fine, which is the most important from my point
of vue :-)

Daniel

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

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Reply via email to