qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 12/15] qtest: add support for target-i386 -M pc


From: Paolo Bonzini
Subject: Re: [Qemu-devel] [PATCH 12/15] qtest: add support for target-i386 -M pc
Date: Thu, 12 Jan 2012 10:25:14 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:9.0) Gecko/20111222 Thunderbird/9.0

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]