[PATCH 8/8] provide -cpu-map option

Glauber Costa
2008-03-04T16:22:01Z

this patch introduces a -cpu-map option.
It has the form C:x,y,z..., and have the effect
of setting the affinity mask of vcpu C to processors
x,y,z...

Signed-off-by: Glauber Costa <gcosta@redhat.com>
---
qemu/vl.c | 13 +++++++++++++
1 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/qemu/vl.c b/qemu/vl.c
index 4715594..fa830dd 100644
--- a/qemu/vl.c
+++ b/qemu/vl.c
@@ -8059,6 +8059,7 @@ static void help(int exitcode)
"-no-kvm disable KVM hardware virtualization\n"
#endif
"-no-kvm-irqchip disable KVM kernel mode PIC/IOAPIC/LAPIC\n"
+ "-cpu-map C:x,y,z... set cpu 'C' affinity to processors x,y,z...\n"
#endif
#ifdef TARGET_I386
"-std-vga simulate a standard VGA card with VESA Bochs Extensions\n"
@@ -8177,6 +8178,7 @@ enum {
QEMU_OPTION_no_acpi,
QEMU_OPTION_no_kvm,
QEMU_OPTION_no_kvm_irqchip,
+ QEMU_OPTION_cpu_map,
QEMU_OPTION_no_reboot,
QEMU_OPTION_show_cursor,
QEMU_OPTION_daemonize,
@@ -8263,6 +8265,7 @@ const QEMUOption qemu_options[] = {
{ "no-kvm", 0, QEMU_OPTION_no_kvm },
#endif
{ "no-kvm-irqchip", 0, QEMU_OPTION_no_kvm_irqchip },
+ { "cpu-map", HAS_ARG, QEMU_OPTION_cpu_map },
#endif
#if defined(TARGET_PPC) || defined(TARGET_SPARC)
{ "g", 1, QEMU_OPTION_g },
@@ -9211,6 +9214,16 @@ int main(int argc, char **argv)
kvm_irqchip = 0;
break;
}
+ case QEMU_OPTION_cpu_map: {
+ int c = atoi(optarg);
+ char *ptr = strchr(optarg, ':');
+ cpu_set_t set;
+ if (!ptr)
+ fprintf(stderr, "invalid cpu mapping %s\n", ptr);
+ process_cpu_set(++ptr, &set);
+ kvm_store_cpu_affinity(c, &set);
+ break;
+ }
#endif
case QEMU_OPTION_usb:
usb_enabled = 1;
--
1.5.0.6