From owner-freebsd-virtualization@FreeBSD.ORG Wed Jun 3 22:41:24 2015 Return-Path: Delivered-To: freebsd-virtualization@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 393B5E52; Wed, 3 Jun 2015 22:41:24 +0000 (UTC) (envelope-from stefan.andritoiu@gmail.com) Received: from mail-ob0-x233.google.com (mail-ob0-x233.google.com [IPv6:2607:f8b0:4003:c01::233]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 015FD11AB; Wed, 3 Jun 2015 22:41:24 +0000 (UTC) (envelope-from stefan.andritoiu@gmail.com) Received: by obbea3 with SMTP id ea3so19841248obb.0; Wed, 03 Jun 2015 15:41:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=BYkc+8YYXHrfpeD5AALbzLdDYdYWSM3lUidee1gQGxk=; b=nqwf7uXEwOpgYEbKqL4yUbyTdFHVQUESyxQ2nSb1yPE/Nd3Z+STL3uLZ1qlXcZXvd5 OgM6db2Nbv+L4ItH/LrsTckvJvC91mR4fmLCT8R62kVbhlN1EJbw8E9yV2BKemWoDI9z Mq3DM7NTlhER8xzvcpG+VcIjGqAK74jGZsfAOgpVUqCZlyRW4P8qdE9RDHsPtmGditRl iC6Q80/lHG089pCZf8xC6P0DeRWl7RF3XZFeiukYdQiG2Ml7qP73Ij5qCdfIjeHOCAvj 0k2bBAOZB+e3+2jfIMjHLALVMD7RXoa07sJ5LdcLwet9CDjV7xvaiV/WGsgvfUALxmc3 7XUg== MIME-Version: 1.0 X-Received: by 10.60.132.208 with SMTP id ow16mr29488343oeb.66.1433371283034; Wed, 03 Jun 2015 15:41:23 -0700 (PDT) Received: by 10.60.82.168 with HTTP; Wed, 3 Jun 2015 15:41:22 -0700 (PDT) In-Reply-To: <556F3699.7000609@freebsd.org> References: <556F3699.7000609@freebsd.org> Date: Thu, 4 Jun 2015 01:41:22 +0300 Message-ID: Subject: Re: Where are the VCPU threads created? From: Stefan Andritoiu To: Peter Grehan Cc: freebsd-virtualization@freebsd.org Content-Type: text/plain; charset=UTF-8 X-BeenThere: freebsd-virtualization@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "Discussion of various virtualization techniques FreeBSD supports." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Jun 2015 22:41:24 -0000 On Wed, Jun 3, 2015 at 8:17 PM, Peter Grehan wrote: >> I see that in the main() function of bhyverun.c it adds CPU0 by >> calling fbsdrun_addcpu(ctx, 0, 0, rip). But I can't find where the >> other VCPUs are added. Or if the 'guest_ncpus' variable is ever used >> (except for error checks) > > > Have a look at bhyve/spinup_ap.c:spinup_ap() which is called when a the vmm > kernel module detects a SIPI message being sent to the local APIC and forces > a vm-exit to userspace. Hi Peter, Thank you, that answered my question. Another thing: Are these threads (the ones that run the VCPUs) ever destroyed and recreated? In the timespan between the moment they are created (when the guest starts) and when the guest is shut down, is there any chance of the threads ending/being killed and others created to take their place? Or do you end up with the same threads? I am trying to add some information to the VCPU thread at the moment it is created by bhyve, and want that information to be available for the entirety of the guest's lifespan.