From nobody Wed May 14 02:27:45 2025 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