You can subscribe to this list here.
2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(33) |
Nov
(325) |
Dec
(320) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2007 |
Jan
(484) |
Feb
(438) |
Mar
(407) |
Apr
(713) |
May
(831) |
Jun
(806) |
Jul
(1023) |
Aug
(1184) |
Sep
(1118) |
Oct
(1461) |
Nov
(1224) |
Dec
(1042) |
2008 |
Jan
(1449) |
Feb
(1110) |
Mar
(1428) |
Apr
(1643) |
May
(682) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: David A. <da...@bo...> - 2008-04-12 00:02:54
|
Avi Kivity wrote: > David Abrahams wrote: >> on Wed Apr 02 2008, Avi Kivity <avi-AT-qumranet.com> wrote: >> >> >>> David Abrahams wrote: >>> >>>> With the title combination, the guest takes nearly 100% of my real CPU >>>> time and still only sees one CPU. Is this a known problem, and does it >>>> have a known solution? >>>> >>>> >>> Can you send the output of 'kvm_stat -1'? >> >> $ ./kvm_stat -1 >> exits 5919444 74219 >> halt_exits 1746937 59420 >> invlpg 0 0 >> io_exits 2181506 6569 >> irq_exits 23055 335 >> irq_window 2839 77 >> mmio_exits 200851 0 >> pf_fixed 1160592 6251 >> pf_guest 43473 396 >> request_irq 0 0 >> signal_exits 24838 281 >> tlb_flush 37381 1132 >> >> > > Versions of kvm producing this sort of output are common in > archaeological digs. Please try a more recent release. Well, I'll try Hardy Heron soon enough, I suppose. It's due out in 2 weeks. I'm sure you understand that most people can't afford to rebuild all their important software so that it stays on the bleeding edge. Have you considered getting more recent versions of kvm into the updates or backports repositories of major distros? I'm not really sure how much influence you can have over such things; I'm just asking. >>> What HAL do you see in device manager? >>> >> "Standard PC" >> >> > > This HAL does not support SMP. You need the "ACPI Multiprocessor PC" > HAL or some such. And how would I get that HAL set up? > Unless you have a recent Intel processor, the combination of SMP and > Windows XP will give noticeably lower performance. I recommend sticking > with uniprocessor in such cases. I have a Core Duo; isn't that recent enough? -- Dave Abrahams Boost Consulting http://boost-consulting.com |
From: Carsten O. <co...@de...> - 2008-04-11 22:32:14
|
Avi Kivity wrote: >> @@ -765,6 +766,7 @@ void kvm_vcpu_block(struct kvm_vcpu *vcp >> > > > This breaks ia64 (and shouldn't s390 use this too?) >> * We will block until either an interrupt or a signal wakes us up >> */ >> while (!kvm_cpu_has_interrupt(vcpu) >> + && !kvm_cpu_has_pending_timer(vcpu) >> > > I guess the fix is to stub this out for the other archs. We don't use that, we have our own implementation of vcpu_block. |
From: Marcelo T. <mto...@re...> - 2008-04-11 19:48:38
|
On Fri, Apr 11, 2008 at 01:59:35PM -0500, Anthony Liguori wrote: > >-static void enable_sigio_timer(int fd) > >+static void enable_sigio(int fd) > >+{ > >+ struct sigaction act; > >+ > >+ sigfillset(&act.sa_mask); > >+ act.sa_flags = 0; > >+ act.sa_handler = host_io_handler; > >+ > >+ sigaction(SIGIO, &act, NULL); > >+ fcntl(fd, F_SETFL, O_ASYNC); This should be O_ASYNC|O_NONBLOCK, if there is interesting in taking the patch. |
From: Marcelo T. <mto...@re...> - 2008-04-11 19:41:41
|
On Fri, Apr 11, 2008 at 01:59:35PM -0500, Anthony Liguori wrote: > With the IO thread, shouldn't we be striving to perform the select()s > within the IO thread itself to completely avoid the need to use SIGIO at > all? Fully agree. Problem with it are the fundamental changes in qemu that are required (and the difficulty merging those in qemu). This is an immediate and easy fix to reduce CPU consumption of -nographic. |
From: Jeremy F. <je...@go...> - 2008-04-11 19:02:31
|
Gerd Hoffmann wrote: > Wall clock is off a few hours though. Oops. > > I think the way wall clock and system clock work together in xen (Jeremy > correct me if I'm wrong) is that the wall clock specifies the point in > time where the system clock started going. As kvm fills in host system > time into the guest system time fields the guest wall clock fields > should be filled with the host boot time timestamp I'd say. > Yes. The wallclock field in the shared info structure is the wallclock time at boot; you compute the current time by adding the system timestamp to it. System time changes are effected by retroactively changing the boot time of the machine, though that can also change because of suspend/resume/migrate. In general the kernel only reads the wallclock time at boot, and then maintains it for itself from then on. I think. J |
From: Anthony L. <ali...@us...> - 2008-04-11 19:00:38
|
With the IO thread, shouldn't we be striving to perform the select()s within the IO thread itself to completely avoid the need to use SIGIO at all? Regards, Anthony Liguori Marcelo Tosatti wrote: > From: Anders Melchiorsen <ma...@fl...> > > Without I/O signals, qemu is relying on periodic timer events to poll > the I/O. That seems wrong, even though it works reasonably well > because timers are so frequent. In KVM, timers are less frequent, and > it does not work quite as well. > > Here is a quick try at a more elaborate patch. > > It attaches a signal to all[1] file descriptors that will be used in > select(). Also, it uses a dedicated SIGIO handler rather than > piggybacking on the alarm handler, so alarm I/O is changed to use > SIGALRM. > > I copied the handler function from the alarm case, quite frankly I do > not quite understand what is going on. Also, I left _WIN32 out, since > I have no idea how signals work there. > > [1] The slirp file descriptors are not included yet. > > > Index: kvm-userspace.io/qemu/vl.c > =================================================================== > --- kvm-userspace.io.orig/qemu/vl.c > +++ kvm-userspace.io/qemu/vl.c > @@ -1177,6 +1177,25 @@ static int timer_load(QEMUFile *f, void > return 0; > } > > +#ifndef _WIN32 > +static void host_io_handler(int host_signum) > +{ > + CPUState *env = next_cpu; > + > + if (env) { > + /* stop the currently executing cpu because io occured */ > + cpu_interrupt(env, CPU_INTERRUPT_EXIT); > +#ifdef USE_KQEMU > + if (env->kqemu_enabled) { > + kqemu_cpu_interrupt(env); > + } > +#endif > + } > + > + event_pending = 1; > +} > +#endif > + > #ifdef _WIN32 > void CALLBACK host_alarm_handler(UINT uTimerID, UINT uMsg, > DWORD_PTR dwUser, DWORD_PTR dw1, DWORD_PTR dw2) > @@ -1270,7 +1289,20 @@ static uint64_t qemu_next_deadline(void) > > #define RTC_FREQ 1024 > > -static void enable_sigio_timer(int fd) > +static void enable_sigio(int fd) > +{ > + struct sigaction act; > + > + sigfillset(&act.sa_mask); > + act.sa_flags = 0; > + act.sa_handler = host_io_handler; > + > + sigaction(SIGIO, &act, NULL); > + fcntl(fd, F_SETFL, O_ASYNC); > + fcntl(fd, F_SETOWN, getpid()); > +} > + > +static void enable_sigalrm(int fd) > { > struct sigaction act; > > @@ -1279,8 +1311,9 @@ static void enable_sigio_timer(int fd) > act.sa_flags = 0; > act.sa_handler = host_alarm_handler; > > - sigaction(SIGIO, &act, NULL); > + sigaction(SIGALRM, &act, NULL); > fcntl(fd, F_SETFL, O_ASYNC); > + fcntl(fd, F_SETSIG, SIGALRM); > fcntl(fd, F_SETOWN, getpid()); > } > > @@ -1317,7 +1350,7 @@ static int hpet_start_timer(struct qemu_ > if (r < 0) > goto fail; > > - enable_sigio_timer(fd); > + enable_sigalrm(fd); > t->priv = (void *)(long)fd; > > return 0; > @@ -1355,7 +1388,7 @@ static int rtc_start_timer(struct qemu_a > return -1; > } > > - enable_sigio_timer(rtc_fd); > + enable_sigalrm(rtc_fd); > > t->priv = (void *)(long)rtc_fd; > > @@ -4029,7 +4062,6 @@ static TAPState *net_tap_fd_init(VLANSta > return NULL; > s->fd = fd; > s->no_poll = 0; > - enable_sigio_timer(fd); > s->vc = qemu_new_vlan_client(vlan, tap_receive, NULL, s); > qemu_set_fd_handler2(s->fd, tap_read_poll, tap_send, NULL, s); > snprintf(s->vc->info_str, sizeof(s->vc->info_str), "tap: fd=%d", fd); > @@ -5661,6 +5693,10 @@ int qemu_set_fd_handler2(int fd, > return -1; > ioh->next = first_io_handler; > first_io_handler = ioh; > +#ifndef _WIN32 > + enable_sigio(fd); > +#endif > + > found: > ioh->fd = fd; > ioh->fd_read_poll = fd_read_poll; > > |
From: Marcelo T. <mto...@re...> - 2008-04-11 18:50:53
|
With SIGIO enabled on stdio, there's no need to wakeup the thread performing IO every 30ms. Signed-off-by: Marcelo Tosatti <mto...@re...> Index: kvm-userspace.io/qemu/vl.c =================================================================== --- kvm-userspace.io.orig/qemu/vl.c +++ kvm-userspace.io/qemu/vl.c @@ -5640,6 +5640,7 @@ static void dumb_display_init(DisplaySta ds->dpy_update = dumb_update; ds->dpy_resize = dumb_resize; ds->dpy_refresh = dumb_refresh; + ds->gui_timer_interval = 1000; } /***********************************************************/ -- |
From: Marcelo T. <mto...@re...> - 2008-04-11 18:50:46
|
From: Anders Melchiorsen <ma...@fl...> Without I/O signals, qemu is relying on periodic timer events to poll the I/O. That seems wrong, even though it works reasonably well because timers are so frequent. In KVM, timers are less frequent, and it does not work quite as well. Here is a quick try at a more elaborate patch. It attaches a signal to all[1] file descriptors that will be used in select(). Also, it uses a dedicated SIGIO handler rather than piggybacking on the alarm handler, so alarm I/O is changed to use SIGALRM. I copied the handler function from the alarm case, quite frankly I do not quite understand what is going on. Also, I left _WIN32 out, since I have no idea how signals work there. [1] The slirp file descriptors are not included yet. Index: kvm-userspace.io/qemu/vl.c =================================================================== --- kvm-userspace.io.orig/qemu/vl.c +++ kvm-userspace.io/qemu/vl.c @@ -1177,6 +1177,25 @@ static int timer_load(QEMUFile *f, void return 0; } +#ifndef _WIN32 +static void host_io_handler(int host_signum) +{ + CPUState *env = next_cpu; + + if (env) { + /* stop the currently executing cpu because io occured */ + cpu_interrupt(env, CPU_INTERRUPT_EXIT); +#ifdef USE_KQEMU + if (env->kqemu_enabled) { + kqemu_cpu_interrupt(env); + } +#endif + } + + event_pending = 1; +} +#endif + #ifdef _WIN32 void CALLBACK host_alarm_handler(UINT uTimerID, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR dw1, DWORD_PTR dw2) @@ -1270,7 +1289,20 @@ static uint64_t qemu_next_deadline(void) #define RTC_FREQ 1024 -static void enable_sigio_timer(int fd) +static void enable_sigio(int fd) +{ + struct sigaction act; + + sigfillset(&act.sa_mask); + act.sa_flags = 0; + act.sa_handler = host_io_handler; + + sigaction(SIGIO, &act, NULL); + fcntl(fd, F_SETFL, O_ASYNC); + fcntl(fd, F_SETOWN, getpid()); +} + +static void enable_sigalrm(int fd) { struct sigaction act; @@ -1279,8 +1311,9 @@ static void enable_sigio_timer(int fd) act.sa_flags = 0; act.sa_handler = host_alarm_handler; - sigaction(SIGIO, &act, NULL); + sigaction(SIGALRM, &act, NULL); fcntl(fd, F_SETFL, O_ASYNC); + fcntl(fd, F_SETSIG, SIGALRM); fcntl(fd, F_SETOWN, getpid()); } @@ -1317,7 +1350,7 @@ static int hpet_start_timer(struct qemu_ if (r < 0) goto fail; - enable_sigio_timer(fd); + enable_sigalrm(fd); t->priv = (void *)(long)fd; return 0; @@ -1355,7 +1388,7 @@ static int rtc_start_timer(struct qemu_a return -1; } - enable_sigio_timer(rtc_fd); + enable_sigalrm(rtc_fd); t->priv = (void *)(long)rtc_fd; @@ -4029,7 +4062,6 @@ static TAPState *net_tap_fd_init(VLANSta return NULL; s->fd = fd; s->no_poll = 0; - enable_sigio_timer(fd); s->vc = qemu_new_vlan_client(vlan, tap_receive, NULL, s); qemu_set_fd_handler2(s->fd, tap_read_poll, tap_send, NULL, s); snprintf(s->vc->info_str, sizeof(s->vc->info_str), "tap: fd=%d", fd); @@ -5661,6 +5693,10 @@ int qemu_set_fd_handler2(int fd, return -1; ioh->next = first_io_handler; first_io_handler = ioh; +#ifndef _WIN32 + enable_sigio(fd); +#endif + found: ioh->fd = fd; ioh->fd_read_poll = fd_read_poll; -- |
From: Marcelo T. <mto...@re...> - 2008-04-11 18:50:37
|
First patch from Anders Melchiorsen cleans up SIGIO handling: - SIGALRM for alarm timers - enable SIGIO on qemu_set_fd_handler2() - avoid tap from abusing enable_sigio_timer() With that in place its possible to increase the dumb console (-nographic) refresh rate to 1s (from 30ms). -- |
From: Andrea A. <an...@qu...> - 2008-04-11 18:37:15
|
On Fri, Apr 11, 2008 at 05:43:03PM +0530, Amit Shah wrote: > Hi Andrea, > > Did you have to recompile the bios? How did you do that (or did you ask Avi to Yes. > generate it?) Do you have a binary of the bios that I can use to test > reserved ram? make bios; make install should do the trick, the new bios should run after that. thanks, Andrea |
From: Marcelo T. <mto...@re...> - 2008-04-11 17:57:59
|
On Fri, Apr 11, 2008 at 03:18:19PM +0300, Avi Kivity wrote: > kvm_vcpu_kick() can be called from nonatomic contexts, so the vcpu->cpu > == cpu check is dangerous (and will warn on preemptible kernels, no?) Doh, right. How's this. ----------- KVM: fix kvm_vcpu_kick vs __vcpu_run race There is a window open between testing of pending IRQ's and assignment of guest_mode in __vcpu_run. Injection of IRQ's can race with __vcpu_run as follows: CPU0 CPU1 kvm_x86_ops->run() vcpu->guest_mode = 0 SET_IRQ_LINE ioctl .. kvm_x86_ops->inject_pending_irq kvm_cpu_has_interrupt() apic_test_and_set_irr() kvm_vcpu_kick if (vcpu->guest_mode) send_ipi() vcpu->guest_mode = 1 So move guest_mode=1 assignment before ->inject_pending_irq, and make sure that it won't reorder after it. Signed-off-by: Marcelo Tosatti <mto...@re...> Index: kvm/arch/x86/kvm/x86.c =================================================================== --- kvm.orig/arch/x86/kvm/x86.c +++ kvm/arch/x86/kvm/x86.c @@ -2777,6 +2777,13 @@ again: goto out; } + vcpu->guest_mode = 1; + /* + * Make sure that guest_mode assignment won't happen after + * testing the pending IRQ vector bitmap. + */ + smp_wmb(); + if (vcpu->arch.exception.pending) __queue_exception(vcpu); else if (irqchip_in_kernel(vcpu->kvm)) @@ -2788,7 +2795,6 @@ again: up_read(&vcpu->kvm->slots_lock); - vcpu->guest_mode = 1; kvm_guest_enter(); if (vcpu->requests) @@ -3944,11 +3950,13 @@ static void vcpu_kick_intr(void *info) void kvm_vcpu_kick(struct kvm_vcpu *vcpu) { int ipi_pcpu = vcpu->cpu; + int cpu = get_cpu(); if (waitqueue_active(&vcpu->wq)) { wake_up_interruptible(&vcpu->wq); ++vcpu->stat.halt_wakeup; } - if (vcpu->guest_mode) + if (vcpu->guest_mode && vcpu->cpu != cpu) smp_call_function_single(ipi_pcpu, vcpu_kick_intr, vcpu, 0, 0); + put_cpu(); } |
From: Marcelo T. <mto...@re...> - 2008-04-11 17:50:19
|
On Fri, Apr 11, 2008 at 03:12:41PM +0300, Avi Kivity wrote: > This breaks ia64 (and shouldn't s390 use this too?) > > * We will block until either an interrupt or a signal wakes us up > > */ > > while (!kvm_cpu_has_interrupt(vcpu) > >+ && !kvm_cpu_has_pending_timer(vcpu) > > > > I guess the fix is to stub this out for the other archs. Agreed. How's this. ----------- KVM: hlt emulation should take in-kernel APIC/PIT timers into account Timers that fire between guest hlt and vcpu_block's add_wait_queue() are ignored, possibly resulting in hangs. Also make sure that atomic_inc and waitqueue_active tests happen in the specified order, otherwise the following race is open: CPU0 CPU1 if (waitqueue_active(wq)) add_wait_queue() if (!atomic_read(pit_timer->pending)) schedule() atomic_inc(pit_timer->pending) Signed-off-by: Marcelo Tosatti <mto...@re...> Index: kvm/arch/ia64/kvm/kvm-ia64.c =================================================================== --- kvm.orig/arch/ia64/kvm/kvm-ia64.c +++ kvm/arch/ia64/kvm/kvm-ia64.c @@ -1778,6 +1778,11 @@ int kvm_cpu_has_interrupt(struct kvm_vcp return 0; } +int kvm_cpu_has_pending_timer(struct kvm_vcpu *vcpu) +{ + return 0; +} + gfn_t unalias_gfn(struct kvm *kvm, gfn_t gfn) { return gfn; Index: kvm/arch/s390/kvm/interrupt.c =================================================================== --- kvm.orig/arch/s390/kvm/interrupt.c +++ kvm/arch/s390/kvm/interrupt.c @@ -321,6 +321,11 @@ int kvm_cpu_has_interrupt(struct kvm_vcp return rc; } +int kvm_cpu_has_pending_timer(struct kvm_vcpu *vcpu) +{ + return 0; +} + int kvm_s390_handle_wait(struct kvm_vcpu *vcpu) { u64 now, sltime; Index: kvm/arch/x86/kvm/i8254.c =================================================================== --- kvm.orig/arch/x86/kvm/i8254.c +++ kvm/arch/x86/kvm/i8254.c @@ -199,6 +199,7 @@ int __pit_timer_fn(struct kvm_kpit_state struct kvm_kpit_timer *pt = &ps->pit_timer; atomic_inc(&pt->pending); + smp_mb__after_atomic_inc(); if (vcpu0 && waitqueue_active(&vcpu0->wq)) { vcpu0->arch.mp_state = VCPU_MP_STATE_RUNNABLE; wake_up_interruptible(&vcpu0->wq); @@ -210,6 +211,16 @@ int __pit_timer_fn(struct kvm_kpit_state return (pt->period == 0 ? 0 : 1); } +int pit_has_pending_timer(struct kvm_vcpu *vcpu) +{ + struct kvm_pit *pit = vcpu->kvm->arch.vpit; + + if (pit && vcpu->vcpu_id == 0) + return atomic_read(&pit->pit_state.pit_timer.pending); + + return 0; +} + static enum hrtimer_restart pit_timer_fn(struct hrtimer *data) { struct kvm_kpit_state *ps; Index: kvm/arch/x86/kvm/irq.c =================================================================== --- kvm.orig/arch/x86/kvm/irq.c +++ kvm/arch/x86/kvm/irq.c @@ -26,6 +26,21 @@ #include "i8254.h" /* + * check if there are pending timer events + * to be processed. + */ +int kvm_cpu_has_pending_timer(struct kvm_vcpu *vcpu) +{ + int ret; + + ret = pit_has_pending_timer(vcpu); + ret |= apic_has_pending_timer(vcpu); + + return ret; +} +EXPORT_SYMBOL(kvm_cpu_has_pending_timer); + +/* * check if there is pending interrupt without * intack. */ Index: kvm/arch/x86/kvm/irq.h =================================================================== --- kvm.orig/arch/x86/kvm/irq.h +++ kvm/arch/x86/kvm/irq.h @@ -85,4 +85,7 @@ void kvm_inject_pending_timer_irqs(struc void kvm_inject_apic_timer_irqs(struct kvm_vcpu *vcpu); void __kvm_migrate_apic_timer(struct kvm_vcpu *vcpu); +int pit_has_pending_timer(struct kvm_vcpu *vcpu); +int apic_has_pending_timer(struct kvm_vcpu *vcpu); + #endif Index: kvm/arch/x86/kvm/lapic.c =================================================================== --- kvm.orig/arch/x86/kvm/lapic.c +++ kvm/arch/x86/kvm/lapic.c @@ -952,6 +952,16 @@ static int __apic_timer_fn(struct kvm_la return result; } +int apic_has_pending_timer(struct kvm_vcpu *vcpu) +{ + struct kvm_lapic *lapic = vcpu->arch.apic; + + if (lapic) + return atomic_read(&lapic->timer.pending); + + return 0; +} + static int __inject_apic_timer_irq(struct kvm_lapic *apic) { int vector; Index: kvm/include/linux/kvm_host.h =================================================================== --- kvm.orig/include/linux/kvm_host.h +++ kvm/include/linux/kvm_host.h @@ -272,6 +272,7 @@ void kvm_arch_destroy_vm(struct kvm *kvm int kvm_cpu_get_interrupt(struct kvm_vcpu *v); int kvm_cpu_has_interrupt(struct kvm_vcpu *v); +int kvm_cpu_has_pending_timer(struct kvm_vcpu *vcpu); void kvm_vcpu_kick(struct kvm_vcpu *vcpu); static inline void kvm_guest_enter(void) Index: kvm/virt/kvm/kvm_main.c =================================================================== --- kvm.orig/virt/kvm/kvm_main.c +++ kvm/virt/kvm/kvm_main.c @@ -765,6 +765,7 @@ void kvm_vcpu_block(struct kvm_vcpu *vcp * We will block until either an interrupt or a signal wakes us up */ while (!kvm_cpu_has_interrupt(vcpu) + && !kvm_cpu_has_pending_timer(vcpu) && !signal_pending(current) && !kvm_arch_vcpu_runnable(vcpu)) { set_current_state(TASK_INTERRUPTIBLE); |
From: Amit S. <ami...@qu...> - 2008-04-11 17:44:18
|
The -m parameter doesn't take suffixes like G or M currently and it doesn't complain if such a suffix is given. Add support for the G and M suffixes and update the usage instructions appropriately. Signed-off-by: Amit Shah <ami...@qu...> --- qemu/vl.c | 25 +++++++++++++++++++++++-- 1 files changed, 23 insertions(+), 2 deletions(-) diff --git a/qemu/vl.c b/qemu/vl.c index 49d9af2..1c6f603 100644 --- a/qemu/vl.c +++ b/qemu/vl.c @@ -8085,7 +8085,9 @@ static void help(int exitcode) #ifdef TARGET_I386 "-no-fd-bootchk disable boot signature checking for floppy disks\n" #endif - "-m megs set virtual RAM size to megs MB [default=%d]\n" + "-m size set virtual RAM size to size megs [default=%d MB].\n" + " Optional suffixes 'M' (megabyte) and 'G' (gigabyte)" + " are supported\n" "-smp n set the number of CPUs to 'n' [default=1]\n" "-nographic disable graphical output and redirect serial I/Os to console\n" "-portrait rotate graphical output 90 deg left (only PXA LCD)\n" @@ -9140,7 +9142,26 @@ int main(int argc, char **argv) help(0); break; case QEMU_OPTION_m: - ram_size = (int64_t)atoi(optarg) * 1024 * 1024; + errno = 0; + ram_size = (uint64_t) strtoul(optarg, (char **)&optarg, 0); + if (errno) + help(1); + switch (*optarg) { + case 'G': + case 'g': + ram_size *= 1024; + /* fall through */ + case 'M': + case 'm': + case '\0': + ram_size *= 1024 * 1024; + optarg++; + break; + default: + help(1); + break; + } + if (ram_size <= 0) help(1); if (ram_size > PHYS_RAM_MAX_SIZE) { -- 1.4.4.2 |
From: Marcelo T. <mto...@re...> - 2008-04-11 17:35:37
|
Address comments from Avi: - fold mp_state into a structure - IOW/IOR markers for ioctl definitions - return -ENOSYS if extension is not supported -- |
From: Marcelo T. <mto...@re...> - 2008-04-11 16:41:18
|
Use the new interface to save and restore MP_STATE for all vcpu's. Increase version_id for cpu_load/cpu_save. Fixes SMP migration. Signed-off-by: Marcelo Tosatti <mto...@re...> Index: kvm-userspace.io/qemu/hw/pc.c =================================================================== --- kvm-userspace.io.orig/qemu/hw/pc.c +++ kvm-userspace.io/qemu/hw/pc.c @@ -750,7 +750,7 @@ CPUState *pc_new_cpu(int cpu, const char /* XXX: enable it in all cases */ env->cpuid_features |= CPUID_APIC; } - register_savevm("cpu", cpu, 4, cpu_save, cpu_load, env); + register_savevm("cpu", cpu, 5, cpu_save, cpu_load, env); qemu_register_reset(main_cpu_reset, env); if (pci_enabled) { apic_init(env); Index: kvm-userspace.io/qemu/qemu-kvm-x86.c =================================================================== --- kvm-userspace.io.orig/qemu/qemu-kvm-x86.c +++ kvm-userspace.io/qemu/qemu-kvm-x86.c @@ -277,6 +277,33 @@ void kvm_arch_load_regs(CPUState *env) perror("kvm_set_msrs FAILED"); } +void kvm_save_mpstate(CPUState *env) +{ +#ifdef KVM_CAP_MP_STATE + int r; + struct kvm_mp_state mp_state; + + r = kvm_get_mpstate(kvm_context, env->cpu_index, &mp_state); + if (r < 0) + env->mp_state = -1; + else + env->mp_state = mp_state.mp_state; +#endif +} + +void kvm_load_mpstate(CPUState *env) +{ +#ifdef KVM_CAP_MP_STATE + struct kvm_mp_state mp_state = { .mp_state = env->mp_state }; + + /* + * -1 indicates that the host did not support GET_MP_STATE ioctl, + * so don't touch it. + */ + if (env->mp_state != -1) + kvm_set_mpstate(kvm_context, env->cpu_index, &mp_state); +#endif +} void kvm_arch_save_regs(CPUState *env) { Index: kvm-userspace.io/qemu/qemu-kvm.h =================================================================== --- kvm-userspace.io.orig/qemu/qemu-kvm.h +++ kvm-userspace.io/qemu/qemu-kvm.h @@ -18,6 +18,8 @@ int kvm_init_ap(void); void kvm_qemu_destroy(void); void kvm_load_registers(CPUState *env); void kvm_save_registers(CPUState *env); +void kvm_load_mpstate(CPUState *env); +void kvm_save_mpstate(CPUState *env); int kvm_cpu_exec(CPUState *env); int kvm_update_debugger(CPUState *env); int kvm_qemu_init_env(CPUState *env); Index: kvm-userspace.io/qemu/target-i386/cpu.h =================================================================== --- kvm-userspace.io.orig/qemu/target-i386/cpu.h +++ kvm-userspace.io/qemu/target-i386/cpu.h @@ -599,6 +599,7 @@ typedef struct CPUX86State { /* in order to simplify APIC support, we leave this pointer to the user */ struct APICState *apic_state; + int mp_state; } CPUX86State; CPUX86State *cpu_x86_init(const char *cpu_model); Index: kvm-userspace.io/qemu/vl.c =================================================================== --- kvm-userspace.io.orig/qemu/vl.c +++ kvm-userspace.io/qemu/vl.c @@ -6655,8 +6655,10 @@ void cpu_save(QEMUFile *f, void *opaque) uint32_t hflags; int i; - if (kvm_enabled()) + if (kvm_enabled()) { kvm_save_registers(env); + kvm_save_mpstate(env); + } for(i = 0; i < CPU_NB_REGS; i++) qemu_put_betls(f, &env->regs[i]); @@ -6748,6 +6750,7 @@ void cpu_save(QEMUFile *f, void *opaque) qemu_put_be32s(f, &env->kvm_interrupt_bitmap[i]); } qemu_put_be64s(f, &env->tsc); + qemu_put_be32s(f, &env->mp_state); } } @@ -6782,7 +6785,7 @@ int cpu_load(QEMUFile *f, void *opaque, uint32_t hflags; uint16_t fpus, fpuc, fptag, fpregs_format; - if (version_id != 3 && version_id != 4) + if (version_id < 3 || version_id > 5) return -EINVAL; for(i = 0; i < CPU_NB_REGS; i++) qemu_get_betls(f, &env->regs[i]); @@ -6900,6 +6903,10 @@ int cpu_load(QEMUFile *f, void *opaque, } qemu_get_be64s(f, &env->tsc); kvm_load_registers(env); + if (version_id >= 5) { + qemu_get_be32s(f, &env->mp_state); + kvm_load_mpstate(env); + } } return 0; } -- |
From: Marcelo T. <mto...@re...> - 2008-04-11 16:33:52
|
Otherwise a signal can be received in userspace and a vcpu goes back to the kernel while it should stay still. Signed-off-by: Marcelo Tosatti <mto...@re...> Index: kvm-userspace.io/qemu/qemu-kvm.c =================================================================== --- kvm-userspace.io.orig/qemu/qemu-kvm.c +++ kvm-userspace.io/qemu/qemu-kvm.c @@ -350,7 +350,6 @@ static void *ap_main_loop(void *_env) vcpu->env = env; vcpu->env->thread_id = kvm_get_thread_id(); sigfillset(&signals); - sigdelset(&signals, SIG_IPI); sigprocmask(SIG_BLOCK, &signals, NULL); kvm_create_vcpu(kvm_context, env->cpu_index); kvm_qemu_init_env(env); -- |
From: Marcelo T. <mto...@re...> - 2008-04-11 16:33:42
|
So userspace can save/restore the mpstate during migration. Signed-off-by: Marcelo Tosatti <mto...@re...> Index: kvm/arch/x86/kvm/x86.c =================================================================== --- kvm.orig/arch/x86/kvm/x86.c +++ kvm/arch/x86/kvm/x86.c @@ -814,6 +814,7 @@ int kvm_dev_ioctl_check_extension(long e case KVM_CAP_CLOCKSOURCE: case KVM_CAP_PIT: case KVM_CAP_NOP_IO_DELAY: + case KVM_CAP_MP_STATE: r = 1; break; case KVM_CAP_VAPIC: @@ -3057,6 +3058,24 @@ int kvm_arch_vcpu_ioctl_get_sregs(struct return 0; } +int kvm_arch_vcpu_ioctl_get_mpstate(struct kvm_vcpu *vcpu, + struct kvm_mp_state *mp_state) +{ + vcpu_load(vcpu); + mp_state->mp_state = vcpu->arch.mp_state; + vcpu_put(vcpu); + return 0; +} + +int kvm_arch_vcpu_ioctl_set_mpstate(struct kvm_vcpu *vcpu, + struct kvm_mp_state *mp_state) +{ + vcpu_load(vcpu); + vcpu->arch.mp_state = mp_state->mp_state; + vcpu_put(vcpu); + return 0; +} + static void set_segment(struct kvm_vcpu *vcpu, struct kvm_segment *var, int seg) { Index: kvm/include/linux/kvm.h =================================================================== --- kvm.orig/include/linux/kvm.h +++ kvm/include/linux/kvm.h @@ -222,6 +222,11 @@ struct kvm_vapic_addr { __u64 vapic_addr; }; +/* for KVM_SET_MPSTATE */ +struct kvm_mp_state { + __u32 mp_state; +}; + struct kvm_s390_psw { __u64 mask; __u64 addr; @@ -279,6 +284,7 @@ struct kvm_s390_interrupt { #define KVM_CAP_PIT 11 #define KVM_CAP_NOP_IO_DELAY 12 #define KVM_CAP_PV_MMU 13 +#define KVM_CAP_MP_STATE 14 /* * ioctls for VM fds @@ -340,5 +346,7 @@ struct kvm_s390_interrupt { #define KVM_S390_SET_INITIAL_PSW _IOW(KVMIO, 0x96, struct kvm_s390_psw) /* initial reset for s390 */ #define KVM_S390_INITIAL_RESET _IO(KVMIO, 0x97) +#define KVM_GET_MP_STATE _IOR(KVMIO, 0x98, struct kvm_mp_state) +#define KVM_SET_MP_STATE _IOW(KVMIO, 0x99, struct kvm_mp_state) #endif Index: kvm/include/linux/kvm_host.h =================================================================== --- kvm.orig/include/linux/kvm_host.h +++ kvm/include/linux/kvm_host.h @@ -236,6 +236,10 @@ int kvm_arch_vcpu_ioctl_get_sregs(struct struct kvm_sregs *sregs); int kvm_arch_vcpu_ioctl_set_sregs(struct kvm_vcpu *vcpu, struct kvm_sregs *sregs); +int kvm_arch_vcpu_ioctl_get_mpstate(struct kvm_vcpu *vcpu, + struct kvm_mp_state *mp_state); +int kvm_arch_vcpu_ioctl_set_mpstate(struct kvm_vcpu *vcpu, + struct kvm_mp_state *mp_state); int kvm_arch_vcpu_ioctl_debug_guest(struct kvm_vcpu *vcpu, struct kvm_debug_guest *dbg); int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run); Index: kvm/virt/kvm/kvm_main.c =================================================================== --- kvm.orig/virt/kvm/kvm_main.c +++ kvm/virt/kvm/kvm_main.c @@ -978,6 +978,30 @@ out_free2: r = 0; break; } + case KVM_GET_MP_STATE: { + struct kvm_mp_state mp_state; + + r = kvm_arch_vcpu_ioctl_get_mpstate(vcpu, &mp_state); + if (r) + goto out; + r = -EFAULT; + if (copy_to_user(argp, &mp_state, sizeof mp_state)) + goto out; + r = 0; + break; + } + case KVM_SET_MP_STATE: { + struct kvm_mp_state mp_state; + + r = -EFAULT; + if (copy_from_user(&mp_state, argp, sizeof mp_state)) + goto out; + r = kvm_arch_vcpu_ioctl_set_mpstate(vcpu, &mp_state); + if (r) + goto out; + r = 0; + break; + } case KVM_TRANSLATE: { struct kvm_translation tr; -- |
From: Marcelo T. <mto...@re...> - 2008-04-11 16:33:35
|
Signed-off-by: Marcelo Tosatti <mto...@re...> Index: kvm-userspace.io/libkvm/libkvm.c =================================================================== --- kvm-userspace.io.orig/libkvm/libkvm.c +++ kvm-userspace.io/libkvm/libkvm.c @@ -776,6 +776,28 @@ int kvm_set_sregs(kvm_context_t kvm, int return ioctl(kvm->vcpu_fd[vcpu], KVM_SET_SREGS, sregs); } +#ifdef KVM_CAP_MP_STATE +int kvm_get_mpstate(kvm_context_t kvm, int vcpu, struct kvm_mp_state *mp_state) +{ + int r; + + r = ioctl(kvm->fd, KVM_CHECK_EXTENSION, KVM_CAP_MP_STATE); + if (r > 0) + return ioctl(kvm->vcpu_fd[vcpu], KVM_GET_MP_STATE, mp_state); + return -ENOSYS; +} + +int kvm_set_mpstate(kvm_context_t kvm, int vcpu, struct kvm_mp_state *mp_state) +{ + int r; + + r = ioctl(kvm->fd, KVM_CHECK_EXTENSION, KVM_CAP_MP_STATE); + if (r > 0) + return ioctl(kvm->vcpu_fd[vcpu], KVM_SET_MP_STATE, mp_state); + return -ENOSYS; +} +#endif + static int handle_mmio(kvm_context_t kvm, struct kvm_run *kvm_run) { unsigned long addr = kvm_run->mmio.phys_addr; Index: kvm-userspace.io/libkvm/libkvm.h =================================================================== --- kvm-userspace.io.orig/libkvm/libkvm.h +++ kvm-userspace.io/libkvm/libkvm.h @@ -300,6 +300,22 @@ int kvm_get_sregs(kvm_context_t kvm, int */ int kvm_set_sregs(kvm_context_t kvm, int vcpu, struct kvm_sregs *regs); +#ifdef KVM_CAP_MP_STATE +/*! + * * \brief Read VCPU MP state + * + */ +int kvm_get_mpstate(kvm_context_t kvm, int vcpu, + struct kvm_mp_state *mp_state); + +/*! + * * \brief Write VCPU MP state + * + */ +int kvm_set_mpstate(kvm_context_t kvm, int vcpu, + struct kvm_mp_state *mp_state); +#endif + /*! * \brief Simulate an external vectored interrupt * -- |
From: Marcelo T. <mto...@re...> - 2008-04-11 16:33:14
|
The MSR_IA32_APICBASE_ENABLE/MSR_IA32_APICBASE_BSP bits in s->apicbase are not initialized if in-kernel APIC emulation is used, so save the actual value passed by cpu_set_apic_base() caller. Signed-off-by: Marcelo Tosatti <mto...@re...> Index: kvm-userspace.io/qemu/hw/apic.c =================================================================== --- kvm-userspace.io.orig/qemu/hw/apic.c +++ kvm-userspace.io/qemu/hw/apic.c @@ -248,8 +248,11 @@ void cpu_set_apic_base(CPUState *env, ui #ifdef DEBUG_APIC printf("cpu_set_apic_base: %016" PRIx64 "\n", val); #endif - s->apicbase = (val & 0xfffff000) | - (s->apicbase & (MSR_IA32_APICBASE_BSP | MSR_IA32_APICBASE_ENABLE)); + if (kvm_enabled() && qemu_kvm_irqchip_in_kernel()) + s->apicbase = val; + else + s->apicbase = (val & 0xfffff000) | + (s->apicbase & (MSR_IA32_APICBASE_BSP | MSR_IA32_APICBASE_ENABLE)); /* if disabled, cannot be enabled again */ if (!(val & MSR_IA32_APICBASE_ENABLE)) { s->apicbase &= ~MSR_IA32_APICBASE_ENABLE; Index: kvm-userspace.io/qemu/qemu-kvm-x86.c =================================================================== --- kvm-userspace.io.orig/qemu/qemu-kvm-x86.c +++ kvm-userspace.io/qemu/qemu-kvm-x86.c @@ -248,13 +248,8 @@ void kvm_arch_load_regs(CPUState *env) sregs.cr3 = env->cr[3]; sregs.cr4 = env->cr[4]; - if (kvm_irqchip_in_kernel(kvm_context)) { - sregs.cr8 = kvm_get_cr8(kvm_context, env->cpu_index); - sregs.apic_base = kvm_get_apic_base(kvm_context, env->cpu_index); - } else { - sregs.cr8 = cpu_get_apic_tpr(env); - sregs.apic_base = cpu_get_apic_base(env); - } + sregs.cr8 = cpu_get_apic_tpr(env); + sregs.apic_base = cpu_get_apic_base(env); sregs.efer = env->efer; -- |
From: Miguel A. <ma...@No...> - 2008-04-11 16:22:40
|
Thank you Anthony for your program. I have downloaded it and it works great! Until now I was generating the iso without gfxboot doing changes by hand. This is going to let me work faster, thanks. Thanks a lot for the kvmtest information too. Regards, Miguel > Miguel Araujo wrote: > >> Hello all, >> >> I'm interested in automate linux guests installation. First I haven't >> been able to guess if the gfxboot issues with Ubuntu have been solved >> (changelog searching has given zero results), so I thought about >> installing a debootstrap system in a file mounted in loopback mode. >> would be KVM able to boot a file like this? Second I might be having to >> do a bunch of installations in soon future and I'm not interested in >> doing it from CD, is there any way apart cloning the images and >> reconfiguring them after booting? >> >> > > http://hg.codemonkey.ws/gfxboot-disable > > and > > http://kvm.qumranet.com/kvmwiki/KVMTest > > Regards, > > Anthony Liguori > > >> Thank you very much in advanced, Regards >> Miguel >> >> >> ------------------------------------------------------------------------- >> This SF.net email is sponsored by the 2008 JavaOne(SM) Conference >> Don't miss this year's exciting event. There's still time to save $100. >> Use priority code J8TL2D2. >> http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone >> _______________________________________________ >> kvm-devel mailing list >> kvm...@li... >> https://lists.sourceforge.net/lists/listinfo/kvm-devel >> >> > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by the 2008 JavaOne(SM) Conference > Don't miss this year's exciting event. There's still time to save $100. > Use priority code J8TL2D2. > http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone > _______________________________________________ > kvm-devel mailing list > kvm...@li... > https://lists.sourceforge.net/lists/listinfo/kvm-devel > > |
From: Alberto T. <al...@by...> - 2008-04-11 15:50:49
|
When I try to boot from a SCSI device using grub, Qemu crashes (see below). I have been able to boot from SCSI devices using Windows, but anytime I use grub I get a crash, even when booting off a CD with grub. Any ideas? # qemu-system-x86_64 -drive \ file=junk.raw,if=scsi,bus=0,index=0,media=disk,boot=on \ -cdrom /srv/vm/.kvm/install/slim-cd-v4.iso -boot d \ -m 64 -vnc :0 exception 13 (33) rax 0000000000000000 rbx 0000000000000800 rcx 0000000000000000 rdx 00000000000000e0 rsi 00000000ffff7d98 rdi 000000000008f788 rsp 0000000000002018 rbp 0000000000000001 r8 0000000000000000 r9 0000000000000000 r10 0000000000000000 r11 0000000000000000 r12 0000000000000000 r13 0000000000000000 r14 0000000000000000 r15 0000000000000000 rip 0000000000000003 rflags 00033202 cs 0000 (00000000/0000ffff p 1 dpl 3 db 0 s 1 type 3 l 0 g 0 avl 0) ds 0000 (00000000/0000ffff p 1 dpl 3 db 0 s 1 type 3 l 0 g 0 avl 0) es 0800 (00008000/0000ffff p 1 dpl 3 db 0 s 1 type 3 l 0 g 0 avl 0) ss 0000 (00000000/0000ffff p 1 dpl 3 db 0 s 1 type 3 l 0 g 0 avl 0) fs 0000 (00000000/0000ffff p 1 dpl 3 db 0 s 1 type 3 l 0 g 0 avl 0) gs 0000 (00000000/0000ffff p 1 dpl 3 db 0 s 1 type 3 l 0 g 0 avl 0) tr 0000 (fffbd000/00002088 p 1 dpl 0 db 0 s 0 type b l 0 g 0 avl 0) ldt 0000 (00000000/0000ffff p 1 dpl 0 db 0 s 0 type 2 l 0 g 0 avl 0) gdt fb1f2/30 idt 0/3ff cr0 10 cr2 0 cr3 0 cr4 0 cr8 0 efer 0 code: 53 ff 00 --> f0 53 ff 00 f0 53 ff 00 f0 53 ff 00 f0 53 ff 00 f0 53 ff 00 f0 53 ff 00 f0 53 ff 00 f0 a5 fe 00 f0 87 e9 00 f0 53 ff 00 f0 53 ff 00 f0 53 ff Aborted -- Alberto Treviño al...@by... |
From: Gerd H. <kr...@re...> - 2008-04-11 15:01:34
|
Gerd Hoffmann wrote: > Wall clock is off a few hours though. Oops. > > I think the way wall clock and system clock work together in xen (Jeremy > correct me if I'm wrong) is that the wall clock specifies the point in > time where the system clock started going. As kvm fills in host system > time into the guest system time fields the guest wall clock fields > should be filled with the host boot time timestamp I'd say. Following up myself with a quick&dirty patch to tackle this issue too. This one calculates the boot time. That should be solveable better, include/linux/time.h lists two functions which sound promising: extern void getboottime(struct timespec *ts); extern void monotonic_to_bootbased(struct timespec *ts); Neither of them is available to modules though, so I can't test without rebooting my laptop ... monotonic_to_bootbased() sounds like we would get hosts ntp adjustments in the guests for free. cheers, Gerd -- http://kraxel.fedorapeople.org/xenner/ |
From: Anthony L. <an...@co...> - 2008-04-11 14:57:02
|
Miguel Araujo wrote: > Hello all, > > I'm interested in automate linux guests installation. First I haven't > been able to guess if the gfxboot issues with Ubuntu have been solved > (changelog searching has given zero results), so I thought about > installing a debootstrap system in a file mounted in loopback mode. > would be KVM able to boot a file like this? Second I might be having to > do a bunch of installations in soon future and I'm not interested in > doing it from CD, is there any way apart cloning the images and > reconfiguring them after booting? > http://hg.codemonkey.ws/gfxboot-disable and http://kvm.qumranet.com/kvmwiki/KVMTest Regards, Anthony Liguori > Thank you very much in advanced, Regards > Miguel > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by the 2008 JavaOne(SM) Conference > Don't miss this year's exciting event. There's still time to save $100. > Use priority code J8TL2D2. > http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone > _______________________________________________ > kvm-devel mailing list > kvm...@li... > https://lists.sourceforge.net/lists/listinfo/kvm-devel > |
From: Anthony L. <an...@co...> - 2008-04-11 14:55:44
|
Avi Kivity wrote: > Anthony Liguori wrote: >> Joerg Roedel wrote: >>> The compilation of kvm-userspace part fails if the in-kernel pit is not >>> detected in <linux/kvm.h> with the following error message: >>> >>> pc.o: In function `pc_init1': >>> /home/jroedel/src/kvm/kvm-userspace/qemu/hw/pc.c:987: undefined >>> reference to `kvm_pit_init' >>> collect2: ld returned 1 exit status >>> >>> This patch fixes this little issue. >>> >> >> A better solution is to wrap qemu_kvm_put_in_kernel in an #ifdef >> KVM_CAP_PIT so that if it isn't defined, it always returns 0. gcc >> will then do the right thing. >> > > I would like to move qemu from depending on linux/kvm.h directly. > However, there is a lot of work needed to get that (including some > pointless stuff like defining libkvm structures to take the place of > kvm.h structures) so perhaps it is not a realistic goal. My real point was that the #ifdef should be in the definition of qemu_kvm_put_in_kernel() as opposed to in C code. If we use #ifdef USE_KVM_PIT instead of #ifdef KVM_CAP_PIT that's fine by me. Regards, Anthony Liguori |
From: Gerd H. <kr...@re...> - 2008-04-11 13:44:40
|
Avi Kivity wrote: > Gerd Hoffmann wrote: >> Hi, >> >> Tried to use kvmclock with xenner and noticed that the kvmclock >> (MSR_KVM_SYSTEM_TIME msr) is incompatible with xen. > > Patches are welcome, especially as kvmclock isn't merged yet, so there > are no backward compatibility issues. Great, so I'll happily go break kvm guests ;) Patch revision #1 attached. It changes the way the tsc-delta-scaling fields are calculated to be compatible with xen. Code is taken from xenner (which got it from xen) and adapted a bit. Host only, kvm guest side not done (yet). With that patch applied xen guests with pv clock enabled happily boot to the login prompt, without complains about time going backwards. Fine. Wall clock is off a few hours though. Oops. I think the way wall clock and system clock work together in xen (Jeremy correct me if I'm wrong) is that the wall clock specifies the point in time where the system clock started going. As kvm fills in host system time into the guest system time fields the guest wall clock fields should be filled with the host boot time timestamp I'd say. Comments? Gerd -- http://kraxel.fedorapeople.org/xenner/ |