From nobody Fri May 17 10:13:39 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 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=1671702509; cv=none; d=zohomail.com; s=zohoarc; b=F8Ve04gdhgH6xzDiPJ0AToyjfxy54YOF4YGfvFBM2pqstW+rZsF9IKGpsMqKgzv6dQYW4iUUIxYjw899aPtbrIbxALGL3KX40Q0b/br9rAzAfzloDx0Ui6z9vOefTedHx3HX+oqYkX5st7axjpoKN64PwFOSuSvPK8Yw3dQJ9MI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1671702509; 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=TD0MGYh6JtNHIC265+kkp5/py22S2BtYmJmuka75Jv0=; b=a2zQYcPT024griVc5AyaWIO+sIT7zx2EbhiSa5lIQJ5t4vqETvEhfkAKNka3Mm0kwmy/rUU/+4OZle29aaMlVqOWPjPsHuXUZzr4rOWFZKq/c2WgyPiVWZJNwng5QtgMyV6Ba9IjfjegPWqRMh9Lijs64ygneMcJQmZPDJCLeTY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1671702509239842.9940640818729; Thu, 22 Dec 2022 01:48:29 -0800 (PST) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-184-9Yjw9IIbM0aXZbRmxlDCcA-1; Thu, 22 Dec 2022 04:48:24 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id AF1BF3814950; Thu, 22 Dec 2022 09:48:22 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 62297112132C; Thu, 22 Dec 2022 09:48:20 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 465E019465B1; Thu, 22 Dec 2022 09:48:20 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 9CAD319465A8 for ; Thu, 22 Dec 2022 09:48:18 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 8CF4EC16029; Thu, 22 Dec 2022 09:48:18 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 35807C16028 for ; Thu, 22 Dec 2022 09:48:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1671702508; 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=TD0MGYh6JtNHIC265+kkp5/py22S2BtYmJmuka75Jv0=; b=BiH3ww89ReB+gevtuwmL3R0A686/zu6oZdgsYCkSJqjRIaBRPAqQw0ddQk+w2YT1w/R0GV nQ+1l9B4F6ewmwgkQsJmYVChTYefW7qC8u2qfLUjcRLWYBV86ZuADpjABsM9xOuGFtYA/y uXG4JNu32WxflgY7YSVEu/2au12vly8= X-MC-Unique: 9Yjw9IIbM0aXZbRmxlDCcA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH] virQEMUDriverGetDomainCapabilities: Validate machine type Date: Thu, 22 Dec 2022 10:48:14 +0100 Message-Id: <3bcb849655732d83651876f4e1942f623fe5e7de.1671702494.git.mprivozn@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1671702511541100001 Content-Type: text/plain; charset="utf-8"; x-default="true" When calling virConnectGetDomainCapabilities() (exposed as virsh domcapabilities) users have option to specify whatever sub-set of { emulatorbin, arch, machine, virttype } they want. Then we have a logic (hidden in virQEMUCapsCacheLookupDefault()) that picks qemuCaps that satisfy values passed by user. And whatever was not specified is then set to the default value as specified by picked qemuCaps. For instance: if no machine type was provided but emulatorbin was, then the machine type is set to the default one as defined by the emulatorbin. Or, when just virttype was set then the remaining three values are set to their respective defaults. Except, we have a crasher in this case: # virsh domcapabilities --virttype hvf error: Disconnected from qemu:///system due to end of file error: failed to get emulator capabilities error: End of file while reading data: Input/output error This is because for 'hvf' virttype (at least my) QEMU does not have any machine type. Therefore, @machine is set to NULL and the rest of the code does not expect that. Signed-off-by: Michal Privoznik --- src/qemu/qemu_conf.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index ae5bbcd138..cbd339f594 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -1454,6 +1454,13 @@ virQEMUDriverGetDomainCapabilities(virQEMUDriver *dr= iver, g_autoptr(virDomainCaps) domCaps =3D NULL; const char *path =3D virQEMUCapsGetBinary(qemuCaps); =20 + if (!virQEMUCapsIsMachineSupported(qemuCaps, virttype, machine)) { + virReportError(VIR_ERR_INVALID_ARG, + _("the machine '%s' is not supported by emulator '%= s'"), + NULLSTR(machine), path); + return NULL; + } + if (!(domCaps =3D virDomainCapsNew(path, machine, arch, virttype))) return NULL; =20 --=20 2.38.2