From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jorgen Hansen via Virtualization Subject: RE: [PATCH net-next 12/14] vsock/vmci: register vmci_transport only when VMCI guest/host are active Date: Mon, 11 Nov 2019 16:27:28 +0000 Message-ID: References: <20191023095554.11340-1-sgarzare@redhat.com> <20191023095554.11340-13-sgarzare@redhat.com> Reply-To: Jorgen Hansen Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20191023095554.11340-13-sgarzare@redhat.com> Content-Language: en-US List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: virtualization-bounces@lists.linux-foundation.org Errors-To: virtualization-bounces@lists.linux-foundation.org To: 'Stefano Garzarella' , "netdev@vger.kernel.org" Cc: Sasha Levin , "linux-hyperv@vger.kernel.org" , Stephen Hemminger , Arnd Bergmann , "kvm@vger.kernel.org" , "Michael S. Tsirkin" , Greg Kroah-Hartman , Dexuan Cui , "linux-kernel@vger.kernel.org" , "virtualization@lists.linux-foundation.org" , Haiyang Zhang , Stefan Hajnoczi , "David S. Miller" List-Id: virtualization@lists.linuxfoundation.org > From: Stefano Garzarella [mailto:sgarzare@redhat.com] > Sent: Wednesday, October 23, 2019 11:56 AM > > To allow other transports to be loaded with vmci_transport, > we register the vmci_transport as G2H or H2G only when a VMCI guest > or host is active. > > To do that, this patch adds a callback registered in the vmci driver > that will be called when a new host or guest become active. > This callback will register the vmci_transport in the VSOCK core. > If the transport is already registered, we ignore the error coming > from vsock_core_register(). So today this is mainly an issue for the VMCI vsock transport, because VMCI autoloads with vsock (and with this solution it can continue to do that, so none of our old products break due to changed behavior, which is great). Shouldn't vhost behave similar, so that any module that registers a h2g transport only does so if it is in active use? > --- a/drivers/misc/vmw_vmci/vmci_host.c > +++ b/drivers/misc/vmw_vmci/vmci_host.c > @@ -108,6 +108,11 @@ bool vmci_host_code_active(void) > atomic_read(&vmci_host_active_users) > 0); > } > > +int vmci_host_users(void) > +{ > + return atomic_read(&vmci_host_active_users); > +} > + > /* > * Called on open of /dev/vmci. > */ > @@ -338,6 +343,8 @@ static int vmci_host_do_init_context(struct > vmci_host_dev *vmci_host_dev, > vmci_host_dev->ct_type = VMCIOBJ_CONTEXT; > atomic_inc(&vmci_host_active_users); > > + vmci_call_vsock_callback(true); > + Since we don't unregister the transport if user count drops back to 0, we could just call this the first time, a VM is powered on after the module is loaded. > retval = 0; > > out: