From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [patch 01/12] [PATCH] kvm-s390: ioctl to switch to user controlled virtual machines Date: Thu, 01 Dec 2011 15:15:03 +0200 Message-ID: <4ED77DD7.7090507@redhat.com> References: <20111201125732.085553111@de.ibm.com> <20111201130408.897496445@de.ibm.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: Marcelo Tossati , Christian Borntraeger , Heiko Carstens , Martin Schwidefsky , Cornelia Huck , KVM , Joachim von Buttlar , Jens Freimann , Constantin Werner To: Carsten Otte Return-path: Received: from mx1.redhat.com ([209.132.183.28]:64234 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753749Ab1LANPM (ORCPT ); Thu, 1 Dec 2011 08:15:12 -0500 In-Reply-To: <20111201130408.897496445@de.ibm.com> Sender: kvm-owner@vger.kernel.org List-ID: On 12/01/2011 02:57 PM, Carsten Otte wrote: > This patch introduces a new config option for user controlled kernel > virtual machines. It introduces a new ioctl named > KVM_S390_ENABLE_UCONTROL on the kvm file descriptor which allows for > a one way transition from a regular kernel virtual machine to a > user controlled virtual machine. The virtual machine must not have > any memory slots installed, and no virtual cpus defined. > Note that the user controlled virtual machines require CAP_SYS_ADMIN > privileges. > > Signed-off-by: Carsten Otte > --- > --- > arch/s390/kvm/Kconfig | 9 +++++++++ > arch/s390/kvm/kvm-s390.c | 30 ++++++++++++++++++++++++++++++ > arch/s390/kvm/kvm-s390.h | 10 ++++++++++ > include/linux/kvm.h | 3 +++ > 4 files changed, 52 insertions(+) Documentation/virtual/kvm/api.txt +++++++++++++++++++ > > +int kvm_s390_enable_ucontrol(struct kvm *kvm) > +{ > +#ifdef CONFIG_KVM_UCONTROL > + int i; > + > + if (!capable(CAP_SYS_ADMIN)) > + return -EPERM; > + > + for (i = 0; i < KVM_MAX_VCPUS; i++) > + if (kvm->vcpus[i]) > + return -EINVAL; > + > + if (kvm->memslots->nmemslots) > + return -EPERM; Why different errors? > + > + if (kvm->arch.gmap) > + gmap_free(kvm->arch.gmap); > + > + kvm->arch.gmap = NULL; Locking? What happens if a vcpu is created afterwards? I guess you don't mind too much since this is a privileged interface for a single purpose. > --- a/include/linux/kvm.h > +++ b/include/linux/kvm.h > @@ -654,6 +654,9 @@ struct kvm_clock_data { > struct kvm_userspace_memory_region) > #define KVM_SET_TSS_ADDR _IO(KVMIO, 0x47) > #define KVM_SET_IDENTITY_MAP_ADDR _IOW(KVMIO, 0x48, __u64) > +/* enable ucontrol for s390 */ > +#define KVM_S390_ENABLE_UCONTROL _IO(KVMIO, 0x49) > + > /* Device model IOC */ > #define KVM_CREATE_IRQCHIP _IO(KVMIO, 0x60) > #define KVM_IRQ_LINE _IOW(KVMIO, 0x61, struct kvm_irq_level) > #define KVM_CAP_S390_UCONTROL -- error compiling committee.c: too many arguments to function