[Libvir] PATCH 20/20: move the QEMU driver into libvirt.so

Daniel Veillard veillard at redhat.com
Fri Jun 22 15:28:42 UTC 2007


On Fri, Jun 22, 2007 at 03:35:42AM +0100, Daniel P. Berrange wrote:
> This is the final step to move the QEMU code out of the daemon binary and
> into the main libvirt.so library. Practically all of protocol.x goes away
> apart from a single struct representing the header - this should probably
> be moved into remote_protocol.x - or vica-verca. The --remote switch to
> the daemon is removed since its no longer needed. A single --listen switch
> is added to control whether the daemon opens any TCP/IP sockets or not,
> and a config file in /etc/sysconfig/libvirtd is provided to toggle this.
> By default the daemon will only listen on a UNIX socket, unless the admin
> edits /etc/sysconfig/libvirtd to enable TCP - whether it uses TCP or TLS
> is still upto the libvirtd.conf config file.
> 
> The driver.c file is switched over to using virGetDomain and virGetNetwork
> instead of its previous temporary / nasty hack. A qemudRegister function
> is added to make the new implementation be registered.
> 
> The daemon now registers an event loop implementation to be used by the
> QEMU driver. Various bits of code relating to the QEMU protocol are killed
> off in the qemud.c file.
> 
> The remote_internal.c file is adapted so that it will handle qemu:///sesion
> and qemu:///system URLs as if they were  qemu+unix:///session and 
> qemu+unix:///system respectively. It is also adapted so that in the case
> of qemu:///session is uses  $HOME/.libvirt/libvirt-sock for the UNIX domain
> socket path. It is also tweaked to use the abstract namespace if the first
> character is @
> 
> 
> Rather than showing a huge  +10000 lines, -10000 lines diff caused by 
> moving files from qemud/ into src/, i've applied some makefile trickery
> to make libvirt.so compile some files out of qemud/ directly. I intend
> to commit it in this format, and then do the actual file names in a second
> commit. This will avoid mixing functional changes, with plain renames
> to preserve better historical CVS logs. 
> 
> The files to be moved from qemud/ to src/ are:
> 
>    driver.c    -> qemud_driver.c
>    driver.h    -> qemud_driver.h
>    conf.c      -> qemud_conf.c
>    conf.h      -> qemud_conf.h
>    bridge.c
>    bridge.h
>    iptables.c
>    iptables.h
>    uuid.c
>    uuid.h
> 
> The files to be completely deleted are:
>   
>    dispatch.c
>    dispatch.h
>    protocol.c
>    protocol.h
>    protocol.x
>    qemu_internal.c
>    qemu_internal.h
> 
> 
> NB. one feature I've just realized is missing is the autostart of the
> daemon when using  qemu:///session in remote_internal.c. Shouldn't be
> much work to move the neccessary code from qemu_internal.c across.
> 
> Dan.
> -- 
> |=- Red Hat, Engineering, Emerging Technologies, Boston.  +1 978 392 2496 -=|
> |=-           Perl modules: http://search.cpan.org/~danberr/              -=|
> |=-               Projects: http://freshmeat.net/~danielpb/               -=|
> |=-  GnuPG: 7D3B9505   F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505  -=| 

> diff -r c6fe9aa77e5b libvirt.spec.in
> --- a/libvirt.spec.in	Thu Jun 21 21:21:11 2007 -0400
> +++ b/libvirt.spec.in	Thu Jun 21 21:21:14 2007 -0400
> @@ -124,10 +124,7 @@ fi
>  %dir %attr(0700, root, root) %{_sysconfdir}/libvirt/qemu/networks/
>  %dir %attr(0700, root, root) %{_sysconfdir}/libvirt/qemu/networks/autostart
>  %{_sysconfdir}/rc.d/init.d/libvirtd
> -%dir %{_sysconfdir}/libvirt
> -%dir %{_sysconfdir}/libvirt/qemu
> -%dir %{_sysconfdir}/libvirt/qemu/networks
> -%dir %{_sysconfdir}/libvirt/qemu/networks/autostart
> +%config(noreplace) %{_sysconfdir}/sysconfig/libvirtd
>  %dir %{_datadir}/libvirt/
>  %dir %{_datadir}/libvirt/networks/
>  %{_datadir}/libvirt/networks/default.xml

  Hum, what happens on rpm -U of the old version w.r.t. the daemon ?

[...]
> --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
> +++ b/qemud/libvirtd.sysconf	Thu Jun 21 21:21:14 2007 -0400
> @@ -0,0 +1,6 @@
> +# Override the default config file
> +#LIBVIRTD_CONFIG=/etc/libvirt/libvirtd.conf
> +
> +# Listen for TCP/IP connections
> +# NB. must setup TLS/SSL keys prior to using this
> +#LIBVIRTD_ARGS="--listen"

  Hum interesting that wasn't present before

> diff -r c6fe9aa77e5b qemud/qemud.c
[...]
> +        if (snprintf(sockname, maxlen, "@%s/.libvirt/libvirt-sock", pw->pw_dir) >= maxlen)
> +            goto snprintf_error;
> +
> +        if (snprintf(server->logDir, PATH_MAX, "%s/.libvirt/log", pw->pw_dir) >= PATH_MAX)
> +            goto snprintf_error;
> +
> +        if (asprintf (&base, "%s/.libvirt", pw->pw_dir) == -1) {
> +            qemudLog (QEMUD_ERR, "out of memory in asprintf");
> +            return -1;

  We really need one function to cleanup those path builds.

> diff -r c6fe9aa77e5b src/Makefile.am
[...]
> @@ -42,8 +43,12 @@ CLIENT_SOURCES =						\
>  		proxy_internal.c proxy_internal.h		\
>  		conf.c conf.h                                   \
>  		xm_internal.c xm_internal.h                     \
> -		qemu_internal.c qemu_internal.h			\
> -		remote_internal.c remote_internal.h
> +		remote_internal.c remote_internal.h             \
> +		../qemud/bridge.c ../qemud/bridge.h 				\
> +		../qemud/iptables.c ../qemud/iptables.h 				\
> +		../qemud/uuid.c ../qemud/uuid.h 					\
> +		../qemud/driver.c ../qemud/driver.h 			\
> +		../qemud/qemu_conf.c ../qemud/conf.h
>  
>  SERVER_SOURCES = 						\
>  		../qemud/protocol.h ../qemud/protocol.c		\
> @@ -58,6 +63,9 @@ virsh_DEPENDENCIES = $(DEPS)
>  virsh_DEPENDENCIES = $(DEPS)
>  virsh_LDADD = $(LDADDS) $(VIRSH_LIBS)
>  virsh_CFLAGS = $(COVERAGE_CFLAGS)
> +
> +../qemud/qemu_conf.c:
> +	ln -s conf.c $@

  As long as it's temporary just to help review, fine :-)

  Okay, looks fine, +1

  thanks a million !

Daniel

-- 
Red Hat Virtualization group http://redhat.com/virtualization/
Daniel Veillard      | virtualization library  http://libvirt.org/
veillard at redhat.com  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine  http://rpmfind.net/




More information about the libvir-list mailing list