From nobody Tue Apr 23 23:39:39 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1605512644; cv=none; d=zohomail.com; s=zohoarc; b=jv1waEluZ+OzFdGFxkrFC5s+AxtyjR3ViyuJhEHFXRrTqLWlsuy1pPERblzd2SR6YPhtg5uny+fGmmAKIoitekpZ4SxNd+b9wczRqrvg0nTWADgK78OeVdvMVzkxZ9Egco37a3pU8FiG6+21QbahHTiHUnkdhu2mw1xlXimvzxI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605512644; 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=GO8BXQhH6l99uryQgXUYQNcfEOlKbFPn8DMHwNMqZL8=; b=W8D+O+ZeY7OE/X2wLGEzh5VXrUyf4GisX4u6Bb9LVHwFi3P+Z3jqJP+WjtKfet48DRKZdriRYXO9SmZTSeajhKNfpfTtVfHa7L86QfWYvOSHf3NzFn9RrScSODxuS844hSIUtXnBCuUetCjtzV+ggY+KNYUynLtz1d58bpU5x2I= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1605512644607414.5056718371552; Sun, 15 Nov 2020 23:44:04 -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-355-wTjWwlVtNqmSQzJTNGAAAQ-1; Mon, 16 Nov 2020 02:44:00 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0A8BE8015B1; Mon, 16 Nov 2020 07:43:54 +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 DB86455764; Mon, 16 Nov 2020 07:43:53 +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 476EE181A06C; Mon, 16 Nov 2020 07:43:52 +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 0AG7ho8E032546 for ; Mon, 16 Nov 2020 02:43:50 -0500 Received: by smtp.corp.redhat.com (Postfix) id 8BA0F5B4A9; Mon, 16 Nov 2020 07:43:50 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.192.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0CD2D5B4C1 for ; Mon, 16 Nov 2020 07:43:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605512643; 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=GO8BXQhH6l99uryQgXUYQNcfEOlKbFPn8DMHwNMqZL8=; b=LB319QzxG3KBP6e1uz0YcuBMG0J52ZVQr+6+PJqOhr0Mv/t1Myv24WbKyCIRDOSk6VsRpQ /HAUVeigAruTZ3ZFCg/cTSRERsZbZQ5ryiomyUQlseQtBs6BOh47tizgXZMsPk3EgNFtsY sJ1Mb7RU8Mb9U9G8A+SIDYuoT2ZXuIQ= X-MC-Unique: wTjWwlVtNqmSQzJTNGAAAQ-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 1/5] qemu: Validate RNG model Date: Mon, 16 Nov 2020 08:43:40 +0100 Message-Id: <4fbaefb6df0f5c5ea5e6564b1bb92d4e5947d2ad.1605512572.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 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.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com 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" The aim is to eliminate virDomainCapsDeviceDefValidate(). And in order to do so, the domain RNG model has to be validated in qemuValidateDomainRNGDef(). Signed-off-by: Michal Privoznik Reviewed-by: Daniel Henrique Barboza --- src/conf/domain_capabilities.c | 18 +----------------- src/qemu/qemu_validate.c | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 17 deletions(-) diff --git a/src/conf/domain_capabilities.c b/src/conf/domain_capabilities.c index 6ee8730111..b886ba7090 100644 --- a/src/conf/domain_capabilities.c +++ b/src/conf/domain_capabilities.c @@ -640,20 +640,6 @@ virDomainCapsFormat(const virDomainCaps *caps) } while (0) =20 =20 -static int -virDomainCapsDeviceRNGDefValidate(const virDomainCaps *caps, - const virDomainRNGDef *dev) -{ - if (ENUM_VALUE_MISSING(caps->rng.model, dev->model)) { - ENUM_VALUE_ERROR("rng model", - virDomainRNGModelTypeToString(dev->model)); - return -1; - } - - return 0; -} - - static int virDomainCapsDeviceVideoDefValidate(const virDomainCaps *caps, const virDomainVideoDef *dev) @@ -676,9 +662,6 @@ virDomainCapsDeviceDefValidate(const virDomainCaps *cap= s, int ret =3D 0; =20 switch ((virDomainDeviceType) dev->type) { - case VIR_DOMAIN_DEVICE_RNG: - ret =3D virDomainCapsDeviceRNGDefValidate(caps, dev->data.rng); - break; case VIR_DOMAIN_DEVICE_VIDEO: ret =3D virDomainCapsDeviceVideoDefValidate(caps, dev->data.video); break; @@ -706,6 +689,7 @@ virDomainCapsDeviceDefValidate(const virDomainCaps *cap= s, case VIR_DOMAIN_DEVICE_HUB: case VIR_DOMAIN_DEVICE_MEMBALLOON: case VIR_DOMAIN_DEVICE_NVRAM: + case VIR_DOMAIN_DEVICE_RNG: case VIR_DOMAIN_DEVICE_TPM: case VIR_DOMAIN_DEVICE_PANIC: case VIR_DOMAIN_DEVICE_IOMMU: diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index 79e765a212..c18865367e 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -1883,6 +1883,31 @@ qemuValidateDomainRNGDef(const virDomainRNGDef *def, return -1; } =20 + switch ((virDomainRNGModel) def->model) { + case VIR_DOMAIN_RNG_MODEL_VIRTIO: + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VIRTIO_RNG)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("domain configuration does not support rng mo= del '%s'"), + virDomainRNGModelTypeToString(def->model)); + return -1; + } + break; + + case VIR_DOMAIN_RNG_MODEL_VIRTIO_TRANSITIONAL: + case VIR_DOMAIN_RNG_MODEL_VIRTIO_NON_TRANSITIONAL: + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_PCI_TRANSITIONAL) && + !virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY)= ) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("domain configuration does not support rng mo= del '%s'"), + virDomainRNGModelTypeToString(def->model)); + return -1; + } + break; + + case VIR_DOMAIN_RNG_MODEL_LAST: + break; + } + if (qemuValidateDomainVirtioOptions(def->virtio, qemuCaps) < 0) return -1; =20 --=20 2.26.2 From nobody Tue Apr 23 23:39:39 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.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 63.128.21.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=1605512643; cv=none; d=zohomail.com; s=zohoarc; b=GwUbY7BXe80O36K99fls+Wr1fqHzPou4noGxAOmbKEycRL0saww/xe5v180FVONDsyc8pybdLPPrwSTC9+lCCcIQFP/k96jtA5r9r527avJ9nP8UroFIUI3hQZyzQmqGk0GGEEGJ3ZecO5Vc9+BTL/pQ8CuPOag71w0nWxYioTk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605512643; 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=1JIlLJS77cRxbmWfMMwzfD/2sSSxVB/1z9XTG60py+Y=; b=khQiLayU8ka/AYWxd2GfxOhmBva5Y6uVtTdh8pvpOt+aP+KSFE7uM/GLL3rRfGhtJSpbwdzpkRTKi4NgsAuf9KpSnppdhacDKtLGWPCQhMmEDZbaQOBYbg3tGIzPkjtAk0AJP7ihxJeG8Njo3TCJn5SwoKuFDfrB0ChT2CWl1g0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1605512643582852.8291594077798; Sun, 15 Nov 2020 23:44:03 -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-4-8z_p-UafOcmuPwr8FaAjxA-1; Mon, 16 Nov 2020 02:43:59 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0E9DA188C12E; Mon, 16 Nov 2020 07:43:54 +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 E0A705D9CC; Mon, 16 Nov 2020 07:43:53 +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 BD6BA181A06D; Mon, 16 Nov 2020 07:43:52 +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 0AG7hpT8032554 for ; Mon, 16 Nov 2020 02:43:51 -0500 Received: by smtp.corp.redhat.com (Postfix) id 680875B4BB; Mon, 16 Nov 2020 07:43:51 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.192.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id DD9D45B4A9 for ; Mon, 16 Nov 2020 07:43:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605512642; 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=1JIlLJS77cRxbmWfMMwzfD/2sSSxVB/1z9XTG60py+Y=; b=DEntI0jtewt9349fB5cXfMtRspTu2KMamGdh237B+vyPLyaCY/lV6jZNX/iOD8qt0h/5ZS nQHLoMRMfQv83Kt/tXaS5LSHboyyCSNM+7+IYftuAd+iEUghaSes76oQT7jeq8mlj/hAPF lmAFzjphqYwGOZ2Zd9x60SMy1Qed22U= X-MC-Unique: 8z_p-UafOcmuPwr8FaAjxA-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 2/5] qemu: Validate video model Date: Mon, 16 Nov 2020 08:43:41 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 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.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com 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" The aim is to eliminate virDomainCapsDeviceDefValidate(). And in order to do so, the domain video model has to be validated in qemuValidateDomainDeviceDefVideo(). Signed-off-by: Michal Privoznik Reviewed-by: Daniel Henrique Barboza --- src/conf/domain_capabilities.c | 19 +-------- src/qemu/qemu_validate.c | 42 +++++++++++++++++++ .../default-video-type-x86_64-caps-test-0.err | 2 +- .../video-invalid-multiple-devices.err | 2 +- 4 files changed, 45 insertions(+), 20 deletions(-) diff --git a/src/conf/domain_capabilities.c b/src/conf/domain_capabilities.c index b886ba7090..0e0e6d1600 100644 --- a/src/conf/domain_capabilities.c +++ b/src/conf/domain_capabilities.c @@ -640,22 +640,8 @@ virDomainCapsFormat(const virDomainCaps *caps) } while (0) =20 =20 -static int -virDomainCapsDeviceVideoDefValidate(const virDomainCaps *caps, - const virDomainVideoDef *dev) -{ - if (ENUM_VALUE_MISSING(caps->video.modelType, dev->type)) { - ENUM_VALUE_ERROR("video model", - virDomainVideoTypeToString(dev->type)); - return -1; - } - - return 0; -} - - int -virDomainCapsDeviceDefValidate(const virDomainCaps *caps, +virDomainCapsDeviceDefValidate(const virDomainCaps *caps G_GNUC_UNUSED, const virDomainDeviceDef *dev, const virDomainDef *def G_GNUC_UNUSED) { @@ -663,9 +649,6 @@ virDomainCapsDeviceDefValidate(const virDomainCaps *cap= s, =20 switch ((virDomainDeviceType) dev->type) { case VIR_DOMAIN_DEVICE_VIDEO: - ret =3D virDomainCapsDeviceVideoDefValidate(caps, dev->data.video); - break; - case VIR_DOMAIN_DEVICE_AUDIO: /* TODO: add validation */ break; diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index c18865367e..4defdb02cf 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -2203,10 +2203,52 @@ static int qemuValidateDomainDeviceDefVideo(const virDomainVideoDef *video, virQEMUCapsPtr qemuCaps) { + virQEMUCapsFlags cap =3D QEMU_CAPS_LAST; + /* there's no properties to validate for NONE video devices */ if (video->type =3D=3D VIR_DOMAIN_VIDEO_TYPE_NONE) return 0; =20 + switch ((virDomainVideoType) video->type) { + case VIR_DOMAIN_VIDEO_TYPE_VGA: + cap =3D QEMU_CAPS_DEVICE_VGA; + break; + case VIR_DOMAIN_VIDEO_TYPE_CIRRUS: + cap =3D QEMU_CAPS_DEVICE_CIRRUS_VGA; + break; + case VIR_DOMAIN_VIDEO_TYPE_VMVGA: + cap =3D QEMU_CAPS_DEVICE_VMWARE_SVGA; + break; + case VIR_DOMAIN_VIDEO_TYPE_QXL: + cap =3D QEMU_CAPS_DEVICE_QXL; + break; + case VIR_DOMAIN_VIDEO_TYPE_VIRTIO: + cap =3D QEMU_CAPS_DEVICE_VIRTIO_GPU; + break; + case VIR_DOMAIN_VIDEO_TYPE_BOCHS: + cap =3D QEMU_CAPS_DEVICE_BOCHS_DISPLAY; + break; + case VIR_DOMAIN_VIDEO_TYPE_RAMFB: + cap =3D QEMU_CAPS_DEVICE_RAMFB; + break; + case VIR_DOMAIN_VIDEO_TYPE_DEFAULT: + case VIR_DOMAIN_VIDEO_TYPE_XEN: + case VIR_DOMAIN_VIDEO_TYPE_VBOX: + case VIR_DOMAIN_VIDEO_TYPE_PARALLELS: + case VIR_DOMAIN_VIDEO_TYPE_GOP: + case VIR_DOMAIN_VIDEO_TYPE_NONE: + case VIR_DOMAIN_VIDEO_TYPE_LAST: + /* nada */ + break; + } + + if (!virQEMUCapsGet(qemuCaps, cap)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("domain configuration does not support video mode= l '%s'"), + virDomainVideoTypeToString(video->type)); + return -1; + } + if (!video->primary && video->type !=3D VIR_DOMAIN_VIDEO_TYPE_QXL && video->type !=3D VIR_DOMAIN_VIDEO_TYPE_VIRTIO) { diff --git a/tests/qemuxml2argvdata/default-video-type-x86_64-caps-test-0.e= rr b/tests/qemuxml2argvdata/default-video-type-x86_64-caps-test-0.err index 82576471b7..f7b6b57926 100644 --- a/tests/qemuxml2argvdata/default-video-type-x86_64-caps-test-0.err +++ b/tests/qemuxml2argvdata/default-video-type-x86_64-caps-test-0.err @@ -1 +1 @@ -unsupported configuration: domain configuration does not support 'video mo= del' value 'default' +unsupported configuration: domain configuration does not support video mod= el 'default' diff --git a/tests/qemuxml2argvdata/video-invalid-multiple-devices.err b/te= sts/qemuxml2argvdata/video-invalid-multiple-devices.err index 7fc20b2370..5c1e557021 100644 --- a/tests/qemuxml2argvdata/video-invalid-multiple-devices.err +++ b/tests/qemuxml2argvdata/video-invalid-multiple-devices.err @@ -1 +1 @@ -unsupported configuration: domain configuration does not support 'video mo= del' value 'qxl' +unsupported configuration: domain configuration does not support video mod= el 'qxl' --=20 2.26.2 From nobody Tue Apr 23 23:39:39 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1605512650; cv=none; d=zohomail.com; s=zohoarc; b=TJQrqfDv2zfMZkxbybwmciK5chbcC7+MFfyUQdChILhAKH9hyWX+KtB1aX97P7yFSlJuFLfxTT/sq/26kWRckylj//J/PwFkvUV6MsUjZ4KKhGgh5+f4CwxNXcNN2IJy3tt9Ug4BFQj7SmjR9DegYM3giEvOXvVUYk1km+lXddM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605512650; 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=3JnXrua1zASBQ6tXQwAdGuDIPtSHs+5cFuPwncz583o=; b=KyMYJWPmy7iiHhuDWfILxErErW3Sqxaj2HUL+LodEH7jVtwq2zWm27bx2c8RTABRIWZYQRJQ3sgdAcqvp8l2JmMLqMZwAAYLBqLK5Ez7NVz6lCqJ06qAM9d6hU3tqd/ToqivCLx3If9/U7Z7QeX+jZsHCtWevrFPq1re8mPKndw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1605512650449671.6472994442515; Sun, 15 Nov 2020 23:44:10 -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-459-Q3g73KiEPvaOr4wvLHeOjg-1; Mon, 16 Nov 2020 02:44:07 -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 07898809DD9; Mon, 16 Nov 2020 07:44:01 +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 D763B1002C0D; Mon, 16 Nov 2020 07:44:00 +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 9D6D058121; Mon, 16 Nov 2020 07:44:00 +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 0AG7hqdJ032560 for ; Mon, 16 Nov 2020 02:43:52 -0500 Received: by smtp.corp.redhat.com (Postfix) id 470D05B4BB; Mon, 16 Nov 2020 07:43:52 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.192.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id BA0245B4A9 for ; Mon, 16 Nov 2020 07:43:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605512649; 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=3JnXrua1zASBQ6tXQwAdGuDIPtSHs+5cFuPwncz583o=; b=AfA5PSE9NeVpKC0oIzrjjSTRP20uhyonpmW3vShpinPJzvdgueWq75j2IUxtvmAqli1lAH aFTMLIkd8ThXbSMutDLElkqqB/vTt6e+chLdz/ZTz1mY+FqHpxpQ8OxgW1fJKXI4SRWn9l U2NV3R2HyoweRTU8jMrg3xJeghLBd0w= X-MC-Unique: Q3g73KiEPvaOr4wvLHeOjg-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 3/5] conf: Drop virDomainCapsDeviceDefValidate() Date: Mon, 16 Nov 2020 08:43:42 +0100 Message-Id: <0789877e74682589d11135285c50478098b521ff.1605512572.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 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 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com 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" Now that nothing uses virDomainCapsDeviceDefValidate() it can be removed. Signed-off-by: Michal Privoznik Reviewed-by: Daniel Henrique Barboza --- src/conf/domain_capabilities.c | 55 ---------------------------------- src/conf/domain_capabilities.h | 4 --- src/libvirt_private.syms | 1 - src/qemu/qemu_validate.c | 10 ------- 4 files changed, 70 deletions(-) diff --git a/src/conf/domain_capabilities.c b/src/conf/domain_capabilities.c index 0e0e6d1600..8a690a57a3 100644 --- a/src/conf/domain_capabilities.c +++ b/src/conf/domain_capabilities.c @@ -628,58 +628,3 @@ virDomainCapsFormat(const virDomainCaps *caps) =20 return virBufferContentAndReset(&buf); } - - -#define ENUM_VALUE_MISSING(capsEnum, value) !(capsEnum.values & (1 << valu= e)) - -#define ENUM_VALUE_ERROR(valueLabel, valueString) \ - do { \ - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, \ - _("domain configuration does not support '%s' value= '%s'"), \ - valueLabel, valueString); \ - } while (0) - - -int -virDomainCapsDeviceDefValidate(const virDomainCaps *caps G_GNUC_UNUSED, - const virDomainDeviceDef *dev, - const virDomainDef *def G_GNUC_UNUSED) -{ - int ret =3D 0; - - switch ((virDomainDeviceType) dev->type) { - case VIR_DOMAIN_DEVICE_VIDEO: - case VIR_DOMAIN_DEVICE_AUDIO: - /* TODO: add validation */ - break; - - case VIR_DOMAIN_DEVICE_DISK: - case VIR_DOMAIN_DEVICE_REDIRDEV: - case VIR_DOMAIN_DEVICE_NET: - case VIR_DOMAIN_DEVICE_CONTROLLER: - case VIR_DOMAIN_DEVICE_CHR: - case VIR_DOMAIN_DEVICE_SMARTCARD: - case VIR_DOMAIN_DEVICE_HOSTDEV: - case VIR_DOMAIN_DEVICE_MEMORY: - case VIR_DOMAIN_DEVICE_VSOCK: - case VIR_DOMAIN_DEVICE_INPUT: - case VIR_DOMAIN_DEVICE_SHMEM: - case VIR_DOMAIN_DEVICE_LEASE: - case VIR_DOMAIN_DEVICE_FS: - case VIR_DOMAIN_DEVICE_SOUND: - case VIR_DOMAIN_DEVICE_WATCHDOG: - case VIR_DOMAIN_DEVICE_GRAPHICS: - case VIR_DOMAIN_DEVICE_HUB: - case VIR_DOMAIN_DEVICE_MEMBALLOON: - case VIR_DOMAIN_DEVICE_NVRAM: - case VIR_DOMAIN_DEVICE_RNG: - case VIR_DOMAIN_DEVICE_TPM: - case VIR_DOMAIN_DEVICE_PANIC: - case VIR_DOMAIN_DEVICE_IOMMU: - case VIR_DOMAIN_DEVICE_NONE: - case VIR_DOMAIN_DEVICE_LAST: - break; - } - - return ret; -} diff --git a/src/conf/domain_capabilities.h b/src/conf/domain_capabilities.h index 685d5e2a44..4ae6f0fbb1 100644 --- a/src/conf/domain_capabilities.h +++ b/src/conf/domain_capabilities.h @@ -232,10 +232,6 @@ void virDomainCapsEnumClear(virDomainCapsEnumPtr capsE= num); =20 char * virDomainCapsFormat(const virDomainCaps *caps); =20 -int virDomainCapsDeviceDefValidate(const virDomainCaps *caps, - const virDomainDeviceDef *dev, - const virDomainDef *def); - void virSEVCapabilitiesFree(virSEVCapability *capabilities); =20 diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 491bd5bd87..1d98f01334 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -212,7 +212,6 @@ virDomainCapsCPUModelsGet; virDomainCapsCPUModelsNew; virDomainCapsCPUUsableTypeFromString; virDomainCapsCPUUsableTypeToString; -virDomainCapsDeviceDefValidate; virDomainCapsEnumClear; virDomainCapsEnumSet; virDomainCapsFormat; diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index 4defdb02cf..09cdcb20c2 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -4682,24 +4682,14 @@ qemuValidateDomainDeviceDef(const virDomainDeviceDe= f *dev, int ret =3D 0; virQEMUDriverPtr driver =3D opaque; g_autoptr(virQEMUCaps) qemuCaps =3D NULL; - g_autoptr(virDomainCaps) domCaps =3D NULL; =20 if (!(qemuCaps =3D virQEMUCapsCacheLookup(driver->qemuCapsCache, def->emulator))) return -1; =20 - if (!(domCaps =3D virQEMUDriverGetDomainCapabilities(driver, qemuCaps, - def->os.machine, - def->os.arch, - def->virtType))) - return -1; - if ((ret =3D qemuValidateDomainDeviceDefAddress(dev, qemuCaps)) < 0) return ret; =20 - if ((ret =3D virDomainCapsDeviceDefValidate(domCaps, dev, def)) < 0) - return ret; - switch ((virDomainDeviceType)dev->type) { case VIR_DOMAIN_DEVICE_NET: ret =3D qemuValidateDomainDeviceDefNetwork(dev->data.net, qemuCaps= ); --=20 2.26.2 From nobody Tue Apr 23 23:39:39 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.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 63.128.21.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=1605512651; cv=none; d=zohomail.com; s=zohoarc; b=IpRrHiz0UzcmP5InGLZ+nHNA7Q5/yPfrb5qyZbrNiOx7Ooi7lkYN2xtpP9vOABrZVZcgOG983JWwMFkwMCVNeuunBe/3WXviELkWFYH9uenoV0RrHDlvRcn9XNS+l8DexEfNzzM+6AmzCyIwenBcvMpxmR8BZLNbspA01Szemt8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605512651; 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=TrogYxQW3JYUbnzhuscJ9c4Ogh3CpKe3MaDbd6P0XR0=; b=PdvsYbNIRWodnZC0FkqpBvXb9KrXia0dsdh/dh1XUMQBGFW5aM4f6K3as5p64lqmWZBBQCyGX2X2+smbSzzfpFVz+WC2TNKaIlPzneCu/eyqNNTx73xVo/zvucmy0IQSXXTsSzQrzUtHi71aIjJfxATbl6FO6Fs22+u0RDUU+Io= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1605512651881600.5553328551807; Sun, 15 Nov 2020 23:44:11 -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-404-D7bxo2bPMC6rpGwbuqln6A-1; Mon, 16 Nov 2020 02:44:08 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8CA081009443; Mon, 16 Nov 2020 07:44:03 +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 6DE0C5B4CC; Mon, 16 Nov 2020 07:44:03 +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 3A58958124; Mon, 16 Nov 2020 07:44:03 +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 0AG7hrpC032566 for ; Mon, 16 Nov 2020 02:43:53 -0500 Received: by smtp.corp.redhat.com (Postfix) id 23E975B4A9; Mon, 16 Nov 2020 07:43:53 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.192.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 989595B4BB for ; Mon, 16 Nov 2020 07:43:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605512650; 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=TrogYxQW3JYUbnzhuscJ9c4Ogh3CpKe3MaDbd6P0XR0=; b=iGkrsfuOA29ac+EKc/WSugHcKSdg1m7FVqDWuv7tpqt77E7UH9pTR1WhWDnMCCfDdgMOJ5 QbHSr9sdrofy36nLhPJv9T99GDGSuzm2HVidF9Ph8wWcZ7SV/v0HoDmMFtiKz/IcYi+fMd jHHmpFisvxXEW+iajjPMrsdg/7YbrZk= X-MC-Unique: D7bxo2bPMC6rpGwbuqln6A-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 4/5] qemu: Don't cache domCaps in virQEMUDriverGetDomainCapabilities() Date: Mon, 16 Nov 2020 08:43:43 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 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.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com 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" Currently, whenever a domain capabilities is needed (fortunately, after cleanup done by previous commits it is now only in virConnectGetDomainCapabilities()), the object is stored in a cache. But there is no invalidation mechanism for the cache (except the implicit one - the cache is part of qemuCaps and thus share its lifetime, but that is not enough). Therefore, if something changes - for instance new firmware files are installed, or old are removed these changes are not reflected in the virConnectGetDomainCapabilities() output. Originally, the caching was there because domCaps were used during device XML validation and they were used a lot from our test suite. But this is no longer the case. And therefore, we don't need the cache and can construct fresh domCaps on each virConnectGetDomainCapabilities() call. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=3D1807198 Signed-off-by: Michal Privoznik Reviewed-by: Daniel Henrique Barboza --- src/qemu/qemu_conf.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 2fb2f021c2..518f82deaa 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -1422,11 +1422,8 @@ virCapsPtr virQEMUDriverGetCapabilities(virQEMUDrive= rPtr driver, /** * virQEMUDriverGetDomainCapabilities: * - * Get a reference to the virDomainCapsPtr instance from the virQEMUCapsPtr - * domCapsCache. If there's no domcaps in the cache, create a new instance, - * add it to the cache, and return a reference. - * - * The caller must release the reference with virObjetUnref + * Get a reference to the virDomainCapsPtr instance. The caller + * must release the reference with virObjetUnref(). * * Returns: a reference to a virDomainCapsPtr instance or NULL */ @@ -1438,15 +1435,19 @@ virQEMUDriverGetDomainCapabilities(virQEMUDriverPtr= driver, virDomainVirtType virttype) { g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); + g_autoptr(virDomainCaps) domCaps =3D NULL; + const char *path =3D virQEMUCapsGetBinary(qemuCaps); =20 - return virQEMUCapsGetDomainCapsCache(qemuCaps, - machine, - arch, - virttype, - driver->hostarch, - driver->privileged, - cfg->firmwares, - cfg->nfirmwares); + if (!(domCaps =3D virDomainCapsNew(path, machine, arch, virttype))) + return NULL; + + if (virQEMUCapsFillDomainCaps(qemuCaps, driver->hostarch, + domCaps, driver->privileged, + cfg->firmwares, + cfg->nfirmwares) < 0) + return NULL; + + return g_steal_pointer(&domCaps); } =20 =20 --=20 2.26.2 From nobody Tue Apr 23 23:39:39 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1605512707; cv=none; d=zohomail.com; s=zohoarc; b=V2vQyR78UdicIFF0asAw4ifdL9NMrhe2bM59AUqAygGp16++dITpDZ/i6RE/EzBNruaykL+VhquvX7qfb5Gfo2sZZHaMhb81Dmi3sHWqy1VerXdKKPSzoYzgE4zNzsd1V3FMmrNhr5zO/UV1Ah2LuqhSGH/QXHome1h1TXy1gb4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605512707; 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=4I9sGvD7J3DJBS3W1uJItYyMhjSGTkNsKzq/LYVp3io=; b=j1Zfea3Ax2peqxA1Zq1D0Fz5tN+aVHANrc7fBHrJ3ErImi45Fl/Xf0QaupMEg/i0KDjs3zbVnfUXFixx6vF71a6OSGns721cjZU9xsky3HXVx62W8ze7HvcGKR//odbNIQEYe73hBVr1mZFGM3WRUqNlZAiXx/tj4hN91zxn5Lo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1605512707836692.2844203969435; Sun, 15 Nov 2020 23:45:07 -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-560-zJSDiwcnNuWCXRDR1ZiDSw-1; Mon, 16 Nov 2020 02:44:11 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5D6DB188C12C; Mon, 16 Nov 2020 07:44:06 +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 020E351919; Mon, 16 Nov 2020 07:44:06 +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 B7F71181A07B; Mon, 16 Nov 2020 07:44:05 +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 0AG7hs7i032575 for ; Mon, 16 Nov 2020 02:43:54 -0500 Received: by smtp.corp.redhat.com (Postfix) id 0130B5B4BF; Mon, 16 Nov 2020 07:43:54 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.192.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 75BD95B4A9 for ; Mon, 16 Nov 2020 07:43:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605512706; 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=4I9sGvD7J3DJBS3W1uJItYyMhjSGTkNsKzq/LYVp3io=; b=gNQFU5gzIYzHuan+o3YI5zgZbvQ6/8S/clTIdH3LH6Hg8lmSrGdPHAswbJNXBDJE/PqsN2 eC7Mnk4GMAdAp1VjSGIhjcx3GoUw/Ar9JvQcTKwjmhsiLTGDns9r9y9+si2VsbcvXm041S Oo0toQgH+DNa6a9BCSwxLamYhq/AjkY= X-MC-Unique: zJSDiwcnNuWCXRDR1ZiDSw-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 5/5] qemu: Remove virQEMUDomainCapsCache code Date: Mon, 16 Nov 2020 08:43:44 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 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.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com 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" Now that the domCaps cache is history, this code is no longer used and thus can be removed. Signed-off-by: Michal Privoznik Reviewed-by: Daniel Henrique Barboza --- src/qemu/qemu_capabilities.c | 129 ----------------------------------- src/qemu/qemu_capabilities.h | 10 --- 2 files changed, 139 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 212ddf9206..9f9f976754 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -648,25 +648,6 @@ struct _virQEMUCapsAccel { }; =20 =20 -typedef struct _virQEMUDomainCapsCache virQEMUDomainCapsCache; -typedef virQEMUDomainCapsCache *virQEMUDomainCapsCachePtr; -struct _virQEMUDomainCapsCache { - virObjectLockable parent; - - GHashTable *cache; -}; - -G_DEFINE_AUTOPTR_CLEANUP_FUNC(virQEMUDomainCapsCache, virObjectUnref); - -static virClassPtr virQEMUDomainCapsCacheClass; -static void virQEMUDomainCapsCacheDispose(void *obj) -{ - virQEMUDomainCapsCachePtr cache =3D obj; - - virHashFree(cache->cache); -} - - /* * Update the XML parser/formatter when adding more * information to this struct so that it gets cached @@ -700,8 +681,6 @@ struct _virQEMUCaps { =20 virArch arch; =20 - virQEMUDomainCapsCachePtr domCapsCache; - size_t ngicCapabilities; virGICCapability *gicCapabilities; =20 @@ -726,9 +705,6 @@ static int virQEMUCapsOnceInit(void) if (!VIR_CLASS_NEW(virQEMUCaps, virClassForObject())) return -1; =20 - if (!(VIR_CLASS_NEW(virQEMUDomainCapsCache, virClassForObjectLockable(= )))) - return -1; - return 0; } =20 @@ -1774,24 +1750,6 @@ int virQEMUCapsGetDefaultVersion(virCapsPtr caps, } =20 =20 -static virQEMUDomainCapsCachePtr -virQEMUDomainCapsCacheNew(void) -{ - g_autoptr(virQEMUDomainCapsCache) cache =3D NULL; - - if (virQEMUCapsInitialize() < 0) - return NULL; - - if (!(cache =3D virObjectLockableNew(virQEMUDomainCapsCacheClass))) - return NULL; - - if (!(cache->cache =3D virHashNew(virObjectFreeHashData))) - return NULL; - - return g_steal_pointer(&cache); -} - - virQEMUCapsPtr virQEMUCapsNew(void) { @@ -1806,14 +1764,7 @@ virQEMUCapsNew(void) qemuCaps->invalidation =3D true; qemuCaps->flags =3D virBitmapNew(QEMU_CAPS_LAST); =20 - if (!(qemuCaps->domCapsCache =3D virQEMUDomainCapsCacheNew())) - goto error; - return qemuCaps; - - error: - virObjectUnref(qemuCaps); - return NULL; } =20 =20 @@ -1992,7 +1943,6 @@ void virQEMUCapsDispose(void *obj) { virQEMUCapsPtr qemuCaps =3D obj; =20 - virObjectUnref(qemuCaps->domCapsCache); virBitmapFree(qemuCaps->flags); =20 VIR_FREE(qemuCaps->package); @@ -2147,85 +2097,6 @@ const char *virQEMUCapsGetPackage(virQEMUCapsPtr qem= uCaps) } =20 =20 -struct virQEMUCapsSearchDomcapsData { - const char *path; - const char *machine; - virArch arch; - virDomainVirtType virttype; -}; - - -static int -virQEMUCapsSearchDomcaps(const void *payload, - const char *name G_GNUC_UNUSED, - const void *opaque) -{ - virDomainCapsPtr domCaps =3D (virDomainCapsPtr) payload; - struct virQEMUCapsSearchDomcapsData *data =3D (struct virQEMUCapsSearc= hDomcapsData *) opaque; - - if (STREQ_NULLABLE(data->path, domCaps->path) && - STREQ_NULLABLE(data->machine, domCaps->machine) && - data->arch =3D=3D domCaps->arch && - data->virttype =3D=3D domCaps->virttype) - return 1; - - return 0; -} - - -virDomainCapsPtr -virQEMUCapsGetDomainCapsCache(virQEMUCapsPtr qemuCaps, - const char *machine, - virArch arch, - virDomainVirtType virttype, - virArch hostarch, - bool privileged, - virFirmwarePtr *firmwares, - size_t nfirmwares) -{ - virQEMUDomainCapsCachePtr cache =3D qemuCaps->domCapsCache; - virDomainCapsPtr domCaps =3D NULL; - const char *path =3D virQEMUCapsGetBinary(qemuCaps); - struct virQEMUCapsSearchDomcapsData data =3D { - .path =3D path, - .machine =3D machine, - .arch =3D arch, - .virttype =3D virttype, - }; - - virObjectLock(cache); - - domCaps =3D virHashSearch(cache->cache, virQEMUCapsSearchDomcaps, &dat= a, NULL); - - if (!domCaps) { - g_autoptr(virDomainCaps) tempDomCaps =3D NULL; - g_autofree char *key =3D NULL; - - /* hash miss, build new domcaps */ - if (!(tempDomCaps =3D virDomainCapsNew(path, machine, - arch, virttype))) - goto cleanup; - - if (virQEMUCapsFillDomainCaps(qemuCaps, hostarch, tempDomCaps, - privileged, firmwares, nfirmwares) <= 0) - goto cleanup; - - key =3D g_strdup_printf("%d:%d:%s:%s", arch, virttype, - NULLSTR(machine), path); - - if (virHashAddEntry(cache->cache, key, tempDomCaps) < 0) - goto cleanup; - - domCaps =3D g_steal_pointer(&tempDomCaps); - } - - virObjectRef(domCaps); - cleanup: - virObjectUnlock(cache); - return domCaps; -} - - int virQEMUCapsAddCPUDefinitions(virQEMUCapsPtr qemuCaps, virDomainVirtType type, diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index 6b40ff4f15..9d3f73b2ab 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -620,16 +620,6 @@ virArch virQEMUCapsGetArch(virQEMUCapsPtr qemuCaps); unsigned int virQEMUCapsGetVersion(virQEMUCapsPtr qemuCaps); const char *virQEMUCapsGetPackage(virQEMUCapsPtr qemuCaps); =20 -virDomainCapsPtr -virQEMUCapsGetDomainCapsCache(virQEMUCapsPtr qemuCaps, - const char *machine, - virArch arch, - virDomainVirtType virttype, - virArch hostarch, - bool privileged, - virFirmwarePtr *firmwares, - size_t nfirmwares); - unsigned int virQEMUCapsGetKVMVersion(virQEMUCapsPtr qemuCaps); int virQEMUCapsAddCPUDefinitions(virQEMUCapsPtr qemuCaps, virDomainVirtType type, --=20 2.26.2