From nobody Sun Feb 8 06:53:53 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=1576849660; cv=none; d=zohomail.com; s=zohoarc; b=CVp2JqAwTZCAQs+9rZRTJZBFaiglF+tEUsH3awjCjLM+iLPT961leXtB/Vzt6FJmQot4At39Bs7nUMVLa3Houd6cjgWjrLuP8MPZGEQ8gsU0iMnfpi5A7qrBMwIB+PHb9AQS4axThWui2OGXB/GWWAoahWPw3Xo/arg71a8fcwM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576849660; 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=UEnyTFM5Yp5pVV7FBv8Yo5BfoL15vzR3bVKzAubWGcU=; b=NdH1k1uqcYMreOGXq3OnjYwvlFg7LYNgXPrTlhSoZy2tfFnrULly+jmzQNgNrdSGYUZ9SbM4uhQEK9Z5DgB2Gsi22F55LApqbubRLk2vdaos1W1QmPdYYEAuV6dA9fnvIHOWj4Ckq0NJWpJWZOdbHMLkCRjzs9LI46atczYlquI= 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 1576849660032681.7291944866446; Fri, 20 Dec 2019 05:47:40 -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-368-k8epu-3nO-ONhReryyiaYQ-1; Fri, 20 Dec 2019 08:47:36 -0500 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 1DD8A18AAFD0; Fri, 20 Dec 2019 13:47:31 +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 EA3151001281; Fri, 20 Dec 2019 13:47:30 +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 AD82318089CE; Fri, 20 Dec 2019 13:47:30 +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 xBKDl5P2029880 for ; Fri, 20 Dec 2019 08:47:05 -0500 Received: by smtp.corp.redhat.com (Postfix) id 29AF363BAC; Fri, 20 Dec 2019 13:47:05 +0000 (UTC) Received: from dhcp-16-105.lcy.redhat.com (unknown [10.42.16.105]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9D60263B89; Fri, 20 Dec 2019 13:47:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576849658; 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=UEnyTFM5Yp5pVV7FBv8Yo5BfoL15vzR3bVKzAubWGcU=; b=dUAT4G0WPQafK0+wCXqodzsSmD+wnlnj+DLWJUI00oLK1ZmjyNODEUn1YsMDgx9mY2m4FE eK52ue8a79jEC4E9K+EUqMQK+nvRGwtuC1QblkP+R6vP8cJJg8Y0vlWo7ZX85/EjYOqJAr QZypyRSiDnZuOWgwriQN3EHn5WS2hew= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Fri, 20 Dec 2019 13:47:02 +0000 Message-Id: <20191220134703.2164946-3-berrange@redhat.com> In-Reply-To: <20191220134703.2164946-1-berrange@redhat.com> References: <20191220134703.2164946-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 Subject: [libvirt] [PATCH v2 2/3] qemu: add qemu caps constructor which takes binary name 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-MC-Unique: k8epu-3nO-ONhReryyiaYQ-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) Simplify repeated code patterns by providing a new constructor taking the QEMU binary name. Signed-off-by: Daniel P. Berrang=C3=A9 --- src/qemu/qemu_capabilities.c | 23 ++++++++++++++--------- src/qemu/qemu_capabilities.h | 1 + 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index cc6d9bbd44..2ab7ead92e 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -1649,6 +1649,17 @@ virQEMUCapsNew(void) } =20 =20 +virQEMUCapsPtr +virQEMUCapsNewBinary(const char *binary) +{ + virQEMUCapsPtr qemuCaps =3D virQEMUCapsNew(); + + qemuCaps->binary =3D g_strdup(binary); + + return qemuCaps; +} + + void virQEMUCapsSetInvalidation(virQEMUCapsPtr qemuCaps, bool enabled) @@ -1750,7 +1761,7 @@ virQEMUCapsAccelCopy(virQEMUCapsAccelPtr dst, =20 virQEMUCapsPtr virQEMUCapsNewCopy(virQEMUCapsPtr qemuCaps) { - virQEMUCapsPtr ret =3D virQEMUCapsNew(); + virQEMUCapsPtr ret =3D virQEMUCapsNewBinary(qemuCaps->binary); size_t i; =20 if (!ret) @@ -1760,8 +1771,6 @@ virQEMUCapsPtr virQEMUCapsNewCopy(virQEMUCapsPtr qemu= Caps) ret->usedQMP =3D qemuCaps->usedQMP; ret->kvmSupportsNesting =3D qemuCaps->kvmSupportsNesting; =20 - ret->binary =3D g_strdup(qemuCaps->binary); - ret->ctime =3D qemuCaps->ctime; =20 virBitmapCopy(ret->flags, qemuCaps->flags); @@ -4950,11 +4959,9 @@ virQEMUCapsNewForBinaryInternal(virArch hostArch, virQEMUCapsPtr qemuCaps; struct stat sb; =20 - if (!(qemuCaps =3D virQEMUCapsNew())) + if (!(qemuCaps =3D virQEMUCapsNewBinary(binary))) goto error; =20 - qemuCaps->binary =3D g_strdup(binary); - /* We would also want to check faccessat if we cared about ACLs, * but we don't. */ if (stat(binary, &sb) < 0) { @@ -5021,14 +5028,12 @@ virQEMUCapsLoadFile(const char *filename, const char *binary, void *privData) { - virQEMUCapsPtr qemuCaps =3D virQEMUCapsNew(); + virQEMUCapsPtr qemuCaps =3D virQEMUCapsNewBinary(binary); virQEMUCapsCachePrivPtr priv =3D privData; =20 if (!qemuCaps) return NULL; =20 - qemuCaps->binary =3D g_strdup(binary); - if (virQEMUCapsLoadCache(priv->hostArch, qemuCaps, filename) < 0) goto error; =20 diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index 7488b9ddb8..70225926bf 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -544,6 +544,7 @@ typedef virQEMUCaps *virQEMUCapsPtr; G_DEFINE_AUTOPTR_CLEANUP_FUNC(virQEMUCaps, virObjectUnref); =20 virQEMUCapsPtr virQEMUCapsNew(void); +virQEMUCapsPtr virQEMUCapsNewBinary(const char *binary); =20 void virQEMUCapsSetInvalidation(virQEMUCapsPtr qemuCaps, bool enabled); --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list