From nobody Mon May 6 16:56:07 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 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=1587040611; cv=none; d=zohomail.com; s=zohoarc; b=ZVP8iQ5OXPp/FQ/tYclwqHQD0uelRXjC3aNDEdcLGzSHv9Rj2wfesd8tXgE0H0S1DH5Jm7MbL9FANCjlgb/7IE632ftO579SW1JiKTuScEmmOZqvN5M3VymBwiq2XFsQE+vqpC4jBCDvjLZET5Y8oESmfyLGIhidCt3xinrH/pM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1587040611; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=dX32YiPjMGRvFdIF6VuwrfyKw8+3cttQCG0zTwQSq+c=; b=WvtxXr0FK2A3A+wuHfeaQmsSVQA0RKtX8mh9H+ZzddTlygKI+xezTVBfKpnWy9eteYMHQzt067jhUU5uLTKn4gZ6jPVCT+WO6eETy80wd2nHrDCrovJfzlPym4ZwNqh4p6G1Z+uW4uYI469IZNqXb8A+souBz84XtJ/IxSYwQYQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 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-delivery-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1587040611430766.8386537661714; Thu, 16 Apr 2020 05:36:51 -0700 (PDT) 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-275-Thm16RpZN1uQ91EEmb-sXg-1; Thu, 16 Apr 2020 08:36:48 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 64FE713FA; Thu, 16 Apr 2020 12:36:42 +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 9AB7A1036D14; Thu, 16 Apr 2020 12:36:41 +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 7A93318089CD; Thu, 16 Apr 2020 12:36:38 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 03GCab8J029288 for ; Thu, 16 Apr 2020 08:36:37 -0400 Received: by smtp.corp.redhat.com (Postfix) id B4092A099B; Thu, 16 Apr 2020 12:36:37 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.194.82]) by smtp.corp.redhat.com (Postfix) with ESMTP id EE908A1024 for ; Thu, 16 Apr 2020 12:36:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1587040610; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to: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=dX32YiPjMGRvFdIF6VuwrfyKw8+3cttQCG0zTwQSq+c=; b=a5+VncpDu3FN8ZcwzCMswMbns/9MHrG+/852/AcHrLEeW3ux1ChqLlFqNzzeJQ9WuJZa0j VCoNakm9ZZKEW7F1VHx89u2ncYk868ErBx2mP5DCLm3WATtTXhoCkpImBdD1Gya8OkH1+Q Yl+YDLcsGPdceOXEfEicliD9n+ZACLg= X-MC-Unique: Thm16RpZN1uQ91EEmb-sXg-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH] qemuDomainDefPostParse: Fail if unable to fill machine type Date: Thu, 16 Apr 2020 14:33:33 +0200 Message-Id: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com 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.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Previously, we used virCapabilitiesDomainDataLookup() to fill machine type in post parse callback if none was provided in the domain XML. If machine type couldn't be filled in an error was reported. After 4a4132b4625 we've changed it to virQEMUCapsGetPreferredMachine() which returns NULL, but we no longer report an error and proceed with the post parse callbacks processing. This may lead to a crash because the code later on assumes def->os.machine is not NULL. Fixes: 4a4132b4625 Signed-off-by: Michal Privoznik Reviewed-by: Pavel Mores --- src/qemu/qemu_domain.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 91e234d644..98ffd23a71 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -4973,6 +4973,14 @@ qemuDomainDefPostParse(virDomainDefPtr def, if (!def->os.machine) { const char *machine =3D virQEMUCapsGetPreferredMachine(qemuCaps, def->virtType= ); + if (!machine) { + virReportError(VIR_ERR_INVALID_ARG, + _("could not get preferred machine for %s type= =3D%s"), + def->emulator, + virDomainVirtTypeToString(def->virtType)); + return -1; + } + def->os.machine =3D g_strdup(machine); } =20 --=20 2.25.3