[systemd-devel] [PATCH] Added support for EnvironmentDir

2012-12-10 Thread Pekka Lundstrom
Signed-off-by: Pekka Lundstrom pekka.lundst...@jollamobile.com
---
 man/systemd.exec.xml  |   27 
 src/core/dbus-execute.c   |   33 ++
 src/core/dbus-execute.h   |1 +
 src/core/execute.c|  116 -
 src/core/execute.h|4 +-
 src/core/load-fragment-gperf.gperf.m4 |1 +
 src/core/load-fragment.c  |   15 +
 src/core/load-fragment.h  |1 +
 src/systemctl/systemctl.c |   18 +
 9 files changed, 212 insertions(+), 4 deletions(-)

diff --git a/man/systemd.exec.xml b/man/systemd.exec.xml
index 6ca7405..0d0131b 100644
--- a/man/systemd.exec.xml
+++ b/man/systemd.exec.xml
@@ -307,6 +307,33 @@
 later setting will override the
 earlier setting. /para/listitem
 /varlistentry
+varlistentry
+termvarnameEnvironmentDir=/varname/term
+listitemparaSimilar to
+varnameEnvironmentFile=/varname but
+reads the environment variables from a
+directory containing files. Each file in
+that directory named with .conf suffix
+is read and prosessed and these files
+should follow same syntax as files
+listed with 
varnameEnvironmentFile=/varname.
+The argument passed should be an absolute
+path to the directory, optionally prefixed with
+-, which indicates that if the directory
+does not exist it won't be read and no
+error or warning message is
+logged. Same goes for files in that directory.
+The directories listed with this
+directive will be read shortly before
+the process is executed. Settings from
+these files override settings made
+with varnameEnvironmentFile=/varname.
+If the same variable is set twice from
+these directories the directories will be read 
in
+the order they are specified and the
+later setting will override the
+earlier setting. /para/listitem
+/varlistentry
 
 varlistentry
 termvarnameStandardInput=/varname/term
diff --git a/src/core/dbus-execute.c b/src/core/dbus-execute.c
index e815cb5..9e5167e 100644
--- a/src/core/dbus-execute.c
+++ b/src/core/dbus-execute.c
@@ -65,6 +65,38 @@ int bus_execute_append_env_files(DBusMessageIter *i, const 
char *property, void
 return 0;
 }
 
+int bus_execute_append_env_dirs(DBusMessageIter *i, const char *property, void 
*data) {
+char **env_dirs = data, **j;
+DBusMessageIter sub, sub2;
+
+assert(i);
+assert(property);
+
+if (!dbus_message_iter_open_container(i, DBUS_TYPE_ARRAY, (sb), 
sub))
+return -ENOMEM;
+
+STRV_FOREACH(j, env_dirs) {
+dbus_bool_t b = false;
+char *dname = *j;
+
+if (dname[0] == '-') {
+b = true;
+dname++;
+}
+
+if (!dbus_message_iter_open_container(sub, DBUS_TYPE_STRUCT, 
NULL, sub2) ||
+!dbus_message_iter_append_basic(sub2, DBUS_TYPE_STRING, 
dname) ||
+!dbus_message_iter_append_basic(sub2, DBUS_TYPE_BOOLEAN, 
b) ||
+!dbus_message_iter_close_container(sub, sub2))
+return -ENOMEM;
+}
+
+if (!dbus_message_iter_close_container(i, sub))
+return -ENOMEM;
+
+return 0;
+}
+
 int bus_execute_append_oom_score_adjust(DBusMessageIter *i, const char 
*property, void *data) {
 ExecContext *c = data;
 int32_t n;
@@ -376,6 +408,7 @@ int bus_execute_append_syscall_filter(DBusMessageIter *i, 
const char *property,
 const BusProperty bus_exec_context_properties[] = {
 { Environment,  bus_property_append_strv, 
as, offsetof(ExecContext, environment),true },
 { EnvironmentFiles, bus_execute_append_env_files,  
a(sb), offsetof(ExecContext, environment_files),  true },
+{ EnvironmentDirs,  bus_execute_append_env_dirs,   
a(sb), offsetof(ExecContext, environment_dirs),   true },
 { UMask,   

Re: [systemd-devel] [PATCH] Added support for EnvironmentDir

2012-12-10 Thread Jóhann B. Guðmundsson

snip
...
/snip

What's the usecase for environment directory?

JBG
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH] Added support for EnvironmentDir

2012-12-10 Thread Pekka Lundström

On 12/10/2012 04:17 PM, Jóhann B. Guðmundsson wrote:
 snip
 ...
 /snip
 What's the usecase for environment directory?


Especially for user session we need to have common set of environment 
variables and these
variables are coming from multiple packages. It doesn't work with 
environment files
because file names are not known to lower level component that is 
providing startup file
for user session. Now with environmet directory we only need to agree 
that each package
that needs to distribute environment variables installs xyz.conf file to 
common dir.


___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH] Added support for EnvironmentDir

2012-12-10 Thread Colin Guthrie
'Twas brillig, and Pekka Lundstrom at 10/12/12 13:56 did gyre and gimble:
 +
 termvarnameEnvironmentDir=/varname/term
 +listitemparaSimilar to
 +varnameEnvironmentFile=/varname but
 +reads the environment variables from a
 +directory containing files. Each file in
 +that directory named with .conf suffix
 +is read and prosessed and these files
 +should follow same syntax as files
 +listed with 
 varnameEnvironmentFile=/varname.


While not commenting on the need/usefulness etc. of the patch, would it
be possible to make the EnvironmentFile directive simply support globbing?

e.g. Rather than doing:

EnvironmentDir=/etc/foo.d

I could just have:

EnvironmentFile=/etc/foo.d/*.conf


That would, to me at least, seem slightly cleaner than adding a new
directive to parse (although this is just my opinion at first glance -
others may disagree!).

Col

-- 

Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
  Tribalogic Limited http://www.tribalogic.net/
Open Source:
  Mageia Contributor http://www.mageia.org/
  PulseAudio Hacker http://www.pulseaudio.org/
  Trac Hacker http://trac.edgewall.org/

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] Offerta

2012-12-10 Thread geppo
TIPOGRAFIA e STAMPA DIGITALE
www.tipiprint.com
i...@stamparebene.com
Tel.02 45 557 067

Gentile Cliente,
Crediamo sia cosa gradita farvi pervenire questa nostra offerta relativa ai
nostri stampati. E' una occasione da non perdere anche perche' potrete
sfruttare questa OFFERTA fino a tutto il 2012 a sola condizione che
rispondiate allegando questa email alla vostra risposta; verrete contattati
entro 4 ore dal ricevumento; oppure telefona al N. 02 45 557 067. 
Alcuni esempi:

100 Biglietti da visita a colori f.to 85x55 mm solo fronte 4+0 Euro15,00

500 Biglietti da visita a colori f.to 85x55 mm solo fronte 4+0 Euro29,00

1000 Biglietti da visita a colori f.to 85x55 mm solo fronte 4+0 Euro35,00

1000 Biglietti da visita a colori f.to 85x55 mm fronte e retro 4+4 Euro60,00

100 Volantini stampati su carta patinata 15x21 cm (A5) stampa a colori
Euro29,00

200 Volantini stampati su carta patinata 15x21 cm (A5) stampa a colori
Euro54,00

300 Volantini stampati su carta patinata 15x21 cm (A5) stampa a colori
Euro69,00

500 Volantini stampati su carta patinata 15x21 cm (A5) stampa a colori
Euro88,00

1000 Volantini stampati su carta patinata 15x21 cm (A5) stampa a colori
Euro99,00

5000 Volantini stampati su carta patinata 15x21 cm (A5) stampa a colori
Euro150,00

1 Volantini stampati su carta patinata 15x21 cm (A5) stampa a colori
Euro250,00

15000 Volantini stampati su carta patinata 15x21 cm (A5) stampa a colori
Euro320,00

250 Pieghevoli a 2 o 3 ante f.to A4 stampa a colori su patinata Euro99,00

1000 Pieghevoli a 2 o 3 ante f.to A4 stampa a colori su patinata Euro189,00

2500 Pieghevoli a 2 o 3 ante f.to A4 stampa a colori su patinata Euro265,00

5000 Pieghevoli a 2 o 3 ante f.to A4 stampa a colori su patinata Euro312,00

1 Pieghevoli a 2 o 3 ante f.to A4 stampa a colori su patinata Euro490,00

50 Opuscoli 8 pagine A5 chiuso stampa a colori cucitura punto metallico
Euro120,00

100 Opuscoli 8 pagine A5 chiuso stampa a colori cucitura punto metallico
Euro170,00

50 Opuscoli 8 pagine A4 chiuso stampa a colori cucitura punto metallico
Euro140,00

100 Opuscoli 8 pagine A4 chiuso stampa a colori cucitura punto metallico
Euro200,00

50 Locandine f.to A3-A3+ stampa colori 4+0 su carta patinata da 150gr.
Euro39,00

100 Locandine f.to A3-A3+ stampa colori 4+0 su carta patinata da 150gr.
Euro60,00

1 Spesa di corriere espresso in 24 ore su tutto il territorio nazionale
Euro12,00


Tutti i prezzi in questa mail sono riferiti alla sola stampa da vostri file
di stampa in alta risoluzione nei formati Jpg, pdf o eps , inoltre i prezzi
si intendono al netto di IVA.
Visitate il nostro sito dove troverete tutte le quotazioni e le offerte del
periodo.

clicca qui: www.www.tipiprint.com

---
This e-mail was sent to systemd-devel@lists.freedesktop.org because you are
subscribed to at least one of our mailing lists. If at any time you would
like to remove yourself from our mailing list, please feel free to do so by
visiting:
http://www.tipiprint.com/list/public/unsubscribe.php?g=198addr=systemd-devel@lists.freedesktop.org

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] udev device mapper rules for early boot?

2012-12-10 Thread Nikolaus Rath
Hello,

I have created a udev rule to set the owner of a specific block device:

SUBSYSTEM==block,
ENV{DM_UUID}==LVM-yYuoI8k05GWxZnz9BeEIwPUGGeojzF3dZZmXTYRqC051Tllj76OHdDlzYhKZUu7u,
OWNER=1000

If I disable and re-enable this logical volume with lvchange, it gets
created with the correct owner.

However, when I boot the computer, the device is always owned by
root:disk instead.

I checked my initrd, and the rule is present in lib/udev/rules.d as
99-udev-custom.rules.

Does anyone have a suggestion of how I could debug this further? Why is
my rule ignored when the volume comes up the first time?

Best,
Nikolaus


___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [RFC] iscsid: add --initrd option to set run from initrd hint for systemd

2012-12-10 Thread Chris Leech
See http://www.freedesktop.org/wiki/Software/systemd/RootStorageDaemons
---
 usr/iscsid.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/usr/iscsid.c b/usr/iscsid.c
index b4bb65b..7d71085 100644
--- a/usr/iscsid.c
+++ b/usr/iscsid.c
@@ -61,6 +61,7 @@ static pid_t log_pid;
 static gid_t gid;
 static int daemonize = 1;
 static int mgmt_ipc_fd;
+static int initrd = 0;
 
 static struct option const long_options[] = {
{config, required_argument, NULL, 'c'},
@@ -73,6 +74,7 @@ static struct option const long_options[] = {
{pid, required_argument, NULL, 'p'},
{help, no_argument, NULL, 'h'},
{version, no_argument, NULL, 'v'},
+   {initrd, no_argument, initrd, 1},
{NULL, 0, NULL, 0},
 };
 
@@ -95,6 +97,7 @@ Open-iSCSI initiator daemon.\n\
   -p, --pid=pidfile   use pid file (default  PID_FILE ).\n\
   -h, --help  display this help and exit\n\
   -v, --version   display version and exit\n\
+  --initrdrun from initrd\n\
 );
}
exit(status);
@@ -383,12 +386,17 @@ int main(int argc, char *argv[])
case 'h':
usage(0);
break;
+   case 0:
+   break;
default:
usage(1);
break;
}
}
 
+   if (initrd)
+   argv[0][0] = '@';
+
/* initialize logger */
log_pid = log_init(program_name, DEFAULT_AREA_SIZE,
  daemonize ? log_do_log_daemon : log_do_log_std, NULL);
-- 
1.7.11.7

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [RFC] iscsiadm, iscsid: newroot command to survive switch_root

2012-12-10 Thread Chris Leech
When started from initramfs, iscsid needs to be able to chroot itself
to the runtime filesystem before the switch_root occurs.  In the
initramfs iscsiadm --newroot {root fs mount before switch} should be
called before the switch_root.
---
 usr/iscsiadm.c | 30 +-
 usr/mgmt_ipc.c | 11 +++
 usr/mgmt_ipc.h |  6 +-
 3 files changed, 45 insertions(+), 2 deletions(-)

diff --git a/usr/iscsiadm.c b/usr/iscsiadm.c
index 8f9de05..7b601b3 100644
--- a/usr/iscsiadm.c
+++ b/usr/iscsiadm.c
@@ -111,9 +111,10 @@ static struct option const long_options[] =
{packetsize, required_argument, NULL, 'b'},
{count, required_argument, NULL, 'c'},
{interval, required_argument, NULL, 'i'},
+   {newroot, required_argument, NULL, 'N'},
{NULL, 0, NULL, 0},
 };
-static char *short_options = 
RlDVhm:a:b:c:C:p:P:T:H:i:I:U:k:L:d:r:n:v:o:sSt:u;
+static char *short_options = 
RlDVhm:a:b:c:C:p:P:T:H:i:I:U:k:L:d:r:n:v:o:sSt:uN:;
 
 static void usage(int status)
 {
@@ -251,6 +252,22 @@ static void kill_iscsid(int priority)
}
 }
 
+static void do_newroot(char *newroot)
+{
+   iscsiadm_req_t req;
+   iscsiadm_rsp_t rsp;
+   int rc;
+
+   memset(req, 0, sizeof(req));
+   req.command = MGMT_IPC_NEWROOT;
+   strncpy(req.u.newroot.path, newroot, PATH_MAX);
+   rc = iscsid_exec_req(req, rsp, 0);
+   if (rc) {
+   iscsi_err_print_msg(rc);
+   log_error(Could not send NEWROOT command);
+   }
+}
+
 /*
  * TODO: we can display how the ifaces are related to node records.
  * And we can add a scsi_host mode which would display how
@@ -2411,6 +2428,7 @@ main(int argc, char **argv)
uint32_t host_no = -1;
struct user_param *param;
struct list_head params;
+   char *newroot = NULL;
 
INIT_LIST_HEAD(params);
INIT_LIST_HEAD(ifaces);
@@ -2433,6 +2451,9 @@ main(int argc, char **argv)
while ((ch = getopt_long(argc, argv, short_options,
 long_options, longindex)) = 0) {
switch (ch) {
+   case 'N':
+   newroot = strndup(optarg, PATH_MAX);
+   break;
case 'k':
killiscsid = atoi(optarg);
if (killiscsid  0) {
@@ -2579,6 +2600,13 @@ main(int argc, char **argv)
goto free_ifaces;
}
 
+   if (newroot) {
+   do_newroot(newroot);
+   free(newroot);
+   newroot = NULL;
+   goto free_ifaces;
+   }
+
if (mode  0)
usage(ISCSI_ERR_INVAL);
 
diff --git a/usr/mgmt_ipc.c b/usr/mgmt_ipc.c
index f34f688..b4170ce 100644
--- a/usr/mgmt_ipc.c
+++ b/usr/mgmt_ipc.c
@@ -226,6 +226,16 @@ mgmt_ipc_immediate_stop(queue_task_t *qtask)
 }
 
 static int
+mgmt_ipc_newroot(queue_task_t *qtask)
+{
+   char *newroot = qtask-req.u.newroot.path;
+   if (chdir(newroot) || chroot(.) || chdir(/))
+   return ISCSI_ERR;
+   mgmt_ipc_write_rsp(qtask, ISCSI_SUCCESS);
+   return ISCSI_SUCCESS;
+}
+
+static int
 mgmt_ipc_conn_remove(queue_task_t *qtask)
 {
return ISCSI_ERR;
@@ -534,6 +544,7 @@ static mgmt_ipc_fn_t *  
mgmt_ipc_functions[__MGMT_IPC_MAX_COMMAND] = {
 [MGMT_IPC_NOTIFY_DEL_NODE] = mgmt_ipc_notify_del_node,
 [MGMT_IPC_NOTIFY_ADD_PORTAL]   = mgmt_ipc_notify_add_portal,
 [MGMT_IPC_NOTIFY_DEL_PORTAL]   = mgmt_ipc_notify_del_portal,
+[MGMT_IPC_NEWROOT] = mgmt_ipc_newroot,
 };
 
 void mgmt_ipc_handle(int accept_fd)
diff --git a/usr/mgmt_ipc.h b/usr/mgmt_ipc.h
index 55972ed..102 100644
--- a/usr/mgmt_ipc.h
+++ b/usr/mgmt_ipc.h
@@ -22,6 +22,7 @@
 #include types.h
 #include iscsi_if.h
 #include config.h
+#include limits.h
 
 #define ISCSIADM_NAMESPACE ISCSIADM_ABSTRACT_NAMESPACE
 #define PEERUSER_MAX   64
@@ -46,6 +47,7 @@ typedef enum iscsiadm_cmd {
MGMT_IPC_NOTIFY_DEL_NODE= 17,
MGMT_IPC_NOTIFY_ADD_PORTAL  = 18,
MGMT_IPC_NOTIFY_DEL_PORTAL  = 19,
+   MGMT_IPC_NEWROOT= 20,
 
__MGMT_IPC_MAX_COMMAND
 } iscsiadm_cmd_e;
@@ -75,8 +77,10 @@ typedef struct iscsiadm_req {
int param;
/* TODO: make this variable len to support */
char value[IFNAMSIZ + 1];
-
} set_host_param;
+   struct ipc_msg_newroot {
+   char path[PATH_MAX + 1];
+   } newroot;
} u;
 } iscsiadm_req_t;
 
-- 
1.7.11.7

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [RFC] iscsi unit files and helper script

2012-12-10 Thread Chris Leech
iSCSI service and socket files, and the iscsi_mark_root_nodes helper script to
preserve sessions started in the initramfs.

diff -Naur a/iscsid.service b/iscsid.service
--- a/iscsid.service1969-12-31 16:00:00.0 -0800
+++ b/iscsid.service2012-12-10 13:38:38.643307001 -0800
@@ -0,0 +1,9 @@
+[Unit]
+Description=Open-iSCSI
+Documentation=man:iscsid(8) man:iscsiadm(8)
+After=network.target NetworkManager-wait-online.service iscsiuio.service 
tgtd.service targetcli.service
+
+[Service]
+Type=simple
+ExecStart=/usr/sbin/iscsid -f -n
+ExecStop=/sbin/iscsiadm -k 0 2
diff -Naur a/iscsid.socket b/iscsid.socket
--- a/iscsid.socket 1969-12-31 16:00:00.0 -0800
+++ b/iscsid.socket 2012-12-10 13:38:38.643307001 -0800
@@ -0,0 +1,9 @@
+[Unit]
+Description=Open-iSCSI iscsid Socket
+Documentation=man:iscsid(8) man:iscsiadm(8)
+
+[Socket]
+ListenStream=@ISCSIADM_ABSTRACT_NAMESPACE
+
+[Install]
+WantedBy=sockets.target
diff -Naur a/iscsi.service b/iscsi.service
--- a/iscsi.service 1969-12-31 16:00:00.0 -0800
+++ b/iscsi.service 2012-12-10 13:38:38.643307001 -0800
@@ -0,0 +1,18 @@
+[Unit]
+Description=Login and scanning of iSCSI devices
+Documentation=man:iscsiadm(8) man:iscsid(8)
+#Requires=iscsid.service
+#BindTo=iscsid.service
+After=network.target NetworkManager-wait-online.service iscsid.service
+ConditionPathExists=/etc/iscsi/initiatorname.iscsi
+
+[Service]
+Type=oneshot
+ExecStart=/usr/libexec/iscsi_mark_root_nodes
+ExecStart=/sbin/iscsiadm -m node --loginall=automatic
+ExecStop=/bin/sync
+ExecStop=/sbin/iscsiadm -m node --logoutall=automatic
+RemainAfterExit=true
+
+[Install]
+WantedBy=remote-fs.target
diff -Naur a/iscsiuio.service b/iscsiuio.service
--- a/iscsiuio.service  1969-12-31 16:00:00.0 -0800
+++ b/iscsiuio.service  2012-12-10 13:38:38.643307001 -0800
@@ -0,0 +1,11 @@
+[Unit]
+Description=iSCSI UserSpace I/O driver
+Documentation=man:iscsiuio(8)
+Requires=iscsid.service
+BindTo=iscsid.service
+Before=iscsid.service
+After=network.target NetworkManager-wait-online.service
+
+[Service]
+Type=simple
+ExecStart=/usr/sbin/iscsiuio -f
diff -Naur a/iscsiuio.socket b/iscsiuio.socket
--- a/iscsiuio.socket   1969-12-31 16:00:00.0 -0800
+++ b/iscsiuio.socket   2012-12-10 13:38:38.643307001 -0800
@@ -0,0 +1,9 @@
+[Unit]
+Description=Open-iSCSI iscsiuio
+Documentation=man:iscsiuio(8)
+
+[Socket]
+ListenStream=@ISCSID_UIP_ABSTRACT_NAMESPACE
+
+[Install]
+WantedBy=sockets.target
diff -Naur a/usr/libexec/iscsi_mark_root_nodes 
b/usr/libexec/iscsi_mark_root_nodes
--- a/usr/libexec/iscsi_mark_root_nodes 1969-12-31 16:00:00.0 -0800
+++ b/usr/libexec/iscsi_mark_root_nodes 2012-12-10 13:38:47.322082141 -0800
@@ -0,0 +1,14 @@
+#!/bin/bash
+
+ISCSIADM=/sbin/iscsiadm
+SESSION_FILE=/run/initramfs/iscsi.sessions
+
+if [ ! -f $SESSION_FILE ] ; then
+  exit 0
+fi
+
+while read t num i target; do
+  ip=${i%:*}
+  $ISCSIADM -m node -p $ip -T $target -o update -n node.startup -v onboot
+done  $SESSION_FILE
+
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [RFC] dracut iscsi module: early attempt to launch iscsid from the initramfs

2012-12-10 Thread Chris Leech
Not complete, but working well for iBFT configured iSCSI boot for me.
---
 modules.d/95iscsi/cleanup-iscsi.sh|  3 ++-
 modules.d/95iscsi/iscsid-initrd.service   | 10 ++
 modules.d/95iscsi/iscsid-initrd.socket|  9 +
 modules.d/95iscsi/iscsiroot.sh| 26 ++
 modules.d/95iscsi/iscsiuio-initrd.service | 11 +++
 modules.d/95iscsi/iscsiuio-initrd.socket  |  9 +
 modules.d/95iscsi/module-setup.sh | 14 --
 7 files changed, 67 insertions(+), 15 deletions(-)
 create mode 100644 modules.d/95iscsi/iscsid-initrd.service
 create mode 100644 modules.d/95iscsi/iscsid-initrd.socket
 create mode 100644 modules.d/95iscsi/iscsiuio-initrd.service
 create mode 100644 modules.d/95iscsi/iscsiuio-initrd.socket

diff --git a/modules.d/95iscsi/cleanup-iscsi.sh 
b/modules.d/95iscsi/cleanup-iscsi.sh
index a2d5951..0dc0ceb 100755
--- a/modules.d/95iscsi/cleanup-iscsi.sh
+++ b/modules.d/95iscsi/cleanup-iscsi.sh
@@ -2,5 +2,6 @@
 # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
 # ex: ts=8 sw=4 sts=4 et filetype=sh
 
-[ -e /sys/module/bnx2i ]  killproc iscsiuio
+NEWROOT=/sysroot
+iscsiadm --newroot $NEWROOT
 
diff --git a/modules.d/95iscsi/iscsid-initrd.service 
b/modules.d/95iscsi/iscsid-initrd.service
new file mode 100644
index 000..16dc4c4
--- /dev/null
+++ b/modules.d/95iscsi/iscsid-initrd.service
@@ -0,0 +1,10 @@
+[Unit]
+Description=Open-iSCSI
+Documentation=man:iscsid(8) man:iscsiadm(8)
+After=network.target NetworkManager-wait-online.service
+
+[Service]
+Type=forking
+ExecStart=/usr/sbin/iscsid --initrd
+PIDFile=/var/run/iscsid.pid
+KillMode=none
diff --git a/modules.d/95iscsi/iscsid-initrd.socket 
b/modules.d/95iscsi/iscsid-initrd.socket
new file mode 100644
index 000..58a8d12
--- /dev/null
+++ b/modules.d/95iscsi/iscsid-initrd.socket
@@ -0,0 +1,9 @@
+[Unit]
+Description=Open-iSCSI iscsid Socket
+Documentation=man:iscsid(8) man:iscsiadm(8)
+
+[Socket]
+ListenStream=@ISCSIADM_ABSTRACT_NAMESPACE
+
+[Install]
+WantedBy=sockets.target
diff --git a/modules.d/95iscsi/iscsiroot.sh b/modules.d/95iscsi/iscsiroot.sh
index 1a8cc8d..c2766a1 100755
--- a/modules.d/95iscsi/iscsiroot.sh
+++ b/modules.d/95iscsi/iscsiroot.sh
@@ -49,7 +49,9 @@ if getargbool 0 rd.iscsi.firmware -d -y iscsi_firmware ; then
iscsi_param=$iscsi_param --param $p
 done
 
-iscsistart -b $iscsi_param
+# iscsistart -b $iscsi_param
+iscsiadm -m fw -l
+iscsiadm -m session  /run/initramfs/iscsi.sessions
 exit 0
 fi
 
@@ -146,17 +148,17 @@ handle_netroot()
 # force udevsettle to break
  $hookdir/initqueue/work
 
-iscsistart -i $iscsi_initiator -t $iscsi_target_name\
--g $iscsi_target_group -a $iscsi_target_ip  \
--p $iscsi_target_port \
-${iscsi_username+-u $iscsi_username} \
-${iscsi_password+-w $iscsi_password} \
-${iscsi_in_username+-U $iscsi_in_username} \
-${iscsi_in_password+-W $iscsi_in_password} \
-   ${iscsi_iface_name+--param iface.iscsi_ifacename=$iscsi_iface_name} \
-   ${iscsi_netdev_name+--param iface.net_ifacename=$iscsi_netdev_name} \
-${iscsi_param} \
-   || :
+#iscsistart -i $iscsi_initiator -t $iscsi_target_name\
+#-g $iscsi_target_group -a $iscsi_target_ip  \
+#-p $iscsi_target_port \
+#${iscsi_username+-u $iscsi_username} \
+#${iscsi_password+-w $iscsi_password} \
+#${iscsi_in_username+-U $iscsi_in_username} \
+#${iscsi_in_password+-W $iscsi_in_password} \
+#  ${iscsi_iface_name+--param iface.iscsi_ifacename=$iscsi_iface_name} \
+#  ${iscsi_netdev_name+--param iface.net_ifacename=$iscsi_netdev_name} \
+#${iscsi_param} \
+#  || :
 }
 
 # loop over all netroot parameter
diff --git a/modules.d/95iscsi/iscsiuio-initrd.service 
b/modules.d/95iscsi/iscsiuio-initrd.service
new file mode 100644
index 000..54883df
--- /dev/null
+++ b/modules.d/95iscsi/iscsiuio-initrd.service
@@ -0,0 +1,11 @@
+[Unit]
+Description=iSCSI UserSpace I/O driver
+Documentation=man:iscsiuio(8)
+Before=iscsid.service
+After=network.target NetworkManager-wait-online.service
+
+[Service]
+Type=forking
+ExecStart=/usr/sbin/iscsiuio --initrd
+PIDFile=/var/run/iscsiuio.pid
+KillMode=none
diff --git a/modules.d/95iscsi/iscsiuio-initrd.socket 
b/modules.d/95iscsi/iscsiuio-initrd.socket
new file mode 100644
index 000..9eacc56
--- /dev/null
+++ b/modules.d/95iscsi/iscsiuio-initrd.socket
@@ -0,0 +1,9 @@
+[Unit]
+Description=Open-iSCSI iscsiuio
+Documentation=man:iscsiuio(8)
+
+[Socket]
+ListenStream=@ISCSID_UIP_ABSTRACT_NAMESPACE
+
+[Install]
+WantedBy=sockets.target
diff --git a/modules.d/95iscsi/module-setup.sh 
b/modules.d/95iscsi/module-setup.sh
index d251a0d..7acabbe 100755
--- a/modules.d/95iscsi/module-setup.sh
+++ b/modules.d/95iscsi/module-setup.sh
@@ -5,7 +5,7 @@
 check() {
 local _rootdev
 # If our prerequisites are not met, fail anyways.
-  

[systemd-devel] [RFC] iscsid / systemd / dracut integration effort

2012-12-10 Thread Chris Leech
Sorry about the cross-posting, but I think that in order to get this right I'm
going to need as much feedback as I can get.

I think I've got this working pretty well now (at least for my iBFT configured
iSCSI root test case), although the dracut module still needs work.  This is
based on the iscsid socket activation patch from Tomasz Torcz and the unit
files from Tomasz and Jóhann B. Guðmundsson.

Attempting to start iscsid using systemd unit files (socket activated or not)
was impacting my iscsi-root test setup.  Rather than try to preserve the old
logic that used the _netdev mount flag to determine when iscsid could be safely
shutdown, I've been working on following the guidelines for root storage
daemons http://www.freedesktop.org/wiki/Software/systemd/RootStorageDaemons.

1) I patched iscsid to set argv[0][0] = '@' if a new --initrd flag is passed on
   the command line.  It's simple, it works, we don't kill iscsid before the
   root filesystem is unmounted.

2) When starting iscsid from the initrd, I then ran into issues of iscsid not
   functioning properly after the switch_root.  It's not mentioned in the
   RootStorageDaemons documentation, but if a process left running from the
   initrd needs further filesystem access at runtime it will need to be able to
   chroot itself before the switch_root.  I patched iscsid and iscsiadm with a
   newroot command (using plymouth as an example), and used a dracut clenaup
   hook to call iscsiadm --newroot /sysroot.

3) Related to #2, launching iscsid as a Type=simple service from the initrd
   (I'm testing this with Fedora 18 beta, where dracut uses systemd in the
   initrd) results in STDOUT/STDERR access after the switch_root failing with
   EPIPE.  It seems that the connection to the journal process is dead once the
   initrd instantiated systemd-journald is replaced with the runtime process.

   I can at least keep iscsid functioning if I run it as Type=forking, but I'm
   not sure if I'm losing runtime logging or not.  I may be able to do
   something with the StandardOutput and StandardError options in the service
   file.

4) None of this helps if the sessions are shutdown when we still need them.
   Rather than the all-or-nothing _netdev mount option checks that have been
   used in the past, I'm attempting to use the fact that iscsiadm will skip
   over session that match a node with startup=onboot set when doing a
   logoutall.  The iscsi_mark_root_nodes script is borrowed from the SUSE init
   scripts in the open-iscsi repos written by Hannes Reinecke.  I've made minor
   changes to export the list of sessions activated in the initramfs, and then
   mark those as onboot when starting iscsi.service.

Things that still need looking into.

1) Command line configured iSCSI parameters.  If iscsistart is to be fully
   removed something needs to setup the node from the command line.  Or
   iscsistart needs to be able to run alongside iscsid.

2) Proper ordering of the iscsi.service for non-root filesystems.

Any and all feedback and/or help welcome.

- Chris

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [RFC] iscsid / systemd / dracut integration effort

2012-12-10 Thread Jóhann B. Guðmundsson

On 12/10/2012 10:08 PM, Chris Leech wrote:

Sorry about the cross-posting, but I think that in order to get this right I'm
going to need as much feedback as I can get.

I think I've got this working pretty well now (at least for my iBFT configured
iSCSI root test case), although the dracut module still needs work.  This is
based on the iscsid socket activation patch from Tomasz Torcz and the unit
files from Tomasz and Jóhann B. Guðmundsson.

Attempting to start iscsid using systemd unit files (socket activated or not)
was impacting my iscsi-root test setup.  Rather than try to preserve the old
logic that used the _netdev mount flag to determine when iscsid could be safely
shutdown, I've been working on following the guidelines for root storage
daemons http://www.freedesktop.org/wiki/Software/systemd/RootStorageDaemons.

1) I patched iscsid to set argv[0][0] = '@' if a new --initrd flag is passed on
the command line.  It's simple, it works, we don't kill iscsid before the
root filesystem is unmounted.

2) When starting iscsid from the initrd, I then ran into issues of iscsid not
functioning properly after the switch_root.  It's not mentioned in the
RootStorageDaemons documentation, but if a process left running from the
initrd needs further filesystem access at runtime it will need to be able to
chroot itself before the switch_root.  I patched iscsid and iscsiadm with a
newroot command (using plymouth as an example), and used a dracut clenaup
hook to call iscsiadm --newroot /sysroot.

3) Related to #2, launching iscsid as a Type=simple service from the initrd
(I'm testing this with Fedora 18 beta, where dracut uses systemd in the
initrd) results in STDOUT/STDERR access after the switch_root failing with
EPIPE.  It seems that the connection to the journal process is dead once the
initrd instantiated systemd-journald is replaced with the runtime process.

I can at least keep iscsid functioning if I run it as Type=forking, but I'm
not sure if I'm losing runtime logging or not.  I may be able to do
something with the StandardOutput and StandardError options in the service
file.


You should be using Type=forking here



4) None of this helps if the sessions are shutdown when we still need them.
Rather than the all-or-nothing _netdev mount option checks that have been
used in the past, I'm attempting to use the fact that iscsiadm will skip
over session that match a node with startup=onboot set when doing a
logoutall.  The iscsi_mark_root_nodes script is borrowed from the SUSE init
scripts in the open-iscsi repos written by Hannes Reinecke.  I've made minor
changes to export the list of sessions activated in the initramfs, and then
mark those as onboot when starting iscsi.service.

Things that still need looking into.

1) Command line configured iSCSI parameters.  If iscsistart is to be fully
removed something needs to setup the node from the command line.  Or
iscsistart needs to be able to run alongside iscsid.

2) Proper ordering of the iscsi.service for non-root filesystems.

Any and all feedback and/or help welcome.



Looking the unit file for iscsid I do believe I missed this ( basically 
the same as multipath unit ) since you know it's early boot special, 
root and all that ;)


[Unit]

# Before or After lvm2-activation-early.service
DefaultDependencies=no
Conflicts=shutdown.target

[Install]
WantedBy=sysinit.target

JBG
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel