From nobody Mon Apr 29 20:16:26 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.zoho.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 1496319992365961.5242539361873;
Thu, 1 Jun 2017 05:26:32 -0700 (PDT)
Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com
[10.5.11.11])
(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))
(No client certificate requested)
by mx1.redhat.com (Postfix) with ESMTPS id 35F7D15552;
Thu, 1 Jun 2017 12:26:30 +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 F041B83E87;
Thu, 1 Jun 2017 12:26:29 +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 8646E4BB7F;
Thu, 1 Jun 2017 12:26:29 +0000 (UTC)
Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com
[10.5.11.14])
by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP
id v51CQS0v025366 for ;
Thu, 1 Jun 2017 08:26:28 -0400
Received: by smtp.corp.redhat.com (Postfix)
id 10A5D7F6B0; Thu, 1 Jun 2017 12:26:28 +0000 (UTC)
Received: from mx1.redhat.com (ext-mx10.extmail.prod.ext.phx2.redhat.com
[10.5.110.39])
by smtp.corp.redhat.com (Postfix) with ESMTPS id 0B51B7F6AF
for ; Thu, 1 Jun 2017 12:26:26 +0000 (UTC)
Received: from smtp.nue.novell.com (smtp.nue.novell.com [195.135.221.5])
(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
(No client certificate requested)
by mx1.redhat.com (Postfix) with ESMTPS id 038351A6722
for ; Thu, 1 Jun 2017 12:26:24 +0000 (UTC)
Received: from laptop.vms (mhy71-2-88-167-63-197.fbx.proxad.net
[88.167.63.197]) by smtp.nue.novell.com with ESMTP (TLS encrypted);
Thu, 01 Jun 2017 14:26:22 +0200
DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 35F7D15552
Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com;
dmarc=none (p=none dis=none) header.from=suse.com
Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com;
spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com
DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 35F7D15552
DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 038351A6722
Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com;
dmarc=none (p=none dis=none) header.from=suse.com
Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com;
spf=pass smtp.mailfrom=cbosdonnat@suse.com
DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 038351A6722
From: =?UTF-8?q?C=C3=A9dric=20Bosdonnat?=
To: libvir-list@redhat.com
Date: Thu, 1 Jun 2017 14:26:16 +0200
Message-Id: <20170601122617.15145-2-cbosdonnat@suse.com>
In-Reply-To: <20170601122617.15145-1-cbosdonnat@suse.com>
References: <20170601122617.15145-1-cbosdonnat@suse.com>
X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 203
matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com
[10.5.110.39]); Thu, 01 Jun 2017 12:26:24 +0000 (UTC)
X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com
[10.5.110.39]);
Thu, 01 Jun 2017 12:26:24 +0000 (UTC) for IP:'195.135.221.5'
DOMAIN:'smtp.nue.novell.com' HELO:'smtp.nue.novell.com'
FROM:'cbosdonnat@suse.com' RCPT:''
X-RedHat-Spam-Score: 0.699 (BAYES_95, RCVD_IN_DNSWL_MED,
SPF_PASS) 195.135.221.5 smtp.nue.novell.com 195.135.221.5
smtp.nue.novell.com
X-Scanned-By: MIMEDefang 2.78 on 10.5.110.39
X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14
X-loop: libvir-list@redhat.com
Cc: =?UTF-8?q?C=C3=A9dric=20Bosdonnat?=
Subject: [libvirt] [PATCH 1/2] util: share code between virExec and
virCommandExec
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.11
X-Greylist: Sender IP whitelisted,
not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]);
Thu, 01 Jun 2017 12:26:31 +0000 (UTC)
X-ZohoMail: RSF_0 Z_629925259 SPT_0
Content-Type: text/plain; charset="utf-8"
virCommand is a version of virExec that doesn't fork, however it is
just calling execve and doesn't honors setting uid/gid and pwd.
This commit moves those pieces from virExec to virCommandExec and
makes virExec use virCommandExec to avoid code duplication.
---
src/util/vircommand.c | 92 ++++++++++++++++++++++++-----------------------=
----
1 file changed, 43 insertions(+), 49 deletions(-)
diff --git a/src/util/vircommand.c b/src/util/vircommand.c
index e1bbc0526..aa97a5a10 100644
--- a/src/util/vircommand.c
+++ b/src/util/vircommand.c
@@ -481,21 +481,18 @@ virExec(virCommandPtr cmd)
int childerr =3D -1;
int tmpfd;
char *binarystr =3D NULL;
- const char *binary =3D NULL;
int ret;
struct sigaction waxon, waxoff;
- gid_t *groups =3D NULL;
- int ngroups;
=20
if (cmd->args[0][0] !=3D '/') {
- if (!(binary =3D binarystr =3D virFindFileInPath(cmd->args[0]))) {
+ if (!(binarystr =3D virFindFileInPath(cmd->args[0]))) {
virReportSystemError(ENOENT,
_("Cannot find '%s' in path"),
cmd->args[0]);
return -1;
}
- } else {
- binary =3D cmd->args[0];
+ VIR_FREE(cmd->args[0]);
+ cmd->args[0] =3D binarystr;
}
=20
if (childin < 0) {
@@ -556,9 +553,6 @@ virExec(virCommandPtr cmd)
childerr =3D null;
}
=20
- if ((ngroups =3D virGetGroupList(cmd->uid, cmd->gid, &groups)) < 0)
- goto cleanup;
-
pid =3D virFork();
=20
if (pid < 0)
@@ -577,9 +571,6 @@ virExec(virCommandPtr cmd)
=20
cmd->pid =3D pid;
=20
- VIR_FREE(binarystr);
- VIR_FREE(groups);
-
return 0;
}
=20
@@ -727,29 +718,6 @@ virExec(virCommandPtr cmd)
}
# endif
=20
- /* The steps above may need to do something privileged, so we delay
- * setuid and clearing capabilities until the last minute.
- */
- if (cmd->uid !=3D (uid_t)-1 || cmd->gid !=3D (gid_t)-1 ||
- cmd->capabilities || (cmd->flags & VIR_EXEC_CLEAR_CAPS)) {
- VIR_DEBUG("Setting child uid:gid to %d:%d with caps %llx",
- (int)cmd->uid, (int)cmd->gid, cmd->capabilities);
- if (virSetUIDGIDWithCaps(cmd->uid, cmd->gid, groups, ngroups,
- cmd->capabilities,
- !!(cmd->flags & VIR_EXEC_CLEAR_CAPS)) < 0=
) {
- goto fork_error;
- }
- }
-
- if (cmd->pwd) {
- VIR_DEBUG("Running child in %s", cmd->pwd);
- if (chdir(cmd->pwd) < 0) {
- virReportSystemError(errno,
- _("Unable to change to %s"), cmd->pwd);
- goto fork_error;
- }
- }
-
if (virCommandHandshakeChild(cmd) < 0)
goto fork_error;
=20
@@ -771,15 +739,10 @@ virExec(virCommandPtr cmd)
/* Close logging again to ensure no FDs leak to child */
virLogReset();
=20
- if (cmd->env)
- execve(binary, cmd->args, cmd->env);
- else
- execv(binary, cmd->args);
+ if (virCommandExec(cmd) =3D=3D -2)
+ goto fork_error;
=20
ret =3D errno =3D=3D ENOENT ? EXIT_ENOENT : EXIT_CANNOT_INVOKE;
- virReportSystemError(errno,
- _("cannot execute binary %s"),
- cmd->args[0]);
=20
fork_error:
virDispatchError(NULL);
@@ -789,9 +752,6 @@ virExec(virCommandPtr cmd)
/* This is cleanup of parent process only - child
should never jump here on error */
=20
- VIR_FREE(groups);
- VIR_FREE(binarystr);
-
/* NB we don't virReportError() on any failures here
because the code which jumped here already raised
an error condition which we must not overwrite */
@@ -2150,23 +2110,57 @@ virCommandProcessIO(virCommandPtr cmd)
* in the hook after already forking / cloning, so does not attempt to
* daemonize or preserve any FDs.
*
- * Returns -1 on any error executing the command.
+ * Returns -1 on any error executing the command, -2 if the error happen
+ * before running the command.
+ *
* Will not return on success.
*/
#ifndef WIN32
int virCommandExec(virCommandPtr cmd)
{
+ gid_t *groups =3D NULL;
+ int ngroups;
+
if (!cmd ||cmd->has_error =3D=3D ENOMEM) {
virReportOOMError();
- return -1;
+ return -2;
}
if (cmd->has_error) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("invalid use of command API"));
- return -1;
+ return -2;
}
=20
- execve(cmd->args[0], cmd->args, cmd->env);
+ if ((ngroups =3D virGetGroupList(cmd->uid, cmd->gid, &groups)) < 0) {
+ VIR_FREE(groups);
+ return -2;
+ }
+
+ if (cmd->uid !=3D (uid_t)-1 || cmd->gid !=3D (gid_t)-1 ||
+ cmd->capabilities || (cmd->flags & VIR_EXEC_CLEAR_CAPS)) {
+ VIR_DEBUG("Setting child uid:gid to %d:%d with caps %llx",
+ (int)cmd->uid, (int)cmd->gid, cmd->capabilities);
+ if (virSetUIDGIDWithCaps(cmd->uid, cmd->gid, groups, ngroups,
+ cmd->capabilities,
+ !!(cmd->flags & VIR_EXEC_CLEAR_CAPS)) < 0=
) {
+ return -2;
+ }
+ }
+ VIR_FREE(groups);
+
+ if (cmd->pwd) {
+ VIR_DEBUG("Running child in %s", cmd->pwd);
+ if (chdir(cmd->pwd) < 0) {
+ virReportSystemError(errno,
+ _("Unable to change to %s"), cmd->pwd);
+ return -2;
+ }
+ }
+
+ if (cmd->env)
+ execve(cmd->args[0], cmd->args, cmd->env);
+ else
+ execv(cmd->args[0], cmd->args);
=20
virReportSystemError(errno,
_("cannot execute binary %s"),
--=20
2.12.2
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
From nobody Mon Apr 29 20:16:26 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.zoho.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 1496319993697951.930380700533;
Thu, 1 Jun 2017 05:26:33 -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 40DAD40F01;
Thu, 1 Jun 2017 12:26:30 +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 175757E3B0;
Thu, 1 Jun 2017 12:26:30 +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 BD4E61800C89;
Thu, 1 Jun 2017 12:26:29 +0000 (UTC)
Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com
[10.5.11.15])
by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP
id v51CQSP2025365 for ;
Thu, 1 Jun 2017 08:26:28 -0400
Received: by smtp.corp.redhat.com (Postfix)
id 080057FE8B; Thu, 1 Jun 2017 12:26:28 +0000 (UTC)
Received: from mx1.redhat.com (ext-mx06.extmail.prod.ext.phx2.redhat.com
[10.5.110.30])
by smtp.corp.redhat.com (Postfix) with ESMTPS id 01D447FE87
for ; Thu, 1 Jun 2017 12:26:26 +0000 (UTC)
Received: from smtp.nue.novell.com (smtp.nue.novell.com [195.135.221.5])
(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
(No client certificate requested)
by mx1.redhat.com (Postfix) with ESMTPS id 552F83DBE3
for ; Thu, 1 Jun 2017 12:26:24 +0000 (UTC)
Received: from laptop.vms (mhy71-2-88-167-63-197.fbx.proxad.net
[88.167.63.197]) by smtp.nue.novell.com with ESMTP (TLS encrypted);
Thu, 01 Jun 2017 14:26:22 +0200
DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 40DAD40F01
Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com;
dmarc=none (p=none dis=none) header.from=suse.com
Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com;
spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com
DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 40DAD40F01
DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 552F83DBE3
Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com;
dmarc=none (p=none dis=none) header.from=suse.com
Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com;
spf=pass smtp.mailfrom=cbosdonnat@suse.com
DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 552F83DBE3
From: =?UTF-8?q?C=C3=A9dric=20Bosdonnat?=
To: libvir-list@redhat.com
Date: Thu, 1 Jun 2017 14:26:17 +0200
Message-Id: <20170601122617.15145-3-cbosdonnat@suse.com>
In-Reply-To: <20170601122617.15145-1-cbosdonnat@suse.com>
References: <20170601122617.15145-1-cbosdonnat@suse.com>
X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 203
matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com
[10.5.110.30]); Thu, 01 Jun 2017 12:26:25 +0000 (UTC)
X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com
[10.5.110.30]);
Thu, 01 Jun 2017 12:26:25 +0000 (UTC) for IP:'195.135.221.5'
DOMAIN:'smtp.nue.novell.com' HELO:'smtp.nue.novell.com'
FROM:'cbosdonnat@suse.com' RCPT:''
X-RedHat-Spam-Score: -1.501 (BAYES_50, RCVD_IN_DNSWL_MED,
SPF_PASS) 195.135.221.5 smtp.nue.novell.com 195.135.221.5
smtp.nue.novell.com
X-Scanned-By: MIMEDefang 2.78 on 10.5.110.30
X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15
X-loop: libvir-list@redhat.com
Cc: =?UTF-8?q?C=C3=A9dric=20Bosdonnat?=
Subject: [libvirt] [PATCH 2/2] lxc: allow user to specify command working
directory
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.30]);
Thu, 01 Jun 2017 12:26:31 +0000 (UTC)
X-ZohoMail: RSF_0 Z_629925259 SPT_0
Content-Type: text/plain; charset="utf-8"
Some containers may want the application to run in a special directory.
Add element in the domain configuration to handle this case
and use it in the lxc driver.
---
docs/formatdomain.html.in | 5 +++++
docs/schemas/domaincommon.rng | 5 +++++
src/conf/domain_conf.c | 5 +++++
src/conf/domain_conf.h | 1 +
src/lxc/lxc_container.c | 4 +++-
tests/lxcxml2xmldata/lxc-initdir.xml | 30 ++++++++++++++++++++++++++++++
tests/lxcxml2xmltest.c | 1 +
7 files changed, 50 insertions(+), 1 deletion(-)
create mode 100644 tests/lxcxml2xmldata/lxc-initdir.xml
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 8da50875b..7627fd0d0 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -330,6 +330,10 @@
To set environment variables, use the initenv
element, =
one
for each variable.
+
+ To set a custom work directory for the init, use the initdir=
code>
+ element.
+
=20
<os>
@@ -338,6 +342,7 @@
<initarg>--unit</initarg>
<initarg>emergency.service</initarg>
<initenv name=3D'MYENV'>some value</initenv>
+ <initdir>/my/custom/cwd</initdir>
</os>
=20
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 695214816..5a4c4ecf1 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -395,6 +395,11 @@
+
+
+ [
+ ]
+
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 89c803047..bf530fc52 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -2801,6 +2801,7 @@ void virDomainDefFree(virDomainDefPtr def)
VIR_FREE(def->os.initargv);
for (i =3D 0; def->os.initenv && def->os.initenv[i]; i++)
VIR_FREE(def->os.initenv[i]);
+ VIR_FREE(def->os.initdir);
VIR_FREE(def->os.initenv);
VIR_FREE(def->os.kernel);
VIR_FREE(def->os.initrd);
@@ -16796,6 +16797,7 @@ virDomainDefParseBootOptions(virDomainDefPtr def,
if (def->os.type =3D=3D VIR_DOMAIN_OSTYPE_EXE) {
def->os.init =3D virXPathString("string(./os/init[1])", ctxt);
def->os.cmdline =3D virXPathString("string(./os/cmdline[1])", ctxt=
);
+ def->os.initdir =3D virXPathString("string(./os/initdir[1])", ctxt=
);
=20
if ((n =3D virXPathNodeSet("./os/initarg", ctxt, &nodes)) < 0)
goto error;
@@ -24562,6 +24564,9 @@ virDomainDefFormatInternal(virDomainDefPtr def,
for (i =3D 0; def->os.initenv && def->os.initenv[i]; i++)
virBufferAsprintf(buf, "%s\n",
def->os.initenv[i]->name, def->os.initenv[i]->va=
lue);
+ if (def->os.initdir)
+ virBufferEscapeString(buf, "%s\n",
+ def->os.initdir);
if (def->os.loader)
virDomainLoaderDefFormat(buf, def->os.loader);
virBufferEscapeString(buf, "%s\n",
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 03153b972..105f0b7a6 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1841,6 +1841,7 @@ struct _virDomainOSDef {
char *init;
char **initargv;
virDomainOSEnvPtr *initenv;
+ char *initdir;
char *kernel;
char *initrd;
char *cmdline;
diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c
index ffafc39d7..c122a588e 100644
--- a/src/lxc/lxc_container.c
+++ b/src/lxc/lxc_container.c
@@ -237,7 +237,7 @@ static virCommandPtr lxcContainerBuildInitCmd(virDomain=
DefPtr vmDef,
virCommandAddEnvString(cmd, "PATH=3D/bin:/sbin");
virCommandAddEnvString(cmd, "TERM=3Dlinux");
virCommandAddEnvString(cmd, "container=3Dlxc-libvirt");
- virCommandAddEnvString(cmd, "HOME=3D/");
+/* virCommandAddEnvString(cmd, "HOME=3D/"); */
virCommandAddEnvPair(cmd, "container_uuid", uuidstr);
if (nttyPaths > 1)
virCommandAddEnvPair(cmd, "container_ttys", virBufferCurrentConten=
t(&buf));
@@ -245,6 +245,8 @@ static virCommandPtr lxcContainerBuildInitCmd(virDomain=
DefPtr vmDef,
virCommandAddEnvPair(cmd, "LIBVIRT_LXC_NAME", vmDef->name);
if (vmDef->os.cmdline)
virCommandAddEnvPair(cmd, "LIBVIRT_LXC_CMDLINE", vmDef->os.cmdline=
);
+ if (vmDef->os.initdir)
+ virCommandSetWorkingDirectory(cmd, vmDef->os.initdir);
=20
for (i =3D 0; vmDef->os.initenv[i]; i++) {
virCommandAddEnvPair(cmd, vmDef->os.initenv[i]->name,
diff --git a/tests/lxcxml2xmldata/lxc-initdir.xml b/tests/lxcxml2xmldata/lx=
c-initdir.xml
new file mode 100644
index 000000000..2940bda91
--- /dev/null
+++ b/tests/lxcxml2xmldata/lxc-initdir.xml
@@ -0,0 +1,30 @@
+
+ jessie
+ e21987a5-e98e-9c99-0e35-803e4d9ad1fe
+ 1048576
+ 1048576
+ 1
+
+ /machine
+
+
+ exe
+ /sbin/sh
+ /path/to/pwd
+
+
+ destroy
+ restart
+ restart
+
+ /usr/libexec/libvirt_lxc
+
+
+
+
+
+
+
+
diff --git a/tests/lxcxml2xmltest.c b/tests/lxcxml2xmltest.c
index 2a24b60b3..c81b0eace 100644
--- a/tests/lxcxml2xmltest.c
+++ b/tests/lxcxml2xmltest.c
@@ -99,6 +99,7 @@ mymain(void)
DO_TEST_FULL("filesystem-root", 0, false,
VIR_DOMAIN_DEF_PARSE_SKIP_OSTYPE_CHECKS);
DO_TEST("initenv");
+ DO_TEST("initdir");
=20
virObjectUnref(caps);
virObjectUnref(xmlopt);
--=20
2.12.2
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list