From nobody Sat May 4 21:45:43 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1516899011655800.852390261113; Thu, 25 Jan 2018 08:50:11 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C592732F8A; Thu, 25 Jan 2018 16:50:09 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 99D97600CC; Thu, 25 Jan 2018 16:50:09 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 14CA33FB19; Thu, 25 Jan 2018 16:50:09 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w0PGjuKJ024294 for ; Thu, 25 Jan 2018 11:45:56 -0500 Received: by smtp.corp.redhat.com (Postfix) id AC4B8600D1; Thu, 25 Jan 2018 16:45:56 +0000 (UTC) Received: from inaba.usersys.redhat.com (unknown [10.43.2.98]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 335D86017B for ; Thu, 25 Jan 2018 16:45:53 +0000 (UTC) From: Andrea Bolognani To: libvir-list@redhat.com Date: Thu, 25 Jan 2018 17:45:51 +0100 Message-Id: <20180125164551.10058-1-abologna@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH] qemu: Add USB and memory balloon by default for aarch64/virt guests X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Thu, 25 Jan 2018 16:50:10 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Basically all existing guest types, regardless of the architectur, get both a USB controller and a virtio memory balloon by default. s390 guests are an exception, for the very good reason that they don't support USB at all; the other exception is aarch64/virt guests, but in the latter case isn't a compelling reason for them to deviate from the widely adopted convention, especially since: * x86/q35 guests, which aarch64/virt guests are for the most part identical to, add these devices by default; * it's trivial to opt out of both default devices by setting model=3D'none'; * higher level applications such as Nova expect at least the USB controller to be present. So add it by default for newly-defined guests. Existing guests will, of course, be left unchanged. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=3D1538637 Signed-off-by: Andrea Bolognani --- src/qemu/qemu_domain.c | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 6b4bd3cca..f1c3b3d1e 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -2630,7 +2630,8 @@ qemuDomainDefAddImplicitInputDevice(virDomainDef *def) =20 static int qemuDomainDefAddDefaultDevices(virDomainDefPtr def, - virQEMUCapsPtr qemuCaps) + virQEMUCapsPtr qemuCaps, + unsigned int parseFlags) { bool addDefaultUSB =3D true; int usbModel =3D -1; /* "default for machinetype" */ @@ -2680,10 +2681,33 @@ qemuDomainDefAddDefaultDevices(virDomainDefPtr def, =20 case VIR_ARCH_ARMV7L: case VIR_ARCH_AARCH64: - addDefaultUSB =3D false; - addDefaultMemballoon =3D false; - if (qemuDomainIsVirt(def)) + if (qemuDomainIsVirt(def)) { + /* All mach-virt guests get a PCIe Root, if supported by + * the QEMU binary */ addPCIeRoot =3D virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_GPEX= ); + } + + if (qemuDomainIsVirt(def) && + parseFlags & VIR_DOMAIN_DEF_PARSE_ABI_UPDATE) { + /* In addition to PCIe Root, newly-defined mach-virt guests + * also get a couple more devices so that they're more similar + * to guests on other architectures, notably x86/q35: + * + * 1) a USB3 controller, if supported by the QEMU binary; + * 2) a virtio memory balloon, as per the defaults defined + * above. + */ + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_QEMU_XHCI)) + usbModel =3D VIR_DOMAIN_CONTROLLER_MODEL_USB_QEMU_XHCI; + else + addDefaultUSB =3D false; + } else { + /* Other ARM guests (and existing mach-virt guests, in order + * to preserve guest ABI compatibility) don't get a PCIe Root, + * a USB controller or a memory balloon */ + addDefaultUSB =3D false; + addDefaultMemballoon =3D false; + } break; =20 case VIR_ARCH_PPC64: @@ -3187,7 +3211,7 @@ qemuDomainDefPostParse(virDomainDefPtr def, goto cleanup; } =20 - if (qemuDomainDefAddDefaultDevices(def, qemuCaps) < 0) + if (qemuDomainDefAddDefaultDevices(def, qemuCaps, parseFlags) < 0) goto cleanup; =20 if (qemuCanonicalizeMachine(def, qemuCaps) < 0) --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list