From nobody Sun Feb 8 17:47:39 2026 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=1645026101; cv=none; d=zohomail.com; s=zohoarc; b=DLmcs9YBEmI6FZMgiQlt8NML7cjkW2ZD/qxYfVyNwPgI4g70FBs3kBqkTGB4Sqx4e/Vk7kJQJ0RGMyX0Pg/bEVICAECs3eSZSIcRz9lmtczACmtRGNtL8dgqenyupYBH85mhdwEF4k2x1WXsITJdrSr0cuB/KOupOF5S3Tg1EHI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1645026101; 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=Wbko1QuYNnecMP8Tbbj3kgi8qLHB+Y76jD+dRIMZREc=; b=SV+35jhosFnD0yb7BnquXxzpdthoH0GP+b060fanEmypB64N6podUnFLpFl9UUFttMeDLJ+AL3kGgUb3D8XBLd1h0Eu05T2PeYz6Zup8mMpW0YBmG1lJvWh7QtXIWDd9WCI6wk+ipjpI8W6NfBYxgcEiUA3/vCq2TsSzXYbOxYc= 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 1645026101767298.2215917311685; Wed, 16 Feb 2022 07:41:41 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-552-W-AGZ9HaMPedErgEujlymg-1; Wed, 16 Feb 2022 10:41:39 -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 4165C80292E; Wed, 16 Feb 2022 15:41:34 +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 1D00570D5B; Wed, 16 Feb 2022 15:41:34 +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 DC16918033AE; Wed, 16 Feb 2022 15:41:33 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 21GFfMGw021080 for ; Wed, 16 Feb 2022 10:41:22 -0500 Received: by smtp.corp.redhat.com (Postfix) id 8B23D74E95; Wed, 16 Feb 2022 15:41:22 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.41]) by smtp.corp.redhat.com (Postfix) with ESMTP id C6D4674E8A for ; Wed, 16 Feb 2022 15:41:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1645026100; 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=Wbko1QuYNnecMP8Tbbj3kgi8qLHB+Y76jD+dRIMZREc=; b=B6tdlm6LtRcJHUmvBKM1Yzn+jMDNj9i1L/47J3ccI0h5zeaCqIFK9GbL1xzktiFPBfdWb0 ZwwrGlZYyfNLoCh9WGd5MwoJTrpIeBaO6GSjW7ZWROl2sWxe3jRlhGXpey7LnRqW5SGOp4 NF/bHYKCxCMOrjvmgFaGtYmS0oFx9AI= X-MC-Unique: W-AGZ9HaMPedErgEujlymg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 1/8] driver: Introduce global driver feature flag handling function Date: Wed, 16 Feb 2022 16:41:05 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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) X-ZM-MESSAGEID: 1645026103103100001 Content-Type: text/plain; charset="utf-8" The 'virDrvFeature' has a combination of features which are asserted by the specific driver and features which are actually global. In many cases the implementation was cargo-culted into newer drivers without re-assesing whether it makes sense. This patch introduces a global function which will specifically handle these global flags and defer the rest to the driver. Signed-off-by: Peter Krempa --- src/ch/ch_driver.c | 5 +++++ src/driver.c | 41 +++++++++++++++++++++++++++++++++++++ src/driver.h | 3 +++ src/esx/esx_driver.c | 4 ++++ src/libvirt_private.syms | 1 + src/libxl/libxl_driver.c | 5 +++++ src/lxc/lxc_driver.c | 5 +++++ src/network/bridge_driver.c | 5 +++++ src/openvz/openvz_driver.c | 5 +++++ src/qemu/qemu_driver.c | 5 +++++ src/test/test_driver.c | 5 +++++ src/vz/vz_driver.c | 5 +++++ 12 files changed, 89 insertions(+) diff --git a/src/ch/ch_driver.c b/src/ch/ch_driver.c index a0ff687d05..ac9298c0b5 100644 --- a/src/ch/ch_driver.c +++ b/src/ch/ch_driver.c @@ -919,9 +919,14 @@ static int chConnectSupportsFeature(virConnectPtr conn, int feature) { + int supported; + if (virConnectSupportsFeatureEnsureACL(conn) < 0) return -1; + if (virDriverFeatureIsGlobal(feature, &supported)) + return supported; + switch ((virDrvFeature) feature) { case VIR_DRV_FEATURE_TYPED_PARAM_STRING: case VIR_DRV_FEATURE_NETWORK_UPDATE_HAS_CORRECT_ORDER: diff --git a/src/driver.c b/src/driver.c index 9ae95cb4c3..8c70662ccb 100644 --- a/src/driver.c +++ b/src/driver.c @@ -316,3 +316,44 @@ virConnectValidateURIPath(const char *uriPath, return true; } + + +/** + * virDriverFeatureIsGlobal: + * @feat: a VIR_DRV_FEATURE + * @supported: If a feature is globally handled + * + * Certain driver feature flags are really not for individual drivers to d= ecide + * whether they implement them or not, but are rather global based on e.g. + * whether the RPC protocol supports it. + * + * This function returns 'true' and fills @supported if a feature is a glo= bal + * feature and the individual driver implementations don't decide whether + * they support it or not. + */ +bool +virDriverFeatureIsGlobal(virDrvFeature feat, + int *supported G_GNUC_UNUSED) + +{ + switch (feat) { + case VIR_DRV_FEATURE_TYPED_PARAM_STRING: + case VIR_DRV_FEATURE_NETWORK_UPDATE_HAS_CORRECT_ORDER: + case VIR_DRV_FEATURE_FD_PASSING: + case VIR_DRV_FEATURE_MIGRATION_V2: + case VIR_DRV_FEATURE_MIGRATION_V3: + case VIR_DRV_FEATURE_MIGRATION_P2P: + case VIR_DRV_FEATURE_MIGRATE_CHANGE_PROTECTION: + case VIR_DRV_FEATURE_XML_MIGRATABLE: + case VIR_DRV_FEATURE_MIGRATION_OFFLINE: + case VIR_DRV_FEATURE_MIGRATION_PARAMS: + case VIR_DRV_FEATURE_MIGRATION_DIRECT: + case VIR_DRV_FEATURE_MIGRATION_V1: + case VIR_DRV_FEATURE_PROGRAM_KEEPALIVE: + case VIR_DRV_FEATURE_REMOTE: + case VIR_DRV_FEATURE_REMOTE_CLOSE_CALLBACK: + case VIR_DRV_FEATURE_REMOTE_EVENT_CALLBACK: + default: + return false; + } +} diff --git a/src/driver.h b/src/driver.h index 7f45231f24..cd7cd96844 100644 --- a/src/driver.h +++ b/src/driver.h @@ -131,3 +131,6 @@ int virSetConnectStorage(virConnectPtr conn); bool virConnectValidateURIPath(const char *uriPath, const char *entityName, bool privileged); + +bool virDriverFeatureIsGlobal(virDrvFeature feat, + int *supported); diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c index 467740804a..3149f3e963 100644 --- a/src/esx/esx_driver.c +++ b/src/esx/esx_driver.c @@ -1018,6 +1018,10 @@ esxConnectSupportsFeature(virConnectPtr conn, int fe= ature) { esxPrivate *priv =3D conn->privateData; esxVI_Boolean supportsVMotion =3D esxVI_Boolean_Undefined; + int supported; + + if (virDriverFeatureIsGlobal(feature, &supported)) + return supported; switch ((virDrvFeature) feature) { case VIR_DRV_FEATURE_MIGRATION_V1: diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 2380f02b88..6f0d72ca38 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1528,6 +1528,7 @@ virStreamClass; # driver.h virConnectValidateURIPath; +virDriverFeatureIsGlobal; virDriverShouldAutostart; virGetConnectInterface; virGetConnectNetwork; diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index 4c61d330ed..478ab3e941 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -5697,9 +5697,14 @@ libxlConnectListAllDomains(virConnectPtr conn, static int libxlConnectSupportsFeature(virConnectPtr conn, int feature) { + int supported; + if (virConnectSupportsFeatureEnsureACL(conn) < 0) return -1; + if (virDriverFeatureIsGlobal(feature, &supported)) + return supported; + switch ((virDrvFeature) feature) { case VIR_DRV_FEATURE_MIGRATION_V3: case VIR_DRV_FEATURE_TYPED_PARAM_STRING: diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index ff83557bac..020ec257ae 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -1618,9 +1618,14 @@ static int lxcStateCleanup(void) static int lxcConnectSupportsFeature(virConnectPtr conn, int feature) { + int supported; + if (virConnectSupportsFeatureEnsureACL(conn) < 0) return -1; + if (virDriverFeatureIsGlobal(feature, &supported)) + return supported; + switch ((virDrvFeature) feature) { case VIR_DRV_FEATURE_TYPED_PARAM_STRING: case VIR_DRV_FEATURE_NETWORK_UPDATE_HAS_CORRECT_ORDER: diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index 3750da7962..d6ae05360b 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -857,9 +857,14 @@ static int networkConnectIsAlive(virConnectPtr conn G_= GNUC_UNUSED) static int networkConnectSupportsFeature(virConnectPtr conn, int feature) { + int supported; + if (virConnectSupportsFeatureEnsureACL(conn) < 0) return -1; + if (virDriverFeatureIsGlobal(feature, &supported)) + return supported; + switch ((virDrvFeature) feature) { case VIR_DRV_FEATURE_NETWORK_UPDATE_HAS_CORRECT_ORDER: return 1; diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c index b2589059c8..aa1db09540 100644 --- a/src/openvz/openvz_driver.c +++ b/src/openvz/openvz_driver.c @@ -1938,6 +1938,11 @@ openvzNodeGetCPUMap(virConnectPtr conn G_GNUC_UNUSED, static int openvzConnectSupportsFeature(virConnectPtr conn G_GNUC_UNUSED, int feature) { + int supported; + + if (virDriverFeatureIsGlobal(feature, &supported)) + return supported; + switch ((virDrvFeature) feature) { case VIR_DRV_FEATURE_MIGRATION_PARAMS: case VIR_DRV_FEATURE_MIGRATION_V3: diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index f2620200f0..f1f708e511 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -1173,9 +1173,14 @@ static int qemuConnectClose(virConnectPtr conn) static int qemuConnectSupportsFeature(virConnectPtr conn, int feature) { + int supported; + if (virConnectSupportsFeatureEnsureACL(conn) < 0) return -1; + if (virDriverFeatureIsGlobal(feature, &supported)) + return supported; + switch ((virDrvFeature) feature) { case VIR_DRV_FEATURE_MIGRATION_V2: case VIR_DRV_FEATURE_MIGRATION_V3: diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 03c41ca192..4eca5c4a65 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -1667,6 +1667,11 @@ static int testConnectSupportsFeature(virConnectPtr conn G_GNUC_UNUSED, int feature) { + int supported; + + if (virDriverFeatureIsGlobal(feature, &supported)) + return supported; + switch ((virDrvFeature) feature) { case VIR_DRV_FEATURE_TYPED_PARAM_STRING: case VIR_DRV_FEATURE_NETWORK_UPDATE_HAS_CORRECT_ORDER: diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c index 86bc53d631..fc91b6dddf 100644 --- a/src/vz/vz_driver.c +++ b/src/vz/vz_driver.c @@ -3006,9 +3006,14 @@ vzDomainMigratePrepare3Params(virConnectPtr conn, static int vzConnectSupportsFeature(virConnectPtr conn G_GNUC_UNUSED, int feature) { + int supported; + if (virConnectSupportsFeatureEnsureACL(conn) < 0) return -1; + if (virDriverFeatureIsGlobal(feature, &supported)) + return supported; + switch ((virDrvFeature) feature) { case VIR_DRV_FEATURE_MIGRATION_PARAMS: case VIR_DRV_FEATURE_MIGRATION_P2P: --=20 2.35.1