From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jan Kiszka Subject: Re: [PATCH v2] qemu-kvm: Switch to upstream -enable-kvm semantics Date: Sun, 02 Jan 2011 11:15:33 +0100 Message-ID: <4D205045.6000308@web.de> References: Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enigAF2865AE885A431D3EDE63FC" Cc: kvm@vger.kernel.org, "Daniel P. Berrange" , "Richard W. M. Jones" , Anthony Liguori , Avi Kivity To: Markus Armbruster Return-path: Received: from fmmailgate01.web.de ([217.72.192.221]:36991 "EHLO fmmailgate01.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753727Ab1ABKPl (ORCPT ); Sun, 2 Jan 2011 05:15:41 -0500 In-Reply-To: Sender: kvm-owner@vger.kernel.org List-ID: This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigAF2865AE885A431D3EDE63FC Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Am 22.12.2010 13:33, Markus Armbruster wrote: > We currently enable KVM by default, and when it's not available, we > print a message and fall back to TCG. Option -enable-kvm is ignored. > Option -no-kvm suppresses KVM. >=20 > Upstream works differently: KVM is off by default, -enable-kvm > switches it on. -enable-kvm terminates the process unsuccessfully if > KVM is not available. >=20 > upstream qemu | default |-enable-kvm > ----------------+-----------+----------- > KVM available | disabled | enabled > KVM unavailable | disabled | fail >=20 > qemu-kvm | default |-enable-kvm| -no-kvm > ----------------+-----------+-----------+---------- > KVM available | enabled* | enabled | disabled > KVM unavailable | disabled | disabled* | disabled >=20 > * differs from upstream >=20 > Users of qemu and qemu-kvm need to be aware of these differences to > enable / disable use of KVM reliably. This is bothersome. >=20 > Consider -enable-kvm when KVM is unavailable: If the user expects > qemu-kvm behavior (fall back), but qemu fails, he'll likely be > surprised and unhappy. If the user expects upstream behavior (fail), > but qemu-kvm falls back to TCG, the guest runs slow as molasses, and > the user will likely be confused and unhappy (unless he spots and > understands the "disable KVM" message). >=20 > Eventually, we'll sort this upstream with -accel (defaults tied to > machine type). Until then, this patch reduces the difference to > upstream so that most users shouldn't need to be aware of them. >=20 > Make -enable-kvm behave just like in upstream: enable KVM, fail if not > available. But retain current default behavior: enable KVM, fall back > to TCG. >=20 > qemu-kvm new | default |-enable-kvm| -no-kvm > ----------------+-----------+-----------+----------- > KVM available | enabled* | enabled | disabled > KVM unavailable | disabled | fail+ | disabled >=20 > * differs from upstream > + changed by this patch >=20 > Bonus fix: -no-kvm -enable-kvm now enables KVM. Before, it disabled it= =2E >=20 > Signed-off-by: Markus Armbruster > --- > vl.c | 22 +++++++++------------- > 1 files changed, 9 insertions(+), 13 deletions(-) >=20 > diff --git a/vl.c b/vl.c > index e3c8919..1958e01 100644 > --- a/vl.c > +++ b/vl.c > @@ -247,7 +247,7 @@ static void *boot_set_opaque; > static NotifierList exit_notifiers =3D > NOTIFIER_LIST_INITIALIZER(exit_notifiers); > =20 > -int kvm_allowed =3D 1; > +int kvm_allowed =3D -1; > uint32_t xen_domid; > enum xen_mode xen_mode =3D XEN_EMULATE; > =20 > @@ -2436,10 +2436,8 @@ int main(int argc, char **argv, char **envp) > case QEMU_OPTION_smbios: > do_smbios_option(optarg); > break; > -#ifdef OBSOLETE_KVM_IMPL > case QEMU_OPTION_enable_kvm: > kvm_allowed =3D 1; > -#endif > break; > case QEMU_OPTION_no_kvm: > kvm_allowed =3D 0; > @@ -2789,19 +2787,17 @@ int main(int argc, char **argv, char **envp) > if (kvm_allowed) { > int ret =3D kvm_init(smp_cpus); > if (ret < 0) { > -#if defined(OBSOLETE_KVM_IMPL) || defined(CONFIG_NO_CPU_EMULATION) > - if (!kvm_available()) { > - printf("KVM not supported for this target\n"); > - } else { > - fprintf(stderr, "failed to initialize KVM: %s\n", stre= rror(-ret)); > + if (kvm_allowed > 0) { > + if (!kvm_available()) { > + printf("KVM not supported for this target\n"); > + } else { > + fprintf(stderr, "failed to initialize KVM: %s\n", = strerror(-ret)); > + } > + exit(1); > } > - exit(1); > -#endif > -#ifdef CONFIG_KVM > fprintf(stderr, "Could not initialize KVM, will disable KV= M support\n"); > - kvm_allowed =3D 0; > -#endif > } > + kvm_allowed =3D ret >=3D 0; > } > =20 > if (qemu_init_main_loop()) { Does any qemu-kvm user rely on the automatic fallback to TCG if KVM initialization fails? If not, then just set kvm_allowed to 1 in qemu-kvm and leave the rest as upstream provides it. This fallback is really annoying, specifically as the only point of qemu-kvm is, well, running over KVM. Jan --------------enigAF2865AE885A431D3EDE63FC Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.15 (GNU/Linux) Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org/ iEYEARECAAYFAk0gUEoACgkQitSsb3rl5xRXawCdG7IrtCqfVkzyGmfCQKhxYuma xBoAnim/bDqSfdPYKX6YNEDj2LXEiDHn =Hf+e -----END PGP SIGNATURE----- --------------enigAF2865AE885A431D3EDE63FC--