[libvirt] [PATCH 1/2] Separate out StateAutoStart from StateInitialize
Daniel P. Berrange
berrange at redhat.com
Thu Jul 25 18:39:35 UTC 2013
On Thu, Jul 25, 2013 at 02:32:56PM -0400, John Ferlan wrote:
> Separation allows for dependent drivers to be make a connection during
> the AutoStart phase of state initialization.
> ---
> src/driver.h | 4 ++++
> src/libvirt.c | 23 ++++++++++++++++++++++-
> 2 files changed, 26 insertions(+), 1 deletion(-)
>
> diff --git a/src/driver.h b/src/driver.h
> index cc03e9f..b416902 100644
> --- a/src/driver.h
> +++ b/src/driver.h
> @@ -1801,6 +1801,9 @@ typedef int
> void *opaque);
>
> typedef int
> +(*virDrvStateAutoStart)(void);
> +
> +typedef int
> (*virDrvStateCleanup)(void);
>
> typedef int
> @@ -1815,6 +1818,7 @@ typedef virStateDriver *virStateDriverPtr;
> struct _virStateDriver {
> const char *name;
> virDrvStateInitialize stateInitialize;
> + virDrvStateAutoStart stateAutoStart;
> virDrvStateCleanup stateCleanup;
> virDrvStateReload stateReload;
> virDrvStateStop stateStop;
> diff --git a/src/libvirt.c b/src/libvirt.c
> index 444c1c3..864321f 100644
> --- a/src/libvirt.c
> +++ b/src/libvirt.c
> @@ -808,7 +808,11 @@ virRegisterStateDriver(virStateDriverPtr driver)
> * @callback: callback to invoke to inhibit shutdown of the daemon
> * @opaque: data to pass to @callback
> *
> - * Initialize all virtualization drivers.
> + * Initialize all virtualization drivers. Accomplished in two phases,
> + * the first being state and structure initialization followed by any
> + * auto start supported by the driver. This is done to ensure dependencies
> + * that some drivers may have on another driver having been initialized
> + * will exist, such as the storage driver's need to use the secret driver.
> *
> * Returns 0 if all succeed, -1 upon any failure.
> */
> @@ -836,6 +840,23 @@ int virStateInitialize(bool privileged,
> }
> }
> }
> +
> + for (i = 0; i < virStateDriverTabCount; i++) {
> + if (virStateDriverTab[i]->stateAutoStart) {
> + VIR_DEBUG("Running global auto start for %s state driver",
> + virStateDriverTab[i]->name);
> + if (virStateDriverTab[i]->stateAutoStart() < 0) {
> + virErrorPtr err = virGetLastError();
> + VIR_ERROR(_("Auto start for %s driver failed: %s"),
> + virStateDriverTab[i]->name,
> + err && err->message ? err->message :
> + _("Unknown problem"));
> + if (virStateDriverTab[i]->stateCleanup)
> + ignore_value(virStateDriverTab[i]->stateCleanup());
> + return -1;
> + }
> + }
> + }
> return 0;
> }
ACK
Daniel
--
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org -o- http://virt-manager.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
More information about the libvir-list
mailing list