From nobody Wed Feb 11 01:27:44 2026 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=1575469322; cv=none; d=zohomail.com; s=zohoarc; b=SBQWGWZnwXX36xjcoM4XTkQC9y8n+QOCv94R6gLYj6wVnlpdzNi+zYarMlRwstrlTPZB26HzPPShM4YUu4LsGyj9fvkZlgQsN2+qCg1fm1VEyK0uqVQ7m3zO9twYpeZJVNCRKQS1JosOlfL11VeGwDlLR41QGp6DZkqY2wcRpl0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575469322; h=Content-Type:Content-Transfer-Encoding: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=wEEkExoeUac8IQYTup2DTMvUu/Y/C+X9uJbBlv3sEPE=; b=h3v6QY1fI8MlmTojbbDi71uEYdj9SVhyScyiR9E111gCYsE8pFbC1ZXKzBXBI1A4rTjmUQG7Ea5nomadbZvR8qyeEF+sysnMMC1Rd4lCocFJpgSjf4FRR4xStYlXI5tVQwGI7+Z7VFEyUjUGvZwFDWr6NSZaxFdegyZyg2xNlcU= 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 1575469322462551.6645859163477; Wed, 4 Dec 2019 06:22:02 -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-257-5RuDMxZUNUqT9evHDVUimQ-1; Wed, 04 Dec 2019 09:21:59 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9FEBE8D0931; Wed, 4 Dec 2019 14:21:52 +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 7355719C68; Wed, 4 Dec 2019 14:21:52 +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 331CF62D12; Wed, 4 Dec 2019 14:21:52 +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 xB4ELaXv008185 for ; Wed, 4 Dec 2019 09:21:36 -0500 Received: by smtp.corp.redhat.com (Postfix) id 9CDCD691A2; Wed, 4 Dec 2019 14:21:36 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-112-55.ams2.redhat.com [10.36.112.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id DE7DD67E62; Wed, 4 Dec 2019 14:21:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575469321; 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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=wEEkExoeUac8IQYTup2DTMvUu/Y/C+X9uJbBlv3sEPE=; b=R/ohDAxQ1+fcWlgXem9E/R30mW9O+gSOpbSqidCpbXHRRR3ExEJ8gYpMtJHwWlHj+D+F/o 6PaD1VxSXMeFNFva+6cDjbJY+jfDGfvHCyj3ClmCid9oVaCZj5NHEkkqcUrofJg6OR4Zn0 vCu+P+kWRHs/ptOKUGVnvVnOPMQHZ/o= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Wed, 4 Dec 2019 14:20:55 +0000 Message-Id: <20191204142113.2961028-13-berrange@redhat.com> In-Reply-To: <20191204142113.2961028-1-berrange@redhat.com> References: <20191204142113.2961028-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 12/30] conf: drop virCapsPtr param from basic post parse 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.84 on 10.5.11.23 X-MC-Unique: 5RuDMxZUNUqT9evHDVUimQ-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 QEMU impl of the callback can directly use the QEMU capabilities cache to resolve the emulator binary name, allowing virCapsPtr to be dropped. Signed-off-by: Daniel P. Berrang=C3=A9 --- src/conf/domain_conf.c | 2 +- src/conf/domain_conf.h | 1 - src/qemu/qemu_capabilities.c | 28 ++++++++++++++++++++-------- src/qemu/qemu_capabilities.h | 2 ++ src/qemu/qemu_domain.c | 11 +++++++---- tests/testutilsqemu.c | 16 ++++++++++++++++ 6 files changed, 46 insertions(+), 14 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 8dd1ff1017..7327752810 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -5824,7 +5824,7 @@ virDomainDefPostParse(virDomainDefPtr def, =20 /* call the basic post parse callback */ if (xmlopt->config.domainPostParseBasicCallback) { - ret =3D xmlopt->config.domainPostParseBasicCallback(def, caps, + ret =3D xmlopt->config.domainPostParseBasicCallback(def, xmlopt->config.p= riv); =20 if (virDomainDefPostParseCheckFailure(def, parseFlags, ret) < 0) diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 7e925f45d8..cdbd42351f 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2627,7 +2627,6 @@ typedef enum { * parseOpaque is used. This callback is run prior to * virDomainDefPostParseCallback. */ typedef int (*virDomainDefPostParseBasicCallback)(virDomainDefPtr def, - virCapsPtr caps, void *opaque); =20 /* Called once after everything else has been parsed, for adjusting diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 7a62dfb1a2..bfe59a1eff 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -799,16 +799,12 @@ virQEMUCapsFindBinaryForArch(virArch hostarch, return ret; } =20 -static int -virQEMUCapsInitGuest(virCapsPtr caps, - virFileCachePtr cache, - virArch hostarch, - virArch guestarch) + +char * +virQEMUCapsGetDefaultEmulator(virArch hostarch, + virArch guestarch) { char *binary =3D NULL; - virQEMUCapsPtr qemuCaps =3D NULL; - int ret =3D -1; - /* Check for existence of base emulator, or alternate base * which can be used with magic cpu choice */ @@ -819,6 +815,22 @@ virQEMUCapsInitGuest(virCapsPtr caps, if (virQEMUCapsGuestIsNative(hostarch, guestarch) && !binary) binary =3D g_strdup("/usr/libexec/qemu-kvm"); =20 + return binary; +} + + +static int +virQEMUCapsInitGuest(virCapsPtr caps, + virFileCachePtr cache, + virArch hostarch, + virArch guestarch) +{ + char *binary =3D NULL; + virQEMUCapsPtr qemuCaps =3D NULL; + int ret =3D -1; + + binary =3D virQEMUCapsGetDefaultEmulator(hostarch, guestarch); + /* Ignore binary if extracting version info fails */ if (binary) { if (!(qemuCaps =3D virQEMUCapsCacheLookup(cache, binary))) { diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index a8a5c38d73..9b380574f5 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -627,6 +627,8 @@ const char *virQEMUCapsGetMachineDefaultCPU(virQEMUCaps= Ptr qemuCaps, void virQEMUCapsFilterByMachineType(virQEMUCapsPtr qemuCaps, virDomainVirtType virtType, const char *machineType); +char * virQEMUCapsGetDefaultEmulator(virArch hostarch, + virArch guestarch); =20 virFileCachePtr virQEMUCapsCacheNew(const char *libDir, const char *cacheDir, diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 362d644475..3c06b8a104 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -4677,13 +4677,16 @@ qemuDomainDefTsegPostParse(virDomainDefPtr def, =20 static int qemuDomainDefPostParseBasic(virDomainDefPtr def, - virCapsPtr caps, void *opaque G_GNUC_UNUSED) { + virQEMUDriverPtr driver =3D opaque; + /* check for emulator and create a default one if needed */ - if (!def->emulator && - !(def->emulator =3D virDomainDefGetDefaultEmulator(def, caps))) - return 1; + if (!def->emulator) { + if (!(def->emulator =3D virQEMUCapsGetDefaultEmulator( + driver->hostarch, def->os.arch))) + return 1; + } =20 return 0; } diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c index c24b3098a5..38be2cfe42 100644 --- a/tests/testutilsqemu.c +++ b/tests/testutilsqemu.c @@ -93,6 +93,22 @@ static const char *const *kvm_machines[VIR_ARCH_LAST] = =3D { [VIR_ARCH_S390X] =3D s390x_machines, }; =20 + +char * +virFindFileInPath(const char *file) +{ + if (g_str_has_prefix(file, "qemu-system") || + g_str_equal(file, "qemu-kvm")) { + return g_strdup_printf("/usr/bin/%s", file); + } + + /* Nothing in tests should be relying on real files + * in host OS, so we return NULL as to try to force + * an error in such a case + */ + return NULL; +} + static int testQemuAddGuest(virCapsPtr caps, virArch arch) --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list