mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 03:25:20 +00:00
vmx: Support persistent CPU shares
This commit is contained in:
parent
fb92307f0d
commit
81800ff647
@ -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) {
|
||||
|
@ -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"
|
||||
|
@ -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>
|
||||
|
@ -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>
|
||||
|
@ -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"
|
||||
|
@ -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>
|
||||
|
@ -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>
|
||||
|
@ -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>
|
||||
|
@ -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"
|
||||
|
@ -4,6 +4,9 @@
|
||||
<memory>1048576</memory>
|
||||
<currentMemory>1048576</currentMemory>
|
||||
<vcpu>1</vcpu>
|
||||
<cputune>
|
||||
<shares>500</shares>
|
||||
</cputune>
|
||||
<os>
|
||||
<type>hvm</type>
|
||||
</os>
|
||||
|
@ -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"
|
||||
|
@ -4,6 +4,9 @@
|
||||
<memory>524288</memory>
|
||||
<currentMemory>524288</currentMemory>
|
||||
<vcpu>1</vcpu>
|
||||
<cputune>
|
||||
<shares>1000</shares>
|
||||
</cputune>
|
||||
<os>
|
||||
<type>hvm</type>
|
||||
</os>
|
||||
|
@ -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"
|
||||
|
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user