From nobody Tue May 14 12:14:19 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; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=quarantine dis=quarantine) header.from=virtuozzo.com ARC-Seal: i=1; a=rsa-sha256; t=1608274865; cv=none; d=zohomail.com; s=zohoarc; b=Guw9PyUaSYAkzaadKVdiFZNq88nNHIk3attOtaBT3FknKQDFt6plPcKv7lnNaSNF5IAhsXjRjDXDPmOciFt/Lxe6Dj81RAwcIvDDJLtBNMHvYuGnLohx0opfsJDOyK8mt2HA2adSXUqRBXklkPN71Glqu3BRIydugNJCUI0Gbk8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1608274865; h=Content-Type:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=t1kR0/ZiB2Q11em3J089n3DydlweOiyFh1Bl3hZ5Rpg=; b=iSOeKOSS2aisJjicPk16+rckDv+cEKmdW0Zqt6H71/hG5iefT3+xsKn03BIQl5Ce5F+dbI9HLqkHCK4qUn6GlHlQZS5vF589DJ1Wx+1GaAYwZxUZTTkB9wHpAjgy/Ix59tOKlkFMcQFfjve4cNTgM45PLAv+nqdBzCXrTeIYpKc= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=quarantine dis=quarantine) 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 1608274865585355.76986529348505; Thu, 17 Dec 2020 23:01:05 -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-571-N8Gm2JpQNGiFwFTEdiDoGQ-1; Fri, 18 Dec 2020 02:01:00 -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 8686A192AB76; Fri, 18 Dec 2020 07:00:48 +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 58F4E5D9CD; Fri, 18 Dec 2020 07:00:48 +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 1E455180954D; Fri, 18 Dec 2020 07:00:48 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0BI6wB3K028447 for ; Fri, 18 Dec 2020 01:58:11 -0500 Received: by smtp.corp.redhat.com (Postfix) id AAEF22026D36; Fri, 18 Dec 2020 06:58:11 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast06.extmail.prod.ext.rdu2.redhat.com [10.11.55.22]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A5BD02026D15 for ; Fri, 18 Dec 2020 06:58:09 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8EF4B185A794 for ; Fri, 18 Dec 2020 06:58:09 +0000 (UTC) Received: from relay3.sw.ru (relay.sw.ru [185.231.240.75]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-218-iEKtp0pGPWmHfOlYZue9mw-1; Fri, 18 Dec 2020 01:58:06 -0500 Received: from [10.28.15.168] (helo=vz7.sw.ru.) by relay3.sw.ru with esmtp (Exim 4.94) (envelope-from ) id 1kq9hr-00DT1e-LO for libvir-list@redhat.com; Fri, 18 Dec 2020 09:57:39 +0300 X-MC-Unique: N8Gm2JpQNGiFwFTEdiDoGQ-1 X-MC-Unique: iEKtp0pGPWmHfOlYZue9mw-1 From: Nikolay Shirokovskiy To: libvir-list@redhat.com Subject: [PATCH v3 1/4] src: adopt to VIR_DRV_SUPPORTS_FEATURE return -1 Date: Fri, 18 Dec 2020 09:56:45 +0300 Message-Id: <1608274608-818018-2-git-send-email-nshirokovskiy@virtuozzo.com> In-Reply-To: <1608274608-818018-1-git-send-email-nshirokovskiy@virtuozzo.com> References: <1608274608-818018-1-git-send-email-nshirokovskiy@virtuozzo.com> X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 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: 2 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Otherwise in some places we can mistakenly report 'unsupported' error inste= ad of root cause. So let's handle root cause explicitly from the macro. Signed-off-by: Nikolay Shirokovskiy Reviewed-by: Daniel P. Berrang=C3=A9 --- src/libvirt-domain.c | 511 ++++++++++++++++++++++++++++++++++-------------= ---- src/libvirt-host.c | 18 +- src/libvirt.c | 7 +- 3 files changed, 365 insertions(+), 171 deletions(-) diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c index 5edc73e..2f9081a 100644 --- a/src/libvirt-domain.c +++ b/src/libvirt-domain.c @@ -2130,6 +2130,7 @@ virDomainGetMemoryParameters(virDomainPtr domain, int *nparams, unsigned int flags) { virConnectPtr conn; + int rc; =20 VIR_DOMAIN_DEBUG(domain, "params=3D%p, nparams=3D%d, flags=3D0x%x", params, (nparams) ? *nparams : -1, flags); @@ -2142,8 +2143,11 @@ virDomainGetMemoryParameters(virDomainPtr domain, if (*nparams !=3D 0) virCheckNonNullArgGoto(params, error); =20 - if (VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn, - VIR_DRV_FEATURE_TYPED_PARAM_STRING)) + rc =3D VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn, + VIR_DRV_FEATURE_TYPED_PARAM_STRING); + if (rc < 0) + goto error; + if (rc) flags |=3D VIR_TYPED_PARAM_STRING_OKAY; =20 VIR_EXCLUSIVE_FLAGS_GOTO(VIR_DOMAIN_AFFECT_LIVE, @@ -2251,6 +2255,7 @@ virDomainGetNumaParameters(virDomainPtr domain, int *nparams, unsigned int flags) { virConnectPtr conn; + int rc; =20 VIR_DOMAIN_DEBUG(domain, "params=3D%p, nparams=3D%d, flags=3D0x%x", params, (nparams) ? *nparams : -1, flags); @@ -2263,8 +2268,11 @@ virDomainGetNumaParameters(virDomainPtr domain, if (*nparams !=3D 0) virCheckNonNullArgGoto(params, error); =20 - if (VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn, - VIR_DRV_FEATURE_TYPED_PARAM_STRING)) + rc =3D VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn, + VIR_DRV_FEATURE_TYPED_PARAM_STRING); + if (rc < 0) + goto error; + if (rc) flags |=3D VIR_TYPED_PARAM_STRING_OKAY; =20 conn =3D domain->conn; @@ -2369,6 +2377,7 @@ virDomainGetBlkioParameters(virDomainPtr domain, int *nparams, unsigned int flags) { virConnectPtr conn; + int rc; =20 VIR_DOMAIN_DEBUG(domain, "params=3D%p, nparams=3D%d, flags=3D0x%x", params, (nparams) ? *nparams : -1, flags); @@ -2381,8 +2390,11 @@ virDomainGetBlkioParameters(virDomainPtr domain, if (*nparams !=3D 0) virCheckNonNullArgGoto(params, error); =20 - if (VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn, - VIR_DRV_FEATURE_TYPED_PARAM_STRING)) + rc =3D VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn, + VIR_DRV_FEATURE_TYPED_PARAM_STRING); + if (rc < 0) + goto error; + if (rc) flags |=3D VIR_TYPED_PARAM_STRING_OKAY; =20 VIR_EXCLUSIVE_FLAGS_GOTO(VIR_DOMAIN_AFFECT_LIVE, @@ -2851,12 +2863,14 @@ virDomainMigrateVersion2(virDomainPtr domain, return NULL; } =20 - if (VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn, - VIR_DRV_FEATURE_XML_MIGRATABLE)) { + ret =3D VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn, + VIR_DRV_FEATURE_XML_MIGRATABLE); + if (ret < 0) + return NULL; + if (ret) getxml_flags |=3D VIR_DOMAIN_XML_MIGRATABLE; - } else { + else getxml_flags |=3D VIR_DOMAIN_XML_SECURE | VIR_DOMAIN_XML_UPDATE_CP= U; - } =20 dom_xml =3D domain->conn->driver->domainGetXMLDesc(domain, getxml_flag= s); if (!dom_xml) @@ -3005,8 +3019,11 @@ virDomainMigrateVersion3Full(virDomainPtr domain, return NULL; params =3D tmp; =20 - if (VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn, - VIR_DRV_FEATURE_MIGRATE_CHANGE_PROTECTION= )) + ret =3D VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn, + VIR_DRV_FEATURE_MIGRATE_CHANGE_PROTECTI= ON); + if (ret < 0) + return NULL; + if (ret) protection =3D VIR_MIGRATE_CHANGE_PROTECTION; =20 VIR_DEBUG("Begin3 %p", domain->conn); @@ -3403,6 +3420,8 @@ virDomainMigrateUnmanagedParams(virDomainPtr domain, int nparams, unsigned int flags) { + int rc; + VIR_DOMAIN_DEBUG(domain, "dconnuri=3D%s, params=3D%p, nparams=3D%d, fl= ags=3D0x%x", NULLSTR(dconnuri), params, nparams, flags); VIR_TYPED_PARAMS_DEBUG(params, nparams); @@ -3411,19 +3430,28 @@ virDomainMigrateUnmanagedParams(virDomainPtr domain, virDomainMigrateCheckNotLocal(dconnuri) < 0) return -1; =20 - if ((flags & VIR_MIGRATE_PEER2PEER) && - VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn, - VIR_DRV_FEATURE_MIGRATION_PARAMS)) { - VIR_DEBUG("Using migration protocol 3 with extensible parameters"); - if (!domain->conn->driver->domainMigratePerform3Params) { - virReportUnsupportedError(); + if (flags & VIR_MIGRATE_PEER2PEER) { + rc =3D VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn, + VIR_DRV_FEATURE_MIGRATION_PARAMS); + if (rc < 0) return -1; + if (rc) { + VIR_DEBUG("Using migration protocol 3 with extensible paramete= rs"); + if (!domain->conn->driver->domainMigratePerform3Params) { + virReportUnsupportedError(); + return -1; + } + return domain->conn->driver->domainMigratePerform3Params + (domain, dconnuri, params, nparams, + NULL, 0, NULL, NULL, flags); } - return domain->conn->driver->domainMigratePerform3Params - (domain, dconnuri, params, nparams, - NULL, 0, NULL, NULL, flags); - } else if (VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn, - VIR_DRV_FEATURE_MIGRATION_V3)) { + } + + rc =3D VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn, + VIR_DRV_FEATURE_MIGRATION_V3); + if (rc < 0) + return -1; + if (rc) { VIR_DEBUG("Using migration protocol 3"); if (!domain->conn->driver->domainMigratePerform3) { virReportUnsupportedError(); @@ -3515,6 +3543,9 @@ virDomainMigrate(virDomainPtr domain, unsigned long bandwidth) { virDomainPtr ddomain =3D NULL; + int rc_src; + int rc_dst; + int rc; =20 VIR_DOMAIN_DEBUG(domain, "dconn=3D%p, flags=3D0x%lx, dname=3D%s, uri=3D%s, ban= dwidth=3D%lu", @@ -3539,25 +3570,33 @@ virDomainMigrate(virDomainPtr domain, error); =20 if (flags & VIR_MIGRATE_OFFLINE) { - if (!VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn, - VIR_DRV_FEATURE_MIGRATION_OFFLINE)) { - virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", - _("offline migration is not supported by " - "the source host")); + rc =3D VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn, + VIR_DRV_FEATURE_MIGRATION_OFFLINE); + if (rc <=3D 0) { + if (rc =3D=3D 0) + virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", + _("offline migration is not supported by " + "the source host")); goto error; } - if (!VIR_DRV_SUPPORTS_FEATURE(dconn->driver, dconn, - VIR_DRV_FEATURE_MIGRATION_OFFLINE)) { - virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", - _("offline migration is not supported by " - "the destination host")); + + rc =3D VIR_DRV_SUPPORTS_FEATURE(dconn->driver, dconn, + VIR_DRV_FEATURE_MIGRATION_OFFLINE); + if (rc <=3D 0) { + if (rc =3D=3D 0) + virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", + _("offline migration is not supported by " + "the destination host")); goto error; } } =20 if (flags & VIR_MIGRATE_PEER2PEER) { - if (VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn, - VIR_DRV_FEATURE_MIGRATION_P2P)) { + rc =3D VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn, + VIR_DRV_FEATURE_MIGRATION_P2P); + if (rc < 0) + goto error; + if (rc) { g_autofree char *dstURI =3D NULL; if (uri =3D=3D NULL) { dstURI =3D virConnectGetURI(dconn); @@ -3582,12 +3621,15 @@ virDomainMigrate(virDomainPtr domain, * the flag for just the source side. We mask it out for * non-peer2peer to allow migration from newer source to an * older destination that rejects the flag. */ - if (flags & VIR_MIGRATE_CHANGE_PROTECTION && - !VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn, - VIR_DRV_FEATURE_MIGRATE_CHANGE_PROTE= CTION)) { - virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", - _("cannot enforce change protection")); - goto error; + if (flags & VIR_MIGRATE_CHANGE_PROTECTION) { + rc =3D VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->= conn, + VIR_DRV_FEATURE_MIGRATE_CHANGE_P= ROTECTION); + if (rc <=3D 0) { + if (rc =3D=3D 0) + virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", + _("cannot enforce change protection")); + goto error; + } } flags &=3D ~VIR_MIGRATE_CHANGE_PROTECTION; if (flags & VIR_MIGRATE_TUNNELLED) { @@ -3597,34 +3639,57 @@ virDomainMigrate(virDomainPtr domain, } =20 /* Check that migration is supported by both drivers. */ - if (VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn, - VIR_DRV_FEATURE_MIGRATION_V3) && - VIR_DRV_SUPPORTS_FEATURE(dconn->driver, dconn, - VIR_DRV_FEATURE_MIGRATION_V3)) { + rc_src =3D VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->= conn, + VIR_DRV_FEATURE_MIGRATION_V3); + if (rc_src < 0) + goto error; + rc_dst =3D VIR_DRV_SUPPORTS_FEATURE(dconn->driver, dconn, + VIR_DRV_FEATURE_MIGRATION_V3); + if (rc_dst < 0) + goto error; + if (rc_src && rc_dst) { VIR_DEBUG("Using migration protocol 3"); ddomain =3D virDomainMigrateVersion3(domain, dconn, NULL, flags, dname, uri, bandwidt= h); - } else if (VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->= conn, - VIR_DRV_FEATURE_MIGRATION_V2) = && - VIR_DRV_SUPPORTS_FEATURE(dconn->driver, dconn, - VIR_DRV_FEATURE_MIGRATION_V2)) { + goto done; + } + + rc_src =3D VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->= conn, + VIR_DRV_FEATURE_MIGRATION_V2); + if (rc_src < 0) + goto error; + rc_dst =3D VIR_DRV_SUPPORTS_FEATURE(dconn->driver, dconn, + VIR_DRV_FEATURE_MIGRATION_V2); + if (rc_dst < 0) + goto error; + if (rc_src && rc_dst) { VIR_DEBUG("Using migration protocol 2"); ddomain =3D virDomainMigrateVersion2(domain, dconn, flags, dname, uri, bandwidth); - } else if (VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->= conn, - VIR_DRV_FEATURE_MIGRATION_V1) = && - VIR_DRV_SUPPORTS_FEATURE(dconn->driver, dconn, - VIR_DRV_FEATURE_MIGRATION_V1))= { + goto done; + } + + rc_src =3D VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->= conn, + VIR_DRV_FEATURE_MIGRATION_V1); + if (rc_src < 0) + goto error; + rc_dst =3D VIR_DRV_SUPPORTS_FEATURE(dconn->driver, dconn, + VIR_DRV_FEATURE_MIGRATION_V1); + if (rc_dst < 0) + goto error; + if (rc_src && rc_dst) { VIR_DEBUG("Using migration protocol 1"); ddomain =3D virDomainMigrateVersion1(domain, dconn, flags, dname, uri, bandwidth); - } else { - /* This driver does not support any migration method */ - virReportUnsupportedError(); - goto error; + goto done; } + + /* This driver does not support any migration method */ + virReportUnsupportedError(); + goto error; } =20 + done: if (ddomain =3D=3D NULL) goto error; =20 @@ -3671,6 +3736,9 @@ virDomainMigrate2(virDomainPtr domain, unsigned long bandwidth) { virDomainPtr ddomain =3D NULL; + int rc_src; + int rc_dst; + int rc; =20 VIR_DOMAIN_DEBUG(domain, "dconn=3D%p, flags=3D0x%lx, dname=3D%s, uri=3D%s, ban= dwidth=3D%lu", @@ -3695,25 +3763,32 @@ virDomainMigrate2(virDomainPtr domain, error); =20 if (flags & VIR_MIGRATE_OFFLINE) { - if (!VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn, - VIR_DRV_FEATURE_MIGRATION_OFFLINE)) { - virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", - _("offline migration is not supported by " - "the source host")); + rc =3D VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn, + VIR_DRV_FEATURE_MIGRATION_OFFLINE); + if (rc <=3D 0) { + if (rc =3D=3D 0) + virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", + _("offline migration is not supported by " + "the source host")); goto error; } - if (!VIR_DRV_SUPPORTS_FEATURE(dconn->driver, dconn, - VIR_DRV_FEATURE_MIGRATION_OFFLINE)) { - virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", - _("offline migration is not supported by " - "the destination host")); + rc =3D VIR_DRV_SUPPORTS_FEATURE(dconn->driver, dconn, + VIR_DRV_FEATURE_MIGRATION_OFFLINE); + if (rc <=3D 0) { + if (rc =3D=3D 0) + virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", + _("offline migration is not supported by " + "the destination host")); goto error; } } =20 if (flags & VIR_MIGRATE_PEER2PEER) { - if (VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn, - VIR_DRV_FEATURE_MIGRATION_P2P)) { + rc =3D VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn, + VIR_DRV_FEATURE_MIGRATION_P2P); + if (rc < 0) + goto error; + if (rc) { g_autofree char *dstURI =3D virConnectGetURI(dconn); if (!dstURI) return NULL; @@ -3735,12 +3810,15 @@ virDomainMigrate2(virDomainPtr domain, * the flag for just the source side. We mask it out for * non-peer2peer to allow migration from newer source to an * older destination that rejects the flag. */ - if (flags & VIR_MIGRATE_CHANGE_PROTECTION && - !VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn, - VIR_DRV_FEATURE_MIGRATE_CHANGE_PROTE= CTION)) { - virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", - _("cannot enforce change protection")); - goto error; + if (flags & VIR_MIGRATE_CHANGE_PROTECTION) { + rc =3D VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->= conn, + VIR_DRV_FEATURE_MIGRATE_CHANGE_P= ROTECTION); + if (rc <=3D 0) { + if (rc =3D=3D 0) + virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", + _("cannot enforce change protection")); + goto error; + } } flags &=3D ~VIR_MIGRATE_CHANGE_PROTECTION; if (flags & VIR_MIGRATE_TUNNELLED) { @@ -3750,17 +3828,30 @@ virDomainMigrate2(virDomainPtr domain, } =20 /* Check that migration is supported by both drivers. */ - if (VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn, - VIR_DRV_FEATURE_MIGRATION_V3) && - VIR_DRV_SUPPORTS_FEATURE(dconn->driver, dconn, - VIR_DRV_FEATURE_MIGRATION_V3)) { + rc_src =3D VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->= conn, + VIR_DRV_FEATURE_MIGRATION_V3); + if (rc_src < 0) + goto error; + rc_dst =3D VIR_DRV_SUPPORTS_FEATURE(dconn->driver, dconn, + VIR_DRV_FEATURE_MIGRATION_V3); + if (rc_dst < 0) + goto error; + if (rc_src && rc_dst) { VIR_DEBUG("Using migration protocol 3"); ddomain =3D virDomainMigrateVersion3(domain, dconn, dxml, flags, dname, uri, bandwidt= h); - } else if (VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->= conn, - VIR_DRV_FEATURE_MIGRATION_V2) = && - VIR_DRV_SUPPORTS_FEATURE(dconn->driver, dconn, - VIR_DRV_FEATURE_MIGRATION_V2)) { + goto done; + } + + rc_src =3D VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->= conn, + VIR_DRV_FEATURE_MIGRATION_V2); + if (rc_src < 0) + goto error; + rc_dst =3D VIR_DRV_SUPPORTS_FEATURE(dconn->driver, dconn, + VIR_DRV_FEATURE_MIGRATION_V2); + if (rc_dst < 0) + goto error; + if (rc_src && rc_dst) { VIR_DEBUG("Using migration protocol 2"); if (dxml) { virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", @@ -3769,10 +3860,18 @@ virDomainMigrate2(virDomainPtr domain, } ddomain =3D virDomainMigrateVersion2(domain, dconn, flags, dname, uri, bandwidth); - } else if (VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->= conn, - VIR_DRV_FEATURE_MIGRATION_V1) = && - VIR_DRV_SUPPORTS_FEATURE(dconn->driver, dconn, - VIR_DRV_FEATURE_MIGRATION_V1))= { + goto done; + } + + rc_src =3D VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->= conn, + VIR_DRV_FEATURE_MIGRATION_V1); + if (rc_src < 0) + goto error; + rc_dst =3D VIR_DRV_SUPPORTS_FEATURE(dconn->driver, dconn, + VIR_DRV_FEATURE_MIGRATION_V1); + if (rc_dst < 0) + goto error; + if (rc_src && rc_dst) { VIR_DEBUG("Using migration protocol 1"); if (dxml) { virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", @@ -3781,13 +3880,15 @@ virDomainMigrate2(virDomainPtr domain, } ddomain =3D virDomainMigrateVersion1(domain, dconn, flags, dname, uri, bandwidth); - } else { - /* This driver does not support any migration method */ - virReportUnsupportedError(); - goto error; + goto done; } + + /* This driver does not support any migration method */ + virReportUnsupportedError(); + goto error; } =20 + done: if (ddomain =3D=3D NULL) goto error; =20 @@ -3846,6 +3947,9 @@ virDomainMigrate3(virDomainPtr domain, const char *dname =3D NULL; const char *dxml =3D NULL; unsigned long long bandwidth =3D 0; + int rc_src; + int rc_dst; + int rc; =20 VIR_DOMAIN_DEBUG(domain, "dconn=3D%p, params=3D%p, nparms=3D%u flags= =3D0x%x", dconn, params, nparams, flags); @@ -3878,18 +3982,23 @@ virDomainMigrate3(virDomainPtr domain, } =20 if (flags & VIR_MIGRATE_OFFLINE) { - if (!VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn, - VIR_DRV_FEATURE_MIGRATION_OFFLINE)) { - virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", - _("offline migration is not supported by " - "the source host")); + rc =3D VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn, + VIR_DRV_FEATURE_MIGRATION_OFFLINE); + if (rc <=3D 0) { + if (rc =3D=3D 0) + virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", + _("offline migration is not supported by " + "the source host")); goto error; } - if (!VIR_DRV_SUPPORTS_FEATURE(dconn->driver, dconn, - VIR_DRV_FEATURE_MIGRATION_OFFLINE)) { - virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", - _("offline migration is not supported by " - "the destination host")); + + rc =3D VIR_DRV_SUPPORTS_FEATURE(dconn->driver, dconn, + VIR_DRV_FEATURE_MIGRATION_OFFLINE); + if (rc <=3D 0) { + if (rc =3D=3D 0) + virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", + _("offline migration is not supported by " + "the destination host")); goto error; } } @@ -3899,21 +4008,29 @@ virDomainMigrate3(virDomainPtr domain, * the flag for just the source side. We mask it out to allow * migration from newer source to an older destination that * rejects the flag. */ - if (flags & VIR_MIGRATE_CHANGE_PROTECTION && - !VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn, - VIR_DRV_FEATURE_MIGRATE_CHANGE_PROTECTIO= N)) { - virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", - _("cannot enforce change protection")); - goto error; + if (flags & VIR_MIGRATE_CHANGE_PROTECTION) { + rc =3D VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn, + VIR_DRV_FEATURE_MIGRATE_CHANGE_PROTE= CTION); + if (rc <=3D 0) { + if (rc =3D=3D 0) + virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", + _("cannot enforce change protection")); + goto error; + } } flags &=3D ~VIR_MIGRATE_CHANGE_PROTECTION; =20 /* Prefer extensible API but fall back to older migration APIs if para= ms * only contains parameters which were supported by the older API. */ - if (VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn, - VIR_DRV_FEATURE_MIGRATION_PARAMS) && - VIR_DRV_SUPPORTS_FEATURE(dconn->driver, dconn, - VIR_DRV_FEATURE_MIGRATION_PARAMS)) { + rc_src =3D VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn, + VIR_DRV_FEATURE_MIGRATION_PARAMS); + if (rc_src < 0) + goto error; + rc_dst =3D VIR_DRV_SUPPORTS_FEATURE(dconn->driver, dconn, + VIR_DRV_FEATURE_MIGRATION_PARAMS); + if (rc_dst < 0) + goto error; + if (rc_src && rc_dst) { VIR_DEBUG("Using migration protocol 3 with extensible parameters"); ddomain =3D virDomainMigrateVersion3Params(domain, dconn, params, nparams, flags); @@ -3939,17 +4056,30 @@ virDomainMigrate3(virDomainPtr domain, goto error; } =20 - if (VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn, - VIR_DRV_FEATURE_MIGRATION_V3) && - VIR_DRV_SUPPORTS_FEATURE(dconn->driver, dconn, - VIR_DRV_FEATURE_MIGRATION_V3)) { + rc_src =3D VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn, + VIR_DRV_FEATURE_MIGRATION_V3); + if (rc_src < 0) + goto error; + rc_dst =3D VIR_DRV_SUPPORTS_FEATURE(dconn->driver, dconn, + VIR_DRV_FEATURE_MIGRATION_V3); + if (rc_dst < 0) + goto error; + if (rc_src && rc_dst) { VIR_DEBUG("Using migration protocol 3"); ddomain =3D virDomainMigrateVersion3(domain, dconn, dxml, flags, dname, uri, bandwidth); - } else if (VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn, - VIR_DRV_FEATURE_MIGRATION_V2) && - VIR_DRV_SUPPORTS_FEATURE(dconn->driver, dconn, - VIR_DRV_FEATURE_MIGRATION_V2)) { + goto done; + } + + rc_src =3D VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn, + VIR_DRV_FEATURE_MIGRATION_V2); + if (rc_src < 0) + goto error; + rc_dst =3D VIR_DRV_SUPPORTS_FEATURE(dconn->driver, dconn, + VIR_DRV_FEATURE_MIGRATION_V2); + if (rc_dst < 0) + goto error; + if (rc_src && rc_dst) { VIR_DEBUG("Using migration protocol 2"); if (dxml) { virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", @@ -3959,10 +4089,18 @@ virDomainMigrate3(virDomainPtr domain, } ddomain =3D virDomainMigrateVersion2(domain, dconn, flags, dname, uri, bandwidth); - } else if (VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn, - VIR_DRV_FEATURE_MIGRATION_V1) && - VIR_DRV_SUPPORTS_FEATURE(dconn->driver, dconn, - VIR_DRV_FEATURE_MIGRATION_V1)) { + goto done; + } + + rc_src =3D VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn, + VIR_DRV_FEATURE_MIGRATION_V1); + if (rc_src < 0) + goto error; + rc_dst =3D VIR_DRV_SUPPORTS_FEATURE(dconn->driver, dconn, + VIR_DRV_FEATURE_MIGRATION_V1); + if (rc_dst < 0) + goto error; + if (rc_src && rc_dst) { VIR_DEBUG("Using migration protocol 1"); if (dxml) { virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", @@ -3972,12 +4110,13 @@ virDomainMigrate3(virDomainPtr domain, } ddomain =3D virDomainMigrateVersion1(domain, dconn, flags, dname, uri, bandwidth); - } else { - /* This driver does not support any migration method */ - virReportUnsupportedError(); - goto error; + goto done; } =20 + /* This driver does not support any migration method */ + virReportUnsupportedError(); + goto error; + done: if (ddomain =3D=3D NULL) goto error; @@ -3994,33 +4133,44 @@ static int virDomainMigrateUnmanagedCheckCompat(virDomainPtr domain, unsigned int flags) { + int rc; + VIR_EXCLUSIVE_FLAGS_RET(VIR_MIGRATE_NON_SHARED_DISK, VIR_MIGRATE_NON_SHARED_INC, -1); =20 - if (flags & VIR_MIGRATE_OFFLINE && - !VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn, - VIR_DRV_FEATURE_MIGRATION_OFFLINE)) { - virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", - _("offline migration is not supported by " - "the source host")); - return -1; + if (flags & VIR_MIGRATE_OFFLINE) { + rc =3D VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn, + VIR_DRV_FEATURE_MIGRATION_OFFLINE); + + if (rc <=3D 0) { + if (rc =3D=3D 0) + virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", + _("offline migration is not supported by " + "the source host")); + return -1; + } } =20 if (flags & VIR_MIGRATE_PEER2PEER) { - if (!VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn, - VIR_DRV_FEATURE_MIGRATION_P2P)) { - virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", - _("p2p migration is not supported by " - "the source host")); + rc =3D VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn, + VIR_DRV_FEATURE_MIGRATION_P2P); + + if (rc <=3D 0) { + if (rc =3D=3D 0) + virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", + _("p2p migration is not supported by " + "the source host")); return -1; } } else { - if (!VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn, - VIR_DRV_FEATURE_MIGRATION_DIRECT)) { - virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", - _("direct migration is not supported by " - "the source host")); + rc =3D VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn, + VIR_DRV_FEATURE_MIGRATION_DIRECT); + if (rc <=3D 0) { + if (rc =3D=3D 0) + virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", + _("direct migration is not supported by " + "the source host")); return -1; } } @@ -5201,6 +5351,7 @@ virDomainGetSchedulerParametersFlags(virDomainPtr dom= ain, unsigned int flags) { virConnectPtr conn; + int rc; =20 VIR_DOMAIN_DEBUG(domain, "params=3D%p, nparams=3D%p, flags=3D0x%x", params, nparams, flags); @@ -5213,8 +5364,11 @@ virDomainGetSchedulerParametersFlags(virDomainPtr do= main, virCheckNonNullArgGoto(nparams, error); virCheckPositiveArgGoto(*nparams, error); =20 - if (VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn, - VIR_DRV_FEATURE_TYPED_PARAM_STRING)) + rc =3D VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn, + VIR_DRV_FEATURE_TYPED_PARAM_STRING); + if (rc < 0) + goto error; + if (rc) flags |=3D VIR_TYPED_PARAM_STRING_OKAY; =20 VIR_EXCLUSIVE_FLAGS_GOTO(VIR_DOMAIN_AFFECT_LIVE, @@ -5465,6 +5619,7 @@ virDomainBlockStatsFlags(virDomainPtr dom, unsigned int flags) { virConnectPtr conn; + int rc; =20 VIR_DOMAIN_DEBUG(dom, "disk=3D%s, params=3D%p, nparams=3D%d, flags=3D0= x%x", disk, params, nparams ? *nparams : -1, flags); @@ -5478,8 +5633,11 @@ virDomainBlockStatsFlags(virDomainPtr dom, if (*nparams !=3D 0) virCheckNonNullArgGoto(params, error); =20 - if (VIR_DRV_SUPPORTS_FEATURE(dom->conn->driver, dom->conn, - VIR_DRV_FEATURE_TYPED_PARAM_STRING)) + rc =3D VIR_DRV_SUPPORTS_FEATURE(dom->conn->driver, dom->conn, + VIR_DRV_FEATURE_TYPED_PARAM_STRING); + if (rc < 0) + goto error; + if (rc) flags |=3D VIR_TYPED_PARAM_STRING_OKAY; conn =3D dom->conn; =20 @@ -5657,6 +5815,7 @@ virDomainGetInterfaceParameters(virDomainPtr domain, int *nparams, unsigned int flags) { virConnectPtr conn; + int rc; =20 VIR_DOMAIN_DEBUG(domain, "device=3D%s, params=3D%p, nparams=3D%d, flag= s=3D0x%x", device, params, (nparams) ? *nparams : -1, flags); @@ -5669,8 +5828,11 @@ virDomainGetInterfaceParameters(virDomainPtr domain, if (*nparams !=3D 0) virCheckNonNullArgGoto(params, error); =20 - if (VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn, - VIR_DRV_FEATURE_TYPED_PARAM_STRING)) + rc =3D VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn, + VIR_DRV_FEATURE_TYPED_PARAM_STRING); + if (rc < 0) + goto error; + if (rc) flags |=3D VIR_TYPED_PARAM_STRING_OKAY; =20 conn =3D domain->conn; @@ -10581,6 +10743,8 @@ virDomainOpenGraphics(virDomainPtr dom, unsigned int flags) { struct stat sb; + int rc; + VIR_DOMAIN_DEBUG(dom, "idx=3D%u, fd=3D%d, flags=3D0x%x", idx, fd, flags); =20 @@ -10606,10 +10770,12 @@ virDomainOpenGraphics(virDomainPtr dom, =20 virCheckReadOnlyGoto(dom->conn->flags, error); =20 - if (!VIR_DRV_SUPPORTS_FEATURE(dom->conn->driver, dom->conn, - VIR_DRV_FEATURE_FD_PASSING)) { - virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", - _("fd passing is not supported by this connection")= ); + rc =3D VIR_DRV_SUPPORTS_FEATURE(dom->conn->driver, dom->conn, + VIR_DRV_FEATURE_FD_PASSING); + if (rc <=3D 0) { + if (rc =3D=3D 0) + virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", + _("fd passing is not supported by this connecti= on")); goto error; } =20 @@ -10655,6 +10821,8 @@ virDomainOpenGraphicsFD(virDomainPtr dom, unsigned int idx, unsigned int flags) { + int rc; + VIR_DOMAIN_DEBUG(dom, "idx=3D%u, flags=3D0x%x", idx, flags); =20 virResetLastError(); @@ -10663,10 +10831,13 @@ virDomainOpenGraphicsFD(virDomainPtr dom, =20 virCheckReadOnlyGoto(dom->conn->flags, error); =20 - if (!VIR_DRV_SUPPORTS_FEATURE(dom->conn->driver, dom->conn, - VIR_DRV_FEATURE_FD_PASSING)) { - virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", - _("fd passing is not supported by this connection")= ); + rc =3D VIR_DRV_SUPPORTS_FEATURE(dom->conn->driver, dom->conn, + VIR_DRV_FEATURE_FD_PASSING); + + if (rc <=3D 0) { + if (rc =3D=3D 0) + virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", + _("fd passing is not supported by this connecti= on")); goto error; } =20 @@ -10789,6 +10960,7 @@ virDomainGetBlockIoTune(virDomainPtr dom, unsigned int flags) { virConnectPtr conn; + int rc; =20 VIR_DOMAIN_DEBUG(dom, "disk=3D%s, params=3D%p, nparams=3D%d, flags=3D0= x%x", NULLSTR(disk), params, (nparams) ? *nparams : -1, fla= gs); @@ -10804,8 +10976,11 @@ virDomainGetBlockIoTune(virDomainPtr dom, virCheckNonNullArgGoto(disk, error); } =20 - if (VIR_DRV_SUPPORTS_FEATURE(dom->conn->driver, dom->conn, - VIR_DRV_FEATURE_TYPED_PARAM_STRING)) + rc =3D VIR_DRV_SUPPORTS_FEATURE(dom->conn->driver, dom->conn, + VIR_DRV_FEATURE_TYPED_PARAM_STRING); + if (rc < 0) + goto error; + if (rc) flags |=3D VIR_TYPED_PARAM_STRING_OKAY; =20 VIR_EXCLUSIVE_FLAGS_GOTO(VIR_DOMAIN_AFFECT_LIVE, @@ -10915,6 +11090,7 @@ virDomainGetCPUStats(virDomainPtr domain, unsigned int flags) { virConnectPtr conn; + int rc; =20 VIR_DOMAIN_DEBUG(domain, "params=3D%p, nparams=3D%d, start_cpu=3D%d, ncpus=3D%= u, flags=3D0x%x", @@ -10952,8 +11128,11 @@ virDomainGetCPUStats(virDomainPtr domain, nparams, ncpus); goto error; } - if (VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn, - VIR_DRV_FEATURE_TYPED_PARAM_STRING)) + rc =3D VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn, + VIR_DRV_FEATURE_TYPED_PARAM_STRING); + if (rc < 0) + goto error; + if (rc) flags |=3D VIR_TYPED_PARAM_STRING_OKAY; =20 if (conn->driver->domainGetCPUStats) { @@ -12563,6 +12742,7 @@ int virDomainGetLaunchSecurityInfo(virDomainPtr dom= ain, unsigned int flags) { virConnectPtr conn =3D domain->conn; + int rc; =20 VIR_DOMAIN_DEBUG(domain, "params=3D%p, nparams=3D%p flags=3D0x%x", params, nparams, flags); @@ -12574,8 +12754,11 @@ int virDomainGetLaunchSecurityInfo(virDomainPtr do= main, virCheckNonNullArgGoto(nparams, error); virCheckReadOnlyGoto(conn->flags, error); =20 - if (VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn, - VIR_DRV_FEATURE_TYPED_PARAM_STRING)) + rc =3D VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn, + VIR_DRV_FEATURE_TYPED_PARAM_STRING); + if (rc < 0) + goto error; + if (rc) flags |=3D VIR_TYPED_PARAM_STRING_OKAY; =20 if (conn->driver->domainGetLaunchSecurityInfo) { diff --git a/src/libvirt-host.c b/src/libvirt-host.c index 58622d4..8e680cb 100644 --- a/src/libvirt-host.c +++ b/src/libvirt-host.c @@ -772,6 +772,8 @@ virNodeGetMemoryParameters(virConnectPtr conn, int *nparams, unsigned int flags) { + int rc; + VIR_DEBUG("conn=3D%p, params=3D%p, nparams=3D%p, flags=3D0x%x", conn, params, nparams, flags); =20 @@ -783,8 +785,11 @@ virNodeGetMemoryParameters(virConnectPtr conn, if (*nparams !=3D 0) virCheckNonNullArgGoto(params, error); =20 - if (VIR_DRV_SUPPORTS_FEATURE(conn->driver, conn, - VIR_DRV_FEATURE_TYPED_PARAM_STRING)) + rc =3D VIR_DRV_SUPPORTS_FEATURE(conn->driver, conn, + VIR_DRV_FEATURE_TYPED_PARAM_STRING); + if (rc < 0) + goto error; + if (rc) flags |=3D VIR_TYPED_PARAM_STRING_OKAY; =20 if (conn->driver->nodeGetMemoryParameters) { @@ -1724,6 +1729,8 @@ virNodeGetSEVInfo(virConnectPtr conn, int *nparams, unsigned int flags) { + int rc; + VIR_DEBUG("conn=3D%p, params=3D%p, nparams=3D%p, flags=3D0x%x", conn, params, nparams, flags); =20 @@ -1734,8 +1741,11 @@ virNodeGetSEVInfo(virConnectPtr conn, virCheckNonNegativeArgGoto(*nparams, error); virCheckReadOnlyGoto(conn->flags, error); =20 - if (VIR_DRV_SUPPORTS_FEATURE(conn->driver, conn, - VIR_DRV_FEATURE_TYPED_PARAM_STRING)) + rc =3D VIR_DRV_SUPPORTS_FEATURE(conn->driver, conn, + VIR_DRV_FEATURE_TYPED_PARAM_STRING); + if (rc < 0) + goto error; + if (rc) flags |=3D VIR_TYPED_PARAM_STRING_OKAY; =20 if (conn->driver->nodeGetSEVInfo) { diff --git a/src/libvirt.c b/src/libvirt.c index 63c8bde..5778b5d 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -1336,12 +1336,13 @@ virTypedParameterValidateSet(virConnectPtr conn, virTypedParameterPtr params, int nparams) { - bool string_okay; + int string_okay; size_t i; =20 - string_okay =3D VIR_DRV_SUPPORTS_FEATURE(conn->driver, - conn, + string_okay =3D VIR_DRV_SUPPORTS_FEATURE(conn->driver, conn, VIR_DRV_FEATURE_TYPED_PARAM_STR= ING); + if (string_okay < 0) + return -1; for (i =3D 0; i < nparams; i++) { if (strnlen(params[i].field, VIR_TYPED_PARAM_FIELD_LENGTH) =3D=3D VIR_TYPED_PARAM_FIELD_LENGTH) { --=20 1.8.3.1 From nobody Tue May 14 12:14:19 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; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=quarantine dis=quarantine) header.from=virtuozzo.com ARC-Seal: i=1; a=rsa-sha256; t=1608274870; cv=none; d=zohomail.com; s=zohoarc; b=mH9RSMPD/8zeqfmlTxeEiMYmF/2p97OgO/7qsVO8mPI7wpaj1lvT8crBgb1FqWs5VQcrkB1//ThcX2COl//Y+VKqWW7p44ZNcCP91y7eSu3d3sOwLuftqsFmwgp9G9OWhYA597312z+PEwC/N2K2Hhnn+/gr77VrcrqxrQ789Kc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1608274870; h=Content-Type:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=CCPkm9wdprXHc7CtoucLii0DZ6/3c0KkqFRQAqh4k3s=; b=HkZ4eJq2Xv+iEC6159L3P87KYbUpr5bQ7HyBAgIeNvuh02dltTqd6yOV33T7K1JykUvZuphnfUISKLl0DMnEnpUsCuw7FtczjKEt9wDZRGGvrWXdPOJxwvN6OlLBKmrhvQqIDlqfAH5R5sOV33Cwg4M3QpU1z1h2MBH/i5wWrG8= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=quarantine dis=quarantine) 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 1608274870171446.7995038215289; Thu, 17 Dec 2020 23:01: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-17-TUaGqKblP2qv2THHlMMswQ-1; Fri, 18 Dec 2020 02:01:01 -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 A4A0B8144EF; Fri, 18 Dec 2020 07:00:51 +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 7DEEB10013C0; Fri, 18 Dec 2020 07:00:51 +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 369094E590; Fri, 18 Dec 2020 07:00:51 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0BI6waar028478 for ; Fri, 18 Dec 2020 01:58:36 -0500 Received: by smtp.corp.redhat.com (Postfix) id 3A590F00FD; Fri, 18 Dec 2020 06:58:36 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast03.extmail.prod.ext.rdu2.redhat.com [10.11.55.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 354BDF00EE for ; Fri, 18 Dec 2020 06:58:33 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CE63A811E76 for ; Fri, 18 Dec 2020 06:58:33 +0000 (UTC) Received: from relay3.sw.ru (relay.sw.ru [185.231.240.75]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-516-FdXC_TjQO9u9dQXaPWIBqw-1; Fri, 18 Dec 2020 01:58:31 -0500 Received: from [10.28.15.168] (helo=vz7.sw.ru.) by relay3.sw.ru with esmtp (Exim 4.94) (envelope-from ) id 1kq9iF-00DT1e-Ui for libvir-list@redhat.com; Fri, 18 Dec 2020 09:58:03 +0300 X-MC-Unique: TUaGqKblP2qv2THHlMMswQ-1 X-MC-Unique: FdXC_TjQO9u9dQXaPWIBqw-1 From: Nikolay Shirokovskiy To: libvir-list@redhat.com Subject: [PATCH v3 2/4] libxl: adopt to VIR_DRV_SUPPORTS_FEATURE return -1 Date: Fri, 18 Dec 2020 09:56:46 +0300 Message-Id: <1608274608-818018-3-git-send-email-nshirokovskiy@virtuozzo.com> In-Reply-To: <1608274608-818018-1-git-send-email-nshirokovskiy@virtuozzo.com> References: <1608274608-818018-1-git-send-email-nshirokovskiy@virtuozzo.com> X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 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: 2 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Otherwise in some places we can mistakenly report 'unsupported' error inste= ad of root cause. So let's handle root cause explicitly from the macro. Signed-off-by: Nikolay Shirokovskiy Reviewed-by: Daniel P. Berrang=C3=A9 --- src/libxl/libxl_migration.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/libxl/libxl_migration.c b/src/libxl/libxl_migration.c index 6dc6812..2925aaa 100644 --- a/src/libxl/libxl_migration.c +++ b/src/libxl/libxl_migration.c @@ -1146,7 +1146,7 @@ libxlDomainMigrationSrcPerformP2P(libxlDriverPrivateP= tr driver, unsigned int flags) { int ret =3D -1; - bool useParams; + int useParams; virConnectPtr dconn =3D NULL; virErrorPtr orig_err =3D NULL; libxlDriverConfigPtr cfg =3D libxlDriverConfigGet(driver); @@ -1171,9 +1171,11 @@ libxlDomainMigrationSrcPerformP2P(libxlDriverPrivate= Ptr driver, VIR_DRV_FEATURE_MIGRATION_PARAMS); virObjectLock(vm); =20 - if (!useParams) { - virReportError(VIR_ERR_OPERATION_FAILED, "%s", - _("Destination libvirt does not support migration w= ith extensible parameters")); + if (useParams <=3D 0) { + if (useParams =3D=3D 0) + virReportError(VIR_ERR_OPERATION_FAILED, "%s", + _("Destination libvirt does not support migrati= on" + " with extensible parameters")); goto cleanup; } =20 --=20 1.8.3.1 From nobody Tue May 14 12:14:19 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; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=quarantine dis=quarantine) header.from=virtuozzo.com ARC-Seal: i=1; a=rsa-sha256; t=1608274867; cv=none; d=zohomail.com; s=zohoarc; b=Ar1Ou3uNXw57i7LTL9bvHz01H69Q5tDWYpRr3nQFX/B8yuyhbN1zTRQg9Oz3K0bPVFjZ1enGCQGQsTYSixN27/SnN9ELr1S7/9JmeS5+zgWRRAMfGqbiPANBP62ZFxpmzQjfiOzWJf2dhqcxubzBbN9gITH9oqpmMVp6GVtCu0U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1608274867; h=Content-Type:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=ScL+0y0C4dn3N0Bz8Zt4g2twJZDQy1HmN15mKwpIQ2M=; b=KjOPnEsibhn9UTY0FpJrNcFsZ0faAkX9o3qppEfD2Jz294808y9nAHwAI7UC8vueY8wj9Pg4z/tXQ01oHLygUfCRKkK/t5p7WhMkKaTKBFXfSKrm7Yp9kWXQT/7YofKlnLczJ1+rJfMjRt7VK9SlivTobsXXcHBoINng0SIKf50= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=quarantine dis=quarantine) 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 1608274867417747.9834093914744; Thu, 17 Dec 2020 23:01: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-165--1-tY8DdMEWEAPwFef-pcQ-1; Fri, 18 Dec 2020 02:01:02 -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 6E599B8136; Fri, 18 Dec 2020 07:00:56 +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 4632A10013C0; Fri, 18 Dec 2020 07:00:56 +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 CFC601809CA0; Fri, 18 Dec 2020 07:00:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0BI6wx8C028503 for ; Fri, 18 Dec 2020 01:58:59 -0500 Received: by smtp.corp.redhat.com (Postfix) id B1869F00FD; Fri, 18 Dec 2020 06:58:59 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast03.extmail.prod.ext.rdu2.redhat.com [10.11.55.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AC95AF00EE for ; Fri, 18 Dec 2020 06:58:57 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 58334811E76 for ; Fri, 18 Dec 2020 06:58:57 +0000 (UTC) Received: from relay3.sw.ru (relay.sw.ru [185.231.240.75]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-494-OglBSj0LPViOFOFKFKRIBg-1; Fri, 18 Dec 2020 01:58:54 -0500 Received: from [10.28.15.168] (helo=vz7.sw.ru.) by relay3.sw.ru with esmtp (Exim 4.94) (envelope-from ) id 1kq9id-00DT1e-K8 for libvir-list@redhat.com; Fri, 18 Dec 2020 09:58:27 +0300 X-MC-Unique: -1-tY8DdMEWEAPwFef-pcQ-1 X-MC-Unique: OglBSj0LPViOFOFKFKRIBg-1 From: Nikolay Shirokovskiy To: libvir-list@redhat.com Subject: [PATCH v3 3/4] qemu: adopt to VIR_DRV_SUPPORTS_FEATURE return -1 Date: Fri, 18 Dec 2020 09:56:47 +0300 Message-Id: <1608274608-818018-4-git-send-email-nshirokovskiy@virtuozzo.com> In-Reply-To: <1608274608-818018-1-git-send-email-nshirokovskiy@virtuozzo.com> References: <1608274608-818018-1-git-send-email-nshirokovskiy@virtuozzo.com> X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 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: 2 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Otherwise in some places we can mistakenly report 'unsupported' error inste= ad of root cause. So let's handle root cause explicitly from the macro. Signed-off-by: Nikolay Shirokovskiy Reviewed-by: Daniel P. Berrang=C3=A9 --- src/qemu/qemu_migration.c | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 90b0ec9..fca21be 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -4706,12 +4706,13 @@ qemuMigrationSrcPerformPeer2Peer(virQEMUDriverPtr d= river, { int ret =3D -1; g_autoptr(virConnect) dconn =3D NULL; - bool p2p; + int p2p; virErrorPtr orig_err =3D NULL; bool offline =3D !!(flags & VIR_MIGRATE_OFFLINE); - bool dstOffline =3D false; + int dstOffline; g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); - bool useParams; + int useParams; + int rc; =20 VIR_DEBUG("driver=3D%p, sconn=3D%p, vm=3D%p, xmlin=3D%s, dconnuri=3D%s= , uri=3D%s, " "graphicsuri=3D%s, listenAddress=3D%s, nmigrate_disks=3D%zu,= " @@ -4771,17 +4772,27 @@ qemuMigrationSrcPerformPeer2Peer(virQEMUDriverPtr d= river, qemuDomainObjEnterRemote(vm); p2p =3D VIR_DRV_SUPPORTS_FEATURE(dconn->driver, dconn, VIR_DRV_FEATURE_MIGRATION_P2P); - /* v3proto reflects whether the caller used Perform3, but with - * p2p migrate, regardless of whether Perform2 or Perform3 - * were used, we decide protocol based on what target supports - */ - *v3proto =3D VIR_DRV_SUPPORTS_FEATURE(dconn->driver, dconn, - VIR_DRV_FEATURE_MIGRATION_V3); + if (p2p < 0) + goto cleanup; + /* v3proto reflects whether the caller used Perform3, but with + * p2p migrate, regardless of whether Perform2 or Perform3 + * were used, we decide protocol based on what target supports + */ + rc =3D VIR_DRV_SUPPORTS_FEATURE(dconn->driver, dconn, + VIR_DRV_FEATURE_MIGRATION_V3); + if (rc < 0) + goto cleanup; + *v3proto =3D !!rc; useParams =3D VIR_DRV_SUPPORTS_FEATURE(dconn->driver, dconn, VIR_DRV_FEATURE_MIGRATION_PARAMS); - if (offline) + if (useParams < 0) + goto cleanup; + if (offline) { dstOffline =3D VIR_DRV_SUPPORTS_FEATURE(dconn->driver, dconn, VIR_DRV_FEATURE_MIGRATION_OF= FLINE); + if (dstOffline < 0) + goto cleanup; + } if (qemuDomainObjExitRemote(vm, !offline) < 0) goto cleanup; =20 @@ -4819,7 +4830,7 @@ qemuMigrationSrcPerformPeer2Peer(virQEMUDriverPtr dri= ver, persist_xml, dname, uri, g= raphicsuri, listenAddress, nmigrate_di= sks, migrate_disks, nbdPort, nbdURI, migParams= , resource, - useParams, flags); + !!useParams, flags); } else { ret =3D qemuMigrationSrcPerformPeer2Peer2(driver, sconn, dconn, vm, dconnuri, flags, dname, re= source, --=20 1.8.3.1 From nobody Tue May 14 12:14:19 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; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=quarantine dis=quarantine) header.from=virtuozzo.com ARC-Seal: i=1; a=rsa-sha256; t=1608274848; cv=none; d=zohomail.com; s=zohoarc; b=arGMwY1kuGzOXfqp0e1DVeqKKbIIkDye5OslR28fLUp3UaXCKwwWmB9DPuNxc+WbJL6+aOWZPdSpb/dL4BNFPP9ibLBrhUFX0+eVvjFla4NP5C4cB9n5g5B0fuhfXl6euOGsWDnPAwf8ODo5UqMp/LCAtnq7rlBsN4UcRoY4M3o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1608274848; h=Content-Type:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=2T9YLyrulHOcp6D7R68S4KBpeQ47YJwMcycXCHTVJeo=; b=DqExiLekYsVQDhxvPVYwRaPGmuvFgVohBqPwW+h3QcZSFTQzJGsiY/Bq0mTyPuHarEdXPW7nwnp9EDeZ2SFcjgQnWyS2+lJtqncTPxtyeq1Jt4K6LCrhOI2AGpEnPOkrQz7yt+ZN+KL6+12vgXorgN39m2a5nBVkX/WXB+Z/Q5I= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=quarantine dis=quarantine) 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 1608274847927226.42221126921277; Thu, 17 Dec 2020 23:00:47 -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-474-C911cZ_4PI62PRE_sKx04Q-1; Fri, 18 Dec 2020 02:00:42 -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 2AAC3C73CF; Fri, 18 Dec 2020 07:00:25 +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 2F3A45DA71; Fri, 18 Dec 2020 07:00:21 +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 89F3F4BB7B; Fri, 18 Dec 2020 07:00:16 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0BI6xNXc028529 for ; Fri, 18 Dec 2020 01:59:23 -0500 Received: by smtp.corp.redhat.com (Postfix) id A1B331031F25; Fri, 18 Dec 2020 06:59:23 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast04.extmail.prod.ext.rdu2.redhat.com [10.11.55.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 98E16101F0AD for ; Fri, 18 Dec 2020 06:59:21 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 44447101A560 for ; Fri, 18 Dec 2020 06:59:21 +0000 (UTC) Received: from relay3.sw.ru (relay.sw.ru [185.231.240.75]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-522-vRWPr3eiMN22EQP4V8DFiw-1; Fri, 18 Dec 2020 01:59:18 -0500 Received: from [10.28.15.168] (helo=vz7.sw.ru.) by relay3.sw.ru with esmtp (Exim 4.94) (envelope-from ) id 1kq9j1-00DT1e-Fv for libvir-list@redhat.com; Fri, 18 Dec 2020 09:58:51 +0300 X-MC-Unique: C911cZ_4PI62PRE_sKx04Q-1 X-MC-Unique: vRWPr3eiMN22EQP4V8DFiw-1 From: Nikolay Shirokovskiy To: libvir-list@redhat.com Subject: [PATCH v3 4/4] src: don't hide error in VIR_DRV_SUPPORTS_FEATURE Date: Fri, 18 Dec 2020 09:56:48 +0300 Message-Id: <1608274608-818018-5-git-send-email-nshirokovskiy@virtuozzo.com> In-Reply-To: <1608274608-818018-1-git-send-email-nshirokovskiy@virtuozzo.com> References: <1608274608-818018-1-git-send-email-nshirokovskiy@virtuozzo.com> X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 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: 2 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Otherwise we can get misleading error messages. One example is when connect= ion is broken we got "this function is not supported by the connection driver: virDomainMigrate3" from virDomainMigrate3. Signed-off-by: Nikolay Shirokovskiy Reviewed-by: Daniel P. Berrang=C3=A9 --- src/driver.h | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/driver.h b/src/driver.h index 6278aa0..2531ac3 100644 --- a/src/driver.h +++ b/src/driver.h @@ -47,17 +47,14 @@ typedef enum { * directly if you don't have to, because it may be NULL, use this macro * instead. * - * Note that this treats a possible error returned by drv->supports_feature - * the same as not supported. If you care about the error, call - * drv->supports_feature directly. - * * Returns: - * !=3D 0 Feature is supported. + * -1 Error + * >0 Feature is supported. * 0 Feature is not supported. */ #define VIR_DRV_SUPPORTS_FEATURE(drv, conn, feature) \ ((drv)->connectSupportsFeature ? \ - (drv)->connectSupportsFeature((conn), (feature)) > 0 : 0) + (drv)->connectSupportsFeature((conn), (feature)) : 0) =20 =20 #define __VIR_DRIVER_H_INCLUDES___ --=20 1.8.3.1