From nobody Mon Feb 9 03:45:35 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.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 205.139.110.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=1576079928; cv=none; d=zohomail.com; s=zohoarc; b=hsZdtuaeFU2dK/7xMqq2cM0fYJtw7USKx/ZYBswwR2G+n6TBIzJPKyTNn7jNJUBsGltnX3nnrh5HDysOiYRRIfEB+IFepF5BueGs9CpTKcHj40M2avOeSbvAEnQgTIHdVemWxjQrjWGt08DRlM0J2VGAmP21Ytc48xR7zfLfe1o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576079928; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=0V0MmkMXyVj2QOcxDqFwACrCQo7PlXr90AQxJ+Ul15M=; b=StAVdQgDYu0b9DOo4AYLuQlBAdBbkDcczm+9L7aLm2vD+SVQ1P12sWI8jestCO15dz5+r9piiEE5nMPWCqVlaYHk26TOWfVcBLkYfH+X0ZuKNQnGQznbRB37Xb+Rg1M3Yv7VQFZVXF1Fx09tRr2wtVpUMLQVT5qvVbtOFMoaNj8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.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 [205.139.110.120]) by mx.zohomail.com with SMTPS id 1576079928658573.6594043763715; Wed, 11 Dec 2019 07:58:48 -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-158-Y9BMe775MIqMG0RLoHv1gg-1; Wed, 11 Dec 2019 10:58:43 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7AE1F911C8; Wed, 11 Dec 2019 15:58:38 +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 4BED160BA1; Wed, 11 Dec 2019 15:58:38 +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 05ED618089CD; Wed, 11 Dec 2019 15:58:38 +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 xBBFwavg018569 for ; Wed, 11 Dec 2019 10:58:36 -0500 Received: by smtp.corp.redhat.com (Postfix) id A339960303; Wed, 11 Dec 2019 15:58:36 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-112-62.ams2.redhat.com [10.36.112.62]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1018960BA1; Wed, 11 Dec 2019 15:58:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576079925; 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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=0V0MmkMXyVj2QOcxDqFwACrCQo7PlXr90AQxJ+Ul15M=; b=PWDaYwcEqs2LT/mJmh4Xl9hCW/DlHK38lhRqLHnq/EaO/x+Z7VsyUmyH57jskFOLwqxHi9 ak3eCem8mcw4VhV9i90dKfi+Yy5ms+w7k10rAO7SclZcXMKlrb2A7pY2wmne5MdT52529b /YHvZxRHZk7AWYE0NMJe7HZ0egwm09U= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Wed, 11 Dec 2019 15:58:22 +0000 Message-Id: <20191211155823.1704464-3-berrange@redhat.com> In-Reply-To: <20191211155823.1704464-1-berrange@redhat.com> References: <20191211155823.1704464-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Cc: Cole Robinson Subject: [libvirt] [PATCH v2 2/3] qemu: check os type / virt type / arch in validate callback 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.11 X-MC-Unique: Y9BMe775MIqMG0RLoHv1gg-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) Don't check os type / virt type / arch in the post-parse callback because we can't assume qemuCaps is non-NULL at this point. It also conceptually belongs to the validation callback. Signed-off-by: Daniel P. Berrang=C3=A9 --- src/qemu/qemu_domain.c | 42 ++++++++++++++++++++-------------------- tests/qemuxml2argvtest.c | 9 ++++++--- 2 files changed, 27 insertions(+), 24 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 27926c7670..3e1bd52d9f 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -4865,27 +4865,6 @@ qemuDomainDefPostParse(virDomainDefPtr def, return 1; } =20 - if (def->os.type !=3D VIR_DOMAIN_OSTYPE_HVM) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Emulator '%s' does not support os type '%s'"), - def->emulator, virDomainOSTypeToString(def->os.type= )); - return -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; - } - - 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 (def->os.bootloader || def->os.bootloaderArgs) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("bootloader is not supported by QEMU")); @@ -5142,6 +5121,27 @@ qemuDomainDefValidate(const virDomainDef *def, def->emulator))) goto cleanup; =20 + if (def->os.type !=3D VIR_DOMAIN_OSTYPE_HVM) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Emulator '%s' does not support os type '%s'"), + def->emulator, virDomainOSTypeToString(def->os.type= )); + goto cleanup; + } + + if (!virQEMUCapsIsArchSupported(qemuCaps, def->os.arch)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Emulator '%s' does not support arch '%s'"), + def->emulator, virArchToString(def->os.arch)); + goto cleanup; + } + + if (!virQEMUCapsIsVirtTypeSupported(qemuCaps, def->virtType)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Emulator '%s' does not support virt type '%s'"), + def->emulator, virDomainVirtTypeToString(def->virtT= ype)); + goto cleanup; + } + if (def->mem.min_guarantee) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("Parameter 'min_guarantee' not supported by QEMU.= ")); diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index ba4a92ec0a..8655db609e 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -2852,10 +2852,13 @@ mymain(void) QEMU_CAPS_NEC_USB_XHCI); =20 /* VM XML has invalid arch/ostype/virttype combo, but the SKIP flag - * will avoid the error. Still, we expect qemu driver to complain about - * missing machine error, and not crash */ + * will avoid the error during parse. This will cause us to fill in + * the missing machine type using the i386 binary, despite it being + * the wrong binary for the arch. We expect to get a failure about + * bad arch later when creating the pretend command. + */ DO_TEST_FULL("missing-machine", - ARG_FLAGS, FLAG_EXPECT_PARSE_ERROR | FLAG_EXPECT_FAILURE, + ARG_FLAGS, FLAG_EXPECT_FAILURE, ARG_PARSEFLAGS, VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE, ARG_QEMU_CAPS, NONE); =20 --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list