From nobody Wed Apr 24 08:09:25 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; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1528629295950522.7220289290383; Sun, 10 Jun 2018 04:14:55 -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 BACE230820C8; Sun, 10 Jun 2018 11:14:53 +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 2A42382F48; Sun, 10 Jun 2018 11:14:53 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 336EF4CA80; Sun, 10 Jun 2018 11:14:50 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w5ABEm4Y007988 for ; Sun, 10 Jun 2018 07:14:48 -0400 Received: by smtp.corp.redhat.com (Postfix) id 184445799B; Sun, 10 Jun 2018 11:14:48 +0000 (UTC) Received: from mx1.redhat.com (ext-mx20.extmail.prod.ext.phx2.redhat.com [10.5.110.49]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 128F228DD6 for ; Sun, 10 Jun 2018 11:14:46 +0000 (UTC) Received: from mail-wr0-f175.google.com (mail-wr0-f175.google.com [209.85.128.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7BB2A3086244 for ; Sun, 10 Jun 2018 11:14:35 +0000 (UTC) Received: by mail-wr0-f175.google.com with SMTP id o12-v6so17444469wrm.12 for ; Sun, 10 Jun 2018 04:14:35 -0700 (PDT) Received: from rst.Home ([2a02:c7d:692a:c500:1ebc:73f3:5f60:b131]) by smtp.gmail.com with ESMTPSA id f2-v6sm6869448wre.16.2018.06.10.04.14.32 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 10 Jun 2018 04:14:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=rDjOZdf2BtrWOl/K2F+kX6Y6l/VftuLtriDIa1xSZoY=; b=IgmxLnshnVJHULoEQF8wOym3akMtQg6C40+P3wC6w+rqBqpaCTme3SvlLu/NrqAIuF ZVslC+gbpjBdA1MFuYkf50+wcvmWvCAAlrAQUYHRlfeIQoJGihfx/W30sZOHrsXZpoZL zUetG2jHGXHWpN4XNJJC+j+je/jy3EvoieF/hN7QsIrzd8o0ZtJGoev433CNlmCYU7z9 H0vF5AF/z0ES9nvZXy73eulkL6BBy7gizyxK4nSOqWirRgg9Xaykt5rORqvX6nTZ9UM5 pLxDFIoWmpgLR7IlirLiCkImoiKjp2cNCNWrF1u1yvU0LDIT8C/UiMmUPk5gu260gpgC 8Cdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=rDjOZdf2BtrWOl/K2F+kX6Y6l/VftuLtriDIa1xSZoY=; b=mFPBvnWc/Q75R33476FzmHEJPag0EJQA2rmZHZtL2uhfMAFKrPcTqu4lGqnVyQmIF6 wPF5Pp2V+d0poT3TY1PfGIj7Z5yOfdArR+owaObZS0eNb39LsUCmB8V8ZLonRp+o3JwW umMkj1W1+f1TJLfwFgwThrmcl1sgiyRAJuFm8rOv/cX2yWiMXN8RW1P5FB/CEbbTW9lt I0FSaUfg9evNhMQJIrCu+axv2FJJkG3kELaCo2B045Fgs5DDqYAzfFBexOvcIxJ21hRx K1FXp6QjPO6pQq53GHESYNDyGVzT3nyucDT9pl1qMvUwGyPJl8MRDMmf//6ga5JaLWrg IN0A== X-Gm-Message-State: APt69E1K5XOKWdb943IrpMd1HFH+hiAwHq6GaKHtTZCXz762gD9kVumH uW5QEVZyRK3ZyXUX40A8d97/2PyV X-Google-Smtp-Source: ADUXVKIo6dyLm5BswIbuW85nJQDPF2UDvJD4/jKTnoZhQZ5oFrtdHPNgpH3ofKYHapVL+esK2e2ZLA== X-Received: by 2002:adf:a792:: with SMTP id j18-v6mr10499047wrc.187.1528629273963; Sun, 10 Jun 2018 04:14:33 -0700 (PDT) From: Radostin Stoyanov To: libvir-list@redhat.com Date: Sun, 10 Jun 2018 12:14:23 +0100 Message-Id: <20180610111426.5211-2-rstoyanov1@gmail.com> In-Reply-To: <20180610111426.5211-1-rstoyanov1@gmail.com> References: <20180610111426.5211-1-rstoyanov1@gmail.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Sun, 10 Jun 2018 11:14:35 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Sun, 10 Jun 2018 11:14:35 +0000 (UTC) for IP:'209.85.128.175' DOMAIN:'mail-wr0-f175.google.com' HELO:'mail-wr0-f175.google.com' FROM:'rstoyanov1@gmail.com' RCPT:'' X-RedHat-Spam-Score: 1.55 * (DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, NML_ADSP_CUSTOM_MED, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_PASS, T_DKIM_INVALID) 209.85.128.175 mail-wr0-f175.google.com 209.85.128.175 mail-wr0-f175.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.49 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: Radostin Stoyanov Subject: [libvirt] [RFC v2 1/4] lxc: Make lxcContainerMountFSBlock non static 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.47]); Sun, 10 Jun 2018 11:14:54 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" --- src/lxc/lxc_container.c | 5 +---- src/lxc/lxc_container.h | 4 ++++ 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c index 665b93a0ac..3f6be9f44d 100644 --- a/src/lxc/lxc_container.c +++ b/src/lxc/lxc_container.c @@ -113,9 +113,6 @@ struct __lxc_child_argv { int *nsInheritFDs; }; =20 -static int lxcContainerMountFSBlock(virDomainFSDefPtr fs, - const char *srcprefix, - const char *sec_mount_options); =20 =20 /* @@ -1499,7 +1496,7 @@ static int lxcContainerMountFSBlockHelper(virDomainFS= DefPtr fs, } =20 =20 -static int lxcContainerMountFSBlock(virDomainFSDefPtr fs, +int lxcContainerMountFSBlock(virDomainFSDefPtr fs, const char *srcprefix, const char *sec_mount_options) { diff --git a/src/lxc/lxc_container.h b/src/lxc/lxc_container.h index 641e2d4607..3a3564b794 100644 --- a/src/lxc/lxc_container.h +++ b/src/lxc/lxc_container.h @@ -68,4 +68,8 @@ int lxcContainerChown(virDomainDefPtr def, const char *pa= th); =20 bool lxcIsBasicMountLocation(const char *path); =20 +int lxcContainerMountFSBlock(virDomainFSDefPtr fs, + const char *srcprefix, + const char *sec_mount_options); + #endif /* LXC_CONTAINER_H */ --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed Apr 24 08:09:25 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; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1528629318472244.98919172087972; Sun, 10 Jun 2018 04:15:18 -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 589243082A3A; Sun, 10 Jun 2018 11:15: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 1CFFF82F48; Sun, 10 Jun 2018 11:15: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 C55E81801218; Sun, 10 Jun 2018 11:15:16 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w5ABEo4G008007 for ; Sun, 10 Jun 2018 07:14:50 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2A75D308BDAB; Sun, 10 Jun 2018 11:14:50 +0000 (UTC) Received: from mx1.redhat.com (ext-mx20.extmail.prod.ext.phx2.redhat.com [10.5.110.49]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 22642308BDA0 for ; Sun, 10 Jun 2018 11:14:48 +0000 (UTC) Received: from mail-wr0-f194.google.com (mail-wr0-f194.google.com [209.85.128.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2EE5A308625E for ; Sun, 10 Jun 2018 11:14:37 +0000 (UTC) Received: by mail-wr0-f194.google.com with SMTP id v13-v6so17455733wrp.13 for ; Sun, 10 Jun 2018 04:14:37 -0700 (PDT) Received: from rst.Home ([2a02:c7d:692a:c500:1ebc:73f3:5f60:b131]) by smtp.gmail.com with ESMTPSA id f2-v6sm6869448wre.16.2018.06.10.04.14.34 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 10 Jun 2018 04:14:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=UyvFmNq+0tmGyvuxEdBXjJcxv2/k91nnirvJpHyh4iQ=; b=JXder3F5G4vQP0WWL4ZFjOdfwW9MF6F53ka4M62a6f517KfMMyWW8Te4CxLHKeoWY9 kkg2caQDJXA7vnCW1ihrbT5wgCbr1EC9Un0DSxeL9dIQepiqbtoLxxdNd7qRof4MMNTZ 7NU+ai+e/qm8FAOWcU4ZsNcOHiIjURG7snKQmaaIlXhf41sdrP8Nzcy+oY3pFGj8C9uH xYVKpjK0XEYjqkC8PCnbRm0+LUFozNNPGXIPNuOcN8SqFHTf1LgcjFdapZ60bgyODlti 5UcWmNWEFdU5lkGDUINjZZJhIFEiLuF8Nu9q+d9f1xgkzxa7y20pxXPCtLSzuwOxHHro dKNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=UyvFmNq+0tmGyvuxEdBXjJcxv2/k91nnirvJpHyh4iQ=; b=dVT8kYEsKrVAEP0OjSU1Y+FuLm+v/RVm4IyWKkfkCNsbq09MHpEVguA27HszBZvc72 an7jmUs05KufQAttxQTNM/aeLLt/eDrwqWMWv/zZrDcHWZas2UOj+WyW5YRx7mz7hizH G4bHxOcTUQaPJJeFPVSjD4/qF9hgeuFM3WOIsMVijGIlkkVXgpPErgVZwTVTCTk1/aiE ZZAT5Fafo33PyyZP2d0DGTPIxdhlYL7/s2i8Rh02mbCudzyhP2VV2kbAzh70USOSCIiJ gLUBjHTKhxVGHYK2+zReUFMGSxYpsTHVeNehbTRVZyv2h6HmM7+FRjzA4ZHRanEh4vhp A65g== X-Gm-Message-State: APt69E1/AQY4d/prPtmbDt9pyF3Kw/PG5tlg8dyiIRUI+PYoYUcfFP5B IMqMuYu7mFPivVs1Ct1HH3yf93us X-Google-Smtp-Source: ADUXVKLoF4g+sJhhxj2zt9H9y1/3GtB8MD7N89DKmex4U1lN7xm4H6QEuWY+2B1whUkfHMl7XR9gYA== X-Received: by 2002:a5d:4503:: with SMTP id s3-v6mr10054669wrq.191.1528629275508; Sun, 10 Jun 2018 04:14:35 -0700 (PDT) From: Radostin Stoyanov To: libvir-list@redhat.com Date: Sun, 10 Jun 2018 12:14:24 +0100 Message-Id: <20180610111426.5211-3-rstoyanov1@gmail.com> In-Reply-To: <20180610111426.5211-1-rstoyanov1@gmail.com> References: <20180610111426.5211-1-rstoyanov1@gmail.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Sun, 10 Jun 2018 11:14:37 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Sun, 10 Jun 2018 11:14:37 +0000 (UTC) for IP:'209.85.128.194' DOMAIN:'mail-wr0-f194.google.com' HELO:'mail-wr0-f194.google.com' FROM:'rstoyanov1@gmail.com' RCPT:'' X-RedHat-Spam-Score: 1.55 * (DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, NML_ADSP_CUSTOM_MED, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_PASS, T_DKIM_INVALID) 209.85.128.194 mail-wr0-f194.google.com 209.85.128.194 mail-wr0-f194.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.49 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.24 X-loop: libvir-list@redhat.com Cc: Radostin Stoyanov Subject: [libvirt] [RFC v2 2/4] lxc: Move up virLXCControllerAppendNBDPids 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.45]); Sun, 10 Jun 2018 11:15:18 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" There is no functional change in this patch. It only moves virLXCControllerAppendNBDPids above virLXCControllerSetupNBDDeviceFS. --- src/lxc/lxc_controller.c | 96 ++++++++++++++++++++-------------------- 1 file changed, 49 insertions(+), 47 deletions(-) diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c index 4e84391bf5..c9f416aaab 100644 --- a/src/lxc/lxc_controller.c +++ b/src/lxc/lxc_controller.c @@ -481,6 +481,55 @@ static int virLXCControllerSetupLoopDeviceDisk(virDoma= inDiskDefPtr disk) } =20 =20 +static int virLXCControllerAppendNBDPids(virLXCControllerPtr ctrl, + const char *dev) +{ + char *pidpath =3D NULL; + pid_t *pids =3D NULL; + size_t npids =3D 0; + size_t i; + int ret =3D -1; + size_t loops =3D 0; + pid_t pid; + + if (!STRPREFIX(dev, "/dev/") || + virAsprintf(&pidpath, "/sys/devices/virtual/block/%s/pid", dev + 5= ) < 0) + goto cleanup; + + /* Wait for the pid file to appear */ + while (!virFileExists(pidpath)) { + /* wait for 100ms before checking again, but don't do it for ever = */ + if (errno =3D=3D ENOENT && loops < 10) { + usleep(100 * 1000); + loops++; + } else { + virReportSystemError(errno, + _("Cannot check NBD device %s pid"), + dev + 5); + goto cleanup; + } + } + + if (virPidFileReadPath(pidpath, &pid) < 0) + goto cleanup; + + if (virProcessGetPids(pid, &npids, &pids) < 0) + goto cleanup; + + for (i =3D 0; i < npids; i++) { + if (VIR_APPEND_ELEMENT(ctrl->nbdpids, ctrl->nnbdpids, pids[i]) < 0) + goto cleanup; + } + + ret =3D 0; + + cleanup: + VIR_FREE(pids); + VIR_FREE(pidpath); + return ret; +} + + static int virLXCControllerSetupNBDDeviceFS(virDomainFSDefPtr fs) { char *dev; @@ -545,53 +594,6 @@ static int virLXCControllerSetupNBDDeviceDisk(virDomai= nDiskDefPtr disk) return 0; } =20 -static int virLXCControllerAppendNBDPids(virLXCControllerPtr ctrl, - const char *dev) -{ - char *pidpath =3D NULL; - pid_t *pids =3D NULL; - size_t npids =3D 0; - size_t i; - int ret =3D -1; - size_t loops =3D 0; - pid_t pid; - - if (!STRPREFIX(dev, "/dev/") || - virAsprintf(&pidpath, "/sys/devices/virtual/block/%s/pid", dev + 5= ) < 0) - goto cleanup; - - /* Wait for the pid file to appear */ - while (!virFileExists(pidpath)) { - /* wait for 100ms before checking again, but don't do it for ever = */ - if (errno =3D=3D ENOENT && loops < 10) { - usleep(100 * 1000); - loops++; - } else { - virReportSystemError(errno, - _("Cannot check NBD device %s pid"), - dev + 5); - goto cleanup; - } - } - - if (virPidFileReadPath(pidpath, &pid) < 0) - goto cleanup; - - if (virProcessGetPids(pid, &npids, &pids) < 0) - goto cleanup; - - for (i =3D 0; i < npids; i++) { - if (VIR_APPEND_ELEMENT(ctrl->nbdpids, ctrl->nnbdpids, pids[i]) < 0) - goto cleanup; - } - - ret =3D 0; - - cleanup: - VIR_FREE(pids); - VIR_FREE(pidpath); - return ret; -} =20 static int virLXCControllerSetupLoopDevices(virLXCControllerPtr ctrl) { --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed Apr 24 08:09:25 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; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1528629318484114.25479197668267; Sun, 10 Jun 2018 04:15:18 -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 3D43481DF1; Sun, 10 Jun 2018 11:15: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 ED3DC7F544; Sun, 10 Jun 2018 11:15:16 +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 A18694CA83; Sun, 10 Jun 2018 11:15:16 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w5ABEn5F008000 for ; Sun, 10 Jun 2018 07:14:49 -0400 Received: by smtp.corp.redhat.com (Postfix) id A3FE63001A70; Sun, 10 Jun 2018 11:14:49 +0000 (UTC) Received: from mx1.redhat.com (ext-mx16.extmail.prod.ext.phx2.redhat.com [10.5.110.45]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9BB573001A47 for ; Sun, 10 Jun 2018 11:14:49 +0000 (UTC) Received: from mail-wr0-f181.google.com (mail-wr0-f181.google.com [209.85.128.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 689F43082A39 for ; Sun, 10 Jun 2018 11:14:38 +0000 (UTC) Received: by mail-wr0-f181.google.com with SMTP id x4-v6so9312168wro.11 for ; Sun, 10 Jun 2018 04:14:38 -0700 (PDT) Received: from rst.Home ([2a02:c7d:692a:c500:1ebc:73f3:5f60:b131]) by smtp.gmail.com with ESMTPSA id f2-v6sm6869448wre.16.2018.06.10.04.14.35 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 10 Jun 2018 04:14:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=fL/hWvIWTqR9uVcbKTosqe6c9gggQmE+aBjQk7LMNXM=; b=JwAjs96/yxKDF2DYjGLHaWXXHGg9SuwH3wkgIewHkidsumQ5thqK/UNIfbFdxxa/4g je5IFCPNxz1a2gqxLr7H+0dtuTMRGub1dHoWg/PIkigCWLIyIDhuj5IxukwqovAAIje9 aq4aMdiKljMb8j6/grufAYeiN2F9fV2NKjCaaBtSqxYyRwCoSbS3Lw8pdZ8HRMkVbQKN CyRyjlECN53TggFOfvTz0w9Fd+xVtIKWDyY04it7ROLq3U21Wwi876CADXhDtmL0cUsO xGFIYAhwEoaTc/qVdgCjqOyvFWaicdmSiBE42f+zmE+gDRnZ4KQUxow3RCsE8i3ssNv7 0NZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=fL/hWvIWTqR9uVcbKTosqe6c9gggQmE+aBjQk7LMNXM=; b=BRlmRejtjgj5zqL1tRS3vjPtS5KGyuv1lIzmO82Dx+XbkveTapPM7TV+D2dO6cF3ZS emPzxdnXd9/DBOVwS4qfpHObu/LnKmt7AoDtqex0GB8bwBVhv9QCpWF016820j1oHlb5 273A2GRX3FRhnRKqz2mrrPlA3MLyyDfn53Ju+Zl4XoIO3OHXkTj/BhhFHN0vVjKQKJd1 mJ/fwbIxWUry0a+KA0Z5NWDw0dTNToWxehryJs+sot5kgxSWjimyN4rMUcFAybSk9zq+ oiaKIyCrou+/bY/JgT04KfNm3yHXoZqjx2gmOvsOxUCWRCR4LIKUMpEM6HRGUMIGiGw+ ms7g== X-Gm-Message-State: APt69E2Mc7PyBxy1VpJReggRz35HakPa/5ApDGLNJdtdaoUXkaNP1Nko UBWB2kbb4gWa/SY/xga8qwAfRxcN X-Google-Smtp-Source: ADUXVKKO00ZHg2bRwh3gbAVDSfijGDpHHIYG3Xch7JKRS13BLBW9vd4nq5L5ZVEr3uaIdBzFOT+YKQ== X-Received: by 2002:adf:84c2:: with SMTP id 60-v6mr10496832wrg.167.1528629276839; Sun, 10 Jun 2018 04:14:36 -0700 (PDT) From: Radostin Stoyanov To: libvir-list@redhat.com Date: Sun, 10 Jun 2018 12:14:25 +0100 Message-Id: <20180610111426.5211-4-rstoyanov1@gmail.com> In-Reply-To: <20180610111426.5211-1-rstoyanov1@gmail.com> References: <20180610111426.5211-1-rstoyanov1@gmail.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Sun, 10 Jun 2018 11:14:38 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Sun, 10 Jun 2018 11:14:38 +0000 (UTC) for IP:'209.85.128.181' DOMAIN:'mail-wr0-f181.google.com' HELO:'mail-wr0-f181.google.com' FROM:'rstoyanov1@gmail.com' RCPT:'' X-RedHat-Spam-Score: 1.551 * (DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, NML_ADSP_CUSTOM_MED, RCVD_IN_DNSWL_NONE, SPF_PASS, T_DKIM_INVALID) 209.85.128.181 mail-wr0-f181.google.com 209.85.128.181 mail-wr0-f181.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.45 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.26 X-loop: libvir-list@redhat.com Cc: Radostin Stoyanov Subject: [libvirt] [RFC v2 3/4] lxc: Mount NBD devices before clone 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.25]); Sun, 10 Jun 2018 11:15:17 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" When user-namespace is enabled we are not allowed to mount block/NBD devices. Instead, mount /dev/nbdX to /run/libvirt/lxc/.root and set: fs->src->path =3D /run/libvirt/lxc/.root fs->type =3D VIR_DOMAIN_FS_TYPE_MOUNT --- src/lxc/lxc_controller.c | 62 ++++++++++++++++++++++++++++------------ 1 file changed, 43 insertions(+), 19 deletions(-) diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c index c9f416aaab..78b52b7079 100644 --- a/src/lxc/lxc_controller.c +++ b/src/lxc/lxc_controller.c @@ -530,33 +530,63 @@ static int virLXCControllerAppendNBDPids(virLXCContro= llerPtr ctrl, } =20 =20 -static int virLXCControllerSetupNBDDeviceFS(virDomainFSDefPtr fs) +static int virLXCControllerSetupNBDDeviceFS(virLXCControllerPtr ctrl, + virDomainFSDefPtr fs) { - char *dev; + char *dev =3D NULL; + char *dst =3D NULL; + char *tmp =3D NULL; + char *sec_mount_options; + int ret =3D -1; + + virDomainDefPtr def =3D ctrl->def; + virSecurityManagerPtr securityDriver =3D ctrl->securityManager; =20 if (fs->format <=3D VIR_STORAGE_FILE_NONE) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("An explicit disk format must be specified")); - return -1; + goto cleanup; } =20 + if (virAsprintf(&dst, "%s/%s.root/", + LXC_STATE_DIR, def->name) < 0) + goto cleanup; + + if (!(sec_mount_options =3D virSecurityManagerGetMountOptions(security= Driver, def))) + goto cleanup; + if (virFileNBDDeviceAssociate(fs->src->path, fs->format, fs->readonly, &dev) < 0) - return -1; + goto cleanup; =20 - VIR_DEBUG("Changing fs %s to use type=3Dblock for dev %s", - fs->src->path, dev); - /* - * We now change it into a block device type, so that - * the rest of container setup 'just works' - */ - fs->type =3D VIR_DOMAIN_FS_TYPE_BLOCK; VIR_FREE(fs->src->path); fs->src->path =3D dev; =20 - return 0; + tmp =3D fs->dst; + fs->dst =3D dst; + + if (lxcContainerMountFSBlock(fs, "", sec_mount_options) < 0) { + fs->dst =3D tmp; + goto cleanup; + } + + fs->dst =3D tmp; + fs->type =3D VIR_DOMAIN_FS_TYPE_MOUNT; + + if (virLXCControllerAppendNBDPids(ctrl, fs->src->path) < 0) + return -1; + + VIR_STEAL_PTR(fs->src->path, dst); + + ret =3D 0; + + cleanup: + VIR_FREE(dev); + VIR_FREE(dst); + VIR_FREE(sec_mount_options); + return ret; } =20 =20 @@ -637,13 +667,7 @@ static int virLXCControllerSetupLoopDevices(virLXCCont= rollerPtr ctrl) } ctrl->loopDevFds[ctrl->nloopDevs - 1] =3D fd; } else if (fs->fsdriver =3D=3D VIR_DOMAIN_FS_DRIVER_TYPE_NBD) { - if (virLXCControllerSetupNBDDeviceFS(fs) < 0) - goto cleanup; - - /* The NBD device will be cleaned up while the cgroup will end. - * For this we need to remember the qemu-nbd pid and add it to - * the cgroup*/ - if (virLXCControllerAppendNBDPids(ctrl, fs->src->path) < 0) + if (virLXCControllerSetupNBDDeviceFS(ctrl, fs) < 0) goto cleanup; } else { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed Apr 24 08:09:25 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; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1528629323922681.6569541640528; Sun, 10 Jun 2018 04:15:23 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id A297E356D2; Sun, 10 Jun 2018 11:15:21 +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 42EEF811BF; Sun, 10 Jun 2018 11:15:21 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id B8AED180BA80; Sun, 10 Jun 2018 11:15:20 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w5ABErco008030 for ; Sun, 10 Jun 2018 07:14:53 -0400 Received: by smtp.corp.redhat.com (Postfix) id 82FB82010D99; Sun, 10 Jun 2018 11:14:53 +0000 (UTC) Received: from mx1.redhat.com (ext-mx02.extmail.prod.ext.phx2.redhat.com [10.5.110.26]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 783192010D98 for ; Sun, 10 Jun 2018 11:14:50 +0000 (UTC) Received: from mail-wr0-f177.google.com (mail-wr0-f177.google.com [209.85.128.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A0A90883C1 for ; Sun, 10 Jun 2018 11:14:39 +0000 (UTC) Received: by mail-wr0-f177.google.com with SMTP id o12-v6so17444606wrm.12 for ; Sun, 10 Jun 2018 04:14:39 -0700 (PDT) Received: from rst.Home ([2a02:c7d:692a:c500:1ebc:73f3:5f60:b131]) by smtp.gmail.com with ESMTPSA id f2-v6sm6869448wre.16.2018.06.10.04.14.36 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 10 Jun 2018 04:14:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=uUlqCHBTAtkpVGcmLNoJqASeHhLi4eal/zkGZ+RUVks=; b=VWwtl9ac1DLTV2g8U9FBzEFoTTwH3D/mQzVTDA1jOKi5RwBPczeph1M7OqLNNEFxCZ iqnz5L+WmiPP4jh3F5vw4ejpoVRc8dpbr2qXzwa3oXSt5dS0Si8U1QJl2mM1fp2q5dve yR3H2mOETQybE6J9TAbYAeaW8OwK9HHqN4QvSvDbJTeRXX4cFaHPbCbBY1TMyF6EOP3e MqN5twS+uGJRmJMNuO2JCJwnLMuZaqY0mz/21+i6Ddtu/ZiE1y/mh1O9K9UoXbySfXVA p6gbkCIC2mwjX0ptpqywKaXDjUzoyRbjYo/P9h7Wh2jeTi6EVioj1SjIPg+REfrcG9DL s9GQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=uUlqCHBTAtkpVGcmLNoJqASeHhLi4eal/zkGZ+RUVks=; b=FsXzr4uevSgXOmAGnASgVRCpjW4rjHq0TkpRHTlquYBWNx1bZMllUPHZOXCKko9mvv 56xvGVXP2tlqDY/jyJ1+w739jmadbU2JDL2qL6Kgqzsm7M0iUfn9MnNjyUvrHuq70ziF d6XMMrEzeEx2XUbdy1Cr9wanurNCNPHdK55uV48Bd2pzUeiJz/59Kj4EzG1tVdww1UA2 jrjDdmc7UN2sEFdLgTQ+8gj35oQeLcmG6lHPd7PgN9lldQmfH1Xj+R03BHoDBXVQ+S6R XEfYl3U+kgIOf5OUVFtK08kV3kK0NcwA8ZwSAZSaYbg1mFGKOId4bOynMyGn1Cp3s7tZ hRnw== X-Gm-Message-State: APt69E3XTw0SDUKjtd67sZUn3ZPe213lOCXzPFVdwW1mRfhUeEGsBKxA CHSSsgrLfPZnfFnGmLetdgQoFC3p X-Google-Smtp-Source: ADUXVKLcJp7CS6lEXM+pgciLhbNvu5YrxUv4/9JDcwNWVoXpFcMRs+yhqE8fOVX41OXAgDnySpCZFw== X-Received: by 2002:adf:e285:: with SMTP id v5-v6mr9257167wri.54.1528629278103; Sun, 10 Jun 2018 04:14:38 -0700 (PDT) From: Radostin Stoyanov To: libvir-list@redhat.com Date: Sun, 10 Jun 2018 12:14:26 +0100 Message-Id: <20180610111426.5211-5-rstoyanov1@gmail.com> In-Reply-To: <20180610111426.5211-1-rstoyanov1@gmail.com> References: <20180610111426.5211-1-rstoyanov1@gmail.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Sun, 10 Jun 2018 11:14:39 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Sun, 10 Jun 2018 11:14:39 +0000 (UTC) for IP:'209.85.128.177' DOMAIN:'mail-wr0-f177.google.com' HELO:'mail-wr0-f177.google.com' FROM:'rstoyanov1@gmail.com' RCPT:'' X-RedHat-Spam-Score: 1.55 * (DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, NML_ADSP_CUSTOM_MED, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_PASS, T_DKIM_INVALID) 209.85.128.177 mail-wr0-f177.google.com 209.85.128.177 mail-wr0-f177.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.26 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.25 X-loop: libvir-list@redhat.com Cc: Radostin Stoyanov Subject: [libvirt] [RFC v2 4/4] lxc: Remove unused lxcContainerPrepareRoot 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Sun, 10 Jun 2018 11:15:22 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" lxcContainerPrepareRoot was introduced with commit 8dbe858 Ensure root filesystem is mounted if a file/block mount. For a root filesystem with type=3Dfile or type=3Dblock, the LXC container was forgetting to actually mount it, before doing the pivot root step. However, this method is no-longer needed because in the cases when the container root file system is of type 'file' or 'block', it will be mounted= by virLXCControllerSetupNBDDeviceFS. Therefore the function lxcContainerPrepareRoot will always be called with: root->type =3D VIR_DOMAIN_FS_TYPE_MOUNT Which makes the following condition tautology: if (root->type =3D=3D VIR_DOMAIN_FS_TYPE_MOUNT) return 0; Signed-off-by: Radostin Stoyanov --- src/lxc/lxc_container.c | 53 ----------------------------------------- 1 file changed, 53 deletions(-) diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c index 3f6be9f44d..3360c608ff 100644 --- a/src/lxc/lxc_container.c +++ b/src/lxc/lxc_container.c @@ -658,55 +658,6 @@ static int lxcContainerResolveSymlinks(virDomainFSDefP= tr fs, bool gentle) return 0; } =20 -static int lxcContainerPrepareRoot(virDomainDefPtr def, - virDomainFSDefPtr root, - const char *sec_mount_options) -{ - char *dst; - char *tmp; - - VIR_DEBUG("Prepare root %d", root->type); - - if (root->type =3D=3D VIR_DOMAIN_FS_TYPE_MOUNT) - return 0; - - if (root->type =3D=3D VIR_DOMAIN_FS_TYPE_FILE) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Unexpected root filesystem without loop device")= ); - return -1; - } - - if (root->type !=3D VIR_DOMAIN_FS_TYPE_BLOCK) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Unsupported root filesystem type %s"), - virDomainFSTypeToString(root->type)); - return -1; - } - - if (lxcContainerResolveSymlinks(root, false) < 0) - return -1; - - if (virAsprintf(&dst, "%s/%s.root", - LXC_STATE_DIR, def->name) < 0) - return -1; - - tmp =3D root->dst; - root->dst =3D dst; - - if (lxcContainerMountFSBlock(root, "", sec_mount_options) < 0) { - root->dst =3D tmp; - VIR_FREE(dst); - return -1; - } - - root->dst =3D tmp; - root->type =3D VIR_DOMAIN_FS_TYPE_MOUNT; - VIR_FREE(root->src->path); - root->src->path =3D dst; - - return 0; -} - static int lxcContainerPivotRoot(virDomainFSDefPtr root) { int ret; @@ -1755,10 +1706,6 @@ static int lxcContainerSetupPivotRoot(virDomainDefPt= r vmDef, if (virFileResolveAllLinks(LXC_STATE_DIR, &stateDir) < 0) goto cleanup; =20 - /* Ensure the root filesystem is mounted */ - if (lxcContainerPrepareRoot(vmDef, root, sec_mount_options) < 0) - goto cleanup; - /* Gives us a private root, leaving all parent OS mounts on /.oldroot = */ if (lxcContainerPivotRoot(root) < 0) goto cleanup; --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list