From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:38612) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RlGuS-0006m6-Hh for qemu-devel@nongnu.org; Thu, 12 Jan 2012 04:25:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RlGuL-0001WN-9z for qemu-devel@nongnu.org; Thu, 12 Jan 2012 04:25:24 -0500 Received: from mail-ww0-f53.google.com ([74.125.82.53]:47503) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RlGuL-0001WF-2U for qemu-devel@nongnu.org; Thu, 12 Jan 2012 04:25:17 -0500 Received: by wgbdt10 with SMTP id dt10so1743696wgb.10 for ; Thu, 12 Jan 2012 01:25:16 -0800 (PST) Sender: Paolo Bonzini Message-ID: <4F0EA6FA.4030300@redhat.com> Date: Thu, 12 Jan 2012 10:25:14 +0100 From: Paolo Bonzini MIME-Version: 1.0 References: <1326222656-26588-1-git-send-email-aliguori@us.ibm.com> <1326222656-26588-12-git-send-email-aliguori@us.ibm.com> <4F0DE6B0.4000609@codemonkey.ws> In-Reply-To: <4F0DE6B0.4000609@codemonkey.ws> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 12/15] qtest: add support for target-i386 -M pc List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori Cc: qemu-devel@nongnu.org On 01/11/2012 08:44 PM, Anthony Liguori wrote: > This is easier said than done. I started down this road and there's a > huge amount of code that assumes that first_cpu != NULL. That's why I said do not create the CPU _threads_. :) But that wouldn't be a big step forward from halted = 1; for example, it would prevent using per-CPU work items. Currently they're only used internally by KVM, but you never know. So you can also create a CPU thread that does nothing. Here is how it could look like, based on the KVM implementation: static void *qemu_qtest_cpu_thread_fn(void *arg) { CPUState *env = arg; int r; qemu_mutex_lock(&qemu_global_mutex); qemu_thread_get_self(env->thread); env->thread_id = qemu_get_thread_id(); sigset_t waitset; sigemptyset(&waitset); sigaddset(&waitset, SIG_IPI); /* signal CPU creation */ env->created = 1; qemu_cond_signal(&qemu_cpu_cond); cpu_single_env = env; while (1) { cpu_single_env = NULL; qemu_mutex_unlock_iothread(); do { int sig; r = sigwait(&waitset, &sig); } while (r == -1 && (errno == EAGAIN || errno == EINTR)); if (r == -1) { perror("sigtimedwait"); exit(1); } qemu_mutex_lock_iothread(); cpu_single_env = env; qemu_wait_io_event_common(env); } return NULL; } Paolo