Re: [libvirt] [PATCH v3 24/48] storage: introduce virtstoraged daemon

2019-07-30 Thread Christophe de Dinechin

Daniel P. Berrangé writes:

> The virtstoraged daemon will be responsible for providing the storage API
> driver functionality. The storage driver is still loaded by the main
> libvirtd daemon at this stage, so virtstoraged must not be running at
> the same time.
>
> Reviewed-by: Andrea Bolognani 
> Signed-off-by: Daniel P. Berrangé 
> ---
>  .gitignore  |  4 ++
>  libvirt.spec.in |  8 
>  src/storage/Makefile.inc.am | 61 +
>  src/storage/virtstoraged.service.in | 26 
>  4 files changed, 99 insertions(+)
>  create mode 100644 src/storage/virtstoraged.service.in
>
> diff --git a/.gitignore b/.gitignore
> index c361d87868..3b86183bee 100644
> --- a/.gitignore
> +++ b/.gitignore
> @@ -175,6 +175,9 @@
>  /src/secret/test_virtsecretd.aug
>  /src/secret/virtsecretd.aug
>  /src/secret/virtsecretd.conf
> +/src/storage/test_virtstoraged.aug
> +/src/storage/virtstoraged.aug
> +/src/storage/virtstoraged.conf
>  /src/util/virkeycodetable*.h
>  /src/util/virkeynametable*.h
>  /src/virt-aa-helper
> @@ -184,6 +187,7 @@
>  /src/virtnetworkd
>  /src/virtproxyd
>  /src/virtsecretd
> +/src/virtstoraged
>  /src/virt-guest-shutdown.target
>  /tests/*.log
>  /tests/*.pid
> diff --git a/libvirt.spec.in b/libvirt.spec.in
> index b4fab26ea4..c34445090d 100644
> --- a/libvirt.spec.in
> +++ b/libvirt.spec.in
> @@ -1663,6 +1663,14 @@ exit 0
>  %files daemon-driver-storage
>
>  %files daemon-driver-storage-core
> +%config(noreplace) %{_sysconfdir}/libvirt/virtstoraged.conf
> +%{_datadir}/augeas/lenses/virtstoraged.aug
> +%{_datadir}/augeas/lenses/tests/test_virtstoraged.aug
> +%{_unitdir}/virtstoraged.service
> +%{_unitdir}/virtstoraged.socket
> +%{_unitdir}/virtstoraged-ro.socket
> +%{_unitdir}/virtstoraged-admin.socket
> +%attr(0755, root, root) %{_sbindir}/virtstoraged
>  %attr(0755, root, root) %{_libexecdir}/libvirt_parthelper
>  %{_libdir}/%{name}/connection-driver/libvirt_driver_storage.so
>  %{_libdir}/%{name}/storage-backend/libvirt_storage_backend_fs.so
> diff --git a/src/storage/Makefile.inc.am b/src/storage/Makefile.inc.am
> index 538709256d..767875785a 100644
> --- a/src/storage/Makefile.inc.am
> +++ b/src/storage/Makefile.inc.am
> @@ -142,6 +142,67 @@ mod_LTLIBRARIES += libvirt_driver_storage.la
>  libvirt_driver_storage_la_LDFLAGS = $(AM_LDFLAGS_MOD_NOUNDEF)
>  libvirt_driver_storage_impl_la_SOURCES += $(STORAGE_DRIVER_SOURCES)
>
> +sbin_PROGRAMS += virtstoraged
> +
> +nodist_conf_DATA += storage/virtstoraged.conf
> +augeas_DATA += storage/virtstoraged.aug
> +augeastest_DATA += storage/test_virtstoraged.aug
> +CLEANFILES += storage/virtstoraged.aug
> +
> +virtstoraged_SOURCES = $(REMOTE_DAEMON_SOURCES)
> +virtstoraged_CFLAGS = \
> +   $(REMOTE_DAEMON_CFLAGS) \
> +   -DDAEMON_NAME="\"virtstoraged\"" \
> +   -DMODULE_NAME="\"storage\"" \
> +   $(NULL)
> +virtstoraged_LDFLAGS = $(REMOTE_DAEMON_LD_FLAGS)
> +virtstoraged_LDADD = $(REMOTE_DAEMON_LD_ADD)
> +
> +SYSTEMD_UNIT_FILES += \
> + virtstoraged.service \
> + virtstoraged.socket \
> + virtstoraged-ro.socket \
> + virtstoraged-admin.socket \
> + $(NULL)
> +SYSTEMD_UNIT_FILES_IN += \
> + storage/virtstoraged.service.in \
> + $(NULL)
> +
> +VIRTSTORAGED_UNIT_VARS = \
> + $(VIRTD_UNIT_VARS) \
> + -e 's|[@]name[@]|Libvirt storage|g' \
> + -e 's|[@]service[@]|virtstoraged|g' \
> + -e 's|[@]sockprefix[@]|virtstoraged|g' \
> + $(NULL)
> +
> +virtstoraged.service: storage/virtstoraged.service.in 
> $(top_builddir)/config.status
> + $(AM_V_GEN)sed $(VIRTSTORAGED_UNIT_VARS) < $< > $@-t && mv $@-t $@
> +
> +virtstorage%.socket: remote/libvirt%.socket.in $(top_builddir)/config.status
> + $(AM_V_GEN)sed $(VIRTSTORAGED_UNIT_VARS) < $< > $@-t && mv $@-t $@
> +
> +storage/virtstoraged.conf: remote/libvirtd.conf.in
> + $(AM_V_GEN)sed \
> + -e '/[@]CUT_ENABLE_IP[@]/,/[@]END[@]/d' \
> + -e 's/[@]DAEMON_NAME[@]/virtstoraged/' \
> + < $^ > $@
> +
> +storage/virtstoraged.aug: remote/libvirtd.aug.in
> + $(AM_V_GEN)$(SED) \
> + -e '/[@]CUT_ENABLE_IP[@]/,/[@]END[@]/d' \
> + -e 's/[@]DAEMON_NAME[@]/virtstoraged/' \
> + -e 's/[@]DAEMON_NAME_UC[@]/Virtstoraged/' \
> + $< > $@
> +
> +storage/test_virtstoraged.aug: remote/test_libvirtd.aug.in \
> + storage/virtstoraged.conf $(AUG_GENTEST)
> + $(AM_V_GEN)$(AUG_GENTEST) storage/virtstoraged.conf \
> + $(srcdir)/remote/test_libvirtd.aug.in | \
> + $(SED) -e '/[@]CUT_ENABLE_IP[@]/,/[@]END[@]/d' \
> + -e 's/[@]DAEMON_NAME[@]/virtstoraged/' \
> + -e 's/[@]DAEMON_NAME_UC[@]/Virtstoraged/' \
> + > $@ || rm -f $@
> +
>
>  libvirt_storage_backend_fs_la_SOURCES = $(STORAGE_DRIVER_FS_SOURCES)
>  libvirt_storage_backend_fs_la_CFLAGS = \
> diff --git a/src/storage/virtstoraged.service.in 
> b/src/storage/virtstoraged.service.in
> new 

[libvirt] [PATCH v3 24/48] storage: introduce virtstoraged daemon

2019-07-29 Thread Daniel P . Berrangé
The virtstoraged daemon will be responsible for providing the storage API
driver functionality. The storage driver is still loaded by the main
libvirtd daemon at this stage, so virtstoraged must not be running at
the same time.

Reviewed-by: Andrea Bolognani 
Signed-off-by: Daniel P. Berrangé 
---
 .gitignore  |  4 ++
 libvirt.spec.in |  8 
 src/storage/Makefile.inc.am | 61 +
 src/storage/virtstoraged.service.in | 26 
 4 files changed, 99 insertions(+)
 create mode 100644 src/storage/virtstoraged.service.in

diff --git a/.gitignore b/.gitignore
index c361d87868..3b86183bee 100644
--- a/.gitignore
+++ b/.gitignore
@@ -175,6 +175,9 @@
 /src/secret/test_virtsecretd.aug
 /src/secret/virtsecretd.aug
 /src/secret/virtsecretd.conf
+/src/storage/test_virtstoraged.aug
+/src/storage/virtstoraged.aug
+/src/storage/virtstoraged.conf
 /src/util/virkeycodetable*.h
 /src/util/virkeynametable*.h
 /src/virt-aa-helper
@@ -184,6 +187,7 @@
 /src/virtnetworkd
 /src/virtproxyd
 /src/virtsecretd
+/src/virtstoraged
 /src/virt-guest-shutdown.target
 /tests/*.log
 /tests/*.pid
diff --git a/libvirt.spec.in b/libvirt.spec.in
index b4fab26ea4..c34445090d 100644
--- a/libvirt.spec.in
+++ b/libvirt.spec.in
@@ -1663,6 +1663,14 @@ exit 0
 %files daemon-driver-storage
 
 %files daemon-driver-storage-core
+%config(noreplace) %{_sysconfdir}/libvirt/virtstoraged.conf
+%{_datadir}/augeas/lenses/virtstoraged.aug
+%{_datadir}/augeas/lenses/tests/test_virtstoraged.aug
+%{_unitdir}/virtstoraged.service
+%{_unitdir}/virtstoraged.socket
+%{_unitdir}/virtstoraged-ro.socket
+%{_unitdir}/virtstoraged-admin.socket
+%attr(0755, root, root) %{_sbindir}/virtstoraged
 %attr(0755, root, root) %{_libexecdir}/libvirt_parthelper
 %{_libdir}/%{name}/connection-driver/libvirt_driver_storage.so
 %{_libdir}/%{name}/storage-backend/libvirt_storage_backend_fs.so
diff --git a/src/storage/Makefile.inc.am b/src/storage/Makefile.inc.am
index 538709256d..767875785a 100644
--- a/src/storage/Makefile.inc.am
+++ b/src/storage/Makefile.inc.am
@@ -142,6 +142,67 @@ mod_LTLIBRARIES += libvirt_driver_storage.la
 libvirt_driver_storage_la_LDFLAGS = $(AM_LDFLAGS_MOD_NOUNDEF)
 libvirt_driver_storage_impl_la_SOURCES += $(STORAGE_DRIVER_SOURCES)
 
+sbin_PROGRAMS += virtstoraged
+
+nodist_conf_DATA += storage/virtstoraged.conf
+augeas_DATA += storage/virtstoraged.aug
+augeastest_DATA += storage/test_virtstoraged.aug
+CLEANFILES += storage/virtstoraged.aug
+
+virtstoraged_SOURCES = $(REMOTE_DAEMON_SOURCES)
+virtstoraged_CFLAGS = \
+   $(REMOTE_DAEMON_CFLAGS) \
+   -DDAEMON_NAME="\"virtstoraged\"" \
+   -DMODULE_NAME="\"storage\"" \
+   $(NULL)
+virtstoraged_LDFLAGS = $(REMOTE_DAEMON_LD_FLAGS)
+virtstoraged_LDADD = $(REMOTE_DAEMON_LD_ADD)
+
+SYSTEMD_UNIT_FILES += \
+   virtstoraged.service \
+   virtstoraged.socket \
+   virtstoraged-ro.socket \
+   virtstoraged-admin.socket \
+   $(NULL)
+SYSTEMD_UNIT_FILES_IN += \
+   storage/virtstoraged.service.in \
+   $(NULL)
+
+VIRTSTORAGED_UNIT_VARS = \
+   $(VIRTD_UNIT_VARS) \
+   -e 's|[@]name[@]|Libvirt storage|g' \
+   -e 's|[@]service[@]|virtstoraged|g' \
+   -e 's|[@]sockprefix[@]|virtstoraged|g' \
+   $(NULL)
+
+virtstoraged.service: storage/virtstoraged.service.in 
$(top_builddir)/config.status
+   $(AM_V_GEN)sed $(VIRTSTORAGED_UNIT_VARS) < $< > $@-t && mv $@-t $@
+
+virtstorage%.socket: remote/libvirt%.socket.in $(top_builddir)/config.status
+   $(AM_V_GEN)sed $(VIRTSTORAGED_UNIT_VARS) < $< > $@-t && mv $@-t $@
+
+storage/virtstoraged.conf: remote/libvirtd.conf.in
+   $(AM_V_GEN)sed \
+   -e '/[@]CUT_ENABLE_IP[@]/,/[@]END[@]/d' \
+   -e 's/[@]DAEMON_NAME[@]/virtstoraged/' \
+   < $^ > $@
+
+storage/virtstoraged.aug: remote/libvirtd.aug.in
+   $(AM_V_GEN)$(SED) \
+   -e '/[@]CUT_ENABLE_IP[@]/,/[@]END[@]/d' \
+   -e 's/[@]DAEMON_NAME[@]/virtstoraged/' \
+   -e 's/[@]DAEMON_NAME_UC[@]/Virtstoraged/' \
+   $< > $@
+
+storage/test_virtstoraged.aug: remote/test_libvirtd.aug.in \
+   storage/virtstoraged.conf $(AUG_GENTEST)
+   $(AM_V_GEN)$(AUG_GENTEST) storage/virtstoraged.conf \
+   $(srcdir)/remote/test_libvirtd.aug.in | \
+   $(SED) -e '/[@]CUT_ENABLE_IP[@]/,/[@]END[@]/d' \
+   -e 's/[@]DAEMON_NAME[@]/virtstoraged/' \
+   -e 's/[@]DAEMON_NAME_UC[@]/Virtstoraged/' \
+   > $@ || rm -f $@
+
 
 libvirt_storage_backend_fs_la_SOURCES = $(STORAGE_DRIVER_FS_SOURCES)
 libvirt_storage_backend_fs_la_CFLAGS = \
diff --git a/src/storage/virtstoraged.service.in 
b/src/storage/virtstoraged.service.in
new file mode 100644
index 00..9aa26764a9
--- /dev/null
+++ b/src/storage/virtstoraged.service.in
@@ -0,0 +1,26 @@
+[Unit]
+Description=Virtualization storage daemon
+Conflicts=libvirtd.service