From nobody Fri Mar 29 08:07:05 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=1609935979; cv=none; d=zohomail.com; s=zohoarc; b=CGWsuZ6nSerGsFZO44fT1j7DQUyhyo3Mqf0rP6UBYmmYYaBmKEGEV6Uaygk/hyuFJs++KRDxlQxjqY+x7V5s69Qdvkrsl74f3S7/CoQeOpg1i55WU7qKT55ZM6irIPrrBIWMWd2Tssib7br5LI7qr3upfvISWbPPb0xDTL1c9sw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1609935979; 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=I7z43j1QqZqSCTAsFk/g7zFnbk1WaccskNd1FeDvdJ4=; b=Tj5x0XhTs3eGACv1MJfmj35uU+39RZM7aGPSKzF/X1VEobhspwXnZCCzm5SYmACrfrY0o8Cbfx3YPD1ZTh4We+0/qtk9cd2FjrEaDNcgnquMGK2kL6JbOy+PvQzhSmnH0bzpTEs9VpTrYLJtubwP5wGazewYYRu+KIzzTQwlqSk= 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 1609935979637215.30486339773518; Wed, 6 Jan 2021 04:26:19 -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-317-RIIGrM-qPi6ZDZv391geDg-1; Wed, 06 Jan 2021 07:26:16 -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 1E381190A7A0; Wed, 6 Jan 2021 12:26:10 +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 AFFE05D9CA; Wed, 6 Jan 2021 12:26:09 +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 3C08C4A7C6; Wed, 6 Jan 2021 12:26:07 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 106CQ5Wm019006 for ; Wed, 6 Jan 2021 07:26:05 -0500 Received: by smtp.corp.redhat.com (Postfix) id AC75160BE5; Wed, 6 Jan 2021 12:26:05 +0000 (UTC) Received: from antique-work.lan (unknown [10.40.194.49]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2935660BE2 for ; Wed, 6 Jan 2021 12:26:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1609935978; 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=I7z43j1QqZqSCTAsFk/g7zFnbk1WaccskNd1FeDvdJ4=; b=HMstNbtN2n/pLaSxsdABVBUSIAjZIAMAODi9u7DdxcnhfD2chYgY1kgIXOe7Azed6aZ9Rg sGyqiprMRBNC3JgWI6Ep0NiOjApBs44KQCD9qatXFXa3cq6uXkth00n9VroUqyvXv8txjR M4Z72xarwq/NEEosmfEJd3uTwtMeReE= X-MC-Unique: RIIGrM-qPi6ZDZv391geDg-1 From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH v2 1/9] util: remove unused virStorageGenerateQcowPassphrase Date: Wed, 6 Jan 2021 13:25:52 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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 last user was removed by commit <40f0e0348dfc84f28a500e262c4953b0d3b44fa0>. Signed-off-by: Pavel Hrdina Reviewed-by: Peter Krempa --- src/libvirt_private.syms | 1 - src/util/virstorageencryption.c | 34 --------------------------------- src/util/virstorageencryption.h | 2 -- 3 files changed, 37 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 583fc5800e..d7714361d3 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -3118,7 +3118,6 @@ virSocketAddrSetPort; virStorageEncryptionFormat; virStorageEncryptionFree; virStorageEncryptionParseNode; -virStorageGenerateQcowPassphrase; =20 =20 # util/virstoragefile.h diff --git a/src/util/virstorageencryption.c b/src/util/virstorageencryptio= n.c index a330b79637..c893f0babe 100644 --- a/src/util/virstorageencryption.c +++ b/src/util/virstorageencryption.c @@ -364,37 +364,3 @@ virStorageEncryptionFormat(virBufferPtr buf, =20 return 0; } - -int -virStorageGenerateQcowPassphrase(unsigned char *dest) -{ - int fd; - size_t i; - - /* A qcow passphrase is up to 16 bytes, with any data following a NUL - ignored. Prohibit control and non-ASCII characters to avoid possib= le - unpleasant surprises with the qemu monitor input mechanism. */ - fd =3D open("/dev/urandom", O_RDONLY); - if (fd < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Cannot open /dev/urandom")); - return -1; - } - i =3D 0; - while (i < VIR_STORAGE_QCOW_PASSPHRASE_SIZE) { - ssize_t r; - - while ((r =3D read(fd, dest + i, 1)) =3D=3D -1 && errno =3D=3D EIN= TR) - ; - if (r <=3D 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Cannot read from /dev/urandom")); - VIR_FORCE_CLOSE(fd); - return -1; - } - if (dest[i] >=3D 0x20 && dest[i] <=3D 0x7E) - i++; /* Got an acceptable character */ - } - VIR_FORCE_CLOSE(fd); - return 0; -} diff --git a/src/util/virstorageencryption.h b/src/util/virstorageencryptio= n.h index 05a7bffdfc..352dd373d6 100644 --- a/src/util/virstorageencryption.h +++ b/src/util/virstorageencryption.h @@ -90,5 +90,3 @@ int virStorageEncryptionFormat(virBufferPtr buf, enum { VIR_STORAGE_QCOW_PASSPHRASE_SIZE =3D 16 }; - -int virStorageGenerateQcowPassphrase(unsigned char *dest); --=20 2.29.2 From nobody Fri Mar 29 08:07:05 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=1609936029; cv=none; d=zohomail.com; s=zohoarc; b=Wh5FrEMedLRBGgiLRXP30NwXAbfouCncSssgeN6zJzvD3lKQLn+cofacyDi6dBPNiy+OqcqtcLrbtaTeKVlWg1mRQ2OJpkii6c4DYf/1/Dtx4G922ui1fqbNsza+Ci9i10LR+wiTzrAITqTe9/DkgGpOntt6IzZfYMgyYdpzeNE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1609936029; 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=CgmPnAgSCXY5GVAglqklbx6tzNZ+uO6TxaRQHzikv00=; b=lTbetHJZW1dEkU1uyIdGKGhew76EADRV9aKhtXDVYfGjPzgRsdqzrPKyQGBackYHQiMhhyCrhE632/95IW3Kejzn/2XMHI1xrzEl9/6X2u1Z37D9reYLFSJkckNvGSrFT3O4ye/sFISWjerGjewh0KQO4dDNKsoHWiR42mkocK8= 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 1609936029800393.08518241232184; Wed, 6 Jan 2021 04:27:09 -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-464-Twkl2jEbMxKZ3lhwSH52vA-1; Wed, 06 Jan 2021 07:26:23 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A699D107ACF8; Wed, 6 Jan 2021 12:26:17 +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 85AD060BFA; Wed, 6 Jan 2021 12:26:17 +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 4FC8A1809CA4; Wed, 6 Jan 2021 12:26:17 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 106CQ6Us019017 for ; Wed, 6 Jan 2021 07:26:06 -0500 Received: by smtp.corp.redhat.com (Postfix) id 907F260BE5; Wed, 6 Jan 2021 12:26:06 +0000 (UTC) Received: from antique-work.lan (unknown [10.40.194.49]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0D79C60BE2 for ; Wed, 6 Jan 2021 12:26:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1609936028; 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=CgmPnAgSCXY5GVAglqklbx6tzNZ+uO6TxaRQHzikv00=; b=MlZSouQOf9NTmi8EOUqSFAycLiFkoRoEe+eJ84OGjnkciRN6+/AuVmCwbp5M1ibgRpFuP4 bxtrdYZliChBf0M/+v98NExhuci84lmEW/NtGHI8UCdLqjyijveqqCrf1cEx3v4XE2nXPJ PMD78C9alhA1ap6rWuzJJqjZFL8tNpY= X-MC-Unique: Twkl2jEbMxKZ3lhwSH52vA-1 From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH v2 2/9] virstoragefile: remove unused virStorageFileChainCheckBroken Date: Wed, 6 Jan 2021 13:25:53 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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.12 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 last usage outside of tests was removed by commit <780f8c94ca8b3dee7eb59c1bfbc32f672f965df8>. Signed-off-by: Pavel Hrdina Reviewed-by: Peter Krempa --- src/libvirt_private.syms | 1 - src/util/virstoragefile.c | 33 --------------------------------- src/util/virstoragefile.h | 3 --- tests/virstoragetest.c | 6 ------ 4 files changed, 43 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index d7714361d3..f8da4a7648 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -3127,7 +3127,6 @@ virStorageAuthDefFree; virStorageAuthDefParse; virStorageFileAccess; virStorageFileCanonicalizePath; -virStorageFileChainGetBroken; virStorageFileChainLookup; virStorageFileChown; virStorageFileCreate; diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index fac93118fd..119342d296 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -1193,39 +1193,6 @@ virStorageFileGetMetadataFromFD(const char *path, } =20 =20 -/** - * virStorageFileChainCheckBroken - * - * If CHAIN is broken, set *brokenFile to the broken file name, - * otherwise set it to NULL. Caller MUST free *brokenFile after use. - * Return 0 on success (including when brokenFile is set), negative on - * error (allocation failure). - */ -int -virStorageFileChainGetBroken(virStorageSourcePtr chain, - char **brokenFile) -{ - virStorageSourcePtr tmp; - - *brokenFile =3D NULL; - - if (!chain) - return 0; - - for (tmp =3D chain; virStorageSourceIsBacking(tmp); tmp =3D tmp->backi= ngStore) { - /* Break when we hit end of chain; report error if we detected - * a missing backing file, infinite loop, or other error */ - if (!tmp->backingStore && tmp->backingStoreRaw) { - *brokenFile =3D g_strdup(tmp->backingStoreRaw); - - return 0; - } - } - - return 0; -} - - /** * virStorageFileResize: * diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h index 87763cf389..cc9bd4875f 100644 --- a/src/util/virstoragefile.h +++ b/src/util/virstoragefile.h @@ -403,9 +403,6 @@ virStorageSourcePtr virStorageFileGetMetadataFromBuf(co= nst char *path, size_t len, int format) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); -int virStorageFileChainGetBroken(virStorageSourcePtr chain, - char **broken_file); - int virStorageFileParseChainIndex(const char *diskTarget, const char *name, unsigned int *chainIndex) diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c index 2e466ecb99..a376154def 100644 --- a/tests/virstoragetest.c +++ b/tests/virstoragetest.c @@ -270,7 +270,6 @@ testStorageChain(const void *args) virStorageSourcePtr elt; size_t i =3D 0; g_autoptr(virStorageSource) meta =3D NULL; - g_autofree char *broken =3D NULL; =20 meta =3D testStorageFileGetMetadata(data->start, data->format, -1, -1); if (!meta) { @@ -289,11 +288,6 @@ testStorageChain(const void *args) return -1; } =20 - if (virStorageFileChainGetBroken(meta, &broken) || broken) { - fprintf(stderr, "chain should not be identified as broken\n"); - return -1; - } - elt =3D meta; while (virStorageSourceIsBacking(elt)) { g_autofree char *expect =3D NULL; --=20 2.29.2 From nobody Fri Mar 29 08:07:05 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=1609935979; cv=none; d=zohomail.com; s=zohoarc; b=MZSN2i4alXlLRlnVl1VAFF2bWoN7uV2VgjNLCjG29JoU7B3I3OTUWMABFq4J5f/tIrzJVIRuQyyt+nq46mlHXZUwTYGyjvxSxjAbSciJg/KKFqqk5IZEuj4oysNXiO7g32yfxv66/qsWSN1ePfUrq6zNgXWe/QKQ8VoIZTYtg54= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1609935979; 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=ERVDhMyZPIAJ5N2raUD62mK40+tbvj98vbWWfKGTT+w=; b=mpedU+Q8wup42MaYPg7ZmZpbFRZ9+Ylob2JU0Eur+rupIVnTJqumN1ghmylbdGcDXHC8cA7v7SXCAPqFIP8lfJgIkwyRiAGsqLsQAsN39Zqp45Gdy2Cr/LCWyaY0nfGVXFViBh3sww1axUgCM6Q+df2zMKdjLW/zgqnyj+O5XLk= 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 1609935979624534.9175661032364; Wed, 6 Jan 2021 04:26:19 -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-80-p3kWxWsQNFG5Tfw-lHInfw-1; Wed, 06 Jan 2021 07:26:15 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 78DC98144E1; Wed, 6 Jan 2021 12:26:10 +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 4D23419C66; Wed, 6 Jan 2021 12:26:10 +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 D628B1809CA1; Wed, 6 Jan 2021 12:26:09 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 106CQ7lt019025 for ; Wed, 6 Jan 2021 07:26:07 -0500 Received: by smtp.corp.redhat.com (Postfix) id 7415E60BE5; Wed, 6 Jan 2021 12:26:07 +0000 (UTC) Received: from antique-work.lan (unknown [10.40.194.49]) by smtp.corp.redhat.com (Postfix) with ESMTP id E51DF60BE2 for ; Wed, 6 Jan 2021 12:26:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1609935978; 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=ERVDhMyZPIAJ5N2raUD62mK40+tbvj98vbWWfKGTT+w=; b=KwcVqrdfJLklaAaXrvyUndjCCDEBACvilcQ477BjrknvXPpth+8t++Jqoc88k+FfU1MCjT Vj5aQWUUZ/S6cjZFulspMOgSdnVUGl09A5Qjim7vuKGB4vaVx1uUFdlbeuCbsxM6ku4AaU szm53dG+QOfSGebcaoodeBxuo0BJGg4= X-MC-Unique: p3kWxWsQNFG5Tfw-lHInfw-1 From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH v2 3/9] util: move virQEMUBuildQemuImgKeySecretOpts into storage Date: Wed, 6 Jan 2021 13:25:54 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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.23 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" Function virQEMUBuildQemuImgKeySecretOpts is not used anywhere else so there is no need to have it in util. Signed-off-by: Pavel Hrdina Reviewed-by: Peter Krempa --- src/libvirt_private.syms | 1 - src/storage/storage_util.c | 74 ++++++++++++++++++++++++++++++++++++-- src/util/virqemu.c | 69 ----------------------------------- src/util/virqemu.h | 6 ---- 4 files changed, 72 insertions(+), 78 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index f8da4a7648..b8fedc82d5 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2954,7 +2954,6 @@ virQEMUBuildCommandLineJSONArrayNumbered; virQEMUBuildDriveCommandlineFromJSON; virQEMUBuildNetdevCommandlineFromJSON; virQEMUBuildObjectCommandlineFromJSON; -virQEMUBuildQemuImgKeySecretOpts; =20 =20 # util/virrandom.h diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c index 2d46452da5..83b120924b 100644 --- a/src/storage/storage_util.c +++ b/src/storage/storage_util.c @@ -679,6 +679,74 @@ struct _virStorageBackendQemuImgInfo { }; =20 =20 +/** + * storageBackendBuildQemuImgEncriptionOpts: + * @buf: buffer to build the string into + * @encinfo: pointer to encryption info + * @alias: alias to use + * + * Generate the string for id=3D$alias and any encryption options for + * into the buffer. + * + * Important note, a trailing comma (",") is built into the return since + * it's expected other arguments are appended after the id=3D$alias string. + * So either turn something like: + * + * "key-secret=3D$alias," + * + * or + * "key-secret=3D$alias,cipher-alg=3Dtwofish-256,cipher-mode=3Dcbc, + * hash-alg=3Dsha256,ivgen-alg=3Dplain64,igven-hash-alg=3Dsha256," + * + */ +static void +storageBackendBuildQemuImgEncriptionOpts(virBufferPtr buf, + int format, + virStorageEncryptionInfoDefPtr en= cinfo, + const char *alias) +{ + const char *encprefix; + + if (format =3D=3D VIR_STORAGE_FILE_QCOW2) { + virBufferAddLit(buf, "encrypt.format=3Dluks,"); + encprefix =3D "encrypt."; + } else { + encprefix =3D ""; + } + + virBufferAsprintf(buf, "%skey-secret=3D%s,", encprefix, alias); + + if (!encinfo->cipher_name) + return; + + virBufferAsprintf(buf, "%scipher-alg=3D", encprefix); + virQEMUBuildBufferEscapeComma(buf, encinfo->cipher_name); + virBufferAsprintf(buf, "-%u,", encinfo->cipher_size); + if (encinfo->cipher_mode) { + virBufferAsprintf(buf, "%scipher-mode=3D", encprefix); + virQEMUBuildBufferEscapeComma(buf, encinfo->cipher_mode); + virBufferAddLit(buf, ","); + } + if (encinfo->cipher_hash) { + virBufferAsprintf(buf, "%shash-alg=3D", encprefix); + virQEMUBuildBufferEscapeComma(buf, encinfo->cipher_hash); + virBufferAddLit(buf, ","); + } + if (!encinfo->ivgen_name) + return; + + virBufferAsprintf(buf, "%sivgen-alg=3D", encprefix); + virQEMUBuildBufferEscapeComma(buf, encinfo->ivgen_name); + virBufferAddLit(buf, ","); + + if (encinfo->ivgen_hash) { + virBufferAsprintf(buf, "%sivgen-hash-alg=3D", encprefix); + virQEMUBuildBufferEscapeComma(buf, encinfo->ivgen_hash); + virBufferAddLit(buf, ","); + } +} + + static int storageBackendCreateQemuImgOpts(virStorageEncryptionInfoDefPtr encinfo, char **opts, @@ -690,8 +758,10 @@ storageBackendCreateQemuImgOpts(virStorageEncryptionIn= foDefPtr encinfo, virBufferAsprintf(&buf, "backing_fmt=3D%s,", virStorageFileFormatTypeToString(info->backingFo= rmat)); =20 - if (encinfo) - virQEMUBuildQemuImgKeySecretOpts(&buf, info->format, encinfo, info= ->secretAlias); + if (encinfo) { + storageBackendBuildQemuImgEncriptionOpts(&buf, info->format, encin= fo, + info->secretAlias); + } =20 if (info->preallocate) { if (info->size_arg > info->allocation) diff --git a/src/util/virqemu.c b/src/util/virqemu.c index 5405c9eac9..c4b6e8b3db 100644 --- a/src/util/virqemu.c +++ b/src/util/virqemu.c @@ -28,7 +28,6 @@ #include "virqemu.h" #include "virstring.h" #include "viralloc.h" -#include "virstoragefile.h" =20 #define VIR_FROM_THIS VIR_FROM_NONE =20 @@ -384,71 +383,3 @@ virQEMUBuildBufferEscapeComma(virBufferPtr buf, const = char *str) { virBufferEscape(buf, ',', ",", "%s", str); } - - -/** - * virQEMUBuildQemuImgKeySecretOpts: - * @buf: buffer to build the string into - * @encinfo: pointer to encryption info - * @alias: alias to use - * - * Generate the string for id=3D$alias and any encryption options for - * into the buffer. - * - * Important note, a trailing comma (",") is built into the return since - * it's expected other arguments are appended after the id=3D$alias string. - * So either turn something like: - * - * "key-secret=3D$alias," - * - * or - * "key-secret=3D$alias,cipher-alg=3Dtwofish-256,cipher-mode=3Dcbc, - * hash-alg=3Dsha256,ivgen-alg=3Dplain64,igven-hash-alg=3Dsha256," - * - */ -void -virQEMUBuildQemuImgKeySecretOpts(virBufferPtr buf, - int format, - virStorageEncryptionInfoDefPtr encinfo, - const char *alias) -{ - const char *encprefix; - - if (format =3D=3D VIR_STORAGE_FILE_QCOW2) { - virBufferAddLit(buf, "encrypt.format=3Dluks,"); - encprefix =3D "encrypt."; - } else { - encprefix =3D ""; - } - - virBufferAsprintf(buf, "%skey-secret=3D%s,", encprefix, alias); - - if (!encinfo->cipher_name) - return; - - virBufferAsprintf(buf, "%scipher-alg=3D", encprefix); - virQEMUBuildBufferEscapeComma(buf, encinfo->cipher_name); - virBufferAsprintf(buf, "-%u,", encinfo->cipher_size); - if (encinfo->cipher_mode) { - virBufferAsprintf(buf, "%scipher-mode=3D", encprefix); - virQEMUBuildBufferEscapeComma(buf, encinfo->cipher_mode); - virBufferAddLit(buf, ","); - } - if (encinfo->cipher_hash) { - virBufferAsprintf(buf, "%shash-alg=3D", encprefix); - virQEMUBuildBufferEscapeComma(buf, encinfo->cipher_hash); - virBufferAddLit(buf, ","); - } - if (!encinfo->ivgen_name) - return; - - virBufferAsprintf(buf, "%sivgen-alg=3D", encprefix); - virQEMUBuildBufferEscapeComma(buf, encinfo->ivgen_name); - virBufferAddLit(buf, ","); - - if (encinfo->ivgen_hash) { - virBufferAsprintf(buf, "%sivgen-hash-alg=3D", encprefix); - virQEMUBuildBufferEscapeComma(buf, encinfo->ivgen_hash); - virBufferAddLit(buf, ","); - } -} diff --git a/src/util/virqemu.h b/src/util/virqemu.h index 2b33968158..b81efc765f 100644 --- a/src/util/virqemu.h +++ b/src/util/virqemu.h @@ -25,7 +25,6 @@ #include "internal.h" #include "virbuffer.h" #include "virjson.h" -#include "virstorageencryption.h" =20 typedef int (*virQEMUBuildCommandLineJSONArrayFormatFunc)(const char *key, virJSONValuePtr = array, @@ -59,8 +58,3 @@ int virQEMUBuildObjectCommandlineFromJSON(virBufferPtr bu= f, char *virQEMUBuildDriveCommandlineFromJSON(virJSONValuePtr src); =20 void virQEMUBuildBufferEscapeComma(virBufferPtr buf, const char *str); -void virQEMUBuildQemuImgKeySecretOpts(virBufferPtr buf, - int format, - virStorageEncryptionInfoDefPtr enc, - const char *alias) - ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4); --=20 2.29.2 From nobody Fri Mar 29 08:07:05 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=1609935990; cv=none; d=zohomail.com; s=zohoarc; b=PLzwhPIZVQlnHmOkmHbnFJmsbP50aiVXgUwlwqepV+3LgOMA9mnlklu2sihfeLp3rcsKSho/IWA9C7zZ0WuYrLuNTBaRxAr7EOGmG8Bgh1If/uezg0m2+EeAwWbNHAs6ZPXa0EB7iaojPUQxY7IV1tvqjqbwjl6SyQhK11PPP1U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1609935990; 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=nUcRbyO/k3wJlKYwAsz2CC0sZ5WgdCl3TyKdApZAdeQ=; b=LJ336quumq6hfSPvgKcEVCIKkjAEIN+bHot6vFgnKqR3wZPuL6WxkPQs08WiqiAy0tdB81RvPdquTEVuEhaLEPia+2z3tBDMpIcStRa/4nrf93k4IizVkwFRMkKI2SH6TnJMXJUqxQ3zYcp49kzue53DnO06LrFNwfAAcFbnask= 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 1609935990406277.34831511843106; Wed, 6 Jan 2021 04:26:30 -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-347-mS_TcHygOoW0saJqoGJVuQ-1; Wed, 06 Jan 2021 07:26:26 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 82B1D106F8C1; Wed, 6 Jan 2021 12:26:20 +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 56A4119D7D; Wed, 6 Jan 2021 12:26:20 +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 1E72A1809CAB; Wed, 6 Jan 2021 12:26:20 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 106CQ8Ow019033 for ; Wed, 6 Jan 2021 07:26:08 -0500 Received: by smtp.corp.redhat.com (Postfix) id 5803760BE5; Wed, 6 Jan 2021 12:26:08 +0000 (UTC) Received: from antique-work.lan (unknown [10.40.194.49]) by smtp.corp.redhat.com (Postfix) with ESMTP id C8EC360BE2 for ; Wed, 6 Jan 2021 12:26:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1609935989; 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=nUcRbyO/k3wJlKYwAsz2CC0sZ5WgdCl3TyKdApZAdeQ=; b=dMaesvVU/y7xErX6ASZcKn8blsC2wfP4MAwl9NCt06XcD0Vr2YYnjEuIMu8R0m5/98ZA7N Dzy1TV/IXt6dxgePeupNVo2PUX0nle43uAq6Z3eIpCZj/x9vS5ARGeBwPvPyGYEVZOgEYV 7svtf3hpOe8HSAjYYsNQFC4wnetMlY4= X-MC-Unique: mS_TcHygOoW0saJqoGJVuQ-1 From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH v2 4/9] util: move virStorageFileGetLVMKey to locking Date: Wed, 6 Jan 2021 13:25:55 +0100 Message-Id: <780aa25fad35177e51ecc6d20a1425eba21a7e6b.1609935558.git.phrdina@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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.23 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 function doesn't take virStorageSource as argument and has nothing in common with virStorageSource or storage file. Signed-off-by: Pavel Hrdina Reviewed-by: Peter Krempa --- src/libvirt_private.syms | 1 - src/locking/lock_driver_lockd.c | 68 ++++++++++++++++++++++++++++++++- src/util/virstoragefile.c | 62 ------------------------------ src/util/virstoragefile.h | 2 - 4 files changed, 67 insertions(+), 66 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index b8fedc82d5..78d4e5ab30 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -3135,7 +3135,6 @@ virStorageFileFeatureTypeToString; virStorageFileFormatTypeFromString; virStorageFileFormatTypeToString; virStorageFileGetBackingStoreStr; -virStorageFileGetLVMKey; virStorageFileGetMetadata; virStorageFileGetMetadataFromBuf; virStorageFileGetMetadataFromFD; diff --git a/src/locking/lock_driver_lockd.c b/src/locking/lock_driver_lock= d.c index 15d9e5f076..d459c1668c 100644 --- a/src/locking/lock_driver_lockd.c +++ b/src/locking/lock_driver_lockd.c @@ -24,6 +24,7 @@ #include "lock_driver.h" #include "virconf.h" #include "viralloc.h" +#include "vircommand.h" #include "vircrypto.h" #include "virlog.h" #include "viruuid.h" @@ -455,6 +456,71 @@ static int virLockManagerLockDaemonNew(virLockManagerP= tr lock, } =20 =20 +#ifdef LVS +static int +virLockManagerGetLVMKey(const char *path, + char **key) +{ + /* + * # lvs --noheadings --unbuffered --nosuffix --options "uuid" LVNAME + * 06UgP5-2rhb-w3Bo-3mdR-WeoL-pytO-SAa2ky + */ + int status; + int ret =3D -1; + g_autoptr(virCommand) cmd =3D NULL; + + cmd =3D virCommandNewArgList(LVS, "--noheadings", + "--unbuffered", "--nosuffix", + "--options", "uuid", path, + NULL + ); + *key =3D NULL; + + /* Run the program and capture its output */ + virCommandSetOutputBuffer(cmd, key); + if (virCommandRun(cmd, &status) < 0) + goto cleanup; + + /* Explicitly check status =3D=3D 0, rather than passing NULL + * to virCommandRun because we don't want to raise an actual + * error in this scenario, just return a NULL key. + */ + + if (status =3D=3D 0 && *key) { + char *nl; + char *tmp =3D *key; + + /* Find first non-space character */ + while (*tmp && g_ascii_isspace(*tmp)) + tmp++; + /* Kill leading spaces */ + if (tmp !=3D *key) + memmove(*key, tmp, strlen(tmp)+1); + + /* Kill trailing newline */ + if ((nl =3D strchr(*key, '\n'))) + *nl =3D '\0'; + } + + ret =3D 0; + + cleanup: + if (*key && STREQ(*key, "")) + VIR_FREE(*key); + + return ret; +} +#else +static int +virLockManagerGetLVMKey(const char *path, + char **key G_GNUC_UNUSED) +{ + virReportSystemError(ENOSYS, _("Unable to get LVM key for %s"), path); + return -1; +} +#endif + + static int virLockManagerLockDaemonAddResource(virLockManagerPtr lock, unsigned int type, const char *name, @@ -494,7 +560,7 @@ static int virLockManagerLockDaemonAddResource(virLockM= anagerPtr lock, if (STRPREFIX(name, "/dev") && driver->lvmLockSpaceDir) { VIR_DEBUG("Trying to find an LVM UUID for %s", name); - if (virStorageFileGetLVMKey(name, &newName) < 0) + if (virLockManagerGetLVMKey(name, &newName) < 0) goto cleanup; =20 if (newName) { diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index 119342d296..bc342cabe3 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -1251,68 +1251,6 @@ int virStorageFileIsClusterFS(const char *path) VIR_FILE_SHFS_CEPH); } =20 -#ifdef LVS -int virStorageFileGetLVMKey(const char *path, - char **key) -{ - /* - * # lvs --noheadings --unbuffered --nosuffix --options "uuid" LVNAME - * 06UgP5-2rhb-w3Bo-3mdR-WeoL-pytO-SAa2ky - */ - int status; - int ret =3D -1; - g_autoptr(virCommand) cmd =3D NULL; - - cmd =3D virCommandNewArgList(LVS, "--noheadings", - "--unbuffered", "--nosuffix", - "--options", "uuid", path, - NULL - ); - *key =3D NULL; - - /* Run the program and capture its output */ - virCommandSetOutputBuffer(cmd, key); - if (virCommandRun(cmd, &status) < 0) - goto cleanup; - - /* Explicitly check status =3D=3D 0, rather than passing NULL - * to virCommandRun because we don't want to raise an actual - * error in this scenario, just return a NULL key. - */ - - if (status =3D=3D 0 && *key) { - char *nl; - char *tmp =3D *key; - - /* Find first non-space character */ - while (*tmp && g_ascii_isspace(*tmp)) - tmp++; - /* Kill leading spaces */ - if (tmp !=3D *key) - memmove(*key, tmp, strlen(tmp)+1); - - /* Kill trailing newline */ - if ((nl =3D strchr(*key, '\n'))) - *nl =3D '\0'; - } - - ret =3D 0; - - cleanup: - if (*key && STREQ(*key, "")) - VIR_FREE(*key); - - return ret; -} -#else -int virStorageFileGetLVMKey(const char *path, - char **key G_GNUC_UNUSED) -{ - virReportSystemError(ENOSYS, _("Unable to get LVM key for %s"), path); - return -1; -} -#endif - #ifdef WITH_UDEV /* virStorageFileGetSCSIKey * @path: Path to the SCSI device diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h index cc9bd4875f..31feb22f26 100644 --- a/src/util/virstoragefile.h +++ b/src/util/virstoragefile.h @@ -428,8 +428,6 @@ int virStorageFileIsClusterFS(const char *path); bool virStorageIsFile(const char *path); bool virStorageIsRelative(const char *backing); =20 -int virStorageFileGetLVMKey(const char *path, - char **key); int virStorageFileGetSCSIKey(const char *path, char **key, bool ignoreError); --=20 2.29.2 From nobody Fri Mar 29 08:07:05 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=1609935987; cv=none; d=zohomail.com; s=zohoarc; b=ajKGLSwxoiJm/U0Z2rPee/UyZ8pzDblnFF0bXaK9gTKHyV/ScEuY5IuH0hchqXKrohV+1GNDREq5hPCMNZTX/fWJPsxf+Vd9qoSdze2SkMIkC2o92xoeZPY334gaa+/5BIGCVdN/eNpM2QI/GYVE3IkbhcYgtgE+eqYZeS6FVlo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1609935987; 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=+2EoELMaPRhE3MRps2ahQa7QffGHjPfDzhT68EzfoIE=; b=S2QkxOE83EvarZYEz+QrD3Fd53BqQzIS7HJlgHHNOfK/VqOUjvXkm/6xYFAYm807kyZbhWSY01K9GBjDEiMjnf/qV3z+6zhtE7gsIFzSwx6dN51vIgIJWZllulsBqpOLUD3vmMLSPZRPzQAc/5XGGW1LZ/PInVgv4sj1Aa9rZ6g= 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 1609935986984248.11001256526708; Wed, 6 Jan 2021 04:26:26 -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-248-5BnnVtfuNwSgRzr8isCWDQ-1; Wed, 06 Jan 2021 07:26:22 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B1896107ACF9; Wed, 6 Jan 2021 12:26:17 +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 9142060C04; Wed, 6 Jan 2021 12:26:17 +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 5C7B71809CA6; Wed, 6 Jan 2021 12:26:17 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 106CQ91F019043 for ; Wed, 6 Jan 2021 07:26:09 -0500 Received: by smtp.corp.redhat.com (Postfix) id 3BC4460BFA; Wed, 6 Jan 2021 12:26:09 +0000 (UTC) Received: from antique-work.lan (unknown [10.40.194.49]) by smtp.corp.redhat.com (Postfix) with ESMTP id ACA3860BE2 for ; Wed, 6 Jan 2021 12:26:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1609935985; 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=+2EoELMaPRhE3MRps2ahQa7QffGHjPfDzhT68EzfoIE=; b=BHc4hWWVH7O3zOLF21z68tWMU1N1kexRutkL4MnFJGuwf4OwupDqPkMmTwtHAZNVVj1fnq nBdM44PUXlGA6Mt7sy3VBM+al76Kao+Qam/Hj2RtUa1rng6F3kZDeSVYsVCq/A1u+5bjgJ PoFuSEvsSimHdbZOwVyQ+OmlWIOrWgs= X-MC-Unique: 5BnnVtfuNwSgRzr8isCWDQ-1 From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH v2 5/9] util: move virStorageFileCheckCompat into conf Date: Wed, 6 Jan 2021 13:25:56 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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.12 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" It is not used anywhere else. Signed-off-by: Pavel Hrdina Reviewed-by: Peter Krempa --- src/conf/storage_conf.c | 23 ++++++++++++++++++++++- src/util/virstoragefile.c | 24 ------------------------ src/util/virstoragefile.h | 2 -- 3 files changed, 22 insertions(+), 27 deletions(-) diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c index 09769e6c79..0c50529ace 100644 --- a/src/conf/storage_conf.c +++ b/src/conf/storage_conf.c @@ -1296,6 +1296,27 @@ virStorageSize(const char *unit, } =20 =20 +static int +virStorageCheckCompat(const char *compat) +{ + unsigned int result; + g_auto(GStrv) version =3D NULL; + + if (!compat) + return 0; + + version =3D virStringSplit(compat, ".", 2); + if (!version || !version[1] || + virStrToLong_ui(version[0], NULL, 10, &result) < 0 || + virStrToLong_ui(version[1], NULL, 10, &result) < 0) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("forbidden characters in 'compat' attribute")); + return -1; + } + return 0; +} + + static virStorageVolDefPtr virStorageVolDefParseXML(virStoragePoolDefPtr pool, xmlXPathContextPtr ctxt, @@ -1424,7 +1445,7 @@ virStorageVolDefParseXML(virStoragePoolDefPtr pool, } =20 def->target.compat =3D virXPathString("string(./target/compat)", ctxt); - if (virStorageFileCheckCompat(def->target.compat) < 0) + if (virStorageCheckCompat(def->target.compat) < 0) return NULL; =20 if (virXPathNode("./target/nocow", ctxt)) diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index bc342cabe3..d6ff47e4a7 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -4410,30 +4410,6 @@ virStorageFileGetRelativeBackingPath(virStorageSourc= ePtr top, } =20 =20 -/* - * virStorageFileCheckCompat - */ -int -virStorageFileCheckCompat(const char *compat) -{ - unsigned int result; - g_auto(GStrv) version =3D NULL; - - if (!compat) - return 0; - - version =3D virStringSplit(compat, ".", 2); - if (!version || !version[1] || - virStrToLong_ui(version[0], NULL, 10, &result) < 0 || - virStrToLong_ui(version[1], NULL, 10, &result) < 0) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("forbidden characters in 'compat' attribute")); - return -1; - } - return 0; -} - - /** * virStorageSourceIsRelative: * @src: storage source to check diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h index 31feb22f26..ec34f2d899 100644 --- a/src/util/virstoragefile.h +++ b/src/util/virstoragefile.h @@ -513,8 +513,6 @@ int virStorageFileGetRelativeBackingPath(virStorageSour= cePtr from, char **relpath) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3); =20 -int virStorageFileCheckCompat(const char *compat); - int virStorageSourceNewFromBackingAbsolute(const char *path, virStorageSourcePtr *src); =20 --=20 2.29.2 From nobody Fri Mar 29 08:07:05 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=1609935991; cv=none; d=zohomail.com; s=zohoarc; b=gwUyfUpzZMaubvc0mnQb+PQiV95Pk7qQlK+aS0whjI7EdHXFnCULI/ya2wBtGQ9c8oPm2xbQuMZ1jfB7Hu2uzKGUjldjAxi+gqQcveV3Q2WoUSm4CIQhRlCmn9Ow2UZXwrUM2LWS9TZ3Yz6Pky/a7E0ZbePWWyTEmFH7qi9yToE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1609935991; 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=bHpL8dPf/23ozAJLeQg388h9xNJlIJVkzwA54jP0WIg=; b=k1dQPMXjO+vrS1KjeZqwRVjnEInzyH1FXId4PiuizNQws9SUvLwEC6//bYFbkwFMPGxYjS6nBy1fiYX2MxTsn0MDqniMh/W+bxRokADeF1xTC4hNpHaLwf8UDHL5vPrjm38BsUzNgvDLPIVkz9nBEppvVS4g+mkJPvNWTxupNpI= 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 1609935991890979.6864060197228; Wed, 6 Jan 2021 04:26:31 -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-524-BILmDmqNPPq1-AeU6PDlbg-1; Wed, 06 Jan 2021 07:26:28 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 069E78144E7; Wed, 6 Jan 2021 12:26:23 +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 D980260877; Wed, 6 Jan 2021 12:26:22 +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 A78225002E; Wed, 6 Jan 2021 12:26:22 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 106CQArA019061 for ; Wed, 6 Jan 2021 07:26:10 -0500 Received: by smtp.corp.redhat.com (Postfix) id 1FC6C60BE5; Wed, 6 Jan 2021 12:26:10 +0000 (UTC) Received: from antique-work.lan (unknown [10.40.194.49]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9054C60BE2 for ; Wed, 6 Jan 2021 12:26:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1609935990; 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=bHpL8dPf/23ozAJLeQg388h9xNJlIJVkzwA54jP0WIg=; b=WXoEd3Veao50asZf8hv94PLN5Ab0//W9WA6VLIWnUr4Fuh1Hou0fOLeipe4m/32n8wELKK EpXDanwO5FXgxmqPPQelayRAnA8v7TD4xdbEg85MUfNY6L64ZFj/f238nAZOpUX+kt8ZbN 0atdEDQlzlKji/DY1LMEd6Mdd/VWruk= X-MC-Unique: BILmDmqNPPq1-AeU6PDlbg-1 From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH v2 6/9] src: add missing headers to various files Date: Wed, 6 Jan 2021 13:25:57 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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.13 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" All these headers are indirectly included provided by virfile.h having virstoragefile.h which will be removed in the following patch. Signed-off-by: Pavel Hrdina Reviewed-by: Peter Krempa --- src/driver.c | 1 + src/qemu/qemu_interop_config.c | 1 + src/qemu/qemu_shim.c | 1 + src/storage/parthelper.c | 1 + src/util/virarptable.c | 1 + src/util/vircgroupv1.c | 1 + src/util/vircgroupv2devices.c | 1 + src/util/virfile.h | 1 + src/util/virpidfile.c | 1 + src/util/virresctrl.c | 1 + src/util/virsysinfo.c | 1 + src/util/virtpm.c | 1 + tools/virsh-console.c | 1 + tools/virsh-util.c | 1 + 14 files changed, 14 insertions(+) diff --git a/src/driver.c b/src/driver.c index 1cacec24ff..e005a89d57 100644 --- a/src/driver.c +++ b/src/driver.c @@ -29,6 +29,7 @@ #include "virfile.h" #include "virlog.h" #include "virmodule.h" +#include "virobject.h" #include "virstring.h" #include "virthread.h" #include "virutil.h" diff --git a/src/qemu/qemu_interop_config.c b/src/qemu/qemu_interop_config.c index c5a5a9c6ec..bcaddda446 100644 --- a/src/qemu/qemu_interop_config.c +++ b/src/qemu/qemu_interop_config.c @@ -24,6 +24,7 @@ #include "configmake.h" #include "viralloc.h" #include "virenum.h" +#include "virerror.h" #include "virfile.h" #include "virhash.h" #include "virlog.h" diff --git a/src/qemu/qemu_shim.c b/src/qemu/qemu_shim.c index ef0ba086b5..18bdc99256 100644 --- a/src/qemu/qemu_shim.c +++ b/src/qemu/qemu_shim.c @@ -27,6 +27,7 @@ #include "virfile.h" #include "virstring.h" #include "virgettext.h" +#include "virthread.h" =20 #define VIR_FROM_THIS VIR_FROM_QEMU =20 diff --git a/src/storage/parthelper.c b/src/storage/parthelper.c index caa2e8fa62..94d588615f 100644 --- a/src/storage/parthelper.c +++ b/src/storage/parthelper.c @@ -40,6 +40,7 @@ #include "virstring.h" #include "virgettext.h" #include "virdevmapper.h" +#include "virerror.h" =20 /* we don't need to include the full internal.h just for this */ #define STREQ(a, b) (strcmp(a, b) =3D=3D 0) diff --git a/src/util/virarptable.c b/src/util/virarptable.c index 01a27c0093..d62de5e3dd 100644 --- a/src/util/virarptable.c +++ b/src/util/virarptable.c @@ -26,6 +26,7 @@ =20 #include "viralloc.h" #include "virarptable.h" +#include "virerror.h" #include "virfile.h" #include "virlog.h" #include "virnetlink.h" diff --git a/src/util/vircgroupv1.c b/src/util/vircgroupv1.c index 06849efd38..2b4d625c35 100644 --- a/src/util/vircgroupv1.c +++ b/src/util/vircgroupv1.c @@ -41,6 +41,7 @@ #include "virsystemd.h" #include "virerror.h" #include "viralloc.h" +#include "virthread.h" =20 VIR_LOG_INIT("util.cgroup"); =20 diff --git a/src/util/vircgroupv2devices.c b/src/util/vircgroupv2devices.c index f31244f3c1..71591be4c4 100644 --- a/src/util/vircgroupv2devices.c +++ b/src/util/vircgroupv2devices.c @@ -34,6 +34,7 @@ #include "virbpf.h" #include "vircgroup.h" #include "vircgroupv2devices.h" +#include "virerror.h" #include "virfile.h" #include "virlog.h" =20 diff --git a/src/util/virfile.h b/src/util/virfile.h index 32505826ee..0f197be73d 100644 --- a/src/util/virfile.h +++ b/src/util/virfile.h @@ -29,6 +29,7 @@ #include "internal.h" #include "virbitmap.h" #include "virstoragefile.h" +#include "virenum.h" =20 typedef enum { VIR_FILE_CLOSE_PRESERVE_ERRNO =3D 1 << 0, diff --git a/src/util/virpidfile.c b/src/util/virpidfile.c index 895eb83ea9..b4d0059405 100644 --- a/src/util/virpidfile.c +++ b/src/util/virpidfile.c @@ -30,6 +30,7 @@ #include "virpidfile.h" #include "virfile.h" #include "viralloc.h" +#include "virbuffer.h" #include "virutil.h" #include "virlog.h" #include "virerror.h" diff --git a/src/util/virresctrl.c b/src/util/virresctrl.c index d3087b98c1..67a921b44b 100644 --- a/src/util/virresctrl.c +++ b/src/util/virresctrl.c @@ -27,6 +27,7 @@ #define LIBVIRT_VIRRESCTRLPRIV_H_ALLOW #include "virresctrlpriv.h" #include "viralloc.h" +#include "virbuffer.h" #include "virfile.h" #include "virlog.h" #include "virobject.h" diff --git a/src/util/virsysinfo.c b/src/util/virsysinfo.c index 217f842a37..28f7104145 100644 --- a/src/util/virsysinfo.c +++ b/src/util/virsysinfo.c @@ -32,6 +32,7 @@ #include "virlog.h" #include "virfile.h" #include "virstring.h" +#include "virxml.h" =20 #define LIBVIRT_VIRSYSINFOPRIV_H_ALLOW #include "virsysinfopriv.h" diff --git a/src/util/virtpm.c b/src/util/virtpm.c index 0e11674a3c..b41eb00619 100644 --- a/src/util/virtpm.c +++ b/src/util/virtpm.c @@ -31,6 +31,7 @@ #include "virbitmap.h" #include "virjson.h" #include "virlog.h" +#include "virthread.h" =20 #define VIR_FROM_THIS VIR_FROM_TPM =20 diff --git a/tools/virsh-console.c b/tools/virsh-console.c index 2e498a6903..4e9bdb67e1 100644 --- a/tools/virsh-console.c +++ b/tools/virsh-console.c @@ -38,6 +38,7 @@ # include "viralloc.h" # include "virthread.h" # include "virerror.h" +# include "virobject.h" =20 VIR_LOG_INIT("tools.virsh-console"); =20 diff --git a/tools/virsh-util.c b/tools/virsh-util.c index af7ed55348..9f69bad8cc 100644 --- a/tools/virsh-util.c +++ b/tools/virsh-util.c @@ -23,6 +23,7 @@ #include "virfile.h" #include "virstring.h" #include "viralloc.h" +#include "virxml.h" =20 static virDomainPtr virshLookupDomainInternal(vshControl *ctl, --=20 2.29.2 From nobody Fri Mar 29 08:07:05 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=1609936029; cv=none; d=zohomail.com; s=zohoarc; b=Q/Tc6LMKxRX1IK4VOIv2l4bWpGwvCEBsQziYoGCHHmlEy3RyWY9sjcNoJmY7tuuCVhtj/rFt2Nag3c+u1Jj2sU3bvOAp+4clMFMrMydjdvsyFylglbwiS9GOmd/cu/QxpNxf8G6lj5rk4iQCADhq+vW4MxGJpXkCengpwCYM5T8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1609936029; 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=ZB/duAl5/B3QE9zHlv7KE9EBKlrJnlFBamV+pdJulXw=; b=ELsJkmomBfl14eiwGSIlwB1c08umOdn9yIIPbTu+ZBmSpSzevI3oWOhVVB8fzt1DIdxPIIdG9+TAthA+mIYy3mL3ZSmImz7RvmTVcBdFpe6sTBpQwrGlTO8eZTTIqVdkoM1bXcZo2yZRgCgs3/pT3SHyVuVzmgefaMGnG22wqRg= 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 1609936029278498.48700118305067; Wed, 6 Jan 2021 04:27:09 -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-237-OQ0is1peOAOZCxfZMM37Wg-1; Wed, 06 Jan 2021 07:26:23 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A8DC9190A7A0; Wed, 6 Jan 2021 12:26:17 +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 87FFD60875; Wed, 6 Jan 2021 12:26:17 +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 530D44E590; Wed, 6 Jan 2021 12:26:17 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 106CQBYZ019076 for ; Wed, 6 Jan 2021 07:26:11 -0500 Received: by smtp.corp.redhat.com (Postfix) id 067F460BE5; Wed, 6 Jan 2021 12:26:11 +0000 (UTC) Received: from antique-work.lan (unknown [10.40.194.49]) by smtp.corp.redhat.com (Postfix) with ESMTP id 76E8B60BE2 for ; Wed, 6 Jan 2021 12:26:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1609936028; 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=ZB/duAl5/B3QE9zHlv7KE9EBKlrJnlFBamV+pdJulXw=; b=N2qfBQZfxvFDPc38c7uBv1RgfavhYxHRrIQ4S34DMqqeQVwu6p9x43mN634U8zDjJBRQg+ 8nvmsFfLoEUj6IPHM61hdHIo9774MIJzuO822x+WOfKY+Dl57BqTEbE8lazgKpjimDjZgk ecG05FqLzouORRVU74acTfsILqWhLtc= X-MC-Unique: OQ0is1peOAOZCxfZMM37Wg-1 From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH v2 7/9] virfile: refactor virFileNBDDeviceAssociate Date: Wed, 6 Jan 2021 13:25:58 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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.13 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 only reason why virstoragefile.h needs to be included in virfile.h is that virFileNBDDeviceAssociate() takes virStorageFileFormat argument. The function doesn't need the enum value as it converts the value to string and uses only that. Change the argument to string which will allow us to remove that include. Signed-off-by: Pavel Hrdina Reviewed-by: Peter Krempa --- src/lxc/lxc_controller.c | 4 ++-- src/util/virfile.c | 8 ++------ src/util/virfile.h | 3 +-- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c index 67e5e63d00..8f166a436a 100644 --- a/src/lxc/lxc_controller.c +++ b/src/lxc/lxc_controller.c @@ -509,7 +509,7 @@ static int virLXCControllerSetupNBDDeviceFS(virDomainFS= DefPtr fs) } =20 if (virFileNBDDeviceAssociate(fs->src->path, - fs->format, + virStorageFileFormatTypeToString(fs->for= mat), fs->readonly, &dev) < 0) return -1; @@ -541,7 +541,7 @@ static int virLXCControllerSetupNBDDeviceDisk(virDomain= DiskDefPtr disk) } =20 if (virFileNBDDeviceAssociate(src, - format, + virStorageFileFormatTypeToString(format), disk->src->readonly, &dev) < 0) return -1; diff --git a/src/util/virfile.c b/src/util/virfile.c index f7283fa72f..3f4c6d1d0a 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -879,14 +879,13 @@ virFileNBDLoadDriver(void) } =20 int virFileNBDDeviceAssociate(const char *file, - virStorageFileFormat fmt, + const char *fmtstr, bool readonly, char **dev) { g_autofree char *nbddev =3D NULL; g_autofree char *qemunbd =3D NULL; g_autoptr(virCommand) cmd =3D NULL; - const char *fmtstr =3D NULL; =20 if (!virFileNBDLoadDriver()) return -1; @@ -900,9 +899,6 @@ int virFileNBDDeviceAssociate(const char *file, return -1; } =20 - if (fmt > 0) - fmtstr =3D virStorageFileFormatTypeToString(fmt); - cmd =3D virCommandNew(qemunbd); =20 /* Explicitly not trying to cope with old qemu-nbd which @@ -945,7 +941,7 @@ int virFileLoopDeviceAssociate(const char *file, } =20 int virFileNBDDeviceAssociate(const char *file, - virStorageFileFormat fmt G_GNUC_UNUSED, + const char *fmtstr G_GNUC_UNUSED, bool readonly G_GNUC_UNUSED, char **dev G_GNUC_UNUSED) { diff --git a/src/util/virfile.h b/src/util/virfile.h index 0f197be73d..28dfe86445 100644 --- a/src/util/virfile.h +++ b/src/util/virfile.h @@ -28,7 +28,6 @@ =20 #include "internal.h" #include "virbitmap.h" -#include "virstoragefile.h" #include "virenum.h" =20 typedef enum { @@ -144,7 +143,7 @@ int virFileLoopDeviceAssociate(const char *file, char **dev); =20 int virFileNBDDeviceAssociate(const char *file, - virStorageFileFormat fmt, + const char *fmtstr, bool readonly, char **dev); =20 --=20 2.29.2 From nobody Fri Mar 29 08:07:05 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=1609935993; cv=none; d=zohomail.com; s=zohoarc; b=gLwQYGfBLS1z6MEwM+pS/TTUhbTDLVFcEyssLhTHM92YSvMAuYC58Ok7QIVhUU5nBpAvHO2VxfYp5i7igzsIHHTmHmnTI8ddMRAyiqTdRMml5XoSqf2CSMFhuURAFzbf4chIjCdyZDQFO9qIi7cps6BZKycUQsWaHBZP66hXKs8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1609935993; 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=GawMvbS0VXo9yZ0Q/1vTlOWfEgzYN3fHZPvvufrlg8A=; b=X0qc3mylpwuc6P/qq10hUtCx3huaX/BfIBKa0Arjz2UC1mDgqnhs/n97aJVoBQg91+ZW5I6sLNKhxf5MCZRrMGrFxDbAyMdULSyWO90cZe7S0z7JgC2kIotqiIyrdVhggpIbF/urZ4zTJYYQFaSMTD9kSVyF3msxiV9QWOsBrCE= 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 160993599304040.71544585263848; Wed, 6 Jan 2021 04:26:33 -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-490-lw_5YyIlOiihfTqzxEtIoQ-1; Wed, 06 Jan 2021 07:26:29 -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 AFD72107ACFA; Wed, 6 Jan 2021 12:26:24 +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 7F7FA6267A; Wed, 6 Jan 2021 12:26:24 +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 4641E50031; Wed, 6 Jan 2021 12:26:24 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 106CQBme019091 for ; Wed, 6 Jan 2021 07:26:11 -0500 Received: by smtp.corp.redhat.com (Postfix) id DDAE460BE5; Wed, 6 Jan 2021 12:26:11 +0000 (UTC) Received: from antique-work.lan (unknown [10.40.194.49]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5A85C60BE2 for ; Wed, 6 Jan 2021 12:26:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1609935991; 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=GawMvbS0VXo9yZ0Q/1vTlOWfEgzYN3fHZPvvufrlg8A=; b=jQ+4H3/3BO3cxJzFpGmsuocalhn15iYnW658AjlIgw1AdxsPpZWJytAgrALqZH85Wtn5xw siKnkLZ86BsjGNozrCUIoiMUUzJkulYHg1Cc8mQ1tF0djSViqrtTrdSFkl4yga+SlmBlpU 0fth7SO/W2lfZF2v7uMlrMkA7nUFz4Q= X-MC-Unique: lw_5YyIlOiihfTqzxEtIoQ-1 From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH v2 8/9] virstoragefile: move virStorageFileResize into virfile Date: Wed, 6 Jan 2021 13:25:59 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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" Signed-off-by: Pavel Hrdina Reviewed-by: Peter Krempa --- src/libvirt_private.syms | 2 +- src/storage/storage_util.c | 2 +- src/util/virfile.c | 47 ++++++++++++++++++++++++++++++++++++++ src/util/virfile.h | 4 ++++ src/util/virstoragefile.c | 47 -------------------------------------- src/util/virstoragefile.h | 4 ---- 6 files changed, 53 insertions(+), 53 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 78d4e5ab30..e79dc54d33 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2121,6 +2121,7 @@ virFileRelLinkPointsTo; virFileRemove; virFileRemoveLastComponent; virFileRemoveXAttr; +virFileResize; virFileResolveAllLinks; virFileResolveLink; virFileRewrite; @@ -3150,7 +3151,6 @@ virStorageFileParseChainIndex; virStorageFileProbeFormat; virStorageFileRead; virStorageFileReportBrokenChain; -virStorageFileResize; virStorageFileStat; virStorageFileSupportsAccess; virStorageFileSupportsBackingChainTraversal; diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c index 83b120924b..2478cb0a4a 100644 --- a/src/storage/storage_util.c +++ b/src/storage/storage_util.c @@ -2394,7 +2394,7 @@ virStorageBackendVolResizeLocal(virStoragePoolObjPtr = pool, VIR_STORAGE_VOL_RESIZE_SHRINK, -1); =20 if (vol->target.format =3D=3D VIR_STORAGE_FILE_RAW && !vol->target.enc= ryption) { - return virStorageFileResize(vol->target.path, capacity, pre_alloca= te); + return virFileResize(vol->target.path, capacity, pre_allocate); } else if (vol->target.format =3D=3D VIR_STORAGE_FILE_RAW && vol->targ= et.encryption) { if (pre_allocate) { virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", diff --git a/src/util/virfile.c b/src/util/virfile.c index 3f4c6d1d0a..6e16780e30 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -557,6 +557,53 @@ virFileRewriteStr(const char *path, } =20 =20 +/** + * virFileResize: + * + * Change the capacity of the raw storage file at 'path'. + */ +int +virFileResize(const char *path, + unsigned long long capacity, + bool pre_allocate) +{ + int rc; + VIR_AUTOCLOSE fd =3D -1; + + if ((fd =3D open(path, O_RDWR)) < 0) { + virReportSystemError(errno, _("Unable to open '%s'"), path); + return -1; + } + + if (pre_allocate) { + if ((rc =3D virFileAllocate(fd, 0, capacity)) !=3D 0) { + if (rc =3D=3D -2) { + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", + _("preallocate is not supported on this pla= tform")); + } else { + virReportSystemError(errno, + _("Failed to pre-allocate space for " + "file '%s'"), path); + } + return -1; + } + } + + if (ftruncate(fd, capacity) < 0) { + virReportSystemError(errno, + _("Failed to truncate file '%s'"), path); + return -1; + } + + if (VIR_CLOSE(fd) < 0) { + virReportSystemError(errno, _("Unable to save '%s'"), path); + return -1; + } + + return 0; +} + + int virFileTouch(const char *path, mode_t mode) { int fd =3D -1; diff --git a/src/util/virfile.h b/src/util/virfile.h index 28dfe86445..45b75a059e 100644 --- a/src/util/virfile.h +++ b/src/util/virfile.h @@ -133,6 +133,10 @@ int virFileRewriteStr(const char *path, mode_t mode, const char *str); =20 +int virFileResize(const char *path, + unsigned long long capacity, + bool pre_allocate); + int virFileTouch(const char *path, mode_t mode); =20 int virFileUpdatePerm(const char *path, diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index d6ff47e4a7..66694bfcc0 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -1193,53 +1193,6 @@ virStorageFileGetMetadataFromFD(const char *path, } =20 =20 -/** - * virStorageFileResize: - * - * Change the capacity of the raw storage file at 'path'. - */ -int -virStorageFileResize(const char *path, - unsigned long long capacity, - bool pre_allocate) -{ - int rc; - VIR_AUTOCLOSE fd =3D -1; - - if ((fd =3D open(path, O_RDWR)) < 0) { - virReportSystemError(errno, _("Unable to open '%s'"), path); - return -1; - } - - if (pre_allocate) { - if ((rc =3D virFileAllocate(fd, 0, capacity)) !=3D 0) { - if (rc =3D=3D -2) { - virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", - _("preallocate is not supported on this pla= tform")); - } else { - virReportSystemError(errno, - _("Failed to pre-allocate space for " - "file '%s'"), path); - } - return -1; - } - } - - if (ftruncate(fd, capacity) < 0) { - virReportSystemError(errno, - _("Failed to truncate file '%s'"), path); - return -1; - } - - if (VIR_CLOSE(fd) < 0) { - virReportSystemError(errno, _("Unable to save '%s'"), path); - return -1; - } - - return 0; -} - - int virStorageFileIsClusterFS(const char *path) { /* These are coherent cluster filesystems known to be safe for diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h index ec34f2d899..94bb889d84 100644 --- a/src/util/virstoragefile.h +++ b/src/util/virstoragefile.h @@ -420,10 +420,6 @@ virStorageSourcePtr virStorageFileChainLookup(virStora= geSourcePtr chain, virStorageSourcePtr *parent) ATTRIBUTE_NONNULL(1); =20 -int virStorageFileResize(const char *path, - unsigned long long capacity, - bool pre_allocate); - int virStorageFileIsClusterFS(const char *path); bool virStorageIsFile(const char *path); bool virStorageIsRelative(const char *backing); --=20 2.29.2 From nobody Fri Mar 29 08:07:05 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=1609936026; cv=none; d=zohomail.com; s=zohoarc; b=M7WyFg60sA3D9zbPk5RLkSKQLN4vwJHy8D4zwXbLIe9nCwr13q2/pMOo57hXc6Nz68PB3Fg4lOLGZp1v67E00Udv9jKKrtbf83QoVLxj9erwuaEgZzTs66hS8+KE5z87rJdWq4vtMWiBjk4ikgFzuw722TNRg/2eBL2NewVMkKA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1609936026; 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=BvvVUExdjfjHJR3phT/bk1okSzfm4/IGvOcApnsqJH0=; b=fpA08+QGKOHsl13BDvlt9wD8kiiaFRMPh3I7jcCvG6KZgmb6mwd9pUdBRJ5qYNdP2YX3oQqAsbKIjZkExI0iHuFc4v7lXxD7llXojP5FcwZOKG4rTXdTvJ202KMl7/Ajlx9Yir8K+Pfcbi7mYeBSTWXsmrJsowiG3yX6XH9FklI= 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 160993602689039.32185407425959; Wed, 6 Jan 2021 04:27:06 -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-574-WQpcPj1TOu-1JxJT4tqFbg-1; Wed, 06 Jan 2021 07:26:32 -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 823BF106F8DE; Wed, 6 Jan 2021 12:26:27 +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 5B33010021AA; Wed, 6 Jan 2021 12:26:27 +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 259121809CA9; Wed, 6 Jan 2021 12:26:27 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 106CQF9W019116 for ; Wed, 6 Jan 2021 07:26:15 -0500 Received: by smtp.corp.redhat.com (Postfix) id 22E8760BFA; Wed, 6 Jan 2021 12:26:15 +0000 (UTC) Received: from antique-work.lan (unknown [10.40.194.49]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9402960BE5 for ; Wed, 6 Jan 2021 12:26:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1609936025; 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=BvvVUExdjfjHJR3phT/bk1okSzfm4/IGvOcApnsqJH0=; b=ZK56b3xeb3psrGpHTm+XL0wlfnDS4HmkPU3CyqXF8GnaGVUwWyS52WNEnZRUl2Rn8x8L2l KARMrY7MsMh1rheG1nh0ZvUDBm45zLmHv2bR8EwZZyfWbbe+TmPJWfi3qQDw55aga8e2Or PsGXcj6Crj4RinKJ0eT3L+9kr7YiL1s= X-MC-Unique: WQpcPj1TOu-1JxJT4tqFbg-1 From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH v2 9/9] virstoragefile: move virStorageFileIsClusterFS into virfile Date: Wed, 6 Jan 2021 13:26:00 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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" Signed-off-by: Pavel Hrdina Reviewed-by: Peter Krempa --- src/libvirt_private.syms | 2 +- src/qemu/qemu_migration.c | 2 +- src/util/virfile.c | 13 +++++++++++++ src/util/virfile.h | 1 + src/util/virstoragefile.c | 11 ----------- src/util/virstoragefile.h | 1 - 6 files changed, 16 insertions(+), 14 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index e79dc54d33..c67bd2504a 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2087,6 +2087,7 @@ virFileGetXAttr; virFileGetXAttrQuiet; virFileInData; virFileIsCDROM; +virFileIsClusterFS; virFileIsDir; virFileIsExecutable; virFileIsLink; @@ -3145,7 +3146,6 @@ virStorageFileGetSCSIKey; virStorageFileGetUniqueIdentifier; virStorageFileInit; virStorageFileInitAs; -virStorageFileIsClusterFS; virStorageFileParseBackingStoreStr; virStorageFileParseChainIndex; virStorageFileProbeFormat; diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 90b0ec95e3..07235d6480 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -1466,7 +1466,7 @@ qemuMigrationSrcIsSafe(virDomainDefPtr def, } else if (rc =3D=3D 0) { unsafe =3D true; } - if ((rc =3D virStorageFileIsClusterFS(src)) < 0) + if ((rc =3D virFileIsClusterFS(src)) < 0) return false; else if (rc =3D=3D 1) continue; diff --git a/src/util/virfile.c b/src/util/virfile.c index 6e16780e30..609cafdd34 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -3709,6 +3709,19 @@ int virFileIsSharedFS(const char *path) } =20 =20 +int +virFileIsClusterFS(const char *path) +{ + /* These are coherent cluster filesystems known to be safe for + * migration with cache !=3D none + */ + return virFileIsSharedFSType(path, + VIR_FILE_SHFS_GFS2 | + VIR_FILE_SHFS_OCFS | + VIR_FILE_SHFS_CEPH); +} + + #if defined(__linux__) && defined(WITH_SYS_MOUNT_H) int virFileSetupDev(const char *path, diff --git a/src/util/virfile.h b/src/util/virfile.h index 45b75a059e..733d652ac9 100644 --- a/src/util/virfile.h +++ b/src/util/virfile.h @@ -223,6 +223,7 @@ enum { =20 int virFileIsSharedFSType(const char *path, int fstypes) ATTRIBUTE_NONNULL= (1); int virFileIsSharedFS(const char *path) ATTRIBUTE_NONNULL(1); +int virFileIsClusterFS(const char *path) ATTRIBUTE_NONNULL(1); int virFileIsMountPoint(const char *file) ATTRIBUTE_NONNULL(1); int virFileIsCDROM(const char *path) ATTRIBUTE_NONNULL(1) G_GNUC_WARN_UNUSED_RESULT; diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index 66694bfcc0..3db85d8b89 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -1193,17 +1193,6 @@ virStorageFileGetMetadataFromFD(const char *path, } =20 =20 -int virStorageFileIsClusterFS(const char *path) -{ - /* These are coherent cluster filesystems known to be safe for - * migration with cache !=3D none - */ - return virFileIsSharedFSType(path, - VIR_FILE_SHFS_GFS2 | - VIR_FILE_SHFS_OCFS | - VIR_FILE_SHFS_CEPH); -} - #ifdef WITH_UDEV /* virStorageFileGetSCSIKey * @path: Path to the SCSI device diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h index 94bb889d84..2452b967b2 100644 --- a/src/util/virstoragefile.h +++ b/src/util/virstoragefile.h @@ -420,7 +420,6 @@ virStorageSourcePtr virStorageFileChainLookup(virStorag= eSourcePtr chain, virStorageSourcePtr *parent) ATTRIBUTE_NONNULL(1); =20 -int virStorageFileIsClusterFS(const char *path); bool virStorageIsFile(const char *path); bool virStorageIsRelative(const char *backing); =20 --=20 2.29.2