* [Qemu-devel] [PATCH] pc: Fix max_cpus
@ 2012-07-23 10:47 riegamaths
2012-07-23 10:52 ` Andreas Färber
0 siblings, 1 reply; 3+ messages in thread
From: riegamaths @ 2012-07-23 10:47 UTC (permalink / raw)
To: qemu-devel; +Cc: Anthony Liguori, Stefan Hajnoczi, Dunrong Huang
From: Dunrong Huang <riegamaths@gmail.com>
The VCPU count limit in kernel now is 254, defined by KVM_MAX_VCPUS
in kernel's header files. But the count limit in QEMU is 255,
so QEMU will failed to start if user passes "-enable-kvm" and "-smp 255"
to it.
This patch intruduces a Macro MAX_VCPUS whose value is KVM_MAX_VCPUS
if CONFIG_KVM is defined. If user do not use kvm, set it's value to 255.
Signed-off-by: Dunrong Huang <riegamaths@gmail.com>
---
hw/pc_piix.c | 28 +++++++++++++++++++---------
1 files changed, 19 insertions(+), 9 deletions(-)
diff --git a/hw/pc_piix.c b/hw/pc_piix.c
index 0c0096f..49cda51 100644
--- a/hw/pc_piix.c
+++ b/hw/pc_piix.c
@@ -49,6 +49,16 @@
#define MAX_IDE_BUS 2
+#ifndef KVM_MAX_VCPUS
+#define KVM_MAX_VCPUS 254
+#endif
+
+#ifdef CONFIG_KVM
+#define MAX_VCPUS KVM_MAX_VCPUS
+#else
+#define MAX_VCPUS 255
+#endif
+
static const int ide_iobase[MAX_IDE_BUS] = { 0x1f0, 0x170 };
static const int ide_iobase2[MAX_IDE_BUS] = { 0x3f6, 0x376 };
static const int ide_irq[MAX_IDE_BUS] = { 14, 15 };
@@ -354,7 +364,7 @@ static QEMUMachine pc_machine_v1_2 = {
.alias = "pc",
.desc = "Standard PC",
.init = pc_init_pci,
- .max_cpus = 255,
+ .max_cpus = MAX_VCPUS,
.is_default = 1,
};
@@ -381,7 +391,7 @@ static QEMUMachine pc_machine_v1_1 = {
.name = "pc-1.1",
.desc = "Standard PC",
.init = pc_init_pci,
- .max_cpus = 255,
+ .max_cpus = MAX_VCPUS,
.compat_props = (GlobalProperty[]) {
PC_COMPAT_1_1,
{ /* end of list */ }
@@ -416,7 +426,7 @@ static QEMUMachine pc_machine_v1_0 = {
.name = "pc-1.0",
.desc = "Standard PC",
.init = pc_init_pci,
- .max_cpus = 255,
+ .max_cpus = MAX_VCPUS,
.compat_props = (GlobalProperty[]) {
PC_COMPAT_1_0,
{ /* end of list */ }
@@ -431,7 +441,7 @@ static QEMUMachine pc_machine_v0_15 = {
.name = "pc-0.15",
.desc = "Standard PC",
.init = pc_init_pci,
- .max_cpus = 255,
+ .max_cpus = MAX_VCPUS,
.compat_props = (GlobalProperty[]) {
PC_COMPAT_0_15,
{ /* end of list */ }
@@ -463,7 +473,7 @@ static QEMUMachine pc_machine_v0_14 = {
.name = "pc-0.14",
.desc = "Standard PC",
.init = pc_init_pci,
- .max_cpus = 255,
+ .max_cpus = MAX_VCPUS,
.compat_props = (GlobalProperty[]) {
PC_COMPAT_0_14,
{
@@ -496,7 +506,7 @@ static QEMUMachine pc_machine_v0_13 = {
.name = "pc-0.13",
.desc = "Standard PC",
.init = pc_init_pci_no_kvmclock,
- .max_cpus = 255,
+ .max_cpus = MAX_VCPUS,
.compat_props = (GlobalProperty[]) {
PC_COMPAT_0_13,
{
@@ -533,7 +543,7 @@ static QEMUMachine pc_machine_v0_12 = {
.name = "pc-0.12",
.desc = "Standard PC",
.init = pc_init_pci_no_kvmclock,
- .max_cpus = 255,
+ .max_cpus = MAX_VCPUS,
.compat_props = (GlobalProperty[]) {
PC_COMPAT_0_12,
{
@@ -566,7 +576,7 @@ static QEMUMachine pc_machine_v0_11 = {
.name = "pc-0.11",
.desc = "Standard PC, qemu 0.11",
.init = pc_init_pci_no_kvmclock,
- .max_cpus = 255,
+ .max_cpus = MAX_VCPUS,
.compat_props = (GlobalProperty[]) {
PC_COMPAT_0_11,
{
@@ -587,7 +597,7 @@ static QEMUMachine pc_machine_v0_10 = {
.name = "pc-0.10",
.desc = "Standard PC, qemu 0.10",
.init = pc_init_pci_no_kvmclock,
- .max_cpus = 255,
+ .max_cpus = MAX_VCPUS,
.compat_props = (GlobalProperty[]) {
PC_COMPAT_0_11,
{
--
1.7.8.6
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] pc: Fix max_cpus
2012-07-23 10:47 [Qemu-devel] [PATCH] pc: Fix max_cpus riegamaths
@ 2012-07-23 10:52 ` Andreas Färber
2012-07-23 12:33 ` Dunrong Huang
0 siblings, 1 reply; 3+ messages in thread
From: Andreas Färber @ 2012-07-23 10:52 UTC (permalink / raw)
To: riegamaths; +Cc: Anthony Liguori, qemu-devel, Stefan Hajnoczi
Am 23.07.2012 12:47, schrieb riegamaths@gmail.com:
> From: Dunrong Huang <riegamaths@gmail.com>
>
> The VCPU count limit in kernel now is 254, defined by KVM_MAX_VCPUS
> in kernel's header files. But the count limit in QEMU is 255,
> so QEMU will failed to start if user passes "-enable-kvm" and "-smp 255"
> to it.
>
> This patch intruduces a Macro MAX_VCPUS whose value is KVM_MAX_VCPUS
> if CONFIG_KVM is defined. If user do not use kvm, set it's value to 255.
>
> Signed-off-by: Dunrong Huang <riegamaths@gmail.com>
> ---
> hw/pc_piix.c | 28 +++++++++++++++++++---------
> 1 files changed, 19 insertions(+), 9 deletions(-)
>
> diff --git a/hw/pc_piix.c b/hw/pc_piix.c
> index 0c0096f..49cda51 100644
> --- a/hw/pc_piix.c
> +++ b/hw/pc_piix.c
> @@ -49,6 +49,16 @@
>
> #define MAX_IDE_BUS 2
>
> +#ifndef KVM_MAX_VCPUS
> +#define KVM_MAX_VCPUS 254
> +#endif
> +
> +#ifdef CONFIG_KVM
> +#define MAX_VCPUS KVM_MAX_VCPUS
> +#else
> +#define MAX_VCPUS 255
> +#endif
> +
> static const int ide_iobase[MAX_IDE_BUS] = { 0x1f0, 0x170 };
> static const int ide_iobase2[MAX_IDE_BUS] = { 0x3f6, 0x376 };
> static const int ide_irq[MAX_IDE_BUS] = { 14, 15 };
> @@ -354,7 +364,7 @@ static QEMUMachine pc_machine_v1_2 = {
> .alias = "pc",
> .desc = "Standard PC",
> .init = pc_init_pci,
> - .max_cpus = 255,
> + .max_cpus = MAX_VCPUS,
> .is_default = 1,
> };
>
[snip]
This is not so ideal: -enable-kvm is a runtime switch whereas you are
changing a compile-time limit here. Any chance to change the runtime
usage of .max_cpus instead? Possibly introducing a helper function?
Andreas
--
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] pc: Fix max_cpus
2012-07-23 10:52 ` Andreas Färber
@ 2012-07-23 12:33 ` Dunrong Huang
0 siblings, 0 replies; 3+ messages in thread
From: Dunrong Huang @ 2012-07-23 12:33 UTC (permalink / raw)
To: Andreas Färber; +Cc: Anthony Liguori, qemu-devel, Stefan Hajnoczi
2012/7/23 Andreas Färber <afaerber@suse.de>:
> Am 23.07.2012 12:47, schrieb riegamaths@gmail.com:
>> From: Dunrong Huang <riegamaths@gmail.com>
>>
>> The VCPU count limit in kernel now is 254, defined by KVM_MAX_VCPUS
>> in kernel's header files. But the count limit in QEMU is 255,
>> so QEMU will failed to start if user passes "-enable-kvm" and "-smp 255"
>> to it.
>>
>> This patch intruduces a Macro MAX_VCPUS whose value is KVM_MAX_VCPUS
>> if CONFIG_KVM is defined. If user do not use kvm, set it's value to 255.
>>
>> Signed-off-by: Dunrong Huang <riegamaths@gmail.com>
>> ---
>> hw/pc_piix.c | 28 +++++++++++++++++++---------
>> 1 files changed, 19 insertions(+), 9 deletions(-)
>>
>> diff --git a/hw/pc_piix.c b/hw/pc_piix.c
>> index 0c0096f..49cda51 100644
>> --- a/hw/pc_piix.c
>> +++ b/hw/pc_piix.c
>> @@ -49,6 +49,16 @@
>>
>> #define MAX_IDE_BUS 2
>>
>> +#ifndef KVM_MAX_VCPUS
>> +#define KVM_MAX_VCPUS 254
>> +#endif
>> +
>> +#ifdef CONFIG_KVM
>> +#define MAX_VCPUS KVM_MAX_VCPUS
>> +#else
>> +#define MAX_VCPUS 255
>> +#endif
>> +
>> static const int ide_iobase[MAX_IDE_BUS] = { 0x1f0, 0x170 };
>> static const int ide_iobase2[MAX_IDE_BUS] = { 0x3f6, 0x376 };
>> static const int ide_irq[MAX_IDE_BUS] = { 14, 15 };
>> @@ -354,7 +364,7 @@ static QEMUMachine pc_machine_v1_2 = {
>> .alias = "pc",
>> .desc = "Standard PC",
>> .init = pc_init_pci,
>> - .max_cpus = 255,
>> + .max_cpus = MAX_VCPUS,
>> .is_default = 1,
>> };
>>
> [snip]
>
> This is not so ideal: -enable-kvm is a runtime switch whereas you are
> changing a compile-time limit here. Any chance to change the runtime
> usage of .max_cpus instead? Possibly introducing a helper function?
>
Do you mean do some hacks in smp_parse?
I agree with you, there has codes for checking max_cpus in runtime:
if (max_cpus > 255) { // Should be changed to 254 if enable kvm.
fprintf(stderr, "Unsupported number of maxcpus\n");
exit(1);
}
I think we also need to change the hard coded value of .max_cpus from 255
to macro which should be synchronized with KVM_MAX_VCPUS or something else.
> Andreas
>
> --
> SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
> GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
>
>
--
Best Regards,
Dunrong Huang
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-07-23 12:33 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-07-23 10:47 [Qemu-devel] [PATCH] pc: Fix max_cpus riegamaths
2012-07-23 10:52 ` Andreas Färber
2012-07-23 12:33 ` Dunrong Huang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).