From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41868) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vv9qm-0006Yt-TI for qemu-devel@nongnu.org; Mon, 23 Dec 2013 13:03:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Vv9qf-0003Rd-2F for qemu-devel@nongnu.org; Mon, 23 Dec 2013 13:03:32 -0500 Message-ID: <52B87AE8.5080501@suse.de> Date: Mon, 23 Dec 2013 19:03:20 +0100 From: =?ISO-8859-15?Q?Andreas_F=E4rber?= MIME-Version: 1.0 References: <1387813240-13499-1-git-send-email-aneesh.kumar@linux.vnet.ibm.com> In-Reply-To: <1387813240-13499-1-git-send-email-aneesh.kumar@linux.vnet.ibm.com> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH -V5] kvm: Add a new machine property kvm-type List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Aneesh Kumar K.V" , agraf@suse.de Cc: qemu-ppc@nongnu.org, pbonzini@redhat.com, paulus@samba.org, armbru@redhat.com, qemu-devel@nongnu.org Am 23.12.2013 16:40, schrieb Aneesh Kumar K.V: > From: "Aneesh Kumar K.V" >=20 > Targets like ppc64 support different typed of KVM, one which use "types" - Alex, please fix. :) > hypervisor mode and the other which doesn't. Add a new machine > property kvm-type that helps in selecting the respective ones There is no property being added in this patch, it's an "option". Please edit, also in subject. > We also add a new QEMUMachine callback get_vm_type that helps > in mapping the string representation of kvm type specified. >=20 > Signed-off-by: Aneesh Kumar K.V > --- > Changes from V4: > * Fix build failure for ppc{,64}-linux-user >=20 > hw/ppc/spapr.c | 19 +++++++++++++++++++ > include/hw/boards.h | 3 +++ > include/hw/xen/xen.h | 3 ++- > include/sysemu/kvm.h | 4 ++-- > include/sysemu/qtest.h | 3 ++- > kvm-all.c | 16 +++++++++++++--- > kvm-stub.c | 3 ++- > qtest.c | 2 +- > vl.c | 14 +++++++++----- > xen-all.c | 2 +- > xen-stub.c | 2 +- > 11 files changed, 55 insertions(+), 16 deletions(-) >=20 > diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c > index 7e53a5f97781..267a47d6cc4d 100644 > --- a/hw/ppc/spapr.c > +++ b/hw/ppc/spapr.c > @@ -1357,6 +1357,24 @@ static void ppc_spapr_init(QEMUMachineInitArgs *= args) > assert(spapr->fdt_skel !=3D NULL); > } > =20 > +static int spapr_kvm_type(const char *vm_type) > +{ > + if (!vm_type) { > + return 0; > + } > + > + if (!strcmp(vm_type, "HV")) { > + return 1; > + } > + > + if (!strcmp(vm_type, "PR")) { > + return 2; > + } > + > + hw_error("Unknown kvm-type specified '%s'", vm_type); error_report() - hw_error() would need \n IIRC and dumps CPU state, which seems useless at that point. > + exit(1); > +} > + > static QEMUMachine spapr_machine =3D { > .name =3D "pseries", > .desc =3D "pSeries Logical Partition (PAPR compliant)", > @@ -1367,6 +1385,7 @@ static QEMUMachine spapr_machine =3D { > .max_cpus =3D MAX_CPUS, > .no_parallel =3D 1, > .default_boot_order =3D NULL, > + .kvm_type =3D spapr_kvm_type, > }; > =20 > static void spapr_machine_init(void) [...] > diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h > index 3b25f27a7cc5..400a2682923e 100644 > --- a/include/sysemu/kvm.h > +++ b/include/sysemu/kvm.h > @@ -151,8 +151,8 @@ typedef struct KVMState KVMState; > extern KVMState *kvm_state; > =20 > /* external API */ > - Line dropped accidentally? I guess external API doesn't just apply to the two lines added... > -int kvm_init(void); > +typedef struct QEMUMachine QEMUMachine; > +int kvm_init(QEMUMachine *machine); > =20 > int kvm_has_sync_mmu(void); > int kvm_has_vcpu_events(void); > diff --git a/include/sysemu/qtest.h b/include/sysemu/qtest.h > index 112a661ac4b0..7185174a39b2 100644 > --- a/include/sysemu/qtest.h > +++ b/include/sysemu/qtest.h > @@ -23,7 +23,8 @@ static inline bool qtest_enabled(void) > return qtest_allowed; > } > =20 > -int qtest_init_accel(void); > +typedef struct QEMUMachine QEMUMachine; > +int qtest_init_accel(QEMUMachine *machine); > void qtest_init(const char *qtest_chrdev, const char *qtest_log); > =20 > static inline int qtest_available(void) > diff --git a/kvm-all.c b/kvm-all.c > index 393775459d9f..57472804fe44 100644 > --- a/kvm-all.c > +++ b/kvm-all.c > @@ -35,6 +35,8 @@ > #include "qemu/event_notifier.h" > #include "trace.h" > =20 > +#include "hw/boards.h" > + > /* This check must be after config-host.h is included */ > #ifdef CONFIG_EVENTFD > #include > @@ -1352,7 +1354,7 @@ static int kvm_max_vcpus(KVMState *s) > return (ret) ? ret : kvm_recommended_vcpus(s); > } > =20 > -int kvm_init(void) > +int kvm_init(QEMUMachine *machine) > { > static const char upgrade_note[] =3D > "Please upgrade to at least kernel 2.6.29 or recent kvm-kmod\n= " > @@ -1369,7 +1371,8 @@ int kvm_init(void) > KVMState *s; > const KVMCapabilityInfo *missing_cap; > int ret; > - int i; > + int i, type =3D 0; > + const char *kvm_type; > =20 > s =3D g_malloc0(sizeof(KVMState)); > =20 > @@ -1442,7 +1445,14 @@ int kvm_init(void) > nc++; > } > =20 > - s->vmfd =3D kvm_ioctl(s, KVM_CREATE_VM, 0); > + kvm_type =3D qemu_opt_get(qemu_get_machine_opts(), "kvm-type"); > + if (machine->kvm_type) { > + type =3D machine->kvm_type(kvm_type); > + } else if (kvm_type) { > + fprintf(stderr, "Invalid argument kvm-type=3D%s\n", kvm_type); error_report()? (without \n then) > + goto err; > + } > + s->vmfd =3D kvm_ioctl(s, KVM_CREATE_VM, type); > if (s->vmfd < 0) { > #ifdef TARGET_S390X > fprintf(stderr, "Please add the 'switch_amode' kernel paramete= r to " [snip] Almost all remarks could be edited into the patch file on the same line to avoid yet another respin. Andreas --=20 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 N=FCrnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imend=F6rffer; HRB 16746 AG N=FCrnbe= rg