From nobody Tue Nov 26 09:41:54 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1575981803; cv=none; d=zohomail.com; s=zohoarc; b=cuT1w3hwVpAno3ZWyaKp/U9f0+CvXp9m6H9/XHUGHYpMeNHuCDTMJZghMt5v1RPnfd4EAuXJ3YUr1WoPxLcB9oW6Ns1psoGSayPZOdbeH1eyRl2vTiRwVTokK3Ab5ErZ6TfTOmlr58OytSpQaqha2hz9LUo7Fde8NrzAIO3LWLE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575981803; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=DA+lKeNWjohuAV25t7l36x6oGsWkCzgeC3pE4RgEgp8=; b=A33XkI5q76J+zdLaYcn5JXNbGV1iZfd6vfFGkKmhhF0PFChs+abkLelqroHFD9BdC6HY+5UsXRkDU6vfjOCaar/tBBFpI8D3M2k+lhPsBw5Lksa/F6qq54St027h1B9MGBmr6j1Yv4RrQlsG7cCHLjEIno0XDrM+OfQxHsqy7Gw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1575981803719866.5963228511537; Tue, 10 Dec 2019 04:43:23 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-189-265j815lOPCc05_J7XF4Og-1; Tue, 10 Dec 2019 07:43:20 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 35CAB800D41; Tue, 10 Dec 2019 12:43:14 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 01CD76FEE8; Tue, 10 Dec 2019 12:43:14 +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 BE11818089C8; Tue, 10 Dec 2019 12:43:12 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xBAChBI4019272 for ; Tue, 10 Dec 2019 07:43:11 -0500 Received: by smtp.corp.redhat.com (Postfix) id AB40B5C21A; Tue, 10 Dec 2019 12:43:11 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-112-61.ams2.redhat.com [10.36.112.61]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8400C5C1B0; Tue, 10 Dec 2019 12:43:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575981802; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=DA+lKeNWjohuAV25t7l36x6oGsWkCzgeC3pE4RgEgp8=; b=epBzvdKVJ7JzMMf7uLNR7yQg2gwd+vgwOg9WXu8rNzmoWZRPm23N/IesqSlv5SqfiGAj3H T2eDIUne2f5UlXOE2fwFTC65XYYnG90+Y9HZgGZkvBp+SRa2z/qCpaZSv3b7sjrErwFJ9g 8i+LtqP1scYhHx33fn3B8fr0zXwjUN0= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Tue, 10 Dec 2019 12:43:05 +0000 Message-Id: <20191210124305.933306-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Cc: Cole Robinson Subject: [libvirt] [PATCH] qemu: honour parseOpaque instead of refetching caps 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: 265j815lOPCc05_J7XF4Og-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) The use of the parseOpaque parameter was mistakenly removed in commit 4a4132b4625778cf80acb9c92d06351b44468ac3 Author: Daniel P. Berrang=C3=A9 Date: Tue Dec 3 10:49:49 2019 +0000 conf: don't use passed in caps in post parse method causing the method to re-fetch qemuCaps that were already just fetched and put into parseOpaque. This is inefficient when parsing incoming XML, but for live XML this is more serious as it means we use the capabilities for the current QEMU binary on disk, rather than the running QEMU. That commit, however, did have a useful side effect of fixing a crasher bug in the qemu post parse callback introduced by commit 5e939cea896fb3373a6f68f86e325c657429ed3d Author: Jiri Denemark Date: Thu Sep 26 18:42:02 2019 +0200 qemu: Store default CPU in domain XML The qemuDomainDefSetDefaultCPU() method in that patch did not allow for the possibility that qemuCaps would be NULL and thus resulted in a SEGV. This shows a risk in letting each check in the post parse callback look for qemuCaps =3D=3D NULL. The safer option is to check once upfront and immediately stop (postpone) further validation. Honouring the cached caps for the live status XML, highlights a second flaw, which is that it shouldn't check the virt type or arch for running guests. The info needed to check this is not in the cache caps, only the list of flags are populated. Thus some of the post parse logic is made to only run for inactive guests. This showed a bug in one test data file which lacked an ID attribute for the live guest. Signed-off-by: Daniel P. Berrang=C3=A9 --- src/qemu/qemu_domain.c | 52 +++++++++++-------- .../qemustatusxml2xmldata/vcpus-multi-in.xml | 2 +- 2 files changed, 31 insertions(+), 23 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 6f53e17b6a..2abe93c829 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -4703,16 +4703,17 @@ static int qemuDomainDefPostParse(virDomainDefPtr def, unsigned int parseFlags, void *opaque, - void *parseOpaque G_GNUC_UNUSED) + void *parseOpaque) { virQEMUDriverPtr driver =3D opaque; g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); - g_autoptr(virQEMUCaps) qemuCaps =3D NULL; + /* Note that qemuCaps may be NULL when this function is called. This + * function shall not fail in that case. It will be re-run on VM start= up + * with the capabilities populated. */ + virQEMUCapsPtr qemuCaps =3D parseOpaque; =20 - if (!(qemuCaps =3D virQEMUCapsCacheLookup(driver->qemuCapsCache, - def->emulator))) { + if (!qemuCaps) return 1; - } =20 if (def->os.type !=3D VIR_DOMAIN_OSTYPE_HVM) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, @@ -4721,18 +4722,31 @@ qemuDomainDefPostParse(virDomainDefPtr def, return -1; } =20 - if (!virQEMUCapsIsArchSupported(qemuCaps, def->os.arch)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Emulator '%s' does not support arch '%s'"), - def->emulator, virArchToString(def->os.arch)); - return -1; - } + if (def->id =3D=3D -1) { + if (!virQEMUCapsIsArchSupported(qemuCaps, def->os.arch)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Emulator '%s' does not support arch '%s'"), + def->emulator, virArchToString(def->os.arch)); + return -1; + } =20 - if (!virQEMUCapsIsVirtTypeSupported(qemuCaps, def->virtType)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Emulator '%s' does not support virt type '%s'"), - def->emulator, virDomainVirtTypeToString(def->virtT= ype)); - return -1; + if (!virQEMUCapsIsVirtTypeSupported(qemuCaps, def->virtType)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Emulator '%s' does not support virt type '%s= '"), + def->emulator, virDomainVirtTypeToString(def->v= irtType)); + return -1; + } + if (!def->os.machine) { + const char *machine =3D virQEMUCapsGetPreferredMachine(qemuCap= s, + def->virt= Type); + def->os.machine =3D g_strdup(machine); + } + } else { + if (!def->os.machine) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("missing machine type")); + return -1; + } } =20 if (def->os.bootloader || def->os.bootloaderArgs) { @@ -4741,12 +4755,6 @@ qemuDomainDefPostParse(virDomainDefPtr def, return -1; } =20 - if (!def->os.machine) { - const char *machine =3D virQEMUCapsGetPreferredMachine(qemuCaps, - def->virtType= ); - def->os.machine =3D g_strdup(machine); - } - qemuDomainNVRAMPathGenerate(cfg, def); =20 if (qemuDomainDefAddDefaultDevices(def, qemuCaps) < 0) diff --git a/tests/qemustatusxml2xmldata/vcpus-multi-in.xml b/tests/qemusta= tusxml2xmldata/vcpus-multi-in.xml index 11ec74ecf8..be48c55fe0 100644 --- a/tests/qemustatusxml2xmldata/vcpus-multi-in.xml +++ b/tests/qemustatusxml2xmldata/vcpus-multi-in.xml @@ -310,7 +310,7 @@ -2 - + QEMUGuest1 c7a5fdbd-edaf-9455-926a-d65c16db1809 219100 --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list