From nobody Sat May 4 22:19:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1522041435636268.8852566536656; Sun, 25 Mar 2018 22:17:15 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EE4A73DE42; Mon, 26 Mar 2018 05:17:13 +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 352535C890; Mon, 26 Mar 2018 05:17:13 +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 A81ED4CA9A; Mon, 26 Mar 2018 05:17:09 +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 w2Q5H8NP027617 for ; Mon, 26 Mar 2018 01:17:08 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5D8B5200BC7C; Mon, 26 Mar 2018 05:17:08 +0000 (UTC) Received: from localhost.localdomain (ovpn-204-33.brq.redhat.com [10.40.204.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id E50CA2026E04 for ; Mon, 26 Mar 2018 05:17:07 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Mon, 26 Mar 2018 07:16:42 +0200 Message-Id: <5efab8fb32e7e0e68ea0f9cf46c414d795392ee7.1522041162.git.mprivozn@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 1/5] virlog: Don't log devmapper X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 26 Mar 2018 05:17:14 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Unless overridden, libdevmapper logs all messages to stderr. Therefore if something goes wrong in storage_backend_mpath.c or parthelper.c we don't honour user set logging targets. Signed-off-by: Michal Privoznik --- src/util/virlog.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/util/virlog.c b/src/util/virlog.c index dd927f0ba7..51f2d341db 100644 --- a/src/util/virlog.c +++ b/src/util/virlog.c @@ -40,6 +40,9 @@ #if HAVE_SYS_UN_H # include #endif +#if WITH_DEVMAPPER +# include +#endif =20 #include "virerror.h" #include "virlog.h" @@ -258,6 +261,20 @@ virLogPriorityString(virLogPriority lvl) } =20 =20 +#ifdef WITH_DEVMAPPER +static void +virLogDM(int level ATTRIBUTE_UNUSED, + const char *file ATTRIBUTE_UNUSED, + int line ATTRIBUTE_UNUSED, + int dm_errno ATTRIBUTE_UNUSED, + const char *fmt ATTRIBUTE_UNUSED, + ...) +{ + return; +} +#endif + + static int virLogOnceInit(void) { @@ -289,6 +306,12 @@ virLogOnceInit(void) NUL_TERMINATE(virLogHostname); } =20 +#ifdef WITH_DEVMAPPER + /* Ideally, we would not need this. But libdevmapper prints + * error messages to stderr by default. Sad but true. */ + dm_log_with_errno_init(virLogDM); +#endif + virLogUnlock(); return 0; } --=20 2.16.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat May 4 22:19:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 152204145606839.85958543122638; Sun, 25 Mar 2018 22:17:36 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id CB87BC057F92; Mon, 26 Mar 2018 05:17:34 +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 98DBD18B26; Mon, 26 Mar 2018 05:17:34 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 6364D4CA9D; Mon, 26 Mar 2018 05:17:34 +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 w2Q5H93S027623 for ; Mon, 26 Mar 2018 01:17:09 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1CA19200BC7C; Mon, 26 Mar 2018 05:17:09 +0000 (UTC) Received: from localhost.localdomain (ovpn-204-33.brq.redhat.com [10.40.204.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id A4467200BC87 for ; Mon, 26 Mar 2018 05:17:08 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Mon, 26 Mar 2018 07:16:43 +0200 Message-Id: <89296884c9f600f3f4c925163b3faa40a4a57a7d.1522041162.git.mprivozn@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/5] utils: Introduce virFileGetMPathTargets X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Mon, 26 Mar 2018 05:17:35 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This helper fetches targets for multipath devices. Signed-off-by: Michal Privoznik --- src/libvirt_private.syms | 1 + src/util/virfile.c | 90 ++++++++++++++++++++++++++++++++++++++++++++= ++++ src/util/virfile.h | 4 +++ 3 files changed, 95 insertions(+) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 03fe3b315f..1bbff72263 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1773,6 +1773,7 @@ virFileGetACLs; virFileGetHugepageSize; virFileGetMountReverseSubtree; virFileGetMountSubtree; +virFileGetMPathTargets; virFileHasSuffix; virFileInData; virFileIsAbsPath; diff --git a/src/util/virfile.c b/src/util/virfile.c index 5e9bd2007a..f89e4bd823 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -64,6 +64,10 @@ # include #endif =20 +#ifdef WITH_DEVMAPPER +# include +#endif + #include "configmake.h" #include "intprops.h" #include "viralloc.h" @@ -4227,3 +4231,89 @@ virFileWaitForExists(const char *path, =20 return 0; } + + +#ifdef WITH_DEVMAPPER +/** + * virFileGetMPathTargets: + * @path: multipath device + * @devs: returned array of st_rdevs of @path targets + * @ndevs: size of @devs and @devNames + * + * For given @path figure out its targets, and store them in + * @devs. Items from @devs are meant to be used in + * minor() and major() to receive device MAJ:MIN pairs. + * + * If @path is not a multipath device, @ndevs is set to 0 and + * success is returned. + * + * If we don't have permissions to talk to kernel, -1 is returned + * and errno is set to EBADF. + * + * Returns 0 on success, -1 otherwise. + */ +int +virFileGetMPathTargets(const char *path, + unsigned long long **devs, + size_t *ndevs) +{ + struct dm_deps *deps; + struct dm_task *dmt; + struct dm_info info; + size_t i; + int ret =3D -1; + + *ndevs =3D 0; + + if (!(dmt =3D dm_task_create(DM_DEVICE_DEPS))) + goto cleanup; + + if (!dm_task_set_name(dmt, path)) { + if (errno =3D=3D ENOENT) { + /* It's okay, @path is not managed by devmapper =3D> + * not a multipath device. */ + ret =3D 0; + } + goto cleanup; + } + + dm_task_no_open_count(dmt); + + if (!dm_task_run(dmt)) + goto cleanup; + + if (!dm_task_get_info(dmt, &info)) + goto cleanup; + + if (!info.exists) { + ret =3D 0; + goto cleanup; + } + + if (!(deps =3D dm_task_get_deps(dmt))) + goto cleanup; + + if (VIR_ALLOC_N(*devs, deps->count) < 0) + goto cleanup; + *ndevs =3D deps->count; + + for (i =3D 0; i < deps->count; i++) + (*devs)[i] =3D deps->device[i]; + + ret =3D 0; + cleanup: + dm_task_destroy(dmt); + return ret; +} + +#else /* ! WITH_DEVMAPPER */ + +int +virFileGetMPathTargets(const char *path ATTRIBUTE_UNUSED, + unsigned long long **devs ATTRIBUTE_UNUSED, + size_t *ndevs ATTRIBUTE_UNUSED) +{ + errno =3D ENOSYS; + return -1; +} +#endif /* ! WITH_DEVMAPPER */ diff --git a/src/util/virfile.h b/src/util/virfile.h index cd2a3867c2..0db8bf0b99 100644 --- a/src/util/virfile.h +++ b/src/util/virfile.h @@ -358,4 +358,8 @@ int virFileInData(int fd, int *inData, long long *length); =20 +int virFileGetMPathTargets(const char *path, + unsigned long long **devs, + size_t *ndevs); + #endif /* __VIR_FILE_H */ --=20 2.16.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat May 4 22:19:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1522041437105274.25986507549464; Sun, 25 Mar 2018 22:17:17 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 56BFE80F7A; Mon, 26 Mar 2018 05:17:15 +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 2326B60F82; Mon, 26 Mar 2018 05:17:15 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id B9C4E181BA03; Mon, 26 Mar 2018 05:17:14 +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 w2Q5H9hE027628 for ; Mon, 26 Mar 2018 01:17:10 -0400 Received: by smtp.corp.redhat.com (Postfix) id D14B92026E04; Mon, 26 Mar 2018 05:17:09 +0000 (UTC) Received: from localhost.localdomain (ovpn-204-33.brq.redhat.com [10.40.204.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id 646BC202322B for ; Mon, 26 Mar 2018 05:17:09 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Mon, 26 Mar 2018 07:16:44 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 3/5] virfile: Introduce virFileMajMinToName X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 26 Mar 2018 05:17:15 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This function can be used to translate MAJ:MIN device pair into /dev/blah name. Signed-off-by: Michal Privoznik --- src/libvirt_private.syms | 1 + src/util/virfile.c | 53 ++++++++++++++++++++++++++++++++++++++++++++= ++++ src/util/virfile.h | 3 +++ 3 files changed, 57 insertions(+) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 1bbff72263..a705bfd5ef 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1787,6 +1787,7 @@ virFileLength; virFileLinkPointsTo; virFileLock; virFileLoopDeviceAssociate; +virFileMajMinToName; virFileMakeParentPath; virFileMakePath; virFileMakePathWithMode; diff --git a/src/util/virfile.c b/src/util/virfile.c index f89e4bd823..62620862a1 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -68,6 +68,12 @@ # include #endif =20 +#ifdef MAJOR_IN_MKDEV +# include +#elif MAJOR_IN_SYSMACROS +# include +#endif + #include "configmake.h" #include "intprops.h" #include "viralloc.h" @@ -4317,3 +4323,50 @@ virFileGetMPathTargets(const char *path ATTRIBUTE_UN= USED, return -1; } #endif /* ! WITH_DEVMAPPER */ + + +/** + * virFileMajMinToName: + * @device: device (rdev) to translate + * @name: returned name + * + * For given MAJ:MIN pair (stored in one integer like in st_rdev) + * fetch device name, e.g. 8:0 is translated to "/dev/sda". + * Caller is responsible for freeing @name when no longer needed. + * + * Returns 0 on success, -1 otherwise. + */ +int +virFileMajMinToName(unsigned long long device, + char **name) +{ + struct stat sb; + char *sysfsPath =3D NULL; + char *link =3D NULL; + int ret =3D -1; + + *name =3D NULL; + if (virAsprintf(&sysfsPath, "/sys/dev/block/%u:%u", + major(device), minor(device)) < 0) + goto cleanup; + + if (lstat(sysfsPath, &sb) < 0) + goto cleanup; + + if (!S_ISLNK(sb.st_mode)) { + errno =3D ENXIO; + goto cleanup; + } + + if (virFileReadLink(sysfsPath, &link) < 0) + goto cleanup; + + if (virAsprintf(name, "/dev/%s", last_component(link)) < 0) + goto cleanup; + + ret =3D 0; + cleanup: + VIR_FREE(link); + VIR_FREE(sysfsPath); + return ret; +} diff --git a/src/util/virfile.h b/src/util/virfile.h index 0db8bf0b99..390940dc98 100644 --- a/src/util/virfile.h +++ b/src/util/virfile.h @@ -362,4 +362,7 @@ int virFileGetMPathTargets(const char *path, unsigned long long **devs, size_t *ndevs); =20 +int virFileMajMinToName(unsigned long long device, + char **name); + #endif /* __VIR_FILE_H */ --=20 2.16.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat May 4 22:19:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1522041455875531.9944578006277; Sun, 25 Mar 2018 22:17:35 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 7CC7B811A9; Mon, 26 Mar 2018 05:17:34 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5203D4F6D2; Mon, 26 Mar 2018 05:17:34 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 14CB1181BA08; Mon, 26 Mar 2018 05:17:34 +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 w2Q5HALI027633 for ; Mon, 26 Mar 2018 01:17:10 -0400 Received: by smtp.corp.redhat.com (Postfix) id 90E4C200BC87; Mon, 26 Mar 2018 05:17:10 +0000 (UTC) Received: from localhost.localdomain (ovpn-204-33.brq.redhat.com [10.40.204.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2498A200BC7C for ; Mon, 26 Mar 2018 05:17:09 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Mon, 26 Mar 2018 07:16:45 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 4/5] qemu: Handle multipath devices properly X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 26 Mar 2018 05:17:34 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" https://bugzilla.redhat.com/show_bug.cgi?id=3D1557769 Problem with multipath devices is that there can be several other devices 'hidden' behind them. For instance, /dev/dm-1 can consist of /dev/sda, /dev/sdb and /dev/sdc. Therefore, when setting up devices CGroup and namespaces we have to take this into account. Signed-off-by: Michal Privoznik --- libvirt.spec.in | 2 ++ src/qemu/qemu_cgroup.c | 43 ++++++++++++++++++++++++++++++++++--- src/qemu/qemu_domain.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++= ++++ 3 files changed, 100 insertions(+), 3 deletions(-) diff --git a/libvirt.spec.in b/libvirt.spec.in index b55a947ec9..ebfac10866 100644 --- a/libvirt.spec.in +++ b/libvirt.spec.in @@ -796,6 +796,8 @@ Requires: gzip Requires: bzip2 Requires: lzop Requires: xz +# For mpath devices +Requires: device-mapper %if 0%{?fedora} || 0%{?rhel} > 7 Requires: systemd-container %endif diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c index b604edb31c..a2198c9789 100644 --- a/src/qemu/qemu_cgroup.c +++ b/src/qemu/qemu_cgroup.c @@ -60,7 +60,12 @@ qemuSetupImagePathCgroup(virDomainObjPtr vm, { qemuDomainObjPrivatePtr priv =3D vm->privateData; int perms =3D VIR_CGROUP_DEVICE_READ; - int ret; + unsigned long long *mpathdevs =3D NULL; + size_t nmpathdevs =3D 0; + size_t i; + char *devPath =3D NULL; + int rv; + int ret =3D -1; =20 if (!virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_DEVICE= S)) return 0; @@ -71,12 +76,44 @@ qemuSetupImagePathCgroup(virDomainObjPtr vm, VIR_DEBUG("Allow path %s, perms: %s", path, virCgroupGetDevicePermsString(perms)); =20 - ret =3D virCgroupAllowDevicePath(priv->cgroup, path, perms, true); + rv =3D virCgroupAllowDevicePath(priv->cgroup, path, perms, true); =20 virDomainAuditCgroupPath(vm, priv->cgroup, "allow", path, virCgroupGetDevicePermsString(perms), - ret); + rv); + if (rv < 0) + goto cleanup; =20 + if (virFileGetMPathTargets(path, &mpathdevs, &nmpathdevs) < 0 && + errno !=3D ENOSYS && errno !=3D EBADF) { + virReportSystemError(errno, + _("Unable to get mpath targets for %s"), + path); + goto cleanup; + } + + for (i =3D 0; i < nmpathdevs; i++) { + if (virFileMajMinToName(mpathdevs[i], &devPath) < 0) { + virReportSystemError(errno, + _("Unable to translate %llx to device pat= h"), + mpathdevs[i]); + goto cleanup; + } + + rv =3D virCgroupAllowDevicePath(priv->cgroup, devPath, perms, true= ); + + virDomainAuditCgroupPath(vm, priv->cgroup, "allow", devPath, + virCgroupGetDevicePermsString(perms), + rv); + if (rv < 0) + goto cleanup; + VIR_FREE(devPath); + } + + ret =3D 0; + cleanup: + VIR_FREE(devPath); + VIR_FREE(mpathdevs); return ret; } =20 diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 4aaf617dae..cd39eb5942 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -10105,6 +10105,10 @@ qemuDomainSetupDisk(virQEMUDriverConfigPtr cfg ATT= RIBUTE_UNUSED, { virStorageSourcePtr next; char *dst =3D NULL; + unsigned long long *mpathdevs =3D NULL; + size_t nmpathdevs =3D 0; + char *mpathPath =3D NULL; + size_t i; int ret =3D -1; =20 for (next =3D disk->src; virStorageSourceIsBacking(next); next =3D nex= t->backingStore) { @@ -10115,10 +10119,34 @@ qemuDomainSetupDisk(virQEMUDriverConfigPtr cfg AT= TRIBUTE_UNUSED, =20 if (qemuDomainCreateDevice(next->path, data, false) < 0) goto cleanup; + + if (virFileGetMPathTargets(next->path, &mpathdevs, &nmpathdevs) < = 0 && + errno !=3D ENOSYS && errno !=3D EBADF) { + virReportSystemError(errno, + _("Unable to get mpath targets for %s"), + next->path); + goto cleanup; + } + + for (i =3D 0; i < nmpathdevs; i++) { + if (virFileMajMinToName(mpathdevs[i], &mpathPath) < 0) { + virReportSystemError(errno, + _("Unable to translate %llx to device= path"), + mpathdevs[i]); + goto cleanup; + } + + if (qemuDomainCreateDevice(mpathPath, data, false) < 0) + goto cleanup; + + VIR_FREE(mpathPath); + } } =20 ret =3D 0; cleanup: + VIR_FREE(mpathPath); + VIR_FREE(mpathdevs); VIR_FREE(dst); return ret; } @@ -11128,6 +11156,10 @@ qemuDomainNamespaceSetupDisk(virDomainObjPtr vm, virStorageSourcePtr next; char **paths =3D NULL; size_t npaths =3D 0; + unsigned long long *mpathdevs =3D NULL; + char **mpathdevPaths =3D NULL; + size_t nmpathdevs =3D 0; + size_t i; int ret =3D -1; =20 if (!qemuDomainNamespaceEnabled(vm, QEMU_DOMAIN_NS_MOUNT)) @@ -11142,6 +11174,29 @@ qemuDomainNamespaceSetupDisk(virDomainObjPtr vm, =20 if (VIR_APPEND_ELEMENT_COPY(paths, npaths, next->path) < 0) goto cleanup; + + if (virFileGetMPathTargets(next->path, &mpathdevs, &nmpathdevs) < = 0 && + errno !=3D ENOSYS && errno !=3D EBADF) { + virReportSystemError(errno, + _("Unable to get mpath targets for %s"), + next->path); + goto cleanup; + } + + if (VIR_ALLOC_N(mpathdevPaths, nmpathdevs) < 0) + goto cleanup; + + for (i =3D 0; i < nmpathdevs; i++) { + if (virFileMajMinToName(mpathdevs[i], &mpathdevPaths[i]) < 0) { + virReportSystemError(errno, + _("Unable to translate %llx to device= path"), + mpathdevs[i]); + goto cleanup; + } + + if (VIR_APPEND_ELEMENT_COPY(paths, npaths, mpathdevPaths[i]) <= 0) + goto cleanup; + } } =20 if (qemuDomainNamespaceMknodPaths(vm, (const char **)paths, npaths) < = 0) @@ -11149,6 +11204,9 @@ qemuDomainNamespaceSetupDisk(virDomainObjPtr vm, =20 ret =3D 0; cleanup: + for (i =3D 0; i < nmpathdevs; i++) + VIR_FREE(mpathdevPaths[i]); + VIR_FREE(mpathdevPaths); VIR_FREE(paths); return ret; } --=20 2.16.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat May 4 22:19:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1522041459998421.3466192966159; Sun, 25 Mar 2018 22:17:39 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 7AD6587626; Mon, 26 Mar 2018 05:17:38 +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 E234118E59; Mon, 26 Mar 2018 05:17:37 +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 9C298181BA0A; Mon, 26 Mar 2018 05:17:37 +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 w2Q5HBqP027642 for ; Mon, 26 Mar 2018 01:17:11 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4FF34200BC7C; Mon, 26 Mar 2018 05:17:11 +0000 (UTC) Received: from localhost.localdomain (ovpn-204-33.brq.redhat.com [10.40.204.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id D82CC2026E04 for ; Mon, 26 Mar 2018 05:17:10 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Mon, 26 Mar 2018 07:16:46 +0200 Message-Id: <18a15d17d2846bce6cc76fb65c35a348782631a5.1522041162.git.mprivozn@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 5/5] news: Document multipath fix X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 26 Mar 2018 05:17:39 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Michal Privoznik --- docs/news.xml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/docs/news.xml b/docs/news.xml index 1088895746..a7ac63eddb 100644 --- a/docs/news.xml +++ b/docs/news.xml @@ -94,6 +94,16 @@
+ + + Improve handling of multipath devices + + + When starting a domain with a disk hidden behind + devmapper libvirt needs to allow them both in devices + CGroup: the devmapper target and the disk. + +
--=20 2.16.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list