From nobody Fri May 16 03:28:33 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1499690836722328.6569903221464; Mon, 10 Jul 2017 05:47:16 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5D17F3B738; Mon, 10 Jul 2017 12:47:15 +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 321AD17A95; Mon, 10 Jul 2017 12:47:15 +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 D521D27E; Mon, 10 Jul 2017 12:47:14 +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 v6ACl0TN024859 for ; Mon, 10 Jul 2017 08:47:00 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6737F17A6B; Mon, 10 Jul 2017 12:47:00 +0000 (UTC) Received: from antique-work.brq.redhat.com (unknown [10.43.2.41]) by smtp.corp.redhat.com (Postfix) with ESMTP id E39F35C6A1 for ; Mon, 10 Jul 2017 12:46:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 5D17F3B738 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 5D17F3B738 From: Pavel Hrdina To: libvir-list@redhat.com Date: Mon, 10 Jul 2017 14:46:44 +0200 Message-Id: <386aaa5e2bf3f12f75eacfd15f5c97a4ab0da38d.1499690733.git.phrdina@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 05/11] qemu: move virQEMUCapsIsValid before its usage and make it static 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Mon, 10 Jul 2017 12:47:15 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Pavel Hrdina Reviewed-by: Jiri Denemark --- src/qemu/qemu_capabilities.c | 112 +++++++++++++++++++++------------------= ---- src/qemu/qemu_capabilities.h | 5 -- 2 files changed, 56 insertions(+), 61 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index c9c28da556..8a2a73dc5b 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -4282,6 +4282,62 @@ virQEMUCapsReset(virQEMUCapsPtr qemuCaps) } =20 =20 +static bool +virQEMUCapsIsValid(virQEMUCapsPtr qemuCaps, + time_t qemuctime, + uid_t runUid, + gid_t runGid) +{ + bool kvmUsable; + + if (!qemuCaps->binary) + return true; + + if (!qemuctime) { + struct stat sb; + + if (stat(qemuCaps->binary, &sb) < 0) { + char ebuf[1024]; + VIR_DEBUG("Failed to stat QEMU binary '%s': %s", + qemuCaps->binary, + virStrerror(errno, ebuf, sizeof(ebuf))); + return false; + } + qemuctime =3D sb.st_ctime; + } + + if (qemuctime !=3D qemuCaps->ctime) { + VIR_DEBUG("Outdated capabilities for '%s': QEMU binary changed " + "(%lld vs %lld)", + qemuCaps->binary, + (long long) qemuctime, (long long) qemuCaps->ctime); + return false; + } + + kvmUsable =3D virFileAccessibleAs("/dev/kvm", R_OK | W_OK, + runUid, runGid) =3D=3D 0; + + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM) && + virQEMUCapsGet(qemuCaps, QEMU_CAPS_ENABLE_KVM) && + kvmUsable) { + VIR_DEBUG("KVM was not enabled when probing '%s', " + "but it should be usable now", + qemuCaps->binary); + return false; + } + + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM) && + !kvmUsable) { + VIR_DEBUG("KVM was enabled when probing '%s', " + "but it is not available now", + qemuCaps->binary); + return false; + } + + return true; +} + + static int virQEMUCapsInitCached(virCapsPtr caps, virQEMUCapsPtr qemuCaps, @@ -5277,62 +5333,6 @@ virQEMUCapsNewForBinary(virCapsPtr caps, } =20 =20 -bool -virQEMUCapsIsValid(virQEMUCapsPtr qemuCaps, - time_t qemuctime, - uid_t runUid, - gid_t runGid) -{ - bool kvmUsable; - - if (!qemuCaps->binary) - return true; - - if (!qemuctime) { - struct stat sb; - - if (stat(qemuCaps->binary, &sb) < 0) { - char ebuf[1024]; - VIR_DEBUG("Failed to stat QEMU binary '%s': %s", - qemuCaps->binary, - virStrerror(errno, ebuf, sizeof(ebuf))); - return false; - } - qemuctime =3D sb.st_ctime; - } - - if (qemuctime !=3D qemuCaps->ctime) { - VIR_DEBUG("Outdated capabilities for '%s': QEMU binary changed " - "(%lld vs %lld)", - qemuCaps->binary, - (long long) qemuctime, (long long) qemuCaps->ctime); - return false; - } - - kvmUsable =3D virFileAccessibleAs("/dev/kvm", R_OK | W_OK, - runUid, runGid) =3D=3D 0; - - if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM) && - virQEMUCapsGet(qemuCaps, QEMU_CAPS_ENABLE_KVM) && - kvmUsable) { - VIR_DEBUG("KVM was not enabled when probing '%s', " - "but it should be usable now", - qemuCaps->binary); - return false; - } - - if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM) && - !kvmUsable) { - VIR_DEBUG("KVM was enabled when probing '%s', " - "but it is not available now", - qemuCaps->binary); - return false; - } - - return true; -} - - struct virQEMUCapsMachineTypeFilter { const char *machineType; virQEMUCapsFlags *flags; diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index 6e95876e8d..7f5382df62 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -494,11 +494,6 @@ int virQEMUCapsGetMachineTypesCaps(virQEMUCapsPtr qemu= Caps, size_t *nmachines, virCapsGuestMachinePtr **machines); =20 -bool virQEMUCapsIsValid(virQEMUCapsPtr qemuCaps, - time_t ctime, - uid_t runUid, - gid_t runGid); - void virQEMUCapsFilterByMachineType(virQEMUCapsPtr qemuCaps, const char *machineType); =20 --=20 2.13.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list